@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
@@ -1117,7 +1117,7 @@ ${H}
1117
1117
  filter: blur(0);
1118
1118
  transform: scale(1);
1119
1119
  }
1120
- `.trim();X5=new Map});import{createHash as y7}from"crypto";import{readFile as tG,stat as DZ}from"fs/promises";async function T0($){try{let Z=await tG($);return y7("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function XF($){return y7("sha256").update($).digest("hex").slice(0,16)}function IZ($){return y7("sha256").update($).digest("hex").slice(0,16)}function M$($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${IZ($)}-${IZ(Y)}`}async function C7($){try{return(await DZ($)).mtimeMs}catch{return 0}}async function A0($){try{return await DZ($),!0}catch{return!1}}var b1=()=>{};import{mkdir as eG,readFile as kZ,writeFile as $K,readdir as SZ,rm as P7,stat as ZK}from"fs/promises";import{join as J5,dirname as YK}from"path";async function XK($){try{await eG($,{recursive:!0})}catch{}}function bZ($,Z,Y){return J5($,Y,`${Z}.json`)}async function EZ($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await C7(Z)!==$.srcMtime)return!1;return!0}async function I$($,Z,Y,X=Q5){if(!X.enabled)return null;let J=M$($,Z),Q=t0.get(J);if(Q){if(await EZ(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;t0.delete(J)}let G=bZ(X.directory,J,Y);if(await A0(G))try{let K=await kZ(G,"utf-8"),q=JSON.parse(K);if(await EZ(q,$,X.maxAge))return q.lastAccessedAt=Date.now(),t0.set(J,q),q.data}catch{}return null}async function D$($,Z,Y,X,J=Q5){if(!J.enabled)return;let Q=M$($,Z),G=await T0($),K=await C7($),q={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:M$("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};t0.set(Q,q);let z=bZ(J.directory,Q,X);try{await XK(YK(z)),await $K(z,JSON.stringify(q,null,2))}catch(U){console.warn(`[stx-media] Failed to write cache: ${U}`)}}async function qF($,Z,Y=Q5){for(let[X,J]of t0.entries())if(J.src===$)t0.delete(X)}async function E$($,Z=Q5){if($==="all")t0.clear();else t0.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=J5(Z.directory,X);try{await P7(J,{recursive:!0,force:!0})}catch{}}}async function zF($=Q5){let Z={memoryEntries:t0.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=J5($.directory,Y);try{let J=await SZ(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=J5(X,Q),K=await ZK(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function UF($=Q5){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=J5($.directory,X);try{let Q=await SZ(J);for(let G of Q){let K=J5(J,G);try{let q=await kZ(K,"utf-8"),z=JSON.parse(q);if(Date.now()-z.createdAt>Y)await P7(K),t0.delete(z.key),Z++}catch{await P7(K).catch(()=>{}),Z++}}}catch{}}return Z}var t0,Q5;var v7=y(()=>{b1();t0=new Map,Q5={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class S${config;constructor($={}){this.config={...JK,...$}}async get($,Z){return I$($,Z,"image",this.config)}async set($,Z,Y){return D$($,Z,Y,"image",this.config)}async clear(){return E$("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function x7($){if(!k$)k$=new S$($);else if($)k$.updateConfig($);return k$}async function b$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return x7(X).get($,Z)}async function y$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return x7(J).set($,Z,Y)}async function yZ(){return x7().clear()}var JK,k$=null;var f7=y(()=>{v7();JK={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as QK,basename as GK,extname as KK,join as qK}from"path";import{mkdir as zK}from"fs/promises";async function g7(){try{return await import("ts-images")}catch{return null}}function CZ($){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 UK($,Z){let Y=Z?CZ(Z):CZ("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 PZ($,Z,Y){let X=await g7();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await b$($,Z,Y);if(J)return J;try{let Q=QK($);if(!await A0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=UK(Y,Z.preset),K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await zK(K,{recursive:!0});let z=await T0(Q),U=GK($,KK($)),W=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:z},B=null;if(Z.transformations&&Z.transformations.length>0)B=await h7(Q,Z.transformations,X);for(let j of W){let H=G[j]||{},L=`${U}-${z}.${j}`,F=qK(K,L);try{let O=await X.optimizeImage({input:B||Q,output:F,format:j,quality:H.quality,progressive:H.progressive});if(O){if(_.variants.push({path:F,url:`${q}/${L}`,width:O.width||0,height:O.height||0,format:j,size:O.outputSize||0}),!_.originalWidth&&O.width)_.originalWidth=O.width,_.originalHeight=O.height}}catch(O){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${j}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);_.placeholder=j.dataUrl}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});_.dominantColor=j.dominantColor}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to extract dominant color: ${j}`)}return await y$($,Z,_,Y),_}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function vZ($,Z,Y,X){let J=await g7();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 h7($,Z,Y){let X=Y||await g7();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 xZ=y(()=>{b1();f7()});import{resolve as WK,basename as _K,extname as BK,join as jK}from"path";import{mkdir as HK}from"fs/promises";async function OK(){try{return await import("ts-images")}catch{return null}}async function d7($,Z,Y){let X=await OK();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=WK($);if(!await A0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||LK,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await HK(K,{recursive:!0});let z=await T0(J),U=_K($,BK($)),W=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},_={src:$,byFormat:{},srcsets:{}};for(let j of G){_.byFormat[j]=[];let H=[];for(let L of Q){let F=`${U}-${L}w-${z}.${j}`,O=jK(K,F),V=`${q}/${F}`;try{let w=W[j]?.quality||80;if(await A0(O)){_.byFormat[j].push({path:O,url:V,width:L,height:0,format:j,size:0}),H.push(`${V} ${L}w`);continue}let R=await X.processImage({input:J,output:O,format:j,quality:w,resize:{width:L}});if(R)_.byFormat[j].push({path:O,url:V,width:L,height:R.height||Math.round(L*(R.height||1)/(R.width||1)),format:j,size:R.outputSize||0}),H.push(`${V} ${L}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${w}`)}}_.srcsets[j]=H.join(", ")}let B=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(B!=="none")try{if(B==="thumbhash"){let j=await X.generateThumbHash(J);_.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:B,width:20});_.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:B}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return _.sizes=Z.sizes||FK(Q),_}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function FK($){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 fZ($,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(", ")}async function TF($,Z,Y){let X=[];for(let J of Z){let Q=await d7(J.src,{responsiveWidths:J.widths},Y);if(Q){for(let[G,K]of Object.entries(Q.srcsets))if(K)X.push({media:J.media,srcset:K,type:VK(G)})}}return X}function VK($){switch($){case"avif":return"image/avif";case"webp":return"image/webp";case"jpeg":return"image/jpeg";case"png":return"image/png";case"gif":return"image/gif";default:return"image/jpeg"}}var LK;var gZ=y(()=>{b1();LK=[320,480,640,768,1024,1280,1536,1920]});var hZ={};c(hZ,{setCachedImageResult:()=>y$,processImage:()=>PZ,optimizeImage:()=>vZ,getCachedImageResult:()=>b$,generateSrcset:()=>fZ,generateResponsiveVariants:()=>d7,clearImageCache:()=>yZ,applyTransformations:()=>h7,ImageProcessorCache:()=>S$});var dZ=y(()=>{xZ();gZ();f7()});async function wK(){try{return await Promise.resolve().then(() => (dZ(),hZ))}catch($){if(!uZ)console.warn("[stx-media] Image processor not available, some features disabled:",$),uZ=!0;return null}}async function x5($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return MK(X,Y)}if(Y.processedResult?.processed)return c7($,Y.processedResult,Z);if(Y.responsiveVariants)return lZ($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:q,widths:z=S1,dpr:U,formats:W=Y5,quality:_=u7,params:B={},placeholder:j="none",placeholderOptions:H={},lazy:L=!0,priority:F=!1,loading:O=F?"eager":P$,decoding:V=C$,fetchpriority:w,objectFit:R,objectPosition:A,crossorigin:N,referrerpolicy:M}=$,T=$.class,I=$.style,D=$.id,E=$.data||{},{isDev:k=!1,baseUrl:S=""}=Z;if(k&&!Z.optimize)return NK($);let b,C,d=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{b=await TZ(J,{strategy:j,...H}),C=NZ(d,b,H)}catch{}let f=U!==void 0&&G!==void 0,m;if(f)m=AK($,d,b,Z);else m=await RK($,d,b,Z);let o;if(F){let C0=W.includes("webp")?"webp":W[0],E0=v5(J,z,{...B,q:_},C0),X0=typeof q==="object"?D7(q):q||"100vw";o=`<link rel="preload" as="image" imagesrcset="${E0}" imagesizes="${X0}" />`}let N0=[];if(!mZ&&j!=="none")N0.push(S7),mZ=!0;if(C)N0.push(C);let Z1=L?cZ(d):void 0;return{html:m,preloadLink:o,css:N0.length>0?N0.join(`
1120
+ `.trim();X5=new Map});import{createHash as y7}from"crypto";import{readFile as tG,stat as DZ}from"fs/promises";async function M0($){try{let Z=await tG($);return y7("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function XF($){return y7("sha256").update($).digest("hex").slice(0,16)}function IZ($){return y7("sha256").update($).digest("hex").slice(0,16)}function M$($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${IZ($)}-${IZ(Y)}`}async function C7($){try{return(await DZ($)).mtimeMs}catch{return 0}}async function A0($){try{return await DZ($),!0}catch{return!1}}var b1=()=>{};import{mkdir as eG,readFile as kZ,writeFile as $K,readdir as SZ,rm as P7,stat as ZK}from"fs/promises";import{join as J5,dirname as YK}from"path";async function XK($){try{await eG($,{recursive:!0})}catch{}}function bZ($,Z,Y){return J5($,Y,`${Z}.json`)}async function EZ($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await C7(Z)!==$.srcMtime)return!1;return!0}async function I$($,Z,Y,X=Q5){if(!X.enabled)return null;let J=M$($,Z),Q=t0.get(J);if(Q){if(await EZ(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;t0.delete(J)}let G=bZ(X.directory,J,Y);if(await A0(G))try{let K=await kZ(G,"utf-8"),q=JSON.parse(K);if(await EZ(q,$,X.maxAge))return q.lastAccessedAt=Date.now(),t0.set(J,q),q.data}catch{}return null}async function D$($,Z,Y,X,J=Q5){if(!J.enabled)return;let Q=M$($,Z),G=await M0($),K=await C7($),q={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:M$("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};t0.set(Q,q);let z=bZ(J.directory,Q,X);try{await XK(YK(z)),await $K(z,JSON.stringify(q,null,2))}catch(U){console.warn(`[stx-media] Failed to write cache: ${U}`)}}async function qF($,Z,Y=Q5){for(let[X,J]of t0.entries())if(J.src===$)t0.delete(X)}async function E$($,Z=Q5){if($==="all")t0.clear();else t0.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=J5(Z.directory,X);try{await P7(J,{recursive:!0,force:!0})}catch{}}}async function zF($=Q5){let Z={memoryEntries:t0.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=J5($.directory,Y);try{let J=await SZ(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=J5(X,Q),K=await ZK(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function UF($=Q5){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=J5($.directory,X);try{let Q=await SZ(J);for(let G of Q){let K=J5(J,G);try{let q=await kZ(K,"utf-8"),z=JSON.parse(q);if(Date.now()-z.createdAt>Y)await P7(K),t0.delete(z.key),Z++}catch{await P7(K).catch(()=>{}),Z++}}}catch{}}return Z}var t0,Q5;var v7=y(()=>{b1();t0=new Map,Q5={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class S${config;constructor($={}){this.config={...JK,...$}}async get($,Z){return I$($,Z,"image",this.config)}async set($,Z,Y){return D$($,Z,Y,"image",this.config)}async clear(){return E$("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function x7($){if(!k$)k$=new S$($);else if($)k$.updateConfig($);return k$}async function b$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return x7(X).get($,Z)}async function y$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return x7(J).set($,Z,Y)}async function yZ(){return x7().clear()}var JK,k$=null;var f7=y(()=>{v7();JK={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as QK,basename as GK,extname as KK,join as qK}from"path";import{mkdir as zK}from"fs/promises";async function g7(){try{return await import("ts-images")}catch{return null}}function CZ($){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 UK($,Z){let Y=Z?CZ(Z):CZ("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 PZ($,Z,Y){let X=await g7();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await b$($,Z,Y);if(J)return J;try{let Q=QK($);if(!await A0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=UK(Y,Z.preset),K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await zK(K,{recursive:!0});let z=await M0(Q),U=GK($,KK($)),W=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:z},B=null;if(Z.transformations&&Z.transformations.length>0)B=await h7(Q,Z.transformations,X);for(let j of W){let H=G[j]||{},L=`${U}-${z}.${j}`,F=qK(K,L);try{let O=await X.optimizeImage({input:B||Q,output:F,format:j,quality:H.quality,progressive:H.progressive});if(O){if(_.variants.push({path:F,url:`${q}/${L}`,width:O.width||0,height:O.height||0,format:j,size:O.outputSize||0}),!_.originalWidth&&O.width)_.originalWidth=O.width,_.originalHeight=O.height}}catch(O){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${j}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);_.placeholder=j.dataUrl}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});_.dominantColor=j.dominantColor}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to extract dominant color: ${j}`)}return await y$($,Z,_,Y),_}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function vZ($,Z,Y,X){let J=await g7();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 h7($,Z,Y){let X=Y||await g7();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 xZ=y(()=>{b1();f7()});import{resolve as WK,basename as _K,extname as BK,join as jK}from"path";import{mkdir as HK}from"fs/promises";async function OK(){try{return await import("ts-images")}catch{return null}}async function d7($,Z,Y){let X=await OK();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=WK($);if(!await A0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||LK,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await HK(K,{recursive:!0});let z=await M0(J),U=_K($,BK($)),W=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},_={src:$,byFormat:{},srcsets:{}};for(let j of G){_.byFormat[j]=[];let H=[];for(let L of Q){let F=`${U}-${L}w-${z}.${j}`,O=jK(K,F),V=`${q}/${F}`;try{let w=W[j]?.quality||80;if(await A0(O)){_.byFormat[j].push({path:O,url:V,width:L,height:0,format:j,size:0}),H.push(`${V} ${L}w`);continue}let R=await X.processImage({input:J,output:O,format:j,quality:w,resize:{width:L}});if(R)_.byFormat[j].push({path:O,url:V,width:L,height:R.height||Math.round(L*(R.height||1)/(R.width||1)),format:j,size:R.outputSize||0}),H.push(`${V} ${L}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${w}`)}}_.srcsets[j]=H.join(", ")}let B=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(B!=="none")try{if(B==="thumbhash"){let j=await X.generateThumbHash(J);_.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:B,width:20});_.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:B}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return _.sizes=Z.sizes||FK(Q),_}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function FK($){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 fZ($,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(", ")}async function TF($,Z,Y){let X=[];for(let J of Z){let Q=await d7(J.src,{responsiveWidths:J.widths},Y);if(Q){for(let[G,K]of Object.entries(Q.srcsets))if(K)X.push({media:J.media,srcset:K,type:VK(G)})}}return X}function VK($){switch($){case"avif":return"image/avif";case"webp":return"image/webp";case"jpeg":return"image/jpeg";case"png":return"image/png";case"gif":return"image/gif";default:return"image/jpeg"}}var LK;var gZ=y(()=>{b1();LK=[320,480,640,768,1024,1280,1536,1920]});var hZ={};c(hZ,{setCachedImageResult:()=>y$,processImage:()=>PZ,optimizeImage:()=>vZ,getCachedImageResult:()=>b$,generateSrcset:()=>fZ,generateResponsiveVariants:()=>d7,clearImageCache:()=>yZ,applyTransformations:()=>h7,ImageProcessorCache:()=>S$});var dZ=y(()=>{xZ();gZ();f7()});async function wK(){try{return await Promise.resolve().then(() => (dZ(),hZ))}catch($){if(!uZ)console.warn("[stx-media] Image processor not available, some features disabled:",$),uZ=!0;return null}}async function x5($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return MK(X,Y)}if(Y.processedResult?.processed)return c7($,Y.processedResult,Z);if(Y.responsiveVariants)return lZ($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:q,widths:z=S1,dpr:U,formats:W=Y5,quality:_=u7,params:B={},placeholder:j="none",placeholderOptions:H={},lazy:L=!0,priority:F=!1,loading:O=F?"eager":P$,decoding:V=C$,fetchpriority:w,objectFit:R,objectPosition:A,crossorigin:N,referrerpolicy:M}=$,T=$.class,I=$.style,D=$.id,E=$.data||{},{isDev:k=!1,baseUrl:S=""}=Z;if(k&&!Z.optimize)return NK($);let b,P,d=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{b=await TZ(J,{strategy:j,...H}),P=NZ(d,b,H)}catch{}let f=U!==void 0&&G!==void 0,m;if(f)m=AK($,d,b,Z);else m=await RK($,d,b,Z);let o;if(F){let C0=W.includes("webp")?"webp":W[0],k0=v5(J,z,{...B,q:_},C0),X0=typeof q==="object"?D7(q):q||"100vw";o=`<link rel="preload" as="image" imagesrcset="${k0}" imagesizes="${X0}" />`}let N0=[];if(!mZ&&j!=="none")N0.push(S7),mZ=!0;if(P)N0.push(P);let Z1=L?cZ(d):void 0;return{html:m,preloadLink:o,css:N0.length>0?N0.join(`
1121
1121
  `):void 0,script:Z1}}async function RK($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:q,widths:z=S1,formats:U=Y5,quality:W=u7,params:_={},lazy:B=!0,priority:j=!1,loading:H=j?"eager":P$,decoding:L=C$,fetchpriority:F,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:R}=$,A=$.class,N=$.style,M=$.data||{},T=typeof q==="object"?D7(q):q||"100vw",I=[];for(let k of U){let S=v5(J,z,{..._,q:W},k),b=E7(k);if(B&&!j)I.push(` <source type="${b}" data-srcset="${S}" data-sizes="${T}" />`);else I.push(` <source type="${b}" srcset="${S}" sizes="${T}" />`)}let D=m7({src:W1(J,{..._,q:W}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:L,fetchpriority:j?"high":F,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:R,className:pZ(A,Y),style:p7(N,O,V,Y),lazy:B&&!j,data:M}),E;if(Y){let k=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;E=`<div id="${Z}" class="stx-img-placeholder" style="${k}">
1122
1122
  <picture>
1123
1123
  ${I.join(`
@@ -1167,7 +1167,7 @@ ${I.join(`
1167
1167
 
1168
1168
  observer.observe(container);
1169
1169
  })();
1170
- `.trim()}function TK($){let Z=$.match(/<Img\s+([^>]*?)\/?>/);if(!Z)return null;let Y=Z[1],X={},J=/(:?)(\w+)(?:=(?:"([^"]*)"|'([^']*)'|\{([^}]+)\}))?/g,Q;while((Q=J.exec(Y))!==null){let[,G,K,q,z,U]=Q,W=q??z??U??!0;if(G===":"&&typeof W==="string")try{X[K]=JSON.parse(W)}catch{X[K]=W}else switch(K){case"src":X.src=String(W);break;case"alt":X.alt=String(W);break;case"width":X.width=Number(W)||W;break;case"height":X.height=Number(W)||W;break;case"sizes":X.sizes=String(W);break;case"quality":X.quality=Number(W);break;case"placeholder":X.placeholder=W;break;case"lazy":X.lazy=W===!0||W==="true";break;case"priority":X.priority=W===!0||W==="true";break;case"class":X.class=String(W);break;case"style":X.style=String(W);break;case"id":X.id=String(W);break;case"loading":X.loading=W;break;case"decoding":X.decoding=W;break;case"fetchpriority":X.fetchpriority=W;break;case"objectFit":X.objectFit=W;break;case"objectPosition":X.objectPosition=String(W);break;case"crossorigin":X.crossorigin=W;break}}if(!X.src||!X.alt)return null;return X}async function bF($,Z={}){let Y=/<Img\s+[^>]*?\/?>/g,X=[],J=[],Q=[],G=$,K=[],q;while((q=Y.exec($))!==null)K.push({match:q[0],index:q.index});for(let z=K.length-1;z>=0;z--){let{match:U}=K[z],W=TK(U);if(W){let _=await x5(W,Z);if(G=G.replace(U,_.html),_.preloadLink)X.push(_.preloadLink);if(_.css)J.push(_.css);if(_.script)Q.push(_.script)}}return{html:G,preloadLinks:X,styles:J,scripts:Q}}async function MK($,Z){let Y=await wK();if(!Y)return x5({...$,process:!1},Z);let X=Z.tsImagesConfig;if($.responsiveWidths&&$.responsiveWidths.length>0||$.widths&&$.widths.length>0||!$.width&&!$.dpr){let Q=await Y.generateResponsiveVariants($.src,$,X);if(Q)return lZ($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return c7($,Q,Z)}return x5({...$,process:!1},Z)}async function c7($,Z,Y){let{alt:X,width:J,height:Q,lazy:G=!0,priority:K=!1,objectFit:q,objectPosition:z,crossorigin:U,referrerpolicy:W}=$,_=$.class,B=$.style,j=$.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,H=$.data||{},L=Z.variants||[],F=L.find((C)=>C.format==="jpeg")||L.find((C)=>C.format==="webp")||L[0],O=F?.url||$.src,V=L.filter((C)=>C.format===(F?.format||"jpeg")).map((C)=>`${C.url} ${C.width}w`).join(", "),w=new Map;for(let C of L){if(!w.has(C.format))w.set(C.format,[]);w.get(C.format).push(C)}let R=[],A=["avif","webp","jpeg","png"];for(let C of A){let d=w.get(C);if(d&&d.length>0){let f=d.map((o)=>`${o.url} ${o.width}w`).join(", "),m=E7(C);if(G&&!K)R.push(` <source type="${m}" data-srcset="${f}" />`);else R.push(` <source type="${m}" srcset="${f}" />`)}}let N=[];if(G&&!K){if(N.push(`data-src="${m0(O)}"`),N.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),V)N.push(`data-srcset="${V}"`)}else if(N.push(`src="${m0(O)}"`),V)N.push(`srcset="${V}"`);N.push(`alt="${m0(X)}"`);let M=J||Z.originalWidth,T=Q||Z.originalHeight;if(M)N.push(`width="${M}"`);if(T)N.push(`height="${T}"`);if(!K)N.push(`loading="${G?"lazy":"eager"}"`);if(N.push('decoding="async"'),K)N.push('fetchpriority="high"');if(U)N.push(`crossorigin="${U}"`);if(W)N.push(`referrerpolicy="${W}"`);let I=[];if(q)I.push(`object-fit: ${q}`);if(z)I.push(`object-position: ${z}`);if(Z.placeholder&&G)I.push("opacity: 0; transition: opacity 300ms ease-out");if(B)I.push(B);if(I.length>0)N.push(`style="${I.join("; ")}"`);let D=[];if(_)D.push(_);if(Z.placeholder)D.push("stx-img-blur");if(D.length>0)N.push(`class="${D.join(" ")}"`);if(G&&!K)N.push("data-stx-lazy");for(let[C,d]of Object.entries(H))N.push(`data-${C}="${m0(d)}"`);let E;if(Z.placeholder||Z.dominantColor&&$.useDominantColor){let C=Z.placeholder?`background-image: url('${Z.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${Z.dominantColor};`;E=`<div id="${j}" class="stx-img-placeholder" style="${C}">
1170
+ `.trim()}function TK($){let Z=$.match(/<Img\s+([^>]*?)\/?>/);if(!Z)return null;let Y=Z[1],X={},J=/(:?)(\w+)(?:=(?:"([^"]*)"|'([^']*)'|\{([^}]+)\}))?/g,Q;while((Q=J.exec(Y))!==null){let[,G,K,q,z,U]=Q,W=q??z??U??!0;if(G===":"&&typeof W==="string")try{X[K]=JSON.parse(W)}catch{X[K]=W}else switch(K){case"src":X.src=String(W);break;case"alt":X.alt=String(W);break;case"width":X.width=Number(W)||W;break;case"height":X.height=Number(W)||W;break;case"sizes":X.sizes=String(W);break;case"quality":X.quality=Number(W);break;case"placeholder":X.placeholder=W;break;case"lazy":X.lazy=W===!0||W==="true";break;case"priority":X.priority=W===!0||W==="true";break;case"class":X.class=String(W);break;case"style":X.style=String(W);break;case"id":X.id=String(W);break;case"loading":X.loading=W;break;case"decoding":X.decoding=W;break;case"fetchpriority":X.fetchpriority=W;break;case"objectFit":X.objectFit=W;break;case"objectPosition":X.objectPosition=String(W);break;case"crossorigin":X.crossorigin=W;break}}if(!X.src||!X.alt)return null;return X}async function bF($,Z={}){let Y=/<Img\s+[^>]*?\/?>/g,X=[],J=[],Q=[],G=$,K=[],q;while((q=Y.exec($))!==null)K.push({match:q[0],index:q.index});for(let z=K.length-1;z>=0;z--){let{match:U}=K[z],W=TK(U);if(W){let _=await x5(W,Z);if(G=G.replace(U,_.html),_.preloadLink)X.push(_.preloadLink);if(_.css)J.push(_.css);if(_.script)Q.push(_.script)}}return{html:G,preloadLinks:X,styles:J,scripts:Q}}async function MK($,Z){let Y=await wK();if(!Y)return x5({...$,process:!1},Z);let X=Z.tsImagesConfig;if($.responsiveWidths&&$.responsiveWidths.length>0||$.widths&&$.widths.length>0||!$.width&&!$.dpr){let Q=await Y.generateResponsiveVariants($.src,$,X);if(Q)return lZ($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return c7($,Q,Z)}return x5({...$,process:!1},Z)}async function c7($,Z,Y){let{alt:X,width:J,height:Q,lazy:G=!0,priority:K=!1,objectFit:q,objectPosition:z,crossorigin:U,referrerpolicy:W}=$,_=$.class,B=$.style,j=$.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,H=$.data||{},L=Z.variants||[],F=L.find((P)=>P.format==="jpeg")||L.find((P)=>P.format==="webp")||L[0],O=F?.url||$.src,V=L.filter((P)=>P.format===(F?.format||"jpeg")).map((P)=>`${P.url} ${P.width}w`).join(", "),w=new Map;for(let P of L){if(!w.has(P.format))w.set(P.format,[]);w.get(P.format).push(P)}let R=[],A=["avif","webp","jpeg","png"];for(let P of A){let d=w.get(P);if(d&&d.length>0){let f=d.map((o)=>`${o.url} ${o.width}w`).join(", "),m=E7(P);if(G&&!K)R.push(` <source type="${m}" data-srcset="${f}" />`);else R.push(` <source type="${m}" srcset="${f}" />`)}}let N=[];if(G&&!K){if(N.push(`data-src="${m0(O)}"`),N.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),V)N.push(`data-srcset="${V}"`)}else if(N.push(`src="${m0(O)}"`),V)N.push(`srcset="${V}"`);N.push(`alt="${m0(X)}"`);let M=J||Z.originalWidth,T=Q||Z.originalHeight;if(M)N.push(`width="${M}"`);if(T)N.push(`height="${T}"`);if(!K)N.push(`loading="${G?"lazy":"eager"}"`);if(N.push('decoding="async"'),K)N.push('fetchpriority="high"');if(U)N.push(`crossorigin="${U}"`);if(W)N.push(`referrerpolicy="${W}"`);let I=[];if(q)I.push(`object-fit: ${q}`);if(z)I.push(`object-position: ${z}`);if(Z.placeholder&&G)I.push("opacity: 0; transition: opacity 300ms ease-out");if(B)I.push(B);if(I.length>0)N.push(`style="${I.join("; ")}"`);let D=[];if(_)D.push(_);if(Z.placeholder)D.push("stx-img-blur");if(D.length>0)N.push(`class="${D.join(" ")}"`);if(G&&!K)N.push("data-stx-lazy");for(let[P,d]of Object.entries(H))N.push(`data-${P}="${m0(d)}"`);let E;if(Z.placeholder||Z.dominantColor&&$.useDominantColor){let P=Z.placeholder?`background-image: url('${Z.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${Z.dominantColor};`;E=`<div id="${j}" class="stx-img-placeholder" style="${P}">
1171
1171
  <picture>
1172
1172
  ${R.join(`
1173
1173
  `)}
@@ -1181,8 +1181,8 @@ ${R.join(`
1181
1181
  `):void 0,script:S}}async function lZ($,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 c7($,X,Y)}var uZ=!1,u7=80,C$="async",P$="lazy",mZ=!1;var iZ=y(()=>{k7();MZ()});function IK(){return B0({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}=DK($,Z,Y);if(!J)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:J,alt:Q||"",widths:G.widths||S1,formats:G.formats||Y5,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},q=Y.__isDev||!1,z=await x5(K,{isDev:q}),U=z.html;if(z.preloadLink)U=z.preloadLink+`
1182
1182
  `+U;if(z.css)U+=`
1183
1183
  <style>${z.css}</style>`;if(z.script)U+=`
1184
- <script>${z.script}</script>`;return U},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function DK($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let X=$.trim();if(X.startsWith("@img(")||X.startsWith("("))X=X.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let J=EK(X),Q=l7(J[0],Y)||"",G=l7(J[1],Y)||"",K={};if(J[2]){let q=l7(J[2],Y);if(typeof q==="object"&&q!==null)K=q;else if(typeof J[2]==="string")try{K=JSON.parse(J[2])}catch{}}return{src:Q,alt:G,options:K}}function EK($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let q=$[K],z=K>0?$[K-1]:"";if((q==='"'||q==="'"||q==="`")&&z!=="\\"){if(!X)X=!0,J=q;else if(q===J)X=!1,J="";else Y+=q;continue}if(!X){if(q==="{")Q++;if(q==="}")Q--;if(q==="[")G++;if(q==="]")G--;if(q===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=q}if(Y.trim())Z.push(Y.trim());return Z}function l7($,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 nZ;var oZ=y(()=>{L7();iZ();k7();nZ=IK()});class x${config;constructor($={}){this.config={...kK,...$}}async get($,Z){return I$($,Z,"video",this.config)}async set($,Z,Y){return D$($,Z,Y,"video",this.config)}async clear(){return E$("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function i7($){if(!v$)v$=new x$($);else if($)v$.updateConfig($);return v$}async function f$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return i7(X).get($,Z)}async function g$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return i7(J).set($,Z,Y)}async function sZ(){return i7().clear()}var kK,v$=null;var n7=y(()=>{v7();kK={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as o7,basename as s7,extname as r7,join as h$}from"path";import{mkdir as a7}from"fs/promises";async function t7(){try{return await import("ts-videos")}catch{return null}}async function d$($,Z,Y,X){let J=await t7();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=o7($);if(!await A0(Q))return null;await a7(Y,{recursive:!0});let G=await T0(Q),K=s7($,r7($)),q=Z.format||"webp",z=Z.timestamp||0,U=`${K}-poster-${G}.${q}`,W=h$(Y,U),_=await J.extractThumbnails(Q,{timestamps:[z],width:Z.width||1280,height:Z.height,format:q,quality:Z.quality||85,outputDir:Y,outputPattern:U.replace(`.${q}`,"")});if(_&&_.length>0){let B=_[0];return{path:W,url:`${X}/${U}`,width:B.width||Z.width||1280,height:B.height||720,timestamp:z,size:B.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function u$($,Z,Y,X){let J=await t7();if(!J)return[];try{let Q=o7($);if(!await A0(Q))return[];await a7(Y,{recursive:!0});let G=await T0(Q),K=s7($,r7($)),q=Z.format||"webp",W=(await new J.Input(Q).getInfo()).duration||60,_=Z.count||10,B=Z.interval||W/_,j=[];for(let L=0;L<_&&L*B<W;L++)j.push(L*B);let H=await J.extractThumbnails(Q,{timestamps:j,width:Z.width||320,format:q,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((L,F)=>({path:L.path||h$(Y,`${K}-thumb-${G}-${F}.${q}`),url:`${X}/${K}-thumb-${G}-${F}.${q}`,width:L.width||Z.width||320,height:L.height||180,timestamp:j[F],size:L.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function rZ($,Z,Y,X){let J=await t7();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=o7($);if(!await A0(Q))return null;await a7(Y,{recursive:!0});let G=await T0(Q),K=s7($,r7($)),U=(await new J.Input(Q).getInfo()).duration||60,W=Z.columns||10,_=Z.interval||5,B=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",L=Math.ceil(U/_),F=Math.ceil(L/W),O=`${K}-sprite-${G}.${H}`,V=h$(Y,O),w=[];for(let A=0;A<L;A++)w.push(A*_);let R=await J.extractThumbnails(Q,{timestamps:w,width:B,height:j,format:H,quality:Z.quality||70,outputDir:h$(Y,".temp")});if(!R||R.length===0)return null;try{let A=await import("ts-images"),N=W*B,M=F*j,T=await A.createSprite({images:R.map((I)=>I.path),columns:W,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${X}/${O}`,path:V,columns:W,rows:F,thumbnailWidth:B,thumbnailHeight:j,interval:_,totalFrames:L}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(Q){return console.warn(`[stx-media] Failed to generate sprite sheet: ${Q}`),null}}var e7=y(()=>{b1()});import{resolve as tZ,basename as eZ,extname as $Y,join as y1}from"path";import{mkdir as m$,writeFile as ZY}from"fs/promises";async function YY(){try{return await import("ts-videos")}catch{return null}}async function p$($,Z,Y,X,J){let Q=await YY();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=tZ($);if(!await A0(G))return null;let K=await T0(G),q=eZ($,$Y($)),z=y1(Y,`${q}-${K}-hls`);await m$(z,{recursive:!0});let U=Z.length>0?Z:XY,W=J?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,H=[],L=0;for(let V of U){let w=y1(z,V.label);await m$(w,{recursive:!0});let R=`${V.label}.m3u8`,A=y1(w,R);try{let N=await Q.generateHLS(G,{outputDir:w,segmentDuration:W,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(N)H.push({quality:V,url:`${X}/${q}-${K}-hls/${V.label}/${R}`,path:A}),L+=N.segmentCount||Math.ceil(j/W)}catch(N){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${N}`)}}if(H.length===0)return null;let F=y1(z,"master.m3u8"),O=SK(H,X,q,K);return await ZY(F,O),{manifestUrl:`${X}/${q}-${K}-hls/master.m3u8`,manifestPath:F,playlists:H,segmentCount:L,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function SK($,Z,Y,X){let J=["#EXTM3U","#EXT-X-VERSION:3"];for(let Q of $){let{quality:G}=Q,K=G.bitrate+(G.audioBitrate||128000),q=`${G.width}x${G.height||Math.round(G.width*9/16)}`;J.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${q},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return J.join(`
1185
- `)}async function c$($,Z,Y,X,J){let Q=await YY();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=tZ($);if(!await A0(G))return null;let K=await T0(G),q=eZ($,$Y($)),z=y1(Y,`${q}-${K}-dash`);await m$(z,{recursive:!0});let U=Z.length>0?Z:XY,W=J?.segmentDuration||4,_=J?.minBufferTime||2,H=(await new Q.Input(G).getInfo()).duration||0,L=[],F=[];for(let R of U){let A=y1(z,R.label);await m$(A,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:A,segmentDuration:W,width:R.width,height:R.height,videoBitrate:R.bitrate,audioBitrate:R.audioBitrate})){if(L.push({bandwidth:R.bitrate,width:R.width,height:R.height||Math.round(R.width*9/16),url:`${X}/${q}-${K}-dash/${R.label}/video`}),R.audioBitrate)F.push({bandwidth:R.audioBitrate,url:`${X}/${q}-${K}-dash/${R.label}/audio`})}}catch(N){console.warn(`[stx-media] Failed to generate DASH for ${R.label}: ${N}`)}}if(L.length===0)return null;let O=y1(z,"manifest.mpd"),V=bK(L,F,H,W,_);await ZY(O,V);let w=[{type:"video",representations:L}];if(F.length>0)w.push({type:"audio",representations:F});return{manifestUrl:`${X}/${q}-${K}-dash/manifest.mpd`,manifestPath:O,adaptationSets:w,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function bK($,Z,Y,X,J){let Q=aZ(Y),G=aZ(J),K=`<?xml version="1.0" encoding="UTF-8"?>
1184
+ <script>${z.script}</script>`;return U},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function DK($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let X=$.trim();if(X.startsWith("@img(")||X.startsWith("("))X=X.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let J=EK(X),Q=l7(J[0],Y)||"",G=l7(J[1],Y)||"",K={};if(J[2]){let q=l7(J[2],Y);if(typeof q==="object"&&q!==null)K=q;else if(typeof J[2]==="string")try{K=JSON.parse(J[2])}catch{}}return{src:Q,alt:G,options:K}}function EK($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let q=$[K],z=K>0?$[K-1]:"";if((q==='"'||q==="'"||q==="`")&&z!=="\\"){if(!X)X=!0,J=q;else if(q===J)X=!1,J="";else Y+=q;continue}if(!X){if(q==="{")Q++;if(q==="}")Q--;if(q==="[")G++;if(q==="]")G--;if(q===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=q}if(Y.trim())Z.push(Y.trim());return Z}function l7($,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 nZ;var oZ=y(()=>{L7();iZ();k7();nZ=IK()});class x${config;constructor($={}){this.config={...kK,...$}}async get($,Z){return I$($,Z,"video",this.config)}async set($,Z,Y){return D$($,Z,Y,"video",this.config)}async clear(){return E$("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function i7($){if(!v$)v$=new x$($);else if($)v$.updateConfig($);return v$}async function f$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return i7(X).get($,Z)}async function g$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return i7(J).set($,Z,Y)}async function sZ(){return i7().clear()}var kK,v$=null;var n7=y(()=>{v7();kK={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as o7,basename as s7,extname as r7,join as h$}from"path";import{mkdir as a7}from"fs/promises";async function t7(){try{return await import("ts-videos")}catch{return null}}async function d$($,Z,Y,X){let J=await t7();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=o7($);if(!await A0(Q))return null;await a7(Y,{recursive:!0});let G=await M0(Q),K=s7($,r7($)),q=Z.format||"webp",z=Z.timestamp||0,U=`${K}-poster-${G}.${q}`,W=h$(Y,U),_=await J.extractThumbnails(Q,{timestamps:[z],width:Z.width||1280,height:Z.height,format:q,quality:Z.quality||85,outputDir:Y,outputPattern:U.replace(`.${q}`,"")});if(_&&_.length>0){let B=_[0];return{path:W,url:`${X}/${U}`,width:B.width||Z.width||1280,height:B.height||720,timestamp:z,size:B.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function u$($,Z,Y,X){let J=await t7();if(!J)return[];try{let Q=o7($);if(!await A0(Q))return[];await a7(Y,{recursive:!0});let G=await M0(Q),K=s7($,r7($)),q=Z.format||"webp",W=(await new J.Input(Q).getInfo()).duration||60,_=Z.count||10,B=Z.interval||W/_,j=[];for(let L=0;L<_&&L*B<W;L++)j.push(L*B);let H=await J.extractThumbnails(Q,{timestamps:j,width:Z.width||320,format:q,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((L,F)=>({path:L.path||h$(Y,`${K}-thumb-${G}-${F}.${q}`),url:`${X}/${K}-thumb-${G}-${F}.${q}`,width:L.width||Z.width||320,height:L.height||180,timestamp:j[F],size:L.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function rZ($,Z,Y,X){let J=await t7();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=o7($);if(!await A0(Q))return null;await a7(Y,{recursive:!0});let G=await M0(Q),K=s7($,r7($)),U=(await new J.Input(Q).getInfo()).duration||60,W=Z.columns||10,_=Z.interval||5,B=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",L=Math.ceil(U/_),F=Math.ceil(L/W),O=`${K}-sprite-${G}.${H}`,V=h$(Y,O),w=[];for(let A=0;A<L;A++)w.push(A*_);let R=await J.extractThumbnails(Q,{timestamps:w,width:B,height:j,format:H,quality:Z.quality||70,outputDir:h$(Y,".temp")});if(!R||R.length===0)return null;try{let A=await import("ts-images"),N=W*B,M=F*j,T=await A.createSprite({images:R.map((I)=>I.path),columns:W,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${X}/${O}`,path:V,columns:W,rows:F,thumbnailWidth:B,thumbnailHeight:j,interval:_,totalFrames:L}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(Q){return console.warn(`[stx-media] Failed to generate sprite sheet: ${Q}`),null}}var e7=y(()=>{b1()});import{resolve as tZ,basename as eZ,extname as $Y,join as y1}from"path";import{mkdir as m$,writeFile as ZY}from"fs/promises";async function YY(){try{return await import("ts-videos")}catch{return null}}async function p$($,Z,Y,X,J){let Q=await YY();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=tZ($);if(!await A0(G))return null;let K=await M0(G),q=eZ($,$Y($)),z=y1(Y,`${q}-${K}-hls`);await m$(z,{recursive:!0});let U=Z.length>0?Z:XY,W=J?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,H=[],L=0;for(let V of U){let w=y1(z,V.label);await m$(w,{recursive:!0});let R=`${V.label}.m3u8`,A=y1(w,R);try{let N=await Q.generateHLS(G,{outputDir:w,segmentDuration:W,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(N)H.push({quality:V,url:`${X}/${q}-${K}-hls/${V.label}/${R}`,path:A}),L+=N.segmentCount||Math.ceil(j/W)}catch(N){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${N}`)}}if(H.length===0)return null;let F=y1(z,"master.m3u8"),O=SK(H,X,q,K);return await ZY(F,O),{manifestUrl:`${X}/${q}-${K}-hls/master.m3u8`,manifestPath:F,playlists:H,segmentCount:L,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function SK($,Z,Y,X){let J=["#EXTM3U","#EXT-X-VERSION:3"];for(let Q of $){let{quality:G}=Q,K=G.bitrate+(G.audioBitrate||128000),q=`${G.width}x${G.height||Math.round(G.width*9/16)}`;J.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${q},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return J.join(`
1185
+ `)}async function c$($,Z,Y,X,J){let Q=await YY();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=tZ($);if(!await A0(G))return null;let K=await M0(G),q=eZ($,$Y($)),z=y1(Y,`${q}-${K}-dash`);await m$(z,{recursive:!0});let U=Z.length>0?Z:XY,W=J?.segmentDuration||4,_=J?.minBufferTime||2,H=(await new Q.Input(G).getInfo()).duration||0,L=[],F=[];for(let R of U){let A=y1(z,R.label);await m$(A,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:A,segmentDuration:W,width:R.width,height:R.height,videoBitrate:R.bitrate,audioBitrate:R.audioBitrate})){if(L.push({bandwidth:R.bitrate,width:R.width,height:R.height||Math.round(R.width*9/16),url:`${X}/${q}-${K}-dash/${R.label}/video`}),R.audioBitrate)F.push({bandwidth:R.audioBitrate,url:`${X}/${q}-${K}-dash/${R.label}/audio`})}}catch(N){console.warn(`[stx-media] Failed to generate DASH for ${R.label}: ${N}`)}}if(L.length===0)return null;let O=y1(z,"manifest.mpd"),V=bK(L,F,H,W,_);await ZY(O,V);let w=[{type:"video",representations:L}];if(F.length>0)w.push({type:"audio",representations:F});return{manifestUrl:`${X}/${q}-${K}-dash/manifest.mpd`,manifestPath:O,adaptationSets:w,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function bK($,Z,Y,X,J){let Q=aZ(Y),G=aZ(J),K=`<?xml version="1.0" encoding="UTF-8"?>
1186
1186
  <MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
1187
1187
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1188
1188
  xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
@@ -1208,7 +1208,7 @@ ${R.join(`
1208
1208
  </Representation>
1209
1209
  `}K+=` </AdaptationSet>
1210
1210
  `}return K+=` </Period>
1211
- </MPD>`,K}function aZ($){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 XY;var $3=y(()=>{b1();XY=[{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 JY,basename as yK,extname as CK,join as PK}from"path";import{mkdir as vK}from"fs/promises";async function QY(){try{return await import("ts-videos")}catch{return null}}function xK($){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 fK($){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 Z3($){let Z=await QY();if(!Z)return null;try{let Y=JY($),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 GY($,Z,Y,X){let J=await QY();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await f$($,Z,Y);if(Q)return Q;try{let G=JY($);if(!await A0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",q=Y.baseUrl||"/videos";await vK(K,{recursive:!0});let z=await T0(G),U=yK($,CK($)),W={src:$,processed:!0,hash:z};X?.({percentage:5,stage:"analyzing"}),W.metadata=await Z3(G)||void 0;let _={};if(Z.quality)_.bitrate=xK(Z.quality);if(Z.platform)Object.assign(_,fK(Z.platform));if(Z.transcode)Object.assign(_,Z.transcode);if(Object.keys(_).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let B=`${U}-${z}.mp4`,j=PK(K,B);try{let H=await gK(G,j,_,J,(L)=>X?.({percentage:10+L*0.5,stage:"transcoding"}));if(H)W.transcoded={path:j,url:`${q}/${B}`,duration:H.duration,size:H.size,video:{codec:_.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:_.audioCodec||"aac",bitrate:_.audioBitrate||128000,sampleRate:_.sampleRate||48000,channels:_.channels||2}:void 0}}catch(H){W.errors=W.errors||[],W.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let B=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await d$(G,B,K,q);if(j)W.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let B=await u$(G,Y.thumbnails,K,q);if(B.length>0)W.thumbnails=B}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let B=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(B.format==="hls"||B.format===void 0){let j=await p$(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)W.streaming={...W.streaming,hls:j}}if(B.format==="dash"){let j=await c$(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)W.streaming={...W.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await g$($,Z,W,Y),W}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function gK($,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 KY=y(()=>{b1();n7();e7();$3()});var qY={};c(qY,{setCachedVideoResult:()=>g$,processVideo:()=>GY,getCachedVideoResult:()=>f$,generateThumbnails:()=>u$,generateSpriteSheet:()=>rZ,generatePoster:()=>d$,generateHLSManifest:()=>p$,generateDASHManifest:()=>c$,clearVideoCache:()=>sZ,analyzeVideo:()=>Z3,VideoProcessorCache:()=>x$});var zY=y(()=>{KY();e7();$3();n7()});async function WY(){try{return await Promise.resolve().then(() => (zY(),qY))}catch($){if(!UY)console.warn("[stx-media] Video processor not available, some features disabled:",$),UY=!0;return null}}async function l$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return cK(X,Y)}if(Y.processedResult?.processed)return HY($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await lK(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:q,controls:z=_Y,autoplay:U=!1,muted:W=!1,loop:_=!1,preload:B=BY,playsinline:j=!0,lazy:H=!0,player:L="native",type:F,width:O,height:V,crossorigin:w,disablePictureInPicture:R=!1,disableRemotePlayback:A=!1}=$,N=J||K,M=$.class,T=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(L==="ts-video")return uK($,Z);if(F&&F!=="video")return dK(Q||"",F,$);let D=G.length>0?G:Q?[{src:Q,type:jY(Q)}]:[],E=[`id="${I}"`];if(z)E.push("controls");if(U)E.push("autoplay");if(W)E.push("muted");if(_)E.push("loop");if(j)E.push("playsinline");if(R)E.push("disablepictureinpicture");if(A)E.push("disableremoteplayback");if(w)E.push(`crossorigin="${w}"`);if(H){if(E.push(`data-preload="${B}"`),E.push('preload="none"'),N)E.push(`data-poster="${H0(N)}"`);E.push("data-stx-lazy")}else if(E.push(`preload="${B}"`),N)E.push(`poster="${H0(N)}"`);if(O)E.push(`width="${O}"`);if(V)E.push(`height="${V}"`);if(M)E.push(`class="${H0(M)}"`);if(T)E.push(`style="${H0(T)}"`);let k=D.map((C)=>{return` <source ${H?`data-src="${H0(C.src)}"`:`src="${H0(C.src)}"`} type="${C.type}"${C.media?` media="${C.media}"`:""} />`}).join(`
1211
+ </MPD>`,K}function aZ($){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 XY;var $3=y(()=>{b1();XY=[{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 JY,basename as yK,extname as CK,join as PK}from"path";import{mkdir as vK}from"fs/promises";async function QY(){try{return await import("ts-videos")}catch{return null}}function xK($){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 fK($){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 Z3($){let Z=await QY();if(!Z)return null;try{let Y=JY($),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 GY($,Z,Y,X){let J=await QY();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await f$($,Z,Y);if(Q)return Q;try{let G=JY($);if(!await A0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",q=Y.baseUrl||"/videos";await vK(K,{recursive:!0});let z=await M0(G),U=yK($,CK($)),W={src:$,processed:!0,hash:z};X?.({percentage:5,stage:"analyzing"}),W.metadata=await Z3(G)||void 0;let _={};if(Z.quality)_.bitrate=xK(Z.quality);if(Z.platform)Object.assign(_,fK(Z.platform));if(Z.transcode)Object.assign(_,Z.transcode);if(Object.keys(_).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let B=`${U}-${z}.mp4`,j=PK(K,B);try{let H=await gK(G,j,_,J,(L)=>X?.({percentage:10+L*0.5,stage:"transcoding"}));if(H)W.transcoded={path:j,url:`${q}/${B}`,duration:H.duration,size:H.size,video:{codec:_.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:_.audioCodec||"aac",bitrate:_.audioBitrate||128000,sampleRate:_.sampleRate||48000,channels:_.channels||2}:void 0}}catch(H){W.errors=W.errors||[],W.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let B=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await d$(G,B,K,q);if(j)W.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let B=await u$(G,Y.thumbnails,K,q);if(B.length>0)W.thumbnails=B}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let B=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(B.format==="hls"||B.format===void 0){let j=await p$(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)W.streaming={...W.streaming,hls:j}}if(B.format==="dash"){let j=await c$(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)W.streaming={...W.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await g$($,Z,W,Y),W}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function gK($,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 KY=y(()=>{b1();n7();e7();$3()});var qY={};c(qY,{setCachedVideoResult:()=>g$,processVideo:()=>GY,getCachedVideoResult:()=>f$,generateThumbnails:()=>u$,generateSpriteSheet:()=>rZ,generatePoster:()=>d$,generateHLSManifest:()=>p$,generateDASHManifest:()=>c$,clearVideoCache:()=>sZ,analyzeVideo:()=>Z3,VideoProcessorCache:()=>x$});var zY=y(()=>{KY();e7();$3();n7()});async function WY(){try{return await Promise.resolve().then(() => (zY(),qY))}catch($){if(!UY)console.warn("[stx-media] Video processor not available, some features disabled:",$),UY=!0;return null}}async function l$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return cK(X,Y)}if(Y.processedResult?.processed)return HY($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await lK(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:q,controls:z=_Y,autoplay:U=!1,muted:W=!1,loop:_=!1,preload:B=BY,playsinline:j=!0,lazy:H=!0,player:L="native",type:F,width:O,height:V,crossorigin:w,disablePictureInPicture:R=!1,disableRemotePlayback:A=!1}=$,N=J||K,M=$.class,T=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(L==="ts-video")return uK($,Z);if(F&&F!=="video")return dK(Q||"",F,$);let D=G.length>0?G:Q?[{src:Q,type:jY(Q)}]:[],E=[`id="${I}"`];if(z)E.push("controls");if(U)E.push("autoplay");if(W)E.push("muted");if(_)E.push("loop");if(j)E.push("playsinline");if(R)E.push("disablepictureinpicture");if(A)E.push("disableremoteplayback");if(w)E.push(`crossorigin="${w}"`);if(H){if(E.push(`data-preload="${B}"`),E.push('preload="none"'),N)E.push(`data-poster="${H0(N)}"`);E.push("data-stx-lazy")}else if(E.push(`preload="${B}"`),N)E.push(`poster="${H0(N)}"`);if(O)E.push(`width="${O}"`);if(V)E.push(`height="${V}"`);if(M)E.push(`class="${H0(M)}"`);if(T)E.push(`style="${H0(T)}"`);let k=D.map((P)=>{return` <source ${H?`data-src="${H0(P.src)}"`:`src="${H0(P.src)}"`} type="${P.type}"${P.media?` media="${P.media}"`:""} />`}).join(`
1212
1212
  `),S=`<video ${E.join(" ")}>
1213
1213
  ${k}
1214
1214
  Your browser does not support the video tag.
@@ -2317,7 +2317,7 @@ else { this.removeAttribute('${E}'); }`:`this.setAttribute('${E}', ${I.type==="o
2317
2317
  }
2318
2318
  else {
2319
2319
  this.removeAttribute('${E}');
2320
- }`:"",b=I.observer?`this.${I.observer}(value, oldValue);`:"",C=I.render!==!1?"this._scheduleRender();":"";return`
2320
+ }`:"",b=I.observer?`this.${I.observer}(value, oldValue);`:"",P=I.render!==!1?"this._scheduleRender();":"";return`
2321
2321
  get ${T}(): ${D} {
2322
2322
  return this._${T};
2323
2323
  }
@@ -2327,7 +2327,7 @@ else {
2327
2327
  if (oldValue === value) return;
2328
2328
  this._${T} = value;${S}
2329
2329
  ${b}
2330
- ${C}
2330
+ ${P}
2331
2331
  this.dispatchEvent(new CustomEvent('${T}-changed', {
2332
2332
  detail: { value, oldValue },
2333
2333
  bubbles: true
@@ -2933,8 +2933,8 @@ ${U}
2933
2933
  customElements.define('${Z}', ${G});
2934
2934
  `}async function gY($,Z,Y,X){if(Z.length<1)return r("WebComponent","@webcomponent directive requires at least the tag name parameter",l.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[_1.join(_1.dirname(X),G,`${J}.stx`),_1.join(process.cwd(),G,`${J}.stx`),_1.join(_1.dirname(X),`${J}.stx`)],q=null;for(let W of K)if(await n(W)){q=await Bun.file(W).text();break}if(!q)return r("WebComponent",`Component file not found: ${J}.stx`,l.FILE_NOT_FOUND);let z=Cq(q,J);return`<script type="module">
2935
2935
  ${Pq(z)}
2936
- </script>`}var H3;var hY=y(()=>{Q1();V0();H3={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var dY={};c(dY,{timingPlugin:()=>hq,pluginManager:()=>vq,definePlugin:()=>Z4,debugPlugin:()=>gq,createVariablesPlugin:()=>dq,createFilterPlugin:()=>fq,createDirectivePlugin:()=>xq,PluginManager:()=>L3});function Z4($){return $}class L3{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,X]of this.plugins)if(X.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let X of this.sortedPlugins){let J=X[$];if(J)try{let Q=await J(Y);if(Q){if(Q.template!==void 0)Y.template=Q.template;if(Q.context)Y.context={...Y.context,...Q.context};if(Q.metadata)Y.metadata={...Y.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${X.name}" ${$} hook:`,Q)}}return Y}async runDirectiveHooks($,Z,Y){let X={...Y};for(let J of this.sortedPlugins){let Q=J[$];if(Q)try{let G=await Q(Z,X);if(G){if(G.template!==void 0)X.template=G.template;if(G.context)X.context={...X.context,...G.context};if(G.metadata)X.metadata={...X.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${J.name}" ${$} hook:`,G)}}return X}}function xq($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function fq($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function dq($){return Z4({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var vq,gq,hq;var uY=y(()=>{vq=new L3;gq=Z4({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),hq=Z4({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var pY={};c(pY,{validateConfig:()=>cq,loadStxConfig:()=>X4,defineStxConfig:()=>pq,defaultConfig:()=>v1,config:()=>V3});import F3 from"fs";import M0 from"path";import{loadConfigWithResult as uq}from"bunfig";function mq($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=M0.join(process.cwd(),"resources","views"),J=M0.join(process.cwd(),"resources","layouts");if(F3.existsSync(X)&&F3.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=M0.join(process.cwd(),"resources","views","pages");if(F3.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function X4($){if(!$){if(z5)return z5;if(Y4)return Y4}let Z=$?M0.resolve($):process.cwd(),Y=mY.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await uq({name:"stx",alias:"ui",cwd:Z,defaultConfig:v1,verbose:!1})).config,G=mq(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!M0.isAbsolute(Q.partialsDir))Q.partialsDir=M0.join(K,Q.partialsDir);if(Q.componentsDir&&!M0.isAbsolute(Q.componentsDir))Q.componentsDir=M0.join(K,Q.componentsDir);if(Q.layoutsDir&&!M0.isAbsolute(Q.layoutsDir))Q.layoutsDir=M0.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (uY(),dY)),q=[],z=[];for(let U of Q.plugins){let W=typeof U==="string"?U:U[0],_=typeof U==="string"?{}:U[1]||{};try{let B,j;try{B=await import(W),j=M0.dirname(Q0.resolve(W))}catch{let L=M0.resolve(process.cwd(),W);B=await import(L),j=M0.dirname(L)}let H=B.default||B;if(K.register(H,Q),H.components){let L=M0.resolve(j,H.components);q.push(L)}if(H.pages){let L=M0.resolve(j,H.pages),F=_.path||"/";z.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,O)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=O},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:j,config:Q};await H.setup(_,L)}console.log(`[stx] Plugin loaded: ${H.name||W}`)}catch(B){console.warn(`[stx] Failed to load plugin ${W}:`,B.message)}}Q._pluginComponentDirs=q,Q._pluginPageDirs=z}return Q})();if(mY.set(Z,X),!$)Y4=X,X.then((J)=>{z5=J}).catch(()=>{});return X}function pq($){return $}function cq($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${J}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${J}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${J}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${J}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${J}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((J,Q)=>{if(!J.pattern||typeof J.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(J.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(J.maxAgeSeconds!==void 0&&(typeof J.maxAgeSeconds!=="number"||J.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(J.maxEntries!==void 0&&(typeof J.maxEntries!=="number"||J.maxEntries<1))Z.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((J)=>typeof J!=="number"||J<16||J>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!X.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var v1,z5=null,mY,Y4=null,V3;var h5=y(()=>{U7();H7();R7();A7();M7();oZ();X3();VY();j3();hY();v1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:T7,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:gY,hasEndTag:!1,description:"Include a web component in the template"},B$,j$,_3,B3,W7,B7,j7,_7,_Z,HZ,nZ,Y3,...J3],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};mY=new Map;V3=new Proxy(v1,{get($,Z){if(z5&&Z in z5)return z5[Z];if(!Y4)X4().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});var eq={};c(eq,{resetCssCache:()=>sq,resetCrosswindCache:()=>rq,rebuildCrosswindCSS:()=>aq,loadCrosswindConfig:()=>T3,loadCrosswind:()=>N3,injectCrosswindCSS:()=>u5,getCachedCSS:()=>tq,generateCrosswindCSS:()=>nY,extractClassNames:()=>iY,buildCrosswindCSS:()=>lY});import Q4 from"fs";import Y0 from"path";function A3($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function w3($,Z){if(G1.has($))G1.delete($);else if(G1.size>=lq)G1.delete(G1.keys().next().value);G1.set($,Z)}async function iq($){if(!B1)return null;try{let Z=Bun.file(Y0.join(B1,`cw-${A3($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function nq($,Z){if(!B1)return;try{if(!Q4.existsSync(B1))Q4.mkdirSync(B1,{recursive:!0});await Bun.write(Y0.join(B1,`cw-${A3($)}.css`),Z)}catch{}}async function cY($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig}}catch{}return null}function oq(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==Y0.dirname(Y))$.push(Y0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(Y0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(Y0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push(Y0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push(Y0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(Y0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=Y0.dirname(Y);if(Z){let X=[Y0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),Y0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),Y0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),Y0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),Y0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),Y0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(Y0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(Y0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function N3(){if(R3)return W5;R3=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await cY(Y);if(X){if(W5=X,!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} CSS engine loaded`);return W5}}let Z=oq();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await cY(Y);if(X){if(W5=X,!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} CSS engine loaded from ${Y0.dirname(Y0.dirname(Y))}`);return W5}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${K0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${K0.reset}`),console.warn(`${K0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${K0.reset}`),null}}function sq(){G1.clear()}function rq(){W5=null,R3=!1,c0=null,d5="",G1.clear(),J4=null}async function T3($){try{let{loadConfigWithResult:Z}=await import("bunfig"),Y=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let X=Y0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${K0.yellow}[Crosswind]${K0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function lY($){if(U5)return d5;U5=!0;try{let Z=await N3();if(!Z||!Z.build)return U5=!1,"";if(!c0)c0=await T3($);if(!c0)return U5=!1,"";let Y=Z.defaultConfig?.theme||{},X=c0.theme||{},J={...Z.defaultConfig,...c0,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(d5=G.css,console.log(`${K0.cyan}[Crosswind]${K0.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let q=Y0.isAbsolute(J.output)?J.output:Y0.join($,J.output),z=Y0.dirname(q);if(!Q4.existsSync(z))Q4.mkdirSync(z,{recursive:!0});await Bun.write(q,G.css)}return U5=!1,G.css}catch(Z){return console.error(`${K0.red}[Crosswind]${K0.reset} Build error:`,Z),U5=!1,d5}}async function aq($){c0=null,await lY($)}function tq(){return d5}function iY($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,X=Y.exec($);while(X!==null){for(let G of X[1].split(/\s+/))if(G.trim())Z.add(G.trim());X=Y.exec($)}let J=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,Q=J.exec($);while(Q!==null){let G=Q[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let q of K.slice(1,-1).split(/\s+/))if(q.trim())Z.add(q.trim())}Q=J.exec($)}return Z}async function nY($,Z){try{let Y=await N3();if(!Y)return"";let X=iY($);if(X.size===0)return"";let J=Z?Y0.resolve(Z):process.cwd();if(!B1)B1=Y0.join(J,".stx/cache");let Q=[...X].sort().join(" "),G=`${J4||"default"}::${Q}`,K=G1.get(G);if(K!==void 0)return w3(G,K),K;let q=await iq(G);if(q!==null)return w3(G,q),q;if(!c0){let R=null;try{let{loadStxConfig:A}=await Promise.resolve().then(() => (h5(),pY)),N=await A(J);if(N.css)if(typeof N.css==="string"){let M=Y0.isAbsolute(N.css)?N.css:Y0.resolve(J,N.css);if(await Bun.file(M).exists()){let T=await import(M);R=T.default||T,console.log(`${K0.green}[Crosswind]${K0.reset} Loaded config from stx.config.ts \u2192 ${N.css}`)}}else{if(R={...N.css,content:N.css.content||[],preflight:N.css.preflight??!0,minify:N.css.minify??!1},N.css.config){let M=Y0.isAbsolute(N.css.config)?N.css.config:Y0.resolve(J,N.css.config);if(await Bun.file(M).exists()){let T=await import(M);R={...T.default||T,...R}}}console.log(`${K0.green}[Crosswind]${K0.reset} Using inline CSS config from stx.config.ts`)}}catch{}c0=R||await T3(J);try{J4=A3(JSON.stringify(c0??{}))}catch{J4="unhashable"}}let z=Y.defaultConfig||Y.config,U=c0||{},W=z.theme||{},B=(U.theme||{}).extend||{},j={...W};if(Object.keys(B).length>0)j.extend=B;let H=[...z.safelist||[],...U.safelist||[]],L={...z,...U,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},F=new Y.CSSGenerator(L);for(let R of H)F.generate(R);for(let R of X)F.generate(R);let O=F.toCSS(!0,!1),V=L.shortcuts||U.shortcuts||{};for(let[R,A]of Object.entries(V)){if(!X.has(R)&&!H.includes(R))continue;let N=A.split(/\s+/).filter(Boolean);for(let M of N)F.generate(M)}O=F.toCSS(!0,!1);let w=O.split(`
2937
- `);for(let[R,A]of Object.entries(V)){if(!X.has(R)&&!H.includes(R))continue;let N=A.split(/\s+/).filter(Boolean),M=[],T=[];for(let I of N){let D=I.startsWith("dark:"),S=`.${(D?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<w.length;b++){let C=w[b].trim();if(C===`${S} {`||C.startsWith(`${S} {`)){let d=b,f="";while(d<w.length){if(f+=w[d],w[d].includes("}"))break;d++}let m=f.match(/\{([^}]+)\}/);if(m)if(D)T.push(m[1].trim());else M.push(m[1].trim());break}}}if(M.length)O+=`
2936
+ </script>`}var H3;var hY=y(()=>{Q1();V0();H3={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var dY={};c(dY,{timingPlugin:()=>hq,pluginManager:()=>vq,definePlugin:()=>Z4,debugPlugin:()=>gq,createVariablesPlugin:()=>dq,createFilterPlugin:()=>fq,createDirectivePlugin:()=>xq,PluginManager:()=>L3});function Z4($){return $}class L3{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,X]of this.plugins)if(X.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let X of this.sortedPlugins){let J=X[$];if(J)try{let Q=await J(Y);if(Q){if(Q.template!==void 0)Y.template=Q.template;if(Q.context)Y.context={...Y.context,...Q.context};if(Q.metadata)Y.metadata={...Y.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${X.name}" ${$} hook:`,Q)}}return Y}async runDirectiveHooks($,Z,Y){let X={...Y};for(let J of this.sortedPlugins){let Q=J[$];if(Q)try{let G=await Q(Z,X);if(G){if(G.template!==void 0)X.template=G.template;if(G.context)X.context={...X.context,...G.context};if(G.metadata)X.metadata={...X.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${J.name}" ${$} hook:`,G)}}return X}}function xq($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function fq($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function dq($){return Z4({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var vq,gq,hq;var uY=y(()=>{vq=new L3;gq=Z4({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),hq=Z4({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var pY={};c(pY,{validateConfig:()=>cq,loadStxConfig:()=>X4,defineStxConfig:()=>pq,defaultConfig:()=>v1,config:()=>V3});import F3 from"fs";import I0 from"path";import{loadConfigWithResult as uq}from"bunfig";function mq($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=I0.join(process.cwd(),"resources","views"),J=I0.join(process.cwd(),"resources","layouts");if(F3.existsSync(X)&&F3.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=I0.join(process.cwd(),"resources","views","pages");if(F3.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function X4($){if(!$){if(z5)return z5;if(Y4)return Y4}let Z=$?I0.resolve($):process.cwd(),Y=mY.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await uq({name:"stx",alias:"ui",cwd:Z,defaultConfig:v1,verbose:!1})).config,G=mq(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!I0.isAbsolute(Q.partialsDir))Q.partialsDir=I0.join(K,Q.partialsDir);if(Q.componentsDir&&!I0.isAbsolute(Q.componentsDir))Q.componentsDir=I0.join(K,Q.componentsDir);if(Q.layoutsDir&&!I0.isAbsolute(Q.layoutsDir))Q.layoutsDir=I0.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (uY(),dY)),q=[],z=[];for(let U of Q.plugins){let W=typeof U==="string"?U:U[0],_=typeof U==="string"?{}:U[1]||{};try{let B,j;try{B=await import(W),j=I0.dirname(Q0.resolve(W))}catch{let L=I0.resolve(process.cwd(),W);B=await import(L),j=I0.dirname(L)}let H=B.default||B;if(K.register(H,Q),H.components){let L=I0.resolve(j,H.components);q.push(L)}if(H.pages){let L=I0.resolve(j,H.pages),F=_.path||"/";z.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,O)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=O},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:j,config:Q};await H.setup(_,L)}console.log(`[stx] Plugin loaded: ${H.name||W}`)}catch(B){console.warn(`[stx] Failed to load plugin ${W}:`,B.message)}}Q._pluginComponentDirs=q,Q._pluginPageDirs=z}return Q})();if(mY.set(Z,X),!$)Y4=X,X.then((J)=>{z5=J}).catch(()=>{});return X}function pq($){return $}function cq($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${J}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${J}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${J}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${J}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${J}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((J,Q)=>{if(!J.pattern||typeof J.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(J.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(J.maxAgeSeconds!==void 0&&(typeof J.maxAgeSeconds!=="number"||J.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(J.maxEntries!==void 0&&(typeof J.maxEntries!=="number"||J.maxEntries<1))Z.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((J)=>typeof J!=="number"||J<16||J>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!X.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var v1,z5=null,mY,Y4=null,V3;var h5=y(()=>{U7();H7();R7();A7();M7();oZ();X3();VY();j3();hY();v1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:T7,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:gY,hasEndTag:!1,description:"Include a web component in the template"},B$,j$,_3,B3,W7,B7,j7,_7,_Z,HZ,nZ,Y3,...J3],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};mY=new Map;V3=new Proxy(v1,{get($,Z){if(z5&&Z in z5)return z5[Z];if(!Y4)X4().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});var eq={};c(eq,{resetCssCache:()=>sq,resetCrosswindCache:()=>rq,rebuildCrosswindCSS:()=>aq,loadCrosswindConfig:()=>T3,loadCrosswind:()=>N3,injectCrosswindCSS:()=>u5,getCachedCSS:()=>tq,generateCrosswindCSS:()=>nY,extractClassNames:()=>iY,buildCrosswindCSS:()=>lY});import Q4 from"fs";import Y0 from"path";function A3($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function w3($,Z){if(G1.has($))G1.delete($);else if(G1.size>=lq)G1.delete(G1.keys().next().value);G1.set($,Z)}async function iq($){if(!B1)return null;try{let Z=Bun.file(Y0.join(B1,`cw-${A3($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function nq($,Z){if(!B1)return;try{if(!Q4.existsSync(B1))Q4.mkdirSync(B1,{recursive:!0});await Bun.write(Y0.join(B1,`cw-${A3($)}.css`),Z)}catch{}}async function cY($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig}}catch{}return null}function oq(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==Y0.dirname(Y))$.push(Y0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(Y0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(Y0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push(Y0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push(Y0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(Y0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=Y0.dirname(Y);if(Z){let X=[Y0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),Y0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),Y0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),Y0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),Y0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),Y0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(Y0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(Y0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function N3(){if(R3)return W5;R3=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await cY(Y);if(X){if(W5=X,!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} CSS engine loaded`);return W5}}let Z=oq();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await cY(Y);if(X){if(W5=X,!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} CSS engine loaded from ${Y0.dirname(Y0.dirname(Y))}`);return W5}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${K0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${K0.reset}`),console.warn(`${K0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${K0.reset}`),null}}function sq(){G1.clear()}function rq(){W5=null,R3=!1,c0=null,d5="",G1.clear(),J4=null}async function T3($){try{let{loadConfigWithResult:Z}=await import("bunfig"),Y=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let X=Y0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${K0.yellow}[Crosswind]${K0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function lY($){if(U5)return d5;U5=!0;try{let Z=await N3();if(!Z||!Z.build)return U5=!1,"";if(!c0)c0=await T3($);if(!c0)return U5=!1,"";let Y=Z.defaultConfig?.theme||{},X=c0.theme||{},J={...Z.defaultConfig,...c0,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(d5=G.css,console.log(`${K0.cyan}[Crosswind]${K0.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let q=Y0.isAbsolute(J.output)?J.output:Y0.join($,J.output),z=Y0.dirname(q);if(!Q4.existsSync(z))Q4.mkdirSync(z,{recursive:!0});await Bun.write(q,G.css)}return U5=!1,G.css}catch(Z){return console.error(`${K0.red}[Crosswind]${K0.reset} Build error:`,Z),U5=!1,d5}}async function aq($){c0=null,await lY($)}function tq(){return d5}function iY($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,X=Y.exec($);while(X!==null){for(let G of X[1].split(/\s+/))if(G.trim())Z.add(G.trim());X=Y.exec($)}let J=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,Q=J.exec($);while(Q!==null){let G=Q[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let q of K.slice(1,-1).split(/\s+/))if(q.trim())Z.add(q.trim())}Q=J.exec($)}return Z}async function nY($,Z){try{let Y=await N3();if(!Y)return"";let X=iY($);if(X.size===0)return"";let J=Z?Y0.resolve(Z):process.cwd();if(!B1)B1=Y0.join(J,".stx/cache");let Q=[...X].sort().join(" "),G=`${J4||"default"}::${Q}`,K=G1.get(G);if(K!==void 0)return w3(G,K),K;let q=await iq(G);if(q!==null)return w3(G,q),q;if(!c0){let R=null;try{let{loadStxConfig:A}=await Promise.resolve().then(() => (h5(),pY)),N=await A(J);if(N.css)if(typeof N.css==="string"){let M=Y0.isAbsolute(N.css)?N.css:Y0.resolve(J,N.css);if(await Bun.file(M).exists()){let T=await import(M);R=T.default||T,console.log(`${K0.green}[Crosswind]${K0.reset} Loaded config from stx.config.ts \u2192 ${N.css}`)}}else{if(R={...N.css,content:N.css.content||[],preflight:N.css.preflight??!0,minify:N.css.minify??!1},N.css.config){let M=Y0.isAbsolute(N.css.config)?N.css.config:Y0.resolve(J,N.css.config);if(await Bun.file(M).exists()){let T=await import(M);R={...T.default||T,...R}}}console.log(`${K0.green}[Crosswind]${K0.reset} Using inline CSS config from stx.config.ts`)}}catch{}c0=R||await T3(J);try{J4=A3(JSON.stringify(c0??{}))}catch{J4="unhashable"}}let z=Y.defaultConfig||Y.config,U=c0||{},W=z.theme||{},B=(U.theme||{}).extend||{},j={...W};if(Object.keys(B).length>0)j.extend=B;let H=[...z.safelist||[],...U.safelist||[]],L={...z,...U,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},F=new Y.CSSGenerator(L);for(let R of H)F.generate(R);for(let R of X)F.generate(R);let O=F.toCSS(!0,!1),V=L.shortcuts||U.shortcuts||{};for(let[R,A]of Object.entries(V)){if(!X.has(R)&&!H.includes(R))continue;let N=A.split(/\s+/).filter(Boolean);for(let M of N)F.generate(M)}O=F.toCSS(!0,!1);let w=O.split(`
2937
+ `);for(let[R,A]of Object.entries(V)){if(!X.has(R)&&!H.includes(R))continue;let N=A.split(/\s+/).filter(Boolean),M=[],T=[];for(let I of N){let D=I.startsWith("dark:"),S=`.${(D?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<w.length;b++){let P=w[b].trim();if(P===`${S} {`||P.startsWith(`${S} {`)){let d=b,f="";while(d<w.length){if(f+=w[d],w[d].includes("}"))break;d++}let m=f.match(/\{([^}]+)\}/);if(m)if(D)T.push(m[1].trim());else M.push(m[1].trim());break}}}if(M.length)O+=`
2938
2938
  .${R} { ${M.join(" ")} }`;if(T.length)O+=`
2939
2939
  @media (prefers-color-scheme: dark) { .dark .${R} { ${T.join(" ")} } }`}return w3(G,O),nq(G,O),O}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function u5($,Z){let Y=await nY($,Z);if(!Y)return $;let X=`<style data-crosswind="generated">
2940
2940
  ${Y}
@@ -3770,7 +3770,7 @@ ${Y}
3770
3770
  </script>`}function _X($,Z,Y){if(WX=0,!Dz($))return $;let X=wz($);if(X.length===0)return $;let J=Iz($,X),Q=Mz(X,Z),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
3771
3771
  `+J.slice(G);else J+=Q;return J}function Iz($,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*["']${q4(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*["']${q4(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*"${q4(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*'${q4(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 Dz($){return/x-data\s*=\s*["']/.test($)}var WX=0,Vz=0;var BX=y(()=>{a0()});import Ez from"fs";import k3 from"path";import{createHighlighter as kz}from"ts-syntax-highlighter";async function Sz($,Z={}){try{if(!await n($))throw Error(`Markdown file not found: ${$}`);let X=(await Ez.promises.stat($)).mtime.getTime();if(Z.cache&&S3.has($)){let W=S3.get($);if(W.updatedAt>=X)return{content:W.content,data:W.data}}let J=await Bun.file($).text(),{data:Q,content:G}=FZ(J),K=Z.markdown||V3.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},z=P5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)z=await bz(z,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:z,data:Q||{}};if(Z.cache)S3.set($,{...U,updatedAt:X});return U}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function bz($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!z4)try{z4=await kz({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,q,z,U)=>{let W=U.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),_=z||(Y?"text":"");if(!_)return K;try{if(!z4.getSupportedLanguages().includes(_))return K;return(await z4.highlight(W,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${z}:`,B)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[q,z,U,W]=K,_=await J(q,z,U,W);Q=Q.replace(q,_)}return Q}async function jX($,Z,Y="",X={}){return await yz($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,z)=>{try{let U=K;if(!k3.isAbsolute(K))U=k3.resolve(k3.dirname(Y),K);let W={};if(q)try{try{W=JSON.parse(q)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=q.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let w=V.indexOf(":");if(w>0){let R=V.substring(0,w).trim(),A=V.substring(w+1).trim(),N=A.startsWith('"')&&A.endsWith('"'),M=A.startsWith("'")&&A.endsWith("'");if(N||M)A=A.substring(1,A.length-1);W[R]=A}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await Sz(U,X),j={...Z,...B,...W},H=_,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(U){let W=U instanceof Error?U.message:String(U);return J0("Markdown File",`Error including markdown file: ${W}`,Y,$,z,G)}})}async function yz($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],q=J.index,z=J;X.push(Y(...z).then((U)=>({match:K,replacement:U,index:q})))}let Q=await Promise.all(X);Q.sort((K,q)=>q.index-K.index);let G=$;for(let{match:K,replacement:q}of Q)G=G.replace(K,()=>q);return G}var S3,z4=null;var HX=y(()=>{h5();V0();S3=new Map});function H1($,Z){try{let Y=$.trim();if($0(Y))return Z0(Y,Object.keys(Z))(...Object.values(Z));else return e(Y,Z)}catch{return!1}}var OX=y(()=>{F0()});class U4{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]!==`
3772
3772
  `)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]===`
3773
- `)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 O0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,q=!1;while(Q<$.length){let z=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&z==="\\"){q=!0,Q++;continue}if(q=!1,(z==='"'||z==="'"||z==="`")&&!G){G=z,Q++;continue}if(z===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&z==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&z==="}"){K--,Q++;continue}if(z==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(z===Z)J++;else if(z===Y){if(J--,J===0)return Q}Q++}return-1}function LX($,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 b3($){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 O1($,Z){let Y=Cz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Cz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=O0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function x1($,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 q=G.exec($),z=K.exec($),U=q?q.index:1/0,W=z?z.index:1/0;if(U<W)J++,Q=U+q[0].length;else if(W<1/0){if(J--,J===0)return W;Q=W+z[0].length}else break}return-1}function FX($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=O1($,X);if(!J)return null;let Q=J.endPos,G=x1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U="if",W=J.expression,_=0,B=0;while(z<K.length){let j=K.indexOf("@",z);if(j===-1)break;z=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,z++;continue}if(/^@endif(?![a-z])/.test(H)){B--,z+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z});let F=z+L[0].length,O=O1(K,F);if(!O){z++;continue}U="elseif",W=O.expression,z=O.endPos,_=z;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z}),U="else",W=void 0,z+=5,_=z;continue}}z++}return q.push({type:U,condition:W,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function m5($){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=FX($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function W4($,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,q=K+Q[0].length-1,z=O0($,"(",")",q);if(z===-1){Q=J.exec($);continue}let U=$.slice(q+1,z),W=z+1,_=x1($,Z,Y,W);if(_===-1){Q=J.exec($);continue}let B=$.slice(W,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:U,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function y3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=O1($,X);if(!J)return null;let Q=J.endPos,G=x1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U=null,W=0;while(z<K.length){let _=K.slice(z),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(W++,U)U.content+=B[0];z+=B[0].length;continue}if(j){if(W--,U)U.content+=j[0];z+=j[0].length;continue}if(W>0){if(U)U.content+=K[z];z++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(U)q.push(U);let O=z+H[0].length,V=O1(K,O);if(!V){z++;continue}U={type:"case",value:V.expression,content:""},z=V.endPos}else if(L&&_.startsWith("@default")){if(U)q.push(U);U={type:"default",content:""},z+=L[0].length}else if(F&&_.startsWith("@break"))z+=F[0].length;else{if(U)U.content+=K[z];z++}}if(U)q.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:q,start:Z,end:G+10}}var VX=()=>{};function Pz($){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)==="{{{"?"{{{":"{!!":"{{",q=Q?K==="{{{"?"}}}":"!!}":"}}",z=G+K.length,U=vz($,z,q);if(U===-1){Y=G+1;continue}let W=$.slice(z,U).trim(),_=U+q.length;Z.push({fullMatch:$.slice(G,_),expression:W,start:G,end:_,isRaw:Q}),Y=_}return Z}function vz($,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 xz($){let Z=b3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=fz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function fz($){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=O0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=AX(G);return{name:X,args:K}}function AX($){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 gz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=O0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function hz($){let Z=[],X=new U4($).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 q=K.value;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let W=J<X.length?X[J].start:$.length,_=wX(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(W,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(z.type==="PUNCTUATION"&&(z.value==="{"||z.value==="[")){let U=z.start,W=z.value==="{"?"}":"]",_=O0($,z.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=RX(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=wX(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${q} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let q=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.value;J++;let W=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){W=X[J].start;break}J++}if(W!==-1){let _=O0($,"{","}",W);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=RX(X,_+1)}}}else J++}return Z}function wX($,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 RX($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var NX=()=>{};var _4=y(()=>{VX();NX()});function dz($,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=y3(X,G);if(!K)break;try{let q;if($0(K.expression))q=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else q=e(K.expression,Z);let z="",U=!1;for(let W of K.cases)if(W.type==="default"){if(!U)z=W.content.trim()}else try{let _;if(W.value&&$0(W.value))_=Z0(W.value,Object.keys(Z))(...Object.values(Z));else if(W.value)_=e(W.value,Z);if(q===_){z=W.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+z+X.substring(K.end),J=!0}catch(q){let z=q instanceof Error?q.message:String(q),U=r("Switch",`Error evaluating @switch expression: ${z}`,l.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function f1($,Z,Y){let X=$;X=dz(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,q=O1(X,K+7);if(!q)break;let z=q.endPos,U=x1(X,"unless","endunless",z);if(U===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let W=X.slice(z,U),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=L.exec(W))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(W))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(W))!==null)V.push({pos:w.index,type:"else"});V.sort((R,A)=>R.pos-A.pos);for(let R of V)if(R.type==="open")H++;else if(R.type==="close")H--;else if(R.type==="else"&&H===0){B=R.pos;break}}let j;if(B!==-1){let H=W.slice(0,B),L=W.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${W}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=P3(X,Z,Y),X=v3(X,Z,Y),X=C3(X,Z);let J=()=>{let Q=m5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let q="",z=!1;for(let U of K.branches){if(z)break;if(U.type==="else")q=U.content,z=!0;else try{let W;if(U.condition&&$0(U.condition))W=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)W=e(U.condition,Z);if(W)q=U.content,z=!0}catch(W){q=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,l.EVALUATION_ERROR),z=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let z=q instanceof Error?q.message:String(q),U=r("If",`Error processing @if block: ${z}`,l.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function TX($){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 C3($,Z){let Y=$;function X(K,q,z,U){let W=1,_=U,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${z}(?![a-z])`,"g");while(_<K.length&&W>0){B.lastIndex=_,j.lastIndex=_;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)W++,_=F+H[0].length;else if(O<1/0){if(W--,W===0)return O;_=O+L[0].length}else break}return-1}function J(K,q,z){let U=0,W=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${z}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=W.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+5),B=TX(_);if(B)U=B.value,W=z+5+B.consumed;else W=z+5;let j=X(Y,"auth","endauth",W);if(j===-1){console.warn(`[stx] @auth directive at position ${z} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(W,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?H1(`auth?.check && auth?.user?.[${U}]`,Z):H1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,z)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+6),B=TX(_);if(B)U=B.value,W=z+6+B.consumed;else W=z+6;let j=X(Y,"guest","endguest",W);if(j===-1){console.warn(`[stx] @guest directive at position ${z} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(W,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?H1(`!auth?.check || !auth?.user?.[${U}]`,Z):H1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,z)+O+Y.substring(j+9),K=!0}}function Q(K,q,z){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(q)U.push(q);if(z){let W=H1(z,Z);U.push(W)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,z=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let W=Y.match(new RegExp(`@${K}\\s*\\(`));if(!W||W.index===void 0)break;let _=W.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),R=new RegExp(`@${q}(?![a-z])`,"g"),A=new RegExp(`@${z}\\s*\\(`,"g"),N=/@else(?![a-z])/g,M=[],T;while((T=w.exec(F))!==null)M.push({pos:T.index,type:"open"});while((T=R.exec(F))!==null)M.push({pos:T.index,type:"close"});while((T=A.exec(F))!==null)M.push({pos:T.index,type:"elseDirective"});while((T=N.exec(F))!==null)M.push({pos:T.index,type:"else"});M.sort((b,C)=>b.pos-C.pos);for(let b of M){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)O.push(b)}let I=[],D=0;for(let b=0;b<O.length;b++){let C=O[b];if(I.push({content:F.slice(D,C.pos),ability:void 0}),C.type==="elseDirective"){let d=F.slice(C.pos+`@${z}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(D,C.pos)},D=C.pos+`@${z}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[b+1],o=m?m.pos:F.length;I.push({content:F.slice(D,o),ability:f.ability,type:f.type,id:f.id}),D=o}}else D=C.pos+5}if(D<F.length){let b=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(D),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(D)})}let E=Q(j.ability,j.type,j.id),k=K==="can"?E:!E,S="";if(k)S=I[0]?.content||"";else{let b=!1;for(let C=1;C<I.length;C++){let d=I[C];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&I.length>0){let C=I[I.length-1];if(C.isFinalElse)S=C.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${q}`.length),U=!0}}return Y}function P3($,Z,Y){let X=$;function J(Q,G,K,q,z){let U=!0;while(U){U=!1;let W=new RegExp(`@${G}\\s*\\(`),_=Q.match(W);if(!_||_.index===void 0)break;let B=_.index,j=O1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=x1(Q,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,L),O=j.expression,V=-1,w=0,R=0;while(R<F.length){let A=F.indexOf("@",R);if(A===-1)break;let N=F.substring(A);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){w++,R=A+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){w--,R=A+1;continue}if(w===0&&/^@else(?![a-z])/.test(N)){V=A;break}R=A+1}try{let A=q(O.trim()),N;if(V!==-1){let M=F.slice(0,V),T=F.slice(V+5);N=A?M:T}else N=A?F:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(A){let N=A instanceof Error?A.message:String(A),M=r(z,`Error processing @${G} directive: ${N}`,l.EVALUATION_ERROR);Q=Q.substring(0,B)+M+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=H1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=H1(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 v3($,Z,Y){let X=$,J="development";function Q(G,K,q,z){let U=new RegExp(`@${K}(?![a-z])`,"g"),W=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,z=J===E[2]}let V=1,w=O,R=-1;while(V>0&&w<j.length){U.lastIndex=w,W.lastIndex=w;let E=U.exec(j),k=W.exec(j),S=E?E.index:1/0,b=k?k.index:1/0;if(S<b)V++,w=S+E[0].length;else if(b<1/0){if(V--,V===0){R=b;break}w=b+k[0].length}else break}if(R===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let A=j.substring(O,R),N=-1,M=0,T=0;while(T<A.length){let E=A.indexOf("@",T);if(E===-1)break;let k=A.substring(E);if(_.test(k)){M++,T=E+1;continue}if(B.test(k)){M--,T=E+1;continue}if(M===0&&/^@else(?![a-z])/.test(k)){N=E;break}T=E+1}let I;if(N!==-1){let E=A.slice(0,N),k=A.slice(N+5);I=z?E:k}else I=z?A:"";let D=`@${q}`.length;j=j.substring(0,F)+I+j.substring(R+D),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 B4=y(()=>{OX();Q1();_4();F0()});function MX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function g1($,Z){if(!$)return Z?.nonceGenerator?.()??MX();let Y=x3.get($);if(!Y)Y=Z?.nonceGenerator?.()??MX(),x3.set($,Y);return Y}function UR($){x3.delete($)}function IX($,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 g3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${IX($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function WR($){return{enabled:!0,directives:{strict:uz,moderate:f3,relaxed:mz,api:pz}[$]||f3,useNonce:$==="strict",addMetaTag:!0}}function _R($,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:[],q=[...new Set([...K,...J])];Y[Q]=q}}return Y}function DX($,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?g1(Y,Z):void 0,J=g3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
3773
+ `)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 O0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,q=!1;while(Q<$.length){let z=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&z==="\\"){q=!0,Q++;continue}if(q=!1,(z==='"'||z==="'"||z==="`")&&!G){G=z,Q++;continue}if(z===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&z==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&z==="}"){K--,Q++;continue}if(z==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(z===Z)J++;else if(z===Y){if(J--,J===0)return Q}Q++}return-1}function LX($,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 b3($){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 O1($,Z){let Y=Cz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Cz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=O0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function x1($,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 q=G.exec($),z=K.exec($),U=q?q.index:1/0,W=z?z.index:1/0;if(U<W)J++,Q=U+q[0].length;else if(W<1/0){if(J--,J===0)return W;Q=W+z[0].length}else break}return-1}function FX($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=O1($,X);if(!J)return null;let Q=J.endPos,G=x1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U="if",W=J.expression,_=0,B=0;while(z<K.length){let j=K.indexOf("@",z);if(j===-1)break;z=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,z++;continue}if(/^@endif(?![a-z])/.test(H)){B--,z+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z});let F=z+L[0].length,O=O1(K,F);if(!O){z++;continue}U="elseif",W=O.expression,z=O.endPos,_=z;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z}),U="else",W=void 0,z+=5,_=z;continue}}z++}return q.push({type:U,condition:W,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function m5($){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=FX($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function W4($,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,q=K+Q[0].length-1,z=O0($,"(",")",q);if(z===-1){Q=J.exec($);continue}let U=$.slice(q+1,z),W=z+1,_=x1($,Z,Y,W);if(_===-1){Q=J.exec($);continue}let B=$.slice(W,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:U,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function y3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=O1($,X);if(!J)return null;let Q=J.endPos,G=x1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U=null,W=0;while(z<K.length){let _=K.slice(z),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(W++,U)U.content+=B[0];z+=B[0].length;continue}if(j){if(W--,U)U.content+=j[0];z+=j[0].length;continue}if(W>0){if(U)U.content+=K[z];z++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(U)q.push(U);let O=z+H[0].length,V=O1(K,O);if(!V){z++;continue}U={type:"case",value:V.expression,content:""},z=V.endPos}else if(L&&_.startsWith("@default")){if(U)q.push(U);U={type:"default",content:""},z+=L[0].length}else if(F&&_.startsWith("@break"))z+=F[0].length;else{if(U)U.content+=K[z];z++}}if(U)q.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:q,start:Z,end:G+10}}var VX=()=>{};function Pz($){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)==="{{{"?"{{{":"{!!":"{{",q=Q?K==="{{{"?"}}}":"!!}":"}}",z=G+K.length,U=vz($,z,q);if(U===-1){Y=G+1;continue}let W=$.slice(z,U).trim(),_=U+q.length;Z.push({fullMatch:$.slice(G,_),expression:W,start:G,end:_,isRaw:Q}),Y=_}return Z}function vz($,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 xz($){let Z=b3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=fz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function fz($){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=O0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=AX(G);return{name:X,args:K}}function AX($){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 gz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=O0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function hz($){let Z=[],X=new U4($).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 q=K.value;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let W=J<X.length?X[J].start:$.length,_=wX(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(W,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(z.type==="PUNCTUATION"&&(z.value==="{"||z.value==="[")){let U=z.start,W=z.value==="{"?"}":"]",_=O0($,z.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=RX(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=wX(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${q} ${B} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let q=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.value;J++;let W=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){W=X[J].start;break}J++}if(W!==-1){let _=O0($,"{","}",W);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=RX(X,_+1)}}}else J++}return Z}function wX($,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 RX($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var NX=()=>{};var _4=y(()=>{VX();NX()});function dz($,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=y3(X,G);if(!K)break;try{let q;if($0(K.expression))q=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else q=e(K.expression,Z);let z="",U=!1;for(let W of K.cases)if(W.type==="default"){if(!U)z=W.content.trim()}else try{let _;if(W.value&&$0(W.value))_=Z0(W.value,Object.keys(Z))(...Object.values(Z));else if(W.value)_=e(W.value,Z);if(q===_){z=W.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+z+X.substring(K.end),J=!0}catch(q){let z=q instanceof Error?q.message:String(q),U=r("Switch",`Error evaluating @switch expression: ${z}`,l.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function f1($,Z,Y){let X=$;X=dz(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,q=O1(X,K+7);if(!q)break;let z=q.endPos,U=x1(X,"unless","endunless",z);if(U===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let W=X.slice(z,U),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=L.exec(W))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(W))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(W))!==null)V.push({pos:w.index,type:"else"});V.sort((R,A)=>R.pos-A.pos);for(let R of V)if(R.type==="open")H++;else if(R.type==="close")H--;else if(R.type==="else"&&H===0){B=R.pos;break}}let j;if(B!==-1){let H=W.slice(0,B),L=W.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${W}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=P3(X,Z,Y),X=v3(X,Z,Y),X=C3(X,Z);let J=()=>{let Q=m5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let q="",z=!1;for(let U of K.branches){if(z)break;if(U.type==="else")q=U.content,z=!0;else try{let W;if(U.condition&&$0(U.condition))W=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)W=e(U.condition,Z);if(W)q=U.content,z=!0}catch(W){q=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,l.EVALUATION_ERROR),z=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let z=q instanceof Error?q.message:String(q),U=r("If",`Error processing @if block: ${z}`,l.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function TX($){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 C3($,Z){let Y=$;function X(K,q,z,U){let W=1,_=U,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${z}(?![a-z])`,"g");while(_<K.length&&W>0){B.lastIndex=_,j.lastIndex=_;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)W++,_=F+H[0].length;else if(O<1/0){if(W--,W===0)return O;_=O+L[0].length}else break}return-1}function J(K,q,z){let U=0,W=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${z}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=W.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+5),B=TX(_);if(B)U=B.value,W=z+5+B.consumed;else W=z+5;let j=X(Y,"auth","endauth",W);if(j===-1){console.warn(`[stx] @auth directive at position ${z} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(W,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?H1(`auth?.check && auth?.user?.[${U}]`,Z):H1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,z)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+6),B=TX(_);if(B)U=B.value,W=z+6+B.consumed;else W=z+6;let j=X(Y,"guest","endguest",W);if(j===-1){console.warn(`[stx] @guest directive at position ${z} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(W,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?H1(`!auth?.check || !auth?.user?.[${U}]`,Z):H1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,z)+O+Y.substring(j+9),K=!0}}function Q(K,q,z){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(q)U.push(q);if(z){let W=H1(z,Z);U.push(W)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,z=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let W=Y.match(new RegExp(`@${K}\\s*\\(`));if(!W||W.index===void 0)break;let _=W.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),R=new RegExp(`@${q}(?![a-z])`,"g"),A=new RegExp(`@${z}\\s*\\(`,"g"),N=/@else(?![a-z])/g,M=[],T;while((T=w.exec(F))!==null)M.push({pos:T.index,type:"open"});while((T=R.exec(F))!==null)M.push({pos:T.index,type:"close"});while((T=A.exec(F))!==null)M.push({pos:T.index,type:"elseDirective"});while((T=N.exec(F))!==null)M.push({pos:T.index,type:"else"});M.sort((b,P)=>b.pos-P.pos);for(let b of M){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)O.push(b)}let I=[],D=0;for(let b=0;b<O.length;b++){let P=O[b];if(I.push({content:F.slice(D,P.pos),ability:void 0}),P.type==="elseDirective"){let d=F.slice(P.pos+`@${z}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(D,P.pos)},D=P.pos+`@${z}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[b+1],o=m?m.pos:F.length;I.push({content:F.slice(D,o),ability:f.ability,type:f.type,id:f.id}),D=o}}else D=P.pos+5}if(D<F.length){let b=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(D),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(D)})}let E=Q(j.ability,j.type,j.id),k=K==="can"?E:!E,S="";if(k)S=I[0]?.content||"";else{let b=!1;for(let P=1;P<I.length;P++){let d=I[P];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&I.length>0){let P=I[I.length-1];if(P.isFinalElse)S=P.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${q}`.length),U=!0}}return Y}function P3($,Z,Y){let X=$;function J(Q,G,K,q,z){let U=!0;while(U){U=!1;let W=new RegExp(`@${G}\\s*\\(`),_=Q.match(W);if(!_||_.index===void 0)break;let B=_.index,j=O1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=x1(Q,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,L),O=j.expression,V=-1,w=0,R=0;while(R<F.length){let A=F.indexOf("@",R);if(A===-1)break;let N=F.substring(A);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){w++,R=A+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){w--,R=A+1;continue}if(w===0&&/^@else(?![a-z])/.test(N)){V=A;break}R=A+1}try{let A=q(O.trim()),N;if(V!==-1){let M=F.slice(0,V),T=F.slice(V+5);N=A?M:T}else N=A?F:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(A){let N=A instanceof Error?A.message:String(A),M=r(z,`Error processing @${G} directive: ${N}`,l.EVALUATION_ERROR);Q=Q.substring(0,B)+M+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=H1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=H1(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 v3($,Z,Y){let X=$,J="development";function Q(G,K,q,z){let U=new RegExp(`@${K}(?![a-z])`,"g"),W=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,z=J===E[2]}let V=1,w=O,R=-1;while(V>0&&w<j.length){U.lastIndex=w,W.lastIndex=w;let E=U.exec(j),k=W.exec(j),S=E?E.index:1/0,b=k?k.index:1/0;if(S<b)V++,w=S+E[0].length;else if(b<1/0){if(V--,V===0){R=b;break}w=b+k[0].length}else break}if(R===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let A=j.substring(O,R),N=-1,M=0,T=0;while(T<A.length){let E=A.indexOf("@",T);if(E===-1)break;let k=A.substring(E);if(_.test(k)){M++,T=E+1;continue}if(B.test(k)){M--,T=E+1;continue}if(M===0&&/^@else(?![a-z])/.test(k)){N=E;break}T=E+1}let I;if(N!==-1){let E=A.slice(0,N),k=A.slice(N+5);I=z?E:k}else I=z?A:"";let D=`@${q}`.length;j=j.substring(0,F)+I+j.substring(R+D),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 B4=y(()=>{OX();Q1();_4();F0()});function MX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function g1($,Z){if(!$)return Z?.nonceGenerator?.()??MX();let Y=x3.get($);if(!Y)Y=Z?.nonceGenerator?.()??MX(),x3.set($,Y);return Y}function UR($){x3.delete($)}function IX($,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 g3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${IX($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function WR($){return{enabled:!0,directives:{strict:uz,moderate:f3,relaxed:mz,api:pz}[$]||f3,useNonce:$==="strict",addMetaTag:!0}}function _R($,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:[],q=[...new Set([...K,...J])];Y[Q]=q}}return Y}function DX($,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?g1(Y,Z):void 0,J=g3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
3774
3774
  ${J}`)}function BR($,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 EX($,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?g1(Z,Q):void 0;return g3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return g1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=g1(Z,Q);return J}function jR(){return[cz,lz]}function HR($){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 iz($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function OR($,Z){if(!$.enabled)return{};let Y=$.useNonce?g1(Z,$):void 0,X=IX($.directives,Y);return{[iz($.reportOnly)]:X}}var x3,uz,f3,mz,pz,cz,lz,LR;var kX=y(()=>{x3=new WeakMap;uz={"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},f3={"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},mz={"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'"]},pz={"default-src":["'none'"],"frame-ancestors":["'none'"]};cz={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?g1(Y,Q):void 0;return g3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},lz={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return g1(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};LR={enabled:!1,reportOnly:!1,directives:f3,useNonce:!1,addMetaTag:!0}});import{Buffer as SX}from"buffer";import bX from"crypto";function oz($=nz){let Z=bX.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return _5=Z,Z}function sz(){if(!_5)oz();return _5}function RR(){_5=null}function AR($){_5=$}function rz($=yX){let Z=sz();return`<input type="hidden" name="${$}" value="${Z}">`}function CX($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return rz(X||yX)})}function NR($,Z){let Y=Z??_5;if(!Y)return!1;let X=SX.from($),J=SX.from(Y);if(X.length!==J.length)return!1;return bX.timingSafeEqual(X,J)}var nz=40,yX="_token",_5=null;var PX=()=>{};async function vX($,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 az(J,Q,Z,Y,X);else J=await tz(J,Q,Z,Y,X)}return J}async function az($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,q=`@end${Q}`,z=$,U=k1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),W=[],_=U.exec(z);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?xX(j):[],O=H.trim(),V=await G(O,F,Y,X);W.push({original:B,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${O}`,l.EVALUATION_ERROR),startIndex:L})}_=U.exec(z)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:H}=W[B];z=z.replace(j,H)}return z}async function tz($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,q=k1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),z=[],U=q.exec(K);while(U!==null){let[B,j=""]=U,H=U.index||0;try{let L=xX(j),F=await G("",L,Y,X);z.push({original:B,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(J.debug)console.error(`Error processing custom directive @${Q}:`,L);z.push({original:B,processed:r("CustomDirective",`Error in @${Q}(${j}): ${F}`,l.EVALUATION_ERROR),startIndex:H})}U=q.exec(K)}let W=k1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=W.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let H=await G("",[],Y,X);z.push({original:B,processed:H,startIndex:j})}catch(H){let L=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);z.push({original:B,processed:r("CustomDirective",`Error in @${Q}: ${L}`,l.EVALUATION_ERROR),startIndex:j})}_=W.exec(K)}for(let B=z.length-1;B>=0;B--){let{original:j,processed:H}=z[B];K=K.replace(j,H)}return K}function xX($){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 fX=y(()=>{Q1();Z5()});var h3={};c(h3,{useTitle:()=>JU,useSeoMeta:()=>H4,usePageTitle:()=>JU,useHead:()=>d1,resetHead:()=>ZU,renderHtmlAttrs:()=>GU,renderHead:()=>QU,renderBodyAttrs:()=>KU,processTitleDirective:()=>UU,processMetaDirective:()=>WU,processHeadDirective:()=>zU,getPageMeta:()=>$U,getHead:()=>p5,definePageMeta:()=>XU,applyHead:()=>qU});function p5(){return L1}function $U(){return j4}function ZU(){L1={},ez.length=0,j4={}}function d1($){L1=YU(L1,$)}function YU($,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 H4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let q=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:q})}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 q of $.articleTags)Z.push({property:"article:tag",content:q});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});d1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function XU($){if(j4={...j4,...$},$.title||$.description)H4({title:$.title,description:$.description})}function JU($){let Z=typeof $==="function"?$():$;d1({title:Z})}function QU($=L1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${h1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${h1(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}="${h1(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}="${h1(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}="${h1(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(`
3775
3775
  `)}function GU($=L1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${h1(Y)}"`).join(" ")}function KU($=L1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${h1(Y)}"`).join(" ")}function h1($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function qU($=L1){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 zU($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
3776
3776
  `,""}),headContent:Z.trim()}}function UU($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return d1({title:G}),""})}function WU($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let q=Q?G:K,z=Q?q:Z[(q||"").trim()]??q,W=J.includes(":")?{property:J,content:z}:{name:J,content:z};return d1({meta:[W]}),""})}var L1,ez,j4;var c5=y(()=>{L1={},ez=[],j4={}});import _U from"crypto";function w0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function BU($){return{...d3,...$.forms?.classes}}function O4($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function jU(){return _U.randomUUID()}function SR($,Z,Y,X){let J=BU(X),Q=$;return Q=OU(Q,Z),Q=n5(Q,Z),Q=u3(Q,Z,J),Q=m3(Q,Z,J),Q}function n5($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=jU();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${w0(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="${w0(Q)}">`;return X}),Y}function u3($,Z,Y=d3){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,q,z="")=>{let U=Q||G||"POST",W=K||q||"",_=F1(z),B=U.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${w0(j)}" action="${w0(W)}"${_?` ${_}`:""}>`;if(H+=`
@@ -4020,8 +4020,8 @@ else {
4020
4020
  ${q?`{${q}}`:"{}"}
4021
4021
  </script>
4022
4022
  </div>`}}});var XJ={};c(XJ,{warnUnbalancedTags:()=>$8,findUnbalancedTags:()=>YJ});function V1($){return $.replace(/[^\n]/g," ")}function YJ($){let Z=$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,V1).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,V1).replace(/<!--[\s\S]*?-->/g,V1).replace(/\{\{\{[\s\S]*?\}\}\}/g,V1).replace(/\{\{[\s\S]*?\}\}/g,V1).replace(/\{!![\s\S]*?!!\}/g,V1).replace(/"[^"]*"/g,V1).replace(/'[^']*'/g,V1),Y=new Map,X=new Map,J=/<(\/?)([A-Za-z][\w-]*)\b[^>]*?(\/?)>/g,Q;while((Q=J.exec(Z))!==null){let K=Q[1]==="/",q=Q[2],z=Q[3]==="/";if(qW.has(q.toLowerCase()))continue;if(z)continue;if(K)X.set(q,(X.get(q)??0)+1);else{let U=Y.get(q);if(U)U.count++;else{let W=Z.slice(0,Q.index).split(`
4023
- `).length;Y.set(q,{count:1,firstLine:W})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(zW.has(K.toLowerCase()))continue;let q=Y.get(K)?.count??0,z=X.get(K)??0;if(q!==z)G.push({tag:K,opened:q,closed:z,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function $8($,Z){let Y;try{Y=YJ($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(ZJ.has(X))return;ZJ.add(X);let J=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:q}of Y)if(G>K){let z=q?` (first opened at line ${q})`:"";console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${z} may swallow the content that follows it.`)}else console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var qW,zW,ZJ;var Z8=y(()=>{qW=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),zW=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);ZJ=new Set});import d0 from"path";import Y8 from"fs";function JJ($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function QJ($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class GJ{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 B=[J,J.toLowerCase(),JJ(J),QJ(J)];for(let j of B)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${JJ(J)}.stx`,`${QJ(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let B=d0.resolve(d0.dirname(Z),`${J}.stx`);if(await n(B))return B;return null}let K=[],q=Y.componentsDir||"",z=X?.__originalFilePath;if(z)K.push(d0.join(d0.dirname(z),"components"));if(q)K.push(q);let U=d0.join(d0.dirname(Z),"components");if(!K.includes(U))K.push(U);let W=process.cwd(),_=[d0.resolve(W,"src/components"),d0.resolve(W,"components"),d0.resolve(import.meta.dir,"components")];for(let B of _)if(!K.includes(B))K.push(B);for(let B of K){if(!B)continue;for(let j of G){let H=d0.join(B,j);if(await n(H))return H}try{if(!Y8.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let H=Y8.readdirSync(B,{withFileTypes:!0});for(let L of H)if(L.isDirectory()){let F=d0.join(B,L.name);for(let O of G){let V=d0.join(F,O);if(await n(V))return V}}}catch{}}return null}}var b0;var X8=y(()=>{V0();b0=new GJ});function w1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function UW($){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 J8;var Q8=y(()=>{J8={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=UW($),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,q=[];if(X.reactive)q.push(`:href="${w1(X.value)}"`);else q.push(`href="${w1(X.value)}"`);if(J)q.push(`class="${w1(J)}"`);if(q.push("data-stx-link"),q.push(`data-stx-active-class="${w1(Q)}"`),q.push(`data-stx-exact-active-class="${w1(G)}"`),K)q.push("data-stx-prefetch");let z=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[U,W]of Object.entries($.static)){if(z.has(U))continue;if(typeof W==="boolean"){if(W)q.push(w1(U))}else q.push(`${w1(U)}="${w1(W)}"`)}return`<a ${q.join(" ")}>${Z}</a>`}}});function _0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function I0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function K8($,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 KJ($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[J,Q]=X.split(":"),G=WW[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 q8($,Z,Y,X){return Z.map((J)=>`${r5($,J,void 0,Y,X)} ${J}w`).join(", ")}function _W($,Z,Y,X,J){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${r5($,G,void 0,X,J)} ${Q}x`}).join(", ")}function r5($,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 BW($,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 WW,G8,z8;var U8=y(()=>{WW={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},G8=[320,640,768,1024,1280,1536,1920];z8={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=I0($,"src")||"",J=I0($,"alt")||"",Q=I0($,"width"),G=I0($,"height"),K=I0($,"sizes"),q=I0($,"srcset"),z=I0($,"densities"),U=I0($,"format"),W=I0($,"placeholder"),_=I0($,"placeholderColor")||"#e5e7eb",B=I0($,"provider"),j=I0($,"class")||I0($,"className")||"",H=I0($,"style")||"",L=I0($,"quality"),F=K8($,"lazy",!0),O=K8($,"preload",!1),V=K8($,"picture",!1)||!!U,w=Q?Number.parseInt(Q):void 0,R=G?Number.parseInt(G):void 0,A=q||"",N="";if(!A&&K)A=q8(X,G8,B,U),N=KJ(K);else if(!A&&z){let S=z.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));A=_W(X,S,w,B,U)}else if(K)N=KJ(K);let M=[];if(H)M.push(H);if(w&&R)M.push(`aspect-ratio:${w}/${R}`);if(W==="blur"||W==="color"||W==="thumbhash"){let S=BW(w||16,R||9,_);M.push(`background-image:url(${S})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat")}else if(W&&W!=="empty"&&W!=="none")M.push(`background-image:url(${_0(W)})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat");let T=r5(X,w,R,B,U),I=[];if(I.push(`src="${_0(T)}"`),I.push(`alt="${_0(J)}"`),Q)I.push(`width="${_0(Q)}"`);if(G)I.push(`height="${_0(G)}"`);if(F)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${_0(j)}"`);if(M.length>0)I.push(`style="${_0(M.join(";"))}"`);if(A)I.push(`srcset="${_0(A)}"`);if(N)I.push(`sizes="${_0(N)}"`);let D=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[S,b]of Object.entries($.static)){if(D.has(S))continue;if(typeof b==="boolean"){if(b)I.push(_0(S))}else I.push(`${_0(S)}="${_0(b)}"`)}let E=`<img ${I.join(" ")} />`,k="";if(O){let b=U==="webp"?"image/webp":U==="avif"?"image/avif":"";k=`<link rel="preload" as="image" href="${_0(T)}"${b?` type="${b}"`:""}${A?` imagesrcset="${_0(A)}"`:""}${N?` imagesizes="${_0(N)}"`:""} />
4024
- `}if(V){let S=[];if(U==="avif"||U==="auto"){let b=r5(X,w,R,B,"avif"),C=A?q8(X,G8,B,"avif"):`${b}`;S.push(`<source type="image/avif" srcset="${_0(C)}"${N?` sizes="${_0(N)}"`:""} />`)}if(U==="webp"||U==="auto"){let b=r5(X,w,R,B,"webp"),C=A?q8(X,G8,B,"webp"):`${b}`;S.push(`<source type="image/webp" srcset="${_0(C)}"${N?` sizes="${_0(N)}"`:""} />`)}return`${k}<picture>
4023
+ `).length;Y.set(q,{count:1,firstLine:W})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(zW.has(K.toLowerCase()))continue;let q=Y.get(K)?.count??0,z=X.get(K)??0;if(q!==z)G.push({tag:K,opened:q,closed:z,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function $8($,Z){let Y;try{Y=YJ($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(ZJ.has(X))return;ZJ.add(X);let J=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:q}of Y)if(G>K){let z=q?` (first opened at line ${q})`:"";console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${z} may swallow the content that follows it.`)}else console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var qW,zW,ZJ;var Z8=y(()=>{qW=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),zW=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);ZJ=new Set});import d0 from"path";import Y8 from"fs";function JJ($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function QJ($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class GJ{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 B=[J,J.toLowerCase(),JJ(J),QJ(J)];for(let j of B)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${JJ(J)}.stx`,`${QJ(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let B=d0.resolve(d0.dirname(Z),`${J}.stx`);if(await n(B))return B;return null}let K=[],q=Y.componentsDir||"",z=X?.__originalFilePath;if(z)K.push(d0.join(d0.dirname(z),"components"));if(q)K.push(q);let U=d0.join(d0.dirname(Z),"components");if(!K.includes(U))K.push(U);let W=process.cwd(),_=[d0.resolve(W,"src/components"),d0.resolve(W,"components"),d0.resolve(import.meta.dir,"components")];for(let B of _)if(!K.includes(B))K.push(B);for(let B of K){if(!B)continue;for(let j of G){let H=d0.join(B,j);if(await n(H))return H}try{if(!Y8.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let H=Y8.readdirSync(B,{withFileTypes:!0});for(let L of H)if(L.isDirectory()){let F=d0.join(B,L.name);for(let O of G){let V=d0.join(F,O);if(await n(V))return V}}}catch{}}return null}}var b0;var X8=y(()=>{V0();b0=new GJ});function w1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function UW($){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 J8;var Q8=y(()=>{J8={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=UW($),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,q=[];if(X.reactive)q.push(`:href="${w1(X.value)}"`);else q.push(`href="${w1(X.value)}"`);if(J)q.push(`class="${w1(J)}"`);if(q.push("data-stx-link"),q.push(`data-stx-active-class="${w1(Q)}"`),q.push(`data-stx-exact-active-class="${w1(G)}"`),K)q.push("data-stx-prefetch");let z=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[U,W]of Object.entries($.static)){if(z.has(U))continue;if(typeof W==="boolean"){if(W)q.push(w1(U))}else q.push(`${w1(U)}="${w1(W)}"`)}return`<a ${q.join(" ")}>${Z}</a>`}}});function _0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function D0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function K8($,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 KJ($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[J,Q]=X.split(":"),G=WW[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 q8($,Z,Y,X){return Z.map((J)=>`${r5($,J,void 0,Y,X)} ${J}w`).join(", ")}function _W($,Z,Y,X,J){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${r5($,G,void 0,X,J)} ${Q}x`}).join(", ")}function r5($,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 BW($,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 WW,G8,z8;var U8=y(()=>{WW={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},G8=[320,640,768,1024,1280,1536,1920];z8={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=D0($,"src")||"",J=D0($,"alt")||"",Q=D0($,"width"),G=D0($,"height"),K=D0($,"sizes"),q=D0($,"srcset"),z=D0($,"densities"),U=D0($,"format"),W=D0($,"placeholder"),_=D0($,"placeholderColor")||"#e5e7eb",B=D0($,"provider"),j=D0($,"class")||D0($,"className")||"",H=D0($,"style")||"",L=D0($,"quality"),F=K8($,"lazy",!0),O=K8($,"preload",!1),V=K8($,"picture",!1)||!!U,w=Q?Number.parseInt(Q):void 0,R=G?Number.parseInt(G):void 0,A=q||"",N="";if(!A&&K)A=q8(X,G8,B,U),N=KJ(K);else if(!A&&z){let S=z.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));A=_W(X,S,w,B,U)}else if(K)N=KJ(K);let M=[];if(H)M.push(H);if(w&&R)M.push(`aspect-ratio:${w}/${R}`);if(W==="blur"||W==="color"||W==="thumbhash"){let S=BW(w||16,R||9,_);M.push(`background-image:url(${S})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat")}else if(W&&W!=="empty"&&W!=="none")M.push(`background-image:url(${_0(W)})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat");let T=r5(X,w,R,B,U),I=[];if(I.push(`src="${_0(T)}"`),I.push(`alt="${_0(J)}"`),Q)I.push(`width="${_0(Q)}"`);if(G)I.push(`height="${_0(G)}"`);if(F)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${_0(j)}"`);if(M.length>0)I.push(`style="${_0(M.join(";"))}"`);if(A)I.push(`srcset="${_0(A)}"`);if(N)I.push(`sizes="${_0(N)}"`);let D=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[S,b]of Object.entries($.static)){if(D.has(S))continue;if(typeof b==="boolean"){if(b)I.push(_0(S))}else I.push(`${_0(S)}="${_0(b)}"`)}let E=`<img ${I.join(" ")} />`,k="";if(O){let b=U==="webp"?"image/webp":U==="avif"?"image/avif":"";k=`<link rel="preload" as="image" href="${_0(T)}"${b?` type="${b}"`:""}${A?` imagesrcset="${_0(A)}"`:""}${N?` imagesizes="${_0(N)}"`:""} />
4024
+ `}if(V){let S=[];if(U==="avif"||U==="auto"){let b=r5(X,w,R,B,"avif"),P=A?q8(X,G8,B,"avif"):`${b}`;S.push(`<source type="image/avif" srcset="${_0(P)}"${N?` sizes="${_0(N)}"`:""} />`)}if(U==="webp"||U==="auto"){let b=r5(X,w,R,B,"webp"),P=A?q8(X,G8,B,"webp"):`${b}`;S.push(`<source type="image/webp" srcset="${_0(P)}"${N?` sizes="${_0(N)}"`:""} />`)}return`${k}<picture>
4025
4025
  ${S.join(`
4026
4026
  `)}
4027
4027
  ${E}
@@ -4169,15 +4169,15 @@ document.addEventListener("focusout",function(e){
4169
4169
  <style>@keyframes stx-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}</style>
4170
4170
  <script>
4171
4171
  (function(){var el=document.getElementById('stx-loading-indicator'),p=0,l=!1,i=null;function u(v){p=Math.min(Math.max(v,0),100);if(el){el.style.opacity=p>0?'1':'0';el.style.transform='scaleX('+(p/100)+')'}}window.stxLoading={start:function(){l=!0;p=0;u(10);if(i)clearInterval(i);i=setInterval(function(){if(!l)return;var r=90-p,inc=Math.max(0.5,r*0.1);if(p<90)u(p+inc)},${j.throttle})},finish:function(){l=!1;if(i){clearInterval(i);i=null}u(100);setTimeout(function(){if(el)el.style.opacity='0';setTimeout(function(){p=0;if(el)el.style.transform='scaleX(0)'},300)},200)},set:function(v){u(v)},clear:function(){l=!1;p=0;if(i){clearInterval(i);i=null}if(el){el.style.opacity='0';el.style.transform='scaleX(0)'}}};document.addEventListener('click',function(e){var a=e.target.closest&&e.target.closest('a');if(!a)return;var h=a.getAttribute('href');if(!h||h.startsWith('http')||h.startsWith('#')||h.startsWith('mailto:')||h.startsWith('tel:')||a.target==='_blank')return;window.stxLoading.start()});window.addEventListener('popstate',function(){window.stxLoading.start()});window.addEventListener('load',function(){window.stxLoading.finish()})})();
4172
- </script>`}),J}async function uA($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(Q))!==null){let[z,U]=q,W=U.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of W){let B=_.split("/"),H=B[B.length-1].replace(/\.stx$/,""),L=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,O=[O5.resolve(O5.dirname(Y),`${_}.stx`),O5.resolve(O5.dirname(Y),_),O5.resolve(X.componentsDir||"components",`${_}.stx`),O5.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),J.add(F),X.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${_}`)}Q=Q.replace(z,""),K.lastIndex=0}return Q}async function mA($,Z,Y,X,J,Q){let G=$;if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,z;while((z=q.exec(G))!==null){let U=z.index,W=U+z[0].length-1,_=1,B=W+1;while(B<G.length&&_>0){if(G[B]==="(")_++;else if(G[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=G.substring(W+1,B),H=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let F=L[1],O,V=j.slice(L[0].length),w=V.match(/^\s*,\s*/);if(w)O=V.slice(w[0].length).trim();let R={};if(O)try{R=j0(O,Z)}catch(E){let k=E instanceof Error?E.message:String(E);G=G.replace(G.substring(U,H),`[Error parsing component props: ${k}]`);continue}let A="",N=H,T=G.substring(H).match(/^([\s\S]*?)@endcomponent/);if(T)A=T[1].trim(),N=H+T[0].length;let I=G.substring(U,N),D=await q1(F,R,A,X,Z,Y,J,K,Q);G=G.substring(0,U)+D+G.substring(N),q.lastIndex=0}return G}async function pA($,Z,Y,X,J,Q){let G=$;if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=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"]),z=R$(G);return G=z.output,G=await B(G,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),G=await B(G,/[A-Z][a-zA-Z0-9]*/,!0),G=await B(G,/[a-z][a-z0-9]*/,!1,q),G=A$(G,z.scripts),G;async function B(j,H,L,F){let O=j,V=E8(O,H,F);for(let w=V.length-1;w>=0;w--){let R=V[w],A=L?D8(R.tagName):R.tagName,N=AW(R.attributes),M={};for(let[I,D]of Object.entries(N)){if(I.startsWith("@"))continue;if(I.startsWith("__stx_")){let E=I.slice(6);M[E]=k8(D,J);continue}if(I.startsWith(":")){let E=I.slice(1),k=D==="true"?E:D;try{if(!$0(k)){if(J.debug)console.error(`Unsafe expression in :${E} binding: ${k}`);M[E]=D}else{let S=Z0(k,Object.keys(Z));M[E]=S(...Object.values(Z))}}catch(S){if(J.debug)console.error(`Error evaluating :${E} binding:`,S);M[E]=D}continue}if(typeof D==="string"&&D.includes("{{")&&D.includes("}}")){let E=D.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(E)try{let k=E[1];if(!$0(k)){if(J.debug)console.error(`Unsafe expression in ${I}: ${k}`);M[I]=D}else{let S=Z0(k,Object.keys(Z));M[I]=S(...Object.values(Z))}}catch(k){if(J.debug)console.error(`Error evaluating expression for ${I}:`,k);M[I]=D}else{let k=D,S=/\{\{\s*([\s\S]+?)\s*\}\}/g,b;while((b=S.exec(D))!==null)try{let C=b[1];if(!$0(C)){if(J.debug)console.error(`Unsafe expression in ${I}: ${C}`);continue}let f=Z0(C,Object.keys(Z))(...Object.values(Z));k=k.replace(b[0],String(f??""))}catch(C){if(J.debug)console.error(`Error evaluating expression in ${I}:`,C)}M[I]=k}}else M[I]=D}let T=await q1(A,M,R.content,X,Z,Y,J,K,Q);O=O.substring(0,R.startIndex)+T+O.substring(R.endIndex)}return O}}var FJ=y(()=>{F0();V0();N$()});var TJ={};c(TJ,{processESImports:()=>NJ,processComponents:()=>M4});import T4 from"fs";import x0 from"path";function TW($,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,q)=>q.toUpperCase())};for(let[G,K]of Object.entries($)){let q=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(q.startsWith("@")){X.events[q]=K;continue}if(q.startsWith("__stx_")){let z=Q(q.slice(6));X.serverDynamic[z]=k8(K,Y);continue}if(q.startsWith(":")){let z=Q(q.slice(1)),U=K==="true"?z:K;try{if(!$0(U)){if(Y.debug)console.error(`Unsafe expression in :${z} binding: ${U}`);X.clientReactive[z]=U;continue}let W=Object.keys(Z),B=Z0(U,W)(...Object.values(Z));if(B===void 0){let j=U.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!W.includes(F))){X.clientReactive[z]=U;continue}}X.serverDynamic[z]=B}catch{X.clientReactive[z]=U}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let z=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(z)try{let U=z[1];if($0(U)){let _=Z0(U,Object.keys(Z))(...Object.values(Z));X.static[q]=_!=null?String(_):""}else{if(Y.debug)console.error(`Unsafe expression in ${q}: ${U}`);X.static[q]=K}}catch(U){if(Y.debug)console.error(`Error evaluating expression for ${q}:`,U);X.static[q]=K}else{let U=K,W=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=W.exec(K))!==null)try{let B=_[1];if(!$0(B)){if(Y.debug)console.error(`Unsafe expression in ${q}: ${B}`);continue}let H=Z0(B,Object.keys(Z))(...Object.values(Z));U=U.replace(_[0],String(H??""))}catch(B){if(Y.debug)console.error(`Error evaluating expression in ${q}:`,B)}X.static[q]=U}continue}X.static[q]=K}return X}function MW($){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 wJ($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function IW($){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(b0.isBuiltin(J))Z.add(J)}return[...Z].sort()}function DW($){let Z=RJ.get($);if(Z)return Z;let Y=new Map,X=[x0.join($,"src"),x0.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=T4.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let q of K){let z=x0.join(Q,q.name);if(q.isDirectory()){if(q.name==="node_modules"||q.name.startsWith("."))continue;J(z,G+1)}else if(q.isFile()&&q.name.endsWith(".stx")){let U=q.name.slice(0,-4);if(!Y.has(U))Y.set(U,z);let W=U.toLowerCase();if(!Y.has(W))Y.set(W,z);let _=U.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(_))Y.set(_,z)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return RJ.set($,Y),Y}function EW($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=x0.join(Y,"node_modules",$);try{if(T4.statSync(X).isDirectory())return X}catch{}let J=x0.dirname(Y);if(J===Y)return null;Y=J}}async function NJ($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=x0.dirname(Y),K=$,q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(q,(z,U,W)=>{let _=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=W,j,H=[];while((j=_.exec(W))!==null){let[L,F,O,V]=j,w=null,R=null;if(V.startsWith(".")||V.startsWith("/")){let M=x0.resolve(G,V);if(M.endsWith(".stx"))R=M;else{let T=`${M}.stx`;try{if(T4.statSync(T).isFile())R=T}catch{try{if(T4.statSync(M).isDirectory())w=M}catch{}}}}else w=EW(V,G);if(!w&&!R)continue;let A=!1,N=(M,T)=>{Q.set(M,T),Q.set(M.toLowerCase(),T);let I=M.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,T),J.add(T)};if(O&&R)N(O,R),A=!0;else if(F){let M=F.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let D=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:I,local:I}}),T=w?DW(w):null;for(let{source:I,local:D}of M){let E=null;if(R)E=R;else if(T)E=T.get(I)??T.get(I.toLowerCase())??T.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)N(D,E),A=!0}}if(A)H.push({start:j.index,end:j.index+L.length})}if(H.length===0)return z;for(let L=H.length-1;L>=0;L--)B=B.slice(0,H[L].start)+B.slice(H[L].end);return`<script${U}>${B}</script>`}),K}async function kW($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(Q))!==null){let[z,U]=q,W=U.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of W){let B=_.split("/"),H=B[B.length-1].replace(/\.stx$/,""),L=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,O=[x0.resolve(x0.dirname(Y),`${_}.stx`),x0.resolve(x0.dirname(Y),_),x0.resolve(X.componentsDir||"components",`${_}.stx`),x0.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),J.add(F),X.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${_}`)}Q=Q.replace(z,""),K.lastIndex=0}return Q}async function SW($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,z;while((z=q.exec(Q))!==null){let U=z.index,W=U+z[0].length-1,_=1,B=W+1;while(B<Q.length&&_>0){if(Q[B]==="(")_++;else if(Q[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=Q.substring(W+1,B),H=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let F=L[1],O,V=j.slice(L[0].length),w=V.match(/^\s*,\s*/);if(w)O=V.slice(w[0].length).trim();let R={};if(O)try{R=j0(O,Z)}catch(D){let E=D instanceof Error?D.message:String(D);Q=Q.replace(Q.substring(U,H),`[Error parsing component props: ${E}]`);continue}let A="",N=H,T=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(T)A=T[1].trim(),N=H+T[0].length;let I=await q1(F,R,A,G,Z,Y,X,K,J);Q=Q.substring(0,U)+I+Q.substring(N),q.lastIndex=0}return Q}async function bW($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=R$(Q);return Q=q.output,Q=await _(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await _(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await _(Q,/[a-z][a-z0-9]*/,!1,NW),Q=A$(Q,q.scripts),Q;async function _(B,j,H,L){if(!B)return B;let F=B,O=E8(F,j,L);for(let V=O.length-1;V>=0;V--){let w=O[V],R=H?D8(w.tagName):w.tagName,A=MW(w.attributes),N=TW(A,Z,X),M=b0.getBuiltin(w.tagName),T=M?await MJ(R,G,Z,Y,X):!1;if(M&&!T){let k={context:Z,filePath:Y,options:X,dependencies:J},S=M.render(N,w.content,k);if(Object.keys(N.clientReactive).length>0)S=AJ(S,N.clientReactive);if(Object.keys(N.events).length>0){let b=Object.entries(N.events).map(([C,d])=>`${C}="${wJ(d)}"`).join(" ");S=S.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}F=F.substring(0,w.startIndex)+S+F.substring(w.endIndex);continue}let I={};for(let[k,S]of Object.entries(N.static))I[k]=S;for(let[k,S]of Object.entries(N.serverDynamic))I[k]=S;let E=await q1(R,I,w.content,G,Z,Y,X,K,J);if(Object.keys(N.clientReactive).length>0)E=AJ(E,N.clientReactive);if(Object.keys(N.events).length>0){let k=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(k){let S=Object.entries(N.events).map(([C,d])=>`${C}="${wJ(d)}"`).join(" "),b=k[1].length+k[2].length;E=E.substring(0,b)+" "+S+E.substring(b)}}F=F.substring(0,w.startIndex)+E+F.substring(w.endIndex)}return F}}function AJ($,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 M4($,Z,Y,X,J){if(!VJ)OJ(),VJ=!0;let Q=await NJ($,Z,Y,X,J);Q=await kW(Q,Z,Y,X,J),Q=await SW(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await bW(Q,Z,Y,X,J),Q===K)break}if(X.debug){let G=IW(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 VJ=!1,NW,RJ;var S8=y(()=>{X8();LJ();FJ();V0();F0();NW=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"]);RJ=new Map});var I4={};c(I4,{stripTypeScript:()=>SJ,hasVariables:()=>vJ,extractVariables:()=>m1,extractScriptFromTemplate:()=>PJ,convertToCommonJS:()=>y8});import L5 from"path";import t5 from"process";function yW($){let Z=[],Y=0,X=$.split(`
4172
+ </script>`}),J}async function uA($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(Q))!==null){let[z,U]=q,W=U.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of W){let B=_.split("/"),H=B[B.length-1].replace(/\.stx$/,""),L=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,O=[O5.resolve(O5.dirname(Y),`${_}.stx`),O5.resolve(O5.dirname(Y),_),O5.resolve(X.componentsDir||"components",`${_}.stx`),O5.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),J.add(F),X.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${_}`)}Q=Q.replace(z,""),K.lastIndex=0}return Q}async function mA($,Z,Y,X,J,Q){let G=$;if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,z;while((z=q.exec(G))!==null){let U=z.index,W=U+z[0].length-1,_=1,B=W+1;while(B<G.length&&_>0){if(G[B]==="(")_++;else if(G[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=G.substring(W+1,B),H=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let F=L[1],O,V=j.slice(L[0].length),w=V.match(/^\s*,\s*/);if(w)O=V.slice(w[0].length).trim();let R={};if(O)try{R=j0(O,Z)}catch(E){let k=E instanceof Error?E.message:String(E);G=G.replace(G.substring(U,H),`[Error parsing component props: ${k}]`);continue}let A="",N=H,T=G.substring(H).match(/^([\s\S]*?)@endcomponent/);if(T)A=T[1].trim(),N=H+T[0].length;let I=G.substring(U,N),D=await q1(F,R,A,X,Z,Y,J,K,Q);G=G.substring(0,U)+D+G.substring(N),q.lastIndex=0}return G}async function pA($,Z,Y,X,J,Q){let G=$;if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=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"]),z=R$(G);return G=z.output,G=await B(G,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),G=await B(G,/[A-Z][a-zA-Z0-9]*/,!0),G=await B(G,/[a-z][a-z0-9]*/,!1,q),G=A$(G,z.scripts),G;async function B(j,H,L,F){let O=j,V=E8(O,H,F);for(let w=V.length-1;w>=0;w--){let R=V[w],A=L?D8(R.tagName):R.tagName,N=AW(R.attributes),M={};for(let[I,D]of Object.entries(N)){if(I.startsWith("@"))continue;if(I.startsWith("__stx_")){let E=I.slice(6);M[E]=k8(D,J);continue}if(I.startsWith(":")){let E=I.slice(1),k=D==="true"?E:D;try{if(!$0(k)){if(J.debug)console.error(`Unsafe expression in :${E} binding: ${k}`);M[E]=D}else{let S=Z0(k,Object.keys(Z));M[E]=S(...Object.values(Z))}}catch(S){if(J.debug)console.error(`Error evaluating :${E} binding:`,S);M[E]=D}continue}if(typeof D==="string"&&D.includes("{{")&&D.includes("}}")){let E=D.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(E)try{let k=E[1];if(!$0(k)){if(J.debug)console.error(`Unsafe expression in ${I}: ${k}`);M[I]=D}else{let S=Z0(k,Object.keys(Z));M[I]=S(...Object.values(Z))}}catch(k){if(J.debug)console.error(`Error evaluating expression for ${I}:`,k);M[I]=D}else{let k=D,S=/\{\{\s*([\s\S]+?)\s*\}\}/g,b;while((b=S.exec(D))!==null)try{let P=b[1];if(!$0(P)){if(J.debug)console.error(`Unsafe expression in ${I}: ${P}`);continue}let f=Z0(P,Object.keys(Z))(...Object.values(Z));k=k.replace(b[0],String(f??""))}catch(P){if(J.debug)console.error(`Error evaluating expression in ${I}:`,P)}M[I]=k}}else M[I]=D}let T=await q1(A,M,R.content,X,Z,Y,J,K,Q);O=O.substring(0,R.startIndex)+T+O.substring(R.endIndex)}return O}}var FJ=y(()=>{F0();V0();N$()});var TJ={};c(TJ,{processESImports:()=>NJ,processComponents:()=>M4});import T4 from"fs";import x0 from"path";function TW($,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,q)=>q.toUpperCase())};for(let[G,K]of Object.entries($)){let q=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(q.startsWith("@")){X.events[q]=K;continue}if(q.startsWith("__stx_")){let z=Q(q.slice(6));X.serverDynamic[z]=k8(K,Y);continue}if(q.startsWith(":")){let z=Q(q.slice(1)),U=K==="true"?z:K;try{if(!$0(U)){if(Y.debug)console.error(`Unsafe expression in :${z} binding: ${U}`);X.clientReactive[z]=U;continue}let W=Object.keys(Z),B=Z0(U,W)(...Object.values(Z));if(B===void 0){let j=U.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!W.includes(F))){X.clientReactive[z]=U;continue}}X.serverDynamic[z]=B}catch{X.clientReactive[z]=U}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let z=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(z)try{let U=z[1];if($0(U)){let _=Z0(U,Object.keys(Z))(...Object.values(Z));X.static[q]=_!=null?String(_):""}else{if(Y.debug)console.error(`Unsafe expression in ${q}: ${U}`);X.static[q]=K}}catch(U){if(Y.debug)console.error(`Error evaluating expression for ${q}:`,U);X.static[q]=K}else{let U=K,W=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=W.exec(K))!==null)try{let B=_[1];if(!$0(B)){if(Y.debug)console.error(`Unsafe expression in ${q}: ${B}`);continue}let H=Z0(B,Object.keys(Z))(...Object.values(Z));U=U.replace(_[0],String(H??""))}catch(B){if(Y.debug)console.error(`Error evaluating expression in ${q}:`,B)}X.static[q]=U}continue}X.static[q]=K}return X}function MW($){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 wJ($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function IW($){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(b0.isBuiltin(J))Z.add(J)}return[...Z].sort()}function DW($){let Z=RJ.get($);if(Z)return Z;let Y=new Map,X=[x0.join($,"src"),x0.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=T4.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let q of K){let z=x0.join(Q,q.name);if(q.isDirectory()){if(q.name==="node_modules"||q.name.startsWith("."))continue;J(z,G+1)}else if(q.isFile()&&q.name.endsWith(".stx")){let U=q.name.slice(0,-4);if(!Y.has(U))Y.set(U,z);let W=U.toLowerCase();if(!Y.has(W))Y.set(W,z);let _=U.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(_))Y.set(_,z)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return RJ.set($,Y),Y}function EW($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=x0.join(Y,"node_modules",$);try{if(T4.statSync(X).isDirectory())return X}catch{}let J=x0.dirname(Y);if(J===Y)return null;Y=J}}async function NJ($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=x0.dirname(Y),K=$,q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(q,(z,U,W)=>{let _=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=W,j,H=[];while((j=_.exec(W))!==null){let[L,F,O,V]=j,w=null,R=null;if(V.startsWith(".")||V.startsWith("/")){let M=x0.resolve(G,V);if(M.endsWith(".stx"))R=M;else{let T=`${M}.stx`;try{if(T4.statSync(T).isFile())R=T}catch{try{if(T4.statSync(M).isDirectory())w=M}catch{}}}}else w=EW(V,G);if(!w&&!R)continue;let A=!1,N=(M,T)=>{Q.set(M,T),Q.set(M.toLowerCase(),T);let I=M.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,T),J.add(T)};if(O&&R)N(O,R),A=!0;else if(F){let M=F.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let D=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:I,local:I}}),T=w?DW(w):null;for(let{source:I,local:D}of M){let E=null;if(R)E=R;else if(T)E=T.get(I)??T.get(I.toLowerCase())??T.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)N(D,E),A=!0}}if(A)H.push({start:j.index,end:j.index+L.length})}if(H.length===0)return z;for(let L=H.length-1;L>=0;L--)B=B.slice(0,H[L].start)+B.slice(H[L].end);return`<script${U}>${B}</script>`}),K}async function kW($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(Q))!==null){let[z,U]=q,W=U.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of W){let B=_.split("/"),H=B[B.length-1].replace(/\.stx$/,""),L=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,O=[x0.resolve(x0.dirname(Y),`${_}.stx`),x0.resolve(x0.dirname(Y),_),x0.resolve(X.componentsDir||"components",`${_}.stx`),x0.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),J.add(F),X.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${_}`)}Q=Q.replace(z,""),K.lastIndex=0}return Q}async function SW($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,z;while((z=q.exec(Q))!==null){let U=z.index,W=U+z[0].length-1,_=1,B=W+1;while(B<Q.length&&_>0){if(Q[B]==="(")_++;else if(Q[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=Q.substring(W+1,B),H=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let F=L[1],O,V=j.slice(L[0].length),w=V.match(/^\s*,\s*/);if(w)O=V.slice(w[0].length).trim();let R={};if(O)try{R=j0(O,Z)}catch(D){let E=D instanceof Error?D.message:String(D);Q=Q.replace(Q.substring(U,H),`[Error parsing component props: ${E}]`);continue}let A="",N=H,T=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(T)A=T[1].trim(),N=H+T[0].length;let I=await q1(F,R,A,G,Z,Y,X,K,J);Q=Q.substring(0,U)+I+Q.substring(N),q.lastIndex=0}return Q}async function bW($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=R$(Q);return Q=q.output,Q=await _(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await _(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await _(Q,/[a-z][a-z0-9]*/,!1,NW),Q=A$(Q,q.scripts),Q;async function _(B,j,H,L){if(!B)return B;let F=B,O=E8(F,j,L);for(let V=O.length-1;V>=0;V--){let w=O[V],R=H?D8(w.tagName):w.tagName,A=MW(w.attributes),N=TW(A,Z,X),M=b0.getBuiltin(w.tagName),T=M?await MJ(R,G,Z,Y,X):!1;if(M&&!T){let k={context:Z,filePath:Y,options:X,dependencies:J},S=M.render(N,w.content,k);if(Object.keys(N.clientReactive).length>0)S=AJ(S,N.clientReactive);if(Object.keys(N.events).length>0){let b=Object.entries(N.events).map(([P,d])=>`${P}="${wJ(d)}"`).join(" ");S=S.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}F=F.substring(0,w.startIndex)+S+F.substring(w.endIndex);continue}let I={};for(let[k,S]of Object.entries(N.static))I[k]=S;for(let[k,S]of Object.entries(N.serverDynamic))I[k]=S;let E=await q1(R,I,w.content,G,Z,Y,X,K,J);if(Object.keys(N.clientReactive).length>0)E=AJ(E,N.clientReactive);if(Object.keys(N.events).length>0){let k=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(k){let S=Object.entries(N.events).map(([P,d])=>`${P}="${wJ(d)}"`).join(" "),b=k[1].length+k[2].length;E=E.substring(0,b)+" "+S+E.substring(b)}}F=F.substring(0,w.startIndex)+E+F.substring(w.endIndex)}return F}}function AJ($,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 M4($,Z,Y,X,J){if(!VJ)OJ(),VJ=!0;let Q=await NJ($,Z,Y,X,J);Q=await kW(Q,Z,Y,X,J),Q=await SW(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await bW(Q,Z,Y,X,J),Q===K)break}if(X.debug){let G=IW(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 VJ=!1,NW,RJ;var S8=y(()=>{X8();LJ();FJ();V0();F0();NW=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"]);RJ=new Map});var I4={};c(I4,{stripTypeScript:()=>SJ,hasVariables:()=>vJ,extractVariables:()=>m1,extractScriptFromTemplate:()=>PJ,convertToCommonJS:()=>y8});import L5 from"path";import t5 from"process";function yW($){let Z=[],Y=0,X=$.split(`
4173
4173
  `);for(let J of X){let Q=Y,G=null,K=!1;for(let q=0;q<J.length;q++){let z=J[q];if(K){K=!1;continue}if(z==="\\"){K=!0;continue}if(G){if(z===G)G=null;continue}if(z==="'"||z==='"'||z==="`"){G=z;continue}if(z==="/"&&q+1<J.length&&J[q+1]==="/")break;if(z==="{")Y++;else if(z==="}")Y--}if(Q===0){let q=J.match(/(?:const|let|var)\s+(\w+)\s*=/);if(q)Z.push(q[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(J)){let z=J.match(/(?:const|let|var)\s+(\w+)/);if(z)Z.push(z[1])}else{let z=J.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(z){let W=z[1].slice(1,-1).split(",").map((_)=>{let B=_.split(":");return(B.length>1?B[1]:B[0]).trim()}).filter((_)=>/^\w+$/.test(_));Z.push(...W)}}}}return[...new Set(Z)]}function SJ($){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,q=null;for(let z=0;z<X.length;z++){let U=X[z];if(q){if(Q+=U,U===q)q=null;continue}if(U==='"'||U==="'"||U==="`"){q=U,Q+=U;continue}if(U==="<")G++;else if(U===">"&&G>0)G--;else if(U==="(")K++;else if(U===")")K--;if(U===","&&G===0&&K===0){J.push(Q),Q="";continue}Q+=U}if(Q)J.push(Q);return J.map((z)=>{let U=z.trim(),W=U.startsWith("..."),_=W?U.slice(3):U,B=-1,j=0;for(let R=0;R<_.length;R++)if(_[R]==="<")j++;else if(_[R]===">")j--;else if(_[R]===":"&&j===0){B=R;break}if(B===-1)return z;let L=_.substring(0,B).trim().replace(/\?$/,""),F=_.substring(B+1),O=-1,V=0;for(let R=0;R<F.length;R++)if(F[R]==="<")V++;else if(F[R]===">")V--;else if(F[R]==="="&&V===0){O=R;break}let w=W?"...":"";if(O!==-1)return`${w}${L} = ${F.substring(O+1).trim()}`;return`${w}${L}`}).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,q=G+1,z=0,U=null;while(q<Z.length&&K>0){let B=Z[q];if(U){if(B===U)U=null;q++;continue}if(B==='"'||B==="'"||B==="`"){U=B,q++;continue}if(B==="<")z++;else if(B===">"&&z>0)z--;else if(z===0){if(B==="(")K++;else if(B===")")K--}if(K>0)q++}if(K!==0)continue;let W=Z.substring(G+1,q);if(!W.includes(":"))continue;let _=Y(W);Q.push({start:G+1,end:q,replacement:_})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:q,replacement:z}=Q[G];Z=Z.substring(0,K)+z+Z.substring(q)}}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,...q]=G.split("="),z=K.split(":")[0].trim();if(q.length>0)return`${z} = ${q.join("=").trim()}`;return z}).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,`
4174
4174
 
4175
- `),Z}async function m1($,Z,Y,X={}){if(!$.trim())return;let J;try{let P=new Bun.Transpiler({loader:"ts",target:"browser",define:s0()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),J=P.transformSync(v)}catch{J=SJ($)}let Q={exports:{}},G=Q.exports,K=t5.cwd(),q={},z=[...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 z)try{let v=L5.resolve(K,"node_modules",P),x=L5.join(v,"package.json"),g=JSON.parse(Q0("fs").readFileSync(x,"utf8")),p=g.main||"index.js";if(g.exports){let s=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof s==="string")p=s;else if(s?.bun)p=s.bun;else if(s?.import)p=s.import;else if(s?.default)p=s.default}q[P]=await import(L5.resolve(v,p))}catch{}let U=(P)=>{if(q[P])return q[P];return Q0(P)},W=Z.props||{},_=Object.assign((P)=>{if(!P)return W;let v={};for(let[x,g]of Object.entries(P)){let p=W[x];if(p!==void 0)v[x]=p;else if(typeof g==="function")v[x]=g();else v[x]=g}return v},W),B=(P)=>{if(!P)return W;let v={...W};for(let[x,g]of Object.entries(P)){let p=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(v[x]===void 0&&p.default!==void 0)v[x]=typeof p.default==="function"?p.default():p.default}return v},j=()=>Z.slots||{},H=(P,v)=>{let x={...P};for(let[g,p]of Object.entries(v))if(x[g]===void 0)if(typeof p==="function")x[g]=p();else x[g]=p;return x},L=(P)=>{let v=()=>P;return v.set=(x)=>{},v.update=(x)=>{},v},F=(P)=>{let v,x=!1;return()=>{if(!x)try{v=P(),x=!0}catch{v=void 0}return v}},O=(P)=>{},V=(P)=>P(),w=(P)=>{},R=(P)=>{},A=(P)=>{},N=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),M=()=>({push:(P)=>{},replace:(P)=>{},back:()=>{},forward:()=>{},go:(P)=>{}}),T=(P)=>{d1(P);let v=Z.__stx_runtime_head||{},x=P||{};Z.__stx_runtime_head={...v,...x.title&&{title:x.title},meta:[...v.meta||[],...x.meta||[]],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],htmlAttrs:{...v.htmlAttrs||{},...x.htmlAttrs||{}},bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs||{}}}},I=(P)=>{H4(P);let v=p5();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...v.title&&{title:v.title},meta:v.meta?[...v.meta]:[]}},D=(P)=>({value:P}),E=(P)=>P,k=(P)=>({value:typeof P==="function"?P():P}),S=(P,v)=>{},b=(P)=>{},C=(P)=>{},d=(P)=>P?P():Promise.resolve(),f=(P)=>(v,...x)=>{},m=(P)=>{},o=(P,v)=>{},N0=(P,v)=>v,Z1=()=>({value:"light"}),C0=()=>({value:!1}),E0={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:{}},X0=new Proxy(E0,{get(P,v){if(v in P)return P[v];return},set(P,v,x){return P[v]=x,!0}}),L0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},U0=console;try{let P=y8(J,Y),v=new Set(Object.keys(W)),x=Object.keys(Z).filter((t)=>!v.has(t)&&t!=="props"),g=x.map((t)=>Z[t]),p=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"]),s=[],G0=[];for(let[t,o0]of Object.entries(W)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t))continue;if(p.has(t))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${t}\\b`).test(P))continue;s.push(t),G0.push(o0)}let P0=yW(P).map((t)=>`module.exports.${t} = typeof ${t} !== 'undefined' ? ${t} : module.exports.${t};`).join(`
4175
+ `),Z}async function m1($,Z,Y,X={}){if(!$.trim())return;let J;try{let C=new Bun.Transpiler({loader:"ts",target:"browser",define:s0()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),J=C.transformSync(v)}catch{J=SJ($)}let Q={exports:{}},G=Q.exports,K=t5.cwd(),q={},z=[...J.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((C)=>C[1]).filter((C)=>!C.startsWith("node:")&&!C.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(C));for(let C of z)try{let v=L5.resolve(K,"node_modules",C),x=L5.join(v,"package.json"),g=JSON.parse(Q0("fs").readFileSync(x,"utf8")),p=g.main||"index.js";if(g.exports){let s=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof s==="string")p=s;else if(s?.bun)p=s.bun;else if(s?.import)p=s.import;else if(s?.default)p=s.default}q[C]=await import(L5.resolve(v,p))}catch{}let U=(C)=>{if(q[C])return q[C];return Q0(C)},W=Z.props||{},_=Object.assign((C)=>{if(!C)return W;let v={};for(let[x,g]of Object.entries(C)){let p=W[x];if(p!==void 0)v[x]=p;else if(typeof g==="function")v[x]=g();else v[x]=g}return v},W),B=(C)=>{if(!C)return W;let v={...W};for(let[x,g]of Object.entries(C)){let p=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(v[x]===void 0&&p.default!==void 0)v[x]=typeof p.default==="function"?p.default():p.default}return v},j=()=>Z.slots||{},H=(C,v)=>{let x={...C};for(let[g,p]of Object.entries(v))if(x[g]===void 0)if(typeof p==="function")x[g]=p();else x[g]=p;return x},L=(C)=>{let v=()=>C;return v.set=(x)=>{},v.update=(x)=>{},v},F=(C)=>{let v,x=!1;return()=>{if(!x)try{v=C(),x=!0}catch{v=void 0}return v}},O=(C)=>{},V=(C)=>C(),w=(C)=>{},R=(C)=>{},A=(C)=>{},N=()=>{let C=Z.__stxServeContext,v=Z.__stxServeSearch??C?.search??"",x=C?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(v)),path:x,name:"",fullPath:x+v,hash:"",matched:[]}},M=()=>({push:(C)=>{},replace:(C)=>{},back:()=>{},forward:()=>{},go:(C)=>{}}),T=(C)=>{d1(C);let v=Z.__stx_runtime_head||{},x=C||{};Z.__stx_runtime_head={...v,...x.title&&{title:x.title},meta:[...v.meta||[],...x.meta||[]],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],htmlAttrs:{...v.htmlAttrs||{},...x.htmlAttrs||{}},bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs||{}}}},I=(C)=>{H4(C);let v=p5();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...v.title&&{title:v.title},meta:v.meta?[...v.meta]:[]}},D=(C)=>({value:C}),E=(C)=>C,k=(C)=>({value:typeof C==="function"?C():C}),S=(C,v)=>{},b=(C)=>{},P=(C)=>{},d=(C)=>C?C():Promise.resolve(),f=(C)=>(v,...x)=>{},m=(C)=>{},o=(C,v)=>{},N0=(C,v)=>v,Z1=()=>({value:"light"}),C0=()=>({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:{}},X0=new Proxy(k0,{get(C,v){if(v in C)return C[v];return},set(C,v,x){return C[v]=x,!0}}),L0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},U0=console;try{let C=y8(J,Y),v=new Set(Object.keys(W)),x=Object.keys(Z).filter((t)=>!v.has(t)&&t!=="props"),g=x.map((t)=>Z[t]),p=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"]),s=[],G0=[];for(let[t,o0]of Object.entries(W)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t))continue;if(p.has(t))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${t}\\b`).test(C))continue;s.push(t),G0.push(o0)}let P0=yW(C).map((t)=>`module.exports.${t} = typeof ${t} !== 'undefined' ? ${t} : module.exports.${t};`).join(`
4176
4176
  `),I1=Z.params??{},z0=[],D1=[];for(let t=0;t<x.length;t++){if(x[t]==="params")continue;z0.push(x[t]),D1.push(g[t])}let U$=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",...s,...z0,`return (async () => {
4177
- ${P}
4177
+ ${C}
4178
4178
  ${P0}
4179
4179
  return module.exports
4180
- })()`)(Q,G,U,W,_,B,H,L,F,O,V,w,R,A,N,M,T,I,D,E,k,S,b,C,d,f,m,j,o,N0,Z1,C0,X0,L0,U0,E0.confirm,E0.alert,E0.fetch,I1,...G0,...D1);if(X.preserveExisting){for(let[t,o0]of Object.entries(U$))if(!(t in Z)||Z[t]===void 0)Z[t]=o0}else Object.assign(Z,U$);for(let[t,o0]of Object.entries(W))if(!(t in Z))Z[t]=o0}catch(P){if(t5.env.STX_DEBUG){let v=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: ${v}`)}try{await fW(J,Z,Y)}catch(v){if(t5.env.STX_DEBUG){let x=v instanceof Error?v.message:String(v);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${x}`)}}}}function y8($,Z){let Y=Z?L5.dirname(Z):t5.cwd(),X=$.split(`
4180
+ })()`)(Q,G,U,W,_,B,H,L,F,O,V,w,R,A,N,M,T,I,D,E,k,S,b,P,d,f,m,j,o,N0,Z1,C0,X0,L0,U0,k0.confirm,k0.alert,k0.fetch,I1,...G0,...D1);if(X.preserveExisting){for(let[t,o0]of Object.entries(U$))if(!(t in Z)||Z[t]===void 0)Z[t]=o0}else Object.assign(Z,U$);for(let[t,o0]of Object.entries(W))if(!(t in Z))Z[t]=o0}catch(C){if(t5.env.STX_DEBUG){let v=C instanceof Error?C.message:String(C);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${v}`)}try{await fW(J,Z,Y)}catch(v){if(t5.env.STX_DEBUG){let x=v instanceof Error?v.message:String(v);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${x}`)}}}}function y8($,Z){let Y=Z?L5.dirname(Z):t5.cwd(),X=$.split(`
4181
4181
  `),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 q of X[Q])if(q==="{")K++;else if(q==="}")K--;if(K<=0)break}}Q++;continue}if(G.startsWith("definePageMeta(")){let K=0,q=!1;for(let z=Q;z<X.length&&!q;z++){let U=null,W=!1,_=X[z];for(let B=0;B<_.length;B++){let j=_[B];if(W){W=!1;continue}if(j==="\\"){W=!0;continue}if(U){if(j===U)U=null;continue}if(j==='"'||j==="'"||j==="`"){U=j;continue}if(j==="(")K++;else if(j===")"){if(K--,K===0){Q=z+1,q=!0;break}}}}if(!q)Q=X.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),q=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),z=G.match(/^import\s+['"](.+)['"]/),U=(W)=>{if(W.startsWith("."))return L5.resolve(Y,W);return W};if(K){let[,W,_]=K,B=U(_);J.push(`const ${W} = await import('${B}')`),J.push(`module.exports.${W} = ${W};`)}else if(q){let[,W,_]=q,B=W.trim(),j=U(_);J.push(`const { ${B} } = await import('${j}')`);for(let H of B.split(",")){let L=H.trim().split(/\s+as\s+/).pop()?.trim();if(L)J.push(`module.exports.${L} = ${L};`)}}else if(z){let W=U(z[1]);J.push(`await import('${W}')`)}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=IJ(X,Q),{type:q,name:z,value:U}=K;J.push(`${q} ${z} = ${U};`),J.push(`module.exports.${z} = ${z};`),Q=K.nextIndex}else if(G.startsWith("export function ")||G.startsWith("export async function ")){let K=b8(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=IJ(X,Q),{type:q,name:z,value:U}=K;J.push(`${q} ${z} = ${U};`),J.push(`module.exports.${z} = ${z};`),Q=K.nextIndex}else if(G.startsWith("function ")||G.startsWith("async function ")){let K=b8(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"),q=[...X];q[Q]=K;let z=b8(q,Q);if(J.push(z.functionCode),z.name)J.push(`module.exports.default = ${z.name};`);Q=z.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 q=K[1],z=X[Q].replace(/^export\s+/,""),U=0,W=Q;for(;W<X.length;W++){let _=X[W];for(let B of _)if(B==="{")U++;else if(B==="}")U--;if(W>Q)z+=`
4182
4182
  `+_;if(U<=0&&W>=Q)break}J.push(z),J.push(`module.exports.${q} = ${q};`),Q=W+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 CW(J.join(`
4183
4183
  `),Y)}function CW($,Z){let Y=$.length,X="",J=0,Q=null,G=!1,K=!1,q=0;while(J<Y){let z=$[J],U=$[J+1];if(G){if(X+=z,z===`
@@ -4187,7 +4187,7 @@ ${R}`,nextIndex:O}}}}throw Error(`Failed to parse variable declaration: ${Y}`)}l
4187
4187
  ${$[q]}`,q++;else break}return K=K.trim().replace(/;$/,""),{type:J,name:Q,value:K,nextIndex:q}}function b8($,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(vW(Y)){let K=xW($,Z,Q);Q=K.functionCode,G=K.nextIndex}else G=Z+1;return{name:J,functionCode:Q,nextIndex:G}}function DJ($){let Z=$.trim();if(Z.startsWith("{"))return O0(Z,"{","}",0)===-1;if(Z.startsWith("["))return O0(Z,"[","]",0)===-1;return!CJ(Z)}function CJ($){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 vW($){let Z=$.indexOf("{");if(Z===-1)return!0;return O0($,"{","}",Z)===-1}function EJ($,Z,Y){let X=Y,J=Z+1;while(J<$.length&&!CJ(X)){let Q=$[J];X+=`
4188
4188
  ${Q}`,J++}while(J<$.length){let Q=$[J].trim();if(Q.startsWith(".")||Q.startsWith("?."))X+=`
4189
4189
  ${$[J]}`,J++;else break}return{value:X,nextIndex:J}}function xW($,Z,Y){let X=Y,J=Z+1;while(J<$.length){let Q=X.indexOf("{");if(Q!==-1){if(O0(X,"{","}",Q)!==-1)break}let G=$[J];X+=`
4190
- ${G}`,J++}return{functionCode:X,nextIndex:J}}function kJ($,Z){let Y=e($,Z)??e(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{...t5.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 fW($,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 q=K.trim().replace(/;$/,""),z=kJ(q,Z);if(z!==void 0)Z[G]=z}catch(q){console.warn(`Failed to parse export ${G} in fallback:`,q)}}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 q=K.trim().replace(/;$/,""),z=kJ(q,Z);if(z!==void 0)Z[G]=z}catch{}}}function PJ($){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 vJ($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var e5=y(()=>{c5();t1();F0()});var mJ={};c(mJ,{processLoops:()=>C8});function dW($,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,q=1,z=K+1;while(z<X.length&&q>0){if(X[z]==="(")q++;else if(X[z]===")"){if(q--,q===0)break}z++}if(q!==0)continue;let U=X.substring(K+1,z),W=z+1,_=U.match(/^\s*['"]([^'"]+)['"]/);if(!_)continue;let B=_[1],j=U.slice(_[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let L=j.slice(H[0].length).trim();if(!L)continue;try{let F=j0(L,Z),O=JSON.stringify(F),V=`@component('${B}', ${O})`;Q.push({start:G,end:W,replacement:V})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:q,replacement:z}=Q[G];X=X.substring(0,K)+z+X.substring(q)}return X}function D4($,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,q=1,z=K+1,U=null,W=!1;while(z<X.length&&q>0){let j=X[z];if(W){W=!1,z++;continue}if(j==="\\"&&U){W=!0,z++;continue}if(U){if(j===U)U=null;z++;continue}if(j==='"'||j==="'"||j==="`"){U=j,z++;continue}if(j==="(")q++;else if(j===")"){if(q--,q===0)break}z++}if(q!==0)break;let _=X.substring(K+1,z),B=Y(_);X=X.substring(0,G)+B+X.substring(z+1)}return X}function uW($,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);D5(Q);let z=Z0(Q,G)(...K),U=JSON.stringify(z),W=Buffer.from(U,"utf8").toString("base64");return`__stx_${J}="${W}"`}catch(G){return X}}),Y}function mW($,Z){let Y=$;return Y=D4(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if($0(Q)){let K=Z0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(e(Q,Z));return G?E4:""}catch{return""}}),Y=D4(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if($0(Q)){let K=Z0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(e(Q,Z));return G?k4:""}catch{return""}}),Y}function pW($){let Z=$;return Z=Z.replace(/@break(?!\()/g,E4),Z=Z.replace(/@continue(?!\()/g,k4),Z}function xJ($){let Z=$.includes(E4),Y=Z?$.substring(0,$.indexOf(E4)):$;return{hasBreak:Z,content:Y}}function fJ($){let Z=$.includes(k4),Y=Z?$.substring(0,$.indexOf(k4)):$;return{hasContinue:Z,content:Y}}function hJ($){let Z=$;return Z=D4(Z,"@break",(Y)=>{let X=Y.trim();if(!E5(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=D4(Z,"@continue",(Y)=>{let X=Y.trim();if(!E5(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function cW($){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((U,W)=>U.pos-W.pos);let K=[],q=0;for(let U of X)q+=U.delta,K.push({pos:U.pos,depth:q});function z(U){let W=0,_=K.length-1,B=0;while(W<=_){let j=W+_>>1;if(K[j].pos<=U)B=K[j].depth,W=j+1;else _=j-1}return B}while((Y=Z.exec($))!==null){if(z(Y.index)>0)continue;let U=Y.index,W=Y.index+Y[0].length-1,_=1,B=W+1,j=-1;while(B<$.length&&_>0){if($[B]==="(")_++;else if($[B]===")"){if(_--,_===0){j=B;break}}B++}if(j===-1)continue;let H=$.substring(W+1,j),L=H.indexOf(" as ");if(L===-1)continue;let F=H.substring(0,L).trim(),O=H.substring(L+4).trim(),V=j+1,w=1,R=V,A=/@forelse\s*\(/g,N=/@endforelse/g,M=-1;while(w>0&&R<$.length){A.lastIndex=R,N.lastIndex=R;let S=A.exec($),b=N.exec($);if(!b)break;if(S&&S.index<b.index)w++,R=S.index+S[0].length;else{if(w--,w===0){M=b.index;break}R=b.index+11}}if(M===-1)continue;let T=$.substring(V,M),I=M+11,D=-1,E=0,k=0;while(k<T.length){let S=T.indexOf("@",k);if(S===-1)break;let b=T.substring(S);if(/^@forelse\s*\(/.test(b))E++,k=S+1;else if(b.startsWith("@endforelse"))E--,k=S+11;else if(E===0&&b.startsWith("@empty")){if(T.length<=S+6||!/[a-z]/i.test(T[S+6])){D=S;break}k=S+1}else k=S+1}if(D===-1)continue;return{start:U,end:I,arrayExpr:F,itemVar:O,foreachContent:T.substring(0,D),emptyContent:T.substring(D+6)}}return null}function gJ($,Z){let Y=$;while(!0){let X=cW(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:q,emptyContent:z}=X;try{let U;if($0(G))U=Z0(G,Object.keys(Z))(...Object.values(Z));else U=e(G,Z);let W;if(!Array.isArray(U)||U.length===0)W=z;else W=`@foreach (${G} as ${K})${q}@endforeach`;Y=Y.substring(0,J)+W+Y.substring(Q)}catch(U){let W=U instanceof Error?U.message:String(U),_=r("Forelse",`Error in @forelse(${G} as ${K}): ${W}`,l.EVALUATION_ERROR);Y=Y.substring(0,J)+_+Y.substring(Q)}}return Y}function C8($,Z,Y,X){let J=$;J=gJ(J,Z);function Q(q){let z=/@foreach\s*\(/g,U;while((U=z.exec(q))!==null){let W=U.index,_=U.index+U[0].length-1,B=1,j=_+1,H=-1;while(j<q.length&&B>0){if(q[j]==="(")B++;else if(q[j]===")"){if(B--,B===0){H=j;break}}j++}if(H===-1)continue;let L=q.substring(_+1,H),F=L.indexOf(" as ");if(F===-1)continue;let O=W,V=L.substring(0,F),w=L.substring(F+4),R=H+1,A=1,N=R,M=/@foreach\s*\(/g,T=/@endforeach/g;while(A>0&&N<q.length){M.lastIndex=N,T.lastIndex=N;let I=M.exec(q),D=T.exec(q);if(!D)break;if(I&&I.index<D.index)A++,N=I.index+I[0].length;else{if(A--,A===0){let E=q.substring(R,D.index),k=D.index+11;return{start:O,end:k,arrayExpr:V,itemVar:w,content:E}}N=D.index+11}}}return null}function G(q,z){let U=q;while(!0){let W=Q(U);if(!W)break;let{start:_,end:B,arrayExpr:j,itemVar:H,content:L}=W;try{let F=j.trim(),O;if($0(F))O=Z0(F,Object.keys(z))(...Object.values(z));else O=e(F,z);let V=!1;if(!Array.isArray(O))if(O instanceof Map)O=Array.from(O),V=!0;else if(O instanceof Set)O=Array.from(O);else if(typeof O==="string")O=Array.from(O);else if(O&&typeof O==="object"&&!(O instanceof Date)&&!(O instanceof RegExp))O=Object.entries(O),V=!0;else{let D=r("Foreach",`Error in @foreach: ${F} is not iterable`,l.TYPE_ERROR);U=U.substring(0,_)+D+U.substring(B);continue}let w=X?.loops?.useAltLoopVariable??hW,R=H.trim(),A=null,N,M=!1;if(R.includes("=>")){let D=R.split("=>").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])A=D[0],N=D[1];else N=R}else if(!R.startsWith("[")&&!R.startsWith("{")&&R.includes(",")){let D=R.split(",").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])N=D[0],A=D[1],M=!0;else N=R}else N=R;let T="",I=O;for(let D=0;D<I.length;D++){let E=I[D],k={index:D,iteration:D+1,first:D===0,last:D===I.length-1,count:I.length},S={...z,loop:k,$loop:k};if(N.startsWith("[")&&N.endsWith("]")){let f=N.slice(1,-1).split(",").map((m)=>m.trim());if(Array.isArray(E))f.forEach((m,o)=>{if(m)S[m]=E[o]});else S[N]=E}else S[N]=E;if(A)if(!M&&V&&Array.isArray(E)&&E.length===2)S[A]=E[0],S[N]=E[1];else S[A]=D;let b=mW(L,S),C=fJ(b);if(C.hasContinue){T+=C.content;continue}let d=xJ(b);if(d.hasBreak){T+=d.content;break}if(b=gJ(b,S),b=G(b,S),b=f1(b,S,Y),b=pW(b),d=xJ(b),d.hasBreak){T+=d.content;break}if(C=fJ(b),C.hasContinue){T+=C.content;continue}b=r0(b,S,Y),b=uW(b,S),b=dW(b,S),T+=b}U=U.substring(0,_)+T+U.substring(B)}catch(F){let O=r("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,l.EVALUATION_ERROR);U=U.substring(0,_)+O+U.substring(B)}}return U}J=G(J,Z),J=uJ(J,Z,Y,X);let K=X?.loops?.maxWhileIterations??gW;return J=nW(J,Z,K),J}function dJ($){return E5($)}function uJ($,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,q=K+G[0].length-1,z=O0(J,"(",")",q);if(z===-1)break;let U=J.slice(q+1,z),W=z+1,_=W4(J.slice(K),"for","endfor");if(_.length===0)break;let B=_[0].content,j=K+_[0].end;if(!dJ(U)){let H=r("For",`Unsafe expression in @for: ${U}`,l.UNSAFE_EXPRESSION);J=J.substring(0,K)+H+J.substring(j),Q=!0;continue}try{let H=lW(U),L=/@(?:for|foreach|if|unless)\s*\(/.test(B);if(H.length>0&&L){let A=iW({forExpr:U,content:B,iterVarNames:H,context:Z,filePath:Y,options:X});J=J.substring(0,K)+A+J.substring(j),Q=!0;continue}let F=Object.keys(Z),O=Object.values(Z),V=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(A,N)=>{return`\${${N}}`});V=hJ(V);let R=Function(...F,`
4190
+ ${G}`,J++}return{functionCode:X,nextIndex:J}}function kJ($,Z){let Y=e($,Z)??e(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{...t5.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 fW($,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 q=K.trim().replace(/;$/,""),z=kJ(q,Z);if(z!==void 0)Z[G]=z}catch(q){console.warn(`Failed to parse export ${G} in fallback:`,q)}}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 q=K.trim().replace(/;$/,""),z=kJ(q,Z);if(z!==void 0)Z[G]=z}catch{}}}function PJ($){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 vJ($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var e5=y(()=>{c5();t1();F0()});var mJ={};c(mJ,{processLoops:()=>C8});function dW($,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,q=1,z=K+1;while(z<X.length&&q>0){if(X[z]==="(")q++;else if(X[z]===")"){if(q--,q===0)break}z++}if(q!==0)continue;let U=X.substring(K+1,z),W=z+1,_=U.match(/^\s*['"]([^'"]+)['"]/);if(!_)continue;let B=_[1],j=U.slice(_[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let L=j.slice(H[0].length).trim();if(!L)continue;try{let F=j0(L,Z),O=JSON.stringify(F),V=`@component('${B}', ${O})`;Q.push({start:G,end:W,replacement:V})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:q,replacement:z}=Q[G];X=X.substring(0,K)+z+X.substring(q)}return X}function D4($,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,q=1,z=K+1,U=null,W=!1;while(z<X.length&&q>0){let j=X[z];if(W){W=!1,z++;continue}if(j==="\\"&&U){W=!0,z++;continue}if(U){if(j===U)U=null;z++;continue}if(j==='"'||j==="'"||j==="`"){U=j,z++;continue}if(j==="(")q++;else if(j===")"){if(q--,q===0)break}z++}if(q!==0)break;let _=X.substring(K+1,z),B=Y(_);X=X.substring(0,G)+B+X.substring(z+1)}return X}function uW($,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);D5(Q);let z=Z0(Q,G)(...K),U=JSON.stringify(z),W=Buffer.from(U,"utf8").toString("base64");return`__stx_${J}="${W}"`}catch(G){return X}}),Y}function mW($,Z){let Y=$;return Y=D4(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if($0(Q)){let K=Z0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(e(Q,Z));return G?E4:""}catch{return""}}),Y=D4(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if($0(Q)){let K=Z0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(e(Q,Z));return G?k4:""}catch{return""}}),Y}function pW($){let Z=$;return Z=Z.replace(/@break(?!\()/g,E4),Z=Z.replace(/@continue(?!\()/g,k4),Z}function xJ($){let Z=$.includes(E4),Y=Z?$.substring(0,$.indexOf(E4)):$;return{hasBreak:Z,content:Y}}function fJ($){let Z=$.includes(k4),Y=Z?$.substring(0,$.indexOf(k4)):$;return{hasContinue:Z,content:Y}}function hJ($){let Z=$;return Z=D4(Z,"@break",(Y)=>{let X=Y.trim();if(!E5(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=D4(Z,"@continue",(Y)=>{let X=Y.trim();if(!E5(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function cW($){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((U,W)=>U.pos-W.pos);let K=[],q=0;for(let U of X)q+=U.delta,K.push({pos:U.pos,depth:q});function z(U){let W=0,_=K.length-1,B=0;while(W<=_){let j=W+_>>1;if(K[j].pos<=U)B=K[j].depth,W=j+1;else _=j-1}return B}while((Y=Z.exec($))!==null){if(z(Y.index)>0)continue;let U=Y.index,W=Y.index+Y[0].length-1,_=1,B=W+1,j=-1;while(B<$.length&&_>0){if($[B]==="(")_++;else if($[B]===")"){if(_--,_===0){j=B;break}}B++}if(j===-1)continue;let H=$.substring(W+1,j),L=H.indexOf(" as ");if(L===-1)continue;let F=H.substring(0,L).trim(),O=H.substring(L+4).trim(),V=j+1,w=1,R=V,A=/@forelse\s*\(/g,N=/@endforelse/g,M=-1;while(w>0&&R<$.length){A.lastIndex=R,N.lastIndex=R;let S=A.exec($),b=N.exec($);if(!b)break;if(S&&S.index<b.index)w++,R=S.index+S[0].length;else{if(w--,w===0){M=b.index;break}R=b.index+11}}if(M===-1)continue;let T=$.substring(V,M),I=M+11,D=-1,E=0,k=0;while(k<T.length){let S=T.indexOf("@",k);if(S===-1)break;let b=T.substring(S);if(/^@forelse\s*\(/.test(b))E++,k=S+1;else if(b.startsWith("@endforelse"))E--,k=S+11;else if(E===0&&b.startsWith("@empty")){if(T.length<=S+6||!/[a-z]/i.test(T[S+6])){D=S;break}k=S+1}else k=S+1}if(D===-1)continue;return{start:U,end:I,arrayExpr:F,itemVar:O,foreachContent:T.substring(0,D),emptyContent:T.substring(D+6)}}return null}function gJ($,Z){let Y=$;while(!0){let X=cW(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:q,emptyContent:z}=X;try{let U;if($0(G))U=Z0(G,Object.keys(Z))(...Object.values(Z));else U=e(G,Z);let W;if(!Array.isArray(U)||U.length===0)W=z;else W=`@foreach (${G} as ${K})${q}@endforeach`;Y=Y.substring(0,J)+W+Y.substring(Q)}catch(U){let W=U instanceof Error?U.message:String(U),_=r("Forelse",`Error in @forelse(${G} as ${K}): ${W}`,l.EVALUATION_ERROR);Y=Y.substring(0,J)+_+Y.substring(Q)}}return Y}function C8($,Z,Y,X){let J=$;J=gJ(J,Z);function Q(q){let z=/@foreach\s*\(/g,U;while((U=z.exec(q))!==null){let W=U.index,_=U.index+U[0].length-1,B=1,j=_+1,H=-1;while(j<q.length&&B>0){if(q[j]==="(")B++;else if(q[j]===")"){if(B--,B===0){H=j;break}}j++}if(H===-1)continue;let L=q.substring(_+1,H),F=L.indexOf(" as ");if(F===-1)continue;let O=W,V=L.substring(0,F),w=L.substring(F+4),R=H+1,A=1,N=R,M=/@foreach\s*\(/g,T=/@endforeach/g;while(A>0&&N<q.length){M.lastIndex=N,T.lastIndex=N;let I=M.exec(q),D=T.exec(q);if(!D)break;if(I&&I.index<D.index)A++,N=I.index+I[0].length;else{if(A--,A===0){let E=q.substring(R,D.index),k=D.index+11;return{start:O,end:k,arrayExpr:V,itemVar:w,content:E}}N=D.index+11}}}return null}function G(q,z){let U=q;while(!0){let W=Q(U);if(!W)break;let{start:_,end:B,arrayExpr:j,itemVar:H,content:L}=W;try{let F=j.trim(),O;if($0(F))O=Z0(F,Object.keys(z))(...Object.values(z));else O=e(F,z);let V=!1;if(!Array.isArray(O))if(O instanceof Map)O=Array.from(O),V=!0;else if(O instanceof Set)O=Array.from(O);else if(typeof O==="string")O=Array.from(O);else if(O&&typeof O==="object"&&!(O instanceof Date)&&!(O instanceof RegExp))O=Object.entries(O),V=!0;else{let D=r("Foreach",`Error in @foreach: ${F} is not iterable`,l.TYPE_ERROR);U=U.substring(0,_)+D+U.substring(B);continue}let w=X?.loops?.useAltLoopVariable??hW,R=H.trim(),A=null,N,M=!1;if(R.includes("=>")){let D=R.split("=>").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])A=D[0],N=D[1];else N=R}else if(!R.startsWith("[")&&!R.startsWith("{")&&R.includes(",")){let D=R.split(",").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])N=D[0],A=D[1],M=!0;else N=R}else N=R;let T="",I=O;for(let D=0;D<I.length;D++){let E=I[D],k={index:D,iteration:D+1,first:D===0,last:D===I.length-1,count:I.length},S={...z,loop:k,$loop:k};if(N.startsWith("[")&&N.endsWith("]")){let f=N.slice(1,-1).split(",").map((m)=>m.trim());if(Array.isArray(E))f.forEach((m,o)=>{if(m)S[m]=E[o]});else S[N]=E}else S[N]=E;if(A)if(!M&&V&&Array.isArray(E)&&E.length===2)S[A]=E[0],S[N]=E[1];else S[A]=D;let b=mW(L,S),P=fJ(b);if(P.hasContinue){T+=P.content;continue}let d=xJ(b);if(d.hasBreak){T+=d.content;break}if(b=gJ(b,S),b=G(b,S),b=f1(b,S,Y),b=pW(b),d=xJ(b),d.hasBreak){T+=d.content;break}if(P=fJ(b),P.hasContinue){T+=P.content;continue}b=r0(b,S,Y),b=uW(b,S),b=dW(b,S),T+=b}U=U.substring(0,_)+T+U.substring(B)}catch(F){let O=r("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,l.EVALUATION_ERROR);U=U.substring(0,_)+O+U.substring(B)}}return U}J=G(J,Z),J=uJ(J,Z,Y,X);let K=X?.loops?.maxWhileIterations??gW;return J=nW(J,Z,K),J}function dJ($){return E5($)}function uJ($,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,q=K+G[0].length-1,z=O0(J,"(",")",q);if(z===-1)break;let U=J.slice(q+1,z),W=z+1,_=W4(J.slice(K),"for","endfor");if(_.length===0)break;let B=_[0].content,j=K+_[0].end;if(!dJ(U)){let H=r("For",`Unsafe expression in @for: ${U}`,l.UNSAFE_EXPRESSION);J=J.substring(0,K)+H+J.substring(j),Q=!0;continue}try{let H=lW(U),L=/@(?:for|foreach|if|unless)\s*\(/.test(B);if(H.length>0&&L){let A=iW({forExpr:U,content:B,iterVarNames:H,context:Z,filePath:Y,options:X});J=J.substring(0,K)+A+J.substring(j),Q=!0;continue}let F=Object.keys(Z),O=Object.values(Z),V=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(A,N)=>{return`\${${N}}`});V=hJ(V);let R=Function(...F,`
4191
4191
  let result = '';
4192
4192
  for (${U}) {
4193
4193
  result += \`${V}\`;
@@ -4244,14 +4244,14 @@ ${rW($).split(",").map((q)=>q.trim()).filter(Boolean).map((q)=>` try { __scopeR
4244
4244
  } finally {
4245
4245
  if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
4246
4246
  }
4247
- })();`}function tW($,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 wN(){iJ.clear()}function eW($){if($.__onceStore instanceof Set)return $.__onceStore;return iJ}async function x8($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||q0.join(q0.dirname(Y),"partials");if(G&&!q0.isAbsolute(G))G=q0.resolve(process.cwd(),G);let K=oW($,"@partial","@include"),q=eW(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,L)=>{let F=H.trim(),O=`${Y}:${F}`;if(q.has(O))return"";return q.add(O),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let w=K.substring(F+1,V-1),R=w.match(/^\s*['"]([^'"]+)['"]/);if(!R){j.lastIndex=V;continue}let A=R[1],N=z(A,G,Y),M="";if(N&&await Bun.file(N).exists())J.add(N),M=`@include(${w})`;K=K.substring(0,L)+M+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=L.exec(K))!==null){let O=F.index,V=O+F[0].length-1,w=1,R=V+1;while(R<K.length&&w>0){if(K[R]==="(")w++;else if(K[R]===")")w--;R++}if(w!==0)break;let A=K.substring(V+1,R-1),N=v8(A,0);if(N===-1){L.lastIndex=R;continue}let M=A.substring(0,N).trim(),T=A.substring(N+1).trim(),I=T.match(/^\s*['"]([^'"]+)['"]/);if(!I){L.lastIndex=R;continue}let D=I[1],E=T.substring(I[0].length),k,S=v8(E,0);if(S!==-1)k=E.substring(S+1).trim();try{let b=`Boolean(${M})`,C;if($0(b)){let m=Z0(b,Object.keys(Z));C=Boolean(m(...Object.values(Z)))}else C=Boolean(e(b,Z));let d=H?!C:C,f="";if(d){let m=z(D,G,Y);if(m&&await Bun.file(m).exists())J.add(m);f=`@include('${D}'${k?`, ${k}`:""})`}K=K.substring(0,O)+f+K.substring(R),L.lastIndex=0}catch(b){let C=b instanceof Error?b.message:String(b),d=J0("Include",`Error evaluating ${j} condition: ${C}`,Y,$,O);K=K.substring(0,O)+d+K.substring(R),L.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),R=K.substring(L,V+1),A=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!A){j.lastIndex=0,K=K.replace(R,"");continue}let[,N,M,T,I]=A;try{let D,E=M.trim();if($0(E))D=Z0(E,Object.keys(Z))(...Object.values(Z));else D=e(E,Z);let k="";if(Array.isArray(D)&&D.length>0)for(let S of D){let b={...Z,[T]:S},C=await W(N,b,$,L);k+=C}else if(I)k=await W(I,{},$,L);K=K.substring(0,L)+k+K.substring(V+1),j.lastIndex=0}catch(D){let E=D instanceof Error?D.message:String(D);K=K.substring(0,L)+J0("Each",`Error in @each: ${E}`,Y,$,L)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),R=K.substring(L,V+1),A=w.match(/^\s*(\[[^\]]+\])/);if(!A){j.lastIndex=0,K=K.replace(R,"");continue}let N=A[1],M=w.slice(A[0].length),T,I=M.match(/^\s*,\s*\{/);if(I){M=M.slice(I[0].length-1);let k=1,S=1;while(S<M.length&&k>0){if(M[S]==="{")k++;else if(M[S]==="}"){if(k--,k===0)break}S++}T=M.substring(0,S+1),M=M.slice(S+1)}let D,E=M.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(E)D=E[1];try{let k=JSON.parse(N.replace(/'/g,'"')),S={};if(T)try{S=j0(T,Z)}catch(C){let d=C instanceof Error?C.message:String(C);if(X.debug){let f=J0("Include",`Error parsing includeFirst variables: ${d}`,Y,$,L,R);K=K.replace(R,()=>f)}else K=K.replace(R,()=>D||"");continue}let b=!1;for(let C of k){let d=z(C,G,Y);if(!d)continue;if(await n(d)){let f=await W(C,S,$,L);K=K.replace(R,()=>f),b=!0;break}}if(!b)if(D!==void 0)K=K.replace(R,()=>D);else if(X.debug){let C=J0("Include",`None of the includeFirst paths exist: ${N}`,Y,$,L,R);K=K.replace(R,()=>C)}else K=K.replace(R,"")}catch(k){let S=k instanceof Error?k.message:String(k),b=J0("Include",`Error processing @includeFirst: ${S}`,Y,$,L,R);K=K.replace(R,()=>b)}j.lastIndex=0}}function z(j,H,L){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let O=q0.resolve(H),V=q0.resolve(q0.dirname(L)),w;if(!F.startsWith("./")&&!F.startsWith("../"))w=q0.resolve(H,F);else w=q0.resolve(V,F);let R=q0.normalize(w),A=R.startsWith(O+q0.sep)||R===O,N=R.startsWith(V+q0.sep)||R===V,M=!1,T=q0.dirname(V);if(R.startsWith(T+q0.sep)){if(!q0.relative(T,R).split(q0.sep).some((k)=>k.startsWith(".")&&k!=="."&&k!==".."))M=!0}if(!A&&!N&&!M)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${R}`),console.error(` Allowed dirs: ${O}, ${V}`),null;return R}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let U=q0.resolve(Y);Q.add(U);async function W(j,H={},L,F){let O=z(j,G,Y);if(!O)return J0("Include",`Could not resolve path for include: ${j}`,Y,L,F);let V=q0.resolve(O);if(Q.has(V)){let w=[...Q,V].map((R)=>q0.basename(R)).join(" -> ");return J0("Include",`Circular include detected: ${w}`,Y,L,F)}try{J.add(O);let w;if(!w)try{w=await Bun.file(O).text()}catch(f){let m=f instanceof Error?f.message:String(f);return J0("Include",`Error loading include file ${j}: ${m}`,Y,L,F)}if(w&&w.includes("@stream")){let{processStreamDirectives:f}=await Promise.resolve().then(() => (t3(),a3));w=f(w,Z)}if(w&&(X.debug||!f5()&&!o$()))try{let{warnUnbalancedTags:f}=await Promise.resolve().then(() => (Z8(),XJ));f(w,O)}catch{}let R=w;try{let{processESImports:f}=await Promise.resolve().then(() => (S8(),TJ));await f(w,Z,O,X,J)}catch(f){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${O}:`,f instanceof Error?f.message:f)}let A=R.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(A)R=A[1].trim();let M=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),T="";if(M)T=`<style${M[1]}>${M[2]}</style>`;R=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),R=R.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[f,m]of Object.entries(H))I[f]=m;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...w.matchAll(D)],k="",S=null;for(let f of E){let m=f[1]||"",o=f[2]||"",N0=m.includes("server"),Z1=c1(m),C0="";try{let{extractAndStripCssImports:X0,renderVendorStyleTags:L0}=await Promise.resolve().then(() => ($$(),cJ)),U0=X0(o,{filePath:O,projectRoot:process.cwd()});o=U0.code,C0=L0(U0.styles)}catch(X0){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${O}:`,X0 instanceof Error?X0.message:X0)}if(Z1&&o.trim())o=l1(o);if(!N0)try{let{hasUserImports:X0,bundleClientScript:L0}=await Promise.resolve().then(() => (L$(),O$));if(X0(o))o=await L0(o,O,{projectRoot:process.cwd()})}catch(X0){if(X.debug)console.warn(`[stx] bundler skipped for ${O}:`,X0 instanceof Error?X0.message:X0)}let E0=sW(o);if(E0&&!N0){S=`stx_scope_${q0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++pJ}`;let X0=J1(o),L0=aW(X0,S);k+=`${C0}<script data-stx-scoped>${L0}</script>
4248
- `;continue}if(N0)try{let{extractVariables:X0}=await Promise.resolve().then(() => (e5(),I4));await X0(o,I,O)}catch(X0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${O}:`,X0)}if(!N0&&!E0){let X0=m.replace(/\bclient\b/i,"").trim();S=`stx_scope_${q0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++pJ}`;let L0=J1(o),U0=`
4247
+ })();`}function tW($,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 wN(){iJ.clear()}function eW($){if($.__onceStore instanceof Set)return $.__onceStore;return iJ}async function x8($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||q0.join(q0.dirname(Y),"partials");if(G&&!q0.isAbsolute(G))G=q0.resolve(process.cwd(),G);let K=oW($,"@partial","@include"),q=eW(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,L)=>{let F=H.trim(),O=`${Y}:${F}`;if(q.has(O))return"";return q.add(O),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let w=K.substring(F+1,V-1),R=w.match(/^\s*['"]([^'"]+)['"]/);if(!R){j.lastIndex=V;continue}let A=R[1],N=z(A,G,Y),M="";if(N&&await Bun.file(N).exists())J.add(N),M=`@include(${w})`;K=K.substring(0,L)+M+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=L.exec(K))!==null){let O=F.index,V=O+F[0].length-1,w=1,R=V+1;while(R<K.length&&w>0){if(K[R]==="(")w++;else if(K[R]===")")w--;R++}if(w!==0)break;let A=K.substring(V+1,R-1),N=v8(A,0);if(N===-1){L.lastIndex=R;continue}let M=A.substring(0,N).trim(),T=A.substring(N+1).trim(),I=T.match(/^\s*['"]([^'"]+)['"]/);if(!I){L.lastIndex=R;continue}let D=I[1],E=T.substring(I[0].length),k,S=v8(E,0);if(S!==-1)k=E.substring(S+1).trim();try{let b=`Boolean(${M})`,P;if($0(b)){let m=Z0(b,Object.keys(Z));P=Boolean(m(...Object.values(Z)))}else P=Boolean(e(b,Z));let d=H?!P:P,f="";if(d){let m=z(D,G,Y);if(m&&await Bun.file(m).exists())J.add(m);f=`@include('${D}'${k?`, ${k}`:""})`}K=K.substring(0,O)+f+K.substring(R),L.lastIndex=0}catch(b){let P=b instanceof Error?b.message:String(b),d=J0("Include",`Error evaluating ${j} condition: ${P}`,Y,$,O);K=K.substring(0,O)+d+K.substring(R),L.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),R=K.substring(L,V+1),A=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!A){j.lastIndex=0,K=K.replace(R,"");continue}let[,N,M,T,I]=A;try{let D,E=M.trim();if($0(E))D=Z0(E,Object.keys(Z))(...Object.values(Z));else D=e(E,Z);let k="";if(Array.isArray(D)&&D.length>0)for(let S of D){let b={...Z,[T]:S},P=await W(N,b,$,L);k+=P}else if(I)k=await W(I,{},$,L);K=K.substring(0,L)+k+K.substring(V+1),j.lastIndex=0}catch(D){let E=D instanceof Error?D.message:String(D);K=K.substring(0,L)+J0("Each",`Error in @each: ${E}`,Y,$,L)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),R=K.substring(L,V+1),A=w.match(/^\s*(\[[^\]]+\])/);if(!A){j.lastIndex=0,K=K.replace(R,"");continue}let N=A[1],M=w.slice(A[0].length),T,I=M.match(/^\s*,\s*\{/);if(I){M=M.slice(I[0].length-1);let k=1,S=1;while(S<M.length&&k>0){if(M[S]==="{")k++;else if(M[S]==="}"){if(k--,k===0)break}S++}T=M.substring(0,S+1),M=M.slice(S+1)}let D,E=M.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(E)D=E[1];try{let k=JSON.parse(N.replace(/'/g,'"')),S={};if(T)try{S=j0(T,Z)}catch(P){let d=P instanceof Error?P.message:String(P);if(X.debug){let f=J0("Include",`Error parsing includeFirst variables: ${d}`,Y,$,L,R);K=K.replace(R,()=>f)}else K=K.replace(R,()=>D||"");continue}let b=!1;for(let P of k){let d=z(P,G,Y);if(!d)continue;if(await n(d)){let f=await W(P,S,$,L);K=K.replace(R,()=>f),b=!0;break}}if(!b)if(D!==void 0)K=K.replace(R,()=>D);else if(X.debug){let P=J0("Include",`None of the includeFirst paths exist: ${N}`,Y,$,L,R);K=K.replace(R,()=>P)}else K=K.replace(R,"")}catch(k){let S=k instanceof Error?k.message:String(k),b=J0("Include",`Error processing @includeFirst: ${S}`,Y,$,L,R);K=K.replace(R,()=>b)}j.lastIndex=0}}function z(j,H,L){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let O=q0.resolve(H),V=q0.resolve(q0.dirname(L)),w;if(!F.startsWith("./")&&!F.startsWith("../"))w=q0.resolve(H,F);else w=q0.resolve(V,F);let R=q0.normalize(w),A=R.startsWith(O+q0.sep)||R===O,N=R.startsWith(V+q0.sep)||R===V,M=!1,T=q0.dirname(V);if(R.startsWith(T+q0.sep)){if(!q0.relative(T,R).split(q0.sep).some((k)=>k.startsWith(".")&&k!=="."&&k!==".."))M=!0}if(!A&&!N&&!M)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${R}`),console.error(` Allowed dirs: ${O}, ${V}`),null;return R}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let U=q0.resolve(Y);Q.add(U);async function W(j,H={},L,F){let O=z(j,G,Y);if(!O)return J0("Include",`Could not resolve path for include: ${j}`,Y,L,F);let V=q0.resolve(O);if(Q.has(V)){let w=[...Q,V].map((R)=>q0.basename(R)).join(" -> ");return J0("Include",`Circular include detected: ${w}`,Y,L,F)}try{J.add(O);let w;if(!w)try{w=await Bun.file(O).text()}catch(f){let m=f instanceof Error?f.message:String(f);return J0("Include",`Error loading include file ${j}: ${m}`,Y,L,F)}if(w&&w.includes("@stream")){let{processStreamDirectives:f}=await Promise.resolve().then(() => (t3(),a3));w=f(w,Z)}if(w&&(X.debug||!f5()&&!o$()))try{let{warnUnbalancedTags:f}=await Promise.resolve().then(() => (Z8(),XJ));f(w,O)}catch{}let R=w;try{let{processESImports:f}=await Promise.resolve().then(() => (S8(),TJ));await f(w,Z,O,X,J)}catch(f){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${O}:`,f instanceof Error?f.message:f)}let A=R.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(A)R=A[1].trim();let M=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),T="";if(M)T=`<style${M[1]}>${M[2]}</style>`;R=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),R=R.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[f,m]of Object.entries(H))I[f]=m;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...w.matchAll(D)],k="",S=null;for(let f of E){let m=f[1]||"",o=f[2]||"",N0=m.includes("server"),Z1=c1(m),C0="";try{let{extractAndStripCssImports:X0,renderVendorStyleTags:L0}=await Promise.resolve().then(() => ($$(),cJ)),U0=X0(o,{filePath:O,projectRoot:process.cwd()});o=U0.code,C0=L0(U0.styles)}catch(X0){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${O}:`,X0 instanceof Error?X0.message:X0)}if(Z1&&o.trim())o=l1(o);if(!N0)try{let{hasUserImports:X0,bundleClientScript:L0}=await Promise.resolve().then(() => (L$(),O$));if(X0(o))o=await L0(o,O,{projectRoot:process.cwd()})}catch(X0){if(X.debug)console.warn(`[stx] bundler skipped for ${O}:`,X0 instanceof Error?X0.message:X0)}let k0=sW(o);if(k0&&!N0){S=`stx_scope_${q0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++pJ}`;let X0=J1(o),L0=aW(X0,S);k+=`${C0}<script data-stx-scoped>${L0}</script>
4248
+ `;continue}if(N0)try{let{extractVariables:X0}=await Promise.resolve().then(() => (e5(),I4));await X0(o,I,O)}catch(X0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${O}:`,X0)}if(!N0&&!k0){let X0=m.replace(/\bclient\b/i,"").trim();S=`stx_scope_${q0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++pJ}`;let L0=J1(o),U0=`
4249
4249
  if (!window.stx._scopes) window.stx._scopes = {};
4250
4250
  window.stx._scopes['${S}'] = { __destroyCallbacks: __destroyHooks };
4251
- `,P=lJ(L0,U0);k+=`${C0}<script data-stx-scoped${X0?` ${X0}`:""}>${P}</script>
4252
- `}}if(S){let f=tW(R,S);if(R=f.html,f.mergedIntoExisting)k=k.replace(`window.stx._scopes['${S}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),S=f.mergedIntoExisting}if(R.includes("@include")||R.includes("@partial"))R=await x8(R,I,O,X,J,Q);let{processLoops:b}=await Promise.resolve().then(() => (P8(),mJ)),C=b(R,I,O);C=f1(C,I,O);let d=$5(w);if(C=r0(C,I,O,{forceSignals:d}),T)C+=`
4253
- `+T;if(k)C+=`
4254
- `+k;return C}catch(w){let R=w instanceof Error?w.message:String(w);return J0("Include",`Error processing include ${j}: ${R}`,Y,L,F)}}let _=/@include\s*\(/g,B;while((B=_.exec(K))!==null){let j=B.index,H=j+B[0].length-1,L=1,F=H+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let O=K.substring(j,F),V=K.substring(H+1,F-1),w=V.match(/^\s*['"]([^'"]+)['"]/);if(!w){_.lastIndex=F;continue}let R=w[1],A,N=V.substring(w[0].length),M=v8(N,0);if(M!==-1)A=N.substring(M+1).trim();let T={};if(A)try{T=j0(A,Z)}catch(D){let E=D instanceof Error?D.message:String(D);K=K.replace(O,J0("Include",`Error parsing include variables for ${R}: ${E}`,Y,$,j)),_.lastIndex=0;continue}let I=await W(R,T,$,j);K=K.substring(0,j)+I+K.substring(F),_.lastIndex=0}return K}function f8($,Z){let Y=$;function X(J,Q,G,K){let q=J,z=!0;while(z){z=!1;let U=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),W=q.match(U);if(!W||W.index===void 0)break;let _=W.index,B=W[1],j=_+W[0].length,H=new RegExp(`@${Q}\\(`),L=new RegExp(`@${G}(?![a-z])`),F=1,O=j,V=-1;while(F>0&&O<q.length){let R=q.slice(O),A=R.match(H),N=R.match(L),M=A?O+A.index:1/0,T=N?O+N.index:1/0;if(M<T)F++,O=M+(A[0].length||1);else if(T<1/0){if(F--,F===0){V=T;break}O=T+G.length+1}else break}if(V===-1)break;let w=q.slice(j,V);if(!Z[B])Z[B]=[];if(K)Z[B].unshift(w);else Z[B].push(w);q=q.substring(0,_)+q.substring(V+`@${G}`.length),z=!0}return q}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function g8($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
4251
+ `,C=lJ(L0,U0);k+=`${C0}<script data-stx-scoped${X0?` ${X0}`:""}>${C}</script>
4252
+ `}}if(S){let f=tW(R,S);if(R=f.html,f.mergedIntoExisting)k=k.replace(`window.stx._scopes['${S}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),S=f.mergedIntoExisting}if(R.includes("@include")||R.includes("@partial"))R=await x8(R,I,O,X,J,Q);let{processLoops:b}=await Promise.resolve().then(() => (P8(),mJ)),P=b(R,I,O);P=f1(P,I,O);let d=$5(w);if(P=r0(P,I,O,{forceSignals:d}),T)P+=`
4253
+ `+T;if(k)P+=`
4254
+ `+k;return P}catch(w){let R=w instanceof Error?w.message:String(w);return J0("Include",`Error processing include ${j}: ${R}`,Y,L,F)}}let _=/@include\s*\(/g,B;while((B=_.exec(K))!==null){let j=B.index,H=j+B[0].length-1,L=1,F=H+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let O=K.substring(j,F),V=K.substring(H+1,F-1),w=V.match(/^\s*['"]([^'"]+)['"]/);if(!w){_.lastIndex=F;continue}let R=w[1],A,N=V.substring(w[0].length),M=v8(N,0);if(M!==-1)A=N.substring(M+1).trim();let T={};if(A)try{T=j0(A,Z)}catch(D){let E=D instanceof Error?D.message:String(D);K=K.replace(O,J0("Include",`Error parsing include variables for ${R}: ${E}`,Y,$,j)),_.lastIndex=0;continue}let I=await W(R,T,$,j);K=K.substring(0,j)+I+K.substring(F),_.lastIndex=0}return K}function f8($,Z){let Y=$;function X(J,Q,G,K){let q=J,z=!0;while(z){z=!1;let U=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),W=q.match(U);if(!W||W.index===void 0)break;let _=W.index,B=W[1],j=_+W[0].length,H=new RegExp(`@${Q}\\(`),L=new RegExp(`@${G}(?![a-z])`),F=1,O=j,V=-1;while(F>0&&O<q.length){let R=q.slice(O),A=R.match(H),N=R.match(L),M=A?O+A.index:1/0,T=N?O+N.index:1/0;if(M<T)F++,O=M+(A[0].length||1);else if(T<1/0){if(F--,F===0){V=T;break}O=T+G.length+1}else break}if(V===-1)break;let w=q.slice(j,V);if(!Z[B])Z[B]=[];if(K)Z[B].unshift(w);else Z[B].push(w);q=q.substring(0,_)+q.substring(V+`@${G}`.length),z=!0}return q}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function g8($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
4255
4255
  `)})}var pJ=0,VN,iJ;var nJ=y(()=>{B4();a0();Z5();F0();V0();VN=new y5(500),iJ=new Set});import*as h8 from"path";async function oJ($,Z,Y=""){if(h8.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 rJ($,Z,Y,"@js","@endjs")}async function sJ($,Z,Y=""){if(h8.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 rJ($,Z,Y,"@ts","@endts")}async function rJ($,Z,Y,X,J){let Q=$,G=k1(`${X}([\\s\\S]*?)${J}`,"g"),K=[],q;while((q=G.exec($))!==null)K.push({fullMatch:q[0],content:q[1]||"",index:q.index});for(let{fullMatch:z,content:U,index:W}of K)try{let _=Object.keys(Z),B=Object.values(Z),j=U.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 L=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((R)=>R.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=L.length>0?`return { ${L.join(", ")} };`:"return {};",O=`
4256
4256
  ${j}
4257
4257
  ${F}
@@ -13416,24 +13416,24 @@ ${V}`:V,Z.__sections=j}}if(H)try{let O;if(y0.isAbsolute(H))O=H,J.add(H);else O=a
13416
13416
  ${q}`,W(q)}catch(O){return p0.log(O instanceof Error?O:Error(String(O)),{layoutPath:H,filePath:Y},"error"),`[Error processing layout: ${O instanceof Error?O.message:String(O)}]`}return W(await BQ(q,Z,Y,G,J))}function fj($,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 gj($,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 hj($,Z){await K5(()=>Q9($,Z),void 0,(Y)=>{p0.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function dj($,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:q}=await Promise.resolve().then(() => (e5(),I4));await q(G,Z,Y,{preserveExisting:!0})}catch(q){let z=q instanceof Error?q:Error(String(q));p0.log(z,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${z.message}`)}}}async function uj($,Z,Y){try{let{interpolateScriptsInTemplate:X}=await Promise.resolve().then(() => (a0(),JZ));return X($,Z,{skipServer:!0})}catch(X){let J=X instanceof Error?X:Error(String(X));return p0.log(J,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${J.message}`),$}}async function BQ($,Z,Y,X,J){let Q=$,G=X;if(await dj(Q,Z,Y),Q=await uj(Q,Z,Y),Q=await oJ(Q,Z,Y),Q=await sJ(Q,Z,Y),Q=await vX(Q,Z,Y,G),$5(Q))Q=a8(Q,Z),Q=e8(Q,Z);Q=t8(Q);let{processStreamDirectives:K}=await Promise.resolve().then(() => (t3(),a3));Q=K(Q,Z),Q=C8(Q,Z,Y,G),Q=await M4(Q,Z,Y,G,J),Q=await B9(Q,Z,Y,G,J),Q=x6(Q,Z,Y,G);let{processDeferDirectives:q}=await Promise.resolve().then(() => s9);Q=q(Q,Z,Y);let{processTeleportDirectives:z}=await Promise.resolve().then(() => a9);Q=z(Q,Z,Y);let{processTransitionDirectives:U,processTransitionAttributes:W}=await Promise.resolve().then(() => Z2);Q=U(Q,Z,Y),Q=W(Q);let{processErrorBoundaryDirectives:_}=await Promise.resolve().then(() => X2);Q=_(Q,Z,Y);let{processSuspenseDirectives:B}=await Promise.resolve().then(() => J2);Q=B(Q,Z,Y);let{processAsyncDirectives:j}=await Promise.resolve().then(() => q2);Q=j(Q,Z,Y);let{processKeepAliveDirectives:H}=await Promise.resolve().then(() => U2);Q=H(Q,Z,Y);let{processVirtualListDirectives:L,processVirtualGridDirectives:F,processInfiniteListDirectives:O}=await Promise.resolve().then(() => (O2(),H2));Q=L(Q,Z,Y),Q=F(Q,Z,Y),Q=O(Q,Z,Y);let{processPartialHydrationDirectives:V,processStaticDirectives:w}=await Promise.resolve().then(() => (b2(),S2));Q=V(Q,Z,Y),Q=w(Q);let{processComputedDirectives:R,processWatchDirectives:A}=await Promise.resolve().then(() => (p2(),m2));Q=R(Q,Z,Y),Q=A(Q,Z,Y);let{processFormValidationDirectives:N}=await Promise.resolve().then(() => (o2(),n2));Q=N(Q,Z,Y);let{processHeadDirective:M,processTitleDirective:T,processMetaDirective:I,resetHead:D}=await Promise.resolve().then(() => (c5(),h3));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)D();let E=M(Q);if(Q=E.content,E.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${E.headContent}
13417
13417
  `;if(Q=T(Q,Z),Q=I(Q,Z),Q=X9(Q),Q=C3(Q,Z),Q=CX(Q),Q=tJ(Q),Q=await x8(Q,Z,Y,G,J),Q=await M4(Q,Z,Y,G,J),Q=Q.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),Q=Y6(Q),Q=f1(Q,Z,Y),Q=P3(Q,Z),Q=v3(Q,Z),Q=n5(Q,Z),Q=u3(Q,Z),Q=m3(Q,Z),Q=await jX(Q,Z,Y,G),Q=await N7(Q,Z,Y),Q=await o3(Q,Z,Y,G),Q=z7(Q,Z,Y,G),Q=CY(Q,Z,Y,G),Q=PY(Q,Z,Y),Q=vY(Q,Z,Y,G),Q=EX(Q,Z,Y,G),Q=n4(Q,Z),Q=o4(Q),Q=p9(Q),!G.skipEventDirectives)Q=KX(Q,Z,Y);if(Q=_X(Q,Z,Y),G.debug){let x=/\bx-data\s*=/.test(Q),g=i4($);if(x&&g)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
13418
13418
  Both work on the same page, but they manage separate scopes.
13419
- Prefer signals (state/derived/effect) for new components.`)}Q=q9(Q,Z),Q=await r0(Q,Z,Y),Q=c9(Q),Q=l9(Q),Q=$X(Q);let{processXElementDirectives:k}=await Promise.resolve().then(() => a2);Q=k(Q);let S=Z.__originalFilePath||Y,b=G$(Z);if(Q=await $6(Q,G,S,b),Q=await Z9(Q,Z,Y,G),G.media?.image?.autoSiblings){let x=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (g6(),f6));Q=await g(Q,{publicDir:x})}if(G.seo?.enabled)Q=xY(Q,Z,G);let C=(x,g)=>{if(!g)return x;if(/<\/head>/i.test(x))return x.replace(/<\/head>/i,`${g}
13419
+ Prefer signals (state/derived/effect) for new components.`)}Q=q9(Q,Z),Q=await r0(Q,Z,Y),Q=c9(Q),Q=l9(Q),Q=$X(Q);let{processXElementDirectives:k}=await Promise.resolve().then(() => a2);Q=k(Q);let S=Z.__originalFilePath||Y,b=G$(Z);if(Q=await $6(Q,G,S,b),Q=await Z9(Q,Z,Y,G),G.media?.image?.autoSiblings){let x=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (g6(),f6));Q=await g(Q,{publicDir:x})}if(G.seo?.enabled)Q=xY(Q,Z,G);let P=(x,g)=>{if(!g)return x;if(/<\/head>/i.test(x))return x.replace(/<\/head>/i,`${g}
13420
13420
  </head>`);if(/<head\b[^>]*>/i.test(x))return x.replace(/(<head\b[^>]*>)/i,`$1
13421
13421
  ${g}`);if(/<html\b[^>]*>/i.test(x))return x.replace(/(<html\b[^>]*>)/i,`$1
13422
13422
  <head>
13423
13423
  ${g}
13424
- </head>`);return x},{renderHead:d,getHead:f}=await Promise.resolve().then(() => (c5(),h3)),m=Z.__stx_runtime_head,o=m&&(m.title||m.meta?.length||m.link?.length)?m:f();if(o.title||o.meta?.length||o.link?.length){let x=d(o);if(x)Q=C(Q,x)}if(E.headContent)Q=C(Q,E.headContent);if(G.csp?.enabled&&G.csp.addMetaTag)Q=DX(Q,G.csp,Z);if(G.analytics?.enabled)Q=C6(Q,G);if(G.heatmap?.enabled)Q=jZ(Q,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:x}=await Promise.resolve().then(() => (WQ(),UQ));Q=x(Q,G)}let N0=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(Q),Z1=/\bSTX\.\w+/.test(Q),C0=/window\.STX\s*=/.test(Q);if(N0&&Z1&&!C0){let g=`<script data-stx-scoped>
13424
+ </head>`);return x},{renderHead:d,getHead:f}=await Promise.resolve().then(() => (c5(),h3)),m=Z.__stx_runtime_head,o=m&&(m.title||m.meta?.length||m.link?.length)?m:f();if(o.title||o.meta?.length||o.link?.length){let x=d(o);if(x)Q=P(Q,x)}if(E.headContent)Q=P(Q,E.headContent);if(G.csp?.enabled&&G.csp.addMetaTag)Q=DX(Q,G.csp,Z);if(G.analytics?.enabled)Q=C6(Q,G);if(G.heatmap?.enabled)Q=jZ(Q,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:x}=await Promise.resolve().then(() => (WQ(),UQ));Q=x(Q,G)}let N0=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(Q),Z1=/\bSTX\.\w+/.test(Q),C0=/window\.STX\s*=/.test(Q);if(N0&&Z1&&!C0){let g=`<script data-stx-scoped>
13425
13425
  ${rY()}
13426
- </script>`;if(Q.includes("</head>")){let p=Q.indexOf("</head>"),G0=Q.slice(0,p).indexOf("<script");if(G0!==-1){let k0=Q.slice(0,G0),P0=Q.slice(G0);Q=k0+g+`
13426
+ </script>`;if(Q.includes("</head>")){let p=Q.indexOf("</head>"),G0=Q.slice(0,p).indexOf("<script");if(G0!==-1){let T0=Q.slice(0,G0),P0=Q.slice(G0);Q=T0+g+`
13427
13427
  `+P0}else Q=Q.replace("</head>",`${g}
13428
13428
  </head>`)}else if(Q.includes("<body"))Q=Q.replace(/<body([^>]*)>/,`<body$1>
13429
13429
  ${g}`);else Q=g+`
13430
- `+Q}{let x=/<script\s+server\b[^>]*>/gi,g,p=[];while((g=x.exec(Q))!==null){let s=g.index+g[0].length,G0=vj(Q,s);if(G0===-1)continue;let k0=G0+9;while(k0<Q.length&&/\s/.test(Q[k0]))k0++;p.push({start:g.index,end:k0})}for(let s=p.length-1;s>=0;s--){let{start:G0,end:k0}=p[s];Q=Q.substring(0,G0)+Q.substring(k0)}}let E0=b4(Q,Y);if(E0.hasScoped)Q=E0.html;let X0=Z.__stx_event_bindings||[],L0=!1,U0=[],P=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:v}=await Promise.resolve().then(() => (Z6(),g9));for(let x of v(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))U0.push({match:x.fullMatch,attrs:x.attrs,content:x.body});for(let{match:x,attrs:g,content:p}of U0){L0=!0;let s=p;s4(p,Y,X.strict);let G0=await K$(p,{eventBindings:X0,attrs:g,hasColonDirectives:P,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:b});Q=Q.replace(x,()=>G0)}if(L0)Z.__stx_event_bindings=[];return Q}var s1="<!--PARENT_CONTENT_PLACEHOLDER-->";var e3=y(()=>{M3();N$();U7();aY();ZX();P6();A7();H7();qX();$$();BX();HX();B4();kX();PX();fX();Q1();c5();a0();uX();rX();nJ();aJ();P8();M7();Y9();Z5();J9();j3();V0();G9();z9();_9();j9();u8();Z6();S8();m9();X6();J6();F0();Z8();X6();J6()});function ij($){let Z=[],Y=[];return nj($,Z),oj($,Z,Y),sj($,Y),rj($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function nj($,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 oj($,Z,Y){for(let X of pj){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 q=new RegExp(X.altClose,"g");K+=($.match(q)||[]).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 sj($,Z){for(let Y of cj)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function rj($,Z){for(let Y of lj)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function aj($,Z){let Y=$.slice(0,Z).split(`
13430
+ `+Q}{let x=/<script\s+server\b[^>]*>/gi,g,p=[];while((g=x.exec(Q))!==null){let s=g.index+g[0].length,G0=vj(Q,s);if(G0===-1)continue;let T0=G0+9;while(T0<Q.length&&/\s/.test(Q[T0]))T0++;p.push({start:g.index,end:T0}),x.lastIndex=T0}for(let s=p.length-1;s>=0;s--){let{start:G0,end:T0}=p[s];Q=Q.substring(0,G0)+Q.substring(T0)}}let k0=b4(Q,Y);if(k0.hasScoped)Q=k0.html;let X0=Z.__stx_event_bindings||[],L0=!1,U0=[],C=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:v}=await Promise.resolve().then(() => (Z6(),g9));for(let x of v(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))U0.push({match:x.fullMatch,attrs:x.attrs,content:x.body});for(let{match:x,attrs:g,content:p}of U0){L0=!0;let s=p;s4(p,Y,X.strict);let G0=await K$(p,{eventBindings:X0,attrs:g,hasColonDirectives:C,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:b});Q=Q.replace(x,()=>G0)}if(L0)Z.__stx_event_bindings=[];return Q}var s1="<!--PARENT_CONTENT_PLACEHOLDER-->";var e3=y(()=>{M3();N$();U7();aY();ZX();P6();A7();H7();qX();$$();BX();HX();B4();kX();PX();fX();Q1();c5();a0();uX();rX();nJ();aJ();P8();M7();Y9();Z5();J9();j3();V0();G9();z9();_9();j9();u8();Z6();S8();m9();X6();J6();F0();Z8();X6();J6()});function ij($){let Z=[],Y=[];return nj($,Z),oj($,Z,Y),sj($,Y),rj($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function nj($,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 oj($,Z,Y){for(let X of pj){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 q=new RegExp(X.altClose,"g");K+=($.match(q)||[]).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 sj($,Z){for(let Y of cj)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function rj($,Z){for(let Y of lj)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function aj($,Z){let Y=$.slice(0,Z).split(`
13431
13431
  `);return{line:Y.length,column:Y[Y.length-1].length+1}}function tj($,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 ej($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function $H($){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 pj,cj,lj;var jQ=y(()=>{pj=[{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"}],cj=[{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')"}],lj=[{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 VQ={};c(VQ,{renderSlot:()=>OQ,processSlots:()=>FQ,parseSlots:()=>HQ,parseSlotElement:()=>YH,extractSlotContent:()=>QH,applySlots:()=>GH});function ZH($,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 HQ($){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[U,W,_,B,j]=Q,H=W||_||B,L=Q.index+U.length,F=ZH($,L);if(F!==-1){let O=$.slice(L,F-11).trim();J.push({start:Q.index,end:F,slotName:H,content:O,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:O,propsBinding:j||void 0})}}J.sort((U,W)=>W.start-U.start);for(let U of J)Y=Y.slice(0,U.start)+Y.slice(U.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,q;while((q=K.exec(Y))!==null){let[U,W,_,B,j,H]=q,L=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(L+F).trim(),V=`<${W}${O?" "+O:""}>${H}</${W}>`;G.push({start:q.index,end:q.index+U.length,slotName:B,element:V})}let z=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((q=z.exec(Y))!==null){let[U,W,_,B,j]=q,H=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+L).trim(),O=`<${W}${F?" "+F:""} />`;G.push({start:q.index,end:q.index+U.length,slotName:B,element:O})}G.sort((U,W)=>W.start-U.start);for(let U of G){let W=Z.named.get(U.slotName);if(W)W.content+=U.element;else Z.named.set(U.slotName,{name:U.slotName,content:U.element});Y=Y.slice(0,U.start)+Y.slice(U.end)}return Z.default=Y.trim(),Z}function YH($){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 OQ($,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((q)=>q.trim()).filter(Boolean);for(let q of K){let[z,U]=q.split(":").map((_)=>_.trim()),W=U||z;if(Z[z]!==void 0)G[W]=Z[z]}}else G[Q]=Z;J=XH(J,G)}return J}function XH($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let J=X.trim(),Q=LQ(J,Z);return u0(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(!$0($))return;return Z0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function FQ($,Z,Y){let X=$;X=await JH(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,q,z)=>{let U=Z.named.get(K),W=z?.trim()||"",_=q||"",B={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(_))!==null){let L=H[1],F=H[2];B[L]=LQ(F,Y)}return await OQ(U,B,W,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(Q,(G,K)=>{if(G.includes("name="))return G;let q=K?.trim()||"";return Z.default||q}),X}async function JH($,Z,Y){let X=[],J=[];$.replace(Z,(K,...q)=>{let z=q[q.length-2];return J.push({match:K,index:z}),X.push(Y(K,...q.slice(0,-2))),K});let Q=await Promise.all(X),G=$;for(let K=J.length-1;K>=0;K--){let{match:q,index:z}=J[K];G=G.slice(0,z)+Q[K]+G.slice(z+q.length)}return G}function QH($){let Z=HQ($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function GH($,Z,Y,X){return await FQ($,{default:Z,named:Y},X)}var wQ=y(()=>{a0();F0()});import KH from"fs";import h from"path";function RQ($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function zH($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function c1($){return!zH($)}function l1($){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:s0()}).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 UH($){let Z=[],Y=new Set,X=0,J=0,Q=$.length,G=(U)=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]===U){J++;return}J++}},K=()=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]==="`"){J++;return}if($[J]==="$"&&$[J+1]==="{"){J+=2;let U=1;while(J<Q&&U>0)if($[J]==="{")U++,J++;else if($[J]==="}")U--,J++;else if($[J]==="'"||$[J]==='"')G($[J]);else if($[J]==="`")K();else J++;continue}J++}},q=()=>{if($[J]==="/"&&$[J+1]==="/"){while(J<Q&&$[J]!==`
13432
- `)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},z=()=>{if(X!==0)return;let U=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(U){let j=U[2].split(",").map((H)=>{let L=H.trim().split(":");return L[L.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 W=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(W){let j=W[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let _=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(q())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])))z();J++}return Z}function WH($){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 _H($){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 BH($,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 q=$[X];if(q==="}")Q++;else if(q==="{"){if(Q--,Q===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,J);for(let q of WH(K)){let z=q.trim();if(!z||z.startsWith("..."))continue;let U=_H(z);if(U===-1)continue;let W=z.slice(0,U).trim();if(!/^[A-Z_$][\w$]*$/i.test(W))continue;if(Z[W]!==void 0)continue;let _=z.slice(U+1).trim();if(!_)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${_});`);Z[W]=j(...B.map((H)=>Z[H]))}catch{}}}catch{}}async function MJ($,Z,Y,X,J){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(L)=>L.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""),K=(L)=>L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),q=Y.__importedComponents;if(q){for(let L of[Q,Q.toLowerCase(),G(Q),K(Q)])if(q.has(L))return!0}let z=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],U=typeof J.root==="string"?h.resolve(J.root):void 0,W=U??h.dirname(X),_=[],B=(L)=>{if(L&&!_.includes(L))_.push(L)},j=Y.__originalFilePath;if(j)B(h.join(h.dirname(j),"components"));B(Z),B(h.join(h.dirname(X),"components")),B(J.componentsDir);let H=J._pluginComponentDirs;if(Array.isArray(H))for(let L of H)B(typeof L==="string"?L:null);if(U)B(h.resolve(U,"resources/views/components")),B(h.resolve(U,"resources/components")),B(h.resolve(U,"src/components")),B(h.resolve(U,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return n(h.resolve(h.dirname(X),`${Q}.stx`));for(let L of _){let F=h.isAbsolute(L)?L:h.resolve(W,L);for(let O of z)if(await n(h.join(F,O)))return!0}return!1}function jH($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function q1($,Z,Y,X,J,Q,G,K=new Set,q){let{extractVariables:z}=await Promise.resolve().then(() => (e5(),I4)),U=K??new Set;if(U.has($))return`[Circular component reference: ${$}]`;let W=new Set(U);W.add($);let _=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let B=_&&_!=="load"&&jH(_)?_:"";try{let j=(P)=>P.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),H=(P)=>P.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),L=$.endsWith(".stx")?$.slice(0,-4):$,F=null,O=J.__importedComponents;if(O){let P=[L,L.toLowerCase(),j(L),H(L)];for(let v of P)if(O.has(v)){F=O.get(v);break}}let V=[];if(!F){let P=[`${L}.stx`,`${j(L)}.stx`,`${H(L)}.stx`],v=[...new Set(P)],x=J.__originalFilePath,g=[];if(x){let z0=h.join(h.dirname(x),"components");g.push(z0)}if(X)g.push(X);let p=h.join(h.dirname(Q),"components");if(!g.includes(p))g.push(p);if(G.componentsDir&&G.componentsDir!==X&&!g.includes(G.componentsDir))g.push(G.componentsDir);let s=G._pluginComponentDirs;if(Array.isArray(s)){for(let z0 of s)if(typeof z0==="string"&&!g.includes(z0))g.push(z0)}let G0=typeof G.root==="string"?h.resolve(G.root):void 0,k0=G0??h.dirname(Q),P0=[];if(G0)P0.push(h.resolve(G0,"resources/views/components")),P0.push(h.resolve(G0,"resources/components")),P0.push(h.resolve(G0,"src/components")),P0.push(h.resolve(G0,"components"));P0.push(h.resolve(import.meta.dir,"components"));for(let z0 of P0)if(!g.includes(z0))g.push(z0);let I1=[...new Set(g.map((z0)=>{if(!z0)return z0;return h.isAbsolute(z0)?z0:h.resolve(k0,z0)}))];if(g.length=0,g.push(...I1),L.startsWith("./")||L.startsWith("../"))F=h.resolve(h.dirname(Q),`${L}.stx`),V.push(F);else for(let z0 of g){if(!z0)continue;for(let D1 of v){let I5=h.join(z0,D1);if(V.push(I5),await n(I5)){F=I5;break}}if(F)break;if(!F)try{let D1=await import("fs");if(!D1.statSync(z0,{throwIfNoEntry:!1})?.isDirectory())continue;let U$=8,t=[{path:z0,depth:0}];while(t.length>0&&!F){let o0=t.pop();if(o0.depth>=U$)continue;let G7;try{G7=D1.readdirSync(o0.path,{withFileTypes:!0})}catch{continue}for(let W$ of G7){if(!W$.isDirectory())continue;if(W$.name==="node_modules"||W$.name.startsWith("."))continue;let M6=h.join(o0.path,W$.name);for(let yQ of v){let K7=h.join(M6,yQ);if(V.push(K7),await n(K7)){F=K7;break}}if(F)break;t.push({path:M6,depth:o0.depth+1})}}}catch{}if(F)break}}if(!F||!await n(F)){let P=V.length>0?`
13432
+ `)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},z=()=>{if(X!==0)return;let U=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(U){let j=U[2].split(",").map((H)=>{let L=H.trim().split(":");return L[L.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 W=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(W){let j=W[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let _=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(q())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])))z();J++}return Z}function WH($){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 _H($){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 BH($,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 q=$[X];if(q==="}")Q++;else if(q==="{"){if(Q--,Q===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,J);for(let q of WH(K)){let z=q.trim();if(!z||z.startsWith("..."))continue;let U=_H(z);if(U===-1)continue;let W=z.slice(0,U).trim();if(!/^[A-Z_$][\w$]*$/i.test(W))continue;if(Z[W]!==void 0)continue;let _=z.slice(U+1).trim();if(!_)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${_});`);Z[W]=j(...B.map((H)=>Z[H]))}catch{}}}catch{}}async function MJ($,Z,Y,X,J){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(L)=>L.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""),K=(L)=>L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),q=Y.__importedComponents;if(q){for(let L of[Q,Q.toLowerCase(),G(Q),K(Q)])if(q.has(L))return!0}let z=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],U=typeof J.root==="string"?h.resolve(J.root):void 0,W=U??h.dirname(X),_=[],B=(L)=>{if(L&&!_.includes(L))_.push(L)},j=Y.__originalFilePath;if(j)B(h.join(h.dirname(j),"components"));B(Z),B(h.join(h.dirname(X),"components")),B(J.componentsDir);let H=J._pluginComponentDirs;if(Array.isArray(H))for(let L of H)B(typeof L==="string"?L:null);if(U)B(h.resolve(U,"resources/views/components")),B(h.resolve(U,"resources/components")),B(h.resolve(U,"src/components")),B(h.resolve(U,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return n(h.resolve(h.dirname(X),`${Q}.stx`));for(let L of _){let F=h.isAbsolute(L)?L:h.resolve(W,L);for(let O of z)if(await n(h.join(F,O)))return!0}return!1}function jH($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function q1($,Z,Y,X,J,Q,G,K=new Set,q){let{extractVariables:z}=await Promise.resolve().then(() => (e5(),I4)),U=K??new Set;if(U.has($))return`[Circular component reference: ${$}]`;let W=new Set(U);W.add($);let _=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let B=_&&_!=="load"&&jH(_)?_:"";try{let j=(C)=>C.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),H=(C)=>C.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),L=$.endsWith(".stx")?$.slice(0,-4):$,F=null,O=J.__importedComponents;if(O){let C=[L,L.toLowerCase(),j(L),H(L)];for(let v of C)if(O.has(v)){F=O.get(v);break}}let V=[];if(!F){let C=[`${L}.stx`,`${j(L)}.stx`,`${H(L)}.stx`],v=[...new Set(C)],x=J.__originalFilePath,g=[];if(x){let z0=h.join(h.dirname(x),"components");g.push(z0)}if(X)g.push(X);let p=h.join(h.dirname(Q),"components");if(!g.includes(p))g.push(p);if(G.componentsDir&&G.componentsDir!==X&&!g.includes(G.componentsDir))g.push(G.componentsDir);let s=G._pluginComponentDirs;if(Array.isArray(s)){for(let z0 of s)if(typeof z0==="string"&&!g.includes(z0))g.push(z0)}let G0=typeof G.root==="string"?h.resolve(G.root):void 0,T0=G0??h.dirname(Q),P0=[];if(G0)P0.push(h.resolve(G0,"resources/views/components")),P0.push(h.resolve(G0,"resources/components")),P0.push(h.resolve(G0,"src/components")),P0.push(h.resolve(G0,"components"));P0.push(h.resolve(import.meta.dir,"components"));for(let z0 of P0)if(!g.includes(z0))g.push(z0);let I1=[...new Set(g.map((z0)=>{if(!z0)return z0;return h.isAbsolute(z0)?z0:h.resolve(T0,z0)}))];if(g.length=0,g.push(...I1),L.startsWith("./")||L.startsWith("../"))F=h.resolve(h.dirname(Q),`${L}.stx`),V.push(F);else for(let z0 of g){if(!z0)continue;for(let D1 of v){let I5=h.join(z0,D1);if(V.push(I5),await n(I5)){F=I5;break}}if(F)break;if(!F)try{let D1=await import("fs");if(!D1.statSync(z0,{throwIfNoEntry:!1})?.isDirectory())continue;let U$=8,t=[{path:z0,depth:0}];while(t.length>0&&!F){let o0=t.pop();if(o0.depth>=U$)continue;let G7;try{G7=D1.readdirSync(o0.path,{withFileTypes:!0})}catch{continue}for(let W$ of G7){if(!W$.isDirectory())continue;if(W$.name==="node_modules"||W$.name.startsWith("."))continue;let M6=h.join(o0.path,W$.name);for(let yQ of v){let K7=h.join(M6,yQ);if(V.push(K7),await n(K7)){F=K7;break}}if(F)break;t.push({path:M6,depth:o0.depth+1})}}}catch{}if(F)break}}if(!F||!await n(F)){let C=V.length>0?`
13433
13433
  Searched paths:
13434
13434
  ${V.map((v)=>` - ${v}`).join(`
13435
- `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${P}`}q.add(F);let w;if(q$.has(F))w=q$.get(F);else try{w=await Bun.file(F).text(),q$.set(F,w)}catch(P){return`[Error loading component: ${P instanceof Error?P.message:String(P)}]`}let R=new Set(["__originalFilePath","__importedComponents"]),A={};for(let[P,v]of Object.entries(J))if(!P.startsWith("__")||R.has(P))A[P]=v;let N={...A,...Z,props:Z,slot:Y,__processedComponents:W,__sections:{}};BH(w,N);let M=w,T=M.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(T)M=T[1].trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,D=[...w.matchAll(I)],E=[];for(let P of D){let v=P[1]||"",x=P[2]||"",g=v.includes("server");if(c1(v)&&x.trim())x=l1(x);if(g&&x)try{await z(x,N,F)}catch(s){}if(!g){let s=x.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(s.includes("{{")&&s.includes("}}"))s=r0(s,N,F);let G0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");E.push(`<script${G0}>${s}</script>`)}}let k=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),S=k?k[1]:"",b=k?k[2]:"",C="",d=S&&/\bscoped\b/i.test(S);if(k)C=`<style${S}>${b}</style>`;let f=M;if(f=f.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),k)f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let P=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(f=f.replace(P,(x,g)=>{let p=g.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(p)v.push(`<style${p[1]}>${p[2]}</style>`);return""}),f=f.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)C=`${C}${v.join(`
13436
- `)}`}if(Y&&f.includes("{{ text || slot }}"))f=f.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:m,applySlots:o}=await Promise.resolve().then(() => (wQ(),VQ)),{defaultSlot:N0,namedSlots:Z1}=m(Y);f=await o(f,N0||Y,Z1,N);for(let[P,v]of Object.entries(N))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("&lt;")||v.includes("&quot;")){let x=w7(v);N[P]=x}}let C0=E.some((P)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(P)),E0={...G,componentsDir:h.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:C0,defaultLayout:void 0};N.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let X0=await R0(f,N,F,E0,q),L0=`stx_${L.replace(/[^a-zA-Z0-9]/g,"_")}_${++qH}_${Math.random().toString(36).slice(2,8)}`,U0=X0;if(C0){let P="";if(Object.keys(Z).length>0)try{P=` data-stx-props="${RQ(JSON.stringify(Z))}"`}catch{}let v=B?` stx-hydrate="${RQ(B)}"`:"";if(U0=`<div data-stx-scope="${L0}"${P}${v}>${X0}</div>`,U0=E.map((g)=>{let p=g.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!p)return g;let[,s,G0]=p,k0=J1(G0),P0=`
13435
+ `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${C}`}q.add(F);let w;if(q$.has(F))w=q$.get(F);else try{w=await Bun.file(F).text(),q$.set(F,w)}catch(C){return`[Error loading component: ${C instanceof Error?C.message:String(C)}]`}let R=new Set(["__originalFilePath","__importedComponents"]),A={};for(let[C,v]of Object.entries(J))if(!C.startsWith("__")||R.has(C))A[C]=v;let N={...A,...Z,props:Z,slot:Y,__processedComponents:W,__sections:{}};BH(w,N);let M=w,T=M.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(T)M=T[1].trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,D=[...w.matchAll(I)],E=[];for(let C of D){let v=C[1]||"",x=C[2]||"",g=v.includes("server");if(c1(v)&&x.trim())x=l1(x);if(g&&x)try{await z(x,N,F)}catch(s){}if(!g){let s=x.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(s.includes("{{")&&s.includes("}}"))s=r0(s,N,F);let G0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");E.push(`<script${G0}>${s}</script>`)}}let k=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),S=k?k[1]:"",b=k?k[2]:"",P="",d=S&&/\bscoped\b/i.test(S);if(k)P=`<style${S}>${b}</style>`;let f=M;if(f=f.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),k)f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let C=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(f=f.replace(C,(x,g)=>{let p=g.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(p)v.push(`<style${p[1]}>${p[2]}</style>`);return""}),f=f.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)P=`${P}${v.join(`
13436
+ `)}`}if(Y&&f.includes("{{ text || slot }}"))f=f.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:m,applySlots:o}=await Promise.resolve().then(() => (wQ(),VQ)),{defaultSlot:N0,namedSlots:Z1}=m(Y);f=await o(f,N0||Y,Z1,N);for(let[C,v]of Object.entries(N))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("&lt;")||v.includes("&quot;")){let x=w7(v);N[C]=x}}let C0=E.some((C)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(C)),k0={...G,componentsDir:h.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:C0,defaultLayout:void 0};N.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let X0=await R0(f,N,F,k0,q),L0=`stx_${L.replace(/[^a-zA-Z0-9]/g,"_")}_${++qH}_${Math.random().toString(36).slice(2,8)}`,U0=X0;if(C0){let C="";if(Object.keys(Z).length>0)try{C=` data-stx-props="${RQ(JSON.stringify(Z))}"`}catch{}let v=B?` stx-hydrate="${RQ(B)}"`:"";if(U0=`<div data-stx-scope="${L0}"${C}${v}>${X0}</div>`,U0=E.map((g)=>{let p=g.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!p)return g;let[,s,G0]=p,T0=J1(G0),P0=`
13437
13437
  (function() {
13438
13438
  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;
13439
13439
  const __scope = window.stx._scopes = window.stx._scopes || {};
@@ -13445,23 +13445,23 @@ ${V.map((v)=>` - ${v}`).join(`
13445
13445
  const onMount = (fn) => __scopeVars.__mountCallbacks.push(fn);
13446
13446
  const onDestroy = (fn) => __scopeVars.__destroyCallbacks.push(fn);
13447
13447
 
13448
- ${k0}
13448
+ ${T0}
13449
13449
 
13450
13450
  // Register all defined signals and functions in this scope
13451
13451
  const __localVars = {};
13452
13452
  try {
13453
- ${UH(k0).map((I1)=>`if (typeof ${I1} !== 'undefined') __localVars['${I1}'] = ${I1};`).join(`
13453
+ ${UH(T0).map((I1)=>`if (typeof ${I1} !== 'undefined') __localVars['${I1}'] = ${I1};`).join(`
13454
13454
  `)}
13455
13455
  }
13456
13456
  catch (e) {}
13457
13457
  Object.assign(__scopeVars, __localVars);
13458
13458
  })();`;if(B)return`<script type="stx/island" data-stx-island="${L0}" data-stx-scoped${s}>${P0}</script>`;return`<script data-stx-scoped${s}>${P0}</script>`}).join(`
13459
13459
  `)+`
13460
- `+U0,C)U0+=`
13461
- `+C}else{if(C)U0+=`
13462
- `+C;if(E.length>0){let P=N.__stx_event_bindings||[],v=G$(N),x=await Promise.all(E.map(async(g)=>{let p=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!p)return g;return await K$(p[1],{eventBindings:P,templateContent:U0,filePath:F,projectRoot:process.cwd(),serverData:v})}));U0+=`
13460
+ `+U0,P)U0+=`
13461
+ `+P}else{if(P)U0+=`
13462
+ `+P;if(E.length>0){let C=N.__stx_event_bindings||[],v=G$(N),x=await Promise.all(E.map(async(g)=>{let p=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!p)return g;return await K$(p[1],{eventBindings:C,templateContent:U0,filePath:F,projectRoot:process.cwd(),serverData:v})}));U0+=`
13463
13463
  `+x.join(`
13464
- `),N.__stx_event_bindings=[]}}if(d){let P=b4(U0,F);if(P.hasScoped)U0=P.html}return U0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{U.delete($)}}async function n($){return Bun.file($).exists()}function W6($,Z){let Y=h.resolve(Z),X=h.resolve($),J=Y.endsWith(h.sep)?Y:Y+h.sep;if(X===Y||X.startsWith(J))return X;return null}async function $4($,Z,Y,X){let J=await HH($,Z,Y,X);if(J===null)return null;let Q=W6(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 q=h.isAbsolute(K)?K:h.resolve(process.cwd(),K);if(W6(J,q))return h.resolve(J)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${$}, from: ${Z})`),null}async function HH($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let J=h.dirname(Z),Q=process.cwd();if($.startsWith("/")){let _=h.join(Q,$),B=W6(_,Q);if(!B)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${B}`);if(await n(B)&&X)X.add(B);return B}let G=h.join(J,$);if(await n(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 _ of[".stx",".tsx",".jsx"]){let B=`${G}${_}`;if(await n(B)){if(Y.debug)console.log(`Found direct path with extension: ${B}`);if(X)X.add(B);return B}}let K="",q=h.resolve(J),z=process.cwd();for(let _=0;_<10;_++){let B=h.join(q,"layouts"),j=!1;try{j=KH.statSync(B,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=B;break}let H=h.dirname(q);if(H===q||H.length<z.length)break;q=H}if(K){let _=$.startsWith("layouts/")?$.slice(8):$,B=h.join(K,_);if(await n(B)){if(Y.debug)console.log(`Found in current layouts dir: ${B}`);if(X)X.add(B);return B}if(!_.endsWith(".stx")){let j=`${B}.stx`;if(await n(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 _=h.isAbsolute(Y.layoutsDir)?Y.layoutsDir:h.resolve(process.cwd(),Y.layoutsDir),B=$.startsWith("layouts/")?$.slice(8):$,j=h.join(_,B);if(await n(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 n(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 _=$.split("layouts/"),B=h.join(Y.partialsDir||J,"layouts",_[1]);if(await n(B)){if(Y.debug)console.log(`Found in layouts path: ${B}`);if(X)X.add(B);return B}if(!B.endsWith(".stx")){let j=`${B}.stx`;if(await n(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=h.join(Y.partialsDir,"layouts"),await n(K)){let _=h.join(K,$);if(await n(_)){if(Y.debug)console.log(`Found in partials layouts dir: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await n(B)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${B}`);if(X)X.add(B);return B}}}}let U=Y.partialsDir||h.join(process.cwd(),"views"),W=h.join(U,$);if(await n(W)){if(Y.debug)console.log(`Found in views path: ${W}`);if(X)X.add(W);return W}if(!$.endsWith(".stx")){let _=`${W}.stx`;if(await n(_)){if(Y.debug)console.log(`Found in views path with extension: ${_}`);if(X)X.add(_);return _}}if(J.includes("temp")){let _=h.join(h.dirname(J),"layouts",$);if(await n(_)){if(Y.debug)console.log(`Found in temp layouts dir: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await n(B)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${B}`);if(X)X.add(B);return B}}}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 AQ($,Z,Y){let X=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
13464
+ `),N.__stx_event_bindings=[]}}if(d){let C=b4(U0,F);if(C.hasScoped)U0=C.html}return U0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{U.delete($)}}async function n($){return Bun.file($).exists()}function W6($,Z){let Y=h.resolve(Z),X=h.resolve($),J=Y.endsWith(h.sep)?Y:Y+h.sep;if(X===Y||X.startsWith(J))return X;return null}async function $4($,Z,Y,X){let J=await HH($,Z,Y,X);if(J===null)return null;let Q=W6(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 q=h.isAbsolute(K)?K:h.resolve(process.cwd(),K);if(W6(J,q))return h.resolve(J)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${$}, from: ${Z})`),null}async function HH($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let J=h.dirname(Z),Q=process.cwd();if($.startsWith("/")){let _=h.join(Q,$),B=W6(_,Q);if(!B)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${B}`);if(await n(B)&&X)X.add(B);return B}let G=h.join(J,$);if(await n(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 _ of[".stx",".tsx",".jsx"]){let B=`${G}${_}`;if(await n(B)){if(Y.debug)console.log(`Found direct path with extension: ${B}`);if(X)X.add(B);return B}}let K="",q=h.resolve(J),z=process.cwd();for(let _=0;_<10;_++){let B=h.join(q,"layouts"),j=!1;try{j=KH.statSync(B,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=B;break}let H=h.dirname(q);if(H===q||H.length<z.length)break;q=H}if(K){let _=$.startsWith("layouts/")?$.slice(8):$,B=h.join(K,_);if(await n(B)){if(Y.debug)console.log(`Found in current layouts dir: ${B}`);if(X)X.add(B);return B}if(!_.endsWith(".stx")){let j=`${B}.stx`;if(await n(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 _=h.isAbsolute(Y.layoutsDir)?Y.layoutsDir:h.resolve(process.cwd(),Y.layoutsDir),B=$.startsWith("layouts/")?$.slice(8):$,j=h.join(_,B);if(await n(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 n(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 _=$.split("layouts/"),B=h.join(Y.partialsDir||J,"layouts",_[1]);if(await n(B)){if(Y.debug)console.log(`Found in layouts path: ${B}`);if(X)X.add(B);return B}if(!B.endsWith(".stx")){let j=`${B}.stx`;if(await n(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=h.join(Y.partialsDir,"layouts"),await n(K)){let _=h.join(K,$);if(await n(_)){if(Y.debug)console.log(`Found in partials layouts dir: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await n(B)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${B}`);if(X)X.add(B);return B}}}}let U=Y.partialsDir||h.join(process.cwd(),"views"),W=h.join(U,$);if(await n(W)){if(Y.debug)console.log(`Found in views path: ${W}`);if(X)X.add(W);return W}if(!$.endsWith(".stx")){let _=`${W}.stx`;if(await n(_)){if(Y.debug)console.log(`Found in views path with extension: ${_}`);if(X)X.add(_);return _}}if(J.includes("temp")){let _=h.join(h.dirname(J),"layouts",$);if(await n(_)){if(Y.debug)console.log(`Found in temp layouts dir: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await n(B)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${B}`);if(X)X.add(B);return B}}}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 AQ($,Z,Y){let X=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
13465
13465
  `),K=0;for(let q=0;q<G.length;q++)if(K+=G[q].length+1,K>=Z){X=q+1,J=G[q].trim();let z=Math.max(0,q-2),U=Math.min(G.length,q+3);Q=G.slice(z,U).map((W,_)=>{let B=z+_+1;return`${B===X?"> ":" "}${B}: ${W}`}).join(`
13466
13466
  `);break}}else if(Y){let G=$.indexOf(Y);if(G>=0)return AQ($,G)}}catch{}return{lineNumber:X,lineContent:J,context:Q}}function J0($,Z,Y,X,J,Q){let{lineNumber:G,context:K}=AQ(X,J,Q),q=Y.split("/").pop(),z=0;if(typeof J==="number"&&J>=0&&X){let W=X.lastIndexOf(`
13467
13467
  `,Math.max(0,J-1));z=J-(W+1)+1}let U="";if(G>0)U+=`
@@ -13542,12 +13542,12 @@ ${z}${F}
13542
13542
  'use strict';
13543
13543
  ${X}${Y}
13544
13544
  ${z}
13545
- })()</script>`}var OH,AH,NH,TH,EH,yH;var $$=y(()=>{V0();OH=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;AH=["state","derived","effect","batch","untrack","peek","isSignal","isDerived","onMount","onDestroy","useRef","navigate","goBack","goForward","useRoute","setRouteParams","useSearchParams","useFetch","useQuery","useMutation","useOptimistic","useReactiveProp","useLocalStorage","useSessionStorage","useCookie","useWebSocket","useHead","useSeoMeta","definePageMeta","useEventListener","useMeta","useDebounce","useDebouncedValue","useThrottle","useInterval","useTimeout","useToggle","useCounter","useClickOutside","useFocus","useAsync","useColorMode","useDark","ref","reactive","computed","watch","watchEffect","watchMultiple","onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","defineProps","withDefaults","defineEmits","defineExpose","defineSlots","provide","inject","nextTick","getCurrentInstance","onErrorCaptured","useSlots","useAttrs","createStore","defineStore","useStore","action","createSelector","h","Fragment"],NH=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser"],TH=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);EH={left:0,middle:1,right:2};yH=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"])});function _6($,Z,Y={},X="/"){let J=Z.seo??{},Q=Y.title??J.title??Z.name,G=Y.description??J.description??Z.description??"",K=Y.image??J.image,q=`${Z.url.replace(/\/$/,"")}${X}`,z=J.siteName??Z.name,U=J.type??"website",W=J.locale??"en_US",_=[];if(J.favicon){let H=J.favicon.toLowerCase().split(".").pop(),L=H==="svg"?"image/svg+xml":H==="ico"?"image/x-icon":H==="png"?"image/png":H==="jpg"||H==="jpeg"?"image/jpeg":"";_.push(`<link rel="icon"${L?` type="${L}"`:""} href="${D0(J.favicon)}">`)}if(_.push(`<title>${PH(Q)}</title>`,`<link rel="canonical" href="${D0(q)}">`,`<meta name="description" content="${D0(G)}">`,`<meta property="og:title" content="${D0(Q)}">`,`<meta property="og:description" content="${D0(G)}">`,`<meta property="og:type" content="${D0(U)}">`,`<meta property="og:url" content="${D0(q)}">`,`<meta property="og:site_name" content="${D0(z)}">`,`<meta property="og:locale" content="${D0(W)}">`,`<meta name="twitter:card" content="${K?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${D0(Q)}">`,`<meta name="twitter:description" content="${D0(G)}">`),K)_.push(`<meta property="og:image" content="${D0(K)}">`),_.push(`<meta name="twitter:image" content="${D0(K)}">`);if(J.twitter)_.push(`<meta name="twitter:site" content="@${D0(J.twitter.replace(/^@/,""))}">`),_.push(`<meta name="twitter:creator" content="@${D0(J.twitter.replace(/^@/,""))}">`);let B=`<!-- SEO -->
13545
+ })()</script>`}var OH,AH,NH,TH,EH,yH;var $$=y(()=>{V0();OH=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;AH=["state","derived","effect","batch","untrack","peek","isSignal","isDerived","onMount","onDestroy","useRef","navigate","goBack","goForward","useRoute","setRouteParams","useSearchParams","useFetch","useQuery","useMutation","useOptimistic","useReactiveProp","useLocalStorage","useSessionStorage","useCookie","useWebSocket","useHead","useSeoMeta","definePageMeta","useEventListener","useMeta","useDebounce","useDebouncedValue","useThrottle","useInterval","useTimeout","useToggle","useCounter","useClickOutside","useFocus","useAsync","useColorMode","useDark","ref","reactive","computed","watch","watchEffect","watchMultiple","onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","defineProps","withDefaults","defineEmits","defineExpose","defineSlots","provide","inject","nextTick","getCurrentInstance","onErrorCaptured","useSlots","useAttrs","createStore","defineStore","useStore","action","createSelector","h","Fragment"],NH=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser"],TH=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);EH={left:0,middle:1,right:2};yH=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"])});function _6($,Z,Y={},X="/"){let J=Z.seo??{},Q=Y.title??J.title??Z.name,G=Y.description??J.description??Z.description??"",K=Y.image??J.image,q=`${Z.url.replace(/\/$/,"")}${X}`,z=J.siteName??Z.name,U=J.type??"website",W=J.locale??"en_US",_=[];if(J.favicon){let H=J.favicon.toLowerCase().split(".").pop(),L=H==="svg"?"image/svg+xml":H==="ico"?"image/x-icon":H==="png"?"image/png":H==="jpg"||H==="jpeg"?"image/jpeg":"";_.push(`<link rel="icon"${L?` type="${L}"`:""} href="${E0(J.favicon)}">`)}if(_.push(`<title>${PH(Q)}</title>`,`<link rel="canonical" href="${E0(q)}">`,`<meta name="description" content="${E0(G)}">`,`<meta property="og:title" content="${E0(Q)}">`,`<meta property="og:description" content="${E0(G)}">`,`<meta property="og:type" content="${E0(U)}">`,`<meta property="og:url" content="${E0(q)}">`,`<meta property="og:site_name" content="${E0(z)}">`,`<meta property="og:locale" content="${E0(W)}">`,`<meta name="twitter:card" content="${K?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${E0(Q)}">`,`<meta name="twitter:description" content="${E0(G)}">`),K)_.push(`<meta property="og:image" content="${E0(K)}">`),_.push(`<meta name="twitter:image" content="${E0(K)}">`);if(J.twitter)_.push(`<meta name="twitter:site" content="@${E0(J.twitter.replace(/^@/,""))}">`),_.push(`<meta name="twitter:creator" content="@${E0(J.twitter.replace(/^@/,""))}">`);let B=`<!-- SEO -->
13546
13546
  ${_.join(`
13547
13547
  `)}
13548
13548
  <!-- /SEO -->`,j=/<!--\s*stx SEO Tags\s*-->[\s\S]*?<meta\s+name="twitter:description"[^>]*>\s*/i;if(j.test($))$=$.replace(j,"");if($=$.replace(/<!--\s*SEO\s*-->[\s\S]*?<!--\s*\/SEO\s*-->\s*/g,""),$=$.replace(/<title>[\s\S]*?<\/title>\s*/i,""),$=$.replace(/<meta\s+name="title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+property="og:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+property="og:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+property="og:type"\s+content="website"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:card"\s+content="summary_large_image"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,""),/<head[^>]*>/i.test($))return $.replace(/<head([^>]*)>/i,`<head$1>
13549
13549
  ${B}`);return`${B}
13550
- ${$}`}function D0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function PH($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function B6($,Z){let Y=$.url.replace(/\/$/,""),X=new Date().toISOString().slice(0,10);return['<?xml version="1.0" encoding="UTF-8"?>','<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',Z.filter((Q)=>Q.page?.sitemap!==!1).map((Q)=>{let G=`${Y}${Q.path}`,K=Q.page?.priority??(Q.path==="/"?1:0.8),q=Q.page?.changefreq??"monthly";return[" <url>",` <loc>${vH(G)}</loc>`,` <lastmod>${X}</lastmod>`,` <changefreq>${q}</changefreq>`,` <priority>${K.toFixed(1)}</priority>`," </url>"].join(`
13550
+ ${$}`}function E0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function PH($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function B6($,Z){let Y=$.url.replace(/\/$/,""),X=new Date().toISOString().slice(0,10);return['<?xml version="1.0" encoding="UTF-8"?>','<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',Z.filter((Q)=>Q.page?.sitemap!==!1).map((Q)=>{let G=`${Y}${Q.path}`,K=Q.page?.priority??(Q.path==="/"?1:0.8),q=Q.page?.changefreq??"monthly";return[" <url>",` <loc>${vH(G)}</loc>`,` <lastmod>${X}</lastmod>`,` <changefreq>${q}</changefreq>`,` <priority>${K.toFixed(1)}</priority>`," </url>"].join(`
13551
13551
  `)}).join(`
13552
13552
  `),"</urlset>",""].join(`
13553
13553
  `)}function vH($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function j6($){let Z=$.robots??"allow";if(Z===!1)return null;if(typeof Z==="string"&&Z!=="allow"&&Z!=="disallow")return Z.endsWith(`