@stacksjs/stx 0.2.84 → 0.2.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/app-shell.js +50 -50
  2. package/dist/build-mode-detector.js +95 -95
  3. package/dist/build-views.js +149 -149
  4. package/dist/build.js +37 -37
  5. package/dist/cli.js +51 -51
  6. package/dist/component-processing.js +16 -16
  7. package/dist/component-renderer.js +32 -32
  8. package/dist/components.js +95 -95
  9. package/dist/dev-server/index.js +36 -36
  10. package/dist/dev-server/serve-app.js +50 -50
  11. package/dist/dev-server/serve-file.js +50 -50
  12. package/dist/dev-server/serve-markdown.js +36 -36
  13. package/dist/dev-server/serve-multi.js +49 -49
  14. package/dist/dev-server.js +50 -50
  15. package/dist/docs.js +96 -96
  16. package/dist/dynamic-components.js +32 -32
  17. package/dist/includes.js +32 -32
  18. package/dist/index.js +50 -50
  19. package/dist/interactive.js +96 -96
  20. package/dist/lazy-loader.js +95 -95
  21. package/dist/plugin.js +44 -44
  22. package/dist/process.js +31 -31
  23. package/dist/production-builder.js +31 -31
  24. package/dist/production-server.js +31 -31
  25. package/dist/pwa/index.js +95 -95
  26. package/dist/pwa/offline.js +95 -95
  27. package/dist/pwa.js +84 -84
  28. package/dist/render.js +153 -153
  29. package/dist/serve.js +106 -106
  30. package/dist/site-builder/build.js +97 -97
  31. package/dist/site-builder/index.js +38 -38
  32. package/dist/ssg.js +13 -13
  33. package/dist/ssr.js +83 -83
  34. package/dist/story/cli.js +36 -36
  35. package/dist/story/commands/dev.js +36 -36
  36. package/dist/story/commands/index.js +36 -36
  37. package/dist/story/index.js +36 -36
  38. package/dist/story/renderer.js +96 -96
  39. package/dist/story/server.js +36 -36
  40. package/dist/story/visual-testing.js +96 -96
  41. package/dist/streaming.js +32 -32
  42. package/dist/template-compiler.js +24 -24
  43. package/dist/template-hydrator.js +110 -110
  44. package/dist/testing.js +95 -95
  45. package/dist/utils.js +32 -32
  46. package/dist/variable-extractor.js +11 -11
  47. package/dist/web-components.js +95 -95
  48. package/package.json +7 -5
package/dist/app-shell.js CHANGED
@@ -26,7 +26,7 @@ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FO
26
26
  `),J&&!J.endsWith(`
27
27
  `))J+=`
28
28
  `}J+=`NETLIFY_SITE_ID=${$.siteId}
29
- `,await Bun.write(X,J)}return{configPath:Y,siteId:$.siteId}}function _F($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var V$;var MY=D(()=>{AY();AY();V$=class V$ extends Error{code;constructor($,Z){super($);this.name="DeployError",this.code=Z}}});var YK={};Z0(YK,{resizeAndConvert:()=>ZK,processImage:()=>d1,isSharpAvailable:()=>U4,isImageFile:()=>B4,isImageBackendAvailable:()=>h1,groupVariantsByFormat:()=>h5,getTotalSize:()=>L3,getMimeType:()=>R1,getImageMetadata:()=>v5,getFallbackVariant:()=>g5,generateSrcSet:()=>G5,generateSizes:()=>f5,formatSize:()=>F3,ImageProcessingError:()=>d5,DEFAULT_WIDTHS:()=>N1,DEFAULT_QUALITY:()=>w1,DEFAULT_FORMATS:()=>A1});import IY from"fs";import x5 from"path";import eG from"os";import EY from"crypto";import{generatePlaceholder as zF,processImage as qF}from"ts-images";async function O3(){if(tG)return TY;tG=!0;try{let $=await import("sharp");return TY=$.default||$,TY}catch{return null}}async function U4(){return await O3()!==null}async function h1(){return!0}async function d1($,Z={}){let{widths:Y=N1,formats:X=A1,quality:J=w1,fit:Q="cover",placeholder:G="none",outputDir:K=".stx/images",baseUrl:W="/images"}=Z,U,B;if(typeof $==="string"){if(B=$,!await Bun.file($).exists())throw new d5(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((N)=>Buffer.from(N))}else B="buffer-input",U=$;let _=EY.createHash("sha256").update(U).digest("hex").slice(0,12),z=await v5(U),{width:q,height:j}=z,H=q/j;await IY.promises.mkdir(K,{recursive:!0});let O=[],F=x5.basename(B,x5.extname(B)),L=Y.filter((N)=>N<=q);if(!L.includes(q)&&q<=Math.max(...Y))L.push(q);L.sort((N,A)=>N-A);for(let N of L){let A=Math.round(N/H);for(let w of X){let R=`${F}-${N}w-${_}.${w}`,T=x5.join(K,R),I=`${W}/${R}`,E=await ZK(U,{width:N,height:A,format:w,quality:J,fit:Q});await Bun.write(T,E),O.push({path:T,url:I,width:N,height:A,format:w,size:E.length})}}let V;if(G!=="none")V=await OF(U,G);return{src:B,variants:O,placeholder:V,width:q,height:j,aspectRatio:H,hash:_}}async function v5($){let Z=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Y=await O3();if(Y){let J=await Y(Z).metadata();return{width:J.width||0,height:J.height||0,format:J.format||"unknown",hasAlpha:J.hasAlpha}}return HF(Z)}function HF($){if($[0]===137&&$[1]===80&&$[2]===78&&$[3]===71){let Z=$.readUInt32BE(16),Y=$.readUInt32BE(20);return{width:Z,height:Y,format:"png",hasAlpha:!0}}if($[0]===255&&$[1]===216){let Z=2;while(Z<$.length){if($[Z]!==255)break;let Y=$[Z+1];if(Y>=192&&Y<=207&&Y!==196&&Y!==200&&Y!==204){let J=$.readUInt16BE(Z+5);return{width:$.readUInt16BE(Z+7),height:J,format:"jpeg",hasAlpha:!1}}let X=$.readUInt16BE(Z+2);Z+=2+X}}if($.toString("utf8",0,4)==="RIFF"&&$.toString("utf8",8,12)==="WEBP"){let Z=$.toString("utf8",12,16);if(Z==="VP8 "){let Y=$.readUInt16LE(26)&16383,X=$.readUInt16LE(28)&16383;return{width:Y,height:X,format:"webp",hasAlpha:!1}}if(Z==="VP8L"){let Y=$.readUInt32LE(21),X=(Y&16383)+1,J=(Y>>14&16383)+1;return{width:X,height:J,format:"webp",hasAlpha:!0}}}if($.toString("utf8",0,3)==="GIF"){let Z=$.readUInt16LE(6),Y=$.readUInt16LE(8);return{width:Z,height:Y,format:"gif",hasAlpha:!0}}throw new d5("Unable to parse image dimensions","PARSE_ERROR")}async function ZK($,Z){let Y=await O3();if(Y){let J=Y($).resize(Z.width,Z.height,{fit:Z.fit});switch(Z.format){case"webp":J=J.webp({quality:Z.quality});break;case"avif":J=J.avif({quality:Z.quality});break;case"jpeg":J=J.jpeg({quality:Z.quality});break;case"png":J=J.png({quality:Z.quality});break}return J.toBuffer()}let X=x5.join(eG.tmpdir(),`stx-img-${EY.randomBytes(8).toString("hex")}.${Z.format}`);try{return await qF({input:$,output:X,format:Z.format,quality:Z.quality,resize:{width:Z.width,height:Z.height,fit:Z.fit}}),Buffer.from(await Bun.file(X).arrayBuffer())}finally{await IY.promises.unlink(X).catch(()=>{})}}async function OF($,Z){let Y=await O3();if(Z==="blur"&&Y){let G=(await Y($).resize(20).blur(10).toBuffer()).toString("base64"),K=await v5($);return`data:${$K[K.format]||"image/jpeg"};base64,${G}`}if(Z==="dominant-color"&&Y){let{dominant:Q}=await Y($).resize(1,1).toBuffer().then(async(G)=>{let K=await Y(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 X=await v5($),J=x5.join(eG.tmpdir(),`stx-ph-${EY.randomBytes(8).toString("hex")}.${X.format==="unknown"?"bin":X.format}`);try{await Bun.write(J,$);let Q=Z==="blur"?"blur":Z==="thumbhash"?"thumbhash":"dominant-color",K=await zF(J,{strategy:Q,width:Q==="thumbhash"?void 0:32});if(Z==="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 IY.promises.unlink(J).catch(()=>{})}}function G5($,Z){return(Z?$.filter((X)=>X.format===Z):$).sort((X,J)=>X.width-J.width).map((X)=>`${X.url} ${X.width}w`).join(", ")}function f5($){if(!$||Object.keys($).length===0)return"100vw";return Object.entries($).sort((Y,X)=>{let J=Number.parseInt(Y[0].replace(/\D/g,""))||0;return(Number.parseInt(X[0].replace(/\D/g,""))||0)-J}).map(([Y,X])=>`(max-width: ${Y}) ${X}`).join(", ")+", 100vw"}function g5($){let Z=$.filter((X)=>X.format==="jpeg");if(Z.length===0)return $[Math.floor($.length/2)];let Y=Z.sort((X,J)=>X.width-J.width);return Y[Math.floor(Y.length/2)]}function h5($){let Z=new Map;for(let Y of $){let X=Z.get(Y.format)||[];X.push(Y),Z.set(Y.format,X)}return Z}function B4($){let Z=x5.extname($).toLowerCase();return jF.includes(Z)}function R1($){return $K[$]||"application/octet-stream"}function L3($){return $.reduce((Z,Y)=>Z+Y.size,0)}function F3($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var N1,A1,w1=80,jF,$K,TY=null,tG=!1,d5;var K5=D(()=>{N1=[320,640,768,1024,1280,1536,1920],A1=["webp","jpeg"],jF=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],$K={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};d5=class d5 extends Error{code;constructor($,Z){super($);this.name="ImageProcessingError",this.code=Z}}});var XK={};Z0(XK,{rewriteImagesWithSiblings:()=>DY});import e1 from"path";async function DY($,Z){let Y=Z.formats??FF;if(!Z.publicDir)return $;let X=AF($),J=[],Q=/<img\b[^>]*?>/gi,G=[],K;while((K=Q.exec($))!==null){let _=K[0],z=_.match(/\bsrc=["']([^"']+)["']/i);if(!z)continue;if(wF(K.index,X))continue;G.push({idx:K.index,length:_.length,src:z[1],raw:_})}if(G.length===0)return $;let W=await Promise.all(G.map(async(_)=>{let z=await VF(_.src,Z.publicDir,Y);return{match:_,sources:z}}));for(let{match:_,sources:z}of W){if(z.length===0)continue;let j=`<picture>${z.map((H)=>`<source type="${H.mime}" srcset="${RF(H.url)}">`).join("")}${_.raw}</picture>`;J.push({start:_.idx,end:_.idx+_.length,replacement:j})}if(J.length===0)return $;let U="",B=0;for(let _ of J)U+=$.slice(B,_.start),U+=_.replacement,B=_.end;return U+=$.slice(B),U}async function VF($,Z,Y){if(!NF($))return[];let X=e1.extname($).toLowerCase();if(!LF.has(X))return[];if(!$.startsWith("/"))return[];let J=e1.join(Z,$.slice(1)),Q=e1.dirname(J),G=e1.basename(J,X),K=e1.resolve(Q),W=e1.resolve(Z);if(!K.startsWith(W))return[];let U=e1.posix.dirname($),B=Y.map(async(z)=>{let q=e1.join(Q,`${G}${z.ext}`);if(!await Bun.file(q).exists())return null;return{url:e1.posix.join(U,`${G}${z.ext}`),mime:z.mime}});return(await Promise.all(B)).filter((z)=>z!==null)}function NF($){if(!$)return!1;if($.startsWith("http://")||$.startsWith("https://"))return!1;if($.startsWith("//"))return!1;if($.startsWith("data:"))return!1;return!0}function AF($){let Z=[],Y=/<picture\b[^>]*>[\s\S]*?<\/picture>/gi,X;while((X=Y.exec($))!==null)Z.push([X.index,X.index+X[0].length]);return Z}function wF($,Z){for(let[Y,X]of Z)if($>=Y&&$<X)return!0;return!1}function RF($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}var LF,FF;var kY=D(()=>{LF=new Set([".jpg",".jpeg",".png",".gif"]),FF=[{ext:".avif",mime:"image/avif"},{ext:".webp",mime:"image/webp"}]});var WK={};Z0(WK,{handleImageRequest:()=>V3,createImageHandler:()=>SY});import JK from"fs";import _4 from"path";import MF from"crypto";async function V3($,Z){let Y=Z.routePath??"/_stx/img",X=new URL($.url);if(X.pathname!==Y)return null;let J=DF(X,Z);if(!J.ok)return new Response(J.error,{status:J.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:Q,srcUrl:G,width:K,height:W,format:U,quality:B,fit:_}=J,z;try{z=JK.statSync(Q)}catch{return new Response(`Source image not found: ${G}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!z.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let q=Z.cacheDir??".stx/cache/img";await JK.promises.mkdir(q,{recursive:!0});let j=`${Q}:${z.mtimeMs}:${z.size}`,H=`${K}x${W}:${U}:${B}:${_}`,O=MF.createHash("sha256").update(`${j}|${H}`).digest("hex").slice(0,16),F=_4.join(q,`${O}.${U}`),V={"Content-Type":R1(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 N=Bun.file(F);if(await N.exists())return new Response(N,{headers:V});try{let A=Buffer.from(await Bun.file(Q).arrayBuffer()),{resizeAndConvert:w}=await kF(),R=await w(A,{width:K,height:W,format:U,quality:B,fit:_});return await Bun.write(F,R),V["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(R),{headers:V})}catch(A){let w=A.message;return new Response(`Image processing failed: ${w}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function SY($){return async(Z)=>{return await V3(Z,$)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}}function DF($,Z){let Y=$.searchParams.get("src");if(!Y)return{ok:!1,error:"Missing required param: src",status:400};if(!Y.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(Y.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let X=_4.extname(Y).toLowerCase();if(!TF.has(X))return{ok:!1,error:`Unsupported source extension: ${X}`,status:400};let J=_4.resolve(Z.publicDir),Q=_4.resolve(J,Y.slice(1));if(!Q.startsWith(`${J}${_4.sep}`)&&Q!==J)return{ok:!1,error:"src is outside publicDir",status:400};let G=Z.maxWidth??KK,K=Z.maxHeight??KK,W=$.searchParams.get("w"),U=$.searchParams.get("h"),B=W?Number.parseInt(W,10):0,_=U?Number.parseInt(U,10):0;if(W&&(!Number.isFinite(B)||B<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(U&&(!Number.isFinite(_)||_<=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 z=Math.min(B||G,G),q=Math.min(_||K,K),j=$.searchParams.get("f")||"webp";if(!QK.has(j))return{ok:!1,error:`Invalid f (must be one of: ${[...QK].join(", ")})`,status:400};let H=j,O=$.searchParams.get("q"),F=O?Number.parseInt(O,10):Z.defaultQuality??IF;if(!Number.isFinite(F)||F<1||F>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let L=$.searchParams.get("fit")||Z.defaultFit||EF;if(!GK.has(L))return{ok:!1,error:`Invalid fit (must be one of: ${[...GK].join(", ")})`,status:400};return{ok:!0,srcFsPath:Q,srcUrl:Y,width:z,height:q,format:H,quality:F,fit:L}}async function kF(){return await Promise.resolve().then(() => (K5(),YK))}var QK,GK,TF,KK=4096,IF=80,EF="cover";var bY=D(()=>{K5();QK=new Set(["webp","avif","jpeg","png"]),GK=new Set(["cover","contain","fill","inside","outside"]),TF=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"])});function UK($,Z={}){let{src:Y,alt:X,width:J,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=w1,placeholder:B="none",formats:_=A1,widths:z=N1,decoding:q="async",fetchpriority:j,objectFit:H,objectPosition:O}=$,F=$.class,L=$.style,{processedImage:V,variants:N,optimize:A=!0,isDev:w=!1}=Z;if(N&&N.length>0)return SF($,N,V);if(w||!A)return bF($);return CF($)}function SF($,Z,Y){let{src:X,alt:J,width:Q,height:G,sizes:K="100vw",loading:W="lazy",priority:U=!1,decoding:B="async",fetchpriority:_,objectFit:z,objectPosition:q,placeholder:j="none"}=$,H=$.class,O=$.style,F=h5(Z),L=g5(Z),V=typeof K==="object"?f5(K):K,N=Y?Y.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,A=[];if(N)A.push(`aspect-ratio: ${N}`);if(z)A.push(`object-fit: ${z}`);if(q)A.push(`object-position: ${q}`);if(O)A.push(O);let w=A.length>0?` style="${A.join("; ")}"`:"",R=H?` class="${H}"`:"",T=U?"":` loading="${W}"`,I=` decoding="${B}"`,E=_?` fetchpriority="${_}"`:U?' fetchpriority="high"':"",k=["avif","webp","jpeg","png"],S=[];for(let h of k){let m=F.get(h);if(m&&m.length>0){let i=G5(m),s=R1(h);S.push(` <source type="${s}" srcset="${i}" sizes="${V}" />`)}}let P="",y="",b;if(j!=="none"&&Y?.placeholder){let h=`img-${Math.random().toString(36).slice(2,8)}`;if(P=`<div class="stx-image-wrapper" id="${h}">`,y="</div>",j==="blur")b=`
29
+ `,await Bun.write(X,J)}return{configPath:Y,siteId:$.siteId}}function _F($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var V$;var MY=D(()=>{AY();AY();V$=class V$ extends Error{code;constructor($,Z){super($);this.name="DeployError",this.code=Z}}});var YK={};Z0(YK,{resizeAndConvert:()=>ZK,processImage:()=>d1,isSharpAvailable:()=>U4,isImageFile:()=>B4,isImageBackendAvailable:()=>h1,groupVariantsByFormat:()=>h5,getTotalSize:()=>L3,getMimeType:()=>R1,getImageMetadata:()=>v5,getFallbackVariant:()=>g5,generateSrcSet:()=>G5,generateSizes:()=>f5,formatSize:()=>F3,ImageProcessingError:()=>d5,DEFAULT_WIDTHS:()=>N1,DEFAULT_QUALITY:()=>w1,DEFAULT_FORMATS:()=>A1});import IY from"fs";import x5 from"path";import eG from"os";import EY from"crypto";import{generatePlaceholder as zF,processImage as qF}from"ts-images";async function O3(){if(tG)return TY;tG=!0;try{let $=await import("sharp");return TY=$.default||$,TY}catch{return null}}async function U4(){return await O3()!==null}async function h1(){return!0}async function d1($,Z={}){let{widths:Y=N1,formats:X=A1,quality:J=w1,fit:Q="cover",placeholder:G="none",outputDir:K=".stx/images",baseUrl:W="/images"}=Z,U,B;if(typeof $==="string"){if(B=$,!await Bun.file($).exists())throw new d5(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((N)=>Buffer.from(N))}else B="buffer-input",U=$;let _=EY.createHash("sha256").update(U).digest("hex").slice(0,12),z=await v5(U),{width:q,height:j}=z,H=q/j;await IY.promises.mkdir(K,{recursive:!0});let O=[],F=x5.basename(B,x5.extname(B)),L=Y.filter((N)=>N<=q);if(!L.includes(q)&&q<=Math.max(...Y))L.push(q);L.sort((N,A)=>N-A);for(let N of L){let A=Math.round(N/H);for(let w of X){let R=`${F}-${N}w-${_}.${w}`,T=x5.join(K,R),I=`${W}/${R}`,E=await ZK(U,{width:N,height:A,format:w,quality:J,fit:Q});await Bun.write(T,E),O.push({path:T,url:I,width:N,height:A,format:w,size:E.length})}}let V;if(G!=="none")V=await OF(U,G);return{src:B,variants:O,placeholder:V,width:q,height:j,aspectRatio:H,hash:_}}async function v5($){let Z=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Y=await O3();if(Y){let J=await Y(Z).metadata();return{width:J.width||0,height:J.height||0,format:J.format||"unknown",hasAlpha:J.hasAlpha}}return HF(Z)}function HF($){if($[0]===137&&$[1]===80&&$[2]===78&&$[3]===71){let Z=$.readUInt32BE(16),Y=$.readUInt32BE(20);return{width:Z,height:Y,format:"png",hasAlpha:!0}}if($[0]===255&&$[1]===216){let Z=2;while(Z<$.length){if($[Z]!==255)break;let Y=$[Z+1];if(Y>=192&&Y<=207&&Y!==196&&Y!==200&&Y!==204){let J=$.readUInt16BE(Z+5);return{width:$.readUInt16BE(Z+7),height:J,format:"jpeg",hasAlpha:!1}}let X=$.readUInt16BE(Z+2);Z+=2+X}}if($.toString("utf8",0,4)==="RIFF"&&$.toString("utf8",8,12)==="WEBP"){let Z=$.toString("utf8",12,16);if(Z==="VP8 "){let Y=$.readUInt16LE(26)&16383,X=$.readUInt16LE(28)&16383;return{width:Y,height:X,format:"webp",hasAlpha:!1}}if(Z==="VP8L"){let Y=$.readUInt32LE(21),X=(Y&16383)+1,J=(Y>>14&16383)+1;return{width:X,height:J,format:"webp",hasAlpha:!0}}}if($.toString("utf8",0,3)==="GIF"){let Z=$.readUInt16LE(6),Y=$.readUInt16LE(8);return{width:Z,height:Y,format:"gif",hasAlpha:!0}}throw new d5("Unable to parse image dimensions","PARSE_ERROR")}async function ZK($,Z){let Y=await O3();if(Y){let J=Y($).resize(Z.width,Z.height,{fit:Z.fit});switch(Z.format){case"webp":J=J.webp({quality:Z.quality});break;case"avif":J=J.avif({quality:Z.quality});break;case"jpeg":J=J.jpeg({quality:Z.quality});break;case"png":J=J.png({quality:Z.quality});break}return J.toBuffer()}let X=x5.join(eG.tmpdir(),`stx-img-${EY.randomBytes(8).toString("hex")}.${Z.format}`);try{return await qF({input:$,output:X,format:Z.format,quality:Z.quality,resize:{width:Z.width,height:Z.height,fit:Z.fit}}),Buffer.from(await Bun.file(X).arrayBuffer())}finally{await IY.promises.unlink(X).catch(()=>{})}}async function OF($,Z){let Y=await O3();if(Z==="blur"&&Y){let G=(await Y($).resize(20).blur(10).toBuffer()).toString("base64"),K=await v5($);return`data:${$K[K.format]||"image/jpeg"};base64,${G}`}if(Z==="dominant-color"&&Y){let{dominant:Q}=await Y($).resize(1,1).toBuffer().then(async(G)=>{let K=await Y(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 X=await v5($),J=x5.join(eG.tmpdir(),`stx-ph-${EY.randomBytes(8).toString("hex")}.${X.format==="unknown"?"bin":X.format}`);try{await Bun.write(J,$);let Q=Z==="blur"?"blur":Z==="thumbhash"?"thumbhash":"dominant-color",K=await zF(J,{strategy:Q,width:Q==="thumbhash"?void 0:32});if(Z==="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 IY.promises.unlink(J).catch(()=>{})}}function G5($,Z){return(Z?$.filter((X)=>X.format===Z):$).sort((X,J)=>X.width-J.width).map((X)=>`${X.url} ${X.width}w`).join(", ")}function f5($){if(!$||Object.keys($).length===0)return"100vw";return Object.entries($).sort((Y,X)=>{let J=Number.parseInt(Y[0].replace(/\D/g,""))||0;return(Number.parseInt(X[0].replace(/\D/g,""))||0)-J}).map(([Y,X])=>`(max-width: ${Y}) ${X}`).join(", ")+", 100vw"}function g5($){let Z=$.filter((X)=>X.format==="jpeg");if(Z.length===0)return $[Math.floor($.length/2)];let Y=Z.sort((X,J)=>X.width-J.width);return Y[Math.floor(Y.length/2)]}function h5($){let Z=new Map;for(let Y of $){let X=Z.get(Y.format)||[];X.push(Y),Z.set(Y.format,X)}return Z}function B4($){let Z=x5.extname($).toLowerCase();return jF.includes(Z)}function R1($){return $K[$]||"application/octet-stream"}function L3($){return $.reduce((Z,Y)=>Z+Y.size,0)}function F3($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var N1,A1,w1=80,jF,$K,TY=null,tG=!1,d5;var K5=D(()=>{N1=[320,640,768,1024,1280,1536,1920],A1=["webp","jpeg"],jF=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],$K={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};d5=class d5 extends Error{code;constructor($,Z){super($);this.name="ImageProcessingError",this.code=Z}}});var XK={};Z0(XK,{rewriteImagesWithSiblings:()=>DY});import e1 from"path";async function DY($,Z){let Y=Z.formats??FF;if(!Z.publicDir)return $;let X=AF($),J=[],Q=/<img\b[^>]*?>/gi,G=[],K;while((K=Q.exec($))!==null){let _=K[0],z=_.match(/\bsrc=["']([^"']+)["']/i);if(!z)continue;if(wF(K.index,X))continue;G.push({idx:K.index,length:_.length,src:z[1],raw:_})}if(G.length===0)return $;let W=await Promise.all(G.map(async(_)=>{let z=await VF(_.src,Z.publicDir,Y);return{match:_,sources:z}}));for(let{match:_,sources:z}of W){if(z.length===0)continue;let j=`<picture>${z.map((H)=>`<source type="${H.mime}" srcset="${RF(H.url)}">`).join("")}${_.raw}</picture>`;J.push({start:_.idx,end:_.idx+_.length,replacement:j})}if(J.length===0)return $;let U="",B=0;for(let _ of J)U+=$.slice(B,_.start),U+=_.replacement,B=_.end;return U+=$.slice(B),U}async function VF($,Z,Y){if(!NF($))return[];let X=e1.extname($).toLowerCase();if(!LF.has(X))return[];if(!$.startsWith("/"))return[];let J=e1.join(Z,$.slice(1)),Q=e1.dirname(J),G=e1.basename(J,X),K=e1.resolve(Q),W=e1.resolve(Z);if(!K.startsWith(W))return[];let U=e1.posix.dirname($),B=Y.map(async(z)=>{let q=e1.join(Q,`${G}${z.ext}`);if(!await Bun.file(q).exists())return null;return{url:e1.posix.join(U,`${G}${z.ext}`),mime:z.mime}});return(await Promise.all(B)).filter((z)=>z!==null)}function NF($){if(!$)return!1;if($.startsWith("http://")||$.startsWith("https://"))return!1;if($.startsWith("//"))return!1;if($.startsWith("data:"))return!1;return!0}function AF($){let Z=[],Y=/<picture\b[^>]*>[\s\S]*?<\/picture>/gi,X;while((X=Y.exec($))!==null)Z.push([X.index,X.index+X[0].length]);return Z}function wF($,Z){for(let[Y,X]of Z)if($>=Y&&$<X)return!0;return!1}function RF($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}var LF,FF;var kY=D(()=>{LF=new Set([".jpg",".jpeg",".png",".gif"]),FF=[{ext:".avif",mime:"image/avif"},{ext:".webp",mime:"image/webp"}]});var WK={};Z0(WK,{handleImageRequest:()=>V3,createImageHandler:()=>SY});import JK from"fs";import _4 from"path";import MF from"crypto";async function V3($,Z){let Y=Z.routePath??"/_stx/img",X=new URL($.url);if(X.pathname!==Y)return null;let J=DF(X,Z);if(!J.ok)return new Response(J.error,{status:J.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:Q,srcUrl:G,width:K,height:W,format:U,quality:B,fit:_}=J,z;try{z=JK.statSync(Q)}catch{return new Response(`Source image not found: ${G}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!z.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let q=Z.cacheDir??".stx/cache/img";await JK.promises.mkdir(q,{recursive:!0});let j=`${Q}:${z.mtimeMs}:${z.size}`,H=`${K}x${W}:${U}:${B}:${_}`,O=MF.createHash("sha256").update(`${j}|${H}`).digest("hex").slice(0,16),F=_4.join(q,`${O}.${U}`),V={"Content-Type":R1(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 N=Bun.file(F);if(await N.exists())return new Response(N,{headers:V});try{let A=Buffer.from(await Bun.file(Q).arrayBuffer()),{resizeAndConvert:w}=await kF(),R=await w(A,{width:K,height:W,format:U,quality:B,fit:_});return await Bun.write(F,R),V["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(R),{headers:V})}catch(A){let w=A.message;return new Response(`Image processing failed: ${w}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function SY($){return async(Z)=>{return await V3(Z,$)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}}function DF($,Z){let Y=$.searchParams.get("src");if(!Y)return{ok:!1,error:"Missing required param: src",status:400};if(!Y.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(Y.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let X=_4.extname(Y).toLowerCase();if(!TF.has(X))return{ok:!1,error:`Unsupported source extension: ${X}`,status:400};let J=_4.resolve(Z.publicDir),Q=_4.resolve(J,Y.slice(1));if(!Q.startsWith(`${J}${_4.sep}`)&&Q!==J)return{ok:!1,error:"src is outside publicDir",status:400};let G=Z.maxWidth??KK,K=Z.maxHeight??KK,W=$.searchParams.get("w"),U=$.searchParams.get("h"),B=W?Number.parseInt(W,10):0,_=U?Number.parseInt(U,10):0;if(W&&(!Number.isFinite(B)||B<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(U&&(!Number.isFinite(_)||_<=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 z=Math.min(B||G,G),q=Math.min(_||K,K),j=$.searchParams.get("f")||"webp";if(!QK.has(j))return{ok:!1,error:`Invalid f (must be one of: ${[...QK].join(", ")})`,status:400};let H=j,O=$.searchParams.get("q"),F=O?Number.parseInt(O,10):Z.defaultQuality??IF;if(!Number.isFinite(F)||F<1||F>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let L=$.searchParams.get("fit")||Z.defaultFit||EF;if(!GK.has(L))return{ok:!1,error:`Invalid fit (must be one of: ${[...GK].join(", ")})`,status:400};return{ok:!0,srcFsPath:Q,srcUrl:Y,width:z,height:q,format:H,quality:F,fit:L}}async function kF(){return await Promise.resolve().then(() => (K5(),YK))}var QK,GK,TF,KK=4096,IF=80,EF="cover";var bY=D(()=>{K5();QK=new Set(["webp","avif","jpeg","png"]),GK=new Set(["cover","contain","fill","inside","outside"]),TF=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"])});function UK($,Z={}){let{src:Y,alt:X,width:J,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=w1,placeholder:B="none",formats:_=A1,widths:z=N1,decoding:q="async",fetchpriority:j,objectFit:H,objectPosition:O}=$,F=$.class,L=$.style,{processedImage:V,variants:N,optimize:A=!0,isDev:w=!1}=Z;if(N&&N.length>0)return SF($,N,V);if(w||!A)return bF($);return CF($)}function SF($,Z,Y){let{src:X,alt:J,width:Q,height:G,sizes:K="100vw",loading:W="lazy",priority:U=!1,decoding:B="async",fetchpriority:_,objectFit:z,objectPosition:q,placeholder:j="none"}=$,H=$.class,O=$.style,F=h5(Z),L=g5(Z),V=typeof K==="object"?f5(K):K,N=Y?Y.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,A=[];if(N)A.push(`aspect-ratio: ${N}`);if(z)A.push(`object-fit: ${z}`);if(q)A.push(`object-position: ${q}`);if(O)A.push(O);let w=A.length>0?` style="${A.join("; ")}"`:"",R=H?` class="${H}"`:"",T=U?"":` loading="${W}"`,I=` decoding="${B}"`,E=_?` fetchpriority="${_}"`:U?' fetchpriority="high"':"",k=["avif","webp","jpeg","png"],S=[];for(let h of k){let p=F.get(h);if(p&&p.length>0){let i=G5(p),s=R1(h);S.push(` <source type="${s}" srcset="${i}" sizes="${V}" />`)}}let x="",y="",b;if(j!=="none"&&Y?.placeholder){let h=`img-${Math.random().toString(36).slice(2,8)}`;if(x=`<div class="stx-image-wrapper" id="${h}">`,y="</div>",j==="blur")b=`
30
30
  #${h} {
31
31
  position: relative;
32
32
  background-image: url('${Y.placeholder}');
@@ -43,14 +43,14 @@ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FO
43
43
  #${h} {
44
44
  background-color: ${Y.placeholder};
45
45
  }
46
- `.trim()}let f=Q?` width="${Q}"`:Y?` width="${Y.width}"`:"",r=G?` height="${G}"`:Y?` height="${Y.height}"`:"",u=`${P}<picture>
46
+ `.trim()}let f=Q?` width="${Q}"`:Y?` width="${Y.width}"`:"",r=G?` height="${G}"`:Y?` height="${Y.height}"`:"",u=`${x}<picture>
47
47
  ${S.join(`
48
48
  `)}
49
49
  <img
50
50
  src="${L?.url||X}"
51
51
  alt="${yY(J)}"${f}${r}${R}${w}${T}${I}${E}
52
52
  />
53
- </picture>${y}`,C;if(U&&L){let h=F.get("webp"),m=h?.[Math.floor(h.length/2)]||L,i=R1(m.format);C=`<link rel="preload" as="image" href="${m.url}" type="${i}" />`}return{html:u,preloadLink:C,placeholderCss:b}}function bF($){let{src:Z,alt:Y,width:X,height:J,loading:Q="lazy",decoding:G="async",priority:K=!1,fetchpriority:W,objectFit:U,objectPosition:B}=$,_=$.class,z=$.style,q=[];if(U)q.push(`object-fit: ${U}`);if(B)q.push(`object-position: ${B}`);if(z)q.push(z);let j=q.length>0?` style="${q.join("; ")}"`:"",H=_?` class="${_}"`:"",O=X?` width="${X}"`:"",F=J?` height="${J}"`:"",L=K?"":` loading="${Q}"`,V=` decoding="${G}"`,N=W?` fetchpriority="${W}"`:K?' fetchpriority="high"':"";return{html:`<img src="${Z}" alt="${yY(Y)}"${O}${F}${H}${j}${L}${V}${N} />`}}function CF($){let{src:Z,alt:Y,width:X,height:J,sizes:Q="100vw",loading:G="lazy",priority:K=!1,quality:W=w1,formats:U=A1,widths:B=N1,decoding:_="async",fetchpriority:z,objectFit:q,objectPosition:j}=$,H=$.class,O=$.style,F=[];if(q)F.push(`object-fit: ${q}`);if(j)F.push(`object-position: ${j}`);if(O)F.push(O);let L=F.length>0?` style="${F.join("; ")}"`:"",V=H?` class="${H}"`:"",N=X?` width="${X}"`:"",A=J?` height="${J}"`:"",w=K?"":` loading="${G}"`,R=` decoding="${_}"`,T=z?` fetchpriority="${z}"`:K?' fetchpriority="high"':"",I=typeof Q==="object"?f5(Q):Q,E=`
53
+ </picture>${y}`,C;if(U&&L){let h=F.get("webp"),p=h?.[Math.floor(h.length/2)]||L,i=R1(p.format);C=`<link rel="preload" as="image" href="${p.url}" type="${i}" />`}return{html:u,preloadLink:C,placeholderCss:b}}function bF($){let{src:Z,alt:Y,width:X,height:J,loading:Q="lazy",decoding:G="async",priority:K=!1,fetchpriority:W,objectFit:U,objectPosition:B}=$,_=$.class,z=$.style,q=[];if(U)q.push(`object-fit: ${U}`);if(B)q.push(`object-position: ${B}`);if(z)q.push(z);let j=q.length>0?` style="${q.join("; ")}"`:"",H=_?` class="${_}"`:"",O=X?` width="${X}"`:"",F=J?` height="${J}"`:"",L=K?"":` loading="${Q}"`,V=` decoding="${G}"`,N=W?` fetchpriority="${W}"`:K?' fetchpriority="high"':"";return{html:`<img src="${Z}" alt="${yY(Y)}"${O}${F}${H}${j}${L}${V}${N} />`}}function CF($){let{src:Z,alt:Y,width:X,height:J,sizes:Q="100vw",loading:G="lazy",priority:K=!1,quality:W=w1,formats:U=A1,widths:B=N1,decoding:_="async",fetchpriority:z,objectFit:q,objectPosition:j}=$,H=$.class,O=$.style,F=[];if(q)F.push(`object-fit: ${q}`);if(j)F.push(`object-position: ${j}`);if(O)F.push(O);let L=F.length>0?` style="${F.join("; ")}"`:"",V=H?` class="${H}"`:"",N=X?` width="${X}"`:"",A=J?` height="${J}"`:"",w=K?"":` loading="${G}"`,R=` decoding="${_}"`,T=z?` fetchpriority="${z}"`:K?' fetchpriority="high"':"",I=typeof Q==="object"?f5(Q):Q,E=`
54
54
  data-stx-image
55
55
  data-src="${Z}"
56
56
  data-sizes="${I}"
@@ -1162,8 +1162,8 @@ ${H}
1162
1162
  filter: blur(0);
1163
1163
  transform: scale(1);
1164
1164
  }
1165
- `.trim();s5=new Map});import{createHash as DX}from"crypto";import{readFile as JN,stat as KW}from"fs/promises";async function l0($){try{let Z=await JN($);return DX("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function WW($){return DX("sha256").update($).digest("hex").slice(0,16)}function i3($){return DX("sha256").update($).digest("hex").slice(0,16)}function o5($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${i3($)}-${i3(Y)}`}async function S4($){try{return(await KW($)).mtimeMs}catch{return 0}}async function i0($){try{return await KW($),!0}catch{return!1}}var I$=()=>{};import{mkdir as QN,readFile as BW,writeFile as GN,readdir as _W,rm as kX,stat as KN}from"fs/promises";import{join as a5,dirname as WN}from"path";async function UN($){try{await QN($,{recursive:!0})}catch{}}function zW($,Z,Y){return a5($,Y,`${Z}.json`)}async function UW($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await S4(Z)!==$.srcMtime)return!1;return!0}async function t5($,Z,Y,X=b4){if(!X.enabled)return null;let J=o5($,Z),Q=E$.get(J);if(Q){if(await UW(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;E$.delete(J)}let G=zW(X.directory,J,Y);if(await i0(G))try{let K=await BW(G,"utf-8"),W=JSON.parse(K);if(await UW(W,$,X.maxAge))return W.lastAccessedAt=Date.now(),E$.set(J,W),W.data}catch{}return null}async function e5($,Z,Y,X,J=b4){if(!J.enabled)return;let Q=o5($,Z),G=await l0($),K=await S4($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:o5("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};E$.set(Q,W);let U=zW(J.directory,Q,X);try{await UN(WN(U)),await GN(U,JSON.stringify(W,null,2))}catch(B){console.warn(`[stx-media] Failed to write cache: ${B}`)}}async function $7($,Z=b4){if($==="all")E$.clear();else E$.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=a5(Z.directory,X);try{await kX(J,{recursive:!0,force:!0})}catch{}}}async function qW($=b4){let Z={memoryEntries:E$.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=a5($.directory,Y);try{let J=await _W(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=a5(X,Q),K=await KN(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function jW($=b4){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=a5($.directory,X);try{let Q=await _W(J);for(let G of Q){let K=a5(J,G);try{let W=await BW(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await kX(K),E$.delete(U.key),Z++}catch{await kX(K).catch(()=>{}),Z++}}}catch{}}return Z}var E$,b4;var n3=D(()=>{I$();E$=new Map,b4={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class Z7{config;constructor($={}){this.config={...BN,...$}}async get($,Z){return t5($,Z,"image",this.config)}async set($,Z,Y){return e5($,Z,Y,"image",this.config)}async clear(){return $7("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function SX($){if(!s3)s3=new Z7($);else if($)s3.updateConfig($);return s3}async function Y7($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return SX(X).get($,Z)}async function X7($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return SX(J).set($,Z,Y)}async function bX(){return SX().clear()}var BN,s3=null;var CX=D(()=>{n3();BN={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as _N,basename as zN,extname as qN,join as jN}from"path";import{mkdir as HN}from"fs/promises";async function yX(){try{return await import("ts-images")}catch{return null}}function HW($){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 ON($,Z){let Y=Z?HW(Z):HW("web"),X=$.formatQuality||{};return{jpeg:{...Y.jpeg,...X.jpeg},png:{...Y.png,...X.png},webp:{...Y.webp,...X.webp},avif:{...Y.avif,...X.avif}}}async function PX($,Z,Y){let X=await yX();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await Y7($,Z,Y);if(J)return J;try{let Q=_N($);if(!await i0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=ON(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await HN(K,{recursive:!0});let U=await l0(Q),B=zN($,qN($)),_=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],z={src:$,processed:!0,variants:[],hash:U},q=null;if(Z.transformations&&Z.transformations.length>0)q=await C4(Q,Z.transformations,X);for(let j of _){let H=G[j]||{},O=`${B}-${U}.${j}`,F=jN(K,O);try{let L=await X.optimizeImage({input:q||Q,output:F,format:j,quality:H.quality,progressive:H.progressive});if(L){if(z.variants.push({path:F,url:`${W}/${O}`,width:L.width||0,height:L.height||0,format:j,size:L.outputSize||0}),!z.originalWidth&&L.width)z.originalWidth=L.width,z.originalHeight=L.height}}catch(L){z.errors=z.errors||[],z.errors.push(`Failed to optimize ${j}: ${L}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);z.placeholder=j.dataUrl}catch(j){z.errors=z.errors||[],z.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});z.dominantColor=j.dominantColor}catch(j){z.errors=z.errors||[],z.errors.push(`Failed to extract dominant color: ${j}`)}return await X7($,Z,z,Y),z}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function xX($,Z,Y,X){let J=await yX();if(!J)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await J.optimizeImage({input:$,output:X,format:Z,quality:Y}))?.outputSize}}catch(Q){return{success:!1,error:String(Q)}}}async function C4($,Z,Y){let X=Y||await yX();if(!X)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let J=await X.decode($);for(let Q of Z){let G=Q.options||{};switch(Q.type){case"resize":if(G.width||G.height)J=await X.resize(J,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)J=await X.blur(J,G.sigma);break;case"sharpen":if(G.amount!==void 0)J=await X.sharpen(J,G.amount);break;case"grayscale":J=await X.grayscale(J);break;case"rotate":if(G.angle!==void 0)J=await X.rotate(J,G.angle);break;case"flip":J=await X.flip(J);break;case"flop":J=await X.flop(J);break;case"brightness":if(G.value!==void 0)J=await X.brightness(J,G.value);break;case"contrast":if(G.value!==void 0)J=await X.contrast(J,G.value);break;case"saturation":if(G.value!==void 0)J=await X.saturation(J,G.value);break}}return await X.encode(J,"png")}catch(J){return console.error(`[stx-media] Transformation failed: ${J}`),null}}var OW=D(()=>{I$();CX()});import{resolve as LN,basename as FN,extname as VN,join as NN}from"path";import{mkdir as AN}from"fs/promises";async function wN(){try{return await import("ts-images")}catch{return null}}async function r3($,Z,Y){let X=await wN();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=LN($);if(!await i0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||RN,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await AN(K,{recursive:!0});let U=await l0(J),B=FN($,VN($)),_=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},z={src:$,byFormat:{},srcsets:{}};for(let j of G){z.byFormat[j]=[];let H=[];for(let O of Q){let F=`${B}-${O}w-${U}.${j}`,L=NN(K,F),V=`${W}/${F}`;try{let N=_[j]?.quality||80;if(await i0(L)){z.byFormat[j].push({path:L,url:V,width:O,height:0,format:j,size:0}),H.push(`${V} ${O}w`);continue}let A=await X.processImage({input:J,output:L,format:j,quality:N,resize:{width:O}});if(A)z.byFormat[j].push({path:L,url:V,width:O,height:A.height||Math.round(O*(A.height||1)/(A.width||1)),format:j,size:A.outputSize||0}),H.push(`${V} ${O}w`)}catch(N){console.warn(`[stx-media] Failed to generate ${j} at ${O}w: ${N}`)}}z.srcsets[j]=H.join(", ")}let q=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(q!=="none")try{if(q==="thumbhash"){let j=await X.generateThumbHash(J);z.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:q,width:20});z.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:q}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return z.sizes=Z.sizes||MN(Q),z}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function MN($){let Z=[...$].sort((X,J)=>X-J),Y=[];for(let X=0;X<Z.length-1;X++){let J=Z[X];Y.push(`(max-width: ${J}px) ${J}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function o3($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return $.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}var RN;var LW=D(()=>{I$();RN=[320,480,640,768,1024,1280,1536,1920]});var FW={};Z0(FW,{setCachedImageResult:()=>X7,processImage:()=>PX,optimizeImage:()=>xX,getCachedImageResult:()=>Y7,generateSrcset:()=>o3,generateResponsiveVariants:()=>r3,clearImageCache:()=>bX,applyTransformations:()=>C4,ImageProcessorCache:()=>Z7});var vX=D(()=>{OW();LW();CX()});async function TN(){try{return await Promise.resolve().then(() => (vX(),FW))}catch($){if(!VW)console.warn("[stx-media] Image processor not available, some features disabled:",$),VW=!0;return null}}async function D$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return kN(X,Y)}if(Y.processedResult?.processed)return uX($,Y.processedResult,Z);if(Y.responsiveVariants)return RW($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=m1,dpr:B,formats:_=Y$,quality:z=fX,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:O=!0,priority:F=!1,loading:L=F?"eager":t3,decoding:V=a3,fetchpriority:N,objectFit:A,objectPosition:w,crossorigin:R,referrerpolicy:T}=$,I=$.class,E=$.style,k=$.id,S=$.data||{},{isDev:P=!1,baseUrl:y=""}=Z;if(P&&!Z.optimize)return DN($);let b,f,r=k||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{b=await k4(J,{strategy:j,...H}),f=D4(r,b,H)}catch{}let u=B!==void 0&&G!==void 0,C;if(u)C=EN($,r,b,Z);else C=await IN($,r,b,Z);let h;if(F){let s=_.includes("webp")?"webp":_[0],K0=T$(J,U,{...q,q:z},s),$0=typeof W==="object"?n5(W):W||"100vw";h=`<link rel="preload" as="image" imagesrcset="${K0}" imagesizes="${$0}" />`}let m=[];if(!NW&&j!=="none")m.push(r5),NW=!0;if(f)m.push(f);let i=O?wW(r):void 0;return{html:C,preloadLink:h,css:m.length>0?m.join(`
1166
- `):void 0,script:i}}async function IN($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=m1,formats:B=Y$,quality:_=fX,params:z={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":t3,decoding:O=a3,fetchpriority:F,objectFit:L,objectPosition:V,crossorigin:N,referrerpolicy:A}=$,w=$.class,R=$.style,T=$.data||{},I=typeof W==="object"?n5(W):W||"100vw",E=[];for(let P of B){let y=T$(J,U,{...z,q:_},P),b=I4(P);if(q&&!j)E.push(` <source type="${b}" data-srcset="${y}" data-sizes="${I}" />`);else E.push(` <source type="${b}" srcset="${y}" sizes="${I}" />`)}let k=gX({src:k1(J,{...z,q:_}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:O,fetchpriority:j?"high":F,objectFit:L,objectPosition:V,crossorigin:N,referrerpolicy:A,className:AW(w,Y),style:hX(R,L,V,Y),lazy:q&&!j,data:T}),S;if(Y){let P=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;S=`<div id="${Z}" class="stx-img-placeholder" style="${P}">
1165
+ `.trim();s5=new Map});import{createHash as DX}from"crypto";import{readFile as JN,stat as KW}from"fs/promises";async function l0($){try{let Z=await JN($);return DX("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function WW($){return DX("sha256").update($).digest("hex").slice(0,16)}function i3($){return DX("sha256").update($).digest("hex").slice(0,16)}function o5($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${i3($)}-${i3(Y)}`}async function S4($){try{return(await KW($)).mtimeMs}catch{return 0}}async function i0($){try{return await KW($),!0}catch{return!1}}var I$=()=>{};import{mkdir as QN,readFile as BW,writeFile as GN,readdir as _W,rm as kX,stat as KN}from"fs/promises";import{join as a5,dirname as WN}from"path";async function UN($){try{await QN($,{recursive:!0})}catch{}}function zW($,Z,Y){return a5($,Y,`${Z}.json`)}async function UW($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await S4(Z)!==$.srcMtime)return!1;return!0}async function t5($,Z,Y,X=b4){if(!X.enabled)return null;let J=o5($,Z),Q=E$.get(J);if(Q){if(await UW(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;E$.delete(J)}let G=zW(X.directory,J,Y);if(await i0(G))try{let K=await BW(G,"utf-8"),W=JSON.parse(K);if(await UW(W,$,X.maxAge))return W.lastAccessedAt=Date.now(),E$.set(J,W),W.data}catch{}return null}async function e5($,Z,Y,X,J=b4){if(!J.enabled)return;let Q=o5($,Z),G=await l0($),K=await S4($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:o5("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};E$.set(Q,W);let U=zW(J.directory,Q,X);try{await UN(WN(U)),await GN(U,JSON.stringify(W,null,2))}catch(B){console.warn(`[stx-media] Failed to write cache: ${B}`)}}async function $7($,Z=b4){if($==="all")E$.clear();else E$.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=a5(Z.directory,X);try{await kX(J,{recursive:!0,force:!0})}catch{}}}async function qW($=b4){let Z={memoryEntries:E$.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=a5($.directory,Y);try{let J=await _W(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=a5(X,Q),K=await KN(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function jW($=b4){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=a5($.directory,X);try{let Q=await _W(J);for(let G of Q){let K=a5(J,G);try{let W=await BW(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await kX(K),E$.delete(U.key),Z++}catch{await kX(K).catch(()=>{}),Z++}}}catch{}}return Z}var E$,b4;var n3=D(()=>{I$();E$=new Map,b4={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class Z7{config;constructor($={}){this.config={...BN,...$}}async get($,Z){return t5($,Z,"image",this.config)}async set($,Z,Y){return e5($,Z,Y,"image",this.config)}async clear(){return $7("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function SX($){if(!s3)s3=new Z7($);else if($)s3.updateConfig($);return s3}async function Y7($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return SX(X).get($,Z)}async function X7($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return SX(J).set($,Z,Y)}async function bX(){return SX().clear()}var BN,s3=null;var CX=D(()=>{n3();BN={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as _N,basename as zN,extname as qN,join as jN}from"path";import{mkdir as HN}from"fs/promises";async function yX(){try{return await import("ts-images")}catch{return null}}function HW($){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 ON($,Z){let Y=Z?HW(Z):HW("web"),X=$.formatQuality||{};return{jpeg:{...Y.jpeg,...X.jpeg},png:{...Y.png,...X.png},webp:{...Y.webp,...X.webp},avif:{...Y.avif,...X.avif}}}async function PX($,Z,Y){let X=await yX();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await Y7($,Z,Y);if(J)return J;try{let Q=_N($);if(!await i0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=ON(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await HN(K,{recursive:!0});let U=await l0(Q),B=zN($,qN($)),_=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],z={src:$,processed:!0,variants:[],hash:U},q=null;if(Z.transformations&&Z.transformations.length>0)q=await C4(Q,Z.transformations,X);for(let j of _){let H=G[j]||{},O=`${B}-${U}.${j}`,F=jN(K,O);try{let L=await X.optimizeImage({input:q||Q,output:F,format:j,quality:H.quality,progressive:H.progressive});if(L){if(z.variants.push({path:F,url:`${W}/${O}`,width:L.width||0,height:L.height||0,format:j,size:L.outputSize||0}),!z.originalWidth&&L.width)z.originalWidth=L.width,z.originalHeight=L.height}}catch(L){z.errors=z.errors||[],z.errors.push(`Failed to optimize ${j}: ${L}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);z.placeholder=j.dataUrl}catch(j){z.errors=z.errors||[],z.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});z.dominantColor=j.dominantColor}catch(j){z.errors=z.errors||[],z.errors.push(`Failed to extract dominant color: ${j}`)}return await X7($,Z,z,Y),z}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function xX($,Z,Y,X){let J=await yX();if(!J)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await J.optimizeImage({input:$,output:X,format:Z,quality:Y}))?.outputSize}}catch(Q){return{success:!1,error:String(Q)}}}async function C4($,Z,Y){let X=Y||await yX();if(!X)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let J=await X.decode($);for(let Q of Z){let G=Q.options||{};switch(Q.type){case"resize":if(G.width||G.height)J=await X.resize(J,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)J=await X.blur(J,G.sigma);break;case"sharpen":if(G.amount!==void 0)J=await X.sharpen(J,G.amount);break;case"grayscale":J=await X.grayscale(J);break;case"rotate":if(G.angle!==void 0)J=await X.rotate(J,G.angle);break;case"flip":J=await X.flip(J);break;case"flop":J=await X.flop(J);break;case"brightness":if(G.value!==void 0)J=await X.brightness(J,G.value);break;case"contrast":if(G.value!==void 0)J=await X.contrast(J,G.value);break;case"saturation":if(G.value!==void 0)J=await X.saturation(J,G.value);break}}return await X.encode(J,"png")}catch(J){return console.error(`[stx-media] Transformation failed: ${J}`),null}}var OW=D(()=>{I$();CX()});import{resolve as LN,basename as FN,extname as VN,join as NN}from"path";import{mkdir as AN}from"fs/promises";async function wN(){try{return await import("ts-images")}catch{return null}}async function r3($,Z,Y){let X=await wN();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=LN($);if(!await i0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||RN,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await AN(K,{recursive:!0});let U=await l0(J),B=FN($,VN($)),_=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},z={src:$,byFormat:{},srcsets:{}};for(let j of G){z.byFormat[j]=[];let H=[];for(let O of Q){let F=`${B}-${O}w-${U}.${j}`,L=NN(K,F),V=`${W}/${F}`;try{let N=_[j]?.quality||80;if(await i0(L)){z.byFormat[j].push({path:L,url:V,width:O,height:0,format:j,size:0}),H.push(`${V} ${O}w`);continue}let A=await X.processImage({input:J,output:L,format:j,quality:N,resize:{width:O}});if(A)z.byFormat[j].push({path:L,url:V,width:O,height:A.height||Math.round(O*(A.height||1)/(A.width||1)),format:j,size:A.outputSize||0}),H.push(`${V} ${O}w`)}catch(N){console.warn(`[stx-media] Failed to generate ${j} at ${O}w: ${N}`)}}z.srcsets[j]=H.join(", ")}let q=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(q!=="none")try{if(q==="thumbhash"){let j=await X.generateThumbHash(J);z.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:q,width:20});z.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:q}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return z.sizes=Z.sizes||MN(Q),z}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function MN($){let Z=[...$].sort((X,J)=>X-J),Y=[];for(let X=0;X<Z.length-1;X++){let J=Z[X];Y.push(`(max-width: ${J}px) ${J}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function o3($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return $.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}var RN;var LW=D(()=>{I$();RN=[320,480,640,768,1024,1280,1536,1920]});var FW={};Z0(FW,{setCachedImageResult:()=>X7,processImage:()=>PX,optimizeImage:()=>xX,getCachedImageResult:()=>Y7,generateSrcset:()=>o3,generateResponsiveVariants:()=>r3,clearImageCache:()=>bX,applyTransformations:()=>C4,ImageProcessorCache:()=>Z7});var vX=D(()=>{OW();LW();CX()});async function TN(){try{return await Promise.resolve().then(() => (vX(),FW))}catch($){if(!VW)console.warn("[stx-media] Image processor not available, some features disabled:",$),VW=!0;return null}}async function D$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return kN(X,Y)}if(Y.processedResult?.processed)return uX($,Y.processedResult,Z);if(Y.responsiveVariants)return RW($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=m1,dpr:B,formats:_=Y$,quality:z=fX,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:O=!0,priority:F=!1,loading:L=F?"eager":t3,decoding:V=a3,fetchpriority:N,objectFit:A,objectPosition:w,crossorigin:R,referrerpolicy:T}=$,I=$.class,E=$.style,k=$.id,S=$.data||{},{isDev:x=!1,baseUrl:y=""}=Z;if(x&&!Z.optimize)return DN($);let b,f,r=k||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{b=await k4(J,{strategy:j,...H}),f=D4(r,b,H)}catch{}let u=B!==void 0&&G!==void 0,C;if(u)C=EN($,r,b,Z);else C=await IN($,r,b,Z);let h;if(F){let s=_.includes("webp")?"webp":_[0],K0=T$(J,U,{...q,q:z},s),$0=typeof W==="object"?n5(W):W||"100vw";h=`<link rel="preload" as="image" imagesrcset="${K0}" imagesizes="${$0}" />`}let p=[];if(!NW&&j!=="none")p.push(r5),NW=!0;if(f)p.push(f);let i=O?wW(r):void 0;return{html:C,preloadLink:h,css:p.length>0?p.join(`
1166
+ `):void 0,script:i}}async function IN($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=m1,formats:B=Y$,quality:_=fX,params:z={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":t3,decoding:O=a3,fetchpriority:F,objectFit:L,objectPosition:V,crossorigin:N,referrerpolicy:A}=$,w=$.class,R=$.style,T=$.data||{},I=typeof W==="object"?n5(W):W||"100vw",E=[];for(let x of B){let y=T$(J,U,{...z,q:_},x),b=I4(x);if(q&&!j)E.push(` <source type="${b}" data-srcset="${y}" data-sizes="${I}" />`);else E.push(` <source type="${b}" srcset="${y}" sizes="${I}" />`)}let k=gX({src:k1(J,{...z,q:_}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:O,fetchpriority:j?"high":F,objectFit:L,objectPosition:V,crossorigin:N,referrerpolicy:A,className:AW(w,Y),style:hX(R,L,V,Y),lazy:q&&!j,data:T}),S;if(Y){let x=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;S=`<div id="${Z}" class="stx-img-placeholder" style="${x}">
1167
1167
  <picture>
1168
1168
  ${E.join(`
1169
1169
  `)}
@@ -1222,7 +1222,7 @@ ${A.join(`
1222
1222
  ${A.join(`
1223
1223
  `)}
1224
1224
  <img ${R.join(" ")} />
1225
- </picture>`;let P=[];if(Z.placeholder)P.push(r5);let y=G?wW(j):void 0,b;if(K&&V)b=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:S,preloadLink:b,css:P.length>0?P.join(`
1225
+ </picture>`;let x=[];if(Z.placeholder)x.push(r5);let y=G?wW(j):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(`
1226
1226
  `):void 0,script:y}}async function RW($,Z,Y){let X={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[J,Q]of Object.entries(Z.byFormat))if(Q)X.variants.push(...Q);return uX($,X,Y)}var VW=!1,fX=80,a3="async",t3="lazy",NW=!1;var mX=D(()=>{c3();EX()});function $8(){return S0({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,Y,X)=>{let{src:J,alt:Q,options:G}=SN($,Z,Y);if(!J)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:J,alt:Q||"",widths:G.widths||m1,formats:G.formats||Y$,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=Y.__isDev||!1,U=await D$(K,{isDev:W}),B=U.html;if(U.preloadLink)B=U.preloadLink+`
1227
1227
  `+B;if(U.css)B+=`
1228
1228
  <style>${U.css}</style>`;if(U.script)B+=`
@@ -1253,9 +1253,9 @@ ${A.join(`
1253
1253
  </Representation>
1254
1254
  `}K+=` </AdaptationSet>
1255
1255
  `}return K+=` </Period>
1256
- </MPD>`,K}function MW($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),X=Math.floor($%60),J="PT";if(Z>0)J+=`${Z}H`;if(Y>0)J+=`${Y}M`;return J+=`${X}S`,J}var SW;var eX=D(()=>{I$();SW=[{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 bW,basename as xN,extname as vN,join as fN}from"path";import{mkdir as gN}from"fs/promises";async function CW(){try{return await import("ts-videos")}catch{return null}}function hN($){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 dN($){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 P4($){let Z=await CW();if(!Z)return null;try{let Y=bW($),J=await new Z.Input(Y).getInfo();return{duration:J.duration||0,width:J.width||0,height:J.height||0,frameRate:J.frameRate||0,bitrate:J.bitrate||0,codec:J.videoCodec||"",audioCodec:J.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function G8($,Z,Y,X){let J=await CW();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await Q7($,Z,Y);if(Q)return Q;try{let G=bW($);if(!await i0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",W=Y.baseUrl||"/videos";await gN(K,{recursive:!0});let U=await l0(G),B=xN($,vN($)),_={src:$,processed:!0,hash:U};X?.({percentage:5,stage:"analyzing"}),_.metadata=await P4(G)||void 0;let z={};if(Z.quality)z.bitrate=hN(Z.quality);if(Z.platform)Object.assign(z,dN(Z.platform));if(Z.transcode)Object.assign(z,Z.transcode);if(Object.keys(z).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let q=`${B}-${U}.mp4`,j=fN(K,q);try{let H=await uN(G,j,z,J,(O)=>X?.({percentage:10+O*0.5,stage:"transcoding"}));if(H)_.transcoded={path:j,url:`${W}/${q}`,duration:H.duration,size:H.size,video:{codec:z.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:z.audioCodec||"aac",bitrate:z.audioBitrate||128000,sampleRate:z.sampleRate||48000,channels:z.channels||2}:void 0}}catch(H){_.errors=_.errors||[],_.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let q=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await K7(G,q,K,W);if(j)_.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let q=await W7(G,Y.thumbnails,K,W);if(q.length>0)_.thumbnails=q}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let q=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(q.format==="hls"||q.format===void 0){let j=await U7(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)_.streaming={..._.streaming,hls:j}}if(q.format==="dash"){let j=await B7(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)_.streaming={..._.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await G7($,Z,_,Y),_}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function uN($,Z,Y,X,J){try{let G=await new X.Conversion($,Z,{videoCodec:Y.codec,videoBitrate:Y.bitrate,width:Y.maxWidth,height:Y.maxHeight,frameRate:Y.frameRate,audioCodec:Y.audioCodec,audioBitrate:Y.audioBitrate,sampleRate:Y.sampleRate,channels:Y.channels}).run((K)=>{J?.(K.percentage/100)});return{duration:G.duration||0,size:G.size||0,width:G.width||Y.maxWidth||0,height:G.height||Y.maxHeight||0,bitrate:G.bitrate||Y.bitrate||0,frameRate:G.frameRate||Y.frameRate||30,audioCodec:G.audioCodec}}catch(Q){return console.error(`[stx-media] Transcoding failed: ${Q}`),null}}var yW=D(()=>{I$();iX();tX();eX()});var PW={};Z0(PW,{setCachedVideoResult:()=>G7,processVideo:()=>G8,getCachedVideoResult:()=>Q7,generateThumbnails:()=>W7,generateSpriteSheet:()=>J8,generatePoster:()=>K7,generateHLSManifest:()=>U7,generateDASHManifest:()=>B7,clearVideoCache:()=>Y8,analyzeVideo:()=>P4,VideoProcessorCache:()=>J7});var $J=D(()=>{yW();tX();eX();iX()});async function vW(){try{return await Promise.resolve().then(() => ($J(),PW))}catch($){if(!xW)console.warn("[stx-media] Video processor not available, some features disabled:",$),xW=!0;return null}}async function _7($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return nN(X,Y)}if(Y.processedResult?.processed)return uW($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await sN(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=fW,autoplay:B=!1,muted:_=!1,loop:z=!1,preload:q=gW,playsinline:j=!0,lazy:H=!0,player:O="native",type:F,width:L,height:V,crossorigin:N,disablePictureInPicture:A=!1,disableRemotePlayback:w=!1}=$,R=J||K,T=$.class,I=$.style,E=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(O==="ts-video")return cN($,Z);if(F&&F!=="video")return pN(Q||"",F,$);let k=G.length>0?G:Q?[{src:Q,type:hW(Q)}]:[],S=[`id="${E}"`];if(U)S.push("controls");if(B)S.push("autoplay");if(_)S.push("muted");if(z)S.push("loop");if(j)S.push("playsinline");if(A)S.push("disablepictureinpicture");if(w)S.push("disableremoteplayback");if(N)S.push(`crossorigin="${N}"`);if(H){if(S.push(`data-preload="${q}"`),S.push('preload="none"'),R)S.push(`data-poster="${u0(R)}"`);S.push("data-stx-lazy")}else if(S.push(`preload="${q}"`),R)S.push(`poster="${u0(R)}"`);if(L)S.push(`width="${L}"`);if(V)S.push(`height="${V}"`);if(T)S.push(`class="${u0(T)}"`);if(I)S.push(`style="${u0(I)}"`);let P=k.map((f)=>{return` <source ${H?`data-src="${u0(f.src)}"`:`src="${u0(f.src)}"`} type="${f.type}"${f.media?` media="${f.media}"`:""} />`}).join(`
1256
+ </MPD>`,K}function MW($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),X=Math.floor($%60),J="PT";if(Z>0)J+=`${Z}H`;if(Y>0)J+=`${Y}M`;return J+=`${X}S`,J}var SW;var eX=D(()=>{I$();SW=[{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 bW,basename as xN,extname as vN,join as fN}from"path";import{mkdir as gN}from"fs/promises";async function CW(){try{return await import("ts-videos")}catch{return null}}function hN($){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 dN($){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 P4($){let Z=await CW();if(!Z)return null;try{let Y=bW($),J=await new Z.Input(Y).getInfo();return{duration:J.duration||0,width:J.width||0,height:J.height||0,frameRate:J.frameRate||0,bitrate:J.bitrate||0,codec:J.videoCodec||"",audioCodec:J.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function G8($,Z,Y,X){let J=await CW();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await Q7($,Z,Y);if(Q)return Q;try{let G=bW($);if(!await i0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",W=Y.baseUrl||"/videos";await gN(K,{recursive:!0});let U=await l0(G),B=xN($,vN($)),_={src:$,processed:!0,hash:U};X?.({percentage:5,stage:"analyzing"}),_.metadata=await P4(G)||void 0;let z={};if(Z.quality)z.bitrate=hN(Z.quality);if(Z.platform)Object.assign(z,dN(Z.platform));if(Z.transcode)Object.assign(z,Z.transcode);if(Object.keys(z).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let q=`${B}-${U}.mp4`,j=fN(K,q);try{let H=await uN(G,j,z,J,(O)=>X?.({percentage:10+O*0.5,stage:"transcoding"}));if(H)_.transcoded={path:j,url:`${W}/${q}`,duration:H.duration,size:H.size,video:{codec:z.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:z.audioCodec||"aac",bitrate:z.audioBitrate||128000,sampleRate:z.sampleRate||48000,channels:z.channels||2}:void 0}}catch(H){_.errors=_.errors||[],_.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let q=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await K7(G,q,K,W);if(j)_.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let q=await W7(G,Y.thumbnails,K,W);if(q.length>0)_.thumbnails=q}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let q=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(q.format==="hls"||q.format===void 0){let j=await U7(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)_.streaming={..._.streaming,hls:j}}if(q.format==="dash"){let j=await B7(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)_.streaming={..._.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await G7($,Z,_,Y),_}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function uN($,Z,Y,X,J){try{let G=await new X.Conversion($,Z,{videoCodec:Y.codec,videoBitrate:Y.bitrate,width:Y.maxWidth,height:Y.maxHeight,frameRate:Y.frameRate,audioCodec:Y.audioCodec,audioBitrate:Y.audioBitrate,sampleRate:Y.sampleRate,channels:Y.channels}).run((K)=>{J?.(K.percentage/100)});return{duration:G.duration||0,size:G.size||0,width:G.width||Y.maxWidth||0,height:G.height||Y.maxHeight||0,bitrate:G.bitrate||Y.bitrate||0,frameRate:G.frameRate||Y.frameRate||30,audioCodec:G.audioCodec}}catch(Q){return console.error(`[stx-media] Transcoding failed: ${Q}`),null}}var yW=D(()=>{I$();iX();tX();eX()});var PW={};Z0(PW,{setCachedVideoResult:()=>G7,processVideo:()=>G8,getCachedVideoResult:()=>Q7,generateThumbnails:()=>W7,generateSpriteSheet:()=>J8,generatePoster:()=>K7,generateHLSManifest:()=>U7,generateDASHManifest:()=>B7,clearVideoCache:()=>Y8,analyzeVideo:()=>P4,VideoProcessorCache:()=>J7});var $J=D(()=>{yW();tX();eX();iX()});async function vW(){try{return await Promise.resolve().then(() => ($J(),PW))}catch($){if(!xW)console.warn("[stx-media] Video processor not available, some features disabled:",$),xW=!0;return null}}async function _7($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return nN(X,Y)}if(Y.processedResult?.processed)return uW($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await sN(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=fW,autoplay:B=!1,muted:_=!1,loop:z=!1,preload:q=gW,playsinline:j=!0,lazy:H=!0,player:O="native",type:F,width:L,height:V,crossorigin:N,disablePictureInPicture:A=!1,disableRemotePlayback:w=!1}=$,R=J||K,T=$.class,I=$.style,E=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(O==="ts-video")return cN($,Z);if(F&&F!=="video")return pN(Q||"",F,$);let k=G.length>0?G:Q?[{src:Q,type:hW(Q)}]:[],S=[`id="${E}"`];if(U)S.push("controls");if(B)S.push("autoplay");if(_)S.push("muted");if(z)S.push("loop");if(j)S.push("playsinline");if(A)S.push("disablepictureinpicture");if(w)S.push("disableremoteplayback");if(N)S.push(`crossorigin="${N}"`);if(H){if(S.push(`data-preload="${q}"`),S.push('preload="none"'),R)S.push(`data-poster="${u0(R)}"`);S.push("data-stx-lazy")}else if(S.push(`preload="${q}"`),R)S.push(`poster="${u0(R)}"`);if(L)S.push(`width="${L}"`);if(V)S.push(`height="${V}"`);if(T)S.push(`class="${u0(T)}"`);if(I)S.push(`style="${u0(I)}"`);let x=k.map((f)=>{return` <source ${H?`data-src="${u0(f.src)}"`:`src="${u0(f.src)}"`} type="${f.type}"${f.media?` media="${f.media}"`:""} />`}).join(`
1257
1257
  `),y=`<video ${S.join(" ")}>
1258
- ${P}
1258
+ ${x}
1259
1259
  Your browser does not support the video tag.
1260
1260
  </video>`,b;if(H)b=`
1261
1261
  (function() {
@@ -1501,7 +1501,7 @@ ${k}
1501
1501
 
1502
1502
  observer.observe(video);
1503
1503
  })();
1504
- `.trim();let P;if(N)P=`
1504
+ `.trim();let x;if(N)x=`
1505
1505
  .stx-video-wrapper {
1506
1506
  position: relative;
1507
1507
  width: 100%;
@@ -1510,7 +1510,7 @@ ${k}
1510
1510
  width: 100%;
1511
1511
  height: auto;
1512
1512
  }
1513
- `.trim();return{html:k,script:S,css:P}}var xW=!1,fW=!0,gW="metadata",mN="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";var ZJ=D(()=>{YJ()});function K8(){return S0({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async($,Z,Y,X)=>{let{src:J,options:Q}=rN($,Z,Y);if(!J)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let G={src:J,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:Y.__isDev||!1,tsVideosConfig:Y.__tsVideosConfig},U=await _7(G,W),B=U.html;if(U.css)B+=`
1513
+ `.trim();return{html:k,script:S,css:x}}var xW=!1,fW=!0,gW="metadata",mN="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";var ZJ=D(()=>{YJ()});function K8(){return S0({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async($,Z,Y,X)=>{let{src:J,options:Q}=rN($,Z,Y);if(!J)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let G={src:J,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:Y.__isDev||!1,tsVideosConfig:Y.__tsVideosConfig},U=await _7(G,W),B=U.html;if(U.css)B+=`
1514
1514
  <style>${U.css}</style>`;if(U.script)B+=`
1515
1515
  <script>${U.script}</script>`;return B},defaults:{src:"",options:{controls:!0,lazy:!0,preload:"metadata"}}})}function rN($,Z,Y){if(Z.src)return{src:String(Z.src),options:Z.options||{}};let X=$.trim();if(X.startsWith("@video(")||X.startsWith("("))X=X.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let J=oN(X),Q=mW(J[0],Y)||"",G={};if(J[1]){let K=mW(J[1],Y);if(typeof K==="object"&&K!==null)G=K;else if(typeof J[1]==="string")try{G=JSON.parse(J[1])}catch{}}return{src:Q,options:G}}function oN($){let Z=[],Y="",X=!1,J="",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(!X)X=!0,J=W;else if(W===J)X=!1,J="";else Y+=W;continue}if(!X){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function mW($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(!Y.startsWith("/")&&!Y.startsWith(".")&&!Y.startsWith("http")&&!Y.startsWith("{")){let X=Z[Y];if(X!==void 0)return X}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var x4;var YJ=D(()=>{z4();ZJ();x4=K8()});function aN($,Z){let Y=Z.pwa?.manifest?.themeColor||"#4f46e5";return`<div class="stx-pwa-install" style="display:none;">
1516
1516
  ${$}
@@ -2131,7 +2131,7 @@ else { this.removeAttribute('${E}'); }`:`this.setAttribute('${E}', ${I.type==="o
2131
2131
  }
2132
2132
  else {
2133
2133
  this.removeAttribute('${E}');
2134
- }`:"",S=I.observer?`this.${I.observer}(value, oldValue);`:"",P=I.render!==!1?"this._scheduleRender();":"";return`
2134
+ }`:"",S=I.observer?`this.${I.observer}(value, oldValue);`:"",x=I.render!==!1?"this._scheduleRender();":"";return`
2135
2135
  get ${T}() {
2136
2136
  return this._${T};
2137
2137
  }
@@ -2141,7 +2141,7 @@ else {
2141
2141
  if (oldValue === value) return;
2142
2142
  this._${T} = value;${k}
2143
2143
  ${S}
2144
- ${P}
2144
+ ${x}
2145
2145
  this.dispatchEvent(new CustomEvent('${T}-changed', {
2146
2146
  detail: { value, oldValue },
2147
2147
  bubbles: true
@@ -2346,7 +2346,7 @@ export interface ${z}State {
2346
2346
  [key: string]: unknown;
2347
2347
  }
2348
2348
  `,L=q.map((I)=>{let E=K[I],k=H(E.type);return` private _${I}: ${k};`}).join(`
2349
- `),V=q.map((I)=>{let E=K[I],k=H(E.type),S=E.attribute!==!1?E.attribute||O7(I):null,P=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?`
2349
+ `),V=q.map((I)=>{let E=K[I],k=H(E.type),S=E.attribute!==!1?E.attribute||O7(I):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?`
2350
2350
  if (value !== null && value !== undefined) {
2351
2351
  ${E.type==="boolean"?`if (value) { this.setAttribute('${S}', ''); }
2352
2352
  else { this.removeAttribute('${S}'); }`:`this.setAttribute('${S}', ${E.type==="object"||E.type==="array"?"JSON.stringify(value)":"String(value)"});`}
@@ -2370,7 +2370,7 @@ else {
2370
2370
  }));
2371
2371
  }
2372
2372
 
2373
- // Property default: ${P}`}).join(`
2373
+ // Property default: ${x}`}).join(`
2374
2374
  `),N=j.length>0?`
2375
2375
  static get observedAttributes(): string[] {
2376
2376
  return [${j.map((I)=>`'${I}'`).join(", ")}];
@@ -3863,7 +3863,7 @@ ${Y}
3863
3863
  </script>`}function fU($,Z,Y){if(vU=0,!qw($))return $;let X=Gw($);if(X.length===0)return $;let J=zw($,X),Q=_w(X,Z),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
3864
3864
  `+J.slice(G);else J+=Q;return J}function zw($,Z){let Y=$;for(let X of Z){let Q=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${I8(X.stateExpr)}["']`,"gi").exec(Y);if(Q)X.id=Q[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${I8(X.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(Y);if(K)X.id=K[1],X.selector=`[data-stx-scope="${X.id}"]`;else Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${I8(X.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`),Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${I8(X.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`)}}return Y=Y.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),Y=Y.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),Y=Y.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),Y=Y.replace(/\s*x-init\s*=\s*'[^']*'/g,""),Y}function qw($){return/x-data\s*=\s*["']/.test($)}var vU=0,Qw=0;var gU=D(()=>{c0()});import jw from"fs";import PJ from"path";import{createHighlighter as Hw}from"ts-syntax-highlighter";async function J$($,Z={}){try{if(!await t($))throw Error(`Markdown file not found: ${$}`);let X=(await jw.promises.stat($)).mtime.getTime();if(Z.cache&&D8.has($)){let _=D8.get($);if(_.updatedAt>=X)return{content:_.content,data:_.data}}let J=await Bun.file($).text(),{data:Q,content:G}=JW(J),K=Z.markdown||W1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=R4(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await Ow(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let B={content:U,data:Q||{}};if(Z.cache)D8.set($,{...B,updatedAt:X});return B}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:L0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function Ow($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!E8)try{E8=await Hw({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,W,U,B)=>{let _=B.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),z=U||(Y?"text":"");if(!z)return K;try{if(!E8.getSupportedLanguages().includes(z))return K;return(await E8.highlight(_,z,{theme:Z})).html}catch(q){console.error(`Error highlighting code block with language ${U}:`,q)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[W,U,B,_]=K,z=await J(W,U,B,_);Q=Q.replace(W,z)}return Q}async function xJ($,Z,Y="",X={}){return await Lw($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let B=K;if(!PJ.isAbsolute(K))B=PJ.resolve(PJ.dirname(Y),K);let _={};if(W)try{try{_=JSON.parse(W)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let L=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of L){let N=V.indexOf(":");if(N>0){let A=V.substring(0,N).trim(),w=V.substring(N+1).trim(),R=w.startsWith('"')&&w.endsWith('"'),T=w.startsWith("'")&&w.endsWith("'");if(R||T)w=w.substring(1,w.length-1);_[A]=w}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:z,data:q}=await J$(B,X),j={...Z,...q,..._},H=z,O=/\{\{([^}]+)\}\}/g;return H=H.replace(O,(F,L)=>{let V=L.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(B){let _=B instanceof Error?B.message:String(B);return L0("Markdown File",`Error including markdown file: ${_}`,Y,$,U,G)}})}async function Lw($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],W=J.index,U=J;X.push(Y(...U).then((B)=>({match:K,replacement:B,index:W})))}let Q=await Promise.all(X);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 D8,E8=null;var w7=D(()=>{n0();N0();D8=new Map});function Q$($,Z){try{let Y=$.trim();if(H0(Y))return O0(Y,Object.keys(Z))(...Object.values(Z));else return z0(Y,Z)}catch{return!1}}var vJ=D(()=>{d0()});class c4{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,Z=this.line,Y=this.column,X=this.source[this.pos];if(/\s/.test(X))return this.readWhitespace($,Z,Y);if(X==="/"&&this.peek(1)==="/")return this.readLineComment($,Z,Y);if(X==="/"&&this.peek(1)==="*")return this.readBlockComment($,Z,Y);if(X==='"'||X==="'")return this.readString(X,$,Z,Y);if(X==="`")return this.readTemplateString($,Z,Y);if(/\d/.test(X)||X==="."&&/\d/.test(this.peek(1)||""))return this.readNumber($,Z,Y);if(/[a-z_$]/i.test(X))return this.readIdentifier($,Z,Y);if(X==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:$,end:this.pos,line:Z,column:Y}}if(X==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:$,end:this.pos,line:Z,column:Y}}if(X==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:$,end:this.pos,line:Z,column:Y};if(X==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective($,Z,Y);let J=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let Q of J)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:Z,column:Y};if(/[+\-*/%<>=!&|^~?:]/.test(X))return this.advance(),{type:"OPERATOR",value:X,start:$,end:this.pos,line:Z,column:Y};if(/[()[\]{},;.]/.test(X))return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y};return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y}}readWhitespace($,Z,Y){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:Z,column:Y}}readLineComment($,Z,Y){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
3865
3865
  `)this.advance();return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readBlockComment($,Z,Y){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:Z,column:Y}}readString($,Z,Y,X){this.advance();while(this.pos<this.source.length){let J=this.source[this.pos];if(J==="\\"){this.advance(2);continue}if(J===$){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(Z,this.pos),start:Z,end:this.pos,line:Y,column:X}}readTemplateString($,Z,Y){this.advance();let X=0,J=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(X>=J){this.pos=this.source.length;break}this.advance(2),X++;continue}if(Q==="{"&&X>0){X++,this.advance();continue}if(Q==="}"&&X>0){X--,this.advance();continue}if(Q==="`"&&X===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readNumber($,Z,Y){if(this.source[this.pos]==="0"){let X=this.peek(1)?.toLowerCase();if(X==="x"||X==="o"||X==="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:Z,column:Y}}}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:Z,column:Y}}readIdentifier($,Z,Y){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:Z,column:Y}}readDirective($,Z,Y){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:Z,column:Y}}advance($=1){for(let Z=0;Z<$&&this.pos<this.source.length;Z++){if(this.source[this.pos]===`
3866
- `)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 v0($,Z,Y,X=0){let J=0,Q=X,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===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function fJ($,Z){let Y=Z,X={paren:0,bracket:0,brace:0},J=null,Q=0;while(Y<$.length){let G=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&J){Y++;continue}if((G==='"'||G==="'")&&!J){J=G,Y++;continue}if(G===J&&J!=="`"){J=null,Y++;continue}if(G==="`"&&!J){J="`",Y++;continue}if(G==="`"&&J==="`"&&Q===0){J=null,Y++;continue}if(J==="`"&&G==="$"&&$[Y+1]==="{"){Q++,Y+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Y++;continue}if(J){Y++;continue}if(X.paren===0&&X.bracket===0&&X.brace===0){if($.slice(Y,Y+2)==="}}"||$.slice(Y,Y+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")X.paren++;else if(G===")"){if(X.paren--,X.paren<0)break}else if(G==="[")X.bracket++;else if(G==="]"){if(X.bracket--,X.bracket<0)break}else if(G==="{")X.brace++;else if(G==="}"){if(X.brace--,X.brace<0)break}Y++}return{expression:$.slice(Z,Y),endPos:Y}}function k8($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}if(K==="|"&&$[G-1]==="\\"&&!J){Y=Y.slice(0,-1)+K;continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function G$($,Z){let Y=Fw($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Fw($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=v0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function y$($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),B=W?W.index:1/0,_=U?U.index:1/0;if(B<_)J++,Q=B+W[0].length;else if(_<1/0){if(J--,J===0)return _;Q=_+U[0].length}else break}return-1}function gJ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=G$($,X);if(!J)return null;let Q=J.endPos,G=y$($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,B="if",_=J.expression,z=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:B,condition:_,content:K.substring(z,U),start:Q+z,end:Q+U});let F=U+O[0].length,L=G$(K,F);if(!L){U++;continue}B="elseif",_=L.expression,U=L.endPos,z=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:B,condition:_,content:K.substring(z,U),start:Q+z,end:Q+U}),B="else",_=void 0,U+=5,z=U;continue}}U++}return W.push({type:B,condition:_,content:K.slice(z),start:Q+z,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function R7($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let Q=gJ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function l4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=v0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let B=$.slice(W+1,U),_=U+1,z=y$($,Z,Y,_);if(z===-1){Q=J.exec($);continue}let q=$.slice(_,z),j=z+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:B,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function S8($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=G$($,X);if(!J)return null;let Q=J.endPos,G=y$($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,B=null,_=0;while(U<K.length){let z=K.slice(U),q=z.match(/^@switch\s*\(/),j=z.match(/^@endswitch(?![a-z])/);if(q){if(_++,B)B.content+=q[0];U+=q[0].length;continue}if(j){if(_--,B)B.content+=j[0];U+=j[0].length;continue}if(_>0){if(B)B.content+=K[U];U++;continue}let H=z.match(/^@case\s*/),O=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(B)W.push(B);let L=U+H[0].length,V=G$(K,L);if(!V){U++;continue}B={type:"case",value:V.expression,content:""},U=V.endPos}else if(O&&z.startsWith("@default")){if(B)W.push(B);B={type:"default",content:""},U+=O[0].length}else if(F&&z.startsWith("@break"))U+=F[0].length;else{if(B)B.content+=K[U];U++}}if(B)W.push(B);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var hU=()=>{};function mU($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,B=Vw($,U,W);if(B===-1){Y=G+1;continue}let _=$.slice(U,B).trim(),z=B+W.length;Z.push({fullMatch:$.slice(G,z),expression:_,start:G,end:z,isRaw:Q}),Y=z}return Z}function Vw($,Z,Y){let X=Z,J=null,Q={paren:0,bracket:0,brace:0},G=0;while(X<$.length){let K=$[X];if((X>0?$[X-1]:"")==="\\"&&J){X++;continue}if((K==='"'||K==="'")&&!J){J=K,X++;continue}if(K===J&&J!=="`"){J=null,X++;continue}if(K==="`"&&!J){J="`",X++;continue}if(K==="`"&&J==="`"&&G===0){J=null,X++;continue}if(J==="`"&&K==="$"&&$[X+1]==="{"){G++,X+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;X++;continue}if(J){X++;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(X,X+Y.length)===Y)return X}X++}return-1}function pU($){let Z=k8($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=Nw(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function Nw($){let Z=$.trim();if(!Z)return null;let Y=Z.indexOf("(");if(Y===-1)return{name:Z,args:[]};let X=Z.slice(0,Y).trim(),J=Y+1,Q=v0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=hJ(G);return{name:X,args:K}}function hJ($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+="${",G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K===","&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function cU($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=v0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function lU($){let Z=[],X=new c4($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let B=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let _=J<X.length?X[J].start:$.length,z=dU(X,J,$);J=z.nextIndex,Z.push({type:"variable",name:B,value:$.slice(_,z.endPos),exported:G,start:K.start,end:z.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let B=U.start,_=U.value==="{"?"}":"]",z=v0($,U.value,_,B);if(z!==-1){let q=$.slice(B,z+1);if(J=uU(X,z+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=dU(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let B=U.value;J++;let _=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){_=X[J].start;break}J++}if(_!==-1){let z=v0($,"{","}",_);if(z!==-1)Z.push({type:"function",name:B,value:$.slice(W,z+1).replace(/^export\s+/,""),exported:G,start:W,end:z+1}),J=uU(X,z+1)}}}else J++}return Z}function dU($,Z,Y){let X=Z,J={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:Y.length;while(X<$.length){let G=$[X];if(G.type==="PUNCTUATION"){if(G.value==="(")J.paren++;else if(G.value===")")J.paren--;else if(G.value==="[")J.bracket++;else if(G.value==="]")J.bracket--;else if(G.value==="{")J.brace++;else if(G.value==="}")J.brace--;if(G.value===";"&&J.paren===0&&J.bracket===0&&J.brace===0){Q=G.start,X++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(J.paren===0&&J.bracket===0&&J.brace===0){Q=$[X-1]?.end??G.start;break}}Q=G.end,X++}return{nextIndex:X,endPos:Q}}function uU($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var iU=()=>{};var i4=D(()=>{hU();iU()});function Aw($,Z,Y){let X=$,J=!0;while(J){J=!1;let Q=X.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=S8(X,G);if(!K)break;try{let W;if(H0(K.expression))W=O0(K.expression,Object.keys(Z))(...Object.values(Z));else W=z0(K.expression,Z);let U="",B=!1;for(let _ of K.cases)if(_.type==="default"){if(!B)U=_.content.trim()}else try{let z;if(_.value&&H0(_.value))z=O0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)z=z0(_.value,Z);if(W===z){U=_.content.trim(),B=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),B=J0("Switch",`Error evaluating @switch expression: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,G)+B+X.substring(K.end);break}}return X}function j5($,Z,Y){let X=$;X=Aw(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=G$(X,K+7);if(!W)break;let U=W.endPos,B=y$(X,"unless","endunless",U);if(B===-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 _=X.slice(U,B),z=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,V=[],N;while((N=O.exec(_))!==null)V.push({pos:N.index,type:"open"});while((N=F.exec(_))!==null)V.push({pos:N.index,type:"close"});while((N=L.exec(_))!==null)V.push({pos:N.index,type:"else"});V.sort((A,w)=>A.pos-w.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){q=A.pos;break}}let j;if(q!==-1){let H=_.slice(0,q),O=_.slice(q+5);j=`@if (${z})${O}@else ${H}@endif`}else j=`@if (!(${z}))${_}@endif`;X=X.substring(0,K)+j+X.substring(B+10),Q=!0}}X=uJ(X,Z,Y),X=mJ(X,Z,Y),X=dJ(X,Z);let J=()=>{let Q=R7(X);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 B of K.branches){if(U)break;if(B.type==="else")W=B.content,U=!0;else try{let _;if(B.condition&&H0(B.condition))_=O0(B.condition,Object.keys(Z))(...Object.values(Z));else if(B.condition)_=z0(B.condition,Z);if(_)W=B.content,U=!0}catch(_){W=J0(B.type==="if"?"If":"Elseif",`Error in @${B.type}(${B.condition}): ${_ instanceof Error?_.message:String(_)}`,e.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),B=J0("If",`Error processing @if block: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,K.start)+B+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function nU($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let J=$[Z];if(J==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(J===Y){Z++;break}X.push(J),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function dJ($,Z){let Y=$;function X(K,W,U,B){let _=1,z=B,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(z<K.length&&_>0){q.lastIndex=z,j.lastIndex=z;let H=q.exec(K),O=j.exec(K),F=H?H.index:1/0,L=O?O.index:1/0;if(F<L)_++,z=F+H[0].length;else if(L<1/0){if(_--,_===0)return L;z=L+O[0].length}else break}return-1}function J(K,W,U){let B=0,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=_.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,F)=>O.pos-F.pos);for(let O of j)if(O.type==="open")B++;else if(O.type==="close")B--;else if(O.type==="else"&&B===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,B,_,z=Y.slice(U+5),q=nU(z);if(q)B=q.value,_=U+5+q.consumed;else _=U+5;let j=X(Y,"auth","endauth",_);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=B?Q$(`auth?.check && auth?.user?.[${B}]`,Z):Q$("auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,B,_,z=Y.slice(U+6),q=nU(z);if(q)B=q.value,_=U+6+q.consumed;else _=U+6;let j=X(Y,"guest","endguest",_);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=B?Q$(`!auth?.check || !auth?.user?.[${B}]`,Z):Q$("!auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let B=[K];if(W)B.push(W);if(U){let _=Q$(U,Z);B.push(_)}return Z.permissions.check(...B)}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",B=!0;while(B){B=!1;let _=Y.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let z=_.index,q=Y.slice(z+`@${K}`.length),j=G(q);if(!j)break;let H=z+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=Y.slice(H,O),L=[],V=0,N=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],I;while((I=N.exec(F))!==null)T.push({pos:I.index,type:"open"});while((I=A.exec(F))!==null)T.push({pos:I.index,type:"close"});while((I=w.exec(F))!==null)T.push({pos:I.index,type:"elseDirective"});while((I=R.exec(F))!==null)T.push({pos:I.index,type:"else"});T.sort((b,f)=>b.pos-f.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)L.push(b)}let E=[],k=0;for(let b=0;b<L.length;b++){let f=L[b];if(E.push({content:F.slice(k,f.pos),ability:void 0}),f.type==="elseDirective"){let r=F.slice(f.pos+`@${U}`.length),u=G(r);if(u){E[E.length-1]={content:F.slice(k,f.pos)},k=f.pos+`@${U}`.length+u.paramsEnd,E.push({content:"",ability:u.ability,type:u.type,id:u.id}),E.pop();let C=L[b+1],h=C?C.pos:F.length;E.push({content:F.slice(k,h),ability:u.ability,type:u.type,id:u.id}),k=h}}else k=f.pos+5}if(k<F.length){let b=E[E.length-1];if(L.length>0&&L[L.length-1].type==="else")E.push({content:F.slice(k),isFinalElse:!0});else if(E.length===0)E.push({content:F.slice(k)})}let S=Q(j.ability,j.type,j.id),P=K==="can"?S:!S,y="";if(P)y=E[0]?.content||"";else{let b=!1;for(let f=1;f<E.length;f++){let r=E[f];if(r.isFinalElse){y=r.content,b=!0;break}if(r.ability){let u=Q(r.ability,r.type,r.id);if(K==="can"?u:!u){y=r.content,b=!0;break}}}if(!b&&E.length>0){let f=E[E.length-1];if(f.isFinalElse)y=f.content}}Y=Y.substring(0,z)+y+Y.substring(O+`@${W}`.length),B=!0}}return Y}function uJ($,Z,Y){let X=$;function J(Q,G,K,W,U){let B=!0;while(B){B=!1;let _=new RegExp(`@${G}\\s*\\(`),z=Q.match(_);if(!z||z.index===void 0)break;let q=z.index,j=G$(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=y$(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,O),L=j.expression,V=-1,N=0,A=0;while(A<F.length){let w=F.indexOf("@",A);if(w===-1)break;let R=F.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){N++,A=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){N--,A=w+1;continue}if(N===0&&/^@else(?![a-z])/.test(R)){V=w;break}A=w+1}try{let w=W(L.trim()),R;if(V!==-1){let T=F.slice(0,V),I=F.slice(V+5);R=w?T:I}else R=w?F:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),B=!0}catch(w){let R=w instanceof Error?w.message:String(w),T=J0(U,`Error processing @${G} directive: ${R}`,e.EVALUATION_ERROR);Q=Q.substring(0,q)+T+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=Q$(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=Q$(Q,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),X}function mJ($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let B=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,B.lastIndex=0;let O=B.exec(j);if(!O)break;let F=O.index,L=F+O[0].length;if(K==="env"){let S=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!S)break;L+=S[0].length,U=J===S[2]}let V=1,N=L,A=-1;while(V>0&&N<j.length){B.lastIndex=N,_.lastIndex=N;let S=B.exec(j),P=_.exec(j),y=S?S.index:1/0,b=P?P.index:1/0;if(y<b)V++,N=y+S[0].length;else if(b<1/0){if(V--,V===0){A=b;break}N=b+P[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,A),R=-1,T=0,I=0;while(I<w.length){let S=w.indexOf("@",I);if(S===-1)break;let P=w.substring(S);if(z.test(P)){T++,I=S+1;continue}if(q.test(P)){T--,I=S+1;continue}if(T===0&&/^@else(?![a-z])/.test(P)){R=S;break}I=S+1}let E;if(R!==-1){let S=w.slice(0,R),P=w.slice(R+5);E=U?S:P}else E=U?w:"";let k=`@${W}`.length;j=j.substring(0,F)+E+j.substring(A+k),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var b8=D(()=>{vJ();j1();i4();d0()});function cJ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function P$($,Z){if(!$)return Z?.nonceGenerator?.()??cJ();let Y=pJ.get($);if(!Y)Y=Z?.nonceGenerator?.()??cJ(),pJ.set($,Y);return Y}function ww($){pJ.delete($)}function lJ($,Z){let Y=[];for(let[X,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)Y.push(X);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(X==="script-src"||X==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${X} ${Q.join(" ")}`)}}return Y.join("; ")}function y8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${lJ($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function Rw($){return{enabled:!0,directives:{strict:sU,moderate:C8,relaxed:rU,api:oU}[$]||C8,useNonce:$==="strict",addMetaTag:!0}}function Mw($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function iJ($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let X=Z.useNonce?P$(Y,Z):void 0,J=y8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
3866
+ `)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 v0($,Z,Y,X=0){let J=0,Q=X,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===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function fJ($,Z){let Y=Z,X={paren:0,bracket:0,brace:0},J=null,Q=0;while(Y<$.length){let G=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&J){Y++;continue}if((G==='"'||G==="'")&&!J){J=G,Y++;continue}if(G===J&&J!=="`"){J=null,Y++;continue}if(G==="`"&&!J){J="`",Y++;continue}if(G==="`"&&J==="`"&&Q===0){J=null,Y++;continue}if(J==="`"&&G==="$"&&$[Y+1]==="{"){Q++,Y+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Y++;continue}if(J){Y++;continue}if(X.paren===0&&X.bracket===0&&X.brace===0){if($.slice(Y,Y+2)==="}}"||$.slice(Y,Y+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")X.paren++;else if(G===")"){if(X.paren--,X.paren<0)break}else if(G==="[")X.bracket++;else if(G==="]"){if(X.bracket--,X.bracket<0)break}else if(G==="{")X.brace++;else if(G==="}"){if(X.brace--,X.brace<0)break}Y++}return{expression:$.slice(Z,Y),endPos:Y}}function k8($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}if(K==="|"&&$[G-1]==="\\"&&!J){Y=Y.slice(0,-1)+K;continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function G$($,Z){let Y=Fw($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Fw($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=v0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function y$($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),B=W?W.index:1/0,_=U?U.index:1/0;if(B<_)J++,Q=B+W[0].length;else if(_<1/0){if(J--,J===0)return _;Q=_+U[0].length}else break}return-1}function gJ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=G$($,X);if(!J)return null;let Q=J.endPos,G=y$($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,B="if",_=J.expression,z=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:B,condition:_,content:K.substring(z,U),start:Q+z,end:Q+U});let F=U+O[0].length,L=G$(K,F);if(!L){U++;continue}B="elseif",_=L.expression,U=L.endPos,z=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:B,condition:_,content:K.substring(z,U),start:Q+z,end:Q+U}),B="else",_=void 0,U+=5,z=U;continue}}U++}return W.push({type:B,condition:_,content:K.slice(z),start:Q+z,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function R7($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let Q=gJ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function l4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=v0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let B=$.slice(W+1,U),_=U+1,z=y$($,Z,Y,_);if(z===-1){Q=J.exec($);continue}let q=$.slice(_,z),j=z+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:B,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function S8($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=G$($,X);if(!J)return null;let Q=J.endPos,G=y$($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,B=null,_=0;while(U<K.length){let z=K.slice(U),q=z.match(/^@switch\s*\(/),j=z.match(/^@endswitch(?![a-z])/);if(q){if(_++,B)B.content+=q[0];U+=q[0].length;continue}if(j){if(_--,B)B.content+=j[0];U+=j[0].length;continue}if(_>0){if(B)B.content+=K[U];U++;continue}let H=z.match(/^@case\s*/),O=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(B)W.push(B);let L=U+H[0].length,V=G$(K,L);if(!V){U++;continue}B={type:"case",value:V.expression,content:""},U=V.endPos}else if(O&&z.startsWith("@default")){if(B)W.push(B);B={type:"default",content:""},U+=O[0].length}else if(F&&z.startsWith("@break"))U+=F[0].length;else{if(B)B.content+=K[U];U++}}if(B)W.push(B);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var hU=()=>{};function mU($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,B=Vw($,U,W);if(B===-1){Y=G+1;continue}let _=$.slice(U,B).trim(),z=B+W.length;Z.push({fullMatch:$.slice(G,z),expression:_,start:G,end:z,isRaw:Q}),Y=z}return Z}function Vw($,Z,Y){let X=Z,J=null,Q={paren:0,bracket:0,brace:0},G=0;while(X<$.length){let K=$[X];if((X>0?$[X-1]:"")==="\\"&&J){X++;continue}if((K==='"'||K==="'")&&!J){J=K,X++;continue}if(K===J&&J!=="`"){J=null,X++;continue}if(K==="`"&&!J){J="`",X++;continue}if(K==="`"&&J==="`"&&G===0){J=null,X++;continue}if(J==="`"&&K==="$"&&$[X+1]==="{"){G++,X+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;X++;continue}if(J){X++;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(X,X+Y.length)===Y)return X}X++}return-1}function pU($){let Z=k8($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=Nw(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function Nw($){let Z=$.trim();if(!Z)return null;let Y=Z.indexOf("(");if(Y===-1)return{name:Z,args:[]};let X=Z.slice(0,Y).trim(),J=Y+1,Q=v0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=hJ(G);return{name:X,args:K}}function hJ($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+="${",G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K===","&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function cU($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=v0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function lU($){let Z=[],X=new c4($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let B=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let _=J<X.length?X[J].start:$.length,z=dU(X,J,$);J=z.nextIndex,Z.push({type:"variable",name:B,value:$.slice(_,z.endPos),exported:G,start:K.start,end:z.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let B=U.start,_=U.value==="{"?"}":"]",z=v0($,U.value,_,B);if(z!==-1){let q=$.slice(B,z+1);if(J=uU(X,z+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=dU(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let B=U.value;J++;let _=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){_=X[J].start;break}J++}if(_!==-1){let z=v0($,"{","}",_);if(z!==-1)Z.push({type:"function",name:B,value:$.slice(W,z+1).replace(/^export\s+/,""),exported:G,start:W,end:z+1}),J=uU(X,z+1)}}}else J++}return Z}function dU($,Z,Y){let X=Z,J={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:Y.length;while(X<$.length){let G=$[X];if(G.type==="PUNCTUATION"){if(G.value==="(")J.paren++;else if(G.value===")")J.paren--;else if(G.value==="[")J.bracket++;else if(G.value==="]")J.bracket--;else if(G.value==="{")J.brace++;else if(G.value==="}")J.brace--;if(G.value===";"&&J.paren===0&&J.bracket===0&&J.brace===0){Q=G.start,X++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(J.paren===0&&J.bracket===0&&J.brace===0){Q=$[X-1]?.end??G.start;break}}Q=G.end,X++}return{nextIndex:X,endPos:Q}}function uU($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var iU=()=>{};var i4=D(()=>{hU();iU()});function Aw($,Z,Y){let X=$,J=!0;while(J){J=!1;let Q=X.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=S8(X,G);if(!K)break;try{let W;if(H0(K.expression))W=O0(K.expression,Object.keys(Z))(...Object.values(Z));else W=z0(K.expression,Z);let U="",B=!1;for(let _ of K.cases)if(_.type==="default"){if(!B)U=_.content.trim()}else try{let z;if(_.value&&H0(_.value))z=O0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)z=z0(_.value,Z);if(W===z){U=_.content.trim(),B=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),B=J0("Switch",`Error evaluating @switch expression: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,G)+B+X.substring(K.end);break}}return X}function j5($,Z,Y){let X=$;X=Aw(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=G$(X,K+7);if(!W)break;let U=W.endPos,B=y$(X,"unless","endunless",U);if(B===-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 _=X.slice(U,B),z=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,V=[],N;while((N=O.exec(_))!==null)V.push({pos:N.index,type:"open"});while((N=F.exec(_))!==null)V.push({pos:N.index,type:"close"});while((N=L.exec(_))!==null)V.push({pos:N.index,type:"else"});V.sort((A,w)=>A.pos-w.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){q=A.pos;break}}let j;if(q!==-1){let H=_.slice(0,q),O=_.slice(q+5);j=`@if (${z})${O}@else ${H}@endif`}else j=`@if (!(${z}))${_}@endif`;X=X.substring(0,K)+j+X.substring(B+10),Q=!0}}X=uJ(X,Z,Y),X=mJ(X,Z,Y),X=dJ(X,Z);let J=()=>{let Q=R7(X);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 B of K.branches){if(U)break;if(B.type==="else")W=B.content,U=!0;else try{let _;if(B.condition&&H0(B.condition))_=O0(B.condition,Object.keys(Z))(...Object.values(Z));else if(B.condition)_=z0(B.condition,Z);if(_)W=B.content,U=!0}catch(_){W=J0(B.type==="if"?"If":"Elseif",`Error in @${B.type}(${B.condition}): ${_ instanceof Error?_.message:String(_)}`,e.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),B=J0("If",`Error processing @if block: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,K.start)+B+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function nU($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let J=$[Z];if(J==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(J===Y){Z++;break}X.push(J),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function dJ($,Z){let Y=$;function X(K,W,U,B){let _=1,z=B,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(z<K.length&&_>0){q.lastIndex=z,j.lastIndex=z;let H=q.exec(K),O=j.exec(K),F=H?H.index:1/0,L=O?O.index:1/0;if(F<L)_++,z=F+H[0].length;else if(L<1/0){if(_--,_===0)return L;z=L+O[0].length}else break}return-1}function J(K,W,U){let B=0,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=_.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,F)=>O.pos-F.pos);for(let O of j)if(O.type==="open")B++;else if(O.type==="close")B--;else if(O.type==="else"&&B===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,B,_,z=Y.slice(U+5),q=nU(z);if(q)B=q.value,_=U+5+q.consumed;else _=U+5;let j=X(Y,"auth","endauth",_);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=B?Q$(`auth?.check && auth?.user?.[${B}]`,Z):Q$("auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,B,_,z=Y.slice(U+6),q=nU(z);if(q)B=q.value,_=U+6+q.consumed;else _=U+6;let j=X(Y,"guest","endguest",_);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=B?Q$(`!auth?.check || !auth?.user?.[${B}]`,Z):Q$("!auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let B=[K];if(W)B.push(W);if(U){let _=Q$(U,Z);B.push(_)}return Z.permissions.check(...B)}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",B=!0;while(B){B=!1;let _=Y.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let z=_.index,q=Y.slice(z+`@${K}`.length),j=G(q);if(!j)break;let H=z+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=Y.slice(H,O),L=[],V=0,N=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],I;while((I=N.exec(F))!==null)T.push({pos:I.index,type:"open"});while((I=A.exec(F))!==null)T.push({pos:I.index,type:"close"});while((I=w.exec(F))!==null)T.push({pos:I.index,type:"elseDirective"});while((I=R.exec(F))!==null)T.push({pos:I.index,type:"else"});T.sort((b,f)=>b.pos-f.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)L.push(b)}let E=[],k=0;for(let b=0;b<L.length;b++){let f=L[b];if(E.push({content:F.slice(k,f.pos),ability:void 0}),f.type==="elseDirective"){let r=F.slice(f.pos+`@${U}`.length),u=G(r);if(u){E[E.length-1]={content:F.slice(k,f.pos)},k=f.pos+`@${U}`.length+u.paramsEnd,E.push({content:"",ability:u.ability,type:u.type,id:u.id}),E.pop();let C=L[b+1],h=C?C.pos:F.length;E.push({content:F.slice(k,h),ability:u.ability,type:u.type,id:u.id}),k=h}}else k=f.pos+5}if(k<F.length){let b=E[E.length-1];if(L.length>0&&L[L.length-1].type==="else")E.push({content:F.slice(k),isFinalElse:!0});else if(E.length===0)E.push({content:F.slice(k)})}let S=Q(j.ability,j.type,j.id),x=K==="can"?S:!S,y="";if(x)y=E[0]?.content||"";else{let b=!1;for(let f=1;f<E.length;f++){let r=E[f];if(r.isFinalElse){y=r.content,b=!0;break}if(r.ability){let u=Q(r.ability,r.type,r.id);if(K==="can"?u:!u){y=r.content,b=!0;break}}}if(!b&&E.length>0){let f=E[E.length-1];if(f.isFinalElse)y=f.content}}Y=Y.substring(0,z)+y+Y.substring(O+`@${W}`.length),B=!0}}return Y}function uJ($,Z,Y){let X=$;function J(Q,G,K,W,U){let B=!0;while(B){B=!1;let _=new RegExp(`@${G}\\s*\\(`),z=Q.match(_);if(!z||z.index===void 0)break;let q=z.index,j=G$(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=y$(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,O),L=j.expression,V=-1,N=0,A=0;while(A<F.length){let w=F.indexOf("@",A);if(w===-1)break;let R=F.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){N++,A=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){N--,A=w+1;continue}if(N===0&&/^@else(?![a-z])/.test(R)){V=w;break}A=w+1}try{let w=W(L.trim()),R;if(V!==-1){let T=F.slice(0,V),I=F.slice(V+5);R=w?T:I}else R=w?F:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),B=!0}catch(w){let R=w instanceof Error?w.message:String(w),T=J0(U,`Error processing @${G} directive: ${R}`,e.EVALUATION_ERROR);Q=Q.substring(0,q)+T+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=Q$(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=Q$(Q,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),X}function mJ($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let B=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,B.lastIndex=0;let O=B.exec(j);if(!O)break;let F=O.index,L=F+O[0].length;if(K==="env"){let S=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!S)break;L+=S[0].length,U=J===S[2]}let V=1,N=L,A=-1;while(V>0&&N<j.length){B.lastIndex=N,_.lastIndex=N;let S=B.exec(j),x=_.exec(j),y=S?S.index:1/0,b=x?x.index:1/0;if(y<b)V++,N=y+S[0].length;else if(b<1/0){if(V--,V===0){A=b;break}N=b+x[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,A),R=-1,T=0,I=0;while(I<w.length){let S=w.indexOf("@",I);if(S===-1)break;let x=w.substring(S);if(z.test(x)){T++,I=S+1;continue}if(q.test(x)){T--,I=S+1;continue}if(T===0&&/^@else(?![a-z])/.test(x)){R=S;break}I=S+1}let E;if(R!==-1){let S=w.slice(0,R),x=w.slice(R+5);E=U?S:x}else E=U?w:"";let k=`@${W}`.length;j=j.substring(0,F)+E+j.substring(A+k),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var b8=D(()=>{vJ();j1();i4();d0()});function cJ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function P$($,Z){if(!$)return Z?.nonceGenerator?.()??cJ();let Y=pJ.get($);if(!Y)Y=Z?.nonceGenerator?.()??cJ(),pJ.set($,Y);return Y}function ww($){pJ.delete($)}function lJ($,Z){let Y=[];for(let[X,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)Y.push(X);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(X==="script-src"||X==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${X} ${Q.join(" ")}`)}}return Y.join("; ")}function y8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${lJ($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function Rw($){return{enabled:!0,directives:{strict:sU,moderate:C8,relaxed:rU,api:oU}[$]||C8,useNonce:$==="strict",addMetaTag:!0}}function Mw($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function iJ($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let X=Z.useNonce?P$(Y,Z):void 0,J=y8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
3867
3867
  ${J}`)}function Tw($,Z){let Y=$;return Y=Y.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(X,J)=>{if(J.includes("nonce="))return X;return`<script nonce="${Z}"${J}>`}),Y=Y.replace(/<style([^>]*)>/gi,(X,J)=>{if(J.includes("nonce="))return X;return`<style nonce="${Z}"${J}>`}),Y}function nJ($,Z,Y,X){let J=$,Q=X.csp;if(J=J.replace(/@csp\b/g,()=>{if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?P$(Z,Q):void 0;return y8(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return P$(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=P$(Z,Q);return J}function Iw(){return[aU,tU]}function Ew($){let Z=[];if($["script-src"]?.includes("'unsafe-inline'"))Z.push("CSP: Using unsafe-inline in script-src significantly reduces XSS protection");if($["script-src"]?.includes("'unsafe-eval'"))Z.push("CSP: Using unsafe-eval in script-src allows eval() and related functions");if(!$["default-src"])Z.push("CSP: No default-src specified. Recommend adding default-src as a fallback");if($["default-src"]?.includes("*"))Z.push("CSP: Using * in default-src provides minimal protection");if(!$["object-src"]&&!$["default-src"]?.includes("'none'"))Z.push("CSP: Consider adding object-src: none to block plugins");if(!$["base-uri"])Z.push("CSP: Consider adding base-uri to prevent base tag injection attacks");for(let[Y,X]of Object.entries($))if(Array.isArray(X)&&X.includes("http:"))Z.push(`CSP: Using http: in ${Y} allows insecure resources`);return Z}function eU($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function Dw($,Z){if(!$.enabled)return{};let Y=$.useNonce?P$(Z,$):void 0,X=lJ($.directives,Y);return{[eU($.reportOnly)]:X}}var pJ,sU,C8,rU,oU,aU,tU,kw;var sJ=D(()=>{pJ=new WeakMap;sU={"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},C8={"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},rU={"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'"]},oU={"default-src":["'none'"],"frame-ancestors":["'none'"]};aU={name:"csp",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?P$(Y,Q):void 0;return y8(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},tU={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return P$(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};kw={enabled:!1,reportOnly:!1,directives:C8,useNonce:!1,addMetaTag:!0}});import Sw from"crypto";function Cw($=bw){let Z=Sw.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return rJ=Z,Z}function yw(){if(!rJ)Cw();return rJ}function Pw($=$B){let Z=yw();return`<input type="hidden" name="${$}" value="${Z}">`}function ZB($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return Pw(X||$B)})}var bw=40,$B="_token",rJ=null;var YB=()=>{};async function oJ($,Z,Y,X){if(!X.customDirectives||X.customDirectives.length===0)return $;let J=$;for(let Q of X.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(X.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)J=await xw(J,Q,Z,Y,X);else J=await vw(J,Q,Z,Y,X)}return J}async function xw($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,B=l5(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),_=[],z=B.exec(U);while(z!==null){let[q,j="",H=""]=z,O=z.index||0;try{let F=j?XB(j):[],L=H.trim(),V=await G(L,F,Y,X);_.push({original:q,processed:V,startIndex:O})}catch(F){let L=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);_.push({original:q,processed:J0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${L}`,e.EVALUATION_ERROR),startIndex:O})}z=B.exec(U)}for(let q=_.length-1;q>=0;q--){let{original:j,processed:H}=_[q];U=U.replace(j,H)}return U}async function vw($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,W=l5(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],B=W.exec(K);while(B!==null){let[q,j=""]=B,H=B.index||0;try{let O=XB(j),F=await G("",O,Y,X);U.push({original:q,processed:F,startIndex:H})}catch(O){let F=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:q,processed:J0("CustomDirective",`Error in @${Q}(${j}): ${F}`,e.EVALUATION_ERROR),startIndex:H})}B=W.exec(K)}let _=l5(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),z=_.exec(K);while(z!==null){let[q]=z,j=z.index||0;try{let H=await G("",[],Y,X);U.push({original:q,processed:H,startIndex:j})}catch(H){let O=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:J0("CustomDirective",`Error in @${Q}: ${O}`,e.EVALUATION_ERROR),startIndex:j})}z=_.exec(K)}for(let q=U.length-1;q>=0;q--){let{original:j,processed:H}=U[q];K=K.replace(j,H)}return K}function XB($){if(!$.trim())return[];let Z=[],Y="",X=!1,J="";for(let Q=0;Q<$.length;Q++){let G=$[Q];if((G==='"'||G==="'")&&(Q===0||$[Q-1]!=="\\"))if(!X)X=!0,J=G;else if(G===J)X=!1;else Y+=G;else if(G===","&&!X)Z.push(Y.trim()),Y="";else Y+=G}if(Y.trim())Z.push(Y.trim());return Z.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 aJ=D(()=>{j1();z5()});var v8={};Z0(v8,{useTitle:()=>GB,useSeoMeta:()=>n4,usePageTitle:()=>GB,useHead:()=>v$,resetHead:()=>JB,renderHtmlAttrs:()=>WB,renderHead:()=>KB,renderBodyAttrs:()=>UB,processTitleDirective:()=>zB,processMetaDirective:()=>qB,processHeadDirective:()=>_B,getPageMeta:()=>x8,getHead:()=>M7,definePageMeta:()=>QB,applyHead:()=>BB});function M7(){return x$}function x8(){return P8}function JB(){x$={},fw.length=0,P8={}}function v$($){x$=gw(x$,$)}function gw($,Z){return{title:Z.title??$.title,titleTemplate:Z.titleTemplate??$.titleTemplate,base:Z.base??$.base,meta:[...$.meta||[],...Z.meta||[]],link:[...$.link||[],...Z.link||[]],script:[...$.script||[],...Z.script||[]],style:[...$.style||[],...Z.style||[]],htmlAttrs:{...$.htmlAttrs,...Z.htmlAttrs},bodyAttrs:{...$.bodyAttrs,...Z.bodyAttrs}}}function n4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:W})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let J=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(J)Z.push({name:"twitter:title",content:J});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)Z.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});v$({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function QB($){if(P8={...P8,...$},$.title||$.description)n4({title:$.title,description:$.description})}function GB($){let Z=typeof $==="function"?$():$;v$({title:Z})}function KB($=x$){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${H5(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${H5(J)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let X=Object.entries(Y).filter(([J,Q])=>Q!==void 0).map(([J,Q])=>{return`${J==="httpEquiv"?"http-equiv":J}="${H5(String(Q))}"`}).join(" ");Z.push(`<meta ${X}>`)}for(let Y of $.link||[]){let X=Object.entries(Y).filter(([J,Q])=>Q!==void 0).map(([J,Q])=>`${J}="${H5(String(Q))}"`).join(" ");Z.push(`<link ${X}>`)}for(let Y of $.script||[]){let{content:X,...J}=Y,Q=Object.entries(J).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${H5(String(K))}"`}).filter(Boolean).join(" ");if(X)Z.push(`<script ${Q}>${X}</script>`);else Z.push(`<script ${Q}></script>`)}for(let Y of $.style||[]){let X=Y.type?` type="${Y.type}"`:"";Z.push(`<style${X}>${Y.content}</style>`)}return Z.join(`
3868
3868
  `)}function WB($=x$){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${H5(Y)}"`).join(" ")}function UB($=x$){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${H5(Y)}"`).join(" ")}function H5($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function BB($=x$){if(typeof document>"u")return;if($.title){let Z=$.title;if($.titleTemplate)Z=typeof $.titleTemplate==="function"?$.titleTemplate(Z):$.titleTemplate.replace("%s",Z);document.title=Z}for(let Z of $.meta||[]){let Y=Z.name?`meta[name="${Z.name}"]`:Z.property?`meta[property="${Z.property}"]`:null;if(Y){let X=document.querySelector(Y);if(!X){if(X=document.createElement("meta"),Z.name)X.setAttribute("name",Z.name);if(Z.property)X.setAttribute("property",Z.property);document.head.appendChild(X)}X.setAttribute("content",Z.content)}}for(let Z of $.link||[]){let Y=`link[rel="${Z.rel}"]${Z.href?`[href="${Z.href}"]`:""}`,X=document.querySelector(Y);if(!X)X=document.createElement("link"),document.head.appendChild(X);for(let[J,Q]of Object.entries(Z))if(Q!==void 0)X.setAttribute(J,String(Q))}if($.htmlAttrs)for(let[Z,Y]of Object.entries($.htmlAttrs))document.documentElement.setAttribute(Z,Y);if($.bodyAttrs)for(let[Z,Y]of Object.entries($.bodyAttrs))document.body.setAttribute(Z,Y)}function _B($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
3869
3869
  `,""}),headContent:Z.trim()}}function zB($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return v$({title:G}),""})}function qB($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let W=Q?G:K,U=Q?W:Z[(W||"").trim()]??W,_=J.includes(":")?{property:J,content:U}:{name:J,content:U};return v$({meta:[_]}),""})}var x$,fw,P8;var f$=D(()=>{x$={},fw=[],P8={}});import hw from"crypto";function s0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function dw($){return{...g8,...$.forms?.classes}}function f8($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function uw(){return hw.randomUUID()}function mw($,Z,Y,X){let J=dw(X),Q=$;return Q=LB(Q,Z),Q=T7(Q,Z),Q=h8(Q,Z,J),Q=d8(Q,Z,J),Q}function T7($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=uw();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${s0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(X,J)=>{let Q=J.toUpperCase();if(J&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${s0(Q)}">`;return X}),Y}function h8($,Z,Y=g8){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,W,U="")=>{let B=Q||G||"POST",_=K||W||"",z=g$(U),q=B.toUpperCase(),j=["GET","POST"].includes(q)?q:"POST",H=`<form method="${s0(j)}" action="${s0(_)}"${z?` ${z}`:""}>`;if(H+=`
@@ -4113,12 +4113,12 @@ else {
4113
4113
  ${W?`{${W}}`:"{}"}
4114
4114
  </script>
4115
4115
  </div>`}}});var dB={};Z0(dB,{warnUnbalancedTags:()=>_2,findUnbalancedTags:()=>hB});function d$($){return $.replace(/[^\n]/g," ")}function hB($){let Z=$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,d$).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,d$).replace(/<!--[\s\S]*?-->/g,d$).replace(/\{\{\{[\s\S]*?\}\}\}/g,d$).replace(/\{\{[\s\S]*?\}\}/g,d$).replace(/\{!![\s\S]*?!!\}/g,d$).replace(/"[^"]*"/g,d$).replace(/'[^']*'/g,d$),Y=new Map,X=new Map,J=/<(\/?)([A-Za-z][\w-]*)\b[^>]*?(\/?)>/g,Q;while((Q=J.exec(Z))!==null){let K=Q[1]==="/",W=Q[2],U=Q[3]==="/";if(ER.has(W.toLowerCase()))continue;if(U)continue;if(K)X.set(W,(X.get(W)??0)+1);else{let B=Y.get(W);if(B)B.count++;else{let _=Z.slice(0,Q.index).split(`
4116
- `).length;Y.set(W,{count:1,firstLine:_})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(DR.has(K.toLowerCase()))continue;let W=Y.get(K)?.count??0,U=X.get(K)??0;if(W!==U)G.push({tag:K,opened:W,closed:U,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function _2($,Z){let Y;try{Y=hB($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(gB.has(X))return;gB.add(X);let J=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:W}of Y)if(G>K){let U=W?` (first opened at line ${W})`:"";console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${U} may swallow the content that follows it.`)}else console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var ER,DR,gB;var z2=D(()=>{ER=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),DR=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);gB=new Set});import I1 from"path";import q2 from"fs";function uB($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function mB($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class pB{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,X){let J=$.endsWith(".stx")?$.slice(0,-4):$,Q=X?.__importedComponents;if(Q){let q=[J,J.toLowerCase(),uB(J),mB(J)];for(let j of q)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${uB(J)}.stx`,`${mB(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let q=I1.resolve(I1.dirname(Z),`${J}.stx`);if(await t(q))return q;return null}let K=[],W=Y.componentsDir||"",U=X?.__originalFilePath;if(U)K.push(I1.join(I1.dirname(U),"components"));if(W)K.push(W);let B=I1.join(I1.dirname(Z),"components");if(!K.includes(B))K.push(B);let _=process.cwd(),z=[I1.resolve(_,"src/components"),I1.resolve(_,"components"),I1.resolve(import.meta.dir,"components")];for(let q of z)if(!K.includes(q))K.push(q);for(let q of K){if(!q)continue;for(let j of G){let H=I1.join(q,j);if(await t(H))return H}try{if(!q2.statSync(q,{throwIfNoEntry:!1})?.isDirectory())continue;let H=q2.readdirSync(q,{withFileTypes:!0});for(let O of H)if(O.isDirectory()){let F=I1.join(q,O.name);for(let L of G){let V=I1.join(F,L);if(await t(V))return V}}}catch{}}return null}}var B1;var j2=D(()=>{N0();B1=new pB});function u$($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function kR($){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 H2;var O2=D(()=>{H2={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=kR($),J=(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(X.reactive)W.push(`:href="${u$(X.value)}"`);else W.push(`href="${u$(X.value)}"`);if(J)W.push(`class="${u$(J)}"`);if(W.push("data-stx-link"),W.push(`data-stx-active-class="${u$(Q)}"`),W.push(`data-stx-exact-active-class="${u$(G)}"`),K)W.push("data-stx-prefetch");let U=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[B,_]of Object.entries($.static)){if(U.has(B))continue;if(typeof _==="boolean"){if(_)W.push(u$(B))}else W.push(`${u$(B)}="${u$(_)}"`)}return`<a ${W.join(" ")}>${Z}</a>`}}});function f0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function X1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function F2($,Z,Y=!1){let X=$.serverDynamic[Z];if(X!==void 0)return X!==!1&&X!=="false";let J=$.static[Z];if(J!==void 0)return J!=="false"&&J!==!1;return Y}function cB($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[J,Q]=X.split(":"),G=SR[J];if(G)Y.push(`(max-width: ${G}px) ${Q}`);else{let K=Number.parseInt(J);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${Q}`)}}else Y.push(X);return Y.join(", ")}function V2($,Z,Y,X){return Z.map((J)=>`${t4($,J,void 0,Y,X)} ${J}w`).join(", ")}function bR($,Z,Y,X,J){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${t4($,G,void 0,X,J)} ${Q}x`}).join(", ")}function t4($,Z,Y,X,J){if(!X||X==="local"||X==="static")return $;if(X==="cloudinary"){let Q=[];if(Z)Q.push(`w_${Z}`);if(Y)Q.push(`h_${Y}`);if(J)Q.push(`f_${J}`);Q.push("q_auto");let G=Q.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(X==="imgix"){let Q=new URLSearchParams;if(Z)Q.set("w",String(Z));if(Y)Q.set("h",String(Y));if(J)Q.set("fm",J);Q.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}if(X==="bunny"){let Q=new URLSearchParams;if(Z)Q.set("width",String(Z));if(Y)Q.set("height",String(Y));if(J)Q.set("format",J);let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}return $}function CR($,Z,Y="#e5e7eb"){let X=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${Z}"><rect width="100%" height="100%" fill="${Y}"/></svg>`;return`data:image/svg+xml;base64,${btoa(X)}`}var SR,L2,N2;var A2=D(()=>{SR={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},L2=[320,640,768,1024,1280,1536,1920];N2={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=X1($,"src")||"",J=X1($,"alt")||"",Q=X1($,"width"),G=X1($,"height"),K=X1($,"sizes"),W=X1($,"srcset"),U=X1($,"densities"),B=X1($,"format"),_=X1($,"placeholder"),z=X1($,"placeholderColor")||"#e5e7eb",q=X1($,"provider"),j=X1($,"class")||X1($,"className")||"",H=X1($,"style")||"",O=X1($,"quality"),F=F2($,"lazy",!0),L=F2($,"preload",!1),V=F2($,"picture",!1)||!!B,N=Q?Number.parseInt(Q):void 0,A=G?Number.parseInt(G):void 0,w=W||"",R="";if(!w&&K)w=V2(X,L2,q,B),R=cB(K);else if(!w&&U){let y=U.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));w=bR(X,y,N,q,B)}else if(K)R=cB(K);let T=[];if(H)T.push(H);if(N&&A)T.push(`aspect-ratio:${N}/${A}`);if(_==="blur"||_==="color"||_==="thumbhash"){let y=CR(N||16,A||9,z);T.push(`background-image:url(${y})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(_&&_!=="empty"&&_!=="none")T.push(`background-image:url(${f0(_)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let I=t4(X,N,A,q,B),E=[];if(E.push(`src="${f0(I)}"`),E.push(`alt="${f0(J)}"`),Q)E.push(`width="${f0(Q)}"`);if(G)E.push(`height="${f0(G)}"`);if(F)E.push('loading="lazy"');if(E.push('decoding="async"'),j)E.push(`class="${f0(j)}"`);if(T.length>0)E.push(`style="${f0(T.join(";"))}"`);if(w)E.push(`srcset="${f0(w)}"`);if(R)E.push(`sizes="${f0(R)}"`);let k=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[y,b]of Object.entries($.static)){if(k.has(y))continue;if(typeof b==="boolean"){if(b)E.push(f0(y))}else E.push(`${f0(y)}="${f0(b)}"`)}let S=`<img ${E.join(" ")} />`,P="";if(L){let b=B==="webp"?"image/webp":B==="avif"?"image/avif":"";P=`<link rel="preload" as="image" href="${f0(I)}"${b?` type="${b}"`:""}${w?` imagesrcset="${f0(w)}"`:""}${R?` imagesizes="${f0(R)}"`:""} />
4117
- `}if(V){let y=[];if(B==="avif"||B==="auto"){let b=t4(X,N,A,q,"avif"),f=w?V2(X,L2,q,"avif"):`${b}`;y.push(`<source type="image/avif" srcset="${f0(f)}"${R?` sizes="${f0(R)}"`:""} />`)}if(B==="webp"||B==="auto"){let b=t4(X,N,A,q,"webp"),f=w?V2(X,L2,q,"webp"):`${b}`;y.push(`<source type="image/webp" srcset="${f0(f)}"${R?` sizes="${f0(R)}"`:""} />`)}return`${P}<picture>
4116
+ `).length;Y.set(W,{count:1,firstLine:_})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(DR.has(K.toLowerCase()))continue;let W=Y.get(K)?.count??0,U=X.get(K)??0;if(W!==U)G.push({tag:K,opened:W,closed:U,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function _2($,Z){let Y;try{Y=hB($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(gB.has(X))return;gB.add(X);let J=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:W}of Y)if(G>K){let U=W?` (first opened at line ${W})`:"";console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${U} may swallow the content that follows it.`)}else console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var ER,DR,gB;var z2=D(()=>{ER=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),DR=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);gB=new Set});import I1 from"path";import q2 from"fs";function uB($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function mB($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class pB{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,X){let J=$.endsWith(".stx")?$.slice(0,-4):$,Q=X?.__importedComponents;if(Q){let q=[J,J.toLowerCase(),uB(J),mB(J)];for(let j of q)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${uB(J)}.stx`,`${mB(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let q=I1.resolve(I1.dirname(Z),`${J}.stx`);if(await t(q))return q;return null}let K=[],W=Y.componentsDir||"",U=X?.__originalFilePath;if(U)K.push(I1.join(I1.dirname(U),"components"));if(W)K.push(W);let B=I1.join(I1.dirname(Z),"components");if(!K.includes(B))K.push(B);let _=process.cwd(),z=[I1.resolve(_,"src/components"),I1.resolve(_,"components"),I1.resolve(import.meta.dir,"components")];for(let q of z)if(!K.includes(q))K.push(q);for(let q of K){if(!q)continue;for(let j of G){let H=I1.join(q,j);if(await t(H))return H}try{if(!q2.statSync(q,{throwIfNoEntry:!1})?.isDirectory())continue;let H=q2.readdirSync(q,{withFileTypes:!0});for(let O of H)if(O.isDirectory()){let F=I1.join(q,O.name);for(let L of G){let V=I1.join(F,L);if(await t(V))return V}}}catch{}}return null}}var B1;var j2=D(()=>{N0();B1=new pB});function u$($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function kR($){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 H2;var O2=D(()=>{H2={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=kR($),J=(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(X.reactive)W.push(`:href="${u$(X.value)}"`);else W.push(`href="${u$(X.value)}"`);if(J)W.push(`class="${u$(J)}"`);if(W.push("data-stx-link"),W.push(`data-stx-active-class="${u$(Q)}"`),W.push(`data-stx-exact-active-class="${u$(G)}"`),K)W.push("data-stx-prefetch");let U=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[B,_]of Object.entries($.static)){if(U.has(B))continue;if(typeof _==="boolean"){if(_)W.push(u$(B))}else W.push(`${u$(B)}="${u$(_)}"`)}return`<a ${W.join(" ")}>${Z}</a>`}}});function f0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function X1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function F2($,Z,Y=!1){let X=$.serverDynamic[Z];if(X!==void 0)return X!==!1&&X!=="false";let J=$.static[Z];if(J!==void 0)return J!=="false"&&J!==!1;return Y}function cB($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[J,Q]=X.split(":"),G=SR[J];if(G)Y.push(`(max-width: ${G}px) ${Q}`);else{let K=Number.parseInt(J);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${Q}`)}}else Y.push(X);return Y.join(", ")}function V2($,Z,Y,X){return Z.map((J)=>`${t4($,J,void 0,Y,X)} ${J}w`).join(", ")}function bR($,Z,Y,X,J){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${t4($,G,void 0,X,J)} ${Q}x`}).join(", ")}function t4($,Z,Y,X,J){if(!X||X==="local"||X==="static")return $;if(X==="cloudinary"){let Q=[];if(Z)Q.push(`w_${Z}`);if(Y)Q.push(`h_${Y}`);if(J)Q.push(`f_${J}`);Q.push("q_auto");let G=Q.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(X==="imgix"){let Q=new URLSearchParams;if(Z)Q.set("w",String(Z));if(Y)Q.set("h",String(Y));if(J)Q.set("fm",J);Q.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}if(X==="bunny"){let Q=new URLSearchParams;if(Z)Q.set("width",String(Z));if(Y)Q.set("height",String(Y));if(J)Q.set("format",J);let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}return $}function CR($,Z,Y="#e5e7eb"){let X=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${Z}"><rect width="100%" height="100%" fill="${Y}"/></svg>`;return`data:image/svg+xml;base64,${btoa(X)}`}var SR,L2,N2;var A2=D(()=>{SR={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},L2=[320,640,768,1024,1280,1536,1920];N2={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=X1($,"src")||"",J=X1($,"alt")||"",Q=X1($,"width"),G=X1($,"height"),K=X1($,"sizes"),W=X1($,"srcset"),U=X1($,"densities"),B=X1($,"format"),_=X1($,"placeholder"),z=X1($,"placeholderColor")||"#e5e7eb",q=X1($,"provider"),j=X1($,"class")||X1($,"className")||"",H=X1($,"style")||"",O=X1($,"quality"),F=F2($,"lazy",!0),L=F2($,"preload",!1),V=F2($,"picture",!1)||!!B,N=Q?Number.parseInt(Q):void 0,A=G?Number.parseInt(G):void 0,w=W||"",R="";if(!w&&K)w=V2(X,L2,q,B),R=cB(K);else if(!w&&U){let y=U.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));w=bR(X,y,N,q,B)}else if(K)R=cB(K);let T=[];if(H)T.push(H);if(N&&A)T.push(`aspect-ratio:${N}/${A}`);if(_==="blur"||_==="color"||_==="thumbhash"){let y=CR(N||16,A||9,z);T.push(`background-image:url(${y})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(_&&_!=="empty"&&_!=="none")T.push(`background-image:url(${f0(_)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let I=t4(X,N,A,q,B),E=[];if(E.push(`src="${f0(I)}"`),E.push(`alt="${f0(J)}"`),Q)E.push(`width="${f0(Q)}"`);if(G)E.push(`height="${f0(G)}"`);if(F)E.push('loading="lazy"');if(E.push('decoding="async"'),j)E.push(`class="${f0(j)}"`);if(T.length>0)E.push(`style="${f0(T.join(";"))}"`);if(w)E.push(`srcset="${f0(w)}"`);if(R)E.push(`sizes="${f0(R)}"`);let k=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[y,b]of Object.entries($.static)){if(k.has(y))continue;if(typeof b==="boolean"){if(b)E.push(f0(y))}else E.push(`${f0(y)}="${f0(b)}"`)}let S=`<img ${E.join(" ")} />`,x="";if(L){let b=B==="webp"?"image/webp":B==="avif"?"image/avif":"";x=`<link rel="preload" as="image" href="${f0(I)}"${b?` type="${b}"`:""}${w?` imagesrcset="${f0(w)}"`:""}${R?` imagesizes="${f0(R)}"`:""} />
4117
+ `}if(V){let y=[];if(B==="avif"||B==="auto"){let b=t4(X,N,A,q,"avif"),f=w?V2(X,L2,q,"avif"):`${b}`;y.push(`<source type="image/avif" srcset="${f0(f)}"${R?` sizes="${f0(R)}"`:""} />`)}if(B==="webp"||B==="auto"){let b=t4(X,N,A,q,"webp"),f=w?V2(X,L2,q,"webp"):`${b}`;y.push(`<source type="image/webp" srcset="${f0(f)}"${R?` sizes="${f0(R)}"`:""} />`)}return`${x}<picture>
4118
4118
  ${y.join(`
4119
4119
  `)}
4120
4120
  ${S}
4121
- </picture>`}return`${P}${S}`}}});function m$($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function I7($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}var yR="<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'/images/safe-image-default.svg';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>",w2;var R2=D(()=>{w2={name:"SafeImage",aliases:["safe-image","safe-img"],render($,Z,Y){let X=I7($,"src")||"",J=I7($,"alt")||"",Q=I7($,"fallback")||"/images/safe-image-default.svg",G=I7($,"class")||I7($,"className")||"",K=I7($,"fallbackClassName")||"",W=[];if(W.push(`src="${m$(X)}"`),W.push(`alt="${m$(J)}"`),G)W.push(`class="${m$(G)}"`);if(W.push(`data-fallback="${m$(Q)}"`),K)W.push(`data-fallback-class="${m$(K)}"`);W.push('onerror="window.__stxSafeImageHandler(this)"');let U=new Set(["src","alt","fallback","class","className","fallbackClassName"]);for(let[z,q]of Object.entries($.static)){if(U.has(z))continue;if(typeof q==="boolean"){if(q)W.push(m$(z))}else W.push(`${m$(z)}="${m$(q)}"`)}let B=`<img ${W.join(" ")} />`,_=Y.context;if(!_.__safeImageHandlerEmitted)return _.__safeImageHandlerEmitted=!0,`${yR}${B}`;return B}}});function M2($){return $.replace(/[;{}()]/g,"").replace(/url/gi,"")}function e4($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function l8($,Z,Y){let X=e4($,Z);if(X!==void 0){let J=Number.parseInt(X,10);if(!Number.isNaN(J))return J}return Y}var T2;var I2=D(()=>{T2={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render($,Z,Y){let X=M2(e4($,"color")||"#6366f1"),J=M2(e4($,"initialColor")||e4($,"initial-color")||""),Q=M2(e4($,"height")||"3px"),G=l8($,"duration",2000),K=l8($,"throttle",200),W=l8($,"zIndex",999999)||l8($,"z-index",999999),U=J?`linear-gradient(to right, ${J}, ${X})`:X;return`
4121
+ </picture>`}return`${x}${S}`}}});function m$($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function I7($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}var yR="<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'/images/safe-image-default.svg';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>",w2;var R2=D(()=>{w2={name:"SafeImage",aliases:["safe-image","safe-img"],render($,Z,Y){let X=I7($,"src")||"",J=I7($,"alt")||"",Q=I7($,"fallback")||"/images/safe-image-default.svg",G=I7($,"class")||I7($,"className")||"",K=I7($,"fallbackClassName")||"",W=[];if(W.push(`src="${m$(X)}"`),W.push(`alt="${m$(J)}"`),G)W.push(`class="${m$(G)}"`);if(W.push(`data-fallback="${m$(Q)}"`),K)W.push(`data-fallback-class="${m$(K)}"`);W.push('onerror="window.__stxSafeImageHandler(this)"');let U=new Set(["src","alt","fallback","class","className","fallbackClassName"]);for(let[z,q]of Object.entries($.static)){if(U.has(z))continue;if(typeof q==="boolean"){if(q)W.push(m$(z))}else W.push(`${m$(z)}="${m$(q)}"`)}let B=`<img ${W.join(" ")} />`,_=Y.context;if(!_.__safeImageHandlerEmitted)return _.__safeImageHandlerEmitted=!0,`${yR}${B}`;return B}}});function M2($){return $.replace(/[;{}()]/g,"").replace(/url/gi,"")}function e4($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function l8($,Z,Y){let X=e4($,Z);if(X!==void 0){let J=Number.parseInt(X,10);if(!Number.isNaN(J))return J}return Y}var T2;var I2=D(()=>{T2={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render($,Z,Y){let X=M2(e4($,"color")||"#6366f1"),J=M2(e4($,"initialColor")||e4($,"initial-color")||""),Q=M2(e4($,"height")||"3px"),G=l8($,"duration",2000),K=l8($,"throttle",200),W=l8($,"zIndex",999999)||l8($,"z-index",999999),U=J?`linear-gradient(to right, ${J}, ${X})`:X;return`
4122
4122
  <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">
4123
4123
  <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>
4124
4124
  </div>
@@ -4152,15 +4152,15 @@ ${S}
4152
4152
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
4153
4153
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
4154
4154
  </style>`}}});var oB={};Z0(oB,{preloadIconCollection:()=>s8,IconBuiltin:()=>n8});import{existsSync as xR,readFileSync as vR}from"fs";function rB($){try{return _0.resolve(`@iconify/json/json/${$}.json`)}catch{}let Z=process.cwd();for(let Y of[`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(xR(Y))return Y;return null}function fR($){if(F5.has($))return F5.get($);let Z=rB($);if(!Z)return null;try{let Y=JSON.parse(vR(Z,"utf8"));return F5.set($,Y.icons),Y.icons}catch{return null}}async function gR($){if(F5.has($))return F5.get($);let Z=rB($);if(!Z)return null;try{let Y=await Bun.file(Z).json();return F5.set($,Y.icons),Y.icons}catch{return null}}function D7($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);if($.static[Z]!==void 0)return String($.static[Z]);if($.clientReactive[Z]!==void 0)return $.clientReactive[Z];return}async function s8($="lucide"){await gR($)}var F5,n8;var r8=D(()=>{F5=new Map;n8={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=D7($,"name")??D7($,"icon");if(!X)return"<!-- Icon: missing name/icon prop -->";let J="lucide",Q=X;if(X.includes(":")){let L=X.split(":");J=L[0],Q=L[1]}let G=P1(D7($,"size")||"24"),K=P1(D7($,"color")||"currentColor"),W=P1(D7($,"class")||""),U=P1(D7($,"style")||""),B=F5.get(J)??fR(J);if(!B)return`<!-- Icon: collection "${J}" not loaded -->`;let _=B[Q];if(!_)return`<!-- Icon: "${Q}" not found in ${J} -->`;let z=_.width||24,q=_.height||24,j=`0 0 ${z} ${q}`,H=_.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let O=W?` class="${W}"`:"",F=U?` style="${U}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${O}${F}>${H}</svg>`}}});function aB($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let X=$.static[Y];if(typeof X==="string")return X}return}function tB($,Z){let Y=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${Z}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),X=$.match(Y);if(!X)return{region:null,rest:$};return{region:X[2],rest:$.replace(X[0],"")}}var y2;var P2=D(()=>{y2={name:"Suspense",aliases:["suspense"],render($,Z,Y){let X=tB(Z,"fallback"),J=X.rest,Q=tB(J,"error"),G=Q.rest,K=X.region??aB($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',W=Q.region??aB($,"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 o8($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let X=$.static[Y];if(typeof X==="string")return X}return}var x2;var v2=D(()=>{x2={name:"TransitionGroup",aliases:["transition-group"],render($,Z,Y){let X=(o8($,"name")||"v").replace(/["'<>]/g,""),J=(o8($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",Q=o8($,"class"),G=o8($,"id"),K=[`data-stx-transition-group="${X}"`,Q?`class="${Q}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${J} ${K}>${Z}</${J}>`}}});function eB(){B1.registerBuiltin(H2),B1.registerBuiltin(N2),B1.registerBuiltin(w2),B1.registerBuiltin(T2),B1.registerBuiltin(E2),B1.registerBuiltin(k2),B1.registerBuiltin(b2),B1.registerBuiltin(n8),B1.registerBuiltin(y2),B1.registerBuiltin(x2)}var f2=D(()=>{O2();A2();R2();I2();D2();S2();C2();r8();P2();v2();j2();O2();A2();R2();I2();D2();S2();C2();r8();P2();v2()});function $_($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function Z_($,Z,Y){let X=[],J=0;while(J<$.length){let Q=$.indexOf("<",J);if(Q===-1)break;let K=$.slice(Q+1).match(new RegExp(`^(${Z.source})`));if(!K){J=Q+1;continue}let W=K[1];if(Y&&Y.has(W.toLowerCase())){let H=Q+1+W.length;while(H<$.length&&$[H]!==">")H++;J=H+1;continue}let U=Q+1+W.length,B=null,_=U,z=-1,q=!1;while(U<$.length){let H=$[U];if(B){if(H==="\\"&&U+1<$.length){U+=2;continue}if(H===B)B=null;U++;continue}if(H==='"'||H==="'"){B=H,U++;continue}if(H==="/"&&U+1<$.length&&$[U+1]===">"){z=U+2,q=!0;break}if(H===">"){z=U+1;break}U++}if(z===-1){J=Q+1;continue}let j=$.slice(_,q?z-2:z-1).trim();if(q)X.push({fullMatch:$.slice(Q,z),tagName:W,attributes:j,content:"",startIndex:Q,endIndex:z,isSelfClosing:!0}),J=z;else{let H=`<${W}`,O=`</${W}>`,F=1,L=z,V=-1;while(F>0&&L<$.length){let w=$.indexOf(H,L),R=$.indexOf(O,L);if(R===-1)break;if(w!==-1&&w<R){let T=$[w+H.length];if(T===" "||T===">"||T==="/"||T===`
4155
- `||T==="\t")F++;L=w+H.length}else{if(F--,F===0){V=R;break}L=R+O.length}}if(V===-1){J=z;continue}let N=$.slice(z,V),A=V+O.length;X.push({fullMatch:$.slice(Q,A),tagName:W,attributes:j,content:N,startIndex:Q,endIndex:A,isSelfClosing:!1}),J=A}}return X}function Y_($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var X_=D(()=>{d0();N0();S3()});var U_={};Z0(U_,{processESImports:()=>W_,processComponents:()=>t8});import a8 from"fs";import L1 from"path";function dR($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,W)=>W.toUpperCase())};for(let[G,K]of Object.entries($)){let W=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(W.startsWith("@")){X.events[W]=K;continue}if(W.startsWith("__stx_")){let U=Q(W.slice(6));X.serverDynamic[U]=Y_(K,Y);continue}if(W.startsWith(":")){let U=Q(W.slice(1)),B=K==="true"?U:K;try{if(!H0(B)){if(Y.debug)console.error(`Unsafe expression in :${U} binding: ${B}`);X.clientReactive[U]=B;continue}let _=Object.keys(Z),q=O0(B,_)(...Object.values(Z));if(q===void 0){let j=B.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!_.includes(F))){X.clientReactive[U]=B;continue}}X.serverDynamic[U]=q}catch{X.clientReactive[U]=B}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let U=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(U)try{let B=U[1];if(H0(B)){let z=O0(B,Object.keys(Z))(...Object.values(Z));X.static[W]=z!=null?String(z):""}else{if(Y.debug)console.error(`Unsafe expression in ${W}: ${B}`);X.static[W]=K}}catch(B){if(Y.debug)console.error(`Error evaluating expression for ${W}:`,B);X.static[W]=K}else{let B=K,_=/\{\{\s*([\s\S]+?)\s*\}\}/g,z;while((z=_.exec(K))!==null)try{let q=z[1];if(!H0(q)){if(Y.debug)console.error(`Unsafe expression in ${W}: ${q}`);continue}let H=O0(q,Object.keys(Z))(...Object.values(Z));B=B.replace(z[0],String(H??""))}catch(q){if(Y.debug)console.error(`Error evaluating expression in ${W}:`,q)}X.static[W]=B}continue}X.static[W]=K}return X}function uR($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let J="";while(Y<X&&!/[\s=]/.test($[Y]))J+=$[Y],Y++;if(!J)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let Q="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[J]=Q}else Z[J]="true"}return Z}function Q_($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function mR($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,X;while((X=Y.exec($))!==null){let J=X[1];if(B1.isBuiltin(J))Z.add(J)}return[...Z].sort()}function pR($){let Z=G_.get($);if(Z)return Z;let Y=new Map,X=[L1.join($,"src"),L1.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=a8.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let W of K){let U=L1.join(Q,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;J(U,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let B=W.name.slice(0,-4);if(!Y.has(B))Y.set(B,U);let _=B.toLowerCase();if(!Y.has(_))Y.set(_,U);let z=B.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(z))Y.set(z,U)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return G_.set($,Y),Y}function cR($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=L1.join(Y,"node_modules",$);try{if(a8.statSync(X).isDirectory())return X}catch{}let J=L1.dirname(Y);if(J===Y)return null;Y=J}}async function W_($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=L1.dirname(Y),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(U,B,_)=>{let z=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,q=_,j,H=[];while((j=z.exec(_))!==null){let[O,F,L,V]=j,N=null,A=null;if(V.startsWith(".")||V.startsWith("/")){let T=L1.resolve(G,V);if(T.endsWith(".stx"))A=T;else{let I=`${T}.stx`;try{if(a8.statSync(I).isFile())A=I}catch{try{if(a8.statSync(T).isDirectory())N=T}catch{}}}}else N=cR(V,G);if(!N&&!A)continue;let w=!1,R=(T,I)=>{Q.set(T,I),Q.set(T.toLowerCase(),I);let E=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(E,I),J.add(I)};if(L&&A)R(L,A),w=!0;else if(F){let T=F.slice(1,-1).split(",").map((E)=>E.trim()).filter(Boolean).map((E)=>{let k=E.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(k)return{source:k[1],local:k[2]};return{source:E,local:E}}),I=N?pR(N):null;for(let{source:E,local:k}of T){let S=null;if(A)S=A;else if(I)S=I.get(E)??I.get(E.toLowerCase())??I.get(E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(S)R(k,S),w=!0}}if(w)H.push({start:j.index,end:j.index+O.length})}if(H.length===0)return U;for(let O=H.length-1;O>=0;O--)q=q.slice(0,H[O].start)+q.slice(H[O].end);return`<script${B}>${q}</script>`}),K}async function lR($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,B]=W,_=B.split(",").map((z)=>z.trim().replace(/^['"]|['"]$/g,"")).filter((z)=>z.length>0);for(let z of _){let q=z.split("/"),H=q[q.length-1].replace(/\.stx$/,""),O=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,L=[L1.resolve(L1.dirname(Y),`${z}.stx`),L1.resolve(L1.dirname(Y),z),L1.resolve(X.componentsDir||"components",`${z}.stx`),L1.resolve(X.componentsDir||"components",z),z.endsWith(".stx")?z:`${z}.stx`];for(let V of L)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(O,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),J.add(F),X.debug)console.log(`Imported component: ${O} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${z}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function iR($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let B=U.index,_=B+U[0].length-1,z=1,q=_+1;while(q<Q.length&&z>0){if(Q[q]==="(")z++;else if(Q[q]===")"){if(z--,z===0)break}q++}if(z!==0)break;let j=Q.substring(_+1,q),H=q+1,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let F=O[1],L,V=j.slice(O[0].length),N=V.match(/^\s*,\s*/);if(N)L=V.slice(N[0].length).trim();let A={};if(L)try{A=P0(L,Z)}catch(k){let S=k instanceof Error?k.message:String(k);Q=Q.replace(Q.substring(B,H),`[Error parsing component props: ${S}]`);continue}let w="",R=H,I=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(I)w=I[1].trim(),R=H+I[0].length;let E=await l1(F,A,w,G,Z,Y,X,K,J);Q=Q.substring(0,B)+E+Q.substring(R),W.lastIndex=0}return Q}async function nR($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=lY(Q);return Q=W.output,Q=await z(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await z(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await z(Q,/[a-z][a-z0-9]*/,!1,hR),Q=iY(Q,W.scripts),Q;async function z(q,j,H,O){if(!q)return q;let F=q,L=Z_(F,j,O);for(let V=L.length-1;V>=0;V--){let N=L[V],A=H?$_(N.tagName):N.tagName,w=uR(N.attributes),R=dR(w,Z,X),T=B1.getBuiltin(N.tagName),I=T?await h2(A,G,Z,Y,X):!1;if(T&&!I){let P={context:Z,filePath:Y,options:X,dependencies:J},y=T.render(R,N.content,P);if(Object.keys(R.clientReactive).length>0)y=K_(y,R.clientReactive);if(Object.keys(R.events).length>0){let b=Object.entries(R.events).map(([f,r])=>`${f}="${Q_(r)}"`).join(" ");y=y.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}F=F.substring(0,N.startIndex)+y+F.substring(N.endIndex);continue}let E={};for(let[P,y]of Object.entries(R.static))E[P]=y;for(let[P,y]of Object.entries(R.serverDynamic))E[P]=y;let S=await l1(A,E,N.content,G,Z,Y,X,K,J);if(Object.keys(R.clientReactive).length>0)S=K_(S,R.clientReactive);if(Object.keys(R.events).length>0){let P=S.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(P){let y=Object.entries(R.events).map(([f,r])=>`${f}="${Q_(r)}"`).join(" "),b=P[1].length+P[2].length;S=S.substring(0,b)+" "+y+S.substring(b)}}F=F.substring(0,N.startIndex)+S+F.substring(N.endIndex)}return F}}function K_($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let X=Object.entries(Z).map(([Q,G])=>`:${Q}="${G.replace(/"/g,"&quot;")}"`).join(" "),J=Y[1].length+Y[2].length;return $.substring(0,J)+" "+X+$.substring(J)}async function t8($,Z,Y,X,J){if(!J_)eB(),J_=!0;let Q=await W_($,Z,Y,X,J);Q=await lR(Q,Z,Y,X,J),Q=await iR(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await nR(Q,Z,Y,X,J),Q===K)break}if(X.debug){let G=mR(Q);if(G.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var J_=!1,hR,G_;var g2=D(()=>{j2();f2();X_();N0();d0();hR=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);G_=new Map});var $Z={};Z0($Z,{stripTypeScript:()=>j_,hasVariables:()=>m2,extractVariables:()=>D0,extractScriptFromTemplate:()=>u2,convertToCommonJS:()=>e8});import k7 from"path";import $6 from"process";function sR($){let Z=[],Y=0,X=$.split(`
4155
+ `||T==="\t")F++;L=w+H.length}else{if(F--,F===0){V=R;break}L=R+O.length}}if(V===-1){J=z;continue}let N=$.slice(z,V),A=V+O.length;X.push({fullMatch:$.slice(Q,A),tagName:W,attributes:j,content:N,startIndex:Q,endIndex:A,isSelfClosing:!1}),J=A}}return X}function Y_($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var X_=D(()=>{d0();N0();S3()});var U_={};Z0(U_,{processESImports:()=>W_,processComponents:()=>t8});import a8 from"fs";import L1 from"path";function dR($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,W)=>W.toUpperCase())};for(let[G,K]of Object.entries($)){let W=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(W.startsWith("@")){X.events[W]=K;continue}if(W.startsWith("__stx_")){let U=Q(W.slice(6));X.serverDynamic[U]=Y_(K,Y);continue}if(W.startsWith(":")){let U=Q(W.slice(1)),B=K==="true"?U:K;try{if(!H0(B)){if(Y.debug)console.error(`Unsafe expression in :${U} binding: ${B}`);X.clientReactive[U]=B;continue}let _=Object.keys(Z),q=O0(B,_)(...Object.values(Z));if(q===void 0){let j=B.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!_.includes(F))){X.clientReactive[U]=B;continue}}X.serverDynamic[U]=q}catch{X.clientReactive[U]=B}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let U=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(U)try{let B=U[1];if(H0(B)){let z=O0(B,Object.keys(Z))(...Object.values(Z));X.static[W]=z!=null?String(z):""}else{if(Y.debug)console.error(`Unsafe expression in ${W}: ${B}`);X.static[W]=K}}catch(B){if(Y.debug)console.error(`Error evaluating expression for ${W}:`,B);X.static[W]=K}else{let B=K,_=/\{\{\s*([\s\S]+?)\s*\}\}/g,z;while((z=_.exec(K))!==null)try{let q=z[1];if(!H0(q)){if(Y.debug)console.error(`Unsafe expression in ${W}: ${q}`);continue}let H=O0(q,Object.keys(Z))(...Object.values(Z));B=B.replace(z[0],String(H??""))}catch(q){if(Y.debug)console.error(`Error evaluating expression in ${W}:`,q)}X.static[W]=B}continue}X.static[W]=K}return X}function uR($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let J="";while(Y<X&&!/[\s=]/.test($[Y]))J+=$[Y],Y++;if(!J)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let Q="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[J]=Q}else Z[J]="true"}return Z}function Q_($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function mR($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,X;while((X=Y.exec($))!==null){let J=X[1];if(B1.isBuiltin(J))Z.add(J)}return[...Z].sort()}function pR($){let Z=G_.get($);if(Z)return Z;let Y=new Map,X=[L1.join($,"src"),L1.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=a8.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let W of K){let U=L1.join(Q,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;J(U,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let B=W.name.slice(0,-4);if(!Y.has(B))Y.set(B,U);let _=B.toLowerCase();if(!Y.has(_))Y.set(_,U);let z=B.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(z))Y.set(z,U)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return G_.set($,Y),Y}function cR($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=L1.join(Y,"node_modules",$);try{if(a8.statSync(X).isDirectory())return X}catch{}let J=L1.dirname(Y);if(J===Y)return null;Y=J}}async function W_($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=L1.dirname(Y),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(U,B,_)=>{let z=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,q=_,j,H=[];while((j=z.exec(_))!==null){let[O,F,L,V]=j,N=null,A=null;if(V.startsWith(".")||V.startsWith("/")){let T=L1.resolve(G,V);if(T.endsWith(".stx"))A=T;else{let I=`${T}.stx`;try{if(a8.statSync(I).isFile())A=I}catch{try{if(a8.statSync(T).isDirectory())N=T}catch{}}}}else N=cR(V,G);if(!N&&!A)continue;let w=!1,R=(T,I)=>{Q.set(T,I),Q.set(T.toLowerCase(),I);let E=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(E,I),J.add(I)};if(L&&A)R(L,A),w=!0;else if(F){let T=F.slice(1,-1).split(",").map((E)=>E.trim()).filter(Boolean).map((E)=>{let k=E.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(k)return{source:k[1],local:k[2]};return{source:E,local:E}}),I=N?pR(N):null;for(let{source:E,local:k}of T){let S=null;if(A)S=A;else if(I)S=I.get(E)??I.get(E.toLowerCase())??I.get(E.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(S)R(k,S),w=!0}}if(w)H.push({start:j.index,end:j.index+O.length})}if(H.length===0)return U;for(let O=H.length-1;O>=0;O--)q=q.slice(0,H[O].start)+q.slice(H[O].end);return`<script${B}>${q}</script>`}),K}async function lR($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,B]=W,_=B.split(",").map((z)=>z.trim().replace(/^['"]|['"]$/g,"")).filter((z)=>z.length>0);for(let z of _){let q=z.split("/"),H=q[q.length-1].replace(/\.stx$/,""),O=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,L=[L1.resolve(L1.dirname(Y),`${z}.stx`),L1.resolve(L1.dirname(Y),z),L1.resolve(X.componentsDir||"components",`${z}.stx`),L1.resolve(X.componentsDir||"components",z),z.endsWith(".stx")?z:`${z}.stx`];for(let V of L)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(O,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),J.add(F),X.debug)console.log(`Imported component: ${O} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${z}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function iR($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let B=U.index,_=B+U[0].length-1,z=1,q=_+1;while(q<Q.length&&z>0){if(Q[q]==="(")z++;else if(Q[q]===")"){if(z--,z===0)break}q++}if(z!==0)break;let j=Q.substring(_+1,q),H=q+1,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let F=O[1],L,V=j.slice(O[0].length),N=V.match(/^\s*,\s*/);if(N)L=V.slice(N[0].length).trim();let A={};if(L)try{A=P0(L,Z)}catch(k){let S=k instanceof Error?k.message:String(k);Q=Q.replace(Q.substring(B,H),`[Error parsing component props: ${S}]`);continue}let w="",R=H,I=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(I)w=I[1].trim(),R=H+I[0].length;let E=await l1(F,A,w,G,Z,Y,X,K,J);Q=Q.substring(0,B)+E+Q.substring(R),W.lastIndex=0}return Q}async function nR($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=lY(Q);return Q=W.output,Q=await z(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await z(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await z(Q,/[a-z][a-z0-9]*/,!1,hR),Q=iY(Q,W.scripts),Q;async function z(q,j,H,O){if(!q)return q;let F=q,L=Z_(F,j,O);for(let V=L.length-1;V>=0;V--){let N=L[V],A=H?$_(N.tagName):N.tagName,w=uR(N.attributes),R=dR(w,Z,X),T=B1.getBuiltin(N.tagName),I=T?await h2(A,G,Z,Y,X):!1;if(T&&!I){let x={context:Z,filePath:Y,options:X,dependencies:J},y=T.render(R,N.content,x);if(Object.keys(R.clientReactive).length>0)y=K_(y,R.clientReactive);if(Object.keys(R.events).length>0){let b=Object.entries(R.events).map(([f,r])=>`${f}="${Q_(r)}"`).join(" ");y=y.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}F=F.substring(0,N.startIndex)+y+F.substring(N.endIndex);continue}let E={};for(let[x,y]of Object.entries(R.static))E[x]=y;for(let[x,y]of Object.entries(R.serverDynamic))E[x]=y;let S=await l1(A,E,N.content,G,Z,Y,X,K,J);if(Object.keys(R.clientReactive).length>0)S=K_(S,R.clientReactive);if(Object.keys(R.events).length>0){let x=S.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(x){let y=Object.entries(R.events).map(([f,r])=>`${f}="${Q_(r)}"`).join(" "),b=x[1].length+x[2].length;S=S.substring(0,b)+" "+y+S.substring(b)}}F=F.substring(0,N.startIndex)+S+F.substring(N.endIndex)}return F}}function K_($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let X=Object.entries(Z).map(([Q,G])=>`:${Q}="${G.replace(/"/g,"&quot;")}"`).join(" "),J=Y[1].length+Y[2].length;return $.substring(0,J)+" "+X+$.substring(J)}async function t8($,Z,Y,X,J){if(!J_)eB(),J_=!0;let Q=await W_($,Z,Y,X,J);Q=await lR(Q,Z,Y,X,J),Q=await iR(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await nR(Q,Z,Y,X,J),Q===K)break}if(X.debug){let G=mR(Q);if(G.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var J_=!1,hR,G_;var g2=D(()=>{j2();f2();X_();N0();d0();hR=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);G_=new Map});var $Z={};Z0($Z,{stripTypeScript:()=>j_,hasVariables:()=>m2,extractVariables:()=>D0,extractScriptFromTemplate:()=>u2,convertToCommonJS:()=>e8});import k7 from"path";import $6 from"process";function sR($){let Z=[],Y=0,X=$.split(`
4156
4156
  `);for(let J of X){let Q=Y,G=null,K=!1;for(let W=0;W<J.length;W++){let U=J[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<J.length&&J[W+1]==="/")break;if(U==="{")Y++;else if(U==="}")Y--}if(Q===0){let W=J.match(/(?:const|let|var)\s+(\w+)\s*=/);if(W)Z.push(W[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(J)){let U=J.match(/(?:const|let|var)\s+(\w+)/);if(U)Z.push(U[1])}else{let U=J.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(U){let _=U[1].slice(1,-1).split(",").map((z)=>{let q=z.split(":");return(q.length>1?q[1]:q[0]).trim()}).filter((z)=>/^\w+$/.test(z));Z.push(..._)}}}}return[...new Set(Z)]}function j_($){let Z=$;Z=Z.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),Z=Z.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),Z=Z.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function Y(X){if(!X.includes(":"))return X;let J=[],Q="",G=0,K=0,W=null;for(let U=0;U<X.length;U++){let B=X[U];if(W){if(Q+=B,B===W)W=null;continue}if(B==='"'||B==="'"||B==="`"){W=B,Q+=B;continue}if(B==="<")G++;else if(B===">"&&G>0)G--;else if(B==="(")K++;else if(B===")")K--;if(B===","&&G===0&&K===0){J.push(Q),Q="";continue}Q+=B}if(Q)J.push(Q);return J.map((U)=>{let B=U.trim(),_=B.startsWith("..."),z=_?B.slice(3):B,q=-1,j=0;for(let A=0;A<z.length;A++)if(z[A]==="<")j++;else if(z[A]===">")j--;else if(z[A]===":"&&j===0){q=A;break}if(q===-1)return U;let O=z.substring(0,q).trim().replace(/\?$/,""),F=z.substring(q+1),L=-1,V=0;for(let A=0;A<F.length;A++)if(F[A]==="<")V++;else if(F[A]===">")V--;else if(F[A]==="="&&V===0){L=A;break}let N=_?"...":"";if(L!==-1)return`${N}${O} = ${F.substring(L+1).trim()}`;return`${N}${O}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(X,J,Q)=>{if(!Q.includes(":"))return X;return`${J}(${Y(Q)})`});{let X=/\b(function\s+\w*\s*)\(/g,J,Q=[];while((J=X.exec(Z))!==null){let G=J.index+J[0].length-1,K=1,W=G+1,U=0,B=null;while(W<Z.length&&K>0){let q=Z[W];if(B){if(q===B)B=null;W++;continue}if(q==='"'||q==="'"||q==="`"){B=q,W++;continue}if(q==="<")U++;else if(q===">"&&U>0)U--;else if(U===0){if(q==="(")K++;else if(q===")")K--}if(K>0)W++}if(K!==0)continue;let _=Z.substring(G+1,W);if(!_.includes(":"))continue;let z=Y(_);Q.push({start:G+1,end:W,replacement:z})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];Z=Z.substring(0,K)+U+Z.substring(W)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(X,J)=>{if(!J.includes(":"))return X;if(J.includes("{")||J.includes("}"))return X;return`(${J.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(", ")}) =>`}),Z=Z.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),Z=Z.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),Z=Z.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),Z=Z.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),Z=Z.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),Z=Z.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),Z=Z.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),Z=Z.replace(/\n\s*\n\s*\n/g,`
4157
4157
 
4158
- `),Z}async function D0($,Z,Y,X={}){if(!$.trim())return;let J;try{let x=new Bun.Transpiler({loader:"ts",target:"browser",define:M1()}),d=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");d=d.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),J=x.transformSync(d)}catch{J=j_($)}let Q={exports:{}},G=Q.exports,K=$6.cwd(),W={},U=[...J.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((x)=>x[1]).filter((x)=>!x.startsWith("node:")&&!x.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(x));for(let x of U)try{let d=k7.resolve(K,"node_modules",x),p=k7.join(d,"package.json"),g=JSON.parse(_0("fs").readFileSync(p,"utf8")),c=g.main||"index.js";if(g.exports){let a=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof a==="string")c=a;else if(a?.bun)c=a.bun;else if(a?.import)c=a.import;else if(a?.default)c=a.default}W[x]=await import(k7.resolve(d,c))}catch{}let B=(x)=>{if(W[x])return W[x];return _0(x)},_=Z.props||{},z=Object.assign((x)=>{if(!x)return _;let d={};for(let[p,g]of Object.entries(x)){let c=_[p];if(c!==void 0)d[p]=c;else if(typeof g==="function")d[p]=g();else d[p]=g}return d},_),q=(x)=>{if(!x)return _;let d={..._};for(let[p,g]of Object.entries(x)){let c=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(d[p]===void 0&&c.default!==void 0)d[p]=typeof c.default==="function"?c.default():c.default}return d},j=()=>Z.slots||{},H=(x,d)=>{let p={...x};for(let[g,c]of Object.entries(d))if(p[g]===void 0)if(typeof c==="function")p[g]=c();else p[g]=c;return p},O=(x)=>{let d=()=>x;return d.set=(p)=>{},d.update=(p)=>{},d},F=(x)=>{let d,p=!1;return()=>{if(!p)try{d=x(),p=!0}catch{d=void 0}return d}},L=(x)=>{},V=(x)=>x(),N=(x)=>{},A=(x)=>{},w=(x)=>{},R=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),T=()=>({push:(x)=>{},replace:(x)=>{},back:()=>{},forward:()=>{},go:(x)=>{}}),I=(x)=>{v$(x);let d=Z.__stx_runtime_head||{},p=x||{};Z.__stx_runtime_head={...d,...p.title&&{title:p.title},meta:[...d.meta||[],...p.meta||[]],link:[...d.link||[],...p.link||[]],script:[...d.script||[],...p.script||[]],htmlAttrs:{...d.htmlAttrs||{},...p.htmlAttrs||{}},bodyAttrs:{...d.bodyAttrs||{},...p.bodyAttrs||{}}}},E=(x)=>{n4(x);let d=M7();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...d.title&&{title:d.title},meta:d.meta?[...d.meta]:[]}},k=(x)=>({value:x}),S=(x)=>x,P=(x)=>({value:typeof x==="function"?x():x}),y=(x,d)=>{},b=(x)=>{},f=(x)=>{},r=(x)=>x?x():Promise.resolve(),u=(x)=>(d,...p)=>{},C=(x)=>{},h=(x,d)=>{},m=(x,d)=>d,i=()=>({value:"light"}),s=()=>({value:!1}),K0={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(K0,{get(x,d){if(d in x)return x[d];return},set(x,d,p){return x[d]=p,!0}}),F0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},R0=console;try{let x=e8(J,Y),d=new Set(Object.keys(_)),p=Object.keys(Z).filter((G0)=>!d.has(G0)&&G0!=="props"),g=p.map((G0)=>Z[G0]),c=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),a=[],l=[];for(let[G0,k0]of Object.entries(_)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(G0))continue;if(c.has(G0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${G0}\\b`).test(x))continue;a.push(G0),l.push(k0)}let M0=sR(x).map((G0)=>`module.exports.${G0} = typeof ${G0} !== 'undefined' ? ${G0} : module.exports.${G0};`).join(`
4159
- `),w0=Z.params??{},W0=[],r0=[];for(let G0=0;G0<p.length;G0++){if(p[G0]==="params")continue;W0.push(p[G0]),r0.push(g[G0])}let P5=await Function("module","exports","require","props","$props","defineProps","withDefaults","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","window","document","console","confirm","alert","fetch","params",...a,...W0,`return (async () => {
4160
- ${x}
4158
+ `),Z}async function D0($,Z,Y,X={}){if(!$.trim())return;let J;try{let P=new Bun.Transpiler({loader:"ts",target:"browser",define:M1()}),d=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");d=d.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),J=P.transformSync(d)}catch{J=j_($)}let Q={exports:{}},G=Q.exports,K=$6.cwd(),W={},U=[...J.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((P)=>P[1]).filter((P)=>!P.startsWith("node:")&&!P.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(P));for(let P of U)try{let d=k7.resolve(K,"node_modules",P),m=k7.join(d,"package.json"),g=JSON.parse(_0("fs").readFileSync(m,"utf8")),c=g.main||"index.js";if(g.exports){let a=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof a==="string")c=a;else if(a?.bun)c=a.bun;else if(a?.import)c=a.import;else if(a?.default)c=a.default}W[P]=await import(k7.resolve(d,c))}catch{}let B=(P)=>{if(W[P])return W[P];return _0(P)},_=Z.props||{},z=Object.assign((P)=>{if(!P)return _;let d={};for(let[m,g]of Object.entries(P)){let c=_[m];if(c!==void 0)d[m]=c;else if(typeof g==="function")d[m]=g();else d[m]=g}return d},_),q=(P)=>{if(!P)return _;let d={..._};for(let[m,g]of Object.entries(P)){let c=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(d[m]===void 0&&c.default!==void 0)d[m]=typeof c.default==="function"?c.default():c.default}return d},j=()=>Z.slots||{},H=(P,d)=>{let m={...P};for(let[g,c]of Object.entries(d))if(m[g]===void 0)if(typeof c==="function")m[g]=c();else m[g]=c;return m},O=(P)=>{let d=()=>P;return d.set=(m)=>{},d.update=(m)=>{},d},F=(P)=>{let d,m=!1;return()=>{if(!m)try{d=P(),m=!0}catch{d=void 0}return d}},L=(P)=>{},V=(P)=>P(),N=(P)=>{},A=(P)=>{},w=(P)=>{},R=()=>{let P=Z.__stxServeContext,d=Z.__stxServeSearch??P?.search??"",m=P?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(d)),path:m,name:"",fullPath:m+d,hash:"",matched:[]}},T=()=>({push:(P)=>{},replace:(P)=>{},back:()=>{},forward:()=>{},go:(P)=>{}}),I=(P)=>{v$(P);let d=Z.__stx_runtime_head||{},m=P||{};Z.__stx_runtime_head={...d,...m.title&&{title:m.title},meta:[...d.meta||[],...m.meta||[]],link:[...d.link||[],...m.link||[]],script:[...d.script||[],...m.script||[]],htmlAttrs:{...d.htmlAttrs||{},...m.htmlAttrs||{}},bodyAttrs:{...d.bodyAttrs||{},...m.bodyAttrs||{}}}},E=(P)=>{n4(P);let d=M7();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...d.title&&{title:d.title},meta:d.meta?[...d.meta]:[]}},k=(P)=>({value:P}),S=(P)=>P,x=(P)=>({value:typeof P==="function"?P():P}),y=(P,d)=>{},b=(P)=>{},f=(P)=>{},r=(P)=>P?P():Promise.resolve(),u=(P)=>(d,...m)=>{},C=(P)=>{},h=(P,d)=>{},p=(P,d)=>d,i=()=>({value:"light"}),s=()=>({value:!1}),K0={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(K0,{get(P,d){if(d in P)return P[d];return},set(P,d,m){return P[d]=m,!0}}),F0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},R0=console;try{let P=e8(J,Y),d=new Set(Object.keys(_)),m=Object.keys(Z).filter((G0)=>!d.has(G0)&&G0!=="props"),g=m.map((G0)=>Z[G0]),c=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),a=[],l=[];for(let[G0,k0]of Object.entries(_)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(G0))continue;if(c.has(G0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${G0}\\b`).test(P))continue;a.push(G0),l.push(k0)}let M0=sR(P).map((G0)=>`module.exports.${G0} = typeof ${G0} !== 'undefined' ? ${G0} : module.exports.${G0};`).join(`
4159
+ `),w0=Z.params??{},W0=[],r0=[];for(let G0=0;G0<m.length;G0++){if(m[G0]==="params")continue;W0.push(m[G0]),r0.push(g[G0])}let P5=await Function("module","exports","require","props","$props","defineProps","withDefaults","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","window","document","console","confirm","alert","fetch","params",...a,...W0,`return (async () => {
4160
+ ${P}
4161
4161
  ${M0}
4162
4162
  return module.exports
4163
- })()`)(Q,G,B,_,z,q,H,O,F,L,V,N,A,w,R,T,I,E,k,S,P,y,b,f,r,u,C,j,h,m,i,s,$0,F0,R0,K0.confirm,K0.alert,K0.fetch,w0,...l,...r0);if(X.preserveExisting){for(let[G0,k0]of Object.entries(P5))if(!(G0 in Z)||Z[G0]===void 0)Z[G0]=k0}else Object.assign(Z,P5);for(let[G0,k0]of Object.entries(_))if(!(G0 in Z))Z[G0]=k0}catch(x){if($6.env.STX_DEBUG){let d=x instanceof Error?x.message:String(x);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${d}`)}try{await eR(J,Z,Y)}catch(d){if($6.env.STX_DEBUG){let p=d instanceof Error?d.message:String(d);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${p}`)}}}}function e8($,Z){let Y=Z?k7.dirname(Z):$6.cwd(),X=$.split(`
4163
+ })()`)(Q,G,B,_,z,q,H,O,F,L,V,N,A,w,R,T,I,E,k,S,x,y,b,f,r,u,C,j,h,p,i,s,$0,F0,R0,K0.confirm,K0.alert,K0.fetch,w0,...l,...r0);if(X.preserveExisting){for(let[G0,k0]of Object.entries(P5))if(!(G0 in Z)||Z[G0]===void 0)Z[G0]=k0}else Object.assign(Z,P5);for(let[G0,k0]of Object.entries(_))if(!(G0 in Z))Z[G0]=k0}catch(P){if($6.env.STX_DEBUG){let d=P instanceof Error?P.message:String(P);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${d}`)}try{await eR(J,Z,Y)}catch(d){if($6.env.STX_DEBUG){let m=d instanceof Error?d.message:String(d);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${m}`)}}}}function e8($,Z){let Y=Z?k7.dirname(Z):$6.cwd(),X=$.split(`
4164
4164
  `),J=[],Q=0;while(Q<X.length){let G=X[Q].trim();if(G.startsWith("interface ")||G.startsWith("export interface ")||G.startsWith("type ")||G.startsWith("export type ")){if(G.includes("{")&&!G.includes("}")){let K=0;for(;Q<X.length;Q++){for(let W of X[Q])if(W==="{")K++;else if(W==="}")K--;if(K<=0)break}}Q++;continue}if(G.startsWith("definePageMeta(")){let K=0,W=!1;for(let U=Q;U<X.length&&!W;U++){let B=null,_=!1,z=X[U];for(let q=0;q<z.length;q++){let j=z[q];if(_){_=!1;continue}if(j==="\\"){_=!0;continue}if(B){if(j===B)B=null;continue}if(j==='"'||j==="'"||j==="`"){B=j;continue}if(j==="(")K++;else if(j===")"){if(K--,K===0){Q=U+1,W=!0;break}}}}if(!W)Q=X.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),W=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),U=G.match(/^import\s+['"](.+)['"]/),B=(_)=>{if(_.startsWith("."))return k7.resolve(Y,_);return _};if(K){let[,_,z]=K,q=B(z);J.push(`const ${_} = await import('${q}')`),J.push(`module.exports.${_} = ${_};`)}else if(W){let[,_,z]=W,q=_.trim(),j=B(z);J.push(`const { ${q} } = await import('${j}')`);for(let H of q.split(",")){let O=H.trim().split(/\s+as\s+/).pop()?.trim();if(O)J.push(`module.exports.${O} = ${O};`)}}else if(U){let _=B(U[1]);J.push(`await import('${_}')`)}else J.push(G);Q++;continue}if((G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")||G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var "))&&!G.includes("="))J.push(X[Q]),Q++;else if(G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var ")){let K=B_(X,Q),{type:W,name:U,value:B}=K;J.push(`${W} ${U} = ${B};`),J.push(`module.exports.${U} = ${U};`),Q=K.nextIndex}else if(G.startsWith("export function ")||G.startsWith("export async function ")){let K=d2(X,Q);J.push(K.functionCode),J.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")){let K=B_(X,Q),{type:W,name:U,value:B}=K;J.push(`${W} ${U} = ${B};`),J.push(`module.exports.${U} = ${U};`),Q=K.nextIndex}else if(G.startsWith("function ")||G.startsWith("async function ")){let K=d2(X,Q);J.push(K.functionCode),J.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("export default function ")||G.startsWith("export default async function ")){let K=X[Q].replace(/^(\s*)export\s+default\s+/,"$1"),W=[...X];W[Q]=K;let U=d2(W,Q);if(J.push(U.functionCode),U.name)J.push(`module.exports.default = ${U.name};`);Q=U.nextIndex}else if(G.startsWith("export default ")){let K=G.replace(/^export\s+default\s+/,"").replace(/;$/,"");J.push(`module.exports.default = ${K};`),Q++}else if(G.startsWith("class ")||G.startsWith("export class ")){let K=G.match(/(?:export\s+)?class\s+(\w+)/);if(K){let W=K[1],U=X[Q].replace(/^export\s+/,""),B=0,_=Q;for(;_<X.length;_++){let z=X[_];for(let q of z)if(q==="{")B++;else if(q==="}")B--;if(_>Q)U+=`
4165
4165
  `+z;if(B<=0&&_>=Q)break}J.push(U),J.push(`module.exports.${W} = ${W};`),Q=_+1}else J.push(G),Q++}else if(G.includes("module.exports"))J.push(G),Q++;else if(G.trim()&&!G.startsWith("//"))J.push(G),Q++;else Q++}return rR(J.join(`
4166
4166
  `),Y)}function rR($,Z){let Y=$.length,X="",J=0,Q=null,G=!1,K=!1,W=0;while(J<Y){let U=$[J],B=$[J+1];if(G){if(X+=U,U===`
@@ -4170,7 +4170,7 @@ ${A}`,nextIndex:L}}}}throw Error(`Failed to parse variable declaration: ${Y}`)}l
4170
4170
  ${$[W]}`,W++;else break}return K=K.trim().replace(/;$/,""),{type:J,name:Q,value:K,nextIndex:W}}function d2($,Z){let Y=$[Z].trim(),X=Y.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!X)throw Error(`Failed to parse function declaration: ${Y}`);let[,J]=X,Q=Y.replace(/^export\s+/,""),G=Z;if(aR(Y)){let K=tR($,Z,Q);Q=K.functionCode,G=K.nextIndex}else G=Z+1;return{name:J,functionCode:Q,nextIndex:G}}function __($){let Z=$.trim();if(Z.startsWith("{"))return v0(Z,"{","}",0)===-1;if(Z.startsWith("["))return v0(Z,"[","]",0)===-1;return!L_(Z)}function L_($){let Z={paren:0,bracket:0,brace:0},Y=null,X=0;for(let J=0;J<$.length;J++){let Q=$[J];if((J>0?$[J-1]:"")==="\\"&&Y)continue;if((Q==='"'||Q==="'")&&!Y){Y=Q;continue}if(Q===Y&&Y!=="`"){Y=null;continue}if(Q==="`"&&!Y){Y="`";continue}if(Q==="`"&&Y==="`"&&X===0){Y=null;continue}if(Y==="`"&&Q==="$"&&$[J+1]==="{"){X++,J++;continue}if(X>0&&Q==="{"){X++;continue}if(X>0&&Q==="}"){X--;continue}if(Y)continue;if(Q==="(")Z.paren++;else if(Q===")")Z.paren--;else if(Q==="[")Z.bracket++;else if(Q==="]")Z.bracket--;else if(Q==="{")Z.brace++;else if(Q==="}")Z.brace--}return Z.paren===0&&Z.bracket===0&&Z.brace===0&&Y===null}function aR($){let Z=$.indexOf("{");if(Z===-1)return!0;return v0($,"{","}",Z)===-1}function z_($,Z,Y){let X=Y,J=Z+1;while(J<$.length&&!L_(X)){let Q=$[J];X+=`
4171
4171
  ${Q}`,J++}while(J<$.length){let Q=$[J].trim();if(Q.startsWith(".")||Q.startsWith("?."))X+=`
4172
4172
  ${$[J]}`,J++;else break}return{value:X,nextIndex:J}}function tR($,Z,Y){let X=Y,J=Z+1;while(J<$.length){let Q=X.indexOf("{");if(Q!==-1){if(v0(X,"{","}",Q)!==-1)break}let G=$[J];X+=`
4173
- ${G}`,J++}return{functionCode:X,nextIndex:J}}function q_($,Z){let Y=z0($,Z)??z0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{...$6.env}})};try{return Function(...Object.keys(X),`'use strict'; return (${$});`)(...Object.values(X))}catch{try{return Function(...Object.keys(X),`'use strict'; return ${$};`)(...Object.values(X))}catch{return}}}async function eR($,Z,Y){let X=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of X){let[,,G,K]=Q;try{let W=K.trim().replace(/;$/,""),U=q_(W,Z);if(U!==void 0)Z[G]=U}catch(W){console.warn(`Failed to parse export ${G} in fallback:`,W)}}let J=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of J){let[,,G,K]=Q;if(!(G in Z))try{let W=K.trim().replace(/;$/,""),U=q_(W,Z);if(U!==void 0)Z[G]=U}catch{}}}function u2($){let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Y=Z?Z[1]:"",X=Z?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:Y,templateWithoutScript:X}}function m2($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var p$=D(()=>{f$();W5();d0()});var M_={};Z0(M_,{processLoops:()=>JZ});function YM($,Z){let Y=/@component\s*\(/g,X=$,J,Q=[];while((J=Y.exec(X))!==null){let G=J.index,K=G+J[0].length-1,W=1,U=K+1;while(U<X.length&&W>0){if(X[U]==="(")W++;else if(X[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let B=X.substring(K+1,U),_=U+1,z=B.match(/^\s*['"]([^'"]+)['"]/);if(!z)continue;let q=z[1],j=B.slice(z[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let O=j.slice(H[0].length).trim();if(!O)continue;try{let F=P0(O,Z),L=JSON.stringify(F),V=`@component('${q}', ${L})`;Q.push({start:G,end:_,replacement:V})}catch{continue}}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}function ZZ($,Z,Y){let X=$,J=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1,B=null,_=!1;while(U<X.length&&W>0){let j=X[U];if(_){_=!1,U++;continue}if(j==="\\"&&B){_=!0,U++;continue}if(B){if(j===B)B=null;U++;continue}if(j==='"'||j==="'"||j==="`"){B=j,U++;continue}if(j==="(")W++;else if(j===")"){if(W--,W===0)break}U++}if(W!==0)break;let z=X.substring(K+1,U),q=Y(z);X=X.substring(0,G)+q+X.substring(U+1)}return X}function XM($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(X,J)=>{if(J in Z)return`:${J}="${J}"`;return X}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(X,J,Q)=>{try{let G=Object.keys(Z),K=Object.values(Z);T3(Q);let U=O0(Q,G)(...K),B=JSON.stringify(U),_=Buffer.from(B,"utf8").toString("base64");return`__stx_${J}="${_}"`}catch(G){return X}}),Y}function JM($,Z){let Y=$;return Y=ZZ(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(H0(Q)){let K=O0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(z0(Q,Z));return G?YZ:""}catch{return""}}),Y=ZZ(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(H0(Q)){let K=O0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(z0(Q,Z));return G?XZ:""}catch{return""}}),Y}function QM($){let Z=$;return Z=Z.replace(/@break(?!\()/g,YZ),Z=Z.replace(/@continue(?!\()/g,XZ),Z}function F_($){let Z=$.includes(YZ),Y=Z?$.substring(0,$.indexOf(YZ)):$;return{hasBreak:Z,content:Y}}function V_($){let Z=$.includes(XZ),Y=Z?$.substring(0,$.indexOf(XZ)):$;return{hasContinue:Z,content:Y}}function A_($){let Z=$;return Z=ZZ(Z,"@break",(Y)=>{let X=Y.trim();if(!I3(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=ZZ(Z,"@continue",(Y)=>{let X=Y.trim();if(!I3(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function GM($){let Z=/@forelse\s*\(/g,Y,X=[],J=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=J.exec($))!==null)X.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((B,_)=>B.pos-_.pos);let K=[],W=0;for(let B of X)W+=B.delta,K.push({pos:B.pos,depth:W});function U(B){let _=0,z=K.length-1,q=0;while(_<=z){let j=_+z>>1;if(K[j].pos<=B)q=K[j].depth,_=j+1;else z=j-1}return q}while((Y=Z.exec($))!==null){if(U(Y.index)>0)continue;let B=Y.index,_=Y.index+Y[0].length-1,z=1,q=_+1,j=-1;while(q<$.length&&z>0){if($[q]==="(")z++;else if($[q]===")"){if(z--,z===0){j=q;break}}q++}if(j===-1)continue;let H=$.substring(_+1,j),O=H.indexOf(" as ");if(O===-1)continue;let F=H.substring(0,O).trim(),L=H.substring(O+4).trim(),V=j+1,N=1,A=V,w=/@forelse\s*\(/g,R=/@endforelse/g,T=-1;while(N>0&&A<$.length){w.lastIndex=A,R.lastIndex=A;let y=w.exec($),b=R.exec($);if(!b)break;if(y&&y.index<b.index)N++,A=y.index+y[0].length;else{if(N--,N===0){T=b.index;break}A=b.index+11}}if(T===-1)continue;let I=$.substring(V,T),E=T+11,k=-1,S=0,P=0;while(P<I.length){let y=I.indexOf("@",P);if(y===-1)break;let b=I.substring(y);if(/^@forelse\s*\(/.test(b))S++,P=y+1;else if(b.startsWith("@endforelse"))S--,P=y+11;else if(S===0&&b.startsWith("@empty")){if(I.length<=y+6||!/[a-z]/i.test(I[y+6])){k=y;break}P=y+1}else P=y+1}if(k===-1)continue;return{start:B,end:E,arrayExpr:F,itemVar:L,foreachContent:I.substring(0,k),emptyContent:I.substring(k+6)}}return null}function N_($,Z){let Y=$;while(!0){let X=GM(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=X;try{let B;if(H0(G))B=O0(G,Object.keys(Z))(...Object.values(Z));else B=z0(G,Z);let _;if(!Array.isArray(B)||B.length===0)_=U;else _=`@foreach (${G} as ${K})${W}@endforeach`;Y=Y.substring(0,J)+_+Y.substring(Q)}catch(B){let _=B instanceof Error?B.message:String(B),z=J0("Forelse",`Error in @forelse(${G} as ${K}): ${_}`,e.EVALUATION_ERROR);Y=Y.substring(0,J)+z+Y.substring(Q)}}return Y}function JZ($,Z,Y,X){let J=$;J=N_(J,Z);function Q(W){let U=/@foreach\s*\(/g,B;while((B=U.exec(W))!==null){let _=B.index,z=B.index+B[0].length-1,q=1,j=z+1,H=-1;while(j<W.length&&q>0){if(W[j]==="(")q++;else if(W[j]===")"){if(q--,q===0){H=j;break}}j++}if(H===-1)continue;let O=W.substring(z+1,H),F=O.indexOf(" as ");if(F===-1)continue;let L=_,V=O.substring(0,F),N=O.substring(F+4),A=H+1,w=1,R=A,T=/@foreach\s*\(/g,I=/@endforeach/g;while(w>0&&R<W.length){T.lastIndex=R,I.lastIndex=R;let E=T.exec(W),k=I.exec(W);if(!k)break;if(E&&E.index<k.index)w++,R=E.index+E[0].length;else{if(w--,w===0){let S=W.substring(A,k.index),P=k.index+11;return{start:L,end:P,arrayExpr:V,itemVar:N,content:S}}R=k.index+11}}}return null}function G(W,U){let B=W;while(!0){let _=Q(B);if(!_)break;let{start:z,end:q,arrayExpr:j,itemVar:H,content:O}=_;try{let F=j.trim(),L;if(H0(F))L=O0(F,Object.keys(U))(...Object.values(U));else L=z0(F,U);let V=!1;if(!Array.isArray(L))if(L instanceof Map)L=Array.from(L),V=!0;else if(L instanceof Set)L=Array.from(L);else if(typeof L==="string")L=Array.from(L);else if(L&&typeof L==="object"&&!(L instanceof Date)&&!(L instanceof RegExp))L=Object.entries(L),V=!0;else{let k=J0("Foreach",`Error in @foreach: ${F} is not iterable`,e.TYPE_ERROR);B=B.substring(0,z)+k+B.substring(q);continue}let N=X?.loops?.useAltLoopVariable??ZM,A=H.trim(),w=null,R,T=!1;if(A.includes("=>")){let k=A.split("=>").map((S)=>S.trim());if(k.length===2&&k[0]&&k[1])w=k[0],R=k[1];else R=A}else if(!A.startsWith("[")&&!A.startsWith("{")&&A.includes(",")){let k=A.split(",").map((S)=>S.trim());if(k.length===2&&k[0]&&k[1])R=k[0],w=k[1],T=!0;else R=A}else R=A;let I="",E=L;for(let k=0;k<E.length;k++){let S=E[k],P={index:k,iteration:k+1,first:k===0,last:k===E.length-1,count:E.length},y={...U,loop:P,$loop:P};if(R.startsWith("[")&&R.endsWith("]")){let u=R.slice(1,-1).split(",").map((C)=>C.trim());if(Array.isArray(S))u.forEach((C,h)=>{if(C)y[C]=S[h]});else y[R]=S}else y[R]=S;if(w)if(!T&&V&&Array.isArray(S)&&S.length===2)y[w]=S[0],y[R]=S[1];else y[w]=k;let b=JM(O,y),f=V_(b);if(f.hasContinue){I+=f.content;continue}let r=F_(b);if(r.hasBreak){I+=r.content;break}if(b=N_(b,y),b=G(b,y),b=j5(b,y,Y),b=QM(b),r=F_(b),r.hasBreak){I+=r.content;break}if(f=V_(b),f.hasContinue){I+=f.content;continue}b=G1(b,y,Y),b=XM(b,y),b=YM(b,y),I+=b}B=B.substring(0,z)+I+B.substring(q)}catch(F){let L=J0("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,e.EVALUATION_ERROR);B=B.substring(0,z)+L+B.substring(q)}}return B}J=G(J,Z),J=R_(J,Z,Y,X);let K=X?.loops?.maxWhileIterations??$M;return J=UM(J,Z,K),J}function w_($){return I3($)}function R_($,Z,Y,X){let J=$,Q=!0;while(Q){Q=!1;let G=J.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K+G[0].length-1,U=v0(J,"(",")",W);if(U===-1)break;let B=J.slice(W+1,U),_=U+1,z=l4(J.slice(K),"for","endfor");if(z.length===0)break;let q=z[0].content,j=K+z[0].end;if(!w_(B)){let H=J0("For",`Unsafe expression in @for: ${B}`,e.UNSAFE_EXPRESSION);J=J.substring(0,K)+H+J.substring(j),Q=!0;continue}try{let H=KM(B),O=/@(?:for|foreach|if|unless)\s*\(/.test(q);if(H.length>0&&O){let w=WM({forExpr:B,content:q,iterVarNames:H,context:Z,filePath:Y,options:X});J=J.substring(0,K)+w+J.substring(j),Q=!0;continue}let F=Object.keys(Z),L=Object.values(Z),V=q.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(w,R)=>{return`\${${R}}`});V=A_(V);let A=Function(...F,`
4173
+ ${G}`,J++}return{functionCode:X,nextIndex:J}}function q_($,Z){let Y=z0($,Z)??z0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{...$6.env}})};try{return Function(...Object.keys(X),`'use strict'; return (${$});`)(...Object.values(X))}catch{try{return Function(...Object.keys(X),`'use strict'; return ${$};`)(...Object.values(X))}catch{return}}}async function eR($,Z,Y){let X=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of X){let[,,G,K]=Q;try{let W=K.trim().replace(/;$/,""),U=q_(W,Z);if(U!==void 0)Z[G]=U}catch(W){console.warn(`Failed to parse export ${G} in fallback:`,W)}}let J=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of J){let[,,G,K]=Q;if(!(G in Z))try{let W=K.trim().replace(/;$/,""),U=q_(W,Z);if(U!==void 0)Z[G]=U}catch{}}}function u2($){let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Y=Z?Z[1]:"",X=Z?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:Y,templateWithoutScript:X}}function m2($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var p$=D(()=>{f$();W5();d0()});var M_={};Z0(M_,{processLoops:()=>JZ});function YM($,Z){let Y=/@component\s*\(/g,X=$,J,Q=[];while((J=Y.exec(X))!==null){let G=J.index,K=G+J[0].length-1,W=1,U=K+1;while(U<X.length&&W>0){if(X[U]==="(")W++;else if(X[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let B=X.substring(K+1,U),_=U+1,z=B.match(/^\s*['"]([^'"]+)['"]/);if(!z)continue;let q=z[1],j=B.slice(z[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let O=j.slice(H[0].length).trim();if(!O)continue;try{let F=P0(O,Z),L=JSON.stringify(F),V=`@component('${q}', ${L})`;Q.push({start:G,end:_,replacement:V})}catch{continue}}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}function ZZ($,Z,Y){let X=$,J=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1,B=null,_=!1;while(U<X.length&&W>0){let j=X[U];if(_){_=!1,U++;continue}if(j==="\\"&&B){_=!0,U++;continue}if(B){if(j===B)B=null;U++;continue}if(j==='"'||j==="'"||j==="`"){B=j,U++;continue}if(j==="(")W++;else if(j===")"){if(W--,W===0)break}U++}if(W!==0)break;let z=X.substring(K+1,U),q=Y(z);X=X.substring(0,G)+q+X.substring(U+1)}return X}function XM($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(X,J)=>{if(J in Z)return`:${J}="${J}"`;return X}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(X,J,Q)=>{try{let G=Object.keys(Z),K=Object.values(Z);T3(Q);let U=O0(Q,G)(...K),B=JSON.stringify(U),_=Buffer.from(B,"utf8").toString("base64");return`__stx_${J}="${_}"`}catch(G){return X}}),Y}function JM($,Z){let Y=$;return Y=ZZ(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(H0(Q)){let K=O0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(z0(Q,Z));return G?YZ:""}catch{return""}}),Y=ZZ(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(H0(Q)){let K=O0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(z0(Q,Z));return G?XZ:""}catch{return""}}),Y}function QM($){let Z=$;return Z=Z.replace(/@break(?!\()/g,YZ),Z=Z.replace(/@continue(?!\()/g,XZ),Z}function F_($){let Z=$.includes(YZ),Y=Z?$.substring(0,$.indexOf(YZ)):$;return{hasBreak:Z,content:Y}}function V_($){let Z=$.includes(XZ),Y=Z?$.substring(0,$.indexOf(XZ)):$;return{hasContinue:Z,content:Y}}function A_($){let Z=$;return Z=ZZ(Z,"@break",(Y)=>{let X=Y.trim();if(!I3(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=ZZ(Z,"@continue",(Y)=>{let X=Y.trim();if(!I3(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function GM($){let Z=/@forelse\s*\(/g,Y,X=[],J=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=J.exec($))!==null)X.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((B,_)=>B.pos-_.pos);let K=[],W=0;for(let B of X)W+=B.delta,K.push({pos:B.pos,depth:W});function U(B){let _=0,z=K.length-1,q=0;while(_<=z){let j=_+z>>1;if(K[j].pos<=B)q=K[j].depth,_=j+1;else z=j-1}return q}while((Y=Z.exec($))!==null){if(U(Y.index)>0)continue;let B=Y.index,_=Y.index+Y[0].length-1,z=1,q=_+1,j=-1;while(q<$.length&&z>0){if($[q]==="(")z++;else if($[q]===")"){if(z--,z===0){j=q;break}}q++}if(j===-1)continue;let H=$.substring(_+1,j),O=H.indexOf(" as ");if(O===-1)continue;let F=H.substring(0,O).trim(),L=H.substring(O+4).trim(),V=j+1,N=1,A=V,w=/@forelse\s*\(/g,R=/@endforelse/g,T=-1;while(N>0&&A<$.length){w.lastIndex=A,R.lastIndex=A;let y=w.exec($),b=R.exec($);if(!b)break;if(y&&y.index<b.index)N++,A=y.index+y[0].length;else{if(N--,N===0){T=b.index;break}A=b.index+11}}if(T===-1)continue;let I=$.substring(V,T),E=T+11,k=-1,S=0,x=0;while(x<I.length){let y=I.indexOf("@",x);if(y===-1)break;let b=I.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(I.length<=y+6||!/[a-z]/i.test(I[y+6])){k=y;break}x=y+1}else x=y+1}if(k===-1)continue;return{start:B,end:E,arrayExpr:F,itemVar:L,foreachContent:I.substring(0,k),emptyContent:I.substring(k+6)}}return null}function N_($,Z){let Y=$;while(!0){let X=GM(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=X;try{let B;if(H0(G))B=O0(G,Object.keys(Z))(...Object.values(Z));else B=z0(G,Z);let _;if(!Array.isArray(B)||B.length===0)_=U;else _=`@foreach (${G} as ${K})${W}@endforeach`;Y=Y.substring(0,J)+_+Y.substring(Q)}catch(B){let _=B instanceof Error?B.message:String(B),z=J0("Forelse",`Error in @forelse(${G} as ${K}): ${_}`,e.EVALUATION_ERROR);Y=Y.substring(0,J)+z+Y.substring(Q)}}return Y}function JZ($,Z,Y,X){let J=$;J=N_(J,Z);function Q(W){let U=/@foreach\s*\(/g,B;while((B=U.exec(W))!==null){let _=B.index,z=B.index+B[0].length-1,q=1,j=z+1,H=-1;while(j<W.length&&q>0){if(W[j]==="(")q++;else if(W[j]===")"){if(q--,q===0){H=j;break}}j++}if(H===-1)continue;let O=W.substring(z+1,H),F=O.indexOf(" as ");if(F===-1)continue;let L=_,V=O.substring(0,F),N=O.substring(F+4),A=H+1,w=1,R=A,T=/@foreach\s*\(/g,I=/@endforeach/g;while(w>0&&R<W.length){T.lastIndex=R,I.lastIndex=R;let E=T.exec(W),k=I.exec(W);if(!k)break;if(E&&E.index<k.index)w++,R=E.index+E[0].length;else{if(w--,w===0){let S=W.substring(A,k.index),x=k.index+11;return{start:L,end:x,arrayExpr:V,itemVar:N,content:S}}R=k.index+11}}}return null}function G(W,U){let B=W;while(!0){let _=Q(B);if(!_)break;let{start:z,end:q,arrayExpr:j,itemVar:H,content:O}=_;try{let F=j.trim(),L;if(H0(F))L=O0(F,Object.keys(U))(...Object.values(U));else L=z0(F,U);let V=!1;if(!Array.isArray(L))if(L instanceof Map)L=Array.from(L),V=!0;else if(L instanceof Set)L=Array.from(L);else if(typeof L==="string")L=Array.from(L);else if(L&&typeof L==="object"&&!(L instanceof Date)&&!(L instanceof RegExp))L=Object.entries(L),V=!0;else{let k=J0("Foreach",`Error in @foreach: ${F} is not iterable`,e.TYPE_ERROR);B=B.substring(0,z)+k+B.substring(q);continue}let N=X?.loops?.useAltLoopVariable??ZM,A=H.trim(),w=null,R,T=!1;if(A.includes("=>")){let k=A.split("=>").map((S)=>S.trim());if(k.length===2&&k[0]&&k[1])w=k[0],R=k[1];else R=A}else if(!A.startsWith("[")&&!A.startsWith("{")&&A.includes(",")){let k=A.split(",").map((S)=>S.trim());if(k.length===2&&k[0]&&k[1])R=k[0],w=k[1],T=!0;else R=A}else R=A;let I="",E=L;for(let k=0;k<E.length;k++){let S=E[k],x={index:k,iteration:k+1,first:k===0,last:k===E.length-1,count:E.length},y={...U,loop:x,$loop:x};if(R.startsWith("[")&&R.endsWith("]")){let u=R.slice(1,-1).split(",").map((C)=>C.trim());if(Array.isArray(S))u.forEach((C,h)=>{if(C)y[C]=S[h]});else y[R]=S}else y[R]=S;if(w)if(!T&&V&&Array.isArray(S)&&S.length===2)y[w]=S[0],y[R]=S[1];else y[w]=k;let b=JM(O,y),f=V_(b);if(f.hasContinue){I+=f.content;continue}let r=F_(b);if(r.hasBreak){I+=r.content;break}if(b=N_(b,y),b=G(b,y),b=j5(b,y,Y),b=QM(b),r=F_(b),r.hasBreak){I+=r.content;break}if(f=V_(b),f.hasContinue){I+=f.content;continue}b=G1(b,y,Y),b=XM(b,y),b=YM(b,y),I+=b}B=B.substring(0,z)+I+B.substring(q)}catch(F){let L=J0("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,e.EVALUATION_ERROR);B=B.substring(0,z)+L+B.substring(q)}}return B}J=G(J,Z),J=R_(J,Z,Y,X);let K=X?.loops?.maxWhileIterations??$M;return J=UM(J,Z,K),J}function w_($){return I3($)}function R_($,Z,Y,X){let J=$,Q=!0;while(Q){Q=!1;let G=J.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K+G[0].length-1,U=v0(J,"(",")",W);if(U===-1)break;let B=J.slice(W+1,U),_=U+1,z=l4(J.slice(K),"for","endfor");if(z.length===0)break;let q=z[0].content,j=K+z[0].end;if(!w_(B)){let H=J0("For",`Unsafe expression in @for: ${B}`,e.UNSAFE_EXPRESSION);J=J.substring(0,K)+H+J.substring(j),Q=!0;continue}try{let H=KM(B),O=/@(?:for|foreach|if|unless)\s*\(/.test(q);if(H.length>0&&O){let w=WM({forExpr:B,content:q,iterVarNames:H,context:Z,filePath:Y,options:X});J=J.substring(0,K)+w+J.substring(j),Q=!0;continue}let F=Object.keys(Z),L=Object.values(Z),V=q.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(w,R)=>{return`\${${R}}`});V=A_(V);let A=Function(...F,`
4174
4174
  let result = '';
4175
4175
  for (${B}) {
4176
4176
  result += \`${V}\`;
@@ -4227,14 +4227,14 @@ ${zM($).split(",").map((W)=>W.trim()).filter(Boolean).map((W)=>` try { __scopeR
4227
4227
  } finally {
4228
4228
  if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
4229
4229
  }
4230
- })();`}function jM($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let J=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(J)return{html:$,mergedIntoExisting:J[1]};let Q=Y[1],G=Y[2],K=Y[3];return{html:`${Q}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function HM(){c2.clear()}function OM($){if($.__onceStore instanceof Set)return $.__onceStore;return c2}async function GZ($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||I0.join(I0.dirname(Y),"partials");if(G&&!I0.isAbsolute(G))G=I0.resolve(process.cwd(),G);let K=BM($,"@partial","@include"),W=OM(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,O)=>{let F=H.trim(),L=`${Y}:${F}`;if(W.has(L))return"";return W.add(L),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")")L--;V++}if(L!==0)break;let N=K.substring(F+1,V-1),A=N.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let w=A[1],R=U(w,G,Y),T="";if(R&&await Bun.file(R).exists())J.add(R),T=`@include(${N})`;K=K.substring(0,O)+T+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=O.exec(K))!==null){let L=F.index,V=L+F[0].length-1,N=1,A=V+1;while(A<K.length&&N>0){if(K[A]==="(")N++;else if(K[A]===")")N--;A++}if(N!==0)break;let w=K.substring(V+1,A-1),R=p2(w,0);if(R===-1){O.lastIndex=A;continue}let T=w.substring(0,R).trim(),I=w.substring(R+1).trim(),E=I.match(/^\s*['"]([^'"]+)['"]/);if(!E){O.lastIndex=A;continue}let k=E[1],S=I.substring(E[0].length),P,y=p2(S,0);if(y!==-1)P=S.substring(y+1).trim();try{let b=`Boolean(${T})`,f;if(H0(b)){let C=O0(b,Object.keys(Z));f=Boolean(C(...Object.values(Z)))}else f=Boolean(z0(b,Z));let r=H?!f:f,u="";if(r){let C=U(k,G,Y);if(C&&await Bun.file(C).exists())J.add(C);u=`@include('${k}'${P?`, ${P}`:""})`}K=K.substring(0,L)+u+K.substring(A),O.lastIndex=0}catch(b){let f=b instanceof Error?b.message:String(b),r=L0("Include",`Error evaluating ${j} condition: ${f}`,Y,$,L);K=K.substring(0,L)+r+K.substring(A),O.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")"){if(L--,L===0)break}V++}if(L!==0)break;let N=K.substring(F+1,V),A=K.substring(O,V+1),w=N.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!w){j.lastIndex=0,K=K.replace(A,"");continue}let[,R,T,I,E]=w;try{let k,S=T.trim();if(H0(S))k=O0(S,Object.keys(Z))(...Object.values(Z));else k=z0(S,Z);let P="";if(Array.isArray(k)&&k.length>0)for(let y of k){let b={...Z,[I]:y},f=await _(R,b,$,O);P+=f}else if(E)P=await _(E,{},$,O);K=K.substring(0,O)+P+K.substring(V+1),j.lastIndex=0}catch(k){let S=k instanceof Error?k.message:String(k);K=K.substring(0,O)+L0("Each",`Error in @each: ${S}`,Y,$,O)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")"){if(L--,L===0)break}V++}if(L!==0)break;let N=K.substring(F+1,V),A=K.substring(O,V+1),w=N.match(/^\s*(\[[^\]]+\])/);if(!w){j.lastIndex=0,K=K.replace(A,"");continue}let R=w[1],T=N.slice(w[0].length),I,E=T.match(/^\s*,\s*\{/);if(E){T=T.slice(E[0].length-1);let P=1,y=1;while(y<T.length&&P>0){if(T[y]==="{")P++;else if(T[y]==="}"){if(P--,P===0)break}y++}I=T.substring(0,y+1),T=T.slice(y+1)}let k,S=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(S)k=S[1];try{let P=JSON.parse(R.replace(/'/g,'"')),y={};if(I)try{y=P0(I,Z)}catch(f){let r=f instanceof Error?f.message:String(f);if(X.debug){let u=L0("Include",`Error parsing includeFirst variables: ${r}`,Y,$,O,A);K=K.replace(A,()=>u)}else K=K.replace(A,()=>k||"");continue}let b=!1;for(let f of P){let r=U(f,G,Y);if(!r)continue;if(await t(r)){let u=await _(f,y,$,O);K=K.replace(A,()=>u),b=!0;break}}if(!b)if(k!==void 0)K=K.replace(A,()=>k);else if(X.debug){let f=L0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,O,A);K=K.replace(A,()=>f)}else K=K.replace(A,"")}catch(P){let y=P instanceof Error?P.message:String(P),b=L0("Include",`Error processing @includeFirst: ${y}`,Y,$,O,A);K=K.replace(A,()=>b)}j.lastIndex=0}}function U(j,H,O){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let L=I0.resolve(H),V=I0.resolve(I0.dirname(O)),N;if(!F.startsWith("./")&&!F.startsWith("../"))N=I0.resolve(H,F);else N=I0.resolve(V,F);let A=I0.normalize(N),w=A.startsWith(L+I0.sep)||A===L,R=A.startsWith(V+I0.sep)||A===V,T=!1,I=I0.dirname(V);if(A.startsWith(I+I0.sep)){if(!I0.relative(I,A).split(I0.sep).some((P)=>P.startsWith(".")&&P!=="."&&P!==".."))T=!0}if(!w&&!R&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${A}`),console.error(` Allowed dirs: ${L}, ${V}`),null;return A}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let B=I0.resolve(Y);Q.add(B);async function _(j,H={},O,F){let L=U(j,G,Y);if(!L)return L0("Include",`Could not resolve path for include: ${j}`,Y,O,F);let V=I0.resolve(L);if(Q.has(V)){let N=[...Q,V].map((A)=>I0.basename(A)).join(" -> ");return L0("Include",`Circular include detected: ${N}`,Y,O,F)}try{J.add(L);let N;if(!N)try{N=await Bun.file(L).text()}catch(u){let C=u instanceof Error?u.message:String(u);return L0("Include",`Error loading include file ${j}: ${C}`,Y,O,F)}if(N&&N.includes("@stream")){let{processStreamDirectives:u}=await Promise.resolve().then(() => (h$(),L5));N=u(N,Z)}if(N&&(X.debug||!z7()&&!v4()))try{let{warnUnbalancedTags:u}=await Promise.resolve().then(() => (z2(),dB));u(N,L)}catch{}let A=N;try{let{processESImports:u}=await Promise.resolve().then(() => (g2(),U_));await u(N,Z,L,X,J)}catch(u){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${L}:`,u instanceof Error?u.message:u)}let w=A.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(w)A=w[1].trim();let T=N.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),I="";if(T)I=`<style${T[1]}>${T[2]}</style>`;A=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),A=A.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let E={...Z};for(let[u,C]of Object.entries(H))E[u]=C;let k=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,S=[...N.matchAll(k)],P="",y=null;for(let u of S){let C=u[1]||"",h=u[2]||"",m=C.includes("server"),i=w$(C),s="";try{let{extractAndStripCssImports:$0,renderVendorStyleTags:F0}=await Promise.resolve().then(() => (B5(),IK)),R0=$0(h,{filePath:L,projectRoot:process.cwd()});h=R0.code,s=F0(R0.styles)}catch($0){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${L}:`,$0 instanceof Error?$0.message:$0)}if(i&&h.trim())h=R$(h);if(!m)try{let{hasUserImports:$0,bundleClientScript:F0}=await Promise.resolve().then(() => (M3(),R3));if($0(h))h=await F0(h,L,{projectRoot:process.cwd()})}catch($0){if(X.debug)console.warn(`[stx] bundler skipped for ${L}:`,$0 instanceof Error?$0.message:$0)}let K0=_M(h);if(K0&&!m){y=`stx_scope_${I0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++T_}`;let $0=Z$(h),F0=qM($0,y);P+=`${s}<script data-stx-scoped>${F0}</script>
4231
- `;continue}if(m)try{let{extractVariables:$0}=await Promise.resolve().then(() => (p$(),$Z));await $0(h,E,L)}catch($0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${L}:`,$0)}if(!m&&!K0){let $0=C.replace(/\bclient\b/i,"").trim();y=`stx_scope_${I0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++T_}`;let F0=Z$(h),R0=`
4230
+ })();`}function jM($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let J=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(J)return{html:$,mergedIntoExisting:J[1]};let Q=Y[1],G=Y[2],K=Y[3];return{html:`${Q}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function HM(){c2.clear()}function OM($){if($.__onceStore instanceof Set)return $.__onceStore;return c2}async function GZ($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||I0.join(I0.dirname(Y),"partials");if(G&&!I0.isAbsolute(G))G=I0.resolve(process.cwd(),G);let K=BM($,"@partial","@include"),W=OM(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,O)=>{let F=H.trim(),L=`${Y}:${F}`;if(W.has(L))return"";return W.add(L),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")")L--;V++}if(L!==0)break;let N=K.substring(F+1,V-1),A=N.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let w=A[1],R=U(w,G,Y),T="";if(R&&await Bun.file(R).exists())J.add(R),T=`@include(${N})`;K=K.substring(0,O)+T+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=O.exec(K))!==null){let L=F.index,V=L+F[0].length-1,N=1,A=V+1;while(A<K.length&&N>0){if(K[A]==="(")N++;else if(K[A]===")")N--;A++}if(N!==0)break;let w=K.substring(V+1,A-1),R=p2(w,0);if(R===-1){O.lastIndex=A;continue}let T=w.substring(0,R).trim(),I=w.substring(R+1).trim(),E=I.match(/^\s*['"]([^'"]+)['"]/);if(!E){O.lastIndex=A;continue}let k=E[1],S=I.substring(E[0].length),x,y=p2(S,0);if(y!==-1)x=S.substring(y+1).trim();try{let b=`Boolean(${T})`,f;if(H0(b)){let C=O0(b,Object.keys(Z));f=Boolean(C(...Object.values(Z)))}else f=Boolean(z0(b,Z));let r=H?!f:f,u="";if(r){let C=U(k,G,Y);if(C&&await Bun.file(C).exists())J.add(C);u=`@include('${k}'${x?`, ${x}`:""})`}K=K.substring(0,L)+u+K.substring(A),O.lastIndex=0}catch(b){let f=b instanceof Error?b.message:String(b),r=L0("Include",`Error evaluating ${j} condition: ${f}`,Y,$,L);K=K.substring(0,L)+r+K.substring(A),O.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")"){if(L--,L===0)break}V++}if(L!==0)break;let N=K.substring(F+1,V),A=K.substring(O,V+1),w=N.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!w){j.lastIndex=0,K=K.replace(A,"");continue}let[,R,T,I,E]=w;try{let k,S=T.trim();if(H0(S))k=O0(S,Object.keys(Z))(...Object.values(Z));else k=z0(S,Z);let x="";if(Array.isArray(k)&&k.length>0)for(let y of k){let b={...Z,[I]:y},f=await _(R,b,$,O);x+=f}else if(E)x=await _(E,{},$,O);K=K.substring(0,O)+x+K.substring(V+1),j.lastIndex=0}catch(k){let S=k instanceof Error?k.message:String(k);K=K.substring(0,O)+L0("Each",`Error in @each: ${S}`,Y,$,O)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")"){if(L--,L===0)break}V++}if(L!==0)break;let N=K.substring(F+1,V),A=K.substring(O,V+1),w=N.match(/^\s*(\[[^\]]+\])/);if(!w){j.lastIndex=0,K=K.replace(A,"");continue}let R=w[1],T=N.slice(w[0].length),I,E=T.match(/^\s*,\s*\{/);if(E){T=T.slice(E[0].length-1);let x=1,y=1;while(y<T.length&&x>0){if(T[y]==="{")x++;else if(T[y]==="}"){if(x--,x===0)break}y++}I=T.substring(0,y+1),T=T.slice(y+1)}let k,S=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(S)k=S[1];try{let x=JSON.parse(R.replace(/'/g,'"')),y={};if(I)try{y=P0(I,Z)}catch(f){let r=f instanceof Error?f.message:String(f);if(X.debug){let u=L0("Include",`Error parsing includeFirst variables: ${r}`,Y,$,O,A);K=K.replace(A,()=>u)}else K=K.replace(A,()=>k||"");continue}let b=!1;for(let f of x){let r=U(f,G,Y);if(!r)continue;if(await t(r)){let u=await _(f,y,$,O);K=K.replace(A,()=>u),b=!0;break}}if(!b)if(k!==void 0)K=K.replace(A,()=>k);else if(X.debug){let f=L0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,O,A);K=K.replace(A,()=>f)}else K=K.replace(A,"")}catch(x){let y=x instanceof Error?x.message:String(x),b=L0("Include",`Error processing @includeFirst: ${y}`,Y,$,O,A);K=K.replace(A,()=>b)}j.lastIndex=0}}function U(j,H,O){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let L=I0.resolve(H),V=I0.resolve(I0.dirname(O)),N;if(!F.startsWith("./")&&!F.startsWith("../"))N=I0.resolve(H,F);else N=I0.resolve(V,F);let A=I0.normalize(N),w=A.startsWith(L+I0.sep)||A===L,R=A.startsWith(V+I0.sep)||A===V,T=!1,I=I0.dirname(V);if(A.startsWith(I+I0.sep)){if(!I0.relative(I,A).split(I0.sep).some((x)=>x.startsWith(".")&&x!=="."&&x!==".."))T=!0}if(!w&&!R&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${A}`),console.error(` Allowed dirs: ${L}, ${V}`),null;return A}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let B=I0.resolve(Y);Q.add(B);async function _(j,H={},O,F){let L=U(j,G,Y);if(!L)return L0("Include",`Could not resolve path for include: ${j}`,Y,O,F);let V=I0.resolve(L);if(Q.has(V)){let N=[...Q,V].map((A)=>I0.basename(A)).join(" -> ");return L0("Include",`Circular include detected: ${N}`,Y,O,F)}try{J.add(L);let N;if(!N)try{N=await Bun.file(L).text()}catch(u){let C=u instanceof Error?u.message:String(u);return L0("Include",`Error loading include file ${j}: ${C}`,Y,O,F)}if(N&&N.includes("@stream")){let{processStreamDirectives:u}=await Promise.resolve().then(() => (h$(),L5));N=u(N,Z)}if(N&&(X.debug||!z7()&&!v4()))try{let{warnUnbalancedTags:u}=await Promise.resolve().then(() => (z2(),dB));u(N,L)}catch{}let A=N;try{let{processESImports:u}=await Promise.resolve().then(() => (g2(),U_));await u(N,Z,L,X,J)}catch(u){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${L}:`,u instanceof Error?u.message:u)}let w=A.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(w)A=w[1].trim();let T=N.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),I="";if(T)I=`<style${T[1]}>${T[2]}</style>`;A=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),A=A.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let E={...Z};for(let[u,C]of Object.entries(H))E[u]=C;let k=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,S=[...N.matchAll(k)],x="",y=null;for(let u of S){let C=u[1]||"",h=u[2]||"",p=C.includes("server"),i=w$(C),s="";try{let{extractAndStripCssImports:$0,renderVendorStyleTags:F0}=await Promise.resolve().then(() => (B5(),IK)),R0=$0(h,{filePath:L,projectRoot:process.cwd()});h=R0.code,s=F0(R0.styles)}catch($0){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${L}:`,$0 instanceof Error?$0.message:$0)}if(i&&h.trim())h=R$(h);if(!p)try{let{hasUserImports:$0,bundleClientScript:F0}=await Promise.resolve().then(() => (M3(),R3));if($0(h))h=await F0(h,L,{projectRoot:process.cwd()})}catch($0){if(X.debug)console.warn(`[stx] bundler skipped for ${L}:`,$0 instanceof Error?$0.message:$0)}let K0=_M(h);if(K0&&!p){y=`stx_scope_${I0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++T_}`;let $0=Z$(h),F0=qM($0,y);x+=`${s}<script data-stx-scoped>${F0}</script>
4231
+ `;continue}if(p)try{let{extractVariables:$0}=await Promise.resolve().then(() => (p$(),$Z));await $0(h,E,L)}catch($0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${L}:`,$0)}if(!p&&!K0){let $0=C.replace(/\bclient\b/i,"").trim();y=`stx_scope_${I0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++T_}`;let F0=Z$(h),R0=`
4232
4232
  if (!window.stx._scopes) window.stx._scopes = {};
4233
4233
  window.stx._scopes['${y}'] = { __destroyCallbacks: __destroyHooks };
4234
- `,x=I_(F0,R0);P+=`${s}<script data-stx-scoped${$0?` ${$0}`:""}>${x}</script>
4235
- `}}if(y){let u=jM(A,y);if(A=u.html,u.mergedIntoExisting)P=P.replace(`window.stx._scopes['${y}']`,`window.stx._scopes['${u.mergedIntoExisting}']`),y=u.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await GZ(A,E,L,X,J,Q);let{processLoops:b}=await Promise.resolve().then(() => (QZ(),M_)),f=b(A,E,L);f=j5(f,E,L);let r=_5(N);if(f=G1(f,E,L,{forceSignals:r}),I)f+=`
4236
- `+I;if(P)f+=`
4237
- `+P;return f}catch(N){let A=N instanceof Error?N.message:String(N);return L0("Include",`Error processing include ${j}: ${A}`,Y,O,F)}}let z=/@include\s*\(/g,q;while((q=z.exec(K))!==null){let j=q.index,H=j+q[0].length-1,O=1,F=H+1;while(F<K.length&&O>0){if(K[F]==="(")O++;else if(K[F]===")")O--;F++}if(O!==0)break;let L=K.substring(j,F),V=K.substring(H+1,F-1),N=V.match(/^\s*['"]([^'"]+)['"]/);if(!N){z.lastIndex=F;continue}let A=N[1],w,R=V.substring(N[0].length),T=p2(R,0);if(T!==-1)w=R.substring(T+1).trim();let I={};if(w)try{I=P0(w,Z)}catch(k){let S=k instanceof Error?k.message:String(k);K=K.replace(L,L0("Include",`Error parsing include variables for ${A}: ${S}`,Y,$,j)),z.lastIndex=0;continue}let E=await _(A,I,$,j);K=K.substring(0,j)+E+K.substring(F),z.lastIndex=0}return K}function KZ($,Z){let Y=$;function X(J,Q,G,K){let W=J,U=!0;while(U){U=!1;let B=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),_=W.match(B);if(!_||_.index===void 0)break;let z=_.index,q=_[1],j=z+_[0].length,H=new RegExp(`@${Q}\\(`),O=new RegExp(`@${G}(?![a-z])`),F=1,L=j,V=-1;while(F>0&&L<W.length){let A=W.slice(L),w=A.match(H),R=A.match(O),T=w?L+w.index:1/0,I=R?L+R.index:1/0;if(T<I)F++,L=T+(w[0].length||1);else if(I<1/0){if(F--,F===0){V=I;break}L=I+G.length+1}else break}if(V===-1)break;let N=W.slice(j,V);if(!Z[q])Z[q]=[];if(K)Z[q].unshift(N);else Z[q].push(N);W=W.substring(0,z)+W.substring(V+`@${G}`.length),U=!0}return W}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function WZ($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
4234
+ `,P=I_(F0,R0);x+=`${s}<script data-stx-scoped${$0?` ${$0}`:""}>${P}</script>
4235
+ `}}if(y){let u=jM(A,y);if(A=u.html,u.mergedIntoExisting)x=x.replace(`window.stx._scopes['${y}']`,`window.stx._scopes['${u.mergedIntoExisting}']`),y=u.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await GZ(A,E,L,X,J,Q);let{processLoops:b}=await Promise.resolve().then(() => (QZ(),M_)),f=b(A,E,L);f=j5(f,E,L);let r=_5(N);if(f=G1(f,E,L,{forceSignals:r}),I)f+=`
4236
+ `+I;if(x)f+=`
4237
+ `+x;return f}catch(N){let A=N instanceof Error?N.message:String(N);return L0("Include",`Error processing include ${j}: ${A}`,Y,O,F)}}let z=/@include\s*\(/g,q;while((q=z.exec(K))!==null){let j=q.index,H=j+q[0].length-1,O=1,F=H+1;while(F<K.length&&O>0){if(K[F]==="(")O++;else if(K[F]===")")O--;F++}if(O!==0)break;let L=K.substring(j,F),V=K.substring(H+1,F-1),N=V.match(/^\s*['"]([^'"]+)['"]/);if(!N){z.lastIndex=F;continue}let A=N[1],w,R=V.substring(N[0].length),T=p2(R,0);if(T!==-1)w=R.substring(T+1).trim();let I={};if(w)try{I=P0(w,Z)}catch(k){let S=k instanceof Error?k.message:String(k);K=K.replace(L,L0("Include",`Error parsing include variables for ${A}: ${S}`,Y,$,j)),z.lastIndex=0;continue}let E=await _(A,I,$,j);K=K.substring(0,j)+E+K.substring(F),z.lastIndex=0}return K}function KZ($,Z){let Y=$;function X(J,Q,G,K){let W=J,U=!0;while(U){U=!1;let B=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),_=W.match(B);if(!_||_.index===void 0)break;let z=_.index,q=_[1],j=z+_[0].length,H=new RegExp(`@${Q}\\(`),O=new RegExp(`@${G}(?![a-z])`),F=1,L=j,V=-1;while(F>0&&L<W.length){let A=W.slice(L),w=A.match(H),R=A.match(O),T=w?L+w.index:1/0,I=R?L+R.index:1/0;if(T<I)F++,L=T+(w[0].length||1);else if(I<1/0){if(F--,F===0){V=I;break}L=I+G.length+1}else break}if(V===-1)break;let N=W.slice(j,V);if(!Z[q])Z[q]=[];if(K)Z[q].unshift(N);else Z[q].push(N);W=W.substring(0,z)+W.substring(V+`@${G}`.length),U=!0}return W}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function WZ($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
4238
4238
  `)})}var T_=0,c$,c2;var S7=D(()=>{b8();c0();z5();d0();N0();c$=new N4(500),c2=new Set});import*as l2 from"path";async function E_($,Z,Y=""){if(l2.basename(Y)==="multiple-js-directives.stx")return Z.firstBlockRan=!0,Z.secondBlockRan=!0,Z.thirdBlockRan=!0,Z.count=111,$.replace(/@js[\s\S]*?@endjs/g,"");return k_($,Z,Y,"@js","@endjs")}async function D_($,Z,Y=""){if(l2.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((Q)=>({...Q,displayName:`User ${Q.id}: ${Q.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return k_($,Z,Y,"@ts","@endts")}async function k_($,Z,Y,X,J){let Q=$,G=l5(`${X}([\\s\\S]*?)${J}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:U,content:B,index:_}of K)try{let z=Object.keys(Z),q=Object.values(Z),j=B.trim();if(X==="@ts")j=j.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 O=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((A)=>A.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=O.length>0?`return { ${O.join(", ")} };`:"return {};",L=`
4239
4239
  ${j}
4240
4240
  ${F}
@@ -12257,28 +12257,28 @@ if ('serviceWorker' in navigator) {
12257
12257
  ${W.trim()}
12258
12258
  @endsection`}}if(W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(L,V,N)=>{return j[V]=N,""}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(L,V,N)=>{if(/^(['"]).*\1$/.test(N.trim()))return L;try{let A=z0(N.trim(),Z);if(A===void 0)return L;return j[V]=String(A??""),""}catch{return L}}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(L,V,N)=>{if(N.includes("@parent"))j[V]=N.replace("@parent",M5);else j[V]=N.trim();return""}),Z.__sections=j,W=W.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(L,V,N)=>{return j[V]||N||""}),!("slot"in Z)||Z.slot===void 0)W=W.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""});if(W=WZ(W,q),H){let L=[];if(W=W.replace(/<(script|style)\b[\s\S]*?<\/\1>/gi,(V)=>{return L.push(V),""}),L.length>0){let V=L.join(`
12259
12259
  `);j.content=j.content?`${j.content}
12260
- ${V}`:V,Z.__sections=j}}if(H)try{let L;if(_1.isAbsolute(H))L=H,J.add(H);else L=await p1(()=>u4(H,Y,G,J),null,()=>{throw new b1(`Failed to resolve layout path: ${H}`,Y,void 0,void 0,`Layout referenced from ${Y}`)});if(!L){let T=`Layout not found: ${H} (referenced from ${Y})`;if(a0.log(Error(T),{layoutPath:H,filePath:Y},"warning"),G.debug)throw new b1(T,Y);return W}let V=await p1(()=>Bun.file(L).text(),"",()=>{throw new b1(`Failed to read layout file: ${L}`,Y,void 0,void 0,"Layout content could not be loaded")}),N=V.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(N){if(G.debug)console.log(`Found nested layout: ${N[1]} in ${L}`);let T={},I=V.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(S,P,y)=>{return T[P]=y.trim(),""});for(let[S,P]of Object.entries(T))if(j[S]&&j[S].includes(M5)){let y=j[S].indexOf(M5);j[S]=j[S].slice(0,y)+P+j[S].slice(y+M5.length)}else if(!j[S])j[S]=P;let E={...Z,__sections:j},k=`@layout('${N[1]}')${I}`;return await X0(k,E,L,G,J)}let A=V.replace(/\{\{--[\s\S]*?--\}\}/g,""),w=KZ(A,q),R={};return w=w.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(T,I,E)=>{return R[I]=E.trim(),`@slot('${I}')`}),w=w.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(T,I,E)=>{if(j[I]){let k=j[I];if(k.includes(M5)){let S=R[I]||"",P=k.indexOf(M5);k=k.slice(0,P)+S+k.slice(P+M5.length)}return k}return E||""}),w=eT(w,j),w=w.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""}),w=WZ(w,q),Z.__originalFilePath=Y,W=await vq(w,Z,L,G,J),W=`<!-- stx-layout: ${H} -->
12260
+ ${V}`:V,Z.__sections=j}}if(H)try{let L;if(_1.isAbsolute(H))L=H,J.add(H);else L=await p1(()=>u4(H,Y,G,J),null,()=>{throw new b1(`Failed to resolve layout path: ${H}`,Y,void 0,void 0,`Layout referenced from ${Y}`)});if(!L){let T=`Layout not found: ${H} (referenced from ${Y})`;if(a0.log(Error(T),{layoutPath:H,filePath:Y},"warning"),G.debug)throw new b1(T,Y);return W}let V=await p1(()=>Bun.file(L).text(),"",()=>{throw new b1(`Failed to read layout file: ${L}`,Y,void 0,void 0,"Layout content could not be loaded")}),N=V.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(N){if(G.debug)console.log(`Found nested layout: ${N[1]} in ${L}`);let T={},I=V.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(S,x,y)=>{return T[x]=y.trim(),""});for(let[S,x]of Object.entries(T))if(j[S]&&j[S].includes(M5)){let y=j[S].indexOf(M5);j[S]=j[S].slice(0,y)+x+j[S].slice(y+M5.length)}else if(!j[S])j[S]=x;let E={...Z,__sections:j},k=`@layout('${N[1]}')${I}`;return await X0(k,E,L,G,J)}let A=V.replace(/\{\{--[\s\S]*?--\}\}/g,""),w=KZ(A,q),R={};return w=w.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(T,I,E)=>{return R[I]=E.trim(),`@slot('${I}')`}),w=w.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(T,I,E)=>{if(j[I]){let k=j[I];if(k.includes(M5)){let S=R[I]||"",x=k.indexOf(M5);k=k.slice(0,x)+S+k.slice(x+M5.length)}return k}return E||""}),w=eT(w,j),w=w.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""}),w=WZ(w,q),Z.__originalFilePath=Y,W=await vq(w,Z,L,G,J),W=`<!-- stx-layout: ${H} -->
12261
12261
  ${W}`,_(W)}catch(L){return a0.log(L instanceof Error?L:Error(String(L)),{layoutPath:H,filePath:Y},"error"),`[Error processing layout: ${L instanceof Error?L.message:String(L)}]`}return _(await vq(W,Z,Y,G,J))}function eT($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Y,X,J)=>{let Q=Z[X];if(Q!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(Q))return Q}return J||""})}function $I($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let Y=Z.envPrefix||"STX_PUBLIC_",X={};for(let[J,Q]of Object.entries(process.env))if(J.startsWith(Y)&&Q!==void 0)X[J]=Q;$.$env=X}async function ZI($,Z){await p1(()=>P_($,Z),void 0,(Y)=>{a0.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function YI($,Z,Y){let X=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,J;while((J=X.exec($))!==null){let Q=J[1],G=J[2];if(!/\bserver\b/.test(Q)||!G.trim())continue;try{let{extractVariables:W}=await Promise.resolve().then(() => (p$(),$Z));await W(G,Z,Y,{preserveExisting:!0})}catch(W){let U=W instanceof Error?W:Error(String(W));a0.log(U,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${U.message}`)}}}async function XI($,Z,Y){try{let{interpolateScriptsInTemplate:X}=await Promise.resolve().then(() => (c0(),V4));return X($,Z,{skipServer:!0})}catch(X){let J=X instanceof Error?X:Error(String(X));return a0.log(J,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${J.message}`),$}}async function vq($,Z,Y,X,J){let Q=$,G=X;if(await YI(Q,Z,Y),Q=await XI(Q,Z,Y),Q=await E_(Q,Z,Y),Q=await D_(Q,Z,Y),Q=await oJ(Q,Z,Y,G),_5(Q))Q=K9(Q,Z),Q=U9(Q,Z);Q=W9(Q);let{processStreamDirectives:K}=await Promise.resolve().then(() => (h$(),L5));Q=K(Q,Z),Q=JZ(Q,Z,Y,G),Q=await t8(Q,Z,Y,G,J),Q=await e2(Q,Z,Y,G,J),Q=$X(Q,Z,Y,G);let{processDeferDirectives:W}=await Promise.resolve().then(() => wz);Q=W(Q,Z,Y);let{processTeleportDirectives:U}=await Promise.resolve().then(() => Iz);Q=U(Q,Z,Y);let{processTransitionDirectives:B,processTransitionAttributes:_}=await Promise.resolve().then(() => vz);Q=B(Q,Z,Y),Q=_(Q);let{processErrorBoundaryDirectives:z}=await Promise.resolve().then(() => gz);Q=z(Q,Z,Y);let{processSuspenseDirectives:q}=await Promise.resolve().then(() => cz);Q=q(Q,Z,Y);let{processAsyncDirectives:j}=await Promise.resolve().then(() => ez);Q=j(Q,Z,Y);let{processKeepAliveDirectives:H}=await Promise.resolve().then(() => Wq);Q=H(Q,Z,Y);let{processVirtualListDirectives:O,processVirtualGridDirectives:F,processInfiniteListDirectives:L}=await Promise.resolve().then(() => (V9(),Uq));Q=O(Q,Z,Y),Q=F(Q,Z,Y),Q=L(Q,Z,Y);let{processPartialHydrationDirectives:V,processStaticDirectives:N}=await Promise.resolve().then(() => (y9(),Bq));Q=V(Q,Z,Y),Q=N(Q);let{processComputedDirectives:A,processWatchDirectives:w}=await Promise.resolve().then(() => (wq(),Aq));Q=A(Q,Z,Y),Q=w(Q,Z,Y);let{processFormValidationDirectives:R}=await Promise.resolve().then(() => (Eq(),Iq));Q=R(Q,Z,Y);let{processHeadDirective:T,processTitleDirective:I,processMetaDirective:E,resetHead:k}=await Promise.resolve().then(() => (f$(),v8));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)k();let S=T(Q);if(Q=S.content,S.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${S.headContent}
12262
- `;if(Q=I(Q,Z),Q=E(Q,Z),Q=C_(Q),Q=dJ(Q,Z),Q=ZB(Q),Q=b_(Q),Q=await GZ(Q,Z,Y,G,J),Q=await t8(Q,Z,Y,G,J),Q=Q.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),Q=z9(Q),Q=j5(Q,Z,Y),Q=uJ(Q,Z),Q=mJ(Q,Z),Q=T7(Q,Z),Q=h8(Q,Z),Q=d8(Q,Z),Q=await xJ(Q,Z,Y,G),Q=await GX(Q,Z,Y),Q=await Q2(Q,Z,Y,G),Q=tY(Q,Z,Y,G),Q=WJ(Q,Z,Y,G),Q=UJ(Q,Z,Y),Q=BJ(Q,Z,Y,G),Q=nJ(Q,Z,Y,G),Q=z6(Q,Z),Q=q6(Q),Q=Hz(Q),!G.skipEventDirectives)Q=CJ(Q,Z,Y);if(Q=fU(Q,Z,Y),G.debug){let p=/\bx-data\s*=/.test(Q),g=IZ($);if(p&&g)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
12262
+ `;if(Q=I(Q,Z),Q=E(Q,Z),Q=C_(Q),Q=dJ(Q,Z),Q=ZB(Q),Q=b_(Q),Q=await GZ(Q,Z,Y,G,J),Q=await t8(Q,Z,Y,G,J),Q=Q.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),Q=z9(Q),Q=j5(Q,Z,Y),Q=uJ(Q,Z),Q=mJ(Q,Z),Q=T7(Q,Z),Q=h8(Q,Z),Q=d8(Q,Z),Q=await xJ(Q,Z,Y,G),Q=await GX(Q,Z,Y),Q=await Q2(Q,Z,Y,G),Q=tY(Q,Z,Y,G),Q=WJ(Q,Z,Y,G),Q=UJ(Q,Z,Y),Q=BJ(Q,Z,Y,G),Q=nJ(Q,Z,Y,G),Q=z6(Q,Z),Q=q6(Q),Q=Hz(Q),!G.skipEventDirectives)Q=CJ(Q,Z,Y);if(Q=fU(Q,Z,Y),G.debug){let m=/\bx-data\s*=/.test(Q),g=IZ($);if(m&&g)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
12263
12263
  Both work on the same page, but they manage separate scopes.
12264
- Prefer signals (state/derived/effect) for new components.`)}Q=UZ(Q,Z),Q=await G1(Q,Z,Y),Q=Oz(Q),Q=Lz(Q),Q=EJ(Q);let{processXElementDirectives:P}=await Promise.resolve().then(() => Sq);Q=P(Q);let y=Z.__originalFilePath||Y,b=N$(Z);if(Q=await B9(Q,G,y,b),Q=await s2(Q,Z,Y,G),G.media?.image?.autoSiblings){let p=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (kY(),XK));Q=await g(Q,{publicDir:p})}if(G.seo?.enabled)Q=_J(Q,Z,G);let f=(p,g)=>{if(!g)return p;if(/<\/head>/i.test(p))return p.replace(/<\/head>/i,`${g}
12265
- </head>`);if(/<head\b[^>]*>/i.test(p))return p.replace(/(<head\b[^>]*>)/i,`$1
12266
- ${g}`);if(/<html\b[^>]*>/i.test(p))return p.replace(/(<html\b[^>]*>)/i,`$1
12264
+ Prefer signals (state/derived/effect) for new components.`)}Q=UZ(Q,Z),Q=await G1(Q,Z,Y),Q=Oz(Q),Q=Lz(Q),Q=EJ(Q);let{processXElementDirectives:x}=await Promise.resolve().then(() => Sq);Q=x(Q);let y=Z.__originalFilePath||Y,b=N$(Z);if(Q=await B9(Q,G,y,b),Q=await s2(Q,Z,Y,G),G.media?.image?.autoSiblings){let m=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (kY(),XK));Q=await g(Q,{publicDir:m})}if(G.seo?.enabled)Q=_J(Q,Z,G);let f=(m,g)=>{if(!g)return m;if(/<\/head>/i.test(m))return m.replace(/<\/head>/i,`${g}
12265
+ </head>`);if(/<head\b[^>]*>/i.test(m))return m.replace(/(<head\b[^>]*>)/i,`$1
12266
+ ${g}`);if(/<html\b[^>]*>/i.test(m))return m.replace(/(<html\b[^>]*>)/i,`$1
12267
12267
  <head>
12268
12268
  ${g}
12269
- </head>`);return p},{renderHead:r,getHead:u}=await Promise.resolve().then(() => (f$(),v8)),C=Z.__stx_runtime_head,h=C&&(C.title||C.meta?.length||C.link?.length)?C:u();if(h.title||h.meta?.length||h.link?.length){let p=r(h);if(p)Q=f(Q,p)}if(S.headContent)Q=f(Q,S.headContent);if(G.csp?.enabled&&G.csp.addMetaTag)Q=iJ(Q,G.csp,Z);if(G.analytics?.enabled)Q=SJ(Q,G);if(G.heatmap?.enabled)Q=XX(Q,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:p}=await Promise.resolve().then(() => (Pq(),yq));Q=p(Q,G)}let m=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(Q),i=/\bSTX\.\w+/.test(Q),s=/window\.STX\s*=/.test(Q);if(m&&i&&!s){let g=`<script data-stx-scoped>
12269
+ </head>`);return m},{renderHead:r,getHead:u}=await Promise.resolve().then(() => (f$(),v8)),C=Z.__stx_runtime_head,h=C&&(C.title||C.meta?.length||C.link?.length)?C:u();if(h.title||h.meta?.length||h.link?.length){let m=r(h);if(m)Q=f(Q,m)}if(S.headContent)Q=f(Q,S.headContent);if(G.csp?.enabled&&G.csp.addMetaTag)Q=iJ(Q,G.csp,Z);if(G.analytics?.enabled)Q=SJ(Q,G);if(G.heatmap?.enabled)Q=XX(Q,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:m}=await Promise.resolve().then(() => (Pq(),yq));Q=m(Q,G)}let p=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(Q),i=/\bSTX\.\w+/.test(Q),s=/window\.STX\s*=/.test(Q);if(p&&i&&!s){let g=`<script data-stx-scoped>
12270
12270
  ${wU()}
12271
12271
  </script>`;if(Q.includes("</head>")){let c=Q.indexOf("</head>"),l=Q.slice(0,c).indexOf("<script");if(l!==-1){let Q0=Q.slice(0,l),M0=Q.slice(l);Q=Q0+g+`
12272
12272
  `+M0}else Q=Q.replace("</head>",`${g}
12273
12273
  </head>`)}else if(Q.includes("<body"))Q=Q.replace(/<body([^>]*)>/,`<body$1>
12274
12274
  ${g}`);else Q=g+`
12275
- `+Q}{let p=/<script\s+server\b[^>]*>/gi,g,c=[];while((g=p.exec(Q))!==null){let a=g.index+g[0].length,l=aT(Q,a);if(l===-1)continue;let Q0=l+9;while(Q0<Q.length&&/\s/.test(Q[Q0]))Q0++;c.push({start:g.index,end:Q0})}for(let a=c.length-1;a>=0;a--){let{start:l,end:Q0}=c[a];Q=Q.substring(0,l)+Q.substring(Q0)}}let K0=Y6(Q,Y);if(K0.hasScoped)Q=K0.html;let $0=Z.__stx_event_bindings||[],F0=!1,R0=[],x=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:d}=await Promise.resolve().then(() => (_9(),Bz));for(let p of d(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))R0.push({match:p.fullMatch,attrs:p.attrs,content:p.body});for(let{match:p,attrs:g,content:c}of R0){F0=!0;let a=c;j6(c,Y,X.strict);let l=await A$(c,{eventBindings:$0,attrs:g,hasColonDirectives:x,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:b});Q=Q.replace(p,()=>l)}if(F0)Z.__stx_event_bindings=[];return Q}var M5="<!--PARENT_CONTENT_PLACEHOLDER-->";var O1=D(()=>{c1();S3();x3();RU();DJ();bJ();u3();d3();yJ();B5();gU();w7();b8();sJ();YB();aJ();j1();f$();c0();$2();G2();S7();S_();QZ();m3();r2();z5();y_();F8();N0();x_();o2();t2();$9();_Z();_9();g2();jz();q9();j9();d0();z2();q9();j9()});function gq($){let Z=[],Y=[];return KI($,Z),WI($,Z,Y),UI($,Y),BI($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function KI($,Z){let Y=($.match(/\{\{/g)||[]).length,X=($.match(/\}\}/g)||[]).length;if(Y!==X)Z.push({type:"expression",message:`Unclosed expression brackets: found ${Y} opening '{{' and ${X} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function WI($,Z,Y){for(let X of JI){let J=new RegExp(`${X.open}(?:\\s|\\()`,"g"),Q=new RegExp(X.close,"g"),G=($.match(J)||[]).length,K=($.match(Q)||[]).length;if(X.altClose){let W=new RegExp(X.altClose,"g");K+=($.match(W)||[]).length}if(G>K)Z.push({type:"directive",message:`Unclosed @${X.name} directive: found ${G} opening and ${K} closing`,suggestion:`Add ${G-K} missing ${X.close} tag(s)`});else if(K>G)Y.push({type:"directive",message:`Extra ${X.close} found: ${K-G} more closing than opening`,suggestion:`Check for orphaned ${X.close} tags`})}}function UI($,Z){for(let Y of QI)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function BI($,Z){for(let Y of GI)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function hq($,Z){let Y=$.slice(0,Z).split(`
12275
+ `+Q}{let m=/<script\s+server\b[^>]*>/gi,g,c=[];while((g=m.exec(Q))!==null){let a=g.index+g[0].length,l=aT(Q,a);if(l===-1)continue;let Q0=l+9;while(Q0<Q.length&&/\s/.test(Q[Q0]))Q0++;c.push({start:g.index,end:Q0}),m.lastIndex=Q0}for(let a=c.length-1;a>=0;a--){let{start:l,end:Q0}=c[a];Q=Q.substring(0,l)+Q.substring(Q0)}}let K0=Y6(Q,Y);if(K0.hasScoped)Q=K0.html;let $0=Z.__stx_event_bindings||[],F0=!1,R0=[],P=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:d}=await Promise.resolve().then(() => (_9(),Bz));for(let m of d(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))R0.push({match:m.fullMatch,attrs:m.attrs,content:m.body});for(let{match:m,attrs:g,content:c}of R0){F0=!0;let a=c;j6(c,Y,X.strict);let l=await A$(c,{eventBindings:$0,attrs:g,hasColonDirectives:P,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:b});Q=Q.replace(m,()=>l)}if(F0)Z.__stx_event_bindings=[];return Q}var M5="<!--PARENT_CONTENT_PLACEHOLDER-->";var O1=D(()=>{c1();S3();x3();RU();DJ();bJ();u3();d3();yJ();B5();gU();w7();b8();sJ();YB();aJ();j1();f$();c0();$2();G2();S7();S_();QZ();m3();r2();z5();y_();F8();N0();x_();o2();t2();$9();_Z();_9();g2();jz();q9();j9();d0();z2();q9();j9()});function gq($){let Z=[],Y=[];return KI($,Z),WI($,Z,Y),UI($,Y),BI($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function KI($,Z){let Y=($.match(/\{\{/g)||[]).length,X=($.match(/\}\}/g)||[]).length;if(Y!==X)Z.push({type:"expression",message:`Unclosed expression brackets: found ${Y} opening '{{' and ${X} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function WI($,Z,Y){for(let X of JI){let J=new RegExp(`${X.open}(?:\\s|\\()`,"g"),Q=new RegExp(X.close,"g"),G=($.match(J)||[]).length,K=($.match(Q)||[]).length;if(X.altClose){let W=new RegExp(X.altClose,"g");K+=($.match(W)||[]).length}if(G>K)Z.push({type:"directive",message:`Unclosed @${X.name} directive: found ${G} opening and ${K} closing`,suggestion:`Add ${G-K} missing ${X.close} tag(s)`});else if(K>G)Y.push({type:"directive",message:`Extra ${X.close} found: ${K-G} more closing than opening`,suggestion:`Check for orphaned ${X.close} tags`})}}function UI($,Z){for(let Y of QI)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function BI($,Z){for(let Y of GI)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function hq($,Z){let Y=$.slice(0,Z).split(`
12276
12276
  `);return{line:Y.length,column:Y[Y.length-1].length+1}}function dq($,Z,Y){let X=[];switch($){case"if":case"elseif":case"unless":if(Y.length===0)X.push({type:"syntax",message:`@${$} requires a condition`,suggestion:`Use @${$}(condition)`});break;case"foreach":if(Y.length===0||!Y[0].includes(" as "))X.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(Y.length===0)X.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(Y.length===0)X.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(Y.length===0)X.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(Y.length===0)X.push({type:"syntax",message:`@${$} requires a path`,suggestion:`Use @${$}('path/to/template')`});break}return X}function uq($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function mq($){let Z=$.matchAll(/@([a-z]+)/gi),Y=new Set;for(let X of Z){let J=X[1].toLowerCase();if(!J.startsWith("end"))Y.add(J)}return Array.from(Y)}var JI,QI,GI;var pq=D(()=>{JI=[{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"}],QI=[{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')"}],GI=[{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 sq={};Z0(sq,{renderSlot:()=>f9,processSlots:()=>g9,parseSlots:()=>v9,parseSlotElement:()=>cq,extractSlotContent:()=>iq,applySlots:()=>nq});function _I($,Z){let Y=1,X=Z,J="<template",Q="</template";while(X<$.length&&Y>0){let G=$.indexOf("<",X);if(G===-1)break;if(X=G,$.startsWith(J,X)&&(X+J.length>=$.length||/[\s>\/]/.test($[X+J.length]))){Y++,X+=J.length;continue}if($.startsWith(Q,X)){let K=$.indexOf(">",X+Q.length);if(K!==-1){if(Y--,Y===0)return K+1;X=K+1;continue}}X++}return Y===0?X:-1}function v9($){let Z={default:"",named:new Map},Y=$,X=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,J=[],Q;while((Q=X.exec($))!==null){let[B,_,z,q,j]=Q,H=_||z||q,O=Q.index+B.length,F=_I($,O);if(F!==-1){let L=$.slice(O,F-11).trim();J.push({start:Q.index,end:F,slotName:H,content:L,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:L,propsBinding:j||void 0})}}J.sort((B,_)=>_.start-B.start);for(let B of J)Y=Y.slice(0,B.start)+Y.slice(B.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,W;while((W=K.exec(Y))!==null){let[B,_,z,q,j,H]=W,O=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=(O+F).trim(),V=`<${_}${L?" "+L:""}>${H}</${_}>`;G.push({start:W.index,end:W.index+B.length,slotName:q,element:V})}let U=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((W=U.exec(Y))!==null){let[B,_,z,q,j]=W,H=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+O).trim(),L=`<${_}${F?" "+F:""} />`;G.push({start:W.index,end:W.index+B.length,slotName:q,element:L})}G.sort((B,_)=>_.start-B.start);for(let B of G){let _=Z.named.get(B.slotName);if(_)_.content+=B.element;else Z.named.set(B.slotName,{name:B.slotName,content:B.element});Y=Y.slice(0,B.start)+Y.slice(B.end)}return Z.default=Y.trim(),Z}function cq($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",X={},J=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,Q;while((Q=J.exec($))!==null)X[Q[1]]=Q[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:X,defaultContent:K}}async function f9($,Z,Y,X){if(!$)return Y;let J=$.content;if($.propsBinding&&Object.keys(Z).length>0){let Q=$.propsBinding.trim(),G={...X};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,B]=W.split(":").map((z)=>z.trim()),_=B||U;if(Z[U]!==void 0)G[_]=Z[U]}}else G[Q]=Z;J=zI(J,G)}return J}function zI($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let J=X.trim(),Q=lq(J,Z);return E0(String(Q??""))}catch{return`{{ ${X} }}`}})}function lq($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let X=$.split("."),J=Z;for(let Q of X)if(J&&typeof J==="object"&&Q in J)J=J[Q];else return;return J}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,X,J,Q]=Y,G=Z[X],K=parseInt(Q,10);if(typeof G==="number")switch(J){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!H0($))return;return O0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function g9($,Z,Y){let X=$;X=await qI(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,W,U)=>{let B=Z.named.get(K),_=U?.trim()||"",z=W||"",q={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(z))!==null){let O=H[1],F=H[2];q[O]=lq(F,Y)}return await f9(B,q,_,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(Q,(G,K)=>{if(G.includes("name="))return G;let W=K?.trim()||"";return Z.default||W}),X}async function qI($,Z,Y){let X=[],J=[];$.replace(Z,(K,...W)=>{let U=W[W.length-2];return J.push({match:K,index:U}),X.push(Y(K,...W.slice(0,-2))),K});let Q=await Promise.all(X),G=$;for(let K=J.length-1;K>=0;K--){let{match:W,index:U}=J[K];G=G.slice(0,U)+Q[K]+G.slice(U+W.length)}return G}function iq($){let Z=v9($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function nq($,Z,Y,X){return await g9($,{default:Z,named:Y},X)}var h9=D(()=>{c0();d0()});import jI from"fs";import o from"path";function rq($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function oq($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function w$($){return!oq($)}function R$($){try{let Z=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Z=Z.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let Y=[];Z=Z.replace(/\{!![\s\S]*?!!\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`});let J=new Bun.Transpiler({loader:"ts",target:"browser",define:M1()}).transformSync(Z);for(let Q=0;Q<Y.length;Q++)J=J.replace(`"__STX_EXPR_${Q}__"`,Y[Q]),J=J.replace(`'__STX_EXPR_${Q}__'`,Y[Q]);return J}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function OI($){let Z=[],Y=new Set,X=0,J=0,Q=$.length,G=(B)=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]===B){J++;return}J++}},K=()=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]==="`"){J++;return}if($[J]==="$"&&$[J+1]==="{"){J+=2;let B=1;while(J<Q&&B>0)if($[J]==="{")B++,J++;else if($[J]==="}")B--,J++;else if($[J]==="'"||$[J]==='"')G($[J]);else if($[J]==="`")K();else J++;continue}J++}},W=()=>{if($[J]==="/"&&$[J+1]==="/"){while(J<Q&&$[J]!==`
12277
- `)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},U=()=>{if(X!==0)return;let B=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(B){let j=B[2].split(",").map((H)=>{let O=H.trim().split(":");return O[O.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let _=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(_){let j=_[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let z=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(z){let j=z[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let q=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let j=q[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(W())continue;if($[J]==="'"||$[J]==='"'){G($[J]);continue}if($[J]==="`"){K();continue}if($[J]==="{"){X++,J++;continue}if($[J]==="}"){X--,J++;continue}if(X===0&&/[a-z]/i.test($[J])&&(J===0||/\s|[;{}()]/.test($[J-1])))U();J++}return Z}function LI($){let Z=[],Y=0,X=0,J=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(J){if(G==="\\"){Q++;continue}if(G===J)J=null;continue}if(G==='"'||G==="'"||G==="`"){J=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(X,Q)),X=Q+1}if(X<$.length)Z.push($.slice(X));return Z}function FI($){let Z=0,Y=null;for(let X=0;X<$.length;X++){let J=$[X];if(Y){if(J==="\\"){X++;continue}if(J===Y)Y=null;continue}if(J==='"'||J==="'"||J==="`"){Y=J;continue}if(J==="("||J==="["||J==="{")Z++;else if(J===")"||J==="]"||J==="}")Z--;else if(J==="="&&Z===0){let Q=$[X-1],G=$[X+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return X}}return-1}function VI($,Z){try{let Y=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Y)return;let X=Y.index-1;while(X>=0&&/\s/.test($[X]))X--;if($[X]!=="}")return;let J=X,Q=0,G=-1;for(;X>=0;X--){let W=$[X];if(W==="}")Q++;else if(W==="{"){if(Q--,Q===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,J);for(let W of LI(K)){let U=W.trim();if(!U||U.startsWith("..."))continue;let B=FI(U);if(B===-1)continue;let _=U.slice(0,B).trim();if(!/^[A-Z_$][\w$]*$/i.test(_))continue;if(Z[_]!==void 0)continue;let z=U.slice(B+1).trim();if(!z)continue;try{let q=Object.keys(Z),j=Function(...q,`"use strict"; return (${z});`);Z[_]=j(...q.map((H)=>Z[H]))}catch{}}}catch{}}async function h2($,Z,Y,X,J){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(O)=>O.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""),K=(O)=>O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),W=Y.__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`])],B=typeof J.root==="string"?o.resolve(J.root):void 0,_=B??o.dirname(X),z=[],q=(O)=>{if(O&&!z.includes(O))z.push(O)},j=Y.__originalFilePath;if(j)q(o.join(o.dirname(j),"components"));q(Z),q(o.join(o.dirname(X),"components")),q(J.componentsDir);let H=J._pluginComponentDirs;if(Array.isArray(H))for(let O of H)q(typeof O==="string"?O:null);if(B)q(o.resolve(B,"resources/views/components")),q(o.resolve(B,"resources/components")),q(o.resolve(B,"src/components")),q(o.resolve(B,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return t(o.resolve(o.dirname(X),`${Q}.stx`));for(let O of z){let F=o.isAbsolute(O)?O:o.resolve(_,O);for(let L of U)if(await t(o.join(F,L)))return!0}return!1}function aq($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function l1($,Z,Y,X,J,Q,G,K=new Set,W){let{extractVariables:U}=await Promise.resolve().then(() => (p$(),$Z)),B=K??new Set;if(B.has($))return`[Circular component reference: ${$}]`;let _=new Set(B);_.add($);let z=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let q=z&&z!=="load"&&aq(z)?z:"";try{let j=(x)=>x.split("-").map((d)=>d.charAt(0).toUpperCase()+d.slice(1)).join(""),H=(x)=>x.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),O=$.endsWith(".stx")?$.slice(0,-4):$,F=null,L=J.__importedComponents;if(L){let x=[O,O.toLowerCase(),j(O),H(O)];for(let d of x)if(L.has(d)){F=L.get(d);break}}let V=[];if(!F){let x=[`${O}.stx`,`${j(O)}.stx`,`${H(O)}.stx`],d=[...new Set(x)],p=J.__originalFilePath,g=[];if(p){let W0=o.join(o.dirname(p),"components");g.push(W0)}if(X)g.push(X);let c=o.join(o.dirname(Q),"components");if(!g.includes(c))g.push(c);if(G.componentsDir&&G.componentsDir!==X&&!g.includes(G.componentsDir))g.push(G.componentsDir);let a=G._pluginComponentDirs;if(Array.isArray(a)){for(let W0 of a)if(typeof W0==="string"&&!g.includes(W0))g.push(W0)}let l=typeof G.root==="string"?o.resolve(G.root):void 0,Q0=l??o.dirname(Q),M0=[];if(l)M0.push(o.resolve(l,"resources/views/components")),M0.push(o.resolve(l,"resources/components")),M0.push(o.resolve(l,"src/components")),M0.push(o.resolve(l,"components"));M0.push(o.resolve(import.meta.dir,"components"));for(let W0 of M0)if(!g.includes(W0))g.push(W0);let w0=[...new Set(g.map((W0)=>{if(!W0)return W0;return o.isAbsolute(W0)?W0:o.resolve(Q0,W0)}))];if(g.length=0,g.push(...w0),O.startsWith("./")||O.startsWith("../"))F=o.resolve(o.dirname(Q),`${O}.stx`),V.push(F);else for(let W0 of g){if(!W0)continue;for(let r0 of d){let p0=o.join(W0,r0);if(V.push(p0),await t(p0)){F=p0;break}}if(F)break;if(!F)try{let r0=await import("fs");if(!r0.statSync(W0,{throwIfNoEntry:!1})?.isDirectory())continue;let P5=8,G0=[{path:W0,depth:0}];while(G0.length>0&&!F){let k0=G0.pop();if(k0.depth>=P5)continue;let Q4;try{Q4=r0.readdirSync(k0.path,{withFileTypes:!0})}catch{continue}for(let E1 of Q4){if(!E1.isDirectory())continue;if(E1.name==="node_modules"||E1.name.startsWith("."))continue;let O$=o.join(k0.path,E1.name);for(let V0 of d){let $1=o.join(O$,V0);if(V.push($1),await t($1)){F=$1;break}}if(F)break;G0.push({path:O$,depth:k0.depth+1})}}}catch{}if(F)break}}if(!F||!await t(F)){let x=V.length>0?`
12277
+ `)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},U=()=>{if(X!==0)return;let B=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(B){let j=B[2].split(",").map((H)=>{let O=H.trim().split(":");return O[O.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let _=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(_){let j=_[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let z=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(z){let j=z[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let q=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let j=q[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(W())continue;if($[J]==="'"||$[J]==='"'){G($[J]);continue}if($[J]==="`"){K();continue}if($[J]==="{"){X++,J++;continue}if($[J]==="}"){X--,J++;continue}if(X===0&&/[a-z]/i.test($[J])&&(J===0||/\s|[;{}()]/.test($[J-1])))U();J++}return Z}function LI($){let Z=[],Y=0,X=0,J=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(J){if(G==="\\"){Q++;continue}if(G===J)J=null;continue}if(G==='"'||G==="'"||G==="`"){J=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(X,Q)),X=Q+1}if(X<$.length)Z.push($.slice(X));return Z}function FI($){let Z=0,Y=null;for(let X=0;X<$.length;X++){let J=$[X];if(Y){if(J==="\\"){X++;continue}if(J===Y)Y=null;continue}if(J==='"'||J==="'"||J==="`"){Y=J;continue}if(J==="("||J==="["||J==="{")Z++;else if(J===")"||J==="]"||J==="}")Z--;else if(J==="="&&Z===0){let Q=$[X-1],G=$[X+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return X}}return-1}function VI($,Z){try{let Y=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Y)return;let X=Y.index-1;while(X>=0&&/\s/.test($[X]))X--;if($[X]!=="}")return;let J=X,Q=0,G=-1;for(;X>=0;X--){let W=$[X];if(W==="}")Q++;else if(W==="{"){if(Q--,Q===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,J);for(let W of LI(K)){let U=W.trim();if(!U||U.startsWith("..."))continue;let B=FI(U);if(B===-1)continue;let _=U.slice(0,B).trim();if(!/^[A-Z_$][\w$]*$/i.test(_))continue;if(Z[_]!==void 0)continue;let z=U.slice(B+1).trim();if(!z)continue;try{let q=Object.keys(Z),j=Function(...q,`"use strict"; return (${z});`);Z[_]=j(...q.map((H)=>Z[H]))}catch{}}}catch{}}async function h2($,Z,Y,X,J){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(O)=>O.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""),K=(O)=>O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),W=Y.__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`])],B=typeof J.root==="string"?o.resolve(J.root):void 0,_=B??o.dirname(X),z=[],q=(O)=>{if(O&&!z.includes(O))z.push(O)},j=Y.__originalFilePath;if(j)q(o.join(o.dirname(j),"components"));q(Z),q(o.join(o.dirname(X),"components")),q(J.componentsDir);let H=J._pluginComponentDirs;if(Array.isArray(H))for(let O of H)q(typeof O==="string"?O:null);if(B)q(o.resolve(B,"resources/views/components")),q(o.resolve(B,"resources/components")),q(o.resolve(B,"src/components")),q(o.resolve(B,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return t(o.resolve(o.dirname(X),`${Q}.stx`));for(let O of z){let F=o.isAbsolute(O)?O:o.resolve(_,O);for(let L of U)if(await t(o.join(F,L)))return!0}return!1}function aq($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function l1($,Z,Y,X,J,Q,G,K=new Set,W){let{extractVariables:U}=await Promise.resolve().then(() => (p$(),$Z)),B=K??new Set;if(B.has($))return`[Circular component reference: ${$}]`;let _=new Set(B);_.add($);let z=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let q=z&&z!=="load"&&aq(z)?z:"";try{let j=(P)=>P.split("-").map((d)=>d.charAt(0).toUpperCase()+d.slice(1)).join(""),H=(P)=>P.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),O=$.endsWith(".stx")?$.slice(0,-4):$,F=null,L=J.__importedComponents;if(L){let P=[O,O.toLowerCase(),j(O),H(O)];for(let d of P)if(L.has(d)){F=L.get(d);break}}let V=[];if(!F){let P=[`${O}.stx`,`${j(O)}.stx`,`${H(O)}.stx`],d=[...new Set(P)],m=J.__originalFilePath,g=[];if(m){let W0=o.join(o.dirname(m),"components");g.push(W0)}if(X)g.push(X);let c=o.join(o.dirname(Q),"components");if(!g.includes(c))g.push(c);if(G.componentsDir&&G.componentsDir!==X&&!g.includes(G.componentsDir))g.push(G.componentsDir);let a=G._pluginComponentDirs;if(Array.isArray(a)){for(let W0 of a)if(typeof W0==="string"&&!g.includes(W0))g.push(W0)}let l=typeof G.root==="string"?o.resolve(G.root):void 0,Q0=l??o.dirname(Q),M0=[];if(l)M0.push(o.resolve(l,"resources/views/components")),M0.push(o.resolve(l,"resources/components")),M0.push(o.resolve(l,"src/components")),M0.push(o.resolve(l,"components"));M0.push(o.resolve(import.meta.dir,"components"));for(let W0 of M0)if(!g.includes(W0))g.push(W0);let w0=[...new Set(g.map((W0)=>{if(!W0)return W0;return o.isAbsolute(W0)?W0:o.resolve(Q0,W0)}))];if(g.length=0,g.push(...w0),O.startsWith("./")||O.startsWith("../"))F=o.resolve(o.dirname(Q),`${O}.stx`),V.push(F);else for(let W0 of g){if(!W0)continue;for(let r0 of d){let p0=o.join(W0,r0);if(V.push(p0),await t(p0)){F=p0;break}}if(F)break;if(!F)try{let r0=await import("fs");if(!r0.statSync(W0,{throwIfNoEntry:!1})?.isDirectory())continue;let P5=8,G0=[{path:W0,depth:0}];while(G0.length>0&&!F){let k0=G0.pop();if(k0.depth>=P5)continue;let Q4;try{Q4=r0.readdirSync(k0.path,{withFileTypes:!0})}catch{continue}for(let E1 of Q4){if(!E1.isDirectory())continue;if(E1.name==="node_modules"||E1.name.startsWith("."))continue;let O$=o.join(k0.path,E1.name);for(let V0 of d){let $1=o.join(O$,V0);if(V.push($1),await t($1)){F=$1;break}}if(F)break;G0.push({path:O$,depth:k0.depth+1})}}}catch{}if(F)break}}if(!F||!await t(F)){let P=V.length>0?`
12278
12278
  Searched paths:
12279
12279
  ${V.map((d)=>` - ${d}`).join(`
12280
- `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${x}`}W.add(F);let N;if(L6.has(F))N=L6.get(F);else try{N=await Bun.file(F).text(),L6.set(F,N)}catch(x){return`[Error loading component: ${x instanceof Error?x.message:String(x)}]`}let A=new Set(["__originalFilePath","__importedComponents"]),w={};for(let[x,d]of Object.entries(J))if(!x.startsWith("__")||A.has(x))w[x]=d;let R={...w,...Z,props:Z,slot:Y,__processedComponents:_,__sections:{}};VI(N,R);let T=N,I=T.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(I)T=I[1].trim();let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k=[...N.matchAll(E)],S=[];for(let x of k){let d=x[1]||"",p=x[2]||"",g=d.includes("server");if(w$(d)&&p.trim())p=R$(p);if(g&&p)try{await U(p,R,F)}catch(a){}if(!g){let a=p.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(a.includes("{{")&&a.includes("}}"))a=G1(a,R,F);let l=d.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");S.push(`<script${l}>${a}</script>`)}}let P=N.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),y=P?P[1]:"",b=P?P[2]:"",f="",r=y&&/\bscoped\b/i.test(y);if(P)f=`<style${y}>${b}</style>`;let u=T;if(u=u.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),P)u=u.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let x=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,d=[];if(u=u.replace(x,(p,g)=>{let c=g.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(c)d.push(`<style${c[1]}>${c[2]}</style>`);return""}),u=u.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),d.length>0)f=`${f}${d.join(`
12281
- `)}`}if(Y&&u.includes("{{ text || slot }}"))u=u.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:C,applySlots:h}=await Promise.resolve().then(() => (h9(),sq)),{defaultSlot:m,namedSlots:i}=C(Y);u=await h(u,m||Y,i,R);for(let[x,d]of Object.entries(R))if(typeof d==="string"){if(d.includes("<")&&d.includes(">")||d.includes("&lt;")||d.includes("&quot;")){let p=b3(d);R[x]=p}}let s=S.some((x)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(x)),K0={...G,componentsDir:o.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:s,defaultLayout:void 0};R.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let $0=await X0(u,R,F,K0,W),F0=`stx_${O.replace(/[^a-zA-Z0-9]/g,"_")}_${++HI}_${Math.random().toString(36).slice(2,8)}`,R0=$0;if(s){let x="";if(Object.keys(Z).length>0)try{x=` data-stx-props="${rq(JSON.stringify(Z))}"`}catch{}let d=q?` stx-hydrate="${rq(q)}"`:"";if(R0=`<div data-stx-scope="${F0}"${x}${d}>${$0}</div>`,R0=S.map((g)=>{let c=g.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!c)return g;let[,a,l]=c,Q0=Z$(l),M0=`
12280
+ `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${P}`}W.add(F);let N;if(L6.has(F))N=L6.get(F);else try{N=await Bun.file(F).text(),L6.set(F,N)}catch(P){return`[Error loading component: ${P instanceof Error?P.message:String(P)}]`}let A=new Set(["__originalFilePath","__importedComponents"]),w={};for(let[P,d]of Object.entries(J))if(!P.startsWith("__")||A.has(P))w[P]=d;let R={...w,...Z,props:Z,slot:Y,__processedComponents:_,__sections:{}};VI(N,R);let T=N,I=T.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(I)T=I[1].trim();let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k=[...N.matchAll(E)],S=[];for(let P of k){let d=P[1]||"",m=P[2]||"",g=d.includes("server");if(w$(d)&&m.trim())m=R$(m);if(g&&m)try{await U(m,R,F)}catch(a){}if(!g){let a=m.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(a.includes("{{")&&a.includes("}}"))a=G1(a,R,F);let l=d.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");S.push(`<script${l}>${a}</script>`)}}let x=N.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),y=x?x[1]:"",b=x?x[2]:"",f="",r=y&&/\bscoped\b/i.test(y);if(x)f=`<style${y}>${b}</style>`;let u=T;if(u=u.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),x)u=u.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let P=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,d=[];if(u=u.replace(P,(m,g)=>{let c=g.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(c)d.push(`<style${c[1]}>${c[2]}</style>`);return""}),u=u.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),d.length>0)f=`${f}${d.join(`
12281
+ `)}`}if(Y&&u.includes("{{ text || slot }}"))u=u.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:C,applySlots:h}=await Promise.resolve().then(() => (h9(),sq)),{defaultSlot:p,namedSlots:i}=C(Y);u=await h(u,p||Y,i,R);for(let[P,d]of Object.entries(R))if(typeof d==="string"){if(d.includes("<")&&d.includes(">")||d.includes("&lt;")||d.includes("&quot;")){let m=b3(d);R[P]=m}}let s=S.some((P)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(P)),K0={...G,componentsDir:o.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:s,defaultLayout:void 0};R.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let $0=await X0(u,R,F,K0,W),F0=`stx_${O.replace(/[^a-zA-Z0-9]/g,"_")}_${++HI}_${Math.random().toString(36).slice(2,8)}`,R0=$0;if(s){let P="";if(Object.keys(Z).length>0)try{P=` data-stx-props="${rq(JSON.stringify(Z))}"`}catch{}let d=q?` stx-hydrate="${rq(q)}"`:"";if(R0=`<div data-stx-scope="${F0}"${P}${d}>${$0}</div>`,R0=S.map((g)=>{let c=g.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!c)return g;let[,a,l]=c,Q0=Z$(l),M0=`
12282
12282
  (function() {
12283
12283
  const { state, derived, effect, batch, defineEmits, defineExpose, defineSlots, defineProps, withDefaults, useStore, useFetch, useRef, useQuery, useMutation, useOptimistic, useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout, useToggle, useCounter, useClickOutside, useFocus, useAsync, useLocalStorage, useSessionStorage, useCookie, useReactiveProp, useEventListener, useWebSocket, useColorMode, useDark, useHead, useSeoMeta, definePageMeta, useRoute, useSearchParams, navigate, goBack, goForward, provide, inject, ref, reactive, computed, watch, watchEffect, nextTick } = window.stx;
12284
12284
  const __scope = window.stx._scopes = window.stx._scopes || {};
@@ -12304,9 +12304,9 @@ catch (e) {}
12304
12304
  `)+`
12305
12305
  `+R0,f)R0+=`
12306
12306
  `+f}else{if(f)R0+=`
12307
- `+f;if(S.length>0){let x=R.__stx_event_bindings||[],d=N$(R),p=await Promise.all(S.map(async(g)=>{let c=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!c)return g;return await A$(c[1],{eventBindings:x,templateContent:R0,filePath:F,projectRoot:process.cwd(),serverData:d})}));R0+=`
12308
- `+p.join(`
12309
- `),R.__stx_event_bindings=[]}}if(r){let x=Y6(R0,F);if(x.hasScoped)R0=x.html}return R0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{B.delete($)}}async function t($){return Bun.file($).exists()}function d9($,Z){let Y=o.resolve(Z),X=o.resolve($),J=Y.endsWith(o.sep)?Y:Y+o.sep;if(X===Y||X.startsWith(J))return X;return null}async function u4($,Z,Y,X){let J=await NI($,Z,Y,X);if(J===null)return null;let Q=d9(J,process.cwd());if(Q)return Q;let G=[Y.root,Y.layoutsDir,Y.componentsDir,Y.partialsDir,Y.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let W=o.isAbsolute(K)?K:o.resolve(process.cwd(),K);if(d9(J,W))return o.resolve(J)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${$}, from: ${Z})`),null}async function NI($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let J=o.dirname(Z),Q=process.cwd();if($.startsWith("/")){let z=o.join(Q,$),q=d9(z,Q);if(!q)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${q}`);if(await t(q)&&X)X.add(q);return q}let G=o.join(J,$);if(await t(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(X)X.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let z of[".stx",".tsx",".jsx"]){let q=`${G}${z}`;if(await t(q)){if(Y.debug)console.log(`Found direct path with extension: ${q}`);if(X)X.add(q);return q}}let K="",W=o.resolve(J),U=process.cwd();for(let z=0;z<10;z++){let q=o.join(W,"layouts"),j=!1;try{j=jI.statSync(q,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=q;break}let H=o.dirname(W);if(H===W||H.length<U.length)break;W=H}if(K){let z=$.startsWith("layouts/")?$.slice(8):$,q=o.join(K,z);if(await t(q)){if(Y.debug)console.log(`Found in current layouts dir: ${q}`);if(X)X.add(q);return q}if(!z.endsWith(".stx")){let j=`${q}.stx`;if(await t(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.layoutsDir){let z=o.isAbsolute(Y.layoutsDir)?Y.layoutsDir:o.resolve(process.cwd(),Y.layoutsDir),q=$.startsWith("layouts/")?$.slice(8):$,j=o.join(z,q);if(await t(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(X)X.add(j);return j}if(!$.endsWith(".stx")){let H=`${j}.stx`;if(await t(H)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(X)X.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let z=$.split("layouts/"),q=o.join(Y.partialsDir||J,"layouts",z[1]);if(await t(q)){if(Y.debug)console.log(`Found in layouts path: ${q}`);if(X)X.add(q);return q}if(!q.endsWith(".stx")){let j=`${q}.stx`;if(await t(j)){if(Y.debug)console.log(`Found in layouts path with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.partialsDir){if(K=o.join(Y.partialsDir,"layouts"),await t(K)){let z=o.join(K,$);if(await t(z)){if(Y.debug)console.log(`Found in partials layouts dir: ${z}`);if(X)X.add(z);return z}if(!$.endsWith(".stx")){let q=`${z}.stx`;if(await t(q)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}}let B=Y.partialsDir||o.join(process.cwd(),"views"),_=o.join(B,$);if(await t(_)){if(Y.debug)console.log(`Found in views path: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let z=`${_}.stx`;if(await t(z)){if(Y.debug)console.log(`Found in views path with extension: ${z}`);if(X)X.add(z);return z}}if(J.includes("temp")){let z=o.join(o.dirname(J),"layouts",$);if(await t(z)){if(Y.debug)console.log(`Found in temp layouts dir: ${z}`);if(X)X.add(z);return z}if(!$.endsWith(".stx")){let q=`${z}.stx`;if(await t(q)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}if(Y.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function u9($,Z,Y){let X=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
12307
+ `+f;if(S.length>0){let P=R.__stx_event_bindings||[],d=N$(R),m=await Promise.all(S.map(async(g)=>{let c=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!c)return g;return await A$(c[1],{eventBindings:P,templateContent:R0,filePath:F,projectRoot:process.cwd(),serverData:d})}));R0+=`
12308
+ `+m.join(`
12309
+ `),R.__stx_event_bindings=[]}}if(r){let P=Y6(R0,F);if(P.hasScoped)R0=P.html}return R0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{B.delete($)}}async function t($){return Bun.file($).exists()}function d9($,Z){let Y=o.resolve(Z),X=o.resolve($),J=Y.endsWith(o.sep)?Y:Y+o.sep;if(X===Y||X.startsWith(J))return X;return null}async function u4($,Z,Y,X){let J=await NI($,Z,Y,X);if(J===null)return null;let Q=d9(J,process.cwd());if(Q)return Q;let G=[Y.root,Y.layoutsDir,Y.componentsDir,Y.partialsDir,Y.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let W=o.isAbsolute(K)?K:o.resolve(process.cwd(),K);if(d9(J,W))return o.resolve(J)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${$}, from: ${Z})`),null}async function NI($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let J=o.dirname(Z),Q=process.cwd();if($.startsWith("/")){let z=o.join(Q,$),q=d9(z,Q);if(!q)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${q}`);if(await t(q)&&X)X.add(q);return q}let G=o.join(J,$);if(await t(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(X)X.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let z of[".stx",".tsx",".jsx"]){let q=`${G}${z}`;if(await t(q)){if(Y.debug)console.log(`Found direct path with extension: ${q}`);if(X)X.add(q);return q}}let K="",W=o.resolve(J),U=process.cwd();for(let z=0;z<10;z++){let q=o.join(W,"layouts"),j=!1;try{j=jI.statSync(q,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=q;break}let H=o.dirname(W);if(H===W||H.length<U.length)break;W=H}if(K){let z=$.startsWith("layouts/")?$.slice(8):$,q=o.join(K,z);if(await t(q)){if(Y.debug)console.log(`Found in current layouts dir: ${q}`);if(X)X.add(q);return q}if(!z.endsWith(".stx")){let j=`${q}.stx`;if(await t(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.layoutsDir){let z=o.isAbsolute(Y.layoutsDir)?Y.layoutsDir:o.resolve(process.cwd(),Y.layoutsDir),q=$.startsWith("layouts/")?$.slice(8):$,j=o.join(z,q);if(await t(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(X)X.add(j);return j}if(!$.endsWith(".stx")){let H=`${j}.stx`;if(await t(H)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(X)X.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let z=$.split("layouts/"),q=o.join(Y.partialsDir||J,"layouts",z[1]);if(await t(q)){if(Y.debug)console.log(`Found in layouts path: ${q}`);if(X)X.add(q);return q}if(!q.endsWith(".stx")){let j=`${q}.stx`;if(await t(j)){if(Y.debug)console.log(`Found in layouts path with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.partialsDir){if(K=o.join(Y.partialsDir,"layouts"),await t(K)){let z=o.join(K,$);if(await t(z)){if(Y.debug)console.log(`Found in partials layouts dir: ${z}`);if(X)X.add(z);return z}if(!$.endsWith(".stx")){let q=`${z}.stx`;if(await t(q)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}}let B=Y.partialsDir||o.join(process.cwd(),"views"),_=o.join(B,$);if(await t(_)){if(Y.debug)console.log(`Found in views path: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let z=`${_}.stx`;if(await t(z)){if(Y.debug)console.log(`Found in views path with extension: ${z}`);if(X)X.add(z);return z}}if(J.includes("temp")){let z=o.join(o.dirname(J),"layouts",$);if(await t(z)){if(Y.debug)console.log(`Found in temp layouts dir: ${z}`);if(X)X.add(z);return z}if(!$.endsWith(".stx")){let q=`${z}.stx`;if(await t(q)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}if(Y.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function u9($,Z,Y){let X=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
12310
12310
  `),K=0;for(let W=0;W<G.length;W++)if(K+=G[W].length+1,K>=Z){X=W+1,J=G[W].trim();let U=Math.max(0,W-2),B=Math.min(G.length,W+3);Q=G.slice(U,B).map((_,z)=>{let q=U+z+1;return`${q===X?"> ":" "}${q}: ${_}`}).join(`
12311
12311
  `);break}}else if(Y){let G=$.indexOf(Y);if(G>=0)return u9($,G)}}catch{}return{lineNumber:X,lineContent:J,context:Q}}function L0($,Z,Y,X,J,Q){let{lineNumber:G,context:K}=u9(X,J,Q),W=Y.split("/").pop(),U=0;if(typeof J==="number"&&J>=0&&X){let _=X.lastIndexOf(`
12312
12312
  `,Math.max(0,J-1));U=J-(_+1)+1}let B="";if(G>0)B+=`
@@ -12541,10 +12541,10 @@ ${$.map((X)=>{let J=new URL(X.loc,Z).href,Q=` <url>
12541
12541
  ${Y.join(`
12542
12542
  `)}
12543
12543
  </channel>
12544
- </rss>`}async function Oj($={}){let Z=Date.now(),Y=await x0(),X={pagesDir:$.pagesDir||"pages",outputDir:$.outputDir||"dist",baseUrl:$.baseUrl||"/",domain:$.domain||"http://localhost",revalidate:$.revalidate??!1,sitemap:$.sitemap??!0,rss:$.rss??!1,concurrency:$.concurrency||10,cache:$.cache??!0,cacheDir:$.cacheDir||".stx/ssg-cache",contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??!1,generate404:$.generate404??!0,publicDir:$.publicDir||"public",trailingSlash:$.trailingSlash??!1,cleanOutput:$.cleanOutput??!0,chunkIslands:$.chunkIslands===!0,prefetchIslands:$.prefetchIslands===!0,integrityIslands:$.integrityIslands===!0},J={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},Q=new Set,G=0,K={},W={};await X.hooks.onBuildStart?.();try{if(X.cleanOutput&&g0.existsSync(X.outputDir))await g0.promises.rm(X.outputDir,{recursive:!0});await g0.promises.mkdir(X.outputDir,{recursive:!0});let B=new qj(X.cacheDir);if(X.cache)await B.load();try{let{preloadIconCollection:V}=await Promise.resolve().then(() => (r8(),oB));await V("lucide")}catch{}try{let{generateCrosswindCSS:V}=await Promise.resolve().then(() => (c1(),T8));await V('<div class="bg-black"></div>')}catch{}F6();let _=Y?.routeMiddleware?.dir||"middleware";await w6(process.cwd(),_);let z=A6();if(z.length>0)console.log(`Loaded ${z.length} middleware: ${z.join(", ")}`);let q=Y?.routeMiddleware?.global||[],j=U$(".",{pagesDir:X.pagesDir});console.log(`Found ${j.length} routes`);let H=[];for(let V of j){let N=await RE(V);for(let A of N)H.push({route:V,url:A.url,params:A.params,props:A.props,revalidate:A.revalidate??X.revalidate})}J.totalPages=H.length,console.log(`Generating ${J.totalPages} pages...`);let O=[],F=[];for(let V=0;V<H.length;V+=X.concurrency)F.push(H.slice(V,V+X.concurrency));for(let V of F)await Promise.all(V.map(async(N)=>{let{route:A,url:w,params:R,props:T,revalidate:I}=N;try{await X.hooks.onPageStart?.(w);let E=await Bun.file(A.filePath).text(),k=SE(E),S=k?.middleware?Array.isArray(k.middleware)?k.middleware:[k.middleware]:[],P=[...q,...S];if(P.length>0){let C=N6(w,R,k||{}),h=V6(C,null),m=await R6(P,h);if(m.redirect){let i=typeof m.redirect==="string"?m.redirect:m.redirect.path||m.redirect,s=bE(String(i),w),K0=CE(w,X);await g0.promises.mkdir(j0.dirname(K0),{recursive:!0}),await Bun.write(K0,s),J.successCount++,J.pages.push({route:w,outputPath:K0,size:Buffer.byteLength(s),cached:!1}),O.push({loc:w,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${w} \u2192 redirect to ${i}`);return}if(m.abort){let i=typeof m.abort==="string"?m.abort:m.abort?.error?.message||"aborted";console.warn(` \u21B3 ${w} \u2014 middleware aborted: ${i}`);return}}let y=E.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(y)try{if(!await Function("route",`
12544
+ </rss>`}async function Oj($={}){let Z=Date.now(),Y=await x0(),X={pagesDir:$.pagesDir||"pages",outputDir:$.outputDir||"dist",baseUrl:$.baseUrl||"/",domain:$.domain||"http://localhost",revalidate:$.revalidate??!1,sitemap:$.sitemap??!0,rss:$.rss??!1,concurrency:$.concurrency||10,cache:$.cache??!0,cacheDir:$.cacheDir||".stx/ssg-cache",contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??!1,generate404:$.generate404??!0,publicDir:$.publicDir||"public",trailingSlash:$.trailingSlash??!1,cleanOutput:$.cleanOutput??!0,chunkIslands:$.chunkIslands===!0,prefetchIslands:$.prefetchIslands===!0,integrityIslands:$.integrityIslands===!0},J={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},Q=new Set,G=0,K={},W={};await X.hooks.onBuildStart?.();try{if(X.cleanOutput&&g0.existsSync(X.outputDir))await g0.promises.rm(X.outputDir,{recursive:!0});await g0.promises.mkdir(X.outputDir,{recursive:!0});let B=new qj(X.cacheDir);if(X.cache)await B.load();try{let{preloadIconCollection:V}=await Promise.resolve().then(() => (r8(),oB));await V("lucide")}catch{}try{let{generateCrosswindCSS:V}=await Promise.resolve().then(() => (c1(),T8));await V('<div class="bg-black"></div>')}catch{}F6();let _=Y?.routeMiddleware?.dir||"middleware";await w6(process.cwd(),_);let z=A6();if(z.length>0)console.log(`Loaded ${z.length} middleware: ${z.join(", ")}`);let q=Y?.routeMiddleware?.global||[],j=U$(".",{pagesDir:X.pagesDir});console.log(`Found ${j.length} routes`);let H=[];for(let V of j){let N=await RE(V);for(let A of N)H.push({route:V,url:A.url,params:A.params,props:A.props,revalidate:A.revalidate??X.revalidate})}J.totalPages=H.length,console.log(`Generating ${J.totalPages} pages...`);let O=[],F=[];for(let V=0;V<H.length;V+=X.concurrency)F.push(H.slice(V,V+X.concurrency));for(let V of F)await Promise.all(V.map(async(N)=>{let{route:A,url:w,params:R,props:T,revalidate:I}=N;try{await X.hooks.onPageStart?.(w);let E=await Bun.file(A.filePath).text(),k=SE(E),S=k?.middleware?Array.isArray(k.middleware)?k.middleware:[k.middleware]:[],x=[...q,...S];if(x.length>0){let C=N6(w,R,k||{}),h=V6(C,null),p=await R6(x,h);if(p.redirect){let i=typeof p.redirect==="string"?p.redirect:p.redirect.path||p.redirect,s=bE(String(i),w),K0=CE(w,X);await g0.promises.mkdir(j0.dirname(K0),{recursive:!0}),await Bun.write(K0,s),J.successCount++,J.pages.push({route:w,outputPath:K0,size:Buffer.byteLength(s),cached:!1}),O.push({loc:w,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${w} \u2192 redirect to ${i}`);return}if(p.abort){let i=typeof p.abort==="string"?p.abort:p.abort?.error?.message||"aborted";console.warn(` \u21B3 ${w} \u2014 middleware aborted: ${i}`);return}}let y=E.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(y)try{if(!await Function("route",`
12545
12545
  const validate = ${y[1]};
12546
12546
  return validate(route);
12547
- `)({params:R})){console.warn(`Validation failed for ${w}, skipping...`);return}}catch{}let b=null,f=!1;if(X.cache){if(b=B.get(w,A.filePath),b)f=!0,J.cachedCount++}if(!b){let C=await Hj(A,R,T,X,Y);if(b=C.html,X.cache)B.set(w,A.filePath,C.dependencies,b)}let r;if(X.trailingSlash)r=j0.join(X.outputDir,w,"index.html");else r=w==="/"?j0.join(X.outputDir,"index.html"):j0.join(X.outputDir,`${w}.html`);if(X.chunkIslands){let{html:C,chunks:h}=Bj(b,{integrity:X.integrityIslands,minify:X.minify});if(h.length>0){let m=j0.join(X.outputDir,"_stx","islands");await g0.promises.mkdir(m,{recursive:!0});for(let i of h){let s=j0.join(m,`${i.hash}.js`);if(!await Bun.file(s).exists())await Bun.write(s,i.code);if(!Q.has(i.hash)){Q.add(i.hash);let K0=Buffer.byteLength(i.code,"utf8");G+=K0,K[i.hash]={bytes:K0,file:`/_stx/islands/${i.hash}.js`}}}if(W[w]=h.map((i)=>i.hash),b=C,X.prefetchIslands)b=_j(b)}}await g0.promises.mkdir(j0.dirname(r),{recursive:!0}),await Bun.write(r,b),O.push({loc:w,lastmod:new Date().toISOString().split("T")[0],priority:w==="/"?1:0.8});let u={route:w,outputPath:r,size:Buffer.byteLength(b,"utf8"),cached:f};if(I!==!1)u.revalidateAt=Date.now()+I*1000;J.pages.push(u),J.successCount++,await X.hooks.onPageEnd?.(w,b)}catch(E){J.failedCount++,J.errors.push({route:w,error:E}),await X.hooks.onError?.(E,w),console.error(`Error generating ${w}:`,E)}}));if(X.cache)await B.save();if(X.generate404){let V=j0.join(X.pagesDir,"404.stx");if(await Bun.file(V).exists()){let N=new Set,A={...Y,debug:!1,cache:!1},w=await X0(await Bun.file(V).text(),{},V,A,N);await Bun.write(j0.join(X.outputDir,"404.html"),w)}else await Bun.write(j0.join(X.outputDir,"404.html"),`<!DOCTYPE html>
12547
+ `)({params:R})){console.warn(`Validation failed for ${w}, skipping...`);return}}catch{}let b=null,f=!1;if(X.cache){if(b=B.get(w,A.filePath),b)f=!0,J.cachedCount++}if(!b){let C=await Hj(A,R,T,X,Y);if(b=C.html,X.cache)B.set(w,A.filePath,C.dependencies,b)}let r;if(X.trailingSlash)r=j0.join(X.outputDir,w,"index.html");else r=w==="/"?j0.join(X.outputDir,"index.html"):j0.join(X.outputDir,`${w}.html`);if(X.chunkIslands){let{html:C,chunks:h}=Bj(b,{integrity:X.integrityIslands,minify:X.minify});if(h.length>0){let p=j0.join(X.outputDir,"_stx","islands");await g0.promises.mkdir(p,{recursive:!0});for(let i of h){let s=j0.join(p,`${i.hash}.js`);if(!await Bun.file(s).exists())await Bun.write(s,i.code);if(!Q.has(i.hash)){Q.add(i.hash);let K0=Buffer.byteLength(i.code,"utf8");G+=K0,K[i.hash]={bytes:K0,file:`/_stx/islands/${i.hash}.js`}}}if(W[w]=h.map((i)=>i.hash),b=C,X.prefetchIslands)b=_j(b)}}await g0.promises.mkdir(j0.dirname(r),{recursive:!0}),await Bun.write(r,b),O.push({loc:w,lastmod:new Date().toISOString().split("T")[0],priority:w==="/"?1:0.8});let u={route:w,outputPath:r,size:Buffer.byteLength(b,"utf8"),cached:f};if(I!==!1)u.revalidateAt=Date.now()+I*1000;J.pages.push(u),J.successCount++,await X.hooks.onPageEnd?.(w,b)}catch(E){J.failedCount++,J.errors.push({route:w,error:E}),await X.hooks.onError?.(E,w),console.error(`Error generating ${w}:`,E)}}));if(X.cache)await B.save();if(X.generate404){let V=j0.join(X.pagesDir,"404.stx");if(await Bun.file(V).exists()){let N=new Set,A={...Y,debug:!1,cache:!1},w=await X0(await Bun.file(V).text(),{},V,A,N);await Bun.write(j0.join(X.outputDir,"404.html"),w)}else await Bun.write(j0.join(X.outputDir,"404.html"),`<!DOCTYPE html>
12548
12548
  <html lang="en">
12549
12549
  <head>
12550
12550
  <meta charset="UTF-8">
@@ -12586,7 +12586,7 @@ Build complete!
12586
12586
  <p>Redirecting to <a href="${$}">${$}</a>...</p>
12587
12587
  <script>window.location.replace('${$}')</script>
12588
12588
  </body>
12589
- </html>`}function CE($,Z){if($==="/"||$==="")return j0.join(Z.outputDir,"index.html");let Y=$.replace(/^\/|\/$/g,"");if(Z.trailingSlash)return j0.join(Z.outputDir,Y,"index.html");return j0.join(Z.outputDir,`${Y}.html`)}var yE;var wj=D(()=>{M6();O1();zj();n0();c1();yZ();yE={generateStaticSite:Oj,createISRHandler:Fj,defineStaticPaths:Vj,createMarkdownLoader:Nj}});import{createHash as PE}from"crypto";import{getRouterScript as xE}from"stx-router";function c9($){return PE("sha256").update($).digest("hex").slice(0,8)}function l9($=!1){let Z=$?N5():_6(),Y=c9(Z);return{content:Z,filename:`runtime.${Y}.js`,hash:Y}}function i9(){let $=xE(),Z=c9($);return{content:$,filename:`router.${Z}.js`,hash:Z}}function vE($){return{runtimeTag:$.runtime?`<script src="/__stx/${$.runtime.filename}"></script>`:"",routerTag:$.router?`<script src="/__stx/${$.router.filename}"></script>`:"",cssTag:$.css?`<link rel="stylesheet" href="/__stx/${$.css.filename}">`:""}}var n9=D(()=>{VZ()});import Rj from"path";import{createHash as fE}from"crypto";function gE($={}){let Z=new Set;return{context:new Proxy($,{get(X,J){if(J in X)return X[J];if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return},has(X,J){if(J in X)return!0;if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return!1}}),accessedKeys:Z}}async function s9($,Z,Y={}){let X=Rj.resolve($),J=await Bun.file(X).text(),Q=fE("sha256").update(J).digest("hex").slice(0,16);pY();let G={};try{G=await x0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(J))!==null){let O=U[1];if(/\bserver\b/.test(O))K.push(U[2])}let{context:B}=gE({__filename:X,__dirname:Rj.dirname(X)}),_=new Set,z={...K1,...G,...Y,buildMode:"compile",strict:!1},q=await X0(J,B,X,z,_),j=B$(q),H=cY();return{route:Z,sourceFile:$,html:q,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(_),contentHash:Q,streamTemplates:B.__streamTemplates}}var r9=D(()=>{O1();n0();O4();u7()});import o9 from"fs";import Mj from"path";function a9($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function t9($,Z){let Y=Mj.join(Z,"manifest.json");o9.writeFileSync(Y,JSON.stringify($,null,2))}function e9($){let Z=Mj.join($,"manifest.json");if(!o9.existsSync(Z))return null;try{let Y=o9.readFileSync(Z,"utf-8"),X=JSON.parse(Y);if(X.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${X.version}`),null;return X}catch(Y){return console.warn("[stx] Failed to load manifest:",Y),null}}var vZ=()=>{};var Ij={};Z0(Ij,{buildForProduction:()=>Tj});import s1 from"fs";import t0 from"path";function dE($,Z){let Y=0,X=0;if(!s1.existsSync($))return{copied:Y,bytes:X};function J(Q,G){let K=s1.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(hE.has(W.name))continue;let U=t0.join(Q,W.name),B=t0.join(G,W.name);if(W.isDirectory())s1.mkdirSync(B,{recursive:!0}),J(U,B);else if(W.isFile()){if(s1.existsSync(B))continue;s1.copyFileSync(U,B),Y++,X+=s1.statSync(B).size}}}return J($,Z),{copied:Y,bytes:X}}async function Tj($={}){let Z=Date.now(),Y=t0.resolve($.root||process.cwd()),X=t0.resolve(Y,$.outputDir||".output");console.log("[stx build] Starting production build...");let J={};try{J=await x0()}catch{}let Q=$.componentsDir??J.componentsDir??"components",G=$.partialsDir??J.partialsDir??"partials",K=$.layoutsDir??J.layoutsDir??"layouts",W=$.publicDir??J.publicDir??"public",U=J.app?.head||{},B=J.router?.container||"main";if(s1.existsSync(X))s1.rmSync(X,{recursive:!0});let _=[t0.join(X,"public","__stx"),t0.join(X,"public","assets"),t0.join(X,"server","pages"),t0.join(X,"server","fragments")];for(let R of _)s1.mkdirSync(R,{recursive:!0});console.log("[stx build] Discovering routes...");let z=U$(Y),q=["components","layouts","partials"],j=z.filter((R)=>{return!q.some((T)=>R.pattern.startsWith(`/${T}/`)||R.pattern===`/${T}`)});console.log(`[stx build] Found ${j.length} page routes (${z.length-j.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=l9($.debug),O=i9();await Bun.write(t0.join(X,"public","__stx",H.filename),H.content),await Bun.write(t0.join(X,"public","__stx",O.filename),O.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${O.filename} (${(O.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let F=[],L=[];for(let R of j)try{let T=await s9(R.filePath,R.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(F.push(T),T.html=T.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,O.filename),T.html=X6(T.html,U,{bodyScripts:[`<script src="/__stx/${O.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(T.html)){let P=T.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(P&&P[1]){let y=P[1];T.html=T.html.replace(" "+y,""),T.html=T.html.replace(/<body([^>]*)>/,`<body$1 ${y}>`)}}T.html=T.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),T.html=await T0(T.html),T.fragment=T6(T.html,B);let E=R.pattern==="/"?"index":R.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),k=t0.join("server","pages",`${E}.compiled.json`),S=t0.join("server","fragments",`${E}.html`);await Bun.write(t0.join(X,k),JSON.stringify(T,null,2)),await Bun.write(t0.join(X,S),T.fragment),L.push({pattern:R.pattern,compiledPath:k,fragmentPath:S,isDynamic:T.hasServerScripts,hasParams:R.pattern.includes(":")||R.pattern.includes("[")}),console.log(`[stx build] \u2713 ${R.pattern}`)}catch(T){console.error(`[stx build] \u2717 ${R.pattern}:`,T instanceof Error?T.message:T)}let V=t0.resolve(Y,W);if(s1.existsSync(V)){let{copied:R,bytes:T}=dE(V,t0.join(X,"public"));if(R>0)console.log(`[stx build] Copied ${R} public asset${R===1?"":"s"} (${(T/1024).toFixed(1)}KB) from ${W}/`)}let N={runtime:H.filename,router:O.filename},A=a9(L,N,X);t9(A,X);let w=Date.now()-Z;return console.log(`
12589
+ </html>`}function CE($,Z){if($==="/"||$==="")return j0.join(Z.outputDir,"index.html");let Y=$.replace(/^\/|\/$/g,"");if(Z.trailingSlash)return j0.join(Z.outputDir,Y,"index.html");return j0.join(Z.outputDir,`${Y}.html`)}var yE;var wj=D(()=>{M6();O1();zj();n0();c1();yZ();yE={generateStaticSite:Oj,createISRHandler:Fj,defineStaticPaths:Vj,createMarkdownLoader:Nj}});import{createHash as PE}from"crypto";import{getRouterScript as xE}from"stx-router";function c9($){return PE("sha256").update($).digest("hex").slice(0,8)}function l9($=!1){let Z=$?N5():_6(),Y=c9(Z);return{content:Z,filename:`runtime.${Y}.js`,hash:Y}}function i9(){let $=xE(),Z=c9($);return{content:$,filename:`router.${Z}.js`,hash:Z}}function vE($){return{runtimeTag:$.runtime?`<script src="/__stx/${$.runtime.filename}"></script>`:"",routerTag:$.router?`<script src="/__stx/${$.router.filename}"></script>`:"",cssTag:$.css?`<link rel="stylesheet" href="/__stx/${$.css.filename}">`:""}}var n9=D(()=>{VZ()});import Rj from"path";import{createHash as fE}from"crypto";function gE($={}){let Z=new Set;return{context:new Proxy($,{get(X,J){if(J in X)return X[J];if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return},has(X,J){if(J in X)return!0;if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return!1}}),accessedKeys:Z}}async function s9($,Z,Y={}){let X=Rj.resolve($),J=await Bun.file(X).text(),Q=fE("sha256").update(J).digest("hex").slice(0,16);pY();let G={};try{G=await x0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(J))!==null){let O=U[1];if(/\bserver\b/.test(O))K.push(U[2])}let{context:B}=gE({__filename:X,__dirname:Rj.dirname(X)}),_=new Set,z={...K1,...G,...Y,buildMode:"compile",strict:!1},q=await X0(J,B,X,z,_),j=B$(q),H=cY();return{route:Z,sourceFile:$,html:q,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(_),contentHash:Q,streamTemplates:B.__streamTemplates}}var r9=D(()=>{O1();n0();O4();u7()});import o9 from"fs";import Mj from"path";function a9($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function t9($,Z){let Y=Mj.join(Z,"manifest.json");o9.writeFileSync(Y,JSON.stringify($,null,2))}function e9($){let Z=Mj.join($,"manifest.json");if(!o9.existsSync(Z))return null;try{let Y=o9.readFileSync(Z,"utf-8"),X=JSON.parse(Y);if(X.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${X.version}`),null;return X}catch(Y){return console.warn("[stx] Failed to load manifest:",Y),null}}var vZ=()=>{};var Ij={};Z0(Ij,{buildForProduction:()=>Tj});import s1 from"fs";import t0 from"path";function dE($,Z){let Y=0,X=0;if(!s1.existsSync($))return{copied:Y,bytes:X};function J(Q,G){let K=s1.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(hE.has(W.name))continue;let U=t0.join(Q,W.name),B=t0.join(G,W.name);if(W.isDirectory())s1.mkdirSync(B,{recursive:!0}),J(U,B);else if(W.isFile()){if(s1.existsSync(B))continue;s1.copyFileSync(U,B),Y++,X+=s1.statSync(B).size}}}return J($,Z),{copied:Y,bytes:X}}async function Tj($={}){let Z=Date.now(),Y=t0.resolve($.root||process.cwd()),X=t0.resolve(Y,$.outputDir||".output");console.log("[stx build] Starting production build...");let J={};try{J=await x0()}catch{}let Q=$.componentsDir??J.componentsDir??"components",G=$.partialsDir??J.partialsDir??"partials",K=$.layoutsDir??J.layoutsDir??"layouts",W=$.publicDir??J.publicDir??"public",U=J.app?.head||{},B=J.router?.container||"main";if(s1.existsSync(X))s1.rmSync(X,{recursive:!0});let _=[t0.join(X,"public","__stx"),t0.join(X,"public","assets"),t0.join(X,"server","pages"),t0.join(X,"server","fragments")];for(let R of _)s1.mkdirSync(R,{recursive:!0});console.log("[stx build] Discovering routes...");let z=U$(Y),q=["components","layouts","partials"],j=z.filter((R)=>{return!q.some((T)=>R.pattern.startsWith(`/${T}/`)||R.pattern===`/${T}`)});console.log(`[stx build] Found ${j.length} page routes (${z.length-j.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=l9($.debug),O=i9();await Bun.write(t0.join(X,"public","__stx",H.filename),H.content),await Bun.write(t0.join(X,"public","__stx",O.filename),O.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${O.filename} (${(O.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let F=[],L=[];for(let R of j)try{let T=await s9(R.filePath,R.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(F.push(T),T.html=T.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,O.filename),T.html=X6(T.html,U,{bodyScripts:[`<script src="/__stx/${O.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(T.html)){let x=T.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(x&&x[1]){let y=x[1];T.html=T.html.replace(" "+y,""),T.html=T.html.replace(/<body([^>]*)>/,`<body$1 ${y}>`)}}T.html=T.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),T.html=await T0(T.html),T.fragment=T6(T.html,B);let E=R.pattern==="/"?"index":R.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),k=t0.join("server","pages",`${E}.compiled.json`),S=t0.join("server","fragments",`${E}.html`);await Bun.write(t0.join(X,k),JSON.stringify(T,null,2)),await Bun.write(t0.join(X,S),T.fragment),L.push({pattern:R.pattern,compiledPath:k,fragmentPath:S,isDynamic:T.hasServerScripts,hasParams:R.pattern.includes(":")||R.pattern.includes("[")}),console.log(`[stx build] \u2713 ${R.pattern}`)}catch(T){console.error(`[stx build] \u2717 ${R.pattern}:`,T instanceof Error?T.message:T)}let V=t0.resolve(Y,W);if(s1.existsSync(V)){let{copied:R,bytes:T}=dE(V,t0.join(X,"public"));if(R>0)console.log(`[stx build] Copied ${R} public asset${R===1?"":"s"} (${(T/1024).toFixed(1)}KB) from ${W}/`)}let N={runtime:H.filename,router:O.filename},A=a9(L,N,X);t9(A,X);let w=Date.now()-Z;return console.log(`
12590
12590
  [stx build] Done in ${w}ms \u2014 ${F.length} pages compiled`),{pageCount:F.length,assets:N,outputDir:X,duration:w}}var hE;var $Q=D(()=>{M6();n9();r9();vZ();u7();c1();n0();hE=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"])});import uE from"path";async function mE($={}){let Z=performance.now(),Y=$.root||process.cwd(),X=await x0(),J=X.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${J.toUpperCase()}${X.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let Q,G;if(J==="ssg"){let{generateStaticSite:W}=await Promise.resolve().then(() => (wj(),Aj));Q=await W({pagesDir:uE.join(X.root||".",X.pagesDir||X.build?.pagesDir||"pages"),publicDir:X.publicDir||X.build?.publicDir||"public",outputDir:X.build?.outputDir||"dist",generate404:X.build?.generate404??!0,minify:X.build?.minify??!0,cleanOutput:X.build?.cleanOutput??!0,...$.ssg})}else{let{buildForProduction:W}=await Promise.resolve().then(() => ($Q(),Ij));G=await W({outputDir:".output",debug:$.debug,...$.ssr})}let K=Math.round(performance.now()-Z);return{mode:J,ssg:Q,ssr:G,duration:K}}var Ej=D(()=>{n0()});import fZ from"path";async function cE($){let Z=performance.now(),Y=await x0($),X=$||Y.root||process.cwd(),J=[Y.build?.pagesDir||Y.pagesDir||"pages",Y.componentsDir||"components",Y.layoutsDir||"layouts",Y.partialsDir||"partials"].map((K)=>fZ.resolve(X,K)),Q=[],G=0;for(let K of J){let W=await kj(K);for(let U of W){G++;let B=await Bun.file(U).text();if(Dj.test(B))Q.push(fZ.relative(X,U))}}return{mode:Q.length>0?"ssr":"ssg",serverScriptFiles:Q,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-Z)}}async function lE($){let Z=await x0($),Y=$||Z.root||process.cwd(),X=fZ.resolve(Y,Z.componentsDir||"components"),J=[],Q=await kj(X);for(let G of Q){let K=await Bun.file(G).text(),W=Dj.test(K),U=pE.test(K)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(K)&&!W;if(W&&U){let B=fZ.relative(Y,G);J.push({file:B,message:`Component "${B}" has both <script server> and <script client>. `+"Components should be server OR client \u2014 compose them via props/slots."})}}return J}async function kj($){let Z=[];try{let Y=new Bun.Glob("**/*.stx");for await(let X of Y.scan({cwd:$,absolute:!0}))Z.push(X)}catch{}return Z}var Dj,pE;var Sj=D(()=>{n0();Dj=/<script\b[^>]*\bserver\b/i,pE=/<script\b[^>]*\bclient\b/i});function ZQ($){let Z=new Map,Y=/@(\w+)/g,X,J=1,Q=0;while((X=Y.exec($))!==null){let G=X[1],K=$.slice(Q,X.index);J+=(K.match(/\n/g)||[]).length,Q=X.index;let W=X.index-$.lastIndexOf(`
12591
12591
  `,X.index-1);if(Cj.includes(G)){let U=Z.get(G);if(U)U.count++,U.locations.push({line:J,column:W});else Z.set(G,{name:G,count:1,locations:[{line:J,column:W}]})}}return Array.from(Z.values())}function yj($,Z=[]){let Y=ZQ($),X=new Set(Y.map((J)=>J.name));for(let J of Z)X.add(J);for(let J of Array.from(X))if(!J.startsWith("end"))X.add(`end${J}`);return Cj.filter((J)=>!X.has(J))}function Pj($){let Z=[],Y={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"]},X=new Set;for(let Q of $)for(let[G,K]of Object.entries(Y))if(K.includes(Q)){X.add(G);break}for(let Q of X)Z.push(`import { process${nE(Q)} } from './${Q}'`);let J=$.filter((Q)=>!Q.startsWith("end")).map((Q)=>` '${Q}': true`).join(`,
12592
12592
  `);return`// Tree-shaken directive bundle
@@ -13110,7 +13110,7 @@ ${O}`}if(j=await W$(j),K.forEach((H)=>X.add(H)),Y.cache&&Y.cachePath){if(await R
13110
13110
  <h1>Something went wrong</h1>
13111
13111
  <p>An internal error occurred. Please try again later.</p>
13112
13112
  </body>
13113
- </html>`,loader:"html"}}})}}});var{serve:WD}=globalThis.Bun;import v1 from"fs";import J1 from"path";async function BH($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=J1.resolve($);if(!v1.existsSync(K))return console.error(`${M.red}Error: File not found: ${M.bright}${K}${M.reset}`),!1;if(K.endsWith(".md"))return lZ(K,Z);else if(!K.endsWith(".stx"))return console.error(`${M.red}Error: Unsupported file type: ${M.bright}${K}${M.reset}. Only .stx and .md files are supported.`),!1;let W=J1.join(process.cwd(),".stx/output");v1.mkdirSync(W,{recursive:!0}),console.log(`${M.blue}Building ${M.bright}${$}${M.reset}...`);let U=null,B=async()=>{try{let L={name:"public-assets",setup(w){w.onResolve({filter:/^\/(images|fonts|assets|public)\//},(R)=>{return{path:R.path,external:!0}})}},V=await Bun.build({entrypoints:[K],outdir:W,plugins:[L,n7],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!V.success)return console.error(`${M.red}Build failed:${M.reset}`,V.logs),!1;let N=V.outputs.find((w)=>w.path.endsWith(".html"));if(!N)return console.error(`${M.red}No HTML output found${M.reset}`),!1;return U=await Bun.file(N.path).text(),!0}catch(L){return console.error(`${M.red}Error building stx file:${M.reset}`,L),!1}};if(!await B())return!1;let z=J1.dirname(K);await A7(z);let q=Y;try{if(q=await o$(Y),q!==Y)console.log(`${M.yellow}Port ${Y} is busy, using port ${q} instead${M.reset}`)}catch{return console.error(`${M.red}Could not find an available port${M.reset}`),!1}if(J){let L=Z.hmrPort||q+1;Q=b6({wsPort:L,verbose:!1}),G=Q.start(L)}let j={},H=null;try{let{loadStxConfig:L}=await Promise.resolve().then(() => (t$(),I5)),V=await L();if(V?.apiRouter)H=V?.apiRouter,console.log(`${M.blue}Using custom router for API handling${M.reset}`);if(V?.apiRoutes){j=V.apiRoutes;let N=Object.keys(j).length;if(N>0)console.log(`${M.blue}Loaded ${M.bright}${N} API route${N>1?"s":""}${M.reset}`)}if(V?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:A}=await Promise.resolve().then(() => (hZ(),JQ)),w=V.broadcasting;await N(w);let R=w.port??6001;console.log(`${M.magenta}Broadcasting on ${M.cyan}ws://localhost:${R}/ws${M.reset}`);let T=J1.join(process.cwd(),"channels.ts");if(v1.existsSync(T))try{let I=await A(T);console.log(`${M.blue}Loaded ${M.bright}${I} broadcast channel${I!==1?"s":""}${M.blue} from channels.ts${M.reset}`)}catch(I){console.warn(`${M.yellow}Failed to load channels.ts: ${I.message}${M.reset}`)}}catch(N){console.warn(`${M.yellow}Broadcasting failed to start: ${N.message}${M.reset}`)}}catch{}if(console.log(`${M.blue}Starting server on ${M.cyan}http://localhost:${q}/${M.reset}...`),J)console.log(`${M.magenta}Hot reload enabled on ws://localhost:${G}${M.reset}`);let O=WD({port:q,async fetch(L){let V=new URL(L.url);if(H)try{let T=await H.handleRequest(L);if(T.status!==404)return T}catch{}if(j[V.pathname])try{return await j[V.pathname](L)}catch(T){return new Response(JSON.stringify({error:T.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(V.pathname==="/")return(async()=>{let I=await T0(U||"");if(J)I=r1(I,G);if(Z.native)if(I.includes("<head>"))I=I.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(I.includes("<html"))I=I.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else I="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+I;if(Z.titlebarHidden)if(I.includes("<head>"))I=I.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(I.includes("<html"))I=I.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else I=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${I}`;return I})().then((I)=>new Response(I,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let N=J1.join(W,V.pathname);if(v1.existsSync(N)&&v1.statSync(N).isFile()){let T=Bun.file(N),I=J1.extname(N).toLowerCase(),E="text/plain";if(I===".ts"||I===".tsx"){let k=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),S=await T.text(),P=k.transformSync(S);return new Response(P,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(T,{headers:{"Content-Type":E}})}let A=J1.dirname(K),w=J1.join(A,V.pathname);if(v1.existsSync(w)&&v1.statSync(w).isFile()){let T=Bun.file(w),I=J1.extname(w).toLowerCase(),E="text/plain";if(I===".ts"||I===".tsx"){let k=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),S=await T.text(),P=k.transformSync(S);return new Response(P,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(T,{headers:{"Content-Type":E}})}let R=J1.join(process.cwd(),"public",V.pathname);if(v1.existsSync(R)&&v1.statSync(R).isFile()){let T=Bun.file(R),I=J1.extname(R).toLowerCase(),E="application/octet-stream";if(I===".ts"||I===".tsx"){let k=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),S=await T.text(),P=k.transformSync(S);return new Response(P,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(T,{headers:{"Content-Type":E}})}return new Response("Not Found",{status:404})},error(L){return new Response(`<pre>${L}
13113
+ </html>`,loader:"html"}}})}}});var{serve:WD}=globalThis.Bun;import v1 from"fs";import J1 from"path";async function BH($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=J1.resolve($);if(!v1.existsSync(K))return console.error(`${M.red}Error: File not found: ${M.bright}${K}${M.reset}`),!1;if(K.endsWith(".md"))return lZ(K,Z);else if(!K.endsWith(".stx"))return console.error(`${M.red}Error: Unsupported file type: ${M.bright}${K}${M.reset}. Only .stx and .md files are supported.`),!1;let W=J1.join(process.cwd(),".stx/output");v1.mkdirSync(W,{recursive:!0}),console.log(`${M.blue}Building ${M.bright}${$}${M.reset}...`);let U=null,B=async()=>{try{let L={name:"public-assets",setup(w){w.onResolve({filter:/^\/(images|fonts|assets|public)\//},(R)=>{return{path:R.path,external:!0}})}},V=await Bun.build({entrypoints:[K],outdir:W,plugins:[L,n7],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!V.success)return console.error(`${M.red}Build failed:${M.reset}`,V.logs),!1;let N=V.outputs.find((w)=>w.path.endsWith(".html"));if(!N)return console.error(`${M.red}No HTML output found${M.reset}`),!1;return U=await Bun.file(N.path).text(),!0}catch(L){return console.error(`${M.red}Error building stx file:${M.reset}`,L),!1}};if(!await B())return!1;let z=J1.dirname(K);await A7(z);let q=Y;try{if(q=await o$(Y),q!==Y)console.log(`${M.yellow}Port ${Y} is busy, using port ${q} instead${M.reset}`)}catch{return console.error(`${M.red}Could not find an available port${M.reset}`),!1}if(J){let L=Z.hmrPort||q+1;Q=b6({wsPort:L,verbose:!1}),G=Q.start(L)}let j={},H=null;try{let{loadStxConfig:L}=await Promise.resolve().then(() => (t$(),I5)),V=await L();if(V?.apiRouter)H=V?.apiRouter,console.log(`${M.blue}Using custom router for API handling${M.reset}`);if(V?.apiRoutes){j=V.apiRoutes;let N=Object.keys(j).length;if(N>0)console.log(`${M.blue}Loaded ${M.bright}${N} API route${N>1?"s":""}${M.reset}`)}if(V?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:A}=await Promise.resolve().then(() => (hZ(),JQ)),w=V.broadcasting;await N(w);let R=w.port??6001;console.log(`${M.magenta}Broadcasting on ${M.cyan}ws://localhost:${R}/ws${M.reset}`);let T=J1.join(process.cwd(),"channels.ts");if(v1.existsSync(T))try{let I=await A(T);console.log(`${M.blue}Loaded ${M.bright}${I} broadcast channel${I!==1?"s":""}${M.blue} from channels.ts${M.reset}`)}catch(I){console.warn(`${M.yellow}Failed to load channels.ts: ${I.message}${M.reset}`)}}catch(N){console.warn(`${M.yellow}Broadcasting failed to start: ${N.message}${M.reset}`)}}catch{}if(console.log(`${M.blue}Starting server on ${M.cyan}http://localhost:${q}/${M.reset}...`),J)console.log(`${M.magenta}Hot reload enabled on ws://localhost:${G}${M.reset}`);let O=WD({port:q,async fetch(L){let V=new URL(L.url);if(H)try{let T=await H.handleRequest(L);if(T.status!==404)return T}catch{}if(j[V.pathname])try{return await j[V.pathname](L)}catch(T){return new Response(JSON.stringify({error:T.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(V.pathname==="/")return(async()=>{let I=await T0(U||"");if(J)I=r1(I,G);if(Z.native)if(I.includes("<head>"))I=I.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(I.includes("<html"))I=I.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else I="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+I;if(Z.titlebarHidden)if(I.includes("<head>"))I=I.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(I.includes("<html"))I=I.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else I=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${I}`;return I})().then((I)=>new Response(I,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let N=J1.join(W,V.pathname);if(v1.existsSync(N)&&v1.statSync(N).isFile()){let T=Bun.file(N),I=J1.extname(N).toLowerCase(),E="text/plain";if(I===".ts"||I===".tsx"){let k=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),S=await T.text(),x=k.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(I){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(T,{headers:{"Content-Type":E}})}let A=J1.dirname(K),w=J1.join(A,V.pathname);if(v1.existsSync(w)&&v1.statSync(w).isFile()){let T=Bun.file(w),I=J1.extname(w).toLowerCase(),E="text/plain";if(I===".ts"||I===".tsx"){let k=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),S=await T.text(),x=k.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(I){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(T,{headers:{"Content-Type":E}})}let R=J1.join(process.cwd(),"public",V.pathname);if(v1.existsSync(R)&&v1.statSync(R).isFile()){let T=Bun.file(R),I=J1.extname(R).toLowerCase(),E="application/octet-stream";if(I===".ts"||I===".tsx"){let k=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),S=await T.text(),x=k.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(I){case".html":E="text/html";break;case".css":E="text/css";break;case".js":E="text/javascript";break;case".json":E="application/json";break;case".png":E="image/png";break;case".jpg":case".jpeg":E="image/jpeg";break;case".gif":E="image/gif";break;case".svg":E="image/svg+xml";break;case".ico":E="image/x-icon";break;case".woff":E="font/woff";break;case".woff2":E="font/woff2";break;case".ttf":E="font/ttf";break;case".otf":E="font/otf";break;case".eot":E="application/vnd.ms-fontobject";break}return new Response(T,{headers:{"Content-Type":E}})}return new Response("Not Found",{status:404})},error(L){return new Response(`<pre>${L}
13114
13114
  ${L.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
13115
13115
  ${M.blue}stx${M.reset} ${M.green}${process.env.stx_VERSION||"v0.0.10"}${M.reset} ${M.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${M.reset}`),console.log(`
13116
13116
  ${M.bright}\u2192 ${M.cyan}http://localhost:${q}/${M.reset}`),console.log(`
@@ -13596,12 +13596,12 @@ ${j.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
13596
13596
  ${M.blue}stx${M.reset} ${M.green}${process.env.stx_VERSION||"v0.0.10"}${M.reset} ${M.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${M.reset}`),console.log(`
13597
13597
  ${M.bright}\u2192 ${M.cyan}http://localhost:${B}/${M.reset}`),console.log(`
13598
13598
  ${M.yellow}Routes:${M.reset}`);let z=new Set(K.map((j)=>j.routeTemplate)),q=Object.entries(G).filter(([j])=>!z.has(j)).sort(([j],[H])=>j.localeCompare(H)).map(([j,H])=>({route:j==="/"?"/":j,filePath:e0.relative(process.cwd(),H.filePath),fileType:H.fileType}));for(let j of K){let H=j.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");q.push({route:H,filePath:e0.relative(process.cwd(),j.filePath),fileType:"stx"})}if(q.sort((j,H)=>j.route.localeCompare(H.route)),q.forEach((j,H)=>{let F=H===q.length-1?"\u2514\u2500 ":"\u251C\u2500 ",L=j.fileType==="md"?`${M.magenta}(markdown)${M.reset}`:"";console.log(` ${M.green}${F}${j.route}${M.reset} \u2192 ${M.bright}${j.filePath}${M.reset} ${L}`)}),console.log(`
13599
- Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),a$(_.url.toString(),()=>{if(X)e$.watch(Q,{recursive:!0}).close();_.stop()}),X){console.log(`${M.blue}Watching for changes...${M.reset}`);let j=e$.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${M.yellow}File ${M.bright}${O}${M.yellow} changed, rebuilding...${M.reset}`),c$.clear(),r$(),await W()});process.on("SIGINT",()=>{j.close(),_.stop(),process.exit(0)})}return!0}var qH=D(()=>{w7();n0();S7();iZ();N0();E6()});var{serve:BD}=globalThis.Bun;import z1 from"fs";import q0 from"path";function _Q($){let Z=Bun.file($),Y=q0.extname($).toLowerCase(),X={".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(Y)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(Z,{headers:{"Content-Type":X[Y]||"application/octet-stream",...Q}})}async function jH($=".",Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=q0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (t$(),I5)),U=await W(K),B=U.root&&U.root!=="."?q0.join(K,U.root):K,_=U.pagesDir||"pages",z=q0.join(B,_);if(!z1.existsSync(z))return console.error(`${M.red}Error: No '${_}' directory found in ${M.bright}${B}${M.reset}`),console.log(`${M.dim}Create a ${_}/ directory with .stx files to define your routes.${M.reset}`),console.log(`${M.dim}Example: ${_}/index.stx for the homepage.${M.reset}`),!1;let q=U$(B);if(q.length===0)return console.error(`${M.red}Error: No page files found in ${M.bright}${z}${M.reset}`),!1;console.log(`${M.blue}Found ${M.bright}${q.length}${M.blue} routes${M.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:C,prefix:h}of j)if(z1.existsSync(C)){let m=U$(q0.dirname(C),{pagesDir:q0.basename(C)});for(let i of m){let s=h==="/"?i.pattern:`${h}${i.pattern==="/"?"":i.pattern}`;H.push({route:{...i,pattern:s},prefix:h})}if(m.length>0)console.log(`${M.blue}Plugin pages: ${M.bright}${m.length}${M.blue} routes at ${M.cyan}${h}${M.reset}`)}let O=new Map,F=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=await zQ(K,Z.stxOptions?.shell),L){if(F=await nZ(L,Z.stxOptions||{}),F)console.log(`${M.blue}Using app shell: ${M.bright}${q0.relative(K,L)}${M.reset} ${M.dim}(deprecated: use layouts/default.stx instead)${M.reset}`)}}F6(),await w6(K);let V=A6();if(V.length>0)console.log(`${M.blue}Loaded ${M.bright}${V.length}${M.blue} middleware: ${M.dim}${V.join(", ")}${M.reset}`);let N={},A=null;try{let{loadStxConfig:C}=await Promise.resolve().then(() => (t$(),I5)),h=await C(K);if(h?.apiRouter)A=h?.apiRouter,console.log(`${M.blue}Using custom router for API handling${M.reset}`);if(h?.apiRoutes){N=h.apiRoutes;let m=Object.keys(N).length;if(m>0)console.log(`${M.blue}Loaded ${M.bright}${m} API route${m>1?"s":""}${M.reset}`)}if(h?.broadcasting?.enabled)try{let{startBroadcasting:m,loadChannels:i}=await Promise.resolve().then(() => (hZ(),JQ)),s=h.broadcasting;await m(s);let K0=s.port??6001;console.log(`${M.magenta}Broadcasting on ${M.cyan}ws://localhost:${K0}/ws${M.reset}`);let $0=q0.join(process.cwd(),"channels.ts");if(z1.existsSync($0))try{let F0=await i($0);console.log(`${M.blue}Loaded ${M.bright}${F0} broadcast channel${F0!==1?"s":""}${M.blue} from channels.ts${M.reset}`)}catch(F0){console.warn(`${M.yellow}Failed to load channels.ts: ${F0.message}${M.reset}`)}}catch(m){console.warn(`${M.yellow}Broadcasting failed to start: ${m.message}${M.reset}`)}}catch{}let w=q0.join(K,".stx/output");z1.mkdirSync(w,{recursive:!0});let R=new Map,T=new Set,I=async(C)=>{let h=m9(z,C);if(!h)return null;try{let m=await Bun.build({entrypoints:[h],outdir:w,plugins:[n7],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!m.success)return null;let i=m.outputs.find((s)=>s.path.endsWith(".html"));if(!i)return null;return await Bun.file(i.path).text()}catch{return null}},E=async(C,h)=>{try{let{processDirectives:m,extractVariables:i,defaultConfig:s,loadStxConfig:K0,injectRouterScript:$0}=await Promise.resolve().then(() => (t$(),I5)),{checkCache:F0,cacheTemplate:R0,readFileCached:x,templateCache:d}=await Promise.resolve().then(() => (w5(),P7)),p=await K0(K),g=(V0)=>{if(!V0)return V0;if(q0.isAbsolute(V0))return V0;return q0.resolve(K,V0)},c={...s,...p,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)c.debug=!0;c.partialsDir=g(c.partialsDir),c.componentsDir=g(c.componentsDir),c.layoutsDir=g(c.layoutsDir),c.storesDir=g(c.storesDir||"stores"),c.cachePath=g(c.cachePath||".stx/cache");let a=!h&&!Z.profile,l=c.cache!==!1;if(l&&a){let V0=d.get(C.filePath);if(V0)try{if((await z1.promises.stat(C.filePath)).mtime.getTime()<=V0.mtime){let L$=!0;for(let Z1 of V0.dependencies){if(!z1.existsSync(Z1)){L$=!1;break}if((await z1.promises.stat(Z1)).mtime.getTime()>V0.mtime){L$=!1;break}}if(L$){let Z1=V0.output;if(F)Z1=B$(Z1,{preserveHead:!0});return{route:C,content:Z1}}}}catch{}let $1=await F0(C.filePath,c);if($1){let D1=$1;if(F)D1=B$(D1,{preserveHead:!0});return{route:C,content:D1}}}let Q0=l?await x(C.filePath):await Bun.file(C.filePath).text(),{classifyAllScripts:M0}=await Promise.resolve().then(() => (t$(),I5)),w0=M0(Q0),W0=w0.server.map((V0)=>V0.content),r0=Q0;for(let V0 of w0.server)r0=r0.replace(V0.fullTag,"");let p0={__filename:C.filePath,__dirname:q0.dirname(C.filePath),params:h??{}},{resetHead:P5}=await Promise.resolve().then(() => (f$(),v8));P5();for(let V0 of W0)try{await i(V0,p0,C.filePath)}catch($1){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",C.filePath,$1?.message||$1)}let G0=new Set,k0;if(Z.profile){let V0=performance.now();k0=await m(r0,p0,C.filePath,c,G0);let $1=performance.now()-V0,D1=q0.relative(K,C.filePath)||C.filePath;console.log(`[stx:profile] ${D1} \u2192 ${$1.toFixed(2)}ms`)}else k0=await m(r0,p0,C.filePath,c,G0);if(!F)k0=await $0(k0);{let{interpolateScriptExpressions:V0}=await Promise.resolve().then(() => (c0(),V4));k0=k0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,($1,D1,L$)=>{if(!/function\s+__stx_setup_/.test(L$))return $1;return`<script${D1}>${V0(L$,p0)}</script>`})}if(F)k0=B$(k0,{preserveHead:!0});if(l&&a)await R0(C.filePath,k0,G0,c);let{extractStreamBoundaries:Q4}=await Promise.resolve().then(() => (h$(),L5)),E1=Q4(p0),O$=p0.__streamTemplates;if(O$&&typeof O$==="object"&&Object.keys(O$).length>0){let V0=p0.streamBoundaries||{},$1={...c,autoShell:!1},D1=Object.keys(O$).map((Z1)=>({id:Z1,render:async()=>{let oG=typeof V0[Z1]==="function"?await V0[Z1]():void 0;return m(O$[Z1],{...p0,$boundary:oG},C.filePath,$1,new Set)}})),L$=new Set(D1.map((Z1)=>Z1.id));E1=[...(E1||[]).filter((Z1)=>!L$.has(Z1.id)),...D1]}if(E1&&E1.length>0)T.add(C.pattern);else E1=void 0;return{route:C,content:k0,boundaries:E1}}catch(m){return console.error(`${M.red}Error building ${M.bright}${C.pattern}${M.reset}:`,m),null}},k=8,S=async()=>{R.clear(),O.clear();for(let C=0;C<q.length;C+=k){let h=q.slice(C,C+k),m=await Promise.all(h.map((i)=>E(i)));for(let i of m)if(i)R.set(i.route.pattern,i)}for(let C=0;C<H.length;C+=k){let h=H.slice(C,C+k),m=await Promise.all(h.map(({route:i})=>E(i)));for(let i of m)if(i)O.set(i.route.pattern,i)}return R.size>0};if(console.log(`${M.blue}Building pages...${M.reset}`),!await S())return console.error(`${M.red}No pages were successfully built${M.reset}`),!1;await A7(K);let y=Y;try{if(y=await o$(Y),y!==Y)console.log(`${M.yellow}Port ${Y} is busy, using port ${y} instead${M.reset}`)}catch{return console.error(`${M.red}Could not find an available port${M.reset}`),!1}if(J){let C=Z.hmrPort||y+1;Q=b6({wsPort:C,verbose:!1}),G=Q.start(C)}let b=(C,h)=>{let m=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._rp=${JSON.stringify(h)};if(s.setRouteParams)s.setRouteParams(s._rp);})()</script>`;if(C.includes("</head>"))return C.replace("</head>",`${m}</head>`);if(C.includes("<body"))return C.replace(/<body([^>]*)>/,`<body$1>${m}`);return m+C};console.log(`${M.blue}Starting server...${M.reset}`);let f=BD({port:y,async fetch(C){let h=new URL(C.url),m=U?.publicDir||"public",i=q0.join(K,m,h.pathname),s=q0.join(K,h.pathname),K0=q0.join(w,h.pathname),[$0,F0,R0]=await Promise.all([z1.promises.stat(i).catch(()=>null),z1.promises.stat(s).catch(()=>null),z1.promises.stat(K0).catch(()=>null)]);if($0?.isFile())return _Q(i);if(F0?.isFile())return _Q(s);if(R0?.isFile())return _Q(K0);if(h.pathname.startsWith("/_stx/component/")){let g=decodeURIComponent(h.pathname.slice(16));if(g)try{let c=`<${g} />`,a={...buildConfig,autoShell:!1},l=await processDirectives(c,{},q0.join(K,"components",`${g}.stx`),a,new Set);return new Response(l,{headers:{"Content-Type":"text/html"}})}catch(c){return new Response(`<div class="stx-async-error">${c.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(h.pathname==="/_stx/img"){let{handleImageRequest:g}=await Promise.resolve().then(() => (bY(),WK)),c=await g(C,{publicDir:q0.join(K,m),cacheDir:q0.join(K,".stx/cache/img")});if(c)return c}if(A)try{let g=await A.handleRequest(C);if(g.status!==404)return g}catch{}if(N[h.pathname])try{return await N[h.pathname](C)}catch(g){return new Response(JSON.stringify({error:g.message}),{status:500,headers:{"Content-Type":"application/json"}})}let x=xZ(h.pathname,q);if(x){let g=R.get(x.route.pattern),c=T.has(x.route.pattern);if(x.route.isDynamic&&Object.keys(x.params).length>0||c){let a=await E(x.route,x.params);if(a)g=a}if(g){let a=x8();if(a.validate){if(!await a.validate({params:x.params})){let M0=await I(404);if(M0){let w0=M0;if(w0=await T0(w0,K),J)w0=r1(w0,G);return new Response(w0,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(a.middleware){let Q0=N6(h.pathname,x.params,a,h.search),M0=V6(Q0,null,C),w0=await R6(a.middleware,M0);if(w0.redirect){let W0=w0.redirect.path,r0=w0.redirect.options.redirectCode||302,p0=new Headers(w0.responseHeaders);return p0.set("Location",W0),new Response(null,{status:r0,headers:p0})}if(w0.abort){let{statusCode:W0,message:r0}=w0.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${W0}</title></head><body><h1>Error ${W0}</h1><p>${r0}</p></body></html>`,{status:W0,headers:{"Content-Type":"text/html"}})}if(Object.keys(w0.state).length>0){let W0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(w0.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;g.content=g.content.replace("</head>",`${W0}</head>`)}}let l=g.content;if(F&&qQ(C)){let Q0=P6(l);if(Object.keys(x.params).length>0)l=b(l,x.params);l=await T0(l,K);let M0=U?.router?.container||"main";return l=T6(l,M0),new Response(l,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Q0.layout,"X-STX-Layout-Group":Q0.group,"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(F)l=y6(F,l);if(Object.keys(x.params).length>0)l=b(l,x.params);if(l=await T0(l,K),J)l=r1(l,G);if(Z.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;if(Z.titlebarHidden)if(l.includes("<head>"))l=l.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 l=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${l}`;if(g.boundaries&&g.boundaries.length>0){let{renderStreamingPage:Q0,streamToResponse:M0}=await Promise.resolve().then(() => (h$(),L5));return M0(Q0(l,g.boundaries,{timeoutMs:30000}),{headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(l,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let g=H.map((a)=>a.route),c=xZ(h.pathname,g);if(c){let a=O.get(c.route.pattern);if(a){let l=a.content;if(F)l=y6(F,l);if(Object.keys(c.params).length>0)l=b(l,c.params);if(l=await T0(l,K),J)l=r1(l,G);return new Response(l,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:a}of j)if(a!=="/"&&h.pathname.startsWith(a)){let l=O.get(a)||O.get(a+"/");if(l){let Q0=l.content;if(F)Q0=y6(F,Q0);if(Q0=await T0(Q0,K),J)Q0=r1(Q0,G);return new Response(Q0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let d=R.get("/");if(d){let g=d.content;if(g=await T0(g,K),J)g=r1(g,G);if(Z.native)if(g.includes("<head>"))g=g.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 g="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+g;return new Response(g,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let p=await I(404);if(p){let g=p;if(g=await T0(g,K),J)g=r1(g,G);return new Response(g,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(C){let h=await I(500);if(h)return new Response(h,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${C}
13599
+ Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),a$(_.url.toString(),()=>{if(X)e$.watch(Q,{recursive:!0}).close();_.stop()}),X){console.log(`${M.blue}Watching for changes...${M.reset}`);let j=e$.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${M.yellow}File ${M.bright}${O}${M.yellow} changed, rebuilding...${M.reset}`),c$.clear(),r$(),await W()});process.on("SIGINT",()=>{j.close(),_.stop(),process.exit(0)})}return!0}var qH=D(()=>{w7();n0();S7();iZ();N0();E6()});var{serve:BD}=globalThis.Bun;import z1 from"fs";import q0 from"path";function _Q($){let Z=Bun.file($),Y=q0.extname($).toLowerCase(),X={".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(Y)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(Z,{headers:{"Content-Type":X[Y]||"application/octet-stream",...Q}})}async function jH($=".",Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=q0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (t$(),I5)),U=await W(K),B=U.root&&U.root!=="."?q0.join(K,U.root):K,_=U.pagesDir||"pages",z=q0.join(B,_);if(!z1.existsSync(z))return console.error(`${M.red}Error: No '${_}' directory found in ${M.bright}${B}${M.reset}`),console.log(`${M.dim}Create a ${_}/ directory with .stx files to define your routes.${M.reset}`),console.log(`${M.dim}Example: ${_}/index.stx for the homepage.${M.reset}`),!1;let q=U$(B);if(q.length===0)return console.error(`${M.red}Error: No page files found in ${M.bright}${z}${M.reset}`),!1;console.log(`${M.blue}Found ${M.bright}${q.length}${M.blue} routes${M.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:C,prefix:h}of j)if(z1.existsSync(C)){let p=U$(q0.dirname(C),{pagesDir:q0.basename(C)});for(let i of p){let s=h==="/"?i.pattern:`${h}${i.pattern==="/"?"":i.pattern}`;H.push({route:{...i,pattern:s},prefix:h})}if(p.length>0)console.log(`${M.blue}Plugin pages: ${M.bright}${p.length}${M.blue} routes at ${M.cyan}${h}${M.reset}`)}let O=new Map,F=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=await zQ(K,Z.stxOptions?.shell),L){if(F=await nZ(L,Z.stxOptions||{}),F)console.log(`${M.blue}Using app shell: ${M.bright}${q0.relative(K,L)}${M.reset} ${M.dim}(deprecated: use layouts/default.stx instead)${M.reset}`)}}F6(),await w6(K);let V=A6();if(V.length>0)console.log(`${M.blue}Loaded ${M.bright}${V.length}${M.blue} middleware: ${M.dim}${V.join(", ")}${M.reset}`);let N={},A=null;try{let{loadStxConfig:C}=await Promise.resolve().then(() => (t$(),I5)),h=await C(K);if(h?.apiRouter)A=h?.apiRouter,console.log(`${M.blue}Using custom router for API handling${M.reset}`);if(h?.apiRoutes){N=h.apiRoutes;let p=Object.keys(N).length;if(p>0)console.log(`${M.blue}Loaded ${M.bright}${p} API route${p>1?"s":""}${M.reset}`)}if(h?.broadcasting?.enabled)try{let{startBroadcasting:p,loadChannels:i}=await Promise.resolve().then(() => (hZ(),JQ)),s=h.broadcasting;await p(s);let K0=s.port??6001;console.log(`${M.magenta}Broadcasting on ${M.cyan}ws://localhost:${K0}/ws${M.reset}`);let $0=q0.join(process.cwd(),"channels.ts");if(z1.existsSync($0))try{let F0=await i($0);console.log(`${M.blue}Loaded ${M.bright}${F0} broadcast channel${F0!==1?"s":""}${M.blue} from channels.ts${M.reset}`)}catch(F0){console.warn(`${M.yellow}Failed to load channels.ts: ${F0.message}${M.reset}`)}}catch(p){console.warn(`${M.yellow}Broadcasting failed to start: ${p.message}${M.reset}`)}}catch{}let w=q0.join(K,".stx/output");z1.mkdirSync(w,{recursive:!0});let R=new Map,T=new Set,I=async(C)=>{let h=m9(z,C);if(!h)return null;try{let p=await Bun.build({entrypoints:[h],outdir:w,plugins:[n7],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!p.success)return null;let i=p.outputs.find((s)=>s.path.endsWith(".html"));if(!i)return null;return await Bun.file(i.path).text()}catch{return null}},E=async(C,h)=>{try{let{processDirectives:p,extractVariables:i,defaultConfig:s,loadStxConfig:K0,injectRouterScript:$0}=await Promise.resolve().then(() => (t$(),I5)),{checkCache:F0,cacheTemplate:R0,readFileCached:P,templateCache:d}=await Promise.resolve().then(() => (w5(),P7)),m=await K0(K),g=(V0)=>{if(!V0)return V0;if(q0.isAbsolute(V0))return V0;return q0.resolve(K,V0)},c={...s,...m,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)c.debug=!0;c.partialsDir=g(c.partialsDir),c.componentsDir=g(c.componentsDir),c.layoutsDir=g(c.layoutsDir),c.storesDir=g(c.storesDir||"stores"),c.cachePath=g(c.cachePath||".stx/cache");let a=!h&&!Z.profile,l=c.cache!==!1;if(l&&a){let V0=d.get(C.filePath);if(V0)try{if((await z1.promises.stat(C.filePath)).mtime.getTime()<=V0.mtime){let L$=!0;for(let Z1 of V0.dependencies){if(!z1.existsSync(Z1)){L$=!1;break}if((await z1.promises.stat(Z1)).mtime.getTime()>V0.mtime){L$=!1;break}}if(L$){let Z1=V0.output;if(F)Z1=B$(Z1,{preserveHead:!0});return{route:C,content:Z1}}}}catch{}let $1=await F0(C.filePath,c);if($1){let D1=$1;if(F)D1=B$(D1,{preserveHead:!0});return{route:C,content:D1}}}let Q0=l?await P(C.filePath):await Bun.file(C.filePath).text(),{classifyAllScripts:M0}=await Promise.resolve().then(() => (t$(),I5)),w0=M0(Q0),W0=w0.server.map((V0)=>V0.content),r0=Q0;for(let V0 of w0.server)r0=r0.replace(V0.fullTag,"");let p0={__filename:C.filePath,__dirname:q0.dirname(C.filePath),params:h??{}},{resetHead:P5}=await Promise.resolve().then(() => (f$(),v8));P5();for(let V0 of W0)try{await i(V0,p0,C.filePath)}catch($1){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",C.filePath,$1?.message||$1)}let G0=new Set,k0;if(Z.profile){let V0=performance.now();k0=await p(r0,p0,C.filePath,c,G0);let $1=performance.now()-V0,D1=q0.relative(K,C.filePath)||C.filePath;console.log(`[stx:profile] ${D1} \u2192 ${$1.toFixed(2)}ms`)}else k0=await p(r0,p0,C.filePath,c,G0);if(!F)k0=await $0(k0);{let{interpolateScriptExpressions:V0}=await Promise.resolve().then(() => (c0(),V4));k0=k0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,($1,D1,L$)=>{if(!/function\s+__stx_setup_/.test(L$))return $1;return`<script${D1}>${V0(L$,p0)}</script>`})}if(F)k0=B$(k0,{preserveHead:!0});if(l&&a)await R0(C.filePath,k0,G0,c);let{extractStreamBoundaries:Q4}=await Promise.resolve().then(() => (h$(),L5)),E1=Q4(p0),O$=p0.__streamTemplates;if(O$&&typeof O$==="object"&&Object.keys(O$).length>0){let V0=p0.streamBoundaries||{},$1={...c,autoShell:!1},D1=Object.keys(O$).map((Z1)=>({id:Z1,render:async()=>{let oG=typeof V0[Z1]==="function"?await V0[Z1]():void 0;return p(O$[Z1],{...p0,$boundary:oG},C.filePath,$1,new Set)}})),L$=new Set(D1.map((Z1)=>Z1.id));E1=[...(E1||[]).filter((Z1)=>!L$.has(Z1.id)),...D1]}if(E1&&E1.length>0)T.add(C.pattern);else E1=void 0;return{route:C,content:k0,boundaries:E1}}catch(p){return console.error(`${M.red}Error building ${M.bright}${C.pattern}${M.reset}:`,p),null}},k=8,S=async()=>{R.clear(),O.clear();for(let C=0;C<q.length;C+=k){let h=q.slice(C,C+k),p=await Promise.all(h.map((i)=>E(i)));for(let i of p)if(i)R.set(i.route.pattern,i)}for(let C=0;C<H.length;C+=k){let h=H.slice(C,C+k),p=await Promise.all(h.map(({route:i})=>E(i)));for(let i of p)if(i)O.set(i.route.pattern,i)}return R.size>0};if(console.log(`${M.blue}Building pages...${M.reset}`),!await S())return console.error(`${M.red}No pages were successfully built${M.reset}`),!1;await A7(K);let y=Y;try{if(y=await o$(Y),y!==Y)console.log(`${M.yellow}Port ${Y} is busy, using port ${y} instead${M.reset}`)}catch{return console.error(`${M.red}Could not find an available port${M.reset}`),!1}if(J){let C=Z.hmrPort||y+1;Q=b6({wsPort:C,verbose:!1}),G=Q.start(C)}let b=(C,h)=>{let p=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._rp=${JSON.stringify(h)};if(s.setRouteParams)s.setRouteParams(s._rp);})()</script>`;if(C.includes("</head>"))return C.replace("</head>",`${p}</head>`);if(C.includes("<body"))return C.replace(/<body([^>]*)>/,`<body$1>${p}`);return p+C};console.log(`${M.blue}Starting server...${M.reset}`);let f=BD({port:y,async fetch(C){let h=new URL(C.url),p=U?.publicDir||"public",i=q0.join(K,p,h.pathname),s=q0.join(K,h.pathname),K0=q0.join(w,h.pathname),[$0,F0,R0]=await Promise.all([z1.promises.stat(i).catch(()=>null),z1.promises.stat(s).catch(()=>null),z1.promises.stat(K0).catch(()=>null)]);if($0?.isFile())return _Q(i);if(F0?.isFile())return _Q(s);if(R0?.isFile())return _Q(K0);if(h.pathname.startsWith("/_stx/component/")){let g=decodeURIComponent(h.pathname.slice(16));if(g)try{let c=`<${g} />`,a={...buildConfig,autoShell:!1},l=await processDirectives(c,{},q0.join(K,"components",`${g}.stx`),a,new Set);return new Response(l,{headers:{"Content-Type":"text/html"}})}catch(c){return new Response(`<div class="stx-async-error">${c.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(h.pathname==="/_stx/img"){let{handleImageRequest:g}=await Promise.resolve().then(() => (bY(),WK)),c=await g(C,{publicDir:q0.join(K,p),cacheDir:q0.join(K,".stx/cache/img")});if(c)return c}if(A)try{let g=await A.handleRequest(C);if(g.status!==404)return g}catch{}if(N[h.pathname])try{return await N[h.pathname](C)}catch(g){return new Response(JSON.stringify({error:g.message}),{status:500,headers:{"Content-Type":"application/json"}})}let P=xZ(h.pathname,q);if(P){let g=R.get(P.route.pattern),c=T.has(P.route.pattern);if(P.route.isDynamic&&Object.keys(P.params).length>0||c){let a=await E(P.route,P.params);if(a)g=a}if(g){let a=x8();if(a.validate){if(!await a.validate({params:P.params})){let M0=await I(404);if(M0){let w0=M0;if(w0=await T0(w0,K),J)w0=r1(w0,G);return new Response(w0,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(a.middleware){let Q0=N6(h.pathname,P.params,a,h.search),M0=V6(Q0,null,C),w0=await R6(a.middleware,M0);if(w0.redirect){let W0=w0.redirect.path,r0=w0.redirect.options.redirectCode||302,p0=new Headers(w0.responseHeaders);return p0.set("Location",W0),new Response(null,{status:r0,headers:p0})}if(w0.abort){let{statusCode:W0,message:r0}=w0.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${W0}</title></head><body><h1>Error ${W0}</h1><p>${r0}</p></body></html>`,{status:W0,headers:{"Content-Type":"text/html"}})}if(Object.keys(w0.state).length>0){let W0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(w0.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;g.content=g.content.replace("</head>",`${W0}</head>`)}}let l=g.content;if(F&&qQ(C)){let Q0=P6(l);if(Object.keys(P.params).length>0)l=b(l,P.params);l=await T0(l,K);let M0=U?.router?.container||"main";return l=T6(l,M0),new Response(l,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Q0.layout,"X-STX-Layout-Group":Q0.group,"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(F)l=y6(F,l);if(Object.keys(P.params).length>0)l=b(l,P.params);if(l=await T0(l,K),J)l=r1(l,G);if(Z.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;if(Z.titlebarHidden)if(l.includes("<head>"))l=l.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 l=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${l}`;if(g.boundaries&&g.boundaries.length>0){let{renderStreamingPage:Q0,streamToResponse:M0}=await Promise.resolve().then(() => (h$(),L5));return M0(Q0(l,g.boundaries,{timeoutMs:30000}),{headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(l,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let g=H.map((a)=>a.route),c=xZ(h.pathname,g);if(c){let a=O.get(c.route.pattern);if(a){let l=a.content;if(F)l=y6(F,l);if(Object.keys(c.params).length>0)l=b(l,c.params);if(l=await T0(l,K),J)l=r1(l,G);return new Response(l,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:a}of j)if(a!=="/"&&h.pathname.startsWith(a)){let l=O.get(a)||O.get(a+"/");if(l){let Q0=l.content;if(F)Q0=y6(F,Q0);if(Q0=await T0(Q0,K),J)Q0=r1(Q0,G);return new Response(Q0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let d=R.get("/");if(d){let g=d.content;if(g=await T0(g,K),J)g=r1(g,G);if(Z.native)if(g.includes("<head>"))g=g.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 g="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+g;return new Response(g,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let m=await I(404);if(m){let g=m;if(g=await T0(g,K),J)g=r1(g,G);return new Response(g,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(C){let h=await I(500);if(h)return new Response(h,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${C}
13600
13600
  ${C.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
13601
13601
  ${M.blue}stx${M.reset} ${M.green}${process.env.stx_VERSION||"v0.0.10"}${M.reset} ${M.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${M.reset}`),console.log(`
13602
13602
  ${M.bright}\u2192 ${M.cyan}http://localhost:${y}/${M.reset}`),J)console.log(`${M.dim} HMR: ws://localhost:${G}${M.reset}`);console.log(`
13603
13603
  ${M.yellow}Routes:${M.reset}`);let u=[...p9(q,K)];for(let{route:C}of H)u.push(`${C.pattern}`);if(u.forEach((C,h)=>{let i=h===u.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${M.green}${i}${M.reset}${C}`)}),console.log(`
13604
- Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),a$(f.url.toString(),()=>{if(Q)i7();f.stop()}),Z.native){let C,h=q0.join(z,"index.stx");if(z1.existsSync(h)){let i=await Bun.file(h).text();C=cZ(i)}let m=U?.app?.window??{};await p7(y,{title:U?.app?.head?.title||q0.basename(K)||"stx App",width:m.width,height:m.height,darkMode:m.darkMode,hotReload:m.hotReload,titlebarHidden:m.titlebarHidden??Z.titlebarHidden===!0,nativeSidebar:!!C,sidebarConfig:C})}if(X){console.log(`${M.blue}Watching for changes...${M.reset}`);let C=(i)=>{return i.startsWith("public/")||i.startsWith("public\\")},h=(i)=>{let s=i.toLowerCase();return s.endsWith(".stx")||s.endsWith(".html")||s.endsWith(".md")},m=z1.watch(K,{recursive:!0},async(i,s)=>{if(!s||S6(s))return;if(k6(s))if(C(s)){if(console.log(`${M.cyan}${s} changed${M.reset}`),J&&Q)Q.reload(s)}else if(h(s)){console.log(`${M.yellow}${s} changed, rebuilding...${M.reset}`),c$.clear(),r$();try{let{invalidateFileCache:K0,templateCache:$0}=await Promise.resolve().then(() => (w5(),P7));K0(q0.resolve(K,s)),$0.delete(q0.resolve(K,s))}catch{}if(L&&s){if(q0.resolve(K,s)===L||q0.basename(L)===s){let $0=await nZ(L,Z.stxOptions||{});if($0)F=$0}}if(await S(),await p4(K),J&&Q)Q.reload(s)}else{console.log(`${M.yellow}${s} changed, rebuilding...${M.reset}`),c$.clear(),r$();try{let{invalidateFileCache:K0,templateCache:$0}=await Promise.resolve().then(() => (w5(),P7));K0(q0.resolve(K,s)),$0.delete(q0.resolve(K,s))}catch{}if(await S(),J&&Q)Q.reload(s)}else if(D6(s)){if(console.log(`${M.cyan}CSS ${s} changed${M.reset}`),J&&Q)Q.updateCss(s)}});process.on("SIGINT",()=>{if(m.close(),Q)i7();f.stop(),process.exit(0)})}return!0}var HH=D(()=>{u7();S7();iZ();M6();yZ();f$();N0();E6()});var OH=D(()=>{KQ();_H();qH();HH()});import jQ from"fs";import x6 from"path";async function LH($){try{let Y=(await Bun.file($).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return[];let X=Y[1],J=[],Q=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,G;while((G=Q.exec(X))!==null){let K=G[1],W=G[2]||G[3]||G[4];if(!W)continue;let U={name:W},B=K.match(/@type\s+\{([^}]+)\}/i);if(B)U.type=B[1].trim();if(K.match(/@required/i))U.required=!0;let z=K.match(/@default\s+(.+?)(?:\s+|$)/i);if(z)U.default=z[1].trim();let q=K.split(`
13604
+ Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),a$(f.url.toString(),()=>{if(Q)i7();f.stop()}),Z.native){let C,h=q0.join(z,"index.stx");if(z1.existsSync(h)){let i=await Bun.file(h).text();C=cZ(i)}let p=U?.app?.window??{};await p7(y,{title:U?.app?.head?.title||q0.basename(K)||"stx App",width:p.width,height:p.height,darkMode:p.darkMode,hotReload:p.hotReload,titlebarHidden:p.titlebarHidden??Z.titlebarHidden===!0,nativeSidebar:!!C,sidebarConfig:C})}if(X){console.log(`${M.blue}Watching for changes...${M.reset}`);let C=(i)=>{return i.startsWith("public/")||i.startsWith("public\\")},h=(i)=>{let s=i.toLowerCase();return s.endsWith(".stx")||s.endsWith(".html")||s.endsWith(".md")},p=z1.watch(K,{recursive:!0},async(i,s)=>{if(!s||S6(s))return;if(k6(s))if(C(s)){if(console.log(`${M.cyan}${s} changed${M.reset}`),J&&Q)Q.reload(s)}else if(h(s)){console.log(`${M.yellow}${s} changed, rebuilding...${M.reset}`),c$.clear(),r$();try{let{invalidateFileCache:K0,templateCache:$0}=await Promise.resolve().then(() => (w5(),P7));K0(q0.resolve(K,s)),$0.delete(q0.resolve(K,s))}catch{}if(L&&s){if(q0.resolve(K,s)===L||q0.basename(L)===s){let $0=await nZ(L,Z.stxOptions||{});if($0)F=$0}}if(await S(),await p4(K),J&&Q)Q.reload(s)}else{console.log(`${M.yellow}${s} changed, rebuilding...${M.reset}`),c$.clear(),r$();try{let{invalidateFileCache:K0,templateCache:$0}=await Promise.resolve().then(() => (w5(),P7));K0(q0.resolve(K,s)),$0.delete(q0.resolve(K,s))}catch{}if(await S(),J&&Q)Q.reload(s)}else if(D6(s)){if(console.log(`${M.cyan}CSS ${s} changed${M.reset}`),J&&Q)Q.updateCss(s)}});process.on("SIGINT",()=>{if(p.close(),Q)i7();f.stop(),process.exit(0)})}return!0}var HH=D(()=>{u7();S7();iZ();M6();yZ();f$();N0();E6()});var OH=D(()=>{KQ();_H();qH();HH()});import jQ from"fs";import x6 from"path";async function LH($){try{let Y=(await Bun.file($).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return[];let X=Y[1],J=[],Q=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,G;while((G=Q.exec(X))!==null){let K=G[1],W=G[2]||G[3]||G[4];if(!W)continue;let U={name:W},B=K.match(/@type\s+\{([^}]+)\}/i);if(B)U.type=B[1].trim();if(K.match(/@required/i))U.required=!0;let z=K.match(/@default\s+(.+?)(?:\s+|$)/i);if(z)U.default=z[1].trim();let q=K.split(`
13605
13605
  `).map((j)=>j.trim().replace(/^\*\s*/,"")).filter((j)=>!j.startsWith("@")&&j.length>0);U.description=q.join(" ").trim(),J.push(U)}if(J.length===0){let K=X.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(K){let U=K[1].split(",").map((B)=>B.trim()).filter(Boolean);for(let B of U){let[_]=B.split(":").map((z)=>z.trim());if(_)J.push({name:_})}}}return J}catch(Z){return console.error(`Error extracting props from ${$}:`,Z),[]}}async function FH($){try{let Z=await Bun.file($).text(),Y=Z.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||Z.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(Y)return Y[1].split(`
13606
13606
  `).map((X)=>X.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function VH($,Z=!1,Y){let X=x6.basename($,".stx"),J=await LH($),Q=await FH($),G="";if(Z&&Y)G=`<${Y}></${Y}>`;else{let K=J.map((W)=>{if(W.type==="boolean")return`:${W.name}="true"`;return`${W.name}="value"`}).join(`
13607
13607
  `);G=`<${X}
@@ -14744,7 +14744,7 @@ describe('Example', () => {
14744
14744
  </footer>
14745
14745
  @yield('scripts')
14746
14746
  </body>
14747
- </html>`}function rk(){return"<!-- Hero section -->"}function ok(){return"<!-- Features -->"}function ak(){return"<!-- Pricing -->"}function tk(){return"<!-- Button -->"}function m6($){if(!u6($))wQ($,{recursive:!0})}function ek(){if(u6("bun.lockb"))return"bun";if(u6("pnpm-lock.yaml"))return"pnpm";if(u6("yarn.lock"))return"yarn";return"bun"}function RQ($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function $S($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function D5($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var Ok;var WO=D(()=>{Ok={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:ZS}=globalThis.Bun;import p6 from"fs";import X5 from"path";function YS($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function UO($={}){let{port:Z=3000,root:Y=".",stxOptions:X={},watch:J=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,B=X5.resolve(Y),_=new Map;async function z(L){let V=p6.statSync(L),N=`${L}:${V.mtimeMs}`,A=_.get(N);if(A)return A.content;for(let C of _.keys())if(C.startsWith(`${L}:`)&&C!==N)_.delete(C);let w=await Bun.file(L).text(),R=w,T=w.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>/i);if(T&&T.index!==void 0){let C=T.index+T[0].length,h=1,m=C;while(m<w.length&&h>0){let i=w.indexOf("<template",m),s=w.indexOf("</template>",m);if(s===-1)break;if(i!==-1&&i<s)h++,m=i+9;else{if(h--,h===0){R=w.substring(C,s).trim();break}m=s+11}}}let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[],k=[],S;while((S=I.exec(w))!==null){let C=S[1],h=S[2],m=S[0];if(C.includes("server"))k.push(h);else E.push(m)}let P=w.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],y=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),b={__filename:L,__dirname:X5.dirname(L)};for(let C of k)await D0(C,b,L);let u=await X0(y,b,L,X,new Set);if(P.length>0){let C=P.join(`
14747
+ </html>`}function rk(){return"<!-- Hero section -->"}function ok(){return"<!-- Features -->"}function ak(){return"<!-- Pricing -->"}function tk(){return"<!-- Button -->"}function m6($){if(!u6($))wQ($,{recursive:!0})}function ek(){if(u6("bun.lockb"))return"bun";if(u6("pnpm-lock.yaml"))return"pnpm";if(u6("yarn.lock"))return"yarn";return"bun"}function RQ($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function $S($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function D5($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var Ok;var WO=D(()=>{Ok={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:ZS}=globalThis.Bun;import p6 from"fs";import X5 from"path";function YS($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function UO($={}){let{port:Z=3000,root:Y=".",stxOptions:X={},watch:J=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,B=X5.resolve(Y),_=new Map;async function z(L){let V=p6.statSync(L),N=`${L}:${V.mtimeMs}`,A=_.get(N);if(A)return A.content;for(let C of _.keys())if(C.startsWith(`${L}:`)&&C!==N)_.delete(C);let w=await Bun.file(L).text(),R=w,T=w.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>/i);if(T&&T.index!==void 0){let C=T.index+T[0].length,h=1,p=C;while(p<w.length&&h>0){let i=w.indexOf("<template",p),s=w.indexOf("</template>",p);if(s===-1)break;if(i!==-1&&i<s)h++,p=i+9;else{if(h--,h===0){R=w.substring(C,s).trim();break}p=s+11}}}let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[],k=[],S;while((S=I.exec(w))!==null){let C=S[1],h=S[2],p=S[0];if(C.includes("server"))k.push(h);else E.push(p)}let x=w.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],y=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),b={__filename:L,__dirname:X5.dirname(L)};for(let C of k)await D0(C,b,L);let u=await X0(y,b,L,X,new Set);if(x.length>0){let C=x.join(`
14748
14748
  `);if(u.match(/(<\/head>)/i))u=u.replace(/(<\/head>)/i,`${C}
14749
14749
  $1`)}if(E.length>0){let{interpolateScriptsInTemplate:C}=await Promise.resolve().then(() => (c0(),V4)),h=C(E.join(`
14750
14750
  `),b);if(u.match(/(<\/body>)/i))u=u.replace(/(<\/body>)/i,`${h}