@stacksjs/stx 0.2.48 → 0.2.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/dist/cli.js +160 -160
  2. package/dist/index.js +109 -109
  3. package/dist/pwa.js +150 -150
  4. package/dist/ssg.js +106 -106
  5. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ var sF=Object.defineProperty;var aF=($)=>$;function oF($,Z){this[$]=aF.bind(null
12
12
  white-space: nowrap;
13
13
  border-width: 0;
14
14
  }
15
- `.trim()}function jK(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function $V($,Z){let Y=[],X=/<img\s+([^>]*)>/gi,J;J=X.exec($);while(J!==null){let O=J[1];if(!/\balt\s*=/i.test(O))Y.push({type:"missing-alt",element:J[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});J=X.exec($)}let Q=/<button([^>]*)>\s*<\/button>/gi;J=Q.exec($);while(J!==null){let O=J[1];if(!/\baria-label\s*=/i.test(O)&&!/\btitle\s*=/i.test(O))Y.push({type:"missing-accessible-name",element:J[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});J=Q.exec($)}let G=/<a\s+([^>]*)>\s*<\/a>/gi;J=G.exec($);while(J!==null){let O=J[1];if(!/\baria-label\s*=/i.test(O)&&!/\btitle\s*=/i.test(O))Y.push({type:"link-missing-text",element:J[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});J=G.exec($)}let K=/<(input|select|textarea)\s+([^>]*)>/gi;J=K.exec($);while(J!==null){let O=J[2];if(/\btype\s*=\s*["']hidden["']/i.test(O)){J=K.exec($);continue}let F=/\baria-label\s*=/i.test(O)||/\baria-labelledby\s*=/i.test(O),L=O.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!F){let V=L&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${L[1]}["']`,"i").test($),N=J.index,A=$.substring(0,N),w=$.substring(N),M=(A.match(/<label\b/gi)||[]).length,E=(A.match(/<\/label>/gi)||[]).length,I=M>E;if(!V&&!I)Y.push({type:"input-missing-label",element:J[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}J=K.exec($)}let W=/<h([1-6])[^>]*>/gi,U=[];J=W.exec($);while(J!==null)U.push(Number.parseInt(J[1],10)),J=W.exec($);let _=0;for(let O of U){if(_>0&&O>_+1)Y.push({type:"heading-skip",element:`<h${O}>`,message:`Heading level skipped from h${_} to h${O}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});_=O}if(/<html\b/i.test($)&&!/<html[^>]*\slang\s*=/i.test($))Y.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let B=/<table[^>]*>([\s\S]*?)<\/table>/gi;J=B.exec($);while(J!==null){let O=J[1];if(!/<th\b/i.test(O))Y.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});J=B.exec($)}let z=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;J=z.exec($);while(J!==null){if(!/\bmuted\b/i.test(J[0]))Y.push({type:"autoplay-audio",element:`<${J[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});J=z.exec($)}let q=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;J=q.exec($);while(J!==null)Y.push({type:"positive-tabindex",element:`tabindex="${J[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),J=q.exec($);let j=/<iframe\s+([^>]*)>/gi;J=j.exec($);while(J!==null){let O=J[1];if(!/\btitle\s*=/i.test(O)&&!/\baria-label\s*=/i.test(O))Y.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});J=j.exec($)}let H=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;J=H.exec($);while(J!==null){let O=J[1].toLowerCase(),F=J[2];if(O!=="button"&&!/\btabindex\s*=/i.test(F))Y.push({type:"button-not-focusable",element:J[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});J=H.exec($)}return Y}async function j8($,Z){if(!jK())return $V($,Z);let Y=[];try{let X=globalThis.document.createElement("div");X.innerHTML=$,X.querySelectorAll("img").forEach((K)=>{if(!K.hasAttribute("alt"))Y.push({type:"missing-alt",element:`<${K.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),X.querySelectorAll('button, a, [role="button"]').forEach((K)=>{if(!(K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby")||K.textContent&&K.textContent.trim().length>0))Y.push({type:"missing-accessible-name",element:`<${K.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),X.querySelectorAll("input, select, textarea").forEach((K)=>{let W=K.getAttribute("id"),U=W&&X.querySelector(`label[for="${W}"]`),_=K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby"),B=K.closest("label")!==null;if(!U&&!_&&!B)Y.push({type:"input-missing-label",element:`<${K.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let J=Array.from(X.querySelectorAll("h1, h2, h3, h4, h5, h6")),Q=0;for(let K of J){let W=Number.parseInt(K.tagName.charAt(1));if(Q>0&&W>Q+1)Y.push({type:"heading-skip",element:`<${K.outerHTML}>`,message:`Heading level skipped from h${Q} to h${W}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});Q=W}let G=X.querySelector("html");if($.includes("<html")&&G&&!G.hasAttribute("lang"))Y.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(X.querySelectorAll("a").forEach((K)=>{let W=K.textContent&&K.textContent.trim().length>0,U=K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby"),_=K.hasAttribute("title"),B=K.querySelector("img[alt]");if(!W&&!U&&!_&&!B)Y.push({type:"link-missing-text",element:`<${K.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),$.includes("<nav")||$.includes("<header")){if(!X.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&X.querySelectorAll("a").length>5)Y.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(X.querySelectorAll("table").forEach((K)=>{let W=K.querySelector("caption");if(!K.querySelector("th"))Y.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!W&&!K.hasAttribute("aria-label")&&!K.hasAttribute("aria-labelledby"))Y.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),X.querySelectorAll('[style*="color"]').forEach((K)=>{let W=K.getAttribute("style")||"";if(W.includes("color:")&&!W.includes("background"))Y.push({type:"potential-contrast-issue",element:`<${K.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),X.querySelectorAll("video[autoplay], audio[autoplay]").forEach((K)=>{if(!K.hasAttribute("muted"))Y.push({type:"autoplay-audio",element:`<${K.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),X.querySelectorAll("[tabindex]").forEach((K)=>{if(Number.parseInt(K.getAttribute("tabindex")||"0")>0)Y.push({type:"positive-tabindex",element:`<${K.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),X.querySelectorAll('[role="button"]').forEach((K)=>{if(!K.hasAttribute("tabindex"))Y.push({type:"button-not-focusable",element:`<${K.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),$.includes("<body")&&!X.querySelector('main, [role="main"]'))Y.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});X.querySelectorAll("iframe").forEach((K)=>{if(!K.hasAttribute("title")&&!K.hasAttribute("aria-label"))Y.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(X){console.error(`Error checking accessibility in ${Z}:`,X)}return Y}async function DY($,Z={}){let Y={},{recursive:X=!0,ignorePaths:J=[]}=Z,Q=q8.join($,X?"**/*.stx":"*.stx"),G=new Bun.Glob(Q),K=[];for await(let W of G.scan())if(!J.some((_)=>W.includes(q8.normalize(_))))K.push(W);for(let W of K)try{let U=await Bun.file(W).text();if(W.endsWith("good-a11y.stx"))continue;let _=await j8(U,W);if(_.length>0)Y[W]=_}catch(U){console.error(`Error scanning ${W}:`,U)}return Y}function HK($,Z={}){let Y={...ZV,...Z},X=[],J=$;if(Y.fixMissingAlt)J=J.replace(/<img([^>]*?)(?<!\balt\s*=\s*["'][^"']*["'])(\s*\/?>)/gi,(Q,G,K)=>{if(/\balt\s*=/i.test(G))return Q;let W=Q,U=`<img${G} alt=""${K}`;return X.push({type:"missing-alt",description:"Added empty alt attribute to image",before:W,after:U}),U});if(Y.fixMissingLabels)J=J.replace(/<button([^>]*)>\s*<\/button>/gi,(Q,G)=>{if(/\baria-label\s*=/i.test(G)||/\btitle\s*=/i.test(G))return Q;let K=Q,W=`<button${G} aria-label="Button"></button>`;return X.push({type:"missing-accessible-name",description:"Added aria-label to empty button",before:K,after:W}),W}),J=J.replace(/<a([^>]*)>\s*(<(?:i|span|svg)[^>]*(?:class="[^"]*icon[^"]*")?[^>]*>.*?<\/(?:i|span|svg)>)?\s*<\/a>/gi,(Q,G,K)=>{if(/\baria-label\s*=/i.test(G)||/\btitle\s*=/i.test(G))return Q;if(!K&&Q.replace(/<a[^>]*>|<\/a>/gi,"").trim())return Q;let W=Q,U=`<a${G} aria-label="Link">${K||""}</a>`;return X.push({type:"missing-accessible-name",description:"Added aria-label to link without text",before:W,after:U}),U});if(Y.fixMissingFormLabels)J=J.replace(/<(input|select|textarea)([^>]*)>/gi,(Q,G,K)=>{if(/\baria-label\s*=/i.test(K)||/\baria-labelledby\s*=/i.test(K))return Q;if(/\btype\s*=\s*["']hidden["']/i.test(K))return Q;let W=K.match(/\bname\s*=\s*["']([^"']+)["']/i),U=K.match(/\bid\s*=\s*["']([^"']+)["']/i),_=W?.[1]||U?.[1]||G,B=Q,z=`<${G}${K} aria-label="${_}">`;return X.push({type:"input-missing-label",description:`Added aria-label to ${G} element`,before:B,after:z}),z});if(Y.fixMissingLang)J=J.replace(/<html([^>]*)>/gi,(Q,G)=>{if(/\blang\s*=/i.test(G))return Q;let K=Q,W=`<html${G} lang="${Y.defaultLang}">`;return X.push({type:"missing-lang",description:`Added lang="${Y.defaultLang}" to html element`,before:K,after:W}),W});if(Y.fixPositiveTabindex)J=J.replace(/\btabindex\s*=\s*["']([1-9]\d*)["']/gi,(Q,G)=>{let K=Q,W='tabindex="0"';return X.push({type:"positive-tabindex",description:`Changed tabindex="${G}" to tabindex="0"`,before:K,after:'tabindex="0"'}),'tabindex="0"'});if(Y.fixButtonFocusable)J=J.replace(/<([a-z]+)(\s[^>]*role\s*=\s*["']button["'][^>]*)>/gi,(Q,G,K)=>{if(/\btabindex\s*=/i.test(K))return Q;if(G.toLowerCase()==="button")return Q;let W=Q,U=`<${G}${K} tabindex="0">`;return X.push({type:"button-not-focusable",description:'Added tabindex="0" to element with role="button"',before:W,after:U}),U});if(Y.fixTableHeaders)J=J.replace(/<th([^>]*)>/gi,(Q,G)=>{if(/\bscope\s*=/i.test(G))return Q;let K=Q,W=`<th${G} scope="col">`;return X.push({type:"table-missing-scope",description:'Added scope="col" to table header',before:K,after:W}),W});return{original:$,fixed:J,fixCount:X.length,fixes:X}}async function OK($,Z={},Y=!1){let X=await Bun.file($).text(),J=HK(X,Z);if(Y&&J.fixCount>0)await Bun.write($,J.fixed);return J}async function YV($,Z={},Y={}){let X={},{recursive:J=!0,ignorePaths:Q=[],writeBack:G=!1,extensions:K=[".stx",".html",".htm"]}=Y,W=K.length===1?`*${K[0]}`:`*{${K.join(",")}}`,U=q8.join($,J?`**/${W}`:W),_=new Bun.Glob(U);for await(let B of _.scan()){if(Q.some((q)=>B.includes(q8.normalize(q))))continue;try{let q=await OK(B,Z,G);if(q.fixCount>0)X[B]=q}catch(q){console.error(`Error fixing ${B}:`,q)}}return X}function XV(){return[H8,O8]}var ZV,H8,O8;var R6=D(()=>{ZV={fixMissingAlt:!0,fixMissingLabels:!0,fixMissingFormLabels:!0,fixTableHeaders:!0,fixMissingLang:!0,fixPositiveTabindex:!0,fixButtonFocusable:!0,defaultLang:"en"};H8={name:"a11y",handler:($,Z,Y,X)=>{if(!Z.length)return $;let J=Z[0].replace(/['"]/g,""),Q=Z.length>1?Z[1].replace(/['"]/g,""):"",K={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[J]||"Make this element accessible";return`<!-- a11y-hint: ${Q||K} -->${$}`},hasEndTag:!1},O8={name:"screenReader",handler:($)=>{return`<span class="sr-only">${$}</span>`},hasEndTag:!0}});function JV($,Z={}){let{duration:Y,delay:X,ease:J,direction:Q,custom:G}={...b1,...Z};if($==="custom"&&G)return G;switch($){case"fade":return`${Q==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":Q==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
15
+ `.trim()}function jK(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function $V($,Z){let Y=[],X=/<img\s+([^>]*)>/gi,J;J=X.exec($);while(J!==null){let O=J[1];if(!/\balt\s*=/i.test(O))Y.push({type:"missing-alt",element:J[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});J=X.exec($)}let Q=/<button([^>]*)>\s*<\/button>/gi;J=Q.exec($);while(J!==null){let O=J[1];if(!/\baria-label\s*=/i.test(O)&&!/\btitle\s*=/i.test(O))Y.push({type:"missing-accessible-name",element:J[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});J=Q.exec($)}let G=/<a\s+([^>]*)>\s*<\/a>/gi;J=G.exec($);while(J!==null){let O=J[1];if(!/\baria-label\s*=/i.test(O)&&!/\btitle\s*=/i.test(O))Y.push({type:"link-missing-text",element:J[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});J=G.exec($)}let K=/<(input|select|textarea)\s+([^>]*)>/gi;J=K.exec($);while(J!==null){let O=J[2];if(/\btype\s*=\s*["']hidden["']/i.test(O)){J=K.exec($);continue}let F=/\baria-label\s*=/i.test(O)||/\baria-labelledby\s*=/i.test(O),L=O.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!F){let V=L&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${L[1]}["']`,"i").test($),N=J.index,A=$.substring(0,N),w=$.substring(N),M=(A.match(/<label\b/gi)||[]).length,E=(A.match(/<\/label>/gi)||[]).length,T=M>E;if(!V&&!T)Y.push({type:"input-missing-label",element:J[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}J=K.exec($)}let W=/<h([1-6])[^>]*>/gi,U=[];J=W.exec($);while(J!==null)U.push(Number.parseInt(J[1],10)),J=W.exec($);let _=0;for(let O of U){if(_>0&&O>_+1)Y.push({type:"heading-skip",element:`<h${O}>`,message:`Heading level skipped from h${_} to h${O}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});_=O}if(/<html\b/i.test($)&&!/<html[^>]*\slang\s*=/i.test($))Y.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let B=/<table[^>]*>([\s\S]*?)<\/table>/gi;J=B.exec($);while(J!==null){let O=J[1];if(!/<th\b/i.test(O))Y.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});J=B.exec($)}let z=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;J=z.exec($);while(J!==null){if(!/\bmuted\b/i.test(J[0]))Y.push({type:"autoplay-audio",element:`<${J[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});J=z.exec($)}let q=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;J=q.exec($);while(J!==null)Y.push({type:"positive-tabindex",element:`tabindex="${J[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),J=q.exec($);let j=/<iframe\s+([^>]*)>/gi;J=j.exec($);while(J!==null){let O=J[1];if(!/\btitle\s*=/i.test(O)&&!/\baria-label\s*=/i.test(O))Y.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});J=j.exec($)}let H=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;J=H.exec($);while(J!==null){let O=J[1].toLowerCase(),F=J[2];if(O!=="button"&&!/\btabindex\s*=/i.test(F))Y.push({type:"button-not-focusable",element:J[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});J=H.exec($)}return Y}async function j8($,Z){if(!jK())return $V($,Z);let Y=[];try{let X=globalThis.document.createElement("div");X.innerHTML=$,X.querySelectorAll("img").forEach((K)=>{if(!K.hasAttribute("alt"))Y.push({type:"missing-alt",element:`<${K.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),X.querySelectorAll('button, a, [role="button"]').forEach((K)=>{if(!(K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby")||K.textContent&&K.textContent.trim().length>0))Y.push({type:"missing-accessible-name",element:`<${K.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),X.querySelectorAll("input, select, textarea").forEach((K)=>{let W=K.getAttribute("id"),U=W&&X.querySelector(`label[for="${W}"]`),_=K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby"),B=K.closest("label")!==null;if(!U&&!_&&!B)Y.push({type:"input-missing-label",element:`<${K.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let J=Array.from(X.querySelectorAll("h1, h2, h3, h4, h5, h6")),Q=0;for(let K of J){let W=Number.parseInt(K.tagName.charAt(1));if(Q>0&&W>Q+1)Y.push({type:"heading-skip",element:`<${K.outerHTML}>`,message:`Heading level skipped from h${Q} to h${W}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});Q=W}let G=X.querySelector("html");if($.includes("<html")&&G&&!G.hasAttribute("lang"))Y.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(X.querySelectorAll("a").forEach((K)=>{let W=K.textContent&&K.textContent.trim().length>0,U=K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby"),_=K.hasAttribute("title"),B=K.querySelector("img[alt]");if(!W&&!U&&!_&&!B)Y.push({type:"link-missing-text",element:`<${K.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),$.includes("<nav")||$.includes("<header")){if(!X.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&X.querySelectorAll("a").length>5)Y.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(X.querySelectorAll("table").forEach((K)=>{let W=K.querySelector("caption");if(!K.querySelector("th"))Y.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!W&&!K.hasAttribute("aria-label")&&!K.hasAttribute("aria-labelledby"))Y.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),X.querySelectorAll('[style*="color"]').forEach((K)=>{let W=K.getAttribute("style")||"";if(W.includes("color:")&&!W.includes("background"))Y.push({type:"potential-contrast-issue",element:`<${K.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),X.querySelectorAll("video[autoplay], audio[autoplay]").forEach((K)=>{if(!K.hasAttribute("muted"))Y.push({type:"autoplay-audio",element:`<${K.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),X.querySelectorAll("[tabindex]").forEach((K)=>{if(Number.parseInt(K.getAttribute("tabindex")||"0")>0)Y.push({type:"positive-tabindex",element:`<${K.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),X.querySelectorAll('[role="button"]').forEach((K)=>{if(!K.hasAttribute("tabindex"))Y.push({type:"button-not-focusable",element:`<${K.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),$.includes("<body")&&!X.querySelector('main, [role="main"]'))Y.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});X.querySelectorAll("iframe").forEach((K)=>{if(!K.hasAttribute("title")&&!K.hasAttribute("aria-label"))Y.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(X){console.error(`Error checking accessibility in ${Z}:`,X)}return Y}async function DY($,Z={}){let Y={},{recursive:X=!0,ignorePaths:J=[]}=Z,Q=q8.join($,X?"**/*.stx":"*.stx"),G=new Bun.Glob(Q),K=[];for await(let W of G.scan())if(!J.some((_)=>W.includes(q8.normalize(_))))K.push(W);for(let W of K)try{let U=await Bun.file(W).text();if(W.endsWith("good-a11y.stx"))continue;let _=await j8(U,W);if(_.length>0)Y[W]=_}catch(U){console.error(`Error scanning ${W}:`,U)}return Y}function HK($,Z={}){let Y={...ZV,...Z},X=[],J=$;if(Y.fixMissingAlt)J=J.replace(/<img([^>]*?)(?<!\balt\s*=\s*["'][^"']*["'])(\s*\/?>)/gi,(Q,G,K)=>{if(/\balt\s*=/i.test(G))return Q;let W=Q,U=`<img${G} alt=""${K}`;return X.push({type:"missing-alt",description:"Added empty alt attribute to image",before:W,after:U}),U});if(Y.fixMissingLabels)J=J.replace(/<button([^>]*)>\s*<\/button>/gi,(Q,G)=>{if(/\baria-label\s*=/i.test(G)||/\btitle\s*=/i.test(G))return Q;let K=Q,W=`<button${G} aria-label="Button"></button>`;return X.push({type:"missing-accessible-name",description:"Added aria-label to empty button",before:K,after:W}),W}),J=J.replace(/<a([^>]*)>\s*(<(?:i|span|svg)[^>]*(?:class="[^"]*icon[^"]*")?[^>]*>.*?<\/(?:i|span|svg)>)?\s*<\/a>/gi,(Q,G,K)=>{if(/\baria-label\s*=/i.test(G)||/\btitle\s*=/i.test(G))return Q;if(!K&&Q.replace(/<a[^>]*>|<\/a>/gi,"").trim())return Q;let W=Q,U=`<a${G} aria-label="Link">${K||""}</a>`;return X.push({type:"missing-accessible-name",description:"Added aria-label to link without text",before:W,after:U}),U});if(Y.fixMissingFormLabels)J=J.replace(/<(input|select|textarea)([^>]*)>/gi,(Q,G,K)=>{if(/\baria-label\s*=/i.test(K)||/\baria-labelledby\s*=/i.test(K))return Q;if(/\btype\s*=\s*["']hidden["']/i.test(K))return Q;let W=K.match(/\bname\s*=\s*["']([^"']+)["']/i),U=K.match(/\bid\s*=\s*["']([^"']+)["']/i),_=W?.[1]||U?.[1]||G,B=Q,z=`<${G}${K} aria-label="${_}">`;return X.push({type:"input-missing-label",description:`Added aria-label to ${G} element`,before:B,after:z}),z});if(Y.fixMissingLang)J=J.replace(/<html([^>]*)>/gi,(Q,G)=>{if(/\blang\s*=/i.test(G))return Q;let K=Q,W=`<html${G} lang="${Y.defaultLang}">`;return X.push({type:"missing-lang",description:`Added lang="${Y.defaultLang}" to html element`,before:K,after:W}),W});if(Y.fixPositiveTabindex)J=J.replace(/\btabindex\s*=\s*["']([1-9]\d*)["']/gi,(Q,G)=>{let K=Q,W='tabindex="0"';return X.push({type:"positive-tabindex",description:`Changed tabindex="${G}" to tabindex="0"`,before:K,after:'tabindex="0"'}),'tabindex="0"'});if(Y.fixButtonFocusable)J=J.replace(/<([a-z]+)(\s[^>]*role\s*=\s*["']button["'][^>]*)>/gi,(Q,G,K)=>{if(/\btabindex\s*=/i.test(K))return Q;if(G.toLowerCase()==="button")return Q;let W=Q,U=`<${G}${K} tabindex="0">`;return X.push({type:"button-not-focusable",description:'Added tabindex="0" to element with role="button"',before:W,after:U}),U});if(Y.fixTableHeaders)J=J.replace(/<th([^>]*)>/gi,(Q,G)=>{if(/\bscope\s*=/i.test(G))return Q;let K=Q,W=`<th${G} scope="col">`;return X.push({type:"table-missing-scope",description:'Added scope="col" to table header',before:K,after:W}),W});return{original:$,fixed:J,fixCount:X.length,fixes:X}}async function OK($,Z={},Y=!1){let X=await Bun.file($).text(),J=HK(X,Z);if(Y&&J.fixCount>0)await Bun.write($,J.fixed);return J}async function YV($,Z={},Y={}){let X={},{recursive:J=!0,ignorePaths:Q=[],writeBack:G=!1,extensions:K=[".stx",".html",".htm"]}=Y,W=K.length===1?`*${K[0]}`:`*{${K.join(",")}}`,U=q8.join($,J?`**/${W}`:W),_=new Bun.Glob(U);for await(let B of _.scan()){if(Q.some((q)=>B.includes(q8.normalize(q))))continue;try{let q=await OK(B,Z,G);if(q.fixCount>0)X[B]=q}catch(q){console.error(`Error fixing ${B}:`,q)}}return X}function XV(){return[H8,O8]}var ZV,H8,O8;var R6=D(()=>{ZV={fixMissingAlt:!0,fixMissingLabels:!0,fixMissingFormLabels:!0,fixTableHeaders:!0,fixMissingLang:!0,fixPositiveTabindex:!0,fixButtonFocusable:!0,defaultLang:"en"};H8={name:"a11y",handler:($,Z,Y,X)=>{if(!Z.length)return $;let J=Z[0].replace(/['"]/g,""),Q=Z.length>1?Z[1].replace(/['"]/g,""):"",K={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[J]||"Make this element accessible";return`<!-- a11y-hint: ${Q||K} -->${$}`},hasEndTag:!1},O8={name:"screenReader",handler:($)=>{return`<span class="sr-only">${$}</span>`},hasEndTag:!0}});function JV($,Z={}){let{duration:Y,delay:X,ease:J,direction:Q,custom:G}={...b1,...Z};if($==="custom"&&G)return G;switch($){case"fade":return`${Q==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":Q==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
16
16
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
17
17
  @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }`;case"slide":return`${Q==="in"?"transform: translateY(20px); opacity: 0; animation: slideIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":Q==="out"?"transform: translateY(0); opacity: 1; animation: slideOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: translateY(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
18
18
  @keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@@ -904,7 +904,7 @@ catch (e) {
904
904
  throw e;
905
905
  }
906
906
  `),J.set(U,_)}return _(...K)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:G,context:Z.slice()});return G}clear(){this.pool.length=0,this.fnCache.clear()}}class mK{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,Z){this.budgets.set($,{warnThreshold:0.8,action:"warn",...Z})}setBudgets($){for(let[Z,Y]of Object.entries($))this.setBudget(Z,Y)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[Z,Y]of this.budgets.entries())$[Z]=Y;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let Z=this.violationHandlers.indexOf($);if(Z!==-1)this.violationHandlers.splice(Z,1)}time($,Z){if(!this.enabled)return Z();let Y=performance.now(),X=Z(),J=performance.now()-Y;return this.recordTime($,J),this.checkBudget($,J),X}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),X=await Z(),J=performance.now()-Y;return this.recordTime($,J),this.checkBudget($,J),X}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let X=Z/Y.maxTime*100,J=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,Q=Z>=Y.maxTime;if(!J&&!Q)return;let G={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:X,timestamp:new Date,isWarning:J};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let W of this.violationHandlers)try{W(G)}catch{}let K=J?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${X.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${(X-100).toFixed(1)}%)`;switch(Y.action){case"log":console.log(K);break;case"warn":console.warn(K);break;case"error":console.error(K);break;case"throw":if(Q)throw Error(K);else console.warn(K);break}}recordTime($,Z){let Y=this.metrics.get($);if(Y)Y.count++,Y.totalTime+=Z,Y.maxTime=Math.max(Y.maxTime,Z),Y.minTime=Math.min(Y.minTime,Z);else this.metrics.set($,{count:1,totalTime:Z,maxTime:Z,minTime:Z})}getStats($){if($){let Y=this.metrics.get($);if(!Y)return{};let X=this.budgets.get($);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:X?.maxTime,budgetUtilization:X?Y.totalTime/Y.count/X.maxTime*100:void 0}}let Z={};for(let[Y,X]of this.metrics.entries()){let J=this.budgets.get(Y);Z[Y]={count:X.count,avgTime:X.totalTime/X.count,totalTime:X.totalTime,maxTime:X.maxTime,minTime:X.minTime,budget:J?.maxTime,budgetUtilization:J?X.totalTime/X.count/J.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,Y=0;for(let X of this.violations)if($[X.label]=($[X.label]||0)+1,X.isWarning)Z++;else Y++;return{total:this.violations.length,byLabel:$,warnings:Z,errors:Y}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}function nV(){if(!lY)lY=new mK;return lY}var T6,iV=500,mP,lY=null,R1;var V4=D(()=>{T6=new Map;mP=new uK;R1=new Proxy({},{get($,Z){return nV()[Z]}})});var R;var Q5=D(()=>{R={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"}});var S8={};e(S8,{resetCssCache:()=>sV,resetCrosswindCache:()=>aV,rebuildCrosswindCSS:()=>K5,loadCrosswindConfig:()=>rY,loadCrosswind:()=>nY,injectCrosswindCSS:()=>E0,getCachedCSS:()=>oV,generateCrosswindCSS:()=>k8,extractClassNames:()=>D8,buildCrosswindCSS:()=>S6});import cK from"fs";import M0 from"path";async function pK($){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 rV(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==M0.dirname(Y))$.push(M0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(M0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(M0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),Y=M0.dirname(Y);if(Z){let X=[M0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),M0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),M0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),M0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),M0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),M0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(M0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(M0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function nY(){if(iY)return k6;iY=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await pK(Y);if(X)return k6=X,console.log(`${R.green}[Crosswind]${R.reset} CSS engine loaded`),k6}let Z=rV();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await pK(Y);if(X)return k6=X,console.log(`${R.green}[Crosswind]${R.reset} CSS engine loaded from ${M0.dirname(M0.dirname(Y))}`),k6}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${R.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${R.reset}`),console.warn(`${R.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${R.reset}`),null}}function sV(){I8.clear()}function aV(){k6=null,iY=!1,C1=null,G5="",I8.clear()}async function rY($){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=M0.relative($,Y.path);return console.log(`${R.green}[Crosswind]${R.reset} Loaded config from ${X||Y.path}`),Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${R.yellow}[Crosswind]${R.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function S6($){if(D6)return G5;D6=!0;try{let Z=await nY();if(!Z||!Z.build)return D6=!1,"";if(!C1)C1=await rY($);if(!C1)return D6=!1,"";let Y=Z.defaultConfig?.theme||{},X=C1.theme||{},J={...Z.defaultConfig,...C1,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(G5=G.css,console.log(`${R.cyan}[Crosswind]${R.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let W=M0.isAbsolute(J.output)?J.output:M0.join($,J.output),U=M0.dirname(W);if(!cK.existsSync(U))cK.mkdirSync(U,{recursive:!0});await Bun.write(W,G.css)}return D6=!1,G.css}catch(Z){return console.error(`${R.red}[Crosswind]${R.reset} Build error:`,Z),D6=!1,G5}}async function K5($){C1=null,await S6($)}function oV(){return G5}function D8($){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 W of K.slice(1,-1).split(/\s+/))if(W.trim())Z.add(W.trim())}Q=J.exec($)}return Z}async function k8($,Z){try{let Y=await nY();if(!Y)return"";let X=D8($);if(X.size===0)return"";let J=[...X].sort().join(" "),Q=I8.get(J);if(Q!==void 0)return Q;let G=Z?M0.resolve(Z):process.cwd();if(!C1){let V=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (p0(),sY)),A=await N(G);if(A.css)if(typeof A.css==="string"){let w=M0.isAbsolute(A.css)?A.css:M0.resolve(G,A.css);if(await Bun.file(w).exists()){let M=await import(w);V=M.default||M,console.log(`${R.green}[Crosswind]${R.reset} Loaded config from stx.config.ts \u2192 ${A.css}`)}}else{if(V={content:A.css.content||[],preflight:A.css.preflight??!0,minify:A.css.minify??!1},A.css.config){let w=M0.isAbsolute(A.css.config)?A.css.config:M0.resolve(G,A.css.config);if(await Bun.file(w).exists()){let M=await import(w);V={...M.default||M,...V}}}console.log(`${R.green}[Crosswind]${R.reset} Using inline CSS config from stx.config.ts`)}}catch{}C1=V||await rY(G)}let K=Y.defaultConfig||Y.config,W=C1||{},U=K.theme||{},B=(W.theme||{}).extend||{},z={...U};if(Object.keys(B).length>0)z.extend=B;let q=[...K.safelist||[],...W.safelist||[]],j={...K,...W,content:[],output:"",preflight:!0,minify:!1,theme:z,safelist:q},H=new Y.CSSGenerator(j);for(let V of q)H.generate(V);for(let V of X)H.generate(V);let O=H.toCSS(!0,!1),F=j.shortcuts||W.shortcuts||{};for(let[V,N]of Object.entries(F)){if(!X.has(V)&&!q.includes(V))continue;let A=N.split(/\s+/).filter(Boolean);for(let w of A)H.generate(w)}O=H.toCSS(!0,!1);let L=O.split(`
907
- `);for(let[V,N]of Object.entries(F)){if(!X.has(V)&&!q.includes(V))continue;let A=N.split(/\s+/).filter(Boolean),w=[],M=[];for(let E of A){let I=E.startsWith("dark:"),k=`.${(I?E.slice(5):E).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<L.length;b++){let y=L[b].trim();if(y===`${k} {`||y.startsWith(`${k} {`)){let v=b,C="";while(v<L.length){if(C+=L[v],L[v].includes("}"))break;v++}let f=C.match(/\{([^}]+)\}/);if(f)if(I)M.push(f[1].trim());else w.push(f[1].trim());break}}}if(w.length)O+=`
907
+ `);for(let[V,N]of Object.entries(F)){if(!X.has(V)&&!q.includes(V))continue;let A=N.split(/\s+/).filter(Boolean),w=[],M=[];for(let E of A){let T=E.startsWith("dark:"),k=`.${(T?E.slice(5):E).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let x=0;x<L.length;x++){let f=L[x].trim();if(f===`${k} {`||f.startsWith(`${k} {`)){let b=x,C="";while(b<L.length){if(C+=L[b],L[b].includes("}"))break;b++}let v=C.match(/\{([^}]+)\}/);if(v)if(T)M.push(v[1].trim());else w.push(v[1].trim());break}}}if(w.length)O+=`
908
908
  .${V} { ${w.join(" ")} }`;if(M.length)O+=`
909
909
  @media (prefers-color-scheme: dark) { .dark .${V} { ${M.join(" ")} } }`}return I8.set(J,O),O}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function E0($,Z){if($.includes('data-crosswind="generated"'))return $;let Y=await k8($,Z);if(!Y)return $;let X=`<style data-crosswind="generated">
910
910
  ${Y}
@@ -1778,7 +1778,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
1778
1778
  @end${K}`;X.push(`Added ${_} missing @end${K}`)}}if(X.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),X.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:Y,fixes:X}},createFallbackContent($,Z){if(A4())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};t0=new f8,P6={isDevelopment(){return A4()},logDetailedError($,Z){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",$.message),console.error("Stack:",$.stack),Z)console.error("Context:",Z);console.error("========================")},createErrorReport($,Z){let Y=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(Z)Y.push(`Context: ${JSON.stringify(Z,null,2)}`);return Y.push("========================"),Y.join(`
1779
1779
  `)}}});import WX from"path";function kA($){let Z={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return $.replace(/[&<>"']/g,(Y)=>Z[Y]||Y)}function B5($,Z={}){let{allowHtml:Y=!1,maxLength:X=1e4,allowSpecialChars:J=!0,customSanitizer:Q}=Z,G=[],K=$,W=!1;if(Q){let _=Q(K);if(_!==K)K=_,W=!0}if(K.includes("\x00"))K=K.replace(/\0/g,""),W=!0,G.push("Null bytes removed from parameter");if(K.length>X)K=K.substring(0,X),W=!0,G.push(`Parameter truncated to ${X} characters`);if(!Y&&/<[^>]+>/.test(K))K=kA(K),W=!0,G.push("HTML content was escaped");let U=[{pattern:/javascript:/gi,replacement:"",name:"javascript: URI"},{pattern:/vbscript:/gi,replacement:"",name:"vbscript: URI"},{pattern:/data:text\/html/gi,replacement:"",name:"data:text/html URI"}];for(let{pattern:_,replacement:B,name:z}of U)if(_.test(K))K=K.replace(_,B),W=!0,G.push(`Removed ${z} from parameter`);if(!J){let _=K;if(K=K.split("").filter((B)=>{let z=B.charCodeAt(0);return z>=32&&z!==127}).join(""),K!==_)W=!0,G.push("Control characters removed")}return{value:K,modified:W,warnings:G}}function EW($,Z){let Y=$.replace(/\0/g,"");Y=Y.replace(/\\/g,"/"),Y=Y.replace(/^[a-z][a-z0-9+.-]*:/i,"");while(Y.includes("../")||Y.includes("./"))Y=Y.replace(/\.\.\//g,"").replace(/\.\//g,"");if(!h8.isValidFilePath(Y,Z))return null;return Y}function TW($){let Z=[],Y=$.trim(),X=Y!==$,J=[{pattern:/\beval\s*\(/gi,name:"eval()"},{pattern:/\bFunction\s*\(/gi,name:"Function()"},{pattern:/\bsetTimeout\s*\(/gi,name:"setTimeout()"},{pattern:/\bsetInterval\s*\(/gi,name:"setInterval()"},{pattern:/\bimport\s*\(/gi,name:"dynamic import()"},{pattern:/\brequire\s*\(/gi,name:"require()"},{pattern:/\b__proto__\b/gi,name:"__proto__"},{pattern:/\bconstructor\b/gi,name:"constructor"},{pattern:/\bprototype\b/gi,name:"prototype"}];for(let{pattern:Q,name:G}of J)if(Q.test(Y))Z.push(`Potentially dangerous pattern detected: ${G}`);if(Y.includes("\x00"))Y=Y.replace(/\0/g,""),X=!0,Z.push("Null bytes removed from expression");return{value:Y,modified:X,warnings:Z}}function IW($,Z={}){return $.map((Y)=>B5(Y,Z))}function UX($){let Z={};for(let[Y,X]of Object.entries($)){if(!h8.isValidVariableName(Y))continue;if(typeof X==="string"){let J=B5(X);Z[Y]=J.value}else if(Array.isArray(X))Z[Y]=X.map((J)=>typeof J==="string"?B5(J).value:J);else if(typeof X==="object"&&X!==null)Z[Y]=UX(X);else Z[Y]=X}return Z}var h8;var DW=D(()=>{h8={isValidFilePath($,Z){let Y=$.replace(/\\/g,"/");if(Y.includes("\x00"))return!1;if(Y.includes("../")||Y.includes("..\\")||Y===".."||Y.startsWith("../")||Y.endsWith("/..")||Y.includes("/..\\")||Y.includes("\\../"))return!1;if(/^[a-z][a-z0-9+.-]*:/i.test(Y))return!1;if(Y.startsWith("/")){if(["/etc/","/root/","/var/","/usr/","/bin/","/sbin/","/proc/","/sys/","/dev/","/boot/","/home/","/private/","/Library/","/System/"].some((Q)=>Y===Q.slice(0,-1)||Y.startsWith(Q)))return!1}if(/^[a-z]:/i.test(Y)){if(["Windows/","Windows\\","System32/","System32\\","Program Files/","Program Files\\"].some((Q)=>Y.includes(Q)))return!1}if(Z){let J=WX.resolve(Z,$),Q=WX.resolve(Z);if(!J.startsWith(Q+WX.sep)&&J!==Q)return!1}return!0},isValidVariableName($){return/^[a-z_$]\w*$/i.test($)},isValidDirectiveName($){return/^[a-z][\w-]*$/i.test($)},isSafeContent($){return![/<script[^>]*>[\s\S]*?<\/script>/i,/javascript:/i,/data:text\/html/i,/vbscript:/i,/on\w+\s*=/i].some((Y)=>Y.test($))}}});var kW=D(()=>{y8();RW();MW();DW();x8()});var q1=D(()=>{kW()});class z5{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]!==`
1780
1780
  `)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]===`
1781
- `)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 x0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function _X($,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 d8($){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 e1($,Z){let Y=SA($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function SA($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=x0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function w4($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),_=W?W.index:1/0,B=U?U.index:1/0;if(_<B)J++,Q=_+W[0].length;else if(B<1/0){if(J--,J===0)return B;Q=B+U[0].length}else break}return-1}function BX($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=e1($,X);if(!J)return null;let Q=J.endPos,G=w4($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_="if",B=J.expression,z=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:_,condition:B,content:K.substring(z,U),start:Q+z,end:Q+U});let F=U+O[0].length,L=e1(K,F);if(!L){U++;continue}_="elseif",B=L.expression,U=L.endPos,z=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:_,condition:B,content:K.substring(z,U),start:Q+z,end:Q+U}),_="else",B=void 0,U+=5,z=U;continue}}U++}return W.push({type:_,condition:B,content:K.slice(z),start:Q+z,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function u8($){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=BX($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function q5($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=x0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let _=$.slice(W+1,U),B=U+1,z=w4($,Z,Y,B);if(z===-1){Q=J.exec($);continue}let q=$.slice(B,z),j=z+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:_,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function m8($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=e1($,X);if(!J)return null;let Q=J.endPos,G=w4($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_=null,B=0;while(U<K.length){let z=K.slice(U),q=z.match(/^@switch\s*\(/),j=z.match(/^@endswitch(?![a-z])/);if(q){if(B++,_)_.content+=q[0];U+=q[0].length;continue}if(j){if(B--,_)_.content+=j[0];U+=j[0].length;continue}if(B>0){if(_)_.content+=K[U];U++;continue}let H=z.match(/^@case\s*/),O=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(_)W.push(_);let L=U+H[0].length,V=e1(K,L);if(!V){U++;continue}_={type:"case",value:V.expression,content:""},U=V.endPos}else if(O&&z.startsWith("@default")){if(_)W.push(_);_={type:"default",content:""},U+=O[0].length}else if(F&&z.startsWith("@break"))U+=F[0].length;else{if(_)_.content+=K[U];U++}}if(_)W.push(_);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var SW=()=>{};function PW($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,_=bA($,U,W);if(_===-1){Y=G+1;continue}let B=$.slice(U,_).trim(),z=_+W.length;Z.push({fullMatch:$.slice(G,z),expression:B,start:G,end:z,isRaw:Q}),Y=z}return Z}function bA($,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 yW($){let Z=d8($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=CA(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function CA($){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=x0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=zX(G);return{name:X,args:K}}function zX($){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 xW($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=x0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function vW($){let Z=[],X=new z5($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let B=J<X.length?X[J].start:$.length,z=bW(X,J,$);J=z.nextIndex,Z.push({type:"variable",name:_,value:$.slice(B,z.endPos),exported:G,start:K.start,end:z.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let _=U.start,B=U.value==="{"?"}":"]",z=x0($,U.value,B,_);if(z!==-1){let q=$.slice(_,z+1);if(J=CW(X,z+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=bW(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;J++;let B=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){B=X[J].start;break}J++}if(B!==-1){let z=x0($,"{","}",B);if(z!==-1)Z.push({type:"function",name:_,value:$.slice(W,z+1).replace(/^export\s+/,""),exported:G,start:W,end:z+1}),J=CW(X,z+1)}}}else J++}return Z}function bW($,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 CW($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var gW=()=>{};var c8=D(()=>{SW();gW()});function PA($,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=m8(X,G);if(!K)break;try{let W;if(L0(K.expression))W=V0(K.expression,Object.keys(Z))(...Object.values(Z));else W=R0(K.expression,Z);let U="",_=!1;for(let B of K.cases)if(B.type==="default"){if(!_)U=B.content.trim()}else try{let z;if(B.value&&L0(B.value))z=V0(B.value,Object.keys(Z))(...Object.values(Z));else if(B.value)z=R0(B.value,Z);if(W===z){U=B.content.trim(),_=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),_=W0("Switch",`Error evaluating @switch expression: ${U}`,Z0.EVALUATION_ERROR);X=X.substring(0,G)+_+X.substring(K.end);break}}return X}function $6($,Z,Y){let X=$;X=PA(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=e1(X,K+7);if(!W)break;let U=W.endPos,_=w4(X,"unless","endunless",U);if(_===-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 B=X.slice(U,_),z=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,V=[],N;while((N=O.exec(B))!==null)V.push({pos:N.index,type:"open"});while((N=F.exec(B))!==null)V.push({pos:N.index,type:"close"});while((N=L.exec(B))!==null)V.push({pos:N.index,type:"else"});V.sort((A,w)=>A.pos-w.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){q=A.pos;break}}let j;if(q!==-1){let H=B.slice(0,q),O=B.slice(q+5);j=`@if (${z})${O}@else ${H}@endif`}else j=`@if (!(${z}))${B}@endif`;X=X.substring(0,K)+j+X.substring(_+10),Q=!0}}X=jX(X,Z,Y),X=HX(X,Z,Y),X=qX(X,Z);let J=()=>{let Q=u8(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let _ of K.branches){if(U)break;if(_.type==="else")W=_.content,U=!0;else try{let B;if(_.condition&&L0(_.condition))B=V0(_.condition,Object.keys(Z))(...Object.values(Z));else if(_.condition)B=R0(_.condition,Z);if(B)W=_.content,U=!0}catch(B){W=W0(_.type==="if"?"If":"Elseif",`Error in @${_.type}(${_.condition}): ${B instanceof Error?B.message:String(B)}`,Z0.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),_=W0("If",`Error processing @if block: ${U}`,Z0.EVALUATION_ERROR);X=X.substring(0,K.start)+_+X.substring(K.end)}}return!0};while(J());return X}function fW($){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 qX($,Z){let Y=$;function X(K,W,U,_){let B=1,z=_,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(z<K.length&&B>0){q.lastIndex=z,j.lastIndex=z;let H=q.exec(K),O=j.exec(K),F=H?H.index:1/0,L=O?O.index:1/0;if(F<L)B++,z=F+H[0].length;else if(L<1/0){if(B--,B===0)return L;z=L+O[0].length}else break}return-1}function J(K,W,U){let _=0,B=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=B.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,F)=>O.pos-F.pos);for(let O of j)if(O.type==="open")_++;else if(O.type==="close")_--;else if(O.type==="else"&&_===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,B,z=Y.slice(U+5),q=fW(z);if(q)_=q.value,B=U+5+q.consumed;else B=U+5;let j=X(Y,"auth","endauth",B);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(B,j),O=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=_?t1(`auth?.check && auth?.user?.[${_}]`,Z):t1("auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,B,z=Y.slice(U+6),q=fW(z);if(q)_=q.value,B=U+6+q.consumed;else B=U+6;let j=X(Y,"guest","endguest",B);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(B,j),O=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=_?t1(`!auth?.check || !auth?.user?.[${_}]`,Z):t1("!auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let _=[K];if(W)_.push(W);if(U){let B=t1(U,Z);_.push(B)}return Z.permissions.check(..._)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",_=!0;while(_){_=!1;let B=Y.match(new RegExp(`@${K}\\s*\\(`));if(!B||B.index===void 0)break;let z=B.index,q=Y.slice(z+`@${K}`.length),j=G(q);if(!j)break;let H=z+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=Y.slice(H,O),L=[],V=0,N=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),M=/@else(?![a-z])/g,E=[],I;while((I=N.exec(F))!==null)E.push({pos:I.index,type:"open"});while((I=A.exec(F))!==null)E.push({pos:I.index,type:"close"});while((I=w.exec(F))!==null)E.push({pos:I.index,type:"elseDirective"});while((I=M.exec(F))!==null)E.push({pos:I.index,type:"else"});E.sort((v,C)=>v.pos-C.pos);for(let v of E){if(v.type==="open"){V++;continue}if(v.type==="close"){V--;continue}if(V===0)L.push(v)}let T=[],S=0;for(let v=0;v<L.length;v++){let C=L[v];if(T.push({content:F.slice(S,C.pos),ability:void 0}),C.type==="elseDirective"){let f=F.slice(C.pos+`@${U}`.length),h=G(f);if(h){T[T.length-1]={content:F.slice(S,C.pos)},S=C.pos+`@${U}`.length+h.paramsEnd,T.push({content:"",ability:h.ability,type:h.type,id:h.id}),T.pop();let u=L[v+1],l=u?u.pos:F.length;T.push({content:F.slice(S,l),ability:h.ability,type:h.type,id:h.id}),S=l}}else S=C.pos+5}if(S<F.length){let v=T[T.length-1];if(L.length>0&&L[L.length-1].type==="else")T.push({content:F.slice(S),isFinalElse:!0});else if(T.length===0)T.push({content:F.slice(S)})}let k=Q(j.ability,j.type,j.id),b=K==="can"?k:!k,y="";if(b)y=T[0]?.content||"";else{let v=!1;for(let C=1;C<T.length;C++){let f=T[C];if(f.isFinalElse){y=f.content,v=!0;break}if(f.ability){let h=Q(f.ability,f.type,f.id);if(K==="can"?h:!h){y=f.content,v=!0;break}}}if(!v&&T.length>0){let C=T[T.length-1];if(C.isFinalElse)y=C.content}}Y=Y.substring(0,z)+y+Y.substring(O+`@${W}`.length),_=!0}}return Y}function jX($,Z,Y){let X=$;function J(Q,G,K,W,U){let _=!0;while(_){_=!1;let B=new RegExp(`@${G}\\s*\\(`),z=Q.match(B);if(!z||z.index===void 0)break;let q=z.index,j=e1(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=w4(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,O),L=j.expression,V=-1,N=0,A=0;while(A<F.length){let w=F.indexOf("@",A);if(w===-1)break;let M=F.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(M)){N++,A=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(M)){N--,A=w+1;continue}if(N===0&&/^@else(?![a-z])/.test(M)){V=w;break}A=w+1}try{let w=W(L.trim()),M;if(V!==-1){let E=F.slice(0,V),I=F.slice(V+5);M=w?E:I}else M=w?F:"";Q=Q.substring(0,q)+M+Q.substring(O+`@${K}`.length),_=!0}catch(w){let M=w instanceof Error?w.message:String(w),E=W0(U,`Error processing @${G} directive: ${M}`,Z0.EVALUATION_ERROR);Q=Q.substring(0,q)+E+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=t1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=t1(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 HX($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let _=new RegExp(`@${K}(?![a-z])`,"g"),B=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,_.lastIndex=0;let O=_.exec(j);if(!O)break;let F=O.index,L=F+O[0].length;if(K==="env"){let k=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;L+=k[0].length,U=J===k[2]}let V=1,N=L,A=-1;while(V>0&&N<j.length){_.lastIndex=N,B.lastIndex=N;let k=_.exec(j),b=B.exec(j),y=k?k.index:1/0,v=b?b.index:1/0;if(y<v)V++,N=y+k[0].length;else if(v<1/0){if(V--,V===0){A=v;break}N=v+b[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,A),M=-1,E=0,I=0;while(I<w.length){let k=w.indexOf("@",I);if(k===-1)break;let b=w.substring(k);if(z.test(b)){E++,I=k+1;continue}if(q.test(b)){E--,I=k+1;continue}if(E===0&&/^@else(?![a-z])/.test(b)){M=k;break}I=k+1}let T;if(M!==-1){let k=w.slice(0,M),b=w.slice(M+5);T=U?k:b}else T=U?w:"";let S=`@${W}`.length;j=j.substring(0,F)+T+j.substring(A+S),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var p8=D(()=>{JX();q1();c8();a0()});function LX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function R4($,Z){if(!$)return Z?.nonceGenerator?.()??LX();let Y=OX.get($);if(!Y)Y=Z?.nonceGenerator?.()??LX(),OX.set($,Y);return Y}function yA($){OX.delete($)}function FX($,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 i8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${FX($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function xA($){return{enabled:!0,directives:{strict:hW,moderate:l8,relaxed:dW,api:uW}[$]||l8,useNonce:$==="strict",addMetaTag:!0}}function vA($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function VX($,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?R4(Y,Z):void 0,J=i8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
1781
+ `)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 x0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function _X($,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 d8($){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 e1($,Z){let Y=SA($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function SA($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=x0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function w4($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),_=W?W.index:1/0,B=U?U.index:1/0;if(_<B)J++,Q=_+W[0].length;else if(B<1/0){if(J--,J===0)return B;Q=B+U[0].length}else break}return-1}function BX($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=e1($,X);if(!J)return null;let Q=J.endPos,G=w4($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_="if",B=J.expression,z=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:_,condition:B,content:K.substring(z,U),start:Q+z,end:Q+U});let F=U+O[0].length,L=e1(K,F);if(!L){U++;continue}_="elseif",B=L.expression,U=L.endPos,z=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:_,condition:B,content:K.substring(z,U),start:Q+z,end:Q+U}),_="else",B=void 0,U+=5,z=U;continue}}U++}return W.push({type:_,condition:B,content:K.slice(z),start:Q+z,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function u8($){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=BX($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function q5($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=x0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let _=$.slice(W+1,U),B=U+1,z=w4($,Z,Y,B);if(z===-1){Q=J.exec($);continue}let q=$.slice(B,z),j=z+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:_,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function m8($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=e1($,X);if(!J)return null;let Q=J.endPos,G=w4($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_=null,B=0;while(U<K.length){let z=K.slice(U),q=z.match(/^@switch\s*\(/),j=z.match(/^@endswitch(?![a-z])/);if(q){if(B++,_)_.content+=q[0];U+=q[0].length;continue}if(j){if(B--,_)_.content+=j[0];U+=j[0].length;continue}if(B>0){if(_)_.content+=K[U];U++;continue}let H=z.match(/^@case\s*/),O=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(_)W.push(_);let L=U+H[0].length,V=e1(K,L);if(!V){U++;continue}_={type:"case",value:V.expression,content:""},U=V.endPos}else if(O&&z.startsWith("@default")){if(_)W.push(_);_={type:"default",content:""},U+=O[0].length}else if(F&&z.startsWith("@break"))U+=F[0].length;else{if(_)_.content+=K[U];U++}}if(_)W.push(_);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var SW=()=>{};function PW($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,_=bA($,U,W);if(_===-1){Y=G+1;continue}let B=$.slice(U,_).trim(),z=_+W.length;Z.push({fullMatch:$.slice(G,z),expression:B,start:G,end:z,isRaw:Q}),Y=z}return Z}function bA($,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 yW($){let Z=d8($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=CA(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function CA($){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=x0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=zX(G);return{name:X,args:K}}function zX($){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 xW($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=x0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function vW($){let Z=[],X=new z5($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let B=J<X.length?X[J].start:$.length,z=bW(X,J,$);J=z.nextIndex,Z.push({type:"variable",name:_,value:$.slice(B,z.endPos),exported:G,start:K.start,end:z.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let _=U.start,B=U.value==="{"?"}":"]",z=x0($,U.value,B,_);if(z!==-1){let q=$.slice(_,z+1);if(J=CW(X,z+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=bW(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;J++;let B=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){B=X[J].start;break}J++}if(B!==-1){let z=x0($,"{","}",B);if(z!==-1)Z.push({type:"function",name:_,value:$.slice(W,z+1).replace(/^export\s+/,""),exported:G,start:W,end:z+1}),J=CW(X,z+1)}}}else J++}return Z}function bW($,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 CW($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var gW=()=>{};var c8=D(()=>{SW();gW()});function PA($,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=m8(X,G);if(!K)break;try{let W;if(L0(K.expression))W=V0(K.expression,Object.keys(Z))(...Object.values(Z));else W=R0(K.expression,Z);let U="",_=!1;for(let B of K.cases)if(B.type==="default"){if(!_)U=B.content.trim()}else try{let z;if(B.value&&L0(B.value))z=V0(B.value,Object.keys(Z))(...Object.values(Z));else if(B.value)z=R0(B.value,Z);if(W===z){U=B.content.trim(),_=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),_=W0("Switch",`Error evaluating @switch expression: ${U}`,Z0.EVALUATION_ERROR);X=X.substring(0,G)+_+X.substring(K.end);break}}return X}function $6($,Z,Y){let X=$;X=PA(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=e1(X,K+7);if(!W)break;let U=W.endPos,_=w4(X,"unless","endunless",U);if(_===-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 B=X.slice(U,_),z=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,V=[],N;while((N=O.exec(B))!==null)V.push({pos:N.index,type:"open"});while((N=F.exec(B))!==null)V.push({pos:N.index,type:"close"});while((N=L.exec(B))!==null)V.push({pos:N.index,type:"else"});V.sort((A,w)=>A.pos-w.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){q=A.pos;break}}let j;if(q!==-1){let H=B.slice(0,q),O=B.slice(q+5);j=`@if (${z})${O}@else ${H}@endif`}else j=`@if (!(${z}))${B}@endif`;X=X.substring(0,K)+j+X.substring(_+10),Q=!0}}X=jX(X,Z,Y),X=HX(X,Z,Y),X=qX(X,Z);let J=()=>{let Q=u8(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let _ of K.branches){if(U)break;if(_.type==="else")W=_.content,U=!0;else try{let B;if(_.condition&&L0(_.condition))B=V0(_.condition,Object.keys(Z))(...Object.values(Z));else if(_.condition)B=R0(_.condition,Z);if(B)W=_.content,U=!0}catch(B){W=W0(_.type==="if"?"If":"Elseif",`Error in @${_.type}(${_.condition}): ${B instanceof Error?B.message:String(B)}`,Z0.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),_=W0("If",`Error processing @if block: ${U}`,Z0.EVALUATION_ERROR);X=X.substring(0,K.start)+_+X.substring(K.end)}}return!0};while(J());return X}function fW($){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 qX($,Z){let Y=$;function X(K,W,U,_){let B=1,z=_,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(z<K.length&&B>0){q.lastIndex=z,j.lastIndex=z;let H=q.exec(K),O=j.exec(K),F=H?H.index:1/0,L=O?O.index:1/0;if(F<L)B++,z=F+H[0].length;else if(L<1/0){if(B--,B===0)return L;z=L+O[0].length}else break}return-1}function J(K,W,U){let _=0,B=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=B.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,F)=>O.pos-F.pos);for(let O of j)if(O.type==="open")_++;else if(O.type==="close")_--;else if(O.type==="else"&&_===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,B,z=Y.slice(U+5),q=fW(z);if(q)_=q.value,B=U+5+q.consumed;else B=U+5;let j=X(Y,"auth","endauth",B);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(B,j),O=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=_?t1(`auth?.check && auth?.user?.[${_}]`,Z):t1("auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,B,z=Y.slice(U+6),q=fW(z);if(q)_=q.value,B=U+6+q.consumed;else B=U+6;let j=X(Y,"guest","endguest",B);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(B,j),O=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=_?t1(`!auth?.check || !auth?.user?.[${_}]`,Z):t1("!auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let _=[K];if(W)_.push(W);if(U){let B=t1(U,Z);_.push(B)}return Z.permissions.check(..._)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",_=!0;while(_){_=!1;let B=Y.match(new RegExp(`@${K}\\s*\\(`));if(!B||B.index===void 0)break;let z=B.index,q=Y.slice(z+`@${K}`.length),j=G(q);if(!j)break;let H=z+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=Y.slice(H,O),L=[],V=0,N=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),M=/@else(?![a-z])/g,E=[],T;while((T=N.exec(F))!==null)E.push({pos:T.index,type:"open"});while((T=A.exec(F))!==null)E.push({pos:T.index,type:"close"});while((T=w.exec(F))!==null)E.push({pos:T.index,type:"elseDirective"});while((T=M.exec(F))!==null)E.push({pos:T.index,type:"else"});E.sort((b,C)=>b.pos-C.pos);for(let b of E){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)L.push(b)}let I=[],S=0;for(let b=0;b<L.length;b++){let C=L[b];if(I.push({content:F.slice(S,C.pos),ability:void 0}),C.type==="elseDirective"){let v=F.slice(C.pos+`@${U}`.length),h=G(v);if(h){I[I.length-1]={content:F.slice(S,C.pos)},S=C.pos+`@${U}`.length+h.paramsEnd,I.push({content:"",ability:h.ability,type:h.type,id:h.id}),I.pop();let u=L[b+1],p=u?u.pos:F.length;I.push({content:F.slice(S,p),ability:h.ability,type:h.type,id:h.id}),S=p}}else S=C.pos+5}if(S<F.length){let b=I[I.length-1];if(L.length>0&&L[L.length-1].type==="else")I.push({content:F.slice(S),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(S)})}let k=Q(j.ability,j.type,j.id),x=K==="can"?k:!k,f="";if(x)f=I[0]?.content||"";else{let b=!1;for(let C=1;C<I.length;C++){let v=I[C];if(v.isFinalElse){f=v.content,b=!0;break}if(v.ability){let h=Q(v.ability,v.type,v.id);if(K==="can"?h:!h){f=v.content,b=!0;break}}}if(!b&&I.length>0){let C=I[I.length-1];if(C.isFinalElse)f=C.content}}Y=Y.substring(0,z)+f+Y.substring(O+`@${W}`.length),_=!0}}return Y}function jX($,Z,Y){let X=$;function J(Q,G,K,W,U){let _=!0;while(_){_=!1;let B=new RegExp(`@${G}\\s*\\(`),z=Q.match(B);if(!z||z.index===void 0)break;let q=z.index,j=e1(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=w4(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,O),L=j.expression,V=-1,N=0,A=0;while(A<F.length){let w=F.indexOf("@",A);if(w===-1)break;let M=F.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(M)){N++,A=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(M)){N--,A=w+1;continue}if(N===0&&/^@else(?![a-z])/.test(M)){V=w;break}A=w+1}try{let w=W(L.trim()),M;if(V!==-1){let E=F.slice(0,V),T=F.slice(V+5);M=w?E:T}else M=w?F:"";Q=Q.substring(0,q)+M+Q.substring(O+`@${K}`.length),_=!0}catch(w){let M=w instanceof Error?w.message:String(w),E=W0(U,`Error processing @${G} directive: ${M}`,Z0.EVALUATION_ERROR);Q=Q.substring(0,q)+E+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=t1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=t1(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 HX($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let _=new RegExp(`@${K}(?![a-z])`,"g"),B=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,_.lastIndex=0;let O=_.exec(j);if(!O)break;let F=O.index,L=F+O[0].length;if(K==="env"){let k=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;L+=k[0].length,U=J===k[2]}let V=1,N=L,A=-1;while(V>0&&N<j.length){_.lastIndex=N,B.lastIndex=N;let k=_.exec(j),x=B.exec(j),f=k?k.index:1/0,b=x?x.index:1/0;if(f<b)V++,N=f+k[0].length;else if(b<1/0){if(V--,V===0){A=b;break}N=b+x[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,A),M=-1,E=0,T=0;while(T<w.length){let k=w.indexOf("@",T);if(k===-1)break;let x=w.substring(k);if(z.test(x)){E++,T=k+1;continue}if(q.test(x)){E--,T=k+1;continue}if(E===0&&/^@else(?![a-z])/.test(x)){M=k;break}T=k+1}let I;if(M!==-1){let k=w.slice(0,M),x=w.slice(M+5);I=U?k:x}else I=U?w:"";let S=`@${W}`.length;j=j.substring(0,F)+I+j.substring(A+S),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var p8=D(()=>{JX();q1();c8();a0()});function LX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function R4($,Z){if(!$)return Z?.nonceGenerator?.()??LX();let Y=OX.get($);if(!Y)Y=Z?.nonceGenerator?.()??LX(),OX.set($,Y);return Y}function yA($){OX.delete($)}function FX($,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 i8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${FX($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function xA($){return{enabled:!0,directives:{strict:hW,moderate:l8,relaxed:dW,api:uW}[$]||l8,useNonce:$==="strict",addMetaTag:!0}}function vA($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function VX($,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?R4(Y,Z):void 0,J=i8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
1782
1782
  ${J}`)}function gA($,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 AX($,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?R4(Z,Q):void 0;return i8(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return R4(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=R4(Z,Q);return J}function fA(){return[mW,cW]}function hA($){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 pW($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function dA($,Z){if(!$.enabled)return{};let Y=$.useNonce?R4(Z,$):void 0,X=FX($.directives,Y);return{[pW($.reportOnly)]:X}}var OX,hW,l8,dW,uW,mW,cW,uA;var NX=D(()=>{OX=new WeakMap;hW={"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},l8={"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},dW={"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'"]},uW={"default-src":["'none'"],"frame-ancestors":["'none'"]};mW={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?R4(Y,Q):void 0;return i8(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},cW={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return R4(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};uA={enabled:!1,reportOnly:!1,directives:l8,useNonce:!1,addMetaTag:!0}});import mA from"crypto";function pA($=cA){let Z=mA.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return wX=Z,Z}function lA(){if(!wX)pA();return wX}function iA($=lW){let Z=lA();return`<input type="hidden" name="${$}" value="${Z}">`}function iW($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return iA(X||lW)})}var cA=40,lW="_token",wX=null;var nW=()=>{};async function RX($,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 nA(J,Q,Z,Y,X);else J=await rA(J,Q,Z,Y,X)}return J}async function nA($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,_=I6(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),B=[],z=_.exec(U);while(z!==null){let[q,j="",H=""]=z,O=z.index||0;try{let F=j?rW(j):[],L=H.trim(),V=await G(L,F,Y,X);B.push({original:q,processed:V,startIndex:O})}catch(F){let L=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);B.push({original:q,processed:W0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${L}`,Z0.EVALUATION_ERROR),startIndex:O})}z=_.exec(U)}for(let q=B.length-1;q>=0;q--){let{original:j,processed:H}=B[q];U=U.replace(j,H)}return U}async function rA($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,W=I6(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],_=W.exec(K);while(_!==null){let[q,j=""]=_,H=_.index||0;try{let O=rW(j),F=await G("",O,Y,X);U.push({original:q,processed:F,startIndex:H})}catch(O){let F=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:q,processed:W0("CustomDirective",`Error in @${Q}(${j}): ${F}`,Z0.EVALUATION_ERROR),startIndex:H})}_=W.exec(K)}let B=I6(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),z=B.exec(K);while(z!==null){let[q]=z,j=z.index||0;try{let H=await G("",[],Y,X);U.push({original:q,processed:H,startIndex:j})}catch(H){let O=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:W0("CustomDirective",`Error in @${Q}: ${O}`,Z0.EVALUATION_ERROR),startIndex:j})}z=B.exec(K)}for(let q=U.length-1;q>=0;q--){let{original:j,processed:H}=U[q];K=K.replace(j,H)}return K}function rW($){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 MX=D(()=>{q1();V4()});var s8={};e(s8,{useTitle:()=>oW,useSeoMeta:()=>j5,usePageTitle:()=>oW,useHead:()=>E4,resetHead:()=>sW,renderHtmlAttrs:()=>eW,renderHead:()=>tW,renderBodyAttrs:()=>$U,processTitleDirective:()=>XU,processMetaDirective:()=>JU,processHeadDirective:()=>YU,getPageMeta:()=>r8,getHead:()=>y6,definePageMeta:()=>aW,applyHead:()=>ZU});function y6(){return M4}function r8(){return n8}function sW(){M4={},sA.length=0,n8={}}function E4($){M4=aA(M4,$)}function aA($,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 j5($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:W})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let J=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(J)Z.push({name:"twitter:title",content:J});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)Z.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});E4({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function aW($){if(n8={...n8,...$},$.title||$.description)j5({title:$.title,description:$.description})}function oW($){let Z=typeof $==="function"?$():$;E4({title:Z})}function tW($=M4){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${Z6(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${Z6(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}="${Z6(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}="${Z6(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}="${Z6(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(`
1783
1783
  `)}function eW($=M4){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${Z6(Y)}"`).join(" ")}function $U($=M4){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${Z6(Y)}"`).join(" ")}function Z6($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function ZU($=M4){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 YU($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
1784
1784
  `,""}),headContent:Z.trim()}}function XU($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return E4({title:G}),""})}function JU($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let W=Q?G:K,U=Q?W:Z[(W||"").trim()]??W,B=J.includes(":")?{property:J,content:U}:{name:J,content:U};return E4({meta:[B]}),""})}var M4,sA,n8;var T4=D(()=>{M4={},sA=[],n8={}});import oA from"crypto";function l0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function tA($){return{...o8,...$.forms?.classes}}function a8($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function eA(){return oA.randomUUID()}function $N($,Z,Y,X){let J=tA(X),Q=$;return Q=WU(Q,Z),Q=x6(Q,Z),Q=t8(Q,Z,J),Q=e8(Q,Z,J),Q}function x6($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=eA();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${l0(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="${l0(Q)}">`;return X}),Y}function t8($,Z,Y=o8){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,W,U="")=>{let _=Q||G||"POST",B=K||W||"",z=I4(U),q=_.toUpperCase(),j=["GET","POST"].includes(q)?q:"POST",H=`<form method="${l0(j)}" action="${l0(B)}"${z?` ${z}`:""}>`;if(H+=`
@@ -1839,12 +1839,12 @@ catch { return 'Please enter a valid URL'; } },
1839
1839
  `),X=[{obj:Z,indent:-1}];for(let J of Y){let Q=J.replace(/#.*$/,"").trimEnd();if(!Q.trim())continue;let G=Q.search(/\S/);if(G===-1)continue;while(X.length>1&&X[X.length-1].indent>=G)X.pop();let K=X[X.length-1].obj,W=Q.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(W){let[,,U,_]=W,B=U.trim(),z=_.trim();if(z==="")K[B]={},X.push({obj:K[B],indent:G});else K[B]=FN(z)}}return Z}function FN($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);let Z=$.toLowerCase();if(Z==="true"||Z==="yes")return!0;if(Z==="false"||Z==="no")return!1;if(Z==="null"||Z==="~")return null;let Y=Number($);if(!Number.isNaN(Y))return Y;return $}function VN($){switch($){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"json":default:return".json"}}function AN($,Z){for(let Y of $){let X=Y.trim(),J=X.match(/^\{(\d+)\}\s*(.*)$/);if(J){let G=Number.parseInt(J[1],10);if(Z===G)return J[2];continue}let Q=X.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(Q){let G=Number.parseInt(Q[1],10),K=Q[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(Q[2],10);if(Z>=G&&Z<=K)return Q[3];continue}}if($.length===2)return Z===1?$[0].trim():$[1].trim();if(Z<$.length)return $[Z].trim();return $[$.length-1].trim()}function LU($,Z={}){return FU($,Z)}function FU($,Z){let Y="",X=0;while(X<$.length)if($[X]==="{"){let J=NN($,X);if(J===-1){Y+=$[X],X++;continue}let Q=$.slice(X+1,J);Y+=wN(Q,Z),X=J+1}else if($[X]==="'"&&X+1<$.length)if($[X+1]==="'")Y+="'",X+=2;else if($[X+1]==="{"||$[X+1]==="}")Y+=$[X+1],X+=2;else Y+=$[X],X++;else Y+=$[X],X++;return Y}function NN($,Z){let Y=0;for(let X=Z;X<$.length;X++)if($[X]==="{")Y++;else if($[X]==="}"){if(Y--,Y===0)return X}return-1}function wN($,Z){let Y=RN($);if(Y.length===0)return`{${$}}`;let X=Y[0].trim(),J=Z[X];if(Y.length===1)return J!==void 0?String(J):`{${X}}`;switch(Y[1].trim().toLowerCase()){case"plural":return MN(J,Y.slice(2).join(","),Z);case"select":return TN(J,Y.slice(2).join(","));case"selectordinal":return IN(J,Y.slice(2).join(","));case"number":return kN(J,Y[2]?.trim());case"date":return SN(J,Y[2]?.trim());case"time":return bN(J,Y[2]?.trim());default:return J!==void 0?String(J):`{${$}}`}}function RN($){let Z=[],Y="",X=0;for(let J=0;J<$.length;J++){let Q=$[J];if(Q==="{")X++,Y+=Q;else if(Q==="}")X--,Y+=Q;else if(Q===","&&X===0)Z.push(Y),Y="";else Y+=Q}if(Y)Z.push(Y);return Z}function MN($,Z,Y){let X=Number($)||0,J=kX(Z),Q=`=${X}`;if(J[Q])return DX(J[Q],X,Y);let G=EN(X);if(J[G])return DX(J[G],X,Y);if(J.other)return DX(J.other,X,Y);return String(X)}function DX($,Z,Y){let X=$.replace(/#/g,String(Z));return FU(X,Y)}function EN($){let Z=Math.abs($),Y=Math.floor(Z),X=String($).includes(".")?String($).split(".")[1].length:0;if(Y===1&&X===0)return"one";return"other"}function TN($,Z){let Y=String($||""),X=kX(Z);if(X[Y])return X[Y];return X.other||String($)}function IN($,Z){let Y=Number($)||0,X=kX(Z),J=DN(Y);if(X[J])return X[J].replace(/#/g,String(Y));if(X.other)return X.other.replace(/#/g,String(Y));return String(Y)}function DN($){let Z=Math.abs($),Y=Z%10,X=Z%100;if(Y===1&&X!==11)return"one";if(Y===2&&X!==12)return"two";if(Y===3&&X!==13)return"few";return"other"}function kX($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,X=Y.exec($);while(X!==null)Z[X[1]]=X[2],X=Y.exec($);return Z}function kN($,Z){let Y=Number($);if(Number.isNaN(Y))return String($);switch(Z){case"integer":return Math.floor(Y).toLocaleString();case"percent":return`${(Y*100).toFixed(0)}%`;case"currency":return Y.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return Y.toLocaleString()}}function SN($,Z){let Y=$ instanceof Date?$:new Date(String($));if(Number.isNaN(Y.getTime()))return String($);let X={};switch(Z){case"short":X.dateStyle="short";break;case"medium":X.dateStyle="medium";break;case"long":X.dateStyle="long";break;case"full":X.dateStyle="full";break;default:X.dateStyle="medium"}return Y.toLocaleDateString(void 0,X)}function bN($,Z){let Y=$ instanceof Date?$:new Date(String($));if(Number.isNaN(Y.getTime()))return String($);let X={};switch(Z){case"short":X.timeStyle="short";break;case"medium":X.timeStyle="medium";break;case"long":X.timeStyle="long";break;case"full":X.timeStyle="full";break;default:X.timeStyle="short"}return Y.toLocaleTimeString(void 0,X)}function VU($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function $3($,Z,Y=!0,X={}){let J=$.split("."),Q=Z;for(let K of J){if(Q===void 0||Q===null)break;Q=Q[K]}if(Q===void 0||Q===null)return Y?$:"";let G=String(Q);if(VU(G))return LU(G,X);if(G.includes("|")&&"count"in X){let K=Number(X.count),W=G.split("|");G=AN(W,K)}for(let[K,W]of Object.entries(X)){let U=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");G=G.replace(new RegExp(`:${U}`,"g"),String(W))}return G}async function SX($,Z,Y,X){let J=$,Q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...Z3,...X.i18n},K=await OU(G.locale,X);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,J=await BU(J,Q,async(_,B,z,q,j)=>{try{let H={};if(z)try{let F=[()=>JSON.parse(z),()=>{let L=`{"data":${z}}`,V=JSON.parse(L);return typeof V.data==="object"?V.data:{}},()=>{return y0(z,Z)}];for(let L of F)try{if(H=L(),Object.keys(H).length>0)break}catch{}}catch(F){if(X.debug)console.error("Error parsing parameters for @translate directive:",F)}return $3(B,K,G.fallbackToKey,H)||q.trim()}catch(H){if(X.debug)console.error("Error processing @translate directive:",H);return W0("Translate",`Error in @translate('${B}'): ${H instanceof Error?H.message:String(H)}`,Z0.EVALUATION_ERROR)}});let W=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(X.debug){console.warn(`Processing translations in template. Sections: ${J.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let _=[...J.matchAll(W)];console.warn(`Found ${_.length} @translate matches`),_.forEach((B,z)=>console.warn(`Match ${z}: ${B[0]}, Key: ${B[1]}, Params: ${B[2]||"none"}`))}return J=await BU(J,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(_,B,z,q)=>{try{let j={};if(z)try{let H=[()=>JSON.parse(z),()=>{let O=`{"data":${z}}`,F=JSON.parse(O);return typeof F.data==="object"?F.data:{}},()=>{return y0(z,Z)}];for(let O of H)try{if(j=O(),Object.keys(j).length>0)break}catch{}}catch(H){if(X.debug)console.error("Error parsing parameters for @translate directive:",H)}return $3(B,K,G.fallbackToKey,j)}catch(j){if(X.debug)console.error("Error processing @translate directive:",j);return W0("Translate",`Error in @translate('${B}'): ${j instanceof Error?j.message:String(j)}`,Z0.EVALUATION_ERROR)}}),J}async function BU($,Z,Y){let X=[];return $.replace(Z,(Q,...G)=>{let K=Y(Q,...G).then((W)=>({match:Q,replacement:W}));return X.push(K),Q}),(await Promise.all(X)).reduce((Q,{match:G,replacement:K})=>Q.replace(G,K),$)}function CN($,Z=!0){return(Y,X={})=>{return $3(Y,$,Z,X)}}var Z3,G1,E1,$4;var bX=D(()=>{q1();a0();Z3={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},G1={},E1={},$4={}});var X3={};e(X3,{stripTypeScript:()=>RU,hasVariables:()=>yX,extractVariables:()=>A0,extractScriptFromTemplate:()=>PX,convertToCommonJS:()=>Y3});import v6 from"path";function PN($){let Z=[],Y=0,X=$.split(`
1840
1840
  `);for(let J of X){let Q=null,G=!1;for(let K=0;K<J.length;K++){let W=J[K];if(G){G=!1;continue}if(W==="\\"){G=!0;continue}if(Q){if(W===Q)Q=null;continue}if(W==="'"||W==='"'||W==="`"){Q=W;continue}if(W==="/"&&K+1<J.length&&J[K+1]==="/")break;if(W==="{")Y++;else if(W==="}")Y--}if(Y===0){let K=J.match(/(?:const|let|var)\s+(\w+)\s*=/);if(K)Z.push(K[1]);else{let W=J.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(W){let _=W[1].slice(1,-1).split(",").map((B)=>{let z=B.split(":");return(z.length>1?z[1]:z[0]).trim()}).filter((B)=>/^\w+$/.test(B));Z.push(..._)}}}}return[...new Set(Z)]}function RU($){let Z=$;Z=Z.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),Z=Z.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),Z=Z.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function Y(X){if(!X.includes(":"))return X;let J=[],Q="",G=0,K=0,W=null;for(let U=0;U<X.length;U++){let _=X[U];if(W){if(Q+=_,_===W)W=null;continue}if(_==='"'||_==="'"||_==="`"){W=_,Q+=_;continue}if(_==="<")G++;else if(_===">"&&G>0)G--;else if(_==="(")K++;else if(_===")")K--;if(_===","&&G===0&&K===0){J.push(Q),Q="";continue}Q+=_}if(Q)J.push(Q);return J.map((U)=>{let _=U.trim(),B=_.startsWith("..."),z=B?_.slice(3):_,q=-1,j=0;for(let A=0;A<z.length;A++)if(z[A]==="<")j++;else if(z[A]===">")j--;else if(z[A]===":"&&j===0){q=A;break}if(q===-1)return U;let O=z.substring(0,q).trim().replace(/\?$/,""),F=z.substring(q+1),L=-1,V=0;for(let A=0;A<F.length;A++)if(F[A]==="<")V++;else if(F[A]===">")V--;else if(F[A]==="="&&V===0){L=A;break}let N=B?"...":"";if(L!==-1)return`${N}${O} = ${F.substring(L+1).trim()}`;return`${N}${O}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(X,J,Q)=>{if(!Q.includes(":"))return X;return`${J}(${Y(Q)})`});{let X=/\b(function\s+\w*\s*)\(/g,J,Q=[];while((J=X.exec(Z))!==null){let G=J.index+J[0].length-1,K=1,W=G+1,U=0,_=null;while(W<Z.length&&K>0){let q=Z[W];if(_){if(q===_)_=null;W++;continue}if(q==='"'||q==="'"||q==="`"){_=q,W++;continue}if(q==="<")U++;else if(q===">"&&U>0)U--;else if(U===0){if(q==="(")K++;else if(q===")")K--}if(K>0)W++}if(K!==0)continue;let B=Z.substring(G+1,W);if(!B.includes(":"))continue;let z=Y(B);Q.push({start:G+1,end:W,replacement:z})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];Z=Z.substring(0,K)+U+Z.substring(W)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(X,J)=>{if(!J.includes(":"))return X;if(J.includes("{")||J.includes("}"))return X;return`(${J.split(",").map((G)=>{let[K,...W]=G.split("="),U=K.split(":")[0].trim();if(W.length>0)return`${U} = ${W.join("=").trim()}`;return U}).join(", ")}) =>`}),Z=Z.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),Z=Z.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\b(?:defineProps|withDefaults|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,`
1841
1841
 
1842
- `),Z}async function A0($,Z,Y){if(!$.trim())return;let X;try{let g=new Bun.Transpiler({loader:"ts",target:"browser",define:O1()}),m=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");m=m.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),X=g.transformSync(m)}catch{X=RU($)}let J={exports:{}},Q=J.exports,G=process.cwd(),K={},W=[...X.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((g)=>g[1]).filter((g)=>!g.startsWith("node:")&&!g.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(g));for(let g of W)try{let m=v6.resolve(G,"node_modules",g),n=v6.join(m,"package.json"),c=JSON.parse(a("fs").readFileSync(n,"utf8")),$0=c.main||"index.js";if(c.exports){let d=typeof c.exports==="string"?c.exports:c.exports["."];if(typeof d==="string")$0=d;else if(d?.bun)$0=d.bun;else if(d?.import)$0=d.import;else if(d?.default)$0=d.default}K[g]=await import(v6.resolve(m,$0))}catch{}let U=(g)=>{if(K[g])return K[g];return a(g)},_=Z.props||{},B=Object.assign((g)=>{if(!g)return _;let m={};for(let[n,c]of Object.entries(g)){let $0=_[n];if($0!==void 0)m[n]=$0;else if(typeof c==="function")m[n]=c();else m[n]=c}return m},_),z=()=>_,q=(g,m)=>{let n={...g};for(let[c,$0]of Object.entries(m))if(n[c]===void 0)if(typeof $0==="function")n[c]=$0();else n[c]=$0;return n},j=(g)=>{let m=()=>g;return m.set=(n)=>{},m.update=(n)=>{},m},H=(g)=>{let m,n=!1;return()=>{if(!n)try{m=g(),n=!0}catch{m=void 0}return m}},O=(g)=>{},F=(g)=>g(),L=(g)=>{},V=(g)=>{},N=(g)=>{},A=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),w=()=>({push:(g)=>{},replace:(g)=>{},back:()=>{},forward:()=>{},go:(g)=>{}}),M=(g)=>{E4(g);let m=Z.__stx_runtime_head||{},n=g||{};Z.__stx_runtime_head={...m,...n.title&&{title:n.title},meta:[...m.meta||[],...n.meta||[]],link:[...m.link||[],...n.link||[]],script:[...m.script||[],...n.script||[]],htmlAttrs:{...m.htmlAttrs||{},...n.htmlAttrs||{}},bodyAttrs:{...m.bodyAttrs||{},...n.bodyAttrs||{}}}},E=(g)=>{j5(g);let m=y6();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...m.title&&{title:m.title},meta:m.meta?[...m.meta]:[]}},I=(g)=>({value:g}),T=(g)=>g,S=(g)=>({value:typeof g==="function"?g():g}),k=(g,m)=>{},b=(g)=>{},y=(g)=>{},v=(g)=>g?g():Promise.resolve(),C=(g)=>(m,...n)=>{},f=(g)=>{},h=(g,m)=>{},u=(g,m)=>m,l=()=>({value:"light"}),i=()=>({value:!1}),_0={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:{}},q0=new Proxy(_0,{get(g,m){if(m in g)return g[m];return},set(g,m,n){return g[m]=n,!0}}),f0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},D0=console;try{let g=Y3(X,Y),m=new Set(Object.keys(_)),n=Object.keys(Z).filter((j0)=>!m.has(j0)&&j0!=="props"),c=n.map((j0)=>Z[j0]),$0=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"]),d=[],r=[];for(let[j0,w6]of Object.entries(_)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(j0))continue;if($0.has(j0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${j0}\\b`).test(g))continue;d.push(j0),r.push(w6)}let s=PN(g).map((j0)=>`module.exports.${j0} = typeof ${j0} !== 'undefined' ? ${j0} : module.exports.${j0};`).join(`
1842
+ `),Z}async function A0($,Z,Y){if(!$.trim())return;let X;try{let g=new Bun.Transpiler({loader:"ts",target:"browser",define:O1()}),m=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");m=m.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),X=g.transformSync(m)}catch{X=RU($)}let J={exports:{}},Q=J.exports,G=process.cwd(),K={},W=[...X.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((g)=>g[1]).filter((g)=>!g.startsWith("node:")&&!g.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(g));for(let g of W)try{let m=v6.resolve(G,"node_modules",g),n=v6.join(m,"package.json"),c=JSON.parse(a("fs").readFileSync(n,"utf8")),$0=c.main||"index.js";if(c.exports){let d=typeof c.exports==="string"?c.exports:c.exports["."];if(typeof d==="string")$0=d;else if(d?.bun)$0=d.bun;else if(d?.import)$0=d.import;else if(d?.default)$0=d.default}K[g]=await import(v6.resolve(m,$0))}catch{}let U=(g)=>{if(K[g])return K[g];return a(g)},_=Z.props||{},B=Object.assign((g)=>{if(!g)return _;let m={};for(let[n,c]of Object.entries(g)){let $0=_[n];if($0!==void 0)m[n]=$0;else if(typeof c==="function")m[n]=c();else m[n]=c}return m},_),z=()=>_,q=(g,m)=>{let n={...g};for(let[c,$0]of Object.entries(m))if(n[c]===void 0)if(typeof $0==="function")n[c]=$0();else n[c]=$0;return n},j=(g)=>{let m=()=>g;return m.set=(n)=>{},m.update=(n)=>{},m},H=(g)=>{let m,n=!1;return()=>{if(!n)try{m=g(),n=!0}catch{m=void 0}return m}},O=(g)=>{},F=(g)=>g(),L=(g)=>{},V=(g)=>{},N=(g)=>{},A=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),w=()=>({push:(g)=>{},replace:(g)=>{},back:()=>{},forward:()=>{},go:(g)=>{}}),M=(g)=>{E4(g);let m=Z.__stx_runtime_head||{},n=g||{};Z.__stx_runtime_head={...m,...n.title&&{title:n.title},meta:[...m.meta||[],...n.meta||[]],link:[...m.link||[],...n.link||[]],script:[...m.script||[],...n.script||[]],htmlAttrs:{...m.htmlAttrs||{},...n.htmlAttrs||{}},bodyAttrs:{...m.bodyAttrs||{},...n.bodyAttrs||{}}}},E=(g)=>{j5(g);let m=y6();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...m.title&&{title:m.title},meta:m.meta?[...m.meta]:[]}},T=(g)=>({value:g}),I=(g)=>g,S=(g)=>({value:typeof g==="function"?g():g}),k=(g,m)=>{},x=(g)=>{},f=(g)=>{},b=(g)=>g?g():Promise.resolve(),C=(g)=>(m,...n)=>{},v=(g)=>{},h=(g,m)=>{},u=(g,m)=>m,p=()=>({value:"light"}),i=()=>({value:!1}),_0={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:{}},q0=new Proxy(_0,{get(g,m){if(m in g)return g[m];return},set(g,m,n){return g[m]=n,!0}}),f0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},D0=console;try{let g=Y3(X,Y),m=new Set(Object.keys(_)),n=Object.keys(Z).filter((j0)=>!m.has(j0)&&j0!=="props"),c=n.map((j0)=>Z[j0]),$0=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"]),d=[],r=[];for(let[j0,w6]of Object.entries(_)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(j0))continue;if($0.has(j0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${j0}\\b`).test(g))continue;d.push(j0),r.push(w6)}let s=PN(g).map((j0)=>`module.exports.${j0} = typeof ${j0} !== 'undefined' ? ${j0} : module.exports.${j0};`).join(`
1843
1843
  `),G0=Z.params??{},B0=[],h0=[];for(let j0=0;j0<n.length;j0++){if(n[j0]==="params")continue;B0.push(n[j0]),h0.push(c[j0])}let a4=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","provide","inject","useColorMode","useDark","window","document","console","confirm","alert","fetch","params",...d,...B0,`return (async () => {
1844
1844
  ${g}
1845
1845
  ${s}
1846
1846
  return module.exports
1847
- })()`)(J,Q,U,_,B,z,q,j,H,O,F,L,V,N,A,w,M,E,I,T,S,k,b,y,v,C,f,h,u,l,i,q0,f0,D0,_0.confirm,_0.alert,_0.fetch,G0,...r,...h0);Object.assign(Z,a4);for(let[j0,w6]of Object.entries(_))if(!(j0 in Z))Z[j0]=w6}catch{try{await fN(X,Z,Y)}catch{}}}function Y3($,Z){let Y=Z?v6.dirname(Z):process.cwd(),X=$.split(`
1847
+ })()`)(J,Q,U,_,B,z,q,j,H,O,F,L,V,N,A,w,M,E,T,I,S,k,x,f,b,C,v,h,u,p,i,q0,f0,D0,_0.confirm,_0.alert,_0.fetch,G0,...r,...h0);Object.assign(Z,a4);for(let[j0,w6]of Object.entries(_))if(!(j0 in Z))Z[j0]=w6}catch{try{await fN(X,Z,Y)}catch{}}}function Y3($,Z){let Y=Z?v6.dirname(Z):process.cwd(),X=$.split(`
1848
1848
  `),J=[],Q=0;while(Q<X.length){let G=X[Q].trim();if(G.startsWith("interface ")||G.startsWith("export interface ")||G.startsWith("type ")||G.startsWith("export type ")){if(G.includes("{")&&!G.includes("}")){let K=0;for(;Q<X.length;Q++){for(let W of X[Q])if(W==="{")K++;else if(W==="}")K--;if(K<=0)break}}Q++;continue}if(G.startsWith("definePageMeta(")){let K=0,W=!1;for(let U=Q;U<X.length&&!W;U++){let _=null,B=!1,z=X[U];for(let q=0;q<z.length;q++){let j=z[q];if(B){B=!1;continue}if(j==="\\"){B=!0;continue}if(_){if(j===_)_=null;continue}if(j==='"'||j==="'"||j==="`"){_=j;continue}if(j==="(")K++;else if(j===")"){if(K--,K===0){Q=U+1,W=!0;break}}}}if(!W)Q=X.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),W=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),U=G.match(/^import\s+['"](.+)['"]/),_=(B)=>{if(B.startsWith("."))return v6.resolve(Y,B);return B};if(K){let[,B,z]=K,q=_(z);J.push(`const ${B} = await import('${q}')`),J.push(`module.exports.${B} = ${B};`)}else if(W){let[,B,z]=W,q=B.trim(),j=_(z);J.push(`const { ${q} } = await import('${j}')`);for(let H of q.split(",")){let O=H.trim().split(/\s+as\s+/).pop()?.trim();if(O)J.push(`module.exports.${O} = ${O};`)}}else if(U){let B=_(U[1]);J.push(`await import('${B}')`)}else J.push(G);Q++;continue}if(G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var ")){let K=AU(X,Q),{type:W,name:U,value:_}=K;J.push(`${W} ${U} = ${_};`),J.push(`module.exports.${U} = ${U};`),Q=K.nextIndex}else if(G.startsWith("export function ")||G.startsWith("export async function ")){let K=CX(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=AU(X,Q),{type:W,name:U,value:_}=K;J.push(`${W} ${U} = ${_};`),J.push(`module.exports.${U} = ${U};`),Q=K.nextIndex}else if(G.startsWith("function ")||G.startsWith("async function ")){let K=CX(X,Q);J.push(K.functionCode),J.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("export default function ")||G.startsWith("export default async function ")){let K=X[Q].replace(/^(\s*)export\s+default\s+/,"$1"),W=[...X];W[Q]=K;let U=CX(W,Q);if(J.push(U.functionCode),U.name)J.push(`module.exports.default = ${U.name};`);Q=U.nextIndex}else if(G.startsWith("export default ")){let K=G.replace(/^export\s+default\s+/,"").replace(/;$/,"");J.push(`module.exports.default = ${K};`),Q++}else if(G.startsWith("class ")||G.startsWith("export class ")){let K=G.match(/(?:export\s+)?class\s+(\w+)/);if(K){let W=K[1],U=X[Q].replace(/^export\s+/,""),_=0,B=Q;for(;B<X.length;B++){let z=X[B];for(let q of z)if(q==="{")_++;else if(q==="}")_--;if(B>Q)U+=`
1849
1849
  `+z;if(_<=0&&B>=Q)break}J.push(U),J.push(`module.exports.${W} = ${W};`),Q=B+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 yN(J.join(`
1850
1850
  `),Y)}function yN($,Z){let Y=$.length,X="",J=0,Q=null,G=!1,K=!1,W=0;while(J<Y){let U=$[J],_=$[J+1];if(G){if(X+=U,U===`
@@ -1860,7 +1860,7 @@ ${G}`,J++}return{functionCode:X,nextIndex:J}}async function fN($,Z,Y){let X=$.ma
1860
1860
  ${Array.from($.matchAll(/(?:const|let|var)\s+(\w+)\s*=/g)).map((W)=>`if (typeof ${W[1]} !== 'undefined') result.${W[1]} = ${W[1]};`).join(`
1861
1861
  `)}
1862
1862
  return result;
1863
- `)();Object.entries(K).forEach(([W,U])=>{if(U!==void 0&&!(W in Z))Z[W]=U})}catch{}}function PX($){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 yX($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var D4=D(()=>{T4();t4()});var PU={};e(PU,{processLoops:()=>K3});function uN($,Z){let Y=/@component\s*\(/g,X=$,J,Q=[];while((J=Y.exec(X))!==null){let G=J.index,K=G+J[0].length-1,W=1,U=K+1;while(U<X.length&&W>0){if(X[U]==="(")W++;else if(X[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let _=X.substring(K+1,U),B=U+1,z=_.match(/^\s*['"]([^'"]+)['"]/);if(!z)continue;let q=z[1],j=_.slice(z[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let O=j.slice(H[0].length).trim();if(!O)continue;try{let F=y0(O,Z),L=JSON.stringify(F),V=`@component('${q}', ${L})`;Q.push({start:G,end:B,replacement:V})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];X=X.substring(0,K)+U+X.substring(W)}return X}function J3($,Z,Y){let X=$,J=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1,_=null,B=!1;while(U<X.length&&W>0){let j=X[U];if(B){B=!1,U++;continue}if(j==="\\"&&_){B=!0,U++;continue}if(_){if(j===_)_=null;U++;continue}if(j==='"'||j==="'"||j==="`"){_=j,U++;continue}if(j==="(")W++;else if(j===")"){if(W--,W===0)break}U++}if(W!==0)break;let z=X.substring(K+1,U),q=Y(z);X=X.substring(0,G)+q+X.substring(U+1)}return X}function mN($,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);t$(Q);let U=V0(Q,G)(...K),B=JSON.stringify(U).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return`__stx_${J}="${B}"`}catch(G){return X}}),Y}function cN($,Z){let Y=$;return Y=J3(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(L0(Q)){let K=V0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(R0(Q,Z));return G?Q3:""}catch{return""}}),Y=J3(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(L0(Q)){let K=V0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(R0(Q,Z));return G?G3:""}catch{return""}}),Y}function pN($){let Z=$;return Z=Z.replace(/@break(?!\()/g,Q3),Z=Z.replace(/@continue(?!\()/g,G3),Z}function IU($){let Z=$.includes(Q3),Y=Z?$.substring(0,$.indexOf(Q3)):$;return{hasBreak:Z,content:Y}}function DU($){let Z=$.includes(G3),Y=Z?$.substring(0,$.indexOf(G3)):$;return{hasContinue:Z,content:Y}}function SU($){let Z=$;return Z=J3(Z,"@break",(Y)=>{let X=Y.trim();if(!R8(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=J3(Z,"@continue",(Y)=>{let X=Y.trim();if(!R8(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function lN($){let Z=/@forelse\s*\(/g,Y,X=[],J=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=J.exec($))!==null)X.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((_,B)=>_.pos-B.pos);let K=[],W=0;for(let _ of X)W+=_.delta,K.push({pos:_.pos,depth:W});function U(_){let B=0,z=K.length-1,q=0;while(B<=z){let j=B+z>>1;if(K[j].pos<=_)q=K[j].depth,B=j+1;else z=j-1}return q}while((Y=Z.exec($))!==null){if(U(Y.index)>0)continue;let _=Y.index,B=Y.index+Y[0].length-1,z=1,q=B+1,j=-1;while(q<$.length&&z>0){if($[q]==="(")z++;else if($[q]===")"){if(z--,z===0){j=q;break}}q++}if(j===-1)continue;let H=$.substring(B+1,j),O=H.indexOf(" as ");if(O===-1)continue;let F=H.substring(0,O).trim(),L=H.substring(O+4).trim(),V=j+1,N=1,A=V,w=/@forelse\s*\(/g,M=/@endforelse/g,E=-1;while(N>0&&A<$.length){w.lastIndex=A,M.lastIndex=A;let y=w.exec($),v=M.exec($);if(!v)break;if(y&&y.index<v.index)N++,A=y.index+y[0].length;else{if(N--,N===0){E=v.index;break}A=v.index+11}}if(E===-1)continue;let I=$.substring(V,E),T=E+11,S=-1,k=0,b=0;while(b<I.length){let y=I.indexOf("@",b);if(y===-1)break;let v=I.substring(y);if(/^@forelse\s*\(/.test(v))k++,b=y+1;else if(v.startsWith("@endforelse"))k--,b=y+11;else if(k===0&&v.startsWith("@empty")){if(I.length<=y+6||!/[a-z]/i.test(I[y+6])){S=y;break}b=y+1}else b=y+1}if(S===-1)continue;return{start:_,end:T,arrayExpr:F,itemVar:L,foreachContent:I.substring(0,S),emptyContent:I.substring(S+6)}}return null}function kU($,Z){let Y=$;while(!0){let X=lN(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=X;try{let _;if(L0(G))_=V0(G,Object.keys(Z))(...Object.values(Z));else _=R0(G,Z);let B;if(!Array.isArray(_)||_.length===0)B=U;else B=`@foreach (${G} as ${K})${W}@endforeach`;Y=Y.substring(0,J)+B+Y.substring(Q)}catch(_){let B=_ instanceof Error?_.message:String(_),z=W0("Forelse",`Error in @forelse(${G} as ${K}): ${B}`,Z0.EVALUATION_ERROR);Y=Y.substring(0,J)+z+Y.substring(Q)}}return Y}function K3($,Z,Y,X){let J=$;J=kU(J,Z);function Q(W){let U=/@foreach\s*\(/g,_;while((_=U.exec(W))!==null){let B=_.index,z=_.index+_[0].length-1,q=1,j=z+1,H=-1;while(j<W.length&&q>0){if(W[j]==="(")q++;else if(W[j]===")"){if(q--,q===0){H=j;break}}j++}if(H===-1)continue;let O=W.substring(z+1,H),F=O.indexOf(" as ");if(F===-1)continue;let L=B,V=O.substring(0,F),N=O.substring(F+4),A=H+1,w=1,M=A,E=/@foreach\s*\(/g,I=/@endforeach/g;while(w>0&&M<W.length){E.lastIndex=M,I.lastIndex=M;let T=E.exec(W),S=I.exec(W);if(!S)break;if(T&&T.index<S.index)w++,M=T.index+T[0].length;else{if(w--,w===0){let k=W.substring(A,S.index),b=S.index+11;return{start:L,end:b,arrayExpr:V,itemVar:N,content:k}}M=S.index+11}}}return null}function G(W,U){let _=W;while(!0){let B=Q(_);if(!B)break;let{start:z,end:q,arrayExpr:j,itemVar:H,content:O}=B;try{let F=j.trim(),L;if(L0(F))L=V0(F,Object.keys(U))(...Object.values(U));else L=R0(F,U);let V=!1;if(!Array.isArray(L))if(L instanceof Map)L=Array.from(L),V=!0;else if(L instanceof Set)L=Array.from(L);else if(typeof L==="string")L=Array.from(L);else if(L&&typeof L==="object"&&!(L instanceof Date)&&!(L instanceof RegExp))L=Object.entries(L),V=!0;else{let T=W0("Foreach",`Error in @foreach: ${F} is not iterable`,Z0.TYPE_ERROR);_=_.substring(0,z)+T+_.substring(q);continue}let N=X?.loops?.useAltLoopVariable??dN,A=H.trim(),w=null,M;if(A.includes("=>")){let T=A.split("=>").map((S)=>S.trim());if(T.length===2)w=T[0],M=T[1];else M=A}else M=A;let E="",I=L;for(let T=0;T<I.length;T++){let S=I[T],k={index:T,iteration:T+1,first:T===0,last:T===I.length-1,count:I.length},b={...U,loop:k,$loop:k};if(M.startsWith("[")&&M.endsWith("]")){let f=M.slice(1,-1).split(",").map((h)=>h.trim());if(Array.isArray(S))f.forEach((h,u)=>{if(h)b[h]=S[u]});else b[M]=S}else b[M]=S;if(w)if(V&&Array.isArray(S)&&S.length===2)b[w]=S[0],b[M]=S[1];else b[w]=T;let y=cN(O,b),v=DU(y);if(v.hasContinue){E+=v.content;continue}let C=IU(y);if(C.hasBreak){E+=C.content;break}if(y=kU(y,b),y=G(y,b),y=$6(y,b,Y),y=pN(y),C=IU(y),C.hasBreak){E+=C.content;break}if(v=DU(y),v.hasContinue){E+=v.content;continue}y=L1(y,b,Y),y=mN(y,b),y=uN(y,b),E+=y}_=_.substring(0,z)+E+_.substring(q)}catch(F){let L=W0("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,Z0.EVALUATION_ERROR);_=_.substring(0,z)+L+_.substring(q)}}return _}J=G(J,Z),J=CU(J,Z,Y,X);let K=X?.loops?.maxWhileIterations??hN;return J=rN(J,Z,K),J}function bU($){return R8($)}function CU($,Z,Y,X){let J=$,Q=!0;while(Q){Q=!1;let G=J.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K+G[0].length-1,U=x0(J,"(",")",W);if(U===-1)break;let _=J.slice(W+1,U),B=U+1,z=q5(J.slice(K),"for","endfor");if(z.length===0)break;let q=z[0].content,j=K+z[0].end;if(!bU(_)){let H=W0("For",`Unsafe expression in @for: ${_}`,Z0.UNSAFE_EXPRESSION);J=J.substring(0,K)+H+J.substring(j),Q=!0;continue}try{let H=iN(_),O=/@(?:for|foreach|if|unless)\s*\(/.test(q);if(H.length>0&&O){let w=nN({forExpr:_,content:q,iterVarNames:H,context:Z,filePath:Y,options:X});J=J.substring(0,K)+w+J.substring(j),Q=!0;continue}let F=Object.keys(Z),L=Object.values(Z),V=q.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(w,M)=>{return`\${${M}}`});V=SU(V);let A=Function(...F,`
1863
+ `)();Object.entries(K).forEach(([W,U])=>{if(U!==void 0&&!(W in Z))Z[W]=U})}catch{}}function PX($){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 yX($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var D4=D(()=>{T4();t4()});var PU={};e(PU,{processLoops:()=>K3});function uN($,Z){let Y=/@component\s*\(/g,X=$,J,Q=[];while((J=Y.exec(X))!==null){let G=J.index,K=G+J[0].length-1,W=1,U=K+1;while(U<X.length&&W>0){if(X[U]==="(")W++;else if(X[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let _=X.substring(K+1,U),B=U+1,z=_.match(/^\s*['"]([^'"]+)['"]/);if(!z)continue;let q=z[1],j=_.slice(z[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let O=j.slice(H[0].length).trim();if(!O)continue;try{let F=y0(O,Z),L=JSON.stringify(F),V=`@component('${q}', ${L})`;Q.push({start:G,end:B,replacement:V})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];X=X.substring(0,K)+U+X.substring(W)}return X}function J3($,Z,Y){let X=$,J=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1,_=null,B=!1;while(U<X.length&&W>0){let j=X[U];if(B){B=!1,U++;continue}if(j==="\\"&&_){B=!0,U++;continue}if(_){if(j===_)_=null;U++;continue}if(j==='"'||j==="'"||j==="`"){_=j,U++;continue}if(j==="(")W++;else if(j===")"){if(W--,W===0)break}U++}if(W!==0)break;let z=X.substring(K+1,U),q=Y(z);X=X.substring(0,G)+q+X.substring(U+1)}return X}function mN($,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);t$(Q);let U=V0(Q,G)(...K),B=JSON.stringify(U).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return`__stx_${J}="${B}"`}catch(G){return X}}),Y}function cN($,Z){let Y=$;return Y=J3(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(L0(Q)){let K=V0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(R0(Q,Z));return G?Q3:""}catch{return""}}),Y=J3(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(L0(Q)){let K=V0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(R0(Q,Z));return G?G3:""}catch{return""}}),Y}function pN($){let Z=$;return Z=Z.replace(/@break(?!\()/g,Q3),Z=Z.replace(/@continue(?!\()/g,G3),Z}function IU($){let Z=$.includes(Q3),Y=Z?$.substring(0,$.indexOf(Q3)):$;return{hasBreak:Z,content:Y}}function DU($){let Z=$.includes(G3),Y=Z?$.substring(0,$.indexOf(G3)):$;return{hasContinue:Z,content:Y}}function SU($){let Z=$;return Z=J3(Z,"@break",(Y)=>{let X=Y.trim();if(!R8(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=J3(Z,"@continue",(Y)=>{let X=Y.trim();if(!R8(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function lN($){let Z=/@forelse\s*\(/g,Y,X=[],J=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=J.exec($))!==null)X.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((_,B)=>_.pos-B.pos);let K=[],W=0;for(let _ of X)W+=_.delta,K.push({pos:_.pos,depth:W});function U(_){let B=0,z=K.length-1,q=0;while(B<=z){let j=B+z>>1;if(K[j].pos<=_)q=K[j].depth,B=j+1;else z=j-1}return q}while((Y=Z.exec($))!==null){if(U(Y.index)>0)continue;let _=Y.index,B=Y.index+Y[0].length-1,z=1,q=B+1,j=-1;while(q<$.length&&z>0){if($[q]==="(")z++;else if($[q]===")"){if(z--,z===0){j=q;break}}q++}if(j===-1)continue;let H=$.substring(B+1,j),O=H.indexOf(" as ");if(O===-1)continue;let F=H.substring(0,O).trim(),L=H.substring(O+4).trim(),V=j+1,N=1,A=V,w=/@forelse\s*\(/g,M=/@endforelse/g,E=-1;while(N>0&&A<$.length){w.lastIndex=A,M.lastIndex=A;let f=w.exec($),b=M.exec($);if(!b)break;if(f&&f.index<b.index)N++,A=f.index+f[0].length;else{if(N--,N===0){E=b.index;break}A=b.index+11}}if(E===-1)continue;let T=$.substring(V,E),I=E+11,S=-1,k=0,x=0;while(x<T.length){let f=T.indexOf("@",x);if(f===-1)break;let b=T.substring(f);if(/^@forelse\s*\(/.test(b))k++,x=f+1;else if(b.startsWith("@endforelse"))k--,x=f+11;else if(k===0&&b.startsWith("@empty")){if(T.length<=f+6||!/[a-z]/i.test(T[f+6])){S=f;break}x=f+1}else x=f+1}if(S===-1)continue;return{start:_,end:I,arrayExpr:F,itemVar:L,foreachContent:T.substring(0,S),emptyContent:T.substring(S+6)}}return null}function kU($,Z){let Y=$;while(!0){let X=lN(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=X;try{let _;if(L0(G))_=V0(G,Object.keys(Z))(...Object.values(Z));else _=R0(G,Z);let B;if(!Array.isArray(_)||_.length===0)B=U;else B=`@foreach (${G} as ${K})${W}@endforeach`;Y=Y.substring(0,J)+B+Y.substring(Q)}catch(_){let B=_ instanceof Error?_.message:String(_),z=W0("Forelse",`Error in @forelse(${G} as ${K}): ${B}`,Z0.EVALUATION_ERROR);Y=Y.substring(0,J)+z+Y.substring(Q)}}return Y}function K3($,Z,Y,X){let J=$;J=kU(J,Z);function Q(W){let U=/@foreach\s*\(/g,_;while((_=U.exec(W))!==null){let B=_.index,z=_.index+_[0].length-1,q=1,j=z+1,H=-1;while(j<W.length&&q>0){if(W[j]==="(")q++;else if(W[j]===")"){if(q--,q===0){H=j;break}}j++}if(H===-1)continue;let O=W.substring(z+1,H),F=O.indexOf(" as ");if(F===-1)continue;let L=B,V=O.substring(0,F),N=O.substring(F+4),A=H+1,w=1,M=A,E=/@foreach\s*\(/g,T=/@endforeach/g;while(w>0&&M<W.length){E.lastIndex=M,T.lastIndex=M;let I=E.exec(W),S=T.exec(W);if(!S)break;if(I&&I.index<S.index)w++,M=I.index+I[0].length;else{if(w--,w===0){let k=W.substring(A,S.index),x=S.index+11;return{start:L,end:x,arrayExpr:V,itemVar:N,content:k}}M=S.index+11}}}return null}function G(W,U){let _=W;while(!0){let B=Q(_);if(!B)break;let{start:z,end:q,arrayExpr:j,itemVar:H,content:O}=B;try{let F=j.trim(),L;if(L0(F))L=V0(F,Object.keys(U))(...Object.values(U));else L=R0(F,U);let V=!1;if(!Array.isArray(L))if(L instanceof Map)L=Array.from(L),V=!0;else if(L instanceof Set)L=Array.from(L);else if(typeof L==="string")L=Array.from(L);else if(L&&typeof L==="object"&&!(L instanceof Date)&&!(L instanceof RegExp))L=Object.entries(L),V=!0;else{let S=W0("Foreach",`Error in @foreach: ${F} is not iterable`,Z0.TYPE_ERROR);_=_.substring(0,z)+S+_.substring(q);continue}let N=X?.loops?.useAltLoopVariable??dN,A=H.trim(),w=null,M,E=!1;if(A.includes("=>")){let S=A.split("=>").map((k)=>k.trim());if(S.length===2&&S[0]&&S[1])w=S[0],M=S[1];else M=A}else if(!A.startsWith("[")&&!A.startsWith("{")&&A.includes(",")){let S=A.split(",").map((k)=>k.trim());if(S.length===2&&S[0]&&S[1])M=S[0],w=S[1],E=!0;else M=A}else M=A;let T="",I=L;for(let S=0;S<I.length;S++){let k=I[S],x={index:S,iteration:S+1,first:S===0,last:S===I.length-1,count:I.length},f={...U,loop:x,$loop:x};if(M.startsWith("[")&&M.endsWith("]")){let h=M.slice(1,-1).split(",").map((u)=>u.trim());if(Array.isArray(k))h.forEach((u,p)=>{if(u)f[u]=k[p]});else f[M]=k}else f[M]=k;if(w)if(!E&&V&&Array.isArray(k)&&k.length===2)f[w]=k[0],f[M]=k[1];else f[w]=S;let b=cN(O,f),C=DU(b);if(C.hasContinue){T+=C.content;continue}let v=IU(b);if(v.hasBreak){T+=v.content;break}if(b=kU(b,f),b=G(b,f),b=$6(b,f,Y),b=pN(b),v=IU(b),v.hasBreak){T+=v.content;break}if(C=DU(b),C.hasContinue){T+=C.content;continue}b=L1(b,f,Y),b=mN(b,f),b=uN(b,f),T+=b}_=_.substring(0,z)+T+_.substring(q)}catch(F){let L=W0("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,Z0.EVALUATION_ERROR);_=_.substring(0,z)+L+_.substring(q)}}return _}J=G(J,Z),J=CU(J,Z,Y,X);let K=X?.loops?.maxWhileIterations??hN;return J=rN(J,Z,K),J}function bU($){return R8($)}function CU($,Z,Y,X){let J=$,Q=!0;while(Q){Q=!1;let G=J.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K+G[0].length-1,U=x0(J,"(",")",W);if(U===-1)break;let _=J.slice(W+1,U),B=U+1,z=q5(J.slice(K),"for","endfor");if(z.length===0)break;let q=z[0].content,j=K+z[0].end;if(!bU(_)){let H=W0("For",`Unsafe expression in @for: ${_}`,Z0.UNSAFE_EXPRESSION);J=J.substring(0,K)+H+J.substring(j),Q=!0;continue}try{let H=iN(_),O=/@(?:for|foreach|if|unless)\s*\(/.test(q);if(H.length>0&&O){let w=nN({forExpr:_,content:q,iterVarNames:H,context:Z,filePath:Y,options:X});J=J.substring(0,K)+w+J.substring(j),Q=!0;continue}let F=Object.keys(Z),L=Object.values(Z),V=q.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(w,M)=>{return`\${${M}}`});V=SU(V);let A=Function(...F,`
1864
1864
  let result = '';
1865
1865
  for (${_}) {
1866
1866
  result += \`${V}\`;
@@ -1896,11 +1896,11 @@ ${$}
1896
1896
  if (!window.stx._scopes) window.stx._scopes = {};
1897
1897
  window.stx._scopes['${Z}'] = { ${Y}, __destroyCallbacks: __destroyHooks };
1898
1898
  })();
1899
- `}function eN($,Z){let Y=$.match(/^(\s*(?:<!--[\s\S]*?-->\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 Zw(){vX.clear()}function Yw($){if($.__onceStore instanceof Set)return $.__onceStore;return vX}async function U3($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||T0.join(T0.dirname(Y),"partials");if(G&&!T0.isAbsolute(G)){let j=T0.resolve(__dirname,"..");G=T0.resolve(j,G)}let K=sN($,"@partial","@include"),W=Yw(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,O)=>{let F=H.trim(),L=`${Y}:${F}`;if(W.has(L))return"";return W.add(L),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")")L--;V++}if(L!==0)break;let N=K.substring(F+1,V-1),A=N.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let w=A[1],M=U(w,G,Y),E="";if(M&&await Bun.file(M).exists())J.add(M),E=`@include(${N})`;K=K.substring(0,O)+E+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=O.exec(K))!==null){let L=F.index,V=L+F[0].length-1,N=1,A=V+1;while(A<K.length&&N>0){if(K[A]==="(")N++;else if(K[A]===")")N--;A++}if(N!==0)break;let w=K.substring(V+1,A-1),M=xX(w,0);if(M===-1){O.lastIndex=A;continue}let E=w.substring(0,M).trim(),I=w.substring(M+1).trim(),T=I.match(/^\s*['"]([^'"]+)['"]/);if(!T){O.lastIndex=A;continue}let S=T[1],k=I.substring(T[0].length),b,y=xX(k,0);if(y!==-1)b=k.substring(y+1).trim();try{let v=`Boolean(${E})`,C;if(L0(v)){let u=V0(v,Object.keys(Z));C=Boolean(u(...Object.values(Z)))}else C=Boolean(R0(v,Z));let f=H?!C:C,h="";if(f){let u=U(S,G,Y);if(u&&await Bun.file(u).exists())J.add(u);h=`@include('${S}'${b?`, ${b}`:""})`}K=K.substring(0,L)+h+K.substring(A),O.lastIndex=0}catch(v){let C=v instanceof Error?v.message:String(v),f=F0("Include",`Error evaluating ${j} condition: ${C}`,Y,$,L);K=K.substring(0,L)+f+K.substring(A),O.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")"){if(L--,L===0)break}V++}if(L!==0)break;let N=K.substring(F+1,V),A=K.substring(O,V+1),w=N.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!w){j.lastIndex=0,K=K.replace(A,"");continue}let[,M,E,I,T]=w;try{let S,k=E.trim();if(L0(k))S=V0(k,Object.keys(Z))(...Object.values(Z));else S=R0(k,Z);let b="";if(Array.isArray(S)&&S.length>0)for(let y of S){let v={...Z,[I]:y},C=await B(M,v,$,O);b+=C}else if(T)b=await B(T,{},$,O);K=K.substring(0,O)+b+K.substring(V+1),j.lastIndex=0}catch(S){let k=S instanceof Error?S.message:String(S);K=K.substring(0,O)+F0("Each",`Error in @each: ${k}`,Y,$,O)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")"){if(L--,L===0)break}V++}if(L!==0)break;let N=K.substring(F+1,V),A=K.substring(O,V+1),w=N.match(/^\s*(\[[^\]]+\])/);if(!w){j.lastIndex=0,K=K.replace(A,"");continue}let M=w[1],E=N.slice(w[0].length),I,T=E.match(/^\s*,\s*\{/);if(T){E=E.slice(T[0].length-1);let b=1,y=1;while(y<E.length&&b>0){if(E[y]==="{")b++;else if(E[y]==="}"){if(b--,b===0)break}y++}I=E.substring(0,y+1),E=E.slice(y+1)}let S,k=E.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(k)S=k[1];try{let b=JSON.parse(M.replace(/'/g,'"')),y={};if(I)try{y=y0(I,Z)}catch(C){let f=C instanceof Error?C.message:String(C);if(X.debug){let h=F0("Include",`Error parsing includeFirst variables: ${f}`,Y,$,O,A);K=K.replace(A,()=>h)}else K=K.replace(A,()=>S||"");continue}let v=!1;for(let C of b){let f=U(C,G,Y);if(!f)continue;if(await Y0(f)){let h=await B(C,y,$,O);K=K.replace(A,()=>h),v=!0;break}}if(!v)if(S!==void 0)K=K.replace(A,()=>S);else if(X.debug){let C=F0("Include",`None of the includeFirst paths exist: ${M}`,Y,$,O,A);K=K.replace(A,()=>C)}else K=K.replace(A,"")}catch(b){let y=b instanceof Error?b.message:String(b),v=F0("Include",`Error processing @includeFirst: ${y}`,Y,$,O,A);K=K.replace(A,()=>v)}j.lastIndex=0}}function U(j,H,O){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let L=T0.resolve(H),V=T0.resolve(T0.dirname(O)),N;if(!F.startsWith("./")&&!F.startsWith("../"))N=T0.resolve(H,F);else N=T0.resolve(V,F);let A=T0.normalize(N),w=A.startsWith(L+T0.sep)||A===L,M=A.startsWith(V+T0.sep)||A===V,E=!1,I=T0.dirname(V);if(A.startsWith(I+T0.sep)){if(!T0.relative(I,A).split(T0.sep).some((b)=>b.startsWith(".")&&b!=="."&&b!==".."))E=!0}if(!w&&!M&&!E)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${A}`),console.error(` Allowed dirs: ${L}, ${V}`),null;return A}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let _=T0.resolve(Y);Q.add(_);async function B(j,H={},O,F){let L=U(j,G,Y);if(!L)return F0("Include",`Could not resolve path for include: ${j}`,Y,O,F);let V=T0.resolve(L);if(Q.has(V)){let N=[...Q,V].map((A)=>T0.basename(A)).join(" -> ");return F0("Include",`Circular include detected: ${N}`,Y,O,F)}try{J.add(L);let N;if(!N)try{N=await Bun.file(L).text()}catch(C){let f=C instanceof Error?C.message:String(C);return F0("Include",`Error loading include file ${j}: ${f}`,Y,O,F)}let A=N,w=A.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(w)A=w[1].trim();let M=N.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),E="";if(M)E=`<style${M[1]}>${M[2]}</style>`;A=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),A=A.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[C,f]of Object.entries(H))I[C]=f;let T=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,S=[...N.matchAll(T)],k="",b=null;for(let C of S){let f=C[1]||"",h=C[2]||"",u=f.includes("server");if(L4(f)&&h.trim())h=F4(h);let i=aN(h);if(i&&!u){b=`stx_scope_${T0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++$w}`;let _0=O4(h),q0=tN(_0,b);k+=`<script data-stx-scoped>${q0}</script>
1900
- `;continue}if(u)try{let{extractVariables:_0}=await Promise.resolve().then(() => (D4(),X3));await _0(h,I,L)}catch(_0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${L}:`,_0)}if(!u&&!i){let _0=f.replace(/\bclient\b/i,"").trim();k+=`<script data-stx-scoped${_0?` ${_0}`:""}>${h}</script>
1901
- `}}if(b){let C=eN(A,b);if(A=C.html,C.mergedIntoExisting)k=k.replace(`window.stx._scopes['${b}']`,`window.stx._scopes['${C.mergedIntoExisting}']`),b=C.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await U3(A,I,L,X,J,Q);let{processLoops:y}=await Promise.resolve().then(() => (W3(),PU)),v=y(A,I,L);if(v=$6(v,I,L),v=L1(v,I,L),E)v+=`
1902
- `+E;if(k)v+=`
1903
- `+k;return v}catch(N){let A=N instanceof Error?N.message:String(N);return F0("Include",`Error processing include ${j}: ${A}`,Y,O,F)}}let z=/@include\s*\(/g,q;while((q=z.exec(K))!==null){let j=q.index,H=j+q[0].length-1,O=1,F=H+1;while(F<K.length&&O>0){if(K[F]==="(")O++;else if(K[F]===")")O--;F++}if(O!==0)break;let L=K.substring(j,F),V=K.substring(H+1,F-1),N=V.match(/^\s*['"]([^'"]+)['"]/);if(!N){z.lastIndex=F;continue}let A=N[1],w,M=V.substring(N[0].length),E=xX(M,0);if(E!==-1)w=M.substring(E+1).trim();let I={};if(w)try{I=y0(w,Z)}catch(S){let k=S instanceof Error?S.message:String(S);K=K.replace(L,F0("Include",`Error parsing include variables for ${A}: ${k}`,Y,$,j)),z.lastIndex=0;continue}let T=await B(A,I,$,j);K=K.substring(0,j)+T+K.substring(F),z.lastIndex=0}return K}function _3($,Z){let Y=$;function X(J,Q,G,K){let W=J,U=!0;while(U){U=!1;let _=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),B=W.match(_);if(!B||B.index===void 0)break;let z=B.index,q=B[1],j=z+B[0].length,H=new RegExp(`@${Q}\\(`),O=new RegExp(`@${G}(?![a-z])`),F=1,L=j,V=-1;while(F>0&&L<W.length){let A=W.slice(L),w=A.match(H),M=A.match(O),E=w?L+w.index:1/0,I=M?L+M.index:1/0;if(E<I)F++,L=E+(w[0].length||1);else if(I<1/0){if(F--,F===0){V=I;break}L=I+G.length+1}else break}if(V===-1)break;let N=W.slice(j,V);if(!Z[q])Z[q]=[];if(K)Z[q].unshift(N);else Z[q].push(N);W=W.substring(0,z)+W.substring(V+`@${G}`.length),U=!0}return W}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function B3($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
1899
+ `}function eN($,Z){let Y=$.match(/^(\s*(?:<!--[\s\S]*?-->\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 Zw(){vX.clear()}function Yw($){if($.__onceStore instanceof Set)return $.__onceStore;return vX}async function U3($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||T0.join(T0.dirname(Y),"partials");if(G&&!T0.isAbsolute(G)){let j=T0.resolve(__dirname,"..");G=T0.resolve(j,G)}let K=sN($,"@partial","@include"),W=Yw(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,O)=>{let F=H.trim(),L=`${Y}:${F}`;if(W.has(L))return"";return W.add(L),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")")L--;V++}if(L!==0)break;let N=K.substring(F+1,V-1),A=N.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let w=A[1],M=U(w,G,Y),E="";if(M&&await Bun.file(M).exists())J.add(M),E=`@include(${N})`;K=K.substring(0,O)+E+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=O.exec(K))!==null){let L=F.index,V=L+F[0].length-1,N=1,A=V+1;while(A<K.length&&N>0){if(K[A]==="(")N++;else if(K[A]===")")N--;A++}if(N!==0)break;let w=K.substring(V+1,A-1),M=xX(w,0);if(M===-1){O.lastIndex=A;continue}let E=w.substring(0,M).trim(),T=w.substring(M+1).trim(),I=T.match(/^\s*['"]([^'"]+)['"]/);if(!I){O.lastIndex=A;continue}let S=I[1],k=T.substring(I[0].length),x,f=xX(k,0);if(f!==-1)x=k.substring(f+1).trim();try{let b=`Boolean(${E})`,C;if(L0(b)){let u=V0(b,Object.keys(Z));C=Boolean(u(...Object.values(Z)))}else C=Boolean(R0(b,Z));let v=H?!C:C,h="";if(v){let u=U(S,G,Y);if(u&&await Bun.file(u).exists())J.add(u);h=`@include('${S}'${x?`, ${x}`:""})`}K=K.substring(0,L)+h+K.substring(A),O.lastIndex=0}catch(b){let C=b instanceof Error?b.message:String(b),v=F0("Include",`Error evaluating ${j} condition: ${C}`,Y,$,L);K=K.substring(0,L)+v+K.substring(A),O.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")"){if(L--,L===0)break}V++}if(L!==0)break;let N=K.substring(F+1,V),A=K.substring(O,V+1),w=N.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!w){j.lastIndex=0,K=K.replace(A,"");continue}let[,M,E,T,I]=w;try{let S,k=E.trim();if(L0(k))S=V0(k,Object.keys(Z))(...Object.values(Z));else S=R0(k,Z);let x="";if(Array.isArray(S)&&S.length>0)for(let f of S){let b={...Z,[T]:f},C=await B(M,b,$,O);x+=C}else if(I)x=await B(I,{},$,O);K=K.substring(0,O)+x+K.substring(V+1),j.lastIndex=0}catch(S){let k=S instanceof Error?S.message:String(S);K=K.substring(0,O)+F0("Each",`Error in @each: ${k}`,Y,$,O)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")"){if(L--,L===0)break}V++}if(L!==0)break;let N=K.substring(F+1,V),A=K.substring(O,V+1),w=N.match(/^\s*(\[[^\]]+\])/);if(!w){j.lastIndex=0,K=K.replace(A,"");continue}let M=w[1],E=N.slice(w[0].length),T,I=E.match(/^\s*,\s*\{/);if(I){E=E.slice(I[0].length-1);let x=1,f=1;while(f<E.length&&x>0){if(E[f]==="{")x++;else if(E[f]==="}"){if(x--,x===0)break}f++}T=E.substring(0,f+1),E=E.slice(f+1)}let S,k=E.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(k)S=k[1];try{let x=JSON.parse(M.replace(/'/g,'"')),f={};if(T)try{f=y0(T,Z)}catch(C){let v=C instanceof Error?C.message:String(C);if(X.debug){let h=F0("Include",`Error parsing includeFirst variables: ${v}`,Y,$,O,A);K=K.replace(A,()=>h)}else K=K.replace(A,()=>S||"");continue}let b=!1;for(let C of x){let v=U(C,G,Y);if(!v)continue;if(await Y0(v)){let h=await B(C,f,$,O);K=K.replace(A,()=>h),b=!0;break}}if(!b)if(S!==void 0)K=K.replace(A,()=>S);else if(X.debug){let C=F0("Include",`None of the includeFirst paths exist: ${M}`,Y,$,O,A);K=K.replace(A,()=>C)}else K=K.replace(A,"")}catch(x){let f=x instanceof Error?x.message:String(x),b=F0("Include",`Error processing @includeFirst: ${f}`,Y,$,O,A);K=K.replace(A,()=>b)}j.lastIndex=0}}function U(j,H,O){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let L=T0.resolve(H),V=T0.resolve(T0.dirname(O)),N;if(!F.startsWith("./")&&!F.startsWith("../"))N=T0.resolve(H,F);else N=T0.resolve(V,F);let A=T0.normalize(N),w=A.startsWith(L+T0.sep)||A===L,M=A.startsWith(V+T0.sep)||A===V,E=!1,T=T0.dirname(V);if(A.startsWith(T+T0.sep)){if(!T0.relative(T,A).split(T0.sep).some((x)=>x.startsWith(".")&&x!=="."&&x!==".."))E=!0}if(!w&&!M&&!E)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${A}`),console.error(` Allowed dirs: ${L}, ${V}`),null;return A}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let _=T0.resolve(Y);Q.add(_);async function B(j,H={},O,F){let L=U(j,G,Y);if(!L)return F0("Include",`Could not resolve path for include: ${j}`,Y,O,F);let V=T0.resolve(L);if(Q.has(V)){let N=[...Q,V].map((A)=>T0.basename(A)).join(" -> ");return F0("Include",`Circular include detected: ${N}`,Y,O,F)}try{J.add(L);let N;if(!N)try{N=await Bun.file(L).text()}catch(C){let v=C instanceof Error?C.message:String(C);return F0("Include",`Error loading include file ${j}: ${v}`,Y,O,F)}let A=N,w=A.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(w)A=w[1].trim();let M=N.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),E="";if(M)E=`<style${M[1]}>${M[2]}</style>`;A=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),A=A.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let T={...Z};for(let[C,v]of Object.entries(H))T[C]=v;let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,S=[...N.matchAll(I)],k="",x=null;for(let C of S){let v=C[1]||"",h=C[2]||"",u=v.includes("server");if(L4(v)&&h.trim())h=F4(h);let i=aN(h);if(i&&!u){x=`stx_scope_${T0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++$w}`;let _0=O4(h),q0=tN(_0,x);k+=`<script data-stx-scoped>${q0}</script>
1900
+ `;continue}if(u)try{let{extractVariables:_0}=await Promise.resolve().then(() => (D4(),X3));await _0(h,T,L)}catch(_0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${L}:`,_0)}if(!u&&!i){let _0=v.replace(/\bclient\b/i,"").trim();k+=`<script data-stx-scoped${_0?` ${_0}`:""}>${h}</script>
1901
+ `}}if(x){let C=eN(A,x);if(A=C.html,C.mergedIntoExisting)k=k.replace(`window.stx._scopes['${x}']`,`window.stx._scopes['${C.mergedIntoExisting}']`),x=C.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await U3(A,T,L,X,J,Q);let{processLoops:f}=await Promise.resolve().then(() => (W3(),PU)),b=f(A,T,L);if(b=$6(b,T,L),b=L1(b,T,L),E)b+=`
1902
+ `+E;if(k)b+=`
1903
+ `+k;return b}catch(N){let A=N instanceof Error?N.message:String(N);return F0("Include",`Error processing include ${j}: ${A}`,Y,O,F)}}let z=/@include\s*\(/g,q;while((q=z.exec(K))!==null){let j=q.index,H=j+q[0].length-1,O=1,F=H+1;while(F<K.length&&O>0){if(K[F]==="(")O++;else if(K[F]===")")O--;F++}if(O!==0)break;let L=K.substring(j,F),V=K.substring(H+1,F-1),N=V.match(/^\s*['"]([^'"]+)['"]/);if(!N){z.lastIndex=F;continue}let A=N[1],w,M=V.substring(N[0].length),E=xX(M,0);if(E!==-1)w=M.substring(E+1).trim();let T={};if(w)try{T=y0(w,Z)}catch(S){let k=S instanceof Error?S.message:String(S);K=K.replace(L,F0("Include",`Error parsing include variables for ${A}: ${k}`,Y,$,j)),z.lastIndex=0;continue}let I=await B(A,T,$,j);K=K.substring(0,j)+I+K.substring(F),z.lastIndex=0}return K}function _3($,Z){let Y=$;function X(J,Q,G,K){let W=J,U=!0;while(U){U=!1;let _=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),B=W.match(_);if(!B||B.index===void 0)break;let z=B.index,q=B[1],j=z+B[0].length,H=new RegExp(`@${Q}\\(`),O=new RegExp(`@${G}(?![a-z])`),F=1,L=j,V=-1;while(F>0&&L<W.length){let A=W.slice(L),w=A.match(H),M=A.match(O),E=w?L+w.index:1/0,T=M?L+M.index:1/0;if(E<T)F++,L=E+(w[0].length||1);else if(T<1/0){if(F--,F===0){V=T;break}L=T+G.length+1}else break}if(V===-1)break;let N=W.slice(j,V);if(!Z[q])Z[q]=[];if(K)Z[q].unshift(N);else Z[q].push(N);W=W.substring(0,z)+W.substring(V+`@${G}`.length),U=!0}return W}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function B3($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
1904
1904
  `)})}var __dirname="/home/runner/work/stx/stx/packages/stx/src",$w=0,k4,vX;var g6=D(()=>{p8();c0();V4();a0();O0();k4=new J5(500),vX=new Set});import*as gX from"path";async function yU($,Z,Y=""){if(gX.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 vU($,Z,Y,"@js","@endjs")}async function xU($,Z,Y=""){if(gX.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 vU($,Z,Y,"@ts","@endts")}async function vU($,Z,Y,X,J){let Q=$,G=I6(`${X}([\\s\\S]*?)${J}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:U,content:_,index:B}of K)try{let z=Object.keys(Z),q=Object.values(Z),j=_.trim();if(X==="@ts")j=j.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let O=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((A)=>A.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=O.length>0?`return { ${O.join(", ")} };`:"return {};",L=`
1905
1905
  ${j}
1906
1906
  ${F}
@@ -6133,12 +6133,12 @@ if(window.stx)window.stx._latestSetup=${Q};
6133
6133
  `)Q++;return!0}if(Z[Q]==="/"&&Z[Q+1]==="*"){Q+=2;while(Q<G-1&&!(Z[Q]==="*"&&Z[Q+1]==="/"))Q++;return Q+=2,!0}return!1},_=()=>{if(J!==0)return;let B=Z.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(B){let O=B[2];if(!X.has(O))Y.push(O),X.add(O);return}let z=Z.slice(Q).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(z){z[1].split(",").forEach((O)=>{let F=O.trim();if(!F)return;let L=F.indexOf(":"),N=(L>=0?F.slice(L+1).trim():F).split(/[\s=]/)[0];if(N&&!X.has(N))Y.push(N),X.add(N)});return}let q=Z.slice(Q).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(q){q[1].split(",").forEach((O)=>{let F=O.trim().replace(/^\.\.\./,"");if(!F)return;let L=F.split(/[\s=]/)[0];if(L&&!X.has(L))Y.push(L),X.add(L)});return}let j=Z.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(j){let O=j[1];if(!X.has(O))Y.push(O),X.add(O);return}let H=Z.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(H){let O=H[1];if(!X.has(O))Y.push(O),X.add(O)}};while(Q<G){if(U())continue;if(Z[Q]==="'"||Z[Q]==='"'){K(Z[Q]);continue}if(Z[Q]==="`"){W();continue}if(Z[Q]==="{"){J++,Q++;continue}if(Z[Q]==="}"){J--,Q++;continue}if(J===0&&/[a-z]/i.test(Z[Q])&&(Q===0||/\s|[;{}()]/.test(Z[Q-1])))_();Q++}return Y.join(", ")}async function JJ($,Z,Y){if(!P3($))return $;let X=$;if(Z.skipSignalsRuntime)return X;let{output:J,setupCode:Q}=await __(X,Y);if(X=J,X=await Q_(X,Z),X=J_(X),Q)if(X.includes("</head>"))X=X.replace("</head>",`${Q}
6134
6134
  </head>`);else if(X.includes("<body"))X=X.replace(/<body([^>]*)>/,`<body$1>
6135
6135
  ${Q}`);else X=X+`
6136
- `+Q;let G=X.match(/<body([^>]*)>/i),K=G&&/data-stx/.test(G[1]);if(!Q&&!K){if(X.includes("<body")&&G&&!/data-stx-auto/.test(G[1]))X=X.replace(/<body([^>]*)>/,"<body$1 data-stx-auto>")}return X}var xw=0,C3,K_;var QJ=D(()=>{O0();C3=/<script\b([^>]*)>/gi,K_=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s});import F1 from"path";import GJ from"fs";function q_($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function j_($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class H_{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,X){let J=$.endsWith(".stx")?$.slice(0,-4):$,Q=X?.__importedComponents;if(Q){let q=[J,J.toLowerCase(),q_(J),j_(J)];for(let j of q)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${q_(J)}.stx`,`${j_(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let q=F1.resolve(F1.dirname(Z),`${J}.stx`);if(await Y0(q))return q;return null}let K=[],W=Y.componentsDir||"",U=X?.__originalFilePath;if(U)K.push(F1.join(F1.dirname(U),"components"));if(W)K.push(W);let _=F1.join(F1.dirname(Z),"components");if(!K.includes(_))K.push(_);let B=process.cwd(),z=[F1.resolve(B,"src/components"),F1.resolve(B,"components"),F1.resolve(import.meta.dir,"components")];for(let q of z)if(!K.includes(q))K.push(q);for(let q of K){if(!q)continue;for(let j of G){let H=F1.join(q,j);if(await Y0(H))return H}try{if(!GJ.statSync(q,{throwIfNoEntry:!1})?.isDirectory())continue;let H=GJ.readdirSync(q,{withFileTypes:!0});for(let O of H)if(O.isDirectory()){let F=F1.join(q,O.name);for(let L of G){let V=F1.join(F,L);if(await Y0(V))return V}}}catch{}}return null}}var g1;var KJ=D(()=>{O0();g1=new H_});function f1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function fw($){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 WJ;var UJ=D(()=>{WJ={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=fw($),J=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),Q=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,W=[];if(X.reactive)W.push(`:href="${f1(X.value)}"`);else W.push(`href="${f1(X.value)}"`);if(J)W.push(`class="${f1(J)}"`);if(W.push("data-stx-link"),W.push(`data-stx-active-class="${f1(Q)}"`),W.push(`data-stx-exact-active-class="${f1(G)}"`),K)W.push("data-stx-prefetch");for(let[_,B]of Object.entries($.events))W.push(`@${f1(_)}="${f1(B)}"`);let U=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[_,B]of Object.entries($.static)){if(U.has(_))continue;if(typeof B==="boolean"){if(B)W.push(f1(_))}else W.push(`${f1(_)}="${f1(B)}"`)}return`<a ${W.join(" ")}>${Z}</a>`}}});function v0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Z1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function BJ($,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 O_($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[J,Q]=X.split(":"),G=hw[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 zJ($,Z,Y,X){return Z.map((J)=>`${T5($,J,void 0,Y,X)} ${J}w`).join(", ")}function dw($,Z,Y,X,J){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${T5($,G,void 0,X,J)} ${Q}x`}).join(", ")}function T5($,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 uw($,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 hw,_J,qJ;var jJ=D(()=>{hw={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},_J=[320,640,768,1024,1280,1536,1920];qJ={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=Z1($,"src")||"",J=Z1($,"alt")||"",Q=Z1($,"width"),G=Z1($,"height"),K=Z1($,"sizes"),W=Z1($,"srcset"),U=Z1($,"densities"),_=Z1($,"format"),B=Z1($,"placeholder"),z=Z1($,"placeholderColor")||"#e5e7eb",q=Z1($,"provider"),j=Z1($,"class")||Z1($,"className")||"",H=Z1($,"style")||"",O=Z1($,"quality"),F=BJ($,"lazy",!0),L=BJ($,"preload",!1),V=BJ($,"picture",!1)||!!_,N=Q?Number.parseInt(Q):void 0,A=G?Number.parseInt(G):void 0,w=W||"",M="";if(!w&&K)w=zJ(X,_J,q,_),M=O_(K);else if(!w&&U){let y=U.split(/\s+/).map((v)=>Number.parseFloat(v.replace("x","")));w=dw(X,y,N,q,_)}else if(K)M=O_(K);let E=[];if(H)E.push(H);if(N&&A)E.push(`aspect-ratio:${N}/${A}`);if(B==="blur"||B==="color"){let y=uw(N||16,A||9,z);E.push(`background-image:url(${y})`),E.push("background-size:cover"),E.push("background-repeat:no-repeat")}else if(B&&B!=="empty"&&B!=="none")E.push(`background-image:url(${v0(B)})`),E.push("background-size:cover"),E.push("background-repeat:no-repeat");let I=T5(X,N,A,q,_),T=[];if(T.push(`src="${v0(I)}"`),T.push(`alt="${v0(J)}"`),Q)T.push(`width="${v0(Q)}"`);if(G)T.push(`height="${v0(G)}"`);if(F)T.push('loading="lazy"');if(T.push('decoding="async"'),j)T.push(`class="${v0(j)}"`);if(E.length>0)T.push(`style="${v0(E.join(";"))}"`);if(w)T.push(`srcset="${v0(w)}"`);if(M)T.push(`sizes="${v0(M)}"`);let S=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[y,v]of Object.entries($.static)){if(S.has(y))continue;if(typeof v==="boolean"){if(v)T.push(v0(y))}else T.push(`${v0(y)}="${v0(v)}"`)}let k=`<img ${T.join(" ")} />`,b="";if(L){let v=_==="webp"?"image/webp":_==="avif"?"image/avif":"";b=`<link rel="preload" as="image" href="${v0(I)}"${v?` type="${v}"`:""}${w?` imagesrcset="${v0(w)}"`:""}${M?` imagesizes="${v0(M)}"`:""} />
6137
- `}if(V){let y=[];if(_==="avif"||_==="auto"){let v=T5(X,N,A,q,"avif"),C=w?zJ(X,_J,q,"avif"):`${v}`;y.push(`<source type="image/avif" srcset="${v0(C)}"${M?` sizes="${v0(M)}"`:""} />`)}if(_==="webp"||_==="auto"){let v=T5(X,N,A,q,"webp"),C=w?zJ(X,_J,q,"webp"):`${v}`;y.push(`<source type="image/webp" srcset="${v0(C)}"${M?` sizes="${v0(M)}"`:""} />`)}return`${b}<picture>
6138
- ${y.join(`
6136
+ `+Q;let G=X.match(/<body([^>]*)>/i),K=G&&/data-stx/.test(G[1]);if(!Q&&!K){if(X.includes("<body")&&G&&!/data-stx-auto/.test(G[1]))X=X.replace(/<body([^>]*)>/,"<body$1 data-stx-auto>")}return X}var xw=0,C3,K_;var QJ=D(()=>{O0();C3=/<script\b([^>]*)>/gi,K_=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s});import F1 from"path";import GJ from"fs";function q_($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function j_($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class H_{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,X){let J=$.endsWith(".stx")?$.slice(0,-4):$,Q=X?.__importedComponents;if(Q){let q=[J,J.toLowerCase(),q_(J),j_(J)];for(let j of q)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${q_(J)}.stx`,`${j_(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let q=F1.resolve(F1.dirname(Z),`${J}.stx`);if(await Y0(q))return q;return null}let K=[],W=Y.componentsDir||"",U=X?.__originalFilePath;if(U)K.push(F1.join(F1.dirname(U),"components"));if(W)K.push(W);let _=F1.join(F1.dirname(Z),"components");if(!K.includes(_))K.push(_);let B=process.cwd(),z=[F1.resolve(B,"src/components"),F1.resolve(B,"components"),F1.resolve(import.meta.dir,"components")];for(let q of z)if(!K.includes(q))K.push(q);for(let q of K){if(!q)continue;for(let j of G){let H=F1.join(q,j);if(await Y0(H))return H}try{if(!GJ.statSync(q,{throwIfNoEntry:!1})?.isDirectory())continue;let H=GJ.readdirSync(q,{withFileTypes:!0});for(let O of H)if(O.isDirectory()){let F=F1.join(q,O.name);for(let L of G){let V=F1.join(F,L);if(await Y0(V))return V}}}catch{}}return null}}var g1;var KJ=D(()=>{O0();g1=new H_});function f1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function fw($){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 WJ;var UJ=D(()=>{WJ={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=fw($),J=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),Q=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,W=[];if(X.reactive)W.push(`:href="${f1(X.value)}"`);else W.push(`href="${f1(X.value)}"`);if(J)W.push(`class="${f1(J)}"`);if(W.push("data-stx-link"),W.push(`data-stx-active-class="${f1(Q)}"`),W.push(`data-stx-exact-active-class="${f1(G)}"`),K)W.push("data-stx-prefetch");for(let[_,B]of Object.entries($.events))W.push(`@${f1(_)}="${f1(B)}"`);let U=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[_,B]of Object.entries($.static)){if(U.has(_))continue;if(typeof B==="boolean"){if(B)W.push(f1(_))}else W.push(`${f1(_)}="${f1(B)}"`)}return`<a ${W.join(" ")}>${Z}</a>`}}});function v0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Z1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function BJ($,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 O_($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[J,Q]=X.split(":"),G=hw[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 zJ($,Z,Y,X){return Z.map((J)=>`${T5($,J,void 0,Y,X)} ${J}w`).join(", ")}function dw($,Z,Y,X,J){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${T5($,G,void 0,X,J)} ${Q}x`}).join(", ")}function T5($,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 uw($,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 hw,_J,qJ;var jJ=D(()=>{hw={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},_J=[320,640,768,1024,1280,1536,1920];qJ={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=Z1($,"src")||"",J=Z1($,"alt")||"",Q=Z1($,"width"),G=Z1($,"height"),K=Z1($,"sizes"),W=Z1($,"srcset"),U=Z1($,"densities"),_=Z1($,"format"),B=Z1($,"placeholder"),z=Z1($,"placeholderColor")||"#e5e7eb",q=Z1($,"provider"),j=Z1($,"class")||Z1($,"className")||"",H=Z1($,"style")||"",O=Z1($,"quality"),F=BJ($,"lazy",!0),L=BJ($,"preload",!1),V=BJ($,"picture",!1)||!!_,N=Q?Number.parseInt(Q):void 0,A=G?Number.parseInt(G):void 0,w=W||"",M="";if(!w&&K)w=zJ(X,_J,q,_),M=O_(K);else if(!w&&U){let f=U.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));w=dw(X,f,N,q,_)}else if(K)M=O_(K);let E=[];if(H)E.push(H);if(N&&A)E.push(`aspect-ratio:${N}/${A}`);if(B==="blur"||B==="color"){let f=uw(N||16,A||9,z);E.push(`background-image:url(${f})`),E.push("background-size:cover"),E.push("background-repeat:no-repeat")}else if(B&&B!=="empty"&&B!=="none")E.push(`background-image:url(${v0(B)})`),E.push("background-size:cover"),E.push("background-repeat:no-repeat");let T=T5(X,N,A,q,_),I=[];if(I.push(`src="${v0(T)}"`),I.push(`alt="${v0(J)}"`),Q)I.push(`width="${v0(Q)}"`);if(G)I.push(`height="${v0(G)}"`);if(F)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${v0(j)}"`);if(E.length>0)I.push(`style="${v0(E.join(";"))}"`);if(w)I.push(`srcset="${v0(w)}"`);if(M)I.push(`sizes="${v0(M)}"`);let S=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[f,b]of Object.entries($.static)){if(S.has(f))continue;if(typeof b==="boolean"){if(b)I.push(v0(f))}else I.push(`${v0(f)}="${v0(b)}"`)}let k=`<img ${I.join(" ")} />`,x="";if(L){let b=_==="webp"?"image/webp":_==="avif"?"image/avif":"";x=`<link rel="preload" as="image" href="${v0(T)}"${b?` type="${b}"`:""}${w?` imagesrcset="${v0(w)}"`:""}${M?` imagesizes="${v0(M)}"`:""} />
6137
+ `}if(V){let f=[];if(_==="avif"||_==="auto"){let b=T5(X,N,A,q,"avif"),C=w?zJ(X,_J,q,"avif"):`${b}`;f.push(`<source type="image/avif" srcset="${v0(C)}"${M?` sizes="${v0(M)}"`:""} />`)}if(_==="webp"||_==="auto"){let b=T5(X,N,A,q,"webp"),C=w?zJ(X,_J,q,"webp"):`${b}`;f.push(`<source type="image/webp" srcset="${v0(C)}"${M?` sizes="${v0(M)}"`:""} />`)}return`${x}<picture>
6138
+ ${f.join(`
6139
6139
  `)}
6140
6140
  ${k}
6141
- </picture>`}return`${b}${k}`}}});function HJ($){return $.replace(/[;{}()]/g,"").replace(/url/gi,"")}function I5($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function y3($,Z,Y){let X=I5($,Z);if(X!==void 0){let J=Number.parseInt(X,10);if(!Number.isNaN(J))return J}return Y}var OJ;var LJ=D(()=>{OJ={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render($,Z,Y){let X=HJ(I5($,"color")||"#6366f1"),J=HJ(I5($,"initialColor")||I5($,"initial-color")||""),Q=HJ(I5($,"height")||"3px"),G=y3($,"duration",2000),K=y3($,"throttle",200),W=y3($,"zIndex",999999)||y3($,"z-index",999999),U=J?`linear-gradient(to right, ${J}, ${X})`:X;return`
6141
+ </picture>`}return`${x}${k}`}}});function HJ($){return $.replace(/[;{}()]/g,"").replace(/url/gi,"")}function I5($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function y3($,Z,Y){let X=I5($,Z);if(X!==void 0){let J=Number.parseInt(X,10);if(!Number.isNaN(J))return J}return Y}var OJ;var LJ=D(()=>{OJ={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render($,Z,Y){let X=HJ(I5($,"color")||"#6366f1"),J=HJ(I5($,"initialColor")||I5($,"initial-color")||""),Q=HJ(I5($,"height")||"3px"),G=y3($,"duration",2000),K=y3($,"throttle",200),W=y3($,"zIndex",999999)||y3($,"z-index",999999),U=J?`linear-gradient(to right, ${J}, ${X})`:X;return`
6142
6142
  <div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${Q};background:${U};z-index:${W};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
6143
6143
  <div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
6144
6144
  </div>
@@ -6172,13 +6172,13 @@ ${k}
6172
6172
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
6173
6173
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
6174
6174
  </style>`}}});var R_={};e(R_,{preloadIconCollection:()=>w_,IconBuiltin:()=>v3});async function N_($){if(D5.has($))return D5.get($);try{let Z=a.resolve(`@iconify/json/json/${$}.json`),Y=await Bun.file(Z).json();return D5.set($,Y.icons),Y.icons}catch{try{let Y=`${process.cwd()}/node_modules/@iconify/json/json/${$}.json`,X=Bun.file(Y);if(await X.exists()){let J=await X.json();return D5.set($,J.icons),J.icons}}catch{}}return null}function m6($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);if($.static[Z]!==void 0)return String($.static[Z]);if($.clientReactive[Z]!==void 0)return $.clientReactive[Z];return}async function w_($="lucide"){await N_($)}var D5,v3;var g3=D(()=>{D5=new Map;v3={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=m6($,"name")??m6($,"icon");if(!X)return"<!-- Icon: missing name/icon prop -->";let J="lucide",Q=X;if(X.includes(":")){let L=X.split(":");J=L[0],Q=L[1]}let G=m6($,"size")||"24",K=m6($,"color")||"currentColor",W=m6($,"class")||"",U=m6($,"style")||"",_=D5.get(J);if(!_)return N_(J),`<!-- Icon: collection "${J}" not loaded -->`;let B=_[Q];if(!B)return`<!-- Icon: "${Q}" not found in ${J} -->`;let z=B.width||24,q=B.height||24,j=`0 0 ${z} ${q}`,H=B.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let O=W?` class="${W}"`:"",F=U?` style="${U}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${O}${F}>${H}</svg>`}}});function M_(){g1.registerBuiltin(WJ),g1.registerBuiltin(qJ),g1.registerBuiltin(OJ),g1.registerBuiltin(FJ),g1.registerBuiltin(AJ),g1.registerBuiltin(wJ),g1.registerBuiltin(v3)}var E_=D(()=>{UJ();jJ();LJ();VJ();NJ();RJ();g3();KJ();UJ();jJ();LJ();VJ();NJ();RJ();g3()});function T_($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function I_($,Z,Y){let X=[],J=0;while(J<$.length){let Q=$.indexOf("<",J);if(Q===-1)break;let K=$.slice(Q+1).match(new RegExp(`^(${Z.source})`));if(!K){J=Q+1;continue}let W=K[1];if(Y&&Y.has(W.toLowerCase())){let H=Q+1+W.length;while(H<$.length&&$[H]!==">")H++;J=H+1;continue}let U=Q+1+W.length,_=null,B=U,z=-1,q=!1;while(U<$.length){let H=$[U];if(_){if(H==="\\"&&U+1<$.length){U+=2;continue}if(H===_)_=null;U++;continue}if(H==='"'||H==="'"){_=H,U++;continue}if(H==="/"&&U+1<$.length&&$[U+1]===">"){z=U+2,q=!0;break}if(H===">"){z=U+1;break}U++}if(z===-1){J=Q+1;continue}let j=$.slice(B,q?z-2:z-1).trim();if(q)X.push({fullMatch:$.slice(Q,z),tagName:W,attributes:j,content:"",startIndex:Q,endIndex:z,isSelfClosing:!0}),J=z;else{let H=`<${W}`,O=`</${W}>`,F=1,L=z,V=-1;while(F>0&&L<$.length){let w=$.indexOf(H,L),M=$.indexOf(O,L);if(M===-1)break;if(w!==-1&&w<M){let E=$[w+H.length];if(E===" "||E===">"||E==="/"||E===`
6175
- `||E==="\t")F++;L=w+H.length}else{if(F--,F===0){V=M;break}L=M+O.length}}if(V===-1){J=z;continue}let N=$.slice(z,V),A=V+O.length;X.push({fullMatch:$.slice(Q,A),tagName:W,attributes:j,content:N,startIndex:Q,endIndex:A,isSelfClosing:!1}),J=A}}return X}var D_=D(()=>{a0();O0()});import c6 from"path";function pw($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,W)=>W.toUpperCase())};for(let[G,K]of Object.entries($)){let W=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(W.startsWith("@")){X.events[W]=K;continue}if(W.startsWith("__stx_")){let U=Q(W.slice(6));try{let _=K.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");X.serverDynamic[U]=JSON.parse(_)}catch(_){if(Y.debug)console.error(`Error parsing __stx_${U}:`,_);X.serverDynamic[U]=K}continue}if(W.startsWith(":")){let U=Q(W.slice(1)),_=K==="true"?U:K;try{if(!L0(_)){if(Y.debug)console.error(`Unsafe expression in :${U} binding: ${_}`);X.clientReactive[U]=_;continue}let B=Object.keys(Z),q=V0(_,B)(...Object.values(Z));if(q===void 0){let j=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!B.includes(F))){X.clientReactive[U]=_;continue}}X.serverDynamic[U]=q}catch{X.clientReactive[U]=_}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let U=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(U)try{let _=U[1];if(L0(_)){let z=V0(_,Object.keys(Z))(...Object.values(Z));X.static[W]=z!=null?String(z):""}else{if(Y.debug)console.error(`Unsafe expression in ${W}: ${_}`);X.static[W]=K}}catch(_){if(Y.debug)console.error(`Error evaluating expression for ${W}:`,_);X.static[W]=K}else{let _=K,B=/\{\{\s*([\s\S]+?)\s*\}\}/g,z;while((z=B.exec(K))!==null)try{let q=z[1];if(!L0(q)){if(Y.debug)console.error(`Unsafe expression in ${W}: ${q}`);continue}let H=V0(q,Object.keys(Z))(...Object.values(Z));_=_.replace(z[0],String(H??""))}catch(q){if(Y.debug)console.error(`Error evaluating expression in ${W}:`,q)}X.static[W]=_}continue}X.static[W]=K}return X}function lw($){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}async function iw($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,_]=W,B=_.split(",").map((z)=>z.trim().replace(/^['"]|['"]$/g,"")).filter((z)=>z.length>0);for(let z of B){let q=z.split("/"),H=q[q.length-1].replace(/\.stx$/,""),O=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,L=[c6.resolve(c6.dirname(Y),`${z}.stx`),c6.resolve(c6.dirname(Y),z),c6.resolve(X.componentsDir||"components",`${z}.stx`),c6.resolve(X.componentsDir||"components",z),z.endsWith(".stx")?z:`${z}.stx`];for(let V of L)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(O,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),J.add(F),X.debug)console.log(`Imported component: ${O} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${z}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function nw($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let _=U.index,B=_+U[0].length-1,z=1,q=B+1;while(q<Q.length&&z>0){if(Q[q]==="(")z++;else if(Q[q]===")"){if(z--,z===0)break}q++}if(z!==0)break;let j=Q.substring(B+1,q),H=q+1,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let F=O[1],L,V=j.slice(O[0].length),N=V.match(/^\s*,\s*/);if(N)L=V.slice(N[0].length).trim();let A={};if(L)try{A=y0(L,Z)}catch(S){let k=S instanceof Error?S.message:String(S);Q=Q.replace(Q.substring(_,H),`[Error parsing component props: ${k}]`);continue}let w="",M=H,I=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(I)w=I[1].trim(),M=H+I[0].length;let T=await v1(F,A,w,G,Z,Y,X,K,J);Q=Q.substring(0,_)+T+Q.substring(M),W.lastIndex=0}return Q}async function rw($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents;return Q=await B(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await B(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await B(Q,/[a-z][a-z0-9]*/,!1,cw),Q;async function B(z,q,j,H){if(!z)return z;let O=z,F=I_(O,q,H);for(let L=F.length-1;L>=0;L--){let V=F[L],N=j?T_(V.tagName):V.tagName,A=lw(V.attributes),w=pw(A,Z,X),M=g1.getBuiltin(V.tagName);if(M){let S={context:Z,filePath:Y,options:X,dependencies:J},k=M.render(w,V.content,S);if(Object.keys(w.clientReactive).length>0)k=S_(k,w.clientReactive);if(Object.keys(w.events).length>0){let b=Object.entries(w.events).map(([y,v])=>`${y}="${v.replace(/"/g,"&quot;")}"`).join(" ");k=k.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}O=O.substring(0,V.startIndex)+k+O.substring(V.endIndex);continue}let E={};for(let[S,k]of Object.entries(w.static))E[S]=k;for(let[S,k]of Object.entries(w.serverDynamic))E[S]=k;let T=await v1(N,E,V.content,G,Z,Y,X,K,J);if(Object.keys(w.clientReactive).length>0)T=S_(T,w.clientReactive);if(Object.keys(w.events).length>0){let S=T.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(S){let k=Object.entries(w.events).map(([y,v])=>`${y}="${v}"`).join(" "),b=S[1].length+S[2].length;T=T.substring(0,b)+" "+k+T.substring(b)}}O=O.substring(0,V.startIndex)+T+O.substring(V.endIndex)}return O}}function S_($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let X=Object.entries(Z).map(([Q,G])=>`:${Q}="${G.replace(/"/g,"&quot;")}"`).join(" "),J=Y[1].length+Y[2].length;return $.substring(0,J)+" "+X+$.substring(J)}async function MJ($,Z,Y,X,J){if(!k_)M_(),k_=!0;let Q=await iw($,Z,Y,X,J);Q=await nw(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await rw(Q,Z,Y,X,J),Q===K)break}return Q}var k_=!1,cw;var b_=D(()=>{KJ();E_();D_();O0();a0();cw=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"])});import p6 from"path";function C_($){return $.startsWith("http://")||$.startsWith("https://")||$.startsWith("//")}function P_($,Z,Y){try{let X;if($.startsWith("/")){let J=Z;for(let Q=0;Q<5;Q++){let G=p6.join(J,$);if(a("fs").existsSync(G))return G;J=p6.dirname(J)}X=p6.join(Z,$)}else if($.startsWith("./")||$.startsWith("../"))X=p6.resolve(Z,$);else X=p6.resolve(Z,$);if(a("fs").existsSync(X))return X;return null}catch{return null}}async function y_($,Z,Y){let X=$,J=p6.dirname(Z),Q=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,G;while((G=Q.exec(X))!==null){let[U,_,B,z]=G;if(C_(B))continue;let q=P_(B,J,Z);if(q)try{let j=await Bun.file(q).text();if(Y.add(q),B.endsWith(".ts")||B.endsWith(".tsx")){let O=await Bun.build({entrypoints:[q],target:"browser",minify:!1,define:O1()});if(O.outputs.length>0)j=await O.outputs[0].text()}let H=`<script>
6175
+ `||E==="\t")F++;L=w+H.length}else{if(F--,F===0){V=M;break}L=M+O.length}}if(V===-1){J=z;continue}let N=$.slice(z,V),A=V+O.length;X.push({fullMatch:$.slice(Q,A),tagName:W,attributes:j,content:N,startIndex:Q,endIndex:A,isSelfClosing:!1}),J=A}}return X}var D_=D(()=>{a0();O0()});import c6 from"path";function pw($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,W)=>W.toUpperCase())};for(let[G,K]of Object.entries($)){let W=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(W.startsWith("@")){X.events[W]=K;continue}if(W.startsWith("__stx_")){let U=Q(W.slice(6));try{let _=K.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");X.serverDynamic[U]=JSON.parse(_)}catch(_){if(Y.debug)console.error(`Error parsing __stx_${U}:`,_);X.serverDynamic[U]=K}continue}if(W.startsWith(":")){let U=Q(W.slice(1)),_=K==="true"?U:K;try{if(!L0(_)){if(Y.debug)console.error(`Unsafe expression in :${U} binding: ${_}`);X.clientReactive[U]=_;continue}let B=Object.keys(Z),q=V0(_,B)(...Object.values(Z));if(q===void 0){let j=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!B.includes(F))){X.clientReactive[U]=_;continue}}X.serverDynamic[U]=q}catch{X.clientReactive[U]=_}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let U=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(U)try{let _=U[1];if(L0(_)){let z=V0(_,Object.keys(Z))(...Object.values(Z));X.static[W]=z!=null?String(z):""}else{if(Y.debug)console.error(`Unsafe expression in ${W}: ${_}`);X.static[W]=K}}catch(_){if(Y.debug)console.error(`Error evaluating expression for ${W}:`,_);X.static[W]=K}else{let _=K,B=/\{\{\s*([\s\S]+?)\s*\}\}/g,z;while((z=B.exec(K))!==null)try{let q=z[1];if(!L0(q)){if(Y.debug)console.error(`Unsafe expression in ${W}: ${q}`);continue}let H=V0(q,Object.keys(Z))(...Object.values(Z));_=_.replace(z[0],String(H??""))}catch(q){if(Y.debug)console.error(`Error evaluating expression in ${W}:`,q)}X.static[W]=_}continue}X.static[W]=K}return X}function lw($){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}async function iw($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,_]=W,B=_.split(",").map((z)=>z.trim().replace(/^['"]|['"]$/g,"")).filter((z)=>z.length>0);for(let z of B){let q=z.split("/"),H=q[q.length-1].replace(/\.stx$/,""),O=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,L=[c6.resolve(c6.dirname(Y),`${z}.stx`),c6.resolve(c6.dirname(Y),z),c6.resolve(X.componentsDir||"components",`${z}.stx`),c6.resolve(X.componentsDir||"components",z),z.endsWith(".stx")?z:`${z}.stx`];for(let V of L)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(O,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),J.add(F),X.debug)console.log(`Imported component: ${O} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${z}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function nw($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let _=U.index,B=_+U[0].length-1,z=1,q=B+1;while(q<Q.length&&z>0){if(Q[q]==="(")z++;else if(Q[q]===")"){if(z--,z===0)break}q++}if(z!==0)break;let j=Q.substring(B+1,q),H=q+1,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let F=O[1],L,V=j.slice(O[0].length),N=V.match(/^\s*,\s*/);if(N)L=V.slice(N[0].length).trim();let A={};if(L)try{A=y0(L,Z)}catch(S){let k=S instanceof Error?S.message:String(S);Q=Q.replace(Q.substring(_,H),`[Error parsing component props: ${k}]`);continue}let w="",M=H,T=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(T)w=T[1].trim(),M=H+T[0].length;let I=await v1(F,A,w,G,Z,Y,X,K,J);Q=Q.substring(0,_)+I+Q.substring(M),W.lastIndex=0}return Q}async function rw($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents;return Q=await B(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await B(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await B(Q,/[a-z][a-z0-9]*/,!1,cw),Q;async function B(z,q,j,H){if(!z)return z;let O=z,F=I_(O,q,H);for(let L=F.length-1;L>=0;L--){let V=F[L],N=j?T_(V.tagName):V.tagName,A=lw(V.attributes),w=pw(A,Z,X),M=g1.getBuiltin(V.tagName);if(M){let S={context:Z,filePath:Y,options:X,dependencies:J},k=M.render(w,V.content,S);if(Object.keys(w.clientReactive).length>0)k=S_(k,w.clientReactive);if(Object.keys(w.events).length>0){let x=Object.entries(w.events).map(([f,b])=>`${f}="${b.replace(/"/g,"&quot;")}"`).join(" ");k=k.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${x}`)}O=O.substring(0,V.startIndex)+k+O.substring(V.endIndex);continue}let E={};for(let[S,k]of Object.entries(w.static))E[S]=k;for(let[S,k]of Object.entries(w.serverDynamic))E[S]=k;let I=await v1(N,E,V.content,G,Z,Y,X,K,J);if(Object.keys(w.clientReactive).length>0)I=S_(I,w.clientReactive);if(Object.keys(w.events).length>0){let S=I.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(S){let k=Object.entries(w.events).map(([f,b])=>`${f}="${b}"`).join(" "),x=S[1].length+S[2].length;I=I.substring(0,x)+" "+k+I.substring(x)}}O=O.substring(0,V.startIndex)+I+O.substring(V.endIndex)}return O}}function S_($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let X=Object.entries(Z).map(([Q,G])=>`:${Q}="${G.replace(/"/g,"&quot;")}"`).join(" "),J=Y[1].length+Y[2].length;return $.substring(0,J)+" "+X+$.substring(J)}async function MJ($,Z,Y,X,J){if(!k_)M_(),k_=!0;let Q=await iw($,Z,Y,X,J);Q=await nw(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await rw(Q,Z,Y,X,J),Q===K)break}return Q}var k_=!1,cw;var b_=D(()=>{KJ();E_();D_();O0();a0();cw=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"])});import p6 from"path";function C_($){return $.startsWith("http://")||$.startsWith("https://")||$.startsWith("//")}function P_($,Z,Y){try{let X;if($.startsWith("/")){let J=Z;for(let Q=0;Q<5;Q++){let G=p6.join(J,$);if(a("fs").existsSync(G))return G;J=p6.dirname(J)}X=p6.join(Z,$)}else if($.startsWith("./")||$.startsWith("../"))X=p6.resolve(Z,$);else X=p6.resolve(Z,$);if(a("fs").existsSync(X))return X;return null}catch{return null}}async function y_($,Z,Y){let X=$,J=p6.dirname(Z),Q=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,G;while((G=Q.exec(X))!==null){let[U,_,B,z]=G;if(C_(B))continue;let q=P_(B,J,Z);if(q)try{let j=await Bun.file(q).text();if(Y.add(q),B.endsWith(".ts")||B.endsWith(".tsx")){let O=await Bun.build({entrypoints:[q],target:"browser",minify:!1,define:O1()});if(O.outputs.length>0)j=await O.outputs[0].text()}let H=`<script>
6176
6176
  // Source: ${B}
6177
6177
  ${j}
6178
6178
  </script>`;X=X.replace(U,H),Q.lastIndex=0}catch(j){}}let K=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,W;while((W=K.exec(X))!==null){let[U,_,B,z]=W,q=_+z;if(C_(B))continue;if(/rel=["']stylesheet["']/.test(q)||B.endsWith(".css")){let H=P_(B,J,Z);if(H)try{let O=await Bun.file(H).text();Y.add(H);let F=`<style>
6179
6179
  /* Source: ${B} */
6180
6180
  ${O}
6181
- </style>`;X=X.replace(U,F),K.lastIndex=0}catch(O){}}}return X}var x_=D(()=>{t4()});function k5($,Z){let Y=$,X=/@json\s*\(/g,J;while((J=X.exec(Y))!==null){let Q=J.index,G=Q+J[0].length-1,K=1,W=G+1,U=null,_=!1;while(W<Y.length&&K>0){let V=Y[W];if(_){_=!1,W++;continue}if(V==="\\"&&U){_=!0,W++;continue}if(U){if(V===U)U=null;W++;continue}if(V==='"'||V==="'"||V==="`"){U=V,W++;continue}if(V==="(")K++;else if(V===")"){if(K--,K===0)break}W++}if(K!==0)break;let B=Y.substring(G+1,W).trim(),z=Y.substring(Q,W+1),q=-1,j=0,H=null,O=!1;for(let V=0;V<B.length;V++){let N=B[V];if(O){O=!1;continue}if(N==="\\"&&H){O=!0;continue}if(H){if(N===H)H=null;continue}if(N==='"'||N==="'"||N==="`"){H=N;continue}if(N==="("||N==="["||N==="{")j++;else if(N===")"||N==="]"||N==="}")j--;if(N===","&&j===0){q=V;break}}let F=q>=0?B.substring(0,q).trim():B,L=q>=0?B.substring(q+1).trim():void 0;try{let V=F.trim(),N;if(L0(V))N=V0(V,Object.keys(Z))(...Object.values(Z));else N=void 0;let A;if(L==="true")A=JSON.stringify(N,null,2);else A=JSON.stringify(N);let w=A.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");Y=Y.substring(0,Q)+w+Y.substring(W+1),X.lastIndex=Q+w.length}catch(V){t0.log(V instanceof Error?V:Error(String(V)),{directive:"@json"},"error"),X.lastIndex=Q+z.length}}return Y}function S5($){return $.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function v_($){let Z=$,Y=/@memo\s*\(/g,X,J=[];while((X=Y.exec(Z))!==null){let Q=X.index,G=Q+X[0].length,K=1,W=G;while(W<Z.length&&K>0){if(Z[W]==="(")K++;else if(Z[W]===")")K--;W++}if(K!==0)continue;let U=Z.slice(G,W-1).trim(),_=W,B=Z.slice(_),z=B.indexOf("@endmemo");if(z===-1)continue;let q=B.slice(0,z),j=_+z+8,H=q.match(/^(\s*(?:<!--[\s\S]*?-->\s*)*)/),O=H?H[0].length:0,F=q.slice(O),L=q.match(/(\s*)$/),V=L?L[0].length:0,N=F.slice(0,F.length-V),A=N.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),w;if(A){let[M,E,I="",T]=A,S=`<${E}${I} data-stx-memo="${U}"${T}>`;w=q.slice(0,O)+S+N.slice(M.length)+q.slice(O+N.length)}else w=`${q.slice(0,O)}<div data-stx-memo="${U}">${N}</div>${q.slice(O+N.length)}`;J.push({start:Q,end:j,replacement:w}),Y.lastIndex=j}for(let Q=J.length-1;Q>=0;Q--){let G=J[Q];Z=Z.slice(0,G.start)+G.replacement+Z.slice(G.end)}return Z.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function EJ($){let Z=$.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return Z=Z.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),Z}function g_($){let Y=new RegExp("<(div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i)\\b","gi"),X="",J=0,Q;while((Q=Y.exec($))!==null){let G=Q.index,K=G+Q[0].length,W=!1,U=!1,_=-1;while(K<$.length){let H=$[K];if(W){if(H==="'")W=!1}else if(U){if(H==='"')U=!1}else if(H==="'")W=!0;else if(H==='"')U=!0;else if(H===">"){_=K;break}K++}if(_===-1)continue;if($.slice(G,_+1).includes("x-cloak"))continue;let z=$.slice(_+1),q=z.indexOf("</"),j=q>=0?z.slice(0,q):z.slice(0,200);if(/\{\{[\s\S]*?\}\}/.test(j))X+=$.slice(J,_)+" x-cloak>",J=_+1}return X+=$.slice(J),X}var TJ=D(()=>{q1();a0()});function b5($,Z,Y){let X=typeof Y==="boolean"?{enabled:Y,failOnViolation:Y}:Y??{enabled:!1},J=X.allowPatterns??[],Q=[];for(let{pattern:G,message:K,suggestion:W}of sw){if(J.some((_)=>K.includes(_)||G.source.includes(_)))continue;G.lastIndex=0;let U=$.match(G);if(U&&U.length>0){let _=$.split(`
6181
+ </style>`;X=X.replace(U,F),K.lastIndex=0}catch(O){}}}return X}var x_=D(()=>{t4()});function k5($,Z){let Y=$,X=/@json\s*\(/g,J;while((J=X.exec(Y))!==null){let Q=J.index,G=Q+J[0].length-1,K=1,W=G+1,U=null,_=!1;while(W<Y.length&&K>0){let V=Y[W];if(_){_=!1,W++;continue}if(V==="\\"&&U){_=!0,W++;continue}if(U){if(V===U)U=null;W++;continue}if(V==='"'||V==="'"||V==="`"){U=V,W++;continue}if(V==="(")K++;else if(V===")"){if(K--,K===0)break}W++}if(K!==0)break;let B=Y.substring(G+1,W).trim(),z=Y.substring(Q,W+1),q=-1,j=0,H=null,O=!1;for(let V=0;V<B.length;V++){let N=B[V];if(O){O=!1;continue}if(N==="\\"&&H){O=!0;continue}if(H){if(N===H)H=null;continue}if(N==='"'||N==="'"||N==="`"){H=N;continue}if(N==="("||N==="["||N==="{")j++;else if(N===")"||N==="]"||N==="}")j--;if(N===","&&j===0){q=V;break}}let F=q>=0?B.substring(0,q).trim():B,L=q>=0?B.substring(q+1).trim():void 0;try{let V=F.trim(),N;if(L0(V))N=V0(V,Object.keys(Z))(...Object.values(Z));else N=void 0;let A;if(L==="true")A=JSON.stringify(N,null,2);else A=JSON.stringify(N);let w=A.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");Y=Y.substring(0,Q)+w+Y.substring(W+1),X.lastIndex=Q+w.length}catch(V){t0.log(V instanceof Error?V:Error(String(V)),{directive:"@json"},"error"),X.lastIndex=Q+z.length}}return Y}function S5($){return $.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function v_($){let Z=$,Y=/@memo\s*\(/g,X,J=[];while((X=Y.exec(Z))!==null){let Q=X.index,G=Q+X[0].length,K=1,W=G;while(W<Z.length&&K>0){if(Z[W]==="(")K++;else if(Z[W]===")")K--;W++}if(K!==0)continue;let U=Z.slice(G,W-1).trim(),_=W,B=Z.slice(_),z=B.indexOf("@endmemo");if(z===-1)continue;let q=B.slice(0,z),j=_+z+8,H=q.match(/^(\s*(?:<!--[\s\S]*?-->\s*)*)/),O=H?H[0].length:0,F=q.slice(O),L=q.match(/(\s*)$/),V=L?L[0].length:0,N=F.slice(0,F.length-V),A=N.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),w;if(A){let[M,E,T="",I]=A,S=`<${E}${T} data-stx-memo="${U}"${I}>`;w=q.slice(0,O)+S+N.slice(M.length)+q.slice(O+N.length)}else w=`${q.slice(0,O)}<div data-stx-memo="${U}">${N}</div>${q.slice(O+N.length)}`;J.push({start:Q,end:j,replacement:w}),Y.lastIndex=j}for(let Q=J.length-1;Q>=0;Q--){let G=J[Q];Z=Z.slice(0,G.start)+G.replacement+Z.slice(G.end)}return Z.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function EJ($){let Z=$.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return Z=Z.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),Z}function g_($){let Y=new RegExp("<(div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i)\\b","gi"),X="",J=0,Q;while((Q=Y.exec($))!==null){let G=Q.index,K=G+Q[0].length,W=!1,U=!1,_=-1;while(K<$.length){let H=$[K];if(W){if(H==="'")W=!1}else if(U){if(H==='"')U=!1}else if(H==="'")W=!0;else if(H==='"')U=!0;else if(H===">"){_=K;break}K++}if(_===-1)continue;if($.slice(G,_+1).includes("x-cloak"))continue;let z=$.slice(_+1),q=z.indexOf("</"),j=q>=0?z.slice(0,q):z.slice(0,200);if(/\{\{[\s\S]*?\}\}/.test(j))X+=$.slice(J,_)+" x-cloak>",J=_+1}return X+=$.slice(J),X}var TJ=D(()=>{q1();a0()});function b5($,Z,Y){let X=typeof Y==="boolean"?{enabled:Y,failOnViolation:Y}:Y??{enabled:!1},J=X.allowPatterns??[],Q=[];for(let{pattern:G,message:K,suggestion:W}of sw){if(J.some((_)=>K.includes(_)||G.source.includes(_)))continue;G.lastIndex=0;let U=$.match(G);if(U&&U.length>0){let _=$.split(`
6182
6182
  `),B=[];_.forEach((q,j)=>{if(G.lastIndex=0,G.test(q))B.push(j+1)});let z=B.length>0?` (line${B.length>1?"s":""}: ${B.join(", ")})`:"";Q.push(` \u2717 ${K}${z}
6183
6183
  \u2192 ${W}`)}}if(Q.length>0&&X.enabled){let K=`[STX] DOM API violation in ${Z.split("/").pop()||Z}:
6184
6184
  ${Q.join(`
@@ -7873,7 +7873,7 @@ else {
7873
7873
 
7874
7874
  console.log('[stx] Keep-alive runtime initialized');
7875
7875
  })();
7876
- `}function TB($){if(typeof document<"u")document.addEventListener("stx:activated",(Z)=>{$(Z.detail)})}function IB($){if(typeof document<"u")document.addEventListener("stx:deactivated",(Z)=>{$(Z.detail)})}var AR=0;var kB={};e(kB,{useVirtualList:()=>kJ,processVirtualListDirectives:()=>d3,processVirtualGridDirectives:()=>bJ,processInfiniteListDirectives:()=>SJ,generateVirtualListCSS:()=>DJ,default:()=>RR,createVirtualList:()=>h3});function h3($,Z){let{itemHeight:Y,containerHeight:X,overscan:J=3,keyProperty:Q="id",dynamicHeight:G=!1,estimatedItemHeight:K=Y,direction:W="vertical"}=Z,U=[...$],_=0,B=new Map;function z(){if(G)return q();let w=Math.max(0,Math.floor(_/Y)-J),M=Math.ceil(X/Y),E=Math.min(U.length-1,w+M+J*2);return{startIndex:w,endIndex:E}}function q(){let w=0,M=0,E=U.length-1;for(let I=0;I<U.length;I++){let T=B.get(I)||K;if(w+T>_){M=Math.max(0,I-J);break}w+=T}w=0;for(let I=0;I<U.length;I++){let T=B.get(I)||K;if(w+=T,w>_+X){E=Math.min(U.length-1,I+J);break}}return{startIndex:M,endIndex:E}}function j(){if(G){let w=0;for(let M=0;M<U.length;M++)w+=B.get(M)||K;return w}return U.length*Y}function H(w){if(G){let M=0;for(let E=0;E<w;E++)M+=B.get(E)||K;return M}return w*Y}function O(){let{startIndex:w,endIndex:M}=z();return{startIndex:w,endIndex:M,scrollTop:_,totalHeight:j(),visibleItems:U.slice(w,M+1),itemHeights:new Map(B)}}function F(w,M="auto"){let E=H(w);L(E,M)}function L(w,M="auto"){_=Math.max(0,Math.min(w,j()-X))}function V(){z()}function N(w){U=[...w],B.clear(),V()}function A(){U=[],B.clear()}return{scrollToIndex:F,scrollToOffset:L,getState:O,refresh:V,setItems:N,destroy:A}}function d3($,Z={},Y){let X=/@virtualList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualList/gi;return $.replace(X,(J,Q,G,K)=>{let W=Q.trim(),U=Z[W];if(!U||!Array.isArray(U))return`<!-- virtualList: items "${W}" not found or not an array -->`;let _={itemHeight:50,containerHeight:400,overscan:3};if(G)try{let L=G.trim(),V=Function(`return ${L}`)();_={..._,...V}}catch{}let B=`vlist-${Math.random().toString(36).substring(2,9)}`,z=Math.ceil(_.containerHeight/_.itemHeight),q=_.overscan||3,j=0,H=Math.min(U.length-1,z+q),O="";for(let L=j;L<=H&&L<U.length;L++){let V=U[L],N=K.replace(/\{\{\s*item\s*\}\}/g,typeof V==="object"?JSON.stringify(V):String(V)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(A,w)=>{if(typeof V==="object"&&V!==null)return String(V[w]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(L));O+=`
7876
+ `}function TB($){if(typeof document<"u")document.addEventListener("stx:activated",(Z)=>{$(Z.detail)})}function IB($){if(typeof document<"u")document.addEventListener("stx:deactivated",(Z)=>{$(Z.detail)})}var AR=0;var kB={};e(kB,{useVirtualList:()=>kJ,processVirtualListDirectives:()=>d3,processVirtualGridDirectives:()=>bJ,processInfiniteListDirectives:()=>SJ,generateVirtualListCSS:()=>DJ,default:()=>RR,createVirtualList:()=>h3});function h3($,Z){let{itemHeight:Y,containerHeight:X,overscan:J=3,keyProperty:Q="id",dynamicHeight:G=!1,estimatedItemHeight:K=Y,direction:W="vertical"}=Z,U=[...$],_=0,B=new Map;function z(){if(G)return q();let w=Math.max(0,Math.floor(_/Y)-J),M=Math.ceil(X/Y),E=Math.min(U.length-1,w+M+J*2);return{startIndex:w,endIndex:E}}function q(){let w=0,M=0,E=U.length-1;for(let T=0;T<U.length;T++){let I=B.get(T)||K;if(w+I>_){M=Math.max(0,T-J);break}w+=I}w=0;for(let T=0;T<U.length;T++){let I=B.get(T)||K;if(w+=I,w>_+X){E=Math.min(U.length-1,T+J);break}}return{startIndex:M,endIndex:E}}function j(){if(G){let w=0;for(let M=0;M<U.length;M++)w+=B.get(M)||K;return w}return U.length*Y}function H(w){if(G){let M=0;for(let E=0;E<w;E++)M+=B.get(E)||K;return M}return w*Y}function O(){let{startIndex:w,endIndex:M}=z();return{startIndex:w,endIndex:M,scrollTop:_,totalHeight:j(),visibleItems:U.slice(w,M+1),itemHeights:new Map(B)}}function F(w,M="auto"){let E=H(w);L(E,M)}function L(w,M="auto"){_=Math.max(0,Math.min(w,j()-X))}function V(){z()}function N(w){U=[...w],B.clear(),V()}function A(){U=[],B.clear()}return{scrollToIndex:F,scrollToOffset:L,getState:O,refresh:V,setItems:N,destroy:A}}function d3($,Z={},Y){let X=/@virtualList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualList/gi;return $.replace(X,(J,Q,G,K)=>{let W=Q.trim(),U=Z[W];if(!U||!Array.isArray(U))return`<!-- virtualList: items "${W}" not found or not an array -->`;let _={itemHeight:50,containerHeight:400,overscan:3};if(G)try{let L=G.trim(),V=Function(`return ${L}`)();_={..._,...V}}catch{}let B=`vlist-${Math.random().toString(36).substring(2,9)}`,z=Math.ceil(_.containerHeight/_.itemHeight),q=_.overscan||3,j=0,H=Math.min(U.length-1,z+q),O="";for(let L=j;L<=H&&L<U.length;L++){let V=U[L],N=K.replace(/\{\{\s*item\s*\}\}/g,typeof V==="object"?JSON.stringify(V):String(V)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(A,w)=>{if(typeof V==="object"&&V!==null)return String(V[w]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(L));O+=`
7877
7877
  <div class="virtual-item ${_.itemClass||""}"
7878
7878
  style="position: absolute; top: ${L*_.itemHeight}px; height: ${_.itemHeight}px; width: 100%;"
7879
7879
  data-index="${L}">
@@ -8016,11 +8016,11 @@ else {
8016
8016
  ${W}
8017
8017
  </div>
8018
8018
  </div>
8019
- `})}function bJ($,Z={},Y){let X=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return $.replace(X,(J,Q,G,K)=>{let W=Q.trim(),U=Z[W];if(!U||!Array.isArray(U))return`<!-- virtualGrid: items "${W}" not found or not an array -->`;let _={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(G)try{let V=Function(`return ${G.trim()}`)();_={..._,...V}}catch{}let B=`vgrid-${Math.random().toString(36).substring(2,9)}`,z=Math.ceil(U.length/_.columns),q=z*(_.rowHeight+(_.gap||0)),j=Math.ceil(_.containerHeight/(_.rowHeight+(_.gap||0))),H=_.overscan||2,O=0,F=Math.min(z-1,j+H),L="";for(let V=O;V<=F;V++)for(let N=0;N<_.columns;N++){let A=V*_.columns+N;if(A>=U.length)break;let w=U[A],M=N*(100/_.columns),E=V*(_.rowHeight+(_.gap||0)),I=K.replace(/\{\{\s*item\s*\}\}/g,typeof w==="object"?JSON.stringify(w):String(w)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(T,S)=>{if(typeof w==="object"&&w!==null)return String(w[S]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(A));L+=`
8019
+ `})}function bJ($,Z={},Y){let X=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return $.replace(X,(J,Q,G,K)=>{let W=Q.trim(),U=Z[W];if(!U||!Array.isArray(U))return`<!-- virtualGrid: items "${W}" not found or not an array -->`;let _={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(G)try{let V=Function(`return ${G.trim()}`)();_={..._,...V}}catch{}let B=`vgrid-${Math.random().toString(36).substring(2,9)}`,z=Math.ceil(U.length/_.columns),q=z*(_.rowHeight+(_.gap||0)),j=Math.ceil(_.containerHeight/(_.rowHeight+(_.gap||0))),H=_.overscan||2,O=0,F=Math.min(z-1,j+H),L="";for(let V=O;V<=F;V++)for(let N=0;N<_.columns;N++){let A=V*_.columns+N;if(A>=U.length)break;let w=U[A],M=N*(100/_.columns),E=V*(_.rowHeight+(_.gap||0)),T=K.replace(/\{\{\s*item\s*\}\}/g,typeof w==="object"?JSON.stringify(w):String(w)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(I,S)=>{if(typeof w==="object"&&w!==null)return String(w[S]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(A));L+=`
8020
8020
  <div class="virtual-grid-item"
8021
8021
  style="position: absolute; top: ${E}px; left: ${M}%; width: calc(${100/_.columns}% - ${_.gap||0}px); height: ${_.rowHeight}px;"
8022
8022
  data-index="${A}">
8023
- ${I}
8023
+ ${T}
8024
8024
  </div>`}return`
8025
8025
  <div id="${B}"
8026
8026
  class="virtual-grid-container"
@@ -8845,14 +8845,14 @@ if ('serviceWorker' in navigator) {
8845
8845
  <meta name="stx-layout" content="${q}">`)}let z=G.match(/function (__stx_setup_\d+_\d+)\(/);if(z&&G.includes("<body")&&!G.match(/<body[^>]*data-stx=/)){G=G.replace(/<body([^>]*)>/,`<body$1 data-stx="${z[1]}">`);let q=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${z[1]}"`,"i");G=G.replace(q,"$1")}}if(Q)try{let{getStoreScript:K}=await Promise.resolve().then(() => (h_(),f_)),W=X.storesDir,U=await K(W);if(U){let _=`<script data-stx-stores>${U}</script>`,B=G.indexOf("<script data-stx-scoped>");if(B!==-1){let z=G.indexOf("</script>",B+24);if(z!==-1){let q=z+9;G=G.slice(0,q)+`
8846
8846
  `+_+G.slice(q)}}}}catch{}if(Q&&Z.__stx_inject_css!==!1)G=await E0(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof _5)throw G;let K=G instanceof Error?G.message:String(G),W=new M1(`Template processing failed: ${K}`,Y,void 0,void 0,$.substring(0,200)+($.length>200?"...":""));if(t0.log(W,{filePath:Y,context:Z}),P6.logDetailedError(W,{filePath:Y,template:$.substring(0,500)}),X.debug)throw W;return g8.createFallbackContent("Template Processing",W)}}async function cR($,Z,Y,X,J){let Q=process.cwd(),G={...X,partialsDir:X.partialsDir&&!K1.isAbsolute(X.partialsDir)?K1.resolve(Q,X.partialsDir):X.partialsDir,componentsDir:X.componentsDir&&!K1.isAbsolute(X.componentsDir)?K1.resolve(Q,X.componentsDir):X.componentsDir,layoutsDir:X.layoutsDir&&!K1.isAbsolute(X.layoutsDir)?K1.resolve(Q,X.layoutsDir):X.layoutsDir},K=G,W=$;W=W.replace(/\{\{--[\s\S]*?--\}\}/g,"");let U="\x00STX_ESCAPED_AT\x00";W=W.replace(/@@/g,U),W=W.replace(/@\{\{([\s\S]*?)\}\}/g,(H,O)=>{return`{{ ${O} }}`}),W=nX(W),W=await y_(W,Y,J);let _={};W=_3(W,_);let B={...Z.__sections||{}},z="",q=/@nolayout\b/.test(W);if(q)W=W.replace(/@nolayout\b\s*/g,"");let j=W.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(j)z=j[1],W=W.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");if(!z&&!q&&K.defaultLayout){let H=/<!DOCTYPE\s/i.test(W),O=/@section\s*\(/.test(W);if(!H||O){let F="",L=K1.dirname(Y),V=K.layoutsDir?K1.dirname(K.layoutsDir):process.cwd();for(let N=0;N<20;N++){let A=K1.join(L,"_layout.stx");if(await Y0(A)){F=A;break}let w=K1.dirname(L);if(w===L||w.length<V.length)break;L=w}if(F)z=F;else if(K.layoutsDir){let N=K1.isAbsolute(K.layoutsDir)?K.layoutsDir:K1.resolve(process.cwd(),K.layoutsDir),A=K1.join(N,`${K.defaultLayout}.stx`);if(await Y0(A))z=A}if(z&&!O)W=`@section('content')
8847
8847
  ${W.trim()}
8848
- @endsection`}}if(W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(H,O,F)=>{return B[O]=F,""}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(H,O,F)=>{if(F.includes("@parent"))B[O]=F.replace("@parent",G6);else B[O]=F.trim();return""}),Z.__sections=B,W=W.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(H,O,F)=>{return B[O]||F||""}),!("slot"in Z)||Z.slot===void 0)W=W.replace(/\{\{\s*slot\s*\}\}/g,()=>{return B.content||""});if(W=B3(W,_),z)try{let H=K1.isAbsolute(z)?z:await y1(()=>y5(z,Y,G,J),null,()=>{throw new M1(`Failed to resolve layout path: ${z}`,Y,void 0,void 0,`Layout referenced from ${Y}`)});if(!H){let A=`Layout not found: ${z} (referenced from ${Y})`;if(t0.log(Error(A),{layoutPath:z,filePath:Y},"warning"),G.debug)throw new M1(A,Y);return W}let O=await y1(()=>Bun.file(H).text(),"",()=>{throw new M1(`Failed to read layout file: ${H}`,Y,void 0,void 0,"Layout content could not be loaded")}),F=O.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(F){if(G.debug)console.log(`Found nested layout: ${F[1]} in ${H}`);let A={},w=O.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(I,T,S)=>{return A[T]=S.trim(),""});for(let[I,T]of Object.entries(A))if(B[I]&&B[I].includes(G6)){let S=B[I].indexOf(G6);B[I]=B[I].slice(0,S)+T+B[I].slice(S+G6.length)}else if(!B[I])B[I]=T;let M={...Z,__sections:B},E=`@layout('${F[1]}')${w}`;return await K0(E,M,H,G,J)}let L=O.replace(/\{\{--[\s\S]*?--\}\}/g,""),V=_3(L,_),N={};return V=V.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(A,w,M)=>{return N[w]=M.trim(),`@slot('${w}')`}),V=V.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(A,w,M)=>{if(B[w]){let E=B[w];if(E.includes(G6)){let I=N[w]||"",T=E.indexOf(G6);E=E.slice(0,T)+I+E.slice(T+G6.length)}return E}return M||""}),V=V.replace(/\{\{\s*slot\s*\}\}/g,()=>{return B.content||""}),V=B3(V,_),Z.__originalFilePath=Y,W=await Zz(V,Z,H,G,J),W=`<!-- stx-layout: ${z} -->
8849
- ${W}`,W}catch(H){return t0.log(H instanceof Error?H:Error(String(H)),{layoutPath:z,filePath:Y},"error"),`[Error processing layout: ${H instanceof Error?H.message:String(H)}]`}return await Zz(W,Z,Y,G,J)}async function Zz($,Z,Y,X,J){let Q=$;Z.__stx_sfc_mode=!0;let G=X;if(await y1(()=>mU(Y,Z),void 0,(d)=>{t0.log(d,{filePath:Y,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${Y}: ${d.message}`)}),Z.__stx_options=G,G.buildMode)Z.__stx_buildMode=G.buildMode;let K=G.envPrefix||"STX_PUBLIC_",W={};for(let[d,r]of Object.entries(process.env))if(d.startsWith(K)&&r!==void 0)W[d]=r;Z.$env=W,Q=await y1(()=>hX(Q,Z,Y,G),Q,(d)=>{t0.log(d,{filePath:Y,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${Y}: ${d.message}`)});let U=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,_;while((_=U.exec(Q))!==null){let d=_[1],r=_[2];if(/\bserver\b/.test(d)&&r.trim())try{let{extractVariables:s}=await Promise.resolve().then(() => (D4(),X3));await s(r,Z,Y)}catch(s){let G0=s instanceof Error?s:Error(String(s));t0.log(G0,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${G0.message}`)}}try{let{interpolateScriptsInTemplate:d}=await Promise.resolve().then(() => (c0(),X5));Q=d(Q,Z,{skipServer:!0})}catch(d){let r=d instanceof Error?d:Error(String(d));t0.log(r,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${r.message}`)}if(Q=await yU(Q,Z,Y),Q=await xU(Q,Z,Y),Q=await RX(Q,Z,Y,G),Y5(Q))Q=YJ(Q),Q=XJ(Q,Z);Q=K3(Q,Z,Y,G),Q=await MJ(Q,Z,Y,G,J),Q=await sX(Q,Z,Y,G,J),Q=SY(Q,Z,Y,G);let{processDeferDirectives:B}=await Promise.resolve().then(() => m_);Q=B(Q,Z,Y);let{processTeleportDirectives:z}=await Promise.resolve().then(() => i_);Q=z(Q,Z,Y);let{processTransitionDirectives:q,processTransitionAttributes:j}=await Promise.resolve().then(() => YB);Q=q(Q,Z,Y),Q=j(Q);let{processErrorBoundaryDirectives:H}=await Promise.resolve().then(() => JB);Q=H(Q,Z,Y);let{processSuspenseDirectives:O}=await Promise.resolve().then(() => _B);Q=O(Q,Z,Y);let{processAsyncDirectives:F}=await Promise.resolve().then(() => VB);Q=F(Q,Z,Y);let{processKeepAliveDirectives:L}=await Promise.resolve().then(() => DB);Q=L(Q,Z,Y);let{processVirtualListDirectives:V,processVirtualGridDirectives:N,processInfiniteListDirectives:A}=await Promise.resolve().then(() => (CJ(),kB));Q=V(Q,Z,Y),Q=N(Q,Z,Y),Q=A(Q,Z,Y);let{processPartialHydrationDirectives:w,processStaticDirectives:M}=await Promise.resolve().then(() => (iJ(),SB));Q=w(Q,Z,Y),Q=M(Q);let{processComputedDirectives:E,processWatchDirectives:I}=await Promise.resolve().then(() => (mB(),uB));Q=E(Q,Z,Y),Q=I(Q,Z,Y);let{processFormValidationDirectives:T}=await Promise.resolve().then(() => (nB(),iB));Q=T(Q,Z,Y);let{processHeadDirective:S,processTitleDirective:k,processMetaDirective:b,resetHead:y}=await Promise.resolve().then(() => (T4(),s8));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)y();let v=S(Q);if(Q=v.content,Q=k(Q,Z),Q=b(Q,Z),Q=hU(Q),Q=qX(Q,Z),Q=iW(Q),Q=fU(Q),Q=await U3(Q,Z,Y,G,J),Q=await MJ(Q,Z,Y,G,J),Q=EJ(Q),Q=$6(Q,Z,Y),Q=jX(Q,Z),Q=HX(Q,Z),Q=x6(Q,Z),Q=t8(Q,Z),Q=e8(Q,Z),Q=await oJ(Q,Z,Y,G),Q=await aJ(Q,Z,Y),Q=await SX(Q,Z,Y,G),Q=IY(Q,Z,Y,G),Q=mX(Q,Z,Y,G),Q=cX(Q,Z,Y),Q=pX(Q,Z,Y,G),Q=AX(Q,Z,Y,G),Q=k5(Q,Z),Q=S5(Q),Q=v_(Q),!G.skipEventDirectives)Q=YX(Q,Z,Y);if(Q=GW(Q,Z,Y),G.debug){let d=/\bx-data\s*=/.test(Q),r=P3($);if(d&&r)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
8848
+ @endsection`}}if(W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(H,O,F)=>{return B[O]=F,""}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(H,O,F)=>{if(F.includes("@parent"))B[O]=F.replace("@parent",G6);else B[O]=F.trim();return""}),Z.__sections=B,W=W.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(H,O,F)=>{return B[O]||F||""}),!("slot"in Z)||Z.slot===void 0)W=W.replace(/\{\{\s*slot\s*\}\}/g,()=>{return B.content||""});if(W=B3(W,_),z)try{let H=K1.isAbsolute(z)?z:await y1(()=>y5(z,Y,G,J),null,()=>{throw new M1(`Failed to resolve layout path: ${z}`,Y,void 0,void 0,`Layout referenced from ${Y}`)});if(!H){let A=`Layout not found: ${z} (referenced from ${Y})`;if(t0.log(Error(A),{layoutPath:z,filePath:Y},"warning"),G.debug)throw new M1(A,Y);return W}let O=await y1(()=>Bun.file(H).text(),"",()=>{throw new M1(`Failed to read layout file: ${H}`,Y,void 0,void 0,"Layout content could not be loaded")}),F=O.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(F){if(G.debug)console.log(`Found nested layout: ${F[1]} in ${H}`);let A={},w=O.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(T,I,S)=>{return A[I]=S.trim(),""});for(let[T,I]of Object.entries(A))if(B[T]&&B[T].includes(G6)){let S=B[T].indexOf(G6);B[T]=B[T].slice(0,S)+I+B[T].slice(S+G6.length)}else if(!B[T])B[T]=I;let M={...Z,__sections:B},E=`@layout('${F[1]}')${w}`;return await K0(E,M,H,G,J)}let L=O.replace(/\{\{--[\s\S]*?--\}\}/g,""),V=_3(L,_),N={};return V=V.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(A,w,M)=>{return N[w]=M.trim(),`@slot('${w}')`}),V=V.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(A,w,M)=>{if(B[w]){let E=B[w];if(E.includes(G6)){let T=N[w]||"",I=E.indexOf(G6);E=E.slice(0,I)+T+E.slice(I+G6.length)}return E}return M||""}),V=V.replace(/\{\{\s*slot\s*\}\}/g,()=>{return B.content||""}),V=B3(V,_),Z.__originalFilePath=Y,W=await Zz(V,Z,H,G,J),W=`<!-- stx-layout: ${z} -->
8849
+ ${W}`,W}catch(H){return t0.log(H instanceof Error?H:Error(String(H)),{layoutPath:z,filePath:Y},"error"),`[Error processing layout: ${H instanceof Error?H.message:String(H)}]`}return await Zz(W,Z,Y,G,J)}async function Zz($,Z,Y,X,J){let Q=$;Z.__stx_sfc_mode=!0;let G=X;if(await y1(()=>mU(Y,Z),void 0,(d)=>{t0.log(d,{filePath:Y,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${Y}: ${d.message}`)}),Z.__stx_options=G,G.buildMode)Z.__stx_buildMode=G.buildMode;let K=G.envPrefix||"STX_PUBLIC_",W={};for(let[d,r]of Object.entries(process.env))if(d.startsWith(K)&&r!==void 0)W[d]=r;Z.$env=W,Q=await y1(()=>hX(Q,Z,Y,G),Q,(d)=>{t0.log(d,{filePath:Y,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${Y}: ${d.message}`)});let U=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,_;while((_=U.exec(Q))!==null){let d=_[1],r=_[2];if(/\bserver\b/.test(d)&&r.trim())try{let{extractVariables:s}=await Promise.resolve().then(() => (D4(),X3));await s(r,Z,Y)}catch(s){let G0=s instanceof Error?s:Error(String(s));t0.log(G0,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${G0.message}`)}}try{let{interpolateScriptsInTemplate:d}=await Promise.resolve().then(() => (c0(),X5));Q=d(Q,Z,{skipServer:!0})}catch(d){let r=d instanceof Error?d:Error(String(d));t0.log(r,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${r.message}`)}if(Q=await yU(Q,Z,Y),Q=await xU(Q,Z,Y),Q=await RX(Q,Z,Y,G),Y5(Q))Q=YJ(Q),Q=XJ(Q,Z);Q=K3(Q,Z,Y,G),Q=await MJ(Q,Z,Y,G,J),Q=await sX(Q,Z,Y,G,J),Q=SY(Q,Z,Y,G);let{processDeferDirectives:B}=await Promise.resolve().then(() => m_);Q=B(Q,Z,Y);let{processTeleportDirectives:z}=await Promise.resolve().then(() => i_);Q=z(Q,Z,Y);let{processTransitionDirectives:q,processTransitionAttributes:j}=await Promise.resolve().then(() => YB);Q=q(Q,Z,Y),Q=j(Q);let{processErrorBoundaryDirectives:H}=await Promise.resolve().then(() => JB);Q=H(Q,Z,Y);let{processSuspenseDirectives:O}=await Promise.resolve().then(() => _B);Q=O(Q,Z,Y);let{processAsyncDirectives:F}=await Promise.resolve().then(() => VB);Q=F(Q,Z,Y);let{processKeepAliveDirectives:L}=await Promise.resolve().then(() => DB);Q=L(Q,Z,Y);let{processVirtualListDirectives:V,processVirtualGridDirectives:N,processInfiniteListDirectives:A}=await Promise.resolve().then(() => (CJ(),kB));Q=V(Q,Z,Y),Q=N(Q,Z,Y),Q=A(Q,Z,Y);let{processPartialHydrationDirectives:w,processStaticDirectives:M}=await Promise.resolve().then(() => (iJ(),SB));Q=w(Q,Z,Y),Q=M(Q);let{processComputedDirectives:E,processWatchDirectives:T}=await Promise.resolve().then(() => (mB(),uB));Q=E(Q,Z,Y),Q=T(Q,Z,Y);let{processFormValidationDirectives:I}=await Promise.resolve().then(() => (nB(),iB));Q=I(Q,Z,Y);let{processHeadDirective:S,processTitleDirective:k,processMetaDirective:x,resetHead:f}=await Promise.resolve().then(() => (T4(),s8));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)f();let b=S(Q);if(Q=b.content,Q=k(Q,Z),Q=x(Q,Z),Q=hU(Q),Q=qX(Q,Z),Q=iW(Q),Q=fU(Q),Q=await U3(Q,Z,Y,G,J),Q=await MJ(Q,Z,Y,G,J),Q=EJ(Q),Q=$6(Q,Z,Y),Q=jX(Q,Z),Q=HX(Q,Z),Q=x6(Q,Z),Q=t8(Q,Z),Q=e8(Q,Z),Q=await oJ(Q,Z,Y,G),Q=await aJ(Q,Z,Y),Q=await SX(Q,Z,Y,G),Q=IY(Q,Z,Y,G),Q=mX(Q,Z,Y,G),Q=cX(Q,Z,Y),Q=pX(Q,Z,Y,G),Q=AX(Q,Z,Y,G),Q=k5(Q,Z),Q=S5(Q),Q=v_(Q),!G.skipEventDirectives)Q=YX(Q,Z,Y);if(Q=GW(Q,Z,Y),G.debug){let d=/\bx-data\s*=/.test(Q),r=P3($);if(d&&r)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
8850
8850
  Both work on the same page, but they manage separate scopes.
8851
- Prefer signals (state/derived/effect) for new components.`)}Q=H3(Q,Z),Q=await L1(Q,Z,Y),Q=g_(Q),Q=oY(Q);let{processXElementDirectives:C}=await Promise.resolve().then(() => aB);Q=C(Q);let f=Z.__originalFilePath||Y;if(Q=await JJ(Q,G,f),Q=await dX(Q,Z,Y,G),G.seo?.enabled)Q=lX(Q,Z,G);let{renderHead:h,getHead:u}=await Promise.resolve().then(() => (T4(),s8)),l=Z.__stx_runtime_head,i=l&&(l.title||l.meta?.length||l.link?.length)?l:u();if(i.title||i.meta?.length||i.link?.length){let d=h(i);if(d){if(Q.includes("</head>"))Q=Q.replace("</head>",`${d}
8851
+ Prefer signals (state/derived/effect) for new components.`)}Q=H3(Q,Z),Q=await L1(Q,Z,Y),Q=g_(Q),Q=oY(Q);let{processXElementDirectives:C}=await Promise.resolve().then(() => aB);Q=C(Q);let v=Z.__originalFilePath||Y;if(Q=await JJ(Q,G,v),Q=await dX(Q,Z,Y,G),G.seo?.enabled)Q=lX(Q,Z,G);let{renderHead:h,getHead:u}=await Promise.resolve().then(() => (T4(),s8)),p=Z.__stx_runtime_head,i=p&&(p.title||p.meta?.length||p.link?.length)?p:u();if(i.title||i.meta?.length||i.link?.length){let d=h(i);if(d){if(Q.includes("</head>"))Q=Q.replace("</head>",`${d}
8852
8852
  </head>`);else if(Q.includes("<head>"))Q=Q.replace("<head>",`<head>
8853
- ${d}`)}}if(v.headContent){if(Q.includes("</head>"))Q=Q.replace("</head>",`${v.headContent}
8853
+ ${d}`)}}if(b.headContent){if(Q.includes("</head>"))Q=Q.replace("</head>",`${b.headContent}
8854
8854
  </head>`);else if(Q.includes("<head>"))Q=Q.replace("<head>",`<head>
8855
- ${v.headContent}`)}if(G.csp?.enabled&&G.csp.addMetaTag)Q=VX(Q,G.csp,Z);if(G.analytics?.enabled)Q=$X(Q,G);if(G.heatmap?.enabled)Q=PY(Q,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:d}=await Promise.resolve().then(() => ($z(),eB));Q=d(Q,G)}let _0=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(Q),q0=/\bSTX\.\w+/.test(Q),f0=/window\.STX\s*=/.test(Q);if(_0&&q0&&!f0){let r=`<script data-stx-scoped>
8855
+ ${b.headContent}`)}if(G.csp?.enabled&&G.csp.addMetaTag)Q=VX(Q,G.csp,Z);if(G.analytics?.enabled)Q=$X(Q,G);if(G.heatmap?.enabled)Q=PY(Q,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:d}=await Promise.resolve().then(() => ($z(),eB));Q=d(Q,G)}let _0=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(Q),q0=/\bSTX\.\w+/.test(Q),f0=/window\.STX\s*=/.test(Q);if(_0&&q0&&!f0){let r=`<script data-stx-scoped>
8856
8856
  ${lK()}
8857
8857
  </script>`;if(Q.includes("</head>")){let J0=Q.indexOf("</head>"),G0=Q.slice(0,J0).indexOf("<script");if(G0!==-1){let B0=Q.slice(0,G0),h0=Q.slice(G0);Q=B0+r+`
8858
8858
  `+h0}else Q=Q.replace("</head>",`${r}
@@ -8863,7 +8863,7 @@ ${r}`);else Q=r+`
8863
8863
  `)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},U=()=>{if(X!==0)return;let _=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(_){let j=_[2].split(",").map((H)=>{let O=H.trim().split(":");return O[O.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let B=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(B){let j=B[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let z=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(z){let j=z[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let q=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let j=q[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(W())continue;if($[J]==="'"||$[J]==='"'){G($[J]);continue}if($[J]==="`"){K();continue}if($[J]==="{"){X++,J++;continue}if($[J]==="}"){X--,J++;continue}if(X===0&&/[a-z]/i.test($[J])&&(J===0||/\s|[;{}()]/.test($[J-1])))U();J++}return Z}async function v1($,Z,Y,X,J,Q,G,K=new Set,W){let{extractVariables:U}=await Promise.resolve().then(() => (D4(),X3)),_=K??new Set;if(_.has($))return`[Circular component reference: ${$}]`;let B=new Set(_);B.add($);try{let z=(g)=>g.split("-").map((m)=>m.charAt(0).toUpperCase()+m.slice(1)).join(""),q=(g)=>g.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),j=$.endsWith(".stx")?$.slice(0,-4):$,H=null,O=J.__importedComponents;if(O){let g=[j,j.toLowerCase(),z(j),q(j)];for(let m of g)if(O.has(m)){H=O.get(m);break}}let F=[];if(!H){let g=[`${j}.stx`,`${z(j)}.stx`,`${q(j)}.stx`],m=[...new Set(g)],n=J.__originalFilePath,c=[];if(n){let J0=U0.join(U0.dirname(n),"components");c.push(J0)}if(X)c.push(X);let $0=U0.join(U0.dirname(Q),"components");if(!c.includes($0))c.push($0);if(G.componentsDir&&G.componentsDir!==X&&!c.includes(G.componentsDir))c.push(G.componentsDir);let d=process.cwd(),r=[U0.resolve(d,"src/components"),U0.resolve(d,"components"),U0.resolve(import.meta.dir,"components")];for(let J0 of r)if(!c.includes(J0))c.push(J0);if(j.startsWith("./")||j.startsWith("../"))H=U0.resolve(U0.dirname(Q),`${j}.stx`),F.push(H);else for(let J0 of c){if(!J0)continue;for(let s of m){let G0=U0.join(J0,s);if(F.push(G0),await Y0(G0)){H=G0;break}}if(H)break;if(!H)try{let s=await import("fs");if(!s.statSync(J0,{throwIfNoEntry:!1})?.isDirectory())continue;let B0=8,h0=[{path:J0,depth:0}];while(h0.length>0&&!H){let a1=h0.pop();if(a1.depth>=B0)continue;let a4;try{a4=s.readdirSync(a1.path,{withFileTypes:!0})}catch{continue}for(let j0 of a4){if(!j0.isDirectory())continue;if(j0.name==="node_modules"||j0.name.startsWith("."))continue;let w6=U0.join(a1.path,j0.name);for(let qK of m){let TY=U0.join(w6,qK);if(F.push(TY),await Y0(TY)){H=TY;break}}if(H)break;h0.push({path:w6,depth:a1.depth+1})}}}catch{}if(H)break}}if(!H||!await Y0(H)){let g=F.length>0?`
8864
8864
  Searched paths:
8865
8865
  ${F.map((m)=>` - ${m}`).join(`
8866
- `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${g}`}W.add(H);let L;if(x5.has(H))L=x5.get(H);else try{L=await Bun.file(H).text(),x5.set(H,L)}catch(g){return`[Error loading component: ${g instanceof Error?g.message:String(g)}]`}let V=new Set(["__originalFilePath","__importedComponents"]),N={};for(let[g,m]of Object.entries(J))if(!g.startsWith("__")||V.has(g))N[g]=m;let A={...N,...Z,props:Z,slot:Y,__processedComponents:B,__sections:{}},w=L,M=w.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(M)w=M[1].trim();let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[...L.matchAll(E)],T=[];for(let g of I){let m=g[1]||"",n=g[2]||"",c=m.includes("server");if(L4(m)&&n.trim())n=F4(n);if(c&&n)try{await U(n,A,H)}catch(d){}if(!c){let d=n.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),r=m.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");T.push(`<script${r}>${d}</script>`)}}let S=L.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),k=S?S[1]:"",b=S?S[2]:"",y="",v=k&&/\bscoped\b/i.test(k);if(S)y=`<style${k}>${b}</style>`;let C=w;if(C=C.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),S)C=C.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");if(Y&&C.includes("{{ text || slot }}"))C=C.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:f,applySlots:h}=await Promise.resolve().then(() => (Z9(),zz)),{defaultSlot:u,namedSlots:l}=f(Y);C=await h(C,u||Y,l,A);for(let[g,m]of Object.entries(A))if(typeof m==="string"){if(m.includes("<")&&m.includes(">")||m.includes("&lt;")||m.includes("&quot;")){let n=T8(m);A[g]=n}}let i=T.some((g)=>/\b(state|derived|effect)\s*\(/.test(g)),_0={...G,componentsDir:U0.dirname(H),skipSignalsRuntime:!0,skipEventDirectives:i,defaultLayout:void 0};A.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let q0=await K0(C,A,H,_0,W),f0=`stx_${j.replace(/[^a-zA-Z0-9]/g,"_")}_${++ZM}_${Math.random().toString(36).slice(2,8)}`,D0=q0;if(i){let g="";if(Object.keys(Z).length>0)try{g=` data-stx-props="${YM(JSON.stringify(Z))}"`}catch{}if(D0=`<div data-stx-scope="${f0}"${g}>${q0}</div>`,D0=T.map((n)=>{let c=n.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!c)return n;let[,$0,d]=c,r=O4(d),J0=`
8866
+ `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${g}`}W.add(H);let L;if(x5.has(H))L=x5.get(H);else try{L=await Bun.file(H).text(),x5.set(H,L)}catch(g){return`[Error loading component: ${g instanceof Error?g.message:String(g)}]`}let V=new Set(["__originalFilePath","__importedComponents"]),N={};for(let[g,m]of Object.entries(J))if(!g.startsWith("__")||V.has(g))N[g]=m;let A={...N,...Z,props:Z,slot:Y,__processedComponents:B,__sections:{}},w=L,M=w.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(M)w=M[1].trim();let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,T=[...L.matchAll(E)],I=[];for(let g of T){let m=g[1]||"",n=g[2]||"",c=m.includes("server");if(L4(m)&&n.trim())n=F4(n);if(c&&n)try{await U(n,A,H)}catch(d){}if(!c){let d=n.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),r=m.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");I.push(`<script${r}>${d}</script>`)}}let S=L.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),k=S?S[1]:"",x=S?S[2]:"",f="",b=k&&/\bscoped\b/i.test(k);if(S)f=`<style${k}>${x}</style>`;let C=w;if(C=C.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),S)C=C.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");if(Y&&C.includes("{{ text || slot }}"))C=C.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:v,applySlots:h}=await Promise.resolve().then(() => (Z9(),zz)),{defaultSlot:u,namedSlots:p}=v(Y);C=await h(C,u||Y,p,A);for(let[g,m]of Object.entries(A))if(typeof m==="string"){if(m.includes("<")&&m.includes(">")||m.includes("&lt;")||m.includes("&quot;")){let n=T8(m);A[g]=n}}let i=I.some((g)=>/\b(state|derived|effect)\s*\(/.test(g)),_0={...G,componentsDir:U0.dirname(H),skipSignalsRuntime:!0,skipEventDirectives:i,defaultLayout:void 0};A.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let q0=await K0(C,A,H,_0,W),f0=`stx_${j.replace(/[^a-zA-Z0-9]/g,"_")}_${++ZM}_${Math.random().toString(36).slice(2,8)}`,D0=q0;if(i){let g="";if(Object.keys(Z).length>0)try{g=` data-stx-props="${YM(JSON.stringify(Z))}"`}catch{}if(D0=`<div data-stx-scope="${f0}"${g}>${q0}</div>`,D0=I.map((n)=>{let c=n.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!c)return n;let[,$0,d]=c,r=O4(d),J0=`
8867
8867
  (function() {
8868
8868
  const { state, derived, effect, batch } = window.stx;
8869
8869
  const __scope = window.stx._scopes = window.stx._scopes || {};
@@ -8887,11 +8887,11 @@ catch (e) {}
8887
8887
  Object.assign(__scopeVars, __localVars);
8888
8888
  })();`;return`<script data-stx-scoped${$0}>${J0}</script>`}).join(`
8889
8889
  `)+`
8890
- `+D0,y)D0+=`
8891
- `+y}else{if(y)D0+=`
8892
- `+y;if(T.length>0){let g=A.__stx_event_bindings||[],m=await Promise.all(T.map(async(n)=>{let c=n.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!c)return n;return await e4(c[1],{eventBindings:g,templateContent:D0,filePath:H,projectRoot:process.cwd()})}));D0+=`
8890
+ `+D0,f)D0+=`
8891
+ `+f}else{if(f)D0+=`
8892
+ `+f;if(I.length>0){let g=A.__stx_event_bindings||[],m=await Promise.all(I.map(async(n)=>{let c=n.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!c)return n;return await e4(c[1],{eventBindings:g,templateContent:D0,filePath:H,projectRoot:process.cwd()})}));D0+=`
8893
8893
  `+m.join(`
8894
- `),A.__stx_event_bindings=[]}}if(v){let g=V5(D0,H);if(g.hasScoped)D0=g.html}return D0}catch(z){return`[Error processing component: ${z instanceof Error?z.message:String(z)}]`}finally{_.delete($)}}async function Y0($){return Bun.file($).exists()}function Y9($,Z){let Y=U0.resolve(Z),X=U0.resolve($),J=Y.endsWith(U0.sep)?Y:Y+U0.sep;if(X===Y||X.startsWith(J))return X;return null}async function y5($,Z,Y,X){let J=await JM($,Z,Y,X);if(J===null)return null;let Q=Y9(J,process.cwd());if(Q)return Q;let G=[Y.root,Y.layoutsDir,Y.componentsDir,Y.partialsDir,Y.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let W=U0.isAbsolute(K)?K:U0.resolve(process.cwd(),K);if(Y9(J,W))return U0.resolve(J)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${$}, from: ${Z})`),null}async function JM($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let J=U0.dirname(Z),Q=process.cwd();if($.startsWith("/")){let z=U0.join(Q,$),q=Y9(z,Q);if(!q)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${q}`);if(await Y0(q)&&X)X.add(q);return q}let G=U0.join(J,$);if(await Y0(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(X)X.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let z of[".stx",".tsx",".jsx"]){let q=`${G}${z}`;if(await Y0(q)){if(Y.debug)console.log(`Found direct path with extension: ${q}`);if(X)X.add(q);return q}}let K="",W=U0.resolve(J),U=process.cwd();for(let z=0;z<10;z++){let q=U0.join(W,"layouts"),j=!1;try{j=$M.statSync(q,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=q;break}let H=U0.dirname(W);if(H===W||H.length<U.length)break;W=H}if(K){let z=$.startsWith("layouts/")?$.slice(8):$,q=U0.join(K,z);if(await Y0(q)){if(Y.debug)console.log(`Found in current layouts dir: ${q}`);if(X)X.add(q);return q}if(!z.endsWith(".stx")){let j=`${q}.stx`;if(await Y0(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.layoutsDir){let z=U0.isAbsolute(Y.layoutsDir)?Y.layoutsDir:U0.resolve(process.cwd(),Y.layoutsDir),q=$.startsWith("layouts/")?$.slice(8):$,j=U0.join(z,q);if(await Y0(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(X)X.add(j);return j}if(!$.endsWith(".stx")){let H=`${j}.stx`;if(await Y0(H)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(X)X.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let z=$.split("layouts/"),q=U0.join(Y.partialsDir||J,"layouts",z[1]);if(await Y0(q)){if(Y.debug)console.log(`Found in layouts path: ${q}`);if(X)X.add(q);return q}if(!q.endsWith(".stx")){let j=`${q}.stx`;if(await Y0(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=U0.join(Y.partialsDir,"layouts"),await Y0(K)){let z=U0.join(K,$);if(await Y0(z)){if(Y.debug)console.log(`Found in partials layouts dir: ${z}`);if(X)X.add(z);return z}if(!$.endsWith(".stx")){let q=`${z}.stx`;if(await Y0(q)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}}let _=Y.partialsDir||U0.join(process.cwd(),"views"),B=U0.join(_,$);if(await Y0(B)){if(Y.debug)console.log(`Found in views path: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let z=`${B}.stx`;if(await Y0(z)){if(Y.debug)console.log(`Found in views path with extension: ${z}`);if(X)X.add(z);return z}}if(J.includes("temp")){let z=U0.join(U0.dirname(J),"layouts",$);if(await Y0(z)){if(Y.debug)console.log(`Found in temp layouts dir: ${z}`);if(X)X.add(z);return z}if(!$.endsWith(".stx")){let q=`${z}.stx`;if(await Y0(q)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}if(Y.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function X9($,Z,Y){let X=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
8894
+ `),A.__stx_event_bindings=[]}}if(b){let g=V5(D0,H);if(g.hasScoped)D0=g.html}return D0}catch(z){return`[Error processing component: ${z instanceof Error?z.message:String(z)}]`}finally{_.delete($)}}async function Y0($){return Bun.file($).exists()}function Y9($,Z){let Y=U0.resolve(Z),X=U0.resolve($),J=Y.endsWith(U0.sep)?Y:Y+U0.sep;if(X===Y||X.startsWith(J))return X;return null}async function y5($,Z,Y,X){let J=await JM($,Z,Y,X);if(J===null)return null;let Q=Y9(J,process.cwd());if(Q)return Q;let G=[Y.root,Y.layoutsDir,Y.componentsDir,Y.partialsDir,Y.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let W=U0.isAbsolute(K)?K:U0.resolve(process.cwd(),K);if(Y9(J,W))return U0.resolve(J)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${$}, from: ${Z})`),null}async function JM($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let J=U0.dirname(Z),Q=process.cwd();if($.startsWith("/")){let z=U0.join(Q,$),q=Y9(z,Q);if(!q)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${q}`);if(await Y0(q)&&X)X.add(q);return q}let G=U0.join(J,$);if(await Y0(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(X)X.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let z of[".stx",".tsx",".jsx"]){let q=`${G}${z}`;if(await Y0(q)){if(Y.debug)console.log(`Found direct path with extension: ${q}`);if(X)X.add(q);return q}}let K="",W=U0.resolve(J),U=process.cwd();for(let z=0;z<10;z++){let q=U0.join(W,"layouts"),j=!1;try{j=$M.statSync(q,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=q;break}let H=U0.dirname(W);if(H===W||H.length<U.length)break;W=H}if(K){let z=$.startsWith("layouts/")?$.slice(8):$,q=U0.join(K,z);if(await Y0(q)){if(Y.debug)console.log(`Found in current layouts dir: ${q}`);if(X)X.add(q);return q}if(!z.endsWith(".stx")){let j=`${q}.stx`;if(await Y0(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.layoutsDir){let z=U0.isAbsolute(Y.layoutsDir)?Y.layoutsDir:U0.resolve(process.cwd(),Y.layoutsDir),q=$.startsWith("layouts/")?$.slice(8):$,j=U0.join(z,q);if(await Y0(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(X)X.add(j);return j}if(!$.endsWith(".stx")){let H=`${j}.stx`;if(await Y0(H)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(X)X.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let z=$.split("layouts/"),q=U0.join(Y.partialsDir||J,"layouts",z[1]);if(await Y0(q)){if(Y.debug)console.log(`Found in layouts path: ${q}`);if(X)X.add(q);return q}if(!q.endsWith(".stx")){let j=`${q}.stx`;if(await Y0(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=U0.join(Y.partialsDir,"layouts"),await Y0(K)){let z=U0.join(K,$);if(await Y0(z)){if(Y.debug)console.log(`Found in partials layouts dir: ${z}`);if(X)X.add(z);return z}if(!$.endsWith(".stx")){let q=`${z}.stx`;if(await Y0(q)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}}let _=Y.partialsDir||U0.join(process.cwd(),"views"),B=U0.join(_,$);if(await Y0(B)){if(Y.debug)console.log(`Found in views path: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let z=`${B}.stx`;if(await Y0(z)){if(Y.debug)console.log(`Found in views path with extension: ${z}`);if(X)X.add(z);return z}}if(J.includes("temp")){let z=U0.join(U0.dirname(J),"layouts",$);if(await Y0(z)){if(Y.debug)console.log(`Found in temp layouts dir: ${z}`);if(X)X.add(z);return z}if(!$.endsWith(".stx")){let q=`${z}.stx`;if(await Y0(q)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}if(Y.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function X9($,Z,Y){let X=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
8895
8895
  `),K=0;for(let W=0;W<G.length;W++)if(K+=G[W].length+1,K>=Z){X=W+1,J=G[W].trim();let U=Math.max(0,W-2),_=Math.min(G.length,W+3);Q=G.slice(U,_).map((B,z)=>{let q=U+z+1;return`${q===X?"> ":" "}${q}: ${B}`}).join(`
8896
8896
  `);break}}else if(Y){let G=$.indexOf(Y);if(G>=0)return X9($,G)}}catch{}return{lineNumber:X,lineContent:J,context:Q}}function F0($,Z,Y,X,J,Q){let{lineNumber:G,context:K}=X9(X,J,Q),W=Y.split("/").pop(),U=0;if(typeof J==="number"&&J>=0&&X){let B=X.lastIndexOf(`
8897
8897
  `,Math.max(0,J-1));U=J-(B+1)+1}let _="";if(G>0)_+=`
@@ -9100,20 +9100,20 @@ ${z0.dim}${K}${z0.reset}
9100
9100
  filter: blur(0);
9101
9101
  transform: scale(1);
9102
9102
  }
9103
- `.trim();t6=new Map});import{createHash as T9}from"crypto";import{readFile as HM,stat as Lz}from"fs/promises";async function i0($){try{let Z=await HM($);return T9("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function Fz($){return T9("sha256").update($).digest("hex").slice(0,16)}function r3($){return T9("sha256").update($).digest("hex").slice(0,16)}function $$($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${r3($)}-${r3(Y)}`}async function c5($){try{return(await Lz($)).mtimeMs}catch{return 0}}async function n0($){try{return await Lz($),!0}catch{return!1}}var v4=()=>{};import{mkdir as OM,readFile as Az,writeFile as LM,readdir as Nz,rm as I9,stat as FM}from"fs/promises";import{join as Z$,dirname as VM}from"path";async function AM($){try{await OM($,{recursive:!0})}catch{}}function wz($,Z,Y){return Z$($,Y,`${Z}.json`)}async function Vz($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await c5(Z)!==$.srcMtime)return!1;return!0}async function Y$($,Z,Y,X=p5){if(!X.enabled)return null;let J=$$($,Z),Q=g4.get(J);if(Q){if(await Vz(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;g4.delete(J)}let G=wz(X.directory,J,Y);if(await n0(G))try{let K=await Az(G,"utf-8"),W=JSON.parse(K);if(await Vz(W,$,X.maxAge))return W.lastAccessedAt=Date.now(),g4.set(J,W),W.data}catch{}return null}async function X$($,Z,Y,X,J=p5){if(!J.enabled)return;let Q=$$($,Z),G=await i0($),K=await c5($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:$$("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};g4.set(Q,W);let U=wz(J.directory,Q,X);try{await AM(VM(U)),await LM(U,JSON.stringify(W,null,2))}catch(_){console.warn(`[stx-media] Failed to write cache: ${_}`)}}async function J$($,Z=p5){if($==="all")g4.clear();else g4.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=Z$(Z.directory,X);try{await I9(J,{recursive:!0,force:!0})}catch{}}}async function Rz($=p5){let Z={memoryEntries:g4.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=Z$($.directory,Y);try{let J=await Nz(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=Z$(X,Q),K=await FM(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function Mz($=p5){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=Z$($.directory,X);try{let Q=await Nz(J);for(let G of Q){let K=Z$(J,G);try{let W=await Az(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await I9(K),g4.delete(U.key),Z++}catch{await I9(K).catch(()=>{}),Z++}}}catch{}}return Z}var g4,p5;var s3=D(()=>{v4();g4=new Map,p5={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class Q${config;constructor($={}){this.config={...NM,...$}}async get($,Z){return Y$($,Z,"image",this.config)}async set($,Z,Y){return X$($,Z,Y,"image",this.config)}async clear(){return J$("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function D9($){if(!a3)a3=new Q$($);else if($)a3.updateConfig($);return a3}async function G$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return D9(X).get($,Z)}async function K$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return D9(J).set($,Z,Y)}async function k9(){return D9().clear()}var NM,a3=null;var S9=D(()=>{s3();NM={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as wM,basename as RM,extname as MM,join as EM}from"path";import{mkdir as TM}from"fs/promises";async function b9(){try{return await import("ts-images")}catch{return null}}function Ez($){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 IM($,Z){let Y=Z?Ez(Z):Ez("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 C9($,Z,Y){let X=await b9();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await G$($,Z,Y);if(J)return J;try{let Q=wM($);if(!await n0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=IM(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await TM(K,{recursive:!0});let U=await i0(Q),_=RM($,MM($)),B=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],z={src:$,processed:!0,variants:[],hash:U},q=null;if(Z.transformations&&Z.transformations.length>0)q=await l5(Q,Z.transformations,X);for(let j of B){let H=G[j]||{},O=`${_}-${U}.${j}`,F=EM(K,O);try{let L=await X.optimizeImage({input:q||Q,output:F,format:j,quality:H.quality,progressive:H.progressive});if(L){if(z.variants.push({path:F,url:`${W}/${O}`,width:L.width||0,height:L.height||0,format:j,size:L.outputSize||0}),!z.originalWidth&&L.width)z.originalWidth=L.width,z.originalHeight=L.height}}catch(L){z.errors=z.errors||[],z.errors.push(`Failed to optimize ${j}: ${L}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);z.placeholder=j.dataUrl}catch(j){z.errors=z.errors||[],z.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});z.dominantColor=j.dominantColor}catch(j){z.errors=z.errors||[],z.errors.push(`Failed to extract dominant color: ${j}`)}return await K$($,Z,z,Y),z}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function P9($,Z,Y,X){let J=await b9();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 l5($,Z,Y){let X=Y||await b9();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 Tz=D(()=>{v4();S9()});import{resolve as DM,basename as kM,extname as SM,join as bM}from"path";import{mkdir as CM}from"fs/promises";async function PM(){try{return await import("ts-images")}catch{return null}}async function o3($,Z,Y){let X=await PM();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=DM($);if(!await n0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||yM,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await CM(K,{recursive:!0});let U=await i0(J),_=kM($,SM($)),B=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},z={src:$,byFormat:{},srcsets:{}};for(let j of G){z.byFormat[j]=[];let H=[];for(let O of Q){let F=`${_}-${O}w-${U}.${j}`,L=bM(K,F),V=`${W}/${F}`;try{let N=B[j]?.quality||80;if(await n0(L)){z.byFormat[j].push({path:L,url:V,width:O,height:0,format:j,size:0}),H.push(`${V} ${O}w`);continue}let A=await X.processImage({input:J,output:L,format:j,quality:N,resize:{width:O}});if(A)z.byFormat[j].push({path:L,url:V,width:O,height:A.height||Math.round(O*(A.height||1)/(A.width||1)),format:j,size:A.outputSize||0}),H.push(`${V} ${O}w`)}catch(N){console.warn(`[stx-media] Failed to generate ${j} at ${O}w: ${N}`)}}z.srcsets[j]=H.join(", ")}let q=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(q!=="none")try{if(q==="thumbhash"){let j=await X.generateThumbHash(J);z.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:q,width:20});z.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:q}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return z.sizes=Z.sizes||xM(Q),z}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function xM($){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 t3($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return $.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}var yM;var Iz=D(()=>{v4();yM=[320,480,640,768,1024,1280,1536,1920]});var Dz={};e(Dz,{setCachedImageResult:()=>K$,processImage:()=>C9,optimizeImage:()=>P9,getCachedImageResult:()=>G$,generateSrcset:()=>t3,generateResponsiveVariants:()=>o3,clearImageCache:()=>k9,applyTransformations:()=>l5,ImageProcessorCache:()=>Q$});var y9=D(()=>{Tz();Iz();S9()});async function vM(){try{return await Promise.resolve().then(() => (y9(),Dz))}catch($){if(!kz)console.warn("[stx-media] Image processor not available, some features disabled:",$),kz=!0;return null}}async function f4($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return dM(X,Y)}if(Y.processedResult?.processed)return h9($,Y.processedResult,Z);if(Y.responsiveVariants)return Pz($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=d1,dpr:_,formats:B=Y4,quality:z=x9,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:O=!0,priority:F=!1,loading:L=F?"eager":$Z,decoding:V=e3,fetchpriority:N,objectFit:A,objectPosition:w,crossorigin:M,referrerpolicy:E}=$,I=$.class,T=$.style,S=$.id,k=$.data||{},{isDev:b=!1,baseUrl:y=""}=Z;if(b&&!Z.optimize)return hM($);let v,C,f=S||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{v=await m5(J,{strategy:j,...H}),C=u5(f,v,H)}catch{}let h=_!==void 0&&G!==void 0,u;if(h)u=fM($,f,v,Z);else u=await gM($,f,v,Z);let l;if(F){let q0=B.includes("webp")?"webp":B[0],f0=x4(J,U,{...q,q:z},q0),D0=typeof W==="object"?o6(W):W||"100vw";l=`<link rel="preload" as="image" imagesrcset="${f0}" imagesizes="${D0}" />`}let i=[];if(!Sz&&j!=="none")i.push(e6),Sz=!0;if(C)i.push(C);let _0=O?Cz(f):void 0;return{html:u,preloadLink:l,css:i.length>0?i.join(`
9104
- `):void 0,script:_0}}async function gM($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=d1,formats:_=Y4,quality:B=x9,params:z={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":$Z,decoding:O=e3,fetchpriority:F,objectFit:L,objectPosition:V,crossorigin:N,referrerpolicy:A}=$,w=$.class,M=$.style,E=$.data||{},I=typeof W==="object"?o6(W):W||"100vw",T=[];for(let b of _){let y=x4(J,U,{...z,q:B},b),v=h5(b);if(q&&!j)T.push(` <source type="${v}" data-srcset="${y}" data-sizes="${I}" />`);else T.push(` <source type="${v}" srcset="${y}" sizes="${I}" />`)}let S=v9({src:T1(J,{...z,q:B}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:O,fetchpriority:j?"high":F,objectFit:L,objectPosition:V,crossorigin:N,referrerpolicy:A,className:bz(w,Y),style:g9(M,L,V,Y),lazy:q&&!j,data:E}),k;if(Y){let b=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;k=`<div id="${Z}" class="stx-img-placeholder" style="${b}">
9103
+ `.trim();t6=new Map});import{createHash as T9}from"crypto";import{readFile as HM,stat as Lz}from"fs/promises";async function i0($){try{let Z=await HM($);return T9("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function Fz($){return T9("sha256").update($).digest("hex").slice(0,16)}function r3($){return T9("sha256").update($).digest("hex").slice(0,16)}function $$($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${r3($)}-${r3(Y)}`}async function c5($){try{return(await Lz($)).mtimeMs}catch{return 0}}async function n0($){try{return await Lz($),!0}catch{return!1}}var v4=()=>{};import{mkdir as OM,readFile as Az,writeFile as LM,readdir as Nz,rm as I9,stat as FM}from"fs/promises";import{join as Z$,dirname as VM}from"path";async function AM($){try{await OM($,{recursive:!0})}catch{}}function wz($,Z,Y){return Z$($,Y,`${Z}.json`)}async function Vz($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await c5(Z)!==$.srcMtime)return!1;return!0}async function Y$($,Z,Y,X=p5){if(!X.enabled)return null;let J=$$($,Z),Q=g4.get(J);if(Q){if(await Vz(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;g4.delete(J)}let G=wz(X.directory,J,Y);if(await n0(G))try{let K=await Az(G,"utf-8"),W=JSON.parse(K);if(await Vz(W,$,X.maxAge))return W.lastAccessedAt=Date.now(),g4.set(J,W),W.data}catch{}return null}async function X$($,Z,Y,X,J=p5){if(!J.enabled)return;let Q=$$($,Z),G=await i0($),K=await c5($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:$$("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};g4.set(Q,W);let U=wz(J.directory,Q,X);try{await AM(VM(U)),await LM(U,JSON.stringify(W,null,2))}catch(_){console.warn(`[stx-media] Failed to write cache: ${_}`)}}async function J$($,Z=p5){if($==="all")g4.clear();else g4.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=Z$(Z.directory,X);try{await I9(J,{recursive:!0,force:!0})}catch{}}}async function Rz($=p5){let Z={memoryEntries:g4.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=Z$($.directory,Y);try{let J=await Nz(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=Z$(X,Q),K=await FM(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function Mz($=p5){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=Z$($.directory,X);try{let Q=await Nz(J);for(let G of Q){let K=Z$(J,G);try{let W=await Az(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await I9(K),g4.delete(U.key),Z++}catch{await I9(K).catch(()=>{}),Z++}}}catch{}}return Z}var g4,p5;var s3=D(()=>{v4();g4=new Map,p5={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class Q${config;constructor($={}){this.config={...NM,...$}}async get($,Z){return Y$($,Z,"image",this.config)}async set($,Z,Y){return X$($,Z,Y,"image",this.config)}async clear(){return J$("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function D9($){if(!a3)a3=new Q$($);else if($)a3.updateConfig($);return a3}async function G$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return D9(X).get($,Z)}async function K$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return D9(J).set($,Z,Y)}async function k9(){return D9().clear()}var NM,a3=null;var S9=D(()=>{s3();NM={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as wM,basename as RM,extname as MM,join as EM}from"path";import{mkdir as TM}from"fs/promises";async function b9(){try{return await import("ts-images")}catch{return null}}function Ez($){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 IM($,Z){let Y=Z?Ez(Z):Ez("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 C9($,Z,Y){let X=await b9();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await G$($,Z,Y);if(J)return J;try{let Q=wM($);if(!await n0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=IM(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await TM(K,{recursive:!0});let U=await i0(Q),_=RM($,MM($)),B=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],z={src:$,processed:!0,variants:[],hash:U},q=null;if(Z.transformations&&Z.transformations.length>0)q=await l5(Q,Z.transformations,X);for(let j of B){let H=G[j]||{},O=`${_}-${U}.${j}`,F=EM(K,O);try{let L=await X.optimizeImage({input:q||Q,output:F,format:j,quality:H.quality,progressive:H.progressive});if(L){if(z.variants.push({path:F,url:`${W}/${O}`,width:L.width||0,height:L.height||0,format:j,size:L.outputSize||0}),!z.originalWidth&&L.width)z.originalWidth=L.width,z.originalHeight=L.height}}catch(L){z.errors=z.errors||[],z.errors.push(`Failed to optimize ${j}: ${L}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);z.placeholder=j.dataUrl}catch(j){z.errors=z.errors||[],z.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});z.dominantColor=j.dominantColor}catch(j){z.errors=z.errors||[],z.errors.push(`Failed to extract dominant color: ${j}`)}return await K$($,Z,z,Y),z}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function P9($,Z,Y,X){let J=await b9();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 l5($,Z,Y){let X=Y||await b9();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 Tz=D(()=>{v4();S9()});import{resolve as DM,basename as kM,extname as SM,join as bM}from"path";import{mkdir as CM}from"fs/promises";async function PM(){try{return await import("ts-images")}catch{return null}}async function o3($,Z,Y){let X=await PM();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=DM($);if(!await n0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||yM,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await CM(K,{recursive:!0});let U=await i0(J),_=kM($,SM($)),B=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},z={src:$,byFormat:{},srcsets:{}};for(let j of G){z.byFormat[j]=[];let H=[];for(let O of Q){let F=`${_}-${O}w-${U}.${j}`,L=bM(K,F),V=`${W}/${F}`;try{let N=B[j]?.quality||80;if(await n0(L)){z.byFormat[j].push({path:L,url:V,width:O,height:0,format:j,size:0}),H.push(`${V} ${O}w`);continue}let A=await X.processImage({input:J,output:L,format:j,quality:N,resize:{width:O}});if(A)z.byFormat[j].push({path:L,url:V,width:O,height:A.height||Math.round(O*(A.height||1)/(A.width||1)),format:j,size:A.outputSize||0}),H.push(`${V} ${O}w`)}catch(N){console.warn(`[stx-media] Failed to generate ${j} at ${O}w: ${N}`)}}z.srcsets[j]=H.join(", ")}let q=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(q!=="none")try{if(q==="thumbhash"){let j=await X.generateThumbHash(J);z.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:q,width:20});z.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:q}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return z.sizes=Z.sizes||xM(Q),z}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function xM($){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 t3($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return $.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}var yM;var Iz=D(()=>{v4();yM=[320,480,640,768,1024,1280,1536,1920]});var Dz={};e(Dz,{setCachedImageResult:()=>K$,processImage:()=>C9,optimizeImage:()=>P9,getCachedImageResult:()=>G$,generateSrcset:()=>t3,generateResponsiveVariants:()=>o3,clearImageCache:()=>k9,applyTransformations:()=>l5,ImageProcessorCache:()=>Q$});var y9=D(()=>{Tz();Iz();S9()});async function vM(){try{return await Promise.resolve().then(() => (y9(),Dz))}catch($){if(!kz)console.warn("[stx-media] Image processor not available, some features disabled:",$),kz=!0;return null}}async function f4($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return dM(X,Y)}if(Y.processedResult?.processed)return h9($,Y.processedResult,Z);if(Y.responsiveVariants)return Pz($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=d1,dpr:_,formats:B=Y4,quality:z=x9,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:O=!0,priority:F=!1,loading:L=F?"eager":$Z,decoding:V=e3,fetchpriority:N,objectFit:A,objectPosition:w,crossorigin:M,referrerpolicy:E}=$,T=$.class,I=$.style,S=$.id,k=$.data||{},{isDev:x=!1,baseUrl:f=""}=Z;if(x&&!Z.optimize)return hM($);let b,C,v=S||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{b=await m5(J,{strategy:j,...H}),C=u5(v,b,H)}catch{}let h=_!==void 0&&G!==void 0,u;if(h)u=fM($,v,b,Z);else u=await gM($,v,b,Z);let p;if(F){let q0=B.includes("webp")?"webp":B[0],f0=x4(J,U,{...q,q:z},q0),D0=typeof W==="object"?o6(W):W||"100vw";p=`<link rel="preload" as="image" imagesrcset="${f0}" imagesizes="${D0}" />`}let i=[];if(!Sz&&j!=="none")i.push(e6),Sz=!0;if(C)i.push(C);let _0=O?Cz(v):void 0;return{html:u,preloadLink:p,css:i.length>0?i.join(`
9104
+ `):void 0,script:_0}}async function gM($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=d1,formats:_=Y4,quality:B=x9,params:z={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":$Z,decoding:O=e3,fetchpriority:F,objectFit:L,objectPosition:V,crossorigin:N,referrerpolicy:A}=$,w=$.class,M=$.style,E=$.data||{},T=typeof W==="object"?o6(W):W||"100vw",I=[];for(let x of _){let f=x4(J,U,{...z,q:B},x),b=h5(x);if(q&&!j)I.push(` <source type="${b}" data-srcset="${f}" data-sizes="${T}" />`);else I.push(` <source type="${b}" srcset="${f}" sizes="${T}" />`)}let S=v9({src:T1(J,{...z,q:B}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:O,fetchpriority:j?"high":F,objectFit:L,objectPosition:V,crossorigin:N,referrerpolicy:A,className:bz(w,Y),style:g9(M,L,V,Y),lazy:q&&!j,data:E}),k;if(Y){let x=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;k=`<div id="${Z}" class="stx-img-placeholder" style="${x}">
9105
9105
  <picture>
9106
- ${T.join(`
9106
+ ${I.join(`
9107
9107
  `)}
9108
9108
  <img ${S} />
9109
9109
  </picture>
9110
9110
  </div>`}else k=`<picture${Z?` id="${Z}"`:""}>
9111
- ${T.join(`
9111
+ ${I.join(`
9112
9112
  `)}
9113
9113
  <img ${S} />
9114
- </picture>`;return k}function fM($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,dpr:W=[1,2,3],quality:U=x9,params:_={},lazy:B=!0,priority:z=!1,loading:q=z?"eager":$Z,decoding:j=e3,fetchpriority:H,objectFit:O,objectPosition:F,crossorigin:L,referrerpolicy:V}=$,N=$.class,A=$.style,w=$.data||{},M=typeof G==="number"?G:Number.parseInt(String(G),10),E=a6(J,M,W,{..._,q:U}),I=v9({src:T1(J,{..._,w:M,q:U}),alt:Q,width:G,height:K,loading:z?void 0:q,decoding:j,fetchpriority:z?"high":H,objectFit:O,objectPosition:F,crossorigin:L,referrerpolicy:V,className:bz(N,Y),style:g9(A,O,F,Y),lazy:B&&!z,data:w}),T=B&&!z?`data-srcset="${E}"`:`srcset="${E}"`;if(Y){let S=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;return`<div id="${Z}" class="stx-img-placeholder" style="${S}">
9115
- <img ${I} ${T} />
9116
- </div>`}return`<img ${Z?`id="${Z}" `:""}${I} ${T} />`}function hM($){let{src:Z,alt:Y,width:X,height:J,loading:Q=$Z,decoding:G=e3,fetchpriority:K,objectFit:W,objectPosition:U,crossorigin:_,referrerpolicy:B,priority:z=!1}=$,q=$.class,j=$.style,H=$.id,O=$.data||{};return{html:`<img ${v9({src:Z,alt:Y,width:X,height:J,loading:z?"eager":Q,decoding:G,fetchpriority:z?"high":K,objectFit:W,objectPosition:U,crossorigin:_,referrerpolicy:B,className:q,style:g9(j,W,U),id:H,data:O})} />`}}function v9($){let Z=[];if($.lazy)Z.push(`data-src="${I1($.src)}"`),Z.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else Z.push(`src="${I1($.src)}"`);if(Z.push(`alt="${I1($.alt)}"`),$.width)Z.push(`width="${$.width}"`);if($.height)Z.push(`height="${$.height}"`);if($.loading)Z.push(`loading="${$.loading}"`);if($.decoding)Z.push(`decoding="${$.decoding}"`);if($.fetchpriority)Z.push(`fetchpriority="${$.fetchpriority}"`);if($.crossorigin)Z.push(`crossorigin="${$.crossorigin}"`);if($.referrerpolicy)Z.push(`referrerpolicy="${$.referrerpolicy}"`);if($.className)Z.push(`class="${I1($.className)}"`);if($.style)Z.push(`style="${I1($.style)}"`);if($.id)Z.push(`id="${I1($.id)}"`);if($.data)for(let[Y,X]of Object.entries($.data))Z.push(`data-${Y}="${I1(X)}"`);if($.lazy)Z.push("data-stx-lazy");return Z.join(" ")}function bz($,Z){let Y=[];if($)Y.push($);if(Z)Y.push("stx-img-blur");return Y.join(" ")||""}function g9($,Z,Y,X){let J=[];if(Z)J.push(`object-fit: ${Z}`);if(Y)J.push(`object-position: ${Y}`);if(X)J.push("opacity: 0; transition: opacity 300ms ease-out");if($)J.push($);return J.join("; ")}function I1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Cz($){return`
9114
+ </picture>`;return k}function fM($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,dpr:W=[1,2,3],quality:U=x9,params:_={},lazy:B=!0,priority:z=!1,loading:q=z?"eager":$Z,decoding:j=e3,fetchpriority:H,objectFit:O,objectPosition:F,crossorigin:L,referrerpolicy:V}=$,N=$.class,A=$.style,w=$.data||{},M=typeof G==="number"?G:Number.parseInt(String(G),10),E=a6(J,M,W,{..._,q:U}),T=v9({src:T1(J,{..._,w:M,q:U}),alt:Q,width:G,height:K,loading:z?void 0:q,decoding:j,fetchpriority:z?"high":H,objectFit:O,objectPosition:F,crossorigin:L,referrerpolicy:V,className:bz(N,Y),style:g9(A,O,F,Y),lazy:B&&!z,data:w}),I=B&&!z?`data-srcset="${E}"`:`srcset="${E}"`;if(Y){let S=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;return`<div id="${Z}" class="stx-img-placeholder" style="${S}">
9115
+ <img ${T} ${I} />
9116
+ </div>`}return`<img ${Z?`id="${Z}" `:""}${T} ${I} />`}function hM($){let{src:Z,alt:Y,width:X,height:J,loading:Q=$Z,decoding:G=e3,fetchpriority:K,objectFit:W,objectPosition:U,crossorigin:_,referrerpolicy:B,priority:z=!1}=$,q=$.class,j=$.style,H=$.id,O=$.data||{};return{html:`<img ${v9({src:Z,alt:Y,width:X,height:J,loading:z?"eager":Q,decoding:G,fetchpriority:z?"high":K,objectFit:W,objectPosition:U,crossorigin:_,referrerpolicy:B,className:q,style:g9(j,W,U),id:H,data:O})} />`}}function v9($){let Z=[];if($.lazy)Z.push(`data-src="${I1($.src)}"`),Z.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else Z.push(`src="${I1($.src)}"`);if(Z.push(`alt="${I1($.alt)}"`),$.width)Z.push(`width="${$.width}"`);if($.height)Z.push(`height="${$.height}"`);if($.loading)Z.push(`loading="${$.loading}"`);if($.decoding)Z.push(`decoding="${$.decoding}"`);if($.fetchpriority)Z.push(`fetchpriority="${$.fetchpriority}"`);if($.crossorigin)Z.push(`crossorigin="${$.crossorigin}"`);if($.referrerpolicy)Z.push(`referrerpolicy="${$.referrerpolicy}"`);if($.className)Z.push(`class="${I1($.className)}"`);if($.style)Z.push(`style="${I1($.style)}"`);if($.id)Z.push(`id="${I1($.id)}"`);if($.data)for(let[Y,X]of Object.entries($.data))Z.push(`data-${Y}="${I1(X)}"`);if($.lazy)Z.push("data-stx-lazy");return Z.join(" ")}function bz($,Z){let Y=[];if($)Y.push($);if(Z)Y.push("stx-img-blur");return Y.join(" ")||""}function g9($,Z,Y,X){let J=[];if(Z)J.push(`object-fit: ${Z}`);if(Y)J.push(`object-position: ${Y}`);if(X)J.push("opacity: 0; transition: opacity 300ms ease-out");if($)J.push($);return J.join("; ")}function I1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Cz($){return`
9117
9117
  (function() {
9118
9118
  const container = document.getElementById('${$}');
9119
9119
  if (!container) return;
@@ -9150,7 +9150,7 @@ ${T.join(`
9150
9150
 
9151
9151
  observer.observe(container);
9152
9152
  })();
9153
- `.trim()}function ZZ($){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,W,U,_]=Q,B=W??U??_??!0;if(G===":"&&typeof B==="string")try{X[K]=JSON.parse(B)}catch{X[K]=B}else switch(K){case"src":X.src=String(B);break;case"alt":X.alt=String(B);break;case"width":X.width=Number(B)||B;break;case"height":X.height=Number(B)||B;break;case"sizes":X.sizes=String(B);break;case"quality":X.quality=Number(B);break;case"placeholder":X.placeholder=B;break;case"lazy":X.lazy=B===!0||B==="true";break;case"priority":X.priority=B===!0||B==="true";break;case"class":X.class=String(B);break;case"style":X.style=String(B);break;case"id":X.id=String(B);break;case"loading":X.loading=B;break;case"decoding":X.decoding=B;break;case"fetchpriority":X.fetchpriority=B;break;case"objectFit":X.objectFit=B;break;case"objectPosition":X.objectPosition=String(B);break;case"crossorigin":X.crossorigin=B;break}}if(!X.src||!X.alt)return null;return X}async function f9($,Z={}){let Y=/<Img\s+[^>]*?\/?>/g,X=[],J=[],Q=[],G=$,K=[],W;while((W=Y.exec($))!==null)K.push({match:W[0],index:W.index});for(let U=K.length-1;U>=0;U--){let{match:_}=K[U],B=ZZ(_);if(B){let z=await f4(B,Z);if(G=G.replace(_,z.html),z.preloadLink)X.push(z.preloadLink);if(z.css)J.push(z.css);if(z.script)Q.push(z.script)}}return{html:G,preloadLinks:X,styles:J,scripts:Q}}async function dM($,Z){let Y=await vM();if(!Y)return f4({...$,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 Pz($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return h9($,Q,Z)}return f4({...$,process:!1},Z)}async function h9($,Z,Y){let{alt:X,width:J,height:Q,lazy:G=!0,priority:K=!1,objectFit:W,objectPosition:U,crossorigin:_,referrerpolicy:B}=$,z=$.class,q=$.style,j=$.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,H=$.data||{},O=Z.variants||[],F=O.find((C)=>C.format==="jpeg")||O.find((C)=>C.format==="webp")||O[0],L=F?.url||$.src,V=O.filter((C)=>C.format===(F?.format||"jpeg")).map((C)=>`${C.url} ${C.width}w`).join(", "),N=new Map;for(let C of O){if(!N.has(C.format))N.set(C.format,[]);N.get(C.format).push(C)}let A=[],w=["avif","webp","jpeg","png"];for(let C of w){let f=N.get(C);if(f&&f.length>0){let h=f.map((l)=>`${l.url} ${l.width}w`).join(", "),u=h5(C);if(G&&!K)A.push(` <source type="${u}" data-srcset="${h}" />`);else A.push(` <source type="${u}" srcset="${h}" />`)}}let M=[];if(G&&!K){if(M.push(`data-src="${I1(L)}"`),M.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),V)M.push(`data-srcset="${V}"`)}else if(M.push(`src="${I1(L)}"`),V)M.push(`srcset="${V}"`);M.push(`alt="${I1(X)}"`);let E=J||Z.originalWidth,I=Q||Z.originalHeight;if(E)M.push(`width="${E}"`);if(I)M.push(`height="${I}"`);if(!K)M.push(`loading="${G?"lazy":"eager"}"`);if(M.push('decoding="async"'),K)M.push('fetchpriority="high"');if(_)M.push(`crossorigin="${_}"`);if(B)M.push(`referrerpolicy="${B}"`);let T=[];if(W)T.push(`object-fit: ${W}`);if(U)T.push(`object-position: ${U}`);if(Z.placeholder&&G)T.push("opacity: 0; transition: opacity 300ms ease-out");if(q)T.push(q);if(T.length>0)M.push(`style="${T.join("; ")}"`);let S=[];if(z)S.push(z);if(Z.placeholder)S.push("stx-img-blur");if(S.length>0)M.push(`class="${S.join(" ")}"`);if(G&&!K)M.push("data-stx-lazy");for(let[C,f]of Object.entries(H))M.push(`data-${C}="${I1(f)}"`);let k;if(Z.placeholder||Z.dominantColor&&$.useDominantColor){let C=Z.placeholder?`background-image: url('${Z.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${Z.dominantColor};`;k=`<div id="${j}" class="stx-img-placeholder" style="${C}">
9153
+ `.trim()}function ZZ($){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,W,U,_]=Q,B=W??U??_??!0;if(G===":"&&typeof B==="string")try{X[K]=JSON.parse(B)}catch{X[K]=B}else switch(K){case"src":X.src=String(B);break;case"alt":X.alt=String(B);break;case"width":X.width=Number(B)||B;break;case"height":X.height=Number(B)||B;break;case"sizes":X.sizes=String(B);break;case"quality":X.quality=Number(B);break;case"placeholder":X.placeholder=B;break;case"lazy":X.lazy=B===!0||B==="true";break;case"priority":X.priority=B===!0||B==="true";break;case"class":X.class=String(B);break;case"style":X.style=String(B);break;case"id":X.id=String(B);break;case"loading":X.loading=B;break;case"decoding":X.decoding=B;break;case"fetchpriority":X.fetchpriority=B;break;case"objectFit":X.objectFit=B;break;case"objectPosition":X.objectPosition=String(B);break;case"crossorigin":X.crossorigin=B;break}}if(!X.src||!X.alt)return null;return X}async function f9($,Z={}){let Y=/<Img\s+[^>]*?\/?>/g,X=[],J=[],Q=[],G=$,K=[],W;while((W=Y.exec($))!==null)K.push({match:W[0],index:W.index});for(let U=K.length-1;U>=0;U--){let{match:_}=K[U],B=ZZ(_);if(B){let z=await f4(B,Z);if(G=G.replace(_,z.html),z.preloadLink)X.push(z.preloadLink);if(z.css)J.push(z.css);if(z.script)Q.push(z.script)}}return{html:G,preloadLinks:X,styles:J,scripts:Q}}async function dM($,Z){let Y=await vM();if(!Y)return f4({...$,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 Pz($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return h9($,Q,Z)}return f4({...$,process:!1},Z)}async function h9($,Z,Y){let{alt:X,width:J,height:Q,lazy:G=!0,priority:K=!1,objectFit:W,objectPosition:U,crossorigin:_,referrerpolicy:B}=$,z=$.class,q=$.style,j=$.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,H=$.data||{},O=Z.variants||[],F=O.find((C)=>C.format==="jpeg")||O.find((C)=>C.format==="webp")||O[0],L=F?.url||$.src,V=O.filter((C)=>C.format===(F?.format||"jpeg")).map((C)=>`${C.url} ${C.width}w`).join(", "),N=new Map;for(let C of O){if(!N.has(C.format))N.set(C.format,[]);N.get(C.format).push(C)}let A=[],w=["avif","webp","jpeg","png"];for(let C of w){let v=N.get(C);if(v&&v.length>0){let h=v.map((p)=>`${p.url} ${p.width}w`).join(", "),u=h5(C);if(G&&!K)A.push(` <source type="${u}" data-srcset="${h}" />`);else A.push(` <source type="${u}" srcset="${h}" />`)}}let M=[];if(G&&!K){if(M.push(`data-src="${I1(L)}"`),M.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),V)M.push(`data-srcset="${V}"`)}else if(M.push(`src="${I1(L)}"`),V)M.push(`srcset="${V}"`);M.push(`alt="${I1(X)}"`);let E=J||Z.originalWidth,T=Q||Z.originalHeight;if(E)M.push(`width="${E}"`);if(T)M.push(`height="${T}"`);if(!K)M.push(`loading="${G?"lazy":"eager"}"`);if(M.push('decoding="async"'),K)M.push('fetchpriority="high"');if(_)M.push(`crossorigin="${_}"`);if(B)M.push(`referrerpolicy="${B}"`);let I=[];if(W)I.push(`object-fit: ${W}`);if(U)I.push(`object-position: ${U}`);if(Z.placeholder&&G)I.push("opacity: 0; transition: opacity 300ms ease-out");if(q)I.push(q);if(I.length>0)M.push(`style="${I.join("; ")}"`);let S=[];if(z)S.push(z);if(Z.placeholder)S.push("stx-img-blur");if(S.length>0)M.push(`class="${S.join(" ")}"`);if(G&&!K)M.push("data-stx-lazy");for(let[C,v]of Object.entries(H))M.push(`data-${C}="${I1(v)}"`);let k;if(Z.placeholder||Z.dominantColor&&$.useDominantColor){let C=Z.placeholder?`background-image: url('${Z.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${Z.dominantColor};`;k=`<div id="${j}" class="stx-img-placeholder" style="${C}">
9154
9154
  <picture>
9155
9155
  ${A.join(`
9156
9156
  `)}
@@ -9160,11 +9160,11 @@ ${A.join(`
9160
9160
  ${A.join(`
9161
9161
  `)}
9162
9162
  <img ${M.join(" ")} />
9163
- </picture>`;let b=[];if(Z.placeholder)b.push(e6);let y=G?Cz(j):void 0,v;if(K&&V)v=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:k,preloadLink:v,css:b.length>0?b.join(`
9164
- `):void 0,script:y}}async function Pz($,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 h9($,X,Y)}var kz=!1,x9=80,e3="async",$Z="lazy",Sz=!1;var d9=D(()=>{i3();E9()});function YZ(){return b0({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,Y,X)=>{let{src:J,alt:Q,options:G}=uM($,Z,Y);if(!J)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:J,alt:Q||"",widths:G.widths||d1,formats:G.formats||Y4,quality:G.quality,sizes:G.sizes,dpr:G.dpr,params:G.params,placeholder:G.placeholder,placeholderOptions:G.placeholderOptions,lazy:G.lazy!==!1,priority:G.priority||!1,loading:G.loading,decoding:G.decoding,fetchpriority:G.fetchpriority,objectFit:G.objectFit,objectPosition:G.objectPosition,class:G.class,style:G.style,id:G.id,width:G.width,height:G.height},W=Y.__isDev||!1,U=await f4(K,{isDev:W}),_=U.html;if(U.preloadLink)_=U.preloadLink+`
9163
+ </picture>`;let x=[];if(Z.placeholder)x.push(e6);let f=G?Cz(j):void 0,b;if(K&&V)b=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:k,preloadLink:b,css:x.length>0?x.join(`
9164
+ `):void 0,script:f}}async function Pz($,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 h9($,X,Y)}var kz=!1,x9=80,e3="async",$Z="lazy",Sz=!1;var d9=D(()=>{i3();E9()});function YZ(){return b0({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,Y,X)=>{let{src:J,alt:Q,options:G}=uM($,Z,Y);if(!J)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:J,alt:Q||"",widths:G.widths||d1,formats:G.formats||Y4,quality:G.quality,sizes:G.sizes,dpr:G.dpr,params:G.params,placeholder:G.placeholder,placeholderOptions:G.placeholderOptions,lazy:G.lazy!==!1,priority:G.priority||!1,loading:G.loading,decoding:G.decoding,fetchpriority:G.fetchpriority,objectFit:G.objectFit,objectPosition:G.objectPosition,class:G.class,style:G.style,id:G.id,width:G.width,height:G.height},W=Y.__isDev||!1,U=await f4(K,{isDev:W}),_=U.html;if(U.preloadLink)_=U.preloadLink+`
9165
9165
  `+_;if(U.css)_+=`
9166
9166
  <style>${U.css}</style>`;if(U.script)_+=`
9167
- <script>${U.script}</script>`;return _},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function uM($,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=mM(X),Q=u9(J[0],Y)||"",G=u9(J[1],Y)||"",K={};if(J[2]){let W=u9(J[2],Y);if(typeof W==="object"&&W!==null)K=W;else if(typeof J[2]==="string")try{K=JSON.parse(J[2])}catch{}}return{src:Q,alt:G,options:K}}function mM($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'"||W==="`")&&U!=="\\"){if(!X)X=!0,J=W;else if(W===J)X=!1,J="";else Y+=W;continue}if(!X){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function u9($,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 i5;var m9=D(()=>{v5();d9();i3();i5=YZ()});class W${config;constructor($={}){this.config={...cM,...$}}async get($,Z){return Y$($,Z,"video",this.config)}async set($,Z,Y){return X$($,Z,Y,"video",this.config)}async clear(){return J$("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function c9($){if(!XZ)XZ=new W$($);else if($)XZ.updateConfig($);return XZ}async function U$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return c9(X).get($,Z)}async function _$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return c9(J).set($,Z,Y)}async function JZ(){return c9().clear()}var cM,XZ=null;var p9=D(()=>{s3();cM={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as l9,basename as i9,extname as n9,join as QZ}from"path";import{mkdir as r9}from"fs/promises";async function s9(){try{return await import("ts-videos")}catch{return null}}async function B$($,Z,Y,X){let J=await s9();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=l9($);if(!await n0(Q))return null;await r9(Y,{recursive:!0});let G=await i0(Q),K=i9($,n9($)),W=Z.format||"webp",U=Z.timestamp||0,_=`${K}-poster-${G}.${W}`,B=QZ(Y,_),z=await J.extractThumbnails(Q,{timestamps:[U],width:Z.width||1280,height:Z.height,format:W,quality:Z.quality||85,outputDir:Y,outputPattern:_.replace(`.${W}`,"")});if(z&&z.length>0){let q=z[0];return{path:B,url:`${X}/${_}`,width:q.width||Z.width||1280,height:q.height||720,timestamp:U,size:q.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function z$($,Z,Y,X){let J=await s9();if(!J)return[];try{let Q=l9($);if(!await n0(Q))return[];await r9(Y,{recursive:!0});let G=await i0(Q),K=i9($,n9($)),W=Z.format||"webp",B=(await new J.Input(Q).getInfo()).duration||60,z=Z.count||10,q=Z.interval||B/z,j=[];for(let O=0;O<z&&O*q<B;O++)j.push(O*q);let H=await J.extractThumbnails(Q,{timestamps:j,width:Z.width||320,format:W,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((O,F)=>({path:O.path||QZ(Y,`${K}-thumb-${G}-${F}.${W}`),url:`${X}/${K}-thumb-${G}-${F}.${W}`,width:O.width||Z.width||320,height:O.height||180,timestamp:j[F],size:O.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function GZ($,Z,Y,X){let J=await s9();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=l9($);if(!await n0(Q))return null;await r9(Y,{recursive:!0});let G=await i0(Q),K=i9($,n9($)),_=(await new J.Input(Q).getInfo()).duration||60,B=Z.columns||10,z=Z.interval||5,q=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",O=Math.ceil(_/z),F=Math.ceil(O/B),L=`${K}-sprite-${G}.${H}`,V=QZ(Y,L),N=[];for(let w=0;w<O;w++)N.push(w*z);let A=await J.extractThumbnails(Q,{timestamps:N,width:q,height:j,format:H,quality:Z.quality||70,outputDir:QZ(Y,".temp")});if(!A||A.length===0)return null;try{let w=await import("ts-images"),M=B*q,E=F*j,I=await w.createSprite({images:A.map((T)=>T.path),columns:B,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${X}/${L}`,path:V,columns:B,rows:F,thumbnailWidth:q,thumbnailHeight:j,interval:z,totalFrames:O}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(Q){return console.warn(`[stx-media] Failed to generate sprite sheet: ${Q}`),null}}var a9=D(()=>{v4()});import{resolve as xz,basename as vz,extname as gz,join as K6}from"path";import{mkdir as KZ,writeFile as fz}from"fs/promises";async function hz(){try{return await import("ts-videos")}catch{return null}}async function q$($,Z,Y,X,J){let Q=await hz();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=xz($);if(!await n0(G))return null;let K=await i0(G),W=vz($,gz($)),U=K6(Y,`${W}-${K}-hls`);await KZ(U,{recursive:!0});let _=Z.length>0?Z:dz,B=J?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,H=[],O=0;for(let V of _){let N=K6(U,V.label);await KZ(N,{recursive:!0});let A=`${V.label}.m3u8`,w=K6(N,A);try{let M=await Q.generateHLS(G,{outputDir:N,segmentDuration:B,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(M)H.push({quality:V,url:`${X}/${W}-${K}-hls/${V.label}/${A}`,path:w}),O+=M.segmentCount||Math.ceil(j/B)}catch(M){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${M}`)}}if(H.length===0)return null;let F=K6(U,"master.m3u8"),L=pM(H,X,W,K);return await fz(F,L),{manifestUrl:`${X}/${W}-${K}-hls/master.m3u8`,manifestPath:F,playlists:H,segmentCount:O,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function pM($,Z,Y,X){let J=["#EXTM3U","#EXT-X-VERSION:3"];for(let Q of $){let{quality:G}=Q,K=G.bitrate+(G.audioBitrate||128000),W=`${G.width}x${G.height||Math.round(G.width*9/16)}`;J.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${W},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return J.join(`
9167
+ <script>${U.script}</script>`;return _},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function uM($,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=mM(X),Q=u9(J[0],Y)||"",G=u9(J[1],Y)||"",K={};if(J[2]){let W=u9(J[2],Y);if(typeof W==="object"&&W!==null)K=W;else if(typeof J[2]==="string")try{K=JSON.parse(J[2])}catch{}}return{src:Q,alt:G,options:K}}function mM($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'"||W==="`")&&U!=="\\"){if(!X)X=!0,J=W;else if(W===J)X=!1,J="";else Y+=W;continue}if(!X){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function u9($,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 i5;var m9=D(()=>{v5();d9();i3();i5=YZ()});class W${config;constructor($={}){this.config={...cM,...$}}async get($,Z){return Y$($,Z,"video",this.config)}async set($,Z,Y){return X$($,Z,Y,"video",this.config)}async clear(){return J$("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function c9($){if(!XZ)XZ=new W$($);else if($)XZ.updateConfig($);return XZ}async function U$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return c9(X).get($,Z)}async function _$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return c9(J).set($,Z,Y)}async function JZ(){return c9().clear()}var cM,XZ=null;var p9=D(()=>{s3();cM={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as l9,basename as i9,extname as n9,join as QZ}from"path";import{mkdir as r9}from"fs/promises";async function s9(){try{return await import("ts-videos")}catch{return null}}async function B$($,Z,Y,X){let J=await s9();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=l9($);if(!await n0(Q))return null;await r9(Y,{recursive:!0});let G=await i0(Q),K=i9($,n9($)),W=Z.format||"webp",U=Z.timestamp||0,_=`${K}-poster-${G}.${W}`,B=QZ(Y,_),z=await J.extractThumbnails(Q,{timestamps:[U],width:Z.width||1280,height:Z.height,format:W,quality:Z.quality||85,outputDir:Y,outputPattern:_.replace(`.${W}`,"")});if(z&&z.length>0){let q=z[0];return{path:B,url:`${X}/${_}`,width:q.width||Z.width||1280,height:q.height||720,timestamp:U,size:q.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function z$($,Z,Y,X){let J=await s9();if(!J)return[];try{let Q=l9($);if(!await n0(Q))return[];await r9(Y,{recursive:!0});let G=await i0(Q),K=i9($,n9($)),W=Z.format||"webp",B=(await new J.Input(Q).getInfo()).duration||60,z=Z.count||10,q=Z.interval||B/z,j=[];for(let O=0;O<z&&O*q<B;O++)j.push(O*q);let H=await J.extractThumbnails(Q,{timestamps:j,width:Z.width||320,format:W,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((O,F)=>({path:O.path||QZ(Y,`${K}-thumb-${G}-${F}.${W}`),url:`${X}/${K}-thumb-${G}-${F}.${W}`,width:O.width||Z.width||320,height:O.height||180,timestamp:j[F],size:O.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function GZ($,Z,Y,X){let J=await s9();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=l9($);if(!await n0(Q))return null;await r9(Y,{recursive:!0});let G=await i0(Q),K=i9($,n9($)),_=(await new J.Input(Q).getInfo()).duration||60,B=Z.columns||10,z=Z.interval||5,q=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",O=Math.ceil(_/z),F=Math.ceil(O/B),L=`${K}-sprite-${G}.${H}`,V=QZ(Y,L),N=[];for(let w=0;w<O;w++)N.push(w*z);let A=await J.extractThumbnails(Q,{timestamps:N,width:q,height:j,format:H,quality:Z.quality||70,outputDir:QZ(Y,".temp")});if(!A||A.length===0)return null;try{let w=await import("ts-images"),M=B*q,E=F*j,T=await w.createSprite({images:A.map((I)=>I.path),columns:B,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${X}/${L}`,path:V,columns:B,rows:F,thumbnailWidth:q,thumbnailHeight:j,interval:z,totalFrames:O}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(Q){return console.warn(`[stx-media] Failed to generate sprite sheet: ${Q}`),null}}var a9=D(()=>{v4()});import{resolve as xz,basename as vz,extname as gz,join as K6}from"path";import{mkdir as KZ,writeFile as fz}from"fs/promises";async function hz(){try{return await import("ts-videos")}catch{return null}}async function q$($,Z,Y,X,J){let Q=await hz();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=xz($);if(!await n0(G))return null;let K=await i0(G),W=vz($,gz($)),U=K6(Y,`${W}-${K}-hls`);await KZ(U,{recursive:!0});let _=Z.length>0?Z:dz,B=J?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,H=[],O=0;for(let V of _){let N=K6(U,V.label);await KZ(N,{recursive:!0});let A=`${V.label}.m3u8`,w=K6(N,A);try{let M=await Q.generateHLS(G,{outputDir:N,segmentDuration:B,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(M)H.push({quality:V,url:`${X}/${W}-${K}-hls/${V.label}/${A}`,path:w}),O+=M.segmentCount||Math.ceil(j/B)}catch(M){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${M}`)}}if(H.length===0)return null;let F=K6(U,"master.m3u8"),L=pM(H,X,W,K);return await fz(F,L),{manifestUrl:`${X}/${W}-${K}-hls/master.m3u8`,manifestPath:F,playlists:H,segmentCount:O,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function pM($,Z,Y,X){let J=["#EXTM3U","#EXT-X-VERSION:3"];for(let Q of $){let{quality:G}=Q,K=G.bitrate+(G.audioBitrate||128000),W=`${G.width}x${G.height||Math.round(G.width*9/16)}`;J.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${W},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return J.join(`
9168
9168
  `)}async function j$($,Z,Y,X,J){let Q=await hz();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=xz($);if(!await n0(G))return null;let K=await i0(G),W=vz($,gz($)),U=K6(Y,`${W}-${K}-dash`);await KZ(U,{recursive:!0});let _=Z.length>0?Z:dz,B=J?.segmentDuration||4,z=J?.minBufferTime||2,H=(await new Q.Input(G).getInfo()).duration||0,O=[],F=[];for(let A of _){let w=K6(U,A.label);await KZ(w,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:w,segmentDuration:B,width:A.width,height:A.height,videoBitrate:A.bitrate,audioBitrate:A.audioBitrate})){if(O.push({bandwidth:A.bitrate,width:A.width,height:A.height||Math.round(A.width*9/16),url:`${X}/${W}-${K}-dash/${A.label}/video`}),A.audioBitrate)F.push({bandwidth:A.audioBitrate,url:`${X}/${W}-${K}-dash/${A.label}/audio`})}}catch(M){console.warn(`[stx-media] Failed to generate DASH for ${A.label}: ${M}`)}}if(O.length===0)return null;let L=K6(U,"manifest.mpd"),V=lM(O,F,H,B,z);await fz(L,V);let N=[{type:"video",representations:O}];if(F.length>0)N.push({type:"audio",representations:F});return{manifestUrl:`${X}/${W}-${K}-dash/manifest.mpd`,manifestPath:L,adaptationSets:N,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function lM($,Z,Y,X,J){let Q=yz(Y),G=yz(J),K=`<?xml version="1.0" encoding="UTF-8"?>
9169
9169
  <MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
9170
9170
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -9191,13 +9191,13 @@ ${A.join(`
9191
9191
  </Representation>
9192
9192
  `}K+=` </AdaptationSet>
9193
9193
  `}return K+=` </Period>
9194
- </MPD>`,K}function yz($){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 dz;var o9=D(()=>{v4();dz=[{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 uz,basename as iM,extname as nM,join as rM}from"path";import{mkdir as sM}from"fs/promises";async function mz(){try{return await import("ts-videos")}catch{return null}}function aM($){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 oM($){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 n5($){let Z=await mz();if(!Z)return null;try{let Y=uz($),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 WZ($,Z,Y,X){let J=await mz();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await U$($,Z,Y);if(Q)return Q;try{let G=uz($);if(!await n0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",W=Y.baseUrl||"/videos";await sM(K,{recursive:!0});let U=await i0(G),_=iM($,nM($)),B={src:$,processed:!0,hash:U};X?.({percentage:5,stage:"analyzing"}),B.metadata=await n5(G)||void 0;let z={};if(Z.quality)z.bitrate=aM(Z.quality);if(Z.platform)Object.assign(z,oM(Z.platform));if(Z.transcode)Object.assign(z,Z.transcode);if(Object.keys(z).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let q=`${_}-${U}.mp4`,j=rM(K,q);try{let H=await tM(G,j,z,J,(O)=>X?.({percentage:10+O*0.5,stage:"transcoding"}));if(H)B.transcoded={path:j,url:`${W}/${q}`,duration:H.duration,size:H.size,video:{codec:z.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:z.audioCodec||"aac",bitrate:z.audioBitrate||128000,sampleRate:z.sampleRate||48000,channels:z.channels||2}:void 0}}catch(H){B.errors=B.errors||[],B.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let q=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await B$(G,q,K,W);if(j)B.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let q=await z$(G,Y.thumbnails,K,W);if(q.length>0)B.thumbnails=q}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let q=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(q.format==="hls"||q.format===void 0){let j=await q$(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)B.streaming={...B.streaming,hls:j}}if(q.format==="dash"){let j=await j$(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)B.streaming={...B.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await _$($,Z,B,Y),B}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function tM($,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 cz=D(()=>{v4();p9();a9();o9()});var pz={};e(pz,{setCachedVideoResult:()=>_$,processVideo:()=>WZ,getCachedVideoResult:()=>U$,generateThumbnails:()=>z$,generateSpriteSheet:()=>GZ,generatePoster:()=>B$,generateHLSManifest:()=>q$,generateDASHManifest:()=>j$,clearVideoCache:()=>JZ,analyzeVideo:()=>n5,VideoProcessorCache:()=>W$});var t9=D(()=>{cz();a9();o9();p9()});async function iz(){try{return await Promise.resolve().then(() => (t9(),pz))}catch($){if(!lz)console.warn("[stx-media] Video processor not available, some features disabled:",$),lz=!0;return null}}async function H$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return JE(X,Y)}if(Y.processedResult?.processed)return oz($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await QE(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=nz,autoplay:_=!1,muted:B=!1,loop:z=!1,preload:q=rz,playsinline:j=!0,lazy:H=!0,player:O="native",type:F,width:L,height:V,crossorigin:N,disablePictureInPicture:A=!1,disableRemotePlayback:w=!1}=$,M=J||K,E=$.class,I=$.style,T=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(O==="ts-video")return ZE($,Z);if(F&&F!=="video")return $E(Q||"",F,$);let S=G.length>0?G:Q?[{src:Q,type:sz(Q)}]:[],k=[`id="${T}"`];if(U)k.push("controls");if(_)k.push("autoplay");if(B)k.push("muted");if(z)k.push("loop");if(j)k.push("playsinline");if(A)k.push("disablepictureinpicture");if(w)k.push("disableremoteplayback");if(N)k.push(`crossorigin="${N}"`);if(H){if(k.push(`data-preload="${q}"`),k.push('preload="none"'),M)k.push(`data-poster="${d0(M)}"`);k.push("data-stx-lazy")}else if(k.push(`preload="${q}"`),M)k.push(`poster="${d0(M)}"`);if(L)k.push(`width="${L}"`);if(V)k.push(`height="${V}"`);if(E)k.push(`class="${d0(E)}"`);if(I)k.push(`style="${d0(I)}"`);let b=S.map((C)=>{return` <source ${H?`data-src="${d0(C.src)}"`:`src="${d0(C.src)}"`} type="${C.type}"${C.media?` media="${C.media}"`:""} />`}).join(`
9195
- `),y=`<video ${k.join(" ")}>
9196
- ${b}
9194
+ </MPD>`,K}function yz($){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 dz;var o9=D(()=>{v4();dz=[{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 uz,basename as iM,extname as nM,join as rM}from"path";import{mkdir as sM}from"fs/promises";async function mz(){try{return await import("ts-videos")}catch{return null}}function aM($){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 oM($){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 n5($){let Z=await mz();if(!Z)return null;try{let Y=uz($),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 WZ($,Z,Y,X){let J=await mz();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await U$($,Z,Y);if(Q)return Q;try{let G=uz($);if(!await n0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",W=Y.baseUrl||"/videos";await sM(K,{recursive:!0});let U=await i0(G),_=iM($,nM($)),B={src:$,processed:!0,hash:U};X?.({percentage:5,stage:"analyzing"}),B.metadata=await n5(G)||void 0;let z={};if(Z.quality)z.bitrate=aM(Z.quality);if(Z.platform)Object.assign(z,oM(Z.platform));if(Z.transcode)Object.assign(z,Z.transcode);if(Object.keys(z).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let q=`${_}-${U}.mp4`,j=rM(K,q);try{let H=await tM(G,j,z,J,(O)=>X?.({percentage:10+O*0.5,stage:"transcoding"}));if(H)B.transcoded={path:j,url:`${W}/${q}`,duration:H.duration,size:H.size,video:{codec:z.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:z.audioCodec||"aac",bitrate:z.audioBitrate||128000,sampleRate:z.sampleRate||48000,channels:z.channels||2}:void 0}}catch(H){B.errors=B.errors||[],B.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let q=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await B$(G,q,K,W);if(j)B.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let q=await z$(G,Y.thumbnails,K,W);if(q.length>0)B.thumbnails=q}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let q=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(q.format==="hls"||q.format===void 0){let j=await q$(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)B.streaming={...B.streaming,hls:j}}if(q.format==="dash"){let j=await j$(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)B.streaming={...B.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await _$($,Z,B,Y),B}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function tM($,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 cz=D(()=>{v4();p9();a9();o9()});var pz={};e(pz,{setCachedVideoResult:()=>_$,processVideo:()=>WZ,getCachedVideoResult:()=>U$,generateThumbnails:()=>z$,generateSpriteSheet:()=>GZ,generatePoster:()=>B$,generateHLSManifest:()=>q$,generateDASHManifest:()=>j$,clearVideoCache:()=>JZ,analyzeVideo:()=>n5,VideoProcessorCache:()=>W$});var t9=D(()=>{cz();a9();o9();p9()});async function iz(){try{return await Promise.resolve().then(() => (t9(),pz))}catch($){if(!lz)console.warn("[stx-media] Video processor not available, some features disabled:",$),lz=!0;return null}}async function H$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return JE(X,Y)}if(Y.processedResult?.processed)return oz($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await QE(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=nz,autoplay:_=!1,muted:B=!1,loop:z=!1,preload:q=rz,playsinline:j=!0,lazy:H=!0,player:O="native",type:F,width:L,height:V,crossorigin:N,disablePictureInPicture:A=!1,disableRemotePlayback:w=!1}=$,M=J||K,E=$.class,T=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(O==="ts-video")return ZE($,Z);if(F&&F!=="video")return $E(Q||"",F,$);let S=G.length>0?G:Q?[{src:Q,type:sz(Q)}]:[],k=[`id="${I}"`];if(U)k.push("controls");if(_)k.push("autoplay");if(B)k.push("muted");if(z)k.push("loop");if(j)k.push("playsinline");if(A)k.push("disablepictureinpicture");if(w)k.push("disableremoteplayback");if(N)k.push(`crossorigin="${N}"`);if(H){if(k.push(`data-preload="${q}"`),k.push('preload="none"'),M)k.push(`data-poster="${d0(M)}"`);k.push("data-stx-lazy")}else if(k.push(`preload="${q}"`),M)k.push(`poster="${d0(M)}"`);if(L)k.push(`width="${L}"`);if(V)k.push(`height="${V}"`);if(E)k.push(`class="${d0(E)}"`);if(T)k.push(`style="${d0(T)}"`);let x=S.map((C)=>{return` <source ${H?`data-src="${d0(C.src)}"`:`src="${d0(C.src)}"`} type="${C.type}"${C.media?` media="${C.media}"`:""} />`}).join(`
9195
+ `),f=`<video ${k.join(" ")}>
9196
+ ${x}
9197
9197
  Your browser does not support the video tag.
9198
- </video>`,v;if(H)v=`
9198
+ </video>`,b;if(H)b=`
9199
9199
  (function() {
9200
- var video = document.getElementById('${T}');
9200
+ var video = document.getElementById('${I}');
9201
9201
  if (!video) return;
9202
9202
 
9203
9203
  var observer = new IntersectionObserver(function(entries) {
@@ -9230,7 +9230,7 @@ ${b}
9230
9230
 
9231
9231
  observer.observe(video);
9232
9232
  })();
9233
- `.trim();return{html:y,script:v}}function $E($,Z,Y){let{width:X=640,height:J=360}=Y,Q=Y.class,G=Y.style,K=Y.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,W,U=null;switch(Z){case"youtube":U=YE($),W=U?`https://www.youtube-nocookie.com/embed/${U}`:$;break;case"vimeo":U=XE($),W=U?`https://player.vimeo.com/video/${U}`:$;break;case"dailymotion":U=$.split("/").pop()||"",W=`https://www.dailymotion.com/embed/video/${U}`;break;case"twitch":U=$.split("/").pop()||"",W=`https://player.twitch.tv/?video=${U}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:W=$}let _=[`id="${K}"`,`src="${d0(W)}"`,`width="${X}"`,`height="${J}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(Q)_.push(`class="${d0(Q)}"`);if(G)_.push(`style="${d0(G)}"`);if(Y.lazy)_.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
9233
+ `.trim();return{html:f,script:b}}function $E($,Z,Y){let{width:X=640,height:J=360}=Y,Q=Y.class,G=Y.style,K=Y.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,W,U=null;switch(Z){case"youtube":U=YE($),W=U?`https://www.youtube-nocookie.com/embed/${U}`:$;break;case"vimeo":U=XE($),W=U?`https://player.vimeo.com/video/${U}`:$;break;case"dailymotion":U=$.split("/").pop()||"",W=`https://www.dailymotion.com/embed/video/${U}`;break;case"twitch":U=$.split("/").pop()||"",W=`https://player.twitch.tv/?video=${U}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:W=$}let _=[`id="${K}"`,`src="${d0(W)}"`,`width="${X}"`,`height="${J}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(Q)_.push(`class="${d0(Q)}"`);if(G)_.push(`style="${d0(G)}"`);if(Y.lazy)_.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
9234
9234
  <iframe ${_.join(" ")} style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
9235
9235
  </div>`}}function ZE($,Z={}){let{src:Y,sources:X=[],poster:J,controls:Q=!0,autoplay:G=!1,muted:K=!1,loop:W=!1,preload:U="metadata",playsinline:_=!0,lazy:B=!0,width:z,height:q}=$,j=$.class,H=$.style,O=$.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,F={src:X.length>0?X:Y,autoplay:G,loop:W,muted:K,playsinline:_,preload:U,poster:J,controls:Q,title:$.title},L=["position: relative",z?`width: ${typeof z==="number"?z+"px":z}`:"width: 100%",q?`height: ${typeof q==="number"?q+"px":q}`:"",H||""].filter(Boolean).join("; "),V=`
9236
9236
  <div
@@ -9399,8 +9399,8 @@ else {
9399
9399
  .ts-video-player__play-button svg {
9400
9400
  margin-left: 4px;
9401
9401
  }
9402
- `.trim();return{html:V,script:N,css:A}}function sz($){switch($.split(".").pop()?.toLowerCase()){case"mp4":return"video/mp4";case"webm":return"video/webm";case"ogg":case"ogv":return"video/ogg";case"mov":return"video/quicktime";case"avi":return"video/x-msvideo";case"mkv":return"video/x-matroska";case"m3u8":return"application/x-mpegURL";default:return"video/mp4"}}function YE($){let Z=[/youtube\.com\/watch\?v=([^&]+)/,/youtube\.com\/embed\/([^?]+)/,/youtu\.be\/([^?]+)/,/youtube\.com\/v\/([^?]+)/];for(let Y of Z){let X=$.match(Y);if(X)return X[1]}return null}function XE($){let Z=$.match(/vimeo\.com\/(\d+)/);return Z?Z[1]:null}function d0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function az($,Z,Y){if(Z.src)return{src:String(Z.src),...Z};let X=$.trim();if(X.startsWith("@video(")||X.startsWith("("))X=X.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let J=X.indexOf(",");if(J===-1)return{src:X.replace(/^['"]|['"]$/g,"")};let Q=X.slice(0,J).trim().replace(/^['"]|['"]$/g,""),G=X.slice(J+1).trim();try{let K=JSON.parse(G);return{src:Q,...K}}catch{return{src:Q}}}async function JE($,Z){let Y=await iz();if(!Y)return H$({...$,process:!1},Z);let X=Z.tsVideosConfig,J=await Y.processVideo($.src,$,X,$.onProcessProgress);if(J.processed)return oz($,J,Z);return H$({...$,process:!1},Z)}async function QE($,Z){let Y=await iz();if(!Y||!$.src)return;let X=typeof $.generatePoster==="object"?$.generatePoster:{timestamp:0},J=Z.tsVideosConfig||{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos"};return(await Y.generatePoster($.src,X,J.outputDir,J.baseUrl||"/videos"))?.url}function oz($,Z,Y){let{controls:X=nz,autoplay:J=!1,muted:Q=!1,loop:G=!1,preload:K=rz,playsinline:W=!0,lazy:U=!0,width:_,height:B,crossorigin:z,disablePictureInPicture:q=!1,disableRemotePlayback:j=!1}=$,H=$.class,O=$.style,F=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`,L=$.src,V=sz(L);if(Z.transcoded)L=Z.transcoded.url,V="video/mp4";let N=Z.streaming?.hls||Z.streaming?.dash;if(N){if(Z.streaming?.hls)L=Z.streaming.hls.manifestUrl,V="application/x-mpegURL";else if(Z.streaming?.dash)L=Z.streaming.dash.manifestUrl,V="application/dash+xml"}let A=Z.poster?.url||$.poster,w=[`id="${F}"`];if(X)w.push("controls");if(J)w.push("autoplay");if(Q)w.push("muted");if(G)w.push("loop");if(W)w.push("playsinline");if(q)w.push("disablepictureinpicture");if(j)w.push("disableremoteplayback");if(z)w.push(`crossorigin="${z}"`);if(U){if(w.push(`data-preload="${K}"`),w.push('preload="none"'),A)w.push(`data-poster="${d0(A)}"`);w.push("data-stx-lazy")}else if(w.push(`preload="${K}"`),A)w.push(`poster="${d0(A)}"`);let M=_||Z.metadata?.width,E=B||Z.metadata?.height;if(M)w.push(`width="${M}"`);if(E)w.push(`height="${E}"`);if(H)w.push(`class="${d0(H)}"`);if(O)w.push(`style="${d0(O)}"`);let T=` <source ${U?`data-src="${d0(L)}"`:`src="${d0(L)}"`} type="${V}" />`,S=`<video ${w.join(" ")}>
9403
- ${T}
9402
+ `.trim();return{html:V,script:N,css:A}}function sz($){switch($.split(".").pop()?.toLowerCase()){case"mp4":return"video/mp4";case"webm":return"video/webm";case"ogg":case"ogv":return"video/ogg";case"mov":return"video/quicktime";case"avi":return"video/x-msvideo";case"mkv":return"video/x-matroska";case"m3u8":return"application/x-mpegURL";default:return"video/mp4"}}function YE($){let Z=[/youtube\.com\/watch\?v=([^&]+)/,/youtube\.com\/embed\/([^?]+)/,/youtu\.be\/([^?]+)/,/youtube\.com\/v\/([^?]+)/];for(let Y of Z){let X=$.match(Y);if(X)return X[1]}return null}function XE($){let Z=$.match(/vimeo\.com\/(\d+)/);return Z?Z[1]:null}function d0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function az($,Z,Y){if(Z.src)return{src:String(Z.src),...Z};let X=$.trim();if(X.startsWith("@video(")||X.startsWith("("))X=X.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let J=X.indexOf(",");if(J===-1)return{src:X.replace(/^['"]|['"]$/g,"")};let Q=X.slice(0,J).trim().replace(/^['"]|['"]$/g,""),G=X.slice(J+1).trim();try{let K=JSON.parse(G);return{src:Q,...K}}catch{return{src:Q}}}async function JE($,Z){let Y=await iz();if(!Y)return H$({...$,process:!1},Z);let X=Z.tsVideosConfig,J=await Y.processVideo($.src,$,X,$.onProcessProgress);if(J.processed)return oz($,J,Z);return H$({...$,process:!1},Z)}async function QE($,Z){let Y=await iz();if(!Y||!$.src)return;let X=typeof $.generatePoster==="object"?$.generatePoster:{timestamp:0},J=Z.tsVideosConfig||{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos"};return(await Y.generatePoster($.src,X,J.outputDir,J.baseUrl||"/videos"))?.url}function oz($,Z,Y){let{controls:X=nz,autoplay:J=!1,muted:Q=!1,loop:G=!1,preload:K=rz,playsinline:W=!0,lazy:U=!0,width:_,height:B,crossorigin:z,disablePictureInPicture:q=!1,disableRemotePlayback:j=!1}=$,H=$.class,O=$.style,F=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`,L=$.src,V=sz(L);if(Z.transcoded)L=Z.transcoded.url,V="video/mp4";let N=Z.streaming?.hls||Z.streaming?.dash;if(N){if(Z.streaming?.hls)L=Z.streaming.hls.manifestUrl,V="application/x-mpegURL";else if(Z.streaming?.dash)L=Z.streaming.dash.manifestUrl,V="application/dash+xml"}let A=Z.poster?.url||$.poster,w=[`id="${F}"`];if(X)w.push("controls");if(J)w.push("autoplay");if(Q)w.push("muted");if(G)w.push("loop");if(W)w.push("playsinline");if(q)w.push("disablepictureinpicture");if(j)w.push("disableremoteplayback");if(z)w.push(`crossorigin="${z}"`);if(U){if(w.push(`data-preload="${K}"`),w.push('preload="none"'),A)w.push(`data-poster="${d0(A)}"`);w.push("data-stx-lazy")}else if(w.push(`preload="${K}"`),A)w.push(`poster="${d0(A)}"`);let M=_||Z.metadata?.width,E=B||Z.metadata?.height;if(M)w.push(`width="${M}"`);if(E)w.push(`height="${E}"`);if(H)w.push(`class="${d0(H)}"`);if(O)w.push(`style="${d0(O)}"`);let I=` <source ${U?`data-src="${d0(L)}"`:`src="${d0(L)}"`} type="${V}" />`,S=`<video ${w.join(" ")}>
9403
+ ${I}
9404
9404
  Your browser does not support the video tag.
9405
9405
  </video>`;if(Z.spriteSheet)S=`<div class="stx-video-wrapper" data-sprite-sheet="${d0(Z.spriteSheet.url)}" data-sprite-cols="${Z.spriteSheet.columns}" data-sprite-interval="${Z.spriteSheet.interval}">
9406
9406
  ${S}
@@ -9439,7 +9439,7 @@ ${S}
9439
9439
 
9440
9440
  observer.observe(video);
9441
9441
  })();
9442
- `.trim();let b;if(N)b=`
9442
+ `.trim();let x;if(N)x=`
9443
9443
  .stx-video-wrapper {
9444
9444
  position: relative;
9445
9445
  width: 100%;
@@ -9448,7 +9448,7 @@ ${S}
9448
9448
  width: 100%;
9449
9449
  height: auto;
9450
9450
  }
9451
- `.trim();return{html:S,script:k,css:b}}var lz=!1,nz=!0,rz="metadata",eM="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";var e9=D(()=>{$2()});function UZ(){return b0({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async($,Z,Y,X)=>{let{src:J,options:Q}=GE($,Z,Y);if(!J)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let G={src:J,poster:Q.poster,controls:Q.controls!==!1,autoplay:Q.autoplay||!1,muted:Q.muted||!1,loop:Q.loop||!1,preload:Q.preload||"metadata",playsinline:Q.playsinline!==!1,lazy:Q.lazy!==!1,player:Q.player||"native",type:Q.type,width:Q.width,height:Q.height,class:Q.class,style:Q.style,id:Q.id,crossorigin:Q.crossorigin,disablePictureInPicture:Q.disablePictureInPicture,disableRemotePlayback:Q.disableRemotePlayback,title:Q.title,quality:Q.quality,platform:Q.platform,process:Q.process,generatePoster:Q.generatePoster,streaming:Q.streaming,transcode:Q.transcode,spriteSheet:Q.spriteSheet,waveform:Q.waveform},W={isDev:Y.__isDev||!1,tsVideosConfig:Y.__tsVideosConfig},U=await H$(G,W),_=U.html;if(U.css)_+=`
9451
+ `.trim();return{html:S,script:k,css:x}}var lz=!1,nz=!0,rz="metadata",eM="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";var e9=D(()=>{$2()});function UZ(){return b0({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async($,Z,Y,X)=>{let{src:J,options:Q}=GE($,Z,Y);if(!J)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let G={src:J,poster:Q.poster,controls:Q.controls!==!1,autoplay:Q.autoplay||!1,muted:Q.muted||!1,loop:Q.loop||!1,preload:Q.preload||"metadata",playsinline:Q.playsinline!==!1,lazy:Q.lazy!==!1,player:Q.player||"native",type:Q.type,width:Q.width,height:Q.height,class:Q.class,style:Q.style,id:Q.id,crossorigin:Q.crossorigin,disablePictureInPicture:Q.disablePictureInPicture,disableRemotePlayback:Q.disableRemotePlayback,title:Q.title,quality:Q.quality,platform:Q.platform,process:Q.process,generatePoster:Q.generatePoster,streaming:Q.streaming,transcode:Q.transcode,spriteSheet:Q.spriteSheet,waveform:Q.waveform},W={isDev:Y.__isDev||!1,tsVideosConfig:Y.__tsVideosConfig},U=await H$(G,W),_=U.html;if(U.css)_+=`
9452
9452
  <style>${U.css}</style>`;if(U.script)_+=`
9453
9453
  <script>${U.script}</script>`;return _},defaults:{src:"",options:{controls:!0,lazy:!0,preload:"metadata"}}})}function GE($,Z,Y){if(Z.src)return{src:String(Z.src),options:Z.options||{}};let X=$.trim();if(X.startsWith("@video(")||X.startsWith("("))X=X.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let J=KE(X),Q=tz(J[0],Y)||"",G={};if(J[1]){let K=tz(J[1],Y);if(typeof K==="object"&&K!==null)G=K;else if(typeof J[1]==="string")try{G=JSON.parse(J[1])}catch{}}return{src:Q,options:G}}function KE($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'"||W==="`")&&U!=="\\"){if(!X)X=!0,J=W;else if(W===J)X=!1,J="";else Y+=W;continue}if(!X){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function tz($,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 r5;var $2=D(()=>{v5();e9();r5=UZ()});function WE($,Z){let Y=Z.pwa?.manifest?.themeColor||"#4f46e5";return`<div class="stx-pwa-install" style="display:none;">
9454
9454
  ${$}
@@ -9982,15 +9982,15 @@ declare global {
9982
9982
  customElements.define('${Y}', ${_});
9983
9983
  `}function _Z($){let Z=$.split("").reduce((Y,X)=>(Y<<5)-Y+X.charCodeAt(0)|0,0);return Math.abs(Z).toString(36).slice(0,8)}function Zq($,Z,Y={}){let X={...Y2,...Y},J=_Z(Z);switch(X.strategy){case"shadow":return $;case"prefix":return NE($,X.prefix||Z,X.preserveOriginal);case"attribute":return AE($,J,X.attributeName||"data-v",X.preserveOriginal);case"bem":return wE($,Z,X.preserveOriginal);default:return $}}function AE($,Z,Y,X){let J=`[${Y}-${Z}]`;return $.replace(/([.#]?[\w-]+|\*)\s*(\{|,)/g,(Q,G,K)=>{if(G.startsWith("@"))return Q;if(/^(?::root|:host|html|body)$/i.test(G))return Q;return`${X?`${G}${J}`:`${G}${J}`}${K}`})}function NE($,Z,Y){return $.replace(/\.([a-z_][\w-]*)/gi,(X,J)=>{if(J.startsWith(Z))return X;let Q=`${Z}__${J}`;return Y?`.${Q}`:`.${Q}`})}function wE($,Z,Y){let X=Z.replace(/[^a-z0-9]/gi,"-");return $.replace(/\.([a-z_][\w-]*)/gi,(J,Q)=>{if(Q.includes("__")||Q.includes("--")){if(!Q.startsWith(X))return`.${X}__${Q}`;return J}let G=`${X}__${Q}`;return Y?`.${G}`:`.${G}`})}function Yq($,Z,Y={}){let X={...Y2,...Y};if(X.strategy==="shadow")return $;if(X.strategy==="attribute"){let J=_Z(Z),G=`${X.attributeName||"data-v"}-${J}`;return $.replace(/<([a-z][a-z0-9-]*)([^>]*)>/gi,(K,W,U)=>{if(/^(?:script|style|!--)$/i.test(W))return K;let _=U.trimEnd().endsWith("/"),B=_?U.slice(0,-1):U;return`<${W}${B} ${G}${_?"/":""}>`})}if(X.strategy==="prefix"||X.strategy==="bem"){let J=X.strategy==="bem"?Z.replace(/[^a-z0-9]/gi,"-"):X.prefix||Z;return $.replace(/\bclass\s*=\s*["']([^"']+)["']/gi,(Q,G)=>{return`class="${G.split(/\s+/).map((W)=>{if(!W)return W;if(W.startsWith(J))return W;return`${J}__${W}`}).join(" ")}"`})}return $}function RE($,Z={}){let Y={...Y2,...Z},X=_Z($);return`${Y.attributeName||"data-v"}-${X}`}function ME($,Z,Y={}){let X="",J=$.replace(/<style([^>]*)>([\s\S]*?)<\/style>/gi,(G,K,W)=>{if(/\bscoped\b/i.test(K)||Y.strategy!=="shadow")X+=`${Zq(W,Z,Y)}
9984
9984
  `;else X+=`${W}
9985
- `;return""});return{html:Yq(J,Z,Y),css:X.trim()}}function O$($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function EE($){let{name:Z,tag:Y,baseElement:X="HTMLElement",template:J,styles:Q="",shadowDOM:G=!0,properties:K={},lifecycle:W={},events:U={},methods:_={},state:B={}}=$,z=Z.replace(/\W/g,""),q=Object.keys(K),j=q.filter((E)=>K[E].attribute!==!1).map((E)=>K[E].attribute||O$(E)),H=q.map((E)=>{let I=K[E],T=I.default!==void 0?JSON.stringify(I.default):I.type==="string"?'""':I.type==="number"?"0":I.type==="boolean"?"false":I.type==="array"?"[]":"{}";return` this._${E} = ${T};`}).join(`
9986
- `),O=q.map((E)=>{let I=K[E],T=I.attribute!==!1?I.attribute||O$(E):null,S=I.reflect&&T?`
9985
+ `;return""});return{html:Yq(J,Z,Y),css:X.trim()}}function O$($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function EE($){let{name:Z,tag:Y,baseElement:X="HTMLElement",template:J,styles:Q="",shadowDOM:G=!0,properties:K={},lifecycle:W={},events:U={},methods:_={},state:B={}}=$,z=Z.replace(/\W/g,""),q=Object.keys(K),j=q.filter((E)=>K[E].attribute!==!1).map((E)=>K[E].attribute||O$(E)),H=q.map((E)=>{let T=K[E],I=T.default!==void 0?JSON.stringify(T.default):T.type==="string"?'""':T.type==="number"?"0":T.type==="boolean"?"false":T.type==="array"?"[]":"{}";return` this._${E} = ${I};`}).join(`
9986
+ `),O=q.map((E)=>{let T=K[E],I=T.attribute!==!1?T.attribute||O$(E):null,S=T.reflect&&I?`
9987
9987
  if (value !== null && value !== undefined) {
9988
- ${I.type==="boolean"?`if (value) { this.setAttribute('${T}', ''); }
9989
- else { this.removeAttribute('${T}'); }`:`this.setAttribute('${T}', ${I.type==="object"||I.type==="array"?"JSON.stringify(value)":"String(value)"});`}
9988
+ ${T.type==="boolean"?`if (value) { this.setAttribute('${I}', ''); }
9989
+ else { this.removeAttribute('${I}'); }`:`this.setAttribute('${I}', ${T.type==="object"||T.type==="array"?"JSON.stringify(value)":"String(value)"});`}
9990
9990
  }
9991
9991
  else {
9992
- this.removeAttribute('${T}');
9993
- }`:"",k=I.observer?`this.${I.observer}(value, oldValue);`:"",b=I.render!==!1?"this._scheduleRender();":"";return`
9992
+ this.removeAttribute('${I}');
9993
+ }`:"",k=T.observer?`this.${T.observer}(value, oldValue);`:"",x=T.render!==!1?"this._scheduleRender();":"";return`
9994
9994
  get ${E}() {
9995
9995
  return this._${E};
9996
9996
  }
@@ -10000,7 +10000,7 @@ else {
10000
10000
  if (oldValue === value) return;
10001
10001
  this._${E} = value;${S}
10002
10002
  ${k}
10003
- ${b}
10003
+ ${x}
10004
10004
  this.dispatchEvent(new CustomEvent('${E}-changed', {
10005
10005
  detail: { value, oldValue },
10006
10006
  bubbles: true
@@ -10019,10 +10019,10 @@ else {
10019
10019
  this[propName] = this._deserializeAttribute(newValue, propDef.type);
10020
10020
  }
10021
10021
  ${W.attributeChanged||""}
10022
- }`:"",L=Object.entries(U).map(([E,I])=>{return`this._root.addEventListener('${E}', (e) => { ${I} });`}).join(`
10023
- `),V=Object.entries(_).map(([E,I])=>{return`
10022
+ }`:"",L=Object.entries(U).map(([E,T])=>{return`this._root.addEventListener('${E}', (e) => { ${T} });`}).join(`
10023
+ `),V=Object.entries(_).map(([E,T])=>{return`
10024
10024
  ${E}() {
10025
- ${I}
10025
+ ${T}
10026
10026
  }`}).join(`
10027
10027
  `),N=JSON.stringify(Object.fromEntries(q.map((E)=>[E,K[E]]))),A=JSON.stringify(Object.fromEntries(q.filter((E)=>K[E].attribute!==!1).map((E)=>[K[E].attribute||O$(E),E]))),w=J.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),M=Q.replace(/\\/g,"\\\\").replace(/`/g,"\\`");return`/**
10028
10028
  * ${Z} - Reactive Web Component
@@ -10184,12 +10184,12 @@ customElements.define('${Y}', ${z});
10184
10184
  // Export for module usage
10185
10185
  export { ${z} };
10186
10186
  export default ${z};
10187
- `}function TE($){let{name:Z,tag:Y,baseElement:X="HTMLElement",template:J,styles:Q="",shadowDOM:G=!0,properties:K={},lifecycle:W={},events:U={},methods:_={},state:B={}}=$,z=Z.replace(/\W/g,""),q=Object.keys(K),j=q.filter((I)=>K[I].attribute!==!1).map((I)=>K[I].attribute||O$(I)),H=(I)=>{switch(I){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":return"Record<string, unknown>";case"array":return"unknown[]";default:return"unknown"}},O=q.length>0?`
10187
+ `}function TE($){let{name:Z,tag:Y,baseElement:X="HTMLElement",template:J,styles:Q="",shadowDOM:G=!0,properties:K={},lifecycle:W={},events:U={},methods:_={},state:B={}}=$,z=Z.replace(/\W/g,""),q=Object.keys(K),j=q.filter((T)=>K[T].attribute!==!1).map((T)=>K[T].attribute||O$(T)),H=(T)=>{switch(T){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":return"Record<string, unknown>";case"array":return"unknown[]";default:return"unknown"}},O=q.length>0?`
10188
10188
  /**
10189
10189
  * Props interface for ${Z}
10190
10190
  */
10191
10191
  export interface ${z}Props {
10192
- ${q.map((I)=>` ${I}?: ${H(K[I].type)};`).join(`
10192
+ ${q.map((T)=>` ${T}?: ${H(K[T].type)};`).join(`
10193
10193
  `)}
10194
10194
  }
10195
10195
  `:"",F=Object.keys(B).length>0?`
@@ -10197,42 +10197,42 @@ ${q.map((I)=>` ${I}?: ${H(K[I].type)};`).join(`
10197
10197
  * State interface for ${Z}
10198
10198
  */
10199
10199
  export interface ${z}State {
10200
- ${Object.entries(B).map(([I,T])=>` ${I}: ${typeof T};`).join(`
10200
+ ${Object.entries(B).map(([T,I])=>` ${T}: ${typeof I};`).join(`
10201
10201
  `)}
10202
10202
  }
10203
10203
  `:`
10204
10204
  export interface ${z}State {
10205
10205
  [key: string]: unknown;
10206
10206
  }
10207
- `,L=q.map((I)=>{let T=K[I],S=H(T.type);return` private _${I}: ${S};`}).join(`
10208
- `),V=q.map((I)=>{let T=K[I],S=H(T.type),k=T.attribute!==!1?T.attribute||O$(I):null,b=T.default!==void 0?JSON.stringify(T.default):T.type==="string"?'""':T.type==="number"?"0":T.type==="boolean"?"false":T.type==="array"?"[]":"{}",y=T.reflect&&k?`
10207
+ `,L=q.map((T)=>{let I=K[T],S=H(I.type);return` private _${T}: ${S};`}).join(`
10208
+ `),V=q.map((T)=>{let I=K[T],S=H(I.type),k=I.attribute!==!1?I.attribute||O$(T):null,x=I.default!==void 0?JSON.stringify(I.default):I.type==="string"?'""':I.type==="number"?"0":I.type==="boolean"?"false":I.type==="array"?"[]":"{}",f=I.reflect&&k?`
10209
10209
  if (value !== null && value !== undefined) {
10210
- ${T.type==="boolean"?`if (value) { this.setAttribute('${k}', ''); }
10211
- else { this.removeAttribute('${k}'); }`:`this.setAttribute('${k}', ${T.type==="object"||T.type==="array"?"JSON.stringify(value)":"String(value)"});`}
10210
+ ${I.type==="boolean"?`if (value) { this.setAttribute('${k}', ''); }
10211
+ else { this.removeAttribute('${k}'); }`:`this.setAttribute('${k}', ${I.type==="object"||I.type==="array"?"JSON.stringify(value)":"String(value)"});`}
10212
10212
  }
10213
10213
  else {
10214
10214
  this.removeAttribute('${k}');
10215
- }`:"",v=T.observer?`this.${T.observer}(value, oldValue);`:"",C=T.render!==!1?"this._scheduleRender();":"";return`
10216
- get ${I}(): ${S} {
10217
- return this._${I};
10215
+ }`:"",b=I.observer?`this.${I.observer}(value, oldValue);`:"",C=I.render!==!1?"this._scheduleRender();":"";return`
10216
+ get ${T}(): ${S} {
10217
+ return this._${T};
10218
10218
  }
10219
10219
 
10220
- set ${I}(value: ${S}) {
10221
- const oldValue = this._${I};
10220
+ set ${T}(value: ${S}) {
10221
+ const oldValue = this._${T};
10222
10222
  if (oldValue === value) return;
10223
- this._${I} = value;${y}
10224
- ${v}
10223
+ this._${T} = value;${f}
10224
+ ${b}
10225
10225
  ${C}
10226
- this.dispatchEvent(new CustomEvent('${I}-changed', {
10226
+ this.dispatchEvent(new CustomEvent('${T}-changed', {
10227
10227
  detail: { value, oldValue },
10228
10228
  bubbles: true
10229
10229
  }));
10230
10230
  }
10231
10231
 
10232
- // Property default: ${b}`}).join(`
10232
+ // Property default: ${x}`}).join(`
10233
10233
  `),N=j.length>0?`
10234
10234
  static get observedAttributes(): string[] {
10235
- return [${j.map((I)=>`'${I}'`).join(", ")}];
10235
+ return [${j.map((T)=>`'${T}'`).join(", ")}];
10236
10236
  }
10237
10237
 
10238
10238
  attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {
@@ -10243,10 +10243,10 @@ else {
10243
10243
  (this as unknown as Record<string, unknown>)[propName] = this._deserializeAttribute(newValue, propDef.type);
10244
10244
  }
10245
10245
  ${W.attributeChanged||""}
10246
- }`:"",A=Object.entries(U).map(([I,T])=>{return`this._root.addEventListener('${I}', (e: Event) => { ${T} });`}).join(`
10247
- `),w=Object.entries(_).map(([I,T])=>{return`
10248
- ${I}(): void {
10249
- ${T}
10246
+ }`:"",A=Object.entries(U).map(([T,I])=>{return`this._root.addEventListener('${T}', (e: Event) => { ${I} });`}).join(`
10247
+ `),w=Object.entries(_).map(([T,I])=>{return`
10248
+ ${T}(): void {
10249
+ ${I}
10250
10250
  }`}).join(`
10251
10251
  `),M=J.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),E=Q.replace(/\\/g,"\\\\").replace(/`/g,"\\`");return`/**
10252
10252
  * ${Z} - Reactive Web Component (TypeScript)
@@ -10276,7 +10276,7 @@ interface PropertyDefinition {
10276
10276
  export class ${z} extends ${X} {
10277
10277
  // Property definitions
10278
10278
  private _propertyDefs: Record<string, PropertyDefinition> = ${JSON.stringify(K)};
10279
- private _attrToProp: Record<string, string> = ${JSON.stringify(Object.fromEntries(q.filter((I)=>K[I].attribute!==!1).map((I)=>[K[I].attribute||O$(I),I])))};
10279
+ private _attrToProp: Record<string, string> = ${JSON.stringify(Object.fromEntries(q.filter((T)=>K[T].attribute!==!1).map((T)=>[K[T].attribute||O$(T),T])))};
10280
10280
 
10281
10281
  // Internal state
10282
10282
  private _state: ${z}State = ${JSON.stringify(B)};
@@ -10293,7 +10293,7 @@ ${L}
10293
10293
  this._root = ${G?"this.shadowRoot!":"this"};
10294
10294
 
10295
10295
  // Initialize properties with defaults
10296
- ${q.map((I)=>{let T=K[I],S=T.default!==void 0?JSON.stringify(T.default):T.type==="string"?'""':T.type==="number"?"0":T.type==="boolean"?"false":T.type==="array"?"[]":"{}";return` this._${I} = ${S};`}).join(`
10296
+ ${q.map((T)=>{let I=K[T],S=I.default!==void 0?JSON.stringify(I.default):I.type==="string"?'""':I.type==="number"?"0":I.type==="boolean"?"false":I.type==="array"?"[]":"{}";return` this._${T} = ${S};`}).join(`
10297
10297
  `)}
10298
10298
 
10299
10299
  // Initial render
@@ -11301,38 +11301,38 @@ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FO
11301
11301
  `),J&&!J.endsWith(`
11302
11302
  `))J+=`
11303
11303
  `}J+=`NETLIFY_SITE_ID=${$.siteId}
11304
- `,await Bun.write(X,J)}return{configPath:Y,siteId:$.siteId}}function sE($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var G4;var wZ=D(()=>{j2();j2();G4=class G4 extends Error{code;constructor($,Z){super($);this.name="DeployError",this.code=Z}}});import aE from"fs";import RZ from"path";import oE from"crypto";async function MZ(){if(Vq)return L2;Vq=!0;try{let $=await import("sharp");return L2=$.default||$,L2}catch{return null}}async function c1(){return await MZ()!==null}async function p1($,Z={}){let{widths:Y=V1,formats:X=A1,quality:J=N1,fit:Q="cover",placeholder:G="none",outputDir:K=".stx/images",baseUrl:W="/images"}=Z,U,_;if(typeof $==="string"){if(_=$,!await Bun.file($).exists())throw new k$(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((N)=>Buffer.from(N))}else _="buffer-input",U=$;let B=oE.createHash("sha256").update(U).digest("hex").slice(0,12),z=await Q7(U),{width:q,height:j}=z,H=q/j;await aE.promises.mkdir(K,{recursive:!0});let O=[],F=RZ.basename(_,RZ.extname(_)),L=Y.filter((N)=>N<=q);if(!L.includes(q)&&q<=Math.max(...Y))L.push(q);L.sort((N,A)=>N-A);for(let N of L){let A=Math.round(N/H);for(let w of X){let M=`${F}-${N}w-${B}.${w}`,E=RZ.join(K,M),I=`${W}/${M}`,T=await $T(U,{width:N,height:A,format:w,quality:J,fit:Q});await Bun.write(E,T),O.push({path:E,url:I,width:N,height:A,format:w,size:T.length})}}let V;if(G!=="none")V=await ZT(U,G);return{src:_,variants:O,placeholder:V,width:q,height:j,aspectRatio:H,hash:B}}async function Q7($){let Z=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Y=await MZ();if(Y){let J=await Y(Z).metadata();return{width:J.width||0,height:J.height||0,format:J.format||"unknown",hasAlpha:J.hasAlpha}}return eE(Z)}function eE($){if($[0]===137&&$[1]===80&&$[2]===78&&$[3]===71){let Z=$.readUInt32BE(16),Y=$.readUInt32BE(20);return{width:Z,height:Y,format:"png",hasAlpha:!0}}if($[0]===255&&$[1]===216){let Z=2;while(Z<$.length){if($[Z]!==255)break;let Y=$[Z+1];if(Y>=192&&Y<=207&&Y!==196&&Y!==200&&Y!==204){let J=$.readUInt16BE(Z+5);return{width:$.readUInt16BE(Z+7),height:J,format:"jpeg",hasAlpha:!1}}let X=$.readUInt16BE(Z+2);Z+=2+X}}if($.toString("utf8",0,4)==="RIFF"&&$.toString("utf8",8,12)==="WEBP"){let Z=$.toString("utf8",12,16);if(Z==="VP8 "){let Y=$.readUInt16LE(26)&16383,X=$.readUInt16LE(28)&16383;return{width:Y,height:X,format:"webp",hasAlpha:!1}}if(Z==="VP8L"){let Y=$.readUInt32LE(21),X=(Y&16383)+1,J=(Y>>14&16383)+1;return{width:X,height:J,format:"webp",hasAlpha:!0}}}if($.toString("utf8",0,3)==="GIF"){let Z=$.readUInt16LE(6),Y=$.readUInt16LE(8);return{width:Z,height:Y,format:"gif",hasAlpha:!0}}throw new k$("Unable to parse image dimensions","PARSE_ERROR")}async function $T($,Z){let Y=await MZ();if(Y){let X=Y($).resize(Z.width,Z.height,{fit:Z.fit});switch(Z.format){case"webp":X=X.webp({quality:Z.quality});break;case"avif":X=X.avif({quality:Z.quality});break;case"jpeg":X=X.jpeg({quality:Z.quality});break;case"png":X=X.png({quality:Z.quality});break}return X.toBuffer()}return console.warn("sharp not available, returning original image without optimization"),$}async function ZT($,Z){let Y=await MZ();if(Z==="blur"&&Y){let J=(await Y($).resize(20).blur(10).toBuffer()).toString("base64"),Q=await Q7($);return`data:${Aq[Q.format]||"image/jpeg"};base64,${J}`}if(Y){let{dominant:X}=await Y($).resize(1,1).toBuffer().then(async(J)=>{let Q=await Y(J).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${X.r}, ${X.g}, ${X.b})`}return"rgb(128, 128, 128)"}function W6($,Z){return(Z?$.filter((X)=>X.format===Z):$).sort((X,J)=>X.width-J.width).map((X)=>`${X.url} ${X.width}w`).join(", ")}function T$($){if(!$||Object.keys($).length===0)return"100vw";return Object.entries($).sort((Y,X)=>{let J=Number.parseInt(Y[0].replace(/\D/g,""))||0;return(Number.parseInt(X[0].replace(/\D/g,""))||0)-J}).map(([Y,X])=>`(max-width: ${Y}) ${X}`).join(", ")+", 100vw"}function I$($){let Z=$.filter((X)=>X.format==="jpeg");if(Z.length===0)return $[Math.floor($.length/2)];let Y=Z.sort((X,J)=>X.width-J.width);return Y[Math.floor(Y.length/2)]}function D$($){let Z=new Map;for(let Y of $){let X=Z.get(Y.format)||[];X.push(Y),Z.set(Y.format,X)}return Z}function G7($){let Z=RZ.extname($).toLowerCase();return tE.includes(Z)}function l1($){return Aq[$]||"application/octet-stream"}function EZ($){return $.reduce((Z,Y)=>Z+Y.size,0)}function TZ($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var V1,A1,N1=80,tE,Aq,L2=null,Vq=!1,k$;var K7=D(()=>{V1=[320,640,768,1024,1280,1536,1920],A1=["webp","jpeg"],tE=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],Aq={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};k$=class k$ extends Error{code;constructor($,Z){super($);this.name="ImageProcessingError",this.code=Z}}});function F2($,Z={}){let{src:Y,alt:X,width:J,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=N1,placeholder:_="none",formats:B=A1,widths:z=V1,decoding:q="async",fetchpriority:j,objectFit:H,objectPosition:O}=$,F=$.class,L=$.style,{processedImage:V,variants:N,optimize:A=!0,isDev:w=!1}=Z;if(N&&N.length>0)return YT($,N,V);if(w||!A)return XT($);return JT($)}function YT($,Z,Y){let{src:X,alt:J,width:Q,height:G,sizes:K="100vw",loading:W="lazy",priority:U=!1,decoding:_="async",fetchpriority:B,objectFit:z,objectPosition:q,placeholder:j="none"}=$,H=$.class,O=$.style,F=D$(Z),L=I$(Z),V=typeof K==="object"?T$(K):K,N=Y?Y.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,A=[];if(N)A.push(`aspect-ratio: ${N}`);if(z)A.push(`object-fit: ${z}`);if(q)A.push(`object-position: ${q}`);if(O)A.push(O);let w=A.length>0?` style="${A.join("; ")}"`:"",M=H?` class="${H}"`:"",E=U?"":` loading="${W}"`,I=` decoding="${_}"`,T=B?` fetchpriority="${B}"`:U?' fetchpriority="high"':"",S=["avif","webp","jpeg","png"],k=[];for(let l of S){let i=F.get(l);if(i&&i.length>0){let _0=W6(i),q0=l1(l);k.push(` <source type="${q0}" srcset="${_0}" sizes="${V}" />`)}}let b="",y="",v;if(j!=="none"&&Y?.placeholder){let l=`img-${Math.random().toString(36).slice(2,8)}`;if(b=`<div class="stx-image-wrapper" id="${l}">`,y="</div>",j==="blur")v=`
11305
- #${l} {
11304
+ `,await Bun.write(X,J)}return{configPath:Y,siteId:$.siteId}}function sE($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var G4;var wZ=D(()=>{j2();j2();G4=class G4 extends Error{code;constructor($,Z){super($);this.name="DeployError",this.code=Z}}});import aE from"fs";import RZ from"path";import oE from"crypto";async function MZ(){if(Vq)return L2;Vq=!0;try{let $=await import("sharp");return L2=$.default||$,L2}catch{return null}}async function c1(){return await MZ()!==null}async function p1($,Z={}){let{widths:Y=V1,formats:X=A1,quality:J=N1,fit:Q="cover",placeholder:G="none",outputDir:K=".stx/images",baseUrl:W="/images"}=Z,U,_;if(typeof $==="string"){if(_=$,!await Bun.file($).exists())throw new k$(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((N)=>Buffer.from(N))}else _="buffer-input",U=$;let B=oE.createHash("sha256").update(U).digest("hex").slice(0,12),z=await Q7(U),{width:q,height:j}=z,H=q/j;await aE.promises.mkdir(K,{recursive:!0});let O=[],F=RZ.basename(_,RZ.extname(_)),L=Y.filter((N)=>N<=q);if(!L.includes(q)&&q<=Math.max(...Y))L.push(q);L.sort((N,A)=>N-A);for(let N of L){let A=Math.round(N/H);for(let w of X){let M=`${F}-${N}w-${B}.${w}`,E=RZ.join(K,M),T=`${W}/${M}`,I=await $T(U,{width:N,height:A,format:w,quality:J,fit:Q});await Bun.write(E,I),O.push({path:E,url:T,width:N,height:A,format:w,size:I.length})}}let V;if(G!=="none")V=await ZT(U,G);return{src:_,variants:O,placeholder:V,width:q,height:j,aspectRatio:H,hash:B}}async function Q7($){let Z=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Y=await MZ();if(Y){let J=await Y(Z).metadata();return{width:J.width||0,height:J.height||0,format:J.format||"unknown",hasAlpha:J.hasAlpha}}return eE(Z)}function eE($){if($[0]===137&&$[1]===80&&$[2]===78&&$[3]===71){let Z=$.readUInt32BE(16),Y=$.readUInt32BE(20);return{width:Z,height:Y,format:"png",hasAlpha:!0}}if($[0]===255&&$[1]===216){let Z=2;while(Z<$.length){if($[Z]!==255)break;let Y=$[Z+1];if(Y>=192&&Y<=207&&Y!==196&&Y!==200&&Y!==204){let J=$.readUInt16BE(Z+5);return{width:$.readUInt16BE(Z+7),height:J,format:"jpeg",hasAlpha:!1}}let X=$.readUInt16BE(Z+2);Z+=2+X}}if($.toString("utf8",0,4)==="RIFF"&&$.toString("utf8",8,12)==="WEBP"){let Z=$.toString("utf8",12,16);if(Z==="VP8 "){let Y=$.readUInt16LE(26)&16383,X=$.readUInt16LE(28)&16383;return{width:Y,height:X,format:"webp",hasAlpha:!1}}if(Z==="VP8L"){let Y=$.readUInt32LE(21),X=(Y&16383)+1,J=(Y>>14&16383)+1;return{width:X,height:J,format:"webp",hasAlpha:!0}}}if($.toString("utf8",0,3)==="GIF"){let Z=$.readUInt16LE(6),Y=$.readUInt16LE(8);return{width:Z,height:Y,format:"gif",hasAlpha:!0}}throw new k$("Unable to parse image dimensions","PARSE_ERROR")}async function $T($,Z){let Y=await MZ();if(Y){let X=Y($).resize(Z.width,Z.height,{fit:Z.fit});switch(Z.format){case"webp":X=X.webp({quality:Z.quality});break;case"avif":X=X.avif({quality:Z.quality});break;case"jpeg":X=X.jpeg({quality:Z.quality});break;case"png":X=X.png({quality:Z.quality});break}return X.toBuffer()}return console.warn("sharp not available, returning original image without optimization"),$}async function ZT($,Z){let Y=await MZ();if(Z==="blur"&&Y){let J=(await Y($).resize(20).blur(10).toBuffer()).toString("base64"),Q=await Q7($);return`data:${Aq[Q.format]||"image/jpeg"};base64,${J}`}if(Y){let{dominant:X}=await Y($).resize(1,1).toBuffer().then(async(J)=>{let Q=await Y(J).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${X.r}, ${X.g}, ${X.b})`}return"rgb(128, 128, 128)"}function W6($,Z){return(Z?$.filter((X)=>X.format===Z):$).sort((X,J)=>X.width-J.width).map((X)=>`${X.url} ${X.width}w`).join(", ")}function T$($){if(!$||Object.keys($).length===0)return"100vw";return Object.entries($).sort((Y,X)=>{let J=Number.parseInt(Y[0].replace(/\D/g,""))||0;return(Number.parseInt(X[0].replace(/\D/g,""))||0)-J}).map(([Y,X])=>`(max-width: ${Y}) ${X}`).join(", ")+", 100vw"}function I$($){let Z=$.filter((X)=>X.format==="jpeg");if(Z.length===0)return $[Math.floor($.length/2)];let Y=Z.sort((X,J)=>X.width-J.width);return Y[Math.floor(Y.length/2)]}function D$($){let Z=new Map;for(let Y of $){let X=Z.get(Y.format)||[];X.push(Y),Z.set(Y.format,X)}return Z}function G7($){let Z=RZ.extname($).toLowerCase();return tE.includes(Z)}function l1($){return Aq[$]||"application/octet-stream"}function EZ($){return $.reduce((Z,Y)=>Z+Y.size,0)}function TZ($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var V1,A1,N1=80,tE,Aq,L2=null,Vq=!1,k$;var K7=D(()=>{V1=[320,640,768,1024,1280,1536,1920],A1=["webp","jpeg"],tE=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],Aq={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};k$=class k$ extends Error{code;constructor($,Z){super($);this.name="ImageProcessingError",this.code=Z}}});function F2($,Z={}){let{src:Y,alt:X,width:J,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=N1,placeholder:_="none",formats:B=A1,widths:z=V1,decoding:q="async",fetchpriority:j,objectFit:H,objectPosition:O}=$,F=$.class,L=$.style,{processedImage:V,variants:N,optimize:A=!0,isDev:w=!1}=Z;if(N&&N.length>0)return YT($,N,V);if(w||!A)return XT($);return JT($)}function YT($,Z,Y){let{src:X,alt:J,width:Q,height:G,sizes:K="100vw",loading:W="lazy",priority:U=!1,decoding:_="async",fetchpriority:B,objectFit:z,objectPosition:q,placeholder:j="none"}=$,H=$.class,O=$.style,F=D$(Z),L=I$(Z),V=typeof K==="object"?T$(K):K,N=Y?Y.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,A=[];if(N)A.push(`aspect-ratio: ${N}`);if(z)A.push(`object-fit: ${z}`);if(q)A.push(`object-position: ${q}`);if(O)A.push(O);let w=A.length>0?` style="${A.join("; ")}"`:"",M=H?` class="${H}"`:"",E=U?"":` loading="${W}"`,T=` decoding="${_}"`,I=B?` fetchpriority="${B}"`:U?' fetchpriority="high"':"",S=["avif","webp","jpeg","png"],k=[];for(let p of S){let i=F.get(p);if(i&&i.length>0){let _0=W6(i),q0=l1(p);k.push(` <source type="${q0}" srcset="${_0}" sizes="${V}" />`)}}let x="",f="",b;if(j!=="none"&&Y?.placeholder){let p=`img-${Math.random().toString(36).slice(2,8)}`;if(x=`<div class="stx-image-wrapper" id="${p}">`,f="</div>",j==="blur")b=`
11305
+ #${p} {
11306
11306
  position: relative;
11307
11307
  background-image: url('${Y.placeholder}');
11308
11308
  background-size: cover;
11309
11309
  background-position: center;
11310
11310
  }
11311
- #${l} img {
11311
+ #${p} img {
11312
11312
  transition: opacity 0.3s ease;
11313
11313
  }
11314
- #${l}.loaded img {
11314
+ #${p}.loaded img {
11315
11315
  opacity: 1;
11316
11316
  }
11317
- `.trim();else if(j==="color")v=`
11318
- #${l} {
11317
+ `.trim();else if(j==="color")b=`
11318
+ #${p} {
11319
11319
  background-color: ${Y.placeholder};
11320
11320
  }
11321
- `.trim()}let C=Q?` width="${Q}"`:Y?` width="${Y.width}"`:"",f=G?` height="${G}"`:Y?` height="${Y.height}"`:"",h=`${b}<picture>
11321
+ `.trim()}let C=Q?` width="${Q}"`:Y?` width="${Y.width}"`:"",v=G?` height="${G}"`:Y?` height="${Y.height}"`:"",h=`${x}<picture>
11322
11322
  ${k.join(`
11323
11323
  `)}
11324
11324
  <img
11325
11325
  src="${L?.url||X}"
11326
- alt="${A2(J)}"${C}${f}${M}${w}${E}${I}${T}
11326
+ alt="${A2(J)}"${C}${v}${M}${w}${E}${T}${I}
11327
11327
  />
11328
- </picture>${y}`,u;if(U&&L){let l=F.get("webp"),i=l?.[Math.floor(l.length/2)]||L,_0=l1(i.format);u=`<link rel="preload" as="image" href="${i.url}" type="${_0}" />`}return{html:h,preloadLink:u,placeholderCss:v}}function XT($){let{src:Z,alt:Y,width:X,height:J,loading:Q="lazy",decoding:G="async",priority:K=!1,fetchpriority:W,objectFit:U,objectPosition:_}=$,B=$.class,z=$.style,q=[];if(U)q.push(`object-fit: ${U}`);if(_)q.push(`object-position: ${_}`);if(z)q.push(z);let j=q.length>0?` style="${q.join("; ")}"`:"",H=B?` class="${B}"`:"",O=X?` width="${X}"`:"",F=J?` height="${J}"`:"",L=K?"":` loading="${Q}"`,V=` decoding="${G}"`,N=W?` fetchpriority="${W}"`:K?' fetchpriority="high"':"";return{html:`<img src="${Z}" alt="${A2(Y)}"${O}${F}${H}${j}${L}${V}${N} />`}}function JT($){let{src:Z,alt:Y,width:X,height:J,sizes:Q="100vw",loading:G="lazy",priority:K=!1,quality:W=N1,formats:U=A1,widths:_=V1,decoding:B="async",fetchpriority:z,objectFit:q,objectPosition:j}=$,H=$.class,O=$.style,F=[];if(q)F.push(`object-fit: ${q}`);if(j)F.push(`object-position: ${j}`);if(O)F.push(O);let L=F.length>0?` style="${F.join("; ")}"`:"",V=H?` class="${H}"`:"",N=X?` width="${X}"`:"",A=J?` height="${J}"`:"",w=K?"":` loading="${G}"`,M=` decoding="${B}"`,E=z?` fetchpriority="${z}"`:K?' fetchpriority="high"':"",I=typeof Q==="object"?T$(Q):Q,T=`
11328
+ </picture>${f}`,u;if(U&&L){let p=F.get("webp"),i=p?.[Math.floor(p.length/2)]||L,_0=l1(i.format);u=`<link rel="preload" as="image" href="${i.url}" type="${_0}" />`}return{html:h,preloadLink:u,placeholderCss:b}}function XT($){let{src:Z,alt:Y,width:X,height:J,loading:Q="lazy",decoding:G="async",priority:K=!1,fetchpriority:W,objectFit:U,objectPosition:_}=$,B=$.class,z=$.style,q=[];if(U)q.push(`object-fit: ${U}`);if(_)q.push(`object-position: ${_}`);if(z)q.push(z);let j=q.length>0?` style="${q.join("; ")}"`:"",H=B?` class="${B}"`:"",O=X?` width="${X}"`:"",F=J?` height="${J}"`:"",L=K?"":` loading="${Q}"`,V=` decoding="${G}"`,N=W?` fetchpriority="${W}"`:K?' fetchpriority="high"':"";return{html:`<img src="${Z}" alt="${A2(Y)}"${O}${F}${H}${j}${L}${V}${N} />`}}function JT($){let{src:Z,alt:Y,width:X,height:J,sizes:Q="100vw",loading:G="lazy",priority:K=!1,quality:W=N1,formats:U=A1,widths:_=V1,decoding:B="async",fetchpriority:z,objectFit:q,objectPosition:j}=$,H=$.class,O=$.style,F=[];if(q)F.push(`object-fit: ${q}`);if(j)F.push(`object-position: ${j}`);if(O)F.push(O);let L=F.length>0?` style="${F.join("; ")}"`:"",V=H?` class="${H}"`:"",N=X?` width="${X}"`:"",A=J?` height="${J}"`:"",w=K?"":` loading="${G}"`,M=` decoding="${B}"`,E=z?` fetchpriority="${z}"`:K?' fetchpriority="high"':"",T=typeof Q==="object"?T$(Q):Q,I=`
11329
11329
  data-stx-image
11330
11330
  data-src="${Z}"
11331
- data-sizes="${I}"
11331
+ data-sizes="${T}"
11332
11332
  data-quality="${W}"
11333
11333
  data-formats="${U.join(",")}"
11334
11334
  data-widths="${_.join(",")}"
11335
- `.replace(/\s+/g," ").trim();return{html:`<img src="${Z}" alt="${A2(Y)}"${N}${A}${V}${L}${w}${M}${E} ${T} />`}}function IZ($){let Z=$.match(/<Image\s+([^>]*?)\/?>/);if(!Z)return null;let Y=Z[1],X={},J=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|(\{[^}]+\})))?/g,Q;while((Q=J.exec(Y))!==null){let[,G,K,W,U]=Q,_=K??W??U??!0;switch(G){case"src":X.src=String(_);break;case"alt":X.alt=String(_);break;case"width":X.width=Number(_)||_;break;case"height":X.height=Number(_)||_;break;case"sizes":X.sizes=String(_);break;case"loading":X.loading=_;break;case"priority":X.priority=_===!0||_==="true";break;case"quality":X.quality=Number(_);break;case"placeholder":X.placeholder=_;break;case"class":X.class=String(_);break;case"style":X.style=String(_);break;case"decoding":X.decoding=_;break;case"fetchpriority":X.fetchpriority=_;break;case"objectFit":X.objectFit=_;break;case"objectPosition":X.objectPosition=String(_);break}}if(!X.src||!X.alt)return null;return X}async function V2($,Z){let Y=/<Image\s+[^>]*?\/?>/g,X=[],J=[],Q=$,G,K=[];while((G=Y.exec($))!==null)K.push({match:G[0],index:G.index});for(let W=K.length-1;W>=0;W--){let{match:U}=K[W],_=IZ(U);if(_){let B=await Z(_);if(Q=Q.replace(U,B.html),B.preloadLink)X.push(B.preloadLink);if(B.placeholderCss)J.push(B.placeholderCss)}}return{html:Q,preloadLinks:X,styles:J}}function A2($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}var Nq=D(()=>{K7()});function kZ(){DZ.clear()}async function QT($,Z){let Y=`${$}:${JSON.stringify(Z)}`;if(DZ.has(Y))return DZ.get(Y);try{let X=await p1($,Z);return DZ.set(Y,X),X}catch{return null}}function SZ(){return b0({name:"image",hasEndTag:!1,description:"Render an optimized image with responsive variants",transform:async($,Z,Y)=>{let{src:X,alt:J,options:Q}=GT($,Z,Y);if(!X)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let G={widths:Q.widths||(Q.width?[Q.width]:V1),formats:Q.formats||A1,quality:Q.quality||N1,placeholder:(Q.placeholder==="color"?"dominant-color":Q.placeholder)||"none"};if(!await c1())return wq(X,J||"",Q);let W=await QT(X,G);if(!W)return wq(X,J||"",Q);return WT(W,J||"",Q)}})}function GT($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let J=$.trim();if(J.startsWith("@image(")||J.startsWith("("))J=J.replace(/^@image\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Q=KT(J),G=Q[0]||"",K=Q[1]||"",W={};if(G&&!G.startsWith("/")&&!G.startsWith(".")&&!G.startsWith("http")){let U=Y[G];if(typeof U==="string")G=U}if(Q[2])try{if(typeof Q[2]==="string")W=JSON.parse(Q[2]);else W=Q[2]}catch{}return{src:G,alt:K,options:W}}function KT($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'")&&U!=="\\"){if(!X)X=!0,J=W;else if(W===J)X=!1,J="";else Y+=W;continue}if(!X){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function wq($,Z,Y){let X=[`src="${K4($)}"`];if(Z)X.push(`alt="${K4(Z)}"`);if(Y.width)X.push(`width="${Y.width}"`);if(Y.height)X.push(`height="${Y.height}"`);if(Y.class)X.push(`class="${K4(Y.class)}"`);if(Y.style)X.push(`style="${K4(Y.style)}"`);if(Y.lazy!==!1)X.push('loading="lazy"');return X.push('decoding="async"'),`<img ${X.join(" ")} />`}function WT($,Z,Y){let{variants:X,placeholder:J,width:Q,height:G,aspectRatio:K}=$,W=new Map;for(let O of X){let F=W.get(O.format)||[];F.push(O),W.set(O.format,F)}let U=["avif","webp","jpeg","png"],_=[];for(let O of U){let F=W.get(O);if(F&&F.length>0){let L=W6(F),V=l1(O),N=Y.sizes||"100vw";_.push(` <source type="${V}" srcset="${K4(L)}" sizes="${K4(N)}" />`)}}let B=W.get("jpeg")||[],z=B.length>0?B[Math.floor(B.length/2)]:X[Math.floor(X.length/2)],q=[`src="${z?.url||$.src}"`,`alt="${K4(Z)}"`];if(Y.width||Q)q.push(`width="${Y.width||Q}"`);if(Y.height||G)q.push(`height="${Y.height||G}"`);if(Y.class)q.push(`class="${K4(Y.class)}"`);let j=[];if(K)j.push(`aspect-ratio: ${K.toFixed(4)}`);if(Y.style)j.push(Y.style);if(j.length>0)q.push(`style="${j.join("; ")}"`);if(Y.lazy!==!1&&!Y.priority)q.push('loading="lazy"');if(q.push('decoding="async"'),Y.priority)q.push('fetchpriority="high"');let H=`<picture>
11335
+ `.replace(/\s+/g," ").trim();return{html:`<img src="${Z}" alt="${A2(Y)}"${N}${A}${V}${L}${w}${M}${E} ${I} />`}}function IZ($){let Z=$.match(/<Image\s+([^>]*?)\/?>/);if(!Z)return null;let Y=Z[1],X={},J=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|(\{[^}]+\})))?/g,Q;while((Q=J.exec(Y))!==null){let[,G,K,W,U]=Q,_=K??W??U??!0;switch(G){case"src":X.src=String(_);break;case"alt":X.alt=String(_);break;case"width":X.width=Number(_)||_;break;case"height":X.height=Number(_)||_;break;case"sizes":X.sizes=String(_);break;case"loading":X.loading=_;break;case"priority":X.priority=_===!0||_==="true";break;case"quality":X.quality=Number(_);break;case"placeholder":X.placeholder=_;break;case"class":X.class=String(_);break;case"style":X.style=String(_);break;case"decoding":X.decoding=_;break;case"fetchpriority":X.fetchpriority=_;break;case"objectFit":X.objectFit=_;break;case"objectPosition":X.objectPosition=String(_);break}}if(!X.src||!X.alt)return null;return X}async function V2($,Z){let Y=/<Image\s+[^>]*?\/?>/g,X=[],J=[],Q=$,G,K=[];while((G=Y.exec($))!==null)K.push({match:G[0],index:G.index});for(let W=K.length-1;W>=0;W--){let{match:U}=K[W],_=IZ(U);if(_){let B=await Z(_);if(Q=Q.replace(U,B.html),B.preloadLink)X.push(B.preloadLink);if(B.placeholderCss)J.push(B.placeholderCss)}}return{html:Q,preloadLinks:X,styles:J}}function A2($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}var Nq=D(()=>{K7()});function kZ(){DZ.clear()}async function QT($,Z){let Y=`${$}:${JSON.stringify(Z)}`;if(DZ.has(Y))return DZ.get(Y);try{let X=await p1($,Z);return DZ.set(Y,X),X}catch{return null}}function SZ(){return b0({name:"image",hasEndTag:!1,description:"Render an optimized image with responsive variants",transform:async($,Z,Y)=>{let{src:X,alt:J,options:Q}=GT($,Z,Y);if(!X)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let G={widths:Q.widths||(Q.width?[Q.width]:V1),formats:Q.formats||A1,quality:Q.quality||N1,placeholder:(Q.placeholder==="color"?"dominant-color":Q.placeholder)||"none"};if(!await c1())return wq(X,J||"",Q);let W=await QT(X,G);if(!W)return wq(X,J||"",Q);return WT(W,J||"",Q)}})}function GT($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let J=$.trim();if(J.startsWith("@image(")||J.startsWith("("))J=J.replace(/^@image\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Q=KT(J),G=Q[0]||"",K=Q[1]||"",W={};if(G&&!G.startsWith("/")&&!G.startsWith(".")&&!G.startsWith("http")){let U=Y[G];if(typeof U==="string")G=U}if(Q[2])try{if(typeof Q[2]==="string")W=JSON.parse(Q[2]);else W=Q[2]}catch{}return{src:G,alt:K,options:W}}function KT($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'")&&U!=="\\"){if(!X)X=!0,J=W;else if(W===J)X=!1,J="";else Y+=W;continue}if(!X){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function wq($,Z,Y){let X=[`src="${K4($)}"`];if(Z)X.push(`alt="${K4(Z)}"`);if(Y.width)X.push(`width="${Y.width}"`);if(Y.height)X.push(`height="${Y.height}"`);if(Y.class)X.push(`class="${K4(Y.class)}"`);if(Y.style)X.push(`style="${K4(Y.style)}"`);if(Y.lazy!==!1)X.push('loading="lazy"');return X.push('decoding="async"'),`<img ${X.join(" ")} />`}function WT($,Z,Y){let{variants:X,placeholder:J,width:Q,height:G,aspectRatio:K}=$,W=new Map;for(let O of X){let F=W.get(O.format)||[];F.push(O),W.set(O.format,F)}let U=["avif","webp","jpeg","png"],_=[];for(let O of U){let F=W.get(O);if(F&&F.length>0){let L=W6(F),V=l1(O),N=Y.sizes||"100vw";_.push(` <source type="${V}" srcset="${K4(L)}" sizes="${K4(N)}" />`)}}let B=W.get("jpeg")||[],z=B.length>0?B[Math.floor(B.length/2)]:X[Math.floor(X.length/2)],q=[`src="${z?.url||$.src}"`,`alt="${K4(Z)}"`];if(Y.width||Q)q.push(`width="${Y.width||Q}"`);if(Y.height||G)q.push(`height="${Y.height||G}"`);if(Y.class)q.push(`class="${K4(Y.class)}"`);let j=[];if(K)j.push(`aspect-ratio: ${K.toFixed(4)}`);if(Y.style)j.push(Y.style);if(j.length>0)q.push(`style="${j.join("; ")}"`);if(Y.lazy!==!1&&!Y.priority)q.push('loading="lazy"');if(q.push('decoding="async"'),Y.priority)q.push('fetchpriority="high"');let H=`<picture>
11336
11336
  `;if(H+=_.join(`
11337
11337
  `)+`
11338
11338
  `,H+=` <img ${q.join(" ")} />
@@ -11585,10 +11585,10 @@ ${$.map((X)=>{let J=new URL(X.loc,Z).href,Q=` <url>
11585
11585
  ${Y.join(`
11586
11586
  `)}
11587
11587
  </channel>
11588
- </rss>`}async function iq($={}){let Z=Date.now(),Y=await g0(),X={pagesDir:$.pagesDir||"pages",outputDir:$.outputDir||"dist",baseUrl:$.baseUrl||"/",domain:$.domain||"http://localhost",revalidate:$.revalidate??!1,sitemap:$.sitemap??!0,rss:$.rss??!1,concurrency:$.concurrency||10,cache:$.cache??!0,cacheDir:$.cacheDir||".stx/ssg-cache",contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??!1,generate404:$.generate404??!0,publicDir:$.publicDir||"public",trailingSlash:$.trailingSlash??!1,cleanOutput:$.cleanOutput??!0},J={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]};await X.hooks.onBuildStart?.();try{if(X.cleanOutput&&m0.existsSync(X.outputDir))await m0.promises.rm(X.outputDir,{recursive:!0});await m0.promises.mkdir(X.outputDir,{recursive:!0});let Q=new cq(X.cacheDir);if(X.cache)await Q.load();try{let{preloadIconCollection:j}=await Promise.resolve().then(() => (g3(),R_));await j("lucide")}catch{}try{let{generateCrosswindCSS:j}=await Promise.resolve().then(() => (P1(),S8));await j('<div class="bg-black"></div>')}catch{}W7();let G=Y?.routeMiddleware?.dir||"middleware";await z7(process.cwd(),G);let K=B7();if(K.length>0)console.log(`Loaded ${K.length} middleware: ${K.join(", ")}`);let W=Y?.routeMiddleware?.global||[],U=W4(".",{pagesDir:X.pagesDir});console.log(`Found ${U.length} routes`);let _=[];for(let j of U){let H=await UI(j);for(let O of H)_.push({route:j,url:O.url,params:O.params,props:O.props,revalidate:O.revalidate??X.revalidate})}J.totalPages=_.length,console.log(`Generating ${J.totalPages} pages...`);let B=[],z=[];for(let j=0;j<_.length;j+=X.concurrency)z.push(_.slice(j,j+X.concurrency));for(let j of z)await Promise.all(j.map(async(H)=>{let{route:O,url:F,params:L,props:V,revalidate:N}=H;try{await X.hooks.onPageStart?.(F);let A=await Bun.file(O.filePath).text(),w=OI(A),M=w?.middleware?Array.isArray(w.middleware)?w.middleware:[w.middleware]:[],E=[...W,...M];if(E.length>0){let y=_7(F,L,w||{}),v=U7(y,null),C=await q7(E,v);if(C.redirect){let f=typeof C.redirect==="string"?C.redirect:C.redirect.path||C.redirect,h=LI(String(f),F),u=FI(F,X);await m0.promises.mkdir(w0.dirname(u),{recursive:!0}),await Bun.write(u,h),J.successCount++,J.pages.push({route:F,outputPath:u,size:Buffer.byteLength(h),cached:!1}),B.push({loc:F,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${F} \u2192 redirect to ${f}`);return}if(C.abort){let f=typeof C.abort==="string"?C.abort:C.abort?.error?.message||"aborted";console.warn(` \u21B3 ${F} \u2014 middleware aborted: ${f}`);return}}let I=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(I)try{if(!await Function("route",`
11589
- const validate = ${I[1]};
11588
+ </rss>`}async function iq($={}){let Z=Date.now(),Y=await g0(),X={pagesDir:$.pagesDir||"pages",outputDir:$.outputDir||"dist",baseUrl:$.baseUrl||"/",domain:$.domain||"http://localhost",revalidate:$.revalidate??!1,sitemap:$.sitemap??!0,rss:$.rss??!1,concurrency:$.concurrency||10,cache:$.cache??!0,cacheDir:$.cacheDir||".stx/ssg-cache",contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??!1,generate404:$.generate404??!0,publicDir:$.publicDir||"public",trailingSlash:$.trailingSlash??!1,cleanOutput:$.cleanOutput??!0},J={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]};await X.hooks.onBuildStart?.();try{if(X.cleanOutput&&m0.existsSync(X.outputDir))await m0.promises.rm(X.outputDir,{recursive:!0});await m0.promises.mkdir(X.outputDir,{recursive:!0});let Q=new cq(X.cacheDir);if(X.cache)await Q.load();try{let{preloadIconCollection:j}=await Promise.resolve().then(() => (g3(),R_));await j("lucide")}catch{}try{let{generateCrosswindCSS:j}=await Promise.resolve().then(() => (P1(),S8));await j('<div class="bg-black"></div>')}catch{}W7();let G=Y?.routeMiddleware?.dir||"middleware";await z7(process.cwd(),G);let K=B7();if(K.length>0)console.log(`Loaded ${K.length} middleware: ${K.join(", ")}`);let W=Y?.routeMiddleware?.global||[],U=W4(".",{pagesDir:X.pagesDir});console.log(`Found ${U.length} routes`);let _=[];for(let j of U){let H=await UI(j);for(let O of H)_.push({route:j,url:O.url,params:O.params,props:O.props,revalidate:O.revalidate??X.revalidate})}J.totalPages=_.length,console.log(`Generating ${J.totalPages} pages...`);let B=[],z=[];for(let j=0;j<_.length;j+=X.concurrency)z.push(_.slice(j,j+X.concurrency));for(let j of z)await Promise.all(j.map(async(H)=>{let{route:O,url:F,params:L,props:V,revalidate:N}=H;try{await X.hooks.onPageStart?.(F);let A=await Bun.file(O.filePath).text(),w=OI(A),M=w?.middleware?Array.isArray(w.middleware)?w.middleware:[w.middleware]:[],E=[...W,...M];if(E.length>0){let f=_7(F,L,w||{}),b=U7(f,null),C=await q7(E,b);if(C.redirect){let v=typeof C.redirect==="string"?C.redirect:C.redirect.path||C.redirect,h=LI(String(v),F),u=FI(F,X);await m0.promises.mkdir(w0.dirname(u),{recursive:!0}),await Bun.write(u,h),J.successCount++,J.pages.push({route:F,outputPath:u,size:Buffer.byteLength(h),cached:!1}),B.push({loc:F,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${F} \u2192 redirect to ${v}`);return}if(C.abort){let v=typeof C.abort==="string"?C.abort:C.abort?.error?.message||"aborted";console.warn(` \u21B3 ${F} \u2014 middleware aborted: ${v}`);return}}let T=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(T)try{if(!await Function("route",`
11589
+ const validate = ${T[1]};
11590
11590
  return validate(route);
11591
- `)({params:L})){console.warn(`Validation failed for ${F}, skipping...`);return}}catch{}let T=null,S=!1;if(X.cache){if(T=Q.get(F,O.filePath,[]),T)S=!0,J.cachedCount++}if(!T){if(T=await lq(O,L,V,X,Y),X.cache)Q.set(F,O.filePath,[],T)}let k;if(X.trailingSlash)k=w0.join(X.outputDir,F,"index.html");else k=F==="/"?w0.join(X.outputDir,"index.html"):w0.join(X.outputDir,`${F}.html`);await m0.promises.mkdir(w0.dirname(k),{recursive:!0}),await Bun.write(k,T),B.push({loc:F,lastmod:new Date().toISOString().split("T")[0],priority:F==="/"?1:0.8});let b={route:F,outputPath:k,size:Buffer.byteLength(T,"utf8"),cached:S};if(N!==!1)b.revalidateAt=Date.now()+N*1000;J.pages.push(b),J.successCount++,await X.hooks.onPageEnd?.(F,T)}catch(A){J.failedCount++,J.errors.push({route:F,error:A}),await X.hooks.onError?.(A,F),console.error(`Error generating ${F}:`,A)}}));if(X.cache)await Q.save();if(X.generate404){let j=w0.join(X.pagesDir,"404.stx");if(await Bun.file(j).exists()){let H=new Set,O={...Y,debug:!1,cache:!1},F=await K0(await Bun.file(j).text(),{},j,O,H);await Bun.write(w0.join(X.outputDir,"404.html"),F)}else await Bun.write(w0.join(X.outputDir,"404.html"),`<!DOCTYPE html>
11591
+ `)({params:L})){console.warn(`Validation failed for ${F}, skipping...`);return}}catch{}let I=null,S=!1;if(X.cache){if(I=Q.get(F,O.filePath,[]),I)S=!0,J.cachedCount++}if(!I){if(I=await lq(O,L,V,X,Y),X.cache)Q.set(F,O.filePath,[],I)}let k;if(X.trailingSlash)k=w0.join(X.outputDir,F,"index.html");else k=F==="/"?w0.join(X.outputDir,"index.html"):w0.join(X.outputDir,`${F}.html`);await m0.promises.mkdir(w0.dirname(k),{recursive:!0}),await Bun.write(k,I),B.push({loc:F,lastmod:new Date().toISOString().split("T")[0],priority:F==="/"?1:0.8});let x={route:F,outputPath:k,size:Buffer.byteLength(I,"utf8"),cached:S};if(N!==!1)x.revalidateAt=Date.now()+N*1000;J.pages.push(x),J.successCount++,await X.hooks.onPageEnd?.(F,I)}catch(A){J.failedCount++,J.errors.push({route:F,error:A}),await X.hooks.onError?.(A,F),console.error(`Error generating ${F}:`,A)}}));if(X.cache)await Q.save();if(X.generate404){let j=w0.join(X.pagesDir,"404.stx");if(await Bun.file(j).exists()){let H=new Set,O={...Y,debug:!1,cache:!1},F=await K0(await Bun.file(j).text(),{},j,O,H);await Bun.write(w0.join(X.outputDir,"404.html"),F)}else await Bun.write(w0.join(X.outputDir,"404.html"),`<!DOCTYPE html>
11592
11592
  <html lang="en">
11593
11593
  <head>
11594
11594
  <meta charset="UTF-8">
@@ -11629,7 +11629,7 @@ Build complete!
11629
11629
  <p>Redirecting to <a href="${$}">${$}</a>...</p>
11630
11630
  <script>window.location.replace('${$}')</script>
11631
11631
  </body>
11632
- </html>`}function FI($,Z){if($==="/"||$==="")return w0.join(Z.outputDir,"index.html");let Y=$.replace(/^\/|\/$/g,"");if(Z.trailingSlash)return w0.join(Z.outputDir,Y,"index.html");return w0.join(Z.outputDir,`${Y}.html`)}var VI;var tq=D(()=>{F7();W1();p0();P1();xZ();VI={generateStaticSite:iq,createISRHandler:rq,defineStaticPaths:sq,createMarkdownLoader:aq}});import{createHash as AI}from"crypto";import{getRouterScript as NI}from"stx-router";function P2($){return AI("sha256").update($).digest("hex").slice(0,8)}function y2($=!1){let Z=$?X6():M5(),Y=P2(Z);return{content:Z,filename:`runtime.${Y}.js`,hash:Y}}function x2(){let $=NI(),Z=P2($);return{content:$,filename:`router.${Z}.js`,hash:Z}}function wI($){return{runtimeTag:$.runtime?`<script src="/__stx/${$.runtime.filename}"></script>`:"",routerTag:$.router?`<script src="/__stx/${$.router.filename}"></script>`:"",cssTag:$.css?`<link rel="stylesheet" href="/__stx/${$.css.filename}">`:""}}var v2=D(()=>{E5()});import eq from"path";import{createHash as RI}from"crypto";function MI($={}){let Z=new Set;return{context:new Proxy($,{get(X,J){if(J in X)return X[J];if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return},has(X,J){if(J in X)return!0;if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return!1}}),accessedKeys:Z}}async function g2($,Z,Y={}){let X=eq.resolve($),J=await Bun.file(X).text(),Q=RI("sha256").update(J).digest("hex").slice(0,16);hY();let G={};try{G=await g0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(J))!==null){let O=U[1];if(/\bserver\b/.test(O))K.push(U[2])}let{context:_}=MI({__filename:X,__dirname:eq.dirname(X)}),B=new Set,z={...U1,...G,...Y,buildMode:"compile",strict:!1},q=await K0(J,_,X,z,B),j=_6(q),H=dY();return{route:Z,sourceFile:$,html:q,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(B),contentHash:Q}}var f2=D(()=>{W1();p0();$5();L7()});import h2 from"fs";import $j from"path";function d2($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function u2($,Z){let Y=$j.join(Z,"manifest.json");h2.writeFileSync(Y,JSON.stringify($,null,2))}function m2($){let Z=$j.join($,"manifest.json");if(!h2.existsSync(Z))return null;try{let Y=h2.readFileSync(Z,"utf-8"),X=JSON.parse(Y);if(X.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${X.version}`),null;return X}catch(Y){return console.warn("[stx] Failed to load manifest:",Y),null}}var hZ=()=>{};var Yj={};e(Yj,{buildForProduction:()=>Zj});import i1 from"fs";import e0 from"path";function TI($,Z){let Y=0,X=0;if(!i1.existsSync($))return{copied:Y,bytes:X};function J(Q,G){let K=i1.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(EI.has(W.name))continue;let U=e0.join(Q,W.name),_=e0.join(G,W.name);if(W.isDirectory())i1.mkdirSync(_,{recursive:!0}),J(U,_);else if(W.isFile()){if(i1.existsSync(_))continue;i1.copyFileSync(U,_),Y++,X+=i1.statSync(_).size}}}return J($,Z),{copied:Y,bytes:X}}async function Zj($={}){let Z=Date.now(),Y=e0.resolve($.root||process.cwd()),X=e0.resolve(Y,$.outputDir||".output");console.log("[stx build] Starting production build...");let J={};try{J=await g0()}catch{}let Q=$.componentsDir??J.componentsDir??"components",G=$.partialsDir??J.partialsDir??"partials",K=$.layoutsDir??J.layoutsDir??"layouts",W=$.publicDir??J.publicDir??"public",U=J.app?.head||{},_=J.router?.container||"main";if(i1.existsSync(X))i1.rmSync(X,{recursive:!0});let B=[e0.join(X,"public","__stx"),e0.join(X,"public","assets"),e0.join(X,"server","pages"),e0.join(X,"server","fragments")];for(let M of B)i1.mkdirSync(M,{recursive:!0});console.log("[stx build] Discovering routes...");let z=W4(Y),q=["components","layouts","partials"],j=z.filter((M)=>{return!q.some((E)=>M.pattern.startsWith(`/${E}/`)||M.pattern===`/${E}`)});console.log(`[stx build] Found ${j.length} page routes (${z.length-j.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=y2($.debug),O=x2();await Bun.write(e0.join(X,"public","__stx",H.filename),H.content),await Bun.write(e0.join(X,"public","__stx",O.filename),O.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${O.filename} (${(O.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let F=[],L=[];for(let M of j)try{let E=await g2(M.filePath,M.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(F.push(E),E.html=E.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,O.filename),E.html=A5(E.html,U,{bodyScripts:[`<script src="/__stx/${O.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(E.html)){let b=E.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(b&&b[1]){let y=b[1];E.html=E.html.replace(" "+y,""),E.html=E.html.replace(/<body([^>]*)>/,`<body$1 ${y}>`)}}E.html=E.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),E.html=await E0(E.html),E.fragment=O7(E.html,_);let T=M.pattern==="/"?"index":M.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),S=e0.join("server","pages",`${T}.compiled.json`),k=e0.join("server","fragments",`${T}.html`);await Bun.write(e0.join(X,S),JSON.stringify(E,null,2)),await Bun.write(e0.join(X,k),E.fragment),L.push({pattern:M.pattern,compiledPath:S,fragmentPath:k,isDynamic:E.hasServerScripts,hasParams:M.pattern.includes(":")||M.pattern.includes("[")}),console.log(`[stx build] \u2713 ${M.pattern}`)}catch(E){console.error(`[stx build] \u2717 ${M.pattern}:`,E instanceof Error?E.message:E)}let V=e0.resolve(Y,W);if(i1.existsSync(V)){let{copied:M,bytes:E}=TI(V,e0.join(X,"public"));if(M>0)console.log(`[stx build] Copied ${M} public asset${M===1?"":"s"} (${(E/1024).toFixed(1)}KB) from ${W}/`)}let N={runtime:H.filename,router:O.filename},A=d2(L,N,X);u2(A,X);let w=Date.now()-Z;return console.log(`
11632
+ </html>`}function FI($,Z){if($==="/"||$==="")return w0.join(Z.outputDir,"index.html");let Y=$.replace(/^\/|\/$/g,"");if(Z.trailingSlash)return w0.join(Z.outputDir,Y,"index.html");return w0.join(Z.outputDir,`${Y}.html`)}var VI;var tq=D(()=>{F7();W1();p0();P1();xZ();VI={generateStaticSite:iq,createISRHandler:rq,defineStaticPaths:sq,createMarkdownLoader:aq}});import{createHash as AI}from"crypto";import{getRouterScript as NI}from"stx-router";function P2($){return AI("sha256").update($).digest("hex").slice(0,8)}function y2($=!1){let Z=$?X6():M5(),Y=P2(Z);return{content:Z,filename:`runtime.${Y}.js`,hash:Y}}function x2(){let $=NI(),Z=P2($);return{content:$,filename:`router.${Z}.js`,hash:Z}}function wI($){return{runtimeTag:$.runtime?`<script src="/__stx/${$.runtime.filename}"></script>`:"",routerTag:$.router?`<script src="/__stx/${$.router.filename}"></script>`:"",cssTag:$.css?`<link rel="stylesheet" href="/__stx/${$.css.filename}">`:""}}var v2=D(()=>{E5()});import eq from"path";import{createHash as RI}from"crypto";function MI($={}){let Z=new Set;return{context:new Proxy($,{get(X,J){if(J in X)return X[J];if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return},has(X,J){if(J in X)return!0;if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return!1}}),accessedKeys:Z}}async function g2($,Z,Y={}){let X=eq.resolve($),J=await Bun.file(X).text(),Q=RI("sha256").update(J).digest("hex").slice(0,16);hY();let G={};try{G=await g0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(J))!==null){let O=U[1];if(/\bserver\b/.test(O))K.push(U[2])}let{context:_}=MI({__filename:X,__dirname:eq.dirname(X)}),B=new Set,z={...U1,...G,...Y,buildMode:"compile",strict:!1},q=await K0(J,_,X,z,B),j=_6(q),H=dY();return{route:Z,sourceFile:$,html:q,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(B),contentHash:Q}}var f2=D(()=>{W1();p0();$5();L7()});import h2 from"fs";import $j from"path";function d2($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function u2($,Z){let Y=$j.join(Z,"manifest.json");h2.writeFileSync(Y,JSON.stringify($,null,2))}function m2($){let Z=$j.join($,"manifest.json");if(!h2.existsSync(Z))return null;try{let Y=h2.readFileSync(Z,"utf-8"),X=JSON.parse(Y);if(X.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${X.version}`),null;return X}catch(Y){return console.warn("[stx] Failed to load manifest:",Y),null}}var hZ=()=>{};var Yj={};e(Yj,{buildForProduction:()=>Zj});import i1 from"fs";import e0 from"path";function TI($,Z){let Y=0,X=0;if(!i1.existsSync($))return{copied:Y,bytes:X};function J(Q,G){let K=i1.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(EI.has(W.name))continue;let U=e0.join(Q,W.name),_=e0.join(G,W.name);if(W.isDirectory())i1.mkdirSync(_,{recursive:!0}),J(U,_);else if(W.isFile()){if(i1.existsSync(_))continue;i1.copyFileSync(U,_),Y++,X+=i1.statSync(_).size}}}return J($,Z),{copied:Y,bytes:X}}async function Zj($={}){let Z=Date.now(),Y=e0.resolve($.root||process.cwd()),X=e0.resolve(Y,$.outputDir||".output");console.log("[stx build] Starting production build...");let J={};try{J=await g0()}catch{}let Q=$.componentsDir??J.componentsDir??"components",G=$.partialsDir??J.partialsDir??"partials",K=$.layoutsDir??J.layoutsDir??"layouts",W=$.publicDir??J.publicDir??"public",U=J.app?.head||{},_=J.router?.container||"main";if(i1.existsSync(X))i1.rmSync(X,{recursive:!0});let B=[e0.join(X,"public","__stx"),e0.join(X,"public","assets"),e0.join(X,"server","pages"),e0.join(X,"server","fragments")];for(let M of B)i1.mkdirSync(M,{recursive:!0});console.log("[stx build] Discovering routes...");let z=W4(Y),q=["components","layouts","partials"],j=z.filter((M)=>{return!q.some((E)=>M.pattern.startsWith(`/${E}/`)||M.pattern===`/${E}`)});console.log(`[stx build] Found ${j.length} page routes (${z.length-j.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=y2($.debug),O=x2();await Bun.write(e0.join(X,"public","__stx",H.filename),H.content),await Bun.write(e0.join(X,"public","__stx",O.filename),O.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${O.filename} (${(O.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let F=[],L=[];for(let M of j)try{let E=await g2(M.filePath,M.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(F.push(E),E.html=E.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,O.filename),E.html=A5(E.html,U,{bodyScripts:[`<script src="/__stx/${O.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(E.html)){let x=E.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(x&&x[1]){let f=x[1];E.html=E.html.replace(" "+f,""),E.html=E.html.replace(/<body([^>]*)>/,`<body$1 ${f}>`)}}E.html=E.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),E.html=await E0(E.html),E.fragment=O7(E.html,_);let I=M.pattern==="/"?"index":M.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),S=e0.join("server","pages",`${I}.compiled.json`),k=e0.join("server","fragments",`${I}.html`);await Bun.write(e0.join(X,S),JSON.stringify(E,null,2)),await Bun.write(e0.join(X,k),E.fragment),L.push({pattern:M.pattern,compiledPath:S,fragmentPath:k,isDynamic:E.hasServerScripts,hasParams:M.pattern.includes(":")||M.pattern.includes("[")}),console.log(`[stx build] \u2713 ${M.pattern}`)}catch(E){console.error(`[stx build] \u2717 ${M.pattern}:`,E instanceof Error?E.message:E)}let V=e0.resolve(Y,W);if(i1.existsSync(V)){let{copied:M,bytes:E}=TI(V,e0.join(X,"public"));if(M>0)console.log(`[stx build] Copied ${M} public asset${M===1?"":"s"} (${(E/1024).toFixed(1)}KB) from ${W}/`)}let N={runtime:H.filename,router:O.filename},A=d2(L,N,X);u2(A,X);let w=Date.now()-Z;return console.log(`
11633
11633
  [stx build] Done in ${w}ms \u2014 ${F.length} pages compiled`),{pageCount:F.length,assets:N,outputDir:X,duration:w}}var EI;var c2=D(()=>{F7();v2();f2();hZ();L7();P1();p0();EI=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"])});var Jj={};e(Jj,{buildApp:()=>Xj});import II from"path";async function Xj($={}){let Z=performance.now(),Y=$.root||process.cwd(),X=await g0(),J=X.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${J.toUpperCase()}${X.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let Q,G;if(J==="ssg"){let{generateStaticSite:W}=await Promise.resolve().then(() => (tq(),oq));Q=await W({pagesDir:II.join(X.root||".",X.pagesDir||X.build?.pagesDir||"pages"),publicDir:X.publicDir||X.build?.publicDir||"public",outputDir:X.build?.outputDir||"dist",generate404:X.build?.generate404??!0,minify:X.build?.minify??!0,cleanOutput:X.build?.cleanOutput??!0,...$.ssg})}else{let{buildForProduction:W}=await Promise.resolve().then(() => (c2(),Yj));G=await W({outputDir:".output",debug:$.debug,...$.ssr})}let K=Math.round(performance.now()-Z);return{mode:J,ssg:Q,ssr:G,duration:K}}var p2=D(()=>{p0()});import dZ from"path";async function kI($){let Z=performance.now(),Y=await g0(),X=$||Y.root||process.cwd(),J=[Y.build?.pagesDir||Y.pagesDir||"pages",Y.componentsDir||"components",Y.layoutsDir||"layouts",Y.partialsDir||"partials"].map((K)=>dZ.resolve(X,K)),Q=[],G=0;for(let K of J){let W=await Gj(K);for(let U of W){G++;let _=await Bun.file(U).text();if(Qj.test(_))Q.push(dZ.relative(X,U))}}return{mode:Q.length>0?"ssr":"ssg",serverScriptFiles:Q,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-Z)}}async function SI($){let Z=await g0(),Y=$||Z.root||process.cwd(),X=dZ.resolve(Y,Z.componentsDir||"components"),J=[],Q=await Gj(X);for(let G of Q){let K=await Bun.file(G).text(),W=Qj.test(K),U=DI.test(K)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(K)&&!W;if(W&&U){let _=dZ.relative(Y,G);J.push({file:_,message:`Component "${_}" has both <script server> and <script client>. `+"Components should be server OR client \u2014 compose them via props/slots."})}}return J}async function Gj($){let Z=[];try{let Y=new Bun.Glob("**/*.stx");for await(let X of Y.scan({cwd:$,absolute:!0}))Z.push(X)}catch{}return Z}var Qj,DI;var Kj=D(()=>{p0();Qj=/<script\b[^>]*\bserver\b/i,DI=/<script\b[^>]*\bclient\b/i});function l2($){let Z=new Map,Y=/@(\w+)/g,X,J=1,Q=0;while((X=Y.exec($))!==null){let G=X[1],K=$.slice(Q,X.index);J+=(K.match(/\n/g)||[]).length,Q=X.index;let W=X.index-$.lastIndexOf(`
11634
11634
  `,X.index-1);if(Uj.includes(G)){let U=Z.get(G);if(U)U.count++,U.locations.push({line:J,column:W});else Z.set(G,{name:G,count:1,locations:[{line:J,column:W}]})}}return Array.from(Z.values())}function _j($,Z=[]){let Y=l2($),X=new Set(Y.map((J)=>J.name));for(let J of Z)X.add(J);for(let J of Array.from(X))if(!J.startsWith("end"))X.add(`end${J}`);return Uj.filter((J)=>!X.has(J))}function Bj($){let Z=[],Y={conditionals:["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","isset","endisset"],loops:["for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty"],includes:["include","includeIf","includeWhen","includeFirst","once","endonce","extends","section","endsection","yield","parent","push","endpush","prepend","endprepend","stack"],components:["component","endcomponent","slot","endslot","props"],auth:["auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole"],forms:["csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file"],i18n:["translate","lang","choice"],seo:["meta","title","seo","jsonld","canonical","robots","sitemap"]},X=new Set;for(let Q of $)for(let[G,K]of Object.entries(Y))if(K.includes(Q)){X.add(G);break}for(let Q of X)Z.push(`import { process${CI(Q)} } from './${Q}'`);let J=$.filter((Q)=>!Q.startsWith("end")).map((Q)=>` '${Q}': true`).join(`,
11635
11635
  `);return`// Tree-shaken directive bundle
@@ -12789,14 +12789,14 @@ describe('Example', () => {
12789
12789
  </footer>
12790
12790
  @yield('scripts')
12791
12791
  </body>
12792
- </html>`}function _k(){return"<!-- Hero section -->"}function Bk(){return"<!-- Features -->"}function zk(){return"<!-- Pricing -->"}function qk(){return"<!-- Button -->"}function I7($){if(!T7($))BQ($,{recursive:!0})}function jk(){if(T7("bun.lockb"))return"bun";if(T7("pnpm-lock.yaml"))return"pnpm";if(T7("yarn.lock"))return"yarn";return"bun"}function zQ($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function Hk($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function q6($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var bD;var HH=D(()=>{bD={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}}});var{serve:Ok}=globalThis.Bun;import D7 from"fs";import n4 from"path";function Lk($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function OH($={}){let{port:Z=3000,root:Y=".",stxOptions:X={},watch:J=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,_=n4.resolve(Y),B=new Map;async function z(L){let V=D7.statSync(L),N=`${L}:${V.mtimeMs}`,A=B.get(N);if(A)return A.content;for(let u of B.keys())if(u.startsWith(`${L}:`)&&u!==N)B.delete(u);let w=await Bun.file(L).text(),M=w,E=w.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>/i);if(E&&E.index!==void 0){let u=E.index+E[0].length,l=1,i=u;while(i<w.length&&l>0){let _0=w.indexOf("<template",i),q0=w.indexOf("</template>",i);if(q0===-1)break;if(_0!==-1&&_0<q0)l++,i=_0+9;else{if(l--,l===0){M=w.substring(u,q0).trim();break}i=q0+11}}}let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,T=[],S=[],k;while((k=I.exec(w))!==null){let u=k[1],l=k[2],i=k[0];if(u.includes("server"))S.push(l);else T.push(i)}let b=w.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],y=M.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),v={__filename:L,__dirname:n4.dirname(L)};for(let u of S)await A0(u,v,L);let h=await K0(y,v,L,X,new Set);if(b.length>0){let u=b.join(`
12792
+ </html>`}function _k(){return"<!-- Hero section -->"}function Bk(){return"<!-- Features -->"}function zk(){return"<!-- Pricing -->"}function qk(){return"<!-- Button -->"}function I7($){if(!T7($))BQ($,{recursive:!0})}function jk(){if(T7("bun.lockb"))return"bun";if(T7("pnpm-lock.yaml"))return"pnpm";if(T7("yarn.lock"))return"yarn";return"bun"}function zQ($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function Hk($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function q6($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var bD;var HH=D(()=>{bD={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}}});var{serve:Ok}=globalThis.Bun;import D7 from"fs";import n4 from"path";function Lk($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function OH($={}){let{port:Z=3000,root:Y=".",stxOptions:X={},watch:J=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,_=n4.resolve(Y),B=new Map;async function z(L){let V=D7.statSync(L),N=`${L}:${V.mtimeMs}`,A=B.get(N);if(A)return A.content;for(let u of B.keys())if(u.startsWith(`${L}:`)&&u!==N)B.delete(u);let w=await Bun.file(L).text(),M=w,E=w.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>/i);if(E&&E.index!==void 0){let u=E.index+E[0].length,p=1,i=u;while(i<w.length&&p>0){let _0=w.indexOf("<template",i),q0=w.indexOf("</template>",i);if(q0===-1)break;if(_0!==-1&&_0<q0)p++,i=_0+9;else{if(p--,p===0){M=w.substring(u,q0).trim();break}i=q0+11}}}let T=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[],S=[],k;while((k=T.exec(w))!==null){let u=k[1],p=k[2],i=k[0];if(u.includes("server"))S.push(p);else I.push(i)}let x=w.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],f=M.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),b={__filename:L,__dirname:n4.dirname(L)};for(let u of S)await A0(u,b,L);let h=await K0(f,b,L,X,new Set);if(x.length>0){let u=x.join(`
12793
12793
  `);if(h.match(/(<\/head>)/i))h=h.replace(/(<\/head>)/i,`${u}
12794
- $1`)}if(T.length>0){let{interpolateScriptsInTemplate:u}=await Promise.resolve().then(() => (c0(),X5)),l=u(T.join(`
12795
- `),v);if(h.match(/(<\/body>)/i))h=h.replace(/(<\/body>)/i,`${l}
12794
+ $1`)}if(I.length>0){let{interpolateScriptsInTemplate:u}=await Promise.resolve().then(() => (c0(),X5)),p=u(I.join(`
12795
+ `),b);if(h.match(/(<\/body>)/i))h=h.replace(/(<\/body>)/i,`${p}
12796
12796
  $1`);else h+=`
12797
- ${l}`}return B.set(N,{content:h,mtime:V.mtimeMs}),h}async function q(L){let V=D7.statSync(L),N=`${L}:${V.mtimeMs}`,A=B.get(N);if(A)return A.content;let{content:w}=await X4(L,X);return B.set(N,{content:w,mtime:V.mtimeMs}),w}function j(L){let V=L.startsWith("/")?L.slice(1):L,N=[V,`${V}.stx`,`${V}.md`,`${V}.html`,n4.join(V,"index.stx"),n4.join(V,"index.md"),n4.join(V,"index.html")];for(let A of N){let w=n4.join(_,A);if(D7.existsSync(w)&&D7.statSync(w).isFile())return w}return null}async function H(L){let V=new URL(L.url),N=async()=>{if(G[V.pathname])return await G[V.pathname](L);if(Q){let w=await Q(L);if(w)return w}let A=j(V.pathname);if(!A){if(W)return await W(L);return new Response("Not Found",{status:404})}try{let w,M="text/html";if(A.endsWith(".stx"))w=await z(A);else if(A.endsWith(".md"))w=await q(A);else if(A.endsWith(".html"))w=await Bun.file(A).text();else if(A.endsWith(".css"))w=await Bun.file(A).text(),M="text/css";else if(A.endsWith(".js"))w=await Bun.file(A).text(),M="text/javascript";else if(A.endsWith(".json"))w=await Bun.file(A).text(),M="application/json";else return new Response(Bun.file(A));return new Response(w,{headers:{"Content-Type":M}})}catch(w){if(U)return await U(w,L);let M=w instanceof Error?w.message:String(w),I=X?.debug===!0?`<h1>Error</h1><pre>${M}
12798
- ${w instanceof Error?w.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(I,{status:500,headers:{"Content-Type":"text/html"}})}};for(let A=K.length-1;A>=0;A--){let w=K[A],M=N;N=async()=>await w(L,M)}return await N()}let O=Ok({port:Z,fetch:H}),F=null;if(J)F=D7.watch(_,{recursive:!0},(L,V)=>{if(V&&(V.endsWith(".stx")||V.endsWith(".md")||V.endsWith(".html")))B.clear()});return{server:O,url:O.url.toString(),stop(){if(F)F.close();O.stop()}}}async function Fk($,Z={}){let Y=n4.resolve($);if(!await Bun.file(Y).exists())throw Error(`File not found: ${Y}`);let X=Y.endsWith(".md"),J=Y.endsWith(".stx");if(!X&&!J)throw Error(`Unsupported file type: ${Y}. Only .stx and .md files are supported.`);return await OH({...Z,root:n4.dirname(Y),routes:{"/":async()=>{let Q;if(X){let{content:G}=await X4(Y,Z.stxOptions);Q=G}else{let G=await Bun.file(Y).text(),K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(G))!==null)if(U[1].includes("server"))K.push(U[2]);let _=K.join(`
12799
- `),B=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),z={};if(_.trim())await A0(_,z,Y);let q=new Set;Q=await K0(B,z,Y,Z.stxOptions||{},q)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function Vk($){return $}function Ak($){return $}var LH=D(()=>{s6();W1();O0()});import lZ from"path";function Nk($){let Z=[],Y=0,X;FH.lastIndex=0;while((X=FH.exec($))!==null){if(X.index>Y){let G=$.slice(Y,X.index);if(G.trim())Z.push({type:Z.length===0?"shell":"content",content:G})}let J=X[1],Q=X[2];Z.push({type:"suspense",name:J,content:Q}),Y=X.index+X[0].length}if(Y<$.length){let J=$.slice(Y);if(J.trim())Z.push({type:Z.length===0?"shell":"content",content:J})}if(Z.length===0)Z.push({type:"shell",content:$});return Z}async function wk($,Z={},Y={}){let X={...U1,...Y,streaming:{...qQ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:lZ.dirname($)};if(W.trim())await A0(W,_,$);let B=Nk(U),z=new Set;if(!B.some((j)=>j.type==="suspense")){let j=X.streaming?.strategy||"auto",H=new RegExp(j6.source,"g");if(!(j!=="manual"&&H.test(U))){let F=await K0(U,_,$,X,z);for(let L=0;L<F.length;L+=J)Q.enqueue(F.slice(L,L+J)),await new Promise((V)=>setTimeout(V,0))}else{let F=[],L=new RegExp(j6.source,"g"),V;while((V=L.exec(U))!==null)F.push({name:V[1],content:V[2],start:V.index,end:V.index+V[0].length});let N=0;for(let A of F){if(A.start>N){let M=U.slice(N,A.start);if(M.trim()){let E=await K0(M,_,$,X,z);Q.enqueue(E),await new Promise((I)=>setTimeout(I,0))}}let w=await K0(A.content,_,$,X,z);Q.enqueue(w),await new Promise((M)=>setTimeout(M,0)),N=A.end}if(N<U.length){let A=U.slice(N);if(A.trim()){let w=await K0(A,_,$,X,z);Q.enqueue(w)}}}}else{let j=new Map;for(let O of B)if(O.type==="shell"||O.type==="content"){let F=await K0(O.content,_,$,X,z);Q.enqueue(F)}else if(O.type==="suspense"&&O.name){let F=`stx-suspense-${O.name}`;Q.enqueue(`<div id="${F}" data-suspense="${O.name}" style="display:contents;">
12797
+ ${p}`}return B.set(N,{content:h,mtime:V.mtimeMs}),h}async function q(L){let V=D7.statSync(L),N=`${L}:${V.mtimeMs}`,A=B.get(N);if(A)return A.content;let{content:w}=await X4(L,X);return B.set(N,{content:w,mtime:V.mtimeMs}),w}function j(L){let V=L.startsWith("/")?L.slice(1):L,N=[V,`${V}.stx`,`${V}.md`,`${V}.html`,n4.join(V,"index.stx"),n4.join(V,"index.md"),n4.join(V,"index.html")];for(let A of N){let w=n4.join(_,A);if(D7.existsSync(w)&&D7.statSync(w).isFile())return w}return null}async function H(L){let V=new URL(L.url),N=async()=>{if(G[V.pathname])return await G[V.pathname](L);if(Q){let w=await Q(L);if(w)return w}let A=j(V.pathname);if(!A){if(W)return await W(L);return new Response("Not Found",{status:404})}try{let w,M="text/html";if(A.endsWith(".stx"))w=await z(A);else if(A.endsWith(".md"))w=await q(A);else if(A.endsWith(".html"))w=await Bun.file(A).text();else if(A.endsWith(".css"))w=await Bun.file(A).text(),M="text/css";else if(A.endsWith(".js"))w=await Bun.file(A).text(),M="text/javascript";else if(A.endsWith(".json"))w=await Bun.file(A).text(),M="application/json";else return new Response(Bun.file(A));return new Response(w,{headers:{"Content-Type":M}})}catch(w){if(U)return await U(w,L);let M=w instanceof Error?w.message:String(w),T=X?.debug===!0?`<h1>Error</h1><pre>${M}
12798
+ ${w instanceof Error?w.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(T,{status:500,headers:{"Content-Type":"text/html"}})}};for(let A=K.length-1;A>=0;A--){let w=K[A],M=N;N=async()=>await w(L,M)}return await N()}let O=Ok({port:Z,fetch:H}),F=null;if(J)F=D7.watch(_,{recursive:!0},(L,V)=>{if(V&&(V.endsWith(".stx")||V.endsWith(".md")||V.endsWith(".html")))B.clear()});return{server:O,url:O.url.toString(),stop(){if(F)F.close();O.stop()}}}async function Fk($,Z={}){let Y=n4.resolve($);if(!await Bun.file(Y).exists())throw Error(`File not found: ${Y}`);let X=Y.endsWith(".md"),J=Y.endsWith(".stx");if(!X&&!J)throw Error(`Unsupported file type: ${Y}. Only .stx and .md files are supported.`);return await OH({...Z,root:n4.dirname(Y),routes:{"/":async()=>{let Q;if(X){let{content:G}=await X4(Y,Z.stxOptions);Q=G}else{let G=await Bun.file(Y).text(),K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(G))!==null)if(U[1].includes("server"))K.push(U[2]);let _=K.join(`
12799
+ `),B=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),z={};if(_.trim())await A0(_,z,Y);let q=new Set;Q=await K0(B,z,Y,Z.stxOptions||{},q)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function Vk($){return $}function Ak($){return $}var LH=D(()=>{s6();W1();O0()});import lZ from"path";function Nk($){let Z=[],Y=0,X;FH.lastIndex=0;while((X=FH.exec($))!==null){if(X.index>Y){let G=$.slice(Y,X.index);if(G.trim())Z.push({type:Z.length===0?"shell":"content",content:G})}let J=X[1],Q=X[2];Z.push({type:"suspense",name:J,content:Q}),Y=X.index+X[0].length}if(Y<$.length){let J=$.slice(Y);if(J.trim())Z.push({type:Z.length===0?"shell":"content",content:J})}if(Z.length===0)Z.push({type:"shell",content:$});return Z}async function wk($,Z={},Y={}){let X={...U1,...Y,streaming:{...qQ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:lZ.dirname($)};if(W.trim())await A0(W,_,$);let B=Nk(U),z=new Set;if(!B.some((j)=>j.type==="suspense")){let j=X.streaming?.strategy||"auto",H=new RegExp(j6.source,"g");if(!(j!=="manual"&&H.test(U))){let F=await K0(U,_,$,X,z);for(let L=0;L<F.length;L+=J)Q.enqueue(F.slice(L,L+J)),await new Promise((V)=>setTimeout(V,0))}else{let F=[],L=new RegExp(j6.source,"g"),V;while((V=L.exec(U))!==null)F.push({name:V[1],content:V[2],start:V.index,end:V.index+V[0].length});let N=0;for(let A of F){if(A.start>N){let M=U.slice(N,A.start);if(M.trim()){let E=await K0(M,_,$,X,z);Q.enqueue(E),await new Promise((T)=>setTimeout(T,0))}}let w=await K0(A.content,_,$,X,z);Q.enqueue(w),await new Promise((M)=>setTimeout(M,0)),N=A.end}if(N<U.length){let A=U.slice(N);if(A.trim()){let w=await K0(A,_,$,X,z);Q.enqueue(w)}}}}else{let j=new Map;for(let O of B)if(O.type==="shell"||O.type==="content"){let F=await K0(O.content,_,$,X,z);Q.enqueue(F)}else if(O.type==="suspense"&&O.name){let F=`stx-suspense-${O.name}`;Q.enqueue(`<div id="${F}" data-suspense="${O.name}" style="display:contents;">
12800
12800
  <template data-suspense-fallback>Loading...</template>
12801
12801
  </div>`),j.set(O.name,K0(O.content,_,$,X,z))}Q.enqueue(`
12802
12802
  <script>
@@ -14531,7 +14531,7 @@ else {
14531
14531
  window.STX.lazyLoad = loadElement;
14532
14532
  window.STX.initLazyLoading = init;
14533
14533
  })();
14534
- `.trim()}var XO;var jG=D(()=>{XO={root:null,rootMargin:"50px 0px",threshold:0,useNative:!0,selector:"[data-stx-lazy]"}});function YY($,Z={}){let Y={...GS,...Z},X=$.closest(".stx-img-placeholder");if(!X){KS($,Y);return}if(X.style.setProperty("--stx-img-transition-duration",`${Y.duration}ms`),X.style.setProperty("--stx-img-transition-easing",Y.easing),Y.loadingClass)X.classList.add(Y.loadingClass);if($.complete&&$.naturalWidth>0)JO($,X,Y);else $.addEventListener("load",()=>JO($,X,Y),{once:!0}),$.addEventListener("error",()=>WS($,X,Y),{once:!0})}function KS($,Z){let Y=()=>{$.style.transition=`opacity ${Z.duration}ms ${Z.easing}`,$.style.opacity="1",$.classList.remove(Z.loadingClass),$.classList.add(Z.loadedClass)};if($.complete&&$.naturalWidth>0)Y();else $.style.opacity="0",$.classList.add(Z.loadingClass),$.addEventListener("load",Y,{once:!0})}function JO($,Z,Y){if(Y.loadingClass)Z.classList.remove(Y.loadingClass);if(Y.loadedClass)Z.classList.add(Y.loadedClass);if($.style.opacity="1",Y.removePlaceholder)setTimeout(()=>{Z.style.backgroundImage="none"},Y.duration)}function WS($,Z,Y){if(Y.loadingClass)Z.classList.remove(Y.loadingClass);Z.classList.add("stx-img-error"),$.classList.add("stx-img-error")}function HG($,Z){let Y=x7($),X=Z.getContext("2d");if(!X)return;Z.width=Y.w,Z.height=Y.h;let J=X.createImageData(Y.w,Y.h);J.data.set(Y.rgba),X.putImageData(J,0,0)}function x7($){let Z=$[0]|$[1]<<8|$[2]<<16,Y=(Z&63)/63,X=(Z>>6&63)/31.5-1,J=(Z>>12&63)/31.5-1,Q=(Z>>18&31)/31,G=Z>>23!==0,K=$[3]|$[4]<<8,W=(K>>3&63)/63,U=(K>>9&63)/63,_=K>>15!==0,B=Math.max(3,_?G?5:7:G?5:5),z=Math.max(3,_?G?5:5:G?5:7),q=32,j=32,H=new Uint8ClampedArray(4096);for(let O=0;O<32;O++)for(let F=0;F<32;F++){let L=(O*32+F)*4,V=F/31,N=O/31,A=Y+(V-0.5)*Q*0.5+(N-0.5)*Q*0.5,w=X*(1-V*0.3),M=J*(1-N*0.3),E=A-0.6666666666666666*w,I=(3*A-E+M)/2,T=I-M;H[L]=Math.max(0,Math.min(255,Math.round(I*255))),H[L+1]=Math.max(0,Math.min(255,Math.round(T*255))),H[L+2]=Math.max(0,Math.min(255,Math.round(E*255))),H[L+3]=255}return{w:32,h:32,rgba:H}}function OG($){let Z=x7($),Y=document.createElement("canvas");Y.width=Z.w,Y.height=Z.h;let X=Y.getContext("2d");if(!X)return"";let J=X.createImageData(Z.w,Z.h);return J.data.set(Z.rgba),X.putImageData(J,0,0),Y.toDataURL("image/png")}function LG($){let Z=atob($),Y=new Uint8Array(Z.length);for(let X=0;X<Z.length;X++)Y[X]=Z.charCodeAt(X);return Y}function FG($,Z,Y=300){return new Promise((X)=>{$.style.transition=`opacity ${Y}ms ease-out`,Z.style.transition=`opacity ${Y}ms ease-out`,Z.style.opacity="0",Z.offsetWidth,$.style.opacity="0",Z.style.opacity="1",setTimeout(X,Y)})}function VG($={}){document.querySelectorAll("[data-stx-blur-up], .stx-img-placeholder img").forEach((Y)=>{YY(Y,$)})}function v7(){return`
14534
+ `.trim()}var XO;var jG=D(()=>{XO={root:null,rootMargin:"50px 0px",threshold:0,useNative:!0,selector:"[data-stx-lazy]"}});function YY($,Z={}){let Y={...GS,...Z},X=$.closest(".stx-img-placeholder");if(!X){KS($,Y);return}if(X.style.setProperty("--stx-img-transition-duration",`${Y.duration}ms`),X.style.setProperty("--stx-img-transition-easing",Y.easing),Y.loadingClass)X.classList.add(Y.loadingClass);if($.complete&&$.naturalWidth>0)JO($,X,Y);else $.addEventListener("load",()=>JO($,X,Y),{once:!0}),$.addEventListener("error",()=>WS($,X,Y),{once:!0})}function KS($,Z){let Y=()=>{$.style.transition=`opacity ${Z.duration}ms ${Z.easing}`,$.style.opacity="1",$.classList.remove(Z.loadingClass),$.classList.add(Z.loadedClass)};if($.complete&&$.naturalWidth>0)Y();else $.style.opacity="0",$.classList.add(Z.loadingClass),$.addEventListener("load",Y,{once:!0})}function JO($,Z,Y){if(Y.loadingClass)Z.classList.remove(Y.loadingClass);if(Y.loadedClass)Z.classList.add(Y.loadedClass);if($.style.opacity="1",Y.removePlaceholder)setTimeout(()=>{Z.style.backgroundImage="none"},Y.duration)}function WS($,Z,Y){if(Y.loadingClass)Z.classList.remove(Y.loadingClass);Z.classList.add("stx-img-error"),$.classList.add("stx-img-error")}function HG($,Z){let Y=x7($),X=Z.getContext("2d");if(!X)return;Z.width=Y.w,Z.height=Y.h;let J=X.createImageData(Y.w,Y.h);J.data.set(Y.rgba),X.putImageData(J,0,0)}function x7($){let Z=$[0]|$[1]<<8|$[2]<<16,Y=(Z&63)/63,X=(Z>>6&63)/31.5-1,J=(Z>>12&63)/31.5-1,Q=(Z>>18&31)/31,G=Z>>23!==0,K=$[3]|$[4]<<8,W=(K>>3&63)/63,U=(K>>9&63)/63,_=K>>15!==0,B=Math.max(3,_?G?5:7:G?5:5),z=Math.max(3,_?G?5:5:G?5:7),q=32,j=32,H=new Uint8ClampedArray(4096);for(let O=0;O<32;O++)for(let F=0;F<32;F++){let L=(O*32+F)*4,V=F/31,N=O/31,A=Y+(V-0.5)*Q*0.5+(N-0.5)*Q*0.5,w=X*(1-V*0.3),M=J*(1-N*0.3),E=A-0.6666666666666666*w,T=(3*A-E+M)/2,I=T-M;H[L]=Math.max(0,Math.min(255,Math.round(T*255))),H[L+1]=Math.max(0,Math.min(255,Math.round(I*255))),H[L+2]=Math.max(0,Math.min(255,Math.round(E*255))),H[L+3]=255}return{w:32,h:32,rgba:H}}function OG($){let Z=x7($),Y=document.createElement("canvas");Y.width=Z.w,Y.height=Z.h;let X=Y.getContext("2d");if(!X)return"";let J=X.createImageData(Z.w,Z.h);return J.data.set(Z.rgba),X.putImageData(J,0,0),Y.toDataURL("image/png")}function LG($){let Z=atob($),Y=new Uint8Array(Z.length);for(let X=0;X<Z.length;X++)Y[X]=Z.charCodeAt(X);return Y}function FG($,Z,Y=300){return new Promise((X)=>{$.style.transition=`opacity ${Y}ms ease-out`,Z.style.transition=`opacity ${Y}ms ease-out`,Z.style.opacity="0",Z.offsetWidth,$.style.opacity="0",Z.style.opacity="1",setTimeout(X,Y)})}function VG($={}){document.querySelectorAll("[data-stx-blur-up], .stx-img-placeholder img").forEach((Y)=>{YY(Y,$)})}function v7(){return`
14535
14535
  (function() {
14536
14536
  'use strict';
14537
14537
 
@@ -14899,13 +14899,13 @@ ${O}`}if(j=await Z4(j),K.forEach((H)=>X.add(H)),Y.cache&&Y.cachePath){if(await S
14899
14899
  <h1>Something went wrong</h1>
14900
14900
  <p>An internal error occurred. Please try again later.</p>
14901
14901
  </body>
14902
- </html>`,loader:"html"}}})}}});var{serve:Ub}=globalThis.Bun;import k1 from"fs";import Q1 from"path";async function n7($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=Q1.resolve($);if(!k1.existsSync(K))return console.error(`${R.red}Error: File not found: ${R.bright}${K}${R.reset}`),!1;if(K.endsWith(".md"))return VZ(K,Z);else if(!K.endsWith(".stx"))return console.error(`${R.red}Error: Unsupported file type: ${R.bright}${K}${R.reset}. Only .stx and .md files are supported.`),!1;let W=Q1.join(process.cwd(),".stx/output");k1.mkdirSync(W,{recursive:!0}),console.log(`${R.blue}Building ${R.bright}${$}${R.reset}...`);let U=null,_=async()=>{try{let L={name:"public-assets",setup(w){w.onResolve({filter:/^\/(images|fonts|assets|public)\//},(M)=>{return{path:M.path,external:!0}})}},V=await Bun.build({entrypoints:[K],outdir:W,plugins:[L,m$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!V.success)return console.error(`${R.red}Build failed:${R.reset}`,V.logs),!1;let N=V.outputs.find((w)=>w.path.endsWith(".html"));if(!N)return console.error(`${R.red}No HTML output found${R.reset}`),!1;return U=await Bun.file(N.path).text(),!0}catch(L){return console.error(`${R.red}Error building stx file:${R.reset}`,L),!1}};if(!await _())return!1;let z=Q1.dirname(K);await S6(z);let q=Y;try{if(q=await d4(Y),q!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${q} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}if(J){let L=Z.hmrPort||q+1;Q=e5({wsPort:L,verbose:!1}),G=Q.start(L)}let j={},H=null;try{let{loadStxConfig:L}=await Promise.resolve().then(() => (c4(),B6)),V=await L();if(V?.apiRouter)H=V?.apiRouter,console.log(`${R.blue}Using custom router for API handling${R.reset}`);if(V?.apiRoutes){j=V.apiRoutes;let N=Object.keys(j).length;if(N>0)console.log(`${R.blue}Loaded ${R.bright}${N} API route${N>1?"s":""}${R.reset}`)}if(V?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:A}=await Promise.resolve().then(() => (mZ(),r2)),w=V.broadcasting;await N(w);let M=w.port??6001;console.log(`${R.magenta}Broadcasting on ${R.cyan}ws://localhost:${M}/ws${R.reset}`);let E=Q1.join(process.cwd(),"channels.ts");if(k1.existsSync(E))try{let I=await A(E);console.log(`${R.blue}Loaded ${R.bright}${I} broadcast channel${I!==1?"s":""}${R.blue} from channels.ts${R.reset}`)}catch(I){console.warn(`${R.yellow}Failed to load channels.ts: ${I.message}${R.reset}`)}}catch(N){console.warn(`${R.yellow}Broadcasting failed to start: ${N.message}${R.reset}`)}}catch{}if(console.log(`${R.blue}Starting server on ${R.cyan}http://localhost:${q}/${R.reset}...`),J)console.log(`${R.magenta}Hot reload enabled on ws://localhost:${G}${R.reset}`);let O=Ub({port:q,async fetch(L){let V=new URL(L.url);if(H)try{let E=await H.handleRequest(L);if(E.status!==404)return E}catch{}if(j[V.pathname])try{return await j[V.pathname](L)}catch(E){return new Response(JSON.stringify({error:E.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(V.pathname==="/")return(async()=>{let I=await E0(U||"");if(J)I=u1(I,G);if(Z.native)if(I.includes("<head>"))I=I.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(I.includes("<html"))I=I.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else I="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+I;return I})().then((I)=>new Response(I,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let N=Q1.join(W,V.pathname);if(k1.existsSync(N)&&k1.statSync(N).isFile()){let E=Bun.file(N),I=Q1.extname(N).toLowerCase(),T="text/plain";if(I===".ts"||I===".tsx"){let S=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),k=await E.text(),b=S.transformSync(k);return new Response(b,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":T="text/html";break;case".css":T="text/css";break;case".js":T="text/javascript";break;case".json":T="application/json";break;case".png":T="image/png";break;case".jpg":case".jpeg":T="image/jpeg";break;case".gif":T="image/gif";break;case".woff":T="font/woff";break;case".woff2":T="font/woff2";break;case".ttf":T="font/ttf";break;case".otf":T="font/otf";break;case".eot":T="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":T}})}let A=Q1.dirname(K),w=Q1.join(A,V.pathname);if(k1.existsSync(w)&&k1.statSync(w).isFile()){let E=Bun.file(w),I=Q1.extname(w).toLowerCase(),T="text/plain";if(I===".ts"||I===".tsx"){let S=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),k=await E.text(),b=S.transformSync(k);return new Response(b,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":T="text/html";break;case".css":T="text/css";break;case".js":T="text/javascript";break;case".json":T="application/json";break;case".png":T="image/png";break;case".jpg":case".jpeg":T="image/jpeg";break;case".gif":T="image/gif";break;case".svg":T="image/svg+xml";break;case".ico":T="image/x-icon";break;case".woff":T="font/woff";break;case".woff2":T="font/woff2";break;case".ttf":T="font/ttf";break;case".otf":T="font/otf";break;case".eot":T="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":T}})}let M=Q1.join(process.cwd(),"public",V.pathname);if(k1.existsSync(M)&&k1.statSync(M).isFile()){let E=Bun.file(M),I=Q1.extname(M).toLowerCase(),T="application/octet-stream";if(I===".ts"||I===".tsx"){let S=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),k=await E.text(),b=S.transformSync(k);return new Response(b,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":T="text/html";break;case".css":T="text/css";break;case".js":T="text/javascript";break;case".json":T="application/json";break;case".png":T="image/png";break;case".jpg":case".jpeg":T="image/jpeg";break;case".gif":T="image/gif";break;case".svg":T="image/svg+xml";break;case".ico":T="image/x-icon";break;case".woff":T="font/woff";break;case".woff2":T="font/woff2";break;case".ttf":T="font/ttf";break;case".otf":T="font/otf";break;case".eot":T="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":T}})}return new Response("Not Found",{status:404})},error(L){return new Response(`<pre>${L}
14902
+ </html>`,loader:"html"}}})}}});var{serve:Ub}=globalThis.Bun;import k1 from"fs";import Q1 from"path";async function n7($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=Q1.resolve($);if(!k1.existsSync(K))return console.error(`${R.red}Error: File not found: ${R.bright}${K}${R.reset}`),!1;if(K.endsWith(".md"))return VZ(K,Z);else if(!K.endsWith(".stx"))return console.error(`${R.red}Error: Unsupported file type: ${R.bright}${K}${R.reset}. Only .stx and .md files are supported.`),!1;let W=Q1.join(process.cwd(),".stx/output");k1.mkdirSync(W,{recursive:!0}),console.log(`${R.blue}Building ${R.bright}${$}${R.reset}...`);let U=null,_=async()=>{try{let L={name:"public-assets",setup(w){w.onResolve({filter:/^\/(images|fonts|assets|public)\//},(M)=>{return{path:M.path,external:!0}})}},V=await Bun.build({entrypoints:[K],outdir:W,plugins:[L,m$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!V.success)return console.error(`${R.red}Build failed:${R.reset}`,V.logs),!1;let N=V.outputs.find((w)=>w.path.endsWith(".html"));if(!N)return console.error(`${R.red}No HTML output found${R.reset}`),!1;return U=await Bun.file(N.path).text(),!0}catch(L){return console.error(`${R.red}Error building stx file:${R.reset}`,L),!1}};if(!await _())return!1;let z=Q1.dirname(K);await S6(z);let q=Y;try{if(q=await d4(Y),q!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${q} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}if(J){let L=Z.hmrPort||q+1;Q=e5({wsPort:L,verbose:!1}),G=Q.start(L)}let j={},H=null;try{let{loadStxConfig:L}=await Promise.resolve().then(() => (c4(),B6)),V=await L();if(V?.apiRouter)H=V?.apiRouter,console.log(`${R.blue}Using custom router for API handling${R.reset}`);if(V?.apiRoutes){j=V.apiRoutes;let N=Object.keys(j).length;if(N>0)console.log(`${R.blue}Loaded ${R.bright}${N} API route${N>1?"s":""}${R.reset}`)}if(V?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:A}=await Promise.resolve().then(() => (mZ(),r2)),w=V.broadcasting;await N(w);let M=w.port??6001;console.log(`${R.magenta}Broadcasting on ${R.cyan}ws://localhost:${M}/ws${R.reset}`);let E=Q1.join(process.cwd(),"channels.ts");if(k1.existsSync(E))try{let T=await A(E);console.log(`${R.blue}Loaded ${R.bright}${T} broadcast channel${T!==1?"s":""}${R.blue} from channels.ts${R.reset}`)}catch(T){console.warn(`${R.yellow}Failed to load channels.ts: ${T.message}${R.reset}`)}}catch(N){console.warn(`${R.yellow}Broadcasting failed to start: ${N.message}${R.reset}`)}}catch{}if(console.log(`${R.blue}Starting server on ${R.cyan}http://localhost:${q}/${R.reset}...`),J)console.log(`${R.magenta}Hot reload enabled on ws://localhost:${G}${R.reset}`);let O=Ub({port:q,async fetch(L){let V=new URL(L.url);if(H)try{let E=await H.handleRequest(L);if(E.status!==404)return E}catch{}if(j[V.pathname])try{return await j[V.pathname](L)}catch(E){return new Response(JSON.stringify({error:E.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(V.pathname==="/")return(async()=>{let T=await E0(U||"");if(J)T=u1(T,G);if(Z.native)if(T.includes("<head>"))T=T.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(T.includes("<html"))T=T.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else T="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+T;return T})().then((T)=>new Response(T,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let N=Q1.join(W,V.pathname);if(k1.existsSync(N)&&k1.statSync(N).isFile()){let E=Bun.file(N),T=Q1.extname(N).toLowerCase(),I="text/plain";if(T===".ts"||T===".tsx"){let S=new Bun.Transpiler({loader:T===".tsx"?"tsx":"ts"}),k=await E.text(),x=S.transformSync(k);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(T){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":I}})}let A=Q1.dirname(K),w=Q1.join(A,V.pathname);if(k1.existsSync(w)&&k1.statSync(w).isFile()){let E=Bun.file(w),T=Q1.extname(w).toLowerCase(),I="text/plain";if(T===".ts"||T===".tsx"){let S=new Bun.Transpiler({loader:T===".tsx"?"tsx":"ts"}),k=await E.text(),x=S.transformSync(k);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(T){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":I}})}let M=Q1.join(process.cwd(),"public",V.pathname);if(k1.existsSync(M)&&k1.statSync(M).isFile()){let E=Bun.file(M),T=Q1.extname(M).toLowerCase(),I="application/octet-stream";if(T===".ts"||T===".tsx"){let S=new Bun.Transpiler({loader:T===".tsx"?"tsx":"ts"}),k=await E.text(),x=S.transformSync(k);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(T){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":I}})}return new Response("Not Found",{status:404})},error(L){return new Response(`<pre>${L}
14903
14903
  ${L.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
14904
14904
  ${R.blue}stx${R.reset} ${R.green}${process.env.stx_VERSION||"v0.0.10"}${R.reset} ${R.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${R.reset}`),console.log(`
14905
14905
  ${R.bright}\u2192 ${R.cyan}http://localhost:${q}/${R.reset}`),console.log(`
14906
14906
  ${R.yellow}Routes:${R.reset}`);let F=Q1.relative(process.cwd(),K);if(console.log(` ${R.green}\u2514\u2500 /${R.reset} \u2192 ${R.bright}${F}${R.reset}`),console.log(`
14907
14907
  Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),u4(O.url.toString(),()=>{if(X)k1.watch(Q1.dirname(K),{recursive:!0}).close();O.stop()}),Z.native){let L=await Bun.file(K).text(),V=FZ(L);await V$(q,{title:Q1.basename(K,".stx"),nativeSidebar:!!V,sidebarConfig:V})}if(X){let L=Q1.dirname(K);console.log(`${R.blue}Watching ${R.bright}${L}${R.reset} for changes...`);let V=k1.watch(L,{recursive:!0},async(N,A)=>{if(!A||t5(A))return;if(o5(A)){console.log(`${R.yellow}File ${R.bright}${A}${R.yellow} changed, rebuilding...${R.reset}`),k4.clear(),y4();let w=await _();if(await K5(z),J&&Q)if(w)Q.reload(A);else Q.error("Build failed - check console for details")}else if(a5(A)){if(console.log(`${R.cyan}CSS ${R.bright}${A}${R.cyan} changed${R.reset}`),J&&Q)Q.updateCss(A)}});process.on("SIGINT",()=>{if(V.close(),Q)w$();O.stop(),process.exit(0)})}return!0}var sO=D(()=>{g6();qY();O0();s5();z2()});var{serve:_b}=globalThis.Bun;import r4 from"fs";import $1 from"path";function hG($){if($.length===0)return"";if($.length===1)return $[0];let Z=$.map((X)=>X.split($1.sep)),Y=[];for(let X=0;X<Z[0].length;X++){let J=Z[0][X];if(Z.every((Q)=>Q[X]===J))Y.push(J);else break}return Y.join($1.sep)}async function r7($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1;for(let j of $){let H=$1.resolve(j);if(!r4.existsSync(H))return console.error(`${R.red}Error: File not found: ${R.bright}${H}${R.reset}`),!1;if(!H.endsWith(".stx")&&!H.endsWith(".md"))return console.error(`${R.red}Error: Unsupported file type: ${R.bright}${H}${R.reset}. Only .stx and .md files are supported.`),!1}let J=$1.join(process.cwd(),".stx/output");r4.mkdirSync(J,{recursive:!0});let Q=hG($.map((j)=>$1.dirname($1.resolve(j))));console.log(`${R.blue}Processing ${R.bright}${$.length}${R.reset} files...`);let G={},K=[],W=async()=>{try{for(let j of $){let H=$1.resolve(j);if(H.endsWith(".md"))try{let{content:F,data:L}=await X4(H,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:_1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),V=Z.markdown?.syntaxHighlighting||_1.markdown?.syntaxHighlighting,N=V?.defaultTheme||"github-dark",A=["github-dark"],w=V?.additionalThemes||[],E=[...new Set([...A,...w])].map((k)=>`<option value="${k}"${k===N?" selected":""}>${k}</option>`).join(`
14908
- `),I=`
14908
+ `),T=`
14909
14909
  <!DOCTYPE html>
14910
14910
  <html lang="en">
14911
14911
  <head>
@@ -15067,19 +15067,19 @@ Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),u4(O.u
15067
15067
  </script>
15068
15068
  </body>
15069
15069
  </html>
15070
- `,S=`/${$1.relative(Q,H).replace(/\.md$/,"")}`;if(S.endsWith("/index"))S=S.slice(0,-6)||"/";G[S||"/"]={filePath:H,content:I,fileType:"md"}}catch(F){console.error(`${R.red}Error processing Markdown file ${R.bright}${j}${R.reset}:`,F);continue}else{let F={name:"public-assets",setup(M){M.onResolve({filter:/^\/(images|fonts|assets|public)\//},(E)=>{return{path:E.path,external:!0}})}},L=await Bun.build({entrypoints:[H],outdir:J,plugins:[F,m$],define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!L.success){console.error(`${R.red}Build failed for ${R.bright}${j}${R.reset}:`,L.logs);continue}let V=L.outputs.find((M)=>M.path.endsWith(".html"));if(!V){console.error(`${R.red}No HTML output found for ${R.bright}${j}${R.reset}`);continue}let N=await Bun.file(V.path).text(),w=`/${$1.relative(Q,H).replace(/\.stx$/,"")}`;if(w.endsWith("/index"))w=w.slice(0,-6)||"/";if(w.includes("[")){let M=[...w.matchAll(/\[([^\]]+)\]/g)].map((I)=>I[1]),E=w.replace(/\[([^\]]+)\]/g,"([^/]+)");K.push({pattern:new RegExp(`^${E}$`),paramNames:M,filePath:H,routeTemplate:w,fileType:"stx"}),G[w]={filePath:H,content:N,fileType:"stx"}}else G[w||"/"]={filePath:H,content:N,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${R.red}No files were successfully processed${R.reset}`),!1;return!0}catch(j){return console.error(`${R.red}Error processing files:${R.reset}`,j),!1}};if(!await W())return!1;let _=Y;try{if(_=await d4(Y),_!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${_} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}console.log(`${R.blue}Starting server on ${R.cyan}http://localhost:${_}/${R.reset}...`);let B=_b({port:_,async fetch(j){let H=new URL(j.url),O=$1.join(process.cwd(),"public",H.pathname);if(r4.existsSync(O)&&r4.statSync(O).isFile()){let V=Bun.file(O),N=$1.extname(O).toLowerCase(),A="application/octet-stream";if(N===".ts"||N===".tsx"){let w=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),M=await V.text(),E=w.transformSync(M);return new Response(E,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":A="text/html";break;case".css":A="text/css";break;case".js":A="text/javascript";break;case".json":A="application/json";break;case".png":A="image/png";break;case".jpg":case".jpeg":A="image/jpeg";break;case".gif":A="image/gif";break;case".svg":A="image/svg+xml";break;case".ico":A="image/x-icon";break;case".woff":A="font/woff";break;case".woff2":A="font/woff2";break;case".ttf":A="font/ttf";break;case".otf":A="font/otf";break;case".eot":A="application/vnd.ms-fontobject";break}return new Response(V,{headers:{"Content-Type":A}})}let F=G[H.pathname];if(!F&&!H.pathname.endsWith("/"))F=G[`${H.pathname}/`];if(!F)for(let V of K){let N=H.pathname.match(V.pattern);if(N){let A=G[V.routeTemplate];if(A){let w={};for(let I=0;I<V.paramNames.length;I++)w[V.paramNames[I]]=decodeURIComponent(N[I+1]);let M=A.content,E=`<script>window.__routeParams = ${JSON.stringify(w)};</script>`;if(M.includes("</head>"))M=M.replace("</head>",`${E}
15070
+ `,S=`/${$1.relative(Q,H).replace(/\.md$/,"")}`;if(S.endsWith("/index"))S=S.slice(0,-6)||"/";G[S||"/"]={filePath:H,content:T,fileType:"md"}}catch(F){console.error(`${R.red}Error processing Markdown file ${R.bright}${j}${R.reset}:`,F);continue}else{let F={name:"public-assets",setup(M){M.onResolve({filter:/^\/(images|fonts|assets|public)\//},(E)=>{return{path:E.path,external:!0}})}},L=await Bun.build({entrypoints:[H],outdir:J,plugins:[F,m$],define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!L.success){console.error(`${R.red}Build failed for ${R.bright}${j}${R.reset}:`,L.logs);continue}let V=L.outputs.find((M)=>M.path.endsWith(".html"));if(!V){console.error(`${R.red}No HTML output found for ${R.bright}${j}${R.reset}`);continue}let N=await Bun.file(V.path).text(),w=`/${$1.relative(Q,H).replace(/\.stx$/,"")}`;if(w.endsWith("/index"))w=w.slice(0,-6)||"/";if(w.includes("[")){let M=[...w.matchAll(/\[([^\]]+)\]/g)].map((T)=>T[1]),E=w.replace(/\[([^\]]+)\]/g,"([^/]+)");K.push({pattern:new RegExp(`^${E}$`),paramNames:M,filePath:H,routeTemplate:w,fileType:"stx"}),G[w]={filePath:H,content:N,fileType:"stx"}}else G[w||"/"]={filePath:H,content:N,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${R.red}No files were successfully processed${R.reset}`),!1;return!0}catch(j){return console.error(`${R.red}Error processing files:${R.reset}`,j),!1}};if(!await W())return!1;let _=Y;try{if(_=await d4(Y),_!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${_} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}console.log(`${R.blue}Starting server on ${R.cyan}http://localhost:${_}/${R.reset}...`);let B=_b({port:_,async fetch(j){let H=new URL(j.url),O=$1.join(process.cwd(),"public",H.pathname);if(r4.existsSync(O)&&r4.statSync(O).isFile()){let V=Bun.file(O),N=$1.extname(O).toLowerCase(),A="application/octet-stream";if(N===".ts"||N===".tsx"){let w=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),M=await V.text(),E=w.transformSync(M);return new Response(E,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":A="text/html";break;case".css":A="text/css";break;case".js":A="text/javascript";break;case".json":A="application/json";break;case".png":A="image/png";break;case".jpg":case".jpeg":A="image/jpeg";break;case".gif":A="image/gif";break;case".svg":A="image/svg+xml";break;case".ico":A="image/x-icon";break;case".woff":A="font/woff";break;case".woff2":A="font/woff2";break;case".ttf":A="font/ttf";break;case".otf":A="font/otf";break;case".eot":A="application/vnd.ms-fontobject";break}return new Response(V,{headers:{"Content-Type":A}})}let F=G[H.pathname];if(!F&&!H.pathname.endsWith("/"))F=G[`${H.pathname}/`];if(!F)for(let V of K){let N=H.pathname.match(V.pattern);if(N){let A=G[V.routeTemplate];if(A){let w={};for(let T=0;T<V.paramNames.length;T++)w[V.paramNames[T]]=decodeURIComponent(N[T+1]);let M=A.content,E=`<script>window.__routeParams = ${JSON.stringify(w)};</script>`;if(M.includes("</head>"))M=M.replace("</head>",`${E}
15071
15071
  </head>`);else M=E+M;F={...A,content:M}}break}}if(F)return E0(F.content).then((V)=>{if(V.includes("</head>"))V=V.replace("</head>",`${AQ}
15072
15072
  </head>`);return new Response(V,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let L=$1.join(J,H.pathname);if(r4.existsSync(L)&&r4.statSync(L).isFile()){let V=Bun.file(L),N=$1.extname(L).toLowerCase(),A="text/plain";if(N===".ts"||N===".tsx"){let w=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),M=await V.text(),E=w.transformSync(M);return new Response(E,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":A="text/html";break;case".css":A="text/css";break;case".js":A="text/javascript";break;case".json":A="application/json";break;case".png":A="image/png";break;case".jpg":case".jpeg":A="image/jpeg";break;case".gif":A="image/gif";break;case".svg":A="image/svg+xml";break;case".ico":A="image/x-icon";break;case".woff":A="font/woff";break;case".woff2":A="font/woff2";break;case".ttf":A="font/ttf";break;case".otf":A="font/otf";break;case".eot":A="application/vnd.ms-fontobject";break}return new Response(V,{headers:{"Content-Type":A}})}if(H.pathname!=="/"&&G["/"]){let V=j.headers.get("X-STX-Router")==="true";return E0(G["/"].content).then((N)=>{if(V){let A=N.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(A){let w=N.match(/<title[^>]*>([\s\S]*?)<\/title>/i),E=`<!DOCTYPE html><html><head><title>${w?w[1]:""}</title></head><body><main>${A[1]}</main></body></html>`;return new Response(E,{headers:{"Content-Type":"text/html","X-STX-Partial":"true","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}return new Response(N,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})})}return new Response("Not Found",{status:404})},error(j){return new Response(`<pre>${j}
15073
15073
  ${j.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
15074
15074
  ${R.blue}stx${R.reset} ${R.green}${process.env.stx_VERSION||"v0.0.10"}${R.reset} ${R.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${R.reset}`),console.log(`
15075
15075
  ${R.bright}\u2192 ${R.cyan}http://localhost:${_}/${R.reset}`),console.log(`
15076
15076
  ${R.yellow}Routes:${R.reset}`);let z=new Set(K.map((j)=>j.routeTemplate)),q=Object.entries(G).filter(([j])=>!z.has(j)).sort(([j],[H])=>j.localeCompare(H)).map(([j,H])=>({route:j==="/"?"/":j,filePath:$1.relative(process.cwd(),H.filePath),fileType:H.fileType}));for(let j of K){let H=j.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");q.push({route:H,filePath:$1.relative(process.cwd(),j.filePath),fileType:"stx"})}if(q.sort((j,H)=>j.route.localeCompare(H.route)),q.forEach((j,H)=>{let F=H===q.length-1?"\u2514\u2500 ":"\u251C\u2500 ",L=j.fileType==="md"?`${R.magenta}(markdown)${R.reset}`:"";console.log(` ${R.green}${F}${j.route}${R.reset} \u2192 ${R.bright}${j.filePath}${R.reset} ${L}`)}),console.log(`
15077
- Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),u4(B.url.toString(),()=>{if(X)r4.watch(Q,{recursive:!0}).close();B.stop()}),X){console.log(`${R.blue}Watching for changes...${R.reset}`);let j=r4.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${R.yellow}File ${R.bright}${O}${R.yellow} changed, rebuilding...${R.reset}`),k4.clear(),y4(),await W()});process.on("SIGINT",()=>{j.close(),B.stop(),process.exit(0)})}return!0}var aO=D(()=>{s6();p0();g6();qY();O0();s5()});var{serve:Bb}=globalThis.Bun;import j4 from"fs";import I0 from"path";function uG($){let Z=Bun.file($),Y=I0.extname($).toLowerCase(),X={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},Q=[".js",".css",".json"].includes(Y)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(Z,{headers:{"Content-Type":X[Y]||"application/octet-stream",...Q}})}async function s7($=".",Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=I0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (c4(),B6)),U=await W(K),_=U.root&&U.root!=="."?I0.join(K,U.root):K,B=U.pagesDir||"pages",z=I0.join(_,B);if(!j4.existsSync(z))return console.error(`${R.red}Error: No '${B}' directory found in ${R.bright}${_}${R.reset}`),console.log(`${R.dim}Create a ${B}/ directory with .stx files to define your routes.${R.reset}`),console.log(`${R.dim}Example: ${B}/index.stx for the homepage.${R.reset}`),!1;let q=W4(_);if(q.length===0)return console.error(`${R.red}Error: No page files found in ${R.bright}${z}${R.reset}`),!1;console.log(`${R.blue}Found ${R.bright}${q.length}${R.blue} routes${R.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:f,prefix:h}of j)if(j4.existsSync(f)){let u=W4(I0.dirname(f),{pagesDir:I0.basename(f)});for(let l of u){let i=h==="/"?l.pattern:`${h}${l.pattern==="/"?"":l.pattern}`;H.push({route:{...l,pattern:i},prefix:h})}if(u.length>0)console.log(`${R.blue}Plugin pages: ${R.bright}${u.length}${R.blue} routes at ${R.cyan}${h}${R.reset}`)}let O=new Map,F=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=k2(K,Z.stxOptions?.shell),L){if(F=await gZ(L,Z.stxOptions||{}),F)console.log(`${R.blue}Using app shell: ${R.bright}${I0.relative(K,L)}${R.reset} ${R.dim}(deprecated: use layouts/default.stx instead)${R.reset}`)}}W7(),await z7(K);let V=B7();if(V.length>0)console.log(`${R.blue}Loaded ${R.bright}${V.length}${R.blue} middleware: ${R.dim}${V.join(", ")}${R.reset}`);let N={},A=null;try{let{loadStxConfig:f}=await Promise.resolve().then(() => (c4(),B6)),h=await f(K);if(h?.apiRouter)A=h?.apiRouter,console.log(`${R.blue}Using custom router for API handling${R.reset}`);if(h?.apiRoutes){N=h.apiRoutes;let u=Object.keys(N).length;if(u>0)console.log(`${R.blue}Loaded ${R.bright}${u} API route${u>1?"s":""}${R.reset}`)}if(h?.broadcasting?.enabled)try{let{startBroadcasting:u,loadChannels:l}=await Promise.resolve().then(() => (mZ(),r2)),i=h.broadcasting;await u(i);let _0=i.port??6001;console.log(`${R.magenta}Broadcasting on ${R.cyan}ws://localhost:${_0}/ws${R.reset}`);let q0=I0.join(process.cwd(),"channels.ts");if(j4.existsSync(q0))try{let f0=await l(q0);console.log(`${R.blue}Loaded ${R.bright}${f0} broadcast channel${f0!==1?"s":""}${R.blue} from channels.ts${R.reset}`)}catch(f0){console.warn(`${R.yellow}Failed to load channels.ts: ${f0.message}${R.reset}`)}}catch(u){console.warn(`${R.yellow}Broadcasting failed to start: ${u.message}${R.reset}`)}}catch{}let w=I0.join(K,".stx/output");j4.mkdirSync(w,{recursive:!0});let M=new Map,E=async(f)=>{let h=b2(z,f);if(!h)return null;try{let u=await Bun.build({entrypoints:[h],outdir:w,plugins:[m$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!u.success)return null;let l=u.outputs.find((i)=>i.path.endsWith(".html"));if(!l)return null;return await Bun.file(l.path).text()}catch{return null}},I=async(f,h)=>{try{let{processDirectives:u,extractVariables:l,defaultConfig:i,loadStxConfig:_0,injectRouterScript:q0}=await Promise.resolve().then(() => (c4(),B6)),f0=await _0(K),D0=await Bun.file(f.filePath).text(),{classifyAllScripts:g}=await Promise.resolve().then(() => (c4(),B6)),m=g(D0),n=m.server.map((B0)=>B0.content),c=D0;for(let B0 of m.server)c=c.replace(B0.fullTag,"");let $0={__filename:f.filePath,__dirname:I0.dirname(f.filePath),params:h??{}},{resetHead:d}=await Promise.resolve().then(() => (T4(),s8));d();for(let B0 of n)try{await l(B0,$0,f.filePath)}catch(h0){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",f.filePath,h0?.message||h0)}let r=new Set,J0=(B0)=>{if(!B0)return B0;if(I0.isAbsolute(B0))return B0;return I0.resolve(K,B0)},s={...i,...f0,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)s.debug=!0;s.partialsDir=J0(s.partialsDir),s.componentsDir=J0(s.componentsDir),s.layoutsDir=J0(s.layoutsDir),s.storesDir=J0(s.storesDir||"stores");let G0;if(Z.profile){let B0=performance.now();G0=await u(c,$0,f.filePath,s,r);let h0=performance.now()-B0,a1=I0.relative(K,f.filePath)||f.filePath;console.log(`[stx:profile] ${a1} \u2192 ${h0.toFixed(2)}ms`)}else G0=await u(c,$0,f.filePath,s,r);if(!F)G0=await q0(G0);{let{interpolateScriptExpressions:B0}=await Promise.resolve().then(() => (c0(),X5));G0=G0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(h0,a1,a4)=>{if(!/function\s+__stx_setup_/.test(a4))return h0;return`<script${a1}>${B0(a4,$0)}</script>`})}if(F)G0=_6(G0);return{route:f,content:G0}}catch(u){return console.error(`${R.red}Error building ${R.bright}${f.pattern}${R.reset}:`,u),null}},T=async()=>{M.clear(),O.clear();for(let f of q){let h=await I(f);if(h)M.set(f.pattern,h)}for(let{route:f}of H){let h=await I(f);if(h)O.set(f.pattern,h)}return M.size>0};if(console.log(`${R.blue}Building pages...${R.reset}`),!await T())return console.error(`${R.red}No pages were successfully built${R.reset}`),!1;await S6(K);let k=Y;try{if(k=await d4(Y),k!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${k} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}if(J){let f=Z.hmrPort||k+1;Q=e5({wsPort:f,verbose:!1}),G=Q.start(f)}let b=(f,h)=>{let u=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._rp=${JSON.stringify(h)};if(s.setRouteParams)s.setRouteParams(s._rp);})()</script>`;if(f.includes("</head>"))return f.replace("</head>",`${u}</head>`);if(f.includes("<body"))return f.replace(/<body([^>]*)>/,`<body$1>${u}`);return u+f};console.log(`${R.blue}Starting server...${R.reset}`);let y=Bb({port:k,async fetch(f){let h=new URL(f.url),u=U?.publicDir||"public",l=I0.join(K,u,h.pathname),i=I0.join(K,h.pathname),_0=I0.join(w,h.pathname),[q0,f0,D0]=await Promise.all([j4.promises.stat(l).catch(()=>null),j4.promises.stat(i).catch(()=>null),j4.promises.stat(_0).catch(()=>null)]);if(q0?.isFile())return uG(l);if(f0?.isFile())return uG(i);if(D0?.isFile())return uG(_0);if(h.pathname.startsWith("/_stx/component/")){let c=decodeURIComponent(h.pathname.slice(16));if(c)try{let $0=`<${c} />`,d={...buildConfig,autoShell:!1},r=await processDirectives($0,{},I0.join(K,"components",`${c}.stx`),d,new Set);return new Response(r,{headers:{"Content-Type":"text/html"}})}catch($0){return new Response(`<div class="stx-async-error">${$0.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(A)try{let c=await A.handleRequest(f);if(c.status!==404)return c}catch{}if(N[h.pathname])try{return await N[h.pathname](f)}catch(c){return new Response(JSON.stringify({error:c.message}),{status:500,headers:{"Content-Type":"application/json"}})}let g=fZ(h.pathname,q);if(g){let c=M.get(g.route.pattern);if(g.route.isDynamic&&Object.keys(g.params).length>0){let $0=await I(g.route,g.params);if($0)c=$0}if(c){let $0=r8();if($0.validate){if(!await $0.validate({params:g.params})){let J0=await E(404);if(J0){let s=J0;if(s=await E0(s,K),J)s=u1(s,G);return new Response(s,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if($0.middleware){let r=_7(h.pathname,g.params,$0,h.search),J0=U7(r,null,f),s=await q7($0.middleware,J0);if(s.redirect){let G0=s.redirect.path,B0=s.redirect.options.redirectCode||302,h0=new Headers(s.responseHeaders);return h0.set("Location",G0),new Response(null,{status:B0,headers:h0})}if(s.abort){let{statusCode:G0,message:B0}=s.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${G0}</title></head><body><h1>Error ${G0}</h1><p>${B0}</p></body></html>`,{status:G0,headers:{"Content-Type":"text/html"}})}if(Object.keys(s.state).length>0){let G0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(s.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;c.content=c.content.replace("</head>",`${G0}</head>`)}}let d=c.content;if(F&&S2(f)){if(Object.keys(g.params).length>0)d=b(d,g.params);d=await E0(d,K);let r=U?.router?.container||"main";return d=O7(d,r),new Response(d,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","Cache-Control":"no-store, no-cache, must-revalidate"}})}if(F)d=H7(F,d);if(Object.keys(g.params).length>0)d=b(d,g.params);if(d=await E0(d,K),J)d=u1(d,G);if(Z.native)if(d.includes("<head>"))d=d.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else d="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+d;return new Response(d,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let c=H.map((d)=>d.route),$0=fZ(h.pathname,c);if($0){let d=O.get($0.route.pattern);if(d){let r=d.content;if(F)r=H7(F,r);if(Object.keys($0.params).length>0)r=b(r,$0.params);if(r=await E0(r,K),J)r=u1(r,G);return new Response(r,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:d}of j)if(d!=="/"&&h.pathname.startsWith(d)){let r=O.get(d)||O.get(d+"/");if(r){let J0=r.content;if(F)J0=H7(F,J0);if(J0=await E0(J0,K),J)J0=u1(J0,G);return new Response(J0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let m=M.get("/");if(m){let c=m.content;if(c=await E0(c,K),J)c=u1(c,G);if(Z.native)if(c.includes("<head>"))c=c.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else c="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+c;return new Response(c,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let n=await E(404);if(n){let c=n;if(c=await E0(c,K),J)c=u1(c,G);return new Response(c,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(f){let h=await E(500);if(h)return new Response(h,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${f}
15078
- ${f.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
15077
+ Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),u4(B.url.toString(),()=>{if(X)r4.watch(Q,{recursive:!0}).close();B.stop()}),X){console.log(`${R.blue}Watching for changes...${R.reset}`);let j=r4.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${R.yellow}File ${R.bright}${O}${R.yellow} changed, rebuilding...${R.reset}`),k4.clear(),y4(),await W()});process.on("SIGINT",()=>{j.close(),B.stop(),process.exit(0)})}return!0}var aO=D(()=>{s6();p0();g6();qY();O0();s5()});var{serve:Bb}=globalThis.Bun;import j4 from"fs";import I0 from"path";function uG($){let Z=Bun.file($),Y=I0.extname($).toLowerCase(),X={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},Q=[".js",".css",".json"].includes(Y)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(Z,{headers:{"Content-Type":X[Y]||"application/octet-stream",...Q}})}async function s7($=".",Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=I0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (c4(),B6)),U=await W(K),_=U.root&&U.root!=="."?I0.join(K,U.root):K,B=U.pagesDir||"pages",z=I0.join(_,B);if(!j4.existsSync(z))return console.error(`${R.red}Error: No '${B}' directory found in ${R.bright}${_}${R.reset}`),console.log(`${R.dim}Create a ${B}/ directory with .stx files to define your routes.${R.reset}`),console.log(`${R.dim}Example: ${B}/index.stx for the homepage.${R.reset}`),!1;let q=W4(_);if(q.length===0)return console.error(`${R.red}Error: No page files found in ${R.bright}${z}${R.reset}`),!1;console.log(`${R.blue}Found ${R.bright}${q.length}${R.blue} routes${R.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:v,prefix:h}of j)if(j4.existsSync(v)){let u=W4(I0.dirname(v),{pagesDir:I0.basename(v)});for(let p of u){let i=h==="/"?p.pattern:`${h}${p.pattern==="/"?"":p.pattern}`;H.push({route:{...p,pattern:i},prefix:h})}if(u.length>0)console.log(`${R.blue}Plugin pages: ${R.bright}${u.length}${R.blue} routes at ${R.cyan}${h}${R.reset}`)}let O=new Map,F=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=k2(K,Z.stxOptions?.shell),L){if(F=await gZ(L,Z.stxOptions||{}),F)console.log(`${R.blue}Using app shell: ${R.bright}${I0.relative(K,L)}${R.reset} ${R.dim}(deprecated: use layouts/default.stx instead)${R.reset}`)}}W7(),await z7(K);let V=B7();if(V.length>0)console.log(`${R.blue}Loaded ${R.bright}${V.length}${R.blue} middleware: ${R.dim}${V.join(", ")}${R.reset}`);let N={},A=null;try{let{loadStxConfig:v}=await Promise.resolve().then(() => (c4(),B6)),h=await v(K);if(h?.apiRouter)A=h?.apiRouter,console.log(`${R.blue}Using custom router for API handling${R.reset}`);if(h?.apiRoutes){N=h.apiRoutes;let u=Object.keys(N).length;if(u>0)console.log(`${R.blue}Loaded ${R.bright}${u} API route${u>1?"s":""}${R.reset}`)}if(h?.broadcasting?.enabled)try{let{startBroadcasting:u,loadChannels:p}=await Promise.resolve().then(() => (mZ(),r2)),i=h.broadcasting;await u(i);let _0=i.port??6001;console.log(`${R.magenta}Broadcasting on ${R.cyan}ws://localhost:${_0}/ws${R.reset}`);let q0=I0.join(process.cwd(),"channels.ts");if(j4.existsSync(q0))try{let f0=await p(q0);console.log(`${R.blue}Loaded ${R.bright}${f0} broadcast channel${f0!==1?"s":""}${R.blue} from channels.ts${R.reset}`)}catch(f0){console.warn(`${R.yellow}Failed to load channels.ts: ${f0.message}${R.reset}`)}}catch(u){console.warn(`${R.yellow}Broadcasting failed to start: ${u.message}${R.reset}`)}}catch{}let w=I0.join(K,".stx/output");j4.mkdirSync(w,{recursive:!0});let M=new Map,E=async(v)=>{let h=b2(z,v);if(!h)return null;try{let u=await Bun.build({entrypoints:[h],outdir:w,plugins:[m$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!u.success)return null;let p=u.outputs.find((i)=>i.path.endsWith(".html"));if(!p)return null;return await Bun.file(p.path).text()}catch{return null}},T=async(v,h)=>{try{let{processDirectives:u,extractVariables:p,defaultConfig:i,loadStxConfig:_0,injectRouterScript:q0}=await Promise.resolve().then(() => (c4(),B6)),f0=await _0(K),D0=await Bun.file(v.filePath).text(),{classifyAllScripts:g}=await Promise.resolve().then(() => (c4(),B6)),m=g(D0),n=m.server.map((B0)=>B0.content),c=D0;for(let B0 of m.server)c=c.replace(B0.fullTag,"");let $0={__filename:v.filePath,__dirname:I0.dirname(v.filePath),params:h??{}},{resetHead:d}=await Promise.resolve().then(() => (T4(),s8));d();for(let B0 of n)try{await p(B0,$0,v.filePath)}catch(h0){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",v.filePath,h0?.message||h0)}let r=new Set,J0=(B0)=>{if(!B0)return B0;if(I0.isAbsolute(B0))return B0;return I0.resolve(K,B0)},s={...i,...f0,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)s.debug=!0;s.partialsDir=J0(s.partialsDir),s.componentsDir=J0(s.componentsDir),s.layoutsDir=J0(s.layoutsDir),s.storesDir=J0(s.storesDir||"stores");let G0;if(Z.profile){let B0=performance.now();G0=await u(c,$0,v.filePath,s,r);let h0=performance.now()-B0,a1=I0.relative(K,v.filePath)||v.filePath;console.log(`[stx:profile] ${a1} \u2192 ${h0.toFixed(2)}ms`)}else G0=await u(c,$0,v.filePath,s,r);if(!F)G0=await q0(G0);{let{interpolateScriptExpressions:B0}=await Promise.resolve().then(() => (c0(),X5));G0=G0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(h0,a1,a4)=>{if(!/function\s+__stx_setup_/.test(a4))return h0;return`<script${a1}>${B0(a4,$0)}</script>`})}if(F)G0=_6(G0);return{route:v,content:G0}}catch(u){return console.error(`${R.red}Error building ${R.bright}${v.pattern}${R.reset}:`,u),null}},I=async()=>{M.clear(),O.clear();for(let v of q){let h=await T(v);if(h)M.set(v.pattern,h)}for(let{route:v}of H){let h=await T(v);if(h)O.set(v.pattern,h)}return M.size>0};if(console.log(`${R.blue}Building pages...${R.reset}`),!await I())return console.error(`${R.red}No pages were successfully built${R.reset}`),!1;await S6(K);let k=Y;try{if(k=await d4(Y),k!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${k} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}if(J){let v=Z.hmrPort||k+1;Q=e5({wsPort:v,verbose:!1}),G=Q.start(v)}let x=(v,h)=>{let u=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._rp=${JSON.stringify(h)};if(s.setRouteParams)s.setRouteParams(s._rp);})()</script>`;if(v.includes("</head>"))return v.replace("</head>",`${u}</head>`);if(v.includes("<body"))return v.replace(/<body([^>]*)>/,`<body$1>${u}`);return u+v};console.log(`${R.blue}Starting server...${R.reset}`);let f=Bb({port:k,async fetch(v){let h=new URL(v.url),u=U?.publicDir||"public",p=I0.join(K,u,h.pathname),i=I0.join(K,h.pathname),_0=I0.join(w,h.pathname),[q0,f0,D0]=await Promise.all([j4.promises.stat(p).catch(()=>null),j4.promises.stat(i).catch(()=>null),j4.promises.stat(_0).catch(()=>null)]);if(q0?.isFile())return uG(p);if(f0?.isFile())return uG(i);if(D0?.isFile())return uG(_0);if(h.pathname.startsWith("/_stx/component/")){let c=decodeURIComponent(h.pathname.slice(16));if(c)try{let $0=`<${c} />`,d={...buildConfig,autoShell:!1},r=await processDirectives($0,{},I0.join(K,"components",`${c}.stx`),d,new Set);return new Response(r,{headers:{"Content-Type":"text/html"}})}catch($0){return new Response(`<div class="stx-async-error">${$0.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(A)try{let c=await A.handleRequest(v);if(c.status!==404)return c}catch{}if(N[h.pathname])try{return await N[h.pathname](v)}catch(c){return new Response(JSON.stringify({error:c.message}),{status:500,headers:{"Content-Type":"application/json"}})}let g=fZ(h.pathname,q);if(g){let c=M.get(g.route.pattern);if(g.route.isDynamic&&Object.keys(g.params).length>0){let $0=await T(g.route,g.params);if($0)c=$0}if(c){let $0=r8();if($0.validate){if(!await $0.validate({params:g.params})){let J0=await E(404);if(J0){let s=J0;if(s=await E0(s,K),J)s=u1(s,G);return new Response(s,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if($0.middleware){let r=_7(h.pathname,g.params,$0,h.search),J0=U7(r,null,v),s=await q7($0.middleware,J0);if(s.redirect){let G0=s.redirect.path,B0=s.redirect.options.redirectCode||302,h0=new Headers(s.responseHeaders);return h0.set("Location",G0),new Response(null,{status:B0,headers:h0})}if(s.abort){let{statusCode:G0,message:B0}=s.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${G0}</title></head><body><h1>Error ${G0}</h1><p>${B0}</p></body></html>`,{status:G0,headers:{"Content-Type":"text/html"}})}if(Object.keys(s.state).length>0){let G0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(s.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;c.content=c.content.replace("</head>",`${G0}</head>`)}}let d=c.content;if(F&&S2(v)){if(Object.keys(g.params).length>0)d=x(d,g.params);d=await E0(d,K);let r=U?.router?.container||"main";return d=O7(d,r),new Response(d,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","Cache-Control":"no-store, no-cache, must-revalidate"}})}if(F)d=H7(F,d);if(Object.keys(g.params).length>0)d=x(d,g.params);if(d=await E0(d,K),J)d=u1(d,G);if(Z.native)if(d.includes("<head>"))d=d.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else d="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+d;return new Response(d,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let c=H.map((d)=>d.route),$0=fZ(h.pathname,c);if($0){let d=O.get($0.route.pattern);if(d){let r=d.content;if(F)r=H7(F,r);if(Object.keys($0.params).length>0)r=x(r,$0.params);if(r=await E0(r,K),J)r=u1(r,G);return new Response(r,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:d}of j)if(d!=="/"&&h.pathname.startsWith(d)){let r=O.get(d)||O.get(d+"/");if(r){let J0=r.content;if(F)J0=H7(F,J0);if(J0=await E0(J0,K),J)J0=u1(J0,G);return new Response(J0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let m=M.get("/");if(m){let c=m.content;if(c=await E0(c,K),J)c=u1(c,G);if(Z.native)if(c.includes("<head>"))c=c.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else c="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+c;return new Response(c,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let n=await E(404);if(n){let c=n;if(c=await E0(c,K),J)c=u1(c,G);return new Response(c,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(v){let h=await E(500);if(h)return new Response(h,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${v}
15078
+ ${v.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
15079
15079
  ${R.blue}stx${R.reset} ${R.green}${process.env.stx_VERSION||"v0.0.10"}${R.reset} ${R.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${R.reset}`),console.log(`
15080
15080
  ${R.bright}\u2192 ${R.cyan}http://localhost:${k}/${R.reset}`),J)console.log(`${R.dim} HMR: ws://localhost:${G}${R.reset}`);console.log(`
15081
- ${R.yellow}Routes:${R.reset}`);let C=[...C2(q,K)];for(let{route:f}of H)C.push(`${f.pattern}`);if(C.forEach((f,h)=>{let l=h===C.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${R.green}${l}${R.reset}${f}`)}),console.log(`
15082
- Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),u4(y.url.toString(),()=>{if(Q)w$();y.stop()}),Z.native){let f,h=I0.join(z,"index.stx");if(j4.existsSync(h)){let l=await Bun.file(h).text();f=FZ(l)}let u=U?.app?.window??{};await V$(k,{title:U?.app?.head?.title||I0.basename(K)||"stx App",width:u.width,height:u.height,darkMode:u.darkMode,hotReload:u.hotReload,nativeSidebar:!!f,sidebarConfig:f})}if(X){console.log(`${R.blue}Watching for changes...${R.reset}`);let f=(l)=>{return l.startsWith("public/")||l.startsWith("public\\")},h=(l)=>{let i=l.toLowerCase();return i.endsWith(".stx")||i.endsWith(".html")||i.endsWith(".md")},u=j4.watch(K,{recursive:!0},async(l,i)=>{if(!i||t5(i))return;if(o5(i)){if(f(i)){if(console.log(`${R.cyan}${i} changed${R.reset}`),J&&Q)Q.reload(i)}else if(h(i)){if(console.log(`${R.yellow}${i} changed, rebuilding...${R.reset}`),k4.clear(),y4(),L&&i){if(I0.resolve(K,i)===L||I0.basename(L)===i){let q0=await gZ(L,Z.stxOptions||{});if(q0)F=q0}}if(await T(),await K5(K),J&&Q)Q.reload(i)}else if(console.log(`${R.yellow}${i} changed, rebuilding...${R.reset}`),k4.clear(),y4(),await T(),J&&Q)Q.reload(i)}else if(a5(i)){if(console.log(`${R.cyan}CSS ${i} changed${R.reset}`),J&&Q)Q.updateCss(i)}});process.on("SIGINT",()=>{if(u.close(),Q)w$();y.stop(),process.exit(0)})}return!0}var oO=D(()=>{L7();g6();qY();F7();xZ();T4();O0();s5()});var dG=D(()=>{z2();sO();aO();oO()});var ZL={};e(ZL,{runPwaAudit:()=>zb,formatAuditResult:()=>qb,calculateAuditResult:()=>$L,auditConfig:()=>tO,auditBuildOutput:()=>eO});import V6 from"fs";import jY from"path";function tO($){let Z=[],Y=$.pwa;if(Z.push({id:"pwa-enabled",name:"PWA Enabled",category:"required",passed:Y?.enabled===!0,message:Y?.enabled?"PWA is enabled":"PWA is not enabled in config"}),!Y?.enabled)return Z;Z.push({id:"manifest-name",name:"App Name",category:"required",passed:Boolean(Y.manifest?.name),message:Y.manifest?.name?`App name: "${Y.manifest.name}"`:"Missing required manifest name"}),Z.push({id:"manifest-short-name",name:"Short Name",category:"recommended",passed:Boolean(Y.manifest?.shortName),message:Y.manifest?.shortName?`Short name: "${Y.manifest.shortName}"`:"Short name not set (will use full name)"}),Z.push({id:"manifest-description",name:"App Description",category:"recommended",passed:Boolean(Y.manifest?.description),message:Y.manifest?.description?"Description is set":"App description not provided"}),Z.push({id:"manifest-theme-color",name:"Theme Color",category:"required",passed:Boolean(Y.manifest?.themeColor),message:Y.manifest?.themeColor?`Theme color: ${Y.manifest.themeColor}`:"Theme color not set"}),Z.push({id:"manifest-background-color",name:"Background Color",category:"required",passed:Boolean(Y.manifest?.backgroundColor),message:Y.manifest?.backgroundColor?`Background color: ${Y.manifest.backgroundColor}`:"Background color not set"}),Z.push({id:"manifest-display",name:"Display Mode",category:"required",passed:["standalone","fullscreen","minimal-ui"].includes(Y.manifest?.display||""),message:Y.manifest?.display?`Display mode: ${Y.manifest.display}`:"Display mode should be standalone, fullscreen, or minimal-ui"}),Z.push({id:"manifest-start-url",name:"Start URL",category:"required",passed:Boolean(Y.manifest?.startUrl),message:Y.manifest?.startUrl?`Start URL: ${Y.manifest.startUrl}`:"Start URL not set"}),Z.push({id:"icons-source",name:"Icon Source",category:"required",passed:Boolean(Y.icons?.src),message:Y.icons?.src?`Icon source: ${Y.icons.src}`:"No icon source configured"});let X=Y.icons?.sizes||[];Z.push({id:"icons-192",name:"192x192 Icon",category:"required",passed:X.includes(192),message:X.includes(192)?"192x192 icon will be generated":"Missing 192x192 icon (required for Android)"}),Z.push({id:"icons-512",name:"512x512 Icon",category:"required",passed:X.includes(512),message:X.includes(512)?"512x512 icon will be generated":"Missing 512x512 icon (required for splash screen)"}),Z.push({id:"icons-maskable",name:"Maskable Icon",category:"recommended",passed:Y.icons?.purpose?.includes("maskable")||!1,message:Y.icons?.purpose?.includes("maskable")?"Maskable icon purpose is set":"Consider adding maskable icon purpose for adaptive icons"}),Z.push({id:"sw-configured",name:"Service Worker",category:"required",passed:Boolean(Y.serviceWorker),message:Y.serviceWorker?"Service worker is configured":"Service worker configuration missing"}),Z.push({id:"sw-cache-version",name:"Cache Version",category:"recommended",passed:Boolean(Y.serviceWorker?.cacheVersion),message:Y.serviceWorker?.cacheVersion?`Cache version: ${Y.serviceWorker.cacheVersion}`:"Set cache version for proper cache busting"}),Z.push({id:"offline-enabled",name:"Offline Support",category:"required",passed:Y.offline?.enabled===!0,message:Y.offline?.enabled?"Offline support is enabled":"Offline support is disabled"});let J=Y.routes||[];return Z.push({id:"caching-strategies",name:"Caching Strategies",category:"recommended",passed:J.length>0,message:J.length>0?`${J.length} route caching strategies configured`:"No custom caching strategies defined"}),Z.push({id:"push-config",name:"Push Notifications",category:"optional",passed:!Y.push?.enabled||Boolean(Y.push?.vapidPublicKey),message:Y.push?.enabled?Y.push?.vapidPublicKey?"Push notifications configured with VAPID key":"Push enabled but missing VAPID key":"Push notifications not enabled"}),Z.push({id:"share-target",name:"Share Target",category:"optional",passed:!0,message:Y.shareTarget?.enabled?`Share target enabled at ${Y.shareTarget.action}`:"Share target not enabled"}),Z.push({id:"auto-inject",name:"Auto-injection",category:"recommended",passed:Y.autoInject!==!1,message:Y.autoInject!==!1?"PWA tags will be auto-injected":"Auto-injection disabled - manual tag insertion required"}),Z}function eO($){let Z=[],Y=jY.join($,"manifest.json"),X=V6.existsSync(Y);if(Z.push({id:"build-manifest",name:"Manifest File",category:"required",passed:X,message:X?"manifest.json exists":"manifest.json not found in build output"}),X)try{let _=JSON.parse(V6.readFileSync(Y,"utf-8"));Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!0,message:"Manifest is valid JSON"}),Z.push({id:"build-manifest-icons",name:"Manifest Icons",category:"required",passed:Array.isArray(_.icons)&&_.icons.length>0,message:_.icons?.length?`${_.icons.length} icons defined in manifest`:"No icons defined in manifest"})}catch{Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!1,message:"Manifest is not valid JSON"})}let J=jY.join($,"sw.js"),Q=V6.existsSync(J);Z.push({id:"build-sw",name:"Service Worker File",category:"required",passed:Q,message:Q?"Service worker (sw.js) exists":"Service worker not found in build output"});let G=jY.join($,"offline.html"),K=V6.existsSync(G);Z.push({id:"build-offline",name:"Offline Page",category:"recommended",passed:K,message:K?"Offline page exists":"No offline.html found"});let W=jY.join($,"pwa-icons");if(V6.existsSync(W)){let _=V6.readdirSync(W).filter((B)=>B.endsWith(".png")||B.endsWith(".webp"));Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:_.length>0,message:_.length>0?`${_.length} icon files generated`:"No icon files found"})}else Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:!1,message:"Icons directory not found"});return Z}function $L($){let Z=$.filter((W)=>W.category==="required"),Y=$.filter((W)=>W.category==="recommended"),X=Z.filter((W)=>W.passed).length,J=Y.filter((W)=>W.passed).length,Q=Z.length>0?X/Z.length*70:70,G=Y.length>0?J/Y.length*30:30;return{score:Math.round(Q+G),passed:$.filter((W)=>W.passed).length,failed:$.filter((W)=>!W.passed&&W.category==="required").length,warnings:$.filter((W)=>!W.passed&&W.category!=="required").length,checks:$}}function zb($,Z){let Y=tO($),X=Z&&V6.existsSync(Z)?eO(Z):[];return $L([...Y,...X])}function qb($){let Z=[];Z.push(`
15081
+ ${R.yellow}Routes:${R.reset}`);let C=[...C2(q,K)];for(let{route:v}of H)C.push(`${v.pattern}`);if(C.forEach((v,h)=>{let p=h===C.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${R.green}${p}${R.reset}${v}`)}),console.log(`
15082
+ Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),u4(f.url.toString(),()=>{if(Q)w$();f.stop()}),Z.native){let v,h=I0.join(z,"index.stx");if(j4.existsSync(h)){let p=await Bun.file(h).text();v=FZ(p)}let u=U?.app?.window??{};await V$(k,{title:U?.app?.head?.title||I0.basename(K)||"stx App",width:u.width,height:u.height,darkMode:u.darkMode,hotReload:u.hotReload,nativeSidebar:!!v,sidebarConfig:v})}if(X){console.log(`${R.blue}Watching for changes...${R.reset}`);let v=(p)=>{return p.startsWith("public/")||p.startsWith("public\\")},h=(p)=>{let i=p.toLowerCase();return i.endsWith(".stx")||i.endsWith(".html")||i.endsWith(".md")},u=j4.watch(K,{recursive:!0},async(p,i)=>{if(!i||t5(i))return;if(o5(i)){if(v(i)){if(console.log(`${R.cyan}${i} changed${R.reset}`),J&&Q)Q.reload(i)}else if(h(i)){if(console.log(`${R.yellow}${i} changed, rebuilding...${R.reset}`),k4.clear(),y4(),L&&i){if(I0.resolve(K,i)===L||I0.basename(L)===i){let q0=await gZ(L,Z.stxOptions||{});if(q0)F=q0}}if(await I(),await K5(K),J&&Q)Q.reload(i)}else if(console.log(`${R.yellow}${i} changed, rebuilding...${R.reset}`),k4.clear(),y4(),await I(),J&&Q)Q.reload(i)}else if(a5(i)){if(console.log(`${R.cyan}CSS ${i} changed${R.reset}`),J&&Q)Q.updateCss(i)}});process.on("SIGINT",()=>{if(u.close(),Q)w$();f.stop(),process.exit(0)})}return!0}var oO=D(()=>{L7();g6();qY();F7();xZ();T4();O0();s5()});var dG=D(()=>{z2();sO();aO();oO()});var ZL={};e(ZL,{runPwaAudit:()=>zb,formatAuditResult:()=>qb,calculateAuditResult:()=>$L,auditConfig:()=>tO,auditBuildOutput:()=>eO});import V6 from"fs";import jY from"path";function tO($){let Z=[],Y=$.pwa;if(Z.push({id:"pwa-enabled",name:"PWA Enabled",category:"required",passed:Y?.enabled===!0,message:Y?.enabled?"PWA is enabled":"PWA is not enabled in config"}),!Y?.enabled)return Z;Z.push({id:"manifest-name",name:"App Name",category:"required",passed:Boolean(Y.manifest?.name),message:Y.manifest?.name?`App name: "${Y.manifest.name}"`:"Missing required manifest name"}),Z.push({id:"manifest-short-name",name:"Short Name",category:"recommended",passed:Boolean(Y.manifest?.shortName),message:Y.manifest?.shortName?`Short name: "${Y.manifest.shortName}"`:"Short name not set (will use full name)"}),Z.push({id:"manifest-description",name:"App Description",category:"recommended",passed:Boolean(Y.manifest?.description),message:Y.manifest?.description?"Description is set":"App description not provided"}),Z.push({id:"manifest-theme-color",name:"Theme Color",category:"required",passed:Boolean(Y.manifest?.themeColor),message:Y.manifest?.themeColor?`Theme color: ${Y.manifest.themeColor}`:"Theme color not set"}),Z.push({id:"manifest-background-color",name:"Background Color",category:"required",passed:Boolean(Y.manifest?.backgroundColor),message:Y.manifest?.backgroundColor?`Background color: ${Y.manifest.backgroundColor}`:"Background color not set"}),Z.push({id:"manifest-display",name:"Display Mode",category:"required",passed:["standalone","fullscreen","minimal-ui"].includes(Y.manifest?.display||""),message:Y.manifest?.display?`Display mode: ${Y.manifest.display}`:"Display mode should be standalone, fullscreen, or minimal-ui"}),Z.push({id:"manifest-start-url",name:"Start URL",category:"required",passed:Boolean(Y.manifest?.startUrl),message:Y.manifest?.startUrl?`Start URL: ${Y.manifest.startUrl}`:"Start URL not set"}),Z.push({id:"icons-source",name:"Icon Source",category:"required",passed:Boolean(Y.icons?.src),message:Y.icons?.src?`Icon source: ${Y.icons.src}`:"No icon source configured"});let X=Y.icons?.sizes||[];Z.push({id:"icons-192",name:"192x192 Icon",category:"required",passed:X.includes(192),message:X.includes(192)?"192x192 icon will be generated":"Missing 192x192 icon (required for Android)"}),Z.push({id:"icons-512",name:"512x512 Icon",category:"required",passed:X.includes(512),message:X.includes(512)?"512x512 icon will be generated":"Missing 512x512 icon (required for splash screen)"}),Z.push({id:"icons-maskable",name:"Maskable Icon",category:"recommended",passed:Y.icons?.purpose?.includes("maskable")||!1,message:Y.icons?.purpose?.includes("maskable")?"Maskable icon purpose is set":"Consider adding maskable icon purpose for adaptive icons"}),Z.push({id:"sw-configured",name:"Service Worker",category:"required",passed:Boolean(Y.serviceWorker),message:Y.serviceWorker?"Service worker is configured":"Service worker configuration missing"}),Z.push({id:"sw-cache-version",name:"Cache Version",category:"recommended",passed:Boolean(Y.serviceWorker?.cacheVersion),message:Y.serviceWorker?.cacheVersion?`Cache version: ${Y.serviceWorker.cacheVersion}`:"Set cache version for proper cache busting"}),Z.push({id:"offline-enabled",name:"Offline Support",category:"required",passed:Y.offline?.enabled===!0,message:Y.offline?.enabled?"Offline support is enabled":"Offline support is disabled"});let J=Y.routes||[];return Z.push({id:"caching-strategies",name:"Caching Strategies",category:"recommended",passed:J.length>0,message:J.length>0?`${J.length} route caching strategies configured`:"No custom caching strategies defined"}),Z.push({id:"push-config",name:"Push Notifications",category:"optional",passed:!Y.push?.enabled||Boolean(Y.push?.vapidPublicKey),message:Y.push?.enabled?Y.push?.vapidPublicKey?"Push notifications configured with VAPID key":"Push enabled but missing VAPID key":"Push notifications not enabled"}),Z.push({id:"share-target",name:"Share Target",category:"optional",passed:!0,message:Y.shareTarget?.enabled?`Share target enabled at ${Y.shareTarget.action}`:"Share target not enabled"}),Z.push({id:"auto-inject",name:"Auto-injection",category:"recommended",passed:Y.autoInject!==!1,message:Y.autoInject!==!1?"PWA tags will be auto-injected":"Auto-injection disabled - manual tag insertion required"}),Z}function eO($){let Z=[],Y=jY.join($,"manifest.json"),X=V6.existsSync(Y);if(Z.push({id:"build-manifest",name:"Manifest File",category:"required",passed:X,message:X?"manifest.json exists":"manifest.json not found in build output"}),X)try{let _=JSON.parse(V6.readFileSync(Y,"utf-8"));Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!0,message:"Manifest is valid JSON"}),Z.push({id:"build-manifest-icons",name:"Manifest Icons",category:"required",passed:Array.isArray(_.icons)&&_.icons.length>0,message:_.icons?.length?`${_.icons.length} icons defined in manifest`:"No icons defined in manifest"})}catch{Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!1,message:"Manifest is not valid JSON"})}let J=jY.join($,"sw.js"),Q=V6.existsSync(J);Z.push({id:"build-sw",name:"Service Worker File",category:"required",passed:Q,message:Q?"Service worker (sw.js) exists":"Service worker not found in build output"});let G=jY.join($,"offline.html"),K=V6.existsSync(G);Z.push({id:"build-offline",name:"Offline Page",category:"recommended",passed:K,message:K?"Offline page exists":"No offline.html found"});let W=jY.join($,"pwa-icons");if(V6.existsSync(W)){let _=V6.readdirSync(W).filter((B)=>B.endsWith(".png")||B.endsWith(".webp"));Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:_.length>0,message:_.length>0?`${_.length} icon files generated`:"No icon files found"})}else Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:!1,message:"Icons directory not found"});return Z}function $L($){let Z=$.filter((W)=>W.category==="required"),Y=$.filter((W)=>W.category==="recommended"),X=Z.filter((W)=>W.passed).length,J=Y.filter((W)=>W.passed).length,Q=Z.length>0?X/Z.length*70:70,G=Y.length>0?J/Y.length*30:30;return{score:Math.round(Q+G),passed:$.filter((W)=>W.passed).length,failed:$.filter((W)=>!W.passed&&W.category==="required").length,warnings:$.filter((W)=>!W.passed&&W.category!=="required").length,checks:$}}function zb($,Z){let Y=tO($),X=Z&&V6.existsSync(Z)?eO(Z):[];return $L([...Y,...X])}function qb($){let Z=[];Z.push(`
15083
15083
  === PWA Audit Report ===
15084
15084
  `);let Y=$.score>=90?"32":$.score>=70?"33":"31";Z.push(`Score: \x1B[${Y}m${$.score}/100\x1B[0m`),Z.push(`Passed: ${$.passed} | Failed: ${$.failed} | Warnings: ${$.warnings}
15085
15085
  `);let X=["required","recommended","optional"];for(let J of X){let Q=$.checks.filter((G)=>G.category===J);if(Q.length===0)continue;Z.push(`
@@ -18254,17 +18254,17 @@ else {
18254
18254
  `)}function dF($,Z){let Y=" ".repeat(Z),X=[];for(let[K,W]of Object.entries($.props))if(W.type==="literal"){let U=typeof W.value==="string"?`"${W.value}"`:String(W.value);X.push(`${K}: ${U}`)}let J=X.length>0?`{ ${X.join(", ")} }`:"{}",Q=$.children.map((K)=>K.type==="text"?`"${K.props.text?.type==="literal"?K.props.text.value:""}"`:dF(K,Z+1)),G=Q.length>0?`,
18255
18255
  ${Y} [${Q.join(`,
18256
18256
  ${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${J}${G})`}function YP($,Z,Y){if(Z.target==="universal"){let X=[];X.push("// Universal entry point"),X.push("");for(let[J,Q]of Y)X.push(`// --- ${J.toUpperCase()} ---`),X.push(`#if ${J.toUpperCase()}`),X.push(Q),X.push("#endif"),X.push("");return X.join(`
18257
- `)}return Y.get(Z.target)||WK($,Z)}function XP($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:mF(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)J(G)}return J(Z),{version:"1.0.0",components:X,entry:$.id,assets:[],styles:$.styles}}function JP($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function uF(){return`id_${++QP}`}function mF($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Math.abs(Z).toString(36)}function GP($){return $.charAt(0).toUpperCase()+$.slice(1)}function KP($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function WP($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function UK($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=UK(Y);return Z}function _K($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=_K(Y);return Z}function cF($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var BK,QP=0,UP,_P;var lF=D(()=>{BK=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);UP={compileToNative:xF,createHotReloadServer:cF,NATIVE_COMPONENTS:BK},_P=UP});import{spawn as rF}from"child_process";import S0 from"fs";import BP from"os";import t from"path";import x from"process";import{CLI as zP}from"@stacksjs/clapp";var o4="0.2.48";R6();dG();t2();JQ();V4();ZQ();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",H0=new zP("stx");function iF($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function nF($){try{if(!S0.existsSync($)){let Y=t.dirname($),X=t.basename($);if(S0.existsSync(Y)){let Q=S0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(S0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function zK($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var s$=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),qP=($)=>$.endsWith(".stx")||$.endsWith(".md");function r$($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);x.exit(Z)}async function jP($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(s$(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(X.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=t.join(BP.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",t.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...x.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=rF(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let B=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),x.on("SIGINT",()=>{console.log(`
18258
- Test run interrupted`),K.kill("SIGINT"),x.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var HP=x.argv.length>=3&&(qP(x.argv[2])&&S0.existsSync(x.argv[2])||s$(x.argv[2]));if(HP){let $=x.argv[2],Z={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let Y=3;Y<x.argv.length;Y++){let X=x.argv[Y];if(X==="--port"&&Y+1<x.argv.length){let J=iF(x.argv[++Y]);if(!J.isValid)r$(J);Z.port=Number.parseInt(x.argv[Y],10)}else if(X==="--no-watch")Z.watch=!1;else if(X==="--highlight-theme"&&Y+1<x.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=x.argv[++Y]}else if(X==="--no-highlight"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.enabled=!1}else if(X==="--no-highlight-unknown"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(X==="--no-cache")Z.cache=!1;else if(X==="--native")Z.native=!0}if(s$($))try{let Y=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),X=$.endsWith(".stx")?Y.filter((K)=>K.endsWith(".stx")):$.endsWith(".md")?Y.filter((K)=>K.endsWith(".md")):Y.filter((K)=>K.endsWith(".stx")||K.endsWith(".md")),J=$.split("*")[0].replace(/\/$/,"")||".",Q=t.resolve(J);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((_)=>/\[.+\]/.test(t.basename(_)));for(let _ of U)if(!X.includes(_))X.push(_)}catch{}if(X.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),x.exit(1);if(!await r7(X,Z))x.exit(1)}catch(Y){console.error("Failed to process files:",Y),x.exit(1)}else n7($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),x.exit(1)})}else{let $=function(X,J){let Q=[];for(let G=0;G<=J.length;G++)Q[G]=[G];for(let G=0;G<=X.length;G++)Q[0][G]=G;for(let G=1;G<=J.length;G++)for(let K=1;K<=X.length;K++)if(J.charAt(G-1)===X.charAt(K-1))Q[G][K]=Q[G-1][K-1];else Q[G][K]=Math.min(Q[G-1][K-1]+1,Q[G][K-1]+1,Q[G-1][K]+1);return Q[J.length][X.length]};H0.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(X)=>{try{if(await o2(X))console.log("Documentation generated successfully."),x.exit(0);else console.error("Documentation generation failed."),x.exit(1)}catch(J){console.error("Error generating documentation:",J),x.exit(1)}}),H0.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(X,J)=>{try{let{fetchCollections:Q,generatePackage:G}=await import("@stacksjs/iconify-generator");if(X==="list"){console.log(`
18257
+ `)}return Y.get(Z.target)||WK($,Z)}function XP($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:mF(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)J(G)}return J(Z),{version:"1.0.0",components:X,entry:$.id,assets:[],styles:$.styles}}function JP($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function uF(){return`id_${++QP}`}function mF($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Math.abs(Z).toString(36)}function GP($){return $.charAt(0).toUpperCase()+$.slice(1)}function KP($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function WP($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function UK($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=UK(Y);return Z}function _K($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=_K(Y);return Z}function cF($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var BK,QP=0,UP,_P;var lF=D(()=>{BK=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);UP={compileToNative:xF,createHotReloadServer:cF,NATIVE_COMPONENTS:BK},_P=UP});import{spawn as rF}from"child_process";import S0 from"fs";import BP from"os";import t from"path";import y from"process";import{CLI as zP}from"@stacksjs/clapp";var o4="0.2.50";R6();dG();t2();JQ();V4();ZQ();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",H0=new zP("stx");function iF($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function nF($){try{if(!S0.existsSync($)){let Y=t.dirname($),X=t.basename($);if(S0.existsSync(Y)){let Q=S0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(S0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function zK($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var s$=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),qP=($)=>$.endsWith(".stx")||$.endsWith(".md");function r$($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);y.exit(Z)}async function jP($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(s$(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(X.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=t.join(BP.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",t.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...y.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=rF(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let B=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),y.on("SIGINT",()=>{console.log(`
18258
+ Test run interrupted`),K.kill("SIGINT"),y.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var HP=y.argv.length>=3&&(qP(y.argv[2])&&S0.existsSync(y.argv[2])||s$(y.argv[2]));if(HP){let $=y.argv[2],Z={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let Y=3;Y<y.argv.length;Y++){let X=y.argv[Y];if(X==="--port"&&Y+1<y.argv.length){let J=iF(y.argv[++Y]);if(!J.isValid)r$(J);Z.port=Number.parseInt(y.argv[Y],10)}else if(X==="--no-watch")Z.watch=!1;else if(X==="--highlight-theme"&&Y+1<y.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=y.argv[++Y]}else if(X==="--no-highlight"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.enabled=!1}else if(X==="--no-highlight-unknown"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(X==="--no-cache")Z.cache=!1;else if(X==="--native")Z.native=!0}if(s$($))try{let Y=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),X=$.endsWith(".stx")?Y.filter((K)=>K.endsWith(".stx")):$.endsWith(".md")?Y.filter((K)=>K.endsWith(".md")):Y.filter((K)=>K.endsWith(".stx")||K.endsWith(".md")),J=$.split("*")[0].replace(/\/$/,"")||".",Q=t.resolve(J);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((_)=>/\[.+\]/.test(t.basename(_)));for(let _ of U)if(!X.includes(_))X.push(_)}catch{}if(X.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),y.exit(1);if(!await r7(X,Z))y.exit(1)}catch(Y){console.error("Failed to process files:",Y),y.exit(1)}else n7($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),y.exit(1)})}else{let $=function(X,J){let Q=[];for(let G=0;G<=J.length;G++)Q[G]=[G];for(let G=0;G<=X.length;G++)Q[0][G]=G;for(let G=1;G<=J.length;G++)for(let K=1;K<=X.length;K++)if(J.charAt(G-1)===X.charAt(K-1))Q[G][K]=Q[G-1][K-1];else Q[G][K]=Math.min(Q[G-1][K-1]+1,Q[G][K-1]+1,Q[G-1][K]+1);return Q[J.length][X.length]};H0.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(X)=>{try{if(await o2(X))console.log("Documentation generated successfully."),y.exit(0);else console.error("Documentation generation failed."),y.exit(1)}catch(J){console.error("Error generating documentation:",J),y.exit(1)}}),H0.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(X,J)=>{try{let{fetchCollections:Q,generatePackage:G}=await import("@stacksjs/iconify-generator");if(X==="list"){console.log(`
18259
18259
  \uD83D\uDCDA Fetching available icon collections...
18260
18260
  `);let K=await Q(),W=Object.entries(K).sort((U,_)=>_[1].total-U[1].total);console.log(`Available collections:
18261
18261
  `);for(let[U,_]of W){let B=_;console.log(` ${U.padEnd(30)} ${B.name} (${B.total} icons)`)}console.log(`
18262
- Total: ${W.length} collections`)}else if(X.startsWith("generate")){let K=X==="generate"?"":X.replace("generate:","").replace("generate-","").replace("generate","").trim();if(!K)console.error("Error: Please specify a collection prefix"),console.error("Usage: stx iconify generate <prefix> [--icons icon1,icon2,...]"),x.exit(1);let W=J.output||t.join(x.cwd(),"packages/collections"),U=J.icons?J.icons.split(",").map((_)=>_.trim()):void 0;await G(K,W,U),console.log(`
18262
+ Total: ${W.length} collections`)}else if(X.startsWith("generate")){let K=X==="generate"?"":X.replace("generate:","").replace("generate-","").replace("generate","").trim();if(!K)console.error("Error: Please specify a collection prefix"),console.error("Usage: stx iconify generate <prefix> [--icons icon1,icon2,...]"),y.exit(1);let W=J.output||t.join(y.cwd(),"packages/collections"),U=J.icons?J.icons.split(",").map((_)=>_.trim()):void 0;await G(K,W,U),console.log(`
18263
18263
  \u2713 Package generated successfully!`),console.log(`
18264
- To use the package:`),console.log(` 1. cd packages/collections/iconify-${K}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${X}`),console.error("Available commands: list, generate"),x.exit(1)}catch(Q){console.error("Error:",Q instanceof Error?Q.message:String(Q)),x.exit(1)}}),H0.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(X,J)=>{try{if(X==="audit"){let{runPwaAudit:Q,formatAuditResult:G}=await Promise.resolve().then(() => (YL(),ZL)),{loadConfig:K}=await Promise.resolve().then(() => (p0(),sY));console.log(`
18264
+ To use the package:`),console.log(` 1. cd packages/collections/iconify-${K}`),console.log(" 2. bun install"),console.log(" 3. bun run build")}else console.error(`Unknown iconify command: ${X}`),console.error("Available commands: list, generate"),y.exit(1)}catch(Q){console.error("Error:",Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.command("pwa <command>","PWA tools - audit configuration and build output").option("--output <dir>","Build output directory to audit",{default:"dist"}).example("stx pwa audit").example("stx pwa audit --output build").action(async(X,J)=>{try{if(X==="audit"){let{runPwaAudit:Q,formatAuditResult:G}=await Promise.resolve().then(() => (YL(),ZL)),{loadConfig:K}=await Promise.resolve().then(() => (p0(),sY));console.log(`
18265
18265
  \uD83D\uDD0D Running PWA audit...
18266
- `);let W=await K(),U=J.output||"dist",_=Q(W,U);if(console.log(G(_)),_.failed>0)x.exit(1)}else console.error(`Unknown pwa command: ${X}`),console.error("Available commands: audit"),x.exit(1)}catch(Q){console.error("Error:",Q instanceof Error?Q.message:String(Q)),x.exit(1)}}),H0.command("dev [file]","Start a development server for an STX app or file").option("--port <port>","Port to use for the dev server",{default:3000}).option("--no-watch","Disable file watching and auto-reload").option("--native","Open in a native desktop window using Zyte").option("--highlight-theme <theme>","Syntax highlighting theme for Markdown code blocks",{default:"github-dark"}).option("--no-highlight","Disable syntax highlighting for Markdown code blocks").option("--no-highlight-unknown","Disable syntax highlighting for unknown languages in Markdown").option("--no-cache","Disable caching of parsed files").option("--no-hmr","Disable HMR / live-reload script injection (useful for clean network traces)").option("--profile","Print per-directive timing for every page render via performanceMonitor").option("--debug-directives","Log directive ordering and intermediate template state during rendering").example("stx dev").example("stx dev --port 8080").example("stx dev template.stx").example("stx dev components/hero.stx --port 8080").example("stx dev **/*.stx").example("stx dev docs/guide.md").example("stx dev template.stx --native").action(async(X,J)=>{try{if(J.port!==void 0){let G=iF(J.port);if(!G.isValid)r$(G);J.port=Number.parseInt(String(J.port),10)}if(J.timeout!==void 0){let G=zK(J.timeout);if(!G.isValid)r$(G)}let Q={syntaxHighlighting:{enabled:J.highlight!==!1,serverSide:!0,defaultTheme:J.highlightTheme||"github-dark",highlightUnknownLanguages:J.highlightUnknown!==!1}};if(!X){if(!await s7(".",{port:J.port,watch:J.watch!==!1,native:J.native||!1,cache:J.cache!==!1,hotReload:J.hmr!==!1,profile:J.profile===!0,debugDirectives:J.debugDirectives===!0}))x.exit(1);return}if(!s$(X))try{let G=await import("fs");if(G.existsSync(X)&&G.statSync(X).isDirectory()){if(!await s7(X,{port:J.port,watch:J.watch!==!1,native:J.native||!1,cache:J.cache!==!1,hotReload:J.hmr!==!1,profile:J.profile===!0,debugDirectives:J.debugDirectives===!0}))x.exit(1);return}}catch{}if(s$(X)){console.log(`Expanding glob pattern: ${X}`);let G=await R1.timeAsync("glob-expansion",async()=>{return Array.fromAsync(new Bun.Glob(X).scan({onlyFiles:!0,absolute:!0}))}),K=X.endsWith(".stx")?G.filter((B)=>B.endsWith(".stx")):X.endsWith(".md")?G.filter((B)=>B.endsWith(".md")):G.filter((B)=>B.endsWith(".stx")||B.endsWith(".md"));if(K.length===0)console.error(`No STX or Markdown files found matching pattern: ${X}`),console.error("Try using patterns like '*.stx' or 'components/**/*.stx'"),x.exit(1);let W=X.split("*")[0].replace(/\/$/,"")||".",U=t.resolve(W);try{let B=new Bun.Glob("**/*.stx"),q=(await Array.fromAsync(B.scan({cwd:U,onlyFiles:!0,absolute:!0}))).filter((j)=>/\[.+\]/.test(t.basename(j)));for(let j of q)if(!K.includes(j))K.push(j)}catch{}if(console.log(`Found ${K.length} ${K.length===1?"file":"files"} matching ${X}`),!await r7(K,{port:J.port,watch:J.watch!==!1,native:J.native||!1,markdown:Q,cache:J.cache!==!1}))x.exit(1)}else{if(!s$(X)){let K=nF(X);if(!K.isValid)r$(K)}if(!await n7(X,{port:J.port,watch:J.watch!==!1,native:J.native||!1,markdown:Q,cache:J.cache!==!1}))x.exit(1)}}catch(Q){console.error("Error starting dev server:",Q),x.exit(1)}}),H0.command("a11y [directory]","Scan STX files for accessibility issues").option("--no-recursive","Disable recursive scanning of directories").option("--ignore <paths>","Comma-separated paths to ignore",{default:""}).option("--json","Output results as JSON").option("--output <file>","Write results to a file instead of stdout").option("--fix","Automatically fix common accessibility issues").example("stx a11y ./templates").example("stx a11y --json --output a11y-report.json").action(async(X=".",J)=>{try{console.log(`Scanning ${X} for accessibility issues...`);let Q=J.ignore?J.ignore.split(",").map((U)=>U.trim()):[],G=await DY(X,{recursive:J.recursive!==!1,ignorePaths:Q}),K=Object.keys(G).length,W=Object.values(G).reduce((U,_)=>U+_.length,0);if(J.json){let U=JSON.stringify(G,null,2);if(J.output)await Bun.write(J.output,U),console.log(`A11y scan results written to ${J.output}`);else console.log(U)}else if(K===0)console.log("\u2713 No accessibility issues found!");else{console.log(`Found ${W} accessibility issues in ${K} files:
18267
- `);for(let[U,_]of Object.entries(G)){let B=t.relative(x.cwd(),U);console.log(`
18266
+ `);let W=await K(),U=J.output||"dist",_=Q(W,U);if(console.log(G(_)),_.failed>0)y.exit(1)}else console.error(`Unknown pwa command: ${X}`),console.error("Available commands: audit"),y.exit(1)}catch(Q){console.error("Error:",Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.command("dev [file]","Start a development server for an STX app or file").option("--port <port>","Port to use for the dev server",{default:3000}).option("--no-watch","Disable file watching and auto-reload").option("--native","Open in a native desktop window using Zyte").option("--highlight-theme <theme>","Syntax highlighting theme for Markdown code blocks",{default:"github-dark"}).option("--no-highlight","Disable syntax highlighting for Markdown code blocks").option("--no-highlight-unknown","Disable syntax highlighting for unknown languages in Markdown").option("--no-cache","Disable caching of parsed files").option("--no-hmr","Disable HMR / live-reload script injection (useful for clean network traces)").option("--profile","Print per-directive timing for every page render via performanceMonitor").option("--debug-directives","Log directive ordering and intermediate template state during rendering").example("stx dev").example("stx dev --port 8080").example("stx dev template.stx").example("stx dev components/hero.stx --port 8080").example("stx dev **/*.stx").example("stx dev docs/guide.md").example("stx dev template.stx --native").action(async(X,J)=>{try{if(J.port!==void 0){let G=iF(J.port);if(!G.isValid)r$(G);J.port=Number.parseInt(String(J.port),10)}if(J.timeout!==void 0){let G=zK(J.timeout);if(!G.isValid)r$(G)}let Q={syntaxHighlighting:{enabled:J.highlight!==!1,serverSide:!0,defaultTheme:J.highlightTheme||"github-dark",highlightUnknownLanguages:J.highlightUnknown!==!1}};if(!X){if(!await s7(".",{port:J.port,watch:J.watch!==!1,native:J.native||!1,cache:J.cache!==!1,hotReload:J.hmr!==!1,profile:J.profile===!0,debugDirectives:J.debugDirectives===!0}))y.exit(1);return}if(!s$(X))try{let G=await import("fs");if(G.existsSync(X)&&G.statSync(X).isDirectory()){if(!await s7(X,{port:J.port,watch:J.watch!==!1,native:J.native||!1,cache:J.cache!==!1,hotReload:J.hmr!==!1,profile:J.profile===!0,debugDirectives:J.debugDirectives===!0}))y.exit(1);return}}catch{}if(s$(X)){console.log(`Expanding glob pattern: ${X}`);let G=await R1.timeAsync("glob-expansion",async()=>{return Array.fromAsync(new Bun.Glob(X).scan({onlyFiles:!0,absolute:!0}))}),K=X.endsWith(".stx")?G.filter((B)=>B.endsWith(".stx")):X.endsWith(".md")?G.filter((B)=>B.endsWith(".md")):G.filter((B)=>B.endsWith(".stx")||B.endsWith(".md"));if(K.length===0)console.error(`No STX or Markdown files found matching pattern: ${X}`),console.error("Try using patterns like '*.stx' or 'components/**/*.stx'"),y.exit(1);let W=X.split("*")[0].replace(/\/$/,"")||".",U=t.resolve(W);try{let B=new Bun.Glob("**/*.stx"),q=(await Array.fromAsync(B.scan({cwd:U,onlyFiles:!0,absolute:!0}))).filter((j)=>/\[.+\]/.test(t.basename(j)));for(let j of q)if(!K.includes(j))K.push(j)}catch{}if(console.log(`Found ${K.length} ${K.length===1?"file":"files"} matching ${X}`),!await r7(K,{port:J.port,watch:J.watch!==!1,native:J.native||!1,markdown:Q,cache:J.cache!==!1}))y.exit(1)}else{if(!s$(X)){let K=nF(X);if(!K.isValid)r$(K)}if(!await n7(X,{port:J.port,watch:J.watch!==!1,native:J.native||!1,markdown:Q,cache:J.cache!==!1}))y.exit(1)}}catch(Q){console.error("Error starting dev server:",Q),y.exit(1)}}),H0.command("a11y [directory]","Scan STX files for accessibility issues").option("--no-recursive","Disable recursive scanning of directories").option("--ignore <paths>","Comma-separated paths to ignore",{default:""}).option("--json","Output results as JSON").option("--output <file>","Write results to a file instead of stdout").option("--fix","Automatically fix common accessibility issues").example("stx a11y ./templates").example("stx a11y --json --output a11y-report.json").action(async(X=".",J)=>{try{console.log(`Scanning ${X} for accessibility issues...`);let Q=J.ignore?J.ignore.split(",").map((U)=>U.trim()):[],G=await DY(X,{recursive:J.recursive!==!1,ignorePaths:Q}),K=Object.keys(G).length,W=Object.values(G).reduce((U,_)=>U+_.length,0);if(J.json){let U=JSON.stringify(G,null,2);if(J.output)await Bun.write(J.output,U),console.log(`A11y scan results written to ${J.output}`);else console.log(U)}else if(K===0)console.log("\u2713 No accessibility issues found!");else{console.log(`Found ${W} accessibility issues in ${K} files:
18267
+ `);for(let[U,_]of Object.entries(G)){let B=t.relative(y.cwd(),U);console.log(`
18268
18268
  ${B} (${_.length} issues):`);for(let z of _){if(console.log(` \u2022 ${z.impact.toUpperCase()}: ${z.message}`),console.log(` ${z.help}`),z.helpUrl)console.log(` More info: ${z.helpUrl}`);console.log(` Element: ${z.element.substring(0,100)}${z.element.length>100?"...":""}`),console.log("")}}if(console.log(`
18269
18269
  Total: ${W} issues in ${K} files`),J.output){let U=`
18270
18270
  <!DOCTYPE html>
@@ -18299,7 +18299,7 @@ Total: ${W} issues in ${K} files`),J.output){let U=`
18299
18299
 
18300
18300
  ${Object.entries(G).map(([_,B])=>`
18301
18301
  <div class="file">
18302
- <div class="file-header">${t.relative(x.cwd(),_)} (${B.length} issues)</div>
18302
+ <div class="file-header">${t.relative(y.cwd(),_)} (${B.length} issues)</div>
18303
18303
  ${B.map((z)=>`
18304
18304
  <div class="issue">
18305
18305
  <span class="issue-impact ${z.impact}">${z.impact.toUpperCase()}</span>
@@ -18313,96 +18313,96 @@ Total: ${W} issues in ${K} files`),J.output){let U=`
18313
18313
  `).join("")}
18314
18314
  </body>
18315
18315
  </html>
18316
- `.trim();await Bun.write(J.output,U),console.log(`A11y scan results written to ${J.output}`)}}x.exit(W>0?1:0)}catch(Q){console.error("Error scanning for accessibility issues:",Q),x.exit(1)}}),H0.command("build [input]","Generate static HTML files from STX templates (SSG)").option("--pages <dir>","Directory containing page templates",{default:"pages"}).option("--out <dir>","Output directory for generated files",{default:"dist"}).option("--domain <url>","Site domain for absolute URLs (e.g., https://example.com)").option("--base <path>","Base URL path for the site",{default:"/"}).option("--sitemap","Generate sitemap.xml",{default:!0}).option("--no-sitemap","Disable sitemap generation").option("--rss","Generate RSS feed").option("--minify","Minify HTML output",{default:!0}).option("--no-minify","Disable HTML minification").option("--no-cache","Disable build caching").option("--clean","Clean output directory before build",{default:!0}).option("--no-clean","Keep existing files in output directory").option("--concurrency <n>","Parallel page generation limit",{default:"10"}).option("--public <dir>","Directory with static assets to copy",{default:"public"}).option("--trailing-slash","Add trailing slashes to URLs").option("--verbose","Show detailed build output").option("--port <number>","Development server port for preview").option("--timeout <ms>","Build timeout in milliseconds").example("stx build").example("stx build --pages src/pages --out public").example("stx build --domain https://example.com --sitemap").example("stx build --no-minify --verbose").action(async(X,J)=>{try{let Q=performance.now();if(J.port!==void 0){let B=Number.parseInt(J.port,10);if(B<1024||B>65535){if(B<1024)console.error(`
18316
+ `.trim();await Bun.write(J.output,U),console.log(`A11y scan results written to ${J.output}`)}}y.exit(W>0?1:0)}catch(Q){console.error("Error scanning for accessibility issues:",Q),y.exit(1)}}),H0.command("build [input]","Generate static HTML files from STX templates (SSG)").option("--pages <dir>","Directory containing page templates",{default:"pages"}).option("--out <dir>","Output directory for generated files",{default:"dist"}).option("--domain <url>","Site domain for absolute URLs (e.g., https://example.com)").option("--base <path>","Base URL path for the site",{default:"/"}).option("--sitemap","Generate sitemap.xml",{default:!0}).option("--no-sitemap","Disable sitemap generation").option("--rss","Generate RSS feed").option("--minify","Minify HTML output",{default:!0}).option("--no-minify","Disable HTML minification").option("--no-cache","Disable build caching").option("--clean","Clean output directory before build",{default:!0}).option("--no-clean","Keep existing files in output directory").option("--concurrency <n>","Parallel page generation limit",{default:"10"}).option("--public <dir>","Directory with static assets to copy",{default:"public"}).option("--trailing-slash","Add trailing slashes to URLs").option("--verbose","Show detailed build output").option("--port <number>","Development server port for preview").option("--timeout <ms>","Build timeout in milliseconds").example("stx build").example("stx build --pages src/pages --out public").example("stx build --domain https://example.com --sitemap").example("stx build --no-minify --verbose").action(async(X,J)=>{try{let Q=performance.now();if(J.port!==void 0){let B=Number.parseInt(J.port,10);if(B<1024||B>65535){if(B<1024)console.error(`
18317
18317
  Port must be between 1024 and 65535`),console.error(`
18318
18318
  suggestion: Try using a port between 1024 and 65535 (e.g., --port 3000)`);else console.error(`
18319
- Port must be between 1024 and 65535`);x.exit(1)}}if(J.timeout!==void 0){let B=Number.parseInt(J.timeout,10);if(Number.isNaN(B))console.error(`
18320
- Timeout must be a valid number`),x.exit(1)}if(X){let B=t.resolve(X);if(!S0.existsSync(B))console.error(`
18321
- File not found: ${X}`),x.exit(1);if(!X.endsWith(".stx"))console.error(`
18322
- File must have .stx extension: ${X}`),x.exit(1)}let G=t.resolve(J.pages),K=t.resolve(J.out);if(!X&&!S0.existsSync(G))console.error(`
18319
+ Port must be between 1024 and 65535`);y.exit(1)}}if(J.timeout!==void 0){let B=Number.parseInt(J.timeout,10);if(Number.isNaN(B))console.error(`
18320
+ Timeout must be a valid number`),y.exit(1)}if(X){let B=t.resolve(X);if(!S0.existsSync(B))console.error(`
18321
+ File not found: ${X}`),y.exit(1);if(!X.endsWith(".stx"))console.error(`
18322
+ File must have .stx extension: ${X}`),y.exit(1)}let G=t.resolve(J.pages),K=t.resolve(J.out);if(!X&&!S0.existsSync(G))console.error(`
18323
18323
  Pages directory not found: ${G}`),console.log(`
18324
- Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),x.exit(1);let{buildApp:W}=await Promise.resolve().then(() => (p2(),Jj)),U=await W({root:X?t.dirname(X):void 0,debug:J.verbose,ssg:{pagesDir:J.pages,outputDir:J.out,domain:J.domain,baseUrl:J.base,sitemap:J.sitemap,rss:J.rss,minify:J.minify,cache:J.cache!==!1,cleanOutput:J.clean,concurrency:Number.parseInt(J.concurrency,10)||10,publicDir:J.public,trailingSlash:J.trailingSlash,generate404:!0,hooks:J.verbose?{onPageStart:(B)=>console.log(` Generating: ${B}`),onPageEnd:(B,z)=>console.log(` Generated: ${B} (${z.length} bytes)`),onError:(B,z)=>console.error(` Error in ${z}: ${B.message}`)}:void 0},ssr:{outputDir:J.out==="dist"?".output":J.out,debug:J.verbose}}),_=((performance.now()-Q)/1000).toFixed(2);if(U.mode==="ssr"&&U.ssr)console.log(`
18324
+ Create a 'pages' directory with .stx files, or use --pages to specify a different directory.`),y.exit(1);let{buildApp:W}=await Promise.resolve().then(() => (p2(),Jj)),U=await W({root:X?t.dirname(X):void 0,debug:J.verbose,ssg:{pagesDir:J.pages,outputDir:J.out,domain:J.domain,baseUrl:J.base,sitemap:J.sitemap,rss:J.rss,minify:J.minify,cache:J.cache!==!1,cleanOutput:J.clean,concurrency:Number.parseInt(J.concurrency,10)||10,publicDir:J.public,trailingSlash:J.trailingSlash,generate404:!0,hooks:J.verbose?{onPageStart:(B)=>console.log(` Generating: ${B}`),onPageEnd:(B,z)=>console.log(` Generated: ${B} (${z.length} bytes)`),onError:(B,z)=>console.error(` Error in ${z}: ${B.message}`)}:void 0},ssr:{outputDir:J.out==="dist"?".output":J.out,debug:J.verbose}}),_=((performance.now()-Q)/1000).toFixed(2);if(U.mode==="ssr"&&U.ssr)console.log(`
18325
18325
  Build complete! (SSR)
18326
18326
  `),console.log(` Pages compiled: ${U.ssr.pageCount}`),console.log(` Output: ${U.ssr.outputDir}`),console.log(` Duration: ${_}s
18327
18327
  `);else if(U.ssg){if(console.log(`
18328
18328
  Build complete! (SSG)
18329
- `),console.log(` Pages generated: ${U.ssg.successCount}`),U.ssg.failedCount>0)console.log(` Failed: ${U.ssg.failedCount}`);if(U.ssg.cachedCount>0)console.log(` From cache: ${U.ssg.cachedCount}`);if(U.ssg.sitemapPath)console.log(` Sitemap: ${t.relative(x.cwd(),U.ssg.sitemapPath)}`);if(U.ssg.rssPath)console.log(` RSS: ${t.relative(x.cwd(),U.ssg.rssPath)}`);if(console.log(` Build time: ${_}s`),console.log(` Output: ${t.relative(x.cwd(),J.out||"dist")}/
18330
- `),U.ssg.errors.length>0){console.log(" Errors:");for(let B of U.ssg.errors)console.error(` ${B.route}: ${B.error}`);console.log("")}if(J.verbose&&U.ssg.pages.length>0&&U.ssg.pages.length<=20){console.log(" Generated pages:");for(let B of U.ssg.pages){let z=t.relative(x.cwd(),B.outputPath),q=(B.size/1024).toFixed(1);console.log(` ${z} (${q} KB)${B.cached?" [cached]":""}`)}console.log("")}if(U.ssg.failedCount>0)console.error(`
18329
+ `),console.log(` Pages generated: ${U.ssg.successCount}`),U.ssg.failedCount>0)console.log(` Failed: ${U.ssg.failedCount}`);if(U.ssg.cachedCount>0)console.log(` From cache: ${U.ssg.cachedCount}`);if(U.ssg.sitemapPath)console.log(` Sitemap: ${t.relative(y.cwd(),U.ssg.sitemapPath)}`);if(U.ssg.rssPath)console.log(` RSS: ${t.relative(y.cwd(),U.ssg.rssPath)}`);if(console.log(` Build time: ${_}s`),console.log(` Output: ${t.relative(y.cwd(),J.out||"dist")}/
18330
+ `),U.ssg.errors.length>0){console.log(" Errors:");for(let B of U.ssg.errors)console.error(` ${B.route}: ${B.error}`);console.log("")}if(J.verbose&&U.ssg.pages.length>0&&U.ssg.pages.length<=20){console.log(" Generated pages:");for(let B of U.ssg.pages){let z=t.relative(y.cwd(),B.outputPath),q=(B.size/1024).toFixed(1);console.log(` ${z} (${q} KB)${B.cached?" [cached]":""}`)}console.log("")}if(U.ssg.failedCount>0)console.error(`
18331
18331
  Build completed with ${U.ssg.failedCount} error(s). Fix the issues above and try again.
18332
- `),x.exit(1);console.log(" To preview locally:"),console.log(` cd ${J.out||"dist"} && npx serve
18332
+ `),y.exit(1);console.log(" To preview locally:"),console.log(` cd ${J.out||"dist"} && npx serve
18333
18333
  `)}}catch(Q){console.error(`
18334
- Build failed:`,Q instanceof Error?Q.message:String(Q)),x.exit(1)}}),H0.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(X)=>{try{let J=t.resolve(X.output);if(!S0.existsSync(t.join(J,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),x.exit(1);let{startProductionServer:Q}=await Promise.resolve().then(() => (UQ(),WH));await Q({outputDir:J,port:Number.parseInt(X.port,10)||3000})}catch(J){console.error(`
18335
- Failed to start production server:`,J instanceof Error?J.message:String(J)),x.exit(1)}}),H0.command("deploy [directory]","Deploy built site to Netlify").option("--site-id <id>","Netlify site ID (or set NETLIFY_SITE_ID env var)").option("--token <token>","Auth token (or set NETLIFY_AUTH_TOKEN env var)").option("--production","Deploy to production (default: draft preview)").option("--message <msg>","Deploy message/title").option("--no-build","Skip build step before deploy").option("--open","Open deployed URL in browser").option("--dry-run","Preview deployment without uploading").option("--init","Initialize Netlify configuration for this project").example("stx deploy").example("stx deploy --production").example("stx deploy dist --site-id my-site-abc123").example("stx deploy --init").example("stx deploy --dry-run").action(async(X,J)=>{try{let{deploy:Q,initNetlify:G,DeployError:K}=await Promise.resolve().then(() => (wZ(),Fq));if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${o4}\x1B[0m`),J.init){console.log(`
18334
+ Build failed:`,Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(X)=>{try{let J=t.resolve(X.output);if(!S0.existsSync(t.join(J,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),y.exit(1);let{startProductionServer:Q}=await Promise.resolve().then(() => (UQ(),WH));await Q({outputDir:J,port:Number.parseInt(X.port,10)||3000})}catch(J){console.error(`
18335
+ Failed to start production server:`,J instanceof Error?J.message:String(J)),y.exit(1)}}),H0.command("deploy [directory]","Deploy built site to Netlify").option("--site-id <id>","Netlify site ID (or set NETLIFY_SITE_ID env var)").option("--token <token>","Auth token (or set NETLIFY_AUTH_TOKEN env var)").option("--production","Deploy to production (default: draft preview)").option("--message <msg>","Deploy message/title").option("--no-build","Skip build step before deploy").option("--open","Open deployed URL in browser").option("--dry-run","Preview deployment without uploading").option("--init","Initialize Netlify configuration for this project").example("stx deploy").example("stx deploy --production").example("stx deploy dist --site-id my-site-abc123").example("stx deploy --init").example("stx deploy --dry-run").action(async(X,J)=>{try{let{deploy:Q,initNetlify:G,DeployError:K}=await Promise.resolve().then(() => (wZ(),Fq));if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${o4}\x1B[0m`),J.init){console.log(`
18336
18336
  \uD83D\uDCDD Initializing Netlify configuration...
18337
- `);let U=await G({directory:X||x.cwd(),siteId:J.siteId});if(console.log(`\u2713 Created ${U.configPath}`),U.siteId)console.log("\u2713 Saved site ID to .env.local");console.log(`
18337
+ `);let U=await G({directory:X||y.cwd(),siteId:J.siteId});if(console.log(`\u2713 Created ${U.configPath}`),U.siteId)console.log("\u2713 Saved site ID to .env.local");console.log(`
18338
18338
  You can now deploy with: stx deploy`);return}if(J.build!==!1){if(console.log(`
18339
- \uD83D\uDD28 Building project...`),await Bun.spawn(["bun","run","build"],{stdio:["inherit","inherit","inherit"],cwd:x.cwd()}).exited!==0)console.error("\u274C Build failed"),x.exit(1);console.log(`\u2713 Build complete
18339
+ \uD83D\uDD28 Building project...`),await Bun.spawn(["bun","run","build"],{stdio:["inherit","inherit","inherit"],cwd:y.cwd()}).exited!==0)console.error("\u274C Build failed"),y.exit(1);console.log(`\u2713 Build complete
18340
18340
  `)}console.log(`\uD83D\uDE80 Deploying to Netlify...
18341
- `);let W=await Q({directory:X||"dist",siteId:J.siteId,token:J.token,production:J.production,message:J.message,build:!1,open:J.open,dryRun:J.dryRun,onProgress:(U)=>{if(U.stage==="upload"&&U.percent!==void 0){if(x.stdout.write(`\r Uploading: ${U.percent}%`),U.percent===100)x.stdout.write(`
18341
+ `);let W=await Q({directory:X||"dist",siteId:J.siteId,token:J.token,production:J.production,message:J.message,build:!1,open:J.open,dryRun:J.dryRun,onProgress:(U)=>{if(U.stage==="upload"&&U.percent!==void 0){if(y.stdout.write(`\r Uploading: ${U.percent}%`),U.percent===100)y.stdout.write(`
18342
18342
  `)}}});if(W.success){if(console.log(`
18343
18343
  \u2713 Deployed successfully!
18344
18344
  `),console.log(` ${J.dryRun?"Would deploy":"Draft URL"}: ${W.url}`),W.siteUrl)console.log(` Site URL: ${W.siteUrl}`);if(!J.dryRun)console.log(`
18345
18345
  Deploy ID: ${W.deployId}`),console.log(` Duration: ${(W.duration/1000).toFixed(1)}s`),console.log(` Files: ${W.filesUploaded}`)}}catch(Q){if(Q instanceof Error&&Q.name==="DeployError")console.error(`
18346
- \u274C ${Q.message}`),x.exit(1);console.error(`
18347
- \u274C Deploy failed:`,Q instanceof Error?Q.message:String(Q)),x.exit(1)}}),H0.command("images <input>","Optimize images for production").option("-o, --output <dir>","Output directory",{default:"dist/images"}).option("-w, --widths <sizes>","Output widths (comma-separated)",{default:"320,640,768,1024,1280,1536,1920"}).option("-f, --formats <types>","Output formats (comma-separated)",{default:"webp,jpeg"}).option("-q, --quality <n>","Output quality (1-100)",{default:"80"}).option("--placeholder <type>","Placeholder type: blur, dominant-color, none",{default:"none"}).option("--dry-run","Preview without processing").option("--verbose","Show detailed output").example("stx images public/images").example("stx images public/images -o dist/images").example("stx images public/images --widths 640,1024,1920").example("stx images public/images --formats webp,avif").example("stx images public/images --quality 85").example("stx images public/images --dry-run").action(async(X,J)=>{try{let{optimizeDirectory:Q,isSharpAvailable:G,formatSize:K}=await Promise.resolve().then(() => (yZ(),Dq)),W=await import("fs"),U=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${o4}\x1B[0m`),!await G())console.error(`
18346
+ \u274C ${Q.message}`),y.exit(1);console.error(`
18347
+ \u274C Deploy failed:`,Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.command("images <input>","Optimize images for production").option("-o, --output <dir>","Output directory",{default:"dist/images"}).option("-w, --widths <sizes>","Output widths (comma-separated)",{default:"320,640,768,1024,1280,1536,1920"}).option("-f, --formats <types>","Output formats (comma-separated)",{default:"webp,jpeg"}).option("-q, --quality <n>","Output quality (1-100)",{default:"80"}).option("--placeholder <type>","Placeholder type: blur, dominant-color, none",{default:"none"}).option("--dry-run","Preview without processing").option("--verbose","Show detailed output").example("stx images public/images").example("stx images public/images -o dist/images").example("stx images public/images --widths 640,1024,1920").example("stx images public/images --formats webp,avif").example("stx images public/images --quality 85").example("stx images public/images --dry-run").action(async(X,J)=>{try{let{optimizeDirectory:Q,isSharpAvailable:G,formatSize:K}=await Promise.resolve().then(() => (yZ(),Dq)),W=await import("fs"),U=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${o4}\x1B[0m`),!await G())console.error(`
18348
18348
  \u274C sharp is required for image optimization.`),console.log(`
18349
- Install sharp with:`),console.log(" bun add sharp"),x.exit(1);let B=J.widths.split(",").map((L)=>Number.parseInt(L.trim(),10)).filter((L)=>!Number.isNaN(L)),z=J.formats.split(",").map((L)=>L.trim().toLowerCase()),q=Number.parseInt(J.quality,10)||80,j=J.placeholder,H=U.resolve(X);if(!W.existsSync(H))console.error(`
18350
- \u274C Input directory not found: ${H}`),x.exit(1);if(!W.statSync(H).isDirectory())console.error(`
18351
- \u274C Input must be a directory: ${H}`),x.exit(1);if(console.log(`
18349
+ Install sharp with:`),console.log(" bun add sharp"),y.exit(1);let B=J.widths.split(",").map((L)=>Number.parseInt(L.trim(),10)).filter((L)=>!Number.isNaN(L)),z=J.formats.split(",").map((L)=>L.trim().toLowerCase()),q=Number.parseInt(J.quality,10)||80,j=J.placeholder,H=U.resolve(X);if(!W.existsSync(H))console.error(`
18350
+ \u274C Input directory not found: ${H}`),y.exit(1);if(!W.statSync(H).isDirectory())console.error(`
18351
+ \u274C Input must be a directory: ${H}`),y.exit(1);if(console.log(`
18352
18352
  \uD83D\uDCF8 Input: ${H}`),console.log(`\uD83D\uDCC1 Output: ${U.resolve(J.output)}`),console.log(`\uD83D\uDCD0 Widths: ${B.join(", ")}`),console.log(`\uD83C\uDFA8 Formats: ${z.join(", ")}`),console.log(`\u2728 Quality: ${q}`),J.dryRun){console.log(`
18353
18353
  \uD83D\uDD0D Dry run mode - no files will be written
18354
- `);let L=async(A)=>{let w=[],M=await W.promises.readdir(A,{withFileTypes:!0});for(let E of M){let I=U.join(A,E.name);if(E.isDirectory())w.push(...await L(I));else if(/\.(jpg|jpeg|png|webp|avif|gif)$/i.test(E.name))w.push(I)}return w},V=await L(H);console.log(`Found ${V.length} images:`);for(let A of V){let w=U.relative(H,A),M=W.statSync(A);console.log(` ${w} (${K(M.size)})`)}let N=V.length*B.length*z.length;console.log(`
18354
+ `);let L=async(A)=>{let w=[],M=await W.promises.readdir(A,{withFileTypes:!0});for(let E of M){let T=U.join(A,E.name);if(E.isDirectory())w.push(...await L(T));else if(/\.(jpg|jpeg|png|webp|avif|gif)$/i.test(E.name))w.push(T)}return w},V=await L(H);console.log(`Found ${V.length} images:`);for(let A of V){let w=U.relative(H,A),M=W.statSync(A);console.log(` ${w} (${K(M.size)})`)}let N=V.length*B.length*z.length;console.log(`
18355
18355
  Would generate ~${N} image variants`);return}console.log(`
18356
18356
  \u23F3 Optimizing images...
18357
18357
  `);let F=await Q(H,J.output,{widths:B,formats:z,quality:q,placeholder:j,verbose:J.verbose});if(console.log(`
18358
18358
  \u2713 Optimization complete!
18359
18359
  `),console.log(` Images processed: ${F.stats.optimizedImages}/${F.stats.totalImages}`),console.log(` Variants created: ${F.stats.variants}`),F.stats.savedBytes>0)console.log(` Estimated savings: ~${K(F.stats.savedBytes)}`)}catch(Q){console.error(`
18360
- \u274C Image optimization failed:`,Q instanceof Error?Q.message:String(Q)),x.exit(1)}}),H0.command("bundle [directory]","Analyze bundle size and composition").option("-o, --output <file>","Output file path").option("--json","Output as JSON").option("--text","Output as text summary").option("--markdown","Output as Markdown").option("--no-open","Do not open HTML report in browser").option("--no-gzip","Do not show gzip sizes").option("--threshold <size>","Fail if total size exceeds threshold (e.g., 500KB, 1MB)").option("--top <n>","Number of top modules to show",{default:"20"}).example("stx bundle").example("stx bundle dist/").example("stx bundle dist/ --json").example("stx bundle dist/ --text").example("stx bundle dist/ --threshold 500KB").example("stx bundle dist/ --no-open").action(async(X,J)=>{try{let{analyze:Q,formatBytes:G,parseSize:K}=await Promise.resolve().then(() => (WL(),KL)),W=await import("path");console.log(`\x1B[1mstx bundle\x1B[0m \x1B[2mv${o4}\x1B[0m`);let U=X||"dist",_=W.resolve(U);if(!(await import("fs")).existsSync(_))console.error(`
18361
- \u274C Directory not found: ${_}`),console.log("\nRun `stx build` first to generate build output."),x.exit(1);let z="html";if(J.json)z="json";else if(J.text)z="text";else if(J.markdown)z="markdown";console.log(`
18360
+ \u274C Image optimization failed:`,Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.command("bundle [directory]","Analyze bundle size and composition").option("-o, --output <file>","Output file path").option("--json","Output as JSON").option("--text","Output as text summary").option("--markdown","Output as Markdown").option("--no-open","Do not open HTML report in browser").option("--no-gzip","Do not show gzip sizes").option("--threshold <size>","Fail if total size exceeds threshold (e.g., 500KB, 1MB)").option("--top <n>","Number of top modules to show",{default:"20"}).example("stx bundle").example("stx bundle dist/").example("stx bundle dist/ --json").example("stx bundle dist/ --text").example("stx bundle dist/ --threshold 500KB").example("stx bundle dist/ --no-open").action(async(X,J)=>{try{let{analyze:Q,formatBytes:G,parseSize:K}=await Promise.resolve().then(() => (WL(),KL)),W=await import("path");console.log(`\x1B[1mstx bundle\x1B[0m \x1B[2mv${o4}\x1B[0m`);let U=X||"dist",_=W.resolve(U);if(!(await import("fs")).existsSync(_))console.error(`
18361
+ \u274C Directory not found: ${_}`),console.log("\nRun `stx build` first to generate build output."),y.exit(1);let z="html";if(J.json)z="json";else if(J.text)z="text";else if(J.markdown)z="markdown";console.log(`
18362
18362
  \uD83D\uDCE6 Analyzing: ${_}`);let q=await Q({directory:_,output:J.output,format:z,open:J.open!==!1&&z==="html",gzip:J.gzip!==!1,threshold:J.threshold,topModules:Number.parseInt(J.top||"20",10),recommendations:!0});if(z==="html"){if(console.log(`
18363
18363
  \u2713 Report generated: ${q.outputPath}`),J.open!==!1)console.log(" Opening in browser...")}else console.log(q.report);if(q.exceedsThreshold){let j=J.threshold;console.error(`
18364
- \u274C Bundle size (${G(q.stats.totalSize)}) exceeds threshold (${j})`),x.exit(1)}if(z==="html"){if(console.log(`
18364
+ \u274C Bundle size (${G(q.stats.totalSize)}) exceeds threshold (${j})`),y.exit(1)}if(z==="html"){if(console.log(`
18365
18365
  \uD83D\uDCCA Summary:`),console.log(` Total Size: ${G(q.stats.totalSize)}`),console.log(` Gzip Size: ${G(q.stats.totalGzipSize)}`),console.log(` Modules: ${q.stats.moduleCount}`),console.log(` Chunks: ${q.stats.chunks.length}`),q.stats.duplicates.length>0)console.log(` Duplicates: ${q.stats.duplicates.length}`)}}catch(Q){console.error(`
18366
- \u274C Bundle analysis failed:`,Q instanceof Error?Q.message:String(Q)),x.exit(1)}}),H0.command("test [patterns...]","Run tests with Bun test runner and browser environment").option("--watch","Watch for changes and rerun tests").option("--filter <pattern>","Only run tests matching the given pattern").option("--reporter <reporter>","Test reporter to use: default or junit (junit requires Bun v1.0+)",{default:"default"}).option("--timeout <ms>","Test timeout in milliseconds",{default:5000}).option("--coverage","Enable code coverage").option("--ui","Coming soon").option("--verbose","Show verbose output including test command").example("stx test").example("stx test packages/stx/test/").example("stx test **/*.test.ts --verbose").example('stx test --filter "should process"').example("stx test --watch --verbose").example("stx test --reporter junit").action(async(X,J)=>{try{if(console.log(`\x1B[1mstx test\x1B[0m \x1B[2mv${o4} (${_Q})\x1B[0m`),J.timeout){let K=zK(J.timeout);if(!K.isValid)r$(K)}let Q=typeof X==="string"?[X]:X||[];if(Q.length===0)Q.push("**/*.test.ts","**/*.test.js","**/*.spec.ts","**/*.spec.js");if(J.verbose)console.log("Test patterns:",Q),console.log("Options:",JSON.stringify({watch:J.watch||!1,filter:J.filter||"none",reporter:J.reporter||"default",timeout:J.timeout||5000,coverage:J.coverage||!1,ui:J.ui||!1},null,2));if(!await R1.timeAsync("test-execution",()=>jP(Q,J))&&!J.watch)x.exit(1)}catch(Q){console.error("Error running tests:",Q),x.exit(1)}}),H0.command("init [file]","Create a new STX file").alias("new").option("--force","Overwrite existing file").option("--template <file>","Path to a template file to use as a base").example("stx init").example("stx init page.stx").example("stx new contact.stx").example("stx new components/button.stx --template examples/components/button.stx").action(async(X="index.stx",J)=>{try{if(await XQ(X,{force:J.force,template:J.template}))console.log(`
18366
+ \u274C Bundle analysis failed:`,Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.command("test [patterns...]","Run tests with Bun test runner and browser environment").option("--watch","Watch for changes and rerun tests").option("--filter <pattern>","Only run tests matching the given pattern").option("--reporter <reporter>","Test reporter to use: default or junit (junit requires Bun v1.0+)",{default:"default"}).option("--timeout <ms>","Test timeout in milliseconds",{default:5000}).option("--coverage","Enable code coverage").option("--ui","Coming soon").option("--verbose","Show verbose output including test command").example("stx test").example("stx test packages/stx/test/").example("stx test **/*.test.ts --verbose").example('stx test --filter "should process"').example("stx test --watch --verbose").example("stx test --reporter junit").action(async(X,J)=>{try{if(console.log(`\x1B[1mstx test\x1B[0m \x1B[2mv${o4} (${_Q})\x1B[0m`),J.timeout){let K=zK(J.timeout);if(!K.isValid)r$(K)}let Q=typeof X==="string"?[X]:X||[];if(Q.length===0)Q.push("**/*.test.ts","**/*.test.js","**/*.spec.ts","**/*.spec.js");if(J.verbose)console.log("Test patterns:",Q),console.log("Options:",JSON.stringify({watch:J.watch||!1,filter:J.filter||"none",reporter:J.reporter||"default",timeout:J.timeout||5000,coverage:J.coverage||!1,ui:J.ui||!1},null,2));if(!await R1.timeAsync("test-execution",()=>jP(Q,J))&&!J.watch)y.exit(1)}catch(Q){console.error("Error running tests:",Q),y.exit(1)}}),H0.command("init [file]","Create a new STX file").alias("new").option("--force","Overwrite existing file").option("--template <file>","Path to a template file to use as a base").example("stx init").example("stx init page.stx").example("stx new contact.stx").example("stx new components/button.stx --template examples/components/button.stx").action(async(X="index.stx",J)=>{try{if(await XQ(X,{force:J.force,template:J.template}))console.log(`
18367
18367
  \u2728 Successfully created file: ${X}`),console.log(`
18368
18368
  To view it in the development server:`),console.log(` stx dev ${X}
18369
18369
  `);else console.error(`
18370
- \u274C Failed to create file: ${X}`),x.exit(1)}catch(Q){console.error("Error creating file:",Q),x.exit(1)}}),H0.command("format [patterns...]","Format STX and Markdown files automatically").option("--check","Check if files are formatted (exit with error if not)").option("--write","Write formatted files back to disk (default)").option("--diff","Show diff of changes that would be made").option("--ignore <patterns>","Comma-separated patterns to ignore").example("stx format").example("stx format **/*.stx").example("stx format **/*.md").example("stx format **/*.{stx,md}").example("stx format --check").example("stx format --diff --ignore node_modules/**").action(async(X,J)=>{try{if(J.check&&J.write)console.error("\u274C Options --check and --write are mutually exclusive"),console.error("\uD83D\uDCA1 Use --check to verify formatting or --write to apply changes, but not both"),x.exit(1);let Q=X&&X.length>0?X:["**/*.stx","**/*.md"],G=J.ignore?J.ignore.split(",").map((z)=>z.trim()):["node_modules/**","dist/**",".git/**"],K=[];for(let z of Q){let q=await Array.fromAsync(new Bun.Glob(z).scan({onlyFiles:!0,absolute:!0}));K.push(...q.filter((j)=>j.endsWith(".stx")||j.endsWith(".md")))}if(K=K.filter((z)=>{return!G.some((q)=>{let j=q.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*");return new RegExp(j).test(z)})}),K.length===0){console.log("No STX or Markdown files found to format.");return}let W=K.filter((z)=>z.endsWith(".stx")),U=K.filter((z)=>z.endsWith(".md"));console.log(`Formatting ${K.length} files (${W.length} .stx, ${U.length} .md)...`);let _=0,B=0;for(let z of K)try{let q=await Bun.file(z).text(),H=z.endsWith(".md")?$Q(q):cZ(q);if(q!==H)if(J.check)console.log(`\u274C ${t.relative(x.cwd(),z)} needs formatting`),B++;else if(J.diff)console.log(`
18371
- \uD83D\uDCDD ${t.relative(x.cwd(),z)}:`),console.log("--- Original"),console.log("+++ Formatted"),console.log(`@@ Changes in ${t.basename(z)} @@`),console.log("+ Formatted content would be applied");else await Bun.write(z,H),console.log(`\u2705 Formatted ${t.relative(x.cwd(),z)}`),_++}catch(q){console.error(`\u274C Error formatting ${t.relative(x.cwd(),z)}:`,q),B++}if(J.check&&B>0)console.log(`
18372
- ${B} files need formatting. Run 'stx format' to fix.`),x.exit(1);else if(!J.check&&!J.diff)console.log(`\u2728 Formatted ${_} files successfully`)}catch(Q){console.error("Error formatting files:",Q),x.exit(1)}}),H0.command("perf [command...]","Show performance statistics for STX operations").option("--clear","Clear performance statistics").option("--json","Output as JSON").example("stx perf").example("stx perf --clear").example("stx perf --json").action(async(X,J)=>{try{if(J.clear){R1.clear(),console.log("\u2705 Performance statistics cleared");return}let Q=R1.getStats();if(Object.keys(Q).length===0){if(J.json){console.log(JSON.stringify({},null,2));return}console.log("No performance data available. Run some STX commands first.");return}if(J.json)console.log(JSON.stringify(Q,null,2));else{console.log(`
18370
+ \u274C Failed to create file: ${X}`),y.exit(1)}catch(Q){console.error("Error creating file:",Q),y.exit(1)}}),H0.command("format [patterns...]","Format STX and Markdown files automatically").option("--check","Check if files are formatted (exit with error if not)").option("--write","Write formatted files back to disk (default)").option("--diff","Show diff of changes that would be made").option("--ignore <patterns>","Comma-separated patterns to ignore").example("stx format").example("stx format **/*.stx").example("stx format **/*.md").example("stx format **/*.{stx,md}").example("stx format --check").example("stx format --diff --ignore node_modules/**").action(async(X,J)=>{try{if(J.check&&J.write)console.error("\u274C Options --check and --write are mutually exclusive"),console.error("\uD83D\uDCA1 Use --check to verify formatting or --write to apply changes, but not both"),y.exit(1);let Q=X&&X.length>0?X:["**/*.stx","**/*.md"],G=J.ignore?J.ignore.split(",").map((z)=>z.trim()):["node_modules/**","dist/**",".git/**"],K=[];for(let z of Q){let q=await Array.fromAsync(new Bun.Glob(z).scan({onlyFiles:!0,absolute:!0}));K.push(...q.filter((j)=>j.endsWith(".stx")||j.endsWith(".md")))}if(K=K.filter((z)=>{return!G.some((q)=>{let j=q.replace(/\*\*/g,".*").replace(/\*/g,"[^/]*");return new RegExp(j).test(z)})}),K.length===0){console.log("No STX or Markdown files found to format.");return}let W=K.filter((z)=>z.endsWith(".stx")),U=K.filter((z)=>z.endsWith(".md"));console.log(`Formatting ${K.length} files (${W.length} .stx, ${U.length} .md)...`);let _=0,B=0;for(let z of K)try{let q=await Bun.file(z).text(),H=z.endsWith(".md")?$Q(q):cZ(q);if(q!==H)if(J.check)console.log(`\u274C ${t.relative(y.cwd(),z)} needs formatting`),B++;else if(J.diff)console.log(`
18371
+ \uD83D\uDCDD ${t.relative(y.cwd(),z)}:`),console.log("--- Original"),console.log("+++ Formatted"),console.log(`@@ Changes in ${t.basename(z)} @@`),console.log("+ Formatted content would be applied");else await Bun.write(z,H),console.log(`\u2705 Formatted ${t.relative(y.cwd(),z)}`),_++}catch(q){console.error(`\u274C Error formatting ${t.relative(y.cwd(),z)}:`,q),B++}if(J.check&&B>0)console.log(`
18372
+ ${B} files need formatting. Run 'stx format' to fix.`),y.exit(1);else if(!J.check&&!J.diff)console.log(`\u2728 Formatted ${_} files successfully`)}catch(Q){console.error("Error formatting files:",Q),y.exit(1)}}),H0.command("perf [command...]","Show performance statistics for STX operations").option("--clear","Clear performance statistics").option("--json","Output as JSON").example("stx perf").example("stx perf --clear").example("stx perf --json").action(async(X,J)=>{try{if(J.clear){R1.clear(),console.log("\u2705 Performance statistics cleared");return}let Q=R1.getStats();if(Object.keys(Q).length===0){if(J.json){console.log(JSON.stringify({},null,2));return}console.log("No performance data available. Run some STX commands first.");return}if(J.json)console.log(JSON.stringify(Q,null,2));else{console.log(`
18373
18373
  \uD83D\uDCCA STX Performance Statistics
18374
- `);for(let[G,K]of Object.entries(Q))console.log(`\uD83D\uDD27 ${G}:`),console.log(` Count: ${K.count}`),console.log(` Average: ${K.avgTime.toFixed(2)}ms`),console.log(` Total: ${K.totalTime.toFixed(2)}ms`),console.log(` Min: ${K.minTime.toFixed(2)}ms`),console.log(` Max: ${K.maxTime.toFixed(2)}ms`),console.log("")}}catch(Q){console.error("Error showing performance stats:",Q),x.exit(1)}}),H0.command("debug <file>","Debug STX template processing step by step").option("--step","Step through processing stages interactively").option("--verbose","Show detailed processing information").option("--context <data>","JSON string of context data to use").option("--save-report <file>","Save debug report to file").example("stx debug template.stx").example("stx debug template.stx --step").example(`stx debug template.stx --context '{"name": "John", "items": [1,2,3]}'`).action(async(X,J)=>{try{let Q=nF(X);if(!Q.isValid)r$(Q);console.log(`\uD83D\uDD0D Debugging stx template: ${X}
18375
- `);let G={};if(J.context)try{G=JSON.parse(J.context)}catch(U){console.error("\u274C Invalid JSON in --context option"),x.exit(1)}let K=await Bun.file(X).text();console.log(`\uD83D\uDCC4 Template Content (${K.length} chars):`),console.log("\u2500".repeat(50)),console.log(K.substring(0,500)+(K.length>500?`
18374
+ `);for(let[G,K]of Object.entries(Q))console.log(`\uD83D\uDD27 ${G}:`),console.log(` Count: ${K.count}`),console.log(` Average: ${K.avgTime.toFixed(2)}ms`),console.log(` Total: ${K.totalTime.toFixed(2)}ms`),console.log(` Min: ${K.minTime.toFixed(2)}ms`),console.log(` Max: ${K.maxTime.toFixed(2)}ms`),console.log("")}}catch(Q){console.error("Error showing performance stats:",Q),y.exit(1)}}),H0.command("debug <file>","Debug STX template processing step by step").option("--step","Step through processing stages interactively").option("--verbose","Show detailed processing information").option("--context <data>","JSON string of context data to use").option("--save-report <file>","Save debug report to file").example("stx debug template.stx").example("stx debug template.stx --step").example(`stx debug template.stx --context '{"name": "John", "items": [1,2,3]}'`).action(async(X,J)=>{try{let Q=nF(X);if(!Q.isValid)r$(Q);console.log(`\uD83D\uDD0D Debugging stx template: ${X}
18375
+ `);let G={};if(J.context)try{G=JSON.parse(J.context)}catch(U){console.error("\u274C Invalid JSON in --context option"),y.exit(1)}let K=await Bun.file(X).text();console.log(`\uD83D\uDCC4 Template Content (${K.length} chars):`),console.log("\u2500".repeat(50)),console.log(K.substring(0,500)+(K.length>500?`
18376
18376
  ...
18377
18377
  `:"")),console.log("\u2500".repeat(50));let W=K.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(W)console.log(`
18378
18378
  \uD83D\uDCDC Script Section Found:`),console.log("\u2500".repeat(30)),console.log(W[1].trim()),console.log("\u2500".repeat(30));if(console.log(`
18379
18379
  \uD83D\uDCCA Processing Context:`),console.log(JSON.stringify(G,null,2)),J.step)console.log(`
18380
18380
  \u26A0\uFE0F Interactive step-through not yet implemented. Use --verbose for detailed output.`);if(J.verbose)console.log(`
18381
18381
  \uD83D\uDD27 Verbose processing information will be shown during template processing.`);if(console.log(`
18382
- \u2728 Debug analysis complete. Full step-by-step debugging coming soon!`),J.saveReport){let U={file:X,timestamp:new Date().toISOString(),templateLength:K.length,hasScript:!!W,context:G};await Bun.write(J.saveReport,JSON.stringify(U,null,2)),console.log(`\uD83D\uDCCB Debug report saved to: ${J.saveReport}`)}}catch(Q){console.error("Error debugging template:",Q),x.exit(1)}}),H0.command("status [directory]","Show status of STX project and files").option("--verbose","Show detailed information").option("--json","Output as JSON").example("stx status").example("stx status ./src --verbose").action(async(X=".",J)=>{try{let Q=t.resolve(X),G=t.join(Q,"stx.config.ts"),K=t.join(Q,"package.json"),W=await Array.fromAsync(new Bun.Glob("**/*.stx").scan({cwd:Q,onlyFiles:!0,absolute:!0})),U=await Array.fromAsync(new Bun.Glob("**/*.md").scan({cwd:Q,onlyFiles:!0,absolute:!0})),_={projectRoot:Q,hasConfig:S0.existsSync(G),hasPackageJson:S0.existsSync(K),stxFiles:W.length,markdownFiles:U.length,totalFiles:W.length+U.length};if(J.verbose)_.stxFileList=W.map((B)=>t.relative(Q,B)),_.markdownFileList=U.map((B)=>t.relative(Q,B));if(J.json)console.log(JSON.stringify(_,null,2));else{if(console.log(`
18382
+ \u2728 Debug analysis complete. Full step-by-step debugging coming soon!`),J.saveReport){let U={file:X,timestamp:new Date().toISOString(),templateLength:K.length,hasScript:!!W,context:G};await Bun.write(J.saveReport,JSON.stringify(U,null,2)),console.log(`\uD83D\uDCCB Debug report saved to: ${J.saveReport}`)}}catch(Q){console.error("Error debugging template:",Q),y.exit(1)}}),H0.command("status [directory]","Show status of STX project and files").option("--verbose","Show detailed information").option("--json","Output as JSON").example("stx status").example("stx status ./src --verbose").action(async(X=".",J)=>{try{let Q=t.resolve(X),G=t.join(Q,"stx.config.ts"),K=t.join(Q,"package.json"),W=await Array.fromAsync(new Bun.Glob("**/*.stx").scan({cwd:Q,onlyFiles:!0,absolute:!0})),U=await Array.fromAsync(new Bun.Glob("**/*.md").scan({cwd:Q,onlyFiles:!0,absolute:!0})),_={projectRoot:Q,hasConfig:S0.existsSync(G),hasPackageJson:S0.existsSync(K),stxFiles:W.length,markdownFiles:U.length,totalFiles:W.length+U.length};if(J.verbose)_.stxFileList=W.map((B)=>t.relative(Q,B)),_.markdownFileList=U.map((B)=>t.relative(Q,B));if(J.json)console.log(JSON.stringify(_,null,2));else{if(console.log(`
18383
18383
  \uD83D\uDCCB stx Project Status
18384
18384
  `),console.log(`\uD83D\uDCC1 Project Root: ${Q}`),console.log(`\u2699\uFE0F Config File: ${_.hasConfig?"\u2705 Found":"\u274C Not found"}`),console.log(`\uD83D\uDCE6 Package.json: ${_.hasPackageJson?"\u2705 Found":"\u274C Not found"}`),console.log(`\uD83D\uDCC4 stx Files: ${_.stxFiles}`),console.log(`\uD83D\uDCDD Markdown Files: ${_.markdownFiles}`),console.log(`\uD83D\uDCCA Total Files: ${_.totalFiles}`),J.verbose&&W.length>0)console.log(`
18385
18385
  \uD83D\uDCC4 STX Files:`),W.forEach((B)=>{console.log(` ${t.relative(Q,B)}`)});if(J.verbose&&U.length>0)console.log(`
18386
- \uD83D\uDCDD Markdown Files:`),U.forEach((B)=>{console.log(` ${t.relative(Q,B)}`)})}}catch(Q){console.error("Error getting project status:",Q),x.exit(1)}}),H0.command("watch [patterns...]","Watch STX files for changes and run commands").option("--command <cmd>","Command to run on file changes",{default:"build"}).option("--ignore <patterns>","Comma-separated patterns to ignore").option("--debounce <ms>","Debounce delay before running command after change",{default:300}).option("--output <dir>","Output directory for command results").option("--verbose","Show detailed file change information").option("--clear","Clear console before running command").example("stx watch").example('stx watch **/*.stx --command "stx build"').example('stx watch --ignore "node_modules/**,dist/**"').action(async(X,J)=>{try{if(!X||X.length===0)console.error("\u274C Input file or pattern is required"),console.error("\uD83D\uDCA1 Specify a file pattern to watch (e.g., stx watch *.stx)"),x.exit(1);let Q=Array.isArray(X)?X:[X],G=J.ignore?J.ignore.split(",").map((j)=>j.trim()):["node_modules/**","dist/**",".git/**"];if(J.debounce!==void 0){if(!zK(J.debounce).isValid)console.error("\u274C Debounce must be a valid number"),console.error("\uD83D\uDCA1 Specify debounce in milliseconds (e.g., --debounce 300)"),x.exit(1)}if(J.output){if((J.output.match(/\.\.\//g)||[]).length>=3)console.error("\u274C Invalid output directory"),console.error("\uD83D\uDCA1 Specify a valid output directory path"),x.exit(1)}let K=J.debounce||300;console.log(`\uD83D\uDC40 Watching files: ${Q.join(", ")}`),console.log(`\uD83D\uDEAB Ignoring: ${G.join(", ")}`),console.log(`\u23F1\uFE0F Debounce: ${K}ms`),console.log(`\uD83D\uDD27 Command: ${J.command}`),console.log(`
18386
+ \uD83D\uDCDD Markdown Files:`),U.forEach((B)=>{console.log(` ${t.relative(Q,B)}`)})}}catch(Q){console.error("Error getting project status:",Q),y.exit(1)}}),H0.command("watch [patterns...]","Watch STX files for changes and run commands").option("--command <cmd>","Command to run on file changes",{default:"build"}).option("--ignore <patterns>","Comma-separated patterns to ignore").option("--debounce <ms>","Debounce delay before running command after change",{default:300}).option("--output <dir>","Output directory for command results").option("--verbose","Show detailed file change information").option("--clear","Clear console before running command").example("stx watch").example('stx watch **/*.stx --command "stx build"').example('stx watch --ignore "node_modules/**,dist/**"').action(async(X,J)=>{try{if(!X||X.length===0)console.error("\u274C Input file or pattern is required"),console.error("\uD83D\uDCA1 Specify a file pattern to watch (e.g., stx watch *.stx)"),y.exit(1);let Q=Array.isArray(X)?X:[X],G=J.ignore?J.ignore.split(",").map((j)=>j.trim()):["node_modules/**","dist/**",".git/**"];if(J.debounce!==void 0){if(!zK(J.debounce).isValid)console.error("\u274C Debounce must be a valid number"),console.error("\uD83D\uDCA1 Specify debounce in milliseconds (e.g., --debounce 300)"),y.exit(1)}if(J.output){if((J.output.match(/\.\.\//g)||[]).length>=3)console.error("\u274C Invalid output directory"),console.error("\uD83D\uDCA1 Specify a valid output directory path"),y.exit(1)}let K=J.debounce||300;console.log(`\uD83D\uDC40 Watching files: ${Q.join(", ")}`),console.log(`\uD83D\uDEAB Ignoring: ${G.join(", ")}`),console.log(`\u23F1\uFE0F Debounce: ${K}ms`),console.log(`\uD83D\uDD27 Command: ${J.command}`),console.log(`
18387
18387
  Press Ctrl+C to stop watching...
18388
- `);let W,U=!1,_=new Set;_.add(x.cwd());for(let j of Q)(await Array.fromAsync(new Bun.Glob(j).scan({onlyFiles:!0,absolute:!0}))).forEach((O)=>{_.add(t.dirname(O))});let B=async()=>{if(U)return;if(U=!0,J.clear)console.clear();console.log(`\uD83D\uDD04 Running: ${J.command}`);let j=Date.now();try{let[H,...O]=J.command.split(" ");rF(H,O,{stdio:"inherit",shell:!0}).on("close",(L)=>{let V=Date.now()-j;if(L===0)console.log(`\u2705 Command completed successfully in ${V}ms`);else console.log(`\u274C Command failed with exit code ${L} after ${V}ms`);U=!1})}catch(H){console.error("\u274C Error running command:",H),U=!1}},z=(j,H)=>{if(!H)return;if(G.some((L)=>{if(L.includes("*"))return H.match(L.replace(/\*/g,".*"));return H.includes(L)})){if(J.verbose)console.log(`\uD83D\uDEAB Ignoring: ${H}`);return}if(!Q.some((L)=>{if(L.includes("*"))return H.match(L.replace(/\*/g,".*"));return H.endsWith(L)})){if(J.verbose)console.log(`\u23ED\uFE0F Skipping: ${H} (doesn't match patterns)`);return}if(J.verbose)console.log(`\uD83D\uDCDD ${j.toUpperCase()}: ${H}`);if(W)clearTimeout(W);W=setTimeout(B,K)},q=[];for(let j of _)try{let H=S0.watch(j,{recursive:!0},z);if(q.push(H),J.verbose)console.log(`\uD83D\uDCC1 Watching directory: ${j}`)}catch(H){console.warn(`\u26A0\uFE0F Could not watch directory: ${j}`)}x.on("SIGINT",()=>{console.log(`
18389
- \uD83D\uDED1 Stopping file watcher...`),q.forEach((j)=>j.close()),x.exit(0)})}catch(Q){console.error("Error setting up file watcher:",Q),x.exit(1)}}),H0.command("analyze [patterns...]","Analyze STX templates for performance and best practices").option("--json","Output results as JSON").option("--detailed","Show detailed analysis for each file").option("--only-issues","Only show files with issues").option("--save-report <file>","Save analysis report to file").option("--threshold <level>","Only show issues at or above this level (info, warning, error)",{default:"info"}).example("stx analyze").example("stx analyze **/*.stx --detailed").example("stx analyze --only-issues --threshold warning").action(async(X,J)=>{try{let Q=X&&X.length>0?X:["**/*.stx"],G=J.threshold||"info",K={info:0,warning:1,error:2},W=K[G];if(!J.json)console.log("\uD83D\uDD0D Analyzing stx templates...");let{results:U,summary:_}=await E2(Q);if(U.length===0){console.log("No STX files found to analyze.");return}let B=J.onlyIssues?U.filter((z)=>z.issues.some((q)=>K[q.type]>=W)):U;if(J.json){let z={summary:_,results:B,generatedAt:new Date().toISOString()};if(J.saveReport)await Bun.write(J.saveReport,JSON.stringify(z,null,2)),console.log(`\uD83D\uDCCB Analysis report saved to: ${J.saveReport}`);else console.log(JSON.stringify(z,null,2));return}if(console.log(`
18388
+ `);let W,U=!1,_=new Set;_.add(y.cwd());for(let j of Q)(await Array.fromAsync(new Bun.Glob(j).scan({onlyFiles:!0,absolute:!0}))).forEach((O)=>{_.add(t.dirname(O))});let B=async()=>{if(U)return;if(U=!0,J.clear)console.clear();console.log(`\uD83D\uDD04 Running: ${J.command}`);let j=Date.now();try{let[H,...O]=J.command.split(" ");rF(H,O,{stdio:"inherit",shell:!0}).on("close",(L)=>{let V=Date.now()-j;if(L===0)console.log(`\u2705 Command completed successfully in ${V}ms`);else console.log(`\u274C Command failed with exit code ${L} after ${V}ms`);U=!1})}catch(H){console.error("\u274C Error running command:",H),U=!1}},z=(j,H)=>{if(!H)return;if(G.some((L)=>{if(L.includes("*"))return H.match(L.replace(/\*/g,".*"));return H.includes(L)})){if(J.verbose)console.log(`\uD83D\uDEAB Ignoring: ${H}`);return}if(!Q.some((L)=>{if(L.includes("*"))return H.match(L.replace(/\*/g,".*"));return H.endsWith(L)})){if(J.verbose)console.log(`\u23ED\uFE0F Skipping: ${H} (doesn't match patterns)`);return}if(J.verbose)console.log(`\uD83D\uDCDD ${j.toUpperCase()}: ${H}`);if(W)clearTimeout(W);W=setTimeout(B,K)},q=[];for(let j of _)try{let H=S0.watch(j,{recursive:!0},z);if(q.push(H),J.verbose)console.log(`\uD83D\uDCC1 Watching directory: ${j}`)}catch(H){console.warn(`\u26A0\uFE0F Could not watch directory: ${j}`)}y.on("SIGINT",()=>{console.log(`
18389
+ \uD83D\uDED1 Stopping file watcher...`),q.forEach((j)=>j.close()),y.exit(0)})}catch(Q){console.error("Error setting up file watcher:",Q),y.exit(1)}}),H0.command("analyze [patterns...]","Analyze STX templates for performance and best practices").option("--json","Output results as JSON").option("--detailed","Show detailed analysis for each file").option("--only-issues","Only show files with issues").option("--save-report <file>","Save analysis report to file").option("--threshold <level>","Only show issues at or above this level (info, warning, error)",{default:"info"}).example("stx analyze").example("stx analyze **/*.stx --detailed").example("stx analyze --only-issues --threshold warning").action(async(X,J)=>{try{let Q=X&&X.length>0?X:["**/*.stx"],G=J.threshold||"info",K={info:0,warning:1,error:2},W=K[G];if(!J.json)console.log("\uD83D\uDD0D Analyzing stx templates...");let{results:U,summary:_}=await E2(Q);if(U.length===0){console.log("No STX files found to analyze.");return}let B=J.onlyIssues?U.filter((z)=>z.issues.some((q)=>K[q.type]>=W)):U;if(J.json){let z={summary:_,results:B,generatedAt:new Date().toISOString()};if(J.saveReport)await Bun.write(J.saveReport,JSON.stringify(z,null,2)),console.log(`\uD83D\uDCCB Analysis report saved to: ${J.saveReport}`);else console.log(JSON.stringify(z,null,2));return}if(console.log(`
18390
18390
  \uD83D\uDCCA Analysis Summary`),console.log("\u2500".repeat(50)),console.log(`\uD83D\uDCC1 Files analyzed: ${_.totalFiles}`),console.log(`\uD83D\uDCCF Total lines: ${_.totalLines.toLocaleString()}`),console.log(`\uD83E\uDDEE Average complexity: ${_.avgComplexity}/10`),console.log(`\u26A0\uFE0F Total issues: ${_.totalIssues}`),console.log(`\uD83D\uDE80 Performance score: ${_.performanceScore}/10`),Object.keys(_.issuesByCategory).length>0){console.log(`
18391
18391
  \uD83D\uDCCB Issues by category:`);for(let[z,q]of Object.entries(_.issuesByCategory))console.log(` ${z}: ${q}`)}if(_.recommendations.length>0)console.log(`
18392
18392
  \uD83D\uDCA1 Project recommendations:`),_.recommendations.forEach((z)=>{console.log(` \u2022 ${z}`)});if(J.detailed){console.log(`
18393
18393
  \uD83D\uDCC4 Detailed File Analysis`),console.log("\u2550".repeat(60));for(let z of B){if(console.log(`
18394
- \uD83D\uDCDD ${t.relative(x.cwd(),z.file)}`),console.log(` Lines: ${z.metrics.lines} | Complexity: ${z.metrics.complexity}/10 | Estimated render: ${z.performance.estimatedRenderTime}ms`),z.issues.length>0){let q=z.issues.filter((j)=>K[j.type]>=W);if(q.length>0)console.log(` Issues (${q.length}):`),q.forEach((j)=>{let H=j.type==="error"?"\u274C":j.type==="warning"?"\u26A0\uFE0F":"\u2139\uFE0F";if(console.log(` ${H} ${j.message}`),j.suggestion)console.log(` \uD83D\uDCA1 ${j.suggestion}`)})}if(z.suggestions.length>0)console.log(` Suggestions (${z.suggestions.length}):`),z.suggestions.forEach((q)=>{let j=q.impact==="high"?"\uD83D\uDD25":q.impact==="medium"?"\u26A1":"\uD83D\uDCAB";console.log(` ${j} ${q.message} (${q.impact} impact, ${q.effort} effort)`)})}}else if(B.length>0&&!J.onlyIssues)console.log(`
18395
- \uD83D\uDCC4 Files with issues:`),B.forEach((z)=>{let q=z.issues.filter((j)=>K[j.type]>=W).length;if(q>0)console.log(` ${t.relative(x.cwd(),z.file)} (${q} issues)`)});if(J.saveReport){let z={summary:_,results:B,generatedAt:new Date().toISOString(),commandOptions:J};await Bun.write(J.saveReport,JSON.stringify(z,null,2)),console.log(`
18394
+ \uD83D\uDCDD ${t.relative(y.cwd(),z.file)}`),console.log(` Lines: ${z.metrics.lines} | Complexity: ${z.metrics.complexity}/10 | Estimated render: ${z.performance.estimatedRenderTime}ms`),z.issues.length>0){let q=z.issues.filter((j)=>K[j.type]>=W);if(q.length>0)console.log(` Issues (${q.length}):`),q.forEach((j)=>{let H=j.type==="error"?"\u274C":j.type==="warning"?"\u26A0\uFE0F":"\u2139\uFE0F";if(console.log(` ${H} ${j.message}`),j.suggestion)console.log(` \uD83D\uDCA1 ${j.suggestion}`)})}if(z.suggestions.length>0)console.log(` Suggestions (${z.suggestions.length}):`),z.suggestions.forEach((q)=>{let j=q.impact==="high"?"\uD83D\uDD25":q.impact==="medium"?"\u26A1":"\uD83D\uDCAB";console.log(` ${j} ${q.message} (${q.impact} impact, ${q.effort} effort)`)})}}else if(B.length>0&&!J.onlyIssues)console.log(`
18395
+ \uD83D\uDCC4 Files with issues:`),B.forEach((z)=>{let q=z.issues.filter((j)=>K[j.type]>=W).length;if(q>0)console.log(` ${t.relative(y.cwd(),z.file)} (${q} issues)`)});if(J.saveReport){let z={summary:_,results:B,generatedAt:new Date().toISOString(),commandOptions:J};await Bun.write(J.saveReport,JSON.stringify(z,null,2)),console.log(`
18396
18396
  \uD83D\uDCCB Analysis report saved to: ${J.saveReport}`)}console.log(`
18397
- \u2728 Analysis complete! Use --detailed for more information.`)}catch(Q){console.error("Error analyzing templates:",Q),x.exit(1)}}),H0.command("version","Show the version of the CLI").action(()=>{console.log(o4)}),H0.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(X)=>{let{startInteractive:J}=await Promise.resolve().then(() => (QQ(),YH)),Q={};if(X.context){let G=t.resolve(X.context);if(S0.existsSync(G))try{let K=S0.readFileSync(G,"utf-8");Q=JSON.parse(K)}catch(K){console.error("Error loading context file:",K),x.exit(1)}else console.error(`Context file not found: ${G}`),x.exit(1)}await J({context:Q,cwd:X.cwd?t.resolve(X.cwd):x.cwd(),verbose:X.verbose})}),H0.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(X,J)=>{try{let{buildNative:Q,getAvailableTargets:G,getAvailableFormats:K}=await Promise.resolve().then(() => (wL(),NL)),W=t.resolve(X);if(!S0.existsSync(W))console.error(`\u274C Input file not found: ${X}`),x.exit(1);let U=G();if(J.target&&!["macos","windows","linux","ios","android"].includes(J.target))console.error(`\u274C Invalid target: ${J.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${U.join(", ")}`),x.exit(1);let _=J.target||U[0],B=K(_);if(J.format&&!B.includes(J.format))console.error(`\u274C Invalid format for ${_}: ${J.format}`),console.error(`\uD83D\uDCA1 Available formats: ${B.join(", ")}`),x.exit(1);console.log(`
18397
+ \u2728 Analysis complete! Use --detailed for more information.`)}catch(Q){console.error("Error analyzing templates:",Q),y.exit(1)}}),H0.command("version","Show the version of the CLI").action(()=>{console.log(o4)}),H0.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(X)=>{let{startInteractive:J}=await Promise.resolve().then(() => (QQ(),YH)),Q={};if(X.context){let G=t.resolve(X.context);if(S0.existsSync(G))try{let K=S0.readFileSync(G,"utf-8");Q=JSON.parse(K)}catch(K){console.error("Error loading context file:",K),y.exit(1)}else console.error(`Context file not found: ${G}`),y.exit(1)}await J({context:Q,cwd:X.cwd?t.resolve(X.cwd):y.cwd(),verbose:X.verbose})}),H0.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(X,J)=>{try{let{buildNative:Q,getAvailableTargets:G,getAvailableFormats:K}=await Promise.resolve().then(() => (wL(),NL)),W=t.resolve(X);if(!S0.existsSync(W))console.error(`\u274C Input file not found: ${X}`),y.exit(1);let U=G();if(J.target&&!["macos","windows","linux","ios","android"].includes(J.target))console.error(`\u274C Invalid target: ${J.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${U.join(", ")}`),y.exit(1);let _=J.target||U[0],B=K(_);if(J.format&&!B.includes(J.format))console.error(`\u274C Invalid format for ${_}: ${J.format}`),console.error(`\uD83D\uDCA1 Available formats: ${B.join(", ")}`),y.exit(1);console.log(`
18398
18398
  \uD83D\uDD28 Building native app...`),console.log(` Input: ${X}`),console.log(` Target: ${_}`),console.log(` Format: ${J.format||"default"}`),console.log(` Output: ${J.output}
18399
18399
  `);let z=await Q({input:W,output:t.resolve(J.output),target:_,format:J.format,name:J.name,version:J.version,description:J.description,author:J.author,bundleId:J.bundleId,icon:J.icon?t.resolve(J.icon):void 0,window:{title:J.title,width:Number.parseInt(J.width,10),height:Number.parseInt(J.height,10),frameless:J.frameless,alwaysOnTop:J.alwaysOnTop},systemTray:J.systemTray,devTools:J.devTools,craftPath:J.craftPath,verbose:J.verbose});if(z.success){if(console.log("\u2705 Build successful!"),console.log(` Output: ${z.outputPath}`),z.duration)console.log(` Duration: ${(z.duration/1000).toFixed(2)}s`);if(_==="macos"&&z.format==="app")console.log(`
18400
18400
  \uD83D\uDCA1 To run: open "${z.outputPath}"`);else if(_==="linux"&&z.format==="appimage")console.log(`
18401
- \uD83D\uDCA1 To run: chmod +x "${z.outputPath}" && "${z.outputPath}"`)}else console.error(`\u274C Build failed: ${z.error}`),x.exit(1)}catch(Q){console.error(`\u274C Build error: ${Q.message}`),x.exit(1)}}),H0.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(X)=>{try{let{devCommand:J}=await Promise.resolve().then(() => (RF(),wF));await J({port:X.port?Number.parseInt(X.port,10):6006,open:X.open,host:X.host})}catch(J){console.error(`\u274C Story error: ${J.message}`),x.exit(1)}}),H0.command("story:build","Build static story site").option("-o, --outDir <dir>","Output directory",{default:".stx/dist/story"}).example("stx story:build").example("stx story:build --outDir ./docs/components").action(async(X)=>{try{let{buildCommand:J}=await Promise.resolve().then(() => (kF(),DF));await J({outDir:X.outDir})}catch(J){console.error(`\u274C Story build error: ${J.message}`),x.exit(1)}}),H0.command("story:test","Run visual regression tests").option("-u, --update","Update snapshots",{default:!1}).option("-f, --filter <name>","Filter components by name").example("stx story:test").example("stx story:test --update").example("stx story:test --filter Button").action(async(X)=>{try{let{createContext:J}=await Promise.resolve().then(() => (K8(),vL)),{runVisualTests:Q,updateSnapshots:G,formatTestResults:K}=await Promise.resolve().then(() => (PF(),CF)),W=await J({mode:"build"});if(X.update){let U=await G(W,{filter:X.filter?[X.filter]:void 0});console.log(`Updated ${U} snapshots`)}else{let U=await Q(W,{filter:X.filter?[X.filter]:void 0});if(console.log(K(U)),U.failed>0)x.exit(1)}}catch(J){console.error(`\u274C Story test error: ${J.message}`),x.exit(1)}}),H0.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(X,J)=>{try{let{compileToNative:Q}=await Promise.resolve().then(() => (lF(),pF)),G=t.resolve(X);if(!S0.existsSync(G))console.error(`\u274C Input file not found: ${X}`),x.exit(1);let K=["macos","windows","linux","ios","android","universal"];if(!K.includes(J.target))console.error(`\u274C Invalid target: ${J.target}`),console.error(`\uD83D\uDCA1 Available targets: ${K.join(", ")}`),x.exit(1);let W=["zig","typescript","json"];if(!W.includes(J.format))console.error(`\u274C Invalid format: ${J.format}`),console.error(`\uD83D\uDCA1 Available formats: ${W.join(", ")}`),x.exit(1);console.log(`
18401
+ \uD83D\uDCA1 To run: chmod +x "${z.outputPath}" && "${z.outputPath}"`)}else console.error(`\u274C Build failed: ${z.error}`),y.exit(1)}catch(Q){console.error(`\u274C Build error: ${Q.message}`),y.exit(1)}}),H0.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(X)=>{try{let{devCommand:J}=await Promise.resolve().then(() => (RF(),wF));await J({port:X.port?Number.parseInt(X.port,10):6006,open:X.open,host:X.host})}catch(J){console.error(`\u274C Story error: ${J.message}`),y.exit(1)}}),H0.command("story:build","Build static story site").option("-o, --outDir <dir>","Output directory",{default:".stx/dist/story"}).example("stx story:build").example("stx story:build --outDir ./docs/components").action(async(X)=>{try{let{buildCommand:J}=await Promise.resolve().then(() => (kF(),DF));await J({outDir:X.outDir})}catch(J){console.error(`\u274C Story build error: ${J.message}`),y.exit(1)}}),H0.command("story:test","Run visual regression tests").option("-u, --update","Update snapshots",{default:!1}).option("-f, --filter <name>","Filter components by name").example("stx story:test").example("stx story:test --update").example("stx story:test --filter Button").action(async(X)=>{try{let{createContext:J}=await Promise.resolve().then(() => (K8(),vL)),{runVisualTests:Q,updateSnapshots:G,formatTestResults:K}=await Promise.resolve().then(() => (PF(),CF)),W=await J({mode:"build"});if(X.update){let U=await G(W,{filter:X.filter?[X.filter]:void 0});console.log(`Updated ${U} snapshots`)}else{let U=await Q(W,{filter:X.filter?[X.filter]:void 0});if(console.log(K(U)),U.failed>0)y.exit(1)}}catch(J){console.error(`\u274C Story test error: ${J.message}`),y.exit(1)}}),H0.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(X,J)=>{try{let{compileToNative:Q}=await Promise.resolve().then(() => (lF(),pF)),G=t.resolve(X);if(!S0.existsSync(G))console.error(`\u274C Input file not found: ${X}`),y.exit(1);let K=["macos","windows","linux","ios","android","universal"];if(!K.includes(J.target))console.error(`\u274C Invalid target: ${J.target}`),console.error(`\uD83D\uDCA1 Available targets: ${K.join(", ")}`),y.exit(1);let W=["zig","typescript","json"];if(!W.includes(J.format))console.error(`\u274C Invalid format: ${J.format}`),console.error(`\uD83D\uDCA1 Available formats: ${W.join(", ")}`),y.exit(1);console.log(`
18402
18402
  \uD83D\uDD27 Compiling stx template to native code...`),console.log(` Input: ${X}`),console.log(` Target: ${J.target}`),console.log(` Format: ${J.format}`),console.log(` Output: ${J.output}
18403
18403
  `);let U=S0.readFileSync(G,"utf-8"),_=await Q(U,{target:J.target,format:J.format,optimize:J.optimize,treeShake:J.treeShake,hotReload:J.hotReload,debug:J.verbose,sourceMaps:J.sourcemaps,bundle:J.bundle,minify:J.minify}),B=t.resolve(J.output);if(!S0.existsSync(B))S0.mkdirSync(B,{recursive:!0});let z=t.basename(X,t.extname(X)),q=J.format==="typescript"?"ts":J.format==="json"?"json":"zig",j=t.join(B,`${z}.${q}`);S0.writeFileSync(j,_.code);let H=t.join(B,`${z}.manifest.json`);if(S0.writeFileSync(H,JSON.stringify(_.manifest,null,2)),J.sourcemaps&&_.sourceMaps){let O=t.join(B,`${z}.${q}.map`);S0.writeFileSync(O,_.sourceMaps)}if(J.target==="universal"&&_.platformCode.size>0)for(let[O,F]of _.platformCode){let L=t.join(B,`${z}.${O}.${q}`);S0.writeFileSync(L,F)}if(console.log("\u2705 Compilation successful!"),console.log(` Output: ${j}`),console.log(` Manifest: ${H}`),console.log(`
18404
18404
  \uD83D\uDCCA Statistics:`),console.log(` Compilation time: ${_.stats.compilationTime.toFixed(2)}ms`),console.log(` Total components: ${_.stats.totalComponents}`),console.log(` Native components: ${_.stats.nativeComponents}`),console.log(` Web fallback components: ${_.stats.webComponents}`),console.log(` Bundle size: ${(_.stats.bundleSize/1024).toFixed(2)}KB`),_.stats.warnings.length>0){console.log(`
18405
18405
  \u26A0\uFE0F Warnings:`);for(let O of _.stats.warnings)console.log(` - ${O.message}`)}if(_.stats.errors.length>0){console.log(`
18406
- \u274C Errors:`);for(let O of _.stats.errors)console.log(` - ${O.message}`)}}catch(Q){console.error(`\u274C Compilation error: ${Q.message}`),x.exit(1)}});let Z=["docs","iconify","dev","a11y","build","start","build:native","compile","test","init","new","format","perf","debug","status","watch","analyze","version","deploy","interactive","i","story","story:build","story:test"],Y=x.argv.slice(2);if(Y.length>0&&!Y[0].startsWith("-")){let X=Y[0];if(X==="")console.error("\u274C No command provided"),console.error("\uD83D\uDCA1 Use --help to see available commands"),x.exit(1);if(!Z.includes(X)){let J=a("fs"),Q=a("path"),G=X;if(!Q.isAbsolute(G))G=Q.resolve(x.cwd(),G);if(J.existsSync(G)){let K=J.statSync(G);if(K.isFile()||K.isDirectory())x.argv=[x.argv[0],x.argv[1],"dev",...Y]}else{let K=Z.map((U)=>({command:U,distance:$(X,U)}));K.sort((U,_)=>U.distance-_.distance);let W=K[0];if(W.distance<=3)console.error(`\u274C Unknown command: ${X}`),console.error(`\uD83D\uDCA1 Did you mean: ${W.command}?`),console.error(`
18407
- Run 'stx --help' to see available commands.`),x.exit(1);console.error(`\u274C Unknown command or path: ${X}`),console.error(`
18408
- Run 'stx --help' to see available commands.`),x.exit(1)}}}H0.help(),H0.version(o4),H0.parse(x.argv)}
18406
+ \u274C Errors:`);for(let O of _.stats.errors)console.log(` - ${O.message}`)}}catch(Q){console.error(`\u274C Compilation error: ${Q.message}`),y.exit(1)}});let Z=["docs","iconify","dev","a11y","build","start","build:native","compile","test","init","new","format","perf","debug","status","watch","analyze","version","deploy","interactive","i","story","story:build","story:test"],Y=y.argv.slice(2);if(Y.length>0&&!Y[0].startsWith("-")){let X=Y[0];if(X==="")console.error("\u274C No command provided"),console.error("\uD83D\uDCA1 Use --help to see available commands"),y.exit(1);if(!Z.includes(X)){let J=a("fs"),Q=a("path"),G=X;if(!Q.isAbsolute(G))G=Q.resolve(y.cwd(),G);if(J.existsSync(G)){let K=J.statSync(G);if(K.isFile()||K.isDirectory())y.argv=[y.argv[0],y.argv[1],"dev",...Y]}else{let K=Z.map((U)=>({command:U,distance:$(X,U)}));K.sort((U,_)=>U.distance-_.distance);let W=K[0];if(W.distance<=3)console.error(`\u274C Unknown command: ${X}`),console.error(`\uD83D\uDCA1 Did you mean: ${W.command}?`),console.error(`
18407
+ Run 'stx --help' to see available commands.`),y.exit(1);console.error(`\u274C Unknown command or path: ${X}`),console.error(`
18408
+ Run 'stx --help' to see available commands.`),y.exit(1)}}}H0.help(),H0.version(o4),H0.parse(y.argv)}