@stacksjs/stx 0.2.190 → 0.2.191

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.
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- var{defineProperty:fQ,getOwnPropertyNames:jv,getOwnPropertyDescriptor:_v}=Object,Hv=Object.prototype.hasOwnProperty;function Lv($){return this[$]}var Ov=($)=>{var X=(OL??=new WeakMap).get($),Z;if(X)return X;if(X=fQ({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var J of jv($))if(!Hv.call(X,J))fQ(X,J,{get:Lv.bind($,J),enumerable:!(Z=_v($,J))||Z.enumerable})}return OL.set($,X),X},OL;var Bv=($)=>$;function Fv($,X){this[$]=Bv.bind(null,X)}var X0=($,X)=>{for(var Z in X)fQ($,Z,{get:X[Z],enumerable:!0,configurable:!0,set:Fv.bind(X,Z)})};var T=($,X)=>()=>($&&(X=$($=0)),X);var J0=import.meta.require;function gQ($,X){let Z=[],J=`${X}=`;for(let Y=0;Y<$.length;Y++){let Q=$[Y];if(Q.startsWith(J)){let G=Q.slice(J.length);if(G)Z.push(G);continue}if(Q===X){let G=$[Y+1];if(G!==void 0&&!G.startsWith("-"))Z.push(G),Y++}}return Z}var BL={};X0(BL,{resolveStxTargets:()=>Z9,looksLikeGlob:()=>hQ});import{existsSync as wv,statSync as Av}from"fs";import I8 from"path";function hQ($){return Rv.test($)}async function Z9($,X={}){let Z=X.cwd??process.cwd(),J=X.recursive!==!1,Y=X.ignorePaths??[],Q=globalThis.Bun.Glob,G=new Set,K=(U)=>{if(U.includes(`${I8.sep}node_modules${I8.sep}`)||U.includes(`${I8.sep}dist${I8.sep}`))return;if(Y.some((z)=>z&&U.includes(I8.normalize(z))))return;G.add(U)},W=async(U)=>{try{for await(let z of new Q(U).scan({cwd:Z,absolute:!0}))K(z)}catch{}};for(let U of $){if(!U)continue;if(hQ(U)){await W(U);continue}let z=I8.resolve(Z,U);if(!wv(z))continue;if(Av(z).isDirectory()){for await(let q of new Q(J?"**/*.stx":"*.stx").scan({cwd:z,absolute:!0}))K(q);continue}K(z)}return[...G].sort()}var Rv;var J9=T(()=>{Rv=/[*?[\]{}]/});import FL from"path";function uQ($){if(!$)return!1;return $.trim().split(/\s+/)[0]?.toLowerCase()==="presentation"||$.trim().split(/\s+/)[0]?.toLowerCase()==="none"}function VL($,X){let Z=new RegExp(`\\b${X}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec($);if(!Z)return null;return Z[2]??Z[3]??Z[4]??null}function mQ($,X,Z,J){let Y=$;Y=Y.replace(/@a11y\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(G,K,W)=>{let z={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[K]||"Make this element accessible";return`<!-- a11y-hint: ${W||z} -->`});let Q=/@screenReader\(([^@]*)\)@endScreenReader/g;return Y=Y.replace(Q,(G,K)=>{return`<span class="sr-only">${K.trim()}</span>`}),Y=Y.replace(/@ariaDescribe\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(G,K,W)=>{return`<span id="${`desc-${K}`}" class="sr-only">${W}</span>`}),Y}function Nv(){return`
3
+ var{defineProperty:fQ,getOwnPropertyNames:jv,getOwnPropertyDescriptor:_v}=Object,Hv=Object.prototype.hasOwnProperty;function Lv($){return this[$]}var Ov=($)=>{var X=(OL??=new WeakMap).get($),Z;if(X)return X;if(X=fQ({},"__esModule",{value:!0}),$&&typeof $==="object"||typeof $==="function"){for(var J of jv($))if(!Hv.call(X,J))fQ(X,J,{get:Lv.bind($,J),enumerable:!(Z=_v($,J))||Z.enumerable})}return OL.set($,X),X},OL;var Bv=($)=>$;function Fv($,X){this[$]=Bv.bind(null,X)}var X0=($,X)=>{for(var Z in X)fQ($,Z,{get:X[Z],enumerable:!0,configurable:!0,set:Fv.bind(X,Z)})};var T=($,X)=>()=>($&&(X=$($=0)),X);var Y0=import.meta.require;function gQ($,X){let Z=[],J=`${X}=`;for(let Y=0;Y<$.length;Y++){let Q=$[Y];if(Q.startsWith(J)){let G=Q.slice(J.length);if(G)Z.push(G);continue}if(Q===X){let G=$[Y+1];if(G!==void 0&&!G.startsWith("-"))Z.push(G),Y++}}return Z}var BL={};X0(BL,{resolveStxTargets:()=>Z9,looksLikeGlob:()=>hQ});import{existsSync as wv,statSync as Av}from"fs";import I8 from"path";function hQ($){return Rv.test($)}async function Z9($,X={}){let Z=X.cwd??process.cwd(),J=X.recursive!==!1,Y=X.ignorePaths??[],Q=globalThis.Bun.Glob,G=new Set,K=(U)=>{if(U.includes(`${I8.sep}node_modules${I8.sep}`)||U.includes(`${I8.sep}dist${I8.sep}`))return;if(Y.some((z)=>z&&U.includes(I8.normalize(z))))return;G.add(U)},W=async(U)=>{try{for await(let z of new Q(U).scan({cwd:Z,absolute:!0}))K(z)}catch{}};for(let U of $){if(!U)continue;if(hQ(U)){await W(U);continue}let z=I8.resolve(Z,U);if(!wv(z))continue;if(Av(z).isDirectory()){for await(let q of new Q(J?"**/*.stx":"*.stx").scan({cwd:z,absolute:!0}))K(q);continue}K(z)}return[...G].sort()}var Rv;var J9=T(()=>{Rv=/[*?[\]{}]/});import FL from"path";function uQ($){if(!$)return!1;return $.trim().split(/\s+/)[0]?.toLowerCase()==="presentation"||$.trim().split(/\s+/)[0]?.toLowerCase()==="none"}function VL($,X){let Z=new RegExp(`\\b${X}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec($);if(!Z)return null;return Z[2]??Z[3]??Z[4]??null}function mQ($,X,Z,J){let Y=$;Y=Y.replace(/@a11y\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(G,K,W)=>{let z={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[K]||"Make this element accessible";return`<!-- a11y-hint: ${W||z} -->`});let Q=/@screenReader\(([^@]*)\)@endScreenReader/g;return Y=Y.replace(Q,(G,K)=>{return`<span class="sr-only">${K.trim()}</span>`}),Y=Y.replace(/@ariaDescribe\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(G,K,W)=>{return`<span id="${`desc-${K}`}" class="sr-only">${W}</span>`}),Y}function Nv(){return`
4
4
  .sr-only {
5
5
  position: absolute;
6
6
  width: 1px;
@@ -2586,7 +2586,7 @@ else {
2586
2586
  `:" ",Z++}X+=" ",Z++;continue}X+=Y,Z++}return X}function Kf(){let $=globalThis;return $[ZO]??=new Map,$[ZO]}function D0($,X){let Z=Kf(),J=`${import.meta.url}\x00${$}`,Y=Z.get(J);if(Y)return Y;let Q=X();return Z.set(J,Q),Q.catch(()=>{if(Z.get(J)===Q)Z.delete(J)}),Q}var ZO;var W3=T(()=>{ZO=Symbol.for("stx.lazy-module-promises")});function u8($){if(!$||$.indexOf("</")===-1)return $;return $.replace(Wf,"<\\/$1")}var Wf;var UG=T(()=>{Wf=/<\/(script)/gi});import JO from"process";function V1($="STX_PUBLIC_"){let X={},Z={};for(let[J,Y]of Object.entries(JO.env)){if(!J.startsWith($)||Y===void 0)continue;X[`import.meta.env.${J}`]=JSON.stringify(Y),Z[J]=Y}return X["import.meta.env"]=JSON.stringify(Z),X}function YO($="STX_PUBLIC_"){let X={};for(let[Z,J]of Object.entries(JO.env))if(Z.startsWith($)&&J!==void 0)X[Z]=J;return X}var J4=()=>{};import U3 from"path";function zG($){GO=$?.trim()||null}function m8(){return process.env[QO]?.trim()||GO||C6}function n0($=process.cwd(),...X){let Z=m8();return U3.isAbsolute(Z)?U3.join(Z,...X):U3.join($,Z,...X)}function d8($){if(!$||U3.isAbsolute($))return $;let X=$.replace(/\\/g,"/");if(X!==C6&&!X.startsWith(`${C6}/`))return $;let Z=X.slice(C6.length+1);return Z?U3.join(m8(),Z):m8()}var C6=".stx",QO="STX_DIR",GO=null;var z$=()=>{};function Uf($){if(!$||typeof $!=="object")return!1;let X=$;return typeof X.message==="string"&&(X.name==="BuildMessage"||X.name==="ResolveMessage"||("position"in X))}function zf($){if($&&typeof $==="object"&&Array.isArray($.errors))return $.errors;return[$]}function C9($,X){let Z=[];for(let J of zf($)){if(Uf(J)){let Y=J.position||void 0;Z.push({file:X||Y?.file,line:Y?.line,column:Y?.column,message:J.message??"",lineText:Y?.lineText});continue}Z.push({file:X,message:J instanceof Error?J.message:String(J)})}return Z}function x4($,X){return C9($,X).map((Z)=>{let J=Z.file?`${Z.file}${Z.line?`:${Z.line}${Z.column?`:${Z.column}`:""}`:""}`:"",Y=Z.lineText?`
2587
2587
  ${Z.lineText.trim()}`:"";return J?`${J}: ${Z.message}${Y}`:`${Z.message}${Y}`}).join(`
2588
2588
  `)}var j3={};X0(j3,{shouldLogBundlerDiagnostics:()=>zO,setBundlerFallbackMode:()=>jf,resolveBundlerFallback:()=>HG,recordBundleFailure:()=>jG,queueClientBundleBuild:()=>qO,hasUserImports:()=>_f,getBundleFailures:()=>z3,clearBundleFailures:()=>q3,bundleClientScript:()=>Lf});import e0 from"path";import u1 from"fs";function zO($=process.env){return $.STX_DEBUG==="true"||$.STX_DEBUG==="1"}function P6(...$){if(zO())console.log("[stx:bundler]",...$)}function jG($,X,Z){LG.push({filePath:$||"<inline>",message:X,details:Z})}function z3(){return LG.slice()}function q3(){LG.length=0}function jf($){_G=$}function HG(){if(_G)return _G;try{let $=E1.strict;return typeof $==="object"&&$!==null?$.bundlerFallback??"warn":"warn"}catch{return"warn"}}function _f($){let X=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,Z;while((Z=X.exec($))!==null){let Y=Z[1];if(!KO.some((G)=>G.test(Y)))return P6("detected user import:",Y),!0}let J=/^[ \t]*import[ \t]+['"]([^'"]+)['"]/gm;while((Z=J.exec($))!==null){let Y=Z[1];if(/\.css(?:\?.*)?$/.test(Y))continue;if(!KO.some((G)=>G.test(Y)))return P6("detected side-effect import:",Y),!0}return!1}function Hf($,X,Z,J){let Y=(Q,G)=>{let K=Q===Z?X:e0.dirname(Q),W=e0.resolve(K,G),U=[W,`${W}.ts`,`${W}.tsx`,`${W}.js`,`${W}.mjs`,`${W}.jsx`,e0.join(W,"index.ts"),e0.join(W,"index.tsx"),e0.join(W,"index.js"),e0.join(W,"index.mjs")];for(let z of U)try{if(u1.existsSync(z)&&u1.statSync(z,{throwIfNoEntry:!1})?.isFile())return z}catch{}return W};return{name:"stx-client-bundle",setup(Q){Q.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(G)=>({path:G.path,external:!0})),Q.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(G)=>({path:G.path,external:!0})),Q.onResolve({filter:/^\//},(G)=>{if(u1.existsSync(G.path))return{path:G.path};return{path:G.path,external:!0}}),Q.onResolve({filter:/^\.\.?\//},(G)=>{let K=Y(G.importer,G.path);return J.add(K),{path:K}}),Q.onResolve({filter:/^[@~]\//},(G)=>{let K=e0.resolve($,G.path.slice(2)),W=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,e0.join(K,"index.ts"),e0.join(K,"index.tsx"),e0.join(K,"index.js"),e0.join(K,"index.mjs")];for(let U of W)if(u1.existsSync(U)&&u1.statSync(U,{throwIfNoEntry:!1})?.isFile())return P6(`resolved ${G.path[0]}/ import:`,G.path,"\u2192",U),J.add(U),{path:U};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}}),Q.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(G)=>{let K=e0.extname(G.path).toLowerCase(),W=K===".json"?"json":K===".tsx"?"tsx":K===".jsx"?"jsx":K===".ts"||K===".mts"||K===".cts"?"ts":"js";if(G.path!==Z)J.add(G.path);return{contents:u1.readFileSync(G.path,"utf8"),loader:W}})}}}function qO($){let X=globalThis,J=(X[WO]??Promise.resolve()).then($,$);return X[WO]=J.then(()=>{return},()=>{return}),J}async function Lf($,X,Z={}){let J=Z.projectRoot||process.cwd(),Y=Z.minify??!1,Q=Z.cacheDir||n0(J,"bundle-cache"),G=new Bun.CryptoHasher("md5");G.update(`${qf}\x00${$}\x00${X}`);let K=G.digest("hex").slice(0,12),W=e0.join(Q,`${K}.js`),U=e0.join(Q,`${K}.deps.json`),z=Bun.file(W);if(await z.exists()){let _=Bun.file(U),H=!0;if(await _.exists())try{let L=JSON.parse(await _.text());if(L.metadataVersion!==UO||!Array.isArray(L.files))H=!1;for(let O of Array.isArray(L.files)?L.files:[])try{if(u1.statSync(O.path).mtimeMs!==O.mtimeMs){H=!1;break}}catch{H=!1;break}}catch{H=!1}if(H)return P6("cache hit:",K),await z.text();P6("cache invalidated by dep change:",K)}let q=qG.get(K);if(q)return await q;let j=qO(()=>Of($,X,{projectRoot:J,minify:Y,cacheDir:Q,hash:K,cachePath:W,depsPath:U}));qG.set(K,j);try{return await j}finally{qG.delete(K)}}async function Of($,X,Z){let{projectRoot:J,minify:Y,cacheDir:Q,hash:G,cachePath:K,depsPath:W}=Z,U=n0(J,"bundle-tmp"),z=e0.join(U,`${G}.ts`),q=e0.join(U,"out",G);u1.mkdirSync(U,{recursive:!0}),u1.mkdirSync(q,{recursive:!0});let j=e0.dirname(X),_=[],H=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,L=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,O;while((O=H.exec($))!==null){if(O[1])continue;if(O[2])O[2].split(",").forEach((V)=>{let w=V.split(":")[0].trim();if(w)_.push(w)});else if(O[3])_.push(O[3])}while((O=L.exec($))!==null){if(O[1])continue;_.push(O[2])}let B=_.length>0?`
2589
- export { ${_.join(", ")} }`:"";await Bun.write(z,$+B),P6("bundling:",G,"from:",e0.basename(X));let F=new Set;try{let V=await Bun.build({entrypoints:[z],outdir:q,target:"browser",format:"esm",minify:Y,plugins:[Hf(J,j,z,F)],define:{"process.env.NODE_ENV":Y?'"production"':'"development"',...V1()},root:J});if(!V.success){let y=V.logs.filter((b)=>b.level==="error").map((b)=>b.message).join(", ")||`Unable to bundle ${e0.basename(X)}`,x=C9(V.logs,X||void 0);if(console.warn("[stx:bundler] build failed:",y),jG(X||"",y,x),HG()==="error")throw Error(y);return $}let w="";for(let S of V.outputs){w=await S.text();break}let A=[];for(let S of w.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let y of S[1].split(",")){let x=y.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(x){A.push([x[2],x[1]]);continue}let b=y.trim();if(/^[A-Za-z_$][\w$]*$/.test(b))A.push([b,b])}let R=w.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];w=w.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let M=`__stxBundle_${G}`,I=A.map(([S,y])=>`${JSON.stringify(S)}: ${y}`).join(", "),N=A.map(([S])=>`var ${S} = undefined;`).join(`
2589
+ export { ${_.join(", ")} }`:"";await Bun.write(z,$+B),P6("bundling:",G,"from:",e0.basename(X));let F=new Set;try{let V=await Bun.build({entrypoints:[z],outdir:q,target:"browser",format:"esm",minify:Y,plugins:[Hf(J,j,z,F)],define:{"process.env.NODE_ENV":Y?'"production"':'"development"',...V1()},root:J});if(!V.success){let x=V.logs.filter((b)=>b.level==="error").map((b)=>b.message).join(", ")||`Unable to bundle ${e0.basename(X)}`,y=C9(V.logs,X||void 0);if(console.warn("[stx:bundler] build failed:",x),jG(X||"",x,y),HG()==="error")throw Error(x);return $}let w="";for(let S of V.outputs){w=await S.text();break}let A=[];for(let S of w.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let x of S[1].split(",")){let y=x.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(y){A.push([y[2],y[1]]);continue}let b=x.trim();if(/^[A-Za-z_$][\w$]*$/.test(b))A.push([b,b])}let R=w.match(/^\s*import\s+[^;]+;?\s*$/gm)||[];w=w.replace(/^\s*import\s+[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim();let M=`__stxBundle_${G}`,I=A.map(([S,x])=>`${JSON.stringify(S)}: ${x}`).join(", "),N=A.map(([S])=>`var ${S} = undefined;`).join(`
2590
2590
  `),E=A.map(([S])=>`${S} = ${M}[${JSON.stringify(S)}];`).join(`
2591
2591
  `);if(w=`${R.join(`
2592
2592
  `)}
@@ -2712,7 +2712,7 @@ catch (e) {
2712
2712
  }
2713
2713
  `),Y.set(U,z)}return z(...K)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:G,context:X.slice()});return G}clear(){this.pool.length=0,this.fnCache.clear()}}class cO{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,X){this.budgets.set($,{warnThreshold:0.8,action:"warn",...X})}setBudgets($){for(let[X,Z]of Object.entries($))this.setBudget(X,Z)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[X,Z]of this.budgets.entries())$[X]=Z;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let X=this.violationHandlers.indexOf($);if(X!==-1)this.violationHandlers.splice(X,1)}time($,X){if(!this.enabled)return X();let Z=performance.now(),J=X(),Y=performance.now()-Z;return this.recordTime($,Y),this.checkBudget($,Y),J}async timeAsync($,X){if(!this.enabled)return X();let Z=performance.now(),J=await X(),Y=performance.now()-Z;return this.recordTime($,Y),this.checkBudget($,Y),J}checkBudget($,X){let Z=this.budgets.get($);if(!Z)return;let J=X/Z.maxTime*100,Y=Z.warnThreshold!==void 0?X>=Z.maxTime*Z.warnThreshold&&X<Z.maxTime:!1,Q=X>=Z.maxTime;if(!Y&&!Q)return;let G={label:$,actualTime:X,budgetTime:Z.maxTime,exceedancePercent:J,timestamp:new Date,isWarning:Y};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=Y?`[Performance Warning] "${$}" took ${X.toFixed(2)}ms (${J.toFixed(1)}% of ${Z.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${X.toFixed(2)}ms (exceeded ${Z.maxTime}ms budget by ${(J-100).toFixed(1)}%)`;switch(Z.action){case"log":console.log(K);break;case"warn":console.warn(K);break;case"error":console.error(K);break;case"throw":if(Q)throw Error(K);else console.warn(K);break}}recordTime($,X){let Z=this.metrics.get($);if(Z)Z.count++,Z.totalTime+=X,Z.maxTime=Math.max(Z.maxTime,X),Z.minTime=Math.min(Z.minTime,X);else this.metrics.set($,{count:1,totalTime:X,maxTime:X,minTime:X})}getStats($){if($){let Z=this.metrics.get($);if(!Z)return{};let J=this.budgets.get($);return{count:Z.count,avgTime:Z.totalTime/Z.count,totalTime:Z.totalTime,maxTime:Z.maxTime,minTime:Z.minTime,budget:J?.maxTime,budgetUtilization:J?Z.totalTime/Z.count/J.maxTime*100:void 0}}let X={};for(let[Z,J]of this.metrics.entries()){let Y=this.budgets.get(Z);X[Z]={count:J.count,avgTime:J.totalTime/J.count,totalTime:J.totalTime,maxTime:J.maxTime,minTime:J.minTime,budget:Y?.maxTime,budgetUtilization:Y?J.totalTime/J.count/Y.maxTime*100:void 0}}return X}getViolations($){if($)return this.violations.filter((X)=>X.label===$);return[...this.violations]}getViolationStats(){let $={},X=0,Z=0;for(let J of this.violations)if($[J.label]=($[J.label]||0)+1,J.isWarning)X++;else Z++;return{total:this.violations.length,byLabel:$,warnings:X,errors:Z}}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 $g(){if(!EG)EG=new cO;return EG}var n8,ef=500,n40,EG=null,q$;var h4=T(()=>{n8=new Map;n40=new dO;q$=new Proxy({},{get($,X){return $g()[X]}})});function TG($){return`--stx-${$}`}function DG($,X){let Z=X.lastIndexOf("-");if(Z===-1)return typeof $[X]==="string"?$[X]:void 0;let J=$[X.slice(0,Z)];if(!J||typeof J!=="object")return;let Y=J[X.slice(Z+1)];return typeof Y==="string"?Y:void 0}function pO($){let X={};for(let[Z,J]of Object.entries(lO)){let Y=DG($,J.light);if(Y===void 0)continue;X[Z]=`var(${TG(Z)}, ${Y})`}return X}function iO($){let X=[],Z=[];for(let[J,Y]of Object.entries(lO)){let Q=DG($,Y.light),G=DG($,Y.dark);if(Q===void 0)continue;if(X.push(` ${TG(J)}: ${Q};`),G!==void 0)Z.push(` ${TG(J)}: ${G};`)}if(X.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...X,"}",".dark {",...Z,"}",""].join(`
2714
2714
  `)}var lO;var nO=T(()=>{lO={fg:{light:"gray-900",dark:"gray-100",description:"Primary text"},"fg-strong":{light:"gray-700",dark:"gray-300",description:"Labels, secondary headings"},"fg-muted":{light:"gray-600",dark:"gray-400",description:"Supporting text"},"fg-soft":{light:"gray-500",dark:"gray-400",description:"De-emphasised text"},"fg-subtle":{light:"gray-400",dark:"gray-500",description:"Placeholders, disabled text"},surface:{light:"gray-50",dark:"gray-800",description:"Page and panel background"},"surface-raised":{light:"gray-100",dark:"gray-700",description:"Cards, popovers"},"surface-sunken":{light:"gray-200",dark:"gray-700",description:"Wells, track backgrounds"},line:{light:"gray-200",dark:"gray-700",description:"Default border, divider"},"line-strong":{light:"gray-300",dark:"gray-600",description:"Input border, focus ring track"},accent:{light:"indigo-600",dark:"indigo-400",description:"Primary action, selected state"},info:{light:"blue-600",dark:"blue-400",description:"Informational emphasis, links"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-500",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"indigo-600",dark:"indigo-500",description:"Primary button fill"},"info-solid":{light:"blue-600",dark:"blue-500",description:"Informational fill"},"danger-solid":{light:"red-600",dark:"red-500",description:"Destructive button fill"},"success-solid":{light:"green-600",dark:"green-500",description:"Confirmation fill"}}});function rO($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function R3($,X){let Z={...$};for(let[J,Y]of Object.entries(X))Z[J]=rO(Y)&&rO(Z[J])?R3(Z[J],Y):Y;return Z}function h9($={},X={}){let Z=$.theme||{},J=X.theme||{},{extend:Y,...Q}=J,{extend:G,...K}=Z,W=K.colors||{};K.colors={...W,...pO(W)};let U=R3(K,Q),z=R3(G||{},Y||{});if(Object.keys(z).length>0)U.extend=z;let q=[...$.safelist||[],...X.safelist||[]],j={...$.shortcuts||{},...X.shortcuts||{}},_=[...$.preflights||[],...X.preflights||[]];return{config:{...$,...X,theme:U,safelist:q,shortcuts:j,..._.length>0?{preflights:_}:{},content:[],output:""},safelist:q,shortcuts:j,includePreflight:X.preflight!==!1,minify:X.minify===!0,tokenCSS:iO(W)}}var IG=T(()=>{nO()});var D;var N3=T(()=>{D={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"}});var T3={};X0(T3,{resolveUserCrosswindConfig:()=>oO,resetCssCache:()=>Kg,resetCrosswindCache:()=>Wg,rebuildCrosswindCSS:()=>E3,loadCrosswindConfig:()=>yG,loadCrosswind:()=>bG,injectCrosswindCSS:()=>i0,getCrosswindServeAsset:()=>PG,getCachedCSS:()=>Ug,generateCrosswindCSS:()=>d9,fingerprintConfig:()=>tO,extractClassNames:()=>m9,buildCrosswindCSS:()=>s8});import v0 from"path";import{hasLocalConfig as Xg}from"bunfig";function u9($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function kG($,X){if(Q4.has($))Q4.delete($);else if(Q4.size>=sO)Q4.delete(Q4.keys().next().value);Q4.set($,X)}function Zg($){let X=u9($);if(j$.has(X))j$.delete(X);else if(j$.size>=sO)j$.delete(j$.keys().next().value);return j$.set(X,$),X}function PG($){let X=j$.get($);if(X===void 0)return;return j$.delete($),j$.set($,X),X}async function Jg($){if(!u4)return null;try{let X=Bun.file(v0.join(u4,`cw-${u9($)}.css`));if(!await X.exists())return null;return await X.text()}catch{return null}}async function Yg($,X){if(!u4)return;try{if(!fs.existsSync(u4))fs.mkdirSync(u4,{recursive:!0});await Bun.write(v0.join(u4,`cw-${u9($)}.css`),X)}catch{}}async function aO($){try{let X=await import($);if(X&&X.CSSGenerator)return{CSSGenerator:X.CSSGenerator,config:X.config,build:X.build,defaultConfig:X.defaultConfig,extractClasses:X.extractClasses}}catch{}return null}function Qg(){let $=[],X=process.cwd();while(X!==v0.dirname(X))$.push(v0.join(X,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(v0.join(X,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(v0.join(X,"pantry","@cwcss","crosswind","dist","index.js")),$.push(v0.join(X,"pantry","@cwcss","crosswind","src","index.ts")),$.push(v0.join(X,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(v0.join(X,"pantry","@stacksjs","crosswind","dist","index.js")),X=v0.dirname(X);return $}function Gg(){let $=[],X=process.env.HOME||process.env.USERPROFILE||"";if(X){let Z=[v0.join(X,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),v0.join(X,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),v0.join(X,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),v0.join(X,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),v0.join(X,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),v0.join(X,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Z)}return $.push(v0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(v0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function bG(){if(SG)return g$;SG=!0;try{let $=async(Y)=>{for(let Q of Y){if(!await Bun.file(Q).exists())continue;let G=await aO(Q);if(G){if(!process.env.STACKS_DEV_QUIET)console.log(`${D.green}[Crosswind]${D.reset} CSS engine loaded from ${v0.dirname(v0.dirname(Q))}`);return G}}return null};if(process.env.CROSSWIND_SRC){let Y=v0.resolve(process.env.CROSSWIND_SRC),Q=await $([Y]);if(!Q)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${Y}`);return g$=Q,g$}let X=await $(Qg());if(X)return g$=X,g$;let Z=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of Z){let Q=await aO(Y);if(Q){if(g$=Q,!process.env.STACKS_DEV_QUIET)console.log(`${D.green}[Crosswind]${D.reset} CSS engine loaded`);return g$}}let J=await $(Gg());if(J)return g$=J,g$;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${D.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${D.reset}`),console.warn(`${D.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${D.reset}`),null}}function Kg(){Q4.clear(),j$.clear()}function Wg(){g$=null,SG=!1,_$=null,M3="",Q4.clear(),j$.clear(),CG=null}async function yG($){try{if(!Xg({name:"crosswind",cwd:$}))return null;let{loadConfigWithResult:X}=await import("bunfig"),Z=await X({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Z?.path||!Z.config||Object.keys(Z.config).length===0)return null;let J=v0.relative($,Z.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${D.green}[Crosswind]${D.reset} Loaded config from ${J||Z.path}`);return Z.config}catch(X){if(X instanceof Error&&X.name==="ConfigNotFoundError")return null;return console.warn(`${D.yellow}[Crosswind]${D.reset} Failed to load crosswind config:`,X instanceof Error?X.message:X),null}}async function oO($){let X=null;try{let{loadStxConfig:Z}=await Promise.resolve().then(() => ($1(),c9)),J=await Z($);if(J.css)if(typeof J.css==="string"){let Y=v0.isAbsolute(J.css)?J.css:v0.resolve($,J.css);if(await Bun.file(Y).exists()){let Q=await import(Y);X=Q.default||Q,console.log(`${D.green}[Crosswind]${D.reset} Loaded config from stx.config.ts \u2192 ${J.css}`)}}else{if(X={...J.css,content:J.css.content||[],preflight:J.css.preflight??!0,minify:J.css.minify??!1},J.css.config){let Y=v0.isAbsolute(J.css.config)?J.css.config:v0.resolve($,J.css.config);if(await Bun.file(Y).exists()){let Q=await import(Y);X={...Q.default||Q,...X}}}console.log(`${D.green}[Crosswind]${D.reset} Using inline CSS config from stx.config.ts`)}}catch{}return X||await yG($)}function tO($){try{let X=new WeakSet;return u9(JSON.stringify($??{},(Z,J)=>{if(typeof J==="function")return`[fn]${String(J)}`;if(typeof J==="object"&&J!==null){if(X.has(J))return"[circular]";X.add(J)}return J})??"")}catch{return"unhashable"}}async function s8($){if(a8)return M3;a8=!0;try{let X=await bG();if(!X||!X.build)return a8=!1,"";if(!_$)_$=await yG($);if(!_$)return a8=!1,"";let Z=X.defaultConfig?.theme||{},J=_$.theme||{},Y={...X.defaultConfig,..._$,theme:{...Z,...J,extend:{...Z.extend||{},...J.extend||{}}}},Q=performance.now(),G=await X.build(Y),K=performance.now()-Q;if(M3=G.css,console.log(`${D.cyan}[Crosswind]${D.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),Y.output){let W=v0.isAbsolute(Y.output)?Y.output:v0.join($,Y.output),U=v0.dirname(W);if(!fs.existsSync(U))fs.mkdirSync(U,{recursive:!0});await Bun.write(W,G.css)}return a8=!1,G.css}catch(X){return console.error(`${D.red}[Crosswind]${D.reset} Build error:`,X),a8=!1,M3}}async function E3($){_$=null,await s8($)}function Ug(){return M3}function m9($){let X=new Set,Z=/class\s*=\s*["']([^"']+)["']/gi,J=Z.exec($);while(J!==null){for(let G of J[1].split(/\s+/))if(G.trim())X.add(G.trim());J=Z.exec($)}let Y=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,Q=Y.exec($);while(Q!==null){let G=Q[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let W of K.slice(1,-1).split(/\s+/))if(W.trim())X.add(W.trim())}Q=Y.exec($)}return X}async function d9($,X){try{let Z=await bG();if(!Z)return"";let J=typeof Z.extractClasses==="function"?Z.extractClasses($):m9($);if(J.size===0)return"";let Y=X?v0.resolve(X):process.cwd();if(!u4)u4=n0(Y,"cache");let Q=[...J].sort().join(" "),G=`${CG||"default"}::${Q}`,K=Q4.get(G);if(K!==void 0)return kG(G,K),K;let W=await Jg(G);if(W!==null)return kG(G,W),W;if(!_$)_$=await oO(Y),CG=tO(_$);let U=Z.defaultConfig||Z.config,z=_$||{},q=h9(U,z),{safelist:j,includePreflight:_,minify:H,tokenCSS:L}=q,O=q.config,B=new Z.CSSGenerator(O);for(let A of j)B.generate(A);for(let A of J)B.generate(A);let F=B.toCSS(_,H),V=O.shortcuts||z.shortcuts||{};for(let[A,R]of Object.entries(V)){if(!J.has(A)&&!j.includes(A))continue;let M=R.split(/\s+/).filter(Boolean);for(let I of M)B.generate(I)}F=B.toCSS(_,H);let w=F.split(`
2715
- `);for(let[A,R]of Object.entries(V)){if(!J.has(A)&&!j.includes(A))continue;let M=R.split(/\s+/).filter(Boolean),I=[],N=[];for(let E of M){let C=E.startsWith("dark:"),x=`.${(C?E.slice(5):E).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<w.length;b++){let u=w[b].trim();if(u===`${x} {`||u.startsWith(`${x} {`)){let i=b,c="";while(i<w.length){if(c+=w[i],w[i].includes("}"))break;i++}let P=c.match(/\{([^}]+)\}/);if(P)if(C)N.push(P[1].trim());else I.push(P[1].trim());break}}}if(I.length)F+=`
2715
+ `);for(let[A,R]of Object.entries(V)){if(!J.has(A)&&!j.includes(A))continue;let M=R.split(/\s+/).filter(Boolean),I=[],N=[];for(let E of M){let C=E.startsWith("dark:"),y=`.${(C?E.slice(5):E).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<w.length;b++){let u=w[b].trim();if(u===`${y} {`||u.startsWith(`${y} {`)){let i=b,c="";while(i<w.length){if(c+=w[i],w[i].includes("}"))break;i++}let P=c.match(/\{([^}]+)\}/);if(P)if(C)N.push(P[1].trim());else I.push(P[1].trim());break}}}if(I.length)F+=`
2716
2716
  .${A} { ${I.join(" ")} }`;if(N.length)F+=`
2717
2717
  @media (prefers-color-scheme: dark) { .dark .${A} { ${N.join(" ")} } }`}return F=L+F,kG(G,F),Yg(G,F),F}catch(Z){return console.warn("Failed to generate Crosswind CSS:",Z),""}}async function i0($,X,Z=!1){let J=await d9($,X);if(!J)return $;let Y=Z?`<link data-crosswind="generated" rel="stylesheet" href="/_stx/crosswind.${Zg(J)}.css">`:`<style data-crosswind="generated">
2718
2718
  ${J}
@@ -3532,7 +3532,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
3532
3532
  @end${K}`;J.push(`Added ${z} missing @end${K}`)}}if(J.length>0&&X.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),J.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:Z,fixes:J}},createFallbackContent($,X){if(m4())return`<!-- ${$} failed: ${X.message} -->`;return"<!-- stx rendering error -->"}};T1=new o9,X5={isDevelopment(){return m4()},logDetailedError($,X){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",$.message),console.error("Stack:",$.stack),X)console.error("Context:",X);console.error("========================")},createErrorReport($,X){let Z=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(X)Z.push(`Context: ${JSON.stringify(X,null,2)}`);return Z.push("========================"),Z.join(`
3533
3533
  `)}}});import rG from"path";function vg($){let X={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return $.replace(/[&<>"']/g,(Z)=>X[Z]||Z)}function P3($,X={}){let{allowHtml:Z=!1,maxLength:J=1e4,allowSpecialChars:Y=!0,customSanitizer:Q}=X,G=[],K=$,W=!1;if(Q){let z=Q(K);if(z!==K)K=z,W=!0}if(K.includes("\x00"))K=K.replace(/\0/g,""),W=!0,G.push("Null bytes removed from parameter");if(K.length>J)K=K.substring(0,J),W=!0,G.push(`Parameter truncated to ${J} characters`);if(!Z&&/<[^>]+>/.test(K))K=vg(K),W=!0,G.push("HTML content was escaped");let U=[{pattern:/javascript:/gi,replacement:"",name:"javascript: URI"},{pattern:/vbscript:/gi,replacement:"",name:"vbscript: URI"},{pattern:/data:text\/html/gi,replacement:"",name:"data:text/html URI"}];for(let{pattern:z,replacement:q,name:j}of U)if(z.test(K))K=K.replace(z,q),W=!0,G.push(`Removed ${j} from parameter`);if(!Y){let z=K;if(K=K.split("").filter((q)=>{let j=q.charCodeAt(0);return j>=32&&j!==127}).join(""),K!==z)W=!0,G.push("Control characters removed")}return{value:K,modified:W,warnings:G}}function IB($,X){let Z=$.replace(/\0/g,"");Z=Z.replace(/\\/g,"/"),Z=Z.replace(/^[a-z][a-z0-9+.-]*:/i,"");while(Z.includes("../")||Z.includes("./"))Z=Z.replace(/\.\.\//g,"").replace(/\.\//g,"");if(!t9.isValidFilePath(Z,X))return null;return Z}function kB($){let X=[],Z=$.trim(),J=Z!==$,Y=[{pattern:/\beval\s*\(/gi,name:"eval()"},{pattern:/\bFunction\s*\(/gi,name:"Function()"},{pattern:/\bsetTimeout\s*\(/gi,name:"setTimeout()"},{pattern:/\bsetInterval\s*\(/gi,name:"setInterval()"},{pattern:/\bimport\s*\(/gi,name:"dynamic import()"},{pattern:/\brequire\s*\(/gi,name:"require()"},{pattern:/\b__proto__\b/gi,name:"__proto__"},{pattern:/\bconstructor\b/gi,name:"constructor"},{pattern:/\bprototype\b/gi,name:"prototype"}];for(let{pattern:Q,name:G}of Y)if(Q.test(Z))X.push(`Potentially dangerous pattern detected: ${G}`);if(Z.includes("\x00"))Z=Z.replace(/\0/g,""),J=!0,X.push("Null bytes removed from expression");return{value:Z,modified:J,warnings:X}}function SB($,X={}){return $.map((Z)=>P3(Z,X))}function aG($){let X={};for(let[Z,J]of Object.entries($)){if(!t9.isValidVariableName(Z))continue;if(typeof J==="string"){let Y=P3(J);X[Z]=Y.value}else if(Array.isArray(J))X[Z]=J.map((Y)=>typeof Y==="string"?P3(Y).value:Y);else if(typeof J==="object"&&J!==null)X[Z]=aG(J);else X[Z]=J}return X}var t9;var CB=T(()=>{t9={isValidFilePath($,X){let Z=$.replace(/\\/g,"/");if(Z.includes("\x00"))return!1;if(Z.includes("../")||Z.includes("..\\")||Z===".."||Z.startsWith("../")||Z.endsWith("/..")||Z.includes("/..\\")||Z.includes("\\../"))return!1;if(/^[a-z][a-z0-9+.-]*:/i.test(Z))return!1;if(Z.startsWith("/")){if(["/etc/","/root/","/var/","/usr/","/bin/","/sbin/","/proc/","/sys/","/dev/","/boot/","/home/","/private/","/Library/","/System/"].some((Q)=>Z===Q.slice(0,-1)||Z.startsWith(Q)))return!1}if(/^[a-z]:/i.test(Z)){if(["Windows/","Windows\\","System32/","System32\\","Program Files/","Program Files\\"].some((Q)=>Z.includes(Q)))return!1}if(X){let Y=rG.resolve(X,$),Q=rG.resolve(X);if(!Y.startsWith(Q+rG.sep)&&Y!==Q)return!1}return!0},isValidVariableName($){return/^[a-z_$]\w*$/i.test($)},isValidDirectiveName($){return/^[a-z][\w-]*$/i.test($)},isSafeContent($){return![/<script[^>]*>[\s\S]*?<\/script>/i,/javascript:/i,/data:text\/html/i,/vbscript:/i,/on\w+\s*=/i].some((Z)=>Z.test($))}}});var PB=T(()=>{n9();TB();DB();CB();r9()});var a1=T(()=>{PB()});class b3{source;pos=0;line=1;column=0;tokens=[];constructor($){this.source=$}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let $=this.nextToken();if($)this.tokens.push($)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let $=this.pos,X=this.line,Z=this.column,J=this.source[this.pos];if(/\s/.test(J))return this.readWhitespace($,X,Z);if(J==="/"&&this.peek(1)==="/")return this.readLineComment($,X,Z);if(J==="/"&&this.peek(1)==="*")return this.readBlockComment($,X,Z);if(J==='"'||J==="'")return this.readString(J,$,X,Z);if(J==="`")return this.readTemplateString($,X,Z);if(/\d/.test(J)||J==="."&&/\d/.test(this.peek(1)||""))return this.readNumber($,X,Z);if(/[a-z_$]/i.test(J))return this.readIdentifier($,X,Z);if(J==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:$,end:this.pos,line:X,column:Z};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:$,end:this.pos,line:X,column:Z};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:$,end:this.pos,line:X,column:Z}}if(J==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:$,end:this.pos,line:X,column:Z};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:$,end:this.pos,line:X,column:Z}}if(J==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:$,end:this.pos,line:X,column:Z};if(J==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective($,X,Z);let Y=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let Q of Y)if(this.source.slice(this.pos,this.pos+Q.length)===Q)return this.advance(Q.length),{type:"OPERATOR",value:Q,start:$,end:this.pos,line:X,column:Z};if(/[+\-*/%<>=!&|^~?:]/.test(J))return this.advance(),{type:"OPERATOR",value:J,start:$,end:this.pos,line:X,column:Z};if(/[()[\]{},;.]/.test(J))return this.advance(),{type:"PUNCTUATION",value:J,start:$,end:this.pos,line:X,column:Z};return this.advance(),{type:"PUNCTUATION",value:J,start:$,end:this.pos,line:X,column:Z}}readWhitespace($,X,Z){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:X,column:Z}}readLineComment($,X,Z){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
3534
3534
  `)this.advance();return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:X,column:Z}}readBlockComment($,X,Z){this.advance(2);while(this.pos<this.source.length-1){if(this.source[this.pos]==="*"&&this.source[this.pos+1]==="/"){this.advance(2);break}this.advance()}return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:X,column:Z}}readString($,X,Z,J){this.advance();while(this.pos<this.source.length){let Y=this.source[this.pos];if(Y==="\\"){this.advance(2);continue}if(Y===$){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(X,this.pos),start:X,end:this.pos,line:Z,column:J}}readTemplateString($,X,Z){this.advance();let J=0,Y=256;while(this.pos<this.source.length){let Q=this.source[this.pos];if(Q==="\\"){this.advance(2);continue}if(Q==="$"&&this.peek(1)==="{"){if(J>=Y){this.pos=this.source.length;break}this.advance(2),J++;continue}if(Q==="{"&&J>0){J++,this.advance();continue}if(Q==="}"&&J>0){J--,this.advance();continue}if(Q==="`"&&J===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice($,this.pos),start:$,end:this.pos,line:X,column:Z}}readNumber($,X,Z){if(this.source[this.pos]==="0"){let J=this.peek(1)?.toLowerCase();if(J==="x"||J==="o"||J==="b"){this.advance(2);while(this.pos<this.source.length&&/[\da-f_]/i.test(this.source[this.pos]))this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:X,column:Z}}}while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance();if(this.source[this.pos]==="."&&/\d/.test(this.peek(1)||"")){this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(/e/i.test(this.source[this.pos]||"")){if(this.advance(),/[+-]/.test(this.source[this.pos]||""))this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(this.source[this.pos]==="n")this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:X,column:Z}}readIdentifier($,X,Z){while(this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]))this.advance();return{type:"IDENTIFIER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:X,column:Z}}readDirective($,X,Z){this.advance();while(this.pos<this.source.length&&/[a-z]/i.test(this.source[this.pos]))this.advance();return{type:"DIRECTIVE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:X,column:Z}}advance($=1){for(let X=0;X<$&&this.pos<this.source.length;X++){if(this.source[this.pos]===`
3535
- `)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function X1($,X,Z,J=0){let Y=0,Q=J,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===X)Y++;else if(U===Z){if(Y--,Y===0)return Q}Q++}return-1}function sG($,X){let Z=X,J={paren:0,bracket:0,brace:0},Y=null,Q=0;while(Z<$.length){let G=$[Z];if((Z>0?$[Z-1]:"")==="\\"&&Y){Z++;continue}if((G==='"'||G==="'")&&!Y){Y=G,Z++;continue}if(G===Y&&Y!=="`"){Y=null,Z++;continue}if(G==="`"&&!Y){Y="`",Z++;continue}if(G==="`"&&Y==="`"&&Q===0){Y=null,Z++;continue}if(Y==="`"&&G==="$"&&$[Z+1]==="{"){Q++,Z+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Z++;continue}if(Y){Z++;continue}if(J.paren===0&&J.bracket===0&&J.brace===0){if($.slice(Z,Z+2)==="}}"||$.slice(Z,Z+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")J.paren++;else if(G===")"){if(J.paren--,J.paren<0)break}else if(G==="[")J.bracket++;else if(G==="]"){if(J.bracket--,J.bracket<0)break}else if(G==="{")J.brace++;else if(G==="}"){if(J.brace--,J.brace<0)break}Z++}return{expression:$.slice(X,Z),endPos:Z}}function e9($){let X=[],Z="",J={paren:0,bracket:0,brace:0},Y=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&Y){Z+=K;continue}if((K==='"'||K==="'")&&!Y){Y=K,Z+=K;continue}if(K===Y&&Y!=="`"){Y=null,Z+=K;continue}if(K==="`"&&!Y){Y="`",Z+=K;continue}if(K==="`"&&Y==="`"&&Q===0){Y=null,Z+=K;continue}if(Y==="`"&&K==="$"&&$[G+1]==="{"){Q++,Z+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Z+=K;continue}if(Q>0&&K==="}"){Q--,Z+=K;continue}if(Y){Z+=K;continue}if(K==="(")J.paren++;else if(K===")")J.paren--;else if(K==="[")J.bracket++;else if(K==="]")J.bracket--;else if(K==="{")J.brace++;else if(K==="}")J.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&J.paren===0&&J.bracket===0&&J.brace===0){X.push(Z.trim()),Z="";continue}if(K==="|"&&$[G-1]==="\\"&&!Y){Z=Z.slice(0,-1)+K;continue}Z+=K}if(Z.trim())X.push(Z.trim());return X}function K4($,X){let Z=fg($,X);return Z.ok?{expression:Z.expression,endPos:Z.endPos}:null}function fg($,X){let Z=X;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Z};let J=X1($,"(",")",Z);if(J===-1)return{ok:!1,reason:"unclosed-paren",pos:Z};return{ok:!0,expression:$.slice(Z+1,J),endPos:J+1}}function gg($,X){let Z=$.lastIndexOf("<",X);if(Z===-1)return!1;return Z>$.lastIndexOf(">",X)}function c4($,X,Z,J){let Y=1,Q=J,G=new RegExp(`@${X}\\s*\\(`,"g"),K=new RegExp(`@${Z}(?![a-z])`,"g");while(Q<$.length&&Y>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),z=W?W.index:1/0,q=U?U.index:1/0;if(z<q)Y++,Q=z+W[0].length;else if(q<1/0){if(Y--,Y===0)return q;Q=q+U[0].length}else break}return-1}function oG($,X){let Z=$.slice(X).match(/^@if\s*/);if(!Z)return null;let J=X+Z[0].length,Y=K4($,J);if(!Y)return null;let Q=Y.endPos,G=c4($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,z="if",q=Y.expression,j=0,_=0;while(U<K.length){let H=K.indexOf("@",U);if(H===-1)break;U=H;let L=K.substring(H);if(gg(K,H)){U++;continue}if(/^@if\s*\(/.test(L)){_++,U++;continue}if(/^@endif(?![a-z])/.test(L)){_--,U+=6;continue}if(_===0){let O=L.match(/^@elseif\s*/);if(O){W.push({type:z,condition:q,content:K.substring(j,U),start:Q+j,end:Q+U});let B=U+O[0].length,F=K4(K,B);if(!F){U++;continue}z="elseif",q=F.expression,U=F.endPos,j=U;continue}else if(/^@else(?![a-z])/.test(L)){W.push({type:z,condition:q,content:K.substring(j,U),start:Q+j,end:Q+U}),z="else",q=void 0,U+=5,j=U;continue}}U++}return W.push({type:z,condition:q,content:K.slice(j),start:Q+j,end:Q+K.length}),{fullMatch:$.slice(X,G+6),branches:W,start:X,end:G+6}}function Z5($){let X=[],Z=/@if\s*\(/g,J=Z.exec($);while(J!==null){if(X.some((G)=>J.index>G.start&&J.index<G.end)){J=Z.exec($);continue}let Q=oG($,J.index);if(Q)X.push(Q),Z.lastIndex=Q.end;J=Z.exec($)}return X}function y3($,X,Z){let J=[],Y=new RegExp(`@${X}\\s*\\(`,"g"),Q=Y.exec($);while(Q!==null){if(J.some((L)=>Q.index>L.start&&Q.index<L.end)){Q=Y.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=X1($,"(",")",W);if(U===-1){Q=Y.exec($);continue}let z=$.slice(W+1,U),q=U+1,j=c4($,X,Z,q);if(j===-1){Q=Y.exec($);continue}let _=$.slice(q,j),H=j+`@${Z}`.length;J.push({fullMatch:$.slice(K,H),name:X,params:z,content:_,start:K,end:H}),Y.lastIndex=H,Q=Y.exec($)}return J}function $2($,X){let Z=$.slice(X).match(/^@switch\s*/);if(!Z)return null;let J=X+Z[0].length,Y=K4($,J);if(!Y)return null;let Q=Y.endPos,G=c4($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,z=null,q=0;while(U<K.length){let j=K.slice(U),_=j.match(/^@switch\s*\(/),H=j.match(/^@endswitch(?![a-z])/);if(_){if(q++,z)z.content+=_[0];U+=_[0].length;continue}if(H){if(q--,z)z.content+=H[0];U+=H[0].length;continue}if(q>0){if(z)z.content+=K[U];U++;continue}let L=j.match(/^@case\s*/),O=j.match(/^@default(?![a-z])/),B=j.match(/^@break(?![a-z])/);if(L&&j.startsWith("@case")){if(z)W.push(z);let F=U+L[0].length,V=K4(K,F);if(!V){U++;continue}z={type:"case",value:V.expression,content:""},U=V.endPos}else if(O&&j.startsWith("@default")){if(z)W.push(z);z={type:"default",content:""},U+=O[0].length}else if(B&&j.startsWith("@break"))U+=B[0].length;else{if(z)z.content+=K[U];U++}}if(z)W.push(z);return{fullMatch:$.slice(X,G+10),expression:Y.expression,cases:W,start:X,end:G+10}}var bB=()=>{};function vB($){let X=[],Z=0;while(Z<$.length){let J=$.indexOf("{{",Z),Y=$.indexOf("{!!",Z),Q=!1,G;if(J===-1&&Y===-1)break;else if(J===-1)G=Y,Q=!0;else if(Y===-1)G=J,Q=!1;else if(Y<J)G=Y,Q=!0;else G=J,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,z=hg($,U,W);if(z===-1){Z=G+1;continue}let q=$.slice(U,z).trim(),j=z+W.length;X.push({fullMatch:$.slice(G,j),expression:q,start:G,end:j,isRaw:Q}),Z=j}return X}function hg($,X,Z){let J=X,Y=null,Q={paren:0,bracket:0,brace:0},G=0;while(J<$.length){let K=$[J];if((J>0?$[J-1]:"")==="\\"&&Y){J++;continue}if((K==='"'||K==="'")&&!Y){Y=K,J++;continue}if(K===Y&&Y!=="`"){Y=null,J++;continue}if(K==="`"&&!Y){Y="`",J++;continue}if(K==="`"&&Y==="`"&&G===0){Y=null,J++;continue}if(Y==="`"&&K==="$"&&$[J+1]==="{"){G++,J+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;J++;continue}if(Y){J++;continue}if(K==="(")Q.paren++;else if(K===")")Q.paren--;else if(K==="[")Q.bracket++;else if(K==="]")Q.bracket--;else if(K==="{")Q.brace++;else if(K==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(J,J+Z.length)===Z)return J}J++}return-1}function fB($){let X=e9($);if(X.length===0)return{baseExpression:"",filters:[]};let Z=X[0],J=[];for(let Y=1;Y<X.length;Y++){let Q=ug(X[Y]);if(Q)J.push(Q)}return{baseExpression:Z,filters:J}}function ug($){let X=$.trim();if(!X)return null;let Z=X.indexOf("(");if(Z===-1)return{name:X,args:[]};let J=X.slice(0,Z).trim(),Y=Z+1,Q=X1(X,"(",")",Z);if(Q===-1)return{name:J,args:[]};let G=X.slice(Y,Q),K=tG(G);return{name:J,args:K}}function tG($){let X=[],Z="",J={paren:0,bracket:0,brace:0},Y=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&Y){Z+=K;continue}if((K==='"'||K==="'")&&!Y){Y=K,Z+=K;continue}if(K===Y&&Y!=="`"){Y=null,Z+=K;continue}if(K==="`"&&!Y){Y="`",Z+=K;continue}if(K==="`"&&Y==="`"&&Q===0){Y=null,Z+=K;continue}if(Y==="`"&&K==="$"&&$[G+1]==="{"){Q++,Z+="${",G++;continue}if(Q>0&&K==="{"){Q++,Z+=K;continue}if(Q>0&&K==="}"){Q--,Z+=K;continue}if(Y){Z+=K;continue}if(K==="(")J.paren++;else if(K===")")J.paren--;else if(K==="[")J.bracket++;else if(K==="]")J.bracket--;else if(K==="{")J.brace++;else if(K==="}")J.brace--;if(K===","&&J.paren===0&&J.bracket===0&&J.brace===0){X.push(Z.trim()),Z="";continue}Z+=K}if(Z.trim())X.push(Z.trim());return X}function gB($,X){let Z=X;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;let J=X1($,"(",")",Z);if(J===-1)return null;return{params:$.slice(Z+1,J),endPos:J+1}}function hB($){let X=[],J=new b3($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),Y=0;while(Y<J.length){let Q=J[Y],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,Y++,Y>=J.length)break}let K=J[Y];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(Y++,Y>=J.length)break;let U=J[Y];if(U.type==="IDENTIFIER"){let z=U.value;if(Y++,Y<J.length&&J[Y].type==="OPERATOR"&&J[Y].value==="="){Y++;let q=Y<J.length?J[Y].start:$.length,j=yB(J,Y,$);Y=j.nextIndex,X.push({type:"variable",name:z,value:$.slice(q,j.endPos),exported:G,start:K.start,end:j.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let z=U.start,q=U.value==="{"?"}":"]",j=X1($,U.value,q,z);if(j!==-1){let _=$.slice(z,j+1);if(Y=xB(J,j+1),Y<J.length&&J[Y].type==="OPERATOR"&&J[Y].value==="="){Y++;let H=Y<J.length?J[Y].start:$.length,L=yB(J,Y,$);Y=L.nextIndex;let O=`__stx_destructured_${X.length}`;X.push({type:"variable",name:O,value:`${$.slice(H,L.endPos)}; ${W} ${_} = ${O}`,exported:G,start:K.start,end:L.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?J[Y-1].start:K.start;if(Y++,Y>=J.length)break;let U=J[Y];if(U.type==="IDENTIFIER"){let z=U.value;Y++;let q=-1;while(Y<J.length){if(J[Y].type==="PUNCTUATION"&&J[Y].value==="{"){q=J[Y].start;break}Y++}if(q!==-1){let j=X1($,"{","}",q);if(j!==-1)X.push({type:"function",name:z,value:$.slice(W,j+1).replace(/^export\s+/,""),exported:G,start:W,end:j+1}),Y=xB(J,j+1)}}}else Y++}return X}function yB($,X,Z){let J=X,Y={paren:0,bracket:0,brace:0},Q=X<$.length?$[X].start:Z.length;while(J<$.length){let G=$[J];if(G.type==="PUNCTUATION"){if(G.value==="(")Y.paren++;else if(G.value===")")Y.paren--;else if(G.value==="[")Y.bracket++;else if(G.value==="]")Y.bracket--;else if(G.value==="{")Y.brace++;else if(G.value==="}")Y.brace--;if(G.value===";"&&Y.paren===0&&Y.bracket===0&&Y.brace===0){Q=G.start,J++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(Y.paren===0&&Y.bracket===0&&Y.brace===0){Q=$[J-1]?.end??G.start;break}}Q=G.end,J++}return{nextIndex:J,endPos:Q}}function xB($,X){for(let Z=0;Z<$.length;Z++)if($[Z].start>=X)return Z;return $.length}var uB=()=>{};var x3=T(()=>{bB();uB()});function mg($,X,Z){let J=$,Y=!0;while(Y){Y=!1;let Q=J.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=$2(J,G);if(!K)break;try{let W;if(m0(K.expression))W=d0(K.expression,Object.keys(X))(...Object.values(X));else W=x0(K.expression,X);let U="",z=!1;for(let q of K.cases)if(q.type==="default"){if(!z)U=q.content.trim()}else try{let j;if(q.value&&m0(q.value))j=d0(q.value,Object.keys(X))(...Object.values(X));else if(q.value)j=x0(q.value,X);if(W===j){U=q.content.trim(),z=!0;break}}catch{continue}J=J.substring(0,G)+U+J.substring(K.end),Y=!0}catch(W){let U=W instanceof Error?W.message:String(W),z=T0("Switch",`Error evaluating @switch expression: ${U}`,_0.EVALUATION_ERROR);J=J.substring(0,G)+z+J.substring(K.end);break}}return J}function dg($){let X=[];return{masked:$.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(J)=>{return X.push(J),`\x00stx-script-${X.length-1}\x00`}),scripts:X}}function cg($,X){if(X.length===0)return $;return $.replace(/\u0000stx-script-(\d+)\u0000/g,(Z,J)=>X[Number(J)]??Z)}function W4($,X,Z){let{masked:J,scripts:Y}=dg($);return cg(lg(J,X,Z),Y)}function lg($,X,Z){let J=$;J=mg(J,X,Z);{let Q=!0;while(Q){Q=!1;let G=J.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K4(J,K+7);if(!W)break;let U=W.endPos,z=c4(J,"unless","endunless",U);if(z===-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 q=J.slice(U,z),j=W.expression,_=-1;{let L=0,O=/@(?:if|unless)\s*\(/g,B=/@(?:endif|endunless)(?![a-z])/g,F=/@else(?![a-z])/g,V=[],w;while((w=O.exec(q))!==null)V.push({pos:w.index,type:"open"});while((w=B.exec(q))!==null)V.push({pos:w.index,type:"close"});while((w=F.exec(q))!==null)V.push({pos:w.index,type:"else"});V.sort((A,R)=>A.pos-R.pos);for(let A of V)if(A.type==="open")L++;else if(A.type==="close")L--;else if(A.type==="else"&&L===0){_=A.pos;break}}let H;if(_!==-1){let L=q.slice(0,_),O=q.slice(_+5);H=`@if (${j})${O}@else ${L}@endif`}else H=`@if (!(${j}))${q}@endif`;J=J.substring(0,K)+H+J.substring(z+10),Q=!0}}J=$K(J,X,Z),J=XK(J,X,Z),J=eG(J,X);let Y=()=>{let Q=Z5(J);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let z of K.branches){if(U)break;if(z.type==="else")W=z.content,U=!0;else try{let q;if(z.condition&&m0(z.condition))q=d0(z.condition,Object.keys(X))(...Object.values(X));else if(z.condition)q=x0(z.condition,X);if(q)W=z.content,U=!0}catch(q){W=T0(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${q instanceof Error?q.message:String(q)}`,_0.EVALUATION_ERROR),U=!0}}J=J.substring(0,K.start)+W+J.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),z=T0("If",`Error processing @if block: ${U}`,_0.EVALUATION_ERROR);J=J.substring(0,K.start)+z+J.substring(K.end)}}return!0};while(!0){let Q=J;if(!Y())break;if(J===Q)break}return J}function mB($){let X=0;while(X<$.length&&/\s/.test($[X]))X++;if($[X]!=="(")return null;X++;while(X<$.length&&/\s/.test($[X]))X++;let Z=$[X];if(Z!=="'"&&Z!=='"')return null;X++;let J=[];while(X<$.length){let Y=$[X];if(Y==="\\"&&X+1<$.length){J.push($[X+1]),X+=2;continue}if(Y===Z){X++;break}J.push(Y),X++}while(X<$.length&&/\s/.test($[X]))X++;if($[X]!==")")return null;return X++,{value:J.join(""),consumed:X}}function eG($,X){let Z=$;function J(K,W,U,z){let q=1,j=z,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),H=new RegExp(`@${U}(?![a-z])`,"g");while(j<K.length&&q>0){_.lastIndex=j,H.lastIndex=j;let L=_.exec(K),O=H.exec(K),B=L?L.index:1/0,F=O?O.index:1/0;if(B<F)q++,j=B+L[0].length;else if(F<1/0){if(q--,q===0)return F;j=F+O[0].length}else break}return-1}function Y(K,W,U){let z=0,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g"),_=/@else(?![a-z])/g,H=[],L;while((L=q.exec(K))!==null)H.push({pos:L.index,type:"open"});while((L=j.exec(K))!==null)H.push({pos:L.index,type:"close"});while((L=_.exec(K))!==null)H.push({pos:L.index,type:"else"});H.sort((O,B)=>O.pos-B.pos);for(let O of H)if(O.type==="open")z++;else if(O.type==="close")z--;else if(O.type==="else"&&z===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Z.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,z,q,j=Z.slice(U+5),_=mB(j);if(_)z=_.value,q=U+5+_.consumed;else q=U+5;let H=J(Z,"auth","endauth",q);if(H===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let L=Z.slice(q,H),O=Y(L,"auth","endauth"),B;if(!X.auth)B=!1;else B=z?G4(`auth?.check && auth?.user?.[${z}]`,X):G4("auth?.check",X);let F;if(O!==-1){let V=L.slice(0,O),w=L.slice(O+5);F=B?V:w}else F=B?L:"";Z=Z.substring(0,U)+F+Z.substring(H+8),K=!0}}{let K=!0;while(K){K=!1;let W=Z.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,z,q,j=Z.slice(U+6),_=mB(j);if(_)z=_.value,q=U+6+_.consumed;else q=U+6;let H=J(Z,"guest","endguest",q);if(H===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let L=Z.slice(q,H),O=Y(L,"guest","endguest"),B;if(!X.auth)B=!0;else B=z?G4(`!auth?.check || !auth?.user?.[${z}]`,X):G4("!auth?.check",X);let F;if(O!==-1){let V=L.slice(0,O),w=L.slice(O+5);F=B?V:w}else F=B?L:"";Z=Z.substring(0,U)+F+Z.substring(H+9),K=!0}}function Q(K,W,U){if(X.userCan&&typeof X.userCan[K]==="boolean")return X.userCan[K];if(X.permissions?.check&&typeof X.permissions.check==="function")try{let z=[K];if(W)z.push(W);if(U){let q=G4(U,X);z.push(q)}return X.permissions.check(...z)}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}`,U=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let q=Z.match(new RegExp(`@${K}\\s*\\(`));if(!q||q.index===void 0)break;let j=q.index,_=Z.slice(j+`@${K}`.length),H=G(_);if(!H)break;let L=j+`@${K}`.length+H.paramsEnd,O=J(Z,K,W,L);if(O===-1){console.warn(`[stx] @${K} directive at position ${j} has no matching @${W} \u2014 the block was skipped.`);break}let B=Z.slice(L,O),F=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),R=new RegExp(`@${U}\\s*\\(`,"g"),M=/@else(?![a-z])/g,I=[],N;while((N=w.exec(B))!==null)I.push({pos:N.index,type:"open"});while((N=A.exec(B))!==null)I.push({pos:N.index,type:"close"});while((N=R.exec(B))!==null)I.push({pos:N.index,type:"elseDirective"});while((N=M.exec(B))!==null)I.push({pos:N.index,type:"else"});I.sort((b,u)=>b.pos-u.pos);for(let b of I){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)F.push(b)}let E=[],C=0;for(let b=0;b<F.length;b++){let u=F[b];if(E.push({content:B.slice(C,u.pos),ability:void 0}),u.type==="elseDirective"){let i=B.slice(u.pos+`@${U}`.length),c=G(i);if(c){E[E.length-1]={content:B.slice(C,u.pos)},C=u.pos+`@${U}`.length+c.paramsEnd,E.push({content:"",ability:c.ability,type:c.type,id:c.id}),E.pop();let P=F[b+1],v=P?P.pos:B.length;E.push({content:B.slice(C,v),ability:c.ability,type:c.type,id:c.id}),C=v}}else C=u.pos+5}if(C<B.length){let b=E[E.length-1];if(F.length>0&&F[F.length-1].type==="else")E.push({content:B.slice(C),isFinalElse:!0});else if(E.length===0)E.push({content:B.slice(C)})}let S=Q(H.ability,H.type,H.id),y=K==="can"?S:!S,x="";if(y)x=E[0]?.content||"";else{let b=!1;for(let u=1;u<E.length;u++){let i=E[u];if(i.isFinalElse){x=i.content,b=!0;break}if(i.ability){let c=Q(i.ability,i.type,i.id);if(K==="can"?c:!c){x=i.content,b=!0;break}}}if(!b&&E.length>0){let u=E[E.length-1];if(u.isFinalElse)x=u.content}}Z=Z.substring(0,j)+x+Z.substring(O+`@${W}`.length),z=!0}}return Z}function $K($,X,Z){let J=$;function Y(Q,G,K,W,U){let z=!0;while(z){z=!1;let q=new RegExp(`@${G}\\s*\\(`),j=Q.match(q);if(!j||j.index===void 0)break;let _=j.index,H=K4(Q,_+`@${G}`.length);if(!H)break;let L=H.endPos,O=c4(Q,G,K,L);if(O===-1){console.warn(`[stx] @${G} directive at position ${_} has no matching @${K} \u2014 the block was skipped.`);break}let B=Q.slice(L,O),F=H.expression,V=-1,w=0,A=0;while(A<B.length){let R=B.indexOf("@",A);if(R===-1)break;let M=B.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(M)){w++,A=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(M)){w--,A=R+1;continue}if(w===0&&/^@else(?![a-z])/.test(M)){V=R;break}A=R+1}try{let R=W(F.trim()),M;if(V!==-1){let I=B.slice(0,V),N=B.slice(V+5);M=R?I:N}else M=R?B:"";Q=Q.substring(0,_)+M+Q.substring(O+`@${K}`.length),z=!0}catch(R){let M=R instanceof Error?R.message:String(R),I=T0(U,`Error processing @${G} directive: ${M}`,_0.EVALUATION_ERROR);Q=Q.substring(0,_)+I+Q.substring(O+`@${K}`.length);break}}return Q}return J=Y(J,"isset","endisset",(Q)=>{let G=G4(Q,X);return G!==void 0&&G!==null},"Isset"),J=Y(J,"empty","endempty",(Q)=>{let G=G4(Q,X);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"),J}function XK($,X,Z){let J=$,Y="development";function Q(G,K,W,U){let z=new RegExp(`@${K}(?![a-z])`,"g"),q=new RegExp(`@${W}(?![a-z])`,"g"),j=new RegExp(`^@${K}(?![a-z])`),_=new RegExp(`^@${W}(?![a-z])`),H=G,L=!0;while(L){L=!1,z.lastIndex=0;let O=z.exec(H);if(!O)break;let B=O.index,F=B+O[0].length;if(K==="env"){let S=H.substring(F).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!S)break;F+=S[0].length,U=Y===S[2]}let V=1,w=F,A=-1;while(V>0&&w<H.length){z.lastIndex=w,q.lastIndex=w;let S=z.exec(H),y=q.exec(H),x=S?S.index:1/0,b=y?y.index:1/0;if(x<b)V++,w=x+S[0].length;else if(b<1/0){if(V--,V===0){A=b;break}w=b+y[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${W} \u2014 the block was skipped.`);break}let R=H.substring(F,A),M=-1,I=0,N=0;while(N<R.length){let S=R.indexOf("@",N);if(S===-1)break;let y=R.substring(S);if(j.test(y)){I++,N=S+1;continue}if(_.test(y)){I--,N=S+1;continue}if(I===0&&/^@else(?![a-z])/.test(y)){M=S;break}N=S+1}let E;if(M!==-1){let S=R.slice(0,M),y=R.slice(M+5);E=U?S:y}else E=U?R:"";let C=`@${W}`.length;H=H.substring(0,B)+E+H.substring(A+C),L=!0}return H}return J=Q(J,"env","endenv",!1),J=Q(J,"production","endproduction",Y==="production"),J=Q(J,"development","enddevelopment",Y==="development"),J=Q(J,"staging","endstaging",Y==="staging"),J=Q(J,"testing","endtesting",Y==="testing"),J}var v3=T(()=>{lG();a1();x3();j1()});function JK($=16){let X=new Uint8Array($);return crypto.getRandomValues(X),btoa(String.fromCharCode(...X))}function l4($,X){if(!$)return X?.nonceGenerator?.()??JK();let Z=ZK.get($);if(!Z)Z=X?.nonceGenerator?.()??JK(),ZK.set($,Z);return Z}function pg($){ZK.delete($)}function YK($,X){let Z=[];for(let[J,Y]of Object.entries($)){if(Y===void 0||Y===null)continue;if(typeof Y==="boolean"){if(Y)Z.push(J);continue}if(Array.isArray(Y)){let Q=[...Y];if(X&&(J==="script-src"||J==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${X}'`);if(Q.length>0)Z.push(`${J} ${Q.join(" ")}`)}}return Z.join("; ")}function Z2($,X){return`<meta http-equiv="Content-Security-Policy" content="${YK($,X).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function ig($){return{enabled:!0,directives:{strict:dB,moderate:X2,relaxed:cB,api:lB}[$]||X2,useNonce:$==="strict",addMetaTag:!0}}function ng($,X){let Z={...$};for(let[J,Y]of Object.entries(X)){let Q=J,G=Z[Q];if(Y===void 0||Y===null)continue;if(typeof Y==="boolean")Z[Q]=G||Y;else if(Array.isArray(Y)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...Y])];Z[Q]=W}}return Z}function QK($,X,Z){if(!X.enabled||!X.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let J=X.useNonce?l4(Z,X):void 0,Y=Z2(X.directives,J);return $.replace(/<head([^>]*)>/,`<head$1>
3535
+ `)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function X1($,X,Z,J=0){let Y=0,Q=J,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===X)Y++;else if(U===Z){if(Y--,Y===0)return Q}Q++}return-1}function sG($,X){let Z=X,J={paren:0,bracket:0,brace:0},Y=null,Q=0;while(Z<$.length){let G=$[Z];if((Z>0?$[Z-1]:"")==="\\"&&Y){Z++;continue}if((G==='"'||G==="'")&&!Y){Y=G,Z++;continue}if(G===Y&&Y!=="`"){Y=null,Z++;continue}if(G==="`"&&!Y){Y="`",Z++;continue}if(G==="`"&&Y==="`"&&Q===0){Y=null,Z++;continue}if(Y==="`"&&G==="$"&&$[Z+1]==="{"){Q++,Z+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Z++;continue}if(Y){Z++;continue}if(J.paren===0&&J.bracket===0&&J.brace===0){if($.slice(Z,Z+2)==="}}"||$.slice(Z,Z+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")J.paren++;else if(G===")"){if(J.paren--,J.paren<0)break}else if(G==="[")J.bracket++;else if(G==="]"){if(J.bracket--,J.bracket<0)break}else if(G==="{")J.brace++;else if(G==="}"){if(J.brace--,J.brace<0)break}Z++}return{expression:$.slice(X,Z),endPos:Z}}function e9($){let X=[],Z="",J={paren:0,bracket:0,brace:0},Y=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&Y){Z+=K;continue}if((K==='"'||K==="'")&&!Y){Y=K,Z+=K;continue}if(K===Y&&Y!=="`"){Y=null,Z+=K;continue}if(K==="`"&&!Y){Y="`",Z+=K;continue}if(K==="`"&&Y==="`"&&Q===0){Y=null,Z+=K;continue}if(Y==="`"&&K==="$"&&$[G+1]==="{"){Q++,Z+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Z+=K;continue}if(Q>0&&K==="}"){Q--,Z+=K;continue}if(Y){Z+=K;continue}if(K==="(")J.paren++;else if(K===")")J.paren--;else if(K==="[")J.bracket++;else if(K==="]")J.bracket--;else if(K==="{")J.brace++;else if(K==="}")J.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&J.paren===0&&J.bracket===0&&J.brace===0){X.push(Z.trim()),Z="";continue}if(K==="|"&&$[G-1]==="\\"&&!Y){Z=Z.slice(0,-1)+K;continue}Z+=K}if(Z.trim())X.push(Z.trim());return X}function K4($,X){let Z=fg($,X);return Z.ok?{expression:Z.expression,endPos:Z.endPos}:null}function fg($,X){let Z=X;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Z};let J=X1($,"(",")",Z);if(J===-1)return{ok:!1,reason:"unclosed-paren",pos:Z};return{ok:!0,expression:$.slice(Z+1,J),endPos:J+1}}function gg($,X){let Z=$.lastIndexOf("<",X);if(Z===-1)return!1;return Z>$.lastIndexOf(">",X)}function c4($,X,Z,J){let Y=1,Q=J,G=new RegExp(`@${X}\\s*\\(`,"g"),K=new RegExp(`@${Z}(?![a-z])`,"g");while(Q<$.length&&Y>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),z=W?W.index:1/0,q=U?U.index:1/0;if(z<q)Y++,Q=z+W[0].length;else if(q<1/0){if(Y--,Y===0)return q;Q=q+U[0].length}else break}return-1}function oG($,X){let Z=$.slice(X).match(/^@if\s*/);if(!Z)return null;let J=X+Z[0].length,Y=K4($,J);if(!Y)return null;let Q=Y.endPos,G=c4($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,z="if",q=Y.expression,j=0,_=0;while(U<K.length){let H=K.indexOf("@",U);if(H===-1)break;U=H;let L=K.substring(H);if(gg(K,H)){U++;continue}if(/^@if\s*\(/.test(L)){_++,U++;continue}if(/^@endif(?![a-z])/.test(L)){_--,U+=6;continue}if(_===0){let O=L.match(/^@elseif\s*/);if(O){W.push({type:z,condition:q,content:K.substring(j,U),start:Q+j,end:Q+U});let B=U+O[0].length,F=K4(K,B);if(!F){U++;continue}z="elseif",q=F.expression,U=F.endPos,j=U;continue}else if(/^@else(?![a-z])/.test(L)){W.push({type:z,condition:q,content:K.substring(j,U),start:Q+j,end:Q+U}),z="else",q=void 0,U+=5,j=U;continue}}U++}return W.push({type:z,condition:q,content:K.slice(j),start:Q+j,end:Q+K.length}),{fullMatch:$.slice(X,G+6),branches:W,start:X,end:G+6}}function Z5($){let X=[],Z=/@if\s*\(/g,J=Z.exec($);while(J!==null){if(X.some((G)=>J.index>G.start&&J.index<G.end)){J=Z.exec($);continue}let Q=oG($,J.index);if(Q)X.push(Q),Z.lastIndex=Q.end;J=Z.exec($)}return X}function y3($,X,Z){let J=[],Y=new RegExp(`@${X}\\s*\\(`,"g"),Q=Y.exec($);while(Q!==null){if(J.some((L)=>Q.index>L.start&&Q.index<L.end)){Q=Y.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=X1($,"(",")",W);if(U===-1){Q=Y.exec($);continue}let z=$.slice(W+1,U),q=U+1,j=c4($,X,Z,q);if(j===-1){Q=Y.exec($);continue}let _=$.slice(q,j),H=j+`@${Z}`.length;J.push({fullMatch:$.slice(K,H),name:X,params:z,content:_,start:K,end:H}),Y.lastIndex=H,Q=Y.exec($)}return J}function $2($,X){let Z=$.slice(X).match(/^@switch\s*/);if(!Z)return null;let J=X+Z[0].length,Y=K4($,J);if(!Y)return null;let Q=Y.endPos,G=c4($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,z=null,q=0;while(U<K.length){let j=K.slice(U),_=j.match(/^@switch\s*\(/),H=j.match(/^@endswitch(?![a-z])/);if(_){if(q++,z)z.content+=_[0];U+=_[0].length;continue}if(H){if(q--,z)z.content+=H[0];U+=H[0].length;continue}if(q>0){if(z)z.content+=K[U];U++;continue}let L=j.match(/^@case\s*/),O=j.match(/^@default(?![a-z])/),B=j.match(/^@break(?![a-z])/);if(L&&j.startsWith("@case")){if(z)W.push(z);let F=U+L[0].length,V=K4(K,F);if(!V){U++;continue}z={type:"case",value:V.expression,content:""},U=V.endPos}else if(O&&j.startsWith("@default")){if(z)W.push(z);z={type:"default",content:""},U+=O[0].length}else if(B&&j.startsWith("@break"))U+=B[0].length;else{if(z)z.content+=K[U];U++}}if(z)W.push(z);return{fullMatch:$.slice(X,G+10),expression:Y.expression,cases:W,start:X,end:G+10}}var bB=()=>{};function vB($){let X=[],Z=0;while(Z<$.length){let J=$.indexOf("{{",Z),Y=$.indexOf("{!!",Z),Q=!1,G;if(J===-1&&Y===-1)break;else if(J===-1)G=Y,Q=!0;else if(Y===-1)G=J,Q=!1;else if(Y<J)G=Y,Q=!0;else G=J,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,z=hg($,U,W);if(z===-1){Z=G+1;continue}let q=$.slice(U,z).trim(),j=z+W.length;X.push({fullMatch:$.slice(G,j),expression:q,start:G,end:j,isRaw:Q}),Z=j}return X}function hg($,X,Z){let J=X,Y=null,Q={paren:0,bracket:0,brace:0},G=0;while(J<$.length){let K=$[J];if((J>0?$[J-1]:"")==="\\"&&Y){J++;continue}if((K==='"'||K==="'")&&!Y){Y=K,J++;continue}if(K===Y&&Y!=="`"){Y=null,J++;continue}if(K==="`"&&!Y){Y="`",J++;continue}if(K==="`"&&Y==="`"&&G===0){Y=null,J++;continue}if(Y==="`"&&K==="$"&&$[J+1]==="{"){G++,J+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;J++;continue}if(Y){J++;continue}if(K==="(")Q.paren++;else if(K===")")Q.paren--;else if(K==="[")Q.bracket++;else if(K==="]")Q.bracket--;else if(K==="{")Q.brace++;else if(K==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(J,J+Z.length)===Z)return J}J++}return-1}function fB($){let X=e9($);if(X.length===0)return{baseExpression:"",filters:[]};let Z=X[0],J=[];for(let Y=1;Y<X.length;Y++){let Q=ug(X[Y]);if(Q)J.push(Q)}return{baseExpression:Z,filters:J}}function ug($){let X=$.trim();if(!X)return null;let Z=X.indexOf("(");if(Z===-1)return{name:X,args:[]};let J=X.slice(0,Z).trim(),Y=Z+1,Q=X1(X,"(",")",Z);if(Q===-1)return{name:J,args:[]};let G=X.slice(Y,Q),K=tG(G);return{name:J,args:K}}function tG($){let X=[],Z="",J={paren:0,bracket:0,brace:0},Y=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&Y){Z+=K;continue}if((K==='"'||K==="'")&&!Y){Y=K,Z+=K;continue}if(K===Y&&Y!=="`"){Y=null,Z+=K;continue}if(K==="`"&&!Y){Y="`",Z+=K;continue}if(K==="`"&&Y==="`"&&Q===0){Y=null,Z+=K;continue}if(Y==="`"&&K==="$"&&$[G+1]==="{"){Q++,Z+="${",G++;continue}if(Q>0&&K==="{"){Q++,Z+=K;continue}if(Q>0&&K==="}"){Q--,Z+=K;continue}if(Y){Z+=K;continue}if(K==="(")J.paren++;else if(K===")")J.paren--;else if(K==="[")J.bracket++;else if(K==="]")J.bracket--;else if(K==="{")J.brace++;else if(K==="}")J.brace--;if(K===","&&J.paren===0&&J.bracket===0&&J.brace===0){X.push(Z.trim()),Z="";continue}Z+=K}if(Z.trim())X.push(Z.trim());return X}function gB($,X){let Z=X;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;let J=X1($,"(",")",Z);if(J===-1)return null;return{params:$.slice(Z+1,J),endPos:J+1}}function hB($){let X=[],J=new b3($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),Y=0;while(Y<J.length){let Q=J[Y],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,Y++,Y>=J.length)break}let K=J[Y];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(Y++,Y>=J.length)break;let U=J[Y];if(U.type==="IDENTIFIER"){let z=U.value;if(Y++,Y<J.length&&J[Y].type==="OPERATOR"&&J[Y].value==="="){Y++;let q=Y<J.length?J[Y].start:$.length,j=yB(J,Y,$);Y=j.nextIndex,X.push({type:"variable",name:z,value:$.slice(q,j.endPos),exported:G,start:K.start,end:j.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let z=U.start,q=U.value==="{"?"}":"]",j=X1($,U.value,q,z);if(j!==-1){let _=$.slice(z,j+1);if(Y=xB(J,j+1),Y<J.length&&J[Y].type==="OPERATOR"&&J[Y].value==="="){Y++;let H=Y<J.length?J[Y].start:$.length,L=yB(J,Y,$);Y=L.nextIndex;let O=`__stx_destructured_${X.length}`;X.push({type:"variable",name:O,value:`${$.slice(H,L.endPos)}; ${W} ${_} = ${O}`,exported:G,start:K.start,end:L.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?J[Y-1].start:K.start;if(Y++,Y>=J.length)break;let U=J[Y];if(U.type==="IDENTIFIER"){let z=U.value;Y++;let q=-1;while(Y<J.length){if(J[Y].type==="PUNCTUATION"&&J[Y].value==="{"){q=J[Y].start;break}Y++}if(q!==-1){let j=X1($,"{","}",q);if(j!==-1)X.push({type:"function",name:z,value:$.slice(W,j+1).replace(/^export\s+/,""),exported:G,start:W,end:j+1}),Y=xB(J,j+1)}}}else Y++}return X}function yB($,X,Z){let J=X,Y={paren:0,bracket:0,brace:0},Q=X<$.length?$[X].start:Z.length;while(J<$.length){let G=$[J];if(G.type==="PUNCTUATION"){if(G.value==="(")Y.paren++;else if(G.value===")")Y.paren--;else if(G.value==="[")Y.bracket++;else if(G.value==="]")Y.bracket--;else if(G.value==="{")Y.brace++;else if(G.value==="}")Y.brace--;if(G.value===";"&&Y.paren===0&&Y.bracket===0&&Y.brace===0){Q=G.start,J++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(Y.paren===0&&Y.bracket===0&&Y.brace===0){Q=$[J-1]?.end??G.start;break}}Q=G.end,J++}return{nextIndex:J,endPos:Q}}function xB($,X){for(let Z=0;Z<$.length;Z++)if($[Z].start>=X)return Z;return $.length}var uB=()=>{};var x3=T(()=>{bB();uB()});function mg($,X,Z){let J=$,Y=!0;while(Y){Y=!1;let Q=J.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=$2(J,G);if(!K)break;try{let W;if(m0(K.expression))W=d0(K.expression,Object.keys(X))(...Object.values(X));else W=x0(K.expression,X);let U="",z=!1;for(let q of K.cases)if(q.type==="default"){if(!z)U=q.content.trim()}else try{let j;if(q.value&&m0(q.value))j=d0(q.value,Object.keys(X))(...Object.values(X));else if(q.value)j=x0(q.value,X);if(W===j){U=q.content.trim(),z=!0;break}}catch{continue}J=J.substring(0,G)+U+J.substring(K.end),Y=!0}catch(W){let U=W instanceof Error?W.message:String(W),z=T0("Switch",`Error evaluating @switch expression: ${U}`,_0.EVALUATION_ERROR);J=J.substring(0,G)+z+J.substring(K.end);break}}return J}function dg($){let X=[];return{masked:$.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(J)=>{return X.push(J),`\x00stx-script-${X.length-1}\x00`}),scripts:X}}function cg($,X){if(X.length===0)return $;return $.replace(/\u0000stx-script-(\d+)\u0000/g,(Z,J)=>X[Number(J)]??Z)}function W4($,X,Z){let{masked:J,scripts:Y}=dg($);return cg(lg(J,X,Z),Y)}function lg($,X,Z){let J=$;J=mg(J,X,Z);{let Q=!0;while(Q){Q=!1;let G=J.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K4(J,K+7);if(!W)break;let U=W.endPos,z=c4(J,"unless","endunless",U);if(z===-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 q=J.slice(U,z),j=W.expression,_=-1;{let L=0,O=/@(?:if|unless)\s*\(/g,B=/@(?:endif|endunless)(?![a-z])/g,F=/@else(?![a-z])/g,V=[],w;while((w=O.exec(q))!==null)V.push({pos:w.index,type:"open"});while((w=B.exec(q))!==null)V.push({pos:w.index,type:"close"});while((w=F.exec(q))!==null)V.push({pos:w.index,type:"else"});V.sort((A,R)=>A.pos-R.pos);for(let A of V)if(A.type==="open")L++;else if(A.type==="close")L--;else if(A.type==="else"&&L===0){_=A.pos;break}}let H;if(_!==-1){let L=q.slice(0,_),O=q.slice(_+5);H=`@if (${j})${O}@else ${L}@endif`}else H=`@if (!(${j}))${q}@endif`;J=J.substring(0,K)+H+J.substring(z+10),Q=!0}}J=$K(J,X,Z),J=XK(J,X,Z),J=eG(J,X);let Y=()=>{let Q=Z5(J);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let z of K.branches){if(U)break;if(z.type==="else")W=z.content,U=!0;else try{let q;if(z.condition&&m0(z.condition))q=d0(z.condition,Object.keys(X))(...Object.values(X));else if(z.condition)q=x0(z.condition,X);if(q)W=z.content,U=!0}catch(q){W=T0(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${q instanceof Error?q.message:String(q)}`,_0.EVALUATION_ERROR),U=!0}}J=J.substring(0,K.start)+W+J.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),z=T0("If",`Error processing @if block: ${U}`,_0.EVALUATION_ERROR);J=J.substring(0,K.start)+z+J.substring(K.end)}}return!0};while(!0){let Q=J;if(!Y())break;if(J===Q)break}return J}function mB($){let X=0;while(X<$.length&&/\s/.test($[X]))X++;if($[X]!=="(")return null;X++;while(X<$.length&&/\s/.test($[X]))X++;let Z=$[X];if(Z!=="'"&&Z!=='"')return null;X++;let J=[];while(X<$.length){let Y=$[X];if(Y==="\\"&&X+1<$.length){J.push($[X+1]),X+=2;continue}if(Y===Z){X++;break}J.push(Y),X++}while(X<$.length&&/\s/.test($[X]))X++;if($[X]!==")")return null;return X++,{value:J.join(""),consumed:X}}function eG($,X){let Z=$;function J(K,W,U,z){let q=1,j=z,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),H=new RegExp(`@${U}(?![a-z])`,"g");while(j<K.length&&q>0){_.lastIndex=j,H.lastIndex=j;let L=_.exec(K),O=H.exec(K),B=L?L.index:1/0,F=O?O.index:1/0;if(B<F)q++,j=B+L[0].length;else if(F<1/0){if(q--,q===0)return F;j=F+O[0].length}else break}return-1}function Y(K,W,U){let z=0,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g"),_=/@else(?![a-z])/g,H=[],L;while((L=q.exec(K))!==null)H.push({pos:L.index,type:"open"});while((L=j.exec(K))!==null)H.push({pos:L.index,type:"close"});while((L=_.exec(K))!==null)H.push({pos:L.index,type:"else"});H.sort((O,B)=>O.pos-B.pos);for(let O of H)if(O.type==="open")z++;else if(O.type==="close")z--;else if(O.type==="else"&&z===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Z.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,z,q,j=Z.slice(U+5),_=mB(j);if(_)z=_.value,q=U+5+_.consumed;else q=U+5;let H=J(Z,"auth","endauth",q);if(H===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let L=Z.slice(q,H),O=Y(L,"auth","endauth"),B;if(!X.auth)B=!1;else B=z?G4(`auth?.check && auth?.user?.[${z}]`,X):G4("auth?.check",X);let F;if(O!==-1){let V=L.slice(0,O),w=L.slice(O+5);F=B?V:w}else F=B?L:"";Z=Z.substring(0,U)+F+Z.substring(H+8),K=!0}}{let K=!0;while(K){K=!1;let W=Z.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,z,q,j=Z.slice(U+6),_=mB(j);if(_)z=_.value,q=U+6+_.consumed;else q=U+6;let H=J(Z,"guest","endguest",q);if(H===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let L=Z.slice(q,H),O=Y(L,"guest","endguest"),B;if(!X.auth)B=!0;else B=z?G4(`!auth?.check || !auth?.user?.[${z}]`,X):G4("!auth?.check",X);let F;if(O!==-1){let V=L.slice(0,O),w=L.slice(O+5);F=B?V:w}else F=B?L:"";Z=Z.substring(0,U)+F+Z.substring(H+9),K=!0}}function Q(K,W,U){if(X.userCan&&typeof X.userCan[K]==="boolean")return X.userCan[K];if(X.permissions?.check&&typeof X.permissions.check==="function")try{let z=[K];if(W)z.push(W);if(U){let q=G4(U,X);z.push(q)}return X.permissions.check(...z)}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}`,U=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let q=Z.match(new RegExp(`@${K}\\s*\\(`));if(!q||q.index===void 0)break;let j=q.index,_=Z.slice(j+`@${K}`.length),H=G(_);if(!H)break;let L=j+`@${K}`.length+H.paramsEnd,O=J(Z,K,W,L);if(O===-1){console.warn(`[stx] @${K} directive at position ${j} has no matching @${W} \u2014 the block was skipped.`);break}let B=Z.slice(L,O),F=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),R=new RegExp(`@${U}\\s*\\(`,"g"),M=/@else(?![a-z])/g,I=[],N;while((N=w.exec(B))!==null)I.push({pos:N.index,type:"open"});while((N=A.exec(B))!==null)I.push({pos:N.index,type:"close"});while((N=R.exec(B))!==null)I.push({pos:N.index,type:"elseDirective"});while((N=M.exec(B))!==null)I.push({pos:N.index,type:"else"});I.sort((b,u)=>b.pos-u.pos);for(let b of I){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)F.push(b)}let E=[],C=0;for(let b=0;b<F.length;b++){let u=F[b];if(E.push({content:B.slice(C,u.pos),ability:void 0}),u.type==="elseDirective"){let i=B.slice(u.pos+`@${U}`.length),c=G(i);if(c){E[E.length-1]={content:B.slice(C,u.pos)},C=u.pos+`@${U}`.length+c.paramsEnd,E.push({content:"",ability:c.ability,type:c.type,id:c.id}),E.pop();let P=F[b+1],v=P?P.pos:B.length;E.push({content:B.slice(C,v),ability:c.ability,type:c.type,id:c.id}),C=v}}else C=u.pos+5}if(C<B.length){let b=E[E.length-1];if(F.length>0&&F[F.length-1].type==="else")E.push({content:B.slice(C),isFinalElse:!0});else if(E.length===0)E.push({content:B.slice(C)})}let S=Q(H.ability,H.type,H.id),x=K==="can"?S:!S,y="";if(x)y=E[0]?.content||"";else{let b=!1;for(let u=1;u<E.length;u++){let i=E[u];if(i.isFinalElse){y=i.content,b=!0;break}if(i.ability){let c=Q(i.ability,i.type,i.id);if(K==="can"?c:!c){y=i.content,b=!0;break}}}if(!b&&E.length>0){let u=E[E.length-1];if(u.isFinalElse)y=u.content}}Z=Z.substring(0,j)+y+Z.substring(O+`@${W}`.length),z=!0}}return Z}function $K($,X,Z){let J=$;function Y(Q,G,K,W,U){let z=!0;while(z){z=!1;let q=new RegExp(`@${G}\\s*\\(`),j=Q.match(q);if(!j||j.index===void 0)break;let _=j.index,H=K4(Q,_+`@${G}`.length);if(!H)break;let L=H.endPos,O=c4(Q,G,K,L);if(O===-1){console.warn(`[stx] @${G} directive at position ${_} has no matching @${K} \u2014 the block was skipped.`);break}let B=Q.slice(L,O),F=H.expression,V=-1,w=0,A=0;while(A<B.length){let R=B.indexOf("@",A);if(R===-1)break;let M=B.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(M)){w++,A=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(M)){w--,A=R+1;continue}if(w===0&&/^@else(?![a-z])/.test(M)){V=R;break}A=R+1}try{let R=W(F.trim()),M;if(V!==-1){let I=B.slice(0,V),N=B.slice(V+5);M=R?I:N}else M=R?B:"";Q=Q.substring(0,_)+M+Q.substring(O+`@${K}`.length),z=!0}catch(R){let M=R instanceof Error?R.message:String(R),I=T0(U,`Error processing @${G} directive: ${M}`,_0.EVALUATION_ERROR);Q=Q.substring(0,_)+I+Q.substring(O+`@${K}`.length);break}}return Q}return J=Y(J,"isset","endisset",(Q)=>{let G=G4(Q,X);return G!==void 0&&G!==null},"Isset"),J=Y(J,"empty","endempty",(Q)=>{let G=G4(Q,X);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"),J}function XK($,X,Z){let J=$,Y="development";function Q(G,K,W,U){let z=new RegExp(`@${K}(?![a-z])`,"g"),q=new RegExp(`@${W}(?![a-z])`,"g"),j=new RegExp(`^@${K}(?![a-z])`),_=new RegExp(`^@${W}(?![a-z])`),H=G,L=!0;while(L){L=!1,z.lastIndex=0;let O=z.exec(H);if(!O)break;let B=O.index,F=B+O[0].length;if(K==="env"){let S=H.substring(F).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!S)break;F+=S[0].length,U=Y===S[2]}let V=1,w=F,A=-1;while(V>0&&w<H.length){z.lastIndex=w,q.lastIndex=w;let S=z.exec(H),x=q.exec(H),y=S?S.index:1/0,b=x?x.index:1/0;if(y<b)V++,w=y+S[0].length;else if(b<1/0){if(V--,V===0){A=b;break}w=b+x[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${W} \u2014 the block was skipped.`);break}let R=H.substring(F,A),M=-1,I=0,N=0;while(N<R.length){let S=R.indexOf("@",N);if(S===-1)break;let x=R.substring(S);if(j.test(x)){I++,N=S+1;continue}if(_.test(x)){I--,N=S+1;continue}if(I===0&&/^@else(?![a-z])/.test(x)){M=S;break}N=S+1}let E;if(M!==-1){let S=R.slice(0,M),x=R.slice(M+5);E=U?S:x}else E=U?R:"";let C=`@${W}`.length;H=H.substring(0,B)+E+H.substring(A+C),L=!0}return H}return J=Q(J,"env","endenv",!1),J=Q(J,"production","endproduction",Y==="production"),J=Q(J,"development","enddevelopment",Y==="development"),J=Q(J,"staging","endstaging",Y==="staging"),J=Q(J,"testing","endtesting",Y==="testing"),J}var v3=T(()=>{lG();a1();x3();j1()});function JK($=16){let X=new Uint8Array($);return crypto.getRandomValues(X),btoa(String.fromCharCode(...X))}function l4($,X){if(!$)return X?.nonceGenerator?.()??JK();let Z=ZK.get($);if(!Z)Z=X?.nonceGenerator?.()??JK(),ZK.set($,Z);return Z}function pg($){ZK.delete($)}function YK($,X){let Z=[];for(let[J,Y]of Object.entries($)){if(Y===void 0||Y===null)continue;if(typeof Y==="boolean"){if(Y)Z.push(J);continue}if(Array.isArray(Y)){let Q=[...Y];if(X&&(J==="script-src"||J==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${X}'`);if(Q.length>0)Z.push(`${J} ${Q.join(" ")}`)}}return Z.join("; ")}function Z2($,X){return`<meta http-equiv="Content-Security-Policy" content="${YK($,X).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function ig($){return{enabled:!0,directives:{strict:dB,moderate:X2,relaxed:cB,api:lB}[$]||X2,useNonce:$==="strict",addMetaTag:!0}}function ng($,X){let Z={...$};for(let[J,Y]of Object.entries(X)){let Q=J,G=Z[Q];if(Y===void 0||Y===null)continue;if(typeof Y==="boolean")Z[Q]=G||Y;else if(Array.isArray(Y)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...Y])];Z[Q]=W}}return Z}function QK($,X,Z){if(!X.enabled||!X.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let J=X.useNonce?l4(Z,X):void 0,Y=Z2(X.directives,J);return $.replace(/<head([^>]*)>/,`<head$1>
3536
3536
  ${Y}`)}function GK($,X){let Z=$;return Z=Z.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(J,Y)=>{if(Y.includes("nonce="))return J;return`<script nonce="${X}"${Y}>`}),Z=Z.replace(/<style([^>]*)>/gi,(J,Y)=>{if(Y.includes("nonce="))return J;return`<style nonce="${X}"${Y}>`}),Z}function KK($,X,Z,J){let Y=$,Q=J.csp;if(Y=Y.replace(/@csp\b/g,()=>{if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?l4(X,Q):void 0;return Z2(Q.directives,G)}),Y=Y.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return l4(X,Q)}),Q?.enabled&&Q.useNonce)X.cspNonce=l4(X,Q);return Y}function rg(){return[pB,iB]}function ag($){let X=[];if($["script-src"]?.includes("'unsafe-inline'"))X.push("CSP: Using unsafe-inline in script-src significantly reduces XSS protection");if($["script-src"]?.includes("'unsafe-eval'"))X.push("CSP: Using unsafe-eval in script-src allows eval() and related functions");if(!$["default-src"])X.push("CSP: No default-src specified. Recommend adding default-src as a fallback");if($["default-src"]?.includes("*"))X.push("CSP: Using * in default-src provides minimal protection");if(!$["object-src"]&&!$["default-src"]?.includes("'none'"))X.push("CSP: Consider adding object-src: none to block plugins");if(!$["base-uri"])X.push("CSP: Consider adding base-uri to prevent base tag injection attacks");for(let[Z,J]of Object.entries($))if(Array.isArray(J)&&J.includes("http:"))X.push(`CSP: Using http: in ${Z} allows insecure resources`);return X}function nB($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function sg($,X){if(!$.enabled)return{};let Z=$.useNonce?l4(X,$):void 0,J=YK($.directives,Z);return{[nB($.reportOnly)]:J}}var ZK,dB,X2,cB,lB,pB,iB,og;var WK=T(()=>{ZK=new WeakMap;dB={"default-src":["'self'"],"script-src":["'self'","'strict-dynamic'"],"style-src":["'self'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'none'"],"base-uri":["'self'"],"form-action":["'self'"],"frame-ancestors":["'self'"],"upgrade-insecure-requests":!0},X2={"default-src":["'self'"],"script-src":["'self'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'","https:"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"upgrade-insecure-requests":!0},cB={"default-src":["'self'"],"script-src":["'self'","'unsafe-inline'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:","http:"],"font-src":["'self'","https:","http:","data:"],"connect-src":["'self'","https:","http:","ws:","wss:"],"media-src":["'self'","https:","http:"],"object-src":["'none'"],"frame-src":["'self'","https:"],"base-uri":["'self'"]},lB={"default-src":["'none'"],"frame-ancestors":["'none'"]};pB={name:"csp",handler:($,X,Z,J)=>{let Q=Z.__stx_options?.csp;if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?l4(Z,Q):void 0;return Z2(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},iB={name:"cspNonce",handler:($,X,Z,J)=>{let Q=Z.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return l4(Z,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};og={enabled:!1,reportOnly:!1,directives:X2,useNonce:!1,addMetaTag:!0}});import tg from"crypto";function $h($=eg){let X=tg.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return UK=X,X}function Xh(){if(!UK)$h();return UK}function Zh($=rB){let X=Xh();return`<input type="hidden" name="${$}" value="${X}">`}function aB($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(X,Z,J)=>{return Zh(J||rB)})}var eg=40,rB="_token",UK=null;var sB=()=>{};async function zK($,X,Z,J){if(!J.customDirectives||J.customDirectives.length===0)return $;let Y=$;for(let Q of J.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(J.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)Y=await Jh(Y,Q,X,Z,J);else Y=await Yh(Y,Q,X,Z,J)}return Y}async function Jh($,X,Z,J,Y){let{name:Q,handler:G}=X,K=`@${Q}`,W=`@end${Q}`,U=$,z=r8(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),q=[],j=z.exec(U);while(j!==null){let[_,H="",L=""]=j,O=j.index||0;try{let B=H?oB(H):[],F=L.trim(),V=await G(F,B,Z,J);q.push({original:_,processed:V,startIndex:O})}catch(B){let F=B instanceof Error?B.message:String(B);if(Y.debug)console.error(`Error processing custom directive @${Q}:`,B);q.push({original:_,processed:T0("CustomDirective",`Error in @${Q}${H?`(${H})`:""}: ${F}`,_0.EVALUATION_ERROR),startIndex:O})}j=z.exec(U)}for(let _=q.length-1;_>=0;_--){let{original:H,processed:L}=q[_];U=U.replace(H,L)}return U}async function Yh($,X,Z,J,Y){let{name:Q,handler:G}=X,K=$,W=r8(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],z=W.exec(K);while(z!==null){let[_,H=""]=z,L=z.index||0;try{let O=oB(H),B=await G("",O,Z,J);U.push({original:_,processed:B,startIndex:L})}catch(O){let B=O instanceof Error?O.message:String(O);if(Y.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:_,processed:T0("CustomDirective",`Error in @${Q}(${H}): ${B}`,_0.EVALUATION_ERROR),startIndex:L})}z=W.exec(K)}let q=r8(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),j=q.exec(K);while(j!==null){let[_]=j,H=j.index||0;try{let L=await G("",[],Z,J);U.push({original:_,processed:L,startIndex:H})}catch(L){let O=L instanceof Error?L.message:String(L);if(Y.debug)console.error(`Error processing custom directive @${Q}:`,L);U.push({original:_,processed:T0("CustomDirective",`Error in @${Q}: ${O}`,_0.EVALUATION_ERROR),startIndex:H})}j=q.exec(K)}for(let _=U.length-1;_>=0;_--){let{original:H,processed:L}=U[_];K=K.replace(H,L)}return K}function oB($){if(!$.trim())return[];let X=[],Z="",J=!1,Y="";for(let Q=0;Q<$.length;Q++){let G=$[Q];if((G==='"'||G==="'")&&(Q===0||$[Q-1]!=="\\"))if(!J)J=!0,Y=G;else if(G===Y)J=!1;else Z+=G;else if(G===","&&!J)X.push(Z.trim()),Z="";else Z+=G}if(Z.trim())X.push(Z.trim());return X.map((Q)=>{let G=Q.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var qK=T(()=>{a1();h4()});function u6($,X){if(typeof $!=="string"||$.length===0)throw Error(`@appearanceBootstrap ${X} must be a non-empty string`)}function Gh($){if(!$||typeof $!=="object"||Array.isArray($))throw Error("@appearanceBootstrap expects an options object");let X=$,Z=X.appearance,J=X.colorMode;if(u6(X.storageKey,"storageKey"),!Z||typeof Z!=="object"||Array.isArray(Z))throw Error("@appearanceBootstrap appearance must be an object");if(!J||typeof J!=="object"||Array.isArray(J))throw Error("@appearanceBootstrap colorMode must be an object");if(u6(Z.key,"appearance.key"),u6(Z.attribute,"appearance.attribute"),u6(Z.default,"appearance.default"),u6(J.key,"colorMode.key"),u6(J.attribute,"colorMode.attribute"),u6(J.default,"colorMode.default"),!eB.test(Z.key)||!eB.test(J.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!tB.test(Z.attribute)||!tB.test(J.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(Z.allowed)||Z.allowed.length===0||Z.allowed.some((Y)=>typeof Y!=="string"||Y.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!Z.allowed.includes(Z.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");if(!Qh.has(J.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");return{storageKey:X.storageKey,appearance:{key:Z.key,attribute:Z.attribute,allowed:[...new Set(Z.allowed)],default:Z.default},colorMode:{key:J.key,attribute:J.attribute,default:J.default}}}function Kh($){return JSON.stringify($).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Wh($){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${Kh($)};const root=document.documentElement;let stored={};try{const raw=localStorage.getItem(config.storageKey);const parsed=raw?JSON.parse(raw):{};if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed))stored=parsed}catch{}const selectedAppearance=config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default;const selectedMode=["light","dark","system"].includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default;root.setAttribute("data-"+config.appearance.attribute,selectedAppearance);root.setAttribute("data-"+config.colorMode.attribute,selectedMode);let dark=selectedMode==="dark";if(selectedMode==="system"){try{dark=matchMedia("(prefers-color-scheme: dark)").matches}catch{dark=false}}root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light"}());</script>`}function Uh($,X){let Z=1,J=null,Y=!1;for(let Q=X+1;Q<$.length;Q++){let G=$[Q];if(Y){Y=!1;continue}if(J){if(G==="\\")Y=!0;else if(G===J)J=null;continue}if(G==='"'||G==="'"||G==="`"){J=G;continue}if(G==="(")Z++;else if(G===")"&&--Z===0)return Q}return-1}function jK($,X){let Z=$,J=/@appearanceBootstrap\s*\(/g,Y;while((Y=J.exec(Z))!==null){let Q=Y.index+Y[0].length-1,G=Uh(Z,Q);if(G===-1)throw Error("@appearanceBootstrap has an unclosed options object");let K=Z.slice(Q+1,G).trim(),W=x0(`(${K})`,X),U=Wh(Gh(W));Z=Z.slice(0,Y.index)+U+Z.slice(G+1),J.lastIndex=Y.index+U.length}return Z}var tB,eB,Qh;var _K=T(()=>{j1();tB=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,eB=/^[A-Za-z_$][\w$]*$/,Qh=new Set(["light","dark","system"])});var LK={};X0(LK,{useTitle:()=>JF,useSeoMeta:()=>HK,usePageTitle:()=>JF,useHead:()=>Q2,seoMetaToHeadConfig:()=>f3,resetHead:()=>XF,renderHtmlAttrs:()=>QF,renderHead:()=>YF,renderBodyAttrs:()=>GF,processTitleDirective:()=>UF,processMetaDirective:()=>zF,processHeadDirective:()=>WF,mergeHeadConfigs:()=>U4,getPageMeta:()=>$F,getHead:()=>Y2,definePageMeta:()=>ZF,applyHead:()=>KF});function Y2(){return p4}function $F(){return J2}function XF(){p4={},zh.length=0,J2={}}function Q2($){p4=U4(p4,$)}function U4($,X){return{title:X.title??$.title,titleTemplate:X.titleTemplate??$.titleTemplate,base:X.base??$.base,meta:[...$.meta||[],...X.meta||[]],link:[...$.link||[],...X.link||[]],script:[...$.script||[],...X.script||[]],style:[...$.style||[],...X.style||[]],htmlAttrs:{...$.htmlAttrs,...X.htmlAttrs},bodyAttrs:{...$.bodyAttrs,...X.bodyAttrs}}}function HK($){Q2(f3($))}function f3($){let X=[];if($.description)X.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;X.push({name:"keywords",content:W})}if($.author)X.push({name:"author",content:$.author});if($.robots)X.push({name:"robots",content:$.robots});let Z=$.ogTitle??$.title,J=$.ogDescription??$.description;if(Z)X.push({property:"og:title",content:Z});if(J)X.push({property:"og:description",content:J});if($.ogImage)X.push({property:"og:image",content:$.ogImage});if($.ogUrl)X.push({property:"og:url",content:$.ogUrl});if($.ogType)X.push({property:"og:type",content:$.ogType});if($.ogSiteName)X.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)X.push({property:"og:locale",content:$.ogLocale});let Y=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)X.push({name:"twitter:card",content:$.twitterCard});if(Y)X.push({name:"twitter:title",content:Y});if(Q)X.push({name:"twitter:description",content:Q});if(G)X.push({name:"twitter:image",content:G});if($.twitterSite)X.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)X.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)X.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)X.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)X.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)X.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)X.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});return{title:$.title,titleTemplate:$.titleTemplate,meta:X,link:K}}function ZF($){if(J2={...J2,...$},$.title||$.description)HK({title:$.title,description:$.description})}function JF($){let X=typeof $==="function"?$():$;Q2({title:X})}function YF($=p4){let X=[];if($.title){let Z=$.title;if($.titleTemplate)Z=typeof $.titleTemplate==="function"?$.titleTemplate(Z):$.titleTemplate.replace("%s",Z);X.push(`<title>${m6(Z)}</title>`)}if($.base){let Z=Object.entries($.base).map(([J,Y])=>`${J}="${m6(Y)}"`).join(" ");X.push(`<base ${Z}>`)}for(let Z of $.meta||[]){let J=Object.entries(Z).filter(([Y,Q])=>Q!==void 0).map(([Y,Q])=>{return`${Y==="httpEquiv"?"http-equiv":Y}="${m6(String(Q))}"`}).join(" ");X.push(`<meta ${J}>`)}for(let Z of $.link||[]){let J=Object.entries(Z).filter(([Y,Q])=>Q!==void 0).map(([Y,Q])=>`${Y}="${m6(String(Q))}"`).join(" ");X.push(`<link ${J}>`)}for(let Z of $.script||[]){let{content:J,...Y}=Z,Q=Object.entries(Y).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${m6(String(K))}"`}).filter(Boolean).join(" ");if(J)X.push(`<script ${Q}>${J}</script>`);else X.push(`<script ${Q}></script>`)}for(let Z of $.style||[]){let J=Z.type?` type="${Z.type}"`:"";X.push(`<style${J}>${Z.content}</style>`)}return X.join(`
3537
3537
  `)}function QF($=p4){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([X,Z])=>`${X}="${m6(Z)}"`).join(" ")}function GF($=p4){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([X,Z])=>`${X}="${m6(Z)}"`).join(" ")}function m6($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function KF($=p4){if(typeof document>"u")return;if($.title){let X=$.title;if($.titleTemplate)X=typeof $.titleTemplate==="function"?$.titleTemplate(X):$.titleTemplate.replace("%s",X);document.title=X}for(let X of $.meta||[]){let Z=X.name?`meta[name="${X.name}"]`:X.property?`meta[property="${X.property}"]`:null;if(Z){let J=document.querySelector(Z);if(!J){if(J=document.createElement("meta"),X.name)J.setAttribute("name",X.name);if(X.property)J.setAttribute("property",X.property);document.head.appendChild(J)}J.setAttribute("content",X.content)}}for(let X of $.link||[]){let Z=`link[rel="${X.rel}"]${X.href?`[href="${X.href}"]`:""}`,J=document.querySelector(Z);if(!J)J=document.createElement("link"),document.head.appendChild(J);for(let[Y,Q]of Object.entries(X))if(Q!==void 0)J.setAttribute(Y,String(Q))}if($.htmlAttrs)for(let[X,Z]of Object.entries($.htmlAttrs))if(X==="class")for(let J of String(Z).split(/\s+/).filter(Boolean))document.documentElement.classList.add(J);else document.documentElement.setAttribute(X,Z);if($.bodyAttrs)for(let[X,Z]of Object.entries($.bodyAttrs))document.body.setAttribute(X,Z)}function WF($){let X="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(J,Y)=>{return X+=Y.trim()+`
3538
3538
  `,""}),headContent:X.trim()}}function UF($,X){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Z,J,Y,Q)=>{let G=J?Y:X[(Q||"").trim()]??Q,K=X.__stx_runtime_head??{};return X.__stx_runtime_head=U4(K,{title:G}),""})}function zF($,X){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Z,J,Y,Q,G,K)=>{let W=Q?G:K,U=Q?W:X[(W||"").trim()]??W,q=Y.includes(":")?{property:Y,content:U}:{name:Y,content:U},j=X.__stx_runtime_head??{};return X.__stx_runtime_head=U4(j,{meta:[q]}),""})}var p4,zh,J2;var d6=T(()=>{p4={},zh=[],J2={}});import qh from"crypto";function K1($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function jh($){return{...K2,...$.forms?.classes}}function G2($,X,Z,J){let Y=$||X;return Z?`${Y} ${J}`:Y}function Q$($){return String($).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function J5($,X){if(/\bid\s*=/i.test($))return"";return` id="${K1(X)}"`}function OK($,X,Z){if(!X)return"";let J="";if(!/\baria-invalid\s*=/i.test(Z))J+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(Z))J+=` aria-describedby="${K1(`${Q$($)}-error`)}"`;return J}function _h(){return qh.randomUUID()}function Hh($,X,Z,J){let Y=jh(J),Q=$;return Q=HF(Q,X),Q=Y5(Q,X),Q=W2(Q,X,Y),Q=U2(Q,X,Y),Q}function Y5($,X){let Z=$;return Z=Z.replace(/@csrf/g,()=>{if(!X.csrf||typeof X.csrf!=="object"){let J=_h();X.csrf={token:J}}if(X.csrf.field)return X.csrf.field;if(X.csrf.token)return`<input type="hidden" name="_token" value="${K1(X.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Z=Z.replace(/@method\(['"]([^'"]+)['"]\)/g,(J,Y)=>{let Q=Y.toUpperCase();if(Y&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${K1(Q)}">`;return J}),Z}function W2($,X,Z=K2){let J=$;return J=J.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(Y,Q,G,K,W,U="")=>{let z=Q||G||"POST",q=K||W||"",j=i4(U),_=z.toUpperCase(),H=["GET","POST"].includes(_)?_:"POST",L=`<form method="${K1(H)}" action="${K1(q)}"${j?` ${j}`:""}>`;if(L+=`
@@ -3782,12 +3782,12 @@ else {
3782
3782
  ${W?`{${W}}`:"{}"}
3783
3783
  </script>
3784
3784
  </div>`}}});var fF={};X0(fF,{warnUnbalancedTags:()=>SK,findUnbalancedTags:()=>vF});function G5($){return $.replace(/[^\n]/g," ")}function vF($){let X=$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,G5).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,G5).replace(/<!--[\s\S]*?-->/g,G5).replace(/\{\{\{[\s\S]*?\}\}\}/g,G5).replace(/\{\{[\s\S]*?\}\}/g,G5).replace(/\{!![\s\S]*?!!\}/g,G5),Z=new Map,J=new Map,Y=/<(\/?)([A-Za-z][\w-]*)\b(?:[^>"']|"[^"]*"|'[^']*')*?(\/?)>/g,Q;while((Q=Y.exec(X))!==null){let K=Q[1]==="/",W=Q[2],U=Q[3]==="/";if(Xu.has(W.toLowerCase()))continue;if(U)continue;if(K)J.set(W,(J.get(W)??0)+1);else{let z=Z.get(W);if(z)z.count++;else{let q=X.slice(0,Q.index).split(`
3785
- `).length;Z.set(W,{count:1,firstLine:q})}}}let G=[];for(let K of new Set([...Z.keys(),...J.keys()])){if(Zu.has(K.toLowerCase()))continue;let W=Z.get(K)?.count??0,U=J.get(K)??0;if(W!==U)G.push({tag:K,opened:W,closed:U,firstOpenLine:Z.get(K)?.firstLine??0})}return G}function SK($,X){let Z;try{Z=vF($)}catch{return}if(Z.length===0)return;let J=`${X}:${$.length}`;if(xF.has(J))return;xF.add(J);let Y=X?X.split(/[/\\]/).pop()||X:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:W}of Z)if(G>K){let U=W?` (first opened at line ${W})`:"";console.warn(`[stx] ${Y}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${U} may swallow the content that follows it.`)}else console.warn(`[stx] ${Y}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var Xu,Zu,xF;var CK=T(()=>{Xu=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Zu=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);xF=new Set});import G$ from"path";import PK from"fs";function gF($){return $.split("-").map((X)=>X.charAt(0).toUpperCase()+X.slice(1)).join("")}function hF($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class uF{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let X of $.aliases)this.builtins.set(X.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,X,Z,J){let Y=$.endsWith(".stx")?$.slice(0,-4):$,Q=J?.__importedComponents;if(Q){let _=[Y,Y.toLowerCase(),gF(Y),hF(Y)];for(let H of _)if(Q.has(H))return Q.get(H)}let G=[...new Set([`${Y}.stx`,`${gF(Y)}.stx`,`${hF(Y)}.stx`])];if(Y.startsWith("./")||Y.startsWith("../")){let _=G$.resolve(G$.dirname(X),`${Y}.stx`);if(await H0(_))return _;return null}let K=[],W=Z.componentsDir||"",U=J?.__originalFilePath;if(U)K.push(G$.join(G$.dirname(U),"components"));if(W)K.push(W);let z=G$.join(G$.dirname(X),"components");if(!K.includes(z))K.push(z);let q=process.cwd(),j=[G$.resolve(q,"src/components"),G$.resolve(q,"components"),G$.resolve(import.meta.dir,"components")];for(let _ of j)if(!K.includes(_))K.push(_);for(let _ of K){if(!_)continue;for(let H of G){let L=G$.join(_,H);if(await H0(L))return L}try{if(!PK.statSync(_,{throwIfNoEntry:!1})?.isDirectory())continue;let L=PK.readdirSync(_,{withFileTypes:!0});for(let O of L)if(O.isDirectory()){let B=G$.join(_,O.name);for(let F of G){let V=G$.join(B,F);if(await H0(V))return V}}}catch{}}return null}}var d1;var bK=T(()=>{b0();d1=new uF});function _1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function yK($){return $.indexOf("\x00")===-1?$:$.replace(/\0/g,"")}var p6="\x00stx-boolean-attribute";function K5($,X){let Z=[];for(let[J,Y]of Object.entries($.static)){if(X.has(J))continue;let Q=$.staticNames?.[J]??J;if(typeof Y==="boolean"){if(Y)Z.push(_1(Q));continue}if(Y===p6){Z.push(_1(Q));continue}Z.push(`${_1(Q)}="${_1(yK(String(Y)))}"`)}return Z}function W5($,X){let Z=[];for(let[J,Y]of Object.entries($.serverDynamic??{})){if(X.has(J))continue;if(Y===null||Y===void 0||Y===!1)continue;let Q=$.serverDynamicNames?.[J]??J;if(Y===!0){Z.push(_1(Q));continue}if(typeof Y==="object")continue;Z.push(`${_1(Q)}="${_1(yK(String(Y)))}"`)}return Z}var H2=()=>{};function c3($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ju($){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 xK;var vK=T(()=>{H2();xK={name:"StxLink",aliases:["stx-link"],render($,X,Z){let J=Ju($),Y=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),Q=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(J.reactive)W.push(`:href="${c3(J.value)}"`);else W.push(`href="${c3(J.value)}"`);if(Y)W.push(`class="${c3(Y)}"`);if(W.push("data-stx-link"),W.push(`data-stx-active-class="${c3(Q)}"`),W.push(`data-stx-exact-active-class="${c3(G)}"`),K)W.push("data-stx-prefetch");let U=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);return W.push(...K5($,U)),W.push(...W5($,U)),`<a ${W.join(" ")}>${X}</a>`}}});function I1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function b1($,X){if($.serverDynamic[X]!==void 0)return String($.serverDynamic[X]);let Z=$.static[X];if(typeof Z==="string")return Z;return}function gK($,X,Z=!1){let J=$.serverDynamic[X];if(J!==void 0)return J!==!1&&J!=="false";let Y=$.static[X];if(Y!==void 0)return Y!=="false"&&Y!==!1;return Z}function mF($){if($.includes("(")||$.includes(","))return $;let X=$.trim().split(/\s+/),Z=[];for(let J of X)if(J.includes(":")){let[Y,Q]=J.split(":"),G=Yu[Y];if(G)Z.push(`(max-width: ${G}px) ${Q}`);else{let K=Number.parseInt(Y);if(!Number.isNaN(K))Z.push(`(max-width: ${K}px) ${Q}`)}}else Z.push(J);return Z.join(", ")}function hK($,X,Z,J){return X.map((Y)=>`${l3($,Y,void 0,Z,J)} ${Y}w`).join(", ")}function Qu($,X,Z,J,Y){return X.map((Q)=>{let G=Z?Z*Q:void 0;return`${l3($,G,void 0,J,Y)} ${Q}x`}).join(", ")}function l3($,X,Z,J,Y){if(!J||J==="local"||J==="static")return $;if(J==="cloudinary"){let Q=[];if(X)Q.push(`w_${X}`);if(Z)Q.push(`h_${Z}`);if(Y)Q.push(`f_${Y}`);Q.push("q_auto");let G=Q.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(J==="imgix"){let Q=new URLSearchParams;if(X)Q.set("w",String(X));if(Z)Q.set("h",String(Z));if(Y)Q.set("fm",Y);Q.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}if(J==="bunny"){let Q=new URLSearchParams;if(X)Q.set("width",String(X));if(Z)Q.set("height",String(Z));if(Y)Q.set("format",Y);let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}return $}function Gu($,X,Z="#e5e7eb"){let J=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${X}"><rect width="100%" height="100%" fill="${Z}"/></svg>`;return`data:image/svg+xml;base64,${btoa(J)}`}var Yu,fK,uK;var mK=T(()=>{H2();Yu={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},fK=[320,640,768,1024,1280,1536,1920];uK={name:"StxImage",aliases:["stx-image","stx-img"],render($,X,Z){let J=b1($,"src")||"",Y=b1($,"alt")||"",Q=b1($,"width"),G=b1($,"height"),K=b1($,"sizes"),W=b1($,"srcset"),U=b1($,"densities"),z=b1($,"format"),q=b1($,"placeholder"),j=b1($,"placeholderColor")||"#e5e7eb",_=b1($,"provider"),H=b1($,"class")||b1($,"className")||"",L=b1($,"style")||"",O=b1($,"quality"),B=gK($,"lazy",!0),F=gK($,"preload",!1),V=gK($,"picture",!1)||!!z,w=Q?Number.parseInt(Q):void 0,A=G?Number.parseInt(G):void 0,R=W||"",M="";if(!R&&K)R=hK(J,fK,_,z),M=mF(K);else if(!R&&U){let x=U.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));R=Qu(J,x,w,_,z)}else if(K)M=mF(K);let I=[];if(L)I.push(L);if(w&&A)I.push(`aspect-ratio:${w}/${A}`);if(q==="blur"||q==="color"||q==="thumbhash"){let x=Gu(w||16,A||9,j);I.push(`background-image:url(${x})`),I.push("background-size:cover"),I.push("background-repeat:no-repeat")}else if(q&&q!=="empty"&&q!=="none")I.push(`background-image:url(${I1(q)})`),I.push("background-size:cover"),I.push("background-repeat:no-repeat");let N=l3(J,w,A,_,z),E=[];if(E.push(`src="${I1(N)}"`),E.push(`alt="${I1(Y)}"`),Q)E.push(`width="${I1(Q)}"`);if(G)E.push(`height="${I1(G)}"`);if(B)E.push('loading="lazy"');if(E.push('decoding="async"'),H)E.push(`class="${I1(H)}"`);if(I.length>0)E.push(`style="${I1(I.join(";"))}"`);if(R)E.push(`srcset="${I1(R)}"`);if(M)E.push(`sizes="${I1(M)}"`);let C=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);E.push(...K5($,C)),E.push(...W5($,C));let S=`<img ${E.join(" ")} />`,y="";if(F){let b=z==="webp"?"image/webp":z==="avif"?"image/avif":"";y=`<link rel="preload" as="image" href="${I1(N)}"${b?` type="${b}"`:""}${R?` imagesrcset="${I1(R)}"`:""}${M?` imagesizes="${I1(M)}"`:""} />
3786
- `}if(V){let x=[];if(z==="avif"||z==="auto"){let b=l3(J,w,A,_,"avif"),u=R?hK(J,fK,_,"avif"):`${b}`;x.push(`<source type="image/avif" srcset="${I1(u)}"${M?` sizes="${I1(M)}"`:""} />`)}if(z==="webp"||z==="auto"){let b=l3(J,w,A,_,"webp"),u=R?hK(J,fK,_,"webp"):`${b}`;x.push(`<source type="image/webp" srcset="${I1(u)}"${M?` sizes="${I1(M)}"`:""} />`)}return`${y}<picture>
3787
- ${x.join(`
3785
+ `).length;Z.set(W,{count:1,firstLine:q})}}}let G=[];for(let K of new Set([...Z.keys(),...J.keys()])){if(Zu.has(K.toLowerCase()))continue;let W=Z.get(K)?.count??0,U=J.get(K)??0;if(W!==U)G.push({tag:K,opened:W,closed:U,firstOpenLine:Z.get(K)?.firstLine??0})}return G}function SK($,X){let Z;try{Z=vF($)}catch{return}if(Z.length===0)return;let J=`${X}:${$.length}`;if(xF.has(J))return;xF.add(J);let Y=X?X.split(/[/\\]/).pop()||X:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:W}of Z)if(G>K){let U=W?` (first opened at line ${W})`:"";console.warn(`[stx] ${Y}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${U} may swallow the content that follows it.`)}else console.warn(`[stx] ${Y}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var Xu,Zu,xF;var CK=T(()=>{Xu=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Zu=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);xF=new Set});import G$ from"path";import PK from"fs";function gF($){return $.split("-").map((X)=>X.charAt(0).toUpperCase()+X.slice(1)).join("")}function hF($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class uF{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let X of $.aliases)this.builtins.set(X.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,X,Z,J){let Y=$.endsWith(".stx")?$.slice(0,-4):$,Q=J?.__importedComponents;if(Q){let _=[Y,Y.toLowerCase(),gF(Y),hF(Y)];for(let H of _)if(Q.has(H))return Q.get(H)}let G=[...new Set([`${Y}.stx`,`${gF(Y)}.stx`,`${hF(Y)}.stx`])];if(Y.startsWith("./")||Y.startsWith("../")){let _=G$.resolve(G$.dirname(X),`${Y}.stx`);if(await H0(_))return _;return null}let K=[],W=Z.componentsDir||"",U=J?.__originalFilePath;if(U)K.push(G$.join(G$.dirname(U),"components"));if(W)K.push(W);let z=G$.join(G$.dirname(X),"components");if(!K.includes(z))K.push(z);let q=process.cwd(),j=[G$.resolve(q,"src/components"),G$.resolve(q,"components"),G$.resolve(import.meta.dir,"components")];for(let _ of j)if(!K.includes(_))K.push(_);for(let _ of K){if(!_)continue;for(let H of G){let L=G$.join(_,H);if(await H0(L))return L}try{if(!PK.statSync(_,{throwIfNoEntry:!1})?.isDirectory())continue;let L=PK.readdirSync(_,{withFileTypes:!0});for(let O of L)if(O.isDirectory()){let B=G$.join(_,O.name);for(let F of G){let V=G$.join(B,F);if(await H0(V))return V}}}catch{}}return null}}var d1;var bK=T(()=>{b0();d1=new uF});function _1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function yK($){return $.indexOf("\x00")===-1?$:$.replace(/\0/g,"")}var p6="\x00stx-boolean-attribute";function K5($,X){let Z=[];for(let[J,Y]of Object.entries($.static)){if(X.has(J))continue;let Q=$.staticNames?.[J]??J;if(typeof Y==="boolean"){if(Y)Z.push(_1(Q));continue}if(Y===p6){Z.push(_1(Q));continue}Z.push(`${_1(Q)}="${_1(yK(String(Y)))}"`)}return Z}function W5($,X){let Z=[];for(let[J,Y]of Object.entries($.serverDynamic??{})){if(X.has(J))continue;if(Y===null||Y===void 0||Y===!1)continue;let Q=$.serverDynamicNames?.[J]??J;if(Y===!0){Z.push(_1(Q));continue}if(typeof Y==="object")continue;Z.push(`${_1(Q)}="${_1(yK(String(Y)))}"`)}return Z}var H2=()=>{};function c3($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ju($){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 xK;var vK=T(()=>{H2();xK={name:"StxLink",aliases:["stx-link"],render($,X,Z){let J=Ju($),Y=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),Q=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(J.reactive)W.push(`:href="${c3(J.value)}"`);else W.push(`href="${c3(J.value)}"`);if(Y)W.push(`class="${c3(Y)}"`);if(W.push("data-stx-link"),W.push(`data-stx-active-class="${c3(Q)}"`),W.push(`data-stx-exact-active-class="${c3(G)}"`),K)W.push("data-stx-prefetch");let U=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);return W.push(...K5($,U)),W.push(...W5($,U)),`<a ${W.join(" ")}>${X}</a>`}}});function I1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function b1($,X){if($.serverDynamic[X]!==void 0)return String($.serverDynamic[X]);let Z=$.static[X];if(typeof Z==="string")return Z;return}function gK($,X,Z=!1){let J=$.serverDynamic[X];if(J!==void 0)return J!==!1&&J!=="false";let Y=$.static[X];if(Y!==void 0)return Y!=="false"&&Y!==!1;return Z}function mF($){if($.includes("(")||$.includes(","))return $;let X=$.trim().split(/\s+/),Z=[];for(let J of X)if(J.includes(":")){let[Y,Q]=J.split(":"),G=Yu[Y];if(G)Z.push(`(max-width: ${G}px) ${Q}`);else{let K=Number.parseInt(Y);if(!Number.isNaN(K))Z.push(`(max-width: ${K}px) ${Q}`)}}else Z.push(J);return Z.join(", ")}function hK($,X,Z,J){return X.map((Y)=>`${l3($,Y,void 0,Z,J)} ${Y}w`).join(", ")}function Qu($,X,Z,J,Y){return X.map((Q)=>{let G=Z?Z*Q:void 0;return`${l3($,G,void 0,J,Y)} ${Q}x`}).join(", ")}function l3($,X,Z,J,Y){if(!J||J==="local"||J==="static")return $;if(J==="cloudinary"){let Q=[];if(X)Q.push(`w_${X}`);if(Z)Q.push(`h_${Z}`);if(Y)Q.push(`f_${Y}`);Q.push("q_auto");let G=Q.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(J==="imgix"){let Q=new URLSearchParams;if(X)Q.set("w",String(X));if(Z)Q.set("h",String(Z));if(Y)Q.set("fm",Y);Q.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}if(J==="bunny"){let Q=new URLSearchParams;if(X)Q.set("width",String(X));if(Z)Q.set("height",String(Z));if(Y)Q.set("format",Y);let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}return $}function Gu($,X,Z="#e5e7eb"){let J=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${X}"><rect width="100%" height="100%" fill="${Z}"/></svg>`;return`data:image/svg+xml;base64,${btoa(J)}`}var Yu,fK,uK;var mK=T(()=>{H2();Yu={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},fK=[320,640,768,1024,1280,1536,1920];uK={name:"StxImage",aliases:["stx-image","stx-img"],render($,X,Z){let J=b1($,"src")||"",Y=b1($,"alt")||"",Q=b1($,"width"),G=b1($,"height"),K=b1($,"sizes"),W=b1($,"srcset"),U=b1($,"densities"),z=b1($,"format"),q=b1($,"placeholder"),j=b1($,"placeholderColor")||"#e5e7eb",_=b1($,"provider"),H=b1($,"class")||b1($,"className")||"",L=b1($,"style")||"",O=b1($,"quality"),B=gK($,"lazy",!0),F=gK($,"preload",!1),V=gK($,"picture",!1)||!!z,w=Q?Number.parseInt(Q):void 0,A=G?Number.parseInt(G):void 0,R=W||"",M="";if(!R&&K)R=hK(J,fK,_,z),M=mF(K);else if(!R&&U){let y=U.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));R=Qu(J,y,w,_,z)}else if(K)M=mF(K);let I=[];if(L)I.push(L);if(w&&A)I.push(`aspect-ratio:${w}/${A}`);if(q==="blur"||q==="color"||q==="thumbhash"){let y=Gu(w||16,A||9,j);I.push(`background-image:url(${y})`),I.push("background-size:cover"),I.push("background-repeat:no-repeat")}else if(q&&q!=="empty"&&q!=="none")I.push(`background-image:url(${I1(q)})`),I.push("background-size:cover"),I.push("background-repeat:no-repeat");let N=l3(J,w,A,_,z),E=[];if(E.push(`src="${I1(N)}"`),E.push(`alt="${I1(Y)}"`),Q)E.push(`width="${I1(Q)}"`);if(G)E.push(`height="${I1(G)}"`);if(B)E.push('loading="lazy"');if(E.push('decoding="async"'),H)E.push(`class="${I1(H)}"`);if(I.length>0)E.push(`style="${I1(I.join(";"))}"`);if(R)E.push(`srcset="${I1(R)}"`);if(M)E.push(`sizes="${I1(M)}"`);let C=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);E.push(...K5($,C)),E.push(...W5($,C));let S=`<img ${E.join(" ")} />`,x="";if(F){let b=z==="webp"?"image/webp":z==="avif"?"image/avif":"";x=`<link rel="preload" as="image" href="${I1(N)}"${b?` type="${b}"`:""}${R?` imagesrcset="${I1(R)}"`:""}${M?` imagesizes="${I1(M)}"`:""} />
3786
+ `}if(V){let y=[];if(z==="avif"||z==="auto"){let b=l3(J,w,A,_,"avif"),u=R?hK(J,fK,_,"avif"):`${b}`;y.push(`<source type="image/avif" srcset="${I1(u)}"${M?` sizes="${I1(M)}"`:""} />`)}if(z==="webp"||z==="auto"){let b=l3(J,w,A,_,"webp"),u=R?hK(J,fK,_,"webp"):`${b}`;y.push(`<source type="image/webp" srcset="${I1(u)}"${M?` sizes="${I1(M)}"`:""} />`)}return`${x}<picture>
3787
+ ${y.join(`
3788
3788
  `)}
3789
3789
  ${S}
3790
- </picture>`}return`${y}${S}`}}});function p3($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function U5($,X){if($.serverDynamic[X]!==void 0)return String($.serverDynamic[X]);let Z=$.static[X];if(typeof Z==="string")return Z;return}var dF="/images/safe-image-default.svg",Ku,dK;var cK=T(()=>{H2();Ku=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${dF}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,dK={name:"SafeImage",aliases:["safe-image","safe-img"],render($,X,Z){let J=U5($,"src")||"",Y=U5($,"alt")||"",Q=U5($,"fallback")||dF,G=U5($,"class")||U5($,"className")||"",K=U5($,"fallbackClassName")||"",W=[];if(W.push(`src="${p3(J)}"`),W.push(`alt="${p3(Y)}"`),G)W.push(`class="${p3(G)}"`);if(W.push(`data-fallback="${p3(Q)}"`),K)W.push(`data-fallback-class="${p3(K)}"`);W.push('onerror="window.__stxSafeImageHandler(this)"');let U=new Set(["src","alt","fallback","class","className","fallbackClassName"]);W.push(...K5($,U)),W.push(...W5($,U));let z=`<img ${W.join(" ")} />`,q=Z.context;if(!q.__safeImageHandlerEmitted)return q.__safeImageHandlerEmitted=!0,`${Ku}${z}`;return z}}});function lK($){return $.replace(/[;{}()]/g,"").replace(/url/gi,"")}function i3($,X){if($.serverDynamic[X]!==void 0)return String($.serverDynamic[X]);let Z=$.static[X];if(typeof Z==="string")return Z;return}function L2($,X,Z){let J=i3($,X);if(J!==void 0){let Y=Number.parseInt(J,10);if(!Number.isNaN(Y))return Y}return Z}var pK;var iK=T(()=>{pK={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render($,X,Z){let J=lK(i3($,"color")||"#6366f1"),Y=lK(i3($,"initialColor")||i3($,"initial-color")||""),Q=lK(i3($,"height")||"3px"),G=L2($,"duration",2000),K=L2($,"throttle",200),W=L2($,"zIndex",999999)||L2($,"z-index",999999),U=Y?`linear-gradient(to right, ${Y}, ${J})`:J;return`
3790
+ </picture>`}return`${x}${S}`}}});function p3($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function U5($,X){if($.serverDynamic[X]!==void 0)return String($.serverDynamic[X]);let Z=$.static[X];if(typeof Z==="string")return Z;return}var dF="/images/safe-image-default.svg",Ku,dK;var cK=T(()=>{H2();Ku=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${dF}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,dK={name:"SafeImage",aliases:["safe-image","safe-img"],render($,X,Z){let J=U5($,"src")||"",Y=U5($,"alt")||"",Q=U5($,"fallback")||dF,G=U5($,"class")||U5($,"className")||"",K=U5($,"fallbackClassName")||"",W=[];if(W.push(`src="${p3(J)}"`),W.push(`alt="${p3(Y)}"`),G)W.push(`class="${p3(G)}"`);if(W.push(`data-fallback="${p3(Q)}"`),K)W.push(`data-fallback-class="${p3(K)}"`);W.push('onerror="window.__stxSafeImageHandler(this)"');let U=new Set(["src","alt","fallback","class","className","fallbackClassName"]);W.push(...K5($,U)),W.push(...W5($,U));let z=`<img ${W.join(" ")} />`,q=Z.context;if(!q.__safeImageHandlerEmitted)return q.__safeImageHandlerEmitted=!0,`${Ku}${z}`;return z}}});function lK($){return $.replace(/[;{}()]/g,"").replace(/url/gi,"")}function i3($,X){if($.serverDynamic[X]!==void 0)return String($.serverDynamic[X]);let Z=$.static[X];if(typeof Z==="string")return Z;return}function L2($,X,Z){let J=i3($,X);if(J!==void 0){let Y=Number.parseInt(J,10);if(!Number.isNaN(Y))return Y}return Z}var pK;var iK=T(()=>{pK={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render($,X,Z){let J=lK(i3($,"color")||"#6366f1"),Y=lK(i3($,"initialColor")||i3($,"initial-color")||""),Q=lK(i3($,"height")||"3px"),G=L2($,"duration",2000),K=L2($,"throttle",200),W=L2($,"zIndex",999999)||L2($,"z-index",999999),U=Y?`linear-gradient(to right, ${Y}, ${J})`:J;return`
3791
3791
  <div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${Q};background:${U};z-index:${W};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
3792
3792
  <div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
3793
3793
  </div>
@@ -3820,7 +3820,7 @@ ${S}
3820
3820
  @media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
3821
3821
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
3822
3822
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
3823
- </style>`}}});import{existsSync as Uu,readFileSync as zu}from"fs";function rF($){if(nF.has($))return;nF.add($),console.warn(`[stx] icon collection "${$}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${$}\`.`)}function aF($){let X=process.cwd();for(let Z of[`${X}/node_modules/@iconify-json/${$}/icons.json`,`${X}/pantry/@iconify-json/${$}/icons.json`,`${X}/node_modules/@iconify/json/json/${$}.json`,`${X}/pantry/@iconify/json/json/${$}.json`])if(Uu(Z))return Z;for(let Z of[`@iconify-json/${$}/icons.json`,`@iconify/json/json/${$}.json`])try{return J0.resolve(Z)}catch{}return null}function qu($){if(i6.has($))return i6.get($);let X=aF($);if(!X)return rF($),null;try{let Z=JSON.parse(zu(X,"utf8"));return i6.set($,Z.icons),Z.icons}catch{return null}}async function ju($,X=!1){if(i6.has($))return i6.get($);let Z=aF($);if(!Z){if(!X)rF($);return null}try{let J=await Bun.file(Z).json();return i6.set($,J.icons),J.icons}catch{return null}}function q5($,X){if($.serverDynamic[X]!==void 0)return String($.serverDynamic[X]);if($.static[X]!==void 0)return String($.static[X]);if($.clientReactive[X]!==void 0)return $.clientReactive[X];return}async function $W($="lucide",X={}){await ju($,X.speculative??!0)}var i6,nF,eK;var XW=T(()=>{i6=new Map,nF=new Set;eK={name:"Icon",aliases:["icon","stx-icon"],render($,X,Z){let J=q5($,"name")??q5($,"icon");if(!J)return"<!-- Icon: missing name/icon prop -->";let Y="lucide",Q=J;if(J.includes(":")){let F=J.split(":");Y=F[0],Q=F[1]}let G=_1(q5($,"size")||"24"),K=_1(q5($,"color")||"currentColor"),W=_1(q5($,"class")||""),U=_1(q5($,"style")||""),z=i6.get(Y)??qu(Y);if(!z)return`<!-- Icon: collection "${Y}" not loaded -->`;let q=z[Q];if(!q)return`<!-- Icon: "${Q}" not found in ${Y} -->`;let j=q.width||24,_=q.height||24,H=`0 0 ${j} ${_}`,L=q.body;if(K!=="currentColor")L=L.replace(/currentColor/g,K);let O=W?` class="${W}"`:"",B=U?` style="${U}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${H}" fill="none"${O}${B}>${L}</svg>`}}});function ZW(){return`
3823
+ </style>`}}});import{existsSync as Uu,readFileSync as zu}from"fs";function rF($){if(nF.has($))return;nF.add($),console.warn(`[stx] icon collection "${$}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${$}\`.`)}function aF($){let X=process.cwd();for(let Z of[`${X}/node_modules/@iconify-json/${$}/icons.json`,`${X}/pantry/@iconify-json/${$}/icons.json`,`${X}/node_modules/@iconify/json/json/${$}.json`,`${X}/pantry/@iconify/json/json/${$}.json`])if(Uu(Z))return Z;for(let Z of[`@iconify-json/${$}/icons.json`,`@iconify/json/json/${$}.json`])try{return Y0.resolve(Z)}catch{}return null}function qu($){if(i6.has($))return i6.get($);let X=aF($);if(!X)return rF($),null;try{let Z=JSON.parse(zu(X,"utf8"));return i6.set($,Z.icons),Z.icons}catch{return null}}async function ju($,X=!1){if(i6.has($))return i6.get($);let Z=aF($);if(!Z){if(!X)rF($);return null}try{let J=await Bun.file(Z).json();return i6.set($,J.icons),J.icons}catch{return null}}function q5($,X){if($.serverDynamic[X]!==void 0)return String($.serverDynamic[X]);if($.static[X]!==void 0)return String($.static[X]);if($.clientReactive[X]!==void 0)return $.clientReactive[X];return}async function $W($="lucide",X={}){await ju($,X.speculative??!0)}var i6,nF,eK;var XW=T(()=>{i6=new Map,nF=new Set;eK={name:"Icon",aliases:["icon","stx-icon"],render($,X,Z){let J=q5($,"name")??q5($,"icon");if(!J)return"<!-- Icon: missing name/icon prop -->";let Y="lucide",Q=J;if(J.includes(":")){let F=J.split(":");Y=F[0],Q=F[1]}let G=_1(q5($,"size")||"24"),K=_1(q5($,"color")||"currentColor"),W=_1(q5($,"class")||""),U=_1(q5($,"style")||""),z=i6.get(Y)??qu(Y);if(!z)return`<!-- Icon: collection "${Y}" not loaded -->`;let q=z[Q];if(!q)return`<!-- Icon: "${Q}" not found in ${Y} -->`;let j=q.width||24,_=q.height||24,H=`0 0 ${j} ${_}`,L=q.body;if(K!=="currentColor")L=L.replace(/currentColor/g,K);let O=W?` class="${W}"`:"",B=U?` style="${U}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${H}" fill="none"${O}${B}>${L}</svg>`}}});function ZW(){return`
3824
3824
  (function(){
3825
3825
  var tip=null,hideTimer=null,currentEl=null;
3826
3826
 
@@ -3924,15 +3924,15 @@ document.addEventListener("focusout",function(e){
3924
3924
  });
3925
3925
  })();
3926
3926
  `}function sF($,...X){for(let Z of X){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let J=$.static[Z];if(typeof J==="string")return J}return}function oF($,X){let Z=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${X}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),J=$.match(Z);if(!J)return{region:null,rest:$};return{region:J[2],rest:$.replace(J[0],"")}}var JW;var YW=T(()=>{JW={name:"Suspense",aliases:["suspense"],render($,X,Z){let J=oF(X,"fallback"),Y=J.rest,Q=oF(Y,"error"),G=Q.rest,K=J.region??sF($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',W=Q.region??sF($,"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 B2($,...X){for(let Z of X){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let J=$.static[Z];if(typeof J==="string")return J}return}var QW;var GW=T(()=>{QW={name:"TransitionGroup",aliases:["transition-group"],render($,X,Z){let J=(B2($,"name")||"v").replace(/["'<>]/g,""),Y=(B2($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",Q=B2($,"class"),G=B2($,"id"),K=[`data-stx-transition-group="${J}"`,Q?`class="${Q}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${Y} ${K}>${X}</${Y}>`}}});function tF(){d1.registerBuiltin(xK),d1.registerBuiltin(uK),d1.registerBuiltin(dK),d1.registerBuiltin(pK),d1.registerBuiltin(nK),d1.registerBuiltin(aK),d1.registerBuiltin(oK),d1.registerBuiltin(eK),d1.registerBuiltin(JW),d1.registerBuiltin(QW)}var KW=T(()=>{vK();mK();cK();iK();rK();sK();tK();XW();YW();GW();bK();vK();mK();cK();iK();rK();sK();tK();XW();YW();GW()});function F2($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function eF($,X,Z){let J=[],Y=0;while(Y<$.length){let Q=$.indexOf("<",Y);if(Q===-1)break;let K=$.slice(Q+1).match(new RegExp(`^(${X.source})(?![\\w.:-])`));if(!K){Y=Q+1;continue}let W=K[1];if(Z&&Z.has(W.toLowerCase())){let L=Q+1+W.length;while(L<$.length&&$[L]!==">")L++;Y=L+1;continue}let U=Q+1+W.length,z=null,q=U,j=-1,_=!1;while(U<$.length){let L=$[U];if(z){if(L==="\\"&&U+1<$.length){U+=2;continue}if(L===z)z=null;U++;continue}if(L==='"'||L==="'"){z=L,U++;continue}if(L==="/"&&U+1<$.length&&$[U+1]===">"){j=U+2,_=!0;break}if(L===">"){j=U+1;break}U++}if(j===-1){Y=Q+1;continue}let H=$.slice(q,_?j-2:j-1).trim();if(_)J.push({fullMatch:$.slice(Q,j),tagName:W,attributes:H,content:"",startIndex:Q,endIndex:j,isSelfClosing:!0}),Y=j;else{let L=`<${W}`,O=`</${W}>`,B=1,F=j,V=-1;while(B>0&&F<$.length){let R=$.indexOf(L,F),M=$.indexOf(O,F);if(M===-1)break;if(R!==-1&&R<M){let I=$[R+L.length];if(I===" "||I===">"||I==="/"||I===`
3927
- `||I==="\t")B++;F=R+L.length}else{if(B--,B===0){V=M;break}F=M+O.length}}if(V===-1){Y=j;continue}let w=$.slice(j,V),A=V+O.length;J.push({fullMatch:$.slice(Q,A),tagName:W,attributes:H,content:w,startIndex:Q,endIndex:A,isSelfClosing:!1}),Y=A}}return J}function $V($){return $.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function XV($,X){try{let Z=Buffer.from($,"base64").toString("utf8");return JSON.parse(Z)}catch{}try{let Z=$.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(Z)}catch(Z){if(X?.debug)console.error("Error decoding __stx_ prop:",Z);return $}}var ZV=T(()=>{j1();b0();Y4()});var UV={};X0(UV,{processESImports:()=>KV,processComponents:()=>w2});import V2 from"fs";import s1 from"path";function Hu($,X,Z){let J={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},Y=new Set(Array.isArray(X.__stx_client_signal_names)?X.__stx_client_signal_names:[]),Q=(U)=>{if(Y.size===0)return!1;let z=Q1(U),q=z.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(q&&Y.has(q))return!0;for(let j of Y){let _=j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${_}\\s*\\(`).test(z))return!0}return!1},G=new Set(nL),K=(U)=>{if(!U.includes("-")||U.startsWith("@")||U.startsWith(":")||U.startsWith("x-")||U.startsWith("__"))return U;if(U.startsWith("aria-")||U.startsWith("data-"))return U;return U.replace(/-([a-z0-9])/g,(z,q)=>q.toUpperCase())},W=(U,z)=>{let q=K(U);if(J.static[q]=z,q!==U)J.staticNames[q]=U};for(let[U,z]of Object.entries($)){let q=U.startsWith("x-")&&!G.has(U)&&!U.startsWith("x-bind:")&&!U.startsWith("x-on:")?`:${U.slice(2)}`:U;if(q.startsWith("@")){J.events[q]=z;continue}if(q.startsWith("__stx_")){let j=K(q.slice(6));J.serverDynamic[j]=XV(z,Z);continue}if(q.startsWith(":")){let j=K(q.slice(1)),_=z===p6?j:z;if(j==="if"||j==="for"||j==="show"){J.clientReactive[j]=_;continue}if(Q(_)){J.clientReactive[j]=_;continue}try{if(!m0(_)){if(Z.debug)console.error(`Unsafe expression in :${j} binding: ${_}`);J.clientReactive[j]=_;continue}let H=Object.keys(X),O=d0(_,H)(...Object.values(X));if(O===void 0){let B=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],F=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(B.some((w)=>!F.has(w)&&!H.includes(w))){J.clientReactive[j]=_;continue}}if(J.serverDynamic[j]=O,j!==q.slice(1)&&J.serverDynamicNames)J.serverDynamicNames[j]=q.slice(1)}catch{J.clientReactive[j]=_}continue}if(typeof z==="string"&&z.includes("{{")&&z.includes("}}")){let j=z.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(j)try{let _=j[1];if(m0(_)){let L=d0(_,Object.keys(X))(...Object.values(X));W(q,L!=null?String(L):"")}else{if(Z.debug)console.error(`Unsafe expression in ${q}: ${_}`);W(q,z)}}catch(_){if(Z.debug)console.error(`Error evaluating expression for ${q}:`,_);W(q,z)}else{let _=z,H=/\{\{\s*([\s\S]+?)\s*\}\}/g,L;while((L=H.exec(z))!==null)try{let O=L[1];if(!m0(O)){if(Z.debug)console.error(`Unsafe expression in ${q}: ${O}`);continue}let F=d0(O,Object.keys(X))(...Object.values(X));_=_.replace(L[0],String(F??""))}catch(O){if(Z.debug)console.error(`Error evaluating expression in ${q}:`,O)}W(q,_)}continue}W(q,z===p6?"true":$V(z))}return J}function Ou($,X,Z){if(!$.includes("@"))return $;if(!Lu.some(([Y,Q])=>Y.test($)&&$.includes(Q)))return $;try{return W4($,X,Z)}catch{return $}}function Bu($){let X={},Z=0,J=$.length;while(Z<J){while(Z<J&&/\s/.test($[Z]))Z++;if(Z>=J)break;let Y="";while(Z<J&&!/[\s=]/.test($[Z]))Y+=$[Z],Z++;if(!Y)break;while(Z<J&&/\s/.test($[Z]))Z++;if(Z<J&&$[Z]==="="){Z++;while(Z<J&&/\s/.test($[Z]))Z++;let Q="";if(Z<J&&($[Z]==='"'||$[Z]==="'")){let G=$[Z];Z++;while(Z<J){let K=$[Z];if(K==="\\"&&Z+1<J){Z++,Q+=$[Z],Z++;continue}if(K===G){Z++;break}Q+=K,Z++}}else while(Z<J&&!/\s/.test($[Z]))Q+=$[Z],Z++;X[Y]=Q}else X[Y]=p6}return X}function YV($){return Object.entries($).map(([X,Z])=>Z===p6?X:`${X}="${Fu(Z)}"`).join(" ")}function Fu($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Vu($){let X=new Set,Z=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,J;while((J=Z.exec($))!==null){let Y=J[1];if(d1.isBuiltin(Y))X.add(Y)}return[...X].sort()}function wu($){let X=QV.get($);if(X)return X;let Z=new Map,J=[s1.join($,"src"),s1.join($,"dist"),$];function Y(Q,G){if(G>6)return;let K;try{K=V2.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let W of K){let U=s1.join(Q,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;Y(U,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let z=W.name.slice(0,-4);if(!Z.has(z))Z.set(z,U);let q=z.toLowerCase();if(!Z.has(q))Z.set(q,U);let j=z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Z.has(j))Z.set(j,U)}}}for(let Q of J)if(Y(Q,0),Z.size>0)break;return QV.set($,Z),Z}function Au($,X){if($.startsWith(".")||$.startsWith("/"))return null;let Z=X;while(!0){let J=s1.join(Z,"node_modules",$);try{if(V2.statSync(J).isDirectory())return J}catch{}let Y=s1.dirname(Z);if(Y===Z)return null;Z=Y}}async function KV($,X,Z,J,Y){if(!$.includes("import"))return $;if(!X.__importedComponents)X.__importedComponents=new Map;let Q=X.__importedComponents,G=s1.dirname(Z),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(U,z,q)=>{let j=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,_=q,H,L=[];while((H=j.exec(q))!==null){let[O,B,F,V]=H,w=null,A=null;if(V.startsWith(".")||V.startsWith("/")){let I=s1.resolve(G,V);if(I.endsWith(".stx"))A=I;else{let N=`${I}.stx`;try{if(V2.statSync(N).isFile())A=N}catch{try{if(V2.statSync(I).isDirectory())w=I}catch{}}}}else w=Au(V,G);if(!w&&!A)continue;let R=!1,M=(I,N)=>{Q.set(I,N),Q.set(I.toLowerCase(),N);let E=I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(E,N),Y.add(N)};if(F&&A)M(F,A),R=!0;else if(B){let I=B.slice(1,-1).split(",").map((E)=>E.trim()).filter(Boolean).map((E)=>{let C=E.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(C)return{source:C[1],local:C[2]};return{source:E,local:E}}),N=w?wu(w):null;for(let{source:E,local:C}of I){let S=null;if(A)S=A;else if(N)S=N.get(E)??N.get(E.toLowerCase())??N.get(E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(S)M(C,S),R=!0}}if(R)L.push({start:H.index,end:H.index+O.length})}if(L.length===0)return U;for(let O=L.length-1;O>=0;O--)_=_.slice(0,L[O].start)+_.slice(L[O].end);return`<script${z}>${_}</script>`}),K}async function Ru($,X,Z,J,Y){let Q=$;if(!X.__importedComponents)X.__importedComponents=new Map;let G=X.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,z]=W,q=z.split(",").map((j)=>j.trim().replace(/^['"]|['"]$/g,"")).filter((j)=>j.length>0);for(let j of q){let _=j.split("/"),L=_[_.length-1].replace(/\.stx$/,""),O=L.includes("-")?L.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):L.charAt(0).toUpperCase()+L.slice(1),B=null,F=[s1.resolve(s1.dirname(Z),`${j}.stx`),s1.resolve(s1.dirname(Z),j),s1.resolve(J.componentsDir||"components",`${j}.stx`),s1.resolve(J.componentsDir||"components",j),j.endsWith(".stx")?j:`${j}.stx`];for(let V of F)try{if(await Bun.file(V).exists()){B=V;break}}catch{}if(B){G.set(O,B),G.set(L,B),G.set(L.toLowerCase(),B);let V=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,B),Y.add(B),J.debug)console.log(`Imported component: ${O} -> ${B}`)}else if(J.debug)console.warn(`Could not resolve imported component: ${j}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function Nu($,X,Z,J,Y){let Q=$,G=J.componentsDir||"components";if(!X.__processedComponents)X.__processedComponents=new Set;let K=X.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let z=U.index,q=z+U[0].length-1,j=1,_=q+1;while(_<Q.length&&j>0){if(Q[_]==="(")j++;else if(Q[_]===")"){if(j--,j===0)break}_++}if(j!==0)break;let H=Q.substring(q+1,_),L=_+1,O=H.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let B=O[1],F,V=H.slice(O[0].length),w=V.match(/^\s*,\s*/);if(w)F=V.slice(w[0].length).trim();let A={};if(F)try{A=G1(F,X)}catch(C){let S=C instanceof Error?C.message:String(C);Q=Q.replace(Q.substring(z,L),`[Error parsing component props: ${S}]`);continue}let R="",M=L,N=Q.substring(L).match(/^([\s\S]*?)@endcomponent/);if(N)R=N[1].trim(),M=L+N[0].length;let E=await m$(B,A,R,G,X,Z,J,K,Y);Q=Q.substring(0,z)+E+Q.substring(M),W.lastIndex=0}return Q}async function Mu($,X,Z,J,Y){if(!$)return $;let Q=$,G=J.componentsDir||"components";if(!X.__processedComponents)X.__processedComponents=new Set;let K=X.__processedComponents,W=v$(Q);return Q=W.output,Q=await j(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await j(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await j(Q,/[a-z][a-z0-9]*/,!1,_u),Q=p8(Q,W.scripts),Q;async function j(_,H,L,O){if(!_)return _;let B=_,F=eF(B,H,O);for(let V=F.length-1;V>=0;V--){let w=F[V],A=L?F2(w.tagName):w.tagName,R=Bu(Ou(w.attributes,X,Z)),M=Hu(R,X,J),I=d1.getBuiltin(w.tagName),N=I?await n3(A,G,X,Z,J):!1;if(I&&!N){let y={context:X,filePath:Z,options:J,dependencies:Y},x=I.render(M,w.content,y);if(Object.keys(M.clientReactive).length>0)x=GV(x,M.clientReactive);if(Object.keys(M.events).length>0){let b=YV(M.events);x=x.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}B=B.substring(0,w.startIndex)+x+B.substring(w.endIndex);continue}if(!L&&w.tagName.includes("-")&&!await n3(A,G,X,Z,J))continue;let E={};for(let[y,x]of Object.entries(M.static))E[y]=x;for(let[y,x]of Object.entries(M.serverDynamic))E[y]=x;let S=await m$(A,E,p8(w.content,W.scripts),G,X,Z,J,K,Y);if(Object.keys(M.clientReactive).length>0)S=GV(S,M.clientReactive);if(Object.keys(M.events).length>0){let y=WV(S);if(y){let x=YV(M.events),b=Object.keys(M.events).map((u)=>u.replace(/^@/,"").split(".")[0]).join(" ");S=S.substring(0,y.insertPos)+` data-stx-parent-events="${b}" ${x}`+S.substring(y.insertPos)}}B=B.substring(0,w.startIndex)+S+B.substring(w.endIndex)}return B}}function GV($,X){let Z=new Set(["if","for"]),J=new Set(["show"]),Y=Object.entries(X).filter(([z])=>!Z.has(z)),Q=Y.filter(([z])=>!J.has(z)).map(([z])=>F2(z)).join(" "),G=$,K=Y.length>0?WV(G):null;if(K){let z=Y.map(([j,_])=>`:${F2(j)}="${_.replace(/"/g,"&quot;")}"`).join(" "),q=Q?` data-stx-parent-bindings="${Q}"`:"";G=G.substring(0,K.insertPos)+`${q} ${z}`+G.substring(K.insertPos)}let W=X.if;if(W)G=`<template :if="${W.replace(/"/g,"&quot;")}">${G}</template>`;let U=X.for;if(U)G=`<template :for="${U.replace(/"/g,"&quot;")}">${G}</template>`;return G}function WV($){let X=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec($);if(X)return{insertPos:X.index+1+X[1].length};let Z=0;while(Z<$.length){let J=$.slice(Z),Y=J.match(/^\s+/);if(Y){Z+=Y[0].length;continue}if(J.startsWith("<!--")){let K=$.indexOf("-->",Z+4);if(K===-1)return null;Z=K+3;continue}let Q=J.match(/^<(script|style)\b[^>]*>/i);if(Q){let K=`</${Q[1].toLowerCase()}>`,W=$.toLowerCase().indexOf(K,Z+Q[0].length);if(W===-1)return null;Z=W+K.length;continue}let G=J.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!G)return null;return{insertPos:Z+1+G[1].length}}return null}async function w2($,X,Z,J,Y){if(!JV)tF(),JV=!0;let Q=await KV($,X,Z,J,Y);Q=await Ru(Q,X,Z,J,Y),Q=await Nu(Q,X,Z,J,Y);let G=[];for(let K=0;K<3;K++){let W=x$(Q,f6,(z,q)=>`\x00STX_COMPONENT_COMMENT_${G.length+q}\x00`);G.push(...W.tokens);let U=Q;if(Q=await Mu(W.output,X,Z,J,Y),Q===U)break}if(G.length>0)Q=Q.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(K,W)=>G[Number(W)]??"");if(J.debug){let K=Vu(Q);if(K.length>0)console.warn(`[stx] ${Z}: unresolved component tag(s) after render passes: ${K.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var JV=!1,_u,Lu,QV;var WW=T(()=>{bK();v3();KW();ZV();Y4();b0();j1();i1();_u=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","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"]);Lu=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];QV=new Map});var R2={};X0(R2,{stripTypeScript:()=>OV,splitDeclaration:()=>RV,isModuleResolutionFailure:()=>BV,isMissingBindingFailure:()=>FV,isCompleteImport:()=>VV,hasVariables:()=>jW,extractVariables:()=>g0,extractScriptFromTemplate:()=>qW,convertToCommonJS:()=>A2,STX_ENGINE_BINDING_NAMES:()=>zW});import r4 from"path";import j5 from"process";function Du($){let X=[],Z=0,J=$.split(`
3927
+ `||I==="\t")B++;F=R+L.length}else{if(B--,B===0){V=M;break}F=M+O.length}}if(V===-1){Y=j;continue}let w=$.slice(j,V),A=V+O.length;J.push({fullMatch:$.slice(Q,A),tagName:W,attributes:H,content:w,startIndex:Q,endIndex:A,isSelfClosing:!1}),Y=A}}return J}function $V($){return $.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0?39;/g,"'").replace(/&#x27;/gi,"'").replace(/&amp;/g,"&")}function XV($,X){try{let Z=Buffer.from($,"base64").toString("utf8");return JSON.parse(Z)}catch{}try{let Z=$.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(Z)}catch(Z){if(X?.debug)console.error("Error decoding __stx_ prop:",Z);return $}}var ZV=T(()=>{j1();b0();Y4()});var UV={};X0(UV,{processESImports:()=>KV,processComponents:()=>w2});import V2 from"fs";import s1 from"path";function Hu($,X,Z){let J={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},Y=new Set(Array.isArray(X.__stx_client_signal_names)?X.__stx_client_signal_names:[]),Q=(U)=>{if(Y.size===0)return!1;let z=Q1(U),q=z.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(q&&Y.has(q))return!0;for(let j of Y){let _=j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${_}\\s*\\(`).test(z))return!0}return!1},G=new Set(nL),K=(U)=>{if(!U.includes("-")||U.startsWith("@")||U.startsWith(":")||U.startsWith("x-")||U.startsWith("__"))return U;if(U.startsWith("aria-")||U.startsWith("data-"))return U;return U.replace(/-([a-z0-9])/g,(z,q)=>q.toUpperCase())},W=(U,z)=>{let q=K(U);if(J.static[q]=z,q!==U)J.staticNames[q]=U};for(let[U,z]of Object.entries($)){let q=U.startsWith("x-")&&!G.has(U)&&!U.startsWith("x-bind:")&&!U.startsWith("x-on:")?`:${U.slice(2)}`:U;if(q.startsWith("@")){J.events[q]=z;continue}if(q.startsWith("__stx_")){let j=K(q.slice(6));J.serverDynamic[j]=XV(z,Z);continue}if(q.startsWith(":")){let j=K(q.slice(1)),_=z===p6?j:z;if(j==="if"||j==="for"||j==="show"){J.clientReactive[j]=_;continue}if(Q(_)){J.clientReactive[j]=_;continue}try{if(!m0(_)){if(Z.debug)console.error(`Unsafe expression in :${j} binding: ${_}`);J.clientReactive[j]=_;continue}let H=Object.keys(X),O=d0(_,H)(...Object.values(X));if(O===void 0){let B=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],F=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(B.some((w)=>!F.has(w)&&!H.includes(w))){J.clientReactive[j]=_;continue}}if(J.serverDynamic[j]=O,j!==q.slice(1)&&J.serverDynamicNames)J.serverDynamicNames[j]=q.slice(1)}catch{J.clientReactive[j]=_}continue}if(typeof z==="string"&&z.includes("{{")&&z.includes("}}")){let j=z.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(j)try{let _=j[1];if(m0(_)){let L=d0(_,Object.keys(X))(...Object.values(X));W(q,L!=null?String(L):"")}else{if(Z.debug)console.error(`Unsafe expression in ${q}: ${_}`);W(q,z)}}catch(_){if(Z.debug)console.error(`Error evaluating expression for ${q}:`,_);W(q,z)}else{let _=z,H=/\{\{\s*([\s\S]+?)\s*\}\}/g,L;while((L=H.exec(z))!==null)try{let O=L[1];if(!m0(O)){if(Z.debug)console.error(`Unsafe expression in ${q}: ${O}`);continue}let F=d0(O,Object.keys(X))(...Object.values(X));_=_.replace(L[0],String(F??""))}catch(O){if(Z.debug)console.error(`Error evaluating expression in ${q}:`,O)}W(q,_)}continue}W(q,z===p6?"true":$V(z))}return J}function Ou($,X,Z){if(!$.includes("@"))return $;if(!Lu.some(([Y,Q])=>Y.test($)&&$.includes(Q)))return $;try{return W4($,X,Z)}catch{return $}}function Bu($){let X={},Z=0,J=$.length;while(Z<J){while(Z<J&&/\s/.test($[Z]))Z++;if(Z>=J)break;let Y="";while(Z<J&&!/[\s=]/.test($[Z]))Y+=$[Z],Z++;if(!Y)break;while(Z<J&&/\s/.test($[Z]))Z++;if(Z<J&&$[Z]==="="){Z++;while(Z<J&&/\s/.test($[Z]))Z++;let Q="";if(Z<J&&($[Z]==='"'||$[Z]==="'")){let G=$[Z];Z++;while(Z<J){let K=$[Z];if(K==="\\"&&Z+1<J){Z++,Q+=$[Z],Z++;continue}if(K===G){Z++;break}Q+=K,Z++}}else while(Z<J&&!/\s/.test($[Z]))Q+=$[Z],Z++;X[Y]=Q}else X[Y]=p6}return X}function YV($){return Object.entries($).map(([X,Z])=>Z===p6?X:`${X}="${Fu(Z)}"`).join(" ")}function Fu($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Vu($){let X=new Set,Z=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,J;while((J=Z.exec($))!==null){let Y=J[1];if(d1.isBuiltin(Y))X.add(Y)}return[...X].sort()}function wu($){let X=QV.get($);if(X)return X;let Z=new Map,J=[s1.join($,"src"),s1.join($,"dist"),$];function Y(Q,G){if(G>6)return;let K;try{K=V2.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let W of K){let U=s1.join(Q,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;Y(U,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let z=W.name.slice(0,-4);if(!Z.has(z))Z.set(z,U);let q=z.toLowerCase();if(!Z.has(q))Z.set(q,U);let j=z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Z.has(j))Z.set(j,U)}}}for(let Q of J)if(Y(Q,0),Z.size>0)break;return QV.set($,Z),Z}function Au($,X){if($.startsWith(".")||$.startsWith("/"))return null;let Z=X;while(!0){let J=s1.join(Z,"node_modules",$);try{if(V2.statSync(J).isDirectory())return J}catch{}let Y=s1.dirname(Z);if(Y===Z)return null;Z=Y}}async function KV($,X,Z,J,Y){if(!$.includes("import"))return $;if(!X.__importedComponents)X.__importedComponents=new Map;let Q=X.__importedComponents,G=s1.dirname(Z),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(U,z,q)=>{let j=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,_=q,H,L=[];while((H=j.exec(q))!==null){let[O,B,F,V]=H,w=null,A=null;if(V.startsWith(".")||V.startsWith("/")){let I=s1.resolve(G,V);if(I.endsWith(".stx"))A=I;else{let N=`${I}.stx`;try{if(V2.statSync(N).isFile())A=N}catch{try{if(V2.statSync(I).isDirectory())w=I}catch{}}}}else w=Au(V,G);if(!w&&!A)continue;let R=!1,M=(I,N)=>{Q.set(I,N),Q.set(I.toLowerCase(),N);let E=I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(E,N),Y.add(N)};if(F&&A)M(F,A),R=!0;else if(B){let I=B.slice(1,-1).split(",").map((E)=>E.trim()).filter(Boolean).map((E)=>{let C=E.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(C)return{source:C[1],local:C[2]};return{source:E,local:E}}),N=w?wu(w):null;for(let{source:E,local:C}of I){let S=null;if(A)S=A;else if(N)S=N.get(E)??N.get(E.toLowerCase())??N.get(E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(S)M(C,S),R=!0}}if(R)L.push({start:H.index,end:H.index+O.length})}if(L.length===0)return U;for(let O=L.length-1;O>=0;O--)_=_.slice(0,L[O].start)+_.slice(L[O].end);return`<script${z}>${_}</script>`}),K}async function Ru($,X,Z,J,Y){let Q=$;if(!X.__importedComponents)X.__importedComponents=new Map;let G=X.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,z]=W,q=z.split(",").map((j)=>j.trim().replace(/^['"]|['"]$/g,"")).filter((j)=>j.length>0);for(let j of q){let _=j.split("/"),L=_[_.length-1].replace(/\.stx$/,""),O=L.includes("-")?L.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):L.charAt(0).toUpperCase()+L.slice(1),B=null,F=[s1.resolve(s1.dirname(Z),`${j}.stx`),s1.resolve(s1.dirname(Z),j),s1.resolve(J.componentsDir||"components",`${j}.stx`),s1.resolve(J.componentsDir||"components",j),j.endsWith(".stx")?j:`${j}.stx`];for(let V of F)try{if(await Bun.file(V).exists()){B=V;break}}catch{}if(B){G.set(O,B),G.set(L,B),G.set(L.toLowerCase(),B);let V=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,B),Y.add(B),J.debug)console.log(`Imported component: ${O} -> ${B}`)}else if(J.debug)console.warn(`Could not resolve imported component: ${j}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function Nu($,X,Z,J,Y){let Q=$,G=J.componentsDir||"components";if(!X.__processedComponents)X.__processedComponents=new Set;let K=X.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let z=U.index,q=z+U[0].length-1,j=1,_=q+1;while(_<Q.length&&j>0){if(Q[_]==="(")j++;else if(Q[_]===")"){if(j--,j===0)break}_++}if(j!==0)break;let H=Q.substring(q+1,_),L=_+1,O=H.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let B=O[1],F,V=H.slice(O[0].length),w=V.match(/^\s*,\s*/);if(w)F=V.slice(w[0].length).trim();let A={};if(F)try{A=G1(F,X)}catch(C){let S=C instanceof Error?C.message:String(C);Q=Q.replace(Q.substring(z,L),`[Error parsing component props: ${S}]`);continue}let R="",M=L,N=Q.substring(L).match(/^([\s\S]*?)@endcomponent/);if(N)R=N[1].trim(),M=L+N[0].length;let E=await m$(B,A,R,G,X,Z,J,K,Y);Q=Q.substring(0,z)+E+Q.substring(M),W.lastIndex=0}return Q}async function Mu($,X,Z,J,Y){if(!$)return $;let Q=$,G=J.componentsDir||"components";if(!X.__processedComponents)X.__processedComponents=new Set;let K=X.__processedComponents,W=v$(Q);return Q=W.output,Q=await j(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await j(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await j(Q,/[a-z][a-z0-9]*/,!1,_u),Q=p8(Q,W.scripts),Q;async function j(_,H,L,O){if(!_)return _;let B=_,F=eF(B,H,O);for(let V=F.length-1;V>=0;V--){let w=F[V],A=L?F2(w.tagName):w.tagName,R=Bu(Ou(w.attributes,X,Z)),M=Hu(R,X,J),I=d1.getBuiltin(w.tagName),N=I?await n3(A,G,X,Z,J):!1;if(I&&!N){let x={context:X,filePath:Z,options:J,dependencies:Y},y=I.render(M,w.content,x);if(Object.keys(M.clientReactive).length>0)y=GV(y,M.clientReactive);if(Object.keys(M.events).length>0){let b=YV(M.events);y=y.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}B=B.substring(0,w.startIndex)+y+B.substring(w.endIndex);continue}if(!L&&w.tagName.includes("-")&&!await n3(A,G,X,Z,J))continue;let E={};for(let[x,y]of Object.entries(M.static))E[x]=y;for(let[x,y]of Object.entries(M.serverDynamic))E[x]=y;let S=await m$(A,E,p8(w.content,W.scripts),G,X,Z,J,K,Y);if(Object.keys(M.clientReactive).length>0)S=GV(S,M.clientReactive);if(Object.keys(M.events).length>0){let x=WV(S);if(x){let y=YV(M.events),b=Object.keys(M.events).map((u)=>u.replace(/^@/,"").split(".")[0]).join(" ");S=S.substring(0,x.insertPos)+` data-stx-parent-events="${b}" ${y}`+S.substring(x.insertPos)}}B=B.substring(0,w.startIndex)+S+B.substring(w.endIndex)}return B}}function GV($,X){let Z=new Set(["if","for"]),J=new Set(["show"]),Y=Object.entries(X).filter(([z])=>!Z.has(z)),Q=Y.filter(([z])=>!J.has(z)).map(([z])=>F2(z)).join(" "),G=$,K=Y.length>0?WV(G):null;if(K){let z=Y.map(([j,_])=>`:${F2(j)}="${_.replace(/"/g,"&quot;")}"`).join(" "),q=Q?` data-stx-parent-bindings="${Q}"`:"";G=G.substring(0,K.insertPos)+`${q} ${z}`+G.substring(K.insertPos)}let W=X.if;if(W)G=`<template :if="${W.replace(/"/g,"&quot;")}">${G}</template>`;let U=X.for;if(U)G=`<template :for="${U.replace(/"/g,"&quot;")}">${G}</template>`;return G}function WV($){let X=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec($);if(X)return{insertPos:X.index+1+X[1].length};let Z=0;while(Z<$.length){let J=$.slice(Z),Y=J.match(/^\s+/);if(Y){Z+=Y[0].length;continue}if(J.startsWith("<!--")){let K=$.indexOf("-->",Z+4);if(K===-1)return null;Z=K+3;continue}let Q=J.match(/^<(script|style)\b[^>]*>/i);if(Q){let K=`</${Q[1].toLowerCase()}>`,W=$.toLowerCase().indexOf(K,Z+Q[0].length);if(W===-1)return null;Z=W+K.length;continue}let G=J.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!G)return null;return{insertPos:Z+1+G[1].length}}return null}async function w2($,X,Z,J,Y){if(!JV)tF(),JV=!0;let Q=await KV($,X,Z,J,Y);Q=await Ru(Q,X,Z,J,Y),Q=await Nu(Q,X,Z,J,Y);let G=[];for(let K=0;K<3;K++){let W=x$(Q,f6,(z,q)=>`\x00STX_COMPONENT_COMMENT_${G.length+q}\x00`);G.push(...W.tokens);let U=Q;if(Q=await Mu(W.output,X,Z,J,Y),Q===U)break}if(G.length>0)Q=Q.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(K,W)=>G[Number(W)]??"");if(J.debug){let K=Vu(Q);if(K.length>0)console.warn(`[stx] ${Z}: unresolved component tag(s) after render passes: ${K.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var JV=!1,_u,Lu,QV;var WW=T(()=>{bK();v3();KW();ZV();Y4();b0();j1();i1();_u=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","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"]);Lu=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];QV=new Map});var R2={};X0(R2,{stripTypeScript:()=>OV,splitDeclaration:()=>RV,isModuleResolutionFailure:()=>BV,isMissingBindingFailure:()=>FV,isCompleteImport:()=>VV,hasVariables:()=>jW,extractVariables:()=>g0,extractScriptFromTemplate:()=>qW,convertToCommonJS:()=>A2,STX_ENGINE_BINDING_NAMES:()=>zW});import r4 from"path";import j5 from"process";function Du($){let X=[],Z=0,J=$.split(`
3928
3928
  `);for(let Y of J){let Q=Z,G=null,K=!1;for(let W=0;W<Y.length;W++){let U=Y[W];if(K){K=!1;continue}if(U==="\\"){K=!0;continue}if(G){if(U===G)G=null;continue}if(U==="'"||U==='"'||U==="`"){G=U;continue}if(U==="/"&&W+1<Y.length&&Y[W+1]==="/")break;if(U==="{")Z++;else if(U==="}")Z--}if(Q===0){let W=Y.match(/(?:const|let|var)\s+(\w+)\s*=/);if(W)X.push(W[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(Y)){let U=Y.match(/(?:const|let|var)\s+(\w+)/);if(U)X.push(U[1])}else{let U=Y.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(U){let q=U[1].slice(1,-1).split(",").map((j)=>{let _=j.split(":");return(_.length>1?_[1]:_[0]).trim()}).filter((j)=>/^\w+$/.test(j));X.push(...q)}}}}return[...new Set(X)]}function OV($){let X=$;X=X.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),X=X.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),X=X.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),X=X.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),X=X.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function Z(J){if(!J.includes(":"))return J;let Y=[],Q="",G=0,K=0,W=null;for(let U=0;U<J.length;U++){let z=J[U];if(W){if(Q+=z,z===W)W=null;continue}if(z==='"'||z==="'"||z==="`"){W=z,Q+=z;continue}if(z==="<")G++;else if(z===">"&&G>0)G--;else if(z==="(")K++;else if(z===")")K--;if(z===","&&G===0&&K===0){Y.push(Q),Q="";continue}Q+=z}if(Q)Y.push(Q);return Y.map((U)=>{let z=U.trim(),q=z.startsWith("..."),j=q?z.slice(3):z,_=-1,H=0;for(let A=0;A<j.length;A++)if(j[A]==="<")H++;else if(j[A]===">")H--;else if(j[A]===":"&&H===0){_=A;break}if(_===-1)return U;let O=j.substring(0,_).trim().replace(/\?$/,""),B=j.substring(_+1),F=-1,V=0;for(let A=0;A<B.length;A++)if(B[A]==="<")V++;else if(B[A]===">")V--;else if(B[A]==="="&&V===0){F=A;break}let w=q?"...":"";if(F!==-1)return`${w}${O} = ${B.substring(F+1).trim()}`;return`${w}${O}`}).join(", ")}X=X.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(J,Y,Q)=>{if(!Q.includes(":"))return J;return`${Y}(${Z(Q)})`});{let J=/\b(function\s+\w*\s*)\(/g,Y,Q=[];while((Y=J.exec(X))!==null){let G=Y.index+Y[0].length-1,K=1,W=G+1,U=0,z=null;while(W<X.length&&K>0){let _=X[W];if(z){if(_===z)z=null;W++;continue}if(_==='"'||_==="'"||_==="`"){z=_,W++;continue}if(_==="<")U++;else if(_===">"&&U>0)U--;else if(U===0){if(_==="(")K++;else if(_===")")K--}if(K>0)W++}if(K!==0)continue;let q=X.substring(G+1,W);if(!q.includes(":"))continue;let j=Z(q);Q.push({start:G+1,end:W,replacement:j})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];X=X.substring(0,K)+U+X.substring(W)}}return X=X.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(J,Y)=>{if(!Y.includes(":"))return J;if(Y.includes("{")||Y.includes("}"))return J;return`(${Y.split(",").map((G)=>{let[K,...W]=G.split("="),U=K.split(":")[0].trim();if(W.length>0)return`${U} = ${W.join("=").trim()}`;return U}).join(", ")}) =>`}),X=X.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"),X=X.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),X=X.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),X=X.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),X=X.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),X=X.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),X=X.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),X=X.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),X=X.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),X=X.replace(/\n\s*\n\s*\n/g,`
3929
3929
 
3930
- `),X}function BV($){return/cannot find module|could not resolve|module not found|failed to resolve/i.test($)}function FV($){if(!/is not defined|can't find variable/i.test($))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test($)}async function g0($,X,Z,J={}){if(!$.trim())return;let Y;try{let f=B$({loader:"ts",target:"browser",define:V1()}),n=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");n=n.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),Y=f.transformSync(n)}catch{Y=OV($)}let Q={exports:{}},G=Q.exports,K=j5.cwd(),W={},U=[...Y.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((f)=>f[1]).filter((f)=>!f.startsWith("node:")&&!f.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(f));for(let f of U)try{let n=r4.resolve(K,"node_modules",f),q0=r4.join(n,"package.json"),e=JSON.parse(J0("fs").readFileSync(q0,"utf8")),p=e.main||"index.js";if(e.exports){let Z0=typeof e.exports==="string"?e.exports:e.exports["."];if(typeof Z0==="string")p=Z0;else if(Z0?.bun)p=Z0.bun;else if(Z0?.import)p=Z0.import;else if(Z0?.default)p=Z0.default}W[f]=await import(r4.resolve(n,p))}catch{}let z=(f)=>{if(W[f])return W[f];return J0(f)},q=X.props||{},j=(f)=>{if(!f)return q;let n={};for(let[q0,e]of Object.entries(f)){let p=q[q0];if(p!==void 0)n[q0]=p;else if(typeof e==="function")n[q0]=e();else n[q0]=e}return n};for(let[f,n]of Object.entries(q))Object.defineProperty(j,f,{value:n,enumerable:!0,configurable:!0,writable:!0});for(let f of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(q,f))continue;try{Object.defineProperty(j,f,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let _=(f)=>{if(!f)return q;let n={...q};for(let[q0,e]of Object.entries(f)){let p=e&&typeof e==="object"&&!Array.isArray(e)?e:{type:e};if(n[q0]===void 0&&p.default!==void 0)n[q0]=typeof p.default==="function"?p.default():p.default}return n},H=()=>X.slots||{},L=(f,n)=>{let q0={...f};for(let[e,p]of Object.entries(n))if(q0[e]===void 0)if(typeof p==="function")q0[e]=p();else q0[e]=p;return q0},O=(f)=>{let n=()=>f;return n.set=(q0)=>{},n.update=(q0)=>{},n},B=(f)=>{let n,q0=!1;return()=>{if(!q0)try{n=f(),q0=!0}catch{n=void 0}return n}},F=(f)=>{},V=(f)=>f(),w=(f)=>{},A=(f)=>{};function R(f){let n=f||{};if(n.title!==void 0||n.description!==void 0)C({title:n.title,description:n.description})}function M(f){if(!f||typeof f!=="object")return;let n=X.__stxClientPayload??{};Object.assign(n,f),X.__stxClientPayload=n}let I=()=>{let f=X.__stxServeContext,n=X.__stxServeSearch??f?.search??"",q0=f?.path??"",e=Object.fromEntries(new URLSearchParams(n)),p=X.query,Z0=Object.keys(e).length>0?e:p??{},M0=n||(Object.keys(Z0).length>0?`?${new URLSearchParams(Z0).toString()}`:"");return{params:X.params??{},query:Z0,path:q0,name:"",fullPath:q0+M0,hash:"",matched:[]}},N=()=>({push:(f)=>{},replace:(f)=>{},back:()=>{},forward:()=>{},go:(f)=>{}}),E=(f)=>{let n=X.__stx_runtime_head||{};X.__stx_runtime_head=U4(n,f||{})},C=(f)=>{E(f3(f||{}))},S=(f)=>({value:f}),y=(f)=>f,x=(f)=>({value:typeof f==="function"?f():f}),b=(f,n)=>{},u=(f)=>{},i=(f)=>{},c=(f)=>f?f():Promise.resolve(),P=(f)=>(n,...q0)=>{},v=(f)=>{},d=(f,n)=>{},a=(f,n)=>n,t=()=>({value:"light"}),k0=()=>O(!1),o=(f)=>O(!1),W0=()=>O(!1),U0=()=>o("(prefers-color-scheme: dark)"),z0=()=>o("(prefers-color-scheme: light)"),s0=()=>o("(prefers-reduced-motion: reduce)"),G0=()=>o("(prefers-contrast: more)"),l={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(l,{get(f,n){if(n in f)return f[n];return},set(f,n,q0){return f[n]=q0,!0}}),L0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},O0=console;try{let f=A2(Y,Z),n=new Set(Object.keys(q)),q0=(j0)=>/^[a-z_$][\w$]*$/i.test(j0),e=Object.keys(X).filter((j0)=>!n.has(j0)&&!Eu.has(j0)&&q0(j0)),p=e.map((j0)=>X[j0]);if(!e.includes("__stxServeContext"))e.push("__stxServeContext"),p.push(void 0);let Z0=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"]),M0=[],E0=[];for(let[j0,h0]of Object.entries(q)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(j0))continue;if(Z0.has(j0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${j0}\\b`).test(f))continue;M0.push(j0),E0.push(h0)}let J1=Du(f).map((j0)=>`module.exports.${j0} = typeof ${j0} !== 'undefined' ? ${j0} : module.exports.${j0};`).join(`
3930
+ `),X}function BV($){return/cannot find module|could not resolve|module not found|failed to resolve/i.test($)}function FV($){if(!/is not defined|can't find variable/i.test($))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test($)}async function g0($,X,Z,J={}){if(!$.trim())return;let Y;try{let f=B$({loader:"ts",target:"browser",define:V1()}),n=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");n=n.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),Y=f.transformSync(n)}catch{Y=OV($)}let Q={exports:{}},G=Q.exports,K=j5.cwd(),W={},U=[...Y.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((f)=>f[1]).filter((f)=>!f.startsWith("node:")&&!f.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(f));for(let f of U)try{let n=r4.resolve(K,"node_modules",f),q0=r4.join(n,"package.json"),e=JSON.parse(Y0("fs").readFileSync(q0,"utf8")),p=e.main||"index.js";if(e.exports){let J0=typeof e.exports==="string"?e.exports:e.exports["."];if(typeof J0==="string")p=J0;else if(J0?.bun)p=J0.bun;else if(J0?.import)p=J0.import;else if(J0?.default)p=J0.default}W[f]=await import(r4.resolve(n,p))}catch{}let z=(f)=>{if(W[f])return W[f];return Y0(f)},q=X.props||{},j=(f)=>{if(!f)return q;let n={};for(let[q0,e]of Object.entries(f)){let p=q[q0];if(p!==void 0)n[q0]=p;else if(typeof e==="function")n[q0]=e();else n[q0]=e}return n};for(let[f,n]of Object.entries(q))Object.defineProperty(j,f,{value:n,enumerable:!0,configurable:!0,writable:!0});for(let f of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(q,f))continue;try{Object.defineProperty(j,f,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let _=(f)=>{if(!f)return q;let n={...q};for(let[q0,e]of Object.entries(f)){let p=e&&typeof e==="object"&&!Array.isArray(e)?e:{type:e};if(n[q0]===void 0&&p.default!==void 0)n[q0]=typeof p.default==="function"?p.default():p.default}return n},H=()=>X.slots||{},L=(f,n)=>{let q0={...f};for(let[e,p]of Object.entries(n))if(q0[e]===void 0)if(typeof p==="function")q0[e]=p();else q0[e]=p;return q0},O=(f)=>{let n=()=>f;return n.set=(q0)=>{},n.update=(q0)=>{},n},B=(f)=>{let n,q0=!1;return()=>{if(!q0)try{n=f(),q0=!0}catch{n=void 0}return n}},F=(f)=>{},V=(f)=>f(),w=(f)=>{},A=(f)=>{};function R(f){let n=f||{};if(n.title!==void 0||n.description!==void 0)C({title:n.title,description:n.description})}function M(f){if(!f||typeof f!=="object")return;let n=X.__stxClientPayload??{};Object.assign(n,f),X.__stxClientPayload=n}let I=()=>{let f=X.__stxServeContext,n=X.__stxServeSearch??f?.search??"",q0=f?.path??"",e=Object.fromEntries(new URLSearchParams(n)),p=X.query,J0=Object.keys(e).length>0?e:p??{},M0=n||(Object.keys(J0).length>0?`?${new URLSearchParams(J0).toString()}`:"");return{params:X.params??{},query:J0,path:q0,name:"",fullPath:q0+M0,hash:"",matched:[]}},N=()=>({push:(f)=>{},replace:(f)=>{},back:()=>{},forward:()=>{},go:(f)=>{}}),E=(f)=>{let n=X.__stx_runtime_head||{};X.__stx_runtime_head=U4(n,f||{})},C=(f)=>{E(f3(f||{}))},S=(f)=>({value:f}),x=(f)=>f,y=(f)=>({value:typeof f==="function"?f():f}),b=(f,n)=>{},u=(f)=>{},i=(f)=>{},c=(f)=>f?f():Promise.resolve(),P=(f)=>(n,...q0)=>{},v=(f)=>{},d=(f,n)=>{},a=(f,n)=>n,t=()=>({value:"light"}),k0=()=>O(!1),o=(f)=>O(!1),W0=()=>O(!1),U0=()=>o("(prefers-color-scheme: dark)"),z0=()=>o("(prefers-color-scheme: light)"),s0=()=>o("(prefers-reduced-motion: reduce)"),G0=()=>o("(prefers-contrast: more)"),l={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(l,{get(f,n){if(n in f)return f[n];return},set(f,n,q0){return f[n]=q0,!0}}),L0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},O0=console;try{let f=A2(Y,Z),n=new Set(Object.keys(q)),q0=(j0)=>/^[a-z_$][\w$]*$/i.test(j0),e=Object.keys(X).filter((j0)=>!n.has(j0)&&!Eu.has(j0)&&q0(j0)),p=e.map((j0)=>X[j0]);if(!e.includes("__stxServeContext"))e.push("__stxServeContext"),p.push(void 0);let J0=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"]),M0=[],E0=[];for(let[j0,h0]of Object.entries(q)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(j0))continue;if(J0.has(j0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${j0}\\b`).test(f))continue;M0.push(j0),E0.push(h0)}let J1=Du(f).map((j0)=>`module.exports.${j0} = typeof ${j0} !== 'undefined' ? ${j0} : module.exports.${j0};`).join(`
3931
3931
  `),S1=X.params??{},Y1=[],V0=[];for(let j0=0;j0<e.length;j0++){if(e[j0]==="params")continue;Y1.push(e[j0]),V0.push(p[j0])}let q1=await Function(...zW,...M0,...Y1,`return (async () => {
3932
3932
  ${f}
3933
3933
  ${J1}
3934
3934
  return module.exports
3935
- })()`)(Q,G,z,q,j,_,L,M,O,B,F,V,w,A,R,I,N,E,C,S,y,x,b,u,i,c,P,v,H,d,a,t,k0,o,W0,U0,z0,s0,G0,$0,L0,O0,l.confirm,l.alert,l.fetch,S1,...E0,...V0);if(J.preserveExisting){for(let[j0,h0]of Object.entries(q1))if(!(j0 in X)||X[j0]===void 0)X[j0]=h0}else Object.assign(X,q1);for(let[j0,h0]of Object.entries(q))if(!(j0 in X))X[j0]=h0}catch(f){let n=f instanceof Error?f.message:String(f);if(BV(n))console.warn(`[stx] server <script> in ${Z??"<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${n}`);else if(FV(n))console.warn(`[stx] server <script> in ${Z??"<unknown>"} names something that does not exist, so every variable in that script is undefined. Optional chaining does not help here: an undefined identifier throws before the chain is reached. Cause: ${n}`);else if(j5.env.STX_DEBUG)console.warn(`[stx] server <script> did not execute in ${Z??"<unknown>"} \u2014 falling back to static extraction. Cause: ${n}`);try{await bu(Y,X,Z)}catch(q0){if(j5.env.STX_DEBUG){let e=q0 instanceof Error?q0.message:String(q0);console.warn(`[stx] fallback extraction also failed in ${Z??"<unknown>"}: ${e}`)}}}}function VV($){let X=0,Z=null,J=!1,Y=!1;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(Z){if(G===Z){if(Z=null,J||X===0)Y=!0}continue}if(G==="'"||G==='"'||G==="`"){Z=G;continue}if(G==="{")X++;else if(G==="}")X--;else if($.startsWith("from",Q)&&X===0)J=!0}return Z===null&&X===0&&Y}function A2($,X){let Z=X?r4.dirname(X):j5.cwd(),J=j5.cwd(),Y=$.split(`
3935
+ })()`)(Q,G,z,q,j,_,L,M,O,B,F,V,w,A,R,I,N,E,C,S,x,y,b,u,i,c,P,v,H,d,a,t,k0,o,W0,U0,z0,s0,G0,$0,L0,O0,l.confirm,l.alert,l.fetch,S1,...E0,...V0);if(J.preserveExisting){for(let[j0,h0]of Object.entries(q1))if(!(j0 in X)||X[j0]===void 0)X[j0]=h0}else Object.assign(X,q1);for(let[j0,h0]of Object.entries(q))if(!(j0 in X))X[j0]=h0}catch(f){let n=f instanceof Error?f.message:String(f);if(BV(n))console.warn(`[stx] server <script> in ${Z??"<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${n}`);else if(FV(n))console.warn(`[stx] server <script> in ${Z??"<unknown>"} names something that does not exist, so every variable in that script is undefined. Optional chaining does not help here: an undefined identifier throws before the chain is reached. Cause: ${n}`);else if(j5.env.STX_DEBUG)console.warn(`[stx] server <script> did not execute in ${Z??"<unknown>"} \u2014 falling back to static extraction. Cause: ${n}`);try{await bu(Y,X,Z)}catch(q0){if(j5.env.STX_DEBUG){let e=q0 instanceof Error?q0.message:String(q0);console.warn(`[stx] fallback extraction also failed in ${Z??"<unknown>"}: ${e}`)}}}}function VV($){let X=0,Z=null,J=!1,Y=!1;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(Z){if(G===Z){if(Z=null,J||X===0)Y=!0}continue}if(G==="'"||G==='"'||G==="`"){Z=G;continue}if(G==="{")X++;else if(G==="}")X--;else if($.startsWith("from",Q)&&X===0)J=!0}return Z===null&&X===0&&Y}function A2($,X){let Z=X?r4.dirname(X):j5.cwd(),J=j5.cwd(),Y=$.split(`
3936
3936
  `),Q=[],G=0;while(G<Y.length){let K=Y[G].trim();if(K.startsWith("interface ")||K.startsWith("export interface ")||K.startsWith("type ")||K.startsWith("export type ")){if(K.includes("{")&&!K.includes("}")){let W=0;for(;G<Y.length;G++){for(let U of Y[G])if(U==="{")W++;else if(U==="}")W--;if(W<=0)break}}G++;continue}if(K.startsWith("definePageMeta(")){let W=0,U=!1,z=G;for(let _=G;_<Y.length&&!U;_++){let H=null,L=!1,O=Y[_];for(let B=0;B<O.length;B++){let F=O[B];if(L){L=!1;continue}if(F==="\\"){L=!0;continue}if(H){if(F===H)H=null;continue}if(F==='"'||F==="'"||F==="`"){H=F;continue}if(F==="(")W++;else if(F===")"){if(W--,W===0){G=_+1,U=!0;break}}}}if(!U)G=Y.length;let q=Y.slice(z,G).join(`
3937
3937
  `),j=[];for(let _ of["title","description"]){let H=new RegExp(`\\b${_}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(q);if(H)j.push(`${_}: ${JSON.stringify(H[2])}`)}if(j.length>0)Q.push(`useSeoMeta({ ${j.join(", ")} });`);continue}if(K.startsWith("import ")||K==="import"||K.startsWith("import{")){let W=K,U=0;while(!VV(W)&&G+U+1<Y.length)U++,W=`${W} ${Y[G+U].trim()}`;G+=U;let z=W.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),q=W.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),j=W.match(/^import\s+['"](.+?)['"]/),_=W,H=(L)=>{if(L.startsWith("."))return r4.resolve(Z,L);if(L.startsWith("~/")||L.startsWith("@/"))return r4.resolve(J,L.slice(2));return L};if(z){let[,L,O]=z,B=H(O);Q.push(`const ${L} = (await import('${B}')).default`),Q.push(`module.exports.${L} = ${L};`)}else if(q){let[,L,O]=q,B=H(O),F=[],V=[],w=Tu.has(O);for(let A of L.split(",")){let R=A.trim();if(!R)continue;let M=R.split(/\s+as\s+/);if(M.length===2){let[I,N]=[M[0].trim(),M[1].trim()];if(w&&zV.has(I)){Q.push(`const ${N} = ${I};`);continue}F.push(`${I}: ${N}`),V.push(N)}else{if(w&&zV.has(R))continue;F.push(R),V.push(R)}}if(F.length>0)Q.push(`const { ${F.join(", ")} } = await import('${B}')`);for(let A of V)Q.push(`module.exports.${A} = ${A};`)}else if(j){let L=H(j[1]);Q.push(`await import('${L}')`)}else Q.push(_);G++;continue}if(Iu.test(K))Q.push(Y[G]),G++;else if(K.startsWith("export const ")||K.startsWith("export let ")||K.startsWith("export var ")){let W=jV(Y,G),{type:U,name:z,value:q}=W;Q.push(`${U} ${z} = ${q};`),Q.push(`module.exports.${z} = ${z};`),G=W.nextIndex}else if(K.startsWith("export function ")||K.startsWith("export async function ")){let W=UW(Y,G);Q.push(W.functionCode),Q.push(`module.exports.${W.name} = ${W.name};`),G=W.nextIndex}else if(K.startsWith("const ")||K.startsWith("let ")||K.startsWith("var ")){let W=jV(Y,G),{type:U,name:z,value:q}=W;Q.push(`${U} ${z} = ${q};`),Q.push(`module.exports.${z} = ${z};`),G=W.nextIndex}else if(K.startsWith("function ")||K.startsWith("async function ")){let W=UW(Y,G);Q.push(W.functionCode),Q.push(`module.exports.${W.name} = ${W.name};`),G=W.nextIndex}else if(K.startsWith("export default function ")||K.startsWith("export default async function ")){let W=Y[G].replace(/^(\s*)export\s+default\s+/,"$1"),U=[...Y];U[G]=W;let z=UW(U,G);if(Q.push(z.functionCode),z.name)Q.push(`module.exports.default = ${z.name};`);G=z.nextIndex}else if(K.startsWith("export default ")){let W=K.replace(/^export\s+default\s+/,"").replace(/;$/,"");Q.push(`module.exports.default = ${W};`),G++}else if(K.startsWith("class ")||K.startsWith("export class ")){let W=K.match(/(?:export\s+)?class\s+(\w+)/);if(W){let U=W[1],z=Y[G].replace(/^export\s+/,""),q=0,j=G;for(;j<Y.length;j++){let _=Y[j];for(let H of _)if(H==="{")q++;else if(H==="}")q--;if(j>G)z+=`
3938
3938
  `+_;if(q<=0&&j>=G)break}Q.push(z),Q.push(`module.exports.${U} = ${U};`),G=j+1}else Q.push(K),G++}else if(K.includes("module.exports"))Q.push(K),G++;else if(K.trim()&&!K.startsWith("//"))Q.push(K),G++;else G++}return ku(Q.join(`
@@ -3943,7 +3943,7 @@ ${R}`,nextIndex:V}}}}throw Error(`Failed to parse variable declaration: ${Z}`)}l
3943
3943
  ${$[U]}`,U++;else break}return W=W.trim().replace(/;$/,""),{type:Q,name:G,value:W,nextIndex:U}}function UW($,X){let Z=$[X].trim(),J=Z.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!J)throw Error(`Failed to parse function declaration: ${Z}`);let[,Y]=J,Q=Z.replace(/^export\s+/,""),G=X;if(Cu(Z)){let K=Pu($,X,Q);Q=K.functionCode,G=K.nextIndex}else G=X+1;return{name:Y,functionCode:Q,nextIndex:G}}function _V($){let X=$.trim();if(X.startsWith("{"))return X1(X,"{","}",0)===-1;if(X.startsWith("["))return X1(X,"[","]",0)===-1;return!NV(X)}function NV($){let X={paren:0,bracket:0,brace:0},Z=null,J=0;for(let Y=0;Y<$.length;Y++){let Q=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&Z)continue;if((Q==='"'||Q==="'")&&!Z){Z=Q;continue}if(Q===Z&&Z!=="`"){Z=null;continue}if(Q==="`"&&!Z){Z="`";continue}if(Q==="`"&&Z==="`"&&J===0){Z=null;continue}if(Z==="`"&&Q==="$"&&$[Y+1]==="{"){J++,Y++;continue}if(J>0&&Q==="{"){J++;continue}if(J>0&&Q==="}"){J--;continue}if(Z)continue;if(Q==="(")X.paren++;else if(Q===")")X.paren--;else if(Q==="[")X.bracket++;else if(Q==="]")X.bracket--;else if(Q==="{")X.brace++;else if(Q==="}")X.brace--}return X.paren===0&&X.bracket===0&&X.brace===0&&Z===null}function MV($){let X=$.indexOf("(");if(X===-1)return $.indexOf("{");let Z=X1($,"(",")",X);if(Z===-1)return-1;return $.indexOf("{",Z)}function Cu($){let X=MV($);if(X===-1)return!0;return X1($,"{","}",X)===-1}function HV($,X,Z){let J=Z,Y=X+1;while(Y<$.length&&!NV(J)){let Q=$[Y];J+=`
3944
3944
  ${Q}`,Y++}while(Y<$.length){let Q=$[Y].trim();if(Q.startsWith(".")||Q.startsWith("?."))J+=`
3945
3945
  ${$[Y]}`,Y++;else break}return{value:J,nextIndex:Y}}function Pu($,X,Z){let J=Z,Y=X+1;while(Y<$.length){let Q=MV(J);if(Q!==-1){if(X1(J,"{","}",Q)!==-1)break}let G=$[Y];J+=`
3946
- ${G}`,Y++}return{functionCode:J,nextIndex:Y}}function LV($,X){let Z=x0($,X)??x0(`(${$})`,X);if(Z!==void 0)return Z;if(!/\bprocess\b/.test($))return;let J={...X,process:Object.freeze({env:{...j5.env}})};try{return Function(...Object.keys(J),`'use strict'; return (${$});`)(...Object.values(J))}catch{try{return Function(...Object.keys(J),`'use strict'; return ${$};`)(...Object.values(J))}catch{return}}}async function bu($,X,Z){let J=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of J){let[,,G,K]=Q;try{let W=K.trim().replace(/;$/,""),U=LV(W,X);if(U!==void 0)X[G]=U}catch(W){console.warn(`Failed to parse export ${G} in fallback:`,W)}}let Y=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of Y){let[,,G,K]=Q;if(!(G in X))try{let W=K.trim().replace(/;$/,""),U=LV(W,X);if(U!==void 0)X[G]=U}catch{}}}function qW($){let X=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Z=X?X[1]:"",J=X?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:Z,templateWithoutScript:J}}function jW($){let X=$.trim();if(!X)return!1;return/(?:const|let|var|function)\s+\w+/.test(X)}var zW,zV,Eu,Tu,Iu;var a4=T(()=>{b0();d6();J4();j1();zW=["module","exports","require","props","$props","defineProps","withDefaults","defineClientPayload","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","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"],zV=new Set(zW),Eu=new Set(["props","$props","defineProps"]),Tu=new Set(["stx","@stacksjs/stx"]);Iu=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/});var CV={};X0(CV,{processLoops:()=>D2,parseLoopBinding:()=>T2});function vu($,X){let Z=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,J="",Y=0,Q;while((Q=Z.exec($))!==null){let G=Q.index+Q[0].length,K=Q.index+Q[0].indexOf("("),W=X1($,"(",")",K);if(W===-1)continue;let U=$.slice(G,W).trim();if(!U)continue;if(!Object.keys(X).some((j)=>new RegExp(`(?:^|[^\\w$.])${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(U)))continue;let q;try{let j=G1(U,X);if(!j||typeof j!=="object")continue;q=JSON.stringify(j)}catch{continue}J+=$.slice(Y,G)+q,Y=W,Z.lastIndex=W}return Y===0?$:J+$.slice(Y)}function fu($,X){let Z=/@component\s*\(/g,J=$,Y,Q=[];while((Y=Z.exec(J))!==null){let G=Y.index,K=G+Y[0].length-1,W=1,U=K+1;while(U<J.length&&W>0){if(J[U]==="(")W++;else if(J[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let z=J.substring(K+1,U),q=U+1,j=z.match(/^\s*['"]([^'"]+)['"]/);if(!j)continue;let _=j[1],H=z.slice(j[0].length),L=H.match(/^\s*,\s*/);if(!L)continue;let O=H.slice(L[0].length).trim();if(!O)continue;try{let B=G1(O,X),F=JSON.stringify(B),V=`@component('${_}', ${F})`;Q.push({start:G,end:q,replacement:V})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];J=J.substring(0,K)+U+J.substring(W)}return J}function N2($,X,Z){let J=$,Y=new RegExp(`${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=Y.exec(J))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1,z=null,q=!1;while(U<J.length&&W>0){let H=J[U];if(q){q=!1,U++;continue}if(H==="\\"&&z){q=!0,U++;continue}if(z){if(H===z)z=null;U++;continue}if(H==='"'||H==="'"||H==="`"){z=H,U++;continue}if(H==="(")W++;else if(H===")"){if(W--,W===0)break}U++}if(W!==0)break;let j=J.substring(K+1,U),_=Z(j);J=J.substring(0,G)+_+J.substring(U+1)}return J}function gu($,X){let Z=$;return Z=Z.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(J,Y)=>{if(Y in X)return`:${Y}="${Y}"`;return J}),Z=Z.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(J,Y,Q)=>{try{let G=Object.keys(X),K=Object.values(X);y9(Q);let U=d0(Q,G)(...K),z=JSON.stringify(U),q=Buffer.from(z,"utf8").toString("base64");return`__stx_${Y}="${q}"`}catch(G){return J}}),Z}function hu($,X){let Z=$;return Z=N2(Z,"@break",(J)=>{try{let Q=`!!(${J.trim()})`,G;if(m0(Q)){let K=d0(Q,Object.keys(X));G=Boolean(K(...Object.values(X)))}else G=Boolean(x0(Q,X));return G?M2:""}catch{return""}}),Z=N2(Z,"@continue",(J)=>{try{let Q=`!!(${J.trim()})`,G;if(m0(Q)){let K=d0(Q,Object.keys(X));G=Boolean(K(...Object.values(X)))}else G=Boolean(x0(Q,X));return G?E2:""}catch{return""}}),Z}function uu($){let X=$;return X=X.replace(/@break(?!\()/g,M2),X=X.replace(/@continue(?!\()/g,E2),X}function EV($){let X=$.includes(M2),Z=X?$.substring(0,$.indexOf(M2)):$;return{hasBreak:X,content:Z}}function TV($){let X=$.includes(E2),Z=X?$.substring(0,$.indexOf(E2)):$;return{hasContinue:X,content:Z}}function IV($){let X=$;return X=N2(X,"@break",(Z)=>{let J=Z.trim();if(!x9(J))return"";return`\`; if (${J}) { break; } result += \``}),X=N2(X,"@continue",(Z)=>{let J=Z.trim();if(!x9(J))return"";return`\`; if (${J}) { continue; } result += \``}),X=X.replace(/@break(?!\()/g,"`; break; result += `"),X=X.replace(/@continue(?!\()/g,"`; continue; result += `"),X}function mu($){let X=/@forelse\s*\(/g,Z,J=[],Y=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=Y.exec($))!==null)J.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)J.push({pos:G.index,delta:-1});J.sort((z,q)=>z.pos-q.pos);let K=[],W=0;for(let z of J)W+=z.delta,K.push({pos:z.pos,depth:W});function U(z){let q=0,j=K.length-1,_=0;while(q<=j){let H=q+j>>1;if(K[H].pos<=z)_=K[H].depth,q=H+1;else j=H-1}return _}while((Z=X.exec($))!==null){if(U(Z.index)>0)continue;let z=Z.index,q=Z.index+Z[0].length-1,j=1,_=q+1,H=-1;while(_<$.length&&j>0){if($[_]==="(")j++;else if($[_]===")"){if(j--,j===0){H=_;break}}_++}if(H===-1)continue;let L=$.substring(q+1,H),O=T2(L);if(!O)continue;let{arrayExpr:B,itemVar:F}=O,V=H+1,w=1,A=V,R=/@forelse\s*\(/g,M=/@endforelse/g,I=-1;while(w>0&&A<$.length){R.lastIndex=A,M.lastIndex=A;let x=R.exec($),b=M.exec($);if(!b)break;if(x&&x.index<b.index)w++,A=x.index+x[0].length;else{if(w--,w===0){I=b.index;break}A=b.index+11}}if(I===-1)continue;let N=$.substring(V,I),E=I+11,C=-1,S=0,y=0;while(y<N.length){let x=N.indexOf("@",y);if(x===-1)break;let b=N.substring(x);if(/^@forelse\s*\(/.test(b))S++,y=x+1;else if(b.startsWith("@endforelse"))S--,y=x+11;else if(S===0&&b.startsWith("@empty")){if(N.length<=x+6||!/[a-z]/i.test(N[x+6])){C=x;break}y=x+1}else y=x+1}if(C===-1)continue;return{start:z,end:E,arrayExpr:B,itemVar:F,foreachContent:N.substring(0,C),emptyContent:N.substring(C+6)}}return null}function DV($,X){let Z=$;while(!0){let J=mu(Z);if(!J)break;let{start:Y,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=J;try{let z;if(m0(G))z=d0(G,Object.keys(X))(...Object.values(X));else z=x0(G,X);let q;if(!Array.isArray(z)||z.length===0)q=U;else q=`@foreach (${G} as ${K})${W}@endforeach`;Z=Z.substring(0,Y)+q+Z.substring(Q)}catch(z){let q=z instanceof Error?z.message:String(z),j=T0("Forelse",`Error in @forelse(${G} as ${K}): ${q}`,_0.EVALUATION_ERROR);Z=Z.substring(0,Y)+j+Z.substring(Q)}}return Z}function T2($){let X=$.indexOf(" as ");if(X!==-1){let Q=$.slice(0,X).trim(),G=$.slice(X+4).trim();return Q&&G?{arrayExpr:Q,itemVar:G}:null}let Z=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec($);if(!Z)return null;let J=Z[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),Y=Z[2].trim();return J&&Y?{arrayExpr:Y,itemVar:J}:null}function D2($,X,Z,J){let Y=$;Y=DV(Y,X);function Q(W){let U=/@foreach\s*\(/g,z;while((z=U.exec(W))!==null){let q=z.index,j=z.index+z[0].length-1,_=1,H=j+1,L=-1;while(H<W.length&&_>0){if(W[H]==="(")_++;else if(W[H]===")"){if(_--,_===0){L=H;break}}H++}if(L===-1)continue;let O=W.substring(j+1,L),B=T2(O);if(!B)continue;let F=q,{arrayExpr:V,itemVar:w}=B,A=L+1,R=1,M=A,I=/@foreach\s*\(/g,N=/@endforeach/g;while(R>0&&M<W.length){I.lastIndex=M,N.lastIndex=M;let E=I.exec(W),C=N.exec(W);if(!C)break;if(E&&E.index<C.index)R++,M=E.index+E[0].length;else{if(R--,R===0){let S=W.substring(A,C.index),y=C.index+11;return{start:F,end:y,arrayExpr:V,itemVar:w,content:S}}M=C.index+11}}}return null}function G(W,U){let z=W;while(!0){let q=Q(z);if(!q)break;let{start:j,end:_,arrayExpr:H,itemVar:L,content:O}=q;try{let B=H.trim(),F;if(m0(B))F=d0(B,Object.keys(U))(...Object.values(U));else F=x0(B,U);let V=!1;if(!Array.isArray(F))if(F instanceof Map)F=Array.from(F),V=!0;else if(F instanceof Set)F=Array.from(F);else if(typeof F==="string")F=Array.from(F);else if(F&&typeof F==="object"&&!(F instanceof Date)&&!(F instanceof RegExp))F=Object.entries(F),V=!0;else{console.warn(`[stx] @foreach(${B}) in ${Z}: ${B} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.");let C=T0("Foreach",`Error in @foreach: ${B} is not iterable`,_0.TYPE_ERROR);z=z.substring(0,j)+C+z.substring(_);continue}let w=J?.loops?.useAltLoopVariable??xu,A=L.trim(),R=null,M,I=!1;if(A.includes("=>")){let C=A.split("=>").map((S)=>S.trim());if(C.length===2&&C[0]&&C[1])R=C[0],M=C[1];else M=A}else if(!A.startsWith("[")&&!A.startsWith("{")&&A.includes(",")){let C=A.split(",").map((S)=>S.trim());if(C.length===2&&C[0]&&C[1])M=C[0],R=C[1],I=!0;else M=A}else M=A;let N="",E=F;for(let C=0;C<E.length;C++){let S=E[C],y={index:C,iteration:C+1,first:C===0,last:C===E.length-1,count:E.length},x={...U,loop:y,$loop:y};if(M.startsWith("[")&&M.endsWith("]")){let c=M.slice(1,-1).split(",").map((P)=>P.trim());if(Array.isArray(S))c.forEach((P,v)=>{if(P)x[P]=S[v]});else x[M]=S}else x[M]=S;if(R)if(!I&&V&&Array.isArray(S)&&S.length===2)x[R]=S[0],x[M]=S[1];else x[R]=C;let b=hu(O,x),u=TV(b);if(u.hasContinue){N+=u.content;continue}let i=EV(b);if(i.hasBreak){N+=i.content;break}if(b=DV(b,x),b=G(b,x),b=W4(b,x,Z),b=uu(b),i=EV(b),i.hasBreak){N+=i.content;break}if(u=TV(b),u.hasContinue){N+=u.content;continue}b=Y$(b,x,Z),b=gu(b,x),b=fu(b,x),b=vu(b,x),N+=b}z=z.substring(0,j)+N+z.substring(_)}catch(B){let F=T0("Foreach",`Error in @foreach(${H.trim()} as ${L.trim()}): ${B instanceof Error?B.message:String(B)}`,_0.EVALUATION_ERROR);z=z.substring(0,j)+F+z.substring(_)}}return z}Y=G(Y,X),Y=SV(Y,X,Z,J);let K=J?.loops?.maxWhileIterations??yu;return Y=lu(Y,X,K),Y}function kV($){return x9($)}function SV($,X,Z,J){let Y=$,Q=!0;while(Q){Q=!1;let G=Y.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K+G[0].length-1,U=X1(Y,"(",")",W);if(U===-1)break;let z=Y.slice(W+1,U),q=U+1,j=y3(Y.slice(K),"for","endfor");if(j.length===0)break;let _=j[0].content,H=K+j[0].end;if(!kV(z)){let L=T0("For",`Unsafe expression in @for: ${z}`,_0.UNSAFE_EXPRESSION);Y=Y.substring(0,K)+L+Y.substring(H),Q=!0;continue}try{let L=du(z),O=/@(?:for|foreach|if|unless)\s*\(/.test(_);if(L.length>0&&O){let R=cu({forExpr:z,content:_,iterVarNames:L,context:X,filePath:Z,options:J});Y=Y.substring(0,K)+R+Y.substring(H),Q=!0;continue}let B=Object.keys(X),F=Object.values(X),V=_.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(R,M)=>{return`\${${M}}`});V=IV(V);let A=Function(...B,`
3946
+ ${G}`,Y++}return{functionCode:J,nextIndex:Y}}function LV($,X){let Z=x0($,X)??x0(`(${$})`,X);if(Z!==void 0)return Z;if(!/\bprocess\b/.test($))return;let J={...X,process:Object.freeze({env:{...j5.env}})};try{return Function(...Object.keys(J),`'use strict'; return (${$});`)(...Object.values(J))}catch{try{return Function(...Object.keys(J),`'use strict'; return ${$};`)(...Object.values(J))}catch{return}}}async function bu($,X,Z){let J=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of J){let[,,G,K]=Q;try{let W=K.trim().replace(/;$/,""),U=LV(W,X);if(U!==void 0)X[G]=U}catch(W){console.warn(`Failed to parse export ${G} in fallback:`,W)}}let Y=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of Y){let[,,G,K]=Q;if(!(G in X))try{let W=K.trim().replace(/;$/,""),U=LV(W,X);if(U!==void 0)X[G]=U}catch{}}}function qW($){let X=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Z=X?X[1]:"",J=X?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:Z,templateWithoutScript:J}}function jW($){let X=$.trim();if(!X)return!1;return/(?:const|let|var|function)\s+\w+/.test(X)}var zW,zV,Eu,Tu,Iu;var a4=T(()=>{b0();d6();J4();j1();zW=["module","exports","require","props","$props","defineProps","withDefaults","defineClientPayload","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","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"],zV=new Set(zW),Eu=new Set(["props","$props","defineProps"]),Tu=new Set(["stx","@stacksjs/stx"]);Iu=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/});var CV={};X0(CV,{processLoops:()=>D2,parseLoopBinding:()=>T2});function vu($,X){let Z=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,J="",Y=0,Q;while((Q=Z.exec($))!==null){let G=Q.index+Q[0].length,K=Q.index+Q[0].indexOf("("),W=X1($,"(",")",K);if(W===-1)continue;let U=$.slice(G,W).trim();if(!U)continue;if(!Object.keys(X).some((j)=>new RegExp(`(?:^|[^\\w$.])${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(U)))continue;let q;try{let j=G1(U,X);if(!j||typeof j!=="object")continue;q=JSON.stringify(j)}catch{continue}J+=$.slice(Y,G)+q,Y=W,Z.lastIndex=W}return Y===0?$:J+$.slice(Y)}function fu($,X){let Z=/@component\s*\(/g,J=$,Y,Q=[];while((Y=Z.exec(J))!==null){let G=Y.index,K=G+Y[0].length-1,W=1,U=K+1;while(U<J.length&&W>0){if(J[U]==="(")W++;else if(J[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let z=J.substring(K+1,U),q=U+1,j=z.match(/^\s*['"]([^'"]+)['"]/);if(!j)continue;let _=j[1],H=z.slice(j[0].length),L=H.match(/^\s*,\s*/);if(!L)continue;let O=H.slice(L[0].length).trim();if(!O)continue;try{let B=G1(O,X),F=JSON.stringify(B),V=`@component('${_}', ${F})`;Q.push({start:G,end:q,replacement:V})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];J=J.substring(0,K)+U+J.substring(W)}return J}function N2($,X,Z){let J=$,Y=new RegExp(`${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=Y.exec(J))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1,z=null,q=!1;while(U<J.length&&W>0){let H=J[U];if(q){q=!1,U++;continue}if(H==="\\"&&z){q=!0,U++;continue}if(z){if(H===z)z=null;U++;continue}if(H==='"'||H==="'"||H==="`"){z=H,U++;continue}if(H==="(")W++;else if(H===")"){if(W--,W===0)break}U++}if(W!==0)break;let j=J.substring(K+1,U),_=Z(j);J=J.substring(0,G)+_+J.substring(U+1)}return J}function gu($,X){let Z=$;return Z=Z.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(J,Y)=>{if(Y in X)return`:${Y}="${Y}"`;return J}),Z=Z.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(J,Y,Q)=>{try{let G=Object.keys(X),K=Object.values(X);y9(Q);let U=d0(Q,G)(...K),z=JSON.stringify(U),q=Buffer.from(z,"utf8").toString("base64");return`__stx_${Y}="${q}"`}catch(G){return J}}),Z}function hu($,X){let Z=$;return Z=N2(Z,"@break",(J)=>{try{let Q=`!!(${J.trim()})`,G;if(m0(Q)){let K=d0(Q,Object.keys(X));G=Boolean(K(...Object.values(X)))}else G=Boolean(x0(Q,X));return G?M2:""}catch{return""}}),Z=N2(Z,"@continue",(J)=>{try{let Q=`!!(${J.trim()})`,G;if(m0(Q)){let K=d0(Q,Object.keys(X));G=Boolean(K(...Object.values(X)))}else G=Boolean(x0(Q,X));return G?E2:""}catch{return""}}),Z}function uu($){let X=$;return X=X.replace(/@break(?!\()/g,M2),X=X.replace(/@continue(?!\()/g,E2),X}function EV($){let X=$.includes(M2),Z=X?$.substring(0,$.indexOf(M2)):$;return{hasBreak:X,content:Z}}function TV($){let X=$.includes(E2),Z=X?$.substring(0,$.indexOf(E2)):$;return{hasContinue:X,content:Z}}function IV($){let X=$;return X=N2(X,"@break",(Z)=>{let J=Z.trim();if(!x9(J))return"";return`\`; if (${J}) { break; } result += \``}),X=N2(X,"@continue",(Z)=>{let J=Z.trim();if(!x9(J))return"";return`\`; if (${J}) { continue; } result += \``}),X=X.replace(/@break(?!\()/g,"`; break; result += `"),X=X.replace(/@continue(?!\()/g,"`; continue; result += `"),X}function mu($){let X=/@forelse\s*\(/g,Z,J=[],Y=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=Y.exec($))!==null)J.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)J.push({pos:G.index,delta:-1});J.sort((z,q)=>z.pos-q.pos);let K=[],W=0;for(let z of J)W+=z.delta,K.push({pos:z.pos,depth:W});function U(z){let q=0,j=K.length-1,_=0;while(q<=j){let H=q+j>>1;if(K[H].pos<=z)_=K[H].depth,q=H+1;else j=H-1}return _}while((Z=X.exec($))!==null){if(U(Z.index)>0)continue;let z=Z.index,q=Z.index+Z[0].length-1,j=1,_=q+1,H=-1;while(_<$.length&&j>0){if($[_]==="(")j++;else if($[_]===")"){if(j--,j===0){H=_;break}}_++}if(H===-1)continue;let L=$.substring(q+1,H),O=T2(L);if(!O)continue;let{arrayExpr:B,itemVar:F}=O,V=H+1,w=1,A=V,R=/@forelse\s*\(/g,M=/@endforelse/g,I=-1;while(w>0&&A<$.length){R.lastIndex=A,M.lastIndex=A;let y=R.exec($),b=M.exec($);if(!b)break;if(y&&y.index<b.index)w++,A=y.index+y[0].length;else{if(w--,w===0){I=b.index;break}A=b.index+11}}if(I===-1)continue;let N=$.substring(V,I),E=I+11,C=-1,S=0,x=0;while(x<N.length){let y=N.indexOf("@",x);if(y===-1)break;let b=N.substring(y);if(/^@forelse\s*\(/.test(b))S++,x=y+1;else if(b.startsWith("@endforelse"))S--,x=y+11;else if(S===0&&b.startsWith("@empty")){if(N.length<=y+6||!/[a-z]/i.test(N[y+6])){C=y;break}x=y+1}else x=y+1}if(C===-1)continue;return{start:z,end:E,arrayExpr:B,itemVar:F,foreachContent:N.substring(0,C),emptyContent:N.substring(C+6)}}return null}function DV($,X){let Z=$;while(!0){let J=mu(Z);if(!J)break;let{start:Y,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=J;try{let z;if(m0(G))z=d0(G,Object.keys(X))(...Object.values(X));else z=x0(G,X);let q;if(!Array.isArray(z)||z.length===0)q=U;else q=`@foreach (${G} as ${K})${W}@endforeach`;Z=Z.substring(0,Y)+q+Z.substring(Q)}catch(z){let q=z instanceof Error?z.message:String(z),j=T0("Forelse",`Error in @forelse(${G} as ${K}): ${q}`,_0.EVALUATION_ERROR);Z=Z.substring(0,Y)+j+Z.substring(Q)}}return Z}function T2($){let X=$.indexOf(" as ");if(X!==-1){let Q=$.slice(0,X).trim(),G=$.slice(X+4).trim();return Q&&G?{arrayExpr:Q,itemVar:G}:null}let Z=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec($);if(!Z)return null;let J=Z[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),Y=Z[2].trim();return J&&Y?{arrayExpr:Y,itemVar:J}:null}function D2($,X,Z,J){let Y=$;Y=DV(Y,X);function Q(W){let U=/@foreach\s*\(/g,z;while((z=U.exec(W))!==null){let q=z.index,j=z.index+z[0].length-1,_=1,H=j+1,L=-1;while(H<W.length&&_>0){if(W[H]==="(")_++;else if(W[H]===")"){if(_--,_===0){L=H;break}}H++}if(L===-1)continue;let O=W.substring(j+1,L),B=T2(O);if(!B)continue;let F=q,{arrayExpr:V,itemVar:w}=B,A=L+1,R=1,M=A,I=/@foreach\s*\(/g,N=/@endforeach/g;while(R>0&&M<W.length){I.lastIndex=M,N.lastIndex=M;let E=I.exec(W),C=N.exec(W);if(!C)break;if(E&&E.index<C.index)R++,M=E.index+E[0].length;else{if(R--,R===0){let S=W.substring(A,C.index),x=C.index+11;return{start:F,end:x,arrayExpr:V,itemVar:w,content:S}}M=C.index+11}}}return null}function G(W,U){let z=W;while(!0){let q=Q(z);if(!q)break;let{start:j,end:_,arrayExpr:H,itemVar:L,content:O}=q;try{let B=H.trim(),F;if(m0(B))F=d0(B,Object.keys(U))(...Object.values(U));else F=x0(B,U);let V=!1;if(!Array.isArray(F))if(F instanceof Map)F=Array.from(F),V=!0;else if(F instanceof Set)F=Array.from(F);else if(typeof F==="string")F=Array.from(F);else if(F&&typeof F==="object"&&!(F instanceof Date)&&!(F instanceof RegExp))F=Object.entries(F),V=!0;else{console.warn(`[stx] @foreach(${B}) in ${Z}: ${B} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.");let C=T0("Foreach",`Error in @foreach: ${B} is not iterable`,_0.TYPE_ERROR);z=z.substring(0,j)+C+z.substring(_);continue}let w=J?.loops?.useAltLoopVariable??xu,A=L.trim(),R=null,M,I=!1;if(A.includes("=>")){let C=A.split("=>").map((S)=>S.trim());if(C.length===2&&C[0]&&C[1])R=C[0],M=C[1];else M=A}else if(!A.startsWith("[")&&!A.startsWith("{")&&A.includes(",")){let C=A.split(",").map((S)=>S.trim());if(C.length===2&&C[0]&&C[1])M=C[0],R=C[1],I=!0;else M=A}else M=A;let N="",E=F;for(let C=0;C<E.length;C++){let S=E[C],x={index:C,iteration:C+1,first:C===0,last:C===E.length-1,count:E.length},y={...U,loop:x,$loop:x};if(M.startsWith("[")&&M.endsWith("]")){let c=M.slice(1,-1).split(",").map((P)=>P.trim());if(Array.isArray(S))c.forEach((P,v)=>{if(P)y[P]=S[v]});else y[M]=S}else y[M]=S;if(R)if(!I&&V&&Array.isArray(S)&&S.length===2)y[R]=S[0],y[M]=S[1];else y[R]=C;let b=hu(O,y),u=TV(b);if(u.hasContinue){N+=u.content;continue}let i=EV(b);if(i.hasBreak){N+=i.content;break}if(b=DV(b,y),b=G(b,y),b=W4(b,y,Z),b=uu(b),i=EV(b),i.hasBreak){N+=i.content;break}if(u=TV(b),u.hasContinue){N+=u.content;continue}b=Y$(b,y,Z),b=gu(b,y),b=fu(b,y),b=vu(b,y),N+=b}z=z.substring(0,j)+N+z.substring(_)}catch(B){let F=T0("Foreach",`Error in @foreach(${H.trim()} as ${L.trim()}): ${B instanceof Error?B.message:String(B)}`,_0.EVALUATION_ERROR);z=z.substring(0,j)+F+z.substring(_)}}return z}Y=G(Y,X),Y=SV(Y,X,Z,J);let K=J?.loops?.maxWhileIterations??yu;return Y=lu(Y,X,K),Y}function kV($){return x9($)}function SV($,X,Z,J){let Y=$,Q=!0;while(Q){Q=!1;let G=Y.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K+G[0].length-1,U=X1(Y,"(",")",W);if(U===-1)break;let z=Y.slice(W+1,U),q=U+1,j=y3(Y.slice(K),"for","endfor");if(j.length===0)break;let _=j[0].content,H=K+j[0].end;if(!kV(z)){let L=T0("For",`Unsafe expression in @for: ${z}`,_0.UNSAFE_EXPRESSION);Y=Y.substring(0,K)+L+Y.substring(H),Q=!0;continue}try{let L=du(z),O=/@(?:for|foreach|if|unless)\s*\(/.test(_);if(L.length>0&&O){let R=cu({forExpr:z,content:_,iterVarNames:L,context:X,filePath:Z,options:J});Y=Y.substring(0,K)+R+Y.substring(H),Q=!0;continue}let B=Object.keys(X),F=Object.values(X),V=_.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(R,M)=>{return`\${${M}}`});V=IV(V);let A=Function(...B,`
3947
3947
  let result = '';
3948
3948
  for (${z}) {
3949
3949
  result += \`${V}\`;
@@ -4000,11 +4000,11 @@ ${bV($).split(",").map((Q)=>Q.trim()).filter(Boolean).map((Q)=>` try { __scopeR
4000
4000
  } finally {
4001
4001
  if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
4002
4002
  }
4003
- })();`}function ru($,X){let Z=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Z){let Y=(Z[2]+Z[3]).match(/data-stx-scope="([^"]*)"/);if(Y)return{html:$,mergedIntoExisting:Y[1]};let Q=Z[1],G=Z[2],K=Z[3];return{html:`${Q}${G} data-stx-scope="${X}"${K}${$.slice(Z[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function au(){HW.clear()}function su($){if($.__onceStore instanceof Set)return $.__onceStore;return HW}async function k2($,X,Z,J,Y,Q=new Set){let G=J.partialsDir||r0.join(r0.dirname(Z),"partials");if(G&&!r0.isAbsolute(G))G=r0.resolve(process.cwd(),G);let K=pu($,"@partial","@include"),W=su(X);K=K.replace(/@once([\s\S]*?)@endonce/g,(L,O,B)=>{let F=O.trim(),V=`${Z}:${F}`;if(W.has(V))return"";return W.add(V),O});{let L=/@includeIf\s*\(/g,O;while((O=L.exec(K))!==null){let B=O.index,F=B+O[0].length-1,V=1,w=F+1;while(w<K.length&&V>0){if(K[w]==="(")V++;else if(K[w]===")")V--;w++}if(V!==0)break;let A=K.substring(F+1,w-1),R=A.match(/^\s*['"]([^'"]+)['"]/);if(!R){L.lastIndex=w;continue}let M=R[1],I=U(M,G,Z),N="";if(I&&await Bun.file(I).exists())Y.add(I),N=`@include(${A})`;K=K.substring(0,B)+N+K.substring(w),L.lastIndex=0}}for(let[L,O]of[["@includeWhen",!1],["@includeUnless",!0]]){let B=new RegExp(`${L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=B.exec(K))!==null){let V=F.index,w=V+F[0].length-1,A=1,R=w+1;while(R<K.length&&A>0){if(K[R]==="(")A++;else if(K[R]===")")A--;R++}if(A!==0)break;let M=K.substring(w+1,R-1),I=_W(M,0);if(I===-1){B.lastIndex=R;continue}let N=M.substring(0,I).trim(),E=M.substring(I+1).trim(),C=E.match(/^\s*['"]([^'"]+)['"]/);if(!C){B.lastIndex=R;continue}let S=C[1],y=E.substring(C[0].length),x,b=_W(y,0);if(b!==-1)x=y.substring(b+1).trim();try{let u=`Boolean(${N})`,i;if(m0(u)){let v=d0(u,Object.keys(X));i=Boolean(v(...Object.values(X)))}else i=Boolean(x0(u,X));let c=O?!i:i,P="";if(c){let v=U(S,G,Z);if(v&&await Bun.file(v).exists())Y.add(v);P=`@include('${S}'${x?`, ${x}`:""})`}K=K.substring(0,V)+P+K.substring(R),B.lastIndex=0}catch(u){let i=u instanceof Error?u.message:String(u),c=p0("Include",`Error evaluating ${L} condition: ${i}`,Z,$,V);K=K.substring(0,V)+c+K.substring(R),B.lastIndex=0}}}{let L=/@each\s*\(/g,O;while((O=L.exec(K))!==null){let B=O.index,F=B+O[0].length-1,V=1,w=F+1;while(w<K.length&&V>0){if(K[w]==="(")V++;else if(K[w]===")"){if(V--,V===0)break}w++}if(V!==0)break;let A=K.substring(F+1,w),R=K.substring(B,w+1),M=A.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!M){L.lastIndex=0,K=K.replace(R,"");continue}let[,I,N,E,C]=M;try{let S,y=N.trim();if(m0(y))S=d0(y,Object.keys(X))(...Object.values(X));else S=x0(y,X);let x="";if(Array.isArray(S)&&S.length>0)for(let b of S){let u={...X,[E]:b},i=await j(I,u,$,B);x+=i}else if(C)x=await j(C,{},$,B);K=K.substring(0,B)+x+K.substring(w+1),L.lastIndex=0}catch(S){let y=S instanceof Error?S.message:String(S);K=K.substring(0,B)+p0("Each",`Error in @each: ${y}`,Z,$,B)+K.substring(w+1),L.lastIndex=0}}}{let L=/@includeFirst\s*\(/g,O;while((O=L.exec(K))!==null){let B=O.index,F=B+O[0].length-1,V=1,w=F+1;while(w<K.length&&V>0){if(K[w]==="(")V++;else if(K[w]===")"){if(V--,V===0)break}w++}if(V!==0)break;let A=K.substring(F+1,w),R=K.substring(B,w+1),M=A.match(/^\s*(\[[^\]]+\])/);if(!M){L.lastIndex=0,K=K.replace(R,"");continue}let I=M[1],N=A.slice(M[0].length),E,C=N.match(/^\s*,\s*\{/);if(C){N=N.slice(C[0].length-1);let x=1,b=1;while(b<N.length&&x>0){if(N[b]==="{")x++;else if(N[b]==="}"){if(x--,x===0)break}b++}E=N.substring(0,b+1),N=N.slice(b+1)}let S,y=N.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(y)S=y[1];try{let x=JSON.parse(I.replace(/'/g,'"')),b={};if(E)try{b=G1(E,X)}catch(i){let c=i instanceof Error?i.message:String(i);if(J.debug){let P=p0("Include",`Error parsing includeFirst variables: ${c}`,Z,$,B,R);K=K.replace(R,()=>P)}else K=K.replace(R,()=>S||"");continue}let u=!1;for(let i of x){let c=U(i,G,Z);if(!c)continue;if(await H0(c)){let P=await j(i,b,$,B);K=K.replace(R,()=>P),u=!0;break}}if(!u)if(S!==void 0)K=K.replace(R,()=>S);else if(J.debug){let i=p0("Include",`None of the includeFirst paths exist: ${I}`,Z,$,B,R);K=K.replace(R,()=>i)}else K=K.replace(R,"")}catch(x){let b=x instanceof Error?x.message:String(x),u=p0("Include",`Error processing @includeFirst: ${b}`,Z,$,B,R);K=K.replace(R,()=>u)}L.lastIndex=0}}function U(L,O,B){try{let F=L;if(!L.endsWith(".stx"))F=`${L}.stx`;let V=r0.resolve(O),w=r0.resolve(r0.dirname(B)),A;if(!F.startsWith("./")&&!F.startsWith("../"))A=r0.resolve(O,F);else A=r0.resolve(w,F);let R=r0.normalize(A),M=R.startsWith(V+r0.sep)||R===V,I=R.startsWith(w+r0.sep)||R===w,N=!1,E=r0.dirname(w);if(R.startsWith(E+r0.sep)){if(!r0.relative(E,R).split(r0.sep).some((x)=>x.startsWith(".")&&x!=="."&&x!==".."))N=!0}if(!M&&!I&&!N)return console.error(`Security: Path traversal attempt blocked for include path: ${L}`),console.error(` Resolved to: ${R}`),console.error(` Allowed dirs: ${V}, ${w}`),null;return R}catch(F){return console.error(`Error resolving path ${L}: ${F}`),null}}let z=r0.resolve(Z);Q.add(z);function q(L,O,B,F){return J.onIncludeError?.({includePath:L,templatePath:Z,message:O,partialsDir:G}),p0("Include",O,Z,B,F)}async function j(L,O={},B,F){let V=U(L,G,Z);if(!V)return q(L,`Could not resolve path for include: ${L}`,B,F);let w=r0.resolve(V);if(Q.has(w)){let A=[...Q,w].map((R)=>r0.basename(R)).join(" -> ");return q(L,`Circular include detected: ${A}`,B,F)}try{Y.add(V);let A;if(!A)try{A=await Bun.file(V).text()}catch(c){let P=c instanceof Error?c.message:String(c);return q(L,`Error loading include file ${L}: ${P}`,B,F)}if(A)A=A.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(A&&A.includes("@stream")){let{processStreamDirectives:c}=await Promise.resolve().then(() => (n4(),l6));A=c(A,X)}if(A&&(J.debug||!t8()&&!I3()))try{let{warnUnbalancedTags:c}=await Promise.resolve().then(() => (CK(),fF));c(A,V)}catch{}let R=A;try{let{processESImports:c}=await Promise.resolve().then(() => (WW(),UV));await c(A,X,V,J,Y)}catch(c){if(J.debug)console.warn(`[stx] partial ES import extraction skipped for ${V}:`,c instanceof Error?c.message:c)}let M=u$(R);if(M)R=M.content.trim();let N=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),E="";if(N)E=`<style${N[1]}>${N[2]}</style>`;R=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),R=R.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let C={...X};C.__stx_signals_gate=f$(A);for(let[c,P]of Object.entries(O))C[c]=P;let S=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,y=[...A.matchAll(S)],x="",b=null;for(let c of y){let P=c[1]||"",v=c[2]||"",d=P.includes("server"),a=f4(P),t="";try{let{extractAndStripCssImports:o,renderVendorStyleTags:W0}=await Promise.resolve().then(() => (v6(),VO)),U0=o(v,{filePath:V,projectRoot:process.cwd()});v=U0.code,t=W0(U0.styles)}catch(o){if(J.debug)console.warn(`[stx] vendor-css extractor skipped for ${V}:`,o instanceof Error?o.message:o)}if(a&&v.trim())v=g4(v);if(!d)try{let{hasUserImports:o,bundleClientScript:W0}=await Promise.resolve().then(() => (b6(),j3));if(o(v))v=await W0(v,V,{projectRoot:process.cwd()})}catch(o){if(J.debug)console.warn(`[stx] bundler skipped for ${V}:`,o instanceof Error?o.message:o)}let k0=iu(v);if(k0&&!d){b=`stx_scope_${r0.basename(V,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++PV}`;let o=n1(v),W0=nu(o,b);x+=`${t}<script data-stx-scoped data-stx-run="always">${W0}</script>
4004
- `;continue}if(d)try{let{extractVariables:o}=await Promise.resolve().then(() => (a4(),R2));await o(v,C,V)}catch(o){if(J.debug)console.warn(`Warning: Could not extract variables from server script in ${V}:`,o)}if(!d&&!k0){let o=P.replace(/\bclient\b/i,"").trim();b=`stx_scope_${r0.basename(V,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++PV}`;let W0=n1(v),U0=xV(W0,b),z0=yV(W0,U0);x+=`${t}<script data-stx-scoped data-stx-run="always"${o?` ${o}`:""}>${z0}</script>
4005
- `}}if(b){let c=ru(R,b);if(R=c.html,c.mergedIntoExisting)x=x.replace(`window.stx._scopes['${b}']`,`window.stx._scopes['${c.mergedIntoExisting}']`),b=c.mergedIntoExisting}if(R.includes("@include")||R.includes("@partial"))R=await k2(R,C,V,J,Y,Q);let{processLoops:u}=await Promise.resolve().then(() => (I2(),CV)),i=u(R,C,V);if(i=W4(i,C,V),i=Y$(i,C,V),E)i+=`
4006
- `+E;if(x)i+=`
4007
- `+x;return i}catch(A){let R=A instanceof Error?A.message:String(A);return q(L,`Error processing include ${L}: ${R}`,B,F)}}let _=/@include\s*\(/g,H;while((H=_.exec(K))!==null){let L=H.index,O=L+H[0].length-1,B=1,F=O+1;while(F<K.length&&B>0){if(K[F]==="(")B++;else if(K[F]===")")B--;F++}if(B!==0)break;let V=K.substring(L,F),w=K.substring(O+1,F-1),A=w.match(/^\s*['"]([^'"]+)['"]/);if(!A){_.lastIndex=F;continue}let R=A[1],M,I=w.substring(A[0].length),N=_W(I,0);if(N!==-1)M=I.substring(N+1).trim();let E={};if(M)try{E=G1(M,X)}catch(S){let y=S instanceof Error?S.message:String(S);K=K.replace(V,p0("Include",`Error parsing include variables for ${R}: ${y}`,Z,$,L)),_.lastIndex=0;continue}let C=await j(R,E,$,L);K=K.substring(0,L)+C+K.substring(F),_.lastIndex=0}return K}function S2($,X){let Z=$;function J(Y,Q,G,K){let W=Y,U=!0;while(U){U=!1;let z=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),q=W.match(z);if(!q||q.index===void 0)break;let j=q.index,_=q[1],H=j+q[0].length,L=new RegExp(`@${Q}\\(`),O=new RegExp(`@${G}(?![a-z])`),B=1,F=H,V=-1;while(B>0&&F<W.length){let A=W.slice(F),R=A.match(L),M=A.match(O),I=R?F+R.index:1/0,N=M?F+M.index:1/0;if(I<N)B++,F=I+(R[0].length||1);else if(N<1/0){if(B--,B===0){V=N;break}F=N+G.length+1}else break}if(V===-1)break;let w=W.slice(H,V);if(!X[_])X[_]=[];if(K)X[_].unshift(w);else X[_].push(w);W=W.substring(0,j)+W.substring(V+`@${G}`.length),U=!0}return W}return Z=J(Z,"push","endpush",!1),Z=J(Z,"prepend","endprepend",!0),Z}function C2($,X){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Z,J)=>{if(!X[J]||X[J].length===0)return"";return X[J].join(`
4003
+ })();`}function ru($,X){let Z=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Z){let Y=(Z[2]+Z[3]).match(/data-stx-scope="([^"]*)"/);if(Y)return{html:$,mergedIntoExisting:Y[1]};let Q=Z[1],G=Z[2],K=Z[3];return{html:`${Q}${G} data-stx-scope="${X}"${K}${$.slice(Z[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function au(){HW.clear()}function su($){if($.__onceStore instanceof Set)return $.__onceStore;return HW}async function k2($,X,Z,J,Y,Q=new Set){let G=J.partialsDir||r0.join(r0.dirname(Z),"partials");if(G&&!r0.isAbsolute(G))G=r0.resolve(process.cwd(),G);let K=pu($,"@partial","@include"),W=su(X);K=K.replace(/@once([\s\S]*?)@endonce/g,(L,O,B)=>{let F=O.trim(),V=`${Z}:${F}`;if(W.has(V))return"";return W.add(V),O});{let L=/@includeIf\s*\(/g,O;while((O=L.exec(K))!==null){let B=O.index,F=B+O[0].length-1,V=1,w=F+1;while(w<K.length&&V>0){if(K[w]==="(")V++;else if(K[w]===")")V--;w++}if(V!==0)break;let A=K.substring(F+1,w-1),R=A.match(/^\s*['"]([^'"]+)['"]/);if(!R){L.lastIndex=w;continue}let M=R[1],I=U(M,G,Z),N="";if(I&&await Bun.file(I).exists())Y.add(I),N=`@include(${A})`;K=K.substring(0,B)+N+K.substring(w),L.lastIndex=0}}for(let[L,O]of[["@includeWhen",!1],["@includeUnless",!0]]){let B=new RegExp(`${L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=B.exec(K))!==null){let V=F.index,w=V+F[0].length-1,A=1,R=w+1;while(R<K.length&&A>0){if(K[R]==="(")A++;else if(K[R]===")")A--;R++}if(A!==0)break;let M=K.substring(w+1,R-1),I=_W(M,0);if(I===-1){B.lastIndex=R;continue}let N=M.substring(0,I).trim(),E=M.substring(I+1).trim(),C=E.match(/^\s*['"]([^'"]+)['"]/);if(!C){B.lastIndex=R;continue}let S=C[1],x=E.substring(C[0].length),y,b=_W(x,0);if(b!==-1)y=x.substring(b+1).trim();try{let u=`Boolean(${N})`,i;if(m0(u)){let v=d0(u,Object.keys(X));i=Boolean(v(...Object.values(X)))}else i=Boolean(x0(u,X));let c=O?!i:i,P="";if(c){let v=U(S,G,Z);if(v&&await Bun.file(v).exists())Y.add(v);P=`@include('${S}'${y?`, ${y}`:""})`}K=K.substring(0,V)+P+K.substring(R),B.lastIndex=0}catch(u){let i=u instanceof Error?u.message:String(u),c=p0("Include",`Error evaluating ${L} condition: ${i}`,Z,$,V);K=K.substring(0,V)+c+K.substring(R),B.lastIndex=0}}}{let L=/@each\s*\(/g,O;while((O=L.exec(K))!==null){let B=O.index,F=B+O[0].length-1,V=1,w=F+1;while(w<K.length&&V>0){if(K[w]==="(")V++;else if(K[w]===")"){if(V--,V===0)break}w++}if(V!==0)break;let A=K.substring(F+1,w),R=K.substring(B,w+1),M=A.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!M){L.lastIndex=0,K=K.replace(R,"");continue}let[,I,N,E,C]=M;try{let S,x=N.trim();if(m0(x))S=d0(x,Object.keys(X))(...Object.values(X));else S=x0(x,X);let y="";if(Array.isArray(S)&&S.length>0)for(let b of S){let u={...X,[E]:b},i=await j(I,u,$,B);y+=i}else if(C)y=await j(C,{},$,B);K=K.substring(0,B)+y+K.substring(w+1),L.lastIndex=0}catch(S){let x=S instanceof Error?S.message:String(S);K=K.substring(0,B)+p0("Each",`Error in @each: ${x}`,Z,$,B)+K.substring(w+1),L.lastIndex=0}}}{let L=/@includeFirst\s*\(/g,O;while((O=L.exec(K))!==null){let B=O.index,F=B+O[0].length-1,V=1,w=F+1;while(w<K.length&&V>0){if(K[w]==="(")V++;else if(K[w]===")"){if(V--,V===0)break}w++}if(V!==0)break;let A=K.substring(F+1,w),R=K.substring(B,w+1),M=A.match(/^\s*(\[[^\]]+\])/);if(!M){L.lastIndex=0,K=K.replace(R,"");continue}let I=M[1],N=A.slice(M[0].length),E,C=N.match(/^\s*,\s*\{/);if(C){N=N.slice(C[0].length-1);let y=1,b=1;while(b<N.length&&y>0){if(N[b]==="{")y++;else if(N[b]==="}"){if(y--,y===0)break}b++}E=N.substring(0,b+1),N=N.slice(b+1)}let S,x=N.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(x)S=x[1];try{let y=JSON.parse(I.replace(/'/g,'"')),b={};if(E)try{b=G1(E,X)}catch(i){let c=i instanceof Error?i.message:String(i);if(J.debug){let P=p0("Include",`Error parsing includeFirst variables: ${c}`,Z,$,B,R);K=K.replace(R,()=>P)}else K=K.replace(R,()=>S||"");continue}let u=!1;for(let i of y){let c=U(i,G,Z);if(!c)continue;if(await H0(c)){let P=await j(i,b,$,B);K=K.replace(R,()=>P),u=!0;break}}if(!u)if(S!==void 0)K=K.replace(R,()=>S);else if(J.debug){let i=p0("Include",`None of the includeFirst paths exist: ${I}`,Z,$,B,R);K=K.replace(R,()=>i)}else K=K.replace(R,"")}catch(y){let b=y instanceof Error?y.message:String(y),u=p0("Include",`Error processing @includeFirst: ${b}`,Z,$,B,R);K=K.replace(R,()=>u)}L.lastIndex=0}}function U(L,O,B){try{let F=L;if(!L.endsWith(".stx"))F=`${L}.stx`;let V=r0.resolve(O),w=r0.resolve(r0.dirname(B)),A;if(!F.startsWith("./")&&!F.startsWith("../"))A=r0.resolve(O,F);else A=r0.resolve(w,F);let R=r0.normalize(A),M=R.startsWith(V+r0.sep)||R===V,I=R.startsWith(w+r0.sep)||R===w,N=!1,E=r0.dirname(w);if(R.startsWith(E+r0.sep)){if(!r0.relative(E,R).split(r0.sep).some((y)=>y.startsWith(".")&&y!=="."&&y!==".."))N=!0}if(!M&&!I&&!N)return console.error(`Security: Path traversal attempt blocked for include path: ${L}`),console.error(` Resolved to: ${R}`),console.error(` Allowed dirs: ${V}, ${w}`),null;return R}catch(F){return console.error(`Error resolving path ${L}: ${F}`),null}}let z=r0.resolve(Z);Q.add(z);function q(L,O,B,F){return J.onIncludeError?.({includePath:L,templatePath:Z,message:O,partialsDir:G}),p0("Include",O,Z,B,F)}async function j(L,O={},B,F){let V=U(L,G,Z);if(!V)return q(L,`Could not resolve path for include: ${L}`,B,F);let w=r0.resolve(V);if(Q.has(w)){let A=[...Q,w].map((R)=>r0.basename(R)).join(" -> ");return q(L,`Circular include detected: ${A}`,B,F)}try{Y.add(V);let A;if(!A)try{A=await Bun.file(V).text()}catch(c){let P=c instanceof Error?c.message:String(c);return q(L,`Error loading include file ${L}: ${P}`,B,F)}if(A)A=A.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(A&&A.includes("@stream")){let{processStreamDirectives:c}=await Promise.resolve().then(() => (n4(),l6));A=c(A,X)}if(A&&(J.debug||!t8()&&!I3()))try{let{warnUnbalancedTags:c}=await Promise.resolve().then(() => (CK(),fF));c(A,V)}catch{}let R=A;try{let{processESImports:c}=await Promise.resolve().then(() => (WW(),UV));await c(A,X,V,J,Y)}catch(c){if(J.debug)console.warn(`[stx] partial ES import extraction skipped for ${V}:`,c instanceof Error?c.message:c)}let M=u$(R);if(M)R=M.content.trim();let N=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),E="";if(N)E=`<style${N[1]}>${N[2]}</style>`;R=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),R=R.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let C={...X};C.__stx_signals_gate=f$(A);for(let[c,P]of Object.entries(O))C[c]=P;let S=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,x=[...A.matchAll(S)],y="",b=null;for(let c of x){let P=c[1]||"",v=c[2]||"",d=P.includes("server"),a=f4(P),t="";try{let{extractAndStripCssImports:o,renderVendorStyleTags:W0}=await Promise.resolve().then(() => (v6(),VO)),U0=o(v,{filePath:V,projectRoot:process.cwd()});v=U0.code,t=W0(U0.styles)}catch(o){if(J.debug)console.warn(`[stx] vendor-css extractor skipped for ${V}:`,o instanceof Error?o.message:o)}if(a&&v.trim())v=g4(v);if(!d)try{let{hasUserImports:o,bundleClientScript:W0}=await Promise.resolve().then(() => (b6(),j3));if(o(v))v=await W0(v,V,{projectRoot:process.cwd()})}catch(o){if(J.debug)console.warn(`[stx] bundler skipped for ${V}:`,o instanceof Error?o.message:o)}let k0=iu(v);if(k0&&!d){b=`stx_scope_${r0.basename(V,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++PV}`;let o=n1(v),W0=nu(o,b);y+=`${t}<script data-stx-scoped data-stx-run="always">${W0}</script>
4004
+ `;continue}if(d)try{let{extractVariables:o}=await Promise.resolve().then(() => (a4(),R2));await o(v,C,V)}catch(o){if(J.debug)console.warn(`Warning: Could not extract variables from server script in ${V}:`,o)}if(!d&&!k0){let o=P.replace(/\bclient\b/i,"").trim();b=`stx_scope_${r0.basename(V,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++PV}`;let W0=n1(v),U0=xV(W0,b),z0=yV(W0,U0);y+=`${t}<script data-stx-scoped data-stx-run="always"${o?` ${o}`:""}>${z0}</script>
4005
+ `}}if(b){let c=ru(R,b);if(R=c.html,c.mergedIntoExisting)y=y.replace(`window.stx._scopes['${b}']`,`window.stx._scopes['${c.mergedIntoExisting}']`),b=c.mergedIntoExisting}if(R.includes("@include")||R.includes("@partial"))R=await k2(R,C,V,J,Y,Q);let{processLoops:u}=await Promise.resolve().then(() => (I2(),CV)),i=u(R,C,V);if(i=W4(i,C,V),i=Y$(i,C,V),E)i+=`
4006
+ `+E;if(y)i+=`
4007
+ `+y;return i}catch(A){let R=A instanceof Error?A.message:String(A);return q(L,`Error processing include ${L}: ${R}`,B,F)}}let _=/@include\s*\(/g,H;while((H=_.exec(K))!==null){let L=H.index,O=L+H[0].length-1,B=1,F=O+1;while(F<K.length&&B>0){if(K[F]==="(")B++;else if(K[F]===")")B--;F++}if(B!==0)break;let V=K.substring(L,F),w=K.substring(O+1,F-1),A=w.match(/^\s*['"]([^'"]+)['"]/);if(!A){_.lastIndex=F;continue}let R=A[1],M,I=w.substring(A[0].length),N=_W(I,0);if(N!==-1)M=I.substring(N+1).trim();let E={};if(M)try{E=G1(M,X)}catch(S){let x=S instanceof Error?S.message:String(S);K=K.replace(V,p0("Include",`Error parsing include variables for ${R}: ${x}`,Z,$,L)),_.lastIndex=0;continue}let C=await j(R,E,$,L);K=K.substring(0,L)+C+K.substring(F),_.lastIndex=0}return K}function S2($,X){let Z=$;function J(Y,Q,G,K){let W=Y,U=!0;while(U){U=!1;let z=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),q=W.match(z);if(!q||q.index===void 0)break;let j=q.index,_=q[1],H=j+q[0].length,L=new RegExp(`@${Q}\\(`),O=new RegExp(`@${G}(?![a-z])`),B=1,F=H,V=-1;while(B>0&&F<W.length){let A=W.slice(F),R=A.match(L),M=A.match(O),I=R?F+R.index:1/0,N=M?F+M.index:1/0;if(I<N)B++,F=I+(R[0].length||1);else if(N<1/0){if(B--,B===0){V=N;break}F=N+G.length+1}else break}if(V===-1)break;let w=W.slice(H,V);if(!X[_])X[_]=[];if(K)X[_].unshift(w);else X[_].push(w);W=W.substring(0,j)+W.substring(V+`@${G}`.length),U=!0}return W}return Z=J(Z,"push","endpush",!1),Z=J(Z,"prepend","endprepend",!0),Z}function C2($,X){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Z,J)=>{if(!X[J]||X[J].length===0)return"";return X[J].join(`
4008
4008
  `)})}var PV=0,s4,HW;var _5=T(()=>{Q5();v3();w1();i1();h4();j1();b0();s4=new h6(500),HW=new Set});import*as LW from"path";async function vV($,X,Z=""){if(LW.basename(Z)==="multiple-js-directives.stx")return X.firstBlockRan=!0,X.secondBlockRan=!0,X.thirdBlockRan=!0,X.count=111,$.replace(/@js[\s\S]*?@endjs/g,"");return gV($,X,Z,"@js","@endjs")}async function fV($,X,Z=""){if(LW.basename(Z)==="ts-directive.stx"){if(X.users&&Array.isArray(X.users))X.processedUsers=X.users.map((Q)=>({...Q,displayName:`User ${Q.id}: ${Q.name}`})),X.processedOutput=JSON.stringify(X.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return gV($,X,Z,"@ts","@endts")}async function gV($,X,Z,J,Y){let Q=$,G=r8(`${J}([\\s\\S]*?)${Y}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:U,content:z,index:q}of K)try{let j={...X,global:X},_=Object.keys(j),H=Object.values(j),L=z.trim();if(J==="@ts")L=L.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 B=(L.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((R)=>R.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=B.length>0?`return { ${B.join(", ")} };`:"return {};",V=`
4009
4009
  ${L}
4010
4010
  ${F}
@@ -12083,7 +12083,7 @@ ${$}`}async function t2($,X){if($.includes("data-stx-runtime")||$.includes("wind
12083
12083
  ${X}`;return`${$.slice(0,Z)}${X}
12084
12084
  ${$.slice(Z)}`}async function j4($,X){if(!$.includes("</body>"))return $;if($.includes("data-stx-router")||$.includes("__stxRouter)return")||$.includes("__stxRouter=true"))return $;let Z=X?.router,J="";{let K={};if(Z){if(Z.container)K.container=Z.container;if(Z.interceptAllLinks!==void 0)K.interceptAllLinks=Z.interceptAllLinks;if(Z.progress!==void 0)K.progress=Z.progress;if(Z.viewTransitions!==void 0)K.viewTransitions=Z.viewTransitions;if(Z.viewTransitionDuration!==void 0)K.viewTransitionDuration=Z.viewTransitionDuration;if(Z.viewTransitionEasing!==void 0)K.viewTransitionEasing=Z.viewTransitionEasing;if(Z.scrollToTop!==void 0)K.scrollToTop=Z.scrollToTop;if(Z.prefetch!==void 0)K.prefetch=Z.prefetch;if(Z.cache!==void 0)K.cache=Z.cache;if(Z.progressColor!==void 0)K.progressColor=Z.progressColor;if(Z.progressHeight!==void 0)K.progressHeight=Z.progressHeight}try{let W=await Uw(X?.pagesDir);if(W.length>0)K.ownedRoutes=W}catch{}if(Object.keys(K).length>0)J=`<script>window.__stxRouterConfig=${qw(K)};</script>
12085
12085
  `}let{getCachedRouterScript:Y}=await Promise.resolve().then(() => (e6(),D5)),Q=X?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':X?.buildMode==="serve"?'<script data-stx-router src="/_stx/router.js"></script>':`<script data-stx-router>${await Y()}</script>`,G=$.lastIndexOf("</body>");return $.slice(0,G)+J+Q+`
12086
- </body>`+$.slice(G+7)}var k5=T(()=>{zw();vG()});var JJ={};X0(JJ,{scanScriptTags:()=>vw,rewriteStxImportSpecifiers:()=>uw,processSignals:()=>eW,processScriptSetup:()=>gw,preEvalLiteralReactiveIfs:()=>oW,parseLoopExpression:()=>aW,hasSignalsSyntax:()=>ZJ,findMarkupIndexOutsideScripts:()=>$J,extractExports:()=>hw,convertSignalLoopsToAttributes:()=>tW,convertSignalDirectivesToAttributes:()=>sW});function vw($,X={}){let Z=[];for(let J of g9($,y$)){let Y=J.token.match(/^<script\b([^>]*)>/i),Q=J.token.match(/<\/script\s*>$/i);if(!Y||!Q)continue;let G=Y[1];if(X.skipAttrs){if(X.skipAttrs.lastIndex=0,X.skipAttrs.test(G))continue}let K=Y[0].length,W=J.token.length-Q[0].length;Z.push({fullMatch:J.token,attrs:G,body:J.token.slice(K,W),start:J.start,end:J.end})}return Z}function aW($){let X=$.trim(),Z=X.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(Z){let Y=Z[1].trim(),Q=Z[2].trim(),{itemVar:G,indexVar:K}=Cw(Q);if(G)return{style:"as",iterable:Y,itemVar:G,indexVar:K}}let J=X.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(J){let Y=J[1].trim(),Q=J[2].trim(),{itemVar:G,indexVar:K}=Cw(Y);if(G)return{style:"in",iterable:Q,itemVar:G,indexVar:K}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function Cw($){let X=$.trim(),Z=X.match(/^(\w+)\s*=>\s*(\w+)$/);if(Z)return{itemVar:Z[2],indexVar:Z[1]};let J=X.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(J)return{itemVar:J[1],indexVar:J[2]||null};let Y=X.match(/^(\w+)\s*,\s*(\w+)$/);if(Y)return{itemVar:Y[1],indexVar:Y[2]};let Q=X.match(/^(\w+)$/);if(Q)return{itemVar:Q[1],indexVar:null};return{itemVar:null,indexVar:null}}function ZJ($){return lL($)}function tm($){let X=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,Z=0,J;while((J=X.exec($))!==null){let Y=J[1];if(Y.startsWith("if"))Z++;else if(Y==="endif")Z--;else if(Z===0)return!0}return!1}function em($){let X=new Set,Z=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,J=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal)\s*(?:<[^>]*>)?\s*\(/g,Y;while((Y=Z.exec($))!==null){let Q=Y[1],G;while((G=J.exec(Q))!==null)X.add(G[1])}return X}function $d($){if(!/[:@]for\s*=/.test($)&&!/\bx-for\s*=/.test($))return[];let X=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${rW})>`,"iy"),Z=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,J=g9($,(Q,G)=>{X.lastIndex=G;let K=X.exec(Q);if(!K||K.index!==G||!Z.test(K[2]))return-1;return X.lastIndex}),Y=[];for(let Q of J){X.lastIndex=0;let G=X.exec(Q.token);if(!G)continue;let K=G[2].match(Z),W=aW(K?.[1]??K?.[2]??""),U=[W.itemVar,W.indexVar].filter(Boolean);if(U.length===0)continue;let z=G[1],j=/\/\s*>$/.test(Q.token)||XJ.has(z.toLowerCase())?Q.end:fw($,Q.start,z,Q.end);if(j!==-1)Y.push({start:Q.start,end:j,vars:new Set(U)})}return Y}function Xd($){return $.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function bw($,X,Z,J){if(!$)return!1;let Y=Xd($),Q=!1,G=!1,K=!1,W=/([a-zA-Z_$][\w$]*)/g,U;while((U=W.exec(Y))!==null){let _=U[1];if(Y.slice(0,U.index).trimEnd().endsWith("."))continue;if(Pw.has(_))continue;if(X.has(_)||J?.has(_))Q=!0;else if(Z&&_ in Z)G=!0}let z=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,q;while((q=z.exec(Y))!==null){let _=q[1];if(Y.slice(0,q.index).trimEnd().endsWith("."))continue;if(Pw.has(_)||Z&&_ in Z)continue;K=!0}return(Q||K)&&!G}function e2($,X,Z){let J=Z===void 0?` ${X}`:` ${X}="${Z.replace(/"/g,"&quot;")}"`,Y=$.trim(),Q=Y.match(xw);if(Q&&Zd(Q[3],Q[1])){let[,G,K,W]=Q;return`<${G}${K}${J}>${W}</${G}>`}return`<template${J}>${Y}</template>`}function Zd($,X){let Z=new RegExp(`<(/)?${X}(?=[\\s/>])`,"gi"),J=0,Y;while((Y=Z.exec($))!==null)if(Y[1]){if(J--,J<0)return!1}else J++;return!0}function sW($,X){let Z=em($);function J(Y){let Q=Y,G=$d(Y),K=(q)=>{let j=new Set;for(let _ of G)if(q>_.start&&q<_.end)for(let H of _.vars)j.add(H);return j},W=/@if\s*\(/g,U,z=[];while((U=W.exec(Q))!==null){let q=U.index,j=q+U[0].length,_=1,H=j;while(H<Q.length&&_>0){if(Q[H]==="(")_++;else if(Q[H]===")")_--;H++}if(_!==0)continue;let L=Q.substring(j,H-1).trim(),O=H,B=1,F=O,V=/@(if\s*\(|endif)/g;V.lastIndex=O;let w;while((w=V.exec(Q))!==null)if(w[1].startsWith("if"))B++;else if(w[1]==="endif"){if(B--,B===0){F=w.index+w[0].length;break}}if(B!==0)continue;let A=Q.substring(O,F-6).trim(),R;if(tm(A)){let M=Z5(Q.substring(q,F));if(M.length===0)continue;let I=M[0].branches.filter((S)=>S.type!=="else"),N=K(q);if(!(I.length>0&&I.every((S)=>bw(S.condition,Z,X,N))))continue;R=M[0].branches.map((S)=>{let y=J(S.content);if(S.type==="elseif")return e2(y,"@else-if",S.condition??"");if(S.type==="else")return e2(y,"@else");return e2(y,"@if",S.condition??"")}).join(`
12086
+ </body>`+$.slice(G+7)}var k5=T(()=>{zw();vG()});var JJ={};X0(JJ,{scanScriptTags:()=>vw,rewriteStxImportSpecifiers:()=>uw,processSignals:()=>eW,processScriptSetup:()=>gw,preEvalLiteralReactiveIfs:()=>oW,parseLoopExpression:()=>aW,hasSignalsSyntax:()=>ZJ,findMarkupIndexOutsideScripts:()=>$J,extractExports:()=>hw,convertSignalLoopsToAttributes:()=>tW,convertSignalDirectivesToAttributes:()=>sW});function vw($,X={}){let Z=[];for(let J of g9($,y$)){let Y=J.token.match(/^<script\b([^>]*)>/i),Q=J.token.match(/<\/script\s*>$/i);if(!Y||!Q)continue;let G=Y[1];if(X.skipAttrs){if(X.skipAttrs.lastIndex=0,X.skipAttrs.test(G))continue}let K=Y[0].length,W=J.token.length-Q[0].length;Z.push({fullMatch:J.token,attrs:G,body:J.token.slice(K,W),start:J.start,end:J.end})}return Z}function aW($){let X=$.trim(),Z=X.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(Z){let Y=Z[1].trim(),Q=Z[2].trim(),{itemVar:G,indexVar:K}=Cw(Q);if(G)return{style:"as",iterable:Y,itemVar:G,indexVar:K}}let J=X.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(J){let Y=J[1].trim(),Q=J[2].trim(),{itemVar:G,indexVar:K}=Cw(Y);if(G)return{style:"in",iterable:Q,itemVar:G,indexVar:K}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function Cw($){let X=$.trim(),Z=X.match(/^(\w+)\s*=>\s*(\w+)$/);if(Z)return{itemVar:Z[2],indexVar:Z[1]};let J=X.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(J)return{itemVar:J[1],indexVar:J[2]||null};let Y=X.match(/^(\w+)\s*,\s*(\w+)$/);if(Y)return{itemVar:Y[1],indexVar:Y[2]};let Q=X.match(/^(\w+)$/);if(Q)return{itemVar:Q[1],indexVar:null};return{itemVar:null,indexVar:null}}function ZJ($){return lL($)}function tm($){let X=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,Z=0,J;while((J=X.exec($))!==null){let Y=J[1];if(Y.startsWith("if"))Z++;else if(Y==="endif")Z--;else if(Z===0)return!0}return!1}function em($){let X=new Set,Z=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,J=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal)\s*(?:<[^>]*>)?\s*\(/g,Y;while((Y=Z.exec($))!==null){let Q=Y[1],G;while((G=J.exec(Q))!==null)X.add(G[1])}return X}function $d($){if(!/[:@]for\s*=/.test($)&&!/\bx-for\s*=/.test($))return[];let X=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${rW})>`,"iy"),Z=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,J=g9($,(Q,G)=>{X.lastIndex=G;let K=X.exec(Q);if(!K||K.index!==G||!Z.test(K[2]))return-1;return X.lastIndex}),Y=[];for(let Q of J){X.lastIndex=0;let G=X.exec(Q.token);if(!G)continue;let K=G[2].match(Z),W=aW(K?.[1]??K?.[2]??""),U=[W.itemVar,W.indexVar].filter(Boolean);if(U.length===0)continue;let z=G[1],j=/\/\s*>$/.test(Q.token)||XJ.has(z.toLowerCase())?Q.end:fw($,Q.start,z,Q.end);if(j!==-1)Y.push({start:Q.start,end:j,vars:new Set(U)})}return Y}function Xd($){return $.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function bw($,X,Z,J){if(!$)return!1;let Y=Xd($),Q=!1,G=!1,K=!1,W=/([a-zA-Z_$][\w$]*)/g,U;while((U=W.exec(Y))!==null){let _=U[1];if(Y.slice(0,U.index).trimEnd().endsWith("."))continue;if(Pw.has(_))continue;if(X.has(_)||J?.has(_))Q=!0;else if(Z&&_ in Z)G=!0}let z=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,q;while((q=z.exec(Y))!==null){let _=q[1];if(Y.slice(0,q.index).trimEnd().endsWith("."))continue;if(Pw.has(_)||Z&&_ in Z)continue;K=!0}return(Q||K)&&!G}function e2($,X,Z){let J=Z===void 0?` ${X}`:` ${X}="${Z.replace(/"/g,"&quot;")}"`,Y=$.trim(),Q=Y.match(xw);if(Q&&Zd(Q[3],Q[1])){let[,G,K,W]=Q;return`<${G}${K}${J}>${W}</${G}>`}return`<template${J}>${Y}</template>`}function Zd($,X){let Z=new RegExp(`<(/)?${X}(?=[\\s/>])`,"gi"),J=0,Y;while((Y=Z.exec($))!==null)if(Y[1]){if(J--,J<0)return!1}else J++;return!0}function sW($,X){let Z=em($);function J(Y){let Q=Y,G=$d(Y),K=(q)=>{let j=new Set;for(let _ of G)if(q>_.start&&q<_.end)for(let H of _.vars)j.add(H);return j},W=/@if\s*\(/g,U,z=[];while((U=W.exec(Q))!==null){let q=U.index,j=q+U[0].length,_=1,H=j;while(H<Q.length&&_>0){if(Q[H]==="(")_++;else if(Q[H]===")")_--;H++}if(_!==0)continue;let L=Q.substring(j,H-1).trim(),O=H,B=1,F=O,V=/@(if\s*\(|endif)/g;V.lastIndex=O;let w;while((w=V.exec(Q))!==null)if(w[1].startsWith("if"))B++;else if(w[1]==="endif"){if(B--,B===0){F=w.index+w[0].length;break}}if(B!==0)continue;let A=Q.substring(O,F-6).trim(),R;if(tm(A)){let M=Z5(Q.substring(q,F));if(M.length===0)continue;let I=M[0].branches.filter((S)=>S.type!=="else"),N=K(q);if(!(I.length>0&&I.every((S)=>bw(S.condition,Z,X,N))))continue;R=M[0].branches.map((S)=>{let x=J(S.content);if(S.type==="elseif")return e2(x,"@else-if",S.condition??"");if(S.type==="else")return e2(x,"@else");return e2(x,"@if",S.condition??"")}).join(`
12087
12087
  `)}else{if(!bw(L,Z,X,K(q)))continue;R=e2(J(A),"@if",L)}z.push({start:q,end:F,replacement:R}),W.lastIndex=F}for(let q=z.length-1;q>=0;q--){let{start:j,end:_,replacement:H}=z[q];Q=Q.substring(0,j)+H+Q.substring(_)}return Q}return J($)}function Jd($){let X=$.trim();if(X==="")return;if(X==="true")return!0;if(X==="false")return!1;if(X==="null")return!1;if(X==="undefined")return!1;if(X==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(X)){let Y=Number(X);return Y!==0&&!Number.isNaN(Y)}let Z=X.match(/^'((?:\\.|[^'\\])*)'$/);if(Z)return Z[1].length>0;let J=X.match(/^"((?:\\.|[^"\\])*)"$/);if(J)return J[1].length>0;return}function fw($,X,Z,J){if(XJ.has(Z.toLowerCase()))return J;let Y=Z.toLowerCase(),Q=$.toLowerCase(),G=$.length,K=1,W=J;while(W<G){let U=$.indexOf("<",W);if(U===-1)return-1;if(W=U,$.startsWith("<!--",W)){let _=$.indexOf("-->",W+4);if(_===-1)return-1;W=_+3;continue}let z=/^<(script|style)\b/i.exec($.slice(W,W+8));if(z){let _=$.indexOf(">",W);if(_===-1)return-1;if($[_-1]==="/"){W=_+1;continue}let H=Q.indexOf(`</${z[1].toLowerCase()}`,W);if(H===-1)return-1;let L=$.indexOf(">",H);if(L===-1)return-1;W=L+1;continue}if($[W+1]==="/"){let _=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(W,W+64));if(!_){W++;continue}if(_[1].toLowerCase()===Y){if(K--,W+=_[0].length,K===0)return W;continue}W+=_[0].length;continue}let q=/^<([a-z][\w-]*)\b/i.exec($.slice(W,W+64));if(!q){W++;continue}let j=$.indexOf(">",W);if(j===-1)return-1;if(q[1].toLowerCase()===Y){let _=$.slice(W,j+1);if(!(/\/\s*>$/.test(_)||XJ.has(Y)))K++}W=j+1}return-1}function Qd($,X){let Z=X,J=$.length;for(;;){while(Z<J&&$[Z]!=="<")Z++;if(Z>=J)return!1;if($.startsWith("<!--",Z)){let G=$.indexOf("-->",Z+4);if(G===-1)return!1;Z=G+3;continue}break}if($[Z+1]==="/")return!1;let Y=$.indexOf(">",Z);if(Y===-1)return!1;let Q=$.slice(Z,Y+1);return Yd.test(Q)}function oW($){if(!$.includes(":if")&&!$.includes(":show")&&!$.includes("x-if")&&!$.includes("x-show")&&!$.includes("@if=")&&!$.includes("@show="))return $;let X=[],Z=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,J;while((J=Z.exec($))!==null)X.push([J.index,J.index+J[0].length]);let Y=(q)=>X.some(([j,_])=>q>=j&&q<_),Q=/<([a-zA-Z][\w-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*?)\s+(:if|:show|x-if|x-show|@if|@show)\s*=\s*"([^"]*)"((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?)>/g,G=[],K;while((K=Q.exec($))!==null){if(Y(K.index))continue;let[q,j,_,H,L,O,B]=K,F=Jd(L);if(F===void 0)continue;let V=K.index,w=V+q.length,M=!!B||/\/\s*>$/.test(q)||XJ.has(j.toLowerCase())?w:fw($,V,j,w);if(M===-1)continue;if((H===":if"||H==="x-if"||H==="@if")&&Qd($,M)){Q.lastIndex=w;continue}if(F===!0){let N=`<${j}${_}${O}${B}>`;G.push({start:V,end:w,replacement:N});continue}G.push({start:V,end:M,replacement:""}),Q.lastIndex=M}if(G.length===0)return $;G.sort((q,j)=>q.start-j.start);let W=[],U=-1;for(let q of G){if(q.start<U)continue;W.push(q),U=q.end}let z=$;for(let q=W.length-1;q>=0;q--){let{start:j,end:_,replacement:H}=W[q];z=z.substring(0,j)+H+z.substring(_)}return z}function tW($,X){let Z=$,J=/@(for|foreach)\s*\(/g,Y,Q=[],G=[];while((Y=J.exec(Z))!==null){let K=Y[1],W=Y.index,U=W+Y[0].length,z=1,q=U;while(q<Z.length&&z>0){if(Z[q]==="(")z++;else if(Z[q]===")")z--;q++}if(z!==0)continue;let j=Z.substring(U,q-1).trim(),_=q,H=aW(j),L=K==="for"?"@endfor":"@endforeach",O=1,B=_,F=K==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${K}\\s*\\(|end${K})`,"g");F.lastIndex=_;let V;while((V=F.exec(Z))!==null)if(V[1].startsWith(K))O++;else if(O--,O===0){B=V.index+V[0].length;break}if(O!==0)continue;let w=()=>{let I=[H.itemVar,H.indexVar].filter(Boolean);if(I.length)G.push({start:W,end:B,vars:I})};if(H.iterable){let I=H.iterable.trim();if(I.startsWith("[")||I.startsWith("{")||I.startsWith("'")||I.startsWith('"')||I.startsWith("`")||/^-?\d/.test(I)){w();continue}let N=I.split(/[.[(]/)[0].trim(),E=X?N in X:!1,C=G.some((S)=>W>S.start&&W<S.end&&S.vars.includes(N));if(N&&(E||C)){w();continue}}if(H.style==="as")j=H.indexVar?`(${H.itemVar}, ${H.indexVar}) in ${H.iterable}`:`${H.itemVar} in ${H.iterable}`;let A=Z.substring(_,B-L.length).trim(),R=A.match(xw),M;if(R){let[,I,N,E]=R;M=`<${I}${N} @for="${j}">${E}</${I}>`}else M=`<template @for="${j}">${A}</template>`;Q.push({start:W,end:B,replacement:M})}for(let K=Q.length-1;K>=0;K--){let{start:W,end:U,replacement:z}=Q[K];Z=Z.substring(0,W)+z+Z.substring(U)}return Z}function Gd($){let X=new Set,Z=[],J=0,Y=0,Q=$.length,G=(z)=>{let q=J+1;while(q<Q){let j=$[q];if(j==="\\"){q+=2;continue}if(j===z)return q+1;q++}return Q},K=()=>{let z=J+2;while(z<Q&&$[z]!==`
12088
12088
  `)z++;return z},W=()=>{let z=J+2;while(z<Q-1){if($[z]==="*"&&$[z+1]==="/")return z+2;z++}return Q},U=(z)=>{let q=z,j=0;while(q<Q){let _=$[q];if(_==="/"&&$[q+1]==="/"){let H=q+2;while(H<Q&&$[H]!==`
12089
12089
  `)H++;q=H;continue}if(_==="/"&&$[q+1]==="*"){let H=q+2;while(H<Q-1&&!($[H]==="*"&&$[H+1]==="/"))H++;q=H+2;continue}if(_==='"'||_==="'"||_==="`"){let H=q+1;while(H<Q){if($[H]==="\\"){H+=2;continue}if($[H]===_){H++;break}H++}q=H;continue}if(_==="("||_==="["||_==="{"){j++,q++;continue}if(_===")"||_==="]"||_==="}"){j--,q++;continue}if(_===";"&&j===0)return q+1;q++}return Q};while(J<Q){let z=$[J];if(z==="/"&&$[J+1]==="/"){let q=K();Z.push($.slice(J,q)),J=q;continue}if(z==="/"&&$[J+1]==="*"){let q=W();Z.push($.slice(J,q)),J=q;continue}if(z==='"'||z==="'"||z==="`"){let q=G(z);Z.push($.slice(J,q)),J=q;continue}if(z==="{"){Y++,Z.push(z),J++;continue}if(z==="}"){Y--,Z.push(z),J++;continue}if(Y===0){let q=J>0?$[J-1]:"";if(q===""||/\s/.test(q)||q===";"||q==="}"||q==="{"){let _=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(_){let H=_[2],L=U(J+_[0].length);if(X.has(H)){Z.push(`/* stx: deduped const ${H} */`),J=L;continue}X.add(H),Z.push($.slice(J,L)),J=L;continue}}}Z.push(z),J++}return Z.join("")}async function gw($,X,Z){let J=vw($,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),Y=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|useCookie|useId|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,Q=[];for(let O of J){let B=O.body;if(f4(O.attrs))B=g4(B);if(Y.test(B))Q.push({fullMatch:O.fullMatch,attrs:O.attrs,content:B})}if(Q.length===0)return{output:$,setupCode:null};let G=`__stx_setup_${Date.now()}_${om++}`,{hasUserImports:K,bundleClientScript:W}=await D0("stx/client-script-bundler",()=>Promise.resolve().then(() => (b6(),j3))),U=[];for(let O=0;O<Q.length;O++){let B=Q[O].content;if(B=x6(B).code,K(B))B=await W(B,X||"",{projectRoot:process.cwd()});B=B.replace(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm,(V,w)=>uw(w));let F=n1(B);U.push(`// \u2500\u2500 merged signal script #${O+1} \u2500\u2500
@@ -14880,11 +14880,11 @@ ${W.trim()}
14880
14880
  ${W.trim()}
14881
14881
  @endsection`}}if(W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(V,w,A)=>{return H[w]=A,""}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(V,w,A)=>{if(/^(['"]).*\1$/.test(A.trim()))return V;try{let R=x0(A.trim(),X);if(R===void 0)return V;return H[w]=String(R??""),""}catch{return V}}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(V,w,A)=>{if(A.includes("@parent"))H[w]=A.replace("@parent",X8);else H[w]=A.trim();return""}),X.__sections=H,W=W.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(V,w,A)=>{return H[w]||A||""}),!("slot"in X)||X.slot===void 0)W=W.replace(/\{\{\s*slot\s*\}\}/g,()=>{return H.content||""});if(W=C2(W,_),L){let V=[],w=v$(W),A=x$(w.output,l8,(R,M)=>`\x00STX_ORPHAN_STYLE_${M}\x00`);if(W=A.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(R,M,I)=>{let N=M==="SCRIPT"?w.scripts[Number(I)]:A.tokens[Number(I)];if(N)V.push(N);return""}),V.length>0){let R=V.join(`
14882
14882
  `);H.content=H.content?`${H.content}
14883
- ${R}`:R,X.__sections=H}}if(L)try{let V;if(k1.isAbsolute(L))V=L,Y.add(L);else V=await h$(()=>FX(L,Z,G,Y),null,()=>{throw new L$(`Failed to resolve layout path: ${L}`,Z,void 0,void 0,`Layout referenced from ${Z}`)});if(!V){let N=[];try{let C=G.layoutsDir;if(C){let S=k1.isAbsolute(C)?C:k1.resolve(process.cwd(),C);N=Bc.readdirSync(S).filter((y)=>y.endsWith(".stx")).map((y)=>y.replace(/\.stx$/,"")).sort()}}catch{}let E=`Layout not found: ${L} (referenced from ${Z})`+(N.length>0?`. Available layouts: ${N.join(", ")}`:G.layoutsDir?`. No .stx layouts found in ${G.layoutsDir}`:"");if(T1.log(Error(E),{layoutPath:L,filePath:Z,available:N},"error"),console.error(`[stx] ${E}`),G.debug)throw new L$(E,Z);return W}let w=await h$(()=>Bun.file(V).text(),"",()=>{throw new L$(`Failed to read layout file: ${V}`,Z,void 0,void 0,"Layout content could not be loaded")}),A=w.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(A){if(G.debug)console.log(`Found nested layout: ${A[1]} in ${V}`);let N={},E=w.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(y,x,b)=>{return N[x]=b.trim(),""});for(let[y,x]of Object.entries(N))if(H[y]&&H[y].includes(X8)){let b=H[y].indexOf(X8);H[y]=H[y].slice(0,b)+x+H[y].slice(b+X8.length)}else if(!H[y])H[y]=x;let C={...X,__sections:H},S=`@layout('${A[1]}')${E}`;return await w0(S,C,V,G,Y)}let R=w.replace(/\{\{--[\s\S]*?--\}\}/g,""),M=S2(R,_),I={};return M=M.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(N,E,C)=>{return I[E]=C.trim(),`@slot('${E}')`}),M=M.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(N,E,C)=>{if(H[E]){let S=H[E];if(S.includes(X8)){let y=I[E]||"",x=S.indexOf(X8);S=S.slice(0,x)+y+S.slice(x+X8.length)}return S}return C||""}),M=Ac(M,H),M=M.replace(/\{\{\s*slot\s*\}\}/g,()=>{return H.content||""}),M=C2(M,_),X.__originalFilePath=Z,W=await wR(M,X,V,G,Y),W=`<!-- stx-layout: ${L} -->
14883
+ ${R}`:R,X.__sections=H}}if(L)try{let V;if(k1.isAbsolute(L))V=L,Y.add(L);else V=await h$(()=>FX(L,Z,G,Y),null,()=>{throw new L$(`Failed to resolve layout path: ${L}`,Z,void 0,void 0,`Layout referenced from ${Z}`)});if(!V){let N=(S)=>{if(!S)return[];try{let x=k1.isAbsolute(S)?S:k1.resolve(process.cwd(),S);return Bc.readdirSync(x).filter((y)=>y.endsWith(".stx")).map((y)=>y.replace(/\.stx$/,""))}catch{return[]}},E=[...N(G.layoutsDir),...N(G.fallbackLayoutsDir)].filter((S,x,y)=>y.indexOf(S)===x).sort(),C=`Layout not found: ${L} (referenced from ${Z})`+(E.length>0?`. Available layouts: ${E.join(", ")}`:G.layoutsDir?`. No .stx layouts found in ${G.layoutsDir}`:"");if(T1.log(Error(C),{layoutPath:L,filePath:Z,available:E},"error"),console.error(`[stx] ${C}`),G.debug)throw new L$(C,Z);return W}let w=await h$(()=>Bun.file(V).text(),"",()=>{throw new L$(`Failed to read layout file: ${V}`,Z,void 0,void 0,"Layout content could not be loaded")}),A=w.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(A){if(G.debug)console.log(`Found nested layout: ${A[1]} in ${V}`);let N={},E=w.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(x,y,b)=>{return N[y]=b.trim(),""});for(let[x,y]of Object.entries(N))if(H[x]&&H[x].includes(X8)){let b=H[x].indexOf(X8);H[x]=H[x].slice(0,b)+y+H[x].slice(b+X8.length)}else if(!H[x])H[x]=y;let C={...X,__sections:H},S=`@layout('${A[1]}')${E}`;return await w0(S,C,V,G,Y)}let R=w.replace(/\{\{--[\s\S]*?--\}\}/g,""),M=S2(R,_),I={};return M=M.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(N,E,C)=>{return I[E]=C.trim(),`@slot('${E}')`}),M=M.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(N,E,C)=>{if(H[E]){let S=H[E];if(S.includes(X8)){let x=I[E]||"",y=S.indexOf(X8);S=S.slice(0,y)+x+S.slice(y+X8.length)}return S}return C||""}),M=Ac(M,H),M=M.replace(/\{\{\s*slot\s*\}\}/g,()=>{return H.content||""}),M=C2(M,_),X.__originalFilePath=Z,W=await wR(M,X,V,G,Y),W=`<!-- stx-layout: ${L} -->
14884
14884
  ${W}`,q(W)}catch(V){return T1.log(V instanceof Error?V:Error(String(V)),{layoutPath:L,filePath:Z},"error"),`[Error processing layout: ${V instanceof Error?V.message:String(V)}]`}return q(await wR(W,X,Z,G,Y))}function Ac($,X){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Z,J,Y)=>{let Q=X[J];if(Q!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(Q))return Q}return Y||""})}function Rc($,X){if($.__stx_sfc_mode=!0,$.__stx_options=X,X.buildMode)$.__stx_buildMode=X.buildMode;let Z=X.envPrefix||"STX_PUBLIC_",J={};for(let[Y,Q]of Object.entries(process.env))if(Y.startsWith(Z)&&Q!==void 0)J[Y]=Q;$.$env=J}async function Nc($,X){await h$(()=>x2($,X),void 0,(Z)=>{T1.log(Z,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Z.message}`)})}async function Mc($,X,Z){let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Y;while((Y=J.exec($))!==null){let Q=Y[1],G=Y[2];if(!/\bserver\b/.test(Q)||!G.trim())continue;try{let{extractVariables:W}=await D0("stx/variable-extractor",()=>Promise.resolve().then(() => (a4(),R2)));await W(G,X,Z,{preserveExisting:!0})}catch(W){let U=W instanceof Error?W:Error(String(W));T1.log(U,{filePath:Z,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Z}: ${U.message}`)}}}async function Ec($,X,Z){try{let{interpolateScriptsInTemplate:J}=await D0("stx/expressions",()=>Promise.resolve().then(() => (w1(),A3)));return J($,X,{skipServer:!0})}catch(J){let Y=J instanceof Error?J:Error(String(J));return T1.log(Y,{filePath:Z,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Z}: ${Y.message}`),$}}async function wR($,X,Z,J,Y){let Q=$,G=J;if(await Mc(Q,X,Z),Q=await Ec(Q,X,Z),Q=await vV(Q,X,Z),Q=await fV(Q,X,Z),Q=await zK(Q,X,Z,G),f$(Q))Q=sW(Q,X),Q=tW(Q,X);Q=oW(Q);let{processStreamDirectives:K}=await D0("stx/streaming",()=>Promise.resolve().then(() => (n4(),l6)));Q=K(Q,X),Q=D2(Q,X,Z,G),Q=await kW(Q,X,Z,G,Y),Q=await w2(Q,X,Z,G,Y),Q=cQ(Q,X,Z,G);let{processDeferDirectives:W}=await D0("stx/defer",()=>Promise.resolve().then(() => YA));Q=W(Q,X,Z);let{processTeleportDirectives:U}=await D0("stx/teleport",()=>Promise.resolve().then(() => WA));Q=U(Q,X,Z);let{processTransitionDirectives:z,processTransitionAttributes:q}=await D0("stx/transitions",()=>Promise.resolve().then(() => FA));Q=z(Q,X,Z),Q=q(Q);let{processErrorBoundaryDirectives:j}=await D0("stx/error-boundaries",()=>Promise.resolve().then(() => wA));Q=j(Q,X,Z);let{processSuspenseDirectives:_}=await D0("stx/suspense",()=>Promise.resolve().then(() => TA));Q=_(Q,X,Z);let{processAsyncDirectives:H}=await D0("stx/async-components",()=>Promise.resolve().then(() => xA));Q=H(Q,X,Z);let{processKeepAliveDirectives:L}=await D0("stx/keep-alive",()=>Promise.resolve().then(() => lA));Q=L(Q,X,Z);let{processVirtualListDirectives:O,processVirtualGridDirectives:B,processInfiniteListDirectives:F}=await D0("stx/virtual-scrolling",()=>Promise.resolve().then(() => (BU(),pA)));Q=O(Q,X,Z),Q=B(Q,X,Z),Q=F(Q,X,Z);let{processPartialHydrationDirectives:V,processStaticDirectives:w}=await D0("stx/partial-hydration",()=>Promise.resolve().then(() => (CU(),iA)));Q=V(Q,X,Z),Q=w(Q);let{processComputedDirectives:A,processWatchDirectives:R}=await D0("stx/computed",()=>Promise.resolve().then(() => (YR(),JR)));Q=A(Q,X,Z),Q=R(Q,X,Z);let{processFormValidationDirectives:M}=await D0("stx/forms-validation",()=>Promise.resolve().then(() => (bU(),UR)));Q=M(Q,X,Z);let{processHeadDirective:I,processTitleDirective:N,processMetaDirective:E,resetHead:C}=await D0("stx/head",()=>Promise.resolve().then(() => (d6(),LK)));if(!X.__stx_head_preset&&!X.__stx_runtime_head)C();let S=I(Q);if(Q=S.content,S.headContent)X.__stx_head_raw=`${X.__stx_head_raw||""}${S.headContent}
14885
14885
  `;if(Q=N(Q,X),Q=E(Q,X),Q=mV(Q),Q=eG(Q,X),Q=aB(Q),Q=uV(Q),Q=await k2(Q,X,Z,G,Y),Q=await w2(Q,X,Z,G,Y),X.__stxProcessingDepth===1)Q=NO(Q,X);if(Q=Q.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),Q=$U(Q),Q=W4(Q,X,Z),Q=$K(Q,X),Q=XK(Q,X),Q=Y5(Q,X),Q=W2(Q,X),Q=U2(Q,X),Q=await gU(Q,X,Z,G),Q=await fU(Q,X,Z),Q=await MK(Q,X,Z,G),Q=mQ(Q,X,Z,G),Q=wW(Q,X,Z,G),Q=AW(Q,X,Z),Q=RW(Q,X,Z,G),Q=KK(Q,X,Z,G),Q=UX(Q,X),Q=zX(Q),Q=pw(Q),!G.skipEventDirectives)Q=WG(Q,X,Z);if(Q=zB(Q,X,Z),G.debug){let G0=/\bx-data\s*=/.test(Q),l=ZJ($);if(G0&&l)console.warn(`[stx] ${Z}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
14886
14886
  Both work on the same page, but they manage separate scopes.
14887
- Prefer signals (state/derived/effect) for new components.`)}Q=v2(Q,X),Q=await Y$(Q,X,Z),Q=iw(Q),Q=nw(Q),Q=hG(Q);let{processXElementDirectives:y}=await D0("stx/x-element",()=>Promise.resolve().then(() => jR));Q=y(Q);let x=X.__originalFilePath||Z,b=v4(X);if(Q=await eW(Q,G,x,b),Q=jK(Q,X),Q=await FW(Q,X,Z,G),G.media?.image?.autoSiblings){let G0=G.publicDir||"public",{rewriteImagesWithSiblings:l}=await D0("stx/image-optimization/auto-sibling",()=>Promise.resolve().then(() => (yU(),_R)));Q=await l(Q,{publicDir:G0})}if(G.seo?.enabled)Q=NW(Q,X,G);let u=(G0,l,$0=!0)=>{if(!l)return G0;let L0=l.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),O0=G0.match(/<title\b[^>]*>[\s\S]*?<\/title>/i);if(L0&&O0){if($0)G0=G0.replace(O0[0],L0[0]);if(l=l.replace(L0[0],"").trim(),!l)return G0}if(/<\/head>/i.test(G0))return G0.replace(/<\/head>/i,`${l}
14887
+ Prefer signals (state/derived/effect) for new components.`)}Q=v2(Q,X),Q=await Y$(Q,X,Z),Q=iw(Q),Q=nw(Q),Q=hG(Q);let{processXElementDirectives:x}=await D0("stx/x-element",()=>Promise.resolve().then(() => jR));Q=x(Q);let y=X.__originalFilePath||Z,b=v4(X);if(Q=await eW(Q,G,y,b),Q=jK(Q,X),Q=await FW(Q,X,Z,G),G.media?.image?.autoSiblings){let G0=G.publicDir||"public",{rewriteImagesWithSiblings:l}=await D0("stx/image-optimization/auto-sibling",()=>Promise.resolve().then(() => (yU(),_R)));Q=await l(Q,{publicDir:G0})}if(G.seo?.enabled)Q=NW(Q,X,G);let u=(G0,l,$0=!0)=>{if(!l)return G0;let L0=l.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),O0=G0.match(/<title\b[^>]*>[\s\S]*?<\/title>/i);if(L0&&O0){if($0)G0=G0.replace(O0[0],L0[0]);if(l=l.replace(L0[0],"").trim(),!l)return G0}if(/<\/head>/i.test(G0))return G0.replace(/<\/head>/i,`${l}
14888
14888
  </head>`);if(/<head\b[^>]*>/i.test(G0))return G0.replace(/(<head\b[^>]*>)/i,`$1
14889
14889
  ${l}`);if(/<html\b[^>]*>/i.test(G0))return G0.replace(/(<html\b[^>]*>)/i,`$1
14890
14890
  <head>
@@ -14897,12 +14897,12 @@ ${ZB()}
14897
14897
  ${l}`);else Q=l+`
14898
14898
  `+Q}{let{scanScriptTags:G0}=await D0("stx/signal-processing",()=>Promise.resolve().then(() => (WX(),JJ))),l=[];for(let $0 of G0(Q)){if(!/\bserver\b/i.test($0.attrs))continue;let L0=$0.start+$0.fullMatch.indexOf(">")+1,O0=Fc(Q,L0);if(O0===-1)continue;let f=O0+9;while(f<Q.length&&/\s/.test(Q[f]))f++;l.push({start:$0.start,end:f})}for(let $0=l.length-1;$0>=0;$0--){let{start:L0,end:O0}=l[$0];Q=Q.substring(0,L0)+Q.substring(O0)}}let k0=a3(Q,Z);if(k0.hasScoped)Q=k0.html;let o=X.__stx_event_bindings||[],W0=!1,U0=[],z0=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:s0}=await D0("stx/signal-processing",()=>Promise.resolve().then(() => (WX(),JJ)));for(let G0 of s0(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))U0.push({match:G0.fullMatch,attrs:G0.attrs,content:G0.body});for(let{match:G0,attrs:l,content:$0}of U0){W0=!0;let L0=$0;qX($0,Z,J.strict,X.__originalFilePath);let O0=await b$($0,{eventBindings:o,attrs:l,hasColonDirectives:z0,templateContent:$,filePath:Z,projectRoot:process.cwd(),production:J.buildMode==="compile",serverData:b});Q=Q.replace(G0,()=>O0)}if(W0)X.__stx_event_bindings=[];if(!W0&&X.__stxProcessingDepth===1){let G0=X.__stx_event_bindings||[];if(G0.length>0){let l=I9(G0);if(l){let $0=Q.lastIndexOf("</body>");Q=$0===-1?Q+l:Q.slice(0,$0)+l+`
14899
14899
  `+Q.slice($0)}X.__stx_event_bindings=[]}}if(!I5(Q)&&kw(Q))Q=await t2(Q,G);if(Q=Sw(Q),G.csp?.enabled&&G.csp.useNonce&&typeof X.cspNonce==="string")Q=GK(Q,X.cspNonce);return Q}var X8="<!--PARENT_CONTENT_PLACEHOLDER-->";var P1=T(()=>{H$();vG();Y4();k8();gG();uG();cG();E9();j9();k9();v6();qB();v5();v3();WK();sB();qK();_K();a1();d6();w1();VK();EK();_5();hV();I2();OJ();VW();h4();dV();r3();b0();MW();EW();DW();SW();g2();L5();XX();WX();WW();lw();XU();ZU();j1();CK();BG();W3();k5();k5();XU();ZU()});function AR($){let X=[],Z=[];return kc($,X),Sc($,X,Z),Cc($,Z),Pc($,X),{valid:X.length===0,errors:X,warnings:Z}}function kc($,X){let Z=($.match(/\{\{/g)||[]).length,J=($.match(/\}\}/g)||[]).length;if(Z!==J)X.push({type:"expression",message:`Unclosed expression brackets: found ${Z} opening '{{' and ${J} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function Sc($,X,Z){for(let J of Tc){let Y=new RegExp(`${J.open}(?:\\s|\\()`,"g"),Q=new RegExp(J.close,"g"),G=($.match(Y)||[]).length,K=($.match(Q)||[]).length;if(J.altClose){let W=new RegExp(J.altClose,"g");K+=($.match(W)||[]).length}if(G>K)X.push({type:"directive",message:`Unclosed @${J.name} directive: found ${G} opening and ${K} closing`,suggestion:`Add ${G-K} missing ${J.close} tag(s)`});else if(K>G)Z.push({type:"directive",message:`Extra ${J.close} found: ${K-G} more closing than opening`,suggestion:`Check for orphaned ${J.close} tags`})}}function Cc($,X){for(let Z of Dc)if(Z.pattern.test($))X.push({type:"syntax",message:Z.message,suggestion:Z.suggestion})}function Pc($,X){for(let Z of Ic)if(Z.pattern.test($))X.push({type:"expression",message:`Security warning: ${Z.message}`,suggestion:"Remove dangerous code from template expressions"})}function RR($,X){let Z=$.slice(0,X).split(`
14900
- `);return{line:Z.length,column:Z[Z.length-1].length+1}}function NR($,X,Z){let J=[];switch($){case"if":case"elseif":case"unless":if(Z.length===0)J.push({type:"syntax",message:`@${$} requires a condition`,suggestion:`Use @${$}(condition)`});break;case"foreach":if(Z.length===0||!Z[0].includes(" as "))J.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(Z.length===0)J.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(Z.length===0)J.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(Z.length===0)J.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(Z.length===0)J.push({type:"syntax",message:`@${$} requires a path`,suggestion:`Use @${$}('path/to/template')`});break}return J}function MR($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function ER($){let X=$.matchAll(/@([a-z]+)/gi),Z=new Set;for(let J of X){let Y=J[1].toLowerCase();if(!Y.startsWith("end"))Z.add(Y)}return Array.from(Z)}var Tc,Dc,Ic;var TR=T(()=>{Tc=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],Dc=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],Ic=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}]});var dU={};X0(dU,{renderSlot:()=>uU,processSlots:()=>mU,parseSlots:()=>hU,parseSlotElement:()=>DR,extractSlotContent:()=>kR,applySlots:()=>SR});function bc($,X){let Z=1,J=X,Y="<template",Q="</template";while(J<$.length&&Z>0){let G=$.indexOf("<",J);if(G===-1)break;if(J=G,$.startsWith(Y,J)&&(J+Y.length>=$.length||/[\s>\/]/.test($[J+Y.length]))){Z++,J+=Y.length;continue}if($.startsWith(Q,J)){let K=$.indexOf(">",J+Q.length);if(K!==-1){if(Z--,Z===0)return K+1;J=K+1;continue}}J++}return Z===0?J:-1}function xc($,X){let Z=null;for(let J=X;J<$.length;J++){let Y=$[J];if(Z){if(Y==="\\"){J++;continue}if(Y===Z)Z=null;continue}if(Y==='"'||Y==="'"){Z=Y;continue}if(Y===">")return J+1}return-1}function vc($){let X=[],Z=[],J=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,Y=0;while(Y<$.length){let Q=$.indexOf("<",Y);if(Q===-1)break;if($.startsWith("<!--",Q)){let j=$.indexOf("-->",Q+4);Y=j===-1?$.length:j+3;continue}let G=xc($,Q+1);if(G===-1)break;let K=$.slice(Q,G),W=K.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!W){Y=G;continue}let U=W[1]==="/",z=W[2].toLowerCase();if(U){let j=Z.lastIndexOf(z);if(j!==-1)Z.splice(j);Y=G;continue}if(z==="template"&&Z.length===0){let j=K.match(J);if(j){let _=bc($,G);if(_!==-1){let H=j[1]||j[2]||j[3];X.push({start:Q,end:_,slotName:H,content:$.slice(G,_-11).trim(),propsBinding:j[4]||void 0}),Y=_;continue}}}if(!/\/\s*>$/.test(K)&&!yc.has(z)){if(Z.push(z),z==="script"||z==="style"){let j=$.toLowerCase().indexOf(`</${z}>`,G);if(j!==-1){Y=j;continue}}}Y=G}return X}function hU($){let X={default:"",named:new Map},Z=$,J=vc($);for(let W of J)X.named.set(W.slotName,{name:W.slotName,content:W.content,propsBinding:W.propsBinding});J.sort((W,U)=>U.start-W.start);for(let W of J)Z=Z.slice(0,W.start)+Z.slice(W.end);let Y=[],Q=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,G;while((G=Q.exec(Z))!==null){let[W,U,z,q,j,_]=G,H=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(H+L).trim(),B=`<${U}${O?" "+O:""}>${_}</${U}>`;Y.push({start:G.index,end:G.index+W.length,slotName:q,element:B})}let K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((G=K.exec(Z))!==null){let[W,U,z,q,j]=G,_=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),H=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=(_+H).trim(),O=`<${U}${L?" "+L:""} />`;Y.push({start:G.index,end:G.index+W.length,slotName:q,element:O})}Y.sort((W,U)=>U.start-W.start);for(let W of Y){let U=X.named.get(W.slotName);if(U)U.content+=W.element;else X.named.set(W.slotName,{name:W.slotName,content:W.element});Z=Z.slice(0,W.start)+Z.slice(W.end)}return X.default=Z.trim(),X}function DR($){let X=$.match(/name\s*=\s*["']([^"']+)["']/),Z=X?X[1]:"",J={},Y=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,Q;while((Q=Y.exec($))!==null)J[Q[1]]=Q[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Z,props:J,defaultContent:K}}async function uU($,X,Z,J){if(!$)return Z;let Y=$.content;if($.propsBinding&&Object.keys(X).length>0){let Q=$.propsBinding.trim(),G={...J};if(Q.startsWith("{")&&Q.endsWith("}")){let K=Q.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean);for(let W of K){let[U,z]=W.split(":").map((j)=>j.trim()),q=z||U;if(X[U]!==void 0)G[q]=X[U]}}else G[Q]=X;Y=fc(Y,G)}return Y}function fc($,X){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Z,J)=>{try{let Y=J.trim(),Q=IR(Y,X);return O1(String(Q??""))}catch{return`{{ ${J} }}`}})}function IR($,X){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let J=$.split("."),Y=X;for(let Q of J)if(Y&&typeof Y==="object"&&Q in Y)Y=Y[Q];else return;return Y}let Z=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Z){let[,J,Y,Q]=Z,G=X[J],K=parseInt(Q,10);if(typeof G==="number")switch(Y){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!m0($))return;return d0($,Object.keys(X))(...Object.values(X))}catch{return}}async function mU($,X,Z){let J=$;J=await gc(J,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,W,U)=>{let z=X.named.get(K),q=U?.trim()||"",j=W||"",_={},H=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,L;while((L=H.exec(j))!==null){let O=L[1],B=L[2];_[O]=IR(B,Z)}return await uU(z,_,q,Z)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return J=J.replace(Q,(G,K)=>{if(G.includes("name="))return G;let W=K?.trim()||"";return X.default||W}),J}async function gc($,X,Z){let J=[],Y=[];$.replace(X,(K,...W)=>{let U=W[W.length-2];return Y.push({match:K,index:U}),J.push(Z(K,...W.slice(0,-2))),K});let Q=await Promise.all(J),G=$;for(let K=Y.length-1;K>=0;K--){let{match:W,index:U}=Y[K];G=G.slice(0,U)+Q[K]+G.slice(U+W.length)}return G}function kR($){let X=hU($);return{defaultSlot:X.default,namedSlots:X.named}}async function SR($,X,Z,J){return await mU($,{default:X,named:Z},J)}var yc;var BJ=T(()=>{w1();j1();yc=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"])});import hc from"fs";import Y0 from"path";function mc($){let X=new WeakSet;try{let Z=(J)=>{if(J===void 0)return{__stxType:"undefined"};if(typeof J==="bigint")return{__stxType:"bigint",value:J.toString()};if(typeof J==="function"||typeof J==="symbol")throw TypeError("Non-serializable component input");if(J===null||typeof J!=="object")return J;if(X.has(J))throw TypeError("Circular component input");if(X.add(J),J instanceof Date)return{__stxType:"date",value:J.toISOString()};if(Array.isArray(J))return J.map(Z);let Y={};for(let Q of Object.keys(J).sort())Y[Q]=Z(J[Q]);return Y};return JSON.stringify(Z($))}catch{return null}}function CR($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function PR($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function f4($){return!PR($)}function B$($){let X;try{X=JSON.stringify($)}catch{return new Bun.Transpiler($)}let Z=FJ.get(X);if(Z)return Z;if(FJ.size>=16)FJ.clear();let J=new Bun.Transpiler($);return FJ.set(X,J),J}function g4($){try{let X=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");X=X.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let Z=[];X=X.replace(/\{!![\s\S]*?!!\}/g,(Q)=>{let G=Z.length;return Z.push(Q),`"__STX_EXPR_${G}__"`}),X=X.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Q)=>{let G=Z.length;return Z.push(Q),`"__STX_EXPR_${G}__"`}),X=X.replace(/\{\{[\s\S]*?\}\}/g,(Q)=>{let G=Z.length;return Z.push(Q),`"__STX_EXPR_${G}__"`});let Y=B$({loader:"ts",target:"browser",define:V1()}).transformSync(X);for(let Q=0;Q<Z.length;Q++)Y=Y.replace(`"__STX_EXPR_${Q}__"`,Z[Q]),Y=Y.replace(`'__STX_EXPR_${Q}__'`,Z[Q]);return Y}catch(X){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",X);return $}}function dc($){let X=[],Z=new Set,J=0,Y=0,Q=$.length,G=(z)=>{Y++;while(Y<Q){if($[Y]==="\\"){Y+=2;continue}if($[Y]===z){Y++;return}Y++}},K=()=>{Y++;while(Y<Q){if($[Y]==="\\"){Y+=2;continue}if($[Y]==="`"){Y++;return}if($[Y]==="$"&&$[Y+1]==="{"){Y+=2;let z=1;while(Y<Q&&z>0)if($[Y]==="{")z++,Y++;else if($[Y]==="}")z--,Y++;else if($[Y]==="'"||$[Y]==='"')G($[Y]);else if($[Y]==="`")K();else Y++;continue}Y++}},W=()=>{if($[Y]==="/"&&$[Y+1]==="/"){while(Y<Q&&$[Y]!==`
14901
- `)Y++;return!0}if($[Y]==="/"&&$[Y+1]==="*"){Y+=2;while(Y<Q-1&&!($[Y]==="*"&&$[Y+1]==="/"))Y++;return Y+=2,!0}return!1},U=()=>{if(J!==0)return;let z=$.slice(Y).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(z){let H=z[2].split(",").map((L)=>{let O=L.trim().split(":");return O[O.length-1].trim()});for(let L of H)if(L&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(L)&&!Z.has(L))X.push(L),Z.add(L);return}let q=$.slice(Y).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(q){let H=q[2];if(!Z.has(H))X.push(H),Z.add(H);return}let j=$.slice(Y).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(j){let H=j[1];if(!Z.has(H))X.push(H),Z.add(H);return}let _=$.slice(Y).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let H=_[1];if(!Z.has(H))X.push(H),Z.add(H)}};while(Y<Q){if(W())continue;if($[Y]==="'"||$[Y]==='"'){G($[Y]);continue}if($[Y]==="`"){K();continue}if($[Y]==="{"){J++,Y++;continue}if($[Y]==="}"){J--,Y++;continue}if(J===0&&/[a-z]/i.test($[Y])&&(Y===0||/\s|[;{}()]/.test($[Y-1])))U();Y++}return X}function cc($){let X=[],Z=0,J=0,Y=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(Y){if(G==="\\"){Q++;continue}if(G===Y)Y=null;continue}if(G==='"'||G==="'"||G==="`"){Y=G;continue}if(G==="("||G==="["||G==="{")Z++;else if(G===")"||G==="]"||G==="}")Z--;else if(G===","&&Z===0)X.push($.slice(J,Q)),J=Q+1}if(J<$.length)X.push($.slice(J));return X}function lc($){let X=0,Z=null;for(let J=0;J<$.length;J++){let Y=$[J];if(Z){if(Y==="\\"){J++;continue}if(Y===Z)Z=null;continue}if(Y==='"'||Y==="'"||Y==="`"){Z=Y;continue}if(Y==="("||Y==="["||Y==="{")X++;else if(Y===")"||Y==="]"||Y==="}")X--;else if(Y==="="&&X===0){let Q=$[J-1],G=$[J+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return J}}return-1}function pc($,X){try{let Z=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Z)return;let J=Z.index-1;while(J>=0&&/\s/.test($[J]))J--;if($[J]!=="}")return;let Y=J,Q=0,G=-1;for(;J>=0;J--){let W=$[J];if(W==="}")Q++;else if(W==="{"){if(Q--,Q===0){G=J;break}}}if(G===-1)return;let K=$.slice(G+1,Y);for(let W of cc(K)){let U=W.trim();if(!U||U.startsWith("..."))continue;let z=lc(U);if(z===-1)continue;let q=U.slice(0,z).trim();if(!/^[A-Z_$][\w$]*$/i.test(q))continue;if(X[q]!==void 0)continue;let j=U.slice(z+1).trim();if(!j)continue;try{let _=Object.keys(X),H=Function(..._,`"use strict"; return (${j});`);X[q]=H(..._.map((L)=>X[L]))}catch{}}}catch{}}async function n3($,X,Z,J,Y){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(O)=>O.split("-").map((B)=>B.charAt(0).toUpperCase()+B.slice(1)).join(""),K=(O)=>O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),W=Z.__importedComponents;if(W){for(let O of[Q,Q.toLowerCase(),G(Q),K(Q)])if(W.has(O))return!0}let U=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],z=typeof Y.root==="string"?Y0.resolve(Y.root):void 0,q=z??Y0.dirname(J),j=[],_=(O)=>{if(O&&!j.includes(O))j.push(O)},H=Z.__originalFilePath;if(H)_(Y0.join(Y0.dirname(H),"components"));_(X),_(Y._rootComponentsDir),_(Y0.join(Y0.dirname(J),"components")),_(Y.componentsDir);let L=Y._pluginComponentDirs;if(Array.isArray(L))for(let O of L)_(typeof O==="string"?O:null);if(z)_(Y0.resolve(z,"resources/views/components")),_(Y0.resolve(z,"resources/components")),_(Y0.resolve(z,"src/components")),_(Y0.resolve(z,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return H0(Y0.resolve(Y0.dirname(J),`${Q}.stx`));for(let O of j){let B=Y0.isAbsolute(O)?O:Y0.resolve(q,O);for(let F of U)if(await H0(Y0.join(B,F)))return!0}return!1}function bR($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}function yR($){if(!$)return!1;let X=$.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(X)}function xR($){let X=new Set,Z=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useReactiveProp|useLocalStorage|useSessionStorage|useCookie|useDebouncedValue)\s*(?:<[^>]*>)?\s*\(/g;for(let J of $){let Y;while((Y=Z.exec(J))!==null)X.add(Y[1]);Z.lastIndex=0}return[...X]}async function m$($,X,Z,J,Y,Q,G,K=new Set,W){let{extractVariables:U}=await D0("stx/variable-extractor",()=>Promise.resolve().then(() => (a4(),R2))),z=K??new Set;if(z.has($))return`[Circular component reference: ${$}]`;let q=new Set(z);q.add($);let j=typeof X.client==="string"?X.client.trim():"";if("client"in X)delete X.client;let _=j&&j!=="load"&&bR(j)?j:"";try{let H=(p)=>p.split("-").map((Z0)=>Z0.charAt(0).toUpperCase()+Z0.slice(1)).join(""),L=(p)=>p.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),O=$.endsWith(".stx")?$.slice(0,-4):$,B=null,F=Y.__importedComponents;if(F){let p=[O,O.toLowerCase(),H(O),L(O)];for(let Z0 of p)if(F.has(Z0)){B=F.get(Z0);break}}let V=[];if(!B){let p=[`${O}.stx`,`${H(O)}.stx`,`${L(O)}.stx`],Z0=[...new Set(p)],M0=Y.__originalFilePath,E0=[];if(M0){let u0=Y0.join(Y0.dirname(M0),"components");E0.push(u0)}if(J)E0.push(J);let f0=G._rootComponentsDir;if(typeof f0==="string"&&!E0.includes(f0))E0.push(f0);let J1=Y0.join(Y0.dirname(Q),"components");if(!E0.includes(J1))E0.push(J1);if(G.componentsDir&&G.componentsDir!==J&&!E0.includes(G.componentsDir))E0.push(G.componentsDir);let S1=G._pluginComponentDirs;if(Array.isArray(S1)){for(let u0 of S1)if(typeof u0==="string"&&!E0.includes(u0))E0.push(u0)}let Y1=typeof G.root==="string"?Y0.resolve(G.root):void 0,V0=Y1??Y0.dirname(Q),o0=[];if(Y1)o0.push(Y0.resolve(Y1,"resources/views/components")),o0.push(Y0.resolve(Y1,"resources/components")),o0.push(Y0.resolve(Y1,"src/components")),o0.push(Y0.resolve(Y1,"components"));o0.push(Y0.resolve(import.meta.dir,"components"));for(let u0 of o0)if(!E0.includes(u0))E0.push(u0);let q1=[...new Set(E0.map((u0)=>{if(!u0)return u0;return Y0.isAbsolute(u0)?u0:Y0.resolve(V0,u0)}))];E0.length=0,E0.push(...q1);let j0=`${O}\x00${Q}\x00${q1.join("\x00")}`,h0=VJ.get(j0);if(h0)if(await H0(h0))B=h0;else VJ.delete(j0);if(!B&&(O.startsWith("./")||O.startsWith("../")))B=Y0.resolve(Y0.dirname(Q),`${O}.stx`),V.push(B);else if(!B)for(let u0 of E0){if(!u0)continue;for(let T6 of Z0){let D6=Y0.join(u0,T6);if(V.push(D6),await H0(D6)){B=D6;break}}if(B)break;if(!B)try{let T6=await import("fs");if(!T6.statSync(u0,{throwIfNoEntry:!1})?.isDirectory())continue;let eZ=8,D8=[{path:u0,depth:0}];while(D8.length>0&&!B){let X4=D8.pop();if(X4.depth>=eZ)continue;let $9;try{$9=T6.readdirSync(X4.path,{withFileTypes:!0})}catch{continue}for(let X9 of $9){if(!X9.isDirectory())continue;if(X9.name==="node_modules"||X9.name.startsWith("."))continue;let LL=Y0.join(X4.path,X9.name);for(let qv of Z0){let vQ=Y0.join(LL,qv);if(V.push(vQ),await H0(vQ)){B=vQ;break}}if(B)break;D8.push({path:LL,depth:X4.depth+1})}}}catch{}if(B)break}if(B)VJ.set(j0,B)}if(!B||!await H0(B)){let p=V.length>0?`
14900
+ `);return{line:Z.length,column:Z[Z.length-1].length+1}}function NR($,X,Z){let J=[];switch($){case"if":case"elseif":case"unless":if(Z.length===0)J.push({type:"syntax",message:`@${$} requires a condition`,suggestion:`Use @${$}(condition)`});break;case"foreach":if(Z.length===0||!Z[0].includes(" as "))J.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(Z.length===0)J.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(Z.length===0)J.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(Z.length===0)J.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(Z.length===0)J.push({type:"syntax",message:`@${$} requires a path`,suggestion:`Use @${$}('path/to/template')`});break}return J}function MR($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function ER($){let X=$.matchAll(/@([a-z]+)/gi),Z=new Set;for(let J of X){let Y=J[1].toLowerCase();if(!Y.startsWith("end"))Z.add(Y)}return Array.from(Z)}var Tc,Dc,Ic;var TR=T(()=>{Tc=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],Dc=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],Ic=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}]});var dU={};X0(dU,{renderSlot:()=>uU,processSlots:()=>mU,parseSlots:()=>hU,parseSlotElement:()=>DR,extractSlotContent:()=>kR,applySlots:()=>SR});function bc($,X){let Z=1,J=X,Y="<template",Q="</template";while(J<$.length&&Z>0){let G=$.indexOf("<",J);if(G===-1)break;if(J=G,$.startsWith(Y,J)&&(J+Y.length>=$.length||/[\s>\/]/.test($[J+Y.length]))){Z++,J+=Y.length;continue}if($.startsWith(Q,J)){let K=$.indexOf(">",J+Q.length);if(K!==-1){if(Z--,Z===0)return K+1;J=K+1;continue}}J++}return Z===0?J:-1}function xc($,X){let Z=null;for(let J=X;J<$.length;J++){let Y=$[J];if(Z){if(Y==="\\"){J++;continue}if(Y===Z)Z=null;continue}if(Y==='"'||Y==="'"){Z=Y;continue}if(Y===">")return J+1}return-1}function vc($){let X=[],Z=[],J=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,Y=0;while(Y<$.length){let Q=$.indexOf("<",Y);if(Q===-1)break;if($.startsWith("<!--",Q)){let j=$.indexOf("-->",Q+4);Y=j===-1?$.length:j+3;continue}let G=xc($,Q+1);if(G===-1)break;let K=$.slice(Q,G),W=K.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!W){Y=G;continue}let U=W[1]==="/",z=W[2].toLowerCase();if(U){let j=Z.lastIndexOf(z);if(j!==-1)Z.splice(j);Y=G;continue}if(z==="template"&&Z.length===0){let j=K.match(J);if(j){let _=bc($,G);if(_!==-1){let H=j[1]||j[2]||j[3];X.push({start:Q,end:_,slotName:H,content:$.slice(G,_-11).trim(),propsBinding:j[4]||void 0}),Y=_;continue}}}if(!/\/\s*>$/.test(K)&&!yc.has(z)){if(Z.push(z),z==="script"||z==="style"){let j=$.toLowerCase().indexOf(`</${z}>`,G);if(j!==-1){Y=j;continue}}}Y=G}return X}function hU($){let X={default:"",named:new Map},Z=$,J=vc($);for(let W of J)X.named.set(W.slotName,{name:W.slotName,content:W.content,propsBinding:W.propsBinding});J.sort((W,U)=>U.start-W.start);for(let W of J)Z=Z.slice(0,W.start)+Z.slice(W.end);let Y=[],Q=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,G;while((G=Q.exec(Z))!==null){let[W,U,z,q,j,_]=G,H=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(H+L).trim(),B=`<${U}${O?" "+O:""}>${_}</${U}>`;Y.push({start:G.index,end:G.index+W.length,slotName:q,element:B})}let K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((G=K.exec(Z))!==null){let[W,U,z,q,j]=G,_=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),H=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=(_+H).trim(),O=`<${U}${L?" "+L:""} />`;Y.push({start:G.index,end:G.index+W.length,slotName:q,element:O})}Y.sort((W,U)=>U.start-W.start);for(let W of Y){let U=X.named.get(W.slotName);if(U)U.content+=W.element;else X.named.set(W.slotName,{name:W.slotName,content:W.element});Z=Z.slice(0,W.start)+Z.slice(W.end)}return X.default=Z.trim(),X}function DR($){let X=$.match(/name\s*=\s*["']([^"']+)["']/),Z=X?X[1]:"",J={},Y=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,Q;while((Q=Y.exec($))!==null)J[Q[1]]=Q[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Z,props:J,defaultContent:K}}async function uU($,X,Z,J){if(!$)return Z;let Y=$.content;if($.propsBinding&&Object.keys(X).length>0){let Q=$.propsBinding.trim(),G={...J};if(Q.startsWith("{")&&Q.endsWith("}")){let K=Q.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean);for(let W of K){let[U,z]=W.split(":").map((j)=>j.trim()),q=z||U;if(X[U]!==void 0)G[q]=X[U]}}else G[Q]=X;Y=fc(Y,G)}return Y}function fc($,X){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Z,J)=>{try{let Y=J.trim(),Q=IR(Y,X);return O1(String(Q??""))}catch{return`{{ ${J} }}`}})}function IR($,X){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let J=$.split("."),Y=X;for(let Q of J)if(Y&&typeof Y==="object"&&Q in Y)Y=Y[Q];else return;return Y}let Z=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Z){let[,J,Y,Q]=Z,G=X[J],K=parseInt(Q,10);if(typeof G==="number")switch(Y){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!m0($))return;return d0($,Object.keys(X))(...Object.values(X))}catch{return}}async function mU($,X,Z){let J=$;J=await gc(J,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,W,U)=>{let z=X.named.get(K),q=U?.trim()||"",j=W||"",_={},H=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,L;while((L=H.exec(j))!==null){let O=L[1],B=L[2];_[O]=IR(B,Z)}return await uU(z,_,q,Z)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return J=J.replace(Q,(G,K)=>{if(G.includes("name="))return G;let W=K?.trim()||"";return X.default||W}),J}async function gc($,X,Z){let J=[],Y=[];$.replace(X,(K,...W)=>{let U=W[W.length-2];return Y.push({match:K,index:U}),J.push(Z(K,...W.slice(0,-2))),K});let Q=await Promise.all(J),G=$;for(let K=Y.length-1;K>=0;K--){let{match:W,index:U}=Y[K];G=G.slice(0,U)+Q[K]+G.slice(U+W.length)}return G}function kR($){let X=hU($);return{defaultSlot:X.default,namedSlots:X.named}}async function SR($,X,Z,J){return await mU($,{default:X,named:Z},J)}var yc;var BJ=T(()=>{w1();j1();yc=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"])});import hc from"fs";import Z0 from"path";function mc($){let X=new WeakSet;try{let Z=(J)=>{if(J===void 0)return{__stxType:"undefined"};if(typeof J==="bigint")return{__stxType:"bigint",value:J.toString()};if(typeof J==="function"||typeof J==="symbol")throw TypeError("Non-serializable component input");if(J===null||typeof J!=="object")return J;if(X.has(J))throw TypeError("Circular component input");if(X.add(J),J instanceof Date)return{__stxType:"date",value:J.toISOString()};if(Array.isArray(J))return J.map(Z);let Y={};for(let Q of Object.keys(J).sort())Y[Q]=Z(J[Q]);return Y};return JSON.stringify(Z($))}catch{return null}}function CR($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function PR($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function f4($){return!PR($)}function B$($){let X;try{X=JSON.stringify($)}catch{return new Bun.Transpiler($)}let Z=FJ.get(X);if(Z)return Z;if(FJ.size>=16)FJ.clear();let J=new Bun.Transpiler($);return FJ.set(X,J),J}function g4($){try{let X=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");X=X.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let Z=[];X=X.replace(/\{!![\s\S]*?!!\}/g,(Q)=>{let G=Z.length;return Z.push(Q),`"__STX_EXPR_${G}__"`}),X=X.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Q)=>{let G=Z.length;return Z.push(Q),`"__STX_EXPR_${G}__"`}),X=X.replace(/\{\{[\s\S]*?\}\}/g,(Q)=>{let G=Z.length;return Z.push(Q),`"__STX_EXPR_${G}__"`});let Y=B$({loader:"ts",target:"browser",define:V1()}).transformSync(X);for(let Q=0;Q<Z.length;Q++)Y=Y.replace(`"__STX_EXPR_${Q}__"`,Z[Q]),Y=Y.replace(`'__STX_EXPR_${Q}__'`,Z[Q]);return Y}catch(X){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",X);return $}}function dc($){let X=[],Z=new Set,J=0,Y=0,Q=$.length,G=(z)=>{Y++;while(Y<Q){if($[Y]==="\\"){Y+=2;continue}if($[Y]===z){Y++;return}Y++}},K=()=>{Y++;while(Y<Q){if($[Y]==="\\"){Y+=2;continue}if($[Y]==="`"){Y++;return}if($[Y]==="$"&&$[Y+1]==="{"){Y+=2;let z=1;while(Y<Q&&z>0)if($[Y]==="{")z++,Y++;else if($[Y]==="}")z--,Y++;else if($[Y]==="'"||$[Y]==='"')G($[Y]);else if($[Y]==="`")K();else Y++;continue}Y++}},W=()=>{if($[Y]==="/"&&$[Y+1]==="/"){while(Y<Q&&$[Y]!==`
14901
+ `)Y++;return!0}if($[Y]==="/"&&$[Y+1]==="*"){Y+=2;while(Y<Q-1&&!($[Y]==="*"&&$[Y+1]==="/"))Y++;return Y+=2,!0}return!1},U=()=>{if(J!==0)return;let z=$.slice(Y).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(z){let H=z[2].split(",").map((L)=>{let O=L.trim().split(":");return O[O.length-1].trim()});for(let L of H)if(L&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(L)&&!Z.has(L))X.push(L),Z.add(L);return}let q=$.slice(Y).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(q){let H=q[2];if(!Z.has(H))X.push(H),Z.add(H);return}let j=$.slice(Y).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(j){let H=j[1];if(!Z.has(H))X.push(H),Z.add(H);return}let _=$.slice(Y).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let H=_[1];if(!Z.has(H))X.push(H),Z.add(H)}};while(Y<Q){if(W())continue;if($[Y]==="'"||$[Y]==='"'){G($[Y]);continue}if($[Y]==="`"){K();continue}if($[Y]==="{"){J++,Y++;continue}if($[Y]==="}"){J--,Y++;continue}if(J===0&&/[a-z]/i.test($[Y])&&(Y===0||/\s|[;{}()]/.test($[Y-1])))U();Y++}return X}function cc($){let X=[],Z=0,J=0,Y=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(Y){if(G==="\\"){Q++;continue}if(G===Y)Y=null;continue}if(G==='"'||G==="'"||G==="`"){Y=G;continue}if(G==="("||G==="["||G==="{")Z++;else if(G===")"||G==="]"||G==="}")Z--;else if(G===","&&Z===0)X.push($.slice(J,Q)),J=Q+1}if(J<$.length)X.push($.slice(J));return X}function lc($){let X=0,Z=null;for(let J=0;J<$.length;J++){let Y=$[J];if(Z){if(Y==="\\"){J++;continue}if(Y===Z)Z=null;continue}if(Y==='"'||Y==="'"||Y==="`"){Z=Y;continue}if(Y==="("||Y==="["||Y==="{")X++;else if(Y===")"||Y==="]"||Y==="}")X--;else if(Y==="="&&X===0){let Q=$[J-1],G=$[J+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return J}}return-1}function pc($,X){try{let Z=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Z)return;let J=Z.index-1;while(J>=0&&/\s/.test($[J]))J--;if($[J]!=="}")return;let Y=J,Q=0,G=-1;for(;J>=0;J--){let W=$[J];if(W==="}")Q++;else if(W==="{"){if(Q--,Q===0){G=J;break}}}if(G===-1)return;let K=$.slice(G+1,Y);for(let W of cc(K)){let U=W.trim();if(!U||U.startsWith("..."))continue;let z=lc(U);if(z===-1)continue;let q=U.slice(0,z).trim();if(!/^[A-Z_$][\w$]*$/i.test(q))continue;if(X[q]!==void 0)continue;let j=U.slice(z+1).trim();if(!j)continue;try{let _=Object.keys(X),H=Function(..._,`"use strict"; return (${j});`);X[q]=H(..._.map((L)=>X[L]))}catch{}}}catch{}}async function n3($,X,Z,J,Y){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(O)=>O.split("-").map((B)=>B.charAt(0).toUpperCase()+B.slice(1)).join(""),K=(O)=>O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),W=Z.__importedComponents;if(W){for(let O of[Q,Q.toLowerCase(),G(Q),K(Q)])if(W.has(O))return!0}let U=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],z=typeof Y.root==="string"?Z0.resolve(Y.root):void 0,q=z??Z0.dirname(J),j=[],_=(O)=>{if(O&&!j.includes(O))j.push(O)},H=Z.__originalFilePath;if(H)_(Z0.join(Z0.dirname(H),"components"));_(X),_(Y._rootComponentsDir),_(Z0.join(Z0.dirname(J),"components")),_(Y.componentsDir);let L=Y._pluginComponentDirs;if(Array.isArray(L))for(let O of L)_(typeof O==="string"?O:null);if(z)_(Z0.resolve(z,"resources/views/components")),_(Z0.resolve(z,"resources/components")),_(Z0.resolve(z,"src/components")),_(Z0.resolve(z,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return H0(Z0.resolve(Z0.dirname(J),`${Q}.stx`));for(let O of j){let B=Z0.isAbsolute(O)?O:Z0.resolve(q,O);for(let F of U)if(await H0(Z0.join(B,F)))return!0}return!1}function bR($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}function yR($){if(!$)return!1;let X=$.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(X)}function xR($){let X=new Set,Z=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useReactiveProp|useLocalStorage|useSessionStorage|useCookie|useDebouncedValue)\s*(?:<[^>]*>)?\s*\(/g;for(let J of $){let Y;while((Y=Z.exec(J))!==null)X.add(Y[1]);Z.lastIndex=0}return[...X]}async function m$($,X,Z,J,Y,Q,G,K=new Set,W){let{extractVariables:U}=await D0("stx/variable-extractor",()=>Promise.resolve().then(() => (a4(),R2))),z=K??new Set;if(z.has($))return`[Circular component reference: ${$}]`;let q=new Set(z);q.add($);let j=typeof X.client==="string"?X.client.trim():"";if("client"in X)delete X.client;let _=j&&j!=="load"&&bR(j)?j:"";try{let H=(p)=>p.split("-").map((J0)=>J0.charAt(0).toUpperCase()+J0.slice(1)).join(""),L=(p)=>p.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),O=$.endsWith(".stx")?$.slice(0,-4):$,B=null,F=Y.__importedComponents;if(F){let p=[O,O.toLowerCase(),H(O),L(O)];for(let J0 of p)if(F.has(J0)){B=F.get(J0);break}}let V=[];if(!B){let p=[`${O}.stx`,`${H(O)}.stx`,`${L(O)}.stx`],J0=[...new Set(p)],M0=Y.__originalFilePath,E0=[];if(M0){let u0=Z0.join(Z0.dirname(M0),"components");E0.push(u0)}if(J)E0.push(J);let f0=G._rootComponentsDir;if(typeof f0==="string"&&!E0.includes(f0))E0.push(f0);let J1=Z0.join(Z0.dirname(Q),"components");if(!E0.includes(J1))E0.push(J1);if(G.componentsDir&&G.componentsDir!==J&&!E0.includes(G.componentsDir))E0.push(G.componentsDir);let S1=G._pluginComponentDirs;if(Array.isArray(S1)){for(let u0 of S1)if(typeof u0==="string"&&!E0.includes(u0))E0.push(u0)}let Y1=typeof G.root==="string"?Z0.resolve(G.root):void 0,V0=Y1??Z0.dirname(Q),o0=[];if(Y1)o0.push(Z0.resolve(Y1,"resources/views/components")),o0.push(Z0.resolve(Y1,"resources/components")),o0.push(Z0.resolve(Y1,"src/components")),o0.push(Z0.resolve(Y1,"components"));o0.push(Z0.resolve(import.meta.dir,"components"));for(let u0 of o0)if(!E0.includes(u0))E0.push(u0);let q1=[...new Set(E0.map((u0)=>{if(!u0)return u0;return Z0.isAbsolute(u0)?u0:Z0.resolve(V0,u0)}))];E0.length=0,E0.push(...q1);let j0=`${O}\x00${Q}\x00${q1.join("\x00")}`,h0=VJ.get(j0);if(h0)if(await H0(h0))B=h0;else VJ.delete(j0);if(!B&&(O.startsWith("./")||O.startsWith("../")))B=Z0.resolve(Z0.dirname(Q),`${O}.stx`),V.push(B);else if(!B)for(let u0 of E0){if(!u0)continue;for(let T6 of J0){let D6=Z0.join(u0,T6);if(V.push(D6),await H0(D6)){B=D6;break}}if(B)break;if(!B)try{let T6=await import("fs");if(!T6.statSync(u0,{throwIfNoEntry:!1})?.isDirectory())continue;let eZ=8,D8=[{path:u0,depth:0}];while(D8.length>0&&!B){let X4=D8.pop();if(X4.depth>=eZ)continue;let $9;try{$9=T6.readdirSync(X4.path,{withFileTypes:!0})}catch{continue}for(let X9 of $9){if(!X9.isDirectory())continue;if(X9.name==="node_modules"||X9.name.startsWith("."))continue;let LL=Z0.join(X4.path,X9.name);for(let qv of J0){let vQ=Z0.join(LL,qv);if(V.push(vQ),await H0(vQ)){B=vQ;break}}if(B)break;D8.push({path:LL,depth:X4.depth+1})}}}catch{}if(B)break}if(B)VJ.set(j0,B)}if(!B||!await H0(B)){let p=V.length>0?`
14902
14902
  Searched paths:
14903
- ${V.map((Z0)=>` - ${Z0}`).join(`
14904
- `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${p}`}W.add(B);let w;if(VX.has(B))w=VX.get(B);else try{w=await Bun.file(B).text(),VX.set(B,w)}catch(p){return`[Error loading component: ${p instanceof Error?p.message:String(p)}]`}let A=new Set(["__originalFilePath","__importedComponents",b9,"__stx_client_signal_names"]),R={};for(let[p,Z0]of Object.entries(Y))if(!p.startsWith("__")||A.has(p))R[p]=Z0;let M=v$(Z),I=[],N=M.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(p,Z0)=>{let M0=M.scripts[Number(Z0)]||"",E0=M0.match(/^<script\b([^>]*)>/i)?.[1]||"",f0=E0.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),J1=!f0||["module","text/javascript","application/javascript"].includes(f0);if(!/\bserver\b/i.test(E0)&&J1)return I.push(M0),"";return M0}),{extractSlotContent:E}=await D0("stx/slots",()=>Promise.resolve().then(() => (BJ(),dU))),C=E(N),S={};if(C.defaultSlot?.trim())S.default=C.defaultSlot;for(let[p,Z0]of C.namedSlots)S[p]=Z0.content;let y={...R,...X,props:X,slot:N,$slots:S,__processedComponents:q,__sections:{},__stx_signals_gate:f$(w)||yR(Z)};pc(w,y);let x=w,b=u$(x);if(b)x=b.content.trim();let u=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,i=[...w.matchAll(u)],c=[],P=i.some((p)=>/\bserver\b/.test(p[1]||"")&&/\bcache\b/.test(p[1]||""))&&i.every((p)=>/\bserver\b/.test(p[1]||"")),v=null,d=null;if(P){let p=mc({props:X,slot:Z,buildMode:G.buildMode??"",skipEventDirectives:G.skipEventDirectives===!0});if(p!==null){v=`${B}\x00${p}`;let Z0=cU.get(v);if(Z0){for(let M0 of Z0.dependencies)W.add(M0);return Z0.output}d=new Set(W)}}for(let p of i){let Z0=p[1]||"",M0=p[2]||"",E0=Z0.includes("server");if(f4(Z0)&&M0.trim())M0=g4(M0);if(E0&&M0)try{await U(M0,y,B)}catch(J1){}if(!E0){let J1=M0.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),S1=J1.includes("{{")&&J1.includes("}}"),Y1=J1.includes("{!!")&&J1.includes("!!}");if(S1||Y1)J1=w3(J1,y);let V0=Z0.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");c.push(`<script${V0}>${J1}</script>`)}}let a=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),t=a?a[1]:"",k0=a?a[2]:"",o="",W0=t&&/\bscoped\b/i.test(t);if(a)o=`<style${t}>${k0}</style>`;let U0=x;if(U0=U0.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),a)U0=U0.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let p=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,Z0=[];if(U0=U0.replace(p,(M0,E0)=>{let f0=E0.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(f0)Z0.push(`<style${f0[1]}>${f0[2]}</style>`);return""}),U0=U0.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),Z0.length>0)o=`${o}${Z0.join(`
14905
- `)}`}if(Z&&U0.includes("{{ text || slot }}"))U0=U0.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Z);let{applySlots:z0}=await D0("stx/slots",()=>Promise.resolve().then(() => (BJ(),dU))),{defaultSlot:s0,namedSlots:G0}=C;U0=await z0(U0,s0,G0,y);let l=c.some((p)=>/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useReactiveProp|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(p)),$0=xR(c),L0=Array.isArray(y.__stx_client_signal_names)?y.__stx_client_signal_names:[];if($0.length>0||L0.length>0)y.__stx_client_signal_names=[...new Set([...L0,...$0])];let O0={...G,_rootComponentsDir:G._rootComponentsDir||G.componentsDir,componentsDir:Y0.dirname(B),skipSignalsRuntime:!0,skipEventDirectives:l||c.length===0,defaultLayout:void 0};y.__stxProcessingDepth=(Y.__stxProcessingDepth||0)+1;let f=await w0(U0,y,B,O0,W),n=new Set(Array.isArray(Y.__stx_preserved_client_expressions)?Y.__stx_preserved_client_expressions:[]);for(let p of f.matchAll(/\{\{([\s\S]*?)\}\}/g))n.add(p[1].trim());if(n.size>0)Y.__stx_preserved_client_expressions=[...n];let q0=`stx_${O.replace(/[^a-zA-Z0-9]/g,"_")}_${++uc}_${Math.random().toString(36).slice(2,8)}`,e=f;if(l){let p="";if(Object.keys(X).length>0)try{p=` data-stx-props="${CR(JSON.stringify(X))}"`}catch{}let Z0=_?` stx-hydrate="${CR(_)}"`:"";e=`<div data-stx-scope="${q0}"${p}${Z0}>${f}</div>`;let M0=await Promise.all(c.map(async(E0)=>{let f0=E0.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!f0)return E0;let[,J1,S1]=f0,Y1=H3(S1,{filePath:B,projectRoot:process.cwd()}),V0=Y1.code,o0=L3(Y1.styles);V0=x6(V0).code;let{hasUserImports:q1,bundleClientScript:j0}=await D0("stx/client-script-bundler",()=>Promise.resolve().then(() => (b6(),j3)));if(q1(V0))V0=await j0(V0,B,{projectRoot:process.cwd(),minify:G.buildMode==="compile"});let{rewriteStxImportSpecifiers:h0}=await D0("stx/signal-processing",()=>Promise.resolve().then(() => (WX(),JJ)));V0=V0.replace(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm,(X4,$9)=>h0($9));let u0=n1(V0),T6=dc(u0),D6=`function(__scopeId) {
14903
+ ${V.map((J0)=>` - ${J0}`).join(`
14904
+ `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${p}`}W.add(B);let w;if(VX.has(B))w=VX.get(B);else try{w=await Bun.file(B).text(),VX.set(B,w)}catch(p){return`[Error loading component: ${p instanceof Error?p.message:String(p)}]`}let A=new Set(["__originalFilePath","__importedComponents",b9,"__stx_client_signal_names"]),R={};for(let[p,J0]of Object.entries(Y))if(!p.startsWith("__")||A.has(p))R[p]=J0;let M=v$(Z),I=[],N=M.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(p,J0)=>{let M0=M.scripts[Number(J0)]||"",E0=M0.match(/^<script\b([^>]*)>/i)?.[1]||"",f0=E0.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),J1=!f0||["module","text/javascript","application/javascript"].includes(f0);if(!/\bserver\b/i.test(E0)&&J1)return I.push(M0),"";return M0}),{extractSlotContent:E}=await D0("stx/slots",()=>Promise.resolve().then(() => (BJ(),dU))),C=E(N),S={};if(C.defaultSlot?.trim())S.default=C.defaultSlot;for(let[p,J0]of C.namedSlots)S[p]=J0.content;let x={...R,...X,props:X,slot:N,$slots:S,__processedComponents:q,__sections:{},__stx_signals_gate:f$(w)||yR(Z)};pc(w,x);let y=w,b=u$(y);if(b)y=b.content.trim();let u=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,i=[...w.matchAll(u)],c=[],P=i.some((p)=>/\bserver\b/.test(p[1]||"")&&/\bcache\b/.test(p[1]||""))&&i.every((p)=>/\bserver\b/.test(p[1]||"")),v=null,d=null;if(P){let p=mc({props:X,slot:Z,buildMode:G.buildMode??"",skipEventDirectives:G.skipEventDirectives===!0});if(p!==null){v=`${B}\x00${p}`;let J0=cU.get(v);if(J0){for(let M0 of J0.dependencies)W.add(M0);return J0.output}d=new Set(W)}}for(let p of i){let J0=p[1]||"",M0=p[2]||"",E0=J0.includes("server");if(f4(J0)&&M0.trim())M0=g4(M0);if(E0&&M0)try{await U(M0,x,B)}catch(J1){}if(!E0){let J1=M0.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),S1=J1.includes("{{")&&J1.includes("}}"),Y1=J1.includes("{!!")&&J1.includes("!!}");if(S1||Y1)J1=w3(J1,x);let V0=J0.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");c.push(`<script${V0}>${J1}</script>`)}}let a=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),t=a?a[1]:"",k0=a?a[2]:"",o="",W0=t&&/\bscoped\b/i.test(t);if(a)o=`<style${t}>${k0}</style>`;let U0=y;if(U0=U0.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),a)U0=U0.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let p=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,J0=[];if(U0=U0.replace(p,(M0,E0)=>{let f0=E0.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(f0)J0.push(`<style${f0[1]}>${f0[2]}</style>`);return""}),U0=U0.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),J0.length>0)o=`${o}${J0.join(`
14905
+ `)}`}if(Z&&U0.includes("{{ text || slot }}"))U0=U0.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Z);let{applySlots:z0}=await D0("stx/slots",()=>Promise.resolve().then(() => (BJ(),dU))),{defaultSlot:s0,namedSlots:G0}=C;U0=await z0(U0,s0,G0,x);let l=c.some((p)=>/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useReactiveProp|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(p)),$0=xR(c),L0=Array.isArray(x.__stx_client_signal_names)?x.__stx_client_signal_names:[];if($0.length>0||L0.length>0)x.__stx_client_signal_names=[...new Set([...L0,...$0])];let O0={...G,_rootComponentsDir:G._rootComponentsDir||G.componentsDir,componentsDir:Z0.dirname(B),skipSignalsRuntime:!0,skipEventDirectives:l||c.length===0,defaultLayout:void 0};x.__stxProcessingDepth=(Y.__stxProcessingDepth||0)+1;let f=await w0(U0,x,B,O0,W),n=new Set(Array.isArray(Y.__stx_preserved_client_expressions)?Y.__stx_preserved_client_expressions:[]);for(let p of f.matchAll(/\{\{([\s\S]*?)\}\}/g))n.add(p[1].trim());if(n.size>0)Y.__stx_preserved_client_expressions=[...n];let q0=`stx_${O.replace(/[^a-zA-Z0-9]/g,"_")}_${++uc}_${Math.random().toString(36).slice(2,8)}`,e=f;if(l){let p="";if(Object.keys(X).length>0)try{p=` data-stx-props="${CR(JSON.stringify(X))}"`}catch{}let J0=_?` stx-hydrate="${CR(_)}"`:"";e=`<div data-stx-scope="${q0}"${p}${J0}>${f}</div>`;let M0=await Promise.all(c.map(async(E0)=>{let f0=E0.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!f0)return E0;let[,J1,S1]=f0,Y1=H3(S1,{filePath:B,projectRoot:process.cwd()}),V0=Y1.code,o0=L3(Y1.styles);V0=x6(V0).code;let{hasUserImports:q1,bundleClientScript:j0}=await D0("stx/client-script-bundler",()=>Promise.resolve().then(() => (b6(),j3)));if(q1(V0))V0=await j0(V0,B,{projectRoot:process.cwd(),minify:G.buildMode==="compile"});let{rewriteStxImportSpecifiers:h0}=await D0("stx/signal-processing",()=>Promise.resolve().then(() => (WX(),JJ)));V0=V0.replace(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm,(X4,$9)=>h0($9));let u0=n1(V0),T6=dc(u0),D6=`function(__scopeId) {
14906
14906
  ${h8("const",[...cL,...T6],u0)}
14907
14907
  const __scope = window.stx._scopes = window.stx._scopes || {};
14908
14908
  const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
@@ -14935,11 +14935,11 @@ finally {
14935
14935
  `+M0.join(`
14936
14936
  `),o)e+=`
14937
14937
  `+o}else{if(o)e+=`
14938
- `+o;if(c.length>0){let p=y.__stx_event_bindings||[],Z0=v4(y),M0=await Promise.all(c.map(async(E0)=>{let f0=E0.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!f0)return E0;return await b$(f0[1],{eventBindings:p,templateContent:e,filePath:B,projectRoot:process.cwd(),serverData:Z0})}));e+=`
14938
+ `+o;if(c.length>0){let p=x.__stx_event_bindings||[],J0=v4(x),M0=await Promise.all(c.map(async(E0)=>{let f0=E0.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!f0)return E0;return await b$(f0[1],{eventBindings:p,templateContent:e,filePath:B,projectRoot:process.cwd(),serverData:J0})}));e+=`
14939
14939
  `+M0.join(`
14940
- `),y.__stx_event_bindings=[]}}if(W0){let p=a3(e,B);if(p.hasScoped)e=p.html}if(v&&d)cU.set(v,{output:e,dependencies:[...W].filter((p)=>!d.has(p))});return I.length>0?`${e}
14940
+ `),x.__stx_event_bindings=[]}}if(W0){let p=a3(e,B);if(p.hasScoped)e=p.html}if(v&&d)cU.set(v,{output:e,dependencies:[...W].filter((p)=>!d.has(p))});return I.length>0?`${e}
14941
14941
  ${I.join(`
14942
- `)}`:e}catch(H){return`[Error processing component: ${H instanceof Error?H.message:String(H)}]`}finally{z.delete($)}}async function H0($){return Bun.file($).exists()}function lU($,X){let Z=Y0.resolve(X),J=Y0.resolve($),Y=Z.endsWith(Y0.sep)?Z:Z+Y0.sep;if(J===Z||J.startsWith(Y))return J;return null}async function ic($,X,Z,J){let Y=X.startsWith("layouts/")?X.slice(8):X,Q=Y0.join($,Y);for(let G of Q.endsWith(".stx")?[Q]:[Q,`${Q}.stx`])if(await H0(G)){if(J)console.log(`Found layout in ${$}: ${G}`);return Z?.add(G),G}return null}async function FX($,X,Z,J){let Y=await nc($,X,Z,J);if(Y===null)return null;let Q=lU(Y,process.cwd());if(Q)return Q;let G=[Z.root,Z.layoutsDir,Z.componentsDir,Z.partialsDir,Z.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let W=Y0.isAbsolute(K)?K:Y0.resolve(process.cwd(),K);if(lU(Y,W))return Y0.resolve(Y)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${Y} (template: ${$}, from: ${X})`),null}async function nc($,X,Z,J){if(Z.debug)console.log(`Resolving template path: ${$} from ${X}`);let Y=Y0.dirname(X),Q=process.cwd();if($.startsWith("/")){let j=Y0.join(Q,$),_=lU(j,Q);if(!_)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${X})`),null;if(Z.debug)console.log(`Checking absolute path: ${_}`);if(await H0(_)&&J)J.add(_);return _}let G=Y0.join(Y,$);if(await H0(G)){if(Z.debug)console.log(`Found direct path: ${G}`);if(J)J.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let j of[".stx",".tsx",".jsx"]){let _=`${G}${j}`;if(await H0(_)){if(Z.debug)console.log(`Found direct path with extension: ${_}`);if(J)J.add(_);return _}}let K=[];if(Z.layoutsDir)K.push(Y0.isAbsolute(Z.layoutsDir)?Z.layoutsDir:Y0.resolve(process.cwd(),Z.layoutsDir));let W=Y0.resolve(Y),U=process.cwd();for(let j=0;j<10;j++){let _=Y0.join(W,"layouts"),H=!1;try{H=hc.statSync(_,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(H){K.push(_);break}let L=Y0.dirname(W);if(L===W||L.length<U.length)break;W=L}for(let j of K){let _=await ic(j,$,J,Z.debug);if(_)return _}if($.startsWith("layouts/")||$.includes("/layouts/")){let j=$.split("layouts/"),_=Y0.join(Z.partialsDir||Y,"layouts",j[1]);if(await H0(_)){if(Z.debug)console.log(`Found in layouts path: ${_}`);if(J)J.add(_);return _}if(!_.endsWith(".stx")){let H=`${_}.stx`;if(await H0(H)){if(Z.debug)console.log(`Found in layouts path with extension: ${H}`);if(J)J.add(H);return H}}}if(Z.partialsDir){let j=Y0.join(Z.partialsDir,"layouts");if(await H0(j)){let _=Y0.join(j,$);if(await H0(_)){if(Z.debug)console.log(`Found in partials layouts dir: ${_}`);if(J)J.add(_);return _}if(!$.endsWith(".stx")){let H=`${_}.stx`;if(await H0(H)){if(Z.debug)console.log(`Found in partials layouts dir with extension: ${H}`);if(J)J.add(H);return H}}}}let z=Z.partialsDir||Y0.join(process.cwd(),"views"),q=Y0.join(z,$);if(await H0(q)){if(Z.debug)console.log(`Found in views path: ${q}`);if(J)J.add(q);return q}if(!$.endsWith(".stx")){let j=`${q}.stx`;if(await H0(j)){if(Z.debug)console.log(`Found in views path with extension: ${j}`);if(J)J.add(j);return j}}if(Y.includes("temp")){let j=Y0.join(Y0.dirname(Y),"layouts",$);if(await H0(j)){if(Z.debug)console.log(`Found in temp layouts dir: ${j}`);if(J)J.add(j);return j}if(!$.endsWith(".stx")){let _=`${j}.stx`;if(await H0(_)){if(Z.debug)console.log(`Found in temp layouts dir with extension: ${_}`);if(J)J.add(_);return _}}}if(Z.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${X})`);else console.warn(`Template not found: ${$} (referenced from ${X})`);return null}function pU($,X,Z){let J=0,Y="",Q="";try{if(typeof X==="number"&&X>=0){let G=$.split(`
14942
+ `)}`:e}catch(H){return`[Error processing component: ${H instanceof Error?H.message:String(H)}]`}finally{z.delete($)}}async function H0($){return Bun.file($).exists()}function lU($,X){let Z=Z0.resolve(X),J=Z0.resolve($),Y=Z.endsWith(Z0.sep)?Z:Z+Z0.sep;if(J===Z||J.startsWith(Y))return J;return null}async function ic($,X,Z,J){let Y=X.startsWith("layouts/")?X.slice(8):X,Q=Z0.join($,Y);for(let G of Q.endsWith(".stx")?[Q]:[Q,`${Q}.stx`])if(await H0(G)){if(J)console.log(`Found layout in ${$}: ${G}`);return Z?.add(G),G}return null}async function FX($,X,Z,J){let Y=await nc($,X,Z,J);if(Y===null)return null;let Q=lU(Y,process.cwd());if(Q)return Q;let G=[Z.root,Z.layoutsDir,Z.fallbackLayoutsDir,Z.componentsDir,Z.partialsDir,Z.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let W=Z0.isAbsolute(K)?K:Z0.resolve(process.cwd(),K);if(lU(Y,W))return Z0.resolve(Y)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${Y} (template: ${$}, from: ${X})`),null}async function nc($,X,Z,J){if(Z.debug)console.log(`Resolving template path: ${$} from ${X}`);let Y=Z0.dirname(X),Q=process.cwd();if($.startsWith("/")){let j=Z0.join(Q,$),_=lU(j,Q);if(!_)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${X})`),null;if(Z.debug)console.log(`Checking absolute path: ${_}`);if(await H0(_)&&J)J.add(_);return _}let G=Z0.join(Y,$);if(await H0(G)){if(Z.debug)console.log(`Found direct path: ${G}`);if(J)J.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let j of[".stx",".tsx",".jsx"]){let _=`${G}${j}`;if(await H0(_)){if(Z.debug)console.log(`Found direct path with extension: ${_}`);if(J)J.add(_);return _}}let K=[];if(Z.layoutsDir)K.push(Z0.isAbsolute(Z.layoutsDir)?Z.layoutsDir:Z0.resolve(process.cwd(),Z.layoutsDir));let W=Z0.resolve(Y),U=process.cwd();for(let j=0;j<10;j++){let _=Z0.join(W,"layouts"),H=!1;try{H=hc.statSync(_,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(H){K.push(_);break}let L=Z0.dirname(W);if(L===W||L.length<U.length)break;W=L}for(let j of K){let _=await ic(j,$,J,Z.debug);if(_)return _}if(Z.fallbackLayoutsDir){let j=Z0.isAbsolute(Z.fallbackLayoutsDir)?Z.fallbackLayoutsDir:Z0.resolve(process.cwd(),Z.fallbackLayoutsDir),_=$.startsWith("layouts/")?$.slice(8):$,H=[Z0.join(j,_)];if(!$.endsWith(".stx"))H.push(`${H[0]}.stx`);for(let L of H)if(await H0(L)){if(Z.debug)console.log(`Found in options.fallbackLayoutsDir: ${L}`);if(J)J.add(L);return L}}if($.startsWith("layouts/")||$.includes("/layouts/")){let j=$.split("layouts/"),_=Z0.join(Z.partialsDir||Y,"layouts",j[1]);if(await H0(_)){if(Z.debug)console.log(`Found in layouts path: ${_}`);if(J)J.add(_);return _}if(!_.endsWith(".stx")){let H=`${_}.stx`;if(await H0(H)){if(Z.debug)console.log(`Found in layouts path with extension: ${H}`);if(J)J.add(H);return H}}}if(Z.partialsDir){let j=Z0.join(Z.partialsDir,"layouts");if(await H0(j)){let _=Z0.join(j,$);if(await H0(_)){if(Z.debug)console.log(`Found in partials layouts dir: ${_}`);if(J)J.add(_);return _}if(!$.endsWith(".stx")){let H=`${_}.stx`;if(await H0(H)){if(Z.debug)console.log(`Found in partials layouts dir with extension: ${H}`);if(J)J.add(H);return H}}}}let z=Z.partialsDir||Z0.join(process.cwd(),"views"),q=Z0.join(z,$);if(await H0(q)){if(Z.debug)console.log(`Found in views path: ${q}`);if(J)J.add(q);return q}if(!$.endsWith(".stx")){let j=`${q}.stx`;if(await H0(j)){if(Z.debug)console.log(`Found in views path with extension: ${j}`);if(J)J.add(j);return j}}if(Y.includes("temp")){let j=Z0.join(Z0.dirname(Y),"layouts",$);if(await H0(j)){if(Z.debug)console.log(`Found in temp layouts dir: ${j}`);if(J)J.add(j);return j}if(!$.endsWith(".stx")){let _=`${j}.stx`;if(await H0(_)){if(Z.debug)console.log(`Found in temp layouts dir with extension: ${_}`);if(J)J.add(_);return _}}}if(Z.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${X})`);else console.warn(`Template not found: ${$} (referenced from ${X})`);return null}function pU($,X,Z){let J=0,Y="",Q="";try{if(typeof X==="number"&&X>=0){let G=$.split(`
14943
14943
  `),K=0;for(let W=0;W<G.length;W++)if(K+=G[W].length+1,K>=X){J=W+1,Y=G[W].trim();let U=Math.max(0,W-2),z=Math.min(G.length,W+3);Q=G.slice(U,z).map((q,j)=>{let _=U+j+1;return`${_===J?"> ":" "}${_}: ${q}`}).join(`
14944
14944
  `);break}}else if(Z){let G=$.indexOf(Z);if(G>=0)return pU($,G)}}catch{}return{lineNumber:J,lineContent:Y,context:Q}}function p0($,X,Z,J,Y,Q){let{lineNumber:G,context:K}=pU(J,Y,Q),W=Z.split("/").pop(),U=0;if(typeof Y==="number"&&Y>=0&&J){let q=J.lastIndexOf(`
14945
14945
  `,Math.max(0,Y-1));U=Y-(q+1)+1}let z="";if(G>0)z+=`
@@ -15148,8 +15148,8 @@ ${P0.dim}${K}${P0.reset}
15148
15148
  filter: blur(0);
15149
15149
  transform: scale(1);
15150
15150
  }
15151
- `.trim();h5=new Map});import{createHash as Hz}from"crypto";import{readFile as Yl,stat as hR}from"fs/promises";async function A1($){try{let X=await Yl($);return Hz("sha256").update(X).digest("hex").slice(0,16)}catch{return""}}function uR($){return Hz("sha256").update($).digest("hex").slice(0,16)}function MJ($){return Hz("sha256").update($).digest("hex").slice(0,16)}function m5($,X){let Z=JSON.stringify(X,Object.keys(X).sort());return`${MJ($)}-${MJ(Z)}`}async function DX($){try{return(await hR($)).mtimeMs}catch{return 0}}async function R1($){try{return await hR($),!0}catch{return!1}}var Q6=()=>{};import{mkdir as Ql,readFile as dR,writeFile as Gl,readdir as cR,rm as Lz,stat as Kl}from"fs/promises";import{join as d5,dirname as Wl}from"path";async function Ul($){try{await Ql($,{recursive:!0})}catch{}}function lR($,X,Z){return d5($,Z,`${X}.json`)}async function mR($,X,Z){if((Date.now()-$.createdAt)/86400000>Z)return!1;if(await DX(X)!==$.srcMtime)return!1;return!0}async function c5($,X,Z,J=IX){if(!J.enabled)return null;let Y=m5($,X),Q=G6.get(Y);if(Q){if(await mR(Q,$,J.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;G6.delete(Y)}let G=lR(J.directory,Y,Z);if(await R1(G))try{let K=await dR(G,"utf-8"),W=JSON.parse(K);if(await mR(W,$,J.maxAge))return W.lastAccessedAt=Date.now(),G6.set(Y,W),W.data}catch{}return null}async function l5($,X,Z,J,Y=IX){if(!Y.enabled)return;let Q=m5($,X),G=await A1($),K=await DX($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:m5("",X),data:Z,createdAt:Date.now(),lastAccessedAt:Date.now()};G6.set(Q,W);let U=lR(Y.directory,Q,J);try{await Ul(Wl(U)),await Gl(U,JSON.stringify(W,null,2))}catch(z){console.warn(`[stx-media] Failed to write cache: ${z}`)}}async function p5($,X=IX){if($==="all")G6.clear();else G6.clear();let Z=$==="all"?["image","video"]:[$];for(let J of Z){let Y=d5(X.directory,J);try{await Lz(Y,{recursive:!0,force:!0})}catch{}}}async function pR($=IX){let X={memoryEntries:G6.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Z of["image","video"]){let J=d5($.directory,Z);try{let Y=await cR(J);X.diskEntries[Z]=Y.length;for(let Q of Y){let G=d5(J,Q),K=await Kl(G);X.totalSizeMB+=K.size/1048576}}catch{}}return X}async function iR($=IX){let X=0,Z=$.maxAge*24*60*60*1000;for(let J of["image","video"]){let Y=d5($.directory,J);try{let Q=await cR(Y);for(let G of Q){let K=d5(Y,G);try{let W=await dR(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Z)await Lz(K),G6.delete(U.key),X++}catch{await Lz(K).catch(()=>{}),X++}}}catch{}}return X}var G6,IX;var EJ=T(()=>{Q6();G6=new Map,IX={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class i5{config;constructor($={}){this.config={...zl,...$}}async get($,X){return c5($,X,"image",this.config)}async set($,X,Z){return l5($,X,Z,"image",this.config)}async clear(){return p5("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function Oz($){if(!TJ)TJ=new i5($);else if($)TJ.updateConfig($);return TJ}async function n5($,X,Z){let J=Z?{directory:`${Z.outputDir}/../.cache`}:{};return Oz(J).get($,X)}async function r5($,X,Z,J){let Y=J?{directory:`${J.outputDir}/../.cache`}:{};return Oz(Y).set($,X,Z)}async function Bz(){return Oz().clear()}var zl,TJ=null;var Fz=T(()=>{EJ();zl={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as ql,basename as jl,extname as _l,join as Hl}from"path";import{mkdir as Ll}from"fs/promises";async function Vz(){try{return await import("ts-images")}catch{return null}}function nR($){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 Ol($,X){let Z=X?nR(X):nR("web"),J=$.formatQuality||{};return{jpeg:{...Z.jpeg,...J.jpeg},png:{...Z.png,...J.png},webp:{...Z.webp,...J.webp},avif:{...Z.avif,...J.avif}}}async function wz($,X,Z){let J=await Vz();if(!J)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let Y=await n5($,X,Z);if(Y)return Y;try{let Q=ql($);if(!await R1(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=Ol(Z,X.preset),K=Z.outputDir||"dist/images",W=Z.baseUrl||"/images";await Ll(K,{recursive:!0});let U=await A1(Q),z=jl($,_l($)),q=X.outputFormat?[X.outputFormat]:Z.defaultFormats||["avif","webp","jpeg"],j={src:$,processed:!0,variants:[],hash:U},_=null;if(X.transformations&&X.transformations.length>0)_=await kX(Q,X.transformations,J);for(let H of q){let L=G[H]||{},O=`${z}-${U}.${H}`,B=Hl(K,O);try{let F=await J.optimizeImage({input:_||Q,output:B,format:H,quality:L.quality,progressive:L.progressive});if(F){if(j.variants.push({path:B,url:`${W}/${O}`,width:F.width||0,height:F.height||0,format:H,size:F.outputSize||0}),!j.originalWidth&&F.width)j.originalWidth=F.width,j.originalHeight=F.height}}catch(F){j.errors=j.errors||[],j.errors.push(`Failed to optimize ${H}: ${F}`)}}if(X.embedThumbhash||X.placeholder==="thumbhash")try{let H=await J.generateThumbHash(Q);j.placeholder=H.dataUrl}catch(H){j.errors=j.errors||[],j.errors.push(`Failed to generate thumbhash: ${H}`)}if(X.useDominantColor)try{let H=await J.generatePlaceholder(Q,{strategy:"dominant-color"});j.dominantColor=H.dominantColor}catch(H){j.errors=j.errors||[],j.errors.push(`Failed to extract dominant color: ${H}`)}return await r5($,X,j,Z),j}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function Az($,X,Z,J){let Y=await Vz();if(!Y)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await Y.optimizeImage({input:$,output:J,format:X,quality:Z}))?.outputSize}}catch(Q){return{success:!1,error:String(Q)}}}async function kX($,X,Z){let J=Z||await Vz();if(!J)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let Y=await J.decode($);for(let Q of X){let G=Q.options||{};switch(Q.type){case"resize":if(G.width||G.height)Y=await J.resize(Y,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)Y=await J.blur(Y,G.sigma);break;case"sharpen":if(G.amount!==void 0)Y=await J.sharpen(Y,G.amount);break;case"grayscale":Y=await J.grayscale(Y);break;case"rotate":if(G.angle!==void 0)Y=await J.rotate(Y,G.angle);break;case"flip":Y=await J.flip(Y);break;case"flop":Y=await J.flop(Y);break;case"brightness":if(G.value!==void 0)Y=await J.brightness(Y,G.value);break;case"contrast":if(G.value!==void 0)Y=await J.contrast(Y,G.value);break;case"saturation":if(G.value!==void 0)Y=await J.saturation(Y,G.value);break}}return await J.encode(Y,"png")}catch(Y){return console.error(`[stx-media] Transformation failed: ${Y}`),null}}var rR=T(()=>{Q6();Fz()});import{resolve as Bl,basename as Fl,extname as Vl,join as wl}from"path";import{mkdir as Al}from"fs/promises";async function Rl(){try{return await import("ts-images")}catch{return null}}async function DJ($,X,Z){let J=await Rl();if(!J)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let Y=Bl($);if(!await R1(Y))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=X.responsiveWidths||Z.breakpoints||Nl,G=X.formats||Z.defaultFormats||["avif","webp","jpeg"],K=Z.outputDir||"dist/images",W=Z.baseUrl||"/images";await Al(K,{recursive:!0});let U=await A1(Y),z=Fl($,Vl($)),q=Z.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},j={src:$,byFormat:{},srcsets:{}};for(let H of G){j.byFormat[H]=[];let L=[];for(let O of Q){let B=`${z}-${O}w-${U}.${H}`,F=wl(K,B),V=`${W}/${B}`;try{let w=q[H]?.quality||80;if(await R1(F)){j.byFormat[H].push({path:F,url:V,width:O,height:0,format:H,size:0}),L.push(`${V} ${O}w`);continue}let A=await J.processImage({input:Y,output:F,format:H,quality:w,resize:{width:O}});if(A)j.byFormat[H].push({path:F,url:V,width:O,height:A.height||Math.round(O*(A.height||1)/(A.width||1)),format:H,size:A.outputSize||0}),L.push(`${V} ${O}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${H} at ${O}w: ${w}`)}}j.srcsets[H]=L.join(", ")}let _=X.placeholder||Z.placeholderStrategy||"thumbhash";if(_!=="none")try{if(_==="thumbhash"){let H=await J.generateThumbHash(Y);j.placeholder={dataURL:H.dataUrl,width:H.width||32,height:H.height||32,strategy:"thumbhash"}}else{let H=await J.generatePlaceholder(Y,{strategy:_,width:20});j.placeholder={dataURL:H.dataURL,width:H.width,height:H.height,strategy:_}}}catch(H){console.warn(`[stx-media] Failed to generate placeholder: ${H}`)}return j.sizes=X.sizes||Ml(Q),j}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function Ml($){let X=[...$].sort((J,Y)=>J-Y),Z=[];for(let J=0;J<X.length-1;J++){let Y=X[J];Z.push(`(max-width: ${Y}px) ${Y}px`)}return Z.push(`${X[X.length-1]}px`),Z.join(", ")}function IJ($,X="width"){if(!$||$.length===0)return"";if(X==="dpr")return $.filter((Z)=>Z.dpr).map((Z)=>`${Z.url} ${Z.dpr}x`).join(", ");return $.map((Z)=>`${Z.url} ${Z.width}w`).join(", ")}var Nl;var aR=T(()=>{Q6();Nl=[320,480,640,768,1024,1280,1536,1920]});var sR={};X0(sR,{setCachedImageResult:()=>r5,processImage:()=>wz,optimizeImage:()=>Az,getCachedImageResult:()=>n5,generateSrcset:()=>IJ,generateResponsiveVariants:()=>DJ,clearImageCache:()=>Bz,applyTransformations:()=>kX,ImageProcessorCache:()=>i5});var Rz=T(()=>{rR();aR();Fz()});async function El(){try{return await Promise.resolve().then(() => (Rz(),sR))}catch($){if(!oR)console.warn("[stx-media] Image processor not available, some features disabled:",$),oR=!0;return null}}async function K6($,X={}){let Z=X,J=$;if(J.process&&!J.skipOptimization){if(Z.tsImagesConfig?.enabled&&!Z.isDev)return kl(J,Z)}if(Z.processedResult?.processed)return Dz($,Z.processedResult,X);if(Z.responsiveVariants)return XN($,Z.responsiveVariants,X);let{src:Y,alt:Q,width:G,height:K,sizes:W,widths:U=i$,dpr:z,formats:q=H4,quality:j=Nz,params:_={},placeholder:H="none",placeholderOptions:L={},lazy:O=!0,priority:B=!1,loading:F=B?"eager":SJ,decoding:V=kJ,fetchpriority:w,objectFit:A,objectPosition:R,crossorigin:M,referrerpolicy:I}=$,N=$.class,E=$.style,C=$.id,S=$.data||{},{isDev:y=!1,baseUrl:x=""}=X;if(y&&!X.optimize)return Il($);let b,u,i=C||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(H!=="none"&&!B)try{b=await TX(Y,{strategy:H,...L}),u=EX(i,b,L)}catch{}let c=z!==void 0&&G!==void 0,P;if(c)P=Dl($,i,b,X);else P=await Tl($,i,b,X);let v;if(B){let t=q.includes("webp")?"webp":q[0],k0=Y6(Y,U,{..._,q:j},t),o=typeof W==="object"?g5(W):W||"100vw";v=`<link rel="preload" as="image" imagesrcset="${k0}" imagesizes="${o}" />`}let d=[];if(!tR&&H!=="none")d.push(u5),tR=!0;if(u)d.push(u);let a=O?$N(i):void 0;return{html:P,preloadLink:v,css:d.length>0?d.join(`
15152
- `):void 0,script:a}}async function Tl($,X,Z,J){let{src:Y,alt:Q,width:G,height:K,sizes:W,widths:U=i$,formats:z=H4,quality:q=Nz,params:j={},lazy:_=!0,priority:H=!1,loading:L=H?"eager":SJ,decoding:O=kJ,fetchpriority:B,objectFit:F,objectPosition:V,crossorigin:w,referrerpolicy:A}=$,R=$.class,M=$.style,I=$.data||{},N=typeof W==="object"?g5(W):W||"100vw",E=[];for(let y of z){let x=Y6(Y,U,{...j,q},y),b=NX(y);if(_&&!H)E.push(` <source type="${b}" data-srcset="${x}" data-sizes="${N}" />`);else E.push(` <source type="${b}" srcset="${x}" sizes="${N}" />`)}let C=Mz({src:A$(Y,{...j,q}),alt:Q,width:G,height:K,loading:H?void 0:L,decoding:O,fetchpriority:H?"high":B,objectFit:F,objectPosition:V,crossorigin:w,referrerpolicy:A,className:eR(R,Z),style:Ez(M,F,V,Z),lazy:_&&!H,data:I}),S;if(Z){let y=`background-image: url('${Z.dataURL}'); background-size: cover; background-position: center;`;S=`<div id="${X}" class="stx-img-placeholder" style="${y}">
15151
+ `.trim();h5=new Map});import{createHash as Hz}from"crypto";import{readFile as Yl,stat as hR}from"fs/promises";async function A1($){try{let X=await Yl($);return Hz("sha256").update(X).digest("hex").slice(0,16)}catch{return""}}function uR($){return Hz("sha256").update($).digest("hex").slice(0,16)}function MJ($){return Hz("sha256").update($).digest("hex").slice(0,16)}function m5($,X){let Z=JSON.stringify(X,Object.keys(X).sort());return`${MJ($)}-${MJ(Z)}`}async function DX($){try{return(await hR($)).mtimeMs}catch{return 0}}async function R1($){try{return await hR($),!0}catch{return!1}}var Q6=()=>{};import{mkdir as Ql,readFile as dR,writeFile as Gl,readdir as cR,rm as Lz,stat as Kl}from"fs/promises";import{join as d5,dirname as Wl}from"path";async function Ul($){try{await Ql($,{recursive:!0})}catch{}}function lR($,X,Z){return d5($,Z,`${X}.json`)}async function mR($,X,Z){if((Date.now()-$.createdAt)/86400000>Z)return!1;if(await DX(X)!==$.srcMtime)return!1;return!0}async function c5($,X,Z,J=IX){if(!J.enabled)return null;let Y=m5($,X),Q=G6.get(Y);if(Q){if(await mR(Q,$,J.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;G6.delete(Y)}let G=lR(J.directory,Y,Z);if(await R1(G))try{let K=await dR(G,"utf-8"),W=JSON.parse(K);if(await mR(W,$,J.maxAge))return W.lastAccessedAt=Date.now(),G6.set(Y,W),W.data}catch{}return null}async function l5($,X,Z,J,Y=IX){if(!Y.enabled)return;let Q=m5($,X),G=await A1($),K=await DX($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:m5("",X),data:Z,createdAt:Date.now(),lastAccessedAt:Date.now()};G6.set(Q,W);let U=lR(Y.directory,Q,J);try{await Ul(Wl(U)),await Gl(U,JSON.stringify(W,null,2))}catch(z){console.warn(`[stx-media] Failed to write cache: ${z}`)}}async function p5($,X=IX){if($==="all")G6.clear();else G6.clear();let Z=$==="all"?["image","video"]:[$];for(let J of Z){let Y=d5(X.directory,J);try{await Lz(Y,{recursive:!0,force:!0})}catch{}}}async function pR($=IX){let X={memoryEntries:G6.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Z of["image","video"]){let J=d5($.directory,Z);try{let Y=await cR(J);X.diskEntries[Z]=Y.length;for(let Q of Y){let G=d5(J,Q),K=await Kl(G);X.totalSizeMB+=K.size/1048576}}catch{}}return X}async function iR($=IX){let X=0,Z=$.maxAge*24*60*60*1000;for(let J of["image","video"]){let Y=d5($.directory,J);try{let Q=await cR(Y);for(let G of Q){let K=d5(Y,G);try{let W=await dR(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Z)await Lz(K),G6.delete(U.key),X++}catch{await Lz(K).catch(()=>{}),X++}}}catch{}}return X}var G6,IX;var EJ=T(()=>{Q6();G6=new Map,IX={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class i5{config;constructor($={}){this.config={...zl,...$}}async get($,X){return c5($,X,"image",this.config)}async set($,X,Z){return l5($,X,Z,"image",this.config)}async clear(){return p5("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function Oz($){if(!TJ)TJ=new i5($);else if($)TJ.updateConfig($);return TJ}async function n5($,X,Z){let J=Z?{directory:`${Z.outputDir}/../.cache`}:{};return Oz(J).get($,X)}async function r5($,X,Z,J){let Y=J?{directory:`${J.outputDir}/../.cache`}:{};return Oz(Y).set($,X,Z)}async function Bz(){return Oz().clear()}var zl,TJ=null;var Fz=T(()=>{EJ();zl={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as ql,basename as jl,extname as _l,join as Hl}from"path";import{mkdir as Ll}from"fs/promises";async function Vz(){try{return await import("ts-images")}catch{return null}}function nR($){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 Ol($,X){let Z=X?nR(X):nR("web"),J=$.formatQuality||{};return{jpeg:{...Z.jpeg,...J.jpeg},png:{...Z.png,...J.png},webp:{...Z.webp,...J.webp},avif:{...Z.avif,...J.avif}}}async function wz($,X,Z){let J=await Vz();if(!J)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let Y=await n5($,X,Z);if(Y)return Y;try{let Q=ql($);if(!await R1(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=Ol(Z,X.preset),K=Z.outputDir||"dist/images",W=Z.baseUrl||"/images";await Ll(K,{recursive:!0});let U=await A1(Q),z=jl($,_l($)),q=X.outputFormat?[X.outputFormat]:Z.defaultFormats||["avif","webp","jpeg"],j={src:$,processed:!0,variants:[],hash:U},_=null;if(X.transformations&&X.transformations.length>0)_=await kX(Q,X.transformations,J);for(let H of q){let L=G[H]||{},O=`${z}-${U}.${H}`,B=Hl(K,O);try{let F=await J.optimizeImage({input:_||Q,output:B,format:H,quality:L.quality,progressive:L.progressive});if(F){if(j.variants.push({path:B,url:`${W}/${O}`,width:F.width||0,height:F.height||0,format:H,size:F.outputSize||0}),!j.originalWidth&&F.width)j.originalWidth=F.width,j.originalHeight=F.height}}catch(F){j.errors=j.errors||[],j.errors.push(`Failed to optimize ${H}: ${F}`)}}if(X.embedThumbhash||X.placeholder==="thumbhash")try{let H=await J.generateThumbHash(Q);j.placeholder=H.dataUrl}catch(H){j.errors=j.errors||[],j.errors.push(`Failed to generate thumbhash: ${H}`)}if(X.useDominantColor)try{let H=await J.generatePlaceholder(Q,{strategy:"dominant-color"});j.dominantColor=H.dominantColor}catch(H){j.errors=j.errors||[],j.errors.push(`Failed to extract dominant color: ${H}`)}return await r5($,X,j,Z),j}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function Az($,X,Z,J){let Y=await Vz();if(!Y)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await Y.optimizeImage({input:$,output:J,format:X,quality:Z}))?.outputSize}}catch(Q){return{success:!1,error:String(Q)}}}async function kX($,X,Z){let J=Z||await Vz();if(!J)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let Y=await J.decode($);for(let Q of X){let G=Q.options||{};switch(Q.type){case"resize":if(G.width||G.height)Y=await J.resize(Y,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)Y=await J.blur(Y,G.sigma);break;case"sharpen":if(G.amount!==void 0)Y=await J.sharpen(Y,G.amount);break;case"grayscale":Y=await J.grayscale(Y);break;case"rotate":if(G.angle!==void 0)Y=await J.rotate(Y,G.angle);break;case"flip":Y=await J.flip(Y);break;case"flop":Y=await J.flop(Y);break;case"brightness":if(G.value!==void 0)Y=await J.brightness(Y,G.value);break;case"contrast":if(G.value!==void 0)Y=await J.contrast(Y,G.value);break;case"saturation":if(G.value!==void 0)Y=await J.saturation(Y,G.value);break}}return await J.encode(Y,"png")}catch(Y){return console.error(`[stx-media] Transformation failed: ${Y}`),null}}var rR=T(()=>{Q6();Fz()});import{resolve as Bl,basename as Fl,extname as Vl,join as wl}from"path";import{mkdir as Al}from"fs/promises";async function Rl(){try{return await import("ts-images")}catch{return null}}async function DJ($,X,Z){let J=await Rl();if(!J)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let Y=Bl($);if(!await R1(Y))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=X.responsiveWidths||Z.breakpoints||Nl,G=X.formats||Z.defaultFormats||["avif","webp","jpeg"],K=Z.outputDir||"dist/images",W=Z.baseUrl||"/images";await Al(K,{recursive:!0});let U=await A1(Y),z=Fl($,Vl($)),q=Z.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},j={src:$,byFormat:{},srcsets:{}};for(let H of G){j.byFormat[H]=[];let L=[];for(let O of Q){let B=`${z}-${O}w-${U}.${H}`,F=wl(K,B),V=`${W}/${B}`;try{let w=q[H]?.quality||80;if(await R1(F)){j.byFormat[H].push({path:F,url:V,width:O,height:0,format:H,size:0}),L.push(`${V} ${O}w`);continue}let A=await J.processImage({input:Y,output:F,format:H,quality:w,resize:{width:O}});if(A)j.byFormat[H].push({path:F,url:V,width:O,height:A.height||Math.round(O*(A.height||1)/(A.width||1)),format:H,size:A.outputSize||0}),L.push(`${V} ${O}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${H} at ${O}w: ${w}`)}}j.srcsets[H]=L.join(", ")}let _=X.placeholder||Z.placeholderStrategy||"thumbhash";if(_!=="none")try{if(_==="thumbhash"){let H=await J.generateThumbHash(Y);j.placeholder={dataURL:H.dataUrl,width:H.width||32,height:H.height||32,strategy:"thumbhash"}}else{let H=await J.generatePlaceholder(Y,{strategy:_,width:20});j.placeholder={dataURL:H.dataURL,width:H.width,height:H.height,strategy:_}}}catch(H){console.warn(`[stx-media] Failed to generate placeholder: ${H}`)}return j.sizes=X.sizes||Ml(Q),j}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function Ml($){let X=[...$].sort((J,Y)=>J-Y),Z=[];for(let J=0;J<X.length-1;J++){let Y=X[J];Z.push(`(max-width: ${Y}px) ${Y}px`)}return Z.push(`${X[X.length-1]}px`),Z.join(", ")}function IJ($,X="width"){if(!$||$.length===0)return"";if(X==="dpr")return $.filter((Z)=>Z.dpr).map((Z)=>`${Z.url} ${Z.dpr}x`).join(", ");return $.map((Z)=>`${Z.url} ${Z.width}w`).join(", ")}var Nl;var aR=T(()=>{Q6();Nl=[320,480,640,768,1024,1280,1536,1920]});var sR={};X0(sR,{setCachedImageResult:()=>r5,processImage:()=>wz,optimizeImage:()=>Az,getCachedImageResult:()=>n5,generateSrcset:()=>IJ,generateResponsiveVariants:()=>DJ,clearImageCache:()=>Bz,applyTransformations:()=>kX,ImageProcessorCache:()=>i5});var Rz=T(()=>{rR();aR();Fz()});async function El(){try{return await Promise.resolve().then(() => (Rz(),sR))}catch($){if(!oR)console.warn("[stx-media] Image processor not available, some features disabled:",$),oR=!0;return null}}async function K6($,X={}){let Z=X,J=$;if(J.process&&!J.skipOptimization){if(Z.tsImagesConfig?.enabled&&!Z.isDev)return kl(J,Z)}if(Z.processedResult?.processed)return Dz($,Z.processedResult,X);if(Z.responsiveVariants)return XN($,Z.responsiveVariants,X);let{src:Y,alt:Q,width:G,height:K,sizes:W,widths:U=i$,dpr:z,formats:q=H4,quality:j=Nz,params:_={},placeholder:H="none",placeholderOptions:L={},lazy:O=!0,priority:B=!1,loading:F=B?"eager":SJ,decoding:V=kJ,fetchpriority:w,objectFit:A,objectPosition:R,crossorigin:M,referrerpolicy:I}=$,N=$.class,E=$.style,C=$.id,S=$.data||{},{isDev:x=!1,baseUrl:y=""}=X;if(x&&!X.optimize)return Il($);let b,u,i=C||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(H!=="none"&&!B)try{b=await TX(Y,{strategy:H,...L}),u=EX(i,b,L)}catch{}let c=z!==void 0&&G!==void 0,P;if(c)P=Dl($,i,b,X);else P=await Tl($,i,b,X);let v;if(B){let t=q.includes("webp")?"webp":q[0],k0=Y6(Y,U,{..._,q:j},t),o=typeof W==="object"?g5(W):W||"100vw";v=`<link rel="preload" as="image" imagesrcset="${k0}" imagesizes="${o}" />`}let d=[];if(!tR&&H!=="none")d.push(u5),tR=!0;if(u)d.push(u);let a=O?$N(i):void 0;return{html:P,preloadLink:v,css:d.length>0?d.join(`
15152
+ `):void 0,script:a}}async function Tl($,X,Z,J){let{src:Y,alt:Q,width:G,height:K,sizes:W,widths:U=i$,formats:z=H4,quality:q=Nz,params:j={},lazy:_=!0,priority:H=!1,loading:L=H?"eager":SJ,decoding:O=kJ,fetchpriority:B,objectFit:F,objectPosition:V,crossorigin:w,referrerpolicy:A}=$,R=$.class,M=$.style,I=$.data||{},N=typeof W==="object"?g5(W):W||"100vw",E=[];for(let x of z){let y=Y6(Y,U,{...j,q},x),b=NX(x);if(_&&!H)E.push(` <source type="${b}" data-srcset="${y}" data-sizes="${N}" />`);else E.push(` <source type="${b}" srcset="${y}" sizes="${N}" />`)}let C=Mz({src:A$(Y,{...j,q}),alt:Q,width:G,height:K,loading:H?void 0:L,decoding:O,fetchpriority:H?"high":B,objectFit:F,objectPosition:V,crossorigin:w,referrerpolicy:A,className:eR(R,Z),style:Ez(M,F,V,Z),lazy:_&&!H,data:I}),S;if(Z){let x=`background-image: url('${Z.dataURL}'); background-size: cover; background-position: center;`;S=`<div id="${X}" class="stx-img-placeholder" style="${x}">
15153
15153
  <picture>
15154
15154
  ${E.join(`
15155
15155
  `)}
@@ -15208,8 +15208,8 @@ ${A.join(`
15208
15208
  ${A.join(`
15209
15209
  `)}
15210
15210
  <img ${M.join(" ")} />
15211
- </picture>`;let y=[];if(X.placeholder)y.push(u5);let x=G?$N(H):void 0,b;if(K&&V)b=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:S,preloadLink:b,css:y.length>0?y.join(`
15212
- `):void 0,script:x}}async function XN($,X,Z){let J={src:X.src,processed:!0,variants:[],placeholder:X.placeholder?.dataURL,originalWidth:X.placeholder?.width,originalHeight:X.placeholder?.height};for(let[Y,Q]of Object.entries(X.byFormat))if(Q)J.variants.push(...Q);return Dz($,J,Z)}var oR=!1,Nz=80,kJ="async",SJ="lazy",tR=!1;var Iz=T(()=>{RJ();_z()});function PJ(){return Z1({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,X,Z,J)=>{let{src:Y,alt:Q,options:G}=Sl($,X,Z);if(!Y)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:Y,alt:Q||"",widths:G.widths||i$,formats:G.formats||H4,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=Z.__isDev||!1,U=await K6(K,{isDev:W}),z=U.html;if(U.preloadLink)z=U.preloadLink+`
15211
+ </picture>`;let x=[];if(X.placeholder)x.push(u5);let y=G?$N(H):void 0,b;if(K&&V)b=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:S,preloadLink:b,css:x.length>0?x.join(`
15212
+ `):void 0,script:y}}async function XN($,X,Z){let J={src:X.src,processed:!0,variants:[],placeholder:X.placeholder?.dataURL,originalWidth:X.placeholder?.width,originalHeight:X.placeholder?.height};for(let[Y,Q]of Object.entries(X.byFormat))if(Q)J.variants.push(...Q);return Dz($,J,Z)}var oR=!1,Nz=80,kJ="async",SJ="lazy",tR=!1;var Iz=T(()=>{RJ();_z()});function PJ(){return Z1({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,X,Z,J)=>{let{src:Y,alt:Q,options:G}=Sl($,X,Z);if(!Y)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:Y,alt:Q||"",widths:G.widths||i$,formats:G.formats||H4,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=Z.__isDev||!1,U=await K6(K,{isDev:W}),z=U.html;if(U.preloadLink)z=U.preloadLink+`
15213
15213
  `+z;if(U.css)z+=`
15214
15214
  <style>${U.css}</style>`;if(U.script)z+=`
15215
15215
  <script>${U.script}</script>`;return z},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function Sl($,X,Z){if(X.src)return{src:String(X.src),alt:String(X.alt||""),options:X.options||{}};let J=$.trim();if(J.startsWith("@img(")||J.startsWith("("))J=J.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Y=Cl(J),Q=kz(Y[0],Z)||"",G=kz(Y[1],Z)||"",K={};if(Y[2]){let W=kz(Y[2],Z);if(typeof W==="object"&&W!==null)K=W;else if(typeof Y[2]==="string")try{K=JSON.parse(Y[2])}catch{}}return{src:Q,alt:G,options:K}}function Cl($){let X=[],Z="",J=!1,Y="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'"||W==="`")&&U!=="\\"){if(!J)J=!0,Y=W;else if(W===Y)J=!1,Y="";else Z+=W;continue}if(!J){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){X.push(Z.trim()),Z="";continue}}Z+=W}if(Z.trim())X.push(Z.trim());return X}function kz($,X){if(typeof $!=="string")return $;let Z=$.trim();if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'"))return Z.slice(1,-1);if(!Z.startsWith("/")&&!Z.startsWith(".")&&!Z.startsWith("http")&&!Z.startsWith("{")){let J=X[Z];if(J!==void 0)return J}if(Z.startsWith("{")||Z.startsWith("["))try{return JSON.parse(Z)}catch{}return Z}var SX;var Sz=T(()=>{wX();Iz();RJ();SX=PJ()});class a5{config;constructor($={}){this.config={...Pl,...$}}async get($,X){return c5($,X,"video",this.config)}async set($,X,Z){return l5($,X,Z,"video",this.config)}async clear(){return p5("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function Cz($){if(!bJ)bJ=new a5($);else if($)bJ.updateConfig($);return bJ}async function s5($,X,Z){let J=Z?{directory:`${Z.outputDir}/../.cache`}:{};return Cz(J).get($,X)}async function o5($,X,Z,J){let Y=J?{directory:`${J.outputDir}/../.cache`}:{};return Cz(Y).set($,X,Z)}async function yJ(){return Cz().clear()}var Pl,bJ=null;var Pz=T(()=>{EJ();Pl={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as bz,basename as yz,extname as xz,join as xJ}from"path";import{mkdir as vz}from"fs/promises";async function fz(){try{return await import("ts-videos")}catch{return null}}async function t5($,X,Z,J){let Y=await fz();if(!Y)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=bz($);if(!await R1(Q))return null;await vz(Z,{recursive:!0});let G=await A1(Q),K=yz($,xz($)),W=X.format||"webp",U=X.timestamp||0,z=`${K}-poster-${G}.${W}`,q=xJ(Z,z),j=await Y.extractThumbnails(Q,{timestamps:[U],width:X.width||1280,height:X.height,format:W,quality:X.quality||85,outputDir:Z,outputPattern:z.replace(`.${W}`,"")});if(j&&j.length>0){let _=j[0];return{path:q,url:`${J}/${z}`,width:_.width||X.width||1280,height:_.height||720,timestamp:U,size:_.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function e5($,X,Z,J){let Y=await fz();if(!Y)return[];try{let Q=bz($);if(!await R1(Q))return[];await vz(Z,{recursive:!0});let G=await A1(Q),K=yz($,xz($)),W=X.format||"webp",q=(await new Y.Input(Q).getInfo()).duration||60,j=X.count||10,_=X.interval||q/j,H=[];for(let O=0;O<j&&O*_<q;O++)H.push(O*_);let L=await Y.extractThumbnails(Q,{timestamps:H,width:X.width||320,format:W,quality:X.quality||80,outputDir:Z,outputPattern:`${K}-thumb-${G}`});if(L&&L.length>0)return L.map((O,B)=>({path:O.path||xJ(Z,`${K}-thumb-${G}-${B}.${W}`),url:`${J}/${K}-thumb-${G}-${B}.${W}`,width:O.width||X.width||320,height:O.height||180,timestamp:H[B],size:O.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function vJ($,X,Z,J){let Y=await fz();if(!Y)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=bz($);if(!await R1(Q))return null;await vz(Z,{recursive:!0});let G=await A1(Q),K=yz($,xz($)),z=(await new Y.Input(Q).getInfo()).duration||60,q=X.columns||10,j=X.interval||5,_=X.thumbnailWidth||160,H=X.thumbnailHeight||90,L=X.format||"jpeg",O=Math.ceil(z/j),B=Math.ceil(O/q),F=`${K}-sprite-${G}.${L}`,V=xJ(Z,F),w=[];for(let R=0;R<O;R++)w.push(R*j);let A=await Y.extractThumbnails(Q,{timestamps:w,width:_,height:H,format:L,quality:X.quality||70,outputDir:xJ(Z,".temp")});if(!A||A.length===0)return null;try{let R=await import("ts-images"),M=q*_,I=B*H,N=await R.createSprite({images:A.map((E)=>E.path),columns:q,padding:0,outputPath:V,format:L,quality:X.quality||70});return{url:`${J}/${F}`,path:V,columns:q,rows:B,thumbnailWidth:_,thumbnailHeight:H,interval:j,totalFrames:O}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(Q){return console.warn(`[stx-media] Failed to generate sprite sheet: ${Q}`),null}}var gz=T(()=>{Q6()});import{resolve as JN,basename as YN,extname as QN,join as Z8}from"path";import{mkdir as fJ,writeFile as GN}from"fs/promises";async function KN(){try{return await import("ts-videos")}catch{return null}}async function $7($,X,Z,J,Y){let Q=await KN();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=JN($);if(!await R1(G))return null;let K=await A1(G),W=YN($,QN($)),U=Z8(Z,`${W}-${K}-hls`);await fJ(U,{recursive:!0});let z=X.length>0?X:WN,q=Y?.segmentDuration||6,H=(await new Q.Input(G).getInfo()).duration||0,L=[],O=0;for(let V of z){let w=Z8(U,V.label);await fJ(w,{recursive:!0});let A=`${V.label}.m3u8`,R=Z8(w,A);try{let M=await Q.generateHLS(G,{outputDir:w,segmentDuration:q,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(M)L.push({quality:V,url:`${J}/${W}-${K}-hls/${V.label}/${A}`,path:R}),O+=M.segmentCount||Math.ceil(H/q)}catch(M){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${M}`)}}if(L.length===0)return null;let B=Z8(U,"master.m3u8"),F=bl(L,J,W,K);return await GN(B,F),{manifestUrl:`${J}/${W}-${K}-hls/master.m3u8`,manifestPath:B,playlists:L,segmentCount:O,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function bl($,X,Z,J){let Y=["#EXTM3U","#EXT-X-VERSION:3"];for(let Q of $){let{quality:G}=Q,K=G.bitrate+(G.audioBitrate||128000),W=`${G.width}x${G.height||Math.round(G.width*9/16)}`;Y.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${W},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return Y.join(`
@@ -15239,9 +15239,9 @@ ${A.join(`
15239
15239
  </Representation>
15240
15240
  `}K+=` </AdaptationSet>
15241
15241
  `}return K+=` </Period>
15242
- </MPD>`,K}function ZN($){let X=Math.floor($/3600),Z=Math.floor($%3600/60),J=Math.floor($%60),Y="PT";if(X>0)Y+=`${X}H`;if(Z>0)Y+=`${Z}M`;return Y+=`${J}S`,Y}var WN;var hz=T(()=>{Q6();WN=[{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},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}]});import{resolve as UN,basename as xl,extname as vl,join as fl}from"path";import{mkdir as gl}from"fs/promises";async function zN(){try{return await import("ts-videos")}catch{return null}}function hl($){switch($){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function ul($){switch($){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function CX($){let X=await zN();if(!X)return null;try{let Z=UN($),Y=await new X.Input(Z).getInfo();return{duration:Y.duration||0,width:Y.width||0,height:Y.height||0,frameRate:Y.frameRate||0,bitrate:Y.bitrate||0,codec:Y.videoCodec||"",audioCodec:Y.audioCodec}}catch(Z){return console.warn(`[stx-media] Failed to analyze video: ${Z}`),null}}async function gJ($,X,Z,J){let Y=await zN();if(!Y)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await s5($,X,Z);if(Q)return Q;try{let G=UN($);if(!await R1(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Z.outputDir||"dist/videos",W=Z.baseUrl||"/videos";await gl(K,{recursive:!0});let U=await A1(G),z=xl($,vl($)),q={src:$,processed:!0,hash:U};J?.({percentage:5,stage:"analyzing"}),q.metadata=await CX(G)||void 0;let j={};if(X.quality)j.bitrate=hl(X.quality);if(X.platform)Object.assign(j,ul(X.platform));if(X.transcode)Object.assign(j,X.transcode);if(Object.keys(j).length>0||X.process){J?.({percentage:10,stage:"transcoding"});let _=`${z}-${U}.mp4`,H=fl(K,_);try{let L=await ml(G,H,j,Y,(O)=>J?.({percentage:10+O*0.5,stage:"transcoding"}));if(L)q.transcoded={path:H,url:`${W}/${_}`,duration:L.duration,size:L.size,video:{codec:j.codec||"h264",width:L.width,height:L.height,bitrate:L.bitrate,frameRate:L.frameRate},audio:L.audioCodec?{codec:j.audioCodec||"aac",bitrate:j.audioBitrate||128000,sampleRate:j.sampleRate||48000,channels:j.channels||2}:void 0}}catch(L){q.errors=q.errors||[],q.errors.push(`Transcoding failed: ${L}`)}}if(X.generatePoster){J?.({percentage:65,stage:"generating-poster"});let _=typeof X.generatePoster==="object"?X.generatePoster:{timestamp:0},H=await t5(G,_,K,W);if(H)q.poster=H}if(Z.thumbnails?.enabled){J?.({percentage:70,stage:"generating-thumbnails"});let _=await e5(G,Z.thumbnails,K,W);if(_.length>0)q.thumbnails=_}if(X.streaming){J?.({percentage:80,stage:"generating-manifests"});let _=typeof X.streaming==="object"?X.streaming:Z.streaming||{format:"hls"};if(_.format==="hls"||_.format===void 0){let H=await $7(G,_.qualities||Z.streaming?.defaultQualities||[],K,W);if(H)q.streaming={...q.streaming,hls:H}}if(_.format==="dash"){let H=await X7(G,_.qualities||Z.streaming?.defaultQualities||[],K,W);if(H)q.streaming={...q.streaming,dash:H}}}if(X.spriteSheet)J?.({percentage:90,stage:"generating-sprite-sheet"});return J?.({percentage:100,stage:"complete"}),await o5($,X,q,Z),q}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function ml($,X,Z,J,Y){try{let G=await new J.Conversion($,X,{videoCodec:Z.codec,videoBitrate:Z.bitrate,width:Z.maxWidth,height:Z.maxHeight,frameRate:Z.frameRate,audioCodec:Z.audioCodec,audioBitrate:Z.audioBitrate,sampleRate:Z.sampleRate,channels:Z.channels}).run((K)=>{Y?.(K.percentage/100)});return{duration:G.duration||0,size:G.size||0,width:G.width||Z.maxWidth||0,height:G.height||Z.maxHeight||0,bitrate:G.bitrate||Z.bitrate||0,frameRate:G.frameRate||Z.frameRate||30,audioCodec:G.audioCodec}}catch(Q){return console.error(`[stx-media] Transcoding failed: ${Q}`),null}}var qN=T(()=>{Q6();Pz();gz();hz()});var jN={};X0(jN,{setCachedVideoResult:()=>o5,processVideo:()=>gJ,getCachedVideoResult:()=>s5,generateThumbnails:()=>e5,generateSpriteSheet:()=>vJ,generatePoster:()=>t5,generateHLSManifest:()=>$7,generateDASHManifest:()=>X7,clearVideoCache:()=>yJ,analyzeVideo:()=>CX,VideoProcessorCache:()=>a5});var uz=T(()=>{qN();gz();hz();Pz()});async function HN(){try{return await Promise.resolve().then(() => (uz(),jN))}catch($){if(!_N)console.warn("[stx-media] Video processor not available, some features disabled:",$),_N=!0;return null}}async function Z7($,X={}){let Z=X,J=$;if(J.process&&!J.skipProcessing){if(Z.tsVideosConfig?.enabled&&!Z.isDev)return nl(J,Z)}if(Z.processedResult?.processed)return VN($,Z.processedResult,X);let Y;if(J.generatePoster&&J.src&&!$.poster)Y=await rl(J,Z);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=LN,autoplay:z=!1,muted:q=!1,loop:j=!1,preload:_=ON,playsinline:H=!0,lazy:L=!0,player:O="native",type:B,width:F,height:V,crossorigin:w,disablePictureInPicture:A=!1,disableRemotePlayback:R=!1}=$,M=Y||K,I=$.class,N=$.style,E=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(O==="ts-video")return ll($,X);if(B&&B!=="video")return cl(Q||"",B,$);let C=G.length>0?G:Q?[{src:Q,type:BN(Q)}]:[],S=[`id="${E}"`];if(U)S.push("controls");if(z)S.push("autoplay");if(q)S.push("muted");if(j)S.push("loop");if(H)S.push("playsinline");if(A)S.push("disablepictureinpicture");if(R)S.push("disableremoteplayback");if(w)S.push(`crossorigin="${w}"`);if(L){if(S.push(`data-preload="${_}"`),S.push('preload="none"'),M)S.push(`data-poster="${B1(M)}"`);S.push("data-stx-lazy")}else if(S.push(`preload="${_}"`),M)S.push(`poster="${B1(M)}"`);if(F)S.push(`width="${F}"`);if(V)S.push(`height="${V}"`);if(I)S.push(`class="${B1(I)}"`);if(N)S.push(`style="${B1(N)}"`);let y=C.map((u)=>{return` <source ${L?`data-src="${B1(u.src)}"`:`src="${B1(u.src)}"`} type="${u.type}"${u.media?` media="${u.media}"`:""} />`}).join(`
15243
- `),x=`<video ${S.join(" ")}>
15244
- ${y}
15242
+ </MPD>`,K}function ZN($){let X=Math.floor($/3600),Z=Math.floor($%3600/60),J=Math.floor($%60),Y="PT";if(X>0)Y+=`${X}H`;if(Z>0)Y+=`${Z}M`;return Y+=`${J}S`,Y}var WN;var hz=T(()=>{Q6();WN=[{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},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}]});import{resolve as UN,basename as xl,extname as vl,join as fl}from"path";import{mkdir as gl}from"fs/promises";async function zN(){try{return await import("ts-videos")}catch{return null}}function hl($){switch($){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function ul($){switch($){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function CX($){let X=await zN();if(!X)return null;try{let Z=UN($),Y=await new X.Input(Z).getInfo();return{duration:Y.duration||0,width:Y.width||0,height:Y.height||0,frameRate:Y.frameRate||0,bitrate:Y.bitrate||0,codec:Y.videoCodec||"",audioCodec:Y.audioCodec}}catch(Z){return console.warn(`[stx-media] Failed to analyze video: ${Z}`),null}}async function gJ($,X,Z,J){let Y=await zN();if(!Y)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await s5($,X,Z);if(Q)return Q;try{let G=UN($);if(!await R1(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Z.outputDir||"dist/videos",W=Z.baseUrl||"/videos";await gl(K,{recursive:!0});let U=await A1(G),z=xl($,vl($)),q={src:$,processed:!0,hash:U};J?.({percentage:5,stage:"analyzing"}),q.metadata=await CX(G)||void 0;let j={};if(X.quality)j.bitrate=hl(X.quality);if(X.platform)Object.assign(j,ul(X.platform));if(X.transcode)Object.assign(j,X.transcode);if(Object.keys(j).length>0||X.process){J?.({percentage:10,stage:"transcoding"});let _=`${z}-${U}.mp4`,H=fl(K,_);try{let L=await ml(G,H,j,Y,(O)=>J?.({percentage:10+O*0.5,stage:"transcoding"}));if(L)q.transcoded={path:H,url:`${W}/${_}`,duration:L.duration,size:L.size,video:{codec:j.codec||"h264",width:L.width,height:L.height,bitrate:L.bitrate,frameRate:L.frameRate},audio:L.audioCodec?{codec:j.audioCodec||"aac",bitrate:j.audioBitrate||128000,sampleRate:j.sampleRate||48000,channels:j.channels||2}:void 0}}catch(L){q.errors=q.errors||[],q.errors.push(`Transcoding failed: ${L}`)}}if(X.generatePoster){J?.({percentage:65,stage:"generating-poster"});let _=typeof X.generatePoster==="object"?X.generatePoster:{timestamp:0},H=await t5(G,_,K,W);if(H)q.poster=H}if(Z.thumbnails?.enabled){J?.({percentage:70,stage:"generating-thumbnails"});let _=await e5(G,Z.thumbnails,K,W);if(_.length>0)q.thumbnails=_}if(X.streaming){J?.({percentage:80,stage:"generating-manifests"});let _=typeof X.streaming==="object"?X.streaming:Z.streaming||{format:"hls"};if(_.format==="hls"||_.format===void 0){let H=await $7(G,_.qualities||Z.streaming?.defaultQualities||[],K,W);if(H)q.streaming={...q.streaming,hls:H}}if(_.format==="dash"){let H=await X7(G,_.qualities||Z.streaming?.defaultQualities||[],K,W);if(H)q.streaming={...q.streaming,dash:H}}}if(X.spriteSheet)J?.({percentage:90,stage:"generating-sprite-sheet"});return J?.({percentage:100,stage:"complete"}),await o5($,X,q,Z),q}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function ml($,X,Z,J,Y){try{let G=await new J.Conversion($,X,{videoCodec:Z.codec,videoBitrate:Z.bitrate,width:Z.maxWidth,height:Z.maxHeight,frameRate:Z.frameRate,audioCodec:Z.audioCodec,audioBitrate:Z.audioBitrate,sampleRate:Z.sampleRate,channels:Z.channels}).run((K)=>{Y?.(K.percentage/100)});return{duration:G.duration||0,size:G.size||0,width:G.width||Z.maxWidth||0,height:G.height||Z.maxHeight||0,bitrate:G.bitrate||Z.bitrate||0,frameRate:G.frameRate||Z.frameRate||30,audioCodec:G.audioCodec}}catch(Q){return console.error(`[stx-media] Transcoding failed: ${Q}`),null}}var qN=T(()=>{Q6();Pz();gz();hz()});var jN={};X0(jN,{setCachedVideoResult:()=>o5,processVideo:()=>gJ,getCachedVideoResult:()=>s5,generateThumbnails:()=>e5,generateSpriteSheet:()=>vJ,generatePoster:()=>t5,generateHLSManifest:()=>$7,generateDASHManifest:()=>X7,clearVideoCache:()=>yJ,analyzeVideo:()=>CX,VideoProcessorCache:()=>a5});var uz=T(()=>{qN();gz();hz();Pz()});async function HN(){try{return await Promise.resolve().then(() => (uz(),jN))}catch($){if(!_N)console.warn("[stx-media] Video processor not available, some features disabled:",$),_N=!0;return null}}async function Z7($,X={}){let Z=X,J=$;if(J.process&&!J.skipProcessing){if(Z.tsVideosConfig?.enabled&&!Z.isDev)return nl(J,Z)}if(Z.processedResult?.processed)return VN($,Z.processedResult,X);let Y;if(J.generatePoster&&J.src&&!$.poster)Y=await rl(J,Z);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=LN,autoplay:z=!1,muted:q=!1,loop:j=!1,preload:_=ON,playsinline:H=!0,lazy:L=!0,player:O="native",type:B,width:F,height:V,crossorigin:w,disablePictureInPicture:A=!1,disableRemotePlayback:R=!1}=$,M=Y||K,I=$.class,N=$.style,E=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(O==="ts-video")return ll($,X);if(B&&B!=="video")return cl(Q||"",B,$);let C=G.length>0?G:Q?[{src:Q,type:BN(Q)}]:[],S=[`id="${E}"`];if(U)S.push("controls");if(z)S.push("autoplay");if(q)S.push("muted");if(j)S.push("loop");if(H)S.push("playsinline");if(A)S.push("disablepictureinpicture");if(R)S.push("disableremoteplayback");if(w)S.push(`crossorigin="${w}"`);if(L){if(S.push(`data-preload="${_}"`),S.push('preload="none"'),M)S.push(`data-poster="${B1(M)}"`);S.push("data-stx-lazy")}else if(S.push(`preload="${_}"`),M)S.push(`poster="${B1(M)}"`);if(F)S.push(`width="${F}"`);if(V)S.push(`height="${V}"`);if(I)S.push(`class="${B1(I)}"`);if(N)S.push(`style="${B1(N)}"`);let x=C.map((u)=>{return` <source ${L?`data-src="${B1(u.src)}"`:`src="${B1(u.src)}"`} type="${u.type}"${u.media?` media="${u.media}"`:""} />`}).join(`
15243
+ `),y=`<video ${S.join(" ")}>
15244
+ ${x}
15245
15245
  Your browser does not support the video tag.
15246
15246
  </video>`,b;if(L)b=`
15247
15247
  (function() {
@@ -15278,7 +15278,7 @@ ${y}
15278
15278
 
15279
15279
  observer.observe(video);
15280
15280
  })();
15281
- `.trim();return{html:x,script:b}}function cl($,X,Z){let{width:J=640,height:Y=360}=Z,Q=Z.class,G=Z.style,K=Z.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,W,U=null;switch(X){case"youtube":U=pl($),W=U?`https://www.youtube-nocookie.com/embed/${U}`:$;break;case"vimeo":U=il($),W=U?`https://player.vimeo.com/video/${U}`:$;break;case"dailymotion":U=$.split("/").pop()||"",W=`https://www.dailymotion.com/embed/video/${U}`;break;case"twitch":U=$.split("/").pop()||"",W=`https://player.twitch.tv/?video=${U}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:W=$}let z=[`id="${K}"`,`src="${B1(W)}"`,`width="${J}"`,`height="${Y}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(Q)z.push(`class="${B1(Q)}"`);if(G)z.push(`style="${B1(G)}"`);if(Z.lazy)z.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
15281
+ `.trim();return{html:y,script:b}}function cl($,X,Z){let{width:J=640,height:Y=360}=Z,Q=Z.class,G=Z.style,K=Z.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,W,U=null;switch(X){case"youtube":U=pl($),W=U?`https://www.youtube-nocookie.com/embed/${U}`:$;break;case"vimeo":U=il($),W=U?`https://player.vimeo.com/video/${U}`:$;break;case"dailymotion":U=$.split("/").pop()||"",W=`https://www.dailymotion.com/embed/video/${U}`;break;case"twitch":U=$.split("/").pop()||"",W=`https://player.twitch.tv/?video=${U}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:W=$}let z=[`id="${K}"`,`src="${B1(W)}"`,`width="${J}"`,`height="${Y}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(Q)z.push(`class="${B1(Q)}"`);if(G)z.push(`style="${B1(G)}"`);if(Z.lazy)z.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
15282
15282
  <iframe ${z.join(" ")} style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
15283
15283
  </div>`}}function ll($,X={}){let{src:Z,sources:J=[],poster:Y,controls:Q=!0,autoplay:G=!1,muted:K=!1,loop:W=!1,preload:U="metadata",playsinline:z=!0,lazy:q=!0,width:j,height:_}=$,H=$.class,L=$.style,O=$.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,B={src:J.length>0?J:Z,autoplay:G,loop:W,muted:K,playsinline:z,preload:U,poster:Y,controls:Q,title:$.title},F=["position: relative",j?`width: ${typeof j==="number"?j+"px":j}`:"width: 100%",_?`height: ${typeof _==="number"?_+"px":_}`:"",L||""].filter(Boolean).join("; "),V=`
15284
15284
  <div
@@ -15487,7 +15487,7 @@ ${C}
15487
15487
 
15488
15488
  observer.observe(video);
15489
15489
  })();
15490
- `.trim();let y;if(w)y=`
15490
+ `.trim();let x;if(w)x=`
15491
15491
  .stx-video-wrapper {
15492
15492
  position: relative;
15493
15493
  width: 100%;
@@ -15496,7 +15496,7 @@ ${C}
15496
15496
  width: 100%;
15497
15497
  height: auto;
15498
15498
  }
15499
- `.trim();return{html:C,script:S,css:y}}var _N=!1,LN=!0,ON="metadata",dl="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";var mz=T(()=>{dz()});function hJ(){return Z1({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async($,X,Z,J)=>{let{src:Y,options:Q}=al($,X,Z);if(!Y)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let G={src:Y,poster:Q.poster,controls:Q.controls!==!1,autoplay:Q.autoplay||!1,muted:Q.muted||!1,loop:Q.loop||!1,preload:Q.preload||"metadata",playsinline:Q.playsinline!==!1,lazy:Q.lazy!==!1,player:Q.player||"native",type:Q.type,width:Q.width,height:Q.height,class:Q.class,style:Q.style,id:Q.id,crossorigin:Q.crossorigin,disablePictureInPicture:Q.disablePictureInPicture,disableRemotePlayback:Q.disableRemotePlayback,title:Q.title,quality:Q.quality,platform:Q.platform,process:Q.process,generatePoster:Q.generatePoster,streaming:Q.streaming,transcode:Q.transcode,spriteSheet:Q.spriteSheet,waveform:Q.waveform},W={isDev:Z.__isDev||!1,tsVideosConfig:Z.__tsVideosConfig},U=await Z7(G,W),z=U.html;if(U.css)z+=`
15499
+ `.trim();return{html:C,script:S,css:x}}var _N=!1,LN=!0,ON="metadata",dl="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";var mz=T(()=>{dz()});function hJ(){return Z1({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async($,X,Z,J)=>{let{src:Y,options:Q}=al($,X,Z);if(!Y)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let G={src:Y,poster:Q.poster,controls:Q.controls!==!1,autoplay:Q.autoplay||!1,muted:Q.muted||!1,loop:Q.loop||!1,preload:Q.preload||"metadata",playsinline:Q.playsinline!==!1,lazy:Q.lazy!==!1,player:Q.player||"native",type:Q.type,width:Q.width,height:Q.height,class:Q.class,style:Q.style,id:Q.id,crossorigin:Q.crossorigin,disablePictureInPicture:Q.disablePictureInPicture,disableRemotePlayback:Q.disableRemotePlayback,title:Q.title,quality:Q.quality,platform:Q.platform,process:Q.process,generatePoster:Q.generatePoster,streaming:Q.streaming,transcode:Q.transcode,spriteSheet:Q.spriteSheet,waveform:Q.waveform},W={isDev:Z.__isDev||!1,tsVideosConfig:Z.__tsVideosConfig},U=await Z7(G,W),z=U.html;if(U.css)z+=`
15500
15500
  <style>${U.css}</style>`;if(U.script)z+=`
15501
15501
  <script>${U.script}</script>`;return z},defaults:{src:"",options:{controls:!0,lazy:!0,preload:"metadata"}}})}function al($,X,Z){if(X.src)return{src:String(X.src),options:X.options||{}};let J=$.trim();if(J.startsWith("@video(")||J.startsWith("("))J=J.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Y=sl(J),Q=wN(Y[0],Z)||"",G={};if(Y[1]){let K=wN(Y[1],Z);if(typeof K==="object"&&K!==null)G=K;else if(typeof Y[1]==="string")try{G=JSON.parse(Y[1])}catch{}}return{src:Q,options:G}}function sl($){let X=[],Z="",J=!1,Y="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'"||W==="`")&&U!=="\\"){if(!J)J=!0,Y=W;else if(W===Y)J=!1,Y="";else Z+=W;continue}if(!J){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){X.push(Z.trim()),Z="";continue}}Z+=W}if(Z.trim())X.push(Z.trim());return X}function wN($,X){if(typeof $!=="string")return $;let Z=$.trim();if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'"))return Z.slice(1,-1);if(!Z.startsWith("/")&&!Z.startsWith(".")&&!Z.startsWith("http")&&!Z.startsWith("{")){let J=X[Z];if(J!==void 0)return J}if(Z.startsWith("{")||Z.startsWith("["))try{return JSON.parse(Z)}catch{}return Z}var PX;var dz=T(()=>{wX();mz();PX=hJ()});function ol($,X){let Z=X.pwa?.manifest?.themeColor||"#4f46e5";return`<div class="stx-pwa-install" style="display:none;">
15502
15502
  ${$}
@@ -16054,7 +16054,7 @@ else { this.removeAttribute('${E}'); }`:`this.setAttribute('${E}', ${N.type==="o
16054
16054
  }
16055
16055
  else {
16056
16056
  this.removeAttribute('${E}');
16057
- }`:"",S=N.observer?`this.${N.observer}(value, oldValue);`:"",y=N.render!==!1?"this._scheduleRender();":"";return`
16057
+ }`:"",S=N.observer?`this.${N.observer}(value, oldValue);`:"",x=N.render!==!1?"this._scheduleRender();":"";return`
16058
16058
  get ${I}() {
16059
16059
  return this._${I};
16060
16060
  }
@@ -16064,7 +16064,7 @@ else {
16064
16064
  if (oldValue === value) return;
16065
16065
  this._${I} = value;${C}
16066
16066
  ${S}
16067
- ${y}
16067
+ ${x}
16068
16068
  this.dispatchEvent(new CustomEvent('${I}-changed', {
16069
16069
  detail: { value, oldValue },
16070
16070
  bubbles: true
@@ -16269,7 +16269,7 @@ export interface ${j}State {
16269
16269
  [key: string]: unknown;
16270
16270
  }
16271
16271
  `,F=_.map((N)=>{let E=K[N],C=L(E.type);return` private _${N}: ${C};`}).join(`
16272
- `),V=_.map((N)=>{let E=K[N],C=L(E.type),S=E.attribute!==!1?E.attribute||J7(N):null,y=E.default!==void 0?JSON.stringify(E.default):E.type==="string"?'""':E.type==="number"?"0":E.type==="boolean"?"false":E.type==="array"?"[]":"{}",x=E.reflect&&S?`
16272
+ `),V=_.map((N)=>{let E=K[N],C=L(E.type),S=E.attribute!==!1?E.attribute||J7(N):null,x=E.default!==void 0?JSON.stringify(E.default):E.type==="string"?'""':E.type==="number"?"0":E.type==="boolean"?"false":E.type==="array"?"[]":"{}",y=E.reflect&&S?`
16273
16273
  if (value !== null && value !== undefined) {
16274
16274
  ${E.type==="boolean"?`if (value) { this.setAttribute('${S}', ''); }
16275
16275
  else { this.removeAttribute('${S}'); }`:`this.setAttribute('${S}', ${E.type==="object"||E.type==="array"?"JSON.stringify(value)":"String(value)"});`}
@@ -16284,7 +16284,7 @@ else {
16284
16284
  set ${N}(value: ${C}) {
16285
16285
  const oldValue = this._${N};
16286
16286
  if (oldValue === value) return;
16287
- this._${N} = value;${x}
16287
+ this._${N} = value;${y}
16288
16288
  ${b}
16289
16289
  ${u}
16290
16290
  this.dispatchEvent(new CustomEvent('${N}-changed', {
@@ -16293,7 +16293,7 @@ else {
16293
16293
  }));
16294
16294
  }
16295
16295
 
16296
- // Property default: ${y}`}).join(`
16296
+ // Property default: ${x}`}).join(`
16297
16297
  `),w=H.length>0?`
16298
16298
  static get observedAttributes(): string[] {
16299
16299
  return [${H.map((N)=>`'${N}'`).join(", ")}];
@@ -16892,7 +16892,7 @@ ${z}
16892
16892
  customElements.define('${X}', ${G});
16893
16893
  `}async function lz($,X,Z,J){if(X.length<1)return T0("WebComponent","@webcomponent directive requires at least the tag name parameter",_0.INVALID_DIRECTIVE_SYNTAX);let Y=X[0].replace(/['"]/g,""),G=(Z.__stx_options||{}).componentsDir||"components",K=[W6.join(W6.dirname(J),G,`${Y}.stx`),W6.join(process.cwd(),G,`${Y}.stx`),W6.join(W6.dirname(J),`${Y}.stx`)],W=null;for(let q of K)if(await H0(q)){W=await Bun.file(q).text();break}if(!W)return T0("WebComponent",`Component file not found: ${Y}.stx`,_0.FILE_NOT_FOUND);let U=EN(W,Y);return`<script type="module">
16894
16894
  ${TN(U)}
16895
- </script>`}var cz;var pz=T(()=>{a1();b0();cz={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var DN={};X0(DN,{timingPlugin:()=>Ap,pluginManager:()=>nz,definePlugin:()=>Y7,debugPlugin:()=>wp,createVariablesPlugin:()=>Rp,createFilterPlugin:()=>Vp,createDirectivePlugin:()=>Fp,PluginManager:()=>iz});function Y7($){return $}class iz{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,X){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Z of $.dependencies)if(!this.plugins.has(Z))throw Error(`Plugin "${$.name}" depends on "${Z}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(X);this.sortPlugins()}async unregister($){let X=this.plugins.get($);if(!X)return!1;for(let[Z,J]of this.plugins)if(J.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Z}" depends on it`);if(X.onUnregister)await X.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 X of this.sortedPlugins)if(X.registerDirectives)$.push(...X.registerDirectives());return $}getAllFilters(){let $={};for(let X of this.sortedPlugins)if(X.registerFilters)Object.assign($,X.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,X){return this.runDirectiveHooks("beforeDirective",$,X)}async runAfterDirective($,X){return this.runDirectiveHooks("afterDirective",$,X)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let X of this.sortedPlugins)if(X.onError)try{let Z=await X.onError($);if(Z){if(Z.template!==void 0)$.template=Z.template;if(Z.context)$.context={...$.context,...Z.context};if(Z.metadata)$.metadata={...$.metadata,...Z.metadata};if(Z.skip)return $}}catch(Z){console.error(`Error in plugin "${X.name}" onError hook:`,Z)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,X)=>($.priority??100)-(X.priority??100))}async runHooks($,X){let Z={...X};for(let J of this.sortedPlugins){let Y=J[$];if(Y)try{let Q=await Y(Z);if(Q){if(Q.template!==void 0)Z.template=Q.template;if(Q.context)Z.context={...Z.context,...Q.context};if(Q.metadata)Z.metadata={...Z.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${J.name}" ${$} hook:`,Q)}}return Z}async runDirectiveHooks($,X,Z){let J={...Z};for(let Y of this.sortedPlugins){let Q=Y[$];if(Q)try{let G=await Q(X,J);if(G){if(G.template!==void 0)J.template=G.template;if(G.context)J.context={...J.context,...G.context};if(G.metadata)J.metadata={...J.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${Y.name}" ${$} hook:`,G)}}return J}}function Fp($,X,Z={}){return{name:$,...Z,registerDirectives:()=>X}}function Vp($,X,Z={}){return{name:$,...Z,registerFilters:()=>X}}function Rp($){return Y7({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(X){return{context:{...X.context,...$}}}})}var nz,wp,Ap;var rz=T(()=>{nz=new iz;wp=Y7({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($,X){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,X){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)}}),Ap=Y7({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let X=$.metadata.startTime;if(X){let Z=performance.now()-X;console.log(`[stx-timing] Processing took ${Z.toFixed(2)}ms`)}}})});var c9={};X0(c9,{validateConfig:()=>CN,resolveStxDirectories:()=>az,loadStxConfig:()=>a0,defineStxConfig:()=>SN,defaultConfig:()=>D1,config:()=>E1});import mJ from"fs";import o1 from"path";import{loadConfigWithResult as Np}from"bunfig";function Mp($,X,Z){let J=X||"pages";if($)return{root:$,pagesDir:J};let Y=Z||process.cwd(),Q=o1.join(Y,"resources","views"),G=o1.join(Y,"resources","layouts");if(mJ.existsSync(Q)&&mJ.existsSync(G))return{root:"resources",pagesDir:"views"};let K=o1.join(Y,"resources","views","pages");if(mJ.existsSync(K))return{root:"resources/views",pagesDir:J};return{root:".",pagesDir:J}}function Ep($,X){let Z=X.replace(/[\\/]+$/,"");if(!Z||Z===".")return!0;let J=$.replace(/\\/g,"/"),Y=Z.replace(/\\/g,"/");return J===Y||J.startsWith(`${Y}/`)}function az($,X){let Z=!$.root,J=Mp($.root,$.pagesDir,X);if($.root=J.root,$.pagesDir=J.pagesDir,Z&&J.root!=="."){let Y=`${X}::${J.root}`;if(!IN.has(Y))IN.add(Y),console.warn(`[stx] No "root" in config \u2014 inferred "${J.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if($.root&&$.root!=="."){let Y=$.root;for(let Q of["partialsDir","componentsDir","layoutsDir"]){let G=$[Q];if(typeof G!=="string"||!G)continue;if(o1.isAbsolute(G)||Ep(G,Y))continue;$[Q]=o1.join(Y,G)}}return $}function Tp($,X){let Z=["componentsDir","layoutsDir","partialsDir"];for(let J of Z){let Y=$[J];if(typeof Y!=="string"||!Y)continue;let Q=o1.isAbsolute(Y)?Y:o1.join(X,Y);if(mJ.existsSync(Q))continue;let G=$.root,K=!!G&&G!==".";console.warn(`[stx] ${String(J)} resolves to "${Q}", which does not exist. Configured as "${Y}"`+(K?`, resolved under root "${G}".`:"."))}}function Dp($){if(zG($.stateDir),$.stateDir=m8(),$.cachePath=d8($.cachePath),$.build)$.build.cacheDir=d8($.build.cacheDir);if($.media?.cache)$.media.cache.directory=d8($.media.cache.directory);if($.story)$.story.outDir=d8($.story.outDir)}async function a0($){if(!$){if(Q7)return Q7;if(dJ)return dJ}let X=$?o1.resolve($):process.cwd(),Z=kN.get(X);if(Z)return Z;let J=(async()=>{let Q=(await Np({name:"stx",alias:"ui",cwd:X,defaultConfig:D1,verbose:!1})).config;if(Dp(Q),az(Q,X),Tp(Q,X),Q.plugins&&Q.plugins.length>0){let{pluginManager:G}=await Promise.resolve().then(() => (rz(),DN)),K=[],W=[];for(let U of Q.plugins){let z=typeof U==="string"?U:U[0],q=typeof U==="string"?{}:U[1]||{};try{let j,_;try{j=await import(z),_=o1.dirname(J0.resolve(z))}catch{let L=o1.resolve(process.cwd(),z);j=await import(L),_=o1.dirname(L)}let H=j.default||j;if(G.register(H,Q),H.components){let L=Array.isArray(H.components)?H.components:[H.components];for(let O of L)K.push(o1.resolve(_,O))}if(H.pages){let L=o1.resolve(_,H.pages),O=q.path||"/";W.push({dir:L,prefix:O})}if(H.setup){let L={addDirective:(O)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(O)},addRoute:(O,B)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[O]=B},addMiddleware:(O)=>{Q.middleware=Q.middleware||[],Q.middleware.push(O)},pluginDir:_,config:Q};await H.setup(q,L)}console.log(`[stx] Plugin loaded: ${H.name||z}`)}catch(j){console.warn(`[stx] Failed to load plugin ${z}:`,j.message)}}Q._pluginComponentDirs=K,Q._pluginPageDirs=W}return Q})();if(kN.set(X,J),!$)dJ=J,J.then((Y)=>{Q7=Y}).catch(()=>{});return J}function SN($){return $}function CN($){let X=[],Z=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")X.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")X.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")X.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")X.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)X.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)X.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let J=["auto","manual","sections"];if(!J.includes($.streaming.strategy))X.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${J.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let J=["json","yaml","yml","js"];if(!J.includes($.i18n.format))X.push({path:"i18n.format",message:`i18n.format must be one of: ${J.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)X.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)X.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let J=["AA","AAA"];if(!J.includes($.a11y.level))X.push({path:"a11y.level",message:`a11y.level must be one of: ${J.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let J=["progressive","islands"];if(!J.includes($.hydration.mode))X.push({path:"hydration.mode",message:`hydration.mode must be one of: ${J.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let J=["none","eager","lazy"];if(!J.includes($.hydration.preload))X.push({path:"hydration.preload",message:`hydration.preload must be one of: ${J.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))X.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((J,Y)=>{if(!J.name||typeof J.name!=="string")X.push({path:`customDirectives[${Y}].name`,message:"Custom directive must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")X.push({path:`customDirectives[${Y}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))X.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((J,Y)=>{if(!J.name||typeof J.name!=="string")X.push({path:`middleware[${Y}].name`,message:"Middleware must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")X.push({path:`middleware[${Y}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!J.timing||!["before","after"].includes(J.timing))X.push({path:`middleware[${Y}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Z.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)Z.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)X.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let J=["fullscreen","standalone","minimal-ui","browser"];if(!J.includes($.pwa.manifest.display))X.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let J=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!J.includes($.pwa.manifest.orientation))X.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.routes){let J=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((Y,Q)=>{if(!Y.pattern||typeof Y.pattern!=="string")X.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!J.includes(Y.strategy))X.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${J.join(", ")}`,severity:"error"});if(Y.maxAgeSeconds!==void 0&&(typeof Y.maxAgeSeconds!=="number"||Y.maxAgeSeconds<0))X.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(Y.maxEntries!==void 0&&(typeof Y.maxEntries!=="number"||Y.maxEntries<1))X.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))X.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((Y)=>typeof Y!=="number"||Y<16||Y>1024).length>0)X.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let J=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!J.includes(Q)).length>0)X.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Z.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)Z.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:X.length===0,errors:X,warnings:Z}}var D1,IN,Q7=null,kN,dJ=null,E1;var $1=T(()=>{k8();j9();XG();E9();OJ();Sz();dz();RN();r3();z$();pz();D1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:C6,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:iU,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:lz,hasEndTag:!1,description:"Include a web component in the template"},G9,K9,P2,b2,W9,z9,q9,U9,uL,YG,SX,PX,...AN],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:"main",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}};IN=new Set;kN=new Map;E1=new Proxy(D1,{get($,X){if(Q7&&X in Q7)return Q7[X];if(!dJ)a0().catch((Z)=>{console.warn("[stx] Failed to load config file:",Z?.message||Z)});return $[X]}})});import Ip from"fs";import sz from"path";import{createHighlighter as kp}from"ts-syntax-highlighter";async function K$($,X={}){try{if(!await H0($))throw Error(`Markdown file not found: ${$}`);let J=(await Ip.promises.stat($)).mtime.getTime();if(X.cache&&lJ.has($)){let q=lJ.get($);if(q.updatedAt>=J)return{content:q.content,data:q.data}}let Y=await Bun.file($).text(),{data:Q,content:G}=T9(Y),K=X.markdown||E1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=S6(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await Sp(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let z={content:U,data:Q||{}};if(X.cache)lJ.set($,{...z,updatedAt:J});return z}catch(Z){if(X.debug)console.error(`Error reading/parsing markdown file ${$}:`,Z);let J=Z instanceof Error?Z.message:String(Z);return{content:p0("Markdown File",`Error reading/parsing markdown file: ${J}`,$,"",0,""),data:{}}}}async function Sp($,X,Z){let J=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!cJ)try{cJ=await kp({theme:X||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Y=async(K,W,U,z)=>{let q=z.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),j=U||(Z?"text":"");if(!j)return K;try{if(!cJ.getSupportedLanguages().includes(j))return K;return(await cJ.highlight(q,j,{theme:X})).html}catch(_){console.error(`Error highlighting code block with language ${U}:`,_)}return K},Q=$,G=$.matchAll(J);for(let K of G){let[W,U,z,q]=K,j=await Y(W,U,z,q);Q=Q.replace(W,j)}return Q}async function gU($,X,Z="",J={}){return await Cp($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let z=K;if(!sz.isAbsolute(K))z=sz.resolve(sz.dirname(Z),K);let q={};if(W)try{try{q=JSON.parse(W)}catch{if(J.debug)console.warn("Using safer alternative for parsing JS object literal");let F=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of F){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),R=V.substring(w+1).trim(),M=R.startsWith('"')&&R.endsWith('"'),I=R.startsWith("'")&&R.endsWith("'");if(M||I)R=R.substring(1,R.length-1);q[A]=R}}}}catch(B){if(J.debug)console.error("Error parsing context in @markdown-file directive:",B)}let{content:j,data:_}=await K$(z,J),H={...X,..._,...q},L=j,O=/\{\{([^}]+)\}\}/g;return L=L.replace(O,(B,F)=>{let V=F.trim();return H[V]!==void 0?String(H[V]):B}),L}catch(z){let q=z instanceof Error?z.message:String(z);return p0("Markdown File",`Error including markdown file: ${q}`,Z,$,U,G)}})}async function Cp($,X,Z){let J=[],Y;while((Y=X.exec($))!==null){let K=Y[0],W=Y.index,U=Y;J.push(Z(...U).then((z)=>({match:K,replacement:z,index:W})))}let Q=await Promise.all(J);Q.sort((K,W)=>W.index-K.index);let G=$;for(let{match:K,replacement:W}of Q)G=G.replace(K,()=>W);return G}var lJ,cJ=null;var v5=T(()=>{$1();b0();lJ=new Map});function pJ(){return`
16895
+ </script>`}var cz;var pz=T(()=>{a1();b0();cz={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var DN={};X0(DN,{timingPlugin:()=>Ap,pluginManager:()=>nz,definePlugin:()=>Y7,debugPlugin:()=>wp,createVariablesPlugin:()=>Rp,createFilterPlugin:()=>Vp,createDirectivePlugin:()=>Fp,PluginManager:()=>iz});function Y7($){return $}class iz{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,X){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Z of $.dependencies)if(!this.plugins.has(Z))throw Error(`Plugin "${$.name}" depends on "${Z}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(X);this.sortPlugins()}async unregister($){let X=this.plugins.get($);if(!X)return!1;for(let[Z,J]of this.plugins)if(J.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Z}" depends on it`);if(X.onUnregister)await X.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 X of this.sortedPlugins)if(X.registerDirectives)$.push(...X.registerDirectives());return $}getAllFilters(){let $={};for(let X of this.sortedPlugins)if(X.registerFilters)Object.assign($,X.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,X){return this.runDirectiveHooks("beforeDirective",$,X)}async runAfterDirective($,X){return this.runDirectiveHooks("afterDirective",$,X)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let X of this.sortedPlugins)if(X.onError)try{let Z=await X.onError($);if(Z){if(Z.template!==void 0)$.template=Z.template;if(Z.context)$.context={...$.context,...Z.context};if(Z.metadata)$.metadata={...$.metadata,...Z.metadata};if(Z.skip)return $}}catch(Z){console.error(`Error in plugin "${X.name}" onError hook:`,Z)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,X)=>($.priority??100)-(X.priority??100))}async runHooks($,X){let Z={...X};for(let J of this.sortedPlugins){let Y=J[$];if(Y)try{let Q=await Y(Z);if(Q){if(Q.template!==void 0)Z.template=Q.template;if(Q.context)Z.context={...Z.context,...Q.context};if(Q.metadata)Z.metadata={...Z.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${J.name}" ${$} hook:`,Q)}}return Z}async runDirectiveHooks($,X,Z){let J={...Z};for(let Y of this.sortedPlugins){let Q=Y[$];if(Q)try{let G=await Q(X,J);if(G){if(G.template!==void 0)J.template=G.template;if(G.context)J.context={...J.context,...G.context};if(G.metadata)J.metadata={...J.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${Y.name}" ${$} hook:`,G)}}return J}}function Fp($,X,Z={}){return{name:$,...Z,registerDirectives:()=>X}}function Vp($,X,Z={}){return{name:$,...Z,registerFilters:()=>X}}function Rp($){return Y7({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(X){return{context:{...X.context,...$}}}})}var nz,wp,Ap;var rz=T(()=>{nz=new iz;wp=Y7({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($,X){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,X){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)}}),Ap=Y7({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let X=$.metadata.startTime;if(X){let Z=performance.now()-X;console.log(`[stx-timing] Processing took ${Z.toFixed(2)}ms`)}}})});var c9={};X0(c9,{validateConfig:()=>CN,resolveStxDirectories:()=>az,loadStxConfig:()=>a0,defineStxConfig:()=>SN,defaultConfig:()=>D1,config:()=>E1});import mJ from"fs";import o1 from"path";import{loadConfigWithResult as Np}from"bunfig";function Mp($,X,Z){let J=X||"pages";if($)return{root:$,pagesDir:J};let Y=Z||process.cwd(),Q=o1.join(Y,"resources","views"),G=o1.join(Y,"resources","layouts");if(mJ.existsSync(Q)&&mJ.existsSync(G))return{root:"resources",pagesDir:"views"};let K=o1.join(Y,"resources","views","pages");if(mJ.existsSync(K))return{root:"resources/views",pagesDir:J};return{root:".",pagesDir:J}}function Ep($,X){let Z=X.replace(/[\\/]+$/,"");if(!Z||Z===".")return!0;let J=$.replace(/\\/g,"/"),Y=Z.replace(/\\/g,"/");return J===Y||J.startsWith(`${Y}/`)}function az($,X){let Z=!$.root,J=Mp($.root,$.pagesDir,X);if($.root=J.root,$.pagesDir=J.pagesDir,Z&&J.root!=="."){let Y=`${X}::${J.root}`;if(!IN.has(Y))IN.add(Y),console.warn(`[stx] No "root" in config \u2014 inferred "${J.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if($.root&&$.root!=="."){let Y=$.root;for(let Q of["partialsDir","componentsDir","layoutsDir"]){let G=$[Q];if(typeof G!=="string"||!G)continue;if(o1.isAbsolute(G)||Ep(G,Y))continue;$[Q]=o1.join(Y,G)}}return $}function Tp($,X){let Z=["componentsDir","layoutsDir","partialsDir"];for(let J of Z){let Y=$[J];if(typeof Y!=="string"||!Y)continue;let Q=o1.isAbsolute(Y)?Y:o1.join(X,Y);if(mJ.existsSync(Q))continue;let G=$.root,K=!!G&&G!==".";console.warn(`[stx] ${String(J)} resolves to "${Q}", which does not exist. Configured as "${Y}"`+(K?`, resolved under root "${G}".`:"."))}}function Dp($){if(zG($.stateDir),$.stateDir=m8(),$.cachePath=d8($.cachePath),$.build)$.build.cacheDir=d8($.build.cacheDir);if($.media?.cache)$.media.cache.directory=d8($.media.cache.directory);if($.story)$.story.outDir=d8($.story.outDir)}async function a0($){if(!$){if(Q7)return Q7;if(dJ)return dJ}let X=$?o1.resolve($):process.cwd(),Z=kN.get(X);if(Z)return Z;let J=(async()=>{let Q=(await Np({name:"stx",alias:"ui",cwd:X,defaultConfig:D1,verbose:!1})).config;if(Dp(Q),az(Q,X),Tp(Q,X),Q.plugins&&Q.plugins.length>0){let{pluginManager:G}=await Promise.resolve().then(() => (rz(),DN)),K=[],W=[];for(let U of Q.plugins){let z=typeof U==="string"?U:U[0],q=typeof U==="string"?{}:U[1]||{};try{let j,_;try{j=await import(z),_=o1.dirname(Y0.resolve(z))}catch{let L=o1.resolve(process.cwd(),z);j=await import(L),_=o1.dirname(L)}let H=j.default||j;if(G.register(H,Q),H.components){let L=Array.isArray(H.components)?H.components:[H.components];for(let O of L)K.push(o1.resolve(_,O))}if(H.pages){let L=o1.resolve(_,H.pages),O=q.path||"/";W.push({dir:L,prefix:O})}if(H.setup){let L={addDirective:(O)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(O)},addRoute:(O,B)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[O]=B},addMiddleware:(O)=>{Q.middleware=Q.middleware||[],Q.middleware.push(O)},pluginDir:_,config:Q};await H.setup(q,L)}console.log(`[stx] Plugin loaded: ${H.name||z}`)}catch(j){console.warn(`[stx] Failed to load plugin ${z}:`,j.message)}}Q._pluginComponentDirs=K,Q._pluginPageDirs=W}return Q})();if(kN.set(X,J),!$)dJ=J,J.then((Y)=>{Q7=Y}).catch(()=>{});return J}function SN($){return $}function CN($){let X=[],Z=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")X.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")X.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")X.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")X.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)X.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)X.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let J=["auto","manual","sections"];if(!J.includes($.streaming.strategy))X.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${J.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let J=["json","yaml","yml","js"];if(!J.includes($.i18n.format))X.push({path:"i18n.format",message:`i18n.format must be one of: ${J.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)X.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)X.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let J=["AA","AAA"];if(!J.includes($.a11y.level))X.push({path:"a11y.level",message:`a11y.level must be one of: ${J.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let J=["progressive","islands"];if(!J.includes($.hydration.mode))X.push({path:"hydration.mode",message:`hydration.mode must be one of: ${J.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let J=["none","eager","lazy"];if(!J.includes($.hydration.preload))X.push({path:"hydration.preload",message:`hydration.preload must be one of: ${J.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))X.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((J,Y)=>{if(!J.name||typeof J.name!=="string")X.push({path:`customDirectives[${Y}].name`,message:"Custom directive must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")X.push({path:`customDirectives[${Y}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))X.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((J,Y)=>{if(!J.name||typeof J.name!=="string")X.push({path:`middleware[${Y}].name`,message:"Middleware must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")X.push({path:`middleware[${Y}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!J.timing||!["before","after"].includes(J.timing))X.push({path:`middleware[${Y}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Z.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)Z.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)X.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let J=["fullscreen","standalone","minimal-ui","browser"];if(!J.includes($.pwa.manifest.display))X.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let J=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!J.includes($.pwa.manifest.orientation))X.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.routes){let J=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((Y,Q)=>{if(!Y.pattern||typeof Y.pattern!=="string")X.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!J.includes(Y.strategy))X.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${J.join(", ")}`,severity:"error"});if(Y.maxAgeSeconds!==void 0&&(typeof Y.maxAgeSeconds!=="number"||Y.maxAgeSeconds<0))X.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(Y.maxEntries!==void 0&&(typeof Y.maxEntries!=="number"||Y.maxEntries<1))X.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))X.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((Y)=>typeof Y!=="number"||Y<16||Y>1024).length>0)X.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let J=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!J.includes(Q)).length>0)X.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Z.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)Z.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:X.length===0,errors:X,warnings:Z}}var D1,IN,Q7=null,kN,dJ=null,E1;var $1=T(()=>{k8();j9();XG();E9();OJ();Sz();dz();RN();r3();z$();pz();D1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:C6,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:iU,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:lz,hasEndTag:!1,description:"Include a web component in the template"},G9,K9,P2,b2,W9,z9,q9,U9,uL,YG,SX,PX,...AN],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:"main",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}};IN=new Set;kN=new Map;E1=new Proxy(D1,{get($,X){if(Q7&&X in Q7)return Q7[X];if(!dJ)a0().catch((Z)=>{console.warn("[stx] Failed to load config file:",Z?.message||Z)});return $[X]}})});import Ip from"fs";import sz from"path";import{createHighlighter as kp}from"ts-syntax-highlighter";async function K$($,X={}){try{if(!await H0($))throw Error(`Markdown file not found: ${$}`);let J=(await Ip.promises.stat($)).mtime.getTime();if(X.cache&&lJ.has($)){let q=lJ.get($);if(q.updatedAt>=J)return{content:q.content,data:q.data}}let Y=await Bun.file($).text(),{data:Q,content:G}=T9(Y),K=X.markdown||E1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=S6(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await Sp(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let z={content:U,data:Q||{}};if(X.cache)lJ.set($,{...z,updatedAt:J});return z}catch(Z){if(X.debug)console.error(`Error reading/parsing markdown file ${$}:`,Z);let J=Z instanceof Error?Z.message:String(Z);return{content:p0("Markdown File",`Error reading/parsing markdown file: ${J}`,$,"",0,""),data:{}}}}async function Sp($,X,Z){let J=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!cJ)try{cJ=await kp({theme:X||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Y=async(K,W,U,z)=>{let q=z.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),j=U||(Z?"text":"");if(!j)return K;try{if(!cJ.getSupportedLanguages().includes(j))return K;return(await cJ.highlight(q,j,{theme:X})).html}catch(_){console.error(`Error highlighting code block with language ${U}:`,_)}return K},Q=$,G=$.matchAll(J);for(let K of G){let[W,U,z,q]=K,j=await Y(W,U,z,q);Q=Q.replace(W,j)}return Q}async function gU($,X,Z="",J={}){return await Cp($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let z=K;if(!sz.isAbsolute(K))z=sz.resolve(sz.dirname(Z),K);let q={};if(W)try{try{q=JSON.parse(W)}catch{if(J.debug)console.warn("Using safer alternative for parsing JS object literal");let F=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of F){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),R=V.substring(w+1).trim(),M=R.startsWith('"')&&R.endsWith('"'),I=R.startsWith("'")&&R.endsWith("'");if(M||I)R=R.substring(1,R.length-1);q[A]=R}}}}catch(B){if(J.debug)console.error("Error parsing context in @markdown-file directive:",B)}let{content:j,data:_}=await K$(z,J),H={...X,..._,...q},L=j,O=/\{\{([^}]+)\}\}/g;return L=L.replace(O,(B,F)=>{let V=F.trim();return H[V]!==void 0?String(H[V]):B}),L}catch(z){let q=z instanceof Error?z.message:String(z);return p0("Markdown File",`Error including markdown file: ${q}`,Z,$,U,G)}})}async function Cp($,X,Z){let J=[],Y;while((Y=X.exec($))!==null){let K=Y[0],W=Y.index,U=Y;J.push(Z(...U).then((z)=>({match:K,replacement:z,index:W})))}let Q=await Promise.all(J);Q.sort((K,W)=>W.index-K.index);let G=$;for(let{match:K,replacement:W}of Q)G=G.replace(K,()=>W);return G}var lJ,cJ=null;var v5=T(()=>{$1();b0();lJ=new Map});function pJ(){return`
16896
16896
  /* Theme selector for code blocks */
16897
16897
  .theme-selector {
16898
16898
  margin: 1rem 0;
@@ -17794,7 +17794,7 @@ window.stxDialog = {
17794
17794
  // Check if dialog is available
17795
17795
  isAvailable: () => typeof window.craft?.dialog !== 'undefined',
17796
17796
  };
17797
- `}import n$ from"process";import{existsSync as ap}from"fs";import{dirname as sp,join as op}from"path";import{craftBinaryNotFoundMessage as UE,resolveCraftBinary as tp}from"craft-native";function zE($){W7={...W7,...$}}function qE(){return{...W7}}function jE(){W7={}}function Jq($){if(!$.sidebarConfig)return;let X={...$.sidebarConfig};if(X.variant==="desktop")X.material=X.material??"sidebar",X.backgroundEffect=X.backgroundEffect??"shimmer",X.allowsVibrancy=X.allowsVibrancy??!0;return X}function eJ(){let $=[n$.env.CRAFT_BINARY_PATH,W7.craftBinaryPath,...W7.additionalSearchPaths||[],op(sp(n$.execPath),"craft")];for(let X of $)if(X&&ap(X))return X;return tp()}function _E(){return Array.from(M$.keys())}function HE($){let X=M$.get($);if(!X)return null;return $Y($,X.app)}function LE(){for(let[$,X]of M$)try{X.app?.close?.()}catch(Z){console.warn(`Failed to close window ${$}:`,Z)}M$.clear()}function $Y($,X){return{id:$,show:()=>{console.log(`[stx/desktop] Window ${$} shown`)},hide:()=>{console.log("[stx/desktop] To hide window, use window.craft.window.hide() from inside the webview")},close:()=>{let Z=M$.get($);if(Z?.app)Z.app.close(),M$.delete($),console.log(`[stx/desktop] Window ${$} closed`)},focus:()=>{console.log("[stx/desktop] To focus window, use window.craft.window.focus() from inside the webview")},minimize:()=>{console.log("[stx/desktop] To minimize window, use window.craft.window.minimize() from inside the webview")},maximize:()=>{console.log("[stx/desktop] To maximize window, use window.craft.window.maximize() from inside the webview")},restore:()=>{console.log("[stx/desktop] To restore window, use window.craft.window.show() from inside the webview")},setTitle:(Z)=>{console.log(`[stx/desktop] To set title, use window.craft.window.setTitle({ title: "${Z}" }) from inside the webview`)},loadURL:(Z)=>{console.log(`[stx/desktop] To navigate, use window.location.href = "${Z}" from inside the webview`)},reload:()=>{console.log("[stx/desktop] To reload, use window.craft.window.reload() from inside the webview")}}}function XY($,X={}){let Z=["--url",$,"--title",X.title||"stx Desktop","--width",String(X.width??1200),"--height",String(X.height??800)];if(X.darkMode)Z.push("--dark");if(X.hotReload)Z.push("--hot-reload");if(X.resizable===!1)Z.push("--no-resize");if(X.frameless)Z.push("--frameless");if(X.alwaysOnTop)Z.push("--always-on-top");if(X.titlebarHidden)Z.push("--titlebar-hidden");if(X.systemTray)Z.push("--system-tray");if(X.hideDockIcon)Z.push("--hide-dock-icon");if(X.devTools===!1)Z.push("--no-devtools");if(X.nativeSidebar)Z.push("--native-sidebar");if(X.sidebarWidth!==void 0)Z.push("--sidebar-width",String(X.sidebarWidth));let J=Jq(X);if(J)Z.push("--sidebar-config",JSON.stringify(J));return Z}async function OE($,X={}){let Z=`craft-window-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,J=eJ();try{let{createApp:Y}=await import("craft-native"),Q=Y({url:$,craftPath:J,window:{title:X.title||"stx Desktop",width:X.width??1200,height:X.height??800,darkMode:X.darkMode??!1,hotReload:X.hotReload??!1,resizable:X.resizable??!0,frameless:X.frameless??!1,alwaysOnTop:X.alwaysOnTop??!1,titlebarHidden:X.titlebarHidden??!1,systemTray:X.systemTray??!1,hideDockIcon:X.hideDockIcon??!1,devTools:X.devTools??!1,nativeSidebar:X.nativeSidebar??!1,sidebarWidth:X.sidebarWidth,sidebarConfig:Jq(X)}});return M$.set(Z,{app:Q,url:$,options:X}),await Q.show(),$Y(Z,Q)}catch{try{let{spawn:Y}=await import("child_process"),Q=Y(J,XY($,X),{stdio:"inherit"});Q.on("error",(K)=>{console.error(K.code==="ENOENT"?UE(J):`craft child error: ${K.message}`)});let G={close:()=>Q.kill()};return M$.set(Z,{app:G,url:$,options:X}),$Y(Z,G)}catch(Y){return console.error("Failed to spawn craft binary:",Y.message),null}}}async function BE($,X={}){let Z=`http://localhost:${$}/`;if(n$.env.NODE_ENV==="test"||n$.env.BUN_TEST)return console.warn("\u26A0 Skipping native window in test environment"),console.log("(Skipping browser fallback in test environment)"),!1;try{let{createApp:Y}=await import("craft-native");console.log("\u26A1 Opening native window via craft-native\u2026");let Q=!X.nativeSidebar,G=Jq(X),K=Y({url:Z,craftPath:eJ(),window:{title:X.title||"stx Development",width:X.width||1400,height:X.height||900,resizable:!0,systemTray:Q,darkMode:X.darkMode??!0,hotReload:X.hotReload??!0,devTools:!0,titlebarHidden:X.titlebarHidden??!1,nativeSidebar:X.nativeSidebar??!1,sidebarWidth:X.sidebarWidth??260,sidebarConfig:G}}),W=`dev-window-${$}`;return M$.set(W,{app:K,url:Z,options:X}),await K.show(),console.log(`\u2713 Native window opened at ${Z}`),!0}catch{let Y=eJ();try{console.log(`\u26A1 Opening native window via craft binary (${Y})\u2026`);let{spawn:Q}=await import("child_process"),G=Q(Y,XY(Z,{title:"stx Development",width:1400,height:900,hotReload:!0,...X}),{stdio:"inherit"});G.on("exit",()=>n$.exit(0)),G.on("error",(W)=>{console.warn(W.code==="ENOENT"?UE(Y):`craft child error: ${W.message}`)});let K=`dev-window-${$}`;return M$.set(K,{app:{close:()=>G.kill()},url:Z,options:X}),console.log(`\u2713 Native window opened at ${Z}`),!0}catch(Q){console.warn("\u26A0 Could not spawn craft binary:",Q.message)}if(n$.env.NODE_ENV==="test"||n$.env.BUN_TEST)return console.log("(Skipping browser fallback in test environment)"),!1;console.log("\uD83D\uDCF1 Opening in browser instead\u2026");try{let{spawn:Q}=await import("child_process"),G=n$.platform;return Q(G==="darwin"?"open":G==="win32"?"cmd":"xdg-open",G==="win32"?["/c","start",Z]:[Z],{detached:!0,stdio:"ignore"}).unref(),console.log(`\u2713 Browser opened at ${Z}`),!0}catch(Q){return console.error("Could not open browser:",Q),console.log(`Please open manually: ${Z}`),!1}}}async function FE($,X={}){let{title:Z="stx Desktop",width:J=1200,height:Y=800,darkMode:Q=!1,hotReload:G=!1,resizable:K=!0,frameless:W=!1,alwaysOnTop:U=!1}=X;try{let{createApp:z}=await import("craft-native"),q=eJ(),j=z({html:$,craftPath:q,window:{title:Z,width:J,height:Y,darkMode:Q,hotReload:G,resizable:K,frameless:W,alwaysOnTop:U}}),_=`craft-window-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return M$.set(_,{app:j,url:"html-content",options:X}),await j.show(),$Y(_,j)}catch(z){return console.error("Failed to create window with HTML:",z),null}}function VE(){try{return J0.resolve("craft-native"),!0}catch{return!1}}function wE(){return`
17797
+ `}import n$ from"process";import{existsSync as ap}from"fs";import{dirname as sp,join as op}from"path";import{craftBinaryNotFoundMessage as UE,resolveCraftBinary as tp}from"craft-native";function zE($){W7={...W7,...$}}function qE(){return{...W7}}function jE(){W7={}}function Jq($){if(!$.sidebarConfig)return;let X={...$.sidebarConfig};if(X.variant==="desktop")X.material=X.material??"sidebar",X.backgroundEffect=X.backgroundEffect??"shimmer",X.allowsVibrancy=X.allowsVibrancy??!0;return X}function eJ(){let $=[n$.env.CRAFT_BINARY_PATH,W7.craftBinaryPath,...W7.additionalSearchPaths||[],op(sp(n$.execPath),"craft")];for(let X of $)if(X&&ap(X))return X;return tp()}function _E(){return Array.from(M$.keys())}function HE($){let X=M$.get($);if(!X)return null;return $Y($,X.app)}function LE(){for(let[$,X]of M$)try{X.app?.close?.()}catch(Z){console.warn(`Failed to close window ${$}:`,Z)}M$.clear()}function $Y($,X){return{id:$,show:()=>{console.log(`[stx/desktop] Window ${$} shown`)},hide:()=>{console.log("[stx/desktop] To hide window, use window.craft.window.hide() from inside the webview")},close:()=>{let Z=M$.get($);if(Z?.app)Z.app.close(),M$.delete($),console.log(`[stx/desktop] Window ${$} closed`)},focus:()=>{console.log("[stx/desktop] To focus window, use window.craft.window.focus() from inside the webview")},minimize:()=>{console.log("[stx/desktop] To minimize window, use window.craft.window.minimize() from inside the webview")},maximize:()=>{console.log("[stx/desktop] To maximize window, use window.craft.window.maximize() from inside the webview")},restore:()=>{console.log("[stx/desktop] To restore window, use window.craft.window.show() from inside the webview")},setTitle:(Z)=>{console.log(`[stx/desktop] To set title, use window.craft.window.setTitle({ title: "${Z}" }) from inside the webview`)},loadURL:(Z)=>{console.log(`[stx/desktop] To navigate, use window.location.href = "${Z}" from inside the webview`)},reload:()=>{console.log("[stx/desktop] To reload, use window.craft.window.reload() from inside the webview")}}}function XY($,X={}){let Z=["--url",$,"--title",X.title||"stx Desktop","--width",String(X.width??1200),"--height",String(X.height??800)];if(X.darkMode)Z.push("--dark");if(X.hotReload)Z.push("--hot-reload");if(X.resizable===!1)Z.push("--no-resize");if(X.frameless)Z.push("--frameless");if(X.alwaysOnTop)Z.push("--always-on-top");if(X.titlebarHidden)Z.push("--titlebar-hidden");if(X.systemTray)Z.push("--system-tray");if(X.hideDockIcon)Z.push("--hide-dock-icon");if(X.devTools===!1)Z.push("--no-devtools");if(X.nativeSidebar)Z.push("--native-sidebar");if(X.sidebarWidth!==void 0)Z.push("--sidebar-width",String(X.sidebarWidth));let J=Jq(X);if(J)Z.push("--sidebar-config",JSON.stringify(J));return Z}async function OE($,X={}){let Z=`craft-window-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,J=eJ();try{let{createApp:Y}=await import("craft-native"),Q=Y({url:$,craftPath:J,window:{title:X.title||"stx Desktop",width:X.width??1200,height:X.height??800,darkMode:X.darkMode??!1,hotReload:X.hotReload??!1,resizable:X.resizable??!0,frameless:X.frameless??!1,alwaysOnTop:X.alwaysOnTop??!1,titlebarHidden:X.titlebarHidden??!1,systemTray:X.systemTray??!1,hideDockIcon:X.hideDockIcon??!1,devTools:X.devTools??!1,nativeSidebar:X.nativeSidebar??!1,sidebarWidth:X.sidebarWidth,sidebarConfig:Jq(X)}});return M$.set(Z,{app:Q,url:$,options:X}),await Q.show(),$Y(Z,Q)}catch{try{let{spawn:Y}=await import("child_process"),Q=Y(J,XY($,X),{stdio:"inherit"});Q.on("error",(K)=>{console.error(K.code==="ENOENT"?UE(J):`craft child error: ${K.message}`)});let G={close:()=>Q.kill()};return M$.set(Z,{app:G,url:$,options:X}),$Y(Z,G)}catch(Y){return console.error("Failed to spawn craft binary:",Y.message),null}}}async function BE($,X={}){let Z=`http://localhost:${$}/`;if(n$.env.NODE_ENV==="test"||n$.env.BUN_TEST)return console.warn("\u26A0 Skipping native window in test environment"),console.log("(Skipping browser fallback in test environment)"),!1;try{let{createApp:Y}=await import("craft-native");console.log("\u26A1 Opening native window via craft-native\u2026");let Q=!X.nativeSidebar,G=Jq(X),K=Y({url:Z,craftPath:eJ(),window:{title:X.title||"stx Development",width:X.width||1400,height:X.height||900,resizable:!0,systemTray:Q,darkMode:X.darkMode??!0,hotReload:X.hotReload??!0,devTools:!0,titlebarHidden:X.titlebarHidden??!1,nativeSidebar:X.nativeSidebar??!1,sidebarWidth:X.sidebarWidth??260,sidebarConfig:G}}),W=`dev-window-${$}`;return M$.set(W,{app:K,url:Z,options:X}),await K.show(),console.log(`\u2713 Native window opened at ${Z}`),!0}catch{let Y=eJ();try{console.log(`\u26A1 Opening native window via craft binary (${Y})\u2026`);let{spawn:Q}=await import("child_process"),G=Q(Y,XY(Z,{title:"stx Development",width:1400,height:900,hotReload:!0,...X}),{stdio:"inherit"});G.on("exit",()=>n$.exit(0)),G.on("error",(W)=>{console.warn(W.code==="ENOENT"?UE(Y):`craft child error: ${W.message}`)});let K=`dev-window-${$}`;return M$.set(K,{app:{close:()=>G.kill()},url:Z,options:X}),console.log(`\u2713 Native window opened at ${Z}`),!0}catch(Q){console.warn("\u26A0 Could not spawn craft binary:",Q.message)}if(n$.env.NODE_ENV==="test"||n$.env.BUN_TEST)return console.log("(Skipping browser fallback in test environment)"),!1;console.log("\uD83D\uDCF1 Opening in browser instead\u2026");try{let{spawn:Q}=await import("child_process"),G=n$.platform;return Q(G==="darwin"?"open":G==="win32"?"cmd":"xdg-open",G==="win32"?["/c","start",Z]:[Z],{detached:!0,stdio:"ignore"}).unref(),console.log(`\u2713 Browser opened at ${Z}`),!0}catch(Q){return console.error("Could not open browser:",Q),console.log(`Please open manually: ${Z}`),!1}}}async function FE($,X={}){let{title:Z="stx Desktop",width:J=1200,height:Y=800,darkMode:Q=!1,hotReload:G=!1,resizable:K=!0,frameless:W=!1,alwaysOnTop:U=!1}=X;try{let{createApp:z}=await import("craft-native"),q=eJ(),j=z({html:$,craftPath:q,window:{title:Z,width:J,height:Y,darkMode:Q,hotReload:G,resizable:K,frameless:W,alwaysOnTop:U}}),_=`craft-window-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return M$.set(_,{app:j,url:"html-content",options:X}),await j.show(),$Y(_,j)}catch(z){return console.error("Failed to create window with HTML:",z),null}}function VE(){try{return Y0.resolve("craft-native"),!0}catch{return!1}}function wE(){return`
17798
17798
  // STX Desktop Window Bridge
17799
17799
  // Provides convenient wrappers around window.craft APIs
17800
17800
  window.stxWindow = {
@@ -18267,7 +18267,7 @@ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FO
18267
18267
  `),Y&&!Y.endsWith(`
18268
18268
  `))Y+=`
18269
18269
  `}Y+=`NETLIFY_SITE_ID=${$.siteId}
18270
- `,await Bun.write(J,Y)}return{configPath:Z,siteId:$.siteId}}function ni($){let X=process.platform,Z=X==="darwin"?"open":X==="win32"?"start":"xdg-open";Bun.spawn([Z,$],{stdio:["ignore","ignore","ignore"]})}var F4;var HY=T(()=>{bq();bq();F4=class F4 extends Error{code;constructor($,X){super($);this.name="DeployError",this.code=X}}});var kI={};X0(kI,{resizeAndConvert:()=>II,processImage:()=>T$,isSharpAvailable:()=>N7,isImageFile:()=>M7,isImageBackendAvailable:()=>E$,groupVariantsByFormat:()=>U8,getTotalSize:()=>rX,getMimeType:()=>X$,getImageMetadata:()=>G8,getFallbackVariant:()=>W8,generateSrcSet:()=>_6,generateSizes:()=>K8,formatSize:()=>aX,ImageProcessingError:()=>z8,DEFAULT_WIDTHS:()=>t1,DEFAULT_QUALITY:()=>$$,DEFAULT_FORMATS:()=>e1});import fq from"fs";import R7 from"path";import TI from"os";import gq from"crypto";import{generatePlaceholder as ri,processImage as ai}from"ts-images";async function LY(){if(EI)return vq;EI=!0;try{let $=await import("sharp");return vq=$.default||$,vq}catch{return null}}async function N7(){return await LY()!==null}async function E$(){return!0}async function T$($,X={}){let{widths:Z=t1,formats:J=e1,quality:Y=$$,fit:Q="cover",placeholder:G="none",outputDir:K=".stx/images",baseUrl:W="/images"}=X,U,z;if(typeof $==="string"){if(z=$,!await Bun.file($).exists())throw new z8(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((w)=>Buffer.from(w))}else z="buffer-input",U=$;let q=gq.createHash("sha256").update(U).digest("hex").slice(0,12),j=await G8(U),{width:_,height:H}=j,L=_/H;await fq.promises.mkdir(K,{recursive:!0});let O=[],B=R7.basename(z,R7.extname(z)),F=Z.filter((w)=>w<=_);if(!F.includes(_)&&_<=Math.max(...Z))F.push(_);F.sort((w,A)=>w-A);for(let w of F){let A=Math.round(w/L);for(let R of J){let M=`${B}-${w}w-${q}.${R}`,I=R7.join(K,M),N=`${W}/${M}`,E=await II(U,{width:w,height:A,format:R,quality:Y,fit:Q});await Bun.write(I,E),O.push({path:I,url:N,width:w,height:A,format:R,size:E.length})}}let V;if(G!=="none")V=await ti(U,G);return{src:z,variants:O,placeholder:V,width:_,height:H,aspectRatio:L,hash:q}}async function G8($){let X=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Z=await LY();if(Z){let Y=await Z(X).metadata();return{width:Y.width||0,height:Y.height||0,format:Y.format||"unknown",hasAlpha:Y.hasAlpha}}return oi(X)}function oi($){if($[0]===137&&$[1]===80&&$[2]===78&&$[3]===71){let X=$.readUInt32BE(16),Z=$.readUInt32BE(20);return{width:X,height:Z,format:"png",hasAlpha:!0}}if($[0]===255&&$[1]===216){let X=2;while(X<$.length){if($[X]!==255)break;let Z=$[X+1];if(Z>=192&&Z<=207&&Z!==196&&Z!==200&&Z!==204){let Y=$.readUInt16BE(X+5);return{width:$.readUInt16BE(X+7),height:Y,format:"jpeg",hasAlpha:!1}}let J=$.readUInt16BE(X+2);X+=2+J}}if($.toString("utf8",0,4)==="RIFF"&&$.toString("utf8",8,12)==="WEBP"){let X=$.toString("utf8",12,16);if(X==="VP8 "){let Z=$.readUInt16LE(26)&16383,J=$.readUInt16LE(28)&16383;return{width:Z,height:J,format:"webp",hasAlpha:!1}}if(X==="VP8L"){let Z=$.readUInt32LE(21),J=(Z&16383)+1,Y=(Z>>14&16383)+1;return{width:J,height:Y,format:"webp",hasAlpha:!0}}}if($.toString("utf8",0,3)==="GIF"){let X=$.readUInt16LE(6),Z=$.readUInt16LE(8);return{width:X,height:Z,format:"gif",hasAlpha:!0}}throw new z8("Unable to parse image dimensions","PARSE_ERROR")}async function II($,X){let Z=await LY();if(Z){let Y=Z($).resize(X.width,X.height,{fit:X.fit});switch(X.format){case"webp":Y=Y.webp({quality:X.quality});break;case"avif":Y=Y.avif({quality:X.quality});break;case"jpeg":Y=Y.jpeg({quality:X.quality});break;case"png":Y=Y.png({quality:X.quality});break}return Y.toBuffer()}let J=R7.join(TI.tmpdir(),`stx-img-${gq.randomBytes(8).toString("hex")}.${X.format}`);try{return await ai({input:$,output:J,format:X.format,quality:X.quality,resize:{width:X.width,height:X.height,fit:X.fit}}),Buffer.from(await Bun.file(J).arrayBuffer())}finally{await fq.promises.unlink(J).catch(()=>{})}}async function ti($,X){let Z=await LY();if(X==="blur"&&Z){let G=(await Z($).resize(20).blur(10).toBuffer()).toString("base64"),K=await G8($);return`data:${DI[K.format]||"image/jpeg"};base64,${G}`}if(X==="dominant-color"&&Z){let{dominant:Q}=await Z($).resize(1,1).toBuffer().then(async(G)=>{let K=await Z(G).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${Q.r}, ${Q.g}, ${Q.b})`}let J=await G8($),Y=R7.join(TI.tmpdir(),`stx-ph-${gq.randomBytes(8).toString("hex")}.${J.format==="unknown"?"bin":J.format}`);try{await Bun.write(Y,$);let Q=X==="blur"?"blur":X==="thumbhash"?"thumbhash":"dominant-color",K=await ri(Y,{strategy:Q,width:Q==="thumbhash"?void 0:32});if(X==="dominant-color"&&K.dominantColor)return K.dominantColor;if(K.dataURL)return K.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await fq.promises.unlink(Y).catch(()=>{})}}function _6($,X){return(X?$.filter((J)=>J.format===X):$).sort((J,Y)=>J.width-Y.width).map((J)=>`${J.url} ${J.width}w`).join(", ")}function K8($){if(!$||Object.keys($).length===0)return"100vw";return Object.entries($).sort((Z,J)=>{let Y=Number.parseInt(Z[0].replace(/\D/g,""))||0;return(Number.parseInt(J[0].replace(/\D/g,""))||0)-Y}).map(([Z,J])=>`(max-width: ${Z}) ${J}`).join(", ")+", 100vw"}function W8($){let X=$.filter((J)=>J.format==="jpeg");if(X.length===0)return $[Math.floor($.length/2)];let Z=X.sort((J,Y)=>J.width-Y.width);return Z[Math.floor(Z.length/2)]}function U8($){let X=new Map;for(let Z of $){let J=X.get(Z.format)||[];J.push(Z),X.set(Z.format,J)}return X}function M7($){let X=R7.extname($).toLowerCase();return si.includes(X)}function X$($){return DI[$]||"application/octet-stream"}function rX($){return $.reduce((X,Z)=>X+Z.size,0)}function aX($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var t1,e1,$$=80,si,DI,vq=null,EI=!1,z8;var q8=T(()=>{t1=[320,640,768,1024,1280,1536,1920],e1=["webp","jpeg"],si=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],DI={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};z8=class z8 extends Error{code;constructor($,X){super($);this.name="ImageProcessingError",this.code=X}}});var yI={};X0(yI,{handleImageRequest:()=>oX,createImageHandler:()=>OY});import SI from"fs";import sX from"path";import ei from"crypto";async function oX($,X){let Z=X.routePath??"/_stx/img",J=new URL($.url);if(J.pathname!==Z)return null;let Y=Jn(J,X);if(!Y.ok)return new Response(Y.error,{status:Y.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:Q,srcUrl:G,width:K,height:W,format:U,quality:z,fit:q}=Y,j;try{j=SI.statSync(Q)}catch{return new Response(`Source image not found: ${G}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!j.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let _=X.cacheDir??".stx/cache/img";await SI.promises.mkdir(_,{recursive:!0});let H=`${Q}:${j.mtimeMs}:${j.size}`,L=`${K}x${W}:${U}:${z}:${q}`,O=ei.createHash("sha256").update(`${H}|${L}`).digest("hex").slice(0,16),B=sX.join(_,`${O}.${U}`),V={"Content-Type":X$(U),"Cache-Control":"public, max-age=31536000, immutable",ETag:`"${O}"`,"X-Stx-Image-Cache":"HIT"};if($.headers.get("if-none-match")===`"${O}"`)return new Response(null,{status:304,headers:V});let w=Bun.file(B);if(await w.exists())return new Response(w,{headers:V});try{let A=Buffer.from(await Bun.file(Q).arrayBuffer()),{resizeAndConvert:R}=await Yn(),M=await R(A,{width:K,height:W,format:U,quality:z,fit:q});return await Bun.write(B,M),V["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(M),{headers:V})}catch(A){let R=A.message;return new Response(`Image processing failed: ${R}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function OY($){return async(X)=>{return await oX(X,$)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}}function Jn($,X){let Z=$.searchParams.get("src");if(!Z)return{ok:!1,error:"Missing required param: src",status:400};if(!Z.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(Z.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let J=sX.extname(Z).toLowerCase();if(!$n.has(J))return{ok:!1,error:`Unsupported source extension: ${J}`,status:400};let Y=sX.resolve(X.publicDir),Q=sX.resolve(Y,Z.slice(1));if(!Q.startsWith(`${Y}${sX.sep}`)&&Q!==Y)return{ok:!1,error:"src is outside publicDir",status:400};let G=X.maxWidth??bI,K=X.maxHeight??bI,W=$.searchParams.get("w"),U=$.searchParams.get("h"),z=W?Number.parseInt(W,10):0,q=U?Number.parseInt(U,10):0;if(W&&(!Number.isFinite(z)||z<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(U&&(!Number.isFinite(q)||q<=0))return{ok:!1,error:"Invalid h (must be positive integer)",status:400};if(!W&&!U)return{ok:!1,error:"At least one of w or h is required",status:400};let j=Math.min(z||G,G),_=Math.min(q||K,K),H=$.searchParams.get("f")||"webp";if(!CI.has(H))return{ok:!1,error:`Invalid f (must be one of: ${[...CI].join(", ")})`,status:400};let L=H,O=$.searchParams.get("q"),B=O?Number.parseInt(O,10):X.defaultQuality??Xn;if(!Number.isFinite(B)||B<1||B>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let F=$.searchParams.get("fit")||X.defaultFit||Zn;if(!PI.has(F))return{ok:!1,error:`Invalid fit (must be one of: ${[...PI].join(", ")})`,status:400};return{ok:!0,srcFsPath:Q,srcUrl:Z,width:j,height:_,format:L,quality:B,fit:F}}async function Yn(){return await Promise.resolve().then(() => (q8(),kI))}var CI,PI,$n,bI=4096,Xn=80,Zn="cover";var hq=T(()=>{q8();CI=new Set(["webp","avif","jpeg","png"]),PI=new Set(["cover","contain","fill","inside","outside"]),$n=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"])});function uq($,X={}){let{src:Z,alt:J,width:Y,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=$$,placeholder:z="none",formats:q=e1,widths:j=t1,decoding:_="async",fetchpriority:H,objectFit:L,objectPosition:O}=$,B=$.class,F=$.style,{processedImage:V,variants:w,optimize:A=!0,isDev:R=!1}=X;if(w&&w.length>0)return Qn($,w,V);if(R||!A)return Gn($);return Kn($)}function Qn($,X,Z){let{src:J,alt:Y,width:Q,height:G,sizes:K="100vw",loading:W="lazy",priority:U=!1,decoding:z="async",fetchpriority:q,objectFit:j,objectPosition:_,placeholder:H="none"}=$,L=$.class,O=$.style,B=U8(X),F=W8(X),V=typeof K==="object"?K8(K):K,w=Z?Z.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,A=[];if(w)A.push(`aspect-ratio: ${w}`);if(j)A.push(`object-fit: ${j}`);if(_)A.push(`object-position: ${_}`);if(O)A.push(O);let R=A.length>0?` style="${A.join("; ")}"`:"",M=L?` class="${L}"`:"",I=U?"":` loading="${W}"`,N=` decoding="${z}"`,E=q?` fetchpriority="${q}"`:U?' fetchpriority="high"':"",C=["avif","webp","jpeg","png"],S=[];for(let v of C){let d=B.get(v);if(d&&d.length>0){let a=_6(d),t=X$(v);S.push(` <source type="${t}" srcset="${a}" sizes="${V}" />`)}}let y="",x="",b;if(H!=="none"&&Z?.placeholder){let v=`img-${Math.random().toString(36).slice(2,8)}`;if(y=`<div class="stx-image-wrapper" id="${v}">`,x="</div>",H==="blur")b=`
18270
+ `,await Bun.write(J,Y)}return{configPath:Z,siteId:$.siteId}}function ni($){let X=process.platform,Z=X==="darwin"?"open":X==="win32"?"start":"xdg-open";Bun.spawn([Z,$],{stdio:["ignore","ignore","ignore"]})}var F4;var HY=T(()=>{bq();bq();F4=class F4 extends Error{code;constructor($,X){super($);this.name="DeployError",this.code=X}}});var kI={};X0(kI,{resizeAndConvert:()=>II,processImage:()=>T$,isSharpAvailable:()=>N7,isImageFile:()=>M7,isImageBackendAvailable:()=>E$,groupVariantsByFormat:()=>U8,getTotalSize:()=>rX,getMimeType:()=>X$,getImageMetadata:()=>G8,getFallbackVariant:()=>W8,generateSrcSet:()=>_6,generateSizes:()=>K8,formatSize:()=>aX,ImageProcessingError:()=>z8,DEFAULT_WIDTHS:()=>t1,DEFAULT_QUALITY:()=>$$,DEFAULT_FORMATS:()=>e1});import fq from"fs";import R7 from"path";import TI from"os";import gq from"crypto";import{generatePlaceholder as ri,processImage as ai}from"ts-images";async function LY(){if(EI)return vq;EI=!0;try{let $=await import("sharp");return vq=$.default||$,vq}catch{return null}}async function N7(){return await LY()!==null}async function E$(){return!0}async function T$($,X={}){let{widths:Z=t1,formats:J=e1,quality:Y=$$,fit:Q="cover",placeholder:G="none",outputDir:K=".stx/images",baseUrl:W="/images"}=X,U,z;if(typeof $==="string"){if(z=$,!await Bun.file($).exists())throw new z8(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((w)=>Buffer.from(w))}else z="buffer-input",U=$;let q=gq.createHash("sha256").update(U).digest("hex").slice(0,12),j=await G8(U),{width:_,height:H}=j,L=_/H;await fq.promises.mkdir(K,{recursive:!0});let O=[],B=R7.basename(z,R7.extname(z)),F=Z.filter((w)=>w<=_);if(!F.includes(_)&&_<=Math.max(...Z))F.push(_);F.sort((w,A)=>w-A);for(let w of F){let A=Math.round(w/L);for(let R of J){let M=`${B}-${w}w-${q}.${R}`,I=R7.join(K,M),N=`${W}/${M}`,E=await II(U,{width:w,height:A,format:R,quality:Y,fit:Q});await Bun.write(I,E),O.push({path:I,url:N,width:w,height:A,format:R,size:E.length})}}let V;if(G!=="none")V=await ti(U,G);return{src:z,variants:O,placeholder:V,width:_,height:H,aspectRatio:L,hash:q}}async function G8($){let X=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Z=await LY();if(Z){let Y=await Z(X).metadata();return{width:Y.width||0,height:Y.height||0,format:Y.format||"unknown",hasAlpha:Y.hasAlpha}}return oi(X)}function oi($){if($[0]===137&&$[1]===80&&$[2]===78&&$[3]===71){let X=$.readUInt32BE(16),Z=$.readUInt32BE(20);return{width:X,height:Z,format:"png",hasAlpha:!0}}if($[0]===255&&$[1]===216){let X=2;while(X<$.length){if($[X]!==255)break;let Z=$[X+1];if(Z>=192&&Z<=207&&Z!==196&&Z!==200&&Z!==204){let Y=$.readUInt16BE(X+5);return{width:$.readUInt16BE(X+7),height:Y,format:"jpeg",hasAlpha:!1}}let J=$.readUInt16BE(X+2);X+=2+J}}if($.toString("utf8",0,4)==="RIFF"&&$.toString("utf8",8,12)==="WEBP"){let X=$.toString("utf8",12,16);if(X==="VP8 "){let Z=$.readUInt16LE(26)&16383,J=$.readUInt16LE(28)&16383;return{width:Z,height:J,format:"webp",hasAlpha:!1}}if(X==="VP8L"){let Z=$.readUInt32LE(21),J=(Z&16383)+1,Y=(Z>>14&16383)+1;return{width:J,height:Y,format:"webp",hasAlpha:!0}}}if($.toString("utf8",0,3)==="GIF"){let X=$.readUInt16LE(6),Z=$.readUInt16LE(8);return{width:X,height:Z,format:"gif",hasAlpha:!0}}throw new z8("Unable to parse image dimensions","PARSE_ERROR")}async function II($,X){let Z=await LY();if(Z){let Y=Z($).resize(X.width,X.height,{fit:X.fit});switch(X.format){case"webp":Y=Y.webp({quality:X.quality});break;case"avif":Y=Y.avif({quality:X.quality});break;case"jpeg":Y=Y.jpeg({quality:X.quality});break;case"png":Y=Y.png({quality:X.quality});break}return Y.toBuffer()}let J=R7.join(TI.tmpdir(),`stx-img-${gq.randomBytes(8).toString("hex")}.${X.format}`);try{return await ai({input:$,output:J,format:X.format,quality:X.quality,resize:{width:X.width,height:X.height,fit:X.fit}}),Buffer.from(await Bun.file(J).arrayBuffer())}finally{await fq.promises.unlink(J).catch(()=>{})}}async function ti($,X){let Z=await LY();if(X==="blur"&&Z){let G=(await Z($).resize(20).blur(10).toBuffer()).toString("base64"),K=await G8($);return`data:${DI[K.format]||"image/jpeg"};base64,${G}`}if(X==="dominant-color"&&Z){let{dominant:Q}=await Z($).resize(1,1).toBuffer().then(async(G)=>{let K=await Z(G).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${Q.r}, ${Q.g}, ${Q.b})`}let J=await G8($),Y=R7.join(TI.tmpdir(),`stx-ph-${gq.randomBytes(8).toString("hex")}.${J.format==="unknown"?"bin":J.format}`);try{await Bun.write(Y,$);let Q=X==="blur"?"blur":X==="thumbhash"?"thumbhash":"dominant-color",K=await ri(Y,{strategy:Q,width:Q==="thumbhash"?void 0:32});if(X==="dominant-color"&&K.dominantColor)return K.dominantColor;if(K.dataURL)return K.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await fq.promises.unlink(Y).catch(()=>{})}}function _6($,X){return(X?$.filter((J)=>J.format===X):$).sort((J,Y)=>J.width-Y.width).map((J)=>`${J.url} ${J.width}w`).join(", ")}function K8($){if(!$||Object.keys($).length===0)return"100vw";return Object.entries($).sort((Z,J)=>{let Y=Number.parseInt(Z[0].replace(/\D/g,""))||0;return(Number.parseInt(J[0].replace(/\D/g,""))||0)-Y}).map(([Z,J])=>`(max-width: ${Z}) ${J}`).join(", ")+", 100vw"}function W8($){let X=$.filter((J)=>J.format==="jpeg");if(X.length===0)return $[Math.floor($.length/2)];let Z=X.sort((J,Y)=>J.width-Y.width);return Z[Math.floor(Z.length/2)]}function U8($){let X=new Map;for(let Z of $){let J=X.get(Z.format)||[];J.push(Z),X.set(Z.format,J)}return X}function M7($){let X=R7.extname($).toLowerCase();return si.includes(X)}function X$($){return DI[$]||"application/octet-stream"}function rX($){return $.reduce((X,Z)=>X+Z.size,0)}function aX($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var t1,e1,$$=80,si,DI,vq=null,EI=!1,z8;var q8=T(()=>{t1=[320,640,768,1024,1280,1536,1920],e1=["webp","jpeg"],si=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],DI={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};z8=class z8 extends Error{code;constructor($,X){super($);this.name="ImageProcessingError",this.code=X}}});var yI={};X0(yI,{handleImageRequest:()=>oX,createImageHandler:()=>OY});import SI from"fs";import sX from"path";import ei from"crypto";async function oX($,X){let Z=X.routePath??"/_stx/img",J=new URL($.url);if(J.pathname!==Z)return null;let Y=Jn(J,X);if(!Y.ok)return new Response(Y.error,{status:Y.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:Q,srcUrl:G,width:K,height:W,format:U,quality:z,fit:q}=Y,j;try{j=SI.statSync(Q)}catch{return new Response(`Source image not found: ${G}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!j.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let _=X.cacheDir??".stx/cache/img";await SI.promises.mkdir(_,{recursive:!0});let H=`${Q}:${j.mtimeMs}:${j.size}`,L=`${K}x${W}:${U}:${z}:${q}`,O=ei.createHash("sha256").update(`${H}|${L}`).digest("hex").slice(0,16),B=sX.join(_,`${O}.${U}`),V={"Content-Type":X$(U),"Cache-Control":"public, max-age=31536000, immutable",ETag:`"${O}"`,"X-Stx-Image-Cache":"HIT"};if($.headers.get("if-none-match")===`"${O}"`)return new Response(null,{status:304,headers:V});let w=Bun.file(B);if(await w.exists())return new Response(w,{headers:V});try{let A=Buffer.from(await Bun.file(Q).arrayBuffer()),{resizeAndConvert:R}=await Yn(),M=await R(A,{width:K,height:W,format:U,quality:z,fit:q});return await Bun.write(B,M),V["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(M),{headers:V})}catch(A){let R=A.message;return new Response(`Image processing failed: ${R}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function OY($){return async(X)=>{return await oX(X,$)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}}function Jn($,X){let Z=$.searchParams.get("src");if(!Z)return{ok:!1,error:"Missing required param: src",status:400};if(!Z.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(Z.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let J=sX.extname(Z).toLowerCase();if(!$n.has(J))return{ok:!1,error:`Unsupported source extension: ${J}`,status:400};let Y=sX.resolve(X.publicDir),Q=sX.resolve(Y,Z.slice(1));if(!Q.startsWith(`${Y}${sX.sep}`)&&Q!==Y)return{ok:!1,error:"src is outside publicDir",status:400};let G=X.maxWidth??bI,K=X.maxHeight??bI,W=$.searchParams.get("w"),U=$.searchParams.get("h"),z=W?Number.parseInt(W,10):0,q=U?Number.parseInt(U,10):0;if(W&&(!Number.isFinite(z)||z<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(U&&(!Number.isFinite(q)||q<=0))return{ok:!1,error:"Invalid h (must be positive integer)",status:400};if(!W&&!U)return{ok:!1,error:"At least one of w or h is required",status:400};let j=Math.min(z||G,G),_=Math.min(q||K,K),H=$.searchParams.get("f")||"webp";if(!CI.has(H))return{ok:!1,error:`Invalid f (must be one of: ${[...CI].join(", ")})`,status:400};let L=H,O=$.searchParams.get("q"),B=O?Number.parseInt(O,10):X.defaultQuality??Xn;if(!Number.isFinite(B)||B<1||B>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let F=$.searchParams.get("fit")||X.defaultFit||Zn;if(!PI.has(F))return{ok:!1,error:`Invalid fit (must be one of: ${[...PI].join(", ")})`,status:400};return{ok:!0,srcFsPath:Q,srcUrl:Z,width:j,height:_,format:L,quality:B,fit:F}}async function Yn(){return await Promise.resolve().then(() => (q8(),kI))}var CI,PI,$n,bI=4096,Xn=80,Zn="cover";var hq=T(()=>{q8();CI=new Set(["webp","avif","jpeg","png"]),PI=new Set(["cover","contain","fill","inside","outside"]),$n=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"])});function uq($,X={}){let{src:Z,alt:J,width:Y,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=$$,placeholder:z="none",formats:q=e1,widths:j=t1,decoding:_="async",fetchpriority:H,objectFit:L,objectPosition:O}=$,B=$.class,F=$.style,{processedImage:V,variants:w,optimize:A=!0,isDev:R=!1}=X;if(w&&w.length>0)return Qn($,w,V);if(R||!A)return Gn($);return Kn($)}function Qn($,X,Z){let{src:J,alt:Y,width:Q,height:G,sizes:K="100vw",loading:W="lazy",priority:U=!1,decoding:z="async",fetchpriority:q,objectFit:j,objectPosition:_,placeholder:H="none"}=$,L=$.class,O=$.style,B=U8(X),F=W8(X),V=typeof K==="object"?K8(K):K,w=Z?Z.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,A=[];if(w)A.push(`aspect-ratio: ${w}`);if(j)A.push(`object-fit: ${j}`);if(_)A.push(`object-position: ${_}`);if(O)A.push(O);let R=A.length>0?` style="${A.join("; ")}"`:"",M=L?` class="${L}"`:"",I=U?"":` loading="${W}"`,N=` decoding="${z}"`,E=q?` fetchpriority="${q}"`:U?' fetchpriority="high"':"",C=["avif","webp","jpeg","png"],S=[];for(let v of C){let d=B.get(v);if(d&&d.length>0){let a=_6(d),t=X$(v);S.push(` <source type="${t}" srcset="${a}" sizes="${V}" />`)}}let x="",y="",b;if(H!=="none"&&Z?.placeholder){let v=`img-${Math.random().toString(36).slice(2,8)}`;if(x=`<div class="stx-image-wrapper" id="${v}">`,y="</div>",H==="blur")b=`
18271
18271
  #${v} {
18272
18272
  position: relative;
18273
18273
  background-image: url('${Z.placeholder}');
@@ -18284,14 +18284,14 @@ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FO
18284
18284
  #${v} {
18285
18285
  background-color: ${Z.placeholder};
18286
18286
  }
18287
- `.trim()}let u=Q?` width="${Q}"`:Z?` width="${Z.width}"`:"",i=G?` height="${G}"`:Z?` height="${Z.height}"`:"",c=`${y}<picture>
18287
+ `.trim()}let u=Q?` width="${Q}"`:Z?` width="${Z.width}"`:"",i=G?` height="${G}"`:Z?` height="${Z.height}"`:"",c=`${x}<picture>
18288
18288
  ${S.join(`
18289
18289
  `)}
18290
18290
  <img
18291
18291
  src="${F?.url||J}"
18292
18292
  alt="${dq(Y)}"${u}${i}${M}${R}${I}${N}${E}
18293
18293
  />
18294
- </picture>${x}`,P;if(U&&F){let v=B.get("webp"),d=v?.[Math.floor(v.length/2)]||F,a=X$(d.format);P=`<link rel="preload" as="image" href="${d.url}" type="${a}" />`}return{html:c,preloadLink:P,placeholderCss:b}}function Gn($){let{src:X,alt:Z,width:J,height:Y,loading:Q="lazy",decoding:G="async",priority:K=!1,fetchpriority:W,objectFit:U,objectPosition:z}=$,q=$.class,j=$.style,_=[];if(U)_.push(`object-fit: ${U}`);if(z)_.push(`object-position: ${z}`);if(j)_.push(j);let H=_.length>0?` style="${_.join("; ")}"`:"",L=q?` class="${q}"`:"",O=J?` width="${J}"`:"",B=Y?` height="${Y}"`:"",F=K?"":` loading="${Q}"`,V=` decoding="${G}"`,w=W?` fetchpriority="${W}"`:K?' fetchpriority="high"':"";return{html:`<img src="${X}" alt="${dq(Z)}"${O}${B}${L}${H}${F}${V}${w} />`}}function Kn($){let{src:X,alt:Z,width:J,height:Y,sizes:Q="100vw",loading:G="lazy",priority:K=!1,quality:W=$$,formats:U=e1,widths:z=t1,decoding:q="async",fetchpriority:j,objectFit:_,objectPosition:H}=$,L=$.class,O=$.style,B=[];if(_)B.push(`object-fit: ${_}`);if(H)B.push(`object-position: ${H}`);if(O)B.push(O);let F=B.length>0?` style="${B.join("; ")}"`:"",V=L?` class="${L}"`:"",w=J?` width="${J}"`:"",A=Y?` height="${Y}"`:"",R=K?"":` loading="${G}"`,M=` decoding="${q}"`,I=j?` fetchpriority="${j}"`:K?' fetchpriority="high"':"",N=typeof Q==="object"?K8(Q):Q,E=`
18294
+ </picture>${y}`,P;if(U&&F){let v=B.get("webp"),d=v?.[Math.floor(v.length/2)]||F,a=X$(d.format);P=`<link rel="preload" as="image" href="${d.url}" type="${a}" />`}return{html:c,preloadLink:P,placeholderCss:b}}function Gn($){let{src:X,alt:Z,width:J,height:Y,loading:Q="lazy",decoding:G="async",priority:K=!1,fetchpriority:W,objectFit:U,objectPosition:z}=$,q=$.class,j=$.style,_=[];if(U)_.push(`object-fit: ${U}`);if(z)_.push(`object-position: ${z}`);if(j)_.push(j);let H=_.length>0?` style="${_.join("; ")}"`:"",L=q?` class="${q}"`:"",O=J?` width="${J}"`:"",B=Y?` height="${Y}"`:"",F=K?"":` loading="${Q}"`,V=` decoding="${G}"`,w=W?` fetchpriority="${W}"`:K?' fetchpriority="high"':"";return{html:`<img src="${X}" alt="${dq(Z)}"${O}${B}${L}${H}${F}${V}${w} />`}}function Kn($){let{src:X,alt:Z,width:J,height:Y,sizes:Q="100vw",loading:G="lazy",priority:K=!1,quality:W=$$,formats:U=e1,widths:z=t1,decoding:q="async",fetchpriority:j,objectFit:_,objectPosition:H}=$,L=$.class,O=$.style,B=[];if(_)B.push(`object-fit: ${_}`);if(H)B.push(`object-position: ${H}`);if(O)B.push(O);let F=B.length>0?` style="${B.join("; ")}"`:"",V=L?` class="${L}"`:"",w=J?` width="${J}"`:"",A=Y?` height="${Y}"`:"",R=K?"":` loading="${G}"`,M=` decoding="${q}"`,I=j?` fetchpriority="${j}"`:K?' fetchpriority="high"':"",N=typeof Q==="object"?K8(Q):Q,E=`
18295
18295
  data-stx-image
18296
18296
  data-src="${X}"
18297
18297
  data-sizes="${N}"
@@ -18560,10 +18560,10 @@ ${$.map((J)=>{let Y=new URL(J.loc,X).href,Q=` <url>
18560
18560
  ${Z.join(`
18561
18561
  `)}
18562
18562
  </channel>
18563
- </rss>`}async function Lk($={}){let X=Date.now();q3();let Z=await a0(process.cwd()),J=Z.build||{},Y=await Kk({explicit:$.domain||J.domain,stxConfig:Z});if(Y.source==="fallback"&&($.sitemap??J.sitemap??!0))console.warn(Wk());let Q={pagesDir:$.pagesDir||J.pagesDir||"pages",outputDir:$.outputDir||J.outputDir||"dist",baseUrl:$.baseUrl||J.baseUrl||"/",domain:Y.url,revalidate:$.revalidate??J.revalidate??!1,sitemap:$.sitemap??J.sitemap??!0,sitemapExclude:$.sitemapExclude||J.sitemapExclude||[],robots:$.robots??J.robots??!0,rss:$.rss??J.rss??!1,concurrency:$.concurrency||J.concurrency||10,cache:$.cache??J.cache??!0,cacheDir:$.cacheDir||J.cacheDir||n0(process.cwd(),"ssg-cache"),contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??J.minify??!0,generate404:$.generate404??J.generate404??!0,publicDir:$.publicDir||J.publicDir||"public",trailingSlash:$.trailingSlash??J.trailingSlash??!1,cleanOutput:$.cleanOutput??J.cleanOutput??!0,cacheSalt:$.cacheSalt??"",partialsDir:$.partialsDir||Z?.partialsDir||"",componentsDir:$.componentsDir||Z?.componentsDir||"",failOnIncludeError:$.failOnIncludeError??!0,chunkIslands:$.chunkIslands===!0,prefetchIslands:$.prefetchIslands===!0,integrityIslands:$.integrityIslands===!0},G={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},K=new Set,W=0,U={},z={};await Q.hooks.onBuildStart?.();try{if(Q.cleanOutput&&U1.existsSync(Q.outputDir))await U1.promises.rm(Q.outputDir,{recursive:!0});await U1.promises.mkdir(Q.outputDir,{recursive:!0});let j=Q.cacheSalt;if(!j){let{resolveUserCrosswindConfig:N,fingerprintConfig:E}=await Promise.resolve().then(() => (H$(),T3));try{j=E(await N(process.cwd()))}catch{}}let _=new zk(Q.cacheDir,j);if(Q.cache)await _.load();try{let{generateCrosswindCSS:N}=await Promise.resolve().then(() => (H$(),T3));await N('<div class="bg-black"></div>')}catch{}D4();let H=Z?.routeMiddleware?.dir||"middleware";await k4(process.cwd(),H);let L=I4();if(L.length>0)console.log(`Loaded ${L.length} middleware: ${L.join(", ")}`);let O=Z?.routeMiddleware?.global||[];PY(Z?.layoutsDir,n0(process.cwd()));let B=V$(".",{pagesDir:Q.pagesDir});console.log(`Found ${B.length} routes`);let F=[];for(let N of B){let E=await jr(N);for(let C of E)F.push({route:N,url:C.url,params:C.params,props:C.props,revalidate:C.revalidate??Q.revalidate})}G.totalPages=F.length,console.log(`Generating ${G.totalPages} pages...`);let V=[],w=[];for(let N=0;N<F.length;N+=Q.concurrency)w.push(F.slice(N,N+Q.concurrency));for(let N of w)await Promise.all(N.map(async(E)=>{let{route:C,url:S,params:y,props:x,revalidate:b}=E;try{await Q.hooks.onPageStart?.(S);let u=await Bun.file(C.filePath).text(),i=Vr(u),c=i?.middleware?Array.isArray(i.middleware)?i.middleware:[i.middleware]:[],P=[...O,...c];if(P.length>0){let o=S4(S,y,i||{}),W0=C4(o,null,void 0,{isServer:!0}),U0=await P4(P,W0);if(U0.redirect){let z0=typeof U0.redirect==="string"?U0.redirect:U0.redirect.path||U0.redirect,s0=wr(String(z0),S),G0=Ar(S,Q);await U1.promises.mkdir(y0.dirname(G0),{recursive:!0}),await Bun.write(G0,s0),G.successCount++,G.pages.push({route:S,outputPath:G0,size:Buffer.byteLength(s0),cached:!1}),V.push({loc:S,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${S} \u2192 redirect to ${z0}`);return}if(U0.abort){let z0=typeof U0.abort==="string"?U0.abort:U0.abort?.error?.message||"aborted";console.warn(` \u21B3 ${S} \u2014 middleware aborted: ${z0}`);return}}let v=u.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(v)try{if(!await Function("route",`
18563
+ </rss>`}async function Lk($={}){let X=Date.now();q3();let Z=await a0(process.cwd()),J=Z.build||{},Y=await Kk({explicit:$.domain||J.domain,stxConfig:Z});if(Y.source==="fallback"&&($.sitemap??J.sitemap??!0))console.warn(Wk());let Q={pagesDir:$.pagesDir||J.pagesDir||"pages",outputDir:$.outputDir||J.outputDir||"dist",baseUrl:$.baseUrl||J.baseUrl||"/",domain:Y.url,revalidate:$.revalidate??J.revalidate??!1,sitemap:$.sitemap??J.sitemap??!0,sitemapExclude:$.sitemapExclude||J.sitemapExclude||[],robots:$.robots??J.robots??!0,rss:$.rss??J.rss??!1,concurrency:$.concurrency||J.concurrency||10,cache:$.cache??J.cache??!0,cacheDir:$.cacheDir||J.cacheDir||n0(process.cwd(),"ssg-cache"),contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??J.minify??!0,generate404:$.generate404??J.generate404??!0,publicDir:$.publicDir||J.publicDir||"public",trailingSlash:$.trailingSlash??J.trailingSlash??!1,cleanOutput:$.cleanOutput??J.cleanOutput??!0,cacheSalt:$.cacheSalt??"",partialsDir:$.partialsDir||Z?.partialsDir||"",componentsDir:$.componentsDir||Z?.componentsDir||"",failOnIncludeError:$.failOnIncludeError??!0,chunkIslands:$.chunkIslands===!0,prefetchIslands:$.prefetchIslands===!0,integrityIslands:$.integrityIslands===!0},G={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},K=new Set,W=0,U={},z={};await Q.hooks.onBuildStart?.();try{if(Q.cleanOutput&&U1.existsSync(Q.outputDir))await U1.promises.rm(Q.outputDir,{recursive:!0});await U1.promises.mkdir(Q.outputDir,{recursive:!0});let j=Q.cacheSalt;if(!j){let{resolveUserCrosswindConfig:N,fingerprintConfig:E}=await Promise.resolve().then(() => (H$(),T3));try{j=E(await N(process.cwd()))}catch{}}let _=new zk(Q.cacheDir,j);if(Q.cache)await _.load();try{let{generateCrosswindCSS:N}=await Promise.resolve().then(() => (H$(),T3));await N('<div class="bg-black"></div>')}catch{}D4();let H=Z?.routeMiddleware?.dir||"middleware";await k4(process.cwd(),H);let L=I4();if(L.length>0)console.log(`Loaded ${L.length} middleware: ${L.join(", ")}`);let O=Z?.routeMiddleware?.global||[];PY(Z?.layoutsDir,n0(process.cwd()));let B=V$(".",{pagesDir:Q.pagesDir});console.log(`Found ${B.length} routes`);let F=[];for(let N of B){let E=await jr(N);for(let C of E)F.push({route:N,url:C.url,params:C.params,props:C.props,revalidate:C.revalidate??Q.revalidate})}G.totalPages=F.length,console.log(`Generating ${G.totalPages} pages...`);let V=[],w=[];for(let N=0;N<F.length;N+=Q.concurrency)w.push(F.slice(N,N+Q.concurrency));for(let N of w)await Promise.all(N.map(async(E)=>{let{route:C,url:S,params:x,props:y,revalidate:b}=E;try{await Q.hooks.onPageStart?.(S);let u=await Bun.file(C.filePath).text(),i=Vr(u),c=i?.middleware?Array.isArray(i.middleware)?i.middleware:[i.middleware]:[],P=[...O,...c];if(P.length>0){let o=S4(S,x,i||{}),W0=C4(o,null,void 0,{isServer:!0}),U0=await P4(P,W0);if(U0.redirect){let z0=typeof U0.redirect==="string"?U0.redirect:U0.redirect.path||U0.redirect,s0=wr(String(z0),S),G0=Ar(S,Q);await U1.promises.mkdir(y0.dirname(G0),{recursive:!0}),await Bun.write(G0,s0),G.successCount++,G.pages.push({route:S,outputPath:G0,size:Buffer.byteLength(s0),cached:!1}),V.push({loc:S,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${S} \u2192 redirect to ${z0}`);return}if(U0.abort){let z0=typeof U0.abort==="string"?U0.abort:U0.abort?.error?.message||"aborted";console.warn(` \u21B3 ${S} \u2014 middleware aborted: ${z0}`);return}}let v=u.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(v)try{if(!await Function("route",`
18564
18564
  const validate = ${v[1]};
18565
18565
  return validate(route);
18566
- `)({params:y})){console.warn(`Validation failed for ${S}, skipping...`);return}}catch{}let d=null,a=!1;if(Q.cache){if(d=_.get(S,C.filePath),d)a=!0,G.cachedCount++}if(!d){let o=await _k(C,y,x,Q,Z);if(d=o.html,Q.failOnIncludeError&&o.includeFailures.length>0)throw Error(`${o.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
18566
+ `)({params:x})){console.warn(`Validation failed for ${S}, skipping...`);return}}catch{}let d=null,a=!1;if(Q.cache){if(d=_.get(S,C.filePath),d)a=!0,G.cachedCount++}if(!d){let o=await _k(C,x,y,Q,Z);if(d=o.html,Q.failOnIncludeError&&o.includeFailures.length>0)throw Error(`${o.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
18567
18567
  ${o.includeFailures.join(`
18568
18568
  `)}
18569
18569
  Set ssg.failOnIncludeError to false to build anyway.`);if(Q.cache)_.set(S,C.filePath,o.dependencies,d)}let t;if(Q.trailingSlash)t=y0.join(Q.outputDir,S,"index.html");else t=S==="/"?y0.join(Q.outputDir,"index.html"):y0.join(Q.outputDir,`${S}.html`);if(Q.chunkIslands){let{html:o,chunks:W0}=Jk(d,{integrity:Q.integrityIslands,minify:Q.minify});if(W0.length>0){let U0=y0.join(Q.outputDir,"_stx","islands");await U1.promises.mkdir(U0,{recursive:!0});for(let z0 of W0){let s0=y0.join(U0,`${z0.hash}.js`);if(!await Bun.file(s0).exists())await Bun.write(s0,z0.code);if(!K.has(z0.hash)){K.add(z0.hash);let G0=Buffer.byteLength(z0.code,"utf8");W+=G0,U[z0.hash]={bytes:G0,file:`/_stx/islands/${z0.hash}.js`}}}if(z[S]=W0.map((z0)=>z0.hash),d=o,Q.prefetchIslands)d=Yk(d)}}if(await U1.promises.mkdir(y0.dirname(t),{recursive:!0}),await Bun.write(t,d),!Hk(S,d,i,Q.sitemapExclude))V.push({loc:S,lastmod:new Date().toISOString().split("T")[0],priority:S==="/"?1:0.8});let k0={route:S,outputPath:t,size:Buffer.byteLength(d,"utf8"),cached:a};if(b!==!1)k0.revalidateAt=Date.now()+b*1000;G.pages.push(k0),G.successCount++,await Q.hooks.onPageEnd?.(S,d)}catch(u){G.failedCount++,G.errors.push({route:S,error:u}),await Q.hooks.onError?.(u,S),console.error(`Error generating ${S}:`,u)}}));let A=z3();if(A.length>0){let N=A.map((E)=>`${E.filePath}: ${E.message}`).join(`
@@ -18589,7 +18589,7 @@ ${N}`)}if(Q.cache)await _.save();if(Q.generate404){let N=y0.join(Q.pagesDir,"404
18589
18589
  <a href="/">Go home</a>
18590
18590
  </div>
18591
18591
  </body>
18592
- </html>`)}for(let N of[500]){let E=y0.join(Q.pagesDir,`${N}.stx`);if(await Bun.file(E).exists()){let C=new Set,S={...Z,debug:!1,cache:!1},y=await w0(await Bun.file(E).text(),{},E,S,C);await Bun.write(y0.join(Q.outputDir,`${N}.html`),y)}}let R=y0.join(Q.pagesDir,"error.stx");if(await Bun.file(R).exists()){let N=new Set,E={...Z,debug:!1,cache:!1},C=await w0(await Bun.file(R).text(),{},R,E,N);await Bun.write(y0.join(Q.outputDir,"error.html"),C)}if(Q.sitemap&&V.length>0){let N=Br(V,Q.domain),E=y0.join(Q.outputDir,"sitemap.xml");await Bun.write(E,N),G.sitemapPath=E,console.log(`Generated sitemap.xml with ${V.length} URLs`)}if(Q.robots!==!1){let N=typeof Q.robots==="object"?Q.robots:{},E=[...Q.sitemapExclude.filter((S)=>typeof S==="string"),...N.disallow||[]],C=y2({rules:[{userAgent:N.userAgent||"*",allow:N.allow||["/"],...E.length>0?{disallow:E}:{}}],...N.sitemap!==!1&&G.sitemapPath?{sitemap:new URL("/sitemap.xml",Q.domain).href}:{}});await Bun.write(y0.join(Q.outputDir,"robots.txt"),C),console.log("Generated robots.txt")}if(Q.rss){let N=typeof Q.rss==="object"?Q.rss:{title:"Site Feed",description:"Latest updates",link:Q.domain},E=[];if(N.getItems)E=await N.getItems();let C=Fr(N,E),S=y0.join(Q.outputDir,"rss.xml");await Bun.write(S,C),G.rssPath=S,console.log(`Generated rss.xml with ${E.length} items`)}let M=F7(Q.outputDir);if(M.assets>0)console.log(`Externalized ${M.assets} asset(s) from ${M.pages} page(s) (${(M.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(Q.publicDir&&U1.existsSync(Q.publicDir))await Jj(Q.publicDir,Q.outputDir),console.log(`Copied public assets from ${Q.publicDir}`);let I=k7();if(I)await Jj(I,y0.join(Q.outputDir,I7)),console.log(`Copied assets from ${ZZ}`)}catch(j){throw await Q.hooks.onError?.(j),j}if(G.buildTime=Date.now()-X,K.size>0){G.islandChunks={count:K.size,totalBytes:W};let j={generatedChunks:K.size,totalBytes:W,chunks:U,pages:z};await Bun.write(y0.join(Q.outputDir,"_stx","islands-manifest.json"),JSON.stringify(j,null,2))}await Q.hooks.onBuildEnd?.(G);let q=G.islandChunks?`
18592
+ </html>`)}for(let N of[500]){let E=y0.join(Q.pagesDir,`${N}.stx`);if(await Bun.file(E).exists()){let C=new Set,S={...Z,debug:!1,cache:!1},x=await w0(await Bun.file(E).text(),{},E,S,C);await Bun.write(y0.join(Q.outputDir,`${N}.html`),x)}}let R=y0.join(Q.pagesDir,"error.stx");if(await Bun.file(R).exists()){let N=new Set,E={...Z,debug:!1,cache:!1},C=await w0(await Bun.file(R).text(),{},R,E,N);await Bun.write(y0.join(Q.outputDir,"error.html"),C)}if(Q.sitemap&&V.length>0){let N=Br(V,Q.domain),E=y0.join(Q.outputDir,"sitemap.xml");await Bun.write(E,N),G.sitemapPath=E,console.log(`Generated sitemap.xml with ${V.length} URLs`)}if(Q.robots!==!1){let N=typeof Q.robots==="object"?Q.robots:{},E=[...Q.sitemapExclude.filter((S)=>typeof S==="string"),...N.disallow||[]],C=y2({rules:[{userAgent:N.userAgent||"*",allow:N.allow||["/"],...E.length>0?{disallow:E}:{}}],...N.sitemap!==!1&&G.sitemapPath?{sitemap:new URL("/sitemap.xml",Q.domain).href}:{}});await Bun.write(y0.join(Q.outputDir,"robots.txt"),C),console.log("Generated robots.txt")}if(Q.rss){let N=typeof Q.rss==="object"?Q.rss:{title:"Site Feed",description:"Latest updates",link:Q.domain},E=[];if(N.getItems)E=await N.getItems();let C=Fr(N,E),S=y0.join(Q.outputDir,"rss.xml");await Bun.write(S,C),G.rssPath=S,console.log(`Generated rss.xml with ${E.length} items`)}let M=F7(Q.outputDir);if(M.assets>0)console.log(`Externalized ${M.assets} asset(s) from ${M.pages} page(s) (${(M.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(Q.publicDir&&U1.existsSync(Q.publicDir))await Jj(Q.publicDir,Q.outputDir),console.log(`Copied public assets from ${Q.publicDir}`);let I=k7();if(I)await Jj(I,y0.join(Q.outputDir,I7)),console.log(`Copied assets from ${ZZ}`)}catch(j){throw await Q.hooks.onError?.(j),j}if(G.buildTime=Date.now()-X,K.size>0){G.islandChunks={count:K.size,totalBytes:W};let j={generatedChunks:K.size,totalBytes:W,chunks:U,pages:z};await Bun.write(y0.join(Q.outputDir,"_stx","islands-manifest.json"),JSON.stringify(j,null,2))}await Q.hooks.onBuildEnd?.(G);let q=G.islandChunks?`
18593
18593
  Island chunks: ${G.islandChunks.count} (${(G.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
18594
18594
  Build complete!
18595
18595
  Total: ${G.totalPages} pages
@@ -18629,7 +18629,7 @@ Build complete!
18629
18629
  `).forEach((U,z)=>{let q=K.startLine-1+z;if(q<Y.length)Y[q]=U});let G=(K,W)=>{if(Y.push(K),W)Q.set(Y.length,W)};if(X.globals!==!1){if(G(""),X.runtimeGlobals!==!1)for(let W of Pr().split(`
18630
18630
  `))G(W);for(let W of zj().split(`
18631
18631
  `))G(W);for(let W of hr)G(`declare var ${W}: any`);G(`declare var ${Uj}: any`);let K=new Set(Z.flatMap((W)=>H8(W.code)));G(`type ${Rk}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let W of Cr($)){if(K.has(W.name))continue;let U=W.iterable&&K.has(W.iterable)?`${Rk}<typeof ${W.iterable}>`:"any";G(`declare var ${W.name}: ${U}`)}}if(X.templateExpressions!==!1){let K=xY($).map((W)=>({expression:W,statement:mr(W)})).filter((W)=>W.statement!==null);if(K.length>0){let U=[...new Set(Z.flatMap((q)=>H8(q.code)))].filter((q)=>/^[A-Z_$][\w$]*$/i.test(q)),z=0;if(U.length>0){G(Ir);for(let q of U)G(`type __StxT_${q} = ${Sk}<typeof ${q}>`);G(`;((${U.map((q)=>`${q}: __StxT_${q}`).join(", ")}) => {`),z=1}for(let{expression:q,statement:j}of K){let _=" ".repeat(z);G(_+j.text,{line:q.line,column:q.column,expression:q,prefixLength:j.prefixLength+_.length})}if(z>0)G("});")}}return G("export {}"),{text:Y.join(`
18632
- `),lineMap:Q,sourceLineCount:J.length}}function gk($,X,Z){let J=$.lineMap.get(X);if(!J)return X<=$.sourceLineCount?{line:X,column:Z}:null;let Y=Math.max(0,Z-1-(J.prefixLength??0));return{line:J.line,column:J.column+Y,expression:J.expression}}var Ak,kk,yY,Uj="__stx_interpolated",Rk="__StxElement",Sk="__StxTemplateValue",Ir,kr,Sr,Mk,br,Ek="stx: types for the declared client payload (#1868)",gr="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",Tk="__stxServerScope",Dk="__StxClientPayload",hr,ur,dr;var vY=T(()=>{i1();Ak=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;kk=new Set([":for","x-for","v-for"]),yY=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,Ir=`type ${Sk}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;kr=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],Sr=new RegExp(String.raw`^[ \t]*@(?:${kr.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");Mk=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);br=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore"];hr=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","$errors","$csrf","props","slot"],ur=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;dr=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g});import hk from"path";import{createHash as cr}from"crypto";function lr($={}){let X=new Set;return{context:new Proxy($,{get(J,Y){if(Y in J)return J[Y];if(typeof Y==="string"&&!Y.startsWith("__"))X.add(Y);return},has(J,Y){if(Y in J)return!0;if(typeof Y==="string"&&!Y.startsWith("__"))X.add(Y);return!1}}),accessedKeys:X}}async function jj($,X,Z={}){let J=hk.resolve($),Y=await Bun.file(J).text(),Q=cr("sha256").update(Y).digest("hex").slice(0,16);VG();let G={};try{G=await a0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(Y))!==null){let B=U[1];if(/\bserver\b/.test(B))K.push(U[2])}let z=new Set(K.flatMap((B)=>H8(B))),{context:q}=lr({__filename:J,__dirname:hk.dirname(J),__stx_serverDeclared:z}),j=new Set,_={...D1,...G,...Z,buildMode:"compile",strict:!1},H=await w0(Y,q,J,_,j),L=w4(H),O=wG();return{route:X,sourceFile:$,html:H,fragment:L,placeholders:O,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(j),contentHash:Q,streamTemplates:q.__streamTemplates}}var _j=T(()=>{P1();$1();F3();D7();vY()});import Hj from"fs";import uk from"path";function Lj($,X,Z){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:X,outputDir:Z}}function Oj($,X){let Z=uk.join(X,"manifest.json");Hj.writeFileSync(Z,JSON.stringify($,null,2))}function Bj($){let X=uk.join($,"manifest.json");if(!Hj.existsSync(X))return null;try{let Z=Hj.readFileSync(X,"utf-8"),J=JSON.parse(Z);if(J.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${J.version}`),null;return J}catch(Z){return console.warn("[stx] Failed to load manifest:",Z),null}}var fY=()=>{};var ck={};X0(ck,{buildForProduction:()=>dk});import I$ from"fs";import N1 from"path";function mk($,X){let Z=0,J=0;if(!I$.existsSync($))return{copied:Z,bytes:J};I$.mkdirSync(X,{recursive:!0});function Y(Q,G){let K=I$.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(pr.has(W.name))continue;let U=N1.join(Q,W.name),z=N1.join(G,W.name);if(W.isDirectory())I$.mkdirSync(z,{recursive:!0}),Y(U,z);else if(W.isFile()){if(I$.existsSync(z))continue;I$.copyFileSync(U,z),Z++,J+=I$.statSync(z).size}}}return Y($,X),{copied:Z,bytes:J}}async function dk($={}){let X=Date.now(),Z=N1.resolve($.root||process.cwd()),J=N1.resolve(Z,$.outputDir||".output");console.log("[stx build] Starting production build...");let Y={};try{Y=await a0()}catch{}let Q=$.componentsDir??Y.componentsDir??"components",G=$.partialsDir??Y.partialsDir??"partials",K=$.layoutsDir??Y.layoutsDir??"layouts",W=$.publicDir??Y.publicDir??"public",U=Y.app?.head||{},z=Y.app?.colorMode,q=Y.router?.container||"main";if(I$.existsSync(J))I$.rmSync(J,{recursive:!0});let j=[N1.join(J,"public","__stx"),N1.join(J,"public","assets"),N1.join(J,"server","pages"),N1.join(J,"server","fragments")];for(let N of j)I$.mkdirSync(N,{recursive:!0});console.log("[stx build] Discovering routes...");let _=V$(Z),H=["components","layouts","partials"],L=_.filter((N)=>{return!H.some((E)=>N.pattern.startsWith(`/${E}/`)||N.pattern===`/${E}`)});console.log(`[stx build] Found ${L.length} page routes (${_.length-L.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let O=Qj($.debug),B=Gj();await Bun.write(N1.join(J,"public","__stx",O.filename),O.content),await Bun.write(N1.join(J,"public","__stx",B.filename),B.content),console.log(`[stx build] Runtime: ${O.filename} (${(O.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${B.filename} (${(B.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let F=[],V=[];for(let N of L)try{let E=await jj(N.filePath,N.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(F.push(E),E.html=E.html.replace(/runtime\.__STX_HASH__\.js/g,O.filename).replace(/router\.__STX_HASH__\.js/g,B.filename),E.html=$X(E.html,U,{bodyScripts:[`<script src="/__stx/${B.filename}"></script>`],...z&&{colorMode:z}}),z)E.html=s3(E.html,z);if(U.htmlAttrs)E.html=e3(E.html,U.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(E.html)){let b=E.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(b&&b[1]){let u=b[1];E.html=E.html.replace(" "+u,""),E.html=E.html.replace(/<body([^>]*)>/,`<body$1 ${u}>`)}}E.html=E.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),E.html=await i0(E.html),E.fragment=XZ(E.html,q);let S=N.pattern==="/"?"index":N.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),y=N1.join("server","pages",`${S}.compiled.json`),x=N1.join("server","fragments",`${S}.html`);await Bun.write(N1.join(J,y),JSON.stringify(E,null,2)),await Bun.write(N1.join(J,x),E.fragment),V.push({pattern:N.pattern,compiledPath:y,fragmentPath:x,isDynamic:E.hasServerScripts,hasParams:N.pattern.includes(":")||N.pattern.includes("[")}),console.log(`[stx build] \u2713 ${N.pattern}`)}catch(E){console.error(`[stx build] \u2717 ${N.pattern}:`,E instanceof Error?E.message:E)}let w=N1.resolve(Z,W);if(I$.existsSync(w)){let{copied:N,bytes:E}=mk(w,N1.join(J,"public"));if(N>0)console.log(`[stx build] Copied ${N} public asset${N===1?"":"s"} (${(E/1024).toFixed(1)}KB) from ${W}/`)}let A=k7(Z);if(A){let{copied:N,bytes:E}=mk(A,N1.join(J,"public",I7));if(N>0)console.log(`[stx build] Copied ${N} asset${N===1?"":"s"} (${(E/1024).toFixed(1)}KB) from ${ZZ}/`)}let R={runtime:O.filename,router:B.filename},M=Lj(V,R,J);Oj(M,J);let I=Date.now()-X;return console.log(`
18632
+ `),lineMap:Q,sourceLineCount:J.length}}function gk($,X,Z){let J=$.lineMap.get(X);if(!J)return X<=$.sourceLineCount?{line:X,column:Z}:null;let Y=Math.max(0,Z-1-(J.prefixLength??0));return{line:J.line,column:J.column+Y,expression:J.expression}}var Ak,kk,yY,Uj="__stx_interpolated",Rk="__StxElement",Sk="__StxTemplateValue",Ir,kr,Sr,Mk,br,Ek="stx: types for the declared client payload (#1868)",gr="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",Tk="__stxServerScope",Dk="__StxClientPayload",hr,ur,dr;var vY=T(()=>{i1();Ak=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;kk=new Set([":for","x-for","v-for"]),yY=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,Ir=`type ${Sk}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;kr=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],Sr=new RegExp(String.raw`^[ \t]*@(?:${kr.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");Mk=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);br=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore"];hr=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","$errors","$csrf","props","slot"],ur=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;dr=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g});import hk from"path";import{createHash as cr}from"crypto";function lr($={}){let X=new Set;return{context:new Proxy($,{get(J,Y){if(Y in J)return J[Y];if(typeof Y==="string"&&!Y.startsWith("__"))X.add(Y);return},has(J,Y){if(Y in J)return!0;if(typeof Y==="string"&&!Y.startsWith("__"))X.add(Y);return!1}}),accessedKeys:X}}async function jj($,X,Z={}){let J=hk.resolve($),Y=await Bun.file(J).text(),Q=cr("sha256").update(Y).digest("hex").slice(0,16);VG();let G={};try{G=await a0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(Y))!==null){let B=U[1];if(/\bserver\b/.test(B))K.push(U[2])}let z=new Set(K.flatMap((B)=>H8(B))),{context:q}=lr({__filename:J,__dirname:hk.dirname(J),__stx_serverDeclared:z}),j=new Set,_={...D1,...G,...Z,buildMode:"compile",strict:!1},H=await w0(Y,q,J,_,j),L=w4(H),O=wG();return{route:X,sourceFile:$,html:H,fragment:L,placeholders:O,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(j),contentHash:Q,streamTemplates:q.__streamTemplates}}var _j=T(()=>{P1();$1();F3();D7();vY()});import Hj from"fs";import uk from"path";function Lj($,X,Z){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:X,outputDir:Z}}function Oj($,X){let Z=uk.join(X,"manifest.json");Hj.writeFileSync(Z,JSON.stringify($,null,2))}function Bj($){let X=uk.join($,"manifest.json");if(!Hj.existsSync(X))return null;try{let Z=Hj.readFileSync(X,"utf-8"),J=JSON.parse(Z);if(J.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${J.version}`),null;return J}catch(Z){return console.warn("[stx] Failed to load manifest:",Z),null}}var fY=()=>{};var ck={};X0(ck,{buildForProduction:()=>dk});import I$ from"fs";import N1 from"path";function mk($,X){let Z=0,J=0;if(!I$.existsSync($))return{copied:Z,bytes:J};I$.mkdirSync(X,{recursive:!0});function Y(Q,G){let K=I$.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(pr.has(W.name))continue;let U=N1.join(Q,W.name),z=N1.join(G,W.name);if(W.isDirectory())I$.mkdirSync(z,{recursive:!0}),Y(U,z);else if(W.isFile()){if(I$.existsSync(z))continue;I$.copyFileSync(U,z),Z++,J+=I$.statSync(z).size}}}return Y($,X),{copied:Z,bytes:J}}async function dk($={}){let X=Date.now(),Z=N1.resolve($.root||process.cwd()),J=N1.resolve(Z,$.outputDir||".output");console.log("[stx build] Starting production build...");let Y={};try{Y=await a0()}catch{}let Q=$.componentsDir??Y.componentsDir??"components",G=$.partialsDir??Y.partialsDir??"partials",K=$.layoutsDir??Y.layoutsDir??"layouts",W=$.publicDir??Y.publicDir??"public",U=Y.app?.head||{},z=Y.app?.colorMode,q=Y.router?.container||"main";if(I$.existsSync(J))I$.rmSync(J,{recursive:!0});let j=[N1.join(J,"public","__stx"),N1.join(J,"public","assets"),N1.join(J,"server","pages"),N1.join(J,"server","fragments")];for(let N of j)I$.mkdirSync(N,{recursive:!0});console.log("[stx build] Discovering routes...");let _=V$(Z),H=["components","layouts","partials"],L=_.filter((N)=>{return!H.some((E)=>N.pattern.startsWith(`/${E}/`)||N.pattern===`/${E}`)});console.log(`[stx build] Found ${L.length} page routes (${_.length-L.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let O=Qj($.debug),B=Gj();await Bun.write(N1.join(J,"public","__stx",O.filename),O.content),await Bun.write(N1.join(J,"public","__stx",B.filename),B.content),console.log(`[stx build] Runtime: ${O.filename} (${(O.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${B.filename} (${(B.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let F=[],V=[];for(let N of L)try{let E=await jj(N.filePath,N.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(F.push(E),E.html=E.html.replace(/runtime\.__STX_HASH__\.js/g,O.filename).replace(/router\.__STX_HASH__\.js/g,B.filename),E.html=$X(E.html,U,{bodyScripts:[`<script src="/__stx/${B.filename}"></script>`],...z&&{colorMode:z}}),z)E.html=s3(E.html,z);if(U.htmlAttrs)E.html=e3(E.html,U.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(E.html)){let b=E.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(b&&b[1]){let u=b[1];E.html=E.html.replace(" "+u,""),E.html=E.html.replace(/<body([^>]*)>/,`<body$1 ${u}>`)}}E.html=E.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),E.html=await i0(E.html),E.fragment=XZ(E.html,q);let S=N.pattern==="/"?"index":N.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),x=N1.join("server","pages",`${S}.compiled.json`),y=N1.join("server","fragments",`${S}.html`);await Bun.write(N1.join(J,x),JSON.stringify(E,null,2)),await Bun.write(N1.join(J,y),E.fragment),V.push({pattern:N.pattern,compiledPath:x,fragmentPath:y,isDynamic:E.hasServerScripts,hasParams:N.pattern.includes(":")||N.pattern.includes("[")}),console.log(`[stx build] \u2713 ${N.pattern}`)}catch(E){console.error(`[stx build] \u2717 ${N.pattern}:`,E instanceof Error?E.message:E)}let w=N1.resolve(Z,W);if(I$.existsSync(w)){let{copied:N,bytes:E}=mk(w,N1.join(J,"public"));if(N>0)console.log(`[stx build] Copied ${N} public asset${N===1?"":"s"} (${(E/1024).toFixed(1)}KB) from ${W}/`)}let A=k7(Z);if(A){let{copied:N,bytes:E}=mk(A,N1.join(J,"public",I7));if(N>0)console.log(`[stx build] Copied ${N} asset${N===1?"":"s"} (${(E/1024).toFixed(1)}KB) from ${ZZ}/`)}let R={runtime:O.filename,router:B.filename},M=Lj(V,R,J);Oj(M,J);let I=Date.now()-X;return console.log(`
18633
18633
  [stx build] Done in ${I}ms \u2014 ${F.length} pages compiled`),{pageCount:F.length,assets:R,outputDir:J,duration:I}}var pr;var Fj=T(()=>{SY();F5();Kj();_j();fY();L5();XX();D7();H$();$1();pr=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"])});var pk={};X0(pk,{buildApp:()=>lk});import ir from"path";async function lk($={}){let X=performance.now(),Z=$.root||process.cwd(),J=await a0(),Y=J.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${Y.toUpperCase()}${J.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let Q,G;if(Y==="ssg"){let{generateStaticSite:W}=await Promise.resolve().then(() => (wk(),Vk));Q=await W({pagesDir:ir.join(J.root||".",J.pagesDir||J.build?.pagesDir||"pages"),publicDir:J.publicDir||J.build?.publicDir||"public",outputDir:J.build?.outputDir||"dist",generate404:J.build?.generate404??!0,minify:J.build?.minify??!0,cleanOutput:J.build?.cleanOutput??!0,...$.ssg})}else{let{buildForProduction:W}=await Promise.resolve().then(() => (Fj(),ck));G=await W({outputDir:".output",debug:$.debug,...$.ssr})}let K=Math.round(performance.now()-X);return{mode:Y,ssg:Q,ssr:G,duration:K}}var Vj=T(()=>{$1()});import gY from"path";async function rr($){let X=performance.now(),Z=await a0($),J=$||Z.root||process.cwd(),Y=[Z.build?.pagesDir||Z.pagesDir||"pages",Z.componentsDir||"components",Z.layoutsDir||"layouts",Z.partialsDir||"partials"].map((K)=>gY.resolve(J,K)),Q=[],G=0;for(let K of Y){let W=await nk(K);for(let U of W){G++;let z=await Bun.file(U).text();if(ik.test(z))Q.push(gY.relative(J,U))}}return{mode:Q.length>0?"ssr":"ssg",serverScriptFiles:Q,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-X)}}async function ar($){let X=await a0($),Z=$||X.root||process.cwd(),J=gY.resolve(Z,X.componentsDir||"components"),Y=[],Q=await nk(J);for(let G of Q){let K=await Bun.file(G).text(),W=ik.test(K),U=nr.test(K)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(K)&&!W;if(W&&U){let z=gY.relative(Z,G);Y.push({file:z,message:`Component "${z}" has both <script server> and <script client>. `+"Components should be server OR client \u2014 compose them via props/slots."})}}return Y}async function nk($){let X=[];try{let Z=new Bun.Glob("**/*.stx");for await(let J of Z.scan({cwd:$,absolute:!0}))X.push(J)}catch{}return X}var ik,nr;var rk=T(()=>{$1();ik=/<script\b[^>]*\bserver\b/i,nr=/<script\b[^>]*\bclient\b/i});function wj($){let X=new Map,Z=/@(\w+)/g,J,Y=1,Q=0;while((J=Z.exec($))!==null){let G=J[1],K=$.slice(Q,J.index);Y+=(K.match(/\n/g)||[]).length,Q=J.index;let W=J.index-$.lastIndexOf(`
18634
18634
  `,J.index-1);if(sk.includes(G)){let U=X.get(G);if(U)U.count++,U.locations.push({line:Y,column:W});else X.set(G,{name:G,count:1,locations:[{line:Y,column:W}]})}}return Array.from(X.values())}function ok($,X=[]){let Z=wj($),J=new Set(Z.map((Y)=>Y.name));for(let Y of X)J.add(Y);for(let Y of Array.from(J))if(!Y.startsWith("end"))J.add(`end${Y}`);return sk.filter((Y)=>!J.has(Y))}function tk($){let X=[],Z={conditionals:["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","isset","endisset"],loops:["for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty"],includes:["include","includeIf","includeWhen","includeFirst","once","endonce","extends","section","endsection","yield","parent","push","endpush","prepend","endprepend","stack"],components:["component","endcomponent","slot","endslot","props"],auth:["auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole"],forms:["csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file"],i18n:["translate","lang","choice"],seo:["meta","title","seo","jsonld","canonical","robots","sitemap"]},J=new Set;for(let Q of $)for(let[G,K]of Object.entries(Z))if(K.includes(Q)){J.add(G);break}for(let Q of J)X.push(`import { process${or(Q)} } from './${Q}'`);let Y=$.filter((Q)=>!Q.startsWith("end")).map((Q)=>` '${Q}': true`).join(`,
18635
18635
  `);return`// Tree-shaken directive bundle
@@ -20344,7 +20344,7 @@ describe('Example', () => {
20344
20344
  </footer>
20345
20345
  @yield('scripts')
20346
20346
  </body>
20347
- </html>`}function Io(){return"<!-- Hero section -->"}function ko(){return"<!-- Features -->"}function So(){return"<!-- Pricing -->"}function Co(){return"<!-- Button -->"}function _Z($){if(!jZ($))oj($,{recursive:!0})}function Po(){if(jZ("bun.lockb"))return"bun";if(jZ("pnpm-lock.yaml"))return"pnpm";if(jZ("yarn.lock"))return"yarn";return"bun"}function tj($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function bo($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function V8($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var as;var CC=T(()=>{as={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}}});var{serve:yo}=globalThis.Bun;import HZ from"fs";import B6 from"path";function xo($,X=200,Z={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Z}})}async function PC($={}){let{port:X=3000,root:Z=".",stxOptions:J={},watch:Y=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,z=B6.resolve(Z),q=new Map;async function j(F){let V=HZ.statSync(F),w=`${F}:${V.mtimeMs}`,A=q.get(w);if(A)return A.content;for(let P of q.keys())if(P.startsWith(`${F}:`)&&P!==w)q.delete(P);let R=await Bun.file(F).text(),M=R,I=u$(R);if(I)M=I.content.trim();let N=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[],C=[],S;while((S=N.exec(R))!==null){let P=S[1],v=S[2],d=S[0];if(P.includes("server"))C.push(v);else E.push(d)}let y=R.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],x=M.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),b={__filename:F,__dirname:B6.dirname(F)};for(let P of C)await g0(P,b,F);let c=await w0(x,b,F,J,new Set);if(y.length>0){let P=y.join(`
20347
+ </html>`}function Io(){return"<!-- Hero section -->"}function ko(){return"<!-- Features -->"}function So(){return"<!-- Pricing -->"}function Co(){return"<!-- Button -->"}function _Z($){if(!jZ($))oj($,{recursive:!0})}function Po(){if(jZ("bun.lockb"))return"bun";if(jZ("pnpm-lock.yaml"))return"pnpm";if(jZ("yarn.lock"))return"yarn";return"bun"}function tj($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toUpperCase())}function bo($){return $.replace(/[-_\s]+(.)?/g,(X,Z)=>Z?Z.toUpperCase():"").replace(/^./,(X)=>X.toLowerCase())}function V8($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var as;var CC=T(()=>{as={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}}});var{serve:yo}=globalThis.Bun;import HZ from"fs";import B6 from"path";function xo($,X=200,Z={}){return new Response($,{status:X,headers:{"Content-Type":"text/html; charset=utf-8",...Z}})}async function PC($={}){let{port:X=3000,root:Z=".",stxOptions:J={},watch:Y=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,z=B6.resolve(Z),q=new Map;async function j(F){let V=HZ.statSync(F),w=`${F}:${V.mtimeMs}`,A=q.get(w);if(A)return A.content;for(let P of q.keys())if(P.startsWith(`${F}:`)&&P!==w)q.delete(P);let R=await Bun.file(F).text(),M=R,I=u$(R);if(I)M=I.content.trim();let N=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[],C=[],S;while((S=N.exec(R))!==null){let P=S[1],v=S[2],d=S[0];if(P.includes("server"))C.push(v);else E.push(d)}let x=R.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],y=M.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),b={__filename:F,__dirname:B6.dirname(F)};for(let P of C)await g0(P,b,F);let c=await w0(y,b,F,J,new Set);if(x.length>0){let P=x.join(`
20348
20348
  `);if(c.match(/(<\/head>)/i))c=c.replace(/(<\/head>)/i,`${P}
20349
20349
  $1`)}if(E.length>0){let{interpolateScriptsInTemplate:P}=await Promise.resolve().then(() => (w1(),A3)),v=P(E.join(`
20350
20350
  `),b);if(c.match(/(<\/body>)/i))c=c.replace(/(<\/body>)/i,`${v}
@@ -20365,7 +20365,7 @@ export {}
20365
20365
  `;continue}if(O==="/"&&q[L+1]==="*"){L+=2;while(L<q.length&&!(q[L]==="*"&&q[L+1]==="/"))L++;L++;continue}j+=O}return j.replace(/,(\s*[}\]])/g,"$1")},Y=new Set,Q=Z,G,K,W=Z;while(Q&&!Y.has(Q)){Y.add(Q);let q;try{q=JSON.parse(J(lo(Q,"utf8")))}catch{break}let j=q?.compilerOptions??{};if(!G&&j.paths&&typeof j.paths==="object")G=j.paths,W=Q;if(!K&&typeof j.baseUrl==="string")K=H1.resolve(H1.dirname(Q),j.baseUrl);if(G&&K)break;Q=typeof q?.extends==="string"?H1.resolve(H1.dirname(Q),q.extends.endsWith(".json")?q.extends:`${q.extends}.json`):void 0}if(!G)return{};let U=K??H1.dirname(W),z={};for(let[q,j]of Object.entries(G)){if(!Array.isArray(j))continue;z[q]=j.map((_)=>typeof _==="string"&&!H1.isAbsolute(_)?H1.resolve(U,_):_)}return{paths:z}}async function uC($,X={}){let Z=X.client!==!1,J=X.server!==!1,Y=X.templates!==!1,Q=new Map,G=new Map,K=[],W=0,U=0,z=Z_();for(let P of $){let v=await Bun.file(P).text(),d=L8(v).filter((W0)=>{if(W0.kind==="server")return J;return Z}),a=L8(v).filter((W0)=>W0.kind==="server").map((W0)=>W0.code).join(`
20366
20366
  `);if(Z&&a){let W0=d.filter((z0)=>z0.kind!=="server"),U0=[...new Set(W0.flatMap((z0)=>vk(a,z0.code)))];if(U0.length>0)G.set(P,{names:U0,line:W0[0].startLine,kind:W0[0].kind})}let t=H1.dirname(H1.resolve(P)),k0=Y?fk(v,{runtimeGlobals:!z,originDir:t}):null,o=k0?[...k0.lineMap.values()].filter((W0)=>W0.expression).length:0;if(d.length===0&&o===0)continue;if(K.push(P),W+=d.length,U+=o,d.forEach((W0,U0)=>{Q.set(nY(P,W0.kind,U0),{source:X_(W0,a,t),origin:P,kind:W0.kind})}),k0&&o>0)Q.set(nY(P,"template",0),{source:k0.text,origin:P,kind:"template",virtual:k0})}if(Q.size===0)return{diagnostics:[],checkedFiles:K,blockCount:0,expressionCount:0};let q=(X.extraLibs??[]).map((P)=>H1.resolve(P));if(z)q.push(z);let j=`${n0()}/typecheck/__stx_globals.d.ts`,_=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",zj(),...z?[]:["declare const window: any",...C1.map((P)=>`declare const ${P}: any`)],po($),no(await qU())].filter(Boolean).join(`
20367
20367
  `),H=`${n0()}/typecheck`;await Bun.$`rm -rf ${H}`.quiet().nothrow(),await Bun.$`mkdir -p ${H}`.quiet().nothrow(),await Bun.write(j,_);let L=new Map,O=0;for(let[P,v]of Q){let d=`${O++}_${P.replace(/[^\w.-]+/g,"_")}`;await Bun.write(`${H}/${d}`,v.source),L.set(d,v)}let B={target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,allowJs:!0,esModuleInterop:!0,resolveJsonModule:!0,lib:["ESNext","DOM","DOM.Iterable"],types:[],...so($.length>0?H1.dirname(H1.resolve($[0])):process.cwd()),...X.compilerOptions??{}},F=async(P,v)=>{let d=`${H}/tsconfig${v===1?"":`.${v}`}.json`;await Bun.write(d,JSON.stringify({compilerOptions:B,files:P.map((t)=>`${H}/${t}`).concat(j,...q)},null,2));let a=Bun.spawnSync(["bun","x","tsc","-p",d,"--pretty","false"],{stdout:"pipe",stderr:"pipe"});return{output:new TextDecoder().decode(a.stdout)+new TextDecoder().decode(a.stderr),exitCode:a.exitCode??0}},V=await F([...L.keys()],1),w=V.output,A=[],R=V.exitCode,M=0,I=new Set(q.map((P)=>P.split("/").pop())),N=0,E=new Set,C=(P)=>{for(let v of P.split(`
20368
- `)){let d=v.match(ro);if(!d)continue;if(M++,I.has(d[1].split("/").pop()))N++;let[,a,t,k0,o,W0,U0]=d,z0=a.split("/").pop(),s0=L.get(z0);if(!s0)continue;if(ao(Number(W0)))E.add(z0);let G0=Number(t),l=Number(k0),$0;if(s0.virtual){let L0=gk(s0.virtual,G0,l);if(!L0?.expression)continue;if(Number(W0)===2774)continue;G0=L0.line,l=L0.column,$0=L0.expression.code.trim()}A.push({file:s0.origin,line:G0,column:l,code:Number(W0),message:U0,category:o==="error"?"error":"warning",blockKind:s0.kind,expression:$0})}};C(w);let S=M,y=N;if(E.size>0&&E.size<L.size){let P=[...L.keys()].filter((v)=>!E.has(v));C((await F(P,2)).output)}if(Z)for(let[P,v]of G){if(v.names.length===0)continue;A.push({file:P,line:v.line,column:1,code:0,message:`${v.names.length===1?"1 value reaches":`${v.names.length} values reach`} this block on the implicit bridge and ${v.names.length===1?"is":"are"} untyped: ${v.names.join(", ")}. Declare them with defineClientPayload({ ${v.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:v.kind})}let x=new Set,b=A.filter((P)=>{let v=`${P.file}:${P.line}:${P.column}:${P.code}:${P.message}`;if(x.has(v))return!1;return x.add(v),!0});b.sort((P,v)=>P.file.localeCompare(v.file)||P.line-v.line||P.column-v.column);let u=y>0&&b.length===0,c=u||R!==0&&S===0?`${u?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${R} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
20368
+ `)){let d=v.match(ro);if(!d)continue;if(M++,I.has(d[1].split("/").pop()))N++;let[,a,t,k0,o,W0,U0]=d,z0=a.split("/").pop(),s0=L.get(z0);if(!s0)continue;if(ao(Number(W0)))E.add(z0);let G0=Number(t),l=Number(k0),$0;if(s0.virtual){let L0=gk(s0.virtual,G0,l);if(!L0?.expression)continue;if(Number(W0)===2774)continue;G0=L0.line,l=L0.column,$0=L0.expression.code.trim()}A.push({file:s0.origin,line:G0,column:l,code:Number(W0),message:U0,category:o==="error"?"error":"warning",blockKind:s0.kind,expression:$0})}};C(w);let S=M,x=N;if(E.size>0&&E.size<L.size){let P=[...L.keys()].filter((v)=>!E.has(v));C((await F(P,2)).output)}if(Z)for(let[P,v]of G){if(v.names.length===0)continue;A.push({file:P,line:v.line,column:1,code:0,message:`${v.names.length===1?"1 value reaches":`${v.names.length} values reach`} this block on the implicit bridge and ${v.names.length===1?"is":"are"} untyped: ${v.names.join(", ")}. Declare them with defineClientPayload({ ${v.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:v.kind})}let y=new Set,b=A.filter((P)=>{let v=`${P.file}:${P.line}:${P.column}:${P.code}:${P.message}`;if(y.has(v))return!1;return y.add(v),!0});b.sort((P,v)=>P.file.localeCompare(v.file)||P.line-v.line||P.column-v.column);let u=x>0&&b.length===0,c=u||R!==0&&S===0?`${u?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${R} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
20369
20369
  ${w.trim().split(`
20370
20370
  `).slice(0,12).join(`
20371
20371
  `)||"(no output)"}`:void 0;return{diagnostics:b,checkedFiles:K,blockCount:W,expressionCount:U,failure:c}}function mC($){return $.map((X)=>{let Z=X.blockKind==="template"?`[template: ${X.expression??""}]`:`[${X.blockKind==="plain"?"<script>":`<script ${X.blockKind}>`}]`;return`${X.file}:${X.line}:${X.column} ${X.category} TS${X.code} ${X.message} ${Z}`}).join(`
@@ -22334,7 +22334,7 @@ ${O}`}if(H=await j4(H),K.forEach((L)=>J.add(L)),Z.cache&&Z.cachePath){if(await T
22334
22334
  <h1>Something went wrong</h1>
22335
22335
  <p>An internal error occurred. Please try again later.</p>
22336
22336
  </body>
22337
- </html>`,loader:"html"}}})}}});var{serve:fe}=globalThis.Bun;import S$ from"fs";import l1 from"path";async function yZ($,X={}){let Z=X.port||3000,J=X.watch!==!1,Y=X.hotReload!==!1&&J,Q=null,G=X.hmrPort||Z+1,K=l1.resolve($);if(!S$.existsSync(K))return console.error(`${D.red}Error: File not found: ${D.bright}${K}${D.reset}`),!1;if(K.endsWith(".md"))return UY(K,X);else if(!K.endsWith(".stx"))return console.error(`${D.red}Error: Unsupported file type: ${D.bright}${K}${D.reset}. Only .stx and .md files are supported.`),!1;let W=n0(process.cwd(),"output");S$.mkdirSync(W,{recursive:!0}),console.log(`${D.blue}Building ${D.bright}${$}${D.reset}...`);let U=null,z=async()=>{try{let F={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(M)=>{return{path:M.path,external:!0}})}},V=await Bun.build({entrypoints:[K],outdir:W,plugins:[F,d7],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!V.success)return console.error(`${D.red}Build failed:${D.reset}`,V.logs),!1;let w=V.outputs.find((R)=>R.path.endsWith(".html"));if(!w)return console.error(`${D.red}No HTML output found${D.reset}`),!1;return U=await Bun.file(w.path).text(),!0}catch(F){return console.error(`${D.red}Error building stx file:${D.reset}`,F),!1}};if(!await z())return!1;let j=l1.dirname(K);await s8(j);let _=Z;try{if(_=await U6(Z),_!==Z)console.log(`${D.yellow}Port ${Z} is busy, using port ${_} instead${D.reset}`)}catch{return console.error(`${D.red}Could not find an available port${D.reset}`),!1}if(Y){let F=X.hmrPort||_+1;Q=dX({wsPort:F,verbose:!1}),G=Q.start(F)}let H={},L=null;try{let{loadStxConfig:F}=await Promise.resolve().then(() => (s$(),_8)),V=await F();if(V?.apiRouter)L=V?.apiRouter,console.log(`${D.blue}Using custom router for API handling${D.reset}`);if(V?.apiRoutes){H=V.apiRoutes;let w=Object.keys(H).length;if(w>0)console.log(`${D.blue}Loaded ${D.bright}${w} API route${w>1?"s":""}${D.reset}`)}if(V?.broadcasting?.enabled)try{let{startBroadcasting:w,loadChannels:A}=await Promise.resolve().then(() => (uY(),Nj)),R=V.broadcasting;await w(R);let M=R.port??6001;console.log(`${D.magenta}Broadcasting on ${D.cyan}ws://localhost:${M}/ws${D.reset}`);let I=l1.join(process.cwd(),"channels.ts");if(S$.existsSync(I))try{let N=await A(I);console.log(`${D.blue}Loaded ${D.bright}${N} broadcast channel${N!==1?"s":""}${D.blue} from channels.ts${D.reset}`)}catch(N){console.warn(`${D.yellow}Failed to load channels.ts: ${N.message}${D.reset}`)}}catch(w){console.warn(`${D.yellow}Broadcasting failed to start: ${w.message}${D.reset}`)}}catch{}if(console.log(`${D.blue}Starting server on ${D.cyan}http://localhost:${_}/${D.reset}...`),Y)console.log(`${D.magenta}Hot reload enabled on ws://localhost:${G}${D.reset}`);let O=fe({port:_,async fetch(F){return O8(F,await(async()=>{let V=new URL(F.url);if(L)try{let I=await L.handleRequest(F);if(I.status!==404)return I}catch{}if(H[V.pathname])try{return await H[V.pathname](F)}catch(I){return new Response(JSON.stringify({error:I.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(V.pathname==="/")return(async()=>{let N=await i0(U||"");if(Y)N=r$(N,G);if(X.native)if(N.includes("<head>"))N=N.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(N.includes("<html"))N=N.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else N="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+N;if(X.titlebarHidden)if(N.includes("<head>"))N=N.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(N.includes("<html"))N=N.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else N=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${N}`;return N})().then((N)=>new Response(N,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let w=l1.join(W,V.pathname);if(S$.existsSync(w)&&S$.statSync(w).isFile()){let I=Bun.file(w),N=l1.extname(w).toLowerCase(),E="text/plain";if(N===".ts"||N===".tsx"){let C=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),S=await I.text(),y=C.transformSync(S);return new Response(y,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(I,{headers:{"Content-Type":E}})}let A=l1.dirname(K),R=l1.join(A,V.pathname);if(S$.existsSync(R)&&S$.statSync(R).isFile()){let I=Bun.file(R),N=l1.extname(R).toLowerCase(),E="text/plain";if(N===".ts"||N===".tsx"){let C=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),S=await I.text(),y=C.transformSync(S);return new Response(y,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(I,{headers:{"Content-Type":E}})}let M=l1.join(process.cwd(),"public",V.pathname);if(S$.existsSync(M)&&S$.statSync(M).isFile()){let I=Bun.file(M),N=l1.extname(M).toLowerCase(),E="application/octet-stream";if(N===".ts"||N===".tsx"){let C=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),S=await I.text(),y=C.transformSync(S);return new Response(y,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(I,{headers:{"Content-Type":E}})}return new Response("Not Found",{status:404})})())},error(F){return new Response(`<pre>${F}
22337
+ </html>`,loader:"html"}}})}}});var{serve:fe}=globalThis.Bun;import S$ from"fs";import l1 from"path";async function yZ($,X={}){let Z=X.port||3000,J=X.watch!==!1,Y=X.hotReload!==!1&&J,Q=null,G=X.hmrPort||Z+1,K=l1.resolve($);if(!S$.existsSync(K))return console.error(`${D.red}Error: File not found: ${D.bright}${K}${D.reset}`),!1;if(K.endsWith(".md"))return UY(K,X);else if(!K.endsWith(".stx"))return console.error(`${D.red}Error: Unsupported file type: ${D.bright}${K}${D.reset}. Only .stx and .md files are supported.`),!1;let W=n0(process.cwd(),"output");S$.mkdirSync(W,{recursive:!0}),console.log(`${D.blue}Building ${D.bright}${$}${D.reset}...`);let U=null,z=async()=>{try{let F={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(M)=>{return{path:M.path,external:!0}})}},V=await Bun.build({entrypoints:[K],outdir:W,plugins:[F,d7],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!V.success)return console.error(`${D.red}Build failed:${D.reset}`,V.logs),!1;let w=V.outputs.find((R)=>R.path.endsWith(".html"));if(!w)return console.error(`${D.red}No HTML output found${D.reset}`),!1;return U=await Bun.file(w.path).text(),!0}catch(F){return console.error(`${D.red}Error building stx file:${D.reset}`,F),!1}};if(!await z())return!1;let j=l1.dirname(K);await s8(j);let _=Z;try{if(_=await U6(Z),_!==Z)console.log(`${D.yellow}Port ${Z} is busy, using port ${_} instead${D.reset}`)}catch{return console.error(`${D.red}Could not find an available port${D.reset}`),!1}if(Y){let F=X.hmrPort||_+1;Q=dX({wsPort:F,verbose:!1}),G=Q.start(F)}let H={},L=null;try{let{loadStxConfig:F}=await Promise.resolve().then(() => (s$(),_8)),V=await F();if(V?.apiRouter)L=V?.apiRouter,console.log(`${D.blue}Using custom router for API handling${D.reset}`);if(V?.apiRoutes){H=V.apiRoutes;let w=Object.keys(H).length;if(w>0)console.log(`${D.blue}Loaded ${D.bright}${w} API route${w>1?"s":""}${D.reset}`)}if(V?.broadcasting?.enabled)try{let{startBroadcasting:w,loadChannels:A}=await Promise.resolve().then(() => (uY(),Nj)),R=V.broadcasting;await w(R);let M=R.port??6001;console.log(`${D.magenta}Broadcasting on ${D.cyan}ws://localhost:${M}/ws${D.reset}`);let I=l1.join(process.cwd(),"channels.ts");if(S$.existsSync(I))try{let N=await A(I);console.log(`${D.blue}Loaded ${D.bright}${N} broadcast channel${N!==1?"s":""}${D.blue} from channels.ts${D.reset}`)}catch(N){console.warn(`${D.yellow}Failed to load channels.ts: ${N.message}${D.reset}`)}}catch(w){console.warn(`${D.yellow}Broadcasting failed to start: ${w.message}${D.reset}`)}}catch{}if(console.log(`${D.blue}Starting server on ${D.cyan}http://localhost:${_}/${D.reset}...`),Y)console.log(`${D.magenta}Hot reload enabled on ws://localhost:${G}${D.reset}`);let O=fe({port:_,async fetch(F){return O8(F,await(async()=>{let V=new URL(F.url);if(L)try{let I=await L.handleRequest(F);if(I.status!==404)return I}catch{}if(H[V.pathname])try{return await H[V.pathname](F)}catch(I){return new Response(JSON.stringify({error:I.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(V.pathname==="/")return(async()=>{let N=await i0(U||"");if(Y)N=r$(N,G);if(X.native)if(N.includes("<head>"))N=N.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(N.includes("<html"))N=N.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else N="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+N;if(X.titlebarHidden)if(N.includes("<head>"))N=N.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(N.includes("<html"))N=N.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else N=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${N}`;return N})().then((N)=>new Response(N,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let w=l1.join(W,V.pathname);if(S$.existsSync(w)&&S$.statSync(w).isFile()){let I=Bun.file(w),N=l1.extname(w).toLowerCase(),E="text/plain";if(N===".ts"||N===".tsx"){let C=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),S=await I.text(),x=C.transformSync(S);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(I,{headers:{"Content-Type":E}})}let A=l1.dirname(K),R=l1.join(A,V.pathname);if(S$.existsSync(R)&&S$.statSync(R).isFile()){let I=Bun.file(R),N=l1.extname(R).toLowerCase(),E="text/plain";if(N===".ts"||N===".tsx"){let C=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),S=await I.text(),x=C.transformSync(S);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(I,{headers:{"Content-Type":E}})}let M=l1.join(process.cwd(),"public",V.pathname);if(S$.existsSync(M)&&S$.statSync(M).isFile()){let I=Bun.file(M),N=l1.extname(M).toLowerCase(),E="application/octet-stream";if(N===".ts"||N===".tsx"){let C=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),S=await I.text(),x=C.transformSync(S);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(I,{headers:{"Content-Type":E}})}return new Response("Not Found",{status:404})})())},error(F){return new Response(`<pre>${F}
22338
22338
  ${F.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
22339
22339
  ${D.blue}stx${D.reset} ${D.green}${process.env.stx_VERSION||"v0.0.10"}${D.reset} ${D.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${D.reset}`),console.log(`
22340
22340
  ${D.bright}\u2192 ${D.cyan}http://localhost:${_}/${D.reset}`),console.log(`
@@ -22510,12 +22510,12 @@ ${H.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
22510
22510
  ${D.blue}stx${D.reset} ${D.green}${process.env.stx_VERSION||"v0.0.10"}${D.reset} ${D.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${D.reset}`),console.log(`
22511
22511
  ${D.bright}\u2192 ${D.cyan}http://localhost:${z}/${D.reset}`),console.log(`
22512
22512
  ${D.yellow}Routes:${D.reset}`);let j=new Set(K.map((H)=>H.routeTemplate)),_=Object.entries(G).filter(([H])=>!j.has(H)).sort(([H],[L])=>H.localeCompare(L)).map(([H,L])=>({route:H==="/"?"/":H,filePath:g1.relative(process.cwd(),L.filePath),fileType:L.fileType}));for(let H of K){let L=H.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");_.push({route:L,filePath:g1.relative(process.cwd(),H.filePath),fileType:"stx"})}if(_.sort((H,L)=>H.route.localeCompare(L.route)),_.forEach((H,L)=>{let B=L===_.length-1?"\u2514\u2500 ":"\u251C\u2500 ",F=H.fileType==="md"?`${D.magenta}(markdown)${D.reset}`:"";console.log(` ${D.green}${B}${H.route}${D.reset} \u2192 ${D.bright}${H.filePath}${D.reset} ${F}`)}),console.log(`
22513
- Press ${D.cyan}h${D.reset} + ${D.cyan}Enter${D.reset} to show shortcuts`),q6(q.url.toString(),()=>{if(J)w6.watch(Q,{recursive:!0}).close();q.stop()}),J){console.log(`${D.blue}Watching for changes...${D.reset}`);let H=w6.watch(Q,{recursive:!0},async(L,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${D.yellow}File ${D.bright}${O}${D.yellow} changed, rebuilding...${D.reset}`),s4.clear(),c$(),await W()});process.on("SIGINT",()=>{H.close(),q.stop(),process.exit(0)})}return!0}function db($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var cb=T(()=>{v5();$1();_5();z$();AQ();b0();h1();gX()});var{serve:he}=globalThis.Bun;import p1 from"fs";import c0 from"path";async function lb($){try{return TY(await Bun.file($).text())}catch{return}}function gH($){let X=Bun.file($),Z=c0.extname($).toLowerCase(),J={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},Q=[".js",".css",".json"].includes(Z)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":J[Z]||"application/octet-stream",...Q}})}async function vZ($=".",X={}){let Z=X.port||3000,J=X.watch!==!1,Y=X.hotReload!==!1&&J,Q=null,G=X.hmrPort||Z+1,K=c0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (s$(),_8)),U=await W(K),z=U.root&&U.root!=="."?c0.join(K,U.root):K,q=X.pagesDir||U.pagesDir||"pages",j=c0.join(z,q);if(!p1.existsSync(j))return console.error(`${D.red}Error: No '${q}' directory found${D.reset}`),console.log(`${D.dim}Looked in: ${D.bright}${j}${D.reset}`),console.log(`${D.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${D.reset}`),console.log(`${D.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${D.reset}`),console.log(`${D.dim}Starting fresh? Create ${q}/index.stx for the homepage.${D.reset}`),!1;let _=V$(z,{pagesDir:q});if(_.length===0)return console.error(`${D.red}Error: No page files found in ${D.bright}${j}${D.reset}`),!1;console.log(`${D.blue}Found ${D.bright}${_.length}${D.blue} routes${D.reset}`);let H=U?._pluginPageDirs||[],L=[];for(let{dir:P,prefix:v}of H)if(p1.existsSync(P)){let d=V$(c0.dirname(P),{pagesDir:c0.basename(P)});for(let a of d){let t=v==="/"?a.pattern:`${v}${a.pattern==="/"?"":a.pattern}`;L.push({route:{...a,pattern:t},prefix:v})}if(d.length>0)console.log(`${D.blue}Plugin pages: ${D.bright}${d.length}${D.blue} routes at ${D.cyan}${v}${D.reset}`)}let O=new Map,B=null,F=null;if(X.stxOptions?.shell!==!1){if(F=await sq(K,X.stxOptions?.shell),F){if(B=await kY(F,X.stxOptions||{}),B)console.log(`${D.blue}Using app shell: ${D.bright}${c0.relative(K,F)}${D.reset} ${D.dim}(deprecated: use layouts/default.stx instead)${D.reset}`)}}D4(),await k4(K);let V=I4();if(V.length>0)console.log(`${D.blue}Loaded ${D.bright}${V.length}${D.blue} middleware: ${D.dim}${V.join(", ")}${D.reset}`);let w={},A=null;try{let{loadStxConfig:P}=await Promise.resolve().then(() => (s$(),_8)),v=await P(K);if(v?.apiRouter)A=v?.apiRouter,console.log(`${D.blue}Using custom router for API handling${D.reset}`);if(v?.apiRoutes){w=v.apiRoutes;let d=Object.keys(w).length;if(d>0)console.log(`${D.blue}Loaded ${D.bright}${d} API route${d>1?"s":""}${D.reset}`)}if(v?.broadcasting?.enabled)try{let{startBroadcasting:d,loadChannels:a}=await Promise.resolve().then(() => (uY(),Nj)),t=v.broadcasting;await d(t);let k0=t.port??6001;console.log(`${D.magenta}Broadcasting on ${D.cyan}ws://localhost:${k0}/ws${D.reset}`);let o=c0.join(process.cwd(),"channels.ts");if(p1.existsSync(o))try{let W0=await a(o);console.log(`${D.blue}Loaded ${D.bright}${W0} broadcast channel${W0!==1?"s":""}${D.blue} from channels.ts${D.reset}`)}catch(W0){console.warn(`${D.yellow}Failed to load channels.ts: ${W0.message}${D.reset}`)}}catch(d){console.warn(`${D.yellow}Broadcasting failed to start: ${d.message}${D.reset}`)}}catch{}let R=n0(K,"output");p1.mkdirSync(R,{recursive:!0});let M=new Map,I=new Set,N=async(P)=>{let v=x8(j,P);if(!v)return null;try{let d=await Bun.build({entrypoints:[v],outdir:R,plugins:[d7],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!d.success)return null;let a=d.outputs.find((t)=>t.path.endsWith(".html"));if(!a)return null;return await Bun.file(a.path).text()}catch{return null}},E=async(P,v)=>{try{let{processDirectives:d,extractVariables:a,defaultConfig:t,loadStxConfig:k0,injectRouterScript:o}=await Promise.resolve().then(() => (s$(),_8)),{checkCache:W0,cacheTemplate:U0,readFileCached:z0,templateCache:s0}=await Promise.resolve().then(() => (e6(),D5)),G0=await k0(K),l=(V0)=>{if(!V0)return V0;if(c0.isAbsolute(V0))return V0;return c0.resolve(K,V0)},$0={...t,...G0,...X.stxOptions,autoShell:!0};if(X.debugDirectives)$0.debug=!0;$0.partialsDir=l($0.partialsDir),$0.componentsDir=l($0.componentsDir),$0.layoutsDir=l($0.layoutsDir),$0.storesDir=l($0.storesDir||"stores"),$0.cachePath=l($0.cachePath)??n0(K,"cache");let L0=!v&&!X.profile,O0=$0.cache!==!1;if(O0&&L0){let V0=s0.get(P.filePath);if(V0)try{if((await p1.promises.stat(P.filePath)).mtime.getTime()<=V0.mtime){let j0=!0;for(let h0 of V0.dependencies){if(!p1.existsSync(h0)){j0=!1;break}if((await p1.promises.stat(h0)).mtime.getTime()>V0.mtime){j0=!1;break}}if(j0){let h0=V0.output;if(B)h0=w4(h0,{preserveHead:!0});return{route:P,content:h0,status:await lb(P.filePath)}}}}catch{}let o0=await W0(P.filePath,$0);if(o0){let q1=o0;if(B)q1=w4(q1,{preserveHead:!0});return{route:P,content:q1,status:await lb(P.filePath)}}}let f=O0?await z0(P.filePath):await Bun.file(P.filePath).text(),n=TY(f),{classifyAllScripts:q0}=await Promise.resolve().then(() => (s$(),_8)),e=q0(f),p=e.server.map((V0)=>V0.content),Z0=f;for(let V0 of e.server)Z0=Z0.replace(V0.fullTag,"");let M0={__filename:P.filePath,__dirname:c0.dirname(P.filePath),params:v??{},__stx_runtime_head:{}};for(let V0 of p)try{await a(V0,M0,P.filePath)}catch(o0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",P.filePath,o0?.message||o0)}let E0=new Set,f0;if(X.profile){let V0=performance.now();f0=await d(Z0,M0,P.filePath,$0,E0);let o0=performance.now()-V0,q1=c0.relative(K,P.filePath)||P.filePath;console.log(`[stx:profile] ${q1} \u2192 ${o0.toFixed(2)}ms`)}else f0=await d(Z0,M0,P.filePath,$0,E0);if(!B)f0=await o(f0,{router:$0.router});{let{interpolateScriptExpressions:V0}=await Promise.resolve().then(() => (w1(),A3));f0=f0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(o0,q1,j0)=>{if(!/function\s+__stx_setup_/.test(j0))return o0;return`<script${q1}>${V0(j0,M0)}</script>`})}if(B)f0=w4(f0,{preserveHead:!0});if(O0&&L0)await U0(P.filePath,f0,E0,$0);let{extractStreamBoundaries:J1}=await Promise.resolve().then(() => (n4(),l6)),S1=J1(M0),Y1=M0.__streamTemplates;if(Y1&&typeof Y1==="object"&&Object.keys(Y1).length>0){let V0=M0.streamBoundaries||{},o0={...$0,autoShell:!1},q1=Object.keys(Y1).map((h0)=>({id:h0,render:async()=>{let u0=typeof V0[h0]==="function"?await V0[h0]():void 0;return d(Y1[h0],{...M0,$boundary:u0},P.filePath,o0,new Set)}})),j0=new Set(q1.map((h0)=>h0.id));S1=[...(S1||[]).filter((h0)=>!j0.has(h0.id)),...q1]}if(S1&&S1.length>0)I.add(P.pattern);else S1=void 0;return{route:P,content:f0,status:n,boundaries:S1}}catch(d){return console.error(`${D.red}Error building ${D.bright}${P.pattern}${D.reset}:`,d),null}},C=8,S=async()=>{M.clear(),O.clear();for(let P=0;P<_.length;P+=C){let v=_.slice(P,P+C),d=await Promise.all(v.map((a)=>E(a)));for(let a of d)if(a)M.set(a.route.pattern,a)}for(let P=0;P<L.length;P+=C){let v=L.slice(P,P+C),d=await Promise.all(v.map(({route:a})=>E(a)));for(let a of d)if(a)O.set(a.route.pattern,a)}return M.size>0};if(console.log(`${D.blue}Building pages...${D.reset}`),!await S())return console.error(`${D.red}No pages were successfully built${D.reset}`),!1;await s8(K);let x=Z;try{if(x=await U6(Z),x!==Z)console.log(`${D.yellow}Port ${Z} is busy, using port ${x} instead${D.reset}`)}catch{return console.error(`${D.red}Could not find an available port${D.reset}`),!1}if(Y){let P=X.hmrPort||x+1;Q=dX({wsPort:P,verbose:!1}),G=Q.start(P)}let b=(P,v)=>{let a=`<script data-stx-route-params>(function(){var p=${JSON.stringify(v).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(P.includes("</head>"))return P.replace("</head>",`${a}</head>`);if(P.includes("<body"))return P.replace(/<body([^>]*)>/,`<body$1>${a}`);return a+P};console.log(`${D.blue}Starting server...${D.reset}`);let u=he({port:x,async fetch(P){let v=new URL(P.url),d=U?.publicDir||"public",a=c0.join(K,d,v.pathname),t=c0.join(K,v.pathname),k0=c0.join(R,v.pathname),[o,W0,U0]=await Promise.all([p1.promises.stat(a).catch(()=>null),p1.promises.stat(t).catch(()=>null),p1.promises.stat(k0).catch(()=>null)]);if(o?.isFile())return gH(a);if(W0?.isFile())return gH(t);if(U0?.isFile())return gH(k0);if(v.pathname.startsWith("/_stx/component/")){let l=decodeURIComponent(v.pathname.slice(16));if(l)try{let $0=`<${l} />`,L0={...buildConfig,autoShell:!1},O0=await processDirectives($0,{},c0.join(K,"components",`${l}.stx`),L0,new Set);return new Response(O0,{headers:{"Content-Type":"text/html"}})}catch($0){return new Response(`<div class="stx-async-error">${$0.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(v.pathname==="/_stx/img"){let{handleImageRequest:l}=await Promise.resolve().then(() => (hq(),yI)),$0=await l(P,{publicDir:c0.join(K,d),cacheDir:n0(K,"cache","img")});if($0)return $0}if(A)try{let l=await A.handleRequest(P);if(l.status!==404)return l}catch{}if(w[v.pathname])try{return await w[v.pathname](P)}catch(l){return new Response(JSON.stringify({error:l.message}),{status:500,headers:{"Content-Type":"application/json"}})}let z0=Z4(v.pathname,_);if(z0){let l=M.get(z0.route.pattern),$0=I.has(z0.route.pattern);if(z0.route.isDynamic&&Object.keys(z0.params).length>0||$0){let L0=await E(z0.route,z0.params);if(L0)l=L0}if(l){let L0=l.status??200,O0=(z0.route.filePath?o8(await Bun.file(z0.route.filePath).text().catch(()=>"")):null)??{};if(O0.validate){if(!await O0.validate({params:z0.params})){let q0=await N(404);if(q0){let e=q0;if(e=await i0(e,K),Y)e=r$(e,G);return new Response(e,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(O0.middleware){let n=S4(v.pathname,z0.params,O0,v.search),q0=C4(n,null,P,{isServer:!0}),e=await P4(O0.middleware,q0);if(e.redirect){let p=e.redirect.path,Z0=e.redirect.options.redirectCode||302,M0=new Headers(e.responseHeaders);return M0.set("Location",p),new Response(null,{status:Z0,headers:M0})}if(e.abort){let{statusCode:p,message:Z0}=e.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${p}</title></head><body><h1>Error ${p}</h1><p>${Z0}</p></body></html>`,{status:p,headers:{"Content-Type":"text/html"}})}if(Object.keys(e.state).length>0){let p=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(e.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;l.content=l.content.replace("</head>",`${p}</head>`)}}let f=l.content;if(B&&oq(P)){let n=b4(f),q0=I5(f),e=f.match(/<title[^>]*>([\s\S]*?)<\/title>/i),p=e?e[1].trim():"";if(Object.keys(z0.params).length>0)f=b(f,z0.params);f=await i0(f,K);let Z0=U?.router?.container||"main";return f=XZ(f,Z0),new Response(f,{status:L0,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":n.layout,"X-STX-Layout-Group":n.group,"X-STX-Runtime":q0?"true":"false",...p&&{"X-STX-Title":encodeURIComponent(p)},[fW]:m2(),"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(B)f=$Z(B,f);if(Object.keys(z0.params).length>0)f=b(f,z0.params);if(f=await i0(f,K),Y)f=r$(f,G);if(X.native)if(f.includes("<head>"))f=f.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else f="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+f;if(X.titlebarHidden)if(f.includes("<head>"))f=f.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else f=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${f}`;if(l.boundaries&&l.boundaries.length>0){let{renderStreamingPage:n,streamToResponse:q0}=await Promise.resolve().then(() => (n4(),l6));return q0(n(f,l.boundaries,{timeoutMs:30000}),{status:L0,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(f,{status:L0,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(L.length>0){let l=L.map((L0)=>L0.route),$0=Z4(v.pathname,l);if($0){let L0=O.get($0.route.pattern);if(L0){let O0=L0.content;if(B)O0=$Z(B,O0);if(Object.keys($0.params).length>0)O0=b(O0,$0.params);if(O0=await i0(O0,K),Y)O0=r$(O0,G);return new Response(O0,{status:L0.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:L0}of H)if(L0!=="/"&&v.pathname.startsWith(L0)){let O0=O.get(L0)||O.get(L0+"/");if(O0){let f=O0.content;if(B)f=$Z(B,f);if(f=await i0(f,K),Y)f=r$(f,G);return new Response(f,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let s0=M.get("/");if(s0){let l=s0.content;if(l=await i0(l,K),Y)l=r$(l,G);if(X.native)if(l.includes("<head>"))l=l.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else l="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+l;return new Response(l,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let G0=await N(404);if(G0){let l=G0;if(l=await i0(l,K),Y)l=r$(l,G);return new Response(l,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(P){let v=await N(500);if(v)return new Response(v,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${P}
22513
+ Press ${D.cyan}h${D.reset} + ${D.cyan}Enter${D.reset} to show shortcuts`),q6(q.url.toString(),()=>{if(J)w6.watch(Q,{recursive:!0}).close();q.stop()}),J){console.log(`${D.blue}Watching for changes...${D.reset}`);let H=w6.watch(Q,{recursive:!0},async(L,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${D.yellow}File ${D.bright}${O}${D.yellow} changed, rebuilding...${D.reset}`),s4.clear(),c$(),await W()});process.on("SIGINT",()=>{H.close(),q.stop(),process.exit(0)})}return!0}function db($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var cb=T(()=>{v5();$1();_5();z$();AQ();b0();h1();gX()});var{serve:he}=globalThis.Bun;import p1 from"fs";import c0 from"path";async function lb($){try{return TY(await Bun.file($).text())}catch{return}}function gH($){let X=Bun.file($),Z=c0.extname($).toLowerCase(),J={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},Q=[".js",".css",".json"].includes(Z)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(X,{headers:{"Content-Type":J[Z]||"application/octet-stream",...Q}})}async function vZ($=".",X={}){let Z=X.port||3000,J=X.watch!==!1,Y=X.hotReload!==!1&&J,Q=null,G=X.hmrPort||Z+1,K=c0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (s$(),_8)),U=await W(K),z=U.root&&U.root!=="."?c0.join(K,U.root):K,q=X.pagesDir||U.pagesDir||"pages",j=c0.join(z,q);if(!p1.existsSync(j))return console.error(`${D.red}Error: No '${q}' directory found${D.reset}`),console.log(`${D.dim}Looked in: ${D.bright}${j}${D.reset}`),console.log(`${D.dim}Run stx dev from the app directory, pass it as an argument (stx dev <dir>),${D.reset}`),console.log(`${D.dim}point at another directory with --pages <dir>, or set pagesDir in stx.config.ts.${D.reset}`),console.log(`${D.dim}Starting fresh? Create ${q}/index.stx for the homepage.${D.reset}`),!1;let _=V$(z,{pagesDir:q});if(_.length===0)return console.error(`${D.red}Error: No page files found in ${D.bright}${j}${D.reset}`),!1;console.log(`${D.blue}Found ${D.bright}${_.length}${D.blue} routes${D.reset}`);let H=U?._pluginPageDirs||[],L=[];for(let{dir:P,prefix:v}of H)if(p1.existsSync(P)){let d=V$(c0.dirname(P),{pagesDir:c0.basename(P)});for(let a of d){let t=v==="/"?a.pattern:`${v}${a.pattern==="/"?"":a.pattern}`;L.push({route:{...a,pattern:t},prefix:v})}if(d.length>0)console.log(`${D.blue}Plugin pages: ${D.bright}${d.length}${D.blue} routes at ${D.cyan}${v}${D.reset}`)}let O=new Map,B=null,F=null;if(X.stxOptions?.shell!==!1){if(F=await sq(K,X.stxOptions?.shell),F){if(B=await kY(F,X.stxOptions||{}),B)console.log(`${D.blue}Using app shell: ${D.bright}${c0.relative(K,F)}${D.reset} ${D.dim}(deprecated: use layouts/default.stx instead)${D.reset}`)}}D4(),await k4(K);let V=I4();if(V.length>0)console.log(`${D.blue}Loaded ${D.bright}${V.length}${D.blue} middleware: ${D.dim}${V.join(", ")}${D.reset}`);let w={},A=null;try{let{loadStxConfig:P}=await Promise.resolve().then(() => (s$(),_8)),v=await P(K);if(v?.apiRouter)A=v?.apiRouter,console.log(`${D.blue}Using custom router for API handling${D.reset}`);if(v?.apiRoutes){w=v.apiRoutes;let d=Object.keys(w).length;if(d>0)console.log(`${D.blue}Loaded ${D.bright}${d} API route${d>1?"s":""}${D.reset}`)}if(v?.broadcasting?.enabled)try{let{startBroadcasting:d,loadChannels:a}=await Promise.resolve().then(() => (uY(),Nj)),t=v.broadcasting;await d(t);let k0=t.port??6001;console.log(`${D.magenta}Broadcasting on ${D.cyan}ws://localhost:${k0}/ws${D.reset}`);let o=c0.join(process.cwd(),"channels.ts");if(p1.existsSync(o))try{let W0=await a(o);console.log(`${D.blue}Loaded ${D.bright}${W0} broadcast channel${W0!==1?"s":""}${D.blue} from channels.ts${D.reset}`)}catch(W0){console.warn(`${D.yellow}Failed to load channels.ts: ${W0.message}${D.reset}`)}}catch(d){console.warn(`${D.yellow}Broadcasting failed to start: ${d.message}${D.reset}`)}}catch{}let R=n0(K,"output");p1.mkdirSync(R,{recursive:!0});let M=new Map,I=new Set,N=async(P)=>{let v=x8(j,P);if(!v)return null;try{let d=await Bun.build({entrypoints:[v],outdir:R,plugins:[d7],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...X.stxOptions});if(!d.success)return null;let a=d.outputs.find((t)=>t.path.endsWith(".html"));if(!a)return null;return await Bun.file(a.path).text()}catch{return null}},E=async(P,v)=>{try{let{processDirectives:d,extractVariables:a,defaultConfig:t,loadStxConfig:k0,injectRouterScript:o}=await Promise.resolve().then(() => (s$(),_8)),{checkCache:W0,cacheTemplate:U0,readFileCached:z0,templateCache:s0}=await Promise.resolve().then(() => (e6(),D5)),G0=await k0(K),l=(V0)=>{if(!V0)return V0;if(c0.isAbsolute(V0))return V0;return c0.resolve(K,V0)},$0={...t,...G0,...X.stxOptions,autoShell:!0};if(X.debugDirectives)$0.debug=!0;$0.partialsDir=l($0.partialsDir),$0.componentsDir=l($0.componentsDir),$0.layoutsDir=l($0.layoutsDir),$0.storesDir=l($0.storesDir||"stores"),$0.cachePath=l($0.cachePath)??n0(K,"cache");let L0=!v&&!X.profile,O0=$0.cache!==!1;if(O0&&L0){let V0=s0.get(P.filePath);if(V0)try{if((await p1.promises.stat(P.filePath)).mtime.getTime()<=V0.mtime){let j0=!0;for(let h0 of V0.dependencies){if(!p1.existsSync(h0)){j0=!1;break}if((await p1.promises.stat(h0)).mtime.getTime()>V0.mtime){j0=!1;break}}if(j0){let h0=V0.output;if(B)h0=w4(h0,{preserveHead:!0});return{route:P,content:h0,status:await lb(P.filePath)}}}}catch{}let o0=await W0(P.filePath,$0);if(o0){let q1=o0;if(B)q1=w4(q1,{preserveHead:!0});return{route:P,content:q1,status:await lb(P.filePath)}}}let f=O0?await z0(P.filePath):await Bun.file(P.filePath).text(),n=TY(f),{classifyAllScripts:q0}=await Promise.resolve().then(() => (s$(),_8)),e=q0(f),p=e.server.map((V0)=>V0.content),J0=f;for(let V0 of e.server)J0=J0.replace(V0.fullTag,"");let M0={__filename:P.filePath,__dirname:c0.dirname(P.filePath),params:v??{},__stx_runtime_head:{}};for(let V0 of p)try{await a(V0,M0,P.filePath)}catch(o0){if(X.stxOptions?.debug)console.error("[stx] variable extraction error",P.filePath,o0?.message||o0)}let E0=new Set,f0;if(X.profile){let V0=performance.now();f0=await d(J0,M0,P.filePath,$0,E0);let o0=performance.now()-V0,q1=c0.relative(K,P.filePath)||P.filePath;console.log(`[stx:profile] ${q1} \u2192 ${o0.toFixed(2)}ms`)}else f0=await d(J0,M0,P.filePath,$0,E0);if(!B)f0=await o(f0,{router:$0.router});{let{interpolateScriptExpressions:V0}=await Promise.resolve().then(() => (w1(),A3));f0=f0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(o0,q1,j0)=>{if(!/function\s+__stx_setup_/.test(j0))return o0;return`<script${q1}>${V0(j0,M0)}</script>`})}if(B)f0=w4(f0,{preserveHead:!0});if(O0&&L0)await U0(P.filePath,f0,E0,$0);let{extractStreamBoundaries:J1}=await Promise.resolve().then(() => (n4(),l6)),S1=J1(M0),Y1=M0.__streamTemplates;if(Y1&&typeof Y1==="object"&&Object.keys(Y1).length>0){let V0=M0.streamBoundaries||{},o0={...$0,autoShell:!1},q1=Object.keys(Y1).map((h0)=>({id:h0,render:async()=>{let u0=typeof V0[h0]==="function"?await V0[h0]():void 0;return d(Y1[h0],{...M0,$boundary:u0},P.filePath,o0,new Set)}})),j0=new Set(q1.map((h0)=>h0.id));S1=[...(S1||[]).filter((h0)=>!j0.has(h0.id)),...q1]}if(S1&&S1.length>0)I.add(P.pattern);else S1=void 0;return{route:P,content:f0,status:n,boundaries:S1}}catch(d){return console.error(`${D.red}Error building ${D.bright}${P.pattern}${D.reset}:`,d),null}},C=8,S=async()=>{M.clear(),O.clear();for(let P=0;P<_.length;P+=C){let v=_.slice(P,P+C),d=await Promise.all(v.map((a)=>E(a)));for(let a of d)if(a)M.set(a.route.pattern,a)}for(let P=0;P<L.length;P+=C){let v=L.slice(P,P+C),d=await Promise.all(v.map(({route:a})=>E(a)));for(let a of d)if(a)O.set(a.route.pattern,a)}return M.size>0};if(console.log(`${D.blue}Building pages...${D.reset}`),!await S())return console.error(`${D.red}No pages were successfully built${D.reset}`),!1;await s8(K);let y=Z;try{if(y=await U6(Z),y!==Z)console.log(`${D.yellow}Port ${Z} is busy, using port ${y} instead${D.reset}`)}catch{return console.error(`${D.red}Could not find an available port${D.reset}`),!1}if(Y){let P=X.hmrPort||y+1;Q=dX({wsPort:P,verbose:!1}),G=Q.start(P)}let b=(P,v)=>{let a=`<script data-stx-route-params>(function(){var p=${JSON.stringify(v).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(P.includes("</head>"))return P.replace("</head>",`${a}</head>`);if(P.includes("<body"))return P.replace(/<body([^>]*)>/,`<body$1>${a}`);return a+P};console.log(`${D.blue}Starting server...${D.reset}`);let u=he({port:y,async fetch(P){let v=new URL(P.url),d=U?.publicDir||"public",a=c0.join(K,d,v.pathname),t=c0.join(K,v.pathname),k0=c0.join(R,v.pathname),[o,W0,U0]=await Promise.all([p1.promises.stat(a).catch(()=>null),p1.promises.stat(t).catch(()=>null),p1.promises.stat(k0).catch(()=>null)]);if(o?.isFile())return gH(a);if(W0?.isFile())return gH(t);if(U0?.isFile())return gH(k0);if(v.pathname.startsWith("/_stx/component/")){let l=decodeURIComponent(v.pathname.slice(16));if(l)try{let $0=`<${l} />`,L0={...buildConfig,autoShell:!1},O0=await processDirectives($0,{},c0.join(K,"components",`${l}.stx`),L0,new Set);return new Response(O0,{headers:{"Content-Type":"text/html"}})}catch($0){return new Response(`<div class="stx-async-error">${$0.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(v.pathname==="/_stx/img"){let{handleImageRequest:l}=await Promise.resolve().then(() => (hq(),yI)),$0=await l(P,{publicDir:c0.join(K,d),cacheDir:n0(K,"cache","img")});if($0)return $0}if(A)try{let l=await A.handleRequest(P);if(l.status!==404)return l}catch{}if(w[v.pathname])try{return await w[v.pathname](P)}catch(l){return new Response(JSON.stringify({error:l.message}),{status:500,headers:{"Content-Type":"application/json"}})}let z0=Z4(v.pathname,_);if(z0){let l=M.get(z0.route.pattern),$0=I.has(z0.route.pattern);if(z0.route.isDynamic&&Object.keys(z0.params).length>0||$0){let L0=await E(z0.route,z0.params);if(L0)l=L0}if(l){let L0=l.status??200,O0=(z0.route.filePath?o8(await Bun.file(z0.route.filePath).text().catch(()=>"")):null)??{};if(O0.validate){if(!await O0.validate({params:z0.params})){let q0=await N(404);if(q0){let e=q0;if(e=await i0(e,K),Y)e=r$(e,G);return new Response(e,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(O0.middleware){let n=S4(v.pathname,z0.params,O0,v.search),q0=C4(n,null,P,{isServer:!0}),e=await P4(O0.middleware,q0);if(e.redirect){let p=e.redirect.path,J0=e.redirect.options.redirectCode||302,M0=new Headers(e.responseHeaders);return M0.set("Location",p),new Response(null,{status:J0,headers:M0})}if(e.abort){let{statusCode:p,message:J0}=e.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${p}</title></head><body><h1>Error ${p}</h1><p>${J0}</p></body></html>`,{status:p,headers:{"Content-Type":"text/html"}})}if(Object.keys(e.state).length>0){let p=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(e.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;l.content=l.content.replace("</head>",`${p}</head>`)}}let f=l.content;if(B&&oq(P)){let n=b4(f),q0=I5(f),e=f.match(/<title[^>]*>([\s\S]*?)<\/title>/i),p=e?e[1].trim():"";if(Object.keys(z0.params).length>0)f=b(f,z0.params);f=await i0(f,K);let J0=U?.router?.container||"main";return f=XZ(f,J0),new Response(f,{status:L0,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":n.layout,"X-STX-Layout-Group":n.group,"X-STX-Runtime":q0?"true":"false",...p&&{"X-STX-Title":encodeURIComponent(p)},[fW]:m2(),"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(B)f=$Z(B,f);if(Object.keys(z0.params).length>0)f=b(f,z0.params);if(f=await i0(f,K),Y)f=r$(f,G);if(X.native)if(f.includes("<head>"))f=f.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else f="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+f;if(X.titlebarHidden)if(f.includes("<head>"))f=f.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else f=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${f}`;if(l.boundaries&&l.boundaries.length>0){let{renderStreamingPage:n,streamToResponse:q0}=await Promise.resolve().then(() => (n4(),l6));return q0(n(f,l.boundaries,{timeoutMs:30000}),{status:L0,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(f,{status:L0,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(L.length>0){let l=L.map((L0)=>L0.route),$0=Z4(v.pathname,l);if($0){let L0=O.get($0.route.pattern);if(L0){let O0=L0.content;if(B)O0=$Z(B,O0);if(Object.keys($0.params).length>0)O0=b(O0,$0.params);if(O0=await i0(O0,K),Y)O0=r$(O0,G);return new Response(O0,{status:L0.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:L0}of H)if(L0!=="/"&&v.pathname.startsWith(L0)){let O0=O.get(L0)||O.get(L0+"/");if(O0){let f=O0.content;if(B)f=$Z(B,f);if(f=await i0(f,K),Y)f=r$(f,G);return new Response(f,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let s0=M.get("/");if(s0){let l=s0.content;if(l=await i0(l,K),Y)l=r$(l,G);if(X.native)if(l.includes("<head>"))l=l.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else l="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+l;return new Response(l,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let G0=await N(404);if(G0){let l=G0;if(l=await i0(l,K),Y)l=r$(l,G);return new Response(l,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(P){let v=await N(500);if(v)return new Response(v,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${P}
22514
22514
  ${P.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
22515
22515
  ${D.blue}stx${D.reset} ${D.green}${process.env.stx_VERSION||"v0.0.10"}${D.reset} ${D.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${D.reset}`),console.log(`
22516
- ${D.bright}\u2192 ${D.cyan}http://localhost:${x}/${D.reset}`),Y)console.log(`${D.dim} HMR: ws://localhost:${G}${D.reset}`);console.log(`
22516
+ ${D.bright}\u2192 ${D.cyan}http://localhost:${y}/${D.reset}`),Y)console.log(`${D.dim} HMR: ws://localhost:${G}${D.reset}`);console.log(`
22517
22517
  ${D.yellow}Routes:${D.reset}`);let c=[...v8(_,K)];for(let{route:P}of L)c.push(`${P.pattern}`);if(c.forEach((P,v)=>{let a=v===c.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${D.green}${a}${D.reset}${P}`)}),console.log(`
22518
- Press ${D.cyan}h${D.reset} + ${D.cyan}Enter${D.reset} to show shortcuts`),q6(u.url.toString(),()=>{if(Q)O7();u.stop()}),X.native){let P,v=c0.join(j,"index.stx");if(p1.existsSync(v)){let a=await Bun.file(v).text();P=WY(a)}let d=U?.app?.window??{};await _7(x,{title:U?.app?.head?.title||c0.basename(K)||"stx App",width:d.width,height:d.height,darkMode:d.darkMode,hotReload:d.hotReload,titlebarHidden:d.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!P,sidebarConfig:P})}if(J){console.log(`${D.blue}Watching for changes...${D.reset}`);let P=(a)=>{return a.startsWith("public/")||a.startsWith("public\\")},v=(a)=>{let t=a.toLowerCase();return t.endsWith(".stx")||t.endsWith(".html")||t.endsWith(".md")},d=p1.watch(K,{recursive:!0},async(a,t)=>{if(!t||mX(t))return;if(uX(t))if(P(t)){if(console.log(`${D.cyan}${t} changed${D.reset}`),Y&&Q)Q.reload(t)}else if(v(t)){console.log(`${D.yellow}${t} changed, rebuilding...${D.reset}`),s4.clear(),c$();try{let{invalidateFileCache:k0,templateCache:o}=await Promise.resolve().then(() => (e6(),D5));k0(c0.resolve(K,t)),o.delete(c0.resolve(K,t))}catch{}if(F&&t){if(c0.resolve(K,t)===F||c0.basename(F)===t){let o=await kY(F,X.stxOptions||{});if(o)B=o}}if(await S(),await E3(K),Y&&Q)Q.reload(t)}else{console.log(`${D.yellow}${t} changed, rebuilding...${D.reset}`),s4.clear(),c$();try{let{invalidateFileCache:k0,templateCache:o}=await Promise.resolve().then(() => (e6(),D5));k0(c0.resolve(K,t)),o.delete(c0.resolve(K,t))}catch{}if(await S(),Y&&Q)Q.reload(t)}else if(hX(t)){if(console.log(`${D.cyan}CSS ${t} changed${D.reset}`),Y&&Q)Q.updateCss(t)}});process.on("SIGINT",()=>{if(d.close(),Q)O7();u.stop(),process.exit(0)})}return!0}var pb=T(()=>{D7();_5();k5();z$();AQ();F5();DY();b0();gX()});var fH=T(()=>{kq();mb();cb();pb()});var Qy={};X0(Qy,{toPascalCase:()=>Yy,toCamelCase:()=>R6,generateTypesFile:()=>eb,generateReadme:()=>Zy,generatePackageJson:()=>$y,generatePackage:()=>ue,generateIndexFile:()=>tb,generateIconData:()=>sb,generateIconComponent:()=>ob,generateDocumentation:()=>Jy,generateBuildFile:()=>Xy,fetchCollections:()=>nb,fetchCollectionIcons:()=>rb,convertIconData:()=>ab});import{mkdir as ib,writeFile as A6}from"fs/promises";import{join as $4}from"path";async function nb(){let $=await fetch(`${hH}/collections`);if(!$.ok)throw Error(`Failed to fetch collections: ${$.statusText}`);return await $.json()}async function rb($,X){try{let Y=J0.resolve("@iconify/json"),G=`${`${Y.substring(0,Y.lastIndexOf("/node_modules/@iconify/json/"))}/node_modules/@iconify/json`}/json/${$}.json`,K=Bun.file(G);if(await K.exists()){let W=await K.json();if(X&&X.length>0){let U={};for(let z of X)if(W.icons[z])U[z]=W.icons[z];return{...W,icons:U}}return W}}catch{}let Z=X&&X.length>0?`${hH}/${$}.json?icons=${X.join(",")}`:`${hH}/${$}.json`,J=await fetch(Z);if(!J.ok)throw Error(`Failed to fetch icons for ${$}: ${J.statusText}`);return await J.json()}function ab($,X=24,Z=24){return{body:$.body,width:$.width||X,height:$.height||Z,viewBox:`0 0 ${$.width||X} ${$.height||Z}`}}function sb($,X){let Z=R6($);return`import type { IconData } from '@stacksjs/iconify-core'
22518
+ Press ${D.cyan}h${D.reset} + ${D.cyan}Enter${D.reset} to show shortcuts`),q6(u.url.toString(),()=>{if(Q)O7();u.stop()}),X.native){let P,v=c0.join(j,"index.stx");if(p1.existsSync(v)){let a=await Bun.file(v).text();P=WY(a)}let d=U?.app?.window??{};await _7(y,{title:U?.app?.head?.title||c0.basename(K)||"stx App",width:d.width,height:d.height,darkMode:d.darkMode,hotReload:d.hotReload,titlebarHidden:d.titlebarHidden??X.titlebarHidden===!0,nativeSidebar:!!P,sidebarConfig:P})}if(J){console.log(`${D.blue}Watching for changes...${D.reset}`);let P=(a)=>{return a.startsWith("public/")||a.startsWith("public\\")},v=(a)=>{let t=a.toLowerCase();return t.endsWith(".stx")||t.endsWith(".html")||t.endsWith(".md")},d=p1.watch(K,{recursive:!0},async(a,t)=>{if(!t||mX(t))return;if(uX(t))if(P(t)){if(console.log(`${D.cyan}${t} changed${D.reset}`),Y&&Q)Q.reload(t)}else if(v(t)){console.log(`${D.yellow}${t} changed, rebuilding...${D.reset}`),s4.clear(),c$();try{let{invalidateFileCache:k0,templateCache:o}=await Promise.resolve().then(() => (e6(),D5));k0(c0.resolve(K,t)),o.delete(c0.resolve(K,t))}catch{}if(F&&t){if(c0.resolve(K,t)===F||c0.basename(F)===t){let o=await kY(F,X.stxOptions||{});if(o)B=o}}if(await S(),await E3(K),Y&&Q)Q.reload(t)}else{console.log(`${D.yellow}${t} changed, rebuilding...${D.reset}`),s4.clear(),c$();try{let{invalidateFileCache:k0,templateCache:o}=await Promise.resolve().then(() => (e6(),D5));k0(c0.resolve(K,t)),o.delete(c0.resolve(K,t))}catch{}if(await S(),Y&&Q)Q.reload(t)}else if(hX(t)){if(console.log(`${D.cyan}CSS ${t} changed${D.reset}`),Y&&Q)Q.updateCss(t)}});process.on("SIGINT",()=>{if(d.close(),Q)O7();u.stop(),process.exit(0)})}return!0}var pb=T(()=>{D7();_5();k5();z$();AQ();F5();DY();b0();gX()});var fH=T(()=>{kq();mb();cb();pb()});var Qy={};X0(Qy,{toPascalCase:()=>Yy,toCamelCase:()=>R6,generateTypesFile:()=>eb,generateReadme:()=>Zy,generatePackageJson:()=>$y,generatePackage:()=>ue,generateIndexFile:()=>tb,generateIconData:()=>sb,generateIconComponent:()=>ob,generateDocumentation:()=>Jy,generateBuildFile:()=>Xy,fetchCollections:()=>nb,fetchCollectionIcons:()=>rb,convertIconData:()=>ab});import{mkdir as ib,writeFile as A6}from"fs/promises";import{join as $4}from"path";async function nb(){let $=await fetch(`${hH}/collections`);if(!$.ok)throw Error(`Failed to fetch collections: ${$.statusText}`);return await $.json()}async function rb($,X){try{let Y=Y0.resolve("@iconify/json"),G=`${`${Y.substring(0,Y.lastIndexOf("/node_modules/@iconify/json/"))}/node_modules/@iconify/json`}/json/${$}.json`,K=Bun.file(G);if(await K.exists()){let W=await K.json();if(X&&X.length>0){let U={};for(let z of X)if(W.icons[z])U[z]=W.icons[z];return{...W,icons:U}}return W}}catch{}let Z=X&&X.length>0?`${hH}/${$}.json?icons=${X.join(",")}`:`${hH}/${$}.json`,J=await fetch(Z);if(!J.ok)throw Error(`Failed to fetch icons for ${$}: ${J.statusText}`);return await J.json()}function ab($,X=24,Z=24){return{body:$.body,width:$.width||X,height:$.height||Z,viewBox:`0 0 ${$.width||X} ${$.height||Z}`}}function sb($,X){let Z=R6($);return`import type { IconData } from '@stacksjs/iconify-core'
22519
22519
 
22520
22520
  export const ${Z}: IconData = ${JSON.stringify(X,null,2)}
22521
22521
 
@@ -25954,8 +25954,8 @@ Exec=${q}
25954
25954
  Terminal=false
25955
25955
  Categories=Utility;
25956
25956
  `;if(await Bun.write(Q0(K,`${X.toLowerCase()}.desktop`),j),Y==="deb"){let _=Q0(J,`${X.toLowerCase()}_${Z}_amd64.deb`),H=await r00(K,_,X,Z,Q);if(!H.success)return{success:!1,target:"linux",format:"deb",error:H.error};return{success:!0,target:"linux",format:"deb",outputPath:_}}if(Y==="appimage"){let _=Q0(J,`${X}-${Z}-x86_64.AppImage`),H=await a00(K,_,X,Q);if(!H.success)return{success:!1,target:"linux",format:"appimage",error:H.error};return{success:!0,target:"linux",format:"appimage",outputPath:_}}return{success:!0,target:"linux",format:"app",outputPath:K}}async function d00($,X,Z,J,Y,Q){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${X}' to create an iOS project.`}}async function c00($,X,Z,J,Y,Q){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${X}' to create an Android project.`}}async function l00(){if(process.env.CRAFT_BIN&&await Bun.file(process.env.CRAFT_BIN).exists())return process.env.CRAFT_BIN;let $=[Q0(process.cwd(),"../../craft/packages/zig/zig-out/bin/craft"),Q0(process.cwd(),"../craft/packages/zig/zig-out/bin/craft"),Q0(iH(),"Code/Tools/craft/packages/zig/zig-out/bin/craft"),Q0(iH(),"Code/craft/packages/zig/zig-out/bin/craft"),"/usr/local/bin/craft","/usr/bin/craft",Q0(iH(),".local/bin/craft"),Q0(process.env.LOCALAPPDATA||"","craft","craft.exe"),Q0(process.env.PROGRAMFILES||"","craft","craft.exe")];for(let X of $)if(await Bun.file(X).exists())return X;try{let Z=x00("which craft 2>/dev/null || where craft 2>nul",{encoding:"utf-8"}).trim().split(`
25957
- `)[0];if(Z&&await Bun.file(Z).exists())return Z}catch{}return null}function cZ(){switch(v00()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function p00($){switch($){case"macos":return"app";case"windows":return"zip";case"linux":return"appimage";case"ios":return"ipa";case"android":return"apk";default:return"app"}}async function i00($,X,Z){return new Promise((J)=>{let Y=kQ("hdiutil",["create","-volname",Z,"-srcfolder",$,"-ov","-format","UDZO",X]);Y.on("close",(Q)=>{if(Q===0)J({success:!0});else J({success:!1,error:`hdiutil exited with code ${Q}`})}),Y.on("error",(Q)=>{J({success:!1,error:Q.message})})})}async function n00($,X){return new Promise((Z)=>{let J=kQ("zip",["-r",X,"."],{cwd:$});J.on("close",(Y)=>{if(Y===0)Z({success:!0});else Z({success:!1,error:`zip exited with code ${Y}`})}),J.on("error",(Y)=>{Z({success:!1,error:Y.message})})})}async function r00($,X,Z,J,Y){return new Promise((Q)=>{try{let G=Q0(yy(),`stx-deb-${Date.now()}`),K=Q0(G,"DEBIAN"),W=Q0(G,"usr","bin"),U=Q0(G,"usr","share","applications"),z=Q0(G,"usr","share",Z.toLowerCase());U$(K,{recursive:!0}),U$(W,{recursive:!0}),U$(U,{recursive:!0}),U$(z,{recursive:!0});let q=J0("fs").readdirSync($);for(let L of q)N6(Q0($,L),Q0(z,L));let j=`#!/bin/bash
25958
- exec /usr/share/${Z.toLowerCase()}/${Z.toLowerCase()} "$@"`;J0("fs").writeFileSync(Q0(W,Z.toLowerCase()),j),M6(Q0(W,Z.toLowerCase()),493);let _=`Package: ${Z.toLowerCase()}
25957
+ `)[0];if(Z&&await Bun.file(Z).exists())return Z}catch{}return null}function cZ(){switch(v00()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function p00($){switch($){case"macos":return"app";case"windows":return"zip";case"linux":return"appimage";case"ios":return"ipa";case"android":return"apk";default:return"app"}}async function i00($,X,Z){return new Promise((J)=>{let Y=kQ("hdiutil",["create","-volname",Z,"-srcfolder",$,"-ov","-format","UDZO",X]);Y.on("close",(Q)=>{if(Q===0)J({success:!0});else J({success:!1,error:`hdiutil exited with code ${Q}`})}),Y.on("error",(Q)=>{J({success:!1,error:Q.message})})})}async function n00($,X){return new Promise((Z)=>{let J=kQ("zip",["-r",X,"."],{cwd:$});J.on("close",(Y)=>{if(Y===0)Z({success:!0});else Z({success:!1,error:`zip exited with code ${Y}`})}),J.on("error",(Y)=>{Z({success:!1,error:Y.message})})})}async function r00($,X,Z,J,Y){return new Promise((Q)=>{try{let G=Q0(yy(),`stx-deb-${Date.now()}`),K=Q0(G,"DEBIAN"),W=Q0(G,"usr","bin"),U=Q0(G,"usr","share","applications"),z=Q0(G,"usr","share",Z.toLowerCase());U$(K,{recursive:!0}),U$(W,{recursive:!0}),U$(U,{recursive:!0}),U$(z,{recursive:!0});let q=Y0("fs").readdirSync($);for(let L of q)N6(Q0($,L),Q0(z,L));let j=`#!/bin/bash
25958
+ exec /usr/share/${Z.toLowerCase()}/${Z.toLowerCase()} "$@"`;Y0("fs").writeFileSync(Q0(W,Z.toLowerCase()),j),M6(Q0(W,Z.toLowerCase()),493);let _=`Package: ${Z.toLowerCase()}
25959
25959
  Version: ${J}
25960
25960
  Section: utils
25961
25961
  Priority: optional
@@ -25963,19 +25963,19 @@ Architecture: amd64
25963
25963
  Depends: libgtk-3-0, libwebkit2gtk-4.0-37
25964
25964
  Maintainer: ${Y.author||"Unknown"}
25965
25965
  Description: ${Y.description||Z}
25966
- `;J0("fs").writeFileSync(Q0(K,"control"),_);let H=kQ("dpkg-deb",["--build",G,X]);H.on("close",(L)=>{if(J0("fs").rmSync(G,{recursive:!0,force:!0}),L===0)Q({success:!0});else Q({success:!1,error:`dpkg-deb exited with code ${L}`})}),H.on("error",(L)=>{J0("fs").rmSync(G,{recursive:!0,force:!0}),Q({success:!1,error:L.message})})}catch(G){Q({success:!1,error:G.message})}})}async function a00($,X,Z,J){return new Promise((Y)=>{try{let Q=Q0(yy(),`stx-appimage-${Date.now()}`),G=Q0(Q,`${Z}.AppDir`),K=Q0(G,"usr"),W=Q0(K,"bin"),U=Q0(K,"share");U$(W,{recursive:!0}),U$(U,{recursive:!0});let z=Q0(U,Z.toLowerCase());U$(z,{recursive:!0});let q=J0("fs").readdirSync($);for(let O of q)N6(Q0($,O),Q0(z,O));let j=`#!/bin/bash
25966
+ `;Y0("fs").writeFileSync(Q0(K,"control"),_);let H=kQ("dpkg-deb",["--build",G,X]);H.on("close",(L)=>{if(Y0("fs").rmSync(G,{recursive:!0,force:!0}),L===0)Q({success:!0});else Q({success:!1,error:`dpkg-deb exited with code ${L}`})}),H.on("error",(L)=>{Y0("fs").rmSync(G,{recursive:!0,force:!0}),Q({success:!1,error:L.message})})}catch(G){Q({success:!1,error:G.message})}})}async function a00($,X,Z,J){return new Promise((Y)=>{try{let Q=Q0(yy(),`stx-appimage-${Date.now()}`),G=Q0(Q,`${Z}.AppDir`),K=Q0(G,"usr"),W=Q0(K,"bin"),U=Q0(K,"share");U$(W,{recursive:!0}),U$(U,{recursive:!0});let z=Q0(U,Z.toLowerCase());U$(z,{recursive:!0});let q=Y0("fs").readdirSync($);for(let O of q)N6(Q0($,O),Q0(z,O));let j=`#!/bin/bash
25967
25967
  SELF=$(readlink -f "$0")
25968
25968
  HERE=\${SELF%/*}
25969
25969
  export PATH="\${HERE}/usr/bin:\${PATH}"
25970
25970
  exec "\${HERE}/usr/share/${Z.toLowerCase()}/${Z.toLowerCase()}" "$@"
25971
- `;J0("fs").writeFileSync(Q0(G,"AppRun"),j),M6(Q0(G,"AppRun"),493);let _=`[Desktop Entry]
25971
+ `;Y0("fs").writeFileSync(Q0(G,"AppRun"),j),M6(Q0(G,"AppRun"),493);let _=`[Desktop Entry]
25972
25972
  Type=Application
25973
25973
  Name=${Z}
25974
25974
  Exec=${Z.toLowerCase()}
25975
25975
  Terminal=false
25976
25976
  Categories=Utility;
25977
25977
  Icon=${Z.toLowerCase()}
25978
- `;J0("fs").writeFileSync(Q0(G,`${Z.toLowerCase()}.desktop`),_);let H=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(J0("fs").writeFileSync(Q0(G,`${Z.toLowerCase()}.png`),H),J.icon&&by(J.icon))N6(J.icon,Q0(G,`${Z.toLowerCase()}.png`));let L=kQ("appimagetool",[G,X],{env:{...process.env,ARCH:"x86_64"}});L.on("close",(O)=>{if(J0("fs").rmSync(Q,{recursive:!0,force:!0}),O===0)M6(X,493),Y({success:!0});else Y({success:!1,error:`appimagetool exited with code ${O}. Install from https://appimage.github.io/appimagetool/`})}),L.on("error",(O)=>{J0("fs").rmSync(Q,{recursive:!0,force:!0}),Y({success:!1,error:`appimagetool not found: ${O.message}`})})}catch(Q){Y({success:!1,error:Q.message})}})}function vy(){return[cZ()]}function fy($){switch($){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var s00,o00;var hy=T(()=>{Ey();Cy();NH();s00={buildNative:xy,getAvailableTargets:vy,getAvailableFormats:fy,detectPlatform:cZ},o00=s00});function lZ($,X){return`${t00[X]}${$}\x1B[0m`}function my($,X){return`${e00[X]}${$}\x1B[0m`}function pZ(){console.log(""),console.log(M1(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(M1(" \u2551")+C$(" \uD83D\uDCD6 STX Story ")+M1("\u2551")),console.log(M1(" \u2551")+CQ(" Component Showcase & Testing ")+M1("\u2551")),console.log(M1(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log("")}function rH($,X){if(console.log(C$(" Server running at:")),console.log(""),console.log(` ${CQ("\u279C")} ${C$("Local:")} ${M1($)}`),X)console.log(` ${CQ("\u279C")} ${C$("Network:")} ${M1(X)}`);console.log("")}function iZ($){let X=$>0?"\u2713":"\u25CB",Z=$>0?SQ:nH;console.log(` ${Z(X)} Found ${C$(String($))} story ${$===1?"file":"files"}`)}function dy($,X){if(console.log(""),console.log(` ${uy("\u2717")} ${C$(uy("Error:"))} ${$}`),X)console.log(` ${CQ(X)}`);console.log("")}function p7($){console.log(` ${nH("\u26A0")} ${nH("Warning:")} ${$}`)}function cy($){console.log(` ${$10("\u2139")} ${$}`)}function ly($,X,Z){console.log(""),console.log(M1(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(M1(" \u2551")+C$(" Build Complete ")+M1("\u2551")),console.log(M1(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log(""),console.log(` ${SQ("\u2713")} Stories: ${C$(String($))}`),console.log(` ${SQ("\u2713")} Output: ${C$(X)}`),console.log(` ${SQ("\u2713")} Time: ${C$(`${Z}ms`)}`),console.log("")}function aH(){console.log(""),console.log(C$(" Keyboard Shortcuts:")),console.log(""),console.log(` ${M1("h")} Show this help`),console.log(` ${M1("o")} Open in browser`),console.log(` ${M1("r")} Restart server`),console.log(` ${M1("c")} Clear console`),console.log(` ${M1("q")} Quit`),console.log("")}var t00,e00,uy=($)=>lZ($,"red"),SQ=($)=>lZ($,"green"),nH=($)=>lZ($,"yellow"),$10=($)=>lZ($,"blue"),M1=($)=>lZ($,"cyan"),C$=($)=>my($,"bold"),CQ=($)=>my($,"dim");var PQ=T(()=>{t00={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",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},e00={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"}});import py from"fs";import sH from"path";function iy($,X){let Z=[sH.join($.root,"stx.config.ts"),sH.join($.root,"stx.config.js"),sH.join($.root,"stx.config.mjs")],J=X.debounceMs??300,Y=null,Q=[];for(let G of Z)try{if(!py.existsSync(G))continue;let K=py.watch(G,(W)=>{if(W==="change"){if(Y)clearTimeout(Y);Y=setTimeout(async()=>{cy("Config file changed, restarting...");try{await X.onChange()}catch(U){p7(`Failed to restart: ${U}`)}},J)}});Q.push(K)}catch{}return{stop(){if(Y)clearTimeout(Y);for(let G of Q)G.close()}}}var ny=T(()=>{PQ()});function oy($){let X={...X10,...$};return{enabled:X.enabled??!0,outDir:X.outDir??".stx/dist/story",storyMatch:X.storyMatch??["**/*.story.stx"],storyIgnored:X.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...sy,...X.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...X.theme},responsivePresets:X.responsivePresets??ry,backgroundPresets:X.backgroundPresets??ay,autoApplyContrastColor:X.autoApplyContrastColor??!1,setupFile:X.setupFile,port:X.port??6006}}var ry,ay,sy,X10;var ty=T(()=>{ry=[{label:"Mobile (Small)",width:320,height:568},{label:"Mobile (Medium)",width:375,height:667},{label:"Mobile (Large)",width:414,height:896},{label:"Tablet",width:768,height:1024},{label:"Laptop",width:1024},{label:"Desktop",width:1280},{label:"Desktop (Large)",width:1920}],ay=[{label:"Transparent",color:"transparent",contrastColor:"#333"},{label:"White",color:"#ffffff",contrastColor:"#333"},{label:"Light Gray",color:"#f5f5f5",contrastColor:"#333"},{label:"Dark Gray",color:"#333333",contrastColor:"#fff"},{label:"Black",color:"#000000",contrastColor:"#fff"}],sy={file:"title",order:"asc",groups:[]},X10={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:sy,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:ry,backgroundPresets:ay,autoApplyContrastColor:!1,port:6006}});var ey={};X0(ey,{updateContextTree:()=>r7,updateContextStoryFiles:()=>n7,createContext:()=>i7});import Z10 from"path";async function i7($){let X=$.root??process.cwd(),Z;try{let G=await import(Z10.join(X,"stx.config.ts"));Z=(G.default||G).story}catch{}let J={...Z,...$.config},Y=oy(J);return{root:X,config:Y,storyFiles:[],tree:void 0,mode:$.mode}}function n7($,X){$.storyFiles=X}function r7($,X){$.tree=X}var nZ=T(()=>{ty()});import oH from"fs";import $x from"path";class tH{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor($){this.storagePath=$x.join($,J10),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let $=oH.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Y10,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let $=$x.dirname(this.storagePath);if(await oH.promises.mkdir($,{recursive:!0}),this.storage.events.length>Xx)this.storage.events=this.storage.events.slice(-Xx);await oH.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Q10(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track($){this.storage.events.push({...$,timestamp:Date.now()}),this.dirty=!0}trackView($,X){if(this.endViewTiming($),this.viewStartTimes.set($,Date.now()),this.track({type:"view",componentId:$,variantId:X}),this.currentSession&&!this.currentSession.componentViews.includes($))this.currentSession.componentViews.push($)}endViewTiming($){let X=this.viewStartTimes.get($);if(X){let Z=Date.now()-X;this.track({type:"view",componentId:$,metadata:{duration:Z,endView:!0}}),this.viewStartTimes.delete($)}}trackPropChange($,X,Z){this.track({type:"prop_change",componentId:$,propName:X,metadata:{value:Z}})}trackVariantSwitch($,X){this.track({type:"variant_switch",componentId:$,variantId:X})}trackSearch($,X){this.track({type:"search",query:$,metadata:{resultCount:X}})}getComponentAnalytics($,X){let Z=this.storage.events.filter((j)=>j.componentId===$),J=Z.filter((j)=>j.type==="view"&&!j.metadata?.endView),Y=Z.filter((j)=>j.type==="prop_change"),Q=Z.filter((j)=>j.type==="variant_switch"),G={};for(let j of Y)if(j.propName)G[j.propName]=(G[j.propName]||0)+1;let K={};for(let j of Q)if(j.variantId)K[j.variantId]=(K[j.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((j)=>j.componentViews.includes($)).map((j)=>j.id)),U=Z.filter((j)=>j.metadata?.duration).map((j)=>j.metadata.duration),z=U.length>0?U.reduce((j,_)=>j+_,0)/U.length:0,q=Object.entries(G).sort((j,_)=>_[1]-j[1]).slice(0,5).map(([j])=>j);return{componentId:$,componentName:X,viewCount:J.length,uniqueViews:W.size,lastViewed:J[J.length-1]?.timestamp,propChanges:G,topChangedProps:q,variantViews:K,avgTimeSpent:z}}getMostViewedComponents($=10){let X=new Map;for(let Z of this.storage.events)if(Z.type==="view"&&Z.componentId&&!Z.metadata?.endView)X.set(Z.componentId,(X.get(Z.componentId)||0)+1);return Array.from(X.entries()).map(([Z,J])=>({componentId:Z,viewCount:J})).sort((Z,J)=>J.viewCount-Z.viewCount).slice(0,$)}getMostChangedProps($=10){let X=new Map;for(let Z of this.storage.events)if(Z.type==="prop_change"&&Z.propName)X.set(Z.propName,(X.get(Z.propName)||0)+1);return Array.from(X.entries()).map(([Z,J])=>({propName:Z,changeCount:J})).sort((Z,J)=>J.changeCount-Z.changeCount).slice(0,$)}getSearchAnalytics(){let $=this.storage.events.filter((Y)=>Y.type==="search"),X=new Map,Z=0;for(let Y of $){if(Y.query)X.set(Y.query,(X.get(Y.query)||0)+1);if(Y.metadata?.resultCount!==void 0)Z+=Y.metadata.resultCount}let J=Array.from(X.entries()).map(([Y,Q])=>({query:Y,count:Q})).sort((Y,Q)=>Q.count-Y.count).slice(0,10);return{totalSearches:$.length,topQueries:J,avgResultCount:$.length>0?Z/$.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function Q10(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var J10=".stx/story/analytics.json",Y10=1,Xx=1e4;var Zx=()=>{};import eH from"fs";import Jx from"path";class $L{storage;storagePath;dirty=!1;constructor($){this.storagePath=Jx.join($,G10),this.storage=this.loadStorage()}loadStorage(){try{let $=eH.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:K10,bookmarks:[]}}}async save(){if(!this.dirty)return;let $=Jx.dirname(this.storagePath);await eH.promises.mkdir($,{recursive:!0}),await eH.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark($,X,Z,J={}){let Y={id:W10(),name:J.name||`${$}/${X}`,storyId:$,variantId:X,props:Z,created:Date.now(),notes:J.notes,color:J.color};return this.storage.bookmarks.push(Y),this.dirty=!0,Y}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory($){return this.storage.bookmarks.filter((X)=>X.storyId===$)}getBookmark($){return this.storage.bookmarks.find((X)=>X.id===$)}isBookmarked($,X){return this.storage.bookmarks.some((Z)=>Z.storyId===$&&Z.variantId===X)}updateBookmark($,X){let Z=this.getBookmark($);if(!Z)return;return Object.assign(Z,X),this.dirty=!0,Z}deleteBookmark($){let X=this.storage.bookmarks.findIndex((Z)=>Z.id===$);if(X===-1)return!1;return this.storage.bookmarks.splice(X,1),this.dirty=!0,!0}toggleBookmark($,X,Z){let J=this.storage.bookmarks.find((Q)=>Q.storyId===$&&Q.variantId===X);if(J)return this.deleteBookmark(J.id),{added:!1};return{added:!0,bookmark:this.addBookmark($,X,Z)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks($,X=!0){let Z=JSON.parse($),J=0;for(let Y of Z.bookmarks){if(X){let Q=this.storage.bookmarks.find((G)=>G.id===Y.id);if(Q)Object.assign(Q,Y);else this.storage.bookmarks.push(Y)}else this.storage.bookmarks.push(Y);J++}if(J>0)this.dirty=!0;return J}}function W10(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var G10=".stx/story/bookmarks.json",K10=1;var Yx=()=>{};import XL from"fs";import rZ from"path";async function aZ($){let{root:X,config:Z}=$,J=[],Y=await U10(X,Z.storyMatch,Z.storyIgnored);for(let Q of Y){let G=rZ.resolve(X,Q),K=ZL(Q,G);J.push(K)}return J}async function U10($,X,Z){let J=[];async function Y(Q,G){let K=await XL.promises.readdir(Q,{withFileTypes:!0});for(let W of K){let U=rZ.join(Q,W.name),z=rZ.relative(G,U);if(Qx(z,Z))continue;if(W.isDirectory())await Y(U,G);else if(W.isFile()){if(Gx(z,X))J.push(z)}}}return await Y($,$),J}function Qx($,X){for(let Z of X)if(Kx($,Z))return!0;return!1}function Gx($,X){for(let Z of X)if(Kx($,Z))return!0;return!1}function Kx($,X){let Z=$.replace(/\\/g,"/"),Y=X.replace(/\\/g,"/").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\?/g,".").replace(/\{\{GLOBSTAR\}\}/g,".*");return Y=`^${Y}$`,new RegExp(Y).test(Z)}function ZL($,X){let Z=rZ.basename($,".story.stx");return{id:$.toLowerCase().replace(/\.story\.stx$/,"").replace(/[/\\]/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),path:X,relativePath:$,fileName:Z,treeFile:{title:Z,path:$}}}function Wx($,X){let{root:Z,config:J}=$,Y=[],Q=XL.watch(Z,{recursive:!0},async(G,K)=>{if(!K)return;let W=K.replace(/\\/g,"/");if(!Gx(W,J.storyMatch))return;if(Qx(W,J.storyIgnored))return;let U=rZ.resolve(Z,W);try{await XL.promises.access(U);let z=ZL(W,U);X(G==="rename"?"add":"change",z)}catch{let z=ZL(W,U);X("unlink",z)}});return Y.push(Q),()=>{for(let G of Y)G.close()}}var JL=()=>{};function z10($,X){let Z=X.treeFile||{title:X.fileName,path:X.relativePath};if($.tree.file==="title")return Z.title.split("/");if($.tree.file==="path")return[...X.relativePath.split("/").slice(0,-1),Z.title];if(typeof $.tree.file==="function")return $.tree.file(Z);return[Z.title]}function sZ($,X){for(let G of X)G.treePath=z10($,G);let Z=($.tree.groups||[]).map((G)=>({groupConfig:{id:G.id||G.title,title:G.title,include:G.include},treeObject:{}})),J={treeObject:{}};Z.push(J);for(let G=0;G<X.length;G++){let K=X[G],W=q10(K,Z,J);j10(K.treePath,G,W.treeObject)}let Y=$.tree.order==="asc"?(G,K)=>G.localeCompare(K):$.tree.order,Q=[];for(let G of Z)if(G===J)Q.push(...YL(G.treeObject,Y));else if(G.groupConfig&&Object.keys(G.treeObject).length>0)Q.push({group:!0,id:G.groupConfig.id,title:G.groupConfig.title,children:YL(G.treeObject,Y)});return Q}function q10($,X,Z){let J=$.treeFile||{title:$.fileName,path:$.relativePath};for(let Y of X)if(Y.groupConfig?.include&&Y.groupConfig.include(J))return Y;return Z}function j10($,X,Z){let J=Z;for(let Y=0;Y<$.length;Y++){let Q=$[Y];if(Y===$.length-1)if(J[Q]!==void 0){let K=1;while(J[`${Q}-${K}`]!==void 0)K++;J[`${Q}-${K}`]=X}else J[Q]=X;else{if(J[Q]===void 0)J[Q]={};else if(typeof J[Q]==="number"){let K=J[Q];J[Q]={"":K}}J=J[Q]}}}function YL($,X){let Z=[];for(let[J,Y]of Object.entries($))if(typeof Y==="number")Z.push({title:J,index:Y});else Z.push({title:J,children:YL(Y,X)});return Z.sort((J,Y)=>X(J.title,Y.title)),Z}function Ux(){return{open($){bQ.add($),$.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close($){bQ.delete($)},message($,X){}}}function QL($){let X=JSON.stringify({...$,timestamp:$.timestamp||Date.now()});for(let Z of bQ)try{Z.send(X)}catch{bQ.delete(Z)}}function zx($,X){QL({type:"story-update",data:{storyId:$,...X}})}function qx($,X){QL({type:"story-add",data:{storyId:$,...X}})}function jx($){QL({type:"story-remove",data:{storyId:$}})}function _x($){return`
25978
+ `;Y0("fs").writeFileSync(Q0(G,`${Z.toLowerCase()}.desktop`),_);let H=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(Y0("fs").writeFileSync(Q0(G,`${Z.toLowerCase()}.png`),H),J.icon&&by(J.icon))N6(J.icon,Q0(G,`${Z.toLowerCase()}.png`));let L=kQ("appimagetool",[G,X],{env:{...process.env,ARCH:"x86_64"}});L.on("close",(O)=>{if(Y0("fs").rmSync(Q,{recursive:!0,force:!0}),O===0)M6(X,493),Y({success:!0});else Y({success:!1,error:`appimagetool exited with code ${O}. Install from https://appimage.github.io/appimagetool/`})}),L.on("error",(O)=>{Y0("fs").rmSync(Q,{recursive:!0,force:!0}),Y({success:!1,error:`appimagetool not found: ${O.message}`})})}catch(Q){Y({success:!1,error:Q.message})}})}function vy(){return[cZ()]}function fy($){switch($){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var s00,o00;var hy=T(()=>{Ey();Cy();NH();s00={buildNative:xy,getAvailableTargets:vy,getAvailableFormats:fy,detectPlatform:cZ},o00=s00});function lZ($,X){return`${t00[X]}${$}\x1B[0m`}function my($,X){return`${e00[X]}${$}\x1B[0m`}function pZ(){console.log(""),console.log(M1(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(M1(" \u2551")+C$(" \uD83D\uDCD6 STX Story ")+M1("\u2551")),console.log(M1(" \u2551")+CQ(" Component Showcase & Testing ")+M1("\u2551")),console.log(M1(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log("")}function rH($,X){if(console.log(C$(" Server running at:")),console.log(""),console.log(` ${CQ("\u279C")} ${C$("Local:")} ${M1($)}`),X)console.log(` ${CQ("\u279C")} ${C$("Network:")} ${M1(X)}`);console.log("")}function iZ($){let X=$>0?"\u2713":"\u25CB",Z=$>0?SQ:nH;console.log(` ${Z(X)} Found ${C$(String($))} story ${$===1?"file":"files"}`)}function dy($,X){if(console.log(""),console.log(` ${uy("\u2717")} ${C$(uy("Error:"))} ${$}`),X)console.log(` ${CQ(X)}`);console.log("")}function p7($){console.log(` ${nH("\u26A0")} ${nH("Warning:")} ${$}`)}function cy($){console.log(` ${$10("\u2139")} ${$}`)}function ly($,X,Z){console.log(""),console.log(M1(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(M1(" \u2551")+C$(" Build Complete ")+M1("\u2551")),console.log(M1(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log(""),console.log(` ${SQ("\u2713")} Stories: ${C$(String($))}`),console.log(` ${SQ("\u2713")} Output: ${C$(X)}`),console.log(` ${SQ("\u2713")} Time: ${C$(`${Z}ms`)}`),console.log("")}function aH(){console.log(""),console.log(C$(" Keyboard Shortcuts:")),console.log(""),console.log(` ${M1("h")} Show this help`),console.log(` ${M1("o")} Open in browser`),console.log(` ${M1("r")} Restart server`),console.log(` ${M1("c")} Clear console`),console.log(` ${M1("q")} Quit`),console.log("")}var t00,e00,uy=($)=>lZ($,"red"),SQ=($)=>lZ($,"green"),nH=($)=>lZ($,"yellow"),$10=($)=>lZ($,"blue"),M1=($)=>lZ($,"cyan"),C$=($)=>my($,"bold"),CQ=($)=>my($,"dim");var PQ=T(()=>{t00={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",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},e00={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"}});import py from"fs";import sH from"path";function iy($,X){let Z=[sH.join($.root,"stx.config.ts"),sH.join($.root,"stx.config.js"),sH.join($.root,"stx.config.mjs")],J=X.debounceMs??300,Y=null,Q=[];for(let G of Z)try{if(!py.existsSync(G))continue;let K=py.watch(G,(W)=>{if(W==="change"){if(Y)clearTimeout(Y);Y=setTimeout(async()=>{cy("Config file changed, restarting...");try{await X.onChange()}catch(U){p7(`Failed to restart: ${U}`)}},J)}});Q.push(K)}catch{}return{stop(){if(Y)clearTimeout(Y);for(let G of Q)G.close()}}}var ny=T(()=>{PQ()});function oy($){let X={...X10,...$};return{enabled:X.enabled??!0,outDir:X.outDir??".stx/dist/story",storyMatch:X.storyMatch??["**/*.story.stx"],storyIgnored:X.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...sy,...X.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...X.theme},responsivePresets:X.responsivePresets??ry,backgroundPresets:X.backgroundPresets??ay,autoApplyContrastColor:X.autoApplyContrastColor??!1,setupFile:X.setupFile,port:X.port??6006}}var ry,ay,sy,X10;var ty=T(()=>{ry=[{label:"Mobile (Small)",width:320,height:568},{label:"Mobile (Medium)",width:375,height:667},{label:"Mobile (Large)",width:414,height:896},{label:"Tablet",width:768,height:1024},{label:"Laptop",width:1024},{label:"Desktop",width:1280},{label:"Desktop (Large)",width:1920}],ay=[{label:"Transparent",color:"transparent",contrastColor:"#333"},{label:"White",color:"#ffffff",contrastColor:"#333"},{label:"Light Gray",color:"#f5f5f5",contrastColor:"#333"},{label:"Dark Gray",color:"#333333",contrastColor:"#fff"},{label:"Black",color:"#000000",contrastColor:"#fff"}],sy={file:"title",order:"asc",groups:[]},X10={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:sy,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:ry,backgroundPresets:ay,autoApplyContrastColor:!1,port:6006}});var ey={};X0(ey,{updateContextTree:()=>r7,updateContextStoryFiles:()=>n7,createContext:()=>i7});import Z10 from"path";async function i7($){let X=$.root??process.cwd(),Z;try{let G=await import(Z10.join(X,"stx.config.ts"));Z=(G.default||G).story}catch{}let J={...Z,...$.config},Y=oy(J);return{root:X,config:Y,storyFiles:[],tree:void 0,mode:$.mode}}function n7($,X){$.storyFiles=X}function r7($,X){$.tree=X}var nZ=T(()=>{ty()});import oH from"fs";import $x from"path";class tH{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor($){this.storagePath=$x.join($,J10),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let $=oH.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Y10,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let $=$x.dirname(this.storagePath);if(await oH.promises.mkdir($,{recursive:!0}),this.storage.events.length>Xx)this.storage.events=this.storage.events.slice(-Xx);await oH.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Q10(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track($){this.storage.events.push({...$,timestamp:Date.now()}),this.dirty=!0}trackView($,X){if(this.endViewTiming($),this.viewStartTimes.set($,Date.now()),this.track({type:"view",componentId:$,variantId:X}),this.currentSession&&!this.currentSession.componentViews.includes($))this.currentSession.componentViews.push($)}endViewTiming($){let X=this.viewStartTimes.get($);if(X){let Z=Date.now()-X;this.track({type:"view",componentId:$,metadata:{duration:Z,endView:!0}}),this.viewStartTimes.delete($)}}trackPropChange($,X,Z){this.track({type:"prop_change",componentId:$,propName:X,metadata:{value:Z}})}trackVariantSwitch($,X){this.track({type:"variant_switch",componentId:$,variantId:X})}trackSearch($,X){this.track({type:"search",query:$,metadata:{resultCount:X}})}getComponentAnalytics($,X){let Z=this.storage.events.filter((j)=>j.componentId===$),J=Z.filter((j)=>j.type==="view"&&!j.metadata?.endView),Y=Z.filter((j)=>j.type==="prop_change"),Q=Z.filter((j)=>j.type==="variant_switch"),G={};for(let j of Y)if(j.propName)G[j.propName]=(G[j.propName]||0)+1;let K={};for(let j of Q)if(j.variantId)K[j.variantId]=(K[j.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((j)=>j.componentViews.includes($)).map((j)=>j.id)),U=Z.filter((j)=>j.metadata?.duration).map((j)=>j.metadata.duration),z=U.length>0?U.reduce((j,_)=>j+_,0)/U.length:0,q=Object.entries(G).sort((j,_)=>_[1]-j[1]).slice(0,5).map(([j])=>j);return{componentId:$,componentName:X,viewCount:J.length,uniqueViews:W.size,lastViewed:J[J.length-1]?.timestamp,propChanges:G,topChangedProps:q,variantViews:K,avgTimeSpent:z}}getMostViewedComponents($=10){let X=new Map;for(let Z of this.storage.events)if(Z.type==="view"&&Z.componentId&&!Z.metadata?.endView)X.set(Z.componentId,(X.get(Z.componentId)||0)+1);return Array.from(X.entries()).map(([Z,J])=>({componentId:Z,viewCount:J})).sort((Z,J)=>J.viewCount-Z.viewCount).slice(0,$)}getMostChangedProps($=10){let X=new Map;for(let Z of this.storage.events)if(Z.type==="prop_change"&&Z.propName)X.set(Z.propName,(X.get(Z.propName)||0)+1);return Array.from(X.entries()).map(([Z,J])=>({propName:Z,changeCount:J})).sort((Z,J)=>J.changeCount-Z.changeCount).slice(0,$)}getSearchAnalytics(){let $=this.storage.events.filter((Y)=>Y.type==="search"),X=new Map,Z=0;for(let Y of $){if(Y.query)X.set(Y.query,(X.get(Y.query)||0)+1);if(Y.metadata?.resultCount!==void 0)Z+=Y.metadata.resultCount}let J=Array.from(X.entries()).map(([Y,Q])=>({query:Y,count:Q})).sort((Y,Q)=>Q.count-Y.count).slice(0,10);return{totalSearches:$.length,topQueries:J,avgResultCount:$.length>0?Z/$.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function Q10(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var J10=".stx/story/analytics.json",Y10=1,Xx=1e4;var Zx=()=>{};import eH from"fs";import Jx from"path";class $L{storage;storagePath;dirty=!1;constructor($){this.storagePath=Jx.join($,G10),this.storage=this.loadStorage()}loadStorage(){try{let $=eH.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:K10,bookmarks:[]}}}async save(){if(!this.dirty)return;let $=Jx.dirname(this.storagePath);await eH.promises.mkdir($,{recursive:!0}),await eH.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark($,X,Z,J={}){let Y={id:W10(),name:J.name||`${$}/${X}`,storyId:$,variantId:X,props:Z,created:Date.now(),notes:J.notes,color:J.color};return this.storage.bookmarks.push(Y),this.dirty=!0,Y}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory($){return this.storage.bookmarks.filter((X)=>X.storyId===$)}getBookmark($){return this.storage.bookmarks.find((X)=>X.id===$)}isBookmarked($,X){return this.storage.bookmarks.some((Z)=>Z.storyId===$&&Z.variantId===X)}updateBookmark($,X){let Z=this.getBookmark($);if(!Z)return;return Object.assign(Z,X),this.dirty=!0,Z}deleteBookmark($){let X=this.storage.bookmarks.findIndex((Z)=>Z.id===$);if(X===-1)return!1;return this.storage.bookmarks.splice(X,1),this.dirty=!0,!0}toggleBookmark($,X,Z){let J=this.storage.bookmarks.find((Q)=>Q.storyId===$&&Q.variantId===X);if(J)return this.deleteBookmark(J.id),{added:!1};return{added:!0,bookmark:this.addBookmark($,X,Z)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks($,X=!0){let Z=JSON.parse($),J=0;for(let Y of Z.bookmarks){if(X){let Q=this.storage.bookmarks.find((G)=>G.id===Y.id);if(Q)Object.assign(Q,Y);else this.storage.bookmarks.push(Y)}else this.storage.bookmarks.push(Y);J++}if(J>0)this.dirty=!0;return J}}function W10(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var G10=".stx/story/bookmarks.json",K10=1;var Yx=()=>{};import XL from"fs";import rZ from"path";async function aZ($){let{root:X,config:Z}=$,J=[],Y=await U10(X,Z.storyMatch,Z.storyIgnored);for(let Q of Y){let G=rZ.resolve(X,Q),K=ZL(Q,G);J.push(K)}return J}async function U10($,X,Z){let J=[];async function Y(Q,G){let K=await XL.promises.readdir(Q,{withFileTypes:!0});for(let W of K){let U=rZ.join(Q,W.name),z=rZ.relative(G,U);if(Qx(z,Z))continue;if(W.isDirectory())await Y(U,G);else if(W.isFile()){if(Gx(z,X))J.push(z)}}}return await Y($,$),J}function Qx($,X){for(let Z of X)if(Kx($,Z))return!0;return!1}function Gx($,X){for(let Z of X)if(Kx($,Z))return!0;return!1}function Kx($,X){let Z=$.replace(/\\/g,"/"),Y=X.replace(/\\/g,"/").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\?/g,".").replace(/\{\{GLOBSTAR\}\}/g,".*");return Y=`^${Y}$`,new RegExp(Y).test(Z)}function ZL($,X){let Z=rZ.basename($,".story.stx");return{id:$.toLowerCase().replace(/\.story\.stx$/,"").replace(/[/\\]/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),path:X,relativePath:$,fileName:Z,treeFile:{title:Z,path:$}}}function Wx($,X){let{root:Z,config:J}=$,Y=[],Q=XL.watch(Z,{recursive:!0},async(G,K)=>{if(!K)return;let W=K.replace(/\\/g,"/");if(!Gx(W,J.storyMatch))return;if(Qx(W,J.storyIgnored))return;let U=rZ.resolve(Z,W);try{await XL.promises.access(U);let z=ZL(W,U);X(G==="rename"?"add":"change",z)}catch{let z=ZL(W,U);X("unlink",z)}});return Y.push(Q),()=>{for(let G of Y)G.close()}}var JL=()=>{};function z10($,X){let Z=X.treeFile||{title:X.fileName,path:X.relativePath};if($.tree.file==="title")return Z.title.split("/");if($.tree.file==="path")return[...X.relativePath.split("/").slice(0,-1),Z.title];if(typeof $.tree.file==="function")return $.tree.file(Z);return[Z.title]}function sZ($,X){for(let G of X)G.treePath=z10($,G);let Z=($.tree.groups||[]).map((G)=>({groupConfig:{id:G.id||G.title,title:G.title,include:G.include},treeObject:{}})),J={treeObject:{}};Z.push(J);for(let G=0;G<X.length;G++){let K=X[G],W=q10(K,Z,J);j10(K.treePath,G,W.treeObject)}let Y=$.tree.order==="asc"?(G,K)=>G.localeCompare(K):$.tree.order,Q=[];for(let G of Z)if(G===J)Q.push(...YL(G.treeObject,Y));else if(G.groupConfig&&Object.keys(G.treeObject).length>0)Q.push({group:!0,id:G.groupConfig.id,title:G.groupConfig.title,children:YL(G.treeObject,Y)});return Q}function q10($,X,Z){let J=$.treeFile||{title:$.fileName,path:$.relativePath};for(let Y of X)if(Y.groupConfig?.include&&Y.groupConfig.include(J))return Y;return Z}function j10($,X,Z){let J=Z;for(let Y=0;Y<$.length;Y++){let Q=$[Y];if(Y===$.length-1)if(J[Q]!==void 0){let K=1;while(J[`${Q}-${K}`]!==void 0)K++;J[`${Q}-${K}`]=X}else J[Q]=X;else{if(J[Q]===void 0)J[Q]={};else if(typeof J[Q]==="number"){let K=J[Q];J[Q]={"":K}}J=J[Q]}}}function YL($,X){let Z=[];for(let[J,Y]of Object.entries($))if(typeof Y==="number")Z.push({title:J,index:Y});else Z.push({title:J,children:YL(Y,X)});return Z.sort((J,Y)=>X(J.title,Y.title)),Z}function Ux(){return{open($){bQ.add($),$.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close($){bQ.delete($)},message($,X){}}}function QL($){let X=JSON.stringify({...$,timestamp:$.timestamp||Date.now()});for(let Z of bQ)try{Z.send(X)}catch{bQ.delete(Z)}}function zx($,X){QL({type:"story-update",data:{storyId:$,...X}})}function qx($,X){QL({type:"story-add",data:{storyId:$,...X}})}function jx($){QL({type:"story-remove",data:{storyId:$}})}function _x($){return`
25979
25979
  <script>
25980
25980
  (function() {
25981
25981
  const ws = new WebSocket('${$}');
@@ -27373,7 +27373,7 @@ else {
27373
27373
  `)}function Zv($,X){let Z=" ".repeat(X),J=[];for(let[K,W]of Object.entries($.props))if(W.type==="literal"){let U=typeof W.value==="string"?`"${W.value}"`:String(W.value);J.push(`${K}: ${U}`)}let Y=J.length>0?`{ ${J.join(", ")} }`:"{}",Q=$.children.map((K)=>K.type==="text"?`"${K.props.text?.type==="literal"?K.props.text.value:""}"`:Zv(K,X+1)),G=Q.length>0?`,
27374
27374
  ${Z} [${Q.join(`,
27375
27375
  ${Z} `)}]`:"";return`Craft.create("${$.zigType}", ${Y}${G})`}function e10($,X,Z){if(X.target==="universal"){let J=[];J.push("// Universal entry point"),J.push("");for(let[Y,Q]of Z)J.push(`// --- ${Y.toUpperCase()} ---`),J.push(`#if ${Y.toUpperCase()}`),J.push(Q),J.push("#endif"),J.push("");return J.join(`
27376
- `)}return Z.get(X.target)||zL($,X)}function $$0($,X,Z){let J=[];function Y(Q){J.push({name:Q.zigType,hash:Yv(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)Y(G)}return Y(X),{version:"1.0.0",components:J,entry:$.id,assets:[],styles:$.styles}}function X$0($,X){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function Jv(){return`id_${++Z$0}`}function Yv($){let X=0;for(let Z=0;Z<$.length;Z++){let J=$.charCodeAt(Z);X=(X<<5)-X+J,X=X&X}return Math.abs(X).toString(36)}function J$0($){return $.charAt(0).toUpperCase()+$.slice(1)}function Y$0($){let X=[],Z=/<script[^>]*>([\s\S]*?)<\/script>/gi,J;while((J=Z.exec($))!==null)X.push(J[1]);return X}function Q$0($){let X=[],Z=/<style[^>]*>([\s\S]*?)<\/style>/gi,J;while((J=Z.exec($))!==null)X.push(J[1]);return X}function qL($){let X=$.type==="component"?1:0;if($.children)for(let Z of $.children)X+=qL(Z);return X}function jL($){let X=$.zigType.startsWith("craft.")?1:0;for(let Z of $.children)X+=jL(Z);return X}function Qv($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(X)=>{console.log(`[craft-compiler] File changed: ${X}`)}}}var _L,Z$0=0,G$0,K$0;var Kv=T(()=>{_L=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);G$0={compileToNative:ox,createHotReloadServer:Qv,NATIVE_COMPONENTS:_L},K$0=G$0});import{spawn as zv}from"child_process";import t0 from"fs";import W$0 from"os";import K0 from"path";import g from"process";import{CLI as U$0}from"@stacksjs/clapp";var I6="0.2.190";k8();fH();bj();dj();h4();hj();Tj();b6();EH();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",C0=new U$0("stx");function Wv($){let X=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(X))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(X<1024||X>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function Uv($){try{if(!t0.existsSync($)){let Z=K0.dirname($),J=K0.basename($);if(t0.existsSync(Z)){let Q=t0.readdirSync(Z).filter((K)=>K.toLowerCase().includes(J.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Z}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Z} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(t0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(X){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function HL($){let X=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(X))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(X<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(X>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var s7=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),z$0=($)=>$.endsWith(".stx")||$.endsWith(".md");function a7($,X=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);g.exit(X)}function q$0($){if(!$)return;let X;try{X=JSON.parse($)}catch(Z){console.error(`\u274C --info-plist is not valid JSON: ${Z.message}`),g.exit(1)}if(typeof X!=="object"||X===null||Array.isArray(X))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),g.exit(1);for(let[Z,J]of Object.entries(X))if(typeof J!=="string"&&typeof J!=="number"&&typeof J!=="boolean")console.error(`\u274C --info-plist value for "${Z}" must be a string, number or boolean`),g.exit(1);return X}async function j$0($,X){try{let Z=["test"],J=[];if($&&$.length>0)for(let W of $)if(s7(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(J.push(...U),X.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else J.push(W);if(J.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Z.push(...J),X.filter)Z.push("--pattern",X.filter);if(X.timeout)Z.push("--timeout",X.timeout.toString());if(X.reporter&&X.reporter!=="default")if(X.reporter==="junit"){let W=K0.join(W$0.tmpdir(),`stx-test-report-${Date.now()}.xml`);Z.push("--reporter",X.reporter),Z.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${X.reporter}' is not supported. Using default reporter.`);if(X.coverage)Z.push("--coverage");if(X.watch)Z.push("--watch");Z.push("--preload",K0.join(__dirname,"../../../test-utils/happy-dom.ts"));let Y={...g.env,STX_TEST_MODE:"true",STX_TEST_UI:X.ui?"true":"false",STX_TEST_VERBOSE:X.verbose?"true":"false"},Q="bun";if(X.verbose)console.log(`Running: ${Q} ${Z.join(" ")}`);let G=performance.now(),K=zv(Q,Z,{stdio:"inherit",shell:!1,env:Y});return new Promise((W)=>{K.on("close",(U)=>{let q=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),g.on("SIGINT",()=>{console.log(`
27376
+ `)}return Z.get(X.target)||zL($,X)}function $$0($,X,Z){let J=[];function Y(Q){J.push({name:Q.zigType,hash:Yv(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)Y(G)}return Y(X),{version:"1.0.0",components:J,entry:$.id,assets:[],styles:$.styles}}function X$0($,X){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function Jv(){return`id_${++Z$0}`}function Yv($){let X=0;for(let Z=0;Z<$.length;Z++){let J=$.charCodeAt(Z);X=(X<<5)-X+J,X=X&X}return Math.abs(X).toString(36)}function J$0($){return $.charAt(0).toUpperCase()+$.slice(1)}function Y$0($){let X=[],Z=/<script[^>]*>([\s\S]*?)<\/script>/gi,J;while((J=Z.exec($))!==null)X.push(J[1]);return X}function Q$0($){let X=[],Z=/<style[^>]*>([\s\S]*?)<\/style>/gi,J;while((J=Z.exec($))!==null)X.push(J[1]);return X}function qL($){let X=$.type==="component"?1:0;if($.children)for(let Z of $.children)X+=qL(Z);return X}function jL($){let X=$.zigType.startsWith("craft.")?1:0;for(let Z of $.children)X+=jL(Z);return X}function Qv($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(X)=>{console.log(`[craft-compiler] File changed: ${X}`)}}}var _L,Z$0=0,G$0,K$0;var Kv=T(()=>{_L=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);G$0={compileToNative:ox,createHotReloadServer:Qv,NATIVE_COMPONENTS:_L},K$0=G$0});import{spawn as zv}from"child_process";import t0 from"fs";import W$0 from"os";import K0 from"path";import g from"process";import{CLI as U$0}from"@stacksjs/clapp";var I6="0.2.191";k8();fH();bj();dj();h4();hj();Tj();b6();EH();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",C0=new U$0("stx");function Wv($){let X=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(X))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(X<1024||X>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function Uv($){try{if(!t0.existsSync($)){let Z=K0.dirname($),J=K0.basename($);if(t0.existsSync(Z)){let Q=t0.readdirSync(Z).filter((K)=>K.toLowerCase().includes(J.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Z}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Z} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(t0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(X){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function HL($){let X=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(X))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(X<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(X>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var s7=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),z$0=($)=>$.endsWith(".stx")||$.endsWith(".md");function a7($,X=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);g.exit(X)}function q$0($){if(!$)return;let X;try{X=JSON.parse($)}catch(Z){console.error(`\u274C --info-plist is not valid JSON: ${Z.message}`),g.exit(1)}if(typeof X!=="object"||X===null||Array.isArray(X))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),g.exit(1);for(let[Z,J]of Object.entries(X))if(typeof J!=="string"&&typeof J!=="number"&&typeof J!=="boolean")console.error(`\u274C --info-plist value for "${Z}" must be a string, number or boolean`),g.exit(1);return X}async function j$0($,X){try{let Z=["test"],J=[];if($&&$.length>0)for(let W of $)if(s7(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(J.push(...U),X.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else J.push(W);if(J.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Z.push(...J),X.filter)Z.push("--pattern",X.filter);if(X.timeout)Z.push("--timeout",X.timeout.toString());if(X.reporter&&X.reporter!=="default")if(X.reporter==="junit"){let W=K0.join(W$0.tmpdir(),`stx-test-report-${Date.now()}.xml`);Z.push("--reporter",X.reporter),Z.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${X.reporter}' is not supported. Using default reporter.`);if(X.coverage)Z.push("--coverage");if(X.watch)Z.push("--watch");Z.push("--preload",K0.join(__dirname,"../../../test-utils/happy-dom.ts"));let Y={...g.env,STX_TEST_MODE:"true",STX_TEST_UI:X.ui?"true":"false",STX_TEST_VERBOSE:X.verbose?"true":"false"},Q="bun";if(X.verbose)console.log(`Running: ${Q} ${Z.join(" ")}`);let G=performance.now(),K=zv(Q,Z,{stdio:"inherit",shell:!1,env:Y});return new Promise((W)=>{K.on("close",(U)=>{let q=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),g.on("SIGINT",()=>{console.log(`
27377
27377
  Test run interrupted`),K.kill("SIGINT"),g.exit(1)})})}catch(Z){return console.error("Error running tests:",Z instanceof Error?Z.message:String(Z)),!1}}var _$0=g.argv.length>=3&&(z$0(g.argv[2])&&t0.existsSync(g.argv[2])||s7(g.argv[2]));if(_$0){let $=g.argv[2],X={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let Z=3;Z<g.argv.length;Z++){let J=g.argv[Z];if(J==="--port"&&Z+1<g.argv.length){let Y=Wv(g.argv[++Z]);if(!Y.isValid)a7(Y);X.port=Number.parseInt(g.argv[Z],10)}else if(J==="--no-watch")X.watch=!1;else if(J==="--highlight-theme"&&Z+1<g.argv.length){if(!X.markdown)X.markdown={};if(!X.markdown.syntaxHighlighting)X.markdown.syntaxHighlighting={};X.markdown.syntaxHighlighting.defaultTheme=g.argv[++Z]}else if(J==="--no-highlight"){if(!X.markdown)X.markdown={};if(!X.markdown.syntaxHighlighting)X.markdown.syntaxHighlighting={};X.markdown.syntaxHighlighting.enabled=!1}else if(J==="--no-highlight-unknown"){if(!X.markdown)X.markdown={};if(!X.markdown.syntaxHighlighting)X.markdown.syntaxHighlighting={};X.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(J==="--no-cache")X.cache=!1;else if(J==="--native")X.native=!0}if(s7($))try{let Z=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),J=$.endsWith(".stx")?Z.filter((K)=>K.endsWith(".stx")):$.endsWith(".md")?Z.filter((K)=>K.endsWith(".md")):Z.filter((K)=>K.endsWith(".stx")||K.endsWith(".md")),Y=$.split("*")[0].replace(/\/$/,"")||".",Q=K0.resolve(Y);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((z)=>/\[.+\]/.test(K0.basename(z)));for(let z of U)if(!J.includes(z))J.push(z)}catch{}if(J.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),g.exit(1);if(!await xZ(J,X))g.exit(1)}catch(Z){console.error("Failed to process files:",Z),g.exit(1)}else yZ($,X).catch((Z)=>{console.error("Failed to start dev server:",Z),g.exit(1)})}else{let $=function(J,Y){let Q=[];for(let G=0;G<=Y.length;G++)Q[G]=[G];for(let G=0;G<=J.length;G++)Q[0][G]=G;for(let G=1;G<=Y.length;G++)for(let K=1;K<=J.length;K++)if(Y.charAt(G-1)===J.charAt(K-1))Q[G][K]=Q[G-1][K-1];else Q[G][K]=Math.min(Q[G-1][K-1]+1,Q[G][K-1]+1,Q[G-1][K]+1);return Q[Y.length][J.length]};C0.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(J)=>{try{if(await Pj(J))console.log("Documentation generated successfully."),g.exit(0);else console.error("Documentation generation failed."),g.exit(1)}catch(Y){console.error("Error generating documentation:",Y),g.exit(1)}}),C0.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(J,Y)=>{try{let{fetchCollections:Q,generatePackage:G}=await Promise.resolve().then(() => (Gy(),Qy));if(J==="list"){console.log(`
27378
27378
  \uD83D\uDCDA Fetching available icon collections...
27379
27379
  `);let K=await Q(),W=Object.entries(K).sort((U,z)=>z[1].total-U[1].total);console.log(`Available collections:
@@ -27542,6 +27542,6 @@ Press Ctrl+C to stop watching...
27542
27542
  `);let U=t0.readFileSync(G,"utf-8"),z=await Q(U,{target:Y.target,format:Y.format,optimize:Y.optimize,treeShake:Y.treeShake,hotReload:Y.hotReload,debug:Y.verbose,sourceMaps:Y.sourcemaps,bundle:Y.bundle,minify:Y.minify}),q=K0.resolve(Y.output);if(!t0.existsSync(q))t0.mkdirSync(q,{recursive:!0});let j=K0.basename(J,K0.extname(J)),_=Y.format==="typescript"?"ts":Y.format==="json"?"json":"zig",H=K0.join(q,`${j}.${_}`);t0.writeFileSync(H,z.code);let L=K0.join(q,`${j}.manifest.json`);if(t0.writeFileSync(L,JSON.stringify(z.manifest,null,2)),Y.sourcemaps&&z.sourceMaps){let O=K0.join(q,`${j}.${_}.map`);t0.writeFileSync(O,z.sourceMaps)}if(Y.target==="universal"&&z.platformCode.size>0)for(let[O,B]of z.platformCode){let F=K0.join(q,`${j}.${O}.${_}`);t0.writeFileSync(F,B)}if(console.log("\u2705 Compilation successful!"),console.log(` Output: ${H}`),console.log(` Manifest: ${L}`),console.log(`
27543
27543
  \uD83D\uDCCA Statistics:`),console.log(` Compilation time: ${z.stats.compilationTime.toFixed(2)}ms`),console.log(` Total components: ${z.stats.totalComponents}`),console.log(` Native components: ${z.stats.nativeComponents}`),console.log(` Web fallback components: ${z.stats.webComponents}`),console.log(` Bundle size: ${(z.stats.bundleSize/1024).toFixed(2)}KB`),z.stats.warnings.length>0){console.log(`
27544
27544
  \u26A0\uFE0F Warnings:`);for(let O of z.stats.warnings)console.log(` - ${O.message}`)}if(z.stats.errors.length>0){console.log(`
27545
- \u274C Errors:`);for(let O of z.stats.errors)console.log(` - ${O.message}`)}}catch(Q){console.error(`\u274C Compilation error: ${Q.message}`),g.exit(1)}});let X=C0.commands.flatMap((J)=>[J.name,...J.aliasNames??[]]).filter((J)=>Boolean(J)),Z=g.argv.slice(2);if(Z.length>0&&!Z[0].startsWith("-")){let J=Z[0];if(J==="")console.error("\u274C No command provided"),console.error("\uD83D\uDCA1 Use --help to see available commands"),g.exit(1);if(!X.includes(J)){let Y=J0("fs"),Q=J0("path"),G=J;if(!Q.isAbsolute(G))G=Q.resolve(g.cwd(),G);if(Y.existsSync(G)){let K=Y.statSync(G);if(K.isFile()||K.isDirectory())g.argv=[g.argv[0],g.argv[1],"dev",...Z]}else{let K=X.map((U)=>({command:U,distance:$(J,U)}));K.sort((U,z)=>U.distance-z.distance);let W=K[0];if(W.distance<=3)console.error(`\u274C Unknown command: ${J}`),console.error(`\uD83D\uDCA1 Did you mean: ${W.command}?`),console.error(`
27545
+ \u274C Errors:`);for(let O of z.stats.errors)console.log(` - ${O.message}`)}}catch(Q){console.error(`\u274C Compilation error: ${Q.message}`),g.exit(1)}});let X=C0.commands.flatMap((J)=>[J.name,...J.aliasNames??[]]).filter((J)=>Boolean(J)),Z=g.argv.slice(2);if(Z.length>0&&!Z[0].startsWith("-")){let J=Z[0];if(J==="")console.error("\u274C No command provided"),console.error("\uD83D\uDCA1 Use --help to see available commands"),g.exit(1);if(!X.includes(J)){let Y=Y0("fs"),Q=Y0("path"),G=J;if(!Q.isAbsolute(G))G=Q.resolve(g.cwd(),G);if(Y.existsSync(G)){let K=Y.statSync(G);if(K.isFile()||K.isDirectory())g.argv=[g.argv[0],g.argv[1],"dev",...Z]}else{let K=X.map((U)=>({command:U,distance:$(J,U)}));K.sort((U,z)=>U.distance-z.distance);let W=K[0];if(W.distance<=3)console.error(`\u274C Unknown command: ${J}`),console.error(`\uD83D\uDCA1 Did you mean: ${W.command}?`),console.error(`
27546
27546
  Run 'stx --help' to see available commands.`),g.exit(1);console.error(`\u274C Unknown command or path: ${J}`),console.error(`
27547
27547
  Run 'stx --help' to see available commands.`),g.exit(1)}}}C0.help(),C0.version(I6),C0.parse(g.argv)}