@stacksjs/stx 0.2.83 → 0.2.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-shell.js +56 -56
- package/dist/build-assets.js +6 -6
- package/dist/build-mode-detector.js +101 -101
- package/dist/build-views.js +155 -155
- package/dist/build.js +43 -43
- package/dist/caching.js +6 -6
- package/dist/cli.js +57 -57
- package/dist/component-processing.js +22 -22
- package/dist/component-renderer.js +38 -38
- package/dist/components.js +101 -101
- package/dist/dev-server/index.js +42 -42
- package/dist/dev-server/serve-app.js +56 -56
- package/dist/dev-server/serve-file.js +56 -56
- package/dist/dev-server/serve-markdown.js +42 -42
- package/dist/dev-server/serve-multi.js +55 -55
- package/dist/dev-server.js +56 -56
- package/dist/docs.js +102 -102
- package/dist/dynamic-components.js +38 -38
- package/dist/includes.js +38 -38
- package/dist/index.js +56 -56
- package/dist/interactive.js +102 -102
- package/dist/lazy-loader.js +101 -101
- package/dist/plugin.js +50 -50
- package/dist/process.js +37 -37
- package/dist/production-builder.js +37 -37
- package/dist/production-server.js +37 -37
- package/dist/pwa/index.js +101 -101
- package/dist/pwa/offline.js +101 -101
- package/dist/pwa.js +90 -90
- package/dist/render.js +159 -159
- package/dist/runtime-injection.js +6 -6
- package/dist/serve.js +112 -112
- package/dist/signal-processing.js +6 -6
- package/dist/signals.js +6 -6
- package/dist/site-builder/build.js +103 -103
- package/dist/site-builder/index.js +44 -44
- package/dist/ssg.js +19 -19
- package/dist/ssr.js +89 -89
- package/dist/story/cli.js +42 -42
- package/dist/story/commands/dev.js +42 -42
- package/dist/story/commands/index.js +42 -42
- package/dist/story/index.js +42 -42
- package/dist/story/renderer.js +102 -102
- package/dist/story/server.js +42 -42
- package/dist/story/visual-testing.js +102 -102
- package/dist/streaming.js +38 -38
- package/dist/template-compiler.js +30 -30
- package/dist/template-hydrator.js +116 -116
- package/dist/testing.js +101 -101
- package/dist/utils.js +38 -38
- package/dist/variable-extractor.js +11 -11
- package/dist/web-components.js +101 -101
- package/package.json +5 -5
package/dist/story/index.js
CHANGED
|
@@ -1117,7 +1117,7 @@ ${O}
|
|
|
1117
1117
|
filter: blur(0);
|
|
1118
1118
|
transform: scale(1);
|
|
1119
1119
|
}
|
|
1120
|
-
`.trim();T5=new Map});import{createHash as P6}from"crypto";import{readFile as IW,stat as sZ}from"fs/promises";async function k0($){try{let Z=await IW($);return P6("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function qR($){return P6("sha256").update($).digest("hex").slice(0,16)}function nZ($){return P6("sha256").update($).digest("hex").slice(0,16)}function L4($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${nZ($)}-${nZ(Y)}`}async function C6($){try{return(await sZ($)).mtimeMs}catch{return 0}}async function M0($){try{return await sZ($),!0}catch{return!1}}var o1=()=>{};import{mkdir as kW,readFile as rZ,writeFile as SW,readdir as aZ,rm as y6,stat as bW}from"fs/promises";import{join as M5,dirname as PW}from"path";async function CW($){try{await kW($,{recursive:!0})}catch{}}function tZ($,Z,Y){return M5($,Y,`${Z}.json`)}async function oZ($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await C6(Z)!==$.srcMtime)return!1;return!0}async function F4($,Z,Y,X=D5){if(!X.enabled)return null;let J=L4($,Z),Q=K1.get(J);if(Q){if(await oZ(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;K1.delete(J)}let G=tZ(X.directory,J,Y);if(await M0(G))try{let K=await rZ(G,"utf-8"),z=JSON.parse(K);if(await oZ(z,$,X.maxAge))return z.lastAccessedAt=Date.now(),K1.set(J,z),z.data}catch{}return null}async function V4($,Z,Y,X,J=D5){if(!J.enabled)return;let Q=L4($,Z),G=await k0($),K=await C6($),z={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:L4("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};K1.set(Q,z);let W=tZ(J.directory,Q,X);try{await CW(PW(W)),await SW(W,JSON.stringify(z,null,2))}catch(U){console.warn(`[stx-media] Failed to write cache: ${U}`)}}async function HR($,Z,Y=D5){for(let[X,J]of K1.entries())if(J.src===$)K1.delete(X)}async function w4($,Z=D5){if($==="all")K1.clear();else K1.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=M5(Z.directory,X);try{await y6(J,{recursive:!0,force:!0})}catch{}}}async function LR($=D5){let Z={memoryEntries:K1.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=M5($.directory,Y);try{let J=await aZ(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=M5(X,Q),K=await bW(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function FR($=D5){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=M5($.directory,X);try{let Q=await aZ(J);for(let G of Q){let K=M5(J,G);try{let z=await rZ(K,"utf-8"),W=JSON.parse(z);if(Date.now()-W.createdAt>Y)await y6(K),K1.delete(W.key),Z++}catch{await y6(K).catch(()=>{}),Z++}}}catch{}}return Z}var K1,D5;var v6=P(()=>{o1();K1=new Map,D5={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class R4{config;constructor($={}){this.config={...yW,...$}}async get($,Z){return F4($,Z,"image",this.config)}async set($,Z,Y){return V4($,Z,Y,"image",this.config)}async clear(){return w4("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function x6($){if(!A4)A4=new R4($);else if($)A4.updateConfig($);return A4}async function N4($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return x6(X).get($,Z)}async function T4($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return x6(J).set($,Z,Y)}async function eZ(){return x6().clear()}var yW,A4=null;var f6=P(()=>{v6();yW={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as vW,basename as xW,extname as fW,join as gW}from"path";import{mkdir as hW}from"fs/promises";async function g6(){try{return await import("ts-images")}catch{return null}}function $Y($){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 dW($,Z){let Y=Z?$Y(Z):$Y("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 ZY($,Z,Y){let X=await g6();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await N4($,Z,Y);if(J)return J;try{let Q=vW($);if(!await M0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=dW(Y,Z.preset),K=Y.outputDir||"dist/images",z=Y.baseUrl||"/images";await hW(K,{recursive:!0});let W=await k0(Q),U=xW($,fW($)),q=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:W},B=null;if(Z.transformations&&Z.transformations.length>0)B=await h6(Q,Z.transformations,X);for(let j of q){let O=G[j]||{},L=`${U}-${W}.${j}`,F=gW(K,L);try{let H=await X.optimizeImage({input:B||Q,output:F,format:j,quality:O.quality,progressive:O.progressive});if(H){if(_.variants.push({path:F,url:`${z}/${L}`,width:H.width||0,height:H.height||0,format:j,size:H.outputSize||0}),!_.originalWidth&&H.width)_.originalWidth=H.width,_.originalHeight=H.height}}catch(H){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${j}: ${H}`)}}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 T4($,Z,_,Y),_}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function YY($,Z,Y,X){let J=await g6();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 h6($,Z,Y){let X=Y||await g6();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 XY=P(()=>{o1();f6()});import{resolve as uW,basename as mW,extname as lW,join as cW}from"path";import{mkdir as pW}from"fs/promises";async function iW(){try{return await import("ts-images")}catch{return null}}async function d6($,Z,Y){let X=await iW();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=uW($);if(!await M0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||nW,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",z=Y.baseUrl||"/images";await pW(K,{recursive:!0});let W=await k0(J),U=mW($,lW($)),q=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 O=[];for(let L of Q){let F=`${U}-${L}w-${W}.${j}`,H=cW(K,F),V=`${z}/${F}`;try{let A=q[j]?.quality||80;if(await M0(H)){_.byFormat[j].push({path:H,url:V,width:L,height:0,format:j,size:0}),O.push(`${V} ${L}w`);continue}let w=await X.processImage({input:J,output:H,format:j,quality:A,resize:{width:L}});if(w)_.byFormat[j].push({path:H,url:V,width:L,height:w.height||Math.round(L*(w.height||1)/(w.width||1)),format:j,size:w.outputSize||0}),O.push(`${V} ${L}w`)}catch(A){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${A}`)}}_.srcsets[j]=O.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||sW(Q),_}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function sW($){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 JY($,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 PR($,Z,Y){let X=[];for(let J of Z){let Q=await d6(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:oW(G)})}}return X}function oW($){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 nW;var QY=P(()=>{o1();nW=[320,480,640,768,1024,1280,1536,1920]});var GY={};u(GY,{setCachedImageResult:()=>T4,processImage:()=>ZY,optimizeImage:()=>YY,getCachedImageResult:()=>N4,generateSrcset:()=>JY,generateResponsiveVariants:()=>d6,clearImageCache:()=>eZ,applyTransformations:()=>h6,ImageProcessorCache:()=>R4});var KY=P(()=>{XY();QY();f6()});async function rW(){try{return await Promise.resolve().then(() => (KY(),GY))}catch($){if(!zY)console.warn("[stx-media] Image processor not available, some features disabled:",$),zY=!0;return null}}async function U$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return ZU(X,Y)}if(Y.processedResult?.processed)return c6($,Y.processedResult,Z);if(Y.responsiveVariants)return _Y($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:z,widths:W=s1,dpr:U,formats:q=N5,quality:_=u6,params:B={},placeholder:j="none",placeholderOptions:O={},lazy:L=!0,priority:F=!1,loading:H=F?"eager":D4,decoding:V=M4,fetchpriority:A,objectFit:w,objectPosition:R,crossorigin:N,referrerpolicy:M}=$,T=$.class,D=$.style,E=$.id,I=$.data||{},{isDev:k=!1,baseUrl:S=""}=Z;if(k&&!Z.optimize)return eW($);let b,C,d=E||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{b=await pZ(J,{strategy:j,...O}),C=cZ(d,b,O)}catch{}let f=U!==void 0&&G!==void 0,m;if(f)m=tW($,d,b,Z);else m=await aW($,d,b,Z);let o;if(F){let h0=q.includes("webp")?"webp":q[0],P0=W$(J,W,{...B,q:_},h0),J0=typeof z==="object"?E6(z):z||"100vw";o=`<link rel="preload" as="image" imagesrcset="${P0}" imagesizes="${J0}" />`}let I0=[];if(!WY&&j!=="none")I0.push(S6),WY=!0;if(C)I0.push(C);let q1=L?qY(d):void 0;return{html:m,preloadLink:o,css:I0.length>0?I0.join(`
|
|
1120
|
+
`.trim();T5=new Map});import{createHash as P6}from"crypto";import{readFile as IW,stat as sZ}from"fs/promises";async function S0($){try{let Z=await IW($);return P6("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function qR($){return P6("sha256").update($).digest("hex").slice(0,16)}function nZ($){return P6("sha256").update($).digest("hex").slice(0,16)}function L4($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${nZ($)}-${nZ(Y)}`}async function C6($){try{return(await sZ($)).mtimeMs}catch{return 0}}async function M0($){try{return await sZ($),!0}catch{return!1}}var o1=()=>{};import{mkdir as kW,readFile as rZ,writeFile as SW,readdir as aZ,rm as y6,stat as bW}from"fs/promises";import{join as M5,dirname as PW}from"path";async function CW($){try{await kW($,{recursive:!0})}catch{}}function tZ($,Z,Y){return M5($,Y,`${Z}.json`)}async function oZ($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await C6(Z)!==$.srcMtime)return!1;return!0}async function F4($,Z,Y,X=D5){if(!X.enabled)return null;let J=L4($,Z),Q=K1.get(J);if(Q){if(await oZ(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;K1.delete(J)}let G=tZ(X.directory,J,Y);if(await M0(G))try{let K=await rZ(G,"utf-8"),z=JSON.parse(K);if(await oZ(z,$,X.maxAge))return z.lastAccessedAt=Date.now(),K1.set(J,z),z.data}catch{}return null}async function V4($,Z,Y,X,J=D5){if(!J.enabled)return;let Q=L4($,Z),G=await S0($),K=await C6($),z={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:L4("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};K1.set(Q,z);let W=tZ(J.directory,Q,X);try{await CW(PW(W)),await SW(W,JSON.stringify(z,null,2))}catch(U){console.warn(`[stx-media] Failed to write cache: ${U}`)}}async function HR($,Z,Y=D5){for(let[X,J]of K1.entries())if(J.src===$)K1.delete(X)}async function w4($,Z=D5){if($==="all")K1.clear();else K1.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=M5(Z.directory,X);try{await y6(J,{recursive:!0,force:!0})}catch{}}}async function LR($=D5){let Z={memoryEntries:K1.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=M5($.directory,Y);try{let J=await aZ(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=M5(X,Q),K=await bW(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function FR($=D5){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=M5($.directory,X);try{let Q=await aZ(J);for(let G of Q){let K=M5(J,G);try{let z=await rZ(K,"utf-8"),W=JSON.parse(z);if(Date.now()-W.createdAt>Y)await y6(K),K1.delete(W.key),Z++}catch{await y6(K).catch(()=>{}),Z++}}}catch{}}return Z}var K1,D5;var v6=P(()=>{o1();K1=new Map,D5={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class R4{config;constructor($={}){this.config={...yW,...$}}async get($,Z){return F4($,Z,"image",this.config)}async set($,Z,Y){return V4($,Z,Y,"image",this.config)}async clear(){return w4("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function x6($){if(!A4)A4=new R4($);else if($)A4.updateConfig($);return A4}async function N4($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return x6(X).get($,Z)}async function T4($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return x6(J).set($,Z,Y)}async function eZ(){return x6().clear()}var yW,A4=null;var f6=P(()=>{v6();yW={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as vW,basename as xW,extname as fW,join as gW}from"path";import{mkdir as hW}from"fs/promises";async function g6(){try{return await import("ts-images")}catch{return null}}function $Y($){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 dW($,Z){let Y=Z?$Y(Z):$Y("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 ZY($,Z,Y){let X=await g6();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await N4($,Z,Y);if(J)return J;try{let Q=vW($);if(!await M0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=dW(Y,Z.preset),K=Y.outputDir||"dist/images",z=Y.baseUrl||"/images";await hW(K,{recursive:!0});let W=await S0(Q),U=xW($,fW($)),q=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:W},B=null;if(Z.transformations&&Z.transformations.length>0)B=await h6(Q,Z.transformations,X);for(let j of q){let O=G[j]||{},L=`${U}-${W}.${j}`,F=gW(K,L);try{let H=await X.optimizeImage({input:B||Q,output:F,format:j,quality:O.quality,progressive:O.progressive});if(H){if(_.variants.push({path:F,url:`${z}/${L}`,width:H.width||0,height:H.height||0,format:j,size:H.outputSize||0}),!_.originalWidth&&H.width)_.originalWidth=H.width,_.originalHeight=H.height}}catch(H){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${j}: ${H}`)}}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 T4($,Z,_,Y),_}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function YY($,Z,Y,X){let J=await g6();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 h6($,Z,Y){let X=Y||await g6();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 XY=P(()=>{o1();f6()});import{resolve as uW,basename as mW,extname as lW,join as cW}from"path";import{mkdir as pW}from"fs/promises";async function iW(){try{return await import("ts-images")}catch{return null}}async function d6($,Z,Y){let X=await iW();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=uW($);if(!await M0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||nW,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",z=Y.baseUrl||"/images";await pW(K,{recursive:!0});let W=await S0(J),U=mW($,lW($)),q=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 O=[];for(let L of Q){let F=`${U}-${L}w-${W}.${j}`,H=cW(K,F),V=`${z}/${F}`;try{let A=q[j]?.quality||80;if(await M0(H)){_.byFormat[j].push({path:H,url:V,width:L,height:0,format:j,size:0}),O.push(`${V} ${L}w`);continue}let w=await X.processImage({input:J,output:H,format:j,quality:A,resize:{width:L}});if(w)_.byFormat[j].push({path:H,url:V,width:L,height:w.height||Math.round(L*(w.height||1)/(w.width||1)),format:j,size:w.outputSize||0}),O.push(`${V} ${L}w`)}catch(A){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${A}`)}}_.srcsets[j]=O.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||sW(Q),_}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function sW($){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 JY($,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 PR($,Z,Y){let X=[];for(let J of Z){let Q=await d6(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:oW(G)})}}return X}function oW($){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 nW;var QY=P(()=>{o1();nW=[320,480,640,768,1024,1280,1536,1920]});var GY={};u(GY,{setCachedImageResult:()=>T4,processImage:()=>ZY,optimizeImage:()=>YY,getCachedImageResult:()=>N4,generateSrcset:()=>JY,generateResponsiveVariants:()=>d6,clearImageCache:()=>eZ,applyTransformations:()=>h6,ImageProcessorCache:()=>R4});var KY=P(()=>{XY();QY();f6()});async function rW(){try{return await Promise.resolve().then(() => (KY(),GY))}catch($){if(!zY)console.warn("[stx-media] Image processor not available, some features disabled:",$),zY=!0;return null}}async function U$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return ZU(X,Y)}if(Y.processedResult?.processed)return c6($,Y.processedResult,Z);if(Y.responsiveVariants)return _Y($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:z,widths:W=s1,dpr:U,formats:q=N5,quality:_=u6,params:B={},placeholder:j="none",placeholderOptions:O={},lazy:L=!0,priority:F=!1,loading:H=F?"eager":D4,decoding:V=M4,fetchpriority:A,objectFit:w,objectPosition:R,crossorigin:N,referrerpolicy:M}=$,T=$.class,D=$.style,E=$.id,I=$.data||{},{isDev:k=!1,baseUrl:S=""}=Z;if(k&&!Z.optimize)return eW($);let b,y,d=E||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{b=await pZ(J,{strategy:j,...O}),y=cZ(d,b,O)}catch{}let f=U!==void 0&&G!==void 0,m;if(f)m=tW($,d,b,Z);else m=await aW($,d,b,Z);let o;if(F){let h0=q.includes("webp")?"webp":q[0],C0=W$(J,W,{...B,q:_},h0),J0=typeof z==="object"?E6(z):z||"100vw";o=`<link rel="preload" as="image" imagesrcset="${C0}" imagesizes="${J0}" />`}let I0=[];if(!WY&&j!=="none")I0.push(S6),WY=!0;if(y)I0.push(y);let q1=L?qY(d):void 0;return{html:m,preloadLink:o,css:I0.length>0?I0.join(`
|
|
1121
1121
|
`):void 0,script:q1}}async function aW($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:z,widths:W=s1,formats:U=N5,quality:q=u6,params:_={},lazy:B=!0,priority:j=!1,loading:O=j?"eager":D4,decoding:L=M4,fetchpriority:F,objectFit:H,objectPosition:V,crossorigin:A,referrerpolicy:w}=$,R=$.class,N=$.style,M=$.data||{},T=typeof z==="object"?E6(z):z||"100vw",D=[];for(let k of U){let S=W$(J,W,{..._,q},k),b=I6(k);if(B&&!j)D.push(` <source type="${b}" data-srcset="${S}" data-sizes="${T}" />`);else D.push(` <source type="${b}" srcset="${S}" sizes="${T}" />`)}let E=m6({src:M1(J,{..._,q}),alt:Q,width:G,height:K,loading:j?void 0:O,decoding:L,fetchpriority:j?"high":F,objectFit:H,objectPosition:V,crossorigin:A,referrerpolicy:w,className:UY(R,Y),style:l6(N,H,V,Y),lazy:B&&!j,data:M}),I;if(Y){let k=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;I=`<div id="${Z}" class="stx-img-placeholder" style="${k}">
|
|
1122
1122
|
<picture>
|
|
1123
1123
|
${D.join(`
|
|
@@ -1167,7 +1167,7 @@ ${D.join(`
|
|
|
1167
1167
|
|
|
1168
1168
|
observer.observe(container);
|
|
1169
1169
|
})();
|
|
1170
|
-
`.trim()}function $U($){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,z,W,U]=Q,q=z??W??U??!0;if(G===":"&&typeof q==="string")try{X[K]=JSON.parse(q)}catch{X[K]=q}else switch(K){case"src":X.src=String(q);break;case"alt":X.alt=String(q);break;case"width":X.width=Number(q)||q;break;case"height":X.height=Number(q)||q;break;case"sizes":X.sizes=String(q);break;case"quality":X.quality=Number(q);break;case"placeholder":X.placeholder=q;break;case"lazy":X.lazy=q===!0||q==="true";break;case"priority":X.priority=q===!0||q==="true";break;case"class":X.class=String(q);break;case"style":X.style=String(q);break;case"id":X.id=String(q);break;case"loading":X.loading=q;break;case"decoding":X.decoding=q;break;case"fetchpriority":X.fetchpriority=q;break;case"objectFit":X.objectFit=q;break;case"objectPosition":X.objectPosition=String(q);break;case"crossorigin":X.crossorigin=q;break}}if(!X.src||!X.alt)return null;return X}async function hR($,Z={}){let Y=/<Img\s+[^>]*?\/?>/g,X=[],J=[],Q=[],G=$,K=[],z;while((z=Y.exec($))!==null)K.push({match:z[0],index:z.index});for(let W=K.length-1;W>=0;W--){let{match:U}=K[W],q=$U(U);if(q){let _=await U$(q,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 ZU($,Z){let Y=await rW();if(!Y)return U$({...$,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 _Y($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return c6($,Q,Z)}return U$({...$,process:!1},Z)}async function c6($,Z,Y){let{alt:X,width:J,height:Q,lazy:G=!0,priority:K=!1,objectFit:z,objectPosition:W,crossorigin:U,referrerpolicy:q}=$,_=$.class,B=$.style,j=$.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,O=$.data||{},L=Z.variants||[],F=L.find((
|
|
1170
|
+
`.trim()}function $U($){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,z,W,U]=Q,q=z??W??U??!0;if(G===":"&&typeof q==="string")try{X[K]=JSON.parse(q)}catch{X[K]=q}else switch(K){case"src":X.src=String(q);break;case"alt":X.alt=String(q);break;case"width":X.width=Number(q)||q;break;case"height":X.height=Number(q)||q;break;case"sizes":X.sizes=String(q);break;case"quality":X.quality=Number(q);break;case"placeholder":X.placeholder=q;break;case"lazy":X.lazy=q===!0||q==="true";break;case"priority":X.priority=q===!0||q==="true";break;case"class":X.class=String(q);break;case"style":X.style=String(q);break;case"id":X.id=String(q);break;case"loading":X.loading=q;break;case"decoding":X.decoding=q;break;case"fetchpriority":X.fetchpriority=q;break;case"objectFit":X.objectFit=q;break;case"objectPosition":X.objectPosition=String(q);break;case"crossorigin":X.crossorigin=q;break}}if(!X.src||!X.alt)return null;return X}async function hR($,Z={}){let Y=/<Img\s+[^>]*?\/?>/g,X=[],J=[],Q=[],G=$,K=[],z;while((z=Y.exec($))!==null)K.push({match:z[0],index:z.index});for(let W=K.length-1;W>=0;W--){let{match:U}=K[W],q=$U(U);if(q){let _=await U$(q,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 ZU($,Z){let Y=await rW();if(!Y)return U$({...$,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 _Y($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return c6($,Q,Z)}return U$({...$,process:!1},Z)}async function c6($,Z,Y){let{alt:X,width:J,height:Q,lazy:G=!0,priority:K=!1,objectFit:z,objectPosition:W,crossorigin:U,referrerpolicy:q}=$,_=$.class,B=$.style,j=$.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,O=$.data||{},L=Z.variants||[],F=L.find((y)=>y.format==="jpeg")||L.find((y)=>y.format==="webp")||L[0],H=F?.url||$.src,V=L.filter((y)=>y.format===(F?.format||"jpeg")).map((y)=>`${y.url} ${y.width}w`).join(", "),A=new Map;for(let y of L){if(!A.has(y.format))A.set(y.format,[]);A.get(y.format).push(y)}let w=[],R=["avif","webp","jpeg","png"];for(let y of R){let d=A.get(y);if(d&&d.length>0){let f=d.map((o)=>`${o.url} ${o.width}w`).join(", "),m=I6(y);if(G&&!K)w.push(` <source type="${m}" data-srcset="${f}" />`);else w.push(` <source type="${m}" srcset="${f}" />`)}}let N=[];if(G&&!K){if(N.push(`data-src="${o0(H)}"`),N.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),V)N.push(`data-srcset="${V}"`)}else if(N.push(`src="${o0(H)}"`),V)N.push(`srcset="${V}"`);N.push(`alt="${o0(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(q)N.push(`referrerpolicy="${q}"`);let D=[];if(z)D.push(`object-fit: ${z}`);if(W)D.push(`object-position: ${W}`);if(Z.placeholder&&G)D.push("opacity: 0; transition: opacity 300ms ease-out");if(B)D.push(B);if(D.length>0)N.push(`style="${D.join("; ")}"`);let E=[];if(_)E.push(_);if(Z.placeholder)E.push("stx-img-blur");if(E.length>0)N.push(`class="${E.join(" ")}"`);if(G&&!K)N.push("data-stx-lazy");for(let[y,d]of Object.entries(O))N.push(`data-${y}="${o0(d)}"`);let I;if(Z.placeholder||Z.dominantColor&&$.useDominantColor){let y=Z.placeholder?`background-image: url('${Z.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${Z.dominantColor};`;I=`<div id="${j}" class="stx-img-placeholder" style="${y}">
|
|
1171
1171
|
<picture>
|
|
1172
1172
|
${w.join(`
|
|
1173
1173
|
`)}
|
|
@@ -1181,8 +1181,8 @@ ${w.join(`
|
|
|
1181
1181
|
`):void 0,script:S}}async function _Y($,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 c6($,X,Y)}var zY=!1,u6=80,M4="async",D4="lazy",WY=!1;var BY=P(()=>{k6();iZ()});function YU(){return H0({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}=XU($,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||N5,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},z=Y.__isDev||!1,W=await U$(K,{isDev:z}),U=W.html;if(W.preloadLink)U=W.preloadLink+`
|
|
1182
1182
|
`+U;if(W.css)U+=`
|
|
1183
1183
|
<style>${W.css}</style>`;if(W.script)U+=`
|
|
1184
|
-
<script>${W.script}</script>`;return U},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function XU($,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=JU(X),Q=p6(J[0],Y)||"",G=p6(J[1],Y)||"",K={};if(J[2]){let z=p6(J[2],Y);if(typeof z==="object"&&z!==null)K=z;else if(typeof J[2]==="string")try{K=JSON.parse(J[2])}catch{}}return{src:Q,alt:G,options:K}}function JU($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let z=$[K],W=K>0?$[K-1]:"";if((z==='"'||z==="'"||z==="`")&&W!=="\\"){if(!X)X=!0,J=z;else if(z===J)X=!1,J="";else Y+=z;continue}if(!X){if(z==="{")Q++;if(z==="}")Q--;if(z==="[")G++;if(z==="]")G--;if(z===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=z}if(Y.trim())Z.push(Y.trim());return Z}function p6($,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 jY;var OY=P(()=>{L6();BY();k6();jY=YU()});class I4{config;constructor($={}){this.config={...QU,...$}}async get($,Z){return F4($,Z,"video",this.config)}async set($,Z,Y){return V4($,Z,Y,"video",this.config)}async clear(){return w4("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function i6($){if(!E4)E4=new I4($);else if($)E4.updateConfig($);return E4}async function k4($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return i6(X).get($,Z)}async function S4($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return i6(J).set($,Z,Y)}async function HY(){return i6().clear()}var QU,E4=null;var n6=P(()=>{v6();QU={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as s6,basename as o6,extname as r6,join as b4}from"path";import{mkdir as a6}from"fs/promises";async function t6(){try{return await import("ts-videos")}catch{return null}}async function P4($,Z,Y,X){let J=await t6();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=s6($);if(!await M0(Q))return null;await a6(Y,{recursive:!0});let G=await
|
|
1185
|
-
`)}async function x4($,Z,Y,X,J){let Q=await NY();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=VY($);if(!await M0(G))return null;let K=await
|
|
1184
|
+
<script>${W.script}</script>`;return U},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function XU($,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=JU(X),Q=p6(J[0],Y)||"",G=p6(J[1],Y)||"",K={};if(J[2]){let z=p6(J[2],Y);if(typeof z==="object"&&z!==null)K=z;else if(typeof J[2]==="string")try{K=JSON.parse(J[2])}catch{}}return{src:Q,alt:G,options:K}}function JU($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let z=$[K],W=K>0?$[K-1]:"";if((z==='"'||z==="'"||z==="`")&&W!=="\\"){if(!X)X=!0,J=z;else if(z===J)X=!1,J="";else Y+=z;continue}if(!X){if(z==="{")Q++;if(z==="}")Q--;if(z==="[")G++;if(z==="]")G--;if(z===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=z}if(Y.trim())Z.push(Y.trim());return Z}function p6($,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 jY;var OY=P(()=>{L6();BY();k6();jY=YU()});class I4{config;constructor($={}){this.config={...QU,...$}}async get($,Z){return F4($,Z,"video",this.config)}async set($,Z,Y){return V4($,Z,Y,"video",this.config)}async clear(){return w4("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function i6($){if(!E4)E4=new I4($);else if($)E4.updateConfig($);return E4}async function k4($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return i6(X).get($,Z)}async function S4($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return i6(J).set($,Z,Y)}async function HY(){return i6().clear()}var QU,E4=null;var n6=P(()=>{v6();QU={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as s6,basename as o6,extname as r6,join as b4}from"path";import{mkdir as a6}from"fs/promises";async function t6(){try{return await import("ts-videos")}catch{return null}}async function P4($,Z,Y,X){let J=await t6();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=s6($);if(!await M0(Q))return null;await a6(Y,{recursive:!0});let G=await S0(Q),K=o6($,r6($)),z=Z.format||"webp",W=Z.timestamp||0,U=`${K}-poster-${G}.${z}`,q=b4(Y,U),_=await J.extractThumbnails(Q,{timestamps:[W],width:Z.width||1280,height:Z.height,format:z,quality:Z.quality||85,outputDir:Y,outputPattern:U.replace(`.${z}`,"")});if(_&&_.length>0){let B=_[0];return{path:q,url:`${X}/${U}`,width:B.width||Z.width||1280,height:B.height||720,timestamp:W,size:B.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function C4($,Z,Y,X){let J=await t6();if(!J)return[];try{let Q=s6($);if(!await M0(Q))return[];await a6(Y,{recursive:!0});let G=await S0(Q),K=o6($,r6($)),z=Z.format||"webp",q=(await new J.Input(Q).getInfo()).duration||60,_=Z.count||10,B=Z.interval||q/_,j=[];for(let L=0;L<_&&L*B<q;L++)j.push(L*B);let O=await J.extractThumbnails(Q,{timestamps:j,width:Z.width||320,format:z,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(O&&O.length>0)return O.map((L,F)=>({path:L.path||b4(Y,`${K}-thumb-${G}-${F}.${z}`),url:`${X}/${K}-thumb-${G}-${F}.${z}`,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 LY($,Z,Y,X){let J=await t6();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=s6($);if(!await M0(Q))return null;await a6(Y,{recursive:!0});let G=await S0(Q),K=o6($,r6($)),U=(await new J.Input(Q).getInfo()).duration||60,q=Z.columns||10,_=Z.interval||5,B=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,O=Z.format||"jpeg",L=Math.ceil(U/_),F=Math.ceil(L/q),H=`${K}-sprite-${G}.${O}`,V=b4(Y,H),A=[];for(let R=0;R<L;R++)A.push(R*_);let w=await J.extractThumbnails(Q,{timestamps:A,width:B,height:j,format:O,quality:Z.quality||70,outputDir:b4(Y,".temp")});if(!w||w.length===0)return null;try{let R=await import("ts-images"),N=q*B,M=F*j,T=await R.createSprite({images:w.map((D)=>D.path),columns:q,padding:0,outputPath:V,format:O,quality:Z.quality||70});return{url:`${X}/${H}`,path:V,columns:q,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 e6=P(()=>{o1()});import{resolve as VY,basename as wY,extname as AY,join as r1}from"path";import{mkdir as y4,writeFile as RY}from"fs/promises";async function NY(){try{return await import("ts-videos")}catch{return null}}async function v4($,Z,Y,X,J){let Q=await NY();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=VY($);if(!await M0(G))return null;let K=await S0(G),z=wY($,AY($)),W=r1(Y,`${z}-${K}-hls`);await y4(W,{recursive:!0});let U=Z.length>0?Z:TY,q=J?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,O=[],L=0;for(let V of U){let A=r1(W,V.label);await y4(A,{recursive:!0});let w=`${V.label}.m3u8`,R=r1(A,w);try{let N=await Q.generateHLS(G,{outputDir:A,segmentDuration:q,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(N)O.push({quality:V,url:`${X}/${z}-${K}-hls/${V.label}/${w}`,path:R}),L+=N.segmentCount||Math.ceil(j/q)}catch(N){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${N}`)}}if(O.length===0)return null;let F=r1(W,"master.m3u8"),H=GU(O,X,z,K);return await RY(F,H),{manifestUrl:`${X}/${z}-${K}-hls/master.m3u8`,manifestPath:F,playlists:O,segmentCount:L,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function GU($,Z,Y,X){let J=["#EXTM3U","#EXT-X-VERSION:3"];for(let Q of $){let{quality:G}=Q,K=G.bitrate+(G.audioBitrate||128000),z=`${G.width}x${G.height||Math.round(G.width*9/16)}`;J.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${z},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return J.join(`
|
|
1185
|
+
`)}async function x4($,Z,Y,X,J){let Q=await NY();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=VY($);if(!await M0(G))return null;let K=await S0(G),z=wY($,AY($)),W=r1(Y,`${z}-${K}-dash`);await y4(W,{recursive:!0});let U=Z.length>0?Z:TY,q=J?.segmentDuration||4,_=J?.minBufferTime||2,O=(await new Q.Input(G).getInfo()).duration||0,L=[],F=[];for(let w of U){let R=r1(W,w.label);await y4(R,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:R,segmentDuration:q,width:w.width,height:w.height,videoBitrate:w.bitrate,audioBitrate:w.audioBitrate})){if(L.push({bandwidth:w.bitrate,width:w.width,height:w.height||Math.round(w.width*9/16),url:`${X}/${z}-${K}-dash/${w.label}/video`}),w.audioBitrate)F.push({bandwidth:w.audioBitrate,url:`${X}/${z}-${K}-dash/${w.label}/audio`})}}catch(N){console.warn(`[stx-media] Failed to generate DASH for ${w.label}: ${N}`)}}if(L.length===0)return null;let H=r1(W,"manifest.mpd"),V=KU(L,F,O,q,_);await RY(H,V);let A=[{type:"video",representations:L}];if(F.length>0)A.push({type:"audio",representations:F});return{manifestUrl:`${X}/${z}-${K}-dash/manifest.mpd`,manifestPath:H,adaptationSets:A,duration:O}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function KU($,Z,Y,X,J){let Q=FY(Y),G=FY(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 @@ ${w.join(`
|
|
|
1208
1208
|
</Representation>
|
|
1209
1209
|
`}K+=` </AdaptationSet>
|
|
1210
1210
|
`}return K+=` </Period>
|
|
1211
|
-
</MPD>`,K}function FY($){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 TY;var $9=P(()=>{o1();TY=[{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 MY,basename as zU,extname as WU,join as UU}from"path";import{mkdir as qU}from"fs/promises";async function DY(){try{return await import("ts-videos")}catch{return null}}function _U($){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 BU($){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 Z9($){let Z=await DY();if(!Z)return null;try{let Y=MY($),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 EY($,Z,Y,X){let J=await DY();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await k4($,Z,Y);if(Q)return Q;try{let G=MY($);if(!await M0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",z=Y.baseUrl||"/videos";await qU(K,{recursive:!0});let W=await
|
|
1211
|
+
</MPD>`,K}function FY($){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 TY;var $9=P(()=>{o1();TY=[{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 MY,basename as zU,extname as WU,join as UU}from"path";import{mkdir as qU}from"fs/promises";async function DY(){try{return await import("ts-videos")}catch{return null}}function _U($){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 BU($){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 Z9($){let Z=await DY();if(!Z)return null;try{let Y=MY($),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 EY($,Z,Y,X){let J=await DY();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await k4($,Z,Y);if(Q)return Q;try{let G=MY($);if(!await M0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",z=Y.baseUrl||"/videos";await qU(K,{recursive:!0});let W=await S0(G),U=zU($,WU($)),q={src:$,processed:!0,hash:W};X?.({percentage:5,stage:"analyzing"}),q.metadata=await Z9(G)||void 0;let _={};if(Z.quality)_.bitrate=_U(Z.quality);if(Z.platform)Object.assign(_,BU(Z.platform));if(Z.transcode)Object.assign(_,Z.transcode);if(Object.keys(_).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let B=`${U}-${W}.mp4`,j=UU(K,B);try{let O=await jU(G,j,_,J,(L)=>X?.({percentage:10+L*0.5,stage:"transcoding"}));if(O)q.transcoded={path:j,url:`${z}/${B}`,duration:O.duration,size:O.size,video:{codec:_.codec||"h264",width:O.width,height:O.height,bitrate:O.bitrate,frameRate:O.frameRate},audio:O.audioCodec?{codec:_.audioCodec||"aac",bitrate:_.audioBitrate||128000,sampleRate:_.sampleRate||48000,channels:_.channels||2}:void 0}}catch(O){q.errors=q.errors||[],q.errors.push(`Transcoding failed: ${O}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let B=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await P4(G,B,K,z);if(j)q.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let B=await C4(G,Y.thumbnails,K,z);if(B.length>0)q.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 v4(G,B.qualities||Y.streaming?.defaultQualities||[],K,z);if(j)q.streaming={...q.streaming,hls:j}}if(B.format==="dash"){let j=await x4(G,B.qualities||Y.streaming?.defaultQualities||[],K,z);if(j)q.streaming={...q.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await S4($,Z,q,Y),q}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function jU($,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 IY=P(()=>{o1();n6();e6();$9()});var kY={};u(kY,{setCachedVideoResult:()=>S4,processVideo:()=>EY,getCachedVideoResult:()=>k4,generateThumbnails:()=>C4,generateSpriteSheet:()=>LY,generatePoster:()=>P4,generateHLSManifest:()=>v4,generateDASHManifest:()=>x4,clearVideoCache:()=>HY,analyzeVideo:()=>Z9,VideoProcessorCache:()=>I4});var SY=P(()=>{IY();e6();$9();n6()});async function PY(){try{return await Promise.resolve().then(() => (SY(),kY))}catch($){if(!bY)console.warn("[stx-media] Video processor not available, some features disabled:",$),bY=!0;return null}}async function f4($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return wU(X,Y)}if(Y.processedResult?.processed)return xY($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await AU(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:z,controls:W=CY,autoplay:U=!1,muted:q=!1,loop:_=!1,preload:B=yY,playsinline:j=!0,lazy:O=!0,player:L="native",type:F,width:H,height:V,crossorigin:A,disablePictureInPicture:w=!1,disableRemotePlayback:R=!1}=$,N=J||K,M=$.class,T=$.style,D=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(L==="ts-video")return LU($,Z);if(F&&F!=="video")return HU(Q||"",F,$);let E=G.length>0?G:Q?[{src:Q,type:vY(Q)}]:[],I=[`id="${D}"`];if(W)I.push("controls");if(U)I.push("autoplay");if(q)I.push("muted");if(_)I.push("loop");if(j)I.push("playsinline");if(w)I.push("disablepictureinpicture");if(R)I.push("disableremoteplayback");if(A)I.push(`crossorigin="${A}"`);if(O){if(I.push(`data-preload="${B}"`),I.push('preload="none"'),N)I.push(`data-poster="${V0(N)}"`);I.push("data-stx-lazy")}else if(I.push(`preload="${B}"`),N)I.push(`poster="${V0(N)}"`);if(H)I.push(`width="${H}"`);if(V)I.push(`height="${V}"`);if(M)I.push(`class="${V0(M)}"`);if(T)I.push(`style="${V0(T)}"`);let k=E.map((y)=>{return` <source ${O?`data-src="${V0(y.src)}"`:`src="${V0(y.src)}"`} type="${y.type}"${y.media?` media="${y.media}"`:""} />`}).join(`
|
|
1212
1212
|
`),S=`<video ${I.join(" ")}>
|
|
1213
1213
|
${k}
|
|
1214
1214
|
Your browser does not support the video tag.
|
|
@@ -2317,7 +2317,7 @@ else { this.removeAttribute('${I}'); }`:`this.setAttribute('${I}', ${D.type==="o
|
|
|
2317
2317
|
}
|
|
2318
2318
|
else {
|
|
2319
2319
|
this.removeAttribute('${I}');
|
|
2320
|
-
}`:"",b=D.observer?`this.${D.observer}(value, oldValue);`:"",
|
|
2320
|
+
}`:"",b=D.observer?`this.${D.observer}(value, oldValue);`:"",y=D.render!==!1?"this._scheduleRender();":"";return`
|
|
2321
2321
|
get ${T}(): ${E} {
|
|
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
|
-
${
|
|
2330
|
+
${y}
|
|
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 QX($,Z,Y,X){if(Z.length<1)return a("WebComponent","@webcomponent directive requires at least the tag name parameter",c.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[D1.join(D1.dirname(X),G,`${J}.stx`),D1.join(process.cwd(),G,`${J}.stx`),D1.join(D1.dirname(X),`${J}.stx`)],z=null;for(let q of K)if(await i(q)){z=await Bun.file(q).text();break}if(!z)return a("WebComponent",`Component file not found: ${J}.stx`,c.FILE_NOT_FOUND);let W=Wq(z,J);return`<script type="module">
|
|
2935
2935
|
${Uq(W)}
|
|
2936
|
-
</script>`}var O9;var GX=P(()=>{O1();F0();O9={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var KX={};u(KX,{timingPlugin:()=>Oq,pluginManager:()=>qq,definePlugin:()=>n4,debugPlugin:()=>jq,createVariablesPlugin:()=>Hq,createFilterPlugin:()=>Bq,createDirectivePlugin:()=>_q,PluginManager:()=>L9});function n4($){return $}class L9{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 _q($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function Bq($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function Hq($){return n4({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var qq,jq,Oq;var zX=P(()=>{qq=new L9;jq=n4({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)}}),Oq=n4({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 UX={};u(UX,{validateConfig:()=>wq,loadStxConfig:()=>o4,defineStxConfig:()=>Vq,defaultConfig:()=>e1,config:()=>V9});import F9 from"fs";import S0 from"path";import{loadConfigWithResult as Lq}from"bunfig";function Fq($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=S0.join(process.cwd(),"resources","views"),J=S0.join(process.cwd(),"resources","layouts");if(F9.existsSync(X)&&F9.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=S0.join(process.cwd(),"resources","views","pages");if(F9.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function o4($){if(!$){if(S5)return S5;if(s4)return s4}let Z=$?S0.resolve($):process.cwd(),Y=WX.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await Lq({name:"stx",alias:"ui",cwd:Z,defaultConfig:e1,verbose:!1})).config,G=Fq(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!S0.isAbsolute(Q.partialsDir))Q.partialsDir=S0.join(K,Q.partialsDir);if(Q.componentsDir&&!S0.isAbsolute(Q.componentsDir))Q.componentsDir=S0.join(K,Q.componentsDir);if(Q.layoutsDir&&!S0.isAbsolute(Q.layoutsDir))Q.layoutsDir=S0.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (zX(),KX)),z=[],W=[];for(let U of Q.plugins){let q=typeof U==="string"?U:U[0],_=typeof U==="string"?{}:U[1]||{};try{let B,j;try{B=await import(q),j=S0.dirname(s.resolve(q))}catch{let L=S0.resolve(process.cwd(),q);B=await import(L),j=S0.dirname(L)}let O=B.default||B;if(K.register(O,Q),O.components){let L=S0.resolve(j,O.components);z.push(L)}if(O.pages){let L=S0.resolve(j,O.pages),F=_.path||"/";W.push({dir:L,prefix:F})}if(O.setup){let L={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,H)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=H},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:j,config:Q};await O.setup(_,L)}console.log(`[stx] Plugin loaded: ${O.name||q}`)}catch(B){console.warn(`[stx] Failed to load plugin ${q}:`,B.message)}}Q._pluginComponentDirs=z,Q._pluginPageDirs=W}return Q})();if(WX.set(Z,X),!$)s4=X,X.then((J)=>{S5=J}).catch(()=>{});return X}function Vq($){return $}function wq($){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 e1,S5=null,WX,s4=null,V9;var B$=P(()=>{G4();O6();A6();R6();M6();OY();X9();dY();j9();GX();e1={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:T6,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:QX,hasEndTag:!1,description:"Include a web component in the template"},J4,Q4,_9,B9,q6,B6,j6,_6,CZ,xZ,jY,Y9,...J9],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}};WX=new Map;V9=new Proxy(e1,{get($,Z){if(S5&&Z in S5)return S5[Z];if(!s4)o4().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});var kq={};u(kq,{resetCssCache:()=>Mq,resetCrosswindCache:()=>Dq,rebuildCrosswindCSS:()=>Eq,loadCrosswindConfig:()=>T9,loadCrosswind:()=>N9,injectCrosswindCSS:()=>M9,getCachedCSS:()=>Iq,generateCrosswindCSS:()=>jX,extractClassNames:()=>BX,buildCrosswindCSS:()=>_X});import a4 from"fs";import X0 from"path";function R9($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function w9($,Z){if(H1.has($))H1.delete($);else if(H1.size>=Aq)H1.delete(H1.keys().next().value);H1.set($,Z)}async function Rq($){if(!E1)return null;try{let Z=Bun.file(X0.join(E1,`cw-${R9($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function Nq($,Z){if(!E1)return;try{if(!a4.existsSync(E1))a4.mkdirSync(E1,{recursive:!0});await Bun.write(X0.join(E1,`cw-${R9($)}.css`),Z)}catch{}}async function qX($){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 Tq(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==X0.dirname(Y))$.push(X0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(X0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=X0.dirname(Y);if(Z){let X=[X0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function N9(){if(A9)return P5;A9=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await qX(Y);if(X){if(P5=X,!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} CSS engine loaded`);return P5}}let Z=Tq();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await qX(Y);if(X){if(P5=X,!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} CSS engine loaded from ${X0.dirname(X0.dirname(Y))}`);return P5}}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 Mq(){H1.clear()}function Dq(){P5=null,A9=!1,a0=null,j$="",H1.clear(),r4=null}async function T9($){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=X0.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 _X($){if(b5)return j$;b5=!0;try{let Z=await N9();if(!Z||!Z.build)return b5=!1,"";if(!a0)a0=await T9($);if(!a0)return b5=!1,"";let Y=Z.defaultConfig?.theme||{},X=a0.theme||{},J={...Z.defaultConfig,...a0,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(j$=G.css,console.log(`${K0.cyan}[Crosswind]${K0.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let z=X0.isAbsolute(J.output)?J.output:X0.join($,J.output),W=X0.dirname(z);if(!a4.existsSync(W))a4.mkdirSync(W,{recursive:!0});await Bun.write(z,G.css)}return b5=!1,G.css}catch(Z){return console.error(`${K0.red}[Crosswind]${K0.reset} Build error:`,Z),b5=!1,j$}}async function Eq($){a0=null,await _X($)}function Iq(){return j$}function BX($){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 z of K.slice(1,-1).split(/\s+/))if(z.trim())Z.add(z.trim())}Q=J.exec($)}return Z}async function jX($,Z){try{let Y=await N9();if(!Y)return"";let X=BX($);if(X.size===0)return"";let J=Z?X0.resolve(Z):process.cwd();if(!E1)E1=X0.join(J,".stx/cache");let Q=[...X].sort().join(" "),G=`${r4||"default"}::${Q}`,K=H1.get(G);if(K!==void 0)return w9(G,K),K;let z=await Rq(G);if(z!==null)return w9(G,z),z;if(!a0){let w=null;try{let{loadStxConfig:R}=await Promise.resolve().then(() => (B$(),UX)),N=await R(J);if(N.css)if(typeof N.css==="string"){let M=X0.isAbsolute(N.css)?N.css:X0.resolve(J,N.css);if(await Bun.file(M).exists()){let T=await import(M);w=T.default||T,console.log(`${K0.green}[Crosswind]${K0.reset} Loaded config from stx.config.ts \u2192 ${N.css}`)}}else{if(w={...N.css,content:N.css.content||[],preflight:N.css.preflight??!0,minify:N.css.minify??!1},N.css.config){let M=X0.isAbsolute(N.css.config)?N.css.config:X0.resolve(J,N.css.config);if(await Bun.file(M).exists()){let T=await import(M);w={...T.default||T,...w}}}console.log(`${K0.green}[Crosswind]${K0.reset} Using inline CSS config from stx.config.ts`)}}catch{}a0=w||await T9(J);try{r4=R9(JSON.stringify(a0??{}))}catch{r4="unhashable"}}let W=Y.defaultConfig||Y.config,U=a0||{},q=W.theme||{},B=(U.theme||{}).extend||{},j={...q};if(Object.keys(B).length>0)j.extend=B;let O=[...W.safelist||[],...U.safelist||[]],L={...W,...U,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:O},F=new Y.CSSGenerator(L);for(let w of O)F.generate(w);for(let w of X)F.generate(w);let H=F.toCSS(!0,!1),V=L.shortcuts||U.shortcuts||{};for(let[w,R]of Object.entries(V)){if(!X.has(w)&&!O.includes(w))continue;let N=R.split(/\s+/).filter(Boolean);for(let M of N)F.generate(M)}H=F.toCSS(!0,!1);let A=H.split(`
|
|
2937
|
-
`);for(let[w,R]of Object.entries(V)){if(!X.has(w)&&!O.includes(w))continue;let N=R.split(/\s+/).filter(Boolean),M=[],T=[];for(let D of N){let E=D.startsWith("dark:"),S=`.${(E?D.slice(5):D).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<A.length;b++){let
|
|
2936
|
+
</script>`}var O9;var GX=P(()=>{O1();F0();O9={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var KX={};u(KX,{timingPlugin:()=>Oq,pluginManager:()=>qq,definePlugin:()=>n4,debugPlugin:()=>jq,createVariablesPlugin:()=>Hq,createFilterPlugin:()=>Bq,createDirectivePlugin:()=>_q,PluginManager:()=>L9});function n4($){return $}class L9{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 _q($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function Bq($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function Hq($){return n4({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var qq,jq,Oq;var zX=P(()=>{qq=new L9;jq=n4({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)}}),Oq=n4({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 UX={};u(UX,{validateConfig:()=>wq,loadStxConfig:()=>o4,defineStxConfig:()=>Vq,defaultConfig:()=>e1,config:()=>V9});import F9 from"fs";import b0 from"path";import{loadConfigWithResult as Lq}from"bunfig";function Fq($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=b0.join(process.cwd(),"resources","views"),J=b0.join(process.cwd(),"resources","layouts");if(F9.existsSync(X)&&F9.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=b0.join(process.cwd(),"resources","views","pages");if(F9.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function o4($){if(!$){if(S5)return S5;if(s4)return s4}let Z=$?b0.resolve($):process.cwd(),Y=WX.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await Lq({name:"stx",alias:"ui",cwd:Z,defaultConfig:e1,verbose:!1})).config,G=Fq(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!b0.isAbsolute(Q.partialsDir))Q.partialsDir=b0.join(K,Q.partialsDir);if(Q.componentsDir&&!b0.isAbsolute(Q.componentsDir))Q.componentsDir=b0.join(K,Q.componentsDir);if(Q.layoutsDir&&!b0.isAbsolute(Q.layoutsDir))Q.layoutsDir=b0.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (zX(),KX)),z=[],W=[];for(let U of Q.plugins){let q=typeof U==="string"?U:U[0],_=typeof U==="string"?{}:U[1]||{};try{let B,j;try{B=await import(q),j=b0.dirname(s.resolve(q))}catch{let L=b0.resolve(process.cwd(),q);B=await import(L),j=b0.dirname(L)}let O=B.default||B;if(K.register(O,Q),O.components){let L=b0.resolve(j,O.components);z.push(L)}if(O.pages){let L=b0.resolve(j,O.pages),F=_.path||"/";W.push({dir:L,prefix:F})}if(O.setup){let L={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,H)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=H},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:j,config:Q};await O.setup(_,L)}console.log(`[stx] Plugin loaded: ${O.name||q}`)}catch(B){console.warn(`[stx] Failed to load plugin ${q}:`,B.message)}}Q._pluginComponentDirs=z,Q._pluginPageDirs=W}return Q})();if(WX.set(Z,X),!$)s4=X,X.then((J)=>{S5=J}).catch(()=>{});return X}function Vq($){return $}function wq($){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 e1,S5=null,WX,s4=null,V9;var B$=P(()=>{G4();O6();A6();R6();M6();OY();X9();dY();j9();GX();e1={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:T6,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:QX,hasEndTag:!1,description:"Include a web component in the template"},J4,Q4,_9,B9,q6,B6,j6,_6,CZ,xZ,jY,Y9,...J9],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}};WX=new Map;V9=new Proxy(e1,{get($,Z){if(S5&&Z in S5)return S5[Z];if(!s4)o4().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});var kq={};u(kq,{resetCssCache:()=>Mq,resetCrosswindCache:()=>Dq,rebuildCrosswindCSS:()=>Eq,loadCrosswindConfig:()=>T9,loadCrosswind:()=>N9,injectCrosswindCSS:()=>M9,getCachedCSS:()=>Iq,generateCrosswindCSS:()=>jX,extractClassNames:()=>BX,buildCrosswindCSS:()=>_X});import a4 from"fs";import X0 from"path";function R9($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function w9($,Z){if(H1.has($))H1.delete($);else if(H1.size>=Aq)H1.delete(H1.keys().next().value);H1.set($,Z)}async function Rq($){if(!E1)return null;try{let Z=Bun.file(X0.join(E1,`cw-${R9($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function Nq($,Z){if(!E1)return;try{if(!a4.existsSync(E1))a4.mkdirSync(E1,{recursive:!0});await Bun.write(X0.join(E1,`cw-${R9($)}.css`),Z)}catch{}}async function qX($){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 Tq(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==X0.dirname(Y))$.push(X0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(X0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=X0.dirname(Y);if(Z){let X=[X0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function N9(){if(A9)return P5;A9=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await qX(Y);if(X){if(P5=X,!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} CSS engine loaded`);return P5}}let Z=Tq();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await qX(Y);if(X){if(P5=X,!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} CSS engine loaded from ${X0.dirname(X0.dirname(Y))}`);return P5}}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 Mq(){H1.clear()}function Dq(){P5=null,A9=!1,a0=null,j$="",H1.clear(),r4=null}async function T9($){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=X0.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 _X($){if(b5)return j$;b5=!0;try{let Z=await N9();if(!Z||!Z.build)return b5=!1,"";if(!a0)a0=await T9($);if(!a0)return b5=!1,"";let Y=Z.defaultConfig?.theme||{},X=a0.theme||{},J={...Z.defaultConfig,...a0,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(j$=G.css,console.log(`${K0.cyan}[Crosswind]${K0.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let z=X0.isAbsolute(J.output)?J.output:X0.join($,J.output),W=X0.dirname(z);if(!a4.existsSync(W))a4.mkdirSync(W,{recursive:!0});await Bun.write(z,G.css)}return b5=!1,G.css}catch(Z){return console.error(`${K0.red}[Crosswind]${K0.reset} Build error:`,Z),b5=!1,j$}}async function Eq($){a0=null,await _X($)}function Iq(){return j$}function BX($){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 z of K.slice(1,-1).split(/\s+/))if(z.trim())Z.add(z.trim())}Q=J.exec($)}return Z}async function jX($,Z){try{let Y=await N9();if(!Y)return"";let X=BX($);if(X.size===0)return"";let J=Z?X0.resolve(Z):process.cwd();if(!E1)E1=X0.join(J,".stx/cache");let Q=[...X].sort().join(" "),G=`${r4||"default"}::${Q}`,K=H1.get(G);if(K!==void 0)return w9(G,K),K;let z=await Rq(G);if(z!==null)return w9(G,z),z;if(!a0){let w=null;try{let{loadStxConfig:R}=await Promise.resolve().then(() => (B$(),UX)),N=await R(J);if(N.css)if(typeof N.css==="string"){let M=X0.isAbsolute(N.css)?N.css:X0.resolve(J,N.css);if(await Bun.file(M).exists()){let T=await import(M);w=T.default||T,console.log(`${K0.green}[Crosswind]${K0.reset} Loaded config from stx.config.ts \u2192 ${N.css}`)}}else{if(w={...N.css,content:N.css.content||[],preflight:N.css.preflight??!0,minify:N.css.minify??!1},N.css.config){let M=X0.isAbsolute(N.css.config)?N.css.config:X0.resolve(J,N.css.config);if(await Bun.file(M).exists()){let T=await import(M);w={...T.default||T,...w}}}console.log(`${K0.green}[Crosswind]${K0.reset} Using inline CSS config from stx.config.ts`)}}catch{}a0=w||await T9(J);try{r4=R9(JSON.stringify(a0??{}))}catch{r4="unhashable"}}let W=Y.defaultConfig||Y.config,U=a0||{},q=W.theme||{},B=(U.theme||{}).extend||{},j={...q};if(Object.keys(B).length>0)j.extend=B;let O=[...W.safelist||[],...U.safelist||[]],L={...W,...U,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:O},F=new Y.CSSGenerator(L);for(let w of O)F.generate(w);for(let w of X)F.generate(w);let H=F.toCSS(!0,!1),V=L.shortcuts||U.shortcuts||{};for(let[w,R]of Object.entries(V)){if(!X.has(w)&&!O.includes(w))continue;let N=R.split(/\s+/).filter(Boolean);for(let M of N)F.generate(M)}H=F.toCSS(!0,!1);let A=H.split(`
|
|
2937
|
+
`);for(let[w,R]of Object.entries(V)){if(!X.has(w)&&!O.includes(w))continue;let N=R.split(/\s+/).filter(Boolean),M=[],T=[];for(let D of N){let E=D.startsWith("dark:"),S=`.${(E?D.slice(5):D).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<A.length;b++){let y=A[b].trim();if(y===`${S} {`||y.startsWith(`${S} {`)){let d=b,f="";while(d<A.length){if(f+=A[d],A[d].includes("}"))break;d++}let m=f.match(/\{([^}]+)\}/);if(m)if(E)T.push(m[1].trim());else M.push(m[1].trim());break}}}if(M.length)H+=`
|
|
2938
2938
|
.${w} { ${M.join(" ")} }`;if(T.length)H+=`
|
|
2939
2939
|
@media (prefers-color-scheme: dark) { .dark .${w} { ${T.join(" ")} } }`}return w9(G,H),Nq(G,H),H}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function M9($,Z){let Y=await jX($,Z);if(!Y)return $;let X=`<style data-crosswind="generated">
|
|
2940
2940
|
${Y}
|
|
@@ -3770,7 +3770,7 @@ ${Y}
|
|
|
3770
3770
|
</script>`}function yX($,Z,Y){if(CX=0,!X_($))return $;let X=rq($);if(X.length===0)return $;let J=Y_($,X),Q=Z_(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 Y_($,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*["']${$7(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*["']${$7(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*"${$7(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*'${$7(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 X_($){return/x-data\s*=\s*["']/.test($)}var CX=0,oq=0;var vX=P(()=>{G1()});import J_ from"fs";import k9 from"path";import{createHighlighter as Q_}from"ts-syntax-highlighter";async function G_($,Z={}){try{if(!await i($))throw Error(`Markdown file not found: ${$}`);let X=(await J_.promises.stat($)).mtime.getTime();if(Z.cache&&S9.has($)){let q=S9.get($);if(q.updatedAt>=X)return{content:q.content,data:q.data}}let J=await Bun.file($).text(),{data:Q,content:G}=hZ(J),K=Z.markdown||V9.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},W=z$(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)W=await K_(W,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:W,data:Q||{}};if(Z.cache)S9.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:Q0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function K_($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!Z7)try{Z7=await Q_({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,z,W,U)=>{let q=U.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),_=W||(Y?"text":"");if(!_)return K;try{if(!Z7.getSupportedLanguages().includes(_))return K;return(await Z7.highlight(q,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${W}:`,B)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[z,W,U,q]=K,_=await J(z,W,U,q);Q=Q.replace(z,_)}return Q}async function xX($,Z,Y="",X={}){return await z_($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,z,W)=>{try{let U=K;if(!k9.isAbsolute(K))U=k9.resolve(k9.dirname(Y),K);let q={};if(z)try{try{q=JSON.parse(z)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let H=z.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of H){let A=V.indexOf(":");if(A>0){let w=V.substring(0,A).trim(),R=V.substring(A+1).trim(),N=R.startsWith('"')&&R.endsWith('"'),M=R.startsWith("'")&&R.endsWith("'");if(N||M)R=R.substring(1,R.length-1);q[w]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await G_(U,X),j={...Z,...B,...q},O=_,L=/\{\{([^}]+)\}\}/g;return O=O.replace(L,(F,H)=>{let V=H.trim();return j[V]!==void 0?String(j[V]):F}),O}catch(U){let q=U instanceof Error?U.message:String(U);return Q0("Markdown File",`Error including markdown file: ${q}`,Y,$,W,G)}})}async function z_($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],z=J.index,W=J;X.push(Y(...W).then((U)=>({match:K,replacement:U,index:z})))}let Q=await Promise.all(X);Q.sort((K,z)=>z.index-K.index);let G=$;for(let{match:K,replacement:z}of Q)G=G.replace(K,()=>z);return G}var S9,Z7=null;var fX=P(()=>{B$();F0();S9=new Map});function k1($,Z){try{let Y=$.trim();if(Z0(Y))return Y0(Y,Object.keys(Z))(...Object.values(Z));else return $0(Y,Z)}catch{return!1}}var gX=P(()=>{R0()});class Y7{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 w0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,z=!1;while(Q<$.length){let W=$[Q];if(G&&z){z=!1,Q++;continue}if(G&&W==="\\"){z=!0,Q++;continue}if(z=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,Q++;continue}if(W===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&W==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&W==="}"){K--,Q++;continue}if(W==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(W===Z)J++;else if(W===Y){if(J--,J===0)return Q}Q++}return-1}function hX($,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 b9($){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 S1($,Z){let Y=W_($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function W_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=w0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function $5($,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 z=G.exec($),W=K.exec($),U=z?z.index:1/0,q=W?W.index:1/0;if(U<q)J++,Q=U+z[0].length;else if(q<1/0){if(J--,J===0)return q;Q=q+W[0].length}else break}return-1}function dX($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=S1($,X);if(!J)return null;let Q=J.endPos,G=$5($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U="if",q=J.expression,_=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let O=K.substring(j);if(/^@if\s*\(/.test(O)){B++,W++;continue}if(/^@endif(?![a-z])/.test(O)){B--,W+=6;continue}if(B===0){let L=O.match(/^@elseif\s*/);if(L){z.push({type:U,condition:q,content:K.substring(_,W),start:Q+_,end:Q+W});let F=W+L[0].length,H=S1(K,F);if(!H){W++;continue}U="elseif",q=H.expression,W=H.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(O)){z.push({type:U,condition:q,content:K.substring(_,W),start:Q+_,end:Q+W}),U="else",q=void 0,W+=5,_=W;continue}}W++}return z.push({type:U,condition:q,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function O$($){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=dX($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function X7($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((O)=>Q.index>O.start&&Q.index<O.end)){Q=J.exec($);continue}let K=Q.index,z=K+Q[0].length-1,W=w0($,"(",")",z);if(W===-1){Q=J.exec($);continue}let U=$.slice(z+1,W),q=W+1,_=$5($,Z,Y,q);if(_===-1){Q=J.exec($);continue}let B=$.slice(q,_),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 P9($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=S1($,X);if(!J)return null;let Q=J.endPos,G=$5($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U=null,q=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(q++,U)U.content+=B[0];W+=B[0].length;continue}if(j){if(q--,U)U.content+=j[0];W+=j[0].length;continue}if(q>0){if(U)U.content+=K[W];W++;continue}let O=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(O&&_.startsWith("@case")){if(U)z.push(U);let H=W+O[0].length,V=S1(K,H);if(!V){W++;continue}U={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(U)z.push(U);U={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(U)U.content+=K[W];W++}}if(U)z.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:z,start:Z,end:G+10}}var uX=()=>{};function U_($){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)==="{{{"?"{{{":"{!!":"{{",z=Q?K==="{{{"?"}}}":"!!}":"}}",W=G+K.length,U=q_($,W,z);if(U===-1){Y=G+1;continue}let q=$.slice(W,U).trim(),_=U+z.length;Z.push({fullMatch:$.slice(G,_),expression:q,start:G,end:_,isRaw:Q}),Y=_}return Z}function q_($,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 __($){let Z=b9($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=B_(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function B_($){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=w0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=cX(G);return{name:X,args:K}}function cX($){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 j_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=w0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function C9($){let Z=[],X=new Y7($).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 z=K.value;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let q=J<X.length?X[J].start:$.length,_=mX(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(q,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(W.type==="PUNCTUATION"&&(W.value==="{"||W.value==="[")){let U=W.start,q=W.value==="{"?"}":"]",_=w0($,W.value,q,U);if(_!==-1){let B=$.slice(U,_+1);if(J=lX(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,O=mX(X,J,$);J=O.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,O.endPos)}; ${z} ${B} = ${L}`,exported:G,start:K.start,end:O.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let z=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;J++;let q=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){q=X[J].start;break}J++}if(q!==-1){let _=w0($,"{","}",q);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(z,_+1).replace(/^export\s+/,""),exported:G,start:z,end:_+1}),J=lX(X,_+1)}}}else J++}return Z}function mX($,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 lX($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var pX=()=>{};var H$=P(()=>{uX();pX()});function O_($,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=P9(X,G);if(!K)break;try{let z;if(Z0(K.expression))z=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else z=$0(K.expression,Z);let W="",U=!1;for(let q of K.cases)if(q.type==="default"){if(!U)W=q.content.trim()}else try{let _;if(q.value&&Z0(q.value))_=Y0(q.value,Object.keys(Z))(...Object.values(Z));else if(q.value)_=$0(q.value,Z);if(z===_){W=q.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+W+X.substring(K.end),J=!0}catch(z){let W=z instanceof Error?z.message:String(z),U=a("Switch",`Error evaluating @switch expression: ${W}`,c.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function Z5($,Z,Y){let X=$;X=O_(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,z=S1(X,K+7);if(!z)break;let W=z.endPos,U=$5(X,"unless","endunless",W);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 q=X.slice(W,U),_=z.expression,B=-1;{let O=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,H=/@else(?![a-z])/g,V=[],A;while((A=L.exec(q))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(q))!==null)V.push({pos:A.index,type:"close"});while((A=H.exec(q))!==null)V.push({pos:A.index,type:"else"});V.sort((w,R)=>w.pos-R.pos);for(let w of V)if(w.type==="open")O++;else if(w.type==="close")O--;else if(w.type==="else"&&O===0){B=w.pos;break}}let j;if(B!==-1){let O=q.slice(0,B),L=q.slice(B+5);j=`@if (${_})${L}@else ${O}@endif`}else j=`@if (!(${_}))${q}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=v9(X,Z,Y),X=x9(X,Z,Y),X=y9(X,Z);let J=()=>{let Q=O$(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let z="",W=!1;for(let U of K.branches){if(W)break;if(U.type==="else")z=U.content,W=!0;else try{let q;if(U.condition&&Z0(U.condition))q=Y0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)q=$0(U.condition,Z);if(q)z=U.content,W=!0}catch(q){z=a(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${q instanceof Error?q.message:String(q)}`,c.EVALUATION_ERROR),W=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let W=z instanceof Error?z.message:String(z),U=a("If",`Error processing @if block: ${W}`,c.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 iX($){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 y9($,Z){let Y=$;function X(K,z,W,U){let q=1,_=U,B=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&q>0){B.lastIndex=_,j.lastIndex=_;let O=B.exec(K),L=j.exec(K),F=O?O.index:1/0,H=L?L.index:1/0;if(F<H)q++,_=F+O[0].length;else if(H<1/0){if(q--,q===0)return H;_=H+L[0].length}else break}return-1}function J(K,z,W){let U=0,q=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],O;while((O=q.exec(K))!==null)j.push({pos:O.index,type:"open"});while((O=_.exec(K))!==null)j.push({pos:O.index,type:"close"});while((O=B.exec(K))!==null)j.push({pos:O.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 z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,q,_=Y.slice(W+5),B=iX(_);if(B)U=B.value,q=W+5+B.consumed;else q=W+5;let j=X(Y,"auth","endauth",q);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let O=Y.slice(q,j),L=J(O,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?k1(`auth?.check && auth?.user?.[${U}]`,Z):k1("auth?.check",Z);let H;if(L!==-1){let V=O.slice(0,L),A=O.slice(L+5);H=F?V:A}else H=F?O:"";Y=Y.substring(0,W)+H+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,q,_=Y.slice(W+6),B=iX(_);if(B)U=B.value,q=W+6+B.consumed;else q=W+6;let j=X(Y,"guest","endguest",q);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let O=Y.slice(q,j),L=J(O,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?k1(`!auth?.check || !auth?.user?.[${U}]`,Z):k1("!auth?.check",Z);let H;if(L!==-1){let V=O.slice(0,L),A=O.slice(L+5);H=F?V:A}else H=F?O:"";Y=Y.substring(0,W)+H+Y.substring(j+9),K=!0}}function Q(K,z,W){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(z)U.push(z);if(W){let q=k1(W,Z);U.push(q)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,W=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let q=Y.match(new RegExp(`@${K}\\s*\\(`));if(!q||q.index===void 0)break;let _=q.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let O=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,z,O);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${z} \u2014 the block was skipped.`);break}let F=Y.slice(O,L),H=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${z}(?![a-z])`,"g"),R=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,M=[],T;while((T=A.exec(F))!==null)M.push({pos:T.index,type:"open"});while((T=w.exec(F))!==null)M.push({pos:T.index,type:"close"});while((T=R.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)H.push(b)}let D=[],E=0;for(let b=0;b<H.length;b++){let C=H[b];if(D.push({content:F.slice(E,C.pos),ability:void 0}),C.type==="elseDirective"){let d=F.slice(C.pos+`@${W}`.length),f=G(d);if(f){D[D.length-1]={content:F.slice(E,C.pos)},E=C.pos+`@${W}`.length+f.paramsEnd,D.push({content:"",ability:f.ability,type:f.type,id:f.id}),D.pop();let m=H[b+1],o=m?m.pos:F.length;D.push({content:F.slice(E,o),ability:f.ability,type:f.type,id:f.id}),E=o}}else E=C.pos+5}if(E<F.length){let b=D[D.length-1];if(H.length>0&&H[H.length-1].type==="else")D.push({content:F.slice(E),isFinalElse:!0});else if(D.length===0)D.push({content:F.slice(E)})}let I=Q(j.ability,j.type,j.id),k=K==="can"?I:!I,S="";if(k)S=D[0]?.content||"";else{let b=!1;for(let C=1;C<D.length;C++){let d=D[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&&D.length>0){let C=D[D.length-1];if(C.isFinalElse)S=C.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${z}`.length),U=!0}}return Y}function v9($,Z,Y){let X=$;function J(Q,G,K,z,W){let U=!0;while(U){U=!1;let q=new RegExp(`@${G}\\s*\\(`),_=Q.match(q);if(!_||_.index===void 0)break;let B=_.index,j=S1(Q,B+`@${G}`.length);if(!j)break;let O=j.endPos,L=$5(Q,G,K,O);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(O,L),H=j.expression,V=-1,A=0,w=0;while(w<F.length){let R=F.indexOf("@",w);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){A++,w=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){A--,w=R+1;continue}if(A===0&&/^@else(?![a-z])/.test(N)){V=R;break}w=R+1}try{let R=z(H.trim()),N;if(V!==-1){let M=F.slice(0,V),T=F.slice(V+5);N=R?M:T}else N=R?F:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),M=a(W,`Error processing @${G} directive: ${N}`,c.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=k1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=k1(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 x9($,Z,Y){let X=$,J="development";function Q(G,K,z,W){let U=new RegExp(`@${K}(?![a-z])`,"g"),q=new RegExp(`@${z}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${z}(?![a-z])`),j=G,O=!0;while(O){O=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,H=F+L[0].length;if(K==="env"){let I=j.substring(H).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!I)break;H+=I[0].length,W=J===I[2]}let V=1,A=H,w=-1;while(V>0&&A<j.length){U.lastIndex=A,q.lastIndex=A;let I=U.exec(j),k=q.exec(j),S=I?I.index:1/0,b=k?k.index:1/0;if(S<b)V++,A=S+I[0].length;else if(b<1/0){if(V--,V===0){w=b;break}A=b+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${z} \u2014 the block was skipped.`);break}let R=j.substring(H,w),N=-1,M=0,T=0;while(T<R.length){let I=R.indexOf("@",T);if(I===-1)break;let k=R.substring(I);if(_.test(k)){M++,T=I+1;continue}if(B.test(k)){M--,T=I+1;continue}if(M===0&&/^@else(?![a-z])/.test(k)){N=I;break}T=I+1}let D;if(N!==-1){let I=R.slice(0,N),k=R.slice(N+5);D=W?I:k}else D=W?R:"";let E=`@${z}`.length;j=j.substring(0,F)+D+j.substring(w+E),O=!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 J7=P(()=>{gX();O1();H$();R0()});function nX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function Y5($,Z){if(!$)return Z?.nonceGenerator?.()??nX();let Y=f9.get($);if(!Y)Y=Z?.nonceGenerator?.()??nX(),f9.set($,Y);return Y}function FM($){f9.delete($)}function sX($,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 h9($,Z){return`<meta http-equiv="Content-Security-Policy" content="${sX($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function VM($){return{enabled:!0,directives:{strict:H_,moderate:g9,relaxed:L_,api:F_}[$]||g9,useNonce:$==="strict",addMetaTag:!0}}function wM($,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:[],z=[...new Set([...K,...J])];Y[Q]=z}}return Y}function oX($,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?Y5(Y,Z):void 0,J=h9(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 w0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,z=!1;while(Q<$.length){let W=$[Q];if(G&&z){z=!1,Q++;continue}if(G&&W==="\\"){z=!0,Q++;continue}if(z=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,Q++;continue}if(W===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&W==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&W==="}"){K--,Q++;continue}if(W==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(W===Z)J++;else if(W===Y){if(J--,J===0)return Q}Q++}return-1}function hX($,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 b9($){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 S1($,Z){let Y=W_($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function W_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=w0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function $5($,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 z=G.exec($),W=K.exec($),U=z?z.index:1/0,q=W?W.index:1/0;if(U<q)J++,Q=U+z[0].length;else if(q<1/0){if(J--,J===0)return q;Q=q+W[0].length}else break}return-1}function dX($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=S1($,X);if(!J)return null;let Q=J.endPos,G=$5($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U="if",q=J.expression,_=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let O=K.substring(j);if(/^@if\s*\(/.test(O)){B++,W++;continue}if(/^@endif(?![a-z])/.test(O)){B--,W+=6;continue}if(B===0){let L=O.match(/^@elseif\s*/);if(L){z.push({type:U,condition:q,content:K.substring(_,W),start:Q+_,end:Q+W});let F=W+L[0].length,H=S1(K,F);if(!H){W++;continue}U="elseif",q=H.expression,W=H.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(O)){z.push({type:U,condition:q,content:K.substring(_,W),start:Q+_,end:Q+W}),U="else",q=void 0,W+=5,_=W;continue}}W++}return z.push({type:U,condition:q,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function O$($){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=dX($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function X7($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((O)=>Q.index>O.start&&Q.index<O.end)){Q=J.exec($);continue}let K=Q.index,z=K+Q[0].length-1,W=w0($,"(",")",z);if(W===-1){Q=J.exec($);continue}let U=$.slice(z+1,W),q=W+1,_=$5($,Z,Y,q);if(_===-1){Q=J.exec($);continue}let B=$.slice(q,_),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 P9($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=S1($,X);if(!J)return null;let Q=J.endPos,G=$5($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),z=[],W=0,U=null,q=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(q++,U)U.content+=B[0];W+=B[0].length;continue}if(j){if(q--,U)U.content+=j[0];W+=j[0].length;continue}if(q>0){if(U)U.content+=K[W];W++;continue}let O=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(O&&_.startsWith("@case")){if(U)z.push(U);let H=W+O[0].length,V=S1(K,H);if(!V){W++;continue}U={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(U)z.push(U);U={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(U)U.content+=K[W];W++}}if(U)z.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:z,start:Z,end:G+10}}var uX=()=>{};function U_($){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)==="{{{"?"{{{":"{!!":"{{",z=Q?K==="{{{"?"}}}":"!!}":"}}",W=G+K.length,U=q_($,W,z);if(U===-1){Y=G+1;continue}let q=$.slice(W,U).trim(),_=U+z.length;Z.push({fullMatch:$.slice(G,_),expression:q,start:G,end:_,isRaw:Q}),Y=_}return Z}function q_($,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 __($){let Z=b9($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=B_(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function B_($){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=w0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=cX(G);return{name:X,args:K}}function cX($){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 j_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=w0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function C9($){let Z=[],X=new Y7($).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 z=K.value;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let q=J<X.length?X[J].start:$.length,_=mX(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(q,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(W.type==="PUNCTUATION"&&(W.value==="{"||W.value==="[")){let U=W.start,q=W.value==="{"?"}":"]",_=w0($,W.value,q,U);if(_!==-1){let B=$.slice(U,_+1);if(J=lX(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,O=mX(X,J,$);J=O.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,O.endPos)}; ${z} ${B} = ${L}`,exported:G,start:K.start,end:O.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let z=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let W=X[J];if(W.type==="IDENTIFIER"){let U=W.value;J++;let q=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){q=X[J].start;break}J++}if(q!==-1){let _=w0($,"{","}",q);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(z,_+1).replace(/^export\s+/,""),exported:G,start:z,end:_+1}),J=lX(X,_+1)}}}else J++}return Z}function mX($,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 lX($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var pX=()=>{};var H$=P(()=>{uX();pX()});function O_($,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=P9(X,G);if(!K)break;try{let z;if(Z0(K.expression))z=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else z=$0(K.expression,Z);let W="",U=!1;for(let q of K.cases)if(q.type==="default"){if(!U)W=q.content.trim()}else try{let _;if(q.value&&Z0(q.value))_=Y0(q.value,Object.keys(Z))(...Object.values(Z));else if(q.value)_=$0(q.value,Z);if(z===_){W=q.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+W+X.substring(K.end),J=!0}catch(z){let W=z instanceof Error?z.message:String(z),U=a("Switch",`Error evaluating @switch expression: ${W}`,c.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function Z5($,Z,Y){let X=$;X=O_(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,z=S1(X,K+7);if(!z)break;let W=z.endPos,U=$5(X,"unless","endunless",W);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 q=X.slice(W,U),_=z.expression,B=-1;{let O=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,H=/@else(?![a-z])/g,V=[],A;while((A=L.exec(q))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(q))!==null)V.push({pos:A.index,type:"close"});while((A=H.exec(q))!==null)V.push({pos:A.index,type:"else"});V.sort((w,R)=>w.pos-R.pos);for(let w of V)if(w.type==="open")O++;else if(w.type==="close")O--;else if(w.type==="else"&&O===0){B=w.pos;break}}let j;if(B!==-1){let O=q.slice(0,B),L=q.slice(B+5);j=`@if (${_})${L}@else ${O}@endif`}else j=`@if (!(${_}))${q}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=v9(X,Z,Y),X=x9(X,Z,Y),X=y9(X,Z);let J=()=>{let Q=O$(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let z="",W=!1;for(let U of K.branches){if(W)break;if(U.type==="else")z=U.content,W=!0;else try{let q;if(U.condition&&Z0(U.condition))q=Y0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)q=$0(U.condition,Z);if(q)z=U.content,W=!0}catch(q){z=a(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${q instanceof Error?q.message:String(q)}`,c.EVALUATION_ERROR),W=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let W=z instanceof Error?z.message:String(z),U=a("If",`Error processing @if block: ${W}`,c.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 iX($){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 y9($,Z){let Y=$;function X(K,z,W,U){let q=1,_=U,B=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&q>0){B.lastIndex=_,j.lastIndex=_;let O=B.exec(K),L=j.exec(K),F=O?O.index:1/0,H=L?L.index:1/0;if(F<H)q++,_=F+O[0].length;else if(H<1/0){if(q--,q===0)return H;_=H+L[0].length}else break}return-1}function J(K,z,W){let U=0,q=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],O;while((O=q.exec(K))!==null)j.push({pos:O.index,type:"open"});while((O=_.exec(K))!==null)j.push({pos:O.index,type:"close"});while((O=B.exec(K))!==null)j.push({pos:O.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 z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,q,_=Y.slice(W+5),B=iX(_);if(B)U=B.value,q=W+5+B.consumed;else q=W+5;let j=X(Y,"auth","endauth",q);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let O=Y.slice(q,j),L=J(O,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?k1(`auth?.check && auth?.user?.[${U}]`,Z):k1("auth?.check",Z);let H;if(L!==-1){let V=O.slice(0,L),A=O.slice(L+5);H=F?V:A}else H=F?O:"";Y=Y.substring(0,W)+H+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let W=z.index,U,q,_=Y.slice(W+6),B=iX(_);if(B)U=B.value,q=W+6+B.consumed;else q=W+6;let j=X(Y,"guest","endguest",q);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let O=Y.slice(q,j),L=J(O,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?k1(`!auth?.check || !auth?.user?.[${U}]`,Z):k1("!auth?.check",Z);let H;if(L!==-1){let V=O.slice(0,L),A=O.slice(L+5);H=F?V:A}else H=F?O:"";Y=Y.substring(0,W)+H+Y.substring(j+9),K=!0}}function Q(K,z,W){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(z)U.push(z);if(W){let q=k1(W,Z);U.push(q)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,W=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let q=Y.match(new RegExp(`@${K}\\s*\\(`));if(!q||q.index===void 0)break;let _=q.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let O=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,z,O);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${z} \u2014 the block was skipped.`);break}let F=Y.slice(O,L),H=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${z}(?![a-z])`,"g"),R=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,M=[],T;while((T=A.exec(F))!==null)M.push({pos:T.index,type:"open"});while((T=w.exec(F))!==null)M.push({pos:T.index,type:"close"});while((T=R.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,y)=>b.pos-y.pos);for(let b of M){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)H.push(b)}let D=[],E=0;for(let b=0;b<H.length;b++){let y=H[b];if(D.push({content:F.slice(E,y.pos),ability:void 0}),y.type==="elseDirective"){let d=F.slice(y.pos+`@${W}`.length),f=G(d);if(f){D[D.length-1]={content:F.slice(E,y.pos)},E=y.pos+`@${W}`.length+f.paramsEnd,D.push({content:"",ability:f.ability,type:f.type,id:f.id}),D.pop();let m=H[b+1],o=m?m.pos:F.length;D.push({content:F.slice(E,o),ability:f.ability,type:f.type,id:f.id}),E=o}}else E=y.pos+5}if(E<F.length){let b=D[D.length-1];if(H.length>0&&H[H.length-1].type==="else")D.push({content:F.slice(E),isFinalElse:!0});else if(D.length===0)D.push({content:F.slice(E)})}let I=Q(j.ability,j.type,j.id),k=K==="can"?I:!I,S="";if(k)S=D[0]?.content||"";else{let b=!1;for(let y=1;y<D.length;y++){let d=D[y];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&&D.length>0){let y=D[D.length-1];if(y.isFinalElse)S=y.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${z}`.length),U=!0}}return Y}function v9($,Z,Y){let X=$;function J(Q,G,K,z,W){let U=!0;while(U){U=!1;let q=new RegExp(`@${G}\\s*\\(`),_=Q.match(q);if(!_||_.index===void 0)break;let B=_.index,j=S1(Q,B+`@${G}`.length);if(!j)break;let O=j.endPos,L=$5(Q,G,K,O);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(O,L),H=j.expression,V=-1,A=0,w=0;while(w<F.length){let R=F.indexOf("@",w);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){A++,w=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){A--,w=R+1;continue}if(A===0&&/^@else(?![a-z])/.test(N)){V=R;break}w=R+1}try{let R=z(H.trim()),N;if(V!==-1){let M=F.slice(0,V),T=F.slice(V+5);N=R?M:T}else N=R?F:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),M=a(W,`Error processing @${G} directive: ${N}`,c.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=k1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=k1(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 x9($,Z,Y){let X=$,J="development";function Q(G,K,z,W){let U=new RegExp(`@${K}(?![a-z])`,"g"),q=new RegExp(`@${z}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${z}(?![a-z])`),j=G,O=!0;while(O){O=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,H=F+L[0].length;if(K==="env"){let I=j.substring(H).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!I)break;H+=I[0].length,W=J===I[2]}let V=1,A=H,w=-1;while(V>0&&A<j.length){U.lastIndex=A,q.lastIndex=A;let I=U.exec(j),k=q.exec(j),S=I?I.index:1/0,b=k?k.index:1/0;if(S<b)V++,A=S+I[0].length;else if(b<1/0){if(V--,V===0){w=b;break}A=b+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${z} \u2014 the block was skipped.`);break}let R=j.substring(H,w),N=-1,M=0,T=0;while(T<R.length){let I=R.indexOf("@",T);if(I===-1)break;let k=R.substring(I);if(_.test(k)){M++,T=I+1;continue}if(B.test(k)){M--,T=I+1;continue}if(M===0&&/^@else(?![a-z])/.test(k)){N=I;break}T=I+1}let D;if(N!==-1){let I=R.slice(0,N),k=R.slice(N+5);D=W?I:k}else D=W?R:"";let E=`@${z}`.length;j=j.substring(0,F)+D+j.substring(w+E),O=!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 J7=P(()=>{gX();O1();H$();R0()});function nX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function Y5($,Z){if(!$)return Z?.nonceGenerator?.()??nX();let Y=f9.get($);if(!Y)Y=Z?.nonceGenerator?.()??nX(),f9.set($,Y);return Y}function FM($){f9.delete($)}function sX($,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 h9($,Z){return`<meta http-equiv="Content-Security-Policy" content="${sX($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function VM($){return{enabled:!0,directives:{strict:H_,moderate:g9,relaxed:L_,api:F_}[$]||g9,useNonce:$==="strict",addMetaTag:!0}}function wM($,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:[],z=[...new Set([...K,...J])];Y[Q]=z}}return Y}function oX($,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?Y5(Y,Z):void 0,J=h9(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3774
3774
|
${J}`)}function AM($,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 rX($,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?Y5(Z,Q):void 0;return h9(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return Y5(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=Y5(Z,Q);return J}function RM(){return[V_,w_]}function NM($){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 A_($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function TM($,Z){if(!$.enabled)return{};let Y=$.useNonce?Y5(Z,$):void 0,X=sX($.directives,Y);return{[A_($.reportOnly)]:X}}var f9,H_,g9,L_,F_,V_,w_,MM;var aX=P(()=>{f9=new WeakMap;H_={"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},g9={"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},L_={"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'"]},F_={"default-src":["'none'"],"frame-ancestors":["'none'"]};V_={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?Y5(Y,Q):void 0;return h9(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},w_={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return Y5(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};MM={enabled:!1,reportOnly:!1,directives:g9,useNonce:!1,addMetaTag:!0}});import{Buffer as tX}from"buffer";import eX from"crypto";function N_($=R_){let Z=eX.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return C5=Z,Z}function T_(){if(!C5)N_();return C5}function kM(){C5=null}function SM($){C5=$}function M_($=$2){let Z=T_();return`<input type="hidden" name="${$}" value="${Z}">`}function Z2($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return M_(X||$2)})}function bM($,Z){let Y=Z??C5;if(!Y)return!1;let X=tX.from($),J=tX.from(Y);if(X.length!==J.length)return!1;return eX.timingSafeEqual(X,J)}var R_=40,$2="_token",C5=null;var Y2=()=>{};async function X2($,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 D_(J,Q,Z,Y,X);else J=await E_(J,Q,Z,Y,X)}return J}async function D_($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,z=`@end${Q}`,W=$,U=n1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${z}`,"g"),q=[],_=U.exec(W);while(_!==null){let[B,j="",O=""]=_,L=_.index||0;try{let F=j?J2(j):[],H=O.trim(),V=await G(H,F,Y,X);q.push({original:B,processed:V,startIndex:L})}catch(F){let H=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);q.push({original:B,processed:a("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${H}`,c.EVALUATION_ERROR),startIndex:L})}_=U.exec(W)}for(let B=q.length-1;B>=0;B--){let{original:j,processed:O}=q[B];W=W.replace(j,O)}return W}async function E_($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,z=n1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),W=[],U=z.exec(K);while(U!==null){let[B,j=""]=U,O=U.index||0;try{let L=J2(j),F=await G("",L,Y,X);W.push({original:B,processed:F,startIndex:O})}catch(L){let F=L instanceof Error?L.message:String(L);if(J.debug)console.error(`Error processing custom directive @${Q}:`,L);W.push({original:B,processed:a("CustomDirective",`Error in @${Q}(${j}): ${F}`,c.EVALUATION_ERROR),startIndex:O})}U=z.exec(K)}let q=n1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=q.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let O=await G("",[],Y,X);W.push({original:B,processed:O,startIndex:j})}catch(O){let L=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);W.push({original:B,processed:a("CustomDirective",`Error in @${Q}: ${L}`,c.EVALUATION_ERROR),startIndex:j})}_=q.exec(K)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:O}=W[B];K=K.replace(j,O)}return K}function J2($){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 Q2=P(()=>{O1();R5()});var d9={};u(d9,{useTitle:()=>C_,useSeoMeta:()=>G7,usePageTitle:()=>C_,useHead:()=>J5,resetHead:()=>S_,renderHtmlAttrs:()=>v_,renderHead:()=>y_,renderBodyAttrs:()=>x_,processTitleDirective:()=>h_,processMetaDirective:()=>d_,processHeadDirective:()=>g_,getPageMeta:()=>k_,getHead:()=>L$,definePageMeta:()=>P_,applyHead:()=>f_});function L$(){return b1}function k_(){return Q7}function S_(){b1={},I_.length=0,Q7={}}function J5($){b1=b_(b1,$)}function b_($,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 G7($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let z=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:z})}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 z of $.articleTags)Z.push({property:"article:tag",content:z});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});J5({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function P_($){if(Q7={...Q7,...$},$.title||$.description)G7({title:$.title,description:$.description})}function C_($){let Z=typeof $==="function"?$():$;J5({title:Z})}function y_($=b1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${X5(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${X5(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}="${X5(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}="${X5(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}="${X5(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 v_($=b1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${X5(Y)}"`).join(" ")}function x_($=b1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${X5(Y)}"`).join(" ")}function X5($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function f_($=b1){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 g_($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
3776
3776
|
`,""}),headContent:Z.trim()}}function h_($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return J5({title:G}),""})}function d_($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let z=Q?G:K,W=Q?z:Z[(z||"").trim()]??z,q=J.includes(":")?{property:J,content:W}:{name:J,content:W};return J5({meta:[q]}),""})}var b1,I_,Q7;var F$=P(()=>{b1={},I_=[],Q7={}});import u_ from"crypto";function N0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function m_($){return{...u9,...$.forms?.classes}}function K7($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function l_(){return u_.randomUUID()}function gM($,Z,Y,X){let J=m_(X),Q=$;return Q=p_(Q,Z),Q=A$(Q,Z),Q=m9(Q,Z,J),Q=l9(Q,Z,J),Q}function A$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=l_();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${N0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(X,J)=>{let Q=J.toUpperCase();if(J&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${N0(Q)}">`;return X}),Y}function m9($,Z,Y=u9){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,z,W="")=>{let U=Q||G||"POST",q=K||z||"",_=P1(W),B=U.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",O=`<form method="${N0(j)}" action="${N0(q)}"${_?` ${_}`:""}>`;if(O+=`
|
|
@@ -4020,8 +4020,8 @@ else {
|
|
|
4020
4020
|
${z?`{${z}}`:"{}"}
|
|
4021
4021
|
</script>
|
|
4022
4022
|
</div>`}}});var M2={};u(M2,{warnUnbalancedTags:()=>$8,findUnbalancedTags:()=>T2});function C1($){return $.replace(/[^\n]/g," ")}function T2($){let Z=$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,C1).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,C1).replace(/<!--[\s\S]*?-->/g,C1).replace(/\{\{\{[\s\S]*?\}\}\}/g,C1).replace(/\{\{[\s\S]*?\}\}/g,C1).replace(/\{!![\s\S]*?!!\}/g,C1).replace(/"[^"]*"/g,C1).replace(/'[^']*'/g,C1),Y=new Map,X=new Map,J=/<(\/?)([A-Za-z][\w-]*)\b[^>]*?(\/?)>/g,Q;while((Q=J.exec(Z))!==null){let K=Q[1]==="/",z=Q[2],W=Q[3]==="/";if(fB.has(z.toLowerCase()))continue;if(W)continue;if(K)X.set(z,(X.get(z)??0)+1);else{let U=Y.get(z);if(U)U.count++;else{let q=Z.slice(0,Q.index).split(`
|
|
4023
|
-
`).length;Y.set(z,{count:1,firstLine:q})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(gB.has(K.toLowerCase()))continue;let z=Y.get(K)?.count??0,W=X.get(K)??0;if(z!==W)G.push({tag:K,opened:z,closed:W,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function $8($,Z){let Y;try{Y=T2($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(N2.has(X))return;N2.add(X);let J=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:z}of Y)if(G>K){let W=z?` (first opened at line ${z})`:"";console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${W} may swallow the content that follows it.`)}else console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var fB,gB,N2;var Z8=P(()=>{fB=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),gB=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);N2=new Set});import i0 from"path";import Y8 from"fs";function D2($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function E2($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class I2{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(),D2(J),E2(J)];for(let j of B)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${D2(J)}.stx`,`${E2(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let B=i0.resolve(i0.dirname(Z),`${J}.stx`);if(await i(B))return B;return null}let K=[],z=Y.componentsDir||"",W=X?.__originalFilePath;if(W)K.push(i0.join(i0.dirname(W),"components"));if(z)K.push(z);let U=i0.join(i0.dirname(Z),"components");if(!K.includes(U))K.push(U);let q=process.cwd(),_=[i0.resolve(q,"src/components"),i0.resolve(q,"components"),i0.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 O=i0.join(B,j);if(await i(O))return O}try{if(!Y8.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let O=Y8.readdirSync(B,{withFileTypes:!0});for(let L of O)if(L.isDirectory()){let F=i0.join(B,L.name);for(let H of G){let V=i0.join(F,H);if(await i(V))return V}}}catch{}}return null}}var v0;var X8=P(()=>{F0();v0=new I2});function y1($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function hB($){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=P(()=>{J8={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=hB($),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,z=[];if(X.reactive)z.push(`:href="${y1(X.value)}"`);else z.push(`href="${y1(X.value)}"`);if(J)z.push(`class="${y1(J)}"`);if(z.push("data-stx-link"),z.push(`data-stx-active-class="${y1(Q)}"`),z.push(`data-stx-exact-active-class="${y1(G)}"`),K)z.push("data-stx-prefetch");let W=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[U,q]of Object.entries($.static)){if(W.has(U))continue;if(typeof q==="boolean"){if(q)z.push(y1(U))}else z.push(`${y1(U)}="${y1(q)}"`)}return`<a ${z.join(" ")}>${Z}</a>`}}});function O0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function
|
|
4024
|
-
`}if(V){let S=[];if(U==="avif"||U==="auto"){let b=M$(X,A,w,B,"avif"),
|
|
4023
|
+
`).length;Y.set(z,{count:1,firstLine:q})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(gB.has(K.toLowerCase()))continue;let z=Y.get(K)?.count??0,W=X.get(K)??0;if(z!==W)G.push({tag:K,opened:z,closed:W,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function $8($,Z){let Y;try{Y=T2($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(N2.has(X))return;N2.add(X);let J=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:z}of Y)if(G>K){let W=z?` (first opened at line ${z})`:"";console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${W} may swallow the content that follows it.`)}else console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var fB,gB,N2;var Z8=P(()=>{fB=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),gB=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);N2=new Set});import i0 from"path";import Y8 from"fs";function D2($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function E2($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class I2{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(),D2(J),E2(J)];for(let j of B)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${D2(J)}.stx`,`${E2(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let B=i0.resolve(i0.dirname(Z),`${J}.stx`);if(await i(B))return B;return null}let K=[],z=Y.componentsDir||"",W=X?.__originalFilePath;if(W)K.push(i0.join(i0.dirname(W),"components"));if(z)K.push(z);let U=i0.join(i0.dirname(Z),"components");if(!K.includes(U))K.push(U);let q=process.cwd(),_=[i0.resolve(q,"src/components"),i0.resolve(q,"components"),i0.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 O=i0.join(B,j);if(await i(O))return O}try{if(!Y8.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let O=Y8.readdirSync(B,{withFileTypes:!0});for(let L of O)if(L.isDirectory()){let F=i0.join(B,L.name);for(let H of G){let V=i0.join(F,H);if(await i(V))return V}}}catch{}}return null}}var v0;var X8=P(()=>{F0();v0=new I2});function y1($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function hB($){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=P(()=>{J8={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=hB($),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,z=[];if(X.reactive)z.push(`:href="${y1(X.value)}"`);else z.push(`href="${y1(X.value)}"`);if(J)z.push(`class="${y1(J)}"`);if(z.push("data-stx-link"),z.push(`data-stx-active-class="${y1(Q)}"`),z.push(`data-stx-exact-active-class="${y1(G)}"`),K)z.push("data-stx-prefetch");let W=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[U,q]of Object.entries($.static)){if(W.has(U))continue;if(typeof q==="boolean"){if(q)z.push(y1(U))}else z.push(`${y1(U)}="${y1(q)}"`)}return`<a ${z.join(" ")}>${Z}</a>`}}});function O0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function P0($,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 k2($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[J,Q]=X.split(":"),G=dB[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 z8($,Z,Y,X){return Z.map((J)=>`${M$($,J,void 0,Y,X)} ${J}w`).join(", ")}function uB($,Z,Y,X,J){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${M$($,G,void 0,X,J)} ${Q}x`}).join(", ")}function M$($,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 mB($,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 dB,G8,W8;var U8=P(()=>{dB={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},G8=[320,640,768,1024,1280,1536,1920];W8={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=P0($,"src")||"",J=P0($,"alt")||"",Q=P0($,"width"),G=P0($,"height"),K=P0($,"sizes"),z=P0($,"srcset"),W=P0($,"densities"),U=P0($,"format"),q=P0($,"placeholder"),_=P0($,"placeholderColor")||"#e5e7eb",B=P0($,"provider"),j=P0($,"class")||P0($,"className")||"",O=P0($,"style")||"",L=P0($,"quality"),F=K8($,"lazy",!0),H=K8($,"preload",!1),V=K8($,"picture",!1)||!!U,A=Q?Number.parseInt(Q):void 0,w=G?Number.parseInt(G):void 0,R=z||"",N="";if(!R&&K)R=z8(X,G8,B,U),N=k2(K);else if(!R&&W){let S=W.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));R=uB(X,S,A,B,U)}else if(K)N=k2(K);let M=[];if(O)M.push(O);if(A&&w)M.push(`aspect-ratio:${A}/${w}`);if(q==="blur"||q==="color"||q==="thumbhash"){let S=mB(A||16,w||9,_);M.push(`background-image:url(${S})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat")}else if(q&&q!=="empty"&&q!=="none")M.push(`background-image:url(${O0(q)})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat");let T=M$(X,A,w,B,U),D=[];if(D.push(`src="${O0(T)}"`),D.push(`alt="${O0(J)}"`),Q)D.push(`width="${O0(Q)}"`);if(G)D.push(`height="${O0(G)}"`);if(F)D.push('loading="lazy"');if(D.push('decoding="async"'),j)D.push(`class="${O0(j)}"`);if(M.length>0)D.push(`style="${O0(M.join(";"))}"`);if(R)D.push(`srcset="${O0(R)}"`);if(N)D.push(`sizes="${O0(N)}"`);let E=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(E.has(S))continue;if(typeof b==="boolean"){if(b)D.push(O0(S))}else D.push(`${O0(S)}="${O0(b)}"`)}let I=`<img ${D.join(" ")} />`,k="";if(H){let b=U==="webp"?"image/webp":U==="avif"?"image/avif":"";k=`<link rel="preload" as="image" href="${O0(T)}"${b?` type="${b}"`:""}${R?` imagesrcset="${O0(R)}"`:""}${N?` imagesizes="${O0(N)}"`:""} />
|
|
4024
|
+
`}if(V){let S=[];if(U==="avif"||U==="auto"){let b=M$(X,A,w,B,"avif"),y=R?z8(X,G8,B,"avif"):`${b}`;S.push(`<source type="image/avif" srcset="${O0(y)}"${N?` sizes="${O0(N)}"`:""} />`)}if(U==="webp"||U==="auto"){let b=M$(X,A,w,B,"webp"),y=R?z8(X,G8,B,"webp"):`${b}`;S.push(`<source type="image/webp" srcset="${O0(y)}"${N?` sizes="${O0(N)}"`:""} />`)}return`${k}<picture>
|
|
4025
4025
|
${S.join(`
|
|
4026
4026
|
`)}
|
|
4027
4027
|
${I}
|
|
@@ -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 oD($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,z;while((z=K.exec(Q))!==null){let[W,U]=z,q=U.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of q){let B=_.split("/"),O=B[B.length-1].replace(/\.stx$/,""),L=O.includes("-")?O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):O.charAt(0).toUpperCase()+O.slice(1),F=null,H=[f5.resolve(f5.dirname(Y),`${_}.stx`),f5.resolve(f5.dirname(Y),_),f5.resolve(X.componentsDir||"components",`${_}.stx`),f5.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of H)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(O,F),G.set(O.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(W,""),K.lastIndex=0}return Q}async function rD($,Z,Y,X,J,Q){let G=$;if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,z=/@component\s*\(/g,W;while((W=z.exec(G))!==null){let U=W.index,q=U+W[0].length-1,_=1,B=q+1;while(B<G.length&&_>0){if(G[B]==="(")_++;else if(G[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=G.substring(q+1,B),O=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){z.lastIndex=0;continue}let F=L[1],H,V=j.slice(L[0].length),A=V.match(/^\s*,\s*/);if(A)H=V.slice(A[0].length).trim();let w={};if(H)try{w=L0(H,Z)}catch(I){let k=I instanceof Error?I.message:String(I);G=G.replace(G.substring(U,O),`[Error parsing component props: ${k}]`);continue}let R="",N=O,T=G.substring(O).match(/^([\s\S]*?)@endcomponent/);if(T)R=T[1].trim(),N=O+T[0].length;let D=G.substring(U,N),E=await F1(F,w,R,X,Z,Y,J,K,Q);G=G.substring(0,U)+E+G.substring(N),z.lastIndex=0}return G}async function aD($,Z,Y,X,J,Q){let G=$;if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,z=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"]),W=B4(G);return G=W.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,z),G=j4(G,W.scripts),G;async function B(j,O,L,F){let H=j,V=I8(H,O,F);for(let A=V.length-1;A>=0;A--){let w=V[A],R=L?E8(w.tagName):w.tagName,N=aB(w.attributes),M={};for(let[D,E]of Object.entries(N)){if(D.startsWith("@"))continue;if(D.startsWith("__stx_")){let I=D.slice(6);M[I]=k8(E,J);continue}if(D.startsWith(":")){let I=D.slice(1),k=E==="true"?I:E;try{if(!Z0(k)){if(J.debug)console.error(`Unsafe expression in :${I} binding: ${k}`);M[I]=E}else{let S=Y0(k,Object.keys(Z));M[I]=S(...Object.values(Z))}}catch(S){if(J.debug)console.error(`Error evaluating :${I} binding:`,S);M[I]=E}continue}if(typeof E==="string"&&E.includes("{{")&&E.includes("}}")){let I=E.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(I)try{let k=I[1];if(!Z0(k)){if(J.debug)console.error(`Unsafe expression in ${D}: ${k}`);M[D]=E}else{let S=Y0(k,Object.keys(Z));M[D]=S(...Object.values(Z))}}catch(k){if(J.debug)console.error(`Error evaluating expression for ${D}:`,k);M[D]=E}else{let k=E,S=/\{\{\s*([\s\S]+?)\s*\}\}/g,b;while((b=S.exec(E))!==null)try{let C=b[1];if(!Z0(C)){if(J.debug)console.error(`Unsafe expression in ${D}: ${C}`);continue}let f=Y0(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 ${D}:`,C)}M[D]=k}}else M[D]=E}let T=await F1(R,M,w.content,X,Z,Y,J,K,Q);H=H.substring(0,w.startIndex)+T+H.substring(w.endIndex)}return H}}var d2=P(()=>{R0();F0();O4()});var i2={};u(i2,{processESImports:()=>p2,processComponents:()=>H7});import O7 from"fs";import m0 from"path";function eB($,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,z)=>z.toUpperCase())};for(let[G,K]of Object.entries($)){let z=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(z.startsWith("@")){X.events[z]=K;continue}if(z.startsWith("__stx_")){let W=Q(z.slice(6));X.serverDynamic[W]=k8(K,Y);continue}if(z.startsWith(":")){let W=Q(z.slice(1)),U=K==="true"?W:K;try{if(!Z0(U)){if(Y.debug)console.error(`Unsafe expression in :${W} binding: ${U}`);X.clientReactive[W]=U;continue}let q=Object.keys(Z),B=Y0(U,q)(...Object.values(Z));if(B===void 0){let j=U.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],O=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!O.has(F)&&!q.includes(F))){X.clientReactive[W]=U;continue}}X.serverDynamic[W]=B}catch{X.clientReactive[W]=U}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let W=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(W)try{let U=W[1];if(Z0(U)){let _=Y0(U,Object.keys(Z))(...Object.values(Z));X.static[z]=_!=null?String(_):""}else{if(Y.debug)console.error(`Unsafe expression in ${z}: ${U}`);X.static[z]=K}}catch(U){if(Y.debug)console.error(`Error evaluating expression for ${z}:`,U);X.static[z]=K}else{let U=K,q=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=q.exec(K))!==null)try{let B=_[1];if(!Z0(B)){if(Y.debug)console.error(`Unsafe expression in ${z}: ${B}`);continue}let O=Y0(B,Object.keys(Z))(...Object.values(Z));U=U.replace(_[0],String(O??""))}catch(B){if(Y.debug)console.error(`Error evaluating expression in ${z}:`,B)}X.static[z]=U}continue}X.static[z]=K}return X}function $j($){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 m2($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Zj($){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(v0.isBuiltin(J))Z.add(J)}return[...Z].sort()}function Yj($){let Z=l2.get($);if(Z)return Z;let Y=new Map,X=[m0.join($,"src"),m0.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=O7.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let z of K){let W=m0.join(Q,z.name);if(z.isDirectory()){if(z.name==="node_modules"||z.name.startsWith("."))continue;J(W,G+1)}else if(z.isFile()&&z.name.endsWith(".stx")){let U=z.name.slice(0,-4);if(!Y.has(U))Y.set(U,W);let q=U.toLowerCase();if(!Y.has(q))Y.set(q,W);let _=U.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(_))Y.set(_,W)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return l2.set($,Y),Y}function Xj($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=m0.join(Y,"node_modules",$);try{if(O7.statSync(X).isDirectory())return X}catch{}let J=m0.dirname(Y);if(J===Y)return null;Y=J}}async function p2($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=m0.dirname(Y),K=$,z=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(z,(W,U,q)=>{let _=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=q,j,O=[];while((j=_.exec(q))!==null){let[L,F,H,V]=j,A=null,w=null;if(V.startsWith(".")||V.startsWith("/")){let M=m0.resolve(G,V);if(M.endsWith(".stx"))w=M;else{let T=`${M}.stx`;try{if(O7.statSync(T).isFile())w=T}catch{try{if(O7.statSync(M).isDirectory())A=M}catch{}}}}else A=Xj(V,G);if(!A&&!w)continue;let R=!1,N=(M,T)=>{Q.set(M,T),Q.set(M.toLowerCase(),T);let D=M.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(D,T),J.add(T)};if(H&&w)N(H,w),R=!0;else if(F){let M=F.slice(1,-1).split(",").map((D)=>D.trim()).filter(Boolean).map((D)=>{let E=D.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(E)return{source:E[1],local:E[2]};return{source:D,local:D}}),T=A?Yj(A):null;for(let{source:D,local:E}of M){let I=null;if(w)I=w;else if(T)I=T.get(D)??T.get(D.toLowerCase())??T.get(D.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(I)N(E,I),R=!0}}if(R)O.push({start:j.index,end:j.index+L.length})}if(O.length===0)return W;for(let L=O.length-1;L>=0;L--)B=B.slice(0,O[L].start)+B.slice(O[L].end);return`<script${U}>${B}</script>`}),K}async function Jj($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,z;while((z=K.exec(Q))!==null){let[W,U]=z,q=U.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of q){let B=_.split("/"),O=B[B.length-1].replace(/\.stx$/,""),L=O.includes("-")?O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):O.charAt(0).toUpperCase()+O.slice(1),F=null,H=[m0.resolve(m0.dirname(Y),`${_}.stx`),m0.resolve(m0.dirname(Y),_),m0.resolve(X.componentsDir||"components",`${_}.stx`),m0.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of H)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(O,F),G.set(O.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(W,""),K.lastIndex=0}return Q}async function Qj($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,z=/@component\s*\(/g,W;while((W=z.exec(Q))!==null){let U=W.index,q=U+W[0].length-1,_=1,B=q+1;while(B<Q.length&&_>0){if(Q[B]==="(")_++;else if(Q[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=Q.substring(q+1,B),O=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){z.lastIndex=0;continue}let F=L[1],H,V=j.slice(L[0].length),A=V.match(/^\s*,\s*/);if(A)H=V.slice(A[0].length).trim();let w={};if(H)try{w=L0(H,Z)}catch(E){let I=E instanceof Error?E.message:String(E);Q=Q.replace(Q.substring(U,O),`[Error parsing component props: ${I}]`);continue}let R="",N=O,T=Q.substring(O).match(/^([\s\S]*?)@endcomponent/);if(T)R=T[1].trim(),N=O+T[0].length;let D=await F1(F,w,R,G,Z,Y,X,K,J);Q=Q.substring(0,U)+D+Q.substring(N),z.lastIndex=0}return Q}async function Gj($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,z=B4(Q);return Q=z.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,tB),Q=j4(Q,z.scripts),Q;async function _(B,j,O,L){if(!B)return B;let F=B,H=I8(F,j,L);for(let V=H.length-1;V>=0;V--){let A=H[V],w=O?E8(A.tagName):A.tagName,R=$j(A.attributes),N=eB(R,Z,X),M=v0.getBuiltin(A.tagName),T=M?await n2(w,G,Z,Y,X):!1;if(M&&!T){let k={context:Z,filePath:Y,options:X,dependencies:J},S=M.render(N,A.content,k);if(Object.keys(N.clientReactive).length>0)S=c2(S,N.clientReactive);if(Object.keys(N.events).length>0){let b=Object.entries(N.events).map(([C,d])=>`${C}="${m2(d)}"`).join(" ");S=S.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}F=F.substring(0,A.startIndex)+S+F.substring(A.endIndex);continue}let D={};for(let[k,S]of Object.entries(N.static))D[k]=S;for(let[k,S]of Object.entries(N.serverDynamic))D[k]=S;let I=await F1(w,D,A.content,G,Z,Y,X,K,J);if(Object.keys(N.clientReactive).length>0)I=c2(I,N.clientReactive);if(Object.keys(N.events).length>0){let k=I.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(k){let S=Object.entries(N.events).map(([C,d])=>`${C}="${m2(d)}"`).join(" "),b=k[1].length+k[2].length;I=I.substring(0,b)+" "+S+I.substring(b)}}F=F.substring(0,A.startIndex)+I+F.substring(A.endIndex)}return F}}function c2($,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,""")}"`).join(" "),J=Y[1].length+Y[2].length;return $.substring(0,J)+" "+X+$.substring(J)}async function H7($,Z,Y,X,J){if(!u2)g2(),u2=!0;let Q=await p2($,Z,Y,X,J);Q=await Jj(Q,Z,Y,X,J),Q=await Qj(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await Gj(Q,Z,Y,X,J),Q===K)break}if(X.debug){let G=Zj(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 u2=!1,tB,l2;var S8=P(()=>{X8();h2();d2();F0();R0();tB=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"]);l2=new Map});var L7={};u(L7,{stripTypeScript:()=>t2,hasVariables:()=>XJ,extractVariables:()=>e0,extractScriptFromTemplate:()=>YJ,convertToCommonJS:()=>P8});import g5 from"path";import E$ from"process";function Kj($){let Z=[],Y=0,X=$.split(`
|
|
4172
|
+
</script>`}),J}async function oD($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,z;while((z=K.exec(Q))!==null){let[W,U]=z,q=U.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of q){let B=_.split("/"),O=B[B.length-1].replace(/\.stx$/,""),L=O.includes("-")?O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):O.charAt(0).toUpperCase()+O.slice(1),F=null,H=[f5.resolve(f5.dirname(Y),`${_}.stx`),f5.resolve(f5.dirname(Y),_),f5.resolve(X.componentsDir||"components",`${_}.stx`),f5.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of H)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(O,F),G.set(O.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(W,""),K.lastIndex=0}return Q}async function rD($,Z,Y,X,J,Q){let G=$;if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,z=/@component\s*\(/g,W;while((W=z.exec(G))!==null){let U=W.index,q=U+W[0].length-1,_=1,B=q+1;while(B<G.length&&_>0){if(G[B]==="(")_++;else if(G[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=G.substring(q+1,B),O=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){z.lastIndex=0;continue}let F=L[1],H,V=j.slice(L[0].length),A=V.match(/^\s*,\s*/);if(A)H=V.slice(A[0].length).trim();let w={};if(H)try{w=L0(H,Z)}catch(I){let k=I instanceof Error?I.message:String(I);G=G.replace(G.substring(U,O),`[Error parsing component props: ${k}]`);continue}let R="",N=O,T=G.substring(O).match(/^([\s\S]*?)@endcomponent/);if(T)R=T[1].trim(),N=O+T[0].length;let D=G.substring(U,N),E=await F1(F,w,R,X,Z,Y,J,K,Q);G=G.substring(0,U)+E+G.substring(N),z.lastIndex=0}return G}async function aD($,Z,Y,X,J,Q){let G=$;if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,z=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"]),W=B4(G);return G=W.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,z),G=j4(G,W.scripts),G;async function B(j,O,L,F){let H=j,V=I8(H,O,F);for(let A=V.length-1;A>=0;A--){let w=V[A],R=L?E8(w.tagName):w.tagName,N=aB(w.attributes),M={};for(let[D,E]of Object.entries(N)){if(D.startsWith("@"))continue;if(D.startsWith("__stx_")){let I=D.slice(6);M[I]=k8(E,J);continue}if(D.startsWith(":")){let I=D.slice(1),k=E==="true"?I:E;try{if(!Z0(k)){if(J.debug)console.error(`Unsafe expression in :${I} binding: ${k}`);M[I]=E}else{let S=Y0(k,Object.keys(Z));M[I]=S(...Object.values(Z))}}catch(S){if(J.debug)console.error(`Error evaluating :${I} binding:`,S);M[I]=E}continue}if(typeof E==="string"&&E.includes("{{")&&E.includes("}}")){let I=E.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(I)try{let k=I[1];if(!Z0(k)){if(J.debug)console.error(`Unsafe expression in ${D}: ${k}`);M[D]=E}else{let S=Y0(k,Object.keys(Z));M[D]=S(...Object.values(Z))}}catch(k){if(J.debug)console.error(`Error evaluating expression for ${D}:`,k);M[D]=E}else{let k=E,S=/\{\{\s*([\s\S]+?)\s*\}\}/g,b;while((b=S.exec(E))!==null)try{let y=b[1];if(!Z0(y)){if(J.debug)console.error(`Unsafe expression in ${D}: ${y}`);continue}let f=Y0(y,Object.keys(Z))(...Object.values(Z));k=k.replace(b[0],String(f??""))}catch(y){if(J.debug)console.error(`Error evaluating expression in ${D}:`,y)}M[D]=k}}else M[D]=E}let T=await F1(R,M,w.content,X,Z,Y,J,K,Q);H=H.substring(0,w.startIndex)+T+H.substring(w.endIndex)}return H}}var d2=P(()=>{R0();F0();O4()});var i2={};u(i2,{processESImports:()=>p2,processComponents:()=>H7});import O7 from"fs";import m0 from"path";function eB($,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,z)=>z.toUpperCase())};for(let[G,K]of Object.entries($)){let z=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(z.startsWith("@")){X.events[z]=K;continue}if(z.startsWith("__stx_")){let W=Q(z.slice(6));X.serverDynamic[W]=k8(K,Y);continue}if(z.startsWith(":")){let W=Q(z.slice(1)),U=K==="true"?W:K;try{if(!Z0(U)){if(Y.debug)console.error(`Unsafe expression in :${W} binding: ${U}`);X.clientReactive[W]=U;continue}let q=Object.keys(Z),B=Y0(U,q)(...Object.values(Z));if(B===void 0){let j=U.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],O=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!O.has(F)&&!q.includes(F))){X.clientReactive[W]=U;continue}}X.serverDynamic[W]=B}catch{X.clientReactive[W]=U}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let W=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(W)try{let U=W[1];if(Z0(U)){let _=Y0(U,Object.keys(Z))(...Object.values(Z));X.static[z]=_!=null?String(_):""}else{if(Y.debug)console.error(`Unsafe expression in ${z}: ${U}`);X.static[z]=K}}catch(U){if(Y.debug)console.error(`Error evaluating expression for ${z}:`,U);X.static[z]=K}else{let U=K,q=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=q.exec(K))!==null)try{let B=_[1];if(!Z0(B)){if(Y.debug)console.error(`Unsafe expression in ${z}: ${B}`);continue}let O=Y0(B,Object.keys(Z))(...Object.values(Z));U=U.replace(_[0],String(O??""))}catch(B){if(Y.debug)console.error(`Error evaluating expression in ${z}:`,B)}X.static[z]=U}continue}X.static[z]=K}return X}function $j($){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 m2($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Zj($){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(v0.isBuiltin(J))Z.add(J)}return[...Z].sort()}function Yj($){let Z=l2.get($);if(Z)return Z;let Y=new Map,X=[m0.join($,"src"),m0.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=O7.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let z of K){let W=m0.join(Q,z.name);if(z.isDirectory()){if(z.name==="node_modules"||z.name.startsWith("."))continue;J(W,G+1)}else if(z.isFile()&&z.name.endsWith(".stx")){let U=z.name.slice(0,-4);if(!Y.has(U))Y.set(U,W);let q=U.toLowerCase();if(!Y.has(q))Y.set(q,W);let _=U.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(_))Y.set(_,W)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return l2.set($,Y),Y}function Xj($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=m0.join(Y,"node_modules",$);try{if(O7.statSync(X).isDirectory())return X}catch{}let J=m0.dirname(Y);if(J===Y)return null;Y=J}}async function p2($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=m0.dirname(Y),K=$,z=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(z,(W,U,q)=>{let _=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=q,j,O=[];while((j=_.exec(q))!==null){let[L,F,H,V]=j,A=null,w=null;if(V.startsWith(".")||V.startsWith("/")){let M=m0.resolve(G,V);if(M.endsWith(".stx"))w=M;else{let T=`${M}.stx`;try{if(O7.statSync(T).isFile())w=T}catch{try{if(O7.statSync(M).isDirectory())A=M}catch{}}}}else A=Xj(V,G);if(!A&&!w)continue;let R=!1,N=(M,T)=>{Q.set(M,T),Q.set(M.toLowerCase(),T);let D=M.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(D,T),J.add(T)};if(H&&w)N(H,w),R=!0;else if(F){let M=F.slice(1,-1).split(",").map((D)=>D.trim()).filter(Boolean).map((D)=>{let E=D.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(E)return{source:E[1],local:E[2]};return{source:D,local:D}}),T=A?Yj(A):null;for(let{source:D,local:E}of M){let I=null;if(w)I=w;else if(T)I=T.get(D)??T.get(D.toLowerCase())??T.get(D.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(I)N(E,I),R=!0}}if(R)O.push({start:j.index,end:j.index+L.length})}if(O.length===0)return W;for(let L=O.length-1;L>=0;L--)B=B.slice(0,O[L].start)+B.slice(O[L].end);return`<script${U}>${B}</script>`}),K}async function Jj($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,z;while((z=K.exec(Q))!==null){let[W,U]=z,q=U.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of q){let B=_.split("/"),O=B[B.length-1].replace(/\.stx$/,""),L=O.includes("-")?O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):O.charAt(0).toUpperCase()+O.slice(1),F=null,H=[m0.resolve(m0.dirname(Y),`${_}.stx`),m0.resolve(m0.dirname(Y),_),m0.resolve(X.componentsDir||"components",`${_}.stx`),m0.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of H)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(O,F),G.set(O.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(W,""),K.lastIndex=0}return Q}async function Qj($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,z=/@component\s*\(/g,W;while((W=z.exec(Q))!==null){let U=W.index,q=U+W[0].length-1,_=1,B=q+1;while(B<Q.length&&_>0){if(Q[B]==="(")_++;else if(Q[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=Q.substring(q+1,B),O=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){z.lastIndex=0;continue}let F=L[1],H,V=j.slice(L[0].length),A=V.match(/^\s*,\s*/);if(A)H=V.slice(A[0].length).trim();let w={};if(H)try{w=L0(H,Z)}catch(E){let I=E instanceof Error?E.message:String(E);Q=Q.replace(Q.substring(U,O),`[Error parsing component props: ${I}]`);continue}let R="",N=O,T=Q.substring(O).match(/^([\s\S]*?)@endcomponent/);if(T)R=T[1].trim(),N=O+T[0].length;let D=await F1(F,w,R,G,Z,Y,X,K,J);Q=Q.substring(0,U)+D+Q.substring(N),z.lastIndex=0}return Q}async function Gj($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,z=B4(Q);return Q=z.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,tB),Q=j4(Q,z.scripts),Q;async function _(B,j,O,L){if(!B)return B;let F=B,H=I8(F,j,L);for(let V=H.length-1;V>=0;V--){let A=H[V],w=O?E8(A.tagName):A.tagName,R=$j(A.attributes),N=eB(R,Z,X),M=v0.getBuiltin(A.tagName),T=M?await n2(w,G,Z,Y,X):!1;if(M&&!T){let k={context:Z,filePath:Y,options:X,dependencies:J},S=M.render(N,A.content,k);if(Object.keys(N.clientReactive).length>0)S=c2(S,N.clientReactive);if(Object.keys(N.events).length>0){let b=Object.entries(N.events).map(([y,d])=>`${y}="${m2(d)}"`).join(" ");S=S.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}F=F.substring(0,A.startIndex)+S+F.substring(A.endIndex);continue}let D={};for(let[k,S]of Object.entries(N.static))D[k]=S;for(let[k,S]of Object.entries(N.serverDynamic))D[k]=S;let I=await F1(w,D,A.content,G,Z,Y,X,K,J);if(Object.keys(N.clientReactive).length>0)I=c2(I,N.clientReactive);if(Object.keys(N.events).length>0){let k=I.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(k){let S=Object.entries(N.events).map(([y,d])=>`${y}="${m2(d)}"`).join(" "),b=k[1].length+k[2].length;I=I.substring(0,b)+" "+S+I.substring(b)}}F=F.substring(0,A.startIndex)+I+F.substring(A.endIndex)}return F}}function c2($,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,""")}"`).join(" "),J=Y[1].length+Y[2].length;return $.substring(0,J)+" "+X+$.substring(J)}async function H7($,Z,Y,X,J){if(!u2)g2(),u2=!0;let Q=await p2($,Z,Y,X,J);Q=await Jj(Q,Z,Y,X,J),Q=await Qj(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await Gj(Q,Z,Y,X,J),Q===K)break}if(X.debug){let G=Zj(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 u2=!1,tB,l2;var S8=P(()=>{X8();h2();d2();F0();R0();tB=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"]);l2=new Map});var L7={};u(L7,{stripTypeScript:()=>t2,hasVariables:()=>XJ,extractVariables:()=>e0,extractScriptFromTemplate:()=>YJ,convertToCommonJS:()=>P8});import g5 from"path";import E$ from"process";function Kj($){let Z=[],Y=0,X=$.split(`
|
|
4173
4173
|
`);for(let J of X){let Q=Y,G=null,K=!1;for(let z=0;z<J.length;z++){let W=J[z];if(K){K=!1;continue}if(W==="\\"){K=!0;continue}if(G){if(W===G)G=null;continue}if(W==="'"||W==='"'||W==="`"){G=W;continue}if(W==="/"&&z+1<J.length&&J[z+1]==="/")break;if(W==="{")Y++;else if(W==="}")Y--}if(Q===0){let z=J.match(/(?:const|let|var)\s+(\w+)\s*=/);if(z)Z.push(z[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(J)){let W=J.match(/(?:const|let|var)\s+(\w+)/);if(W)Z.push(W[1])}else{let W=J.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(W){let q=W[1].slice(1,-1).split(",").map((_)=>{let B=_.split(":");return(B.length>1?B[1]:B[0]).trim()}).filter((_)=>/^\w+$/.test(_));Z.push(...q)}}}}return[...new Set(Z)]}function t2($){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,z=null;for(let W=0;W<X.length;W++){let U=X[W];if(z){if(Q+=U,U===z)z=null;continue}if(U==='"'||U==="'"||U==="`"){z=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((W)=>{let U=W.trim(),q=U.startsWith("..."),_=q?U.slice(3):U,B=-1,j=0;for(let w=0;w<_.length;w++)if(_[w]==="<")j++;else if(_[w]===">")j--;else if(_[w]===":"&&j===0){B=w;break}if(B===-1)return W;let L=_.substring(0,B).trim().replace(/\?$/,""),F=_.substring(B+1),H=-1,V=0;for(let w=0;w<F.length;w++)if(F[w]==="<")V++;else if(F[w]===">")V--;else if(F[w]==="="&&V===0){H=w;break}let A=q?"...":"";if(H!==-1)return`${A}${L} = ${F.substring(H+1).trim()}`;return`${A}${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,z=G+1,W=0,U=null;while(z<Z.length&&K>0){let B=Z[z];if(U){if(B===U)U=null;z++;continue}if(B==='"'||B==="'"||B==="`"){U=B,z++;continue}if(B==="<")W++;else if(B===">"&&W>0)W--;else if(W===0){if(B==="(")K++;else if(B===")")K--}if(K>0)z++}if(K!==0)continue;let q=Z.substring(G+1,z);if(!q.includes(":"))continue;let _=Y(q);Q.push({start:G+1,end:z,replacement:_})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:z,replacement:W}=Q[G];Z=Z.substring(0,K)+W+Z.substring(z)}}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,...z]=G.split("="),W=K.split(":")[0].trim();if(z.length>0)return`${W} = ${z.join("=").trim()}`;return W}).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 e0($,Z,Y,X={}){if(!$.trim())return;let J;try{let
|
|
4175
|
+
`),Z}async function e0($,Z,Y,X={}){if(!$.trim())return;let J;try{let C=new Bun.Transpiler({loader:"ts",target:"browser",define:J1()}),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=t2($)}let Q={exports:{}},G=Q.exports,K=E$.cwd(),z={},W=[...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 W)try{let v=g5.resolve(K,"node_modules",C),x=g5.join(v,"package.json"),g=JSON.parse(s("fs").readFileSync(x,"utf8")),l=g.main||"index.js";if(g.exports){let r=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof r==="string")l=r;else if(r?.bun)l=r.bun;else if(r?.import)l=r.import;else if(r?.default)l=r.default}z[C]=await import(g5.resolve(v,l))}catch{}let U=(C)=>{if(z[C])return z[C];return s(C)},q=Z.props||{},_=Object.assign((C)=>{if(!C)return q;let v={};for(let[x,g]of Object.entries(C)){let l=q[x];if(l!==void 0)v[x]=l;else if(typeof g==="function")v[x]=g();else v[x]=g}return v},q),B=(C)=>{if(!C)return q;let v={...q};for(let[x,g]of Object.entries(C)){let l=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(v[x]===void 0&&l.default!==void 0)v[x]=typeof l.default==="function"?l.default():l.default}return v},j=()=>Z.slots||{},O=(C,v)=>{let x={...C};for(let[g,l]of Object.entries(v))if(x[g]===void 0)if(typeof l==="function")x[g]=l();else x[g]=l;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}},H=(C)=>{},V=(C)=>C(),A=(C)=>{},w=(C)=>{},R=(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)=>{J5(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||{}}}},D=(C)=>{G7(C);let v=L$();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...v.title&&{title:v.title},meta:v.meta?[...v.meta]:[]}},E=(C)=>({value:C}),I=(C)=>C,k=(C)=>({value:typeof C==="function"?C():C}),S=(C,v)=>{},b=(C)=>{},y=(C)=>{},d=(C)=>C?C():Promise.resolve(),f=(C)=>(v,...x)=>{},m=(C)=>{},o=(C,v)=>{},I0=(C,v)=>v,q1=()=>({value:"light"}),h0=()=>({value:!1}),C0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},J0=new Proxy(C0,{get(C,v){if(v in C)return C[v];return},set(C,v,x){return C[v]=x,!0}}),A0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},B0=console;try{let C=P8(J,Y),v=new Set(Object.keys(q)),x=Object.keys(Z).filter((e)=>!v.has(e)&&e!=="props"),g=x.map((e)=>Z[e]),l=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"]),r=[],G0=[];for(let[e,X1]of Object.entries(q)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e))continue;if(l.has(e))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${e}\\b`).test(C))continue;r.push(e),G0.push(X1)}let d0=Kj(C).map((e)=>`module.exports.${e} = typeof ${e} !== 'undefined' ? ${e} : module.exports.${e};`).join(`
|
|
4176
4176
|
`),c1=Z.params??{},U0=[],p1=[];for(let e=0;e<x.length;e++){if(x[e]==="params")continue;U0.push(x[e]),p1.push(g[e])}let $4=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",...r,...U0,`return (async () => {
|
|
4177
|
-
${
|
|
4177
|
+
${C}
|
|
4178
4178
|
${d0}
|
|
4179
4179
|
return module.exports
|
|
4180
|
-
})()`)(Q,G,U,q,_,B,O,L,F,H,V,A,w,R,N,M,T,D,E,I,k,S,b,
|
|
4180
|
+
})()`)(Q,G,U,q,_,B,O,L,F,H,V,A,w,R,N,M,T,D,E,I,k,S,b,y,d,f,m,j,o,I0,q1,h0,J0,A0,B0,C0.confirm,C0.alert,C0.fetch,c1,...G0,...p1);if(X.preserveExisting){for(let[e,X1]of Object.entries($4))if(!(e in Z)||Z[e]===void 0)Z[e]=X1}else Object.assign(Z,$4);for(let[e,X1]of Object.entries(q))if(!(e in Z))Z[e]=X1}catch(C){if(E$.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 _j(J,Z,Y)}catch(v){if(E$.env.STX_DEBUG){let x=v instanceof Error?v.message:String(v);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${x}`)}}}}function P8($,Z){let Y=Z?g5.dirname(Z):E$.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 z of X[Q])if(z==="{")K++;else if(z==="}")K--;if(K<=0)break}}Q++;continue}if(G.startsWith("definePageMeta(")){let K=0,z=!1;for(let W=Q;W<X.length&&!z;W++){let U=null,q=!1,_=X[W];for(let B=0;B<_.length;B++){let j=_[B];if(q){q=!1;continue}if(j==="\\"){q=!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=W+1,z=!0;break}}}}if(!z)Q=X.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),z=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),W=G.match(/^import\s+['"](.+)['"]/),U=(q)=>{if(q.startsWith("."))return g5.resolve(Y,q);return q};if(K){let[,q,_]=K,B=U(_);J.push(`const ${q} = await import('${B}')`),J.push(`module.exports.${q} = ${q};`)}else if(z){let[,q,_]=z,B=q.trim(),j=U(_);J.push(`const { ${B} } = await import('${j}')`);for(let O of B.split(",")){let L=O.trim().split(/\s+as\s+/).pop()?.trim();if(L)J.push(`module.exports.${L} = ${L};`)}}else if(W){let q=U(W[1]);J.push(`await import('${q}')`)}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=s2(X,Q),{type:z,name:W,value:U}=K;J.push(`${z} ${W} = ${U};`),J.push(`module.exports.${W} = ${W};`),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=s2(X,Q),{type:z,name:W,value:U}=K;J.push(`${z} ${W} = ${U};`),J.push(`module.exports.${W} = ${W};`),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"),z=[...X];z[Q]=K;let W=b8(z,Q);if(J.push(W.functionCode),W.name)J.push(`module.exports.default = ${W.name};`);Q=W.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 z=K[1],W=X[Q].replace(/^export\s+/,""),U=0,q=Q;for(;q<X.length;q++){let _=X[q];for(let B of _)if(B==="{")U++;else if(B==="}")U--;if(q>Q)W+=`
|
|
4182
4182
|
`+_;if(U<=0&&q>=Q)break}J.push(W),J.push(`module.exports.${z} = ${z};`),Q=q+1}else J.push(G),Q++}else if(G.includes("module.exports"))J.push(G),Q++;else if(G.trim()&&!G.startsWith("//"))J.push(G),Q++;else Q++}return zj(J.join(`
|
|
4183
4183
|
`),Y)}function zj($,Z){let Y=$.length,X="",J=0,Q=null,G=!1,K=!1,z=0;while(J<Y){let W=$[J],U=$[J+1];if(G){if(X+=W,W===`
|
|
@@ -4187,7 +4187,7 @@ ${w}`,nextIndex:H}}}}throw Error(`Failed to parse variable declaration: ${Y}`)}l
|
|
|
4187
4187
|
${$[z]}`,z++;else break}return K=K.trim().replace(/;$/,""),{type:J,name:Q,value:K,nextIndex:z}}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(Uj(Y)){let K=qj($,Z,Q);Q=K.functionCode,G=K.nextIndex}else G=Z+1;return{name:J,functionCode:Q,nextIndex:G}}function o2($){let Z=$.trim();if(Z.startsWith("{"))return w0(Z,"{","}",0)===-1;if(Z.startsWith("["))return w0(Z,"[","]",0)===-1;return!ZJ(Z)}function ZJ($){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 Uj($){let Z=$.indexOf("{");if(Z===-1)return!0;return w0($,"{","}",Z)===-1}function r2($,Z,Y){let X=Y,J=Z+1;while(J<$.length&&!ZJ(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 qj($,Z,Y){let X=Y,J=Z+1;while(J<$.length){let Q=X.indexOf("{");if(Q!==-1){if(w0(X,"{","}",Q)!==-1)break}let G=$[J];X+=`
|
|
4190
|
-
${G}`,J++}return{functionCode:X,nextIndex:J}}function a2($,Z){let Y=$0($,Z)??$0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{...E$.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 _j($,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 z=K.trim().replace(/;$/,""),W=a2(z,Z);if(W!==void 0)Z[G]=W}catch(z){console.warn(`Failed to parse export ${G} in fallback:`,z)}}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 z=K.trim().replace(/;$/,""),W=a2(z,Z);if(W!==void 0)Z[G]=W}catch{}}}function YJ($){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 XJ($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var I$=P(()=>{F$();V5();R0()});var UJ={};u(UJ,{processLoops:()=>C8});function Oj($,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,z=1,W=K+1;while(W<X.length&&z>0){if(X[W]==="(")z++;else if(X[W]===")"){if(z--,z===0)break}W++}if(z!==0)continue;let U=X.substring(K+1,W),q=W+1,_=U.match(/^\s*['"]([^'"]+)['"]/);if(!_)continue;let B=_[1],j=U.slice(_[0].length),O=j.match(/^\s*,\s*/);if(!O)continue;let L=j.slice(O[0].length).trim();if(!L)continue;try{let F=L0(L,Z),H=JSON.stringify(F),V=`@component('${B}', ${H})`;Q.push({start:G,end:q,replacement:V})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:z,replacement:W}=Q[G];X=X.substring(0,K)+W+X.substring(z)}return X}function F7($,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,z=1,W=K+1,U=null,q=!1;while(W<X.length&&z>0){let j=X[W];if(q){q=!1,W++;continue}if(j==="\\"&&U){q=!0,W++;continue}if(U){if(j===U)U=null;W++;continue}if(j==='"'||j==="'"||j==="`"){U=j,W++;continue}if(j==="(")z++;else if(j===")"){if(z--,z===0)break}W++}if(z!==0)break;let _=X.substring(K+1,W),B=Y(_);X=X.substring(0,G)+B+X.substring(W+1)}return X}function Hj($,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);Z$(Q);let W=Y0(Q,G)(...K),U=JSON.stringify(W),q=Buffer.from(U,"utf8").toString("base64");return`__stx_${J}="${q}"`}catch(G){return X}}),Y}function Lj($,Z){let Y=$;return Y=F7(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(Z0(Q)){let K=Y0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean($0(Q,Z));return G?V7:""}catch{return""}}),Y=F7(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(Z0(Q)){let K=Y0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean($0(Q,Z));return G?w7:""}catch{return""}}),Y}function Fj($){let Z=$;return Z=Z.replace(/@break(?!\()/g,V7),Z=Z.replace(/@continue(?!\()/g,w7),Z}function JJ($){let Z=$.includes(V7),Y=Z?$.substring(0,$.indexOf(V7)):$;return{hasBreak:Z,content:Y}}function QJ($){let Z=$.includes(w7),Y=Z?$.substring(0,$.indexOf(w7)):$;return{hasContinue:Z,content:Y}}function KJ($){let Z=$;return Z=F7(Z,"@break",(Y)=>{let X=Y.trim();if(!Y$(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=F7(Z,"@continue",(Y)=>{let X=Y.trim();if(!Y$(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function Vj($){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,q)=>U.pos-q.pos);let K=[],z=0;for(let U of X)z+=U.delta,K.push({pos:U.pos,depth:z});function W(U){let q=0,_=K.length-1,B=0;while(q<=_){let j=q+_>>1;if(K[j].pos<=U)B=K[j].depth,q=j+1;else _=j-1}return B}while((Y=Z.exec($))!==null){if(W(Y.index)>0)continue;let U=Y.index,q=Y.index+Y[0].length-1,_=1,B=q+1,j=-1;while(B<$.length&&_>0){if($[B]==="(")_++;else if($[B]===")"){if(_--,_===0){j=B;break}}B++}if(j===-1)continue;let O=$.substring(q+1,j),L=O.indexOf(" as ");if(L===-1)continue;let F=O.substring(0,L).trim(),H=O.substring(L+4).trim(),V=j+1,A=1,w=V,R=/@forelse\s*\(/g,N=/@endforelse/g,M=-1;while(A>0&&w<$.length){R.lastIndex=w,N.lastIndex=w;let S=R.exec($),b=N.exec($);if(!b)break;if(S&&S.index<b.index)A++,w=S.index+S[0].length;else{if(A--,A===0){M=b.index;break}w=b.index+11}}if(M===-1)continue;let T=$.substring(V,M),D=M+11,E=-1,I=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))I++,k=S+1;else if(b.startsWith("@endforelse"))I--,k=S+11;else if(I===0&&b.startsWith("@empty")){if(T.length<=S+6||!/[a-z]/i.test(T[S+6])){E=S;break}k=S+1}else k=S+1}if(E===-1)continue;return{start:U,end:D,arrayExpr:F,itemVar:H,foreachContent:T.substring(0,E),emptyContent:T.substring(E+6)}}return null}function GJ($,Z){let Y=$;while(!0){let X=Vj(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:z,emptyContent:W}=X;try{let U;if(Z0(G))U=Y0(G,Object.keys(Z))(...Object.values(Z));else U=$0(G,Z);let q;if(!Array.isArray(U)||U.length===0)q=W;else q=`@foreach (${G} as ${K})${z}@endforeach`;Y=Y.substring(0,J)+q+Y.substring(Q)}catch(U){let q=U instanceof Error?U.message:String(U),_=a("Forelse",`Error in @forelse(${G} as ${K}): ${q}`,c.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(z){let W=/@foreach\s*\(/g,U;while((U=W.exec(z))!==null){let q=U.index,_=U.index+U[0].length-1,B=1,j=_+1,O=-1;while(j<z.length&&B>0){if(z[j]==="(")B++;else if(z[j]===")"){if(B--,B===0){O=j;break}}j++}if(O===-1)continue;let L=z.substring(_+1,O),F=L.indexOf(" as ");if(F===-1)continue;let H=q,V=L.substring(0,F),A=L.substring(F+4),w=O+1,R=1,N=w,M=/@foreach\s*\(/g,T=/@endforeach/g;while(R>0&&N<z.length){M.lastIndex=N,T.lastIndex=N;let D=M.exec(z),E=T.exec(z);if(!E)break;if(D&&D.index<E.index)R++,N=D.index+D[0].length;else{if(R--,R===0){let I=z.substring(w,E.index),k=E.index+11;return{start:H,end:k,arrayExpr:V,itemVar:A,content:I}}N=E.index+11}}}return null}function G(z,W){let U=z;while(!0){let q=Q(U);if(!q)break;let{start:_,end:B,arrayExpr:j,itemVar:O,content:L}=q;try{let F=j.trim(),H;if(Z0(F))H=Y0(F,Object.keys(W))(...Object.values(W));else H=$0(F,W);let V=!1;if(!Array.isArray(H))if(H instanceof Map)H=Array.from(H),V=!0;else if(H instanceof Set)H=Array.from(H);else if(typeof H==="string")H=Array.from(H);else if(H&&typeof H==="object"&&!(H instanceof Date)&&!(H instanceof RegExp))H=Object.entries(H),V=!0;else{let E=a("Foreach",`Error in @foreach: ${F} is not iterable`,c.TYPE_ERROR);U=U.substring(0,_)+E+U.substring(B);continue}let A=X?.loops?.useAltLoopVariable??jj,w=O.trim(),R=null,N,M=!1;if(w.includes("=>")){let E=w.split("=>").map((I)=>I.trim());if(E.length===2&&E[0]&&E[1])R=E[0],N=E[1];else N=w}else if(!w.startsWith("[")&&!w.startsWith("{")&&w.includes(",")){let E=w.split(",").map((I)=>I.trim());if(E.length===2&&E[0]&&E[1])N=E[0],R=E[1],M=!0;else N=w}else N=w;let T="",D=H;for(let E=0;E<D.length;E++){let I=D[E],k={index:E,iteration:E+1,first:E===0,last:E===D.length-1,count:D.length},S={...W,loop:k,$loop:k};if(N.startsWith("[")&&N.endsWith("]")){let f=N.slice(1,-1).split(",").map((m)=>m.trim());if(Array.isArray(I))f.forEach((m,o)=>{if(m)S[m]=I[o]});else S[N]=I}else S[N]=I;if(R)if(!M&&V&&Array.isArray(I)&&I.length===2)S[R]=I[0],S[N]=I[1];else S[R]=E;let b=Lj(L,S),
|
|
4190
|
+
${G}`,J++}return{functionCode:X,nextIndex:J}}function a2($,Z){let Y=$0($,Z)??$0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{...E$.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 _j($,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 z=K.trim().replace(/;$/,""),W=a2(z,Z);if(W!==void 0)Z[G]=W}catch(z){console.warn(`Failed to parse export ${G} in fallback:`,z)}}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 z=K.trim().replace(/;$/,""),W=a2(z,Z);if(W!==void 0)Z[G]=W}catch{}}}function YJ($){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 XJ($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var I$=P(()=>{F$();V5();R0()});var UJ={};u(UJ,{processLoops:()=>C8});function Oj($,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,z=1,W=K+1;while(W<X.length&&z>0){if(X[W]==="(")z++;else if(X[W]===")"){if(z--,z===0)break}W++}if(z!==0)continue;let U=X.substring(K+1,W),q=W+1,_=U.match(/^\s*['"]([^'"]+)['"]/);if(!_)continue;let B=_[1],j=U.slice(_[0].length),O=j.match(/^\s*,\s*/);if(!O)continue;let L=j.slice(O[0].length).trim();if(!L)continue;try{let F=L0(L,Z),H=JSON.stringify(F),V=`@component('${B}', ${H})`;Q.push({start:G,end:q,replacement:V})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:z,replacement:W}=Q[G];X=X.substring(0,K)+W+X.substring(z)}return X}function F7($,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,z=1,W=K+1,U=null,q=!1;while(W<X.length&&z>0){let j=X[W];if(q){q=!1,W++;continue}if(j==="\\"&&U){q=!0,W++;continue}if(U){if(j===U)U=null;W++;continue}if(j==='"'||j==="'"||j==="`"){U=j,W++;continue}if(j==="(")z++;else if(j===")"){if(z--,z===0)break}W++}if(z!==0)break;let _=X.substring(K+1,W),B=Y(_);X=X.substring(0,G)+B+X.substring(W+1)}return X}function Hj($,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);Z$(Q);let W=Y0(Q,G)(...K),U=JSON.stringify(W),q=Buffer.from(U,"utf8").toString("base64");return`__stx_${J}="${q}"`}catch(G){return X}}),Y}function Lj($,Z){let Y=$;return Y=F7(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(Z0(Q)){let K=Y0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean($0(Q,Z));return G?V7:""}catch{return""}}),Y=F7(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(Z0(Q)){let K=Y0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean($0(Q,Z));return G?w7:""}catch{return""}}),Y}function Fj($){let Z=$;return Z=Z.replace(/@break(?!\()/g,V7),Z=Z.replace(/@continue(?!\()/g,w7),Z}function JJ($){let Z=$.includes(V7),Y=Z?$.substring(0,$.indexOf(V7)):$;return{hasBreak:Z,content:Y}}function QJ($){let Z=$.includes(w7),Y=Z?$.substring(0,$.indexOf(w7)):$;return{hasContinue:Z,content:Y}}function KJ($){let Z=$;return Z=F7(Z,"@break",(Y)=>{let X=Y.trim();if(!Y$(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=F7(Z,"@continue",(Y)=>{let X=Y.trim();if(!Y$(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function Vj($){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,q)=>U.pos-q.pos);let K=[],z=0;for(let U of X)z+=U.delta,K.push({pos:U.pos,depth:z});function W(U){let q=0,_=K.length-1,B=0;while(q<=_){let j=q+_>>1;if(K[j].pos<=U)B=K[j].depth,q=j+1;else _=j-1}return B}while((Y=Z.exec($))!==null){if(W(Y.index)>0)continue;let U=Y.index,q=Y.index+Y[0].length-1,_=1,B=q+1,j=-1;while(B<$.length&&_>0){if($[B]==="(")_++;else if($[B]===")"){if(_--,_===0){j=B;break}}B++}if(j===-1)continue;let O=$.substring(q+1,j),L=O.indexOf(" as ");if(L===-1)continue;let F=O.substring(0,L).trim(),H=O.substring(L+4).trim(),V=j+1,A=1,w=V,R=/@forelse\s*\(/g,N=/@endforelse/g,M=-1;while(A>0&&w<$.length){R.lastIndex=w,N.lastIndex=w;let S=R.exec($),b=N.exec($);if(!b)break;if(S&&S.index<b.index)A++,w=S.index+S[0].length;else{if(A--,A===0){M=b.index;break}w=b.index+11}}if(M===-1)continue;let T=$.substring(V,M),D=M+11,E=-1,I=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))I++,k=S+1;else if(b.startsWith("@endforelse"))I--,k=S+11;else if(I===0&&b.startsWith("@empty")){if(T.length<=S+6||!/[a-z]/i.test(T[S+6])){E=S;break}k=S+1}else k=S+1}if(E===-1)continue;return{start:U,end:D,arrayExpr:F,itemVar:H,foreachContent:T.substring(0,E),emptyContent:T.substring(E+6)}}return null}function GJ($,Z){let Y=$;while(!0){let X=Vj(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:z,emptyContent:W}=X;try{let U;if(Z0(G))U=Y0(G,Object.keys(Z))(...Object.values(Z));else U=$0(G,Z);let q;if(!Array.isArray(U)||U.length===0)q=W;else q=`@foreach (${G} as ${K})${z}@endforeach`;Y=Y.substring(0,J)+q+Y.substring(Q)}catch(U){let q=U instanceof Error?U.message:String(U),_=a("Forelse",`Error in @forelse(${G} as ${K}): ${q}`,c.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(z){let W=/@foreach\s*\(/g,U;while((U=W.exec(z))!==null){let q=U.index,_=U.index+U[0].length-1,B=1,j=_+1,O=-1;while(j<z.length&&B>0){if(z[j]==="(")B++;else if(z[j]===")"){if(B--,B===0){O=j;break}}j++}if(O===-1)continue;let L=z.substring(_+1,O),F=L.indexOf(" as ");if(F===-1)continue;let H=q,V=L.substring(0,F),A=L.substring(F+4),w=O+1,R=1,N=w,M=/@foreach\s*\(/g,T=/@endforeach/g;while(R>0&&N<z.length){M.lastIndex=N,T.lastIndex=N;let D=M.exec(z),E=T.exec(z);if(!E)break;if(D&&D.index<E.index)R++,N=D.index+D[0].length;else{if(R--,R===0){let I=z.substring(w,E.index),k=E.index+11;return{start:H,end:k,arrayExpr:V,itemVar:A,content:I}}N=E.index+11}}}return null}function G(z,W){let U=z;while(!0){let q=Q(U);if(!q)break;let{start:_,end:B,arrayExpr:j,itemVar:O,content:L}=q;try{let F=j.trim(),H;if(Z0(F))H=Y0(F,Object.keys(W))(...Object.values(W));else H=$0(F,W);let V=!1;if(!Array.isArray(H))if(H instanceof Map)H=Array.from(H),V=!0;else if(H instanceof Set)H=Array.from(H);else if(typeof H==="string")H=Array.from(H);else if(H&&typeof H==="object"&&!(H instanceof Date)&&!(H instanceof RegExp))H=Object.entries(H),V=!0;else{let E=a("Foreach",`Error in @foreach: ${F} is not iterable`,c.TYPE_ERROR);U=U.substring(0,_)+E+U.substring(B);continue}let A=X?.loops?.useAltLoopVariable??jj,w=O.trim(),R=null,N,M=!1;if(w.includes("=>")){let E=w.split("=>").map((I)=>I.trim());if(E.length===2&&E[0]&&E[1])R=E[0],N=E[1];else N=w}else if(!w.startsWith("[")&&!w.startsWith("{")&&w.includes(",")){let E=w.split(",").map((I)=>I.trim());if(E.length===2&&E[0]&&E[1])N=E[0],R=E[1],M=!0;else N=w}else N=w;let T="",D=H;for(let E=0;E<D.length;E++){let I=D[E],k={index:E,iteration:E+1,first:E===0,last:E===D.length-1,count:D.length},S={...W,loop:k,$loop:k};if(N.startsWith("[")&&N.endsWith("]")){let f=N.slice(1,-1).split(",").map((m)=>m.trim());if(Array.isArray(I))f.forEach((m,o)=>{if(m)S[m]=I[o]});else S[N]=I}else S[N]=I;if(R)if(!M&&V&&Array.isArray(I)&&I.length===2)S[R]=I[0],S[N]=I[1];else S[R]=E;let b=Lj(L,S),y=QJ(b);if(y.hasContinue){T+=y.content;continue}let d=JJ(b);if(d.hasBreak){T+=d.content;break}if(b=GJ(b,S),b=G(b,S),b=Z5(b,S,Y),b=Fj(b),d=JJ(b),d.hasBreak){T+=d.content;break}if(y=QJ(b),y.hasContinue){T+=y.content;continue}b=Q1(b,S,Y),b=Hj(b,S),b=Oj(b,S),T+=b}U=U.substring(0,_)+T+U.substring(B)}catch(F){let H=a("Foreach",`Error in @foreach(${j.trim()} as ${O.trim()}): ${F instanceof Error?F.message:String(F)}`,c.EVALUATION_ERROR);U=U.substring(0,_)+H+U.substring(B)}}return U}J=G(J,Z),J=WJ(J,Z,Y,X);let K=X?.loops?.maxWhileIterations??Bj;return J=Rj(J,Z,K),J}function zJ($){return Y$($)}function WJ($,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,z=K+G[0].length-1,W=w0(J,"(",")",z);if(W===-1)break;let U=J.slice(z+1,W),q=W+1,_=X7(J.slice(K),"for","endfor");if(_.length===0)break;let B=_[0].content,j=K+_[0].end;if(!zJ(U)){let O=a("For",`Unsafe expression in @for: ${U}`,c.UNSAFE_EXPRESSION);J=J.substring(0,K)+O+J.substring(j),Q=!0;continue}try{let O=wj(U),L=/@(?:for|foreach|if|unless)\s*\(/.test(B);if(O.length>0&&L){let R=Aj({forExpr:U,content:B,iterVarNames:O,context:Z,filePath:Y,options:X});J=J.substring(0,K)+R+J.substring(j),Q=!0;continue}let F=Object.keys(Z),H=Object.values(Z),V=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(R,N)=>{return`\${${N}}`});V=KJ(V);let w=Function(...F,`
|
|
4191
4191
|
let result = '';
|
|
4192
4192
|
for (${U}) {
|
|
4193
4193
|
result += \`${V}\`;
|
|
@@ -4244,14 +4244,14 @@ ${Mj($).split(",").map((z)=>z.trim()).filter(Boolean).map((z)=>` try { __scopeR
|
|
|
4244
4244
|
} finally {
|
|
4245
4245
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
4246
4246
|
}
|
|
4247
|
-
})();`}function Ej($,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 IE(){jJ.clear()}function Ij($){if($.__onceStore instanceof Set)return $.__onceStore;return jJ}async function x8($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||z0.join(z0.dirname(Y),"partials");if(G&&!z0.isAbsolute(G))G=z0.resolve(process.cwd(),G);let K=Nj($,"@partial","@include"),z=Ij(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,O,L)=>{let F=O.trim(),H=`${Y}:${F}`;if(z.has(H))return"";return z.add(H),O});{let j=/@includeIf\s*\(/g,O;while((O=j.exec(K))!==null){let L=O.index,F=L+O[0].length-1,H=1,V=F+1;while(V<K.length&&H>0){if(K[V]==="(")H++;else if(K[V]===")")H--;V++}if(H!==0)break;let A=K.substring(F+1,V-1),w=A.match(/^\s*['"]([^'"]+)['"]/);if(!w){j.lastIndex=V;continue}let R=w[1],N=W(R,G,Y),M="";if(N&&await Bun.file(N).exists())J.add(N),M=`@include(${A})`;K=K.substring(0,L)+M+K.substring(V),j.lastIndex=0}}for(let[j,O]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=L.exec(K))!==null){let H=F.index,V=H+F[0].length-1,A=1,w=V+1;while(w<K.length&&A>0){if(K[w]==="(")A++;else if(K[w]===")")A--;w++}if(A!==0)break;let R=K.substring(V+1,w-1),N=v8(R,0);if(N===-1){L.lastIndex=w;continue}let M=R.substring(0,N).trim(),T=R.substring(N+1).trim(),D=T.match(/^\s*['"]([^'"]+)['"]/);if(!D){L.lastIndex=w;continue}let E=D[1],I=T.substring(D[0].length),k,S=v8(I,0);if(S!==-1)k=I.substring(S+1).trim();try{let b=`Boolean(${M})`,
|
|
4248
|
-
`;continue}if(I0)try{let{extractVariables:J0}=await Promise.resolve().then(() => (I$(),L7));await J0(o,D,H)}catch(J0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${H}:`,J0)}if(!I0&&!
|
|
4247
|
+
})();`}function Ej($,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 IE(){jJ.clear()}function Ij($){if($.__onceStore instanceof Set)return $.__onceStore;return jJ}async function x8($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||z0.join(z0.dirname(Y),"partials");if(G&&!z0.isAbsolute(G))G=z0.resolve(process.cwd(),G);let K=Nj($,"@partial","@include"),z=Ij(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,O,L)=>{let F=O.trim(),H=`${Y}:${F}`;if(z.has(H))return"";return z.add(H),O});{let j=/@includeIf\s*\(/g,O;while((O=j.exec(K))!==null){let L=O.index,F=L+O[0].length-1,H=1,V=F+1;while(V<K.length&&H>0){if(K[V]==="(")H++;else if(K[V]===")")H--;V++}if(H!==0)break;let A=K.substring(F+1,V-1),w=A.match(/^\s*['"]([^'"]+)['"]/);if(!w){j.lastIndex=V;continue}let R=w[1],N=W(R,G,Y),M="";if(N&&await Bun.file(N).exists())J.add(N),M=`@include(${A})`;K=K.substring(0,L)+M+K.substring(V),j.lastIndex=0}}for(let[j,O]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=L.exec(K))!==null){let H=F.index,V=H+F[0].length-1,A=1,w=V+1;while(w<K.length&&A>0){if(K[w]==="(")A++;else if(K[w]===")")A--;w++}if(A!==0)break;let R=K.substring(V+1,w-1),N=v8(R,0);if(N===-1){L.lastIndex=w;continue}let M=R.substring(0,N).trim(),T=R.substring(N+1).trim(),D=T.match(/^\s*['"]([^'"]+)['"]/);if(!D){L.lastIndex=w;continue}let E=D[1],I=T.substring(D[0].length),k,S=v8(I,0);if(S!==-1)k=I.substring(S+1).trim();try{let b=`Boolean(${M})`,y;if(Z0(b)){let m=Y0(b,Object.keys(Z));y=Boolean(m(...Object.values(Z)))}else y=Boolean($0(b,Z));let d=O?!y:y,f="";if(d){let m=W(E,G,Y);if(m&&await Bun.file(m).exists())J.add(m);f=`@include('${E}'${k?`, ${k}`:""})`}K=K.substring(0,H)+f+K.substring(w),L.lastIndex=0}catch(b){let y=b instanceof Error?b.message:String(b),d=Q0("Include",`Error evaluating ${j} condition: ${y}`,Y,$,H);K=K.substring(0,H)+d+K.substring(w),L.lastIndex=0}}}{let j=/@each\s*\(/g,O;while((O=j.exec(K))!==null){let L=O.index,F=L+O[0].length-1,H=1,V=F+1;while(V<K.length&&H>0){if(K[V]==="(")H++;else if(K[V]===")"){if(H--,H===0)break}V++}if(H!==0)break;let A=K.substring(F+1,V),w=K.substring(L,V+1),R=A.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!R){j.lastIndex=0,K=K.replace(w,"");continue}let[,N,M,T,D]=R;try{let E,I=M.trim();if(Z0(I))E=Y0(I,Object.keys(Z))(...Object.values(Z));else E=$0(I,Z);let k="";if(Array.isArray(E)&&E.length>0)for(let S of E){let b={...Z,[T]:S},y=await q(N,b,$,L);k+=y}else if(D)k=await q(D,{},$,L);K=K.substring(0,L)+k+K.substring(V+1),j.lastIndex=0}catch(E){let I=E instanceof Error?E.message:String(E);K=K.substring(0,L)+Q0("Each",`Error in @each: ${I}`,Y,$,L)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,O;while((O=j.exec(K))!==null){let L=O.index,F=L+O[0].length-1,H=1,V=F+1;while(V<K.length&&H>0){if(K[V]==="(")H++;else if(K[V]===")"){if(H--,H===0)break}V++}if(H!==0)break;let A=K.substring(F+1,V),w=K.substring(L,V+1),R=A.match(/^\s*(\[[^\]]+\])/);if(!R){j.lastIndex=0,K=K.replace(w,"");continue}let N=R[1],M=A.slice(R[0].length),T,D=M.match(/^\s*,\s*\{/);if(D){M=M.slice(D[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 E,I=M.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(I)E=I[1];try{let k=JSON.parse(N.replace(/'/g,'"')),S={};if(T)try{S=L0(T,Z)}catch(y){let d=y instanceof Error?y.message:String(y);if(X.debug){let f=Q0("Include",`Error parsing includeFirst variables: ${d}`,Y,$,L,w);K=K.replace(w,()=>f)}else K=K.replace(w,()=>E||"");continue}let b=!1;for(let y of k){let d=W(y,G,Y);if(!d)continue;if(await i(d)){let f=await q(y,S,$,L);K=K.replace(w,()=>f),b=!0;break}}if(!b)if(E!==void 0)K=K.replace(w,()=>E);else if(X.debug){let y=Q0("Include",`None of the includeFirst paths exist: ${N}`,Y,$,L,w);K=K.replace(w,()=>y)}else K=K.replace(w,"")}catch(k){let S=k instanceof Error?k.message:String(k),b=Q0("Include",`Error processing @includeFirst: ${S}`,Y,$,L,w);K=K.replace(w,()=>b)}j.lastIndex=0}}function W(j,O,L){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let H=z0.resolve(O),V=z0.resolve(z0.dirname(L)),A;if(!F.startsWith("./")&&!F.startsWith("../"))A=z0.resolve(O,F);else A=z0.resolve(V,F);let w=z0.normalize(A),R=w.startsWith(H+z0.sep)||w===H,N=w.startsWith(V+z0.sep)||w===V,M=!1,T=z0.dirname(V);if(w.startsWith(T+z0.sep)){if(!z0.relative(T,w).split(z0.sep).some((k)=>k.startsWith(".")&&k!=="."&&k!==".."))M=!0}if(!R&&!N&&!M)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${w}`),console.error(` Allowed dirs: ${H}, ${V}`),null;return w}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let U=z0.resolve(Y);Q.add(U);async function q(j,O={},L,F){let H=W(j,G,Y);if(!H)return Q0("Include",`Could not resolve path for include: ${j}`,Y,L,F);let V=z0.resolve(H);if(Q.has(V)){let A=[...Q,V].map((w)=>z0.basename(w)).join(" -> ");return Q0("Include",`Circular include detected: ${A}`,Y,L,F)}try{J.add(H);let A;if(!A)try{A=await Bun.file(H).text()}catch(f){let m=f instanceof Error?f.message:String(f);return Q0("Include",`Error loading include file ${j}: ${m}`,Y,L,F)}if(A&&A.includes("@stream")){let{processStreamDirectives:f}=await Promise.resolve().then(() => (e9(),t9));A=f(A,Z)}if(A&&(X.debug||!q$()&&!d4()))try{let{warnUnbalancedTags:f}=await Promise.resolve().then(() => (Z8(),M2));f(A,H)}catch{}let w=A;try{let{processESImports:f}=await Promise.resolve().then(() => (S8(),i2));await f(A,Z,H,X,J)}catch(f){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${H}:`,f instanceof Error?f.message:f)}let R=w.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(R)w=R[1].trim();let M=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),T="";if(M)T=`<style${M[1]}>${M[2]}</style>`;w=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),w=w.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let D={...Z};for(let[f,m]of Object.entries(O))D[f]=m;let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[...A.matchAll(E)],k="",S=null;for(let f of I){let m=f[1]||"",o=f[2]||"",I0=m.includes("server"),q1=K5(m),h0="";try{let{extractAndStripCssImports:J0,renderVendorStyleTags:A0}=await Promise.resolve().then(() => (k$(),_J)),B0=J0(o,{filePath:H,projectRoot:process.cwd()});o=B0.code,h0=A0(B0.styles)}catch(J0){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${H}:`,J0 instanceof Error?J0.message:J0)}if(q1&&o.trim())o=z5(o);if(!I0)try{let{hasUserImports:J0,bundleClientScript:A0}=await Promise.resolve().then(() => (W4(),z4));if(J0(o))o=await A0(o,H,{projectRoot:process.cwd()})}catch(J0){if(X.debug)console.warn(`[stx] bundler skipped for ${H}:`,J0 instanceof Error?J0.message:J0)}let C0=Tj(o);if(C0&&!I0){S=`stx_scope_${z0.basename(H,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++qJ}`;let J0=j1(o),A0=Dj(J0,S);k+=`${h0}<script data-stx-scoped>${A0}</script>
|
|
4248
|
+
`;continue}if(I0)try{let{extractVariables:J0}=await Promise.resolve().then(() => (I$(),L7));await J0(o,D,H)}catch(J0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${H}:`,J0)}if(!I0&&!C0){let J0=m.replace(/\bclient\b/i,"").trim();S=`stx_scope_${z0.basename(H,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++qJ}`;let A0=j1(o),B0=`
|
|
4249
4249
|
if (!window.stx._scopes) window.stx._scopes = {};
|
|
4250
4250
|
window.stx._scopes['${S}'] = { __destroyCallbacks: __destroyHooks };
|
|
4251
|
-
`,
|
|
4252
|
-
`}}if(S){let f=Ej(w,S);if(w=f.html,f.mergedIntoExisting)k=k.replace(`window.stx._scopes['${S}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),S=f.mergedIntoExisting}if(w.includes("@include")||w.includes("@partial"))w=await x8(w,D,H,X,J,Q);let{processLoops:b}=await Promise.resolve().then(() => (y8(),UJ)),
|
|
4253
|
-
`+T;if(k)
|
|
4254
|
-
`+k;return
|
|
4251
|
+
`,C=BJ(A0,B0);k+=`${h0}<script data-stx-scoped${J0?` ${J0}`:""}>${C}</script>
|
|
4252
|
+
`}}if(S){let f=Ej(w,S);if(w=f.html,f.mergedIntoExisting)k=k.replace(`window.stx._scopes['${S}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),S=f.mergedIntoExisting}if(w.includes("@include")||w.includes("@partial"))w=await x8(w,D,H,X,J,Q);let{processLoops:b}=await Promise.resolve().then(() => (y8(),UJ)),y=b(w,D,H);y=Z5(y,D,H);let d=A5(A);if(y=Q1(y,D,H,{forceSignals:d}),T)y+=`
|
|
4253
|
+
`+T;if(k)y+=`
|
|
4254
|
+
`+k;return y}catch(A){let w=A instanceof Error?A.message:String(A);return Q0("Include",`Error processing include ${j}: ${w}`,Y,L,F)}}let _=/@include\s*\(/g,B;while((B=_.exec(K))!==null){let j=B.index,O=j+B[0].length-1,L=1,F=O+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let H=K.substring(j,F),V=K.substring(O+1,F-1),A=V.match(/^\s*['"]([^'"]+)['"]/);if(!A){_.lastIndex=F;continue}let w=A[1],R,N=V.substring(A[0].length),M=v8(N,0);if(M!==-1)R=N.substring(M+1).trim();let T={};if(R)try{T=L0(R,Z)}catch(E){let I=E instanceof Error?E.message:String(E);K=K.replace(H,Q0("Include",`Error parsing include variables for ${w}: ${I}`,Y,$,j)),_.lastIndex=0;continue}let D=await q(w,T,$,j);K=K.substring(0,j)+D+K.substring(F),_.lastIndex=0}return K}function f8($,Z){let Y=$;function X(J,Q,G,K){let z=J,W=!0;while(W){W=!1;let U=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),q=z.match(U);if(!q||q.index===void 0)break;let _=q.index,B=q[1],j=_+q[0].length,O=new RegExp(`@${Q}\\(`),L=new RegExp(`@${G}(?![a-z])`),F=1,H=j,V=-1;while(F>0&&H<z.length){let w=z.slice(H),R=w.match(O),N=w.match(L),M=R?H+R.index:1/0,T=N?H+N.index:1/0;if(M<T)F++,H=M+(R[0].length||1);else if(T<1/0){if(F--,F===0){V=T;break}H=T+G.length+1}else break}if(V===-1)break;let A=z.slice(j,V);if(!Z[B])Z[B]=[];if(K)Z[B].unshift(A);else Z[B].push(A);z=z.substring(0,_)+z.substring(V+`@${G}`.length),W=!0}return z}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 qJ=0,EE,jJ;var OJ=P(()=>{J7();G1();R5();R0();F0();EE=new G$(500),jJ=new Set});import*as h8 from"path";async function HJ($,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 FJ($,Z,Y,"@js","@endjs")}async function LJ($,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 FJ($,Z,Y,"@ts","@endts")}async function FJ($,Z,Y,X,J){let Q=$,G=n1(`${X}([\\s\\S]*?)${J}`,"g"),K=[],z;while((z=G.exec($))!==null)K.push({fullMatch:z[0],content:z[1]||"",index:z.index});for(let{fullMatch:W,content:U,index:q}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((w)=>w.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=L.length>0?`return { ${L.join(", ")} };`:"return {};",H=`
|
|
4256
4256
|
${j}
|
|
4257
4257
|
${F}
|
|
@@ -8736,10 +8736,10 @@ else {
|
|
|
8736
8736
|
var root = scriptEl ? scriptEl.nextElementSibling : null;
|
|
8737
8737
|
if (!root && scriptEl) root = scriptEl.previousElementSibling || scriptEl.parentElement;
|
|
8738
8738
|
|
|
8739
|
-
// SPA fallback: during router navigation, script is appended to
|
|
8739
|
+
// SPA fallback: during router navigation, script is appended to body>
|
|
8740
8740
|
// (not inside the content container), so nextElementSibling won't find the page content.
|
|
8741
8741
|
// Only use fallback when we genuinely couldn't find a suitable root element.
|
|
8742
|
-
// Do NOT fallback just because the script is in
|
|
8742
|
+
// Do NOT fallback just because the script is in body> \u2014 layout scripts in body>
|
|
8743
8743
|
// with valid siblings (e.g. sidebar <aside>) should use those siblings as root.
|
|
8744
8744
|
var needsFallback = !root || root === document.body
|
|
8745
8745
|
|| (root && root.tagName === 'SCRIPT');
|
|
@@ -9058,7 +9058,7 @@ else {
|
|
|
9058
9058
|
mountCallbacks.forEach(fn => fn());
|
|
9059
9059
|
});
|
|
9060
9060
|
|
|
9061
|
-
// Multi-root fragment fix: a no
|
|
9061
|
+
// Multi-root fragment fix: a no-body> setup page tags only the FIRST
|
|
9062
9062
|
// top-level element with data-stx (signal-processing.ts marks one element),
|
|
9063
9063
|
// so sibling root elements were orphaned \u2014 their :if / :for / {{ }} / x-text
|
|
9064
9064
|
// never hydrated, which read as "{{ }} doesn't work under :if/:for". The
|
|
@@ -9155,7 +9155,7 @@ else {
|
|
|
9155
9155
|
el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });
|
|
9156
9156
|
});
|
|
9157
9157
|
|
|
9158
|
-
// Process
|
|
9158
|
+
// Process head> elements (title, meta) that may contain {{ }} expressions
|
|
9159
9159
|
// Use componentScope which now contains variables from processed components
|
|
9160
9160
|
const headElements = document.querySelectorAll('head title, head meta[content]');
|
|
9161
9161
|
headElements.forEach(el => {
|
|
@@ -9351,7 +9351,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
|
|
|
9351
9351
|
|
|
9352
9352
|
// Apply new page's SFC setup function. During SPA navigation, re-executed page
|
|
9353
9353
|
// scripts set window.stx._latestSetup to the new setup function. This takes priority
|
|
9354
|
-
// over the stale data-stx attribute on
|
|
9354
|
+
// over the stale data-stx attribute on body> (which has the PREVIOUS page's function name).
|
|
9355
9355
|
var usedLatestSetup = false;
|
|
9356
9356
|
if (window.stx._latestSetup && typeof window.stx._latestSetup === 'function') {
|
|
9357
9357
|
try {
|
|
@@ -9435,7 +9435,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
|
|
|
9435
9435
|
|
|
9436
9436
|
// Process the container content \u2014 bind {{ }}, :attr, @event directives.
|
|
9437
9437
|
// Run synchronously (not in setTimeout) so componentScope is captured correctly.
|
|
9438
|
-
// The DOMContentLoaded path processes
|
|
9438
|
+
// The DOMContentLoaded path processes body> synchronously \u2014 the SPA path must match.
|
|
9439
9439
|
console.log('[stx:load] container:', container.tagName, '__stx_scope:', !!container.__stx_scope, 'scope keys:', Object.keys(componentScope).slice(0, 10));
|
|
9440
9440
|
if (!container.__stx_scope) {
|
|
9441
9441
|
// Dispose previous effects on the container (from prior navigation)
|
|
@@ -13416,24 +13416,24 @@ ${V}`:V,Z.__sections=j}}if(O)try{let H;if(x0.isAbsolute(O))H=O,J.add(O);else H=a
|
|
|
13416
13416
|
${z}`,q(z)}catch(H){return r0.log(H instanceof Error?H:Error(String(H)),{layoutPath:O,filePath:Y},"error"),`[Error processing layout: ${H instanceof Error?H.message:String(H)}]`}return q(await vG(z,Z,Y,G,J))}function _L($,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 BL($,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 jL($,Z){await I5(()=>EJ($,Z),void 0,(Y)=>{r0.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function OL($,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:z}=await Promise.resolve().then(() => (I$(),L7));await z(G,Z,Y,{preserveExisting:!0})}catch(z){let W=z instanceof Error?z:Error(String(z));r0.log(W,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${W.message}`)}}}async function HL($,Z,Y){try{let{interpolateScriptsInTemplate:X}=await Promise.resolve().then(() => (G1(),MZ));return X($,Z,{skipServer:!0})}catch(X){let J=X instanceof Error?X:Error(String(X));return r0.log(J,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${J.message}`),$}}async function vG($,Z,Y,X,J){let Q=$,G=X;if(await OL(Q,Z,Y),Q=await HL(Q,Z,Y),Q=await HJ(Q,Z,Y),Q=await LJ(Q,Z,Y),Q=await X2(Q,Z,Y,G),A5(Q))Q=a8(Q,Z),Q=e8(Q,Z);Q=t8(Q);let{processStreamDirectives:K}=await Promise.resolve().then(() => (e9(),t9));Q=K(Q,Z),Q=C8(Q,Z,Y,G),Q=await H7(Q,Z,Y,G,J),Q=await vJ(Q,Z,Y,G,J),Q=XZ(Q,Z,Y,G);let{processDeferDirectives:z}=await Promise.resolve().then(() => LQ);Q=z(Q,Z,Y);let{processTeleportDirectives:W}=await Promise.resolve().then(() => VQ);Q=W(Q,Z,Y);let{processTransitionDirectives:U,processTransitionAttributes:q}=await Promise.resolve().then(() => NQ);Q=U(Q,Z,Y),Q=q(Q);let{processErrorBoundaryDirectives:_}=await Promise.resolve().then(() => MQ);Q=_(Q,Z,Y);let{processSuspenseDirectives:B}=await Promise.resolve().then(() => DQ);Q=B(Q,Z,Y);let{processAsyncDirectives:j}=await Promise.resolve().then(() => SQ);Q=j(Q,Z,Y);let{processKeepAliveDirectives:O}=await Promise.resolve().then(() => PQ);Q=O(Q,Z,Y);let{processVirtualListDirectives:L,processVirtualGridDirectives:F,processInfiniteListDirectives:H}=await Promise.resolve().then(() => (gQ(),fQ));Q=L(Q,Z,Y),Q=F(Q,Z,Y),Q=H(Q,Z,Y);let{processPartialHydrationDirectives:V,processStaticDirectives:A}=await Promise.resolve().then(() => (eQ(),tQ));Q=V(Q,Z,Y),Q=A(Q);let{processComputedDirectives:w,processWatchDirectives:R}=await Promise.resolve().then(() => (qG(),UG));Q=w(Q,Z,Y),Q=R(Q,Z,Y);let{processFormValidationDirectives:N}=await Promise.resolve().then(() => (HG(),OG));Q=N(Q,Z,Y);let{processHeadDirective:M,processTitleDirective:T,processMetaDirective:D,resetHead:E}=await Promise.resolve().then(() => (F$(),d9));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)E();let I=M(Q);if(Q=I.content,I.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${I.headContent}
|
|
13417
13417
|
`;if(Q=T(Q,Z),Q=D(Q,Z),Q=MJ(Q),Q=y9(Q,Z),Q=Z2(Q),Q=wJ(Q),Q=await x8(Q,Z,Y,G,J),Q=await H7(Q,Z,Y,G,J),Q=Q.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),Q=Y3(Q),Q=Z5(Q,Z,Y),Q=v9(Q,Z),Q=x9(Q,Z),Q=A$(Q,Z),Q=m9(Q,Z),Q=l9(Q,Z),Q=await xX(Q,Z,Y,G),Q=await N6(Q,Z,Y),Q=await o9(Q,Z,Y,G),Q=U6(Q,Z,Y,G),Q=$X(Q,Z,Y,G),Q=ZX(Q,Z,Y),Q=YX(Q,Z,Y,G),Q=rX(Q,Z,Y,G),Q=g7(Q,Z),Q=h7(Q),Q=qQ(Q),!G.skipEventDirectives)Q=kX(Q,Z,Y);if(Q=yX(Q,Z,Y),G.debug){let x=/\bx-data\s*=/.test(Q),g=f7($);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=SJ(Q,Z),Q=await Q1(Q,Z,Y),Q=_Q(Q),Q=BQ(Q),Q=RX(Q);let{processXElementDirectives:k}=await Promise.resolve().then(() => VG);Q=k(Q);let S=Z.__originalFilePath||Y,b=v$(Z);if(Q=await $3(Q,G,S,b),Q=await NJ(Q,Z,Y,G),G.media?.image?.autoSiblings){let x=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (QZ(),JZ));Q=await g(Q,{publicDir:x})}if(G.seo?.enabled)Q=XX(Q,Z,G);let
|
|
13419
|
+
Prefer signals (state/derived/effect) for new components.`)}Q=SJ(Q,Z),Q=await Q1(Q,Z,Y),Q=_Q(Q),Q=BQ(Q),Q=RX(Q);let{processXElementDirectives:k}=await Promise.resolve().then(() => VG);Q=k(Q);let S=Z.__originalFilePath||Y,b=v$(Z);if(Q=await $3(Q,G,S,b),Q=await NJ(Q,Z,Y,G),G.media?.image?.autoSiblings){let x=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (QZ(),JZ));Q=await g(Q,{publicDir:x})}if(G.seo?.enabled)Q=XX(Q,Z,G);let y=(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(() => (F$(),d9)),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=
|
|
13424
|
+
</head>`);return x},{renderHead:d,getHead:f}=await Promise.resolve().then(() => (F$(),d9)),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=y(Q,x)}if(I.headContent)Q=y(Q,I.headContent);if(G.csp?.enabled&&G.csp.addMetaTag)Q=oX(Q,G.csp,Z);if(G.analytics?.enabled)Q=$Z(Q,G);if(G.heatmap?.enabled)Q=vZ(Q,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:x}=await Promise.resolve().then(() => (CG(),PG));Q=x(Q,G)}let I0=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(Q),q1=/\bSTX\.\w+/.test(Q),h0=/window\.STX\s*=/.test(Q);if(I0&&q1&&!h0){let g=`<script data-stx-scoped>
|
|
13425
13425
|
${FX()}
|
|
13426
|
-
</script>`;if(Q.includes("</head>")){let l=Q.indexOf("</head>"),G0=Q.slice(0,l).indexOf("<script");if(G0!==-1){let
|
|
13426
|
+
</script>`;if(Q.includes("</head>")){let l=Q.indexOf("</head>"),G0=Q.slice(0,l).indexOf("<script");if(G0!==-1){let k0=Q.slice(0,G0),d0=Q.slice(G0);Q=k0+g+`
|
|
13427
13427
|
`+d0}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,l=[];while((g=x.exec(Q))!==null){let r=g.index+g[0].length,G0=UL(Q,r);if(G0===-1)continue;let
|
|
13430
|
+
`+Q}{let x=/<script\s+server\b[^>]*>/gi,g,l=[];while((g=x.exec(Q))!==null){let r=g.index+g[0].length,G0=UL(Q,r);if(G0===-1)continue;let k0=G0+9;while(k0<Q.length&&/\s/.test(Q[k0]))k0++;l.push({start:g.index,end:k0}),x.lastIndex=k0}for(let r=l.length-1;r>=0;r--){let{start:G0,end:k0}=l[r];Q=Q.substring(0,G0)+Q.substring(k0)}}let C0=R7(Q,Y);if(C0.hasScoped)Q=C0.html;let J0=Z.__stx_event_bindings||[],A0=!1,B0=[],C=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:v}=await Promise.resolve().then(() => (Z3(),GQ));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)["'])[^"']*["']/}))B0.push({match:x.fullMatch,attrs:x.attrs,content:x.body});for(let{match:x,attrs:g,content:l}of B0){A0=!0;let r=l;d7(l,Y,X.strict);let G0=await x$(l,{eventBindings:J0,attrs:g,hasColonDirectives:C,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:b});Q=Q.replace(x,()=>G0)}if(A0)Z.__stx_event_bindings=[];return Q}var _5="<!--PARENT_CONTENT_PLACEHOLDER-->";var T$=P(()=>{OX();O4();G4();VX();NX();ZZ();R6();O6();SX();k$();vX();fX();J7();aX();Y2();Q2();O1();F$();G1();W2();F2();OJ();VJ();y8();M6();TJ();R5();DJ();j9();F0();IJ();bJ();yJ();xJ();u8();Z3();S8();UQ();X3();J3();R0();Z8();X3();J3()});function wL($){let Z=[],Y=[];return AL($,Z),RL($,Z,Y),NL($,Y),TL($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function AL($,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 RL($,Z,Y){for(let X of LL){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 z=new RegExp(X.altClose,"g");K+=($.match(z)||[]).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 NL($,Z){for(let Y of FL)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function TL($,Z){for(let Y of VL)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function ML($,Z){let Y=$.slice(0,Z).split(`
|
|
13431
13431
|
`);return{line:Y.length,column:Y[Y.length-1].length+1}}function DL($,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 EL($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function IL($){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 LL,FL,VL;var xG=P(()=>{LL=[{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"}],FL=[{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')"}],VL=[{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 uG={};u(uG,{renderSlot:()=>gG,processSlots:()=>dG,parseSlots:()=>fG,parseSlotElement:()=>SL,extractSlotContent:()=>CL,applySlots:()=>yL});function kL($,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 fG($){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,q,_,B,j]=Q,O=q||_||B,L=Q.index+U.length,F=kL($,L);if(F!==-1){let H=$.slice(L,F-11).trim();J.push({start:Q.index,end:F,slotName:O,content:H,propsBinding:j||void 0}),Z.named.set(O,{name:O,content:H,propsBinding:j||void 0})}}J.sort((U,q)=>q.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,z;while((z=K.exec(Y))!==null){let[U,q,_,B,j,O]=z,L=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),H=(L+F).trim(),V=`<${q}${H?" "+H:""}>${O}</${q}>`;G.push({start:z.index,end:z.index+U.length,slotName:B,element:V})}let W=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((z=W.exec(Y))!==null){let[U,q,_,B,j]=z,O=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(O+L).trim(),H=`<${q}${F?" "+F:""} />`;G.push({start:z.index,end:z.index+U.length,slotName:B,element:H})}G.sort((U,q)=>q.start-U.start);for(let U of G){let q=Z.named.get(U.slotName);if(q)q.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 SL($){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 gG($,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((z)=>z.trim()).filter(Boolean);for(let z of K){let[W,U]=z.split(":").map((_)=>_.trim()),q=U||W;if(Z[W]!==void 0)G[q]=Z[W]}}else G[Q]=Z;J=bL(J,G)}return J}function bL($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let J=X.trim(),Q=hG(J,Z);return s0(String(Q??""))}catch{return`{{ ${X} }}`}})}function hG($,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(!Z0($))return;return Y0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function dG($,Z,Y){let X=$;X=await PL(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,z,W)=>{let U=Z.named.get(K),q=W?.trim()||"",_=z||"",B={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,O;while((O=j.exec(_))!==null){let L=O[1],F=O[2];B[L]=hG(F,Y)}return await gG(U,B,q,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(Q,(G,K)=>{if(G.includes("name="))return G;let z=K?.trim()||"";return Z.default||z}),X}async function PL($,Z,Y){let X=[],J=[];$.replace(Z,(K,...z)=>{let W=z[z.length-2];return J.push({match:K,index:W}),X.push(Y(K,...z.slice(0,-2))),K});let Q=await Promise.all(X),G=$;for(let K=J.length-1;K>=0;K--){let{match:z,index:W}=J[K];G=G.slice(0,W)+Q[K]+G.slice(W+z.length)}return G}function CL($){let Z=fG($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function yL($,Z,Y,X){return await dG($,{default:Z,named:Y},X)}var mG=P(()=>{G1();R0()});import vL from"fs";import h from"path";function lG($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function fL($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function K5($){return!fL($)}function z5($){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:J1()}).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 gL($){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++}},z=()=>{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},W=()=>{if(X!==0)return;let U=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(U){let j=U[2].split(",").map((O)=>{let L=O.trim().split(":");return L[L.length-1].trim()});for(let O of j)if(O&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(O)&&!Y.has(O))Z.push(O),Y.add(O);return}let q=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(q){let j=q[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(z())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])))W();J++}return Z}function hL($){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 dL($){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 uL($,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 z=$[X];if(z==="}")Q++;else if(z==="{"){if(Q--,Q===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,J);for(let z of hL(K)){let W=z.trim();if(!W||W.startsWith("..."))continue;let U=dL(W);if(U===-1)continue;let q=W.slice(0,U).trim();if(!/^[A-Z_$][\w$]*$/i.test(q))continue;if(Z[q]!==void 0)continue;let _=W.slice(U+1).trim();if(!_)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${_});`);Z[q]=j(...B.map((O)=>Z[O]))}catch{}}}catch{}}async function n2($,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(),z=Y.__importedComponents;if(z){for(let L of[Q,Q.toLowerCase(),G(Q),K(Q)])if(z.has(L))return!0}let W=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],U=typeof J.root==="string"?h.resolve(J.root):void 0,q=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 O=J._pluginComponentDirs;if(Array.isArray(O))for(let L of O)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 i(h.resolve(h.dirname(X),`${Q}.stx`));for(let L of _){let F=h.isAbsolute(L)?L:h.resolve(q,L);for(let H of W)if(await i(h.join(F,H)))return!0}return!1}function mL($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function F1($,Z,Y,X,J,Q,G,K=new Set,z){let{extractVariables:W}=await Promise.resolve().then(() => (I$(),L7)),U=K??new Set;if(U.has($))return`[Circular component reference: ${$}]`;let q=new Set(U);q.add($);let _=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let B=_&&_!=="load"&&mL(_)?_:"";try{let 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},W=()=>{if(X!==0)return;let U=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(U){let j=U[2].split(",").map((O)=>{let L=O.trim().split(":");return L[L.length-1].trim()});for(let O of j)if(O&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(O)&&!Y.has(O))Z.push(O),Y.add(O);return}let q=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(q){let j=q[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(z())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])))W();J++}return Z}function hL($){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 dL($){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 uL($,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 z=$[X];if(z==="}")Q++;else if(z==="{"){if(Q--,Q===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,J);for(let z of hL(K)){let W=z.trim();if(!W||W.startsWith("..."))continue;let U=dL(W);if(U===-1)continue;let q=W.slice(0,U).trim();if(!/^[A-Z_$][\w$]*$/i.test(q))continue;if(Z[q]!==void 0)continue;let _=W.slice(U+1).trim();if(!_)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${_});`);Z[q]=j(...B.map((O)=>Z[O]))}catch{}}}catch{}}async function n2($,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(),z=Y.__importedComponents;if(z){for(let L of[Q,Q.toLowerCase(),G(Q),K(Q)])if(z.has(L))return!0}let W=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],U=typeof J.root==="string"?h.resolve(J.root):void 0,q=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 O=J._pluginComponentDirs;if(Array.isArray(O))for(let L of O)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 i(h.resolve(h.dirname(X),`${Q}.stx`));for(let L of _){let F=h.isAbsolute(L)?L:h.resolve(q,L);for(let H of W)if(await i(h.join(F,H)))return!0}return!1}function mL($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function F1($,Z,Y,X,J,Q,G,K=new Set,z){let{extractVariables:W}=await Promise.resolve().then(() => (I$(),L7)),U=K??new Set;if(U.has($))return`[Circular component reference: ${$}]`;let q=new Set(U);q.add($);let _=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let B=_&&_!=="load"&&mL(_)?_:"";try{let j=(C)=>C.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),O=(C)=>C.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),L=$.endsWith(".stx")?$.slice(0,-4):$,F=null,H=J.__importedComponents;if(H){let C=[L,L.toLowerCase(),j(L),O(L)];for(let v of C)if(H.has(v)){F=H.get(v);break}}let V=[];if(!F){let C=[`${L}.stx`,`${j(L)}.stx`,`${O(L)}.stx`],v=[...new Set(C)],x=J.__originalFilePath,g=[];if(x){let U0=h.join(h.dirname(x),"components");g.push(U0)}if(X)g.push(X);let l=h.join(h.dirname(Q),"components");if(!g.includes(l))g.push(l);if(G.componentsDir&&G.componentsDir!==X&&!g.includes(G.componentsDir))g.push(G.componentsDir);let r=G._pluginComponentDirs;if(Array.isArray(r)){for(let U0 of r)if(typeof U0==="string"&&!g.includes(U0))g.push(U0)}let G0=typeof G.root==="string"?h.resolve(G.root):void 0,k0=G0??h.dirname(Q),d0=[];if(G0)d0.push(h.resolve(G0,"resources/views/components")),d0.push(h.resolve(G0,"resources/components")),d0.push(h.resolve(G0,"src/components")),d0.push(h.resolve(G0,"components"));d0.push(h.resolve(import.meta.dir,"components"));for(let U0 of d0)if(!g.includes(U0))g.push(U0);let c1=[...new Set(g.map((U0)=>{if(!U0)return U0;return h.isAbsolute(U0)?U0:h.resolve(k0,U0)}))];if(g.length=0,g.push(...c1),L.startsWith("./")||L.startsWith("../"))F=h.resolve(h.dirname(Q),`${L}.stx`),V.push(F);else for(let U0 of g){if(!U0)continue;for(let p1 of v){let $$=h.join(U0,p1);if(V.push($$),await i($$)){F=$$;break}}if(F)break;if(!F)try{let p1=await import("fs");if(!p1.statSync(U0,{throwIfNoEntry:!1})?.isDirectory())continue;let $4=8,e=[{path:U0,depth:0}];while(e.length>0&&!F){let X1=e.pop();if(X1.depth>=$4)continue;let K6;try{K6=p1.readdirSync(X1.path,{withFileTypes:!0})}catch{continue}for(let Z4 of K6){if(!Z4.isDirectory())continue;if(Z4.name==="node_modules"||Z4.name.startsWith("."))continue;let n3=h.join(X1.path,Z4.name);for(let zz of v){let z6=h.join(n3,zz);if(V.push(z6),await i(z6)){F=z6;break}}if(F)break;e.push({path:n3,depth:X1.depth+1})}}}catch{}if(F)break}}if(!F||!await i(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 '${$}']${
|
|
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(() => (mG(),uG)),{defaultSlot:I0,namedSlots:q1}=m(Y);f=await o(f,I0||Y,q1,N);for(let[
|
|
13435
|
+
`)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${C}`}z.add(F);let A;if(f$.has(F))A=f$.get(F);else try{A=await Bun.file(F).text(),f$.set(F,A)}catch(C){return`[Error loading component: ${C instanceof Error?C.message:String(C)}]`}let w=new Set(["__originalFilePath","__importedComponents"]),R={};for(let[C,v]of Object.entries(J))if(!C.startsWith("__")||w.has(C))R[C]=v;let N={...R,...Z,props:Z,slot:Y,__processedComponents:q,__sections:{}};uL(A,N);let M=A,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 D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...A.matchAll(D)],I=[];for(let C of E){let v=C[1]||"",x=C[2]||"",g=v.includes("server");if(K5(v)&&x.trim())x=z5(x);if(g&&x)try{await W(x,N,F)}catch(r){}if(!g){let r=x.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(r.includes("{{")&&r.includes("}}"))r=Q1(r,N,F);let G0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");I.push(`<script${G0}>${r}</script>`)}}let k=A.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),S=k?k[1]:"",b=k?k[2]:"",y="",d=S&&/\bscoped\b/i.test(S);if(k)y=`<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 l=g.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(l)v.push(`<style${l[1]}>${l[2]}</style>`);return""}),f=f.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)y=`${y}${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(() => (mG(),uG)),{defaultSlot:I0,namedSlots:q1}=m(Y);f=await o(f,I0||Y,q1,N);for(let[C,v]of Object.entries(N))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("<")||v.includes(""")){let x=w6(v);N[C]=x}}let h0=I.some((C)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(C)),C0={...G,componentsDir:h.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:h0,defaultLayout:void 0};N.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let J0=await T0(f,N,F,C0,z),A0=`stx_${L.replace(/[^a-zA-Z0-9]/g,"_")}_${++xL}_${Math.random().toString(36).slice(2,8)}`,B0=J0;if(h0){let C="";if(Object.keys(Z).length>0)try{C=` data-stx-props="${lG(JSON.stringify(Z))}"`}catch{}let v=B?` stx-hydrate="${lG(B)}"`:"";if(B0=`<div data-stx-scope="${A0}"${C}${v}>${J0}</div>`,B0=I.map((g)=>{let l=g.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!l)return g;let[,r,G0]=l,k0=j1(G0),d0=`
|
|
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
|
-
${
|
|
13448
|
+
${k0}
|
|
13449
13449
|
|
|
13450
13450
|
// Register all defined signals and functions in this scope
|
|
13451
13451
|
const __localVars = {};
|
|
13452
13452
|
try {
|
|
13453
|
-
${gL(
|
|
13453
|
+
${gL(k0).map((c1)=>`if (typeof ${c1} !== 'undefined') __localVars['${c1}'] = ${c1};`).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="${A0}" data-stx-scoped${r}>${d0}</script>`;return`<script data-stx-scoped${r}>${d0}</script>`}).join(`
|
|
13459
13459
|
`)+`
|
|
13460
|
-
`+B0,
|
|
13461
|
-
`+
|
|
13462
|
-
`+
|
|
13460
|
+
`+B0,y)B0+=`
|
|
13461
|
+
`+y}else{if(y)B0+=`
|
|
13462
|
+
`+y;if(I.length>0){let C=N.__stx_event_bindings||[],v=v$(N),x=await Promise.all(I.map(async(g)=>{let l=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!l)return g;return await x$(l[1],{eventBindings:C,templateContent:B0,filePath:F,projectRoot:process.cwd(),serverData:v})}));B0+=`
|
|
13463
13463
|
`+x.join(`
|
|
13464
|
-
`),N.__stx_event_bindings=[]}}if(d){let
|
|
13464
|
+
`),N.__stx_event_bindings=[]}}if(d){let C=R7(B0,F);if(C.hasScoped)B0=C.html}return B0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{U.delete($)}}async function i($){return Bun.file($).exists()}function _3($,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 i4($,Z,Y,X){let J=await lL($,Z,Y,X);if(J===null)return null;let Q=_3(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 z=h.isAbsolute(K)?K:h.resolve(process.cwd(),K);if(_3(J,z))return h.resolve(J)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${$}, from: ${Z})`),null}async function lL($,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=_3(_,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 i(B)&&X)X.add(B);return B}let G=h.join(J,$);if(await i(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 i(B)){if(Y.debug)console.log(`Found direct path with extension: ${B}`);if(X)X.add(B);return B}}let K="",z=h.resolve(J),W=process.cwd();for(let _=0;_<10;_++){let B=h.join(z,"layouts"),j=!1;try{j=vL.statSync(B,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=B;break}let O=h.dirname(z);if(O===z||O.length<W.length)break;z=O}if(K){let _=$.startsWith("layouts/")?$.slice(8):$,B=h.join(K,_);if(await i(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 i(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 i(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(X)X.add(j);return j}if(!$.endsWith(".stx")){let O=`${j}.stx`;if(await i(O)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${O}`);if(X)X.add(O);return O}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let _=$.split("layouts/"),B=h.join(Y.partialsDir||J,"layouts",_[1]);if(await i(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 i(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 i(K)){let _=h.join(K,$);if(await i(_)){if(Y.debug)console.log(`Found in partials layouts dir: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await i(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"),q=h.join(U,$);if(await i(q)){if(Y.debug)console.log(`Found in views path: ${q}`);if(X)X.add(q);return q}if(!$.endsWith(".stx")){let _=`${q}.stx`;if(await i(_)){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 i(_)){if(Y.debug)console.log(`Found in temp layouts dir: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await i(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 cG($,Z,Y){let X=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
|
|
13465
13465
|
`),K=0;for(let z=0;z<G.length;z++)if(K+=G[z].length+1,K>=Z){X=z+1,J=G[z].trim();let W=Math.max(0,z-2),U=Math.min(G.length,z+3);Q=G.slice(W,U).map((q,_)=>{let B=W+_+1;return`${B===X?"> ":" "}${B}: ${q}`}).join(`
|
|
13466
13466
|
`);break}}else if(Y){let G=$.indexOf(Y);if(G>=0)return cG($,G)}}catch{}return{lineNumber:X,lineContent:J,context:Q}}function Q0($,Z,Y,X,J,Q){let{lineNumber:G,context:K}=cG(X,J,Q),z=Y.split("/").pop(),W=0;if(typeof J==="number"&&J>=0&&X){let q=X.lastIndexOf(`
|
|
13467
13467
|
`,Math.max(0,J-1));W=J-(q+1)+1}let U="";if(G>0)U+=`
|