@stacksjs/stx 0.2.332 → 0.2.334

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 (163) hide show
  1. package/dist/builtins/image-worker.d.ts +17 -0
  2. package/dist/builtins/image-worker.js +12 -1
  3. package/dist/caching.d.ts +17 -0
  4. package/dist/caching.js +24 -0
  5. package/dist/chunk-046dp691.js +2 -0
  6. package/dist/{chunk-kx30cykj.js → chunk-08w4gtyf.js} +3 -3
  7. package/dist/{chunk-be5es9s3.js → chunk-09jdvqhg.js} +2 -2
  8. package/dist/{chunk-7ds14xsn.js → chunk-0vv5s039.js} +1 -1
  9. package/dist/chunk-1brnvyhv.js +2 -0
  10. package/dist/{chunk-3n9rvrk1.js → chunk-1ebyt1ba.js} +1 -1
  11. package/dist/{chunk-wx3kf6tm.js → chunk-1hzgxk2m.js} +1 -1
  12. package/dist/chunk-1jzdpvvx.js +2 -0
  13. package/dist/{chunk-mnsaf11z.js → chunk-1tva0f8f.js} +1 -1
  14. package/dist/{chunk-bsa8pxtc.js → chunk-24b4711v.js} +1 -1
  15. package/dist/{chunk-wv9v9mj9.js → chunk-27xfkzks.js} +1 -1
  16. package/dist/{chunk-mywrt0dp.js → chunk-2cm03y4y.js} +1 -1
  17. package/dist/{chunk-tp6wkx7g.js → chunk-2tjk867y.js} +1 -1
  18. package/dist/{chunk-am42axf7.js → chunk-2vgkc0kg.js} +1 -1
  19. package/dist/{chunk-w4ckece4.js → chunk-2ye35vms.js} +10 -10
  20. package/dist/{chunk-ys8sm556.js → chunk-3ntf8f5e.js} +1 -1
  21. package/dist/{chunk-33rznhw1.js → chunk-42en0cxm.js} +1 -1
  22. package/dist/{chunk-09zjty4k.js → chunk-4jdj52c5.js} +1 -1
  23. package/dist/{chunk-424e1tyj.js → chunk-4k0ce745.js} +1 -1
  24. package/dist/chunk-4tnxnzja.js +2 -0
  25. package/dist/{chunk-peqad61h.js → chunk-4ty8j3xn.js} +1 -1
  26. package/dist/{chunk-gwrrs1qh.js → chunk-5swem3qy.js} +1 -1
  27. package/dist/chunk-63yfp05p.js +2 -0
  28. package/dist/{chunk-afsy9158.js → chunk-67bh5vrj.js} +1 -1
  29. package/dist/{chunk-kptkb3j4.js → chunk-6k8h1fj1.js} +1 -1
  30. package/dist/{chunk-289vztwy.js → chunk-71y3bhcw.js} +1 -1
  31. package/dist/{chunk-yjkaqxtc.js → chunk-7r80apc5.js} +1 -1
  32. package/dist/chunk-7y4eqkv4.js +2 -0
  33. package/dist/chunk-7ywnkv1f.js +2 -0
  34. package/dist/{chunk-77sa9wz4.js → chunk-80zj5516.js} +1 -1
  35. package/dist/chunk-8730k51r.js +2 -0
  36. package/dist/chunk-907qxn09.js +2 -0
  37. package/dist/{chunk-mv6dw7dn.js → chunk-9fcq5x2r.js} +1 -1
  38. package/dist/{chunk-2jfneptq.js → chunk-9kxfz708.js} +1 -1
  39. package/dist/{chunk-97yd8erh.js → chunk-9v0fsdsf.js} +1 -1
  40. package/dist/chunk-a97tp43x.js +2 -0
  41. package/dist/{chunk-1czvb2wx.js → chunk-amxtypkp.js} +1 -1
  42. package/dist/chunk-atw841yx.js +2 -0
  43. package/dist/chunk-c1c2a5es.js +2 -0
  44. package/dist/{chunk-70nkn5te.js → chunk-c1m1gng4.js} +1 -1
  45. package/dist/chunk-c2ta859c.js +3 -0
  46. package/dist/{chunk-cqp01pgs.js → chunk-caaenc3w.js} +2 -2
  47. package/dist/{chunk-kcn1ay55.js → chunk-cdqx2c2h.js} +1 -1
  48. package/dist/{chunk-pcvayb2f.js → chunk-cdsbxghb.js} +1 -1
  49. package/dist/{chunk-mbaew5a8.js → chunk-cmtjq1db.js} +2 -2
  50. package/dist/{chunk-7kfp7jde.js → chunk-crj19mqr.js} +1 -1
  51. package/dist/chunk-cvphepjb.js +2 -0
  52. package/dist/{chunk-xgj1jw4p.js → chunk-d4etph79.js} +1 -1
  53. package/dist/{chunk-tjhzxbxa.js → chunk-deqnt1w5.js} +1 -1
  54. package/dist/{chunk-meqcxfpr.js → chunk-dfejgnny.js} +1 -1
  55. package/dist/chunk-dnesmvvb.js +2 -0
  56. package/dist/{chunk-qcf4506g.js → chunk-drqdc0mh.js} +1 -1
  57. package/dist/{chunk-g5e5kja6.js → chunk-e1sxe3q4.js} +2 -2
  58. package/dist/{chunk-6t9xcjag.js → chunk-ef0ra05n.js} +1 -1
  59. package/dist/{chunk-dwjcmxez.js → chunk-eth22r93.js} +1 -1
  60. package/dist/chunk-ewsx2qxm.js +2 -0
  61. package/dist/{chunk-sj3k3jwt.js → chunk-farwrdr2.js} +1 -1
  62. package/dist/chunk-fcenm8n1.js +2 -0
  63. package/dist/chunk-fkdnfjc2.js +3 -0
  64. package/dist/chunk-gbz6pfs8.js +2 -0
  65. package/dist/chunk-gd2d52kn.js +2 -0
  66. package/dist/{chunk-2h6pmz31.js → chunk-gdbkqatx.js} +1 -1
  67. package/dist/{chunk-gne68nyp.js → chunk-gptwwv3c.js} +1 -1
  68. package/dist/{chunk-5ep11kvc.js → chunk-hyfjnn7g.js} +1 -1
  69. package/dist/{chunk-2jzntvfr.js → chunk-hzfd8cz0.js} +13 -2
  70. package/dist/{chunk-zyb5gfr0.js → chunk-j2dj21ay.js} +1 -1
  71. package/dist/chunk-jnahcd4d.js +2 -0
  72. package/dist/{chunk-kbv4km5j.js → chunk-k6ky5et7.js} +1 -1
  73. package/dist/{chunk-4zwjqcw4.js → chunk-kffndzch.js} +3 -3
  74. package/dist/{chunk-n2y2941z.js → chunk-kk7p8ekz.js} +1 -1
  75. package/dist/{chunk-dfymexrx.js → chunk-kpeqn5tx.js} +1 -1
  76. package/dist/{chunk-2t8jekek.js → chunk-krpkfndf.js} +1 -1
  77. package/dist/{chunk-m3a20mmb.js → chunk-kw98dfza.js} +1 -1
  78. package/dist/{chunk-r6g1n649.js → chunk-kxtqbrfr.js} +22 -22
  79. package/dist/chunk-m1yrakpk.js +2 -0
  80. package/dist/{chunk-mkk731dy.js → chunk-m8kezfrt.js} +1 -1
  81. package/dist/{chunk-z6xtb8fj.js → chunk-mm59b0gg.js} +1 -1
  82. package/dist/{chunk-7ymv9pd6.js → chunk-n66k2v2q.js} +2 -2
  83. package/dist/chunk-n9c975db.js +2 -0
  84. package/dist/{chunk-fc1g65e0.js → chunk-nat3actx.js} +1 -1
  85. package/dist/{chunk-kxtfmwy0.js → chunk-p1hy2bwn.js} +3 -3
  86. package/dist/{chunk-tz7t6ybm.js → chunk-pbexz0d4.js} +2 -2
  87. package/dist/{chunk-ms2kjpdt.js → chunk-pbzdjhp8.js} +1 -1
  88. package/dist/{chunk-d9ajsetq.js → chunk-q05eh1n4.js} +1 -1
  89. package/dist/{chunk-3wvdm033.js → chunk-q0g5c39d.js} +1 -1
  90. package/dist/chunk-q2hvne0v.js +2 -0
  91. package/dist/{chunk-cvedh4a7.js → chunk-q4p1h741.js} +1 -1
  92. package/dist/{chunk-qnx0eb8x.js → chunk-q569zmrr.js} +1 -1
  93. package/dist/{chunk-0w8t922h.js → chunk-q85qp5we.js} +1 -1
  94. package/dist/chunk-qpbk50xd.js +2 -0
  95. package/dist/{chunk-bsm13y1j.js → chunk-r8rbf28v.js} +1 -1
  96. package/dist/chunk-rxdd3k6n.js +2 -0
  97. package/dist/chunk-ssd10kje.js +2 -0
  98. package/dist/chunk-szx6pxh3.js +2 -0
  99. package/dist/{chunk-557n2zx7.js → chunk-t8ctvjqe.js} +1 -1
  100. package/dist/{chunk-wbtamqdk.js → chunk-te6qym2g.js} +2 -2
  101. package/dist/{chunk-xzkc36wt.js → chunk-tjag2cmm.js} +1 -1
  102. package/dist/{chunk-fw4nxafz.js → chunk-tpmgq2dx.js} +1 -1
  103. package/dist/chunk-tte4m2s9.js +2 -0
  104. package/dist/chunk-v0v1pxwh.js +2 -0
  105. package/dist/chunk-vv289x82.js +2 -0
  106. package/dist/{chunk-7080py5f.js → chunk-vvd659y4.js} +1 -1
  107. package/dist/chunk-vx6mxybh.js +2 -0
  108. package/dist/{chunk-3cba0xw5.js → chunk-wx5zf66r.js} +1 -1
  109. package/dist/chunk-x510wr8z.js +2 -0
  110. package/dist/{chunk-xt7bsyj7.js → chunk-x7yc7e9v.js} +1 -1
  111. package/dist/chunk-x95sxapm.js +2 -0
  112. package/dist/{chunk-rkna71t2.js → chunk-xdmb578h.js} +1 -1
  113. package/dist/chunk-y1x2ebhv.js +2 -0
  114. package/dist/{chunk-jwkmc175.js → chunk-yk6446kr.js} +1 -1
  115. package/dist/{chunk-0tyw6va3.js → chunk-ymrxpwr8.js} +1 -1
  116. package/dist/{chunk-g3cyygvf.js → chunk-yxppshfd.js} +1 -1
  117. package/dist/chunk-yzxm75jp.js +2 -0
  118. package/dist/{chunk-33az7v0k.js → chunk-zsnrcbw1.js} +2 -2
  119. package/dist/{chunk-qjh40e31.js → chunk-zz8qgqa1.js} +2 -2
  120. package/dist/cli.js +14 -14
  121. package/dist/craft-entry.js +1 -1
  122. package/dist/craft.js +1 -1
  123. package/dist/database.js +1 -1
  124. package/dist/pwa.js +2 -2
  125. package/dist/ssg.js +2 -2
  126. package/dist/visual-testing.js +1 -1
  127. package/package.json +5 -5
  128. package/dist/chunk-0ck064qf.js +0 -2
  129. package/dist/chunk-1f43h46q.js +0 -2
  130. package/dist/chunk-20e4pcq1.js +0 -2
  131. package/dist/chunk-2evvkp6k.js +0 -2
  132. package/dist/chunk-2gfjp8q1.js +0 -2
  133. package/dist/chunk-41fhbhbn.js +0 -2
  134. package/dist/chunk-476dmgkd.js +0 -2
  135. package/dist/chunk-73sq0e73.js +0 -2
  136. package/dist/chunk-793gxvjv.js +0 -2
  137. package/dist/chunk-7f16ymjn.js +0 -2
  138. package/dist/chunk-85e05tzn.js +0 -2
  139. package/dist/chunk-94c8we2y.js +0 -2
  140. package/dist/chunk-axe4hgv2.js +0 -2
  141. package/dist/chunk-b9jknz2y.js +0 -2
  142. package/dist/chunk-c2mvx2m8.js +0 -3
  143. package/dist/chunk-cn74d92v.js +0 -2
  144. package/dist/chunk-d9gk60kk.js +0 -2
  145. package/dist/chunk-epm72mma.js +0 -2
  146. package/dist/chunk-gcjr4mwg.js +0 -2
  147. package/dist/chunk-h3w1y4q7.js +0 -2
  148. package/dist/chunk-htsetvt7.js +0 -2
  149. package/dist/chunk-j762mz1x.js +0 -2
  150. package/dist/chunk-jhhp2d7n.js +0 -2
  151. package/dist/chunk-k14sz6cz.js +0 -2
  152. package/dist/chunk-kgxbad5v.js +0 -2
  153. package/dist/chunk-m3ya2dvf.js +0 -3
  154. package/dist/chunk-nxbje85a.js +0 -2
  155. package/dist/chunk-rsp59c5x.js +0 -2
  156. package/dist/chunk-tbsgchrd.js +0 -2
  157. package/dist/chunk-v82r1j02.js +0 -2
  158. package/dist/chunk-x3evfp7c.js +0 -2
  159. package/dist/chunk-x7qbgqps.js +0 -2
  160. package/dist/chunk-xgeps3fn.js +0 -2
  161. package/dist/chunk-zgnk8tpp.js +0 -2
  162. package/dist/chunk-zhtttwz2.js +0 -2
  163. package/dist/chunk-znn3ngey.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{pw as Re,qw as d}from"./chunk-5ep11kvc.js";function N(t){return t.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>v.includes(a))}function w(t){return N(t.replace(/^\//,""))}var v;var k=d(()=>{v=["components","layouts","partials","emails"]});import f from"fs";import b from"path";function A(t,e){let a=t.filter((s)=>!w(s.pattern)),r=["// Auto-generated by STX - do not edit"];if(a.length===0)r.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{r.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let s of a){let l=[];for(let c of s.params){let u=s.pattern.includes(`:${c}?`)?"?":"";l.push(`${c}${u}: string`)}let i=l.join("; ");r.push(` '${s.pattern}': { ${i} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
2
+ import{qw as Re,rw as d}from"./chunk-hyfjnn7g.js";function N(t){return t.split(/[\\/]/).filter(Boolean).slice(0,-1).some((a)=>v.includes(a))}function w(t){return N(t.replace(/^\//,""))}var v;var k=d(()=>{v=["components","layouts","partials","emails"]});import f from"fs";import b from"path";function A(t,e){let a=t.filter((s)=>!w(s.pattern)),r=["// Auto-generated by STX - do not edit"];if(a.length===0)r.push("// No page routes found \u2014 route paths stay typed as string.","export {}","");else{r.push("declare module '@stacksjs/stx' {"," interface KnownRoutes {");for(let s of a){let l=[];for(let c of s.params){let u=s.pattern.includes(`:${c}?`)?"?":"";l.push(`${c}${u}: string`)}let i=l.join("; ");r.push(` '${s.pattern}': { ${i} }`)}r.push(" }","}","","export {}","")}let n=r.join(`
3
3
  `),o=b.join(e,"route-types.d.ts");try{if(f.existsSync(o)&&f.readFileSync(o,"utf8")===n)return;f.mkdirSync(e,{recursive:!0}),f.writeFileSync(o,n)}catch{}}function C(t,e,a){let r=process.cwd(),n=b.relative(r,a),o=t.filter((l)=>!w(l.pattern)),s=["// Auto-generated by stx \u2014 do not edit",`// Source: ${n||"pages"}/`,"","export const routes = ["];for(let l of o){let i=b.relative(r,l.filePath).replace(/\\/g,"/"),c=JSON.stringify(l.params),u=l.layout?`, layout: '${b.relative(r,l.layout).replace(/\\/g,"/")}'`:"";s.push(` { pattern: '${l.pattern}', filePath: '${i}', isDynamic: ${l.isDynamic}, params: ${c}${u} },`)}s.push("] as const",""),s.push("export type RouteName = typeof routes[number]['pattern']",""),f.mkdirSync(e,{recursive:!0}),f.writeFileSync(b.join(e,"routes.ts"),s.join(`
4
4
  `))}var P=d(()=>{k()});import K from"path";function T(t,e){let r=K.relative(e,t).replace(/\.(stx|md)$/,"");if(r=r.split(K.sep).join("/"),r==="index")return"/";if(r.endsWith("/index"))r=r.slice(0,-6);return r=r.replace(/\[\[([^\]]+)\]\]/g,":$1?"),r=r.replace(/\[([^\]]+)\]/g,":$1"),r=r.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${r}`}function x(t){let e=[],a="",r=0;while(r<t.length){let n=t.slice(r),o=/^\/:([^/?*]+)\?/.exec(n);if(o){e.push(o[1]),a+="(?:/([^/]+))?",r+=o[0].length;continue}let s=/^:([^/?*]+)\*/.exec(n);if(s){e.push(s[1]),a+="(.+)",r+=s[0].length;continue}let l=/^:([^/?*]+)/.exec(n);if(l){e.push(l[1]),a+="([^/]+)",r+=l[0].length;continue}a+=t[r].replace(/[.+^${}()|[\]\\*?]/g,"\\$&"),r+=1}return{regex:new RegExp(`^${a}$`),params:e}}function $(t,e){let a=t===""?"/":t;for(let r of e){let n=a.match(r.regex);if(n){let o={};return r.params.forEach((s,l)=>{o[s]=n[l+1]}),{route:r,params:o}}}return null}function z(t){let e=t.replace(/\[\[([^\]]+)\]\]/g,":$1?").replace(/\[([^\]]+)\]/g,":$1").replace(/:\.\.\.([^/]+)/g,":$1*");return x(e)}var B=()=>{};import Ce from"fs";import G from"path";function E(t,e){let a=[],r=G.dirname(t);while(r.startsWith(e)||r===e){let n=G.join(r,"_layout.stx");if(Ce.existsSync(n))a.unshift(n);if(r===e)break;r=G.dirname(r)}return a}var U=()=>{};import R from"fs";import p from"path";function Y(t,e){let a=[];if(!R.existsSync(t))return a;let r=R.readdirSync(t,{withFileTypes:!0});for(let n of r){let o=p.join(t,n.name);if(n.isDirectory()){if(n.name.startsWith("."))continue;if(v.includes(n.name))continue;a.push(...Y(o,e))}else if(n.isFile()){let s=p.extname(n.name);if(e.includes(s)){if(n.name.startsWith("_")&&n.name!=="_layout.stx")continue;if(n.name==="_layout.stx")continue;a.push(o)}}}return a}class L{routes;pagesDir;pagesDirs;config;constructor(t,e={}){this.config=e;let a=e.pagesDirs&&e.pagesDirs.length>0?e.pagesDirs:[e.pagesDir||"pages"];this.pagesDirs=a.map((i)=>p.resolve(t,i)),this.pagesDir=this.pagesDirs[0];let r=e.extensions||[".stx"],n=(i)=>{let c=p.resolve(t,i);try{return R.realpathSync(c)}catch{return c}},o=(e.exclude??[]).filter((i)=>typeof i==="string"&&i.trim()!=="").map(n),s=(i)=>{if(o.length===0)return!1;let c=n(i);return o.some((u)=>c===u||c.startsWith(`${u}${p.sep}`))},l=new Set;this.routes=[];for(let i of this.pagesDirs){let c=Y(i,r).filter((h)=>!s(h)),u=new Map;for(let h of c){let m=T(h,i),y=e.pagesDirs?m.replace(/:[\w]+/g,":param"):m;if(e.pagesDirs&&u.has(y))throw Error(`Conflicting layer pages for ${m}: ${u.get(y)} and ${h}`);if(u.set(y,h),l.has(y))continue;l.add(y);let{regex:Ae,params:W}=x(m),I=e.layouts!==!1?E(h,i):[];this.routes.push({pattern:m,regex:Ae,params:W,filePath:h,isDynamic:W.length>0,layout:I.length>0?I[I.length-1]:void 0})}}if(this.routes.sort((i,c)=>{if(!i.isDynamic&&c.isDynamic)return-1;if(i.isDynamic&&!c.isDynamic)return 1;let u=i.pattern.split("/").length,h=c.pattern.split("/").length;if(u!==h)return h-u;return i.pattern.localeCompare(c.pattern)}),e.emit!==!1){let i=p.resolve(t,e.stateDir||process.env.STX_DIR?.trim()||".stx");A(this.routes,i),C(this.routes,i,this.pagesDir)}}match(t){let e=t===""?"/":t;for(let a of this.routes){let r=e.match(a.regex);if(r){let n={};return a.params.forEach((o,s)=>{n[o]=r[s+1]}),{route:a,params:n}}}return null}resolve(t,e){let a=this.routes.find((n)=>n.pattern===t||n.filePath.includes(t));if(!a)return"#not-found";let r=a.pattern;if(e)for(let[n,o]of Object.entries(e))r=r.replace(`:${n}`,encodeURIComponent(o));return r}addRoute(t){this.routes.push(t),this.routes.sort((e,a)=>{if(!e.isDynamic&&a.isDynamic)return-1;if(e.isDynamic&&!a.isDynamic)return 1;return e.pattern.localeCompare(a.pattern)})}getLayout(t){return t.layout??null}}function J(t,e){return new L(t,e)}function Z(t,e){let a=[`${e}.stx`,"error.stx"];for(let r of a){let n=p.join(t,r);if(R.existsSync(n))return n}return null}function Q(t,e){return t.map((a)=>{let r=p.relative(e,a.filePath),n=a.isDynamic?" (dynamic)":"";return`${a.pattern} \u2192 ${r}${n}`})}var ee=d(()=>{P();B();U();k()});function te(t){_=t.replace(/\/$/,"")}function re(t,e,a={}){g[t]={path:e,name:t,params:a}}function ae(t){for(let[e,a]of Object.entries(t))if(typeof a==="string")g[e]={path:a,name:e};else g[e]={...a,name:e}}function ne(t,e={},a=!1){let r=g[t];if(!r)return console.warn(`Route [${t}] not defined.`),"#undefined-route";let n={...r.params,...e},o=r.path;o=o.replace(/:(\w+)/g,(l,i)=>{let c=n[i];if(c===void 0)return console.warn(`Missing parameter [${i}] for route [${t}].`),`:${i}`;return delete n[i],encodeURIComponent(String(c))});let s=Object.entries(n);if(s.length>0){let l=s.map(([i,c])=>`${encodeURIComponent(i)}=${encodeURIComponent(String(c))}`).join("&");o+=(o.includes("?")?"&":"?")+l}return a&&_?`${_}${o}`:o}function se(){for(let t of Object.keys(g))delete g[t];_=""}var g,_="";var oe=d(()=>{g={}});import ie from"fs";import le from"path";function ce(t,e={}){return{type:"redirect",path:t,options:{replace:e.replace??!1,external:e.external??!1,redirectCode:e.redirectCode??302}}}function ue(t){return{type:"abort",error:typeof t==="string"?{statusCode:500,message:t}:t}}function he(t,e={}){return{handler:t,mode:e.mode??"universal"}}function X(t){let e={};if(!t)return e;let a=t.split(";");for(let r of a){let[n,...o]=r.split("=");if(n){let s=n.trim(),l=o.join("=").trim();if(s)e[s]=decodeURIComponent(l)}}return e}function O(t,e,a={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(e)}`;if(a.expires){let n=typeof a.expires==="number"?new Date(Date.now()+a.expires*1000):a.expires;r+=`; Expires=${n.toUTCString()}`}if(a.path)r+=`; Path=${a.path}`;if(a.domain)r+=`; Domain=${a.domain}`;if(a.secure)r+="; Secure";if(a.httpOnly)r+="; HttpOnly";if(a.sameSite)r+=`; SameSite=${a.sameSite}`;return r}function j(t,e){let a=t.headers.get("cookie")||"",r=X(a);return{get(n){return r[n]},set(n,o,s={}){r[n]=o,e.append("Set-Cookie",O(n,o,s))},delete(n){delete r[n],e.append("Set-Cookie",O(n,"",{expires:new Date(0),path:"/"}))},getAll(){return{...r}}}}function q(){return{get(t){if(typeof document>"u")return;return X(document.cookie)[t]},set(t,e,a={}){if(typeof document>"u")return;document.cookie=O(t,e,a)},delete(t){if(typeof document>"u")return;document.cookie=O(t,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return X(document.cookie)}}}function H(){let t=typeof window<"u"&&typeof window.localStorage<"u";return{get(e){if(!t)return null;try{return window.localStorage.getItem(e)}catch{return null}},set(e,a){if(!t)return;try{window.localStorage.setItem(e,a)}catch{}},remove(e){if(!t)return;try{window.localStorage.removeItem(e)}catch{}},isAvailable(){return t}}}function M(t,e){S.set(t,e)}function V(t){return S.get(t)}function de(t){return S.has(t)}function pe(){S.clear()}function fe(){return Array.from(S.keys())}async function ge(t,e="middleware"){let a=le.resolve(t,e);if(!ie.existsSync(a))return;let r=ie.readdirSync(a);for(let n of r){if(!n.endsWith(".ts")&&!n.endsWith(".js"))continue;if(n.includes(".test.")||n.includes(".spec."))continue;let o=n.replace(/\.(ts|js)$/,""),s=le.join(a,n);try{let i=(await import(s)).default;if(i&&typeof i.handler==="function")M(o,i);else if(typeof i==="function")M(o,{handler:i,mode:"universal"})}catch(l){console.warn(`Failed to load middleware '${o}' from ${s}:`,l)}}}function Te(t){let e={};if(!t)return e;let a=new URLSearchParams(t);for(let[r,n]of a)e[r]=n;return e}function me(t,e,a,r=""){return{path:t,params:e,query:Te(r),fullPath:r?`${t}?${r}`:t,meta:a}}function ye(t,e,a,r){let n=r?.isServer??typeof window>"u",o=!n,s=new Headers;return{to:t,from:e,isClient:o,isServer:n,cookies:n&&a?j(a,s):q(),storage:H(),state:{},request:a,responseHeaders:s}}async function ve(t,e){let a=Array.isArray(t)?t:[t],r=e.isServer;for(let n of a){let o=V(n);if(!o)return console.error(`Route middleware '${n}' is not registered \u2014 failing the guard closed.`),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:`Route middleware '${n}' is not registered`}},state:e.state,responseHeaders:e.responseHeaders};if(o.mode==="server"&&!r)continue;try{let s=await o.handler(e);if(s){if(s.type==="redirect")return{passed:!1,redirect:s,state:e.state,responseHeaders:e.responseHeaders};if(s.type==="abort")return{passed:!1,abort:s,state:e.state,responseHeaders:e.responseHeaders}}}catch(s){return console.error(`Error in middleware '${n}':`,s),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:s instanceof Error?s.message:"Middleware error"}},state:e.state,responseHeaders:e.responseHeaders}}}return{passed:!0,state:e.state,responseHeaders:e.responseHeaders}}var S;var we=d(()=>{S=new Map});function D(t){let a=t.replace(/\\/g,"/").split("/").filter(Boolean),r=a.lastIndexOf("layouts"),n=r>=0?a[r+1]:a.at(-1);if(!n)return"app";return n.replace(/\.stx$/i,"")||"app"}function be(t){let e=t.match(/<meta\b[^>]*name=["']stx-layout["'][^>]*content=["']([^"']+)["'][^>]*>/i),a=t.match(/<meta\b[^>]*name=["']stx-layout-group["'][^>]*content=["']([^"']+)["'][^>]*>/i),r=t.match(/<!--\s*stx-layout:\s*([^ ]+)\s*-->/i),n=e?.[1]||r?.[1]||"";return{layout:n,group:a?.[1]||D(n)}}var xe=()=>{};function Ee(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}function Se(){if(F)return F;return F=Ee(`
5
5
  ;(function(){
@@ -1002,6 +1002,16 @@ else {
1002
1002
  }
1003
1003
  return '';
1004
1004
  });
1005
+ // A <style> inside a script is a string the script owns \u2014 a web
1006
+ // component's shadow-DOM CSS, typically \u2014 not a page style. Lifted into
1007
+ // <head> it restyles the whole document (its bare button rule shrank
1008
+ // every button on the page) and the component loses it. Hold scripts
1009
+ // aside while the fragment's own styles are collected.
1010
+ var heldScripts=[];
1011
+ cleanFrag=cleanFrag.replace(new RegExp('<scr'+'ipt\\\\b[^>]*>[\\\\s\\\\S]*?<\\\\/scr'+'ipt>','gi'),function(m){
1012
+ heldScripts.push(m);
1013
+ return '<!--stx-held-script-'+(heldScripts.length-1)+'-->';
1014
+ });
1005
1015
  cleanFrag=cleanFrag.replace(new RegExp('<sty'+'le\\\\b([^>]*)>([\\\\s\\\\S]*?)<\\\\/sty'+'le>','gi'),function(m,attrs,css){
1006
1016
  if(attrs.indexOf('data-css')!==-1){
1007
1017
  fragCss=css;
@@ -1016,6 +1026,7 @@ else {
1016
1026
  if(hrefMatch&&hrefMatch[2])fragCssHrefs.push(hrefMatch[2]);
1017
1027
  return '';
1018
1028
  });
1029
+ cleanFrag=cleanFrag.replace(new RegExp('<!--stx-held-script-(\\\\d+)-->','g'),function(m,i){return heldScripts[Number(i)]});
1019
1030
  // Remove old page styles (not css \u2014 that gets merged)
1020
1031
  document.querySelectorAll('style[data-stx-page]').forEach(function(s){s.remove()});
1021
1032
  // Merge css CSS from fragment into existing css style
@@ -2105,4 +2116,4 @@ else {
2105
2116
  if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
2106
2117
  })();
2107
2118
  `),F}var F;var ke=()=>{};var Le={};Re(Le,{setAppUrl:()=>te,runMiddleware:()=>ve,route:()=>ne,resolveLayoutChain:()=>E,resetRoutes:()=>se,registerMiddleware:()=>M,patternToRegex:()=>x,navigateTo:()=>ce,matchRoute:()=>$,loadMiddlewareFromDirectory:()=>ge,isNonPageRoutePattern:()=>w,isNonPageRoutePath:()=>N,hasMiddleware:()=>de,getRouterScript:()=>Se,getMiddlewareNames:()=>fe,getMiddleware:()=>V,generateRouteTypes:()=>A,generateRouteManifest:()=>C,formatRoutes:()=>Q,findErrorPage:()=>Z,filePathToPattern:()=>T,extractLayoutMetadata:()=>be,deriveLayoutGroup:()=>D,defineRoutes:()=>ae,defineRoute:()=>re,defineMiddleware:()=>he,createStorageManager:()=>H,createServerCookieManager:()=>j,createRouter:()=>J,createRouteLocation:()=>me,createMiddlewareContext:()=>ye,createClientCookieManager:()=>q,clearMiddleware:()=>pe,bracketPathToRegex:()=>z,abortNavigation:()=>ue,Router:()=>L,NON_PAGE_DIRS:()=>v});var _e=d(()=>{ee();B();oe();we();U();xe();P();k();ke()});
2108
- export{v as wv,N as xv,w as yv,A as zv,C as Av,T as Bv,x as Cv,$ as Dv,z as Ev,E as Fv,L as Gv,J as Hv,Z as Iv,Q as Jv,te as Kv,re as Lv,ae as Mv,ne as Nv,se as Ov,ce as Pv,ue as Qv,he as Rv,j as Sv,q as Tv,H as Uv,M as Vv,V as Wv,de as Xv,pe as Yv,fe as Zv,ge as _v,me as $v,ye as aw,ve as bw,D as cw,be as dw,xe as ew,Se as fw,Le as gw,_e as hw};
2119
+ export{v as xv,N as yv,w as zv,A as Av,C as Bv,T as Cv,x as Dv,$ as Ev,z as Fv,E as Gv,L as Hv,J as Iv,Z as Jv,Q as Kv,te as Lv,re as Mv,ae as Nv,ne as Ov,se as Pv,ce as Qv,ue as Rv,he as Sv,j as Tv,q as Uv,H as Vv,M as Wv,V as Xv,de as Yv,pe as Zv,fe as _v,ge as $v,me as aw,ye as bw,ve as cw,D as dw,be as ew,xe as fw,Se as gw,Le as hw,_e as iw};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{rw as l}from"./chunk-5ep11kvc.js";import U from"fs";import G from"path";import I from"os";import H from"crypto";import{generatePlaceholder as m,processImage as g}from"ts-images";var d=[320,640,768,1024,1280,1536,1920],h=["webp","jpeg"],b=80,u=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],P={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},N=null,W=!1;async function Y(){if(W)return N;W=!0;try{let J=await import("sharp");return N=J.default||J,N}catch{return null}}async function e(){return await Y()!==null}async function t(){return!0}async function JJ(J,K={}){let{widths:Z=d,formats:$=h,quality:q=b,fit:C="cover",placeholder:X="none",outputDir:Q=".stx/images",baseUrl:_="/images"}=K,j,x;if(typeof J==="string"){if(x=J,!await Bun.file(J).exists())throw new L(`Image not found: ${J}`,"NOT_FOUND");j=await Bun.file(J).arrayBuffer().then((V)=>Buffer.from(V))}else x="buffer-input",j=J;let w=H.createHash("sha256").update(j).digest("hex").slice(0,12),y=await O(j),{width:B,height:D}=y,A=B/D;await U.promises.mkdir(Q,{recursive:!0});let T=[],v=G.basename(x,G.extname(x)),z=Z.filter((V)=>V<=B);if(!z.includes(B)&&B<=Math.max(...Z))z.push(B);z.sort((V,R)=>V-R);for(let V of z){let R=Math.round(V/A);for(let F of $){let S=`${v}-${V}w-${w}.${F}`,k=G.join(Q,S),c=`${_}/${S}`,E=await n(j,{width:V,height:R,format:F,quality:q,fit:C});await Bun.write(k,E),T.push({path:k,url:c,width:V,height:R,format:F,size:E.length})}}let M;if(X!=="none")M=await o(j,X);return{src:x,variants:T,placeholder:M,width:B,height:D,aspectRatio:A,hash:w}}async function O(J){let K=typeof J==="string"?Buffer.from(await Bun.file(J).arrayBuffer()):J,Z=await Y();if(Z){let q=await Z(K).metadata();return{width:q.width||0,height:q.height||0,format:q.format||"unknown",hasAlpha:q.hasAlpha}}return p(K)}function p(J){if(J[0]===137&&J[1]===80&&J[2]===78&&J[3]===71){let K=J.readUInt32BE(16),Z=J.readUInt32BE(20);return{width:K,height:Z,format:"png",hasAlpha:!0}}if(J[0]===255&&J[1]===216){let K=2;while(K<J.length){if(J[K]!==255)break;let Z=J[K+1];if(Z>=192&&Z<=207&&Z!==196&&Z!==200&&Z!==204){let q=J.readUInt16BE(K+5);return{width:J.readUInt16BE(K+7),height:q,format:"jpeg",hasAlpha:!1}}let $=J.readUInt16BE(K+2);K+=2+$}}if(J.toString("utf8",0,4)==="RIFF"&&J.toString("utf8",8,12)==="WEBP"){let K=J.toString("utf8",12,16);if(K==="VP8 "){let Z=J.readUInt16LE(26)&16383,$=J.readUInt16LE(28)&16383;return{width:Z,height:$,format:"webp",hasAlpha:!1}}if(K==="VP8L"){let Z=J.readUInt32LE(21),$=(Z&16383)+1,q=(Z>>14&16383)+1;return{width:$,height:q,format:"webp",hasAlpha:!0}}}if(J.toString("utf8",0,3)==="GIF"){let K=J.readUInt16LE(6),Z=J.readUInt16LE(8);return{width:K,height:Z,format:"gif",hasAlpha:!0}}throw new L("Unable to parse image dimensions","PARSE_ERROR")}async function n(J,K){let Z=await Y();if(Z){let q=Z(J).resize(K.width,K.height,{fit:K.fit});switch(K.format){case"webp":q=q.webp({quality:K.quality});break;case"avif":q=q.avif({quality:K.quality});break;case"jpeg":q=q.jpeg({quality:K.quality});break;case"png":q=q.png({quality:K.quality});break}return q.toBuffer()}let $=G.join(I.tmpdir(),`stx-img-${H.randomBytes(8).toString("hex")}.${K.format}`);try{return await g({input:J,output:$,format:K.format,quality:K.quality,resize:{width:K.width,height:K.height,fit:K.fit}}),Buffer.from(await Bun.file($).arrayBuffer())}finally{await U.promises.unlink($).catch(()=>{})}}async function o(J,K){let Z=await Y();if(K==="blur"&&Z){let X=(await Z(J).resize(20).blur(10).toBuffer()).toString("base64"),Q=await O(J);return`data:${P[Q.format]||"image/jpeg"};base64,${X}`}if(K==="dominant-color"&&Z){let{dominant:C}=await Z(J).resize(1,1).toBuffer().then(async(X)=>{let Q=await Z(X).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${C.r}, ${C.g}, ${C.b})`}let $=await O(J),q=G.join(I.tmpdir(),`stx-ph-${H.randomBytes(8).toString("hex")}.${$.format==="unknown"?"bin":$.format}`);try{await Bun.write(q,J);let C=K==="blur"?"blur":K==="thumbhash"?"thumbhash":"dominant-color",Q=await m(q,{strategy:C,width:C==="thumbhash"?void 0:32});if(K==="dominant-color"&&Q.dominantColor)return Q.dominantColor;if(Q.dataURL)return Q.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await U.promises.unlink(q).catch(()=>{})}}function KJ(J,K){return(K?J.filter(($)=>$.format===K):J).sort(($,q)=>$.width-q.width).map(($)=>`${$.url} ${$.width}w`).join(", ")}function ZJ(J){if(!J||Object.keys(J).length===0)return"100vw";return Object.entries(J).sort((Z,$)=>{let q=Number.parseInt(Z[0].replace(/\D/g,""))||0;return(Number.parseInt($[0].replace(/\D/g,""))||0)-q}).map(([Z,$])=>`(max-width: ${Z}) ${$}`).join(", ")+", 100vw"}function $J(J){let K=J.filter(($)=>$.format==="jpeg");if(K.length===0)return J[Math.floor(J.length/2)];let Z=K.sort(($,q)=>$.width-q.width);return Z[Math.floor(Z.length/2)]}function qJ(J){let K=new Map;for(let Z of J){let $=K.get(Z.format)||[];$.push(Z),K.set(Z.format,$)}return K}function CJ(J){let K=G.extname(J).toLowerCase();return u.includes(K)}function QJ(J){return P[J]||"application/octet-stream"}function VJ(J){return J.reduce((K,Z)=>K+Z.size,0)}function XJ(J){if(J<1024)return`${J} B`;if(J<1048576)return`${(J/1024).toFixed(1)} KB`;return`${(J/1048576).toFixed(2)} MB`}class L extends Error{code;constructor(J,K){super(J);this.name="ImageProcessingError",this.code=K}}
2
+ import{sw as l}from"./chunk-hyfjnn7g.js";import U from"fs";import G from"path";import I from"os";import H from"crypto";import{generatePlaceholder as m,processImage as g}from"ts-images";var d=[320,640,768,1024,1280,1536,1920],h=["webp","jpeg"],b=80,u=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],P={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},N=null,W=!1;async function Y(){if(W)return N;W=!0;try{let J=await import("sharp");return N=J.default||J,N}catch{return null}}async function e(){return await Y()!==null}async function t(){return!0}async function JJ(J,K={}){let{widths:Z=d,formats:$=h,quality:q=b,fit:C="cover",placeholder:X="none",outputDir:Q=".stx/images",baseUrl:_="/images"}=K,j,x;if(typeof J==="string"){if(x=J,!await Bun.file(J).exists())throw new L(`Image not found: ${J}`,"NOT_FOUND");j=await Bun.file(J).arrayBuffer().then((V)=>Buffer.from(V))}else x="buffer-input",j=J;let w=H.createHash("sha256").update(j).digest("hex").slice(0,12),y=await O(j),{width:B,height:D}=y,A=B/D;await U.promises.mkdir(Q,{recursive:!0});let T=[],v=G.basename(x,G.extname(x)),z=Z.filter((V)=>V<=B);if(!z.includes(B)&&B<=Math.max(...Z))z.push(B);z.sort((V,R)=>V-R);for(let V of z){let R=Math.round(V/A);for(let F of $){let S=`${v}-${V}w-${w}.${F}`,k=G.join(Q,S),c=`${_}/${S}`,E=await n(j,{width:V,height:R,format:F,quality:q,fit:C});await Bun.write(k,E),T.push({path:k,url:c,width:V,height:R,format:F,size:E.length})}}let M;if(X!=="none")M=await o(j,X);return{src:x,variants:T,placeholder:M,width:B,height:D,aspectRatio:A,hash:w}}async function O(J){let K=typeof J==="string"?Buffer.from(await Bun.file(J).arrayBuffer()):J,Z=await Y();if(Z){let q=await Z(K).metadata();return{width:q.width||0,height:q.height||0,format:q.format||"unknown",hasAlpha:q.hasAlpha}}return p(K)}function p(J){if(J[0]===137&&J[1]===80&&J[2]===78&&J[3]===71){let K=J.readUInt32BE(16),Z=J.readUInt32BE(20);return{width:K,height:Z,format:"png",hasAlpha:!0}}if(J[0]===255&&J[1]===216){let K=2;while(K<J.length){if(J[K]!==255)break;let Z=J[K+1];if(Z>=192&&Z<=207&&Z!==196&&Z!==200&&Z!==204){let q=J.readUInt16BE(K+5);return{width:J.readUInt16BE(K+7),height:q,format:"jpeg",hasAlpha:!1}}let $=J.readUInt16BE(K+2);K+=2+$}}if(J.toString("utf8",0,4)==="RIFF"&&J.toString("utf8",8,12)==="WEBP"){let K=J.toString("utf8",12,16);if(K==="VP8 "){let Z=J.readUInt16LE(26)&16383,$=J.readUInt16LE(28)&16383;return{width:Z,height:$,format:"webp",hasAlpha:!1}}if(K==="VP8L"){let Z=J.readUInt32LE(21),$=(Z&16383)+1,q=(Z>>14&16383)+1;return{width:$,height:q,format:"webp",hasAlpha:!0}}}if(J.toString("utf8",0,3)==="GIF"){let K=J.readUInt16LE(6),Z=J.readUInt16LE(8);return{width:K,height:Z,format:"gif",hasAlpha:!0}}throw new L("Unable to parse image dimensions","PARSE_ERROR")}async function n(J,K){let Z=await Y();if(Z){let q=Z(J).resize(K.width,K.height,{fit:K.fit});switch(K.format){case"webp":q=q.webp({quality:K.quality});break;case"avif":q=q.avif({quality:K.quality});break;case"jpeg":q=q.jpeg({quality:K.quality});break;case"png":q=q.png({quality:K.quality});break}return q.toBuffer()}let $=G.join(I.tmpdir(),`stx-img-${H.randomBytes(8).toString("hex")}.${K.format}`);try{return await g({input:J,output:$,format:K.format,quality:K.quality,resize:{width:K.width,height:K.height,fit:K.fit}}),Buffer.from(await Bun.file($).arrayBuffer())}finally{await U.promises.unlink($).catch(()=>{})}}async function o(J,K){let Z=await Y();if(K==="blur"&&Z){let X=(await Z(J).resize(20).blur(10).toBuffer()).toString("base64"),Q=await O(J);return`data:${P[Q.format]||"image/jpeg"};base64,${X}`}if(K==="dominant-color"&&Z){let{dominant:C}=await Z(J).resize(1,1).toBuffer().then(async(X)=>{let Q=await Z(X).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${C.r}, ${C.g}, ${C.b})`}let $=await O(J),q=G.join(I.tmpdir(),`stx-ph-${H.randomBytes(8).toString("hex")}.${$.format==="unknown"?"bin":$.format}`);try{await Bun.write(q,J);let C=K==="blur"?"blur":K==="thumbhash"?"thumbhash":"dominant-color",Q=await m(q,{strategy:C,width:C==="thumbhash"?void 0:32});if(K==="dominant-color"&&Q.dominantColor)return Q.dominantColor;if(Q.dataURL)return Q.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await U.promises.unlink(q).catch(()=>{})}}function KJ(J,K){return(K?J.filter(($)=>$.format===K):J).sort(($,q)=>$.width-q.width).map(($)=>`${$.url} ${$.width}w`).join(", ")}function ZJ(J){if(!J||Object.keys(J).length===0)return"100vw";return Object.entries(J).sort((Z,$)=>{let q=Number.parseInt(Z[0].replace(/\D/g,""))||0;return(Number.parseInt($[0].replace(/\D/g,""))||0)-q}).map(([Z,$])=>`(max-width: ${Z}) ${$}`).join(", ")+", 100vw"}function $J(J){let K=J.filter(($)=>$.format==="jpeg");if(K.length===0)return J[Math.floor(J.length/2)];let Z=K.sort(($,q)=>$.width-q.width);return Z[Math.floor(Z.length/2)]}function qJ(J){let K=new Map;for(let Z of J){let $=K.get(Z.format)||[];$.push(Z),K.set(Z.format,$)}return K}function CJ(J){let K=G.extname(J).toLowerCase();return u.includes(K)}function QJ(J){return P[J]||"application/octet-stream"}function VJ(J){return J.reduce((K,Z)=>K+Z.size,0)}function XJ(J){if(J<1024)return`${J} B`;if(J<1048576)return`${(J/1024).toFixed(1)} KB`;return`${(J/1048576).toFixed(2)} MB`}class L extends Error{code;constructor(J,K){super(J);this.name="ImageProcessingError",this.code=K}}
3
3
  export{d as Af,h as Bf,b as Cf,e as Df,t as Ef,JJ as Ff,O as Gf,n as Hf,KJ as If,ZJ as Jf,$J as Kf,qJ as Lf,CJ as Mf,QJ as Nf,VJ as Of,XJ as Pf,L as Qf};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Al as e,Bl as f,Cl as g,wl as a,xl as b,yl as c,zl as d}from"./chunk-p1hy2bwn.js";import"./chunk-r8rbf28v.js";import"./chunk-gptwwv3c.js";import"./chunk-vvd659y4.js";import"./chunk-hzfd8cz0.js";import"./chunk-hyfjnn7g.js";export{e as productionApiDispatcher,g as isServerApiSource,b as generateApiTypes,a as discoverServerApi,f as createServerApi,d as createApiDispatcher,c as buildServerApi};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$t as g,Vt as a,Wt as b,Xt as c,Yt as d,Zt as e,_t as f,au as h,bu as i,cu as j,du as k,eu as l}from"./chunk-4zwjqcw4.js";import"./chunk-gne68nyp.js";import"./chunk-5ep11kvc.js";export{e as resolveUserCssConfig,c as resetCssCache,h as rebuildCss,d as loadCssEngineConfig,b as loadCssEngine,l as injectCss,a as getCssServeAsset,i as getCachedCSS,k as generateCss,f as fingerprintConfig,j as extractClassNames,g as buildCss};
2
+ import{$t as f,Wt as a,Xt as b,Yt as c,Zt as d,_t as e,au as g,bu as h,cu as i,du as j,eu as k,fu as l}from"./chunk-kffndzch.js";import"./chunk-gptwwv3c.js";import"./chunk-hyfjnn7g.js";export{e as resolveUserCssConfig,c as resetCssCache,h as rebuildCss,d as loadCssEngineConfig,b as loadCssEngine,l as injectCss,a as getCssServeAsset,i as getCachedCSS,k as generateCss,f as fingerprintConfig,j as extractClassNames,g as buildCss};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Bu as uJ}from"./chunk-gne68nyp.js";import{rw as gJ}from"./chunk-5ep11kvc.js";import z from"path";import{hasLocalConfig as yJ}from"bunfig";var wJ={fg:{light:"gray-900",dark:"gray-100",description:"Primary text"},"fg-strong":{light:"gray-700",dark:"gray-300",description:"Labels, secondary headings"},"fg-muted":{light:"gray-600",dark:"gray-400",description:"Supporting text"},"fg-soft":{light:"gray-500",dark:"gray-400",description:"De-emphasised text"},"fg-subtle":{light:"gray-400",dark:"gray-500",description:"Placeholders, disabled text"},surface:{light:"gray-50",dark:"gray-800",description:"Page and panel background"},"surface-raised":{light:"gray-100",dark:"gray-700",description:"Cards, popovers"},"surface-sunken":{light:"gray-200",dark:"gray-700",description:"Wells, track backgrounds"},line:{light:"gray-200",dark:"gray-700",description:"Default border, divider"},"line-strong":{light:"gray-300",dark:"gray-600",description:"Input border, focus ring track"},accent:{light:"indigo-600",dark:"indigo-400",description:"Primary action, selected state"},info:{light:"blue-600",dark:"blue-400",description:"Informational emphasis, links"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-500",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"indigo-600",dark:"indigo-500",description:"Primary button fill"},"info-solid":{light:"blue-600",dark:"blue-500",description:"Informational fill"},"danger-solid":{light:"red-600",dark:"red-500",description:"Destructive button fill"},"success-solid":{light:"green-600",dark:"green-500",description:"Confirmation fill"}};function p(J){return`--stx-${J}`}function m(J,Q){let Z=Q.lastIndexOf("-");if(Z===-1)return typeof J[Q]==="string"?J[Q]:void 0;let $=J[Q.slice(0,Z)];if(!$||typeof $!=="object")return;let U=$[Q.slice(Z+1)];return typeof U==="string"?U:void 0}function BJ(J){let Q={};for(let[Z,$]of Object.entries(wJ)){let U=m(J,$.light);if(U===void 0)continue;Q[Z]=`var(${p(Z)}, ${U})`}return Q}function HJ(J){let Q=[],Z=[];for(let[$,U]of Object.entries(wJ)){let F=m(J,U.light),W=m(J,U.dark);if(F===void 0)continue;if(Q.push(` ${p($)}: ${F};`),W!==void 0)Z.push(` ${p($)}: ${W};`)}if(Q.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...Q,"}",".dark {",...Z,"}",""].join(`
2
+ import{Cu as uJ}from"./chunk-gptwwv3c.js";import{sw as gJ}from"./chunk-hyfjnn7g.js";import z from"path";import{hasLocalConfig as yJ}from"bunfig";var wJ={fg:{light:"gray-900",dark:"gray-100",description:"Primary text"},"fg-strong":{light:"gray-700",dark:"gray-300",description:"Labels, secondary headings"},"fg-muted":{light:"gray-600",dark:"gray-400",description:"Supporting text"},"fg-soft":{light:"gray-500",dark:"gray-400",description:"De-emphasised text"},"fg-subtle":{light:"gray-400",dark:"gray-500",description:"Placeholders, disabled text"},surface:{light:"gray-50",dark:"gray-800",description:"Page and panel background"},"surface-raised":{light:"gray-100",dark:"gray-700",description:"Cards, popovers"},"surface-sunken":{light:"gray-200",dark:"gray-700",description:"Wells, track backgrounds"},line:{light:"gray-200",dark:"gray-700",description:"Default border, divider"},"line-strong":{light:"gray-300",dark:"gray-600",description:"Input border, focus ring track"},accent:{light:"indigo-600",dark:"indigo-400",description:"Primary action, selected state"},info:{light:"blue-600",dark:"blue-400",description:"Informational emphasis, links"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-500",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"indigo-600",dark:"indigo-500",description:"Primary button fill"},"info-solid":{light:"blue-600",dark:"blue-500",description:"Informational fill"},"danger-solid":{light:"red-600",dark:"red-500",description:"Destructive button fill"},"success-solid":{light:"green-600",dark:"green-500",description:"Confirmation fill"}};function p(J){return`--stx-${J}`}function m(J,Q){let Z=Q.lastIndexOf("-");if(Z===-1)return typeof J[Q]==="string"?J[Q]:void 0;let $=J[Q.slice(0,Z)];if(!$||typeof $!=="object")return;let U=$[Q.slice(Z+1)];return typeof U==="string"?U:void 0}function BJ(J){let Q={};for(let[Z,$]of Object.entries(wJ)){let U=m(J,$.light);if(U===void 0)continue;Q[Z]=`var(${p(Z)}, ${U})`}return Q}function HJ(J){let Q=[],Z=[];for(let[$,U]of Object.entries(wJ)){let F=m(J,U.light),W=m(J,U.dark);if(F===void 0)continue;if(Q.push(` ${p($)}: ${F};`),W!==void 0)Z.push(` ${p($)}: ${W};`)}if(Q.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...Q,"}",".dark {",...Z,"}",""].join(`
3
3
  `)}function OJ(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}function h(J,Q){let Z={...J};for(let[$,U]of Object.entries(Q))Z[$]=OJ(U)&&OJ(Z[$])?h(Z[$],U):U;return Z}function LJ(J={},Q={}){let Z=J.theme||{},$=Q.theme||{},{extend:U,...F}=$,{extend:W,...j}=Z,V=j.colors||{};j.colors={...V,...BJ(V)};let X=h(j,F),q=h(W||{},U||{});if(Object.keys(q).length>0)X.extend=q;let G=[...J.safelist||[],...Q.safelist||[]],w={...J.shortcuts||{},...Q.shortcuts||{}},K=[...J.preflights||[],...Q.preflights||[]];return{config:{...J,...Q,theme:X,safelist:G,shortcuts:w,...K.length>0?{preflights:K}:{},content:[],output:""},safelist:G,shortcuts:w,includePreflight:Q.preflight!==!1,minify:Q.minify===!0,tokenCSS:HJ(V)}}var x=/<script\b[^>]*>/iy,c=/<\/script\s*>/ig,S=/<style\b[^>]*>/iy,o=/<\/style\s*>/ig;function KJ(J,Q,Z,$){Z.lastIndex=Q;let U=Z.exec(J);if(!U||U.index!==Q)return-1;$.lastIndex=Z.lastIndex;let F=$.exec(J);if(!F)return-1;return F.index+F[0].length}function l(J,Q){return KJ(J,Q,x,c)}function IJ(J,Q){return KJ(J,Q,S,o)}function iJ(J,Q){if(!J.startsWith("<!--",Q))return-1;let Z=J.indexOf("-->",Q+4);if(Z===-1)return-1;return Z+3}function DJ(J,Q){if(J.startsWith("<!--",Q)){let U=iJ(J,Q);return U===-1?J.length:U}if(x.lastIndex=Q,x.exec(J)?.index===Q){c.lastIndex=x.lastIndex;let U=c.exec(J);return U?U.index+U[0].length:J.length}if(S.lastIndex=Q,S.exec(J)?.index===Q){o.lastIndex=S.lastIndex;let U=o.exec(J);return U?U.index+U[0].length:J.length}return-1}function rJ(J,Q){let Z=[],$=0,U=J.length,F=!1,W=null;while($<U){let j=J[$];if(F){if(W){if(j===W)W=null}else if(j==='"'||j==="'")W=j;else if(j===">")F=!1;$++;continue}if(j!=="<"){let G=J.indexOf("<",$+1);if(G===-1)break;$=G;continue}let V=Q(J,$);if(V>$){Z.push({start:$,end:V,token:J.slice($,V)}),$=V;continue}let X=DJ(J,$);if(X>$){$=X;continue}let q=J.charCodeAt($+1);if(q>=65&&q<=90||q>=97&&q<=122)F=!0;$++}return Z}function vQ(J){let Q=0,Z=0,$=0,U=!1,F=null;while($<J.length){if(U){let G=J[$];if(F){if(G===F)F=null}else if(G==='"'||G==="'")F=G;else if(G===">")U=!1;$++;continue}let W=J.indexOf("<",$),j=W===-1?J.length:W;while($<j){let G=J[$++];if(G==="{")Q++;else if(G==="}")Z++;if(Q>=2&&Z>=2)return!0}if(W===-1)break;let V=DJ(J,W);if(V>W){$=V;continue}let X=J.charCodeAt(W+1),q=X===47?J.charCodeAt(W+2):X;if(q>=65&&q<=90||q>=97&&q<=122)U=!0;$=W+1}return!1}function NJ(J,Q){while(J.size>=Q){let Z=J.keys().next();if(Z.done)return;J.delete(Z.value)}}var nJ=65536,cJ=12,i=new Map;function a(J,Q,Z,$){let U=$!==void 0&&J.length>=nJ,F=U?`${$}\x00${J}`:"";if(U){let q=i.get(F);if(q)return{output:q.output,tokens:q.tokens.slice()}}let W=rJ(J,Q);if(W.length===0)return{output:J,tokens:[]};let j=W.map((q)=>q.token),V="",X=0;for(let q=0;q<W.length;q++){let G=W[q];V+=J.slice(X,G.start),V+=Z(G.token,q),X=G.end}if(V+=J.slice(X),U)return NJ(i,cJ),i.set(F,{output:V,tokens:j}),{output:V,tokens:j.slice()};return{output:V,tokens:j}}var oJ=65536,lJ=4,r=new Map;function n(J,Q,Z){return{output:Q,scripts:Z,restore:($)=>$===Q?J:aJ($,Z)}}function RQ(J){let Q=J.length>=oJ;if(Q){let U=r.get(J);if(U)return n(J,U.output,U.scripts.slice())}let{output:Z,tokens:$}=a(J,l,(U,F)=>`\x00STX_SCRIPT_${F}\x00`);if(Q)return NJ(r,lJ),r.set(J,{output:Z,scripts:$}),n(J,Z,$.slice());return n(J,Z,$)}function aJ(J,Q){if(Q.length===0)return J;return J.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(Z,$)=>Q[+$]??"")}function MJ(J,Q=""){let Z=`${J}${Q}`,$=0;for(let U=0;U<Z.length;U++){let F=Z.charCodeAt(U);$=($<<5)-$+F,$=$&$}return`stx-${Math.abs($).toString(36)}`}function PJ(J,Q,Z={}){let{prefix:$="",preserveHost:U=!0,scopeKeyframes:F=!0,scopeCustomProperties:W=!1}=Z;if(!J.trim())return"";let j=s(J),V=[],X=new Map;if(F)for(let q of j){let G=q.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(G){let w=G[1],K=`${Q}_${w}`;X.set(w,K)}}for(let q of j){let G=AJ(q,Q,$,U,X,W);V.push(G)}return V.join(`
4
4
 
5
5
  `)}function s(J){let Q=[],Z=J.replace(/\/\*[\s\S]*?\*\//g,""),$=0,U="",F=!1,W="";for(let j=0;j<Z.length;j++){let V=Z[j];if(V==="@"&&$===0)F=!0;if(V==="{")$++;else if(V==="}"){if($--,$===0){if(F){W+=V;let X=W.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(X){let[,q,G,w]=X;if(q==="keyframes")Q.push({selector:`@keyframes ${G.trim()}`,declarations:w.trim()});else if(q==="media"||q==="supports"||q==="container"){let K=s(w);Q.push({selector:`@${q} ${G.trim()}`,declarations:K.map((M)=>`${M.selector} { ${M.declarations} }`).join(`
@@ -17,7 +17,7 @@ catch (e) {
17
17
  }
18
18
  throw e;
19
19
  }
20
- `),U.set(X,q)}return q(...j)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:W,context:Q.slice()});return W}clear(){this.pool.length=0,this.fnCache.clear()}}var CQ=new bJ;class kJ{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(J){this.enabled=J}isEnabled(){return this.enabled}setBudget(J,Q){this.budgets.set(J,{warnThreshold:0.8,action:"warn",...Q})}setBudgets(J){for(let[Q,Z]of Object.entries(J))this.setBudget(Q,Z)}removeBudget(J){this.budgets.delete(J)}getBudgets(){let J={};for(let[Q,Z]of this.budgets.entries())J[Q]=Z;return J}onViolation(J){this.violationHandlers.push(J)}offViolation(J){let Q=this.violationHandlers.indexOf(J);if(Q!==-1)this.violationHandlers.splice(Q,1)}time(J,Q){if(!this.enabled)return Q();let Z=performance.now(),$=Q(),U=performance.now()-Z;return this.recordTime(J,U),this.checkBudget(J,U),$}async timeAsync(J,Q){if(!this.enabled)return Q();let Z=performance.now(),$=await Q(),U=performance.now()-Z;return this.recordTime(J,U),this.checkBudget(J,U),$}checkBudget(J,Q){let Z=this.budgets.get(J);if(!Z)return;let $=Q/Z.maxTime*100,U=Z.warnThreshold!==void 0?Q>=Z.maxTime*Z.warnThreshold&&Q<Z.maxTime:!1,F=Q>=Z.maxTime;if(!U&&!F)return;let W={label:J,actualTime:Q,budgetTime:Z.maxTime,exceedancePercent:$,timestamp:new Date,isWarning:U};this.violations.push(W);while(this.violations.length>this.maxViolations)this.violations.shift();for(let V of this.violationHandlers)try{V(W)}catch{}let j=U?`[Performance Warning] "${J}" took ${Q.toFixed(2)}ms (${$.toFixed(1)}% of ${Z.maxTime}ms budget)`:`[Performance Budget Exceeded] "${J}" took ${Q.toFixed(2)}ms (exceeded ${Z.maxTime}ms budget by ${($-100).toFixed(1)}%)`;switch(Z.action){case"log":console.log(j);break;case"warn":console.warn(j);break;case"error":console.error(j);break;case"throw":if(F)throw Error(j);else console.warn(j);break}}recordTime(J,Q){let Z=this.metrics.get(J);if(Z)Z.count++,Z.totalTime+=Q,Z.maxTime=Math.max(Z.maxTime,Q),Z.minTime=Math.min(Z.minTime,Q);else this.metrics.set(J,{count:1,totalTime:Q,maxTime:Q,minTime:Q})}getStats(J){if(J){let Z=this.metrics.get(J);if(!Z)return{};let $=this.budgets.get(J);return{count:Z.count,avgTime:Z.totalTime/Z.count,totalTime:Z.totalTime,maxTime:Z.maxTime,minTime:Z.minTime,budget:$?.maxTime,budgetUtilization:$?Z.totalTime/Z.count/$.maxTime*100:void 0}}let Q={};for(let[Z,$]of this.metrics.entries()){let U=this.budgets.get(Z);Q[Z]={count:$.count,avgTime:$.totalTime/$.count,totalTime:$.totalTime,maxTime:$.maxTime,minTime:$.minTime,budget:U?.maxTime,budgetUtilization:U?$.totalTime/$.count/U.maxTime*100:void 0}}return Q}getViolations(J){if(J)return this.violations.filter((Q)=>Q.label===J);return[...this.violations]}getViolationStats(){let J={},Q=0,Z=0;for(let $ of this.violations)if(J[$.label]=(J[$.label]||0)+1,$.isWarning)Q++;else Z++;return{total:this.violations.length,byLabel:J,warnings:Q,errors:Z}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var $J=null;function WQ(){if(!$J)$J=new kJ;return $J}var gQ=new Proxy({},{get(J,Q){return WQ()[Q]}});var xJ=[];function SJ(J){let Q=new ZJ(J);return xJ.push(Q),Q}function mQ(){for(let J of xJ)J.clear()}function UJ(J,...Q){return`${Q.map((Z)=>String(Z??"")).join("\x00")}\x00${J.length}\x00${Bun.hash(J)}`}function hQ(J){let Q=[];for(let Z of new Set(J))try{Q.push({path:Z,mtimeMs:EJ.statSync(Z).mtimeMs})}catch{}return Q}function iQ(J){for(let Q of J)try{if(EJ.statSync(Q.path).mtimeMs!==Q.mtimeMs)return!1}catch{return!1}return!0}var O=null,WJ=!1,H=null,T="",A=!1,dJ=256,D=new Map,L=new Map,N=null,b=null;function y(J){return Bun.hash(J).toString(16).padStart(16,"0").slice(0,16)}function FJ(J,Q){if(D.has(J))D.delete(J);else if(D.size>=dJ)D.delete(D.keys().next().value);D.set(J,Q)}function VQ(J){let Q=y(J);if(L.has(Q))L.delete(Q);else if(L.size>=dJ)L.delete(L.keys().next().value);return L.set(Q,J),Q}function eQ(J){let Q=L.get(J);if(Q===void 0)return;return L.delete(J),L.set(J,Q),Q}async function XQ(J){if(!N)return null;try{let Q=Bun.file(z.join(N,`cw-${y(J)}.css`));if(!await Q.exists())return null;return await Q.text()}catch{return null}}async function jQ(J,Q){if(!N)return;try{if(!fs.existsSync(N))fs.mkdirSync(N,{recursive:!0});await Bun.write(z.join(N,`cw-${y(J)}.css`),Q)}catch{}}async function fJ(J){try{let Q=await import(J);if(Q&&Q.CSSGenerator)return{CSSGenerator:Q.CSSGenerator,config:Q.config,build:Q.build,defaultConfig:Q.defaultConfig,extractClasses:Q.extractClasses}}catch{}return null}var qQ=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],GQ=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function zQ(){let J=[],Q=process.cwd();while(Q!==z.dirname(Q)){for(let Z of["node_modules","pantry"])for(let $ of qQ)J.push(z.join(Q,Z,...$));Q=z.dirname(Q)}return J}function YQ(){let J=[],Q=process.env.HOME||process.env.USERPROFILE||"",Z=[Q&&z.join(Q,"Code","Tools","ts-css"),Q&&z.join(Q,"Code","Tools","crosswind"),Q&&z.join(Q,"repos","stacks-org","ts-css"),Q&&z.join(Q,"repos","stacks-org","crosswind"),z.join(process.cwd(),"..","ts-css"),z.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let $ of Z)J.push(z.join($,"packages","toolkit","dist","engine","index.js")),J.push(z.join($,"packages","toolkit","src","engine","index.ts"));if(Q)J.push(z.join(Q,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return J}async function pJ(){if(WJ)return O;WJ=!0;try{let J=async(U)=>{for(let F of U){if(!await Bun.file(F).exists())continue;let W=await fJ(F);if(W){if(!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} CSS engine loaded from ${z.dirname(z.dirname(F))}`);return W}}return null};if(process.env.CROSSWIND_SRC){let U=z.resolve(process.env.CROSSWIND_SRC),F=await J([U]);if(!F)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${U}`);return O=F,O}let Q=await J(zQ());if(Q)return O=Q,O;let Z=GQ;for(let U of Z){let F=await fJ(U);if(F){if(O=F,!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} CSS engine loaded`);return O}}let $=await J(YQ());if($)return O=$,O;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${Y.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${Y.reset}`),console.warn(`${Y.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${Y.reset}`),null}}function J0(){VJ.clear(),O=null,WJ=!1,H=null,T="",D.clear(),L.clear(),b=null}var CJ=!1;async function mJ(J){try{let Q=yJ({name:"css",cwd:J})?"css":yJ({name:"crosswind",cwd:J})?"crosswind":null;if(!Q)return null;if(Q==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!CJ)CJ=!0,console.warn(`${Y.yellow}[ts-css]${Y.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:Z}=await import("bunfig"),$=await Z({name:Q,cwd:J,defaultConfig:{},checkEnv:!1,verbose:!1});if(!$?.path||!$.config||Object.keys($.config).length===0)return null;let U=z.relative(J,$.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} Loaded config from ${U||$.path}`);return $.config}catch(Q){if(Q instanceof Error&&Q.name==="ConfigNotFoundError")return null;return console.warn(`${Y.yellow}[ts-css]${Y.reset} Failed to load css config:`,Q instanceof Error?Q.message:Q),null}}async function wQ(J){let Q=null;try{let{loadStxConfig:Z}=await import("./chunk-85e05tzn.js"),$=await Z(J);if($.css)if(typeof $.css==="string"){let U=z.isAbsolute($.css)?$.css:z.resolve(J,$.css);if(await Bun.file(U).exists()){let F=await import(U);Q=F.default||F,console.log(`${Y.green}[ts-css]${Y.reset} Loaded config from stx.config.ts \u2192 ${$.css}`)}}else{if(Q={...$.css,content:$.css.content||[],preflight:$.css.preflight??!0,minify:$.css.minify??!1},$.css.config){let U=z.isAbsolute($.css.config)?$.css.config:z.resolve(J,$.css.config);if(await Bun.file(U).exists()){let F=await import(U);Q={...F.default||F,...Q}}}console.log(`${Y.green}[ts-css]${Y.reset} Using inline CSS config from stx.config.ts`)}}catch{}return Q||await mJ(J)}function BQ(J){try{let Q=new WeakSet;return y(JSON.stringify(J??{},(Z,$)=>{if(typeof $==="function")return`[fn]${String($)}`;if(typeof $==="object"&&$!==null){if(Q.has($))return"[circular]";Q.add($)}return $})??"")}catch{return"unhashable"}}async function HQ(J){if(A)return T;A=!0;try{let Q=await pJ();if(!Q||!Q.build)return A=!1,"";if(!H)H=await mJ(J);if(!H)return A=!1,"";let Z=Q.defaultConfig?.theme||{},$=H.theme||{},U={...Q.defaultConfig,...H,theme:{...Z,...$,extend:{...Z.extend||{},...$.extend||{}}}},F=performance.now(),W=await Q.build(U),j=performance.now()-F;if(T=W.css,console.log(`${Y.cyan}[ts-css]${Y.reset} Built ${W.classes.size} classes in ${j.toFixed(1)}ms`),U.output){let V=z.isAbsolute(U.output)?U.output:z.join(J,U.output),X=z.dirname(V);if(!fs.existsSync(X))fs.mkdirSync(X,{recursive:!0});await Bun.write(V,W.css)}return A=!1,W.css}catch(Q){return console.error(`${Y.red}[ts-css]${Y.reset} Build error:`,Q),A=!1,T}}async function Q0(J){H=null,await HQ(J)}function $0(){return T}function OQ(J){let Q=new Set,Z=/class\s*=\s*["']([^"']+)["']/gi,$=Z.exec(J);while($!==null){for(let W of $[1].split(/\s+/))if(W.trim())Q.add(W.trim());$=Z.exec(J)}let U=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,F=U.exec(J);while(F!==null){let W=F[1].match(/'([^']+)'/g);if(W){for(let j of W)for(let V of j.slice(1,-1).split(/\s+/))if(V.trim())Q.add(V.trim())}F=U.exec(J)}return Q}var VJ=SJ(64);async function LQ(J,Q){let Z=VJ.get(UJ(J,Q,b));if(Z!==void 0)return Z;let $=await KQ(J,Q);if($)VJ.set(UJ(J,Q,b),$);return $}async function KQ(J,Q){try{let Z=await pJ();if(!Z)return"";let $=typeof Z.extractClasses==="function"?Z.extractClasses(J):OQ(J);if($.size===0)return"";let U=Q?z.resolve(Q):process.cwd();if(!N)N=uJ(U,"cache");let F=[...$].sort().join(" "),W=`${b||"default"}::${F}`,j=D.get(W);if(j!==void 0)return FJ(W,j),j;let V=await XQ(W);if(V!==null)return FJ(W,V),V;if(!H)H=await wQ(U),b=BQ(H);let X=Z.defaultConfig||Z.config,q=H||{},G=LJ(X,q),{safelist:w,includePreflight:K,minify:M,tokenCSS:hJ}=G,XJ=G.config,_=new Z.CSSGenerator(XJ);for(let B of w)_.generate(B);for(let B of $)_.generate(B);let I=_.toCSS(K,M),jJ=XJ.shortcuts||q.shortcuts||{};for(let[B,f]of Object.entries(jJ)){if(!$.has(B)&&!w.includes(B))continue;let C=f.split(/\s+/).filter(Boolean);for(let R of C)_.generate(R)}I=_.toCSS(K,M);let v=I.split(`
20
+ `),U.set(X,q)}return q(...j)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:W,context:Q.slice()});return W}clear(){this.pool.length=0,this.fnCache.clear()}}var CQ=new bJ;class kJ{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(J){this.enabled=J}isEnabled(){return this.enabled}setBudget(J,Q){this.budgets.set(J,{warnThreshold:0.8,action:"warn",...Q})}setBudgets(J){for(let[Q,Z]of Object.entries(J))this.setBudget(Q,Z)}removeBudget(J){this.budgets.delete(J)}getBudgets(){let J={};for(let[Q,Z]of this.budgets.entries())J[Q]=Z;return J}onViolation(J){this.violationHandlers.push(J)}offViolation(J){let Q=this.violationHandlers.indexOf(J);if(Q!==-1)this.violationHandlers.splice(Q,1)}time(J,Q){if(!this.enabled)return Q();let Z=performance.now(),$=Q(),U=performance.now()-Z;return this.recordTime(J,U),this.checkBudget(J,U),$}async timeAsync(J,Q){if(!this.enabled)return Q();let Z=performance.now(),$=await Q(),U=performance.now()-Z;return this.recordTime(J,U),this.checkBudget(J,U),$}checkBudget(J,Q){let Z=this.budgets.get(J);if(!Z)return;let $=Q/Z.maxTime*100,U=Z.warnThreshold!==void 0?Q>=Z.maxTime*Z.warnThreshold&&Q<Z.maxTime:!1,F=Q>=Z.maxTime;if(!U&&!F)return;let W={label:J,actualTime:Q,budgetTime:Z.maxTime,exceedancePercent:$,timestamp:new Date,isWarning:U};this.violations.push(W);while(this.violations.length>this.maxViolations)this.violations.shift();for(let V of this.violationHandlers)try{V(W)}catch{}let j=U?`[Performance Warning] "${J}" took ${Q.toFixed(2)}ms (${$.toFixed(1)}% of ${Z.maxTime}ms budget)`:`[Performance Budget Exceeded] "${J}" took ${Q.toFixed(2)}ms (exceeded ${Z.maxTime}ms budget by ${($-100).toFixed(1)}%)`;switch(Z.action){case"log":console.log(j);break;case"warn":console.warn(j);break;case"error":console.error(j);break;case"throw":if(F)throw Error(j);else console.warn(j);break}}recordTime(J,Q){let Z=this.metrics.get(J);if(Z)Z.count++,Z.totalTime+=Q,Z.maxTime=Math.max(Z.maxTime,Q),Z.minTime=Math.min(Z.minTime,Q);else this.metrics.set(J,{count:1,totalTime:Q,maxTime:Q,minTime:Q})}getStats(J){if(J){let Z=this.metrics.get(J);if(!Z)return{};let $=this.budgets.get(J);return{count:Z.count,avgTime:Z.totalTime/Z.count,totalTime:Z.totalTime,maxTime:Z.maxTime,minTime:Z.minTime,budget:$?.maxTime,budgetUtilization:$?Z.totalTime/Z.count/$.maxTime*100:void 0}}let Q={};for(let[Z,$]of this.metrics.entries()){let U=this.budgets.get(Z);Q[Z]={count:$.count,avgTime:$.totalTime/$.count,totalTime:$.totalTime,maxTime:$.maxTime,minTime:$.minTime,budget:U?.maxTime,budgetUtilization:U?$.totalTime/$.count/U.maxTime*100:void 0}}return Q}getViolations(J){if(J)return this.violations.filter((Q)=>Q.label===J);return[...this.violations]}getViolationStats(){let J={},Q=0,Z=0;for(let $ of this.violations)if(J[$.label]=(J[$.label]||0)+1,$.isWarning)Q++;else Z++;return{total:this.violations.length,byLabel:J,warnings:Q,errors:Z}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var $J=null;function WQ(){if(!$J)$J=new kJ;return $J}var gQ=new Proxy({},{get(J,Q){return WQ()[Q]}});var xJ=[];function SJ(J){let Q=new ZJ(J);return xJ.push(Q),Q}function mQ(){for(let J of xJ)J.clear()}function UJ(J,...Q){return`${Q.map((Z)=>String(Z??"")).join("\x00")}\x00${J.length}\x00${Bun.hash(J)}`}function hQ(J){let Q=[];for(let Z of new Set(J))try{Q.push({path:Z,mtimeMs:EJ.statSync(Z).mtimeMs})}catch{}return Q}function iQ(J){for(let Q of J)try{if(EJ.statSync(Q.path).mtimeMs!==Q.mtimeMs)return!1}catch{return!1}return!0}var O=null,WJ=!1,H=null,T="",A=!1,dJ=256,D=new Map,L=new Map,N=null,b=null;function y(J){return Bun.hash(J).toString(16).padStart(16,"0").slice(0,16)}function FJ(J,Q){if(D.has(J))D.delete(J);else if(D.size>=dJ)D.delete(D.keys().next().value);D.set(J,Q)}function VQ(J){let Q=y(J);if(L.has(Q))L.delete(Q);else if(L.size>=dJ)L.delete(L.keys().next().value);return L.set(Q,J),Q}function eQ(J){let Q=L.get(J);if(Q===void 0)return;return L.delete(J),L.set(J,Q),Q}async function XQ(J){if(!N)return null;try{let Q=Bun.file(z.join(N,`cw-${y(J)}.css`));if(!await Q.exists())return null;return await Q.text()}catch{return null}}async function jQ(J,Q){if(!N)return;try{if(!fs.existsSync(N))fs.mkdirSync(N,{recursive:!0});await Bun.write(z.join(N,`cw-${y(J)}.css`),Q)}catch{}}async function fJ(J){try{let Q=await import(J);if(Q&&Q.CSSGenerator)return{CSSGenerator:Q.CSSGenerator,config:Q.config,build:Q.build,defaultConfig:Q.defaultConfig,extractClasses:Q.extractClasses}}catch{}return null}var qQ=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],GQ=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function zQ(){let J=[],Q=process.cwd();while(Q!==z.dirname(Q)){for(let Z of["node_modules","pantry"])for(let $ of qQ)J.push(z.join(Q,Z,...$));Q=z.dirname(Q)}return J}function YQ(){let J=[],Q=process.env.HOME||process.env.USERPROFILE||"",Z=[Q&&z.join(Q,"Code","Tools","ts-css"),Q&&z.join(Q,"Code","Tools","crosswind"),Q&&z.join(Q,"repos","stacks-org","ts-css"),Q&&z.join(Q,"repos","stacks-org","crosswind"),z.join(process.cwd(),"..","ts-css"),z.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let $ of Z)J.push(z.join($,"packages","toolkit","dist","engine","index.js")),J.push(z.join($,"packages","toolkit","src","engine","index.ts"));if(Q)J.push(z.join(Q,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return J}async function pJ(){if(WJ)return O;WJ=!0;try{let J=async(U)=>{for(let F of U){if(!await Bun.file(F).exists())continue;let W=await fJ(F);if(W){if(!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} CSS engine loaded from ${z.dirname(z.dirname(F))}`);return W}}return null};if(process.env.CROSSWIND_SRC){let U=z.resolve(process.env.CROSSWIND_SRC),F=await J([U]);if(!F)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${U}`);return O=F,O}let Q=await J(zQ());if(Q)return O=Q,O;let Z=GQ;for(let U of Z){let F=await fJ(U);if(F){if(O=F,!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} CSS engine loaded`);return O}}let $=await J(YQ());if($)return O=$,O;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${Y.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${Y.reset}`),console.warn(`${Y.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${Y.reset}`),null}}function J0(){VJ.clear(),O=null,WJ=!1,H=null,T="",D.clear(),L.clear(),b=null}var CJ=!1;async function mJ(J){try{let Q=yJ({name:"css",cwd:J})?"css":yJ({name:"crosswind",cwd:J})?"crosswind":null;if(!Q)return null;if(Q==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!CJ)CJ=!0,console.warn(`${Y.yellow}[ts-css]${Y.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:Z}=await import("bunfig"),$=await Z({name:Q,cwd:J,defaultConfig:{},checkEnv:!1,verbose:!1});if(!$?.path||!$.config||Object.keys($.config).length===0)return null;let U=z.relative(J,$.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} Loaded config from ${U||$.path}`);return $.config}catch(Q){if(Q instanceof Error&&Q.name==="ConfigNotFoundError")return null;return console.warn(`${Y.yellow}[ts-css]${Y.reset} Failed to load css config:`,Q instanceof Error?Q.message:Q),null}}async function wQ(J){let Q=null;try{let{loadStxConfig:Z}=await import("./chunk-ssd10kje.js"),$=await Z(J);if($.css)if(typeof $.css==="string"){let U=z.isAbsolute($.css)?$.css:z.resolve(J,$.css);if(await Bun.file(U).exists()){let F=await import(U);Q=F.default||F,console.log(`${Y.green}[ts-css]${Y.reset} Loaded config from stx.config.ts \u2192 ${$.css}`)}}else{if(Q={...$.css,content:$.css.content||[],preflight:$.css.preflight??!0,minify:$.css.minify??!1},$.css.config){let U=z.isAbsolute($.css.config)?$.css.config:z.resolve(J,$.css.config);if(await Bun.file(U).exists()){let F=await import(U);Q={...F.default||F,...Q}}}console.log(`${Y.green}[ts-css]${Y.reset} Using inline CSS config from stx.config.ts`)}}catch{}return Q||await mJ(J)}function BQ(J){try{let Q=new WeakSet;return y(JSON.stringify(J??{},(Z,$)=>{if(typeof $==="function")return`[fn]${String($)}`;if(typeof $==="object"&&$!==null){if(Q.has($))return"[circular]";Q.add($)}return $})??"")}catch{return"unhashable"}}async function HQ(J){if(A)return T;A=!0;try{let Q=await pJ();if(!Q||!Q.build)return A=!1,"";if(!H)H=await mJ(J);if(!H)return A=!1,"";let Z=Q.defaultConfig?.theme||{},$=H.theme||{},U={...Q.defaultConfig,...H,theme:{...Z,...$,extend:{...Z.extend||{},...$.extend||{}}}},F=performance.now(),W=await Q.build(U),j=performance.now()-F;if(T=W.css,console.log(`${Y.cyan}[ts-css]${Y.reset} Built ${W.classes.size} classes in ${j.toFixed(1)}ms`),U.output){let V=z.isAbsolute(U.output)?U.output:z.join(J,U.output),X=z.dirname(V);if(!fs.existsSync(X))fs.mkdirSync(X,{recursive:!0});await Bun.write(V,W.css)}return A=!1,W.css}catch(Q){return console.error(`${Y.red}[ts-css]${Y.reset} Build error:`,Q),A=!1,T}}async function Q0(J){H=null,await HQ(J)}function $0(){return T}function OQ(J){let Q=new Set,Z=/class\s*=\s*["']([^"']+)["']/gi,$=Z.exec(J);while($!==null){for(let W of $[1].split(/\s+/))if(W.trim())Q.add(W.trim());$=Z.exec(J)}let U=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,F=U.exec(J);while(F!==null){let W=F[1].match(/'([^']+)'/g);if(W){for(let j of W)for(let V of j.slice(1,-1).split(/\s+/))if(V.trim())Q.add(V.trim())}F=U.exec(J)}return Q}var VJ=SJ(64);async function LQ(J,Q){let Z=VJ.get(UJ(J,Q,b));if(Z!==void 0)return Z;let $=await KQ(J,Q);if($)VJ.set(UJ(J,Q,b),$);return $}async function KQ(J,Q){try{let Z=await pJ();if(!Z)return"";let $=typeof Z.extractClasses==="function"?Z.extractClasses(J):OQ(J);if($.size===0)return"";let U=Q?z.resolve(Q):process.cwd();if(!N)N=uJ(U,"cache");let F=[...$].sort().join(" "),W=`${b||"default"}::${F}`,j=D.get(W);if(j!==void 0)return FJ(W,j),j;let V=await XQ(W);if(V!==null)return FJ(W,V),V;if(!H)H=await wQ(U),b=BQ(H);let X=Z.defaultConfig||Z.config,q=H||{},G=LJ(X,q),{safelist:w,includePreflight:K,minify:M,tokenCSS:hJ}=G,XJ=G.config,_=new Z.CSSGenerator(XJ);for(let B of w)_.generate(B);for(let B of $)_.generate(B);let I=_.toCSS(K,M),jJ=XJ.shortcuts||q.shortcuts||{};for(let[B,f]of Object.entries(jJ)){if(!$.has(B)&&!w.includes(B))continue;let C=f.split(/\s+/).filter(Boolean);for(let R of C)_.generate(R)}I=_.toCSS(K,M);let v=I.split(`
21
21
  `);for(let[B,f]of Object.entries(jJ)){if(!$.has(B)&&!w.includes(B))continue;let C=f.split(/\s+/).filter(Boolean),R=[],g=[];for(let u of C){let qJ=u.startsWith("dark:"),GJ=`.${(qJ?u.slice(5):u).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let k=0;k<v.length;k++){let zJ=v[k].trim();if(zJ===`${GJ} {`||zJ.startsWith(`${GJ} {`)){let E=k,YJ="";while(E<v.length){if(YJ+=v[E],v[E].includes("}"))break;E++}let d=YJ.match(/\{([^}]+)\}/);if(d)if(qJ)g.push(d[1].trim());else R.push(d[1].trim());break}}}if(R.length)I+=`
22
22
  .${B} { ${R.join(" ")} }`;if(g.length)I+=`
23
23
  @media (prefers-color-scheme: dark) { .dark .${B} { ${g.join(" ")} } }`}return I=hJ+I,FJ(W,I),jQ(W,I),I}catch(Z){return console.warn("Failed to generate Css CSS:",Z),""}}async function Z0(J,Q,Z=!1,$=!1){let U=await LQ(J,Q);if(!U)return $?QJ(J):J;let F=Z?`<link data-css="generated" rel="stylesheet" href="/_stx/css.${VQ(U)}.css">`:`<style data-css="generated">
@@ -29,4 +29,4 @@ ${F}`);return F+J}function IQ(J,Q){let Z=JJ(J).map((V)=>({...V,replacement:""}))
29
29
  ${Q}`});else Z.push({start:0,end:0,replacement:Q})}}Z.sort((V,X)=>V.start-X.start||V.end-X.end);for(let V=1;V<Z.length;V++)if(Z[V].start<Z[V-1].end)return DQ(QJ(J),Q);let F=Array(Z.length*2+1),W=0,j=0;for(let V of Z)F[j++]=J.slice(W,V.start),F[j++]=V.replacement,W=V.end;return F[j]=J.slice(W),F.join("")}function DQ(J,Q){let Z=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(Z.test(J)){let $=!1;return J.replace(Z,()=>{if($)return"";return $=!0,Q})}if(J.includes("</head>"))return J.replace("</head>",`${Q}
30
30
  </head>`);if(J.includes("<body"))return J.replace(/<body([^>]*)>/,`<body$1>
31
31
  ${Q}`);return Q+J}
32
- export{ZJ as yt,fQ as zt,gQ as At,SJ as Bt,mQ as Ct,UJ as Dt,hQ as Et,iQ as Ft,l as Gt,IJ as Ht,iJ as It,rJ as Jt,vQ as Kt,NJ as Lt,a as Mt,RQ as Nt,aJ as Ot,h as Pt,LJ as Qt,JJ as Rt,QJ as St,xQ as Tt,Y as Ut,eQ as Vt,pJ as Wt,J0 as Xt,mJ as Yt,wQ as Zt,BQ as _t,HQ as $t,Q0 as au,$0 as bu,OQ as cu,LQ as du,Z0 as eu};
32
+ export{ZJ as zt,fQ as At,gQ as Bt,SJ as Ct,mQ as Dt,UJ as Et,hQ as Ft,iQ as Gt,l as Ht,IJ as It,iJ as Jt,rJ as Kt,vQ as Lt,NJ as Mt,a as Nt,RQ as Ot,aJ as Pt,h as Qt,LJ as Rt,JJ as St,QJ as Tt,xQ as Ut,Y as Vt,eQ as Wt,pJ as Xt,J0 as Yt,mJ as Zt,wQ as _t,BQ as $t,HQ as au,Q0 as bu,$0 as cu,OQ as du,LQ as eu,Z0 as fu};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{$f as e}from"./chunk-2h6pmz31.js";import{Fg as EF,tg as t,vg as kF,wg as UF,xg as wF}from"./chunk-mbaew5a8.js";import{Ig as BF}from"./chunk-dvvx1wny.js";import{yj as l,zj as d}from"./chunk-289vztwy.js";import{Lk as HF,Mk as IF,Nk as KF}from"./chunk-09zjty4k.js";import{vl as YF,xl as ZF}from"./chunk-kxtfmwy0.js";import{$p as VF,Ar as o,Cr as M,Ep as $F,Tp as GF,_m as s,dq as r,tm as p,uo as zF,vm as i}from"./chunk-r6g1n649.js";import{eu as qF}from"./chunk-4zwjqcw4.js";import{wu as XF}from"./chunk-bsm13y1j.js";import{Eu as WF}from"./chunk-7ymv9pd6.js";import{Ju as QF}from"./chunk-7080py5f.js";import{fw as h,hw as _F}from"./chunk-2jzntvfr.js";import G from"fs";import q from"path";import{createHash as NF}from"crypto";_F();function u(Q){return NF("sha256").update(Q).digest("hex").slice(0,8)}function c(Q=!1){let z=Q?d():l(),Z=u(z);return{content:z,filename:`runtime.${Z}.js`,hash:Z}}function a(){let Q=h(),z=u(Q);return{content:Q,filename:`router.${z}.js`,hash:z}}function bF(Q){return{runtimeTag:Q.runtime?`<script src="/__stx/${Q.runtime.filename}"></script>`:"",routerTag:Q.router?`<script src="/__stx/${Q.router.filename}"></script>`:"",cssTag:Q.css?`<link rel="stylesheet" href="/__stx/${Q.css.filename}">`:""}}import n from"path";import{createHash as OF}from"crypto";function TF(Q={}){let z=new Set;return{context:new Proxy(Q,{get(X,F){if(F in X)return X[F];if(typeof F==="string"&&!F.startsWith("__"))z.add(F);return},has(X,F){if(F in X)return!0;if(typeof F==="string"&&!F.startsWith("__"))z.add(F);return!1}}),accessedKeys:z}}async function FF(Q,z,Z={}){let X=n.resolve(Q),F=await Bun.file(X).text(),U=OF("sha256").update(F).digest("hex").slice(0,16);p();let w={};try{w=await M(Z.configDir)}catch{}let H=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(F))!==null){let E=k[1];if(/\bserver\b/.test(E))H.push(k[2])}let W=new Set(H.flatMap((E)=>e(E))),{context:_}=TF({__filename:X,__dirname:n.dirname(X),__stx_serverDeclared:W}),N=new Set,x={...o,...w,...Z,buildMode:"compile",strict:!1},I=await r(F,_,X,x,N),O=t(I),j=i();return{route:z,sourceFile:Q,html:I,fragment:O,placeholders:j,hasServerScripts:H.length>0,serverScriptContent:H,dependencies:Array.from(N),contentHash:U,status:s(F),streamTemplates:_.__streamTemplates}}var MF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function JF(Q,z){let Z=0,X=0;if(!G.existsSync(Q))return{copied:Z,bytes:X};G.mkdirSync(z,{recursive:!0});function F(U,w){let H=G.readdirSync(U,{withFileTypes:!0});for(let V of H){if(MF.has(V.name))continue;let k=q.join(U,V.name),W=q.join(w,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),F(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),Z++,X+=G.statSync(W).size}}}return F(Q,z),{copied:Z,bytes:X}}async function qJ(Q={}){let z=Date.now(),Z=q.resolve(Q.root||process.cwd()),X=q.resolve(Z,Q.outputDir||".output");console.log("[stx build] Starting production build...");let F=await M(Z),U=q.resolve(Z,Q.componentsDir??F.componentsDir??"components"),w=q.resolve(Z,Q.partialsDir??F.partialsDir??"partials"),H=q.resolve(Z,Q.layoutsDir??F.layoutsDir??"layouts"),V=Q.publicDir??F.publicDir??"public",k=F.app?.head||{},W=F.app?.colorMode,_=F.router?.container||"main",N=Q.routeRules??F.routeRules??{},x=BF(N),I=Q.serverApi??F.serverApi,O=typeof I==="object"?I:{};if(I)YF(Z,O);if(F.runtimeConfig)QF(F.runtimeConfig,{});if(G.existsSync(X))G.rmSync(X,{recursive:!0});let j=[q.join(X,"public","__stx"),q.join(X,"public","assets"),q.join(X,"server","pages"),q.join(X,"server","fragments")];for(let Y of j)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let E=zF(Z,{pagesDirs:F._layerPageDirs}),LF=["components","layouts","partials"],y=E.filter((Y)=>{return!LF.some((B)=>Y.pattern.startsWith(`/${B}/`)||Y.pattern===`/${B}`)});console.log(`[stx build] Found ${y.length} page routes (${E.length-y.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let L=c(Q.debug),K=a();await Bun.write(q.join(X,"public","__stx",L.filename),L.content),await Bun.write(q.join(X,"public","__stx",K.filename),K.content),console.log(`[stx build] Runtime: ${L.filename} (${(L.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${K.filename} (${(K.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let R=[],v=[];for(let Y of y){let B=x(Y.pattern),b=B.rendering==="prerender";if(b&&(Y.pattern.includes(":")||Y.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${Y.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let J=await FF(Y.filePath,Y.pattern,{configDir:Z,componentsDir:U,partialsDir:w,layoutsDir:H,debug:Q.debug});if(R.push(J),J.html=J.html.replace(/runtime\.__STX_HASH__\.js/g,L.filename).replace(/router\.__STX_HASH__\.js/g,K.filename),J.html=VF(J.html,k,{bodyScripts:[`<script src="/__stx/${K.filename}"></script>`],...W&&{colorMode:W}}),W)J.html=$F(J.html,W);if(k.htmlAttrs)J.html=GF(J.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(J.html)){let $=J.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if($&&$[1]){let m=$[1];J.html=J.html.replace(" "+m,""),J.html=J.html.replace(/<body([^>]*)>/,`<body$1 ${m}>`)}}if(J.html=J.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),J.html=await qF(J.html),b){let $=await EF(J,{params:{},request:new Request(`http://stx.build${Y.pattern}`),method:"GET",__stx_strict_hydration:!0});if($.redirect||$.cookies?.length||$.boundaries?.length||$.headers&&Object.keys($.headers).length)throw Error(`Prerendered route ${Y.pattern} cannot set response headers/cookies, redirect or stream`);J.html=$.html,J.status=$.status??J.status,J.hasServerScripts=!1,J.serverScriptContent=[],J.placeholders={}}J.fragment=kF(J.html,_);let C=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),g=q.join("server","pages",`${C}.compiled.json`),f=q.join("server","fragments",`${C}.html`);await Bun.write(q.join(X,g),JSON.stringify(J,null,2)),await Bun.write(q.join(X,f),J.fragment),v.push({pattern:Y.pattern,compiledPath:g,fragmentPath:f,isDynamic:J.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("["),prerendered:b}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(J){if(Object.keys(B).length)throw J;console.error(`[stx build] \u2717 ${Y.pattern}:`,J instanceof Error?J.message:J)}}let P=q.resolve(Z,V);if(G.existsSync(P)){let{copied:Y,bytes:B}=JF(P,q.join(X,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(B/1024).toFixed(1)}KB) from ${V}/`)}let A=KF(Z);if(A){let{copied:Y,bytes:B}=JF(A,q.join(X,"public",IF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(B/1024).toFixed(1)}KB) from ${HF}/`)}let S={runtime:L.filename,router:K.filename},T=UF(v,S,X);if(T.routeRules=N,T.routerContainer=_,I)T.apiRoutes=await ZF(Z,X,O);if(F.runtimeConfig)await Bun.write(q.join(X,"server/runtime-config.json"),JSON.stringify(F.runtimeConfig)),await WF(Z,F.runtimeConfig);if(F._layerGraph)await Bun.write(q.join(X,"server/layers.json"),JSON.stringify(XF(F._layerGraph),null,2));wF(T,X);let D=Date.now()-z;return console.log(`
2
+ import{$f as e}from"./chunk-gdbkqatx.js";import{Fg as EF,tg as t,vg as kF,wg as UF,xg as wF}from"./chunk-cmtjq1db.js";import{Ig as BF}from"./chunk-dvvx1wny.js";import{yj as l,zj as d}from"./chunk-71y3bhcw.js";import{Mk as HF,Nk as IF,Ok as KF}from"./chunk-4jdj52c5.js";import{wl as YF,yl as ZF}from"./chunk-p1hy2bwn.js";import{$m as s,Br as o,Dr as M,Fp as $F,Up as GF,aq as VF,eq as r,um as p,vo as zF,wm as i}from"./chunk-kxtqbrfr.js";import{fu as qF}from"./chunk-kffndzch.js";import{xu as XF}from"./chunk-r8rbf28v.js";import{Fu as WF}from"./chunk-n66k2v2q.js";import{Ku as QF}from"./chunk-vvd659y4.js";import{gw as h,iw as _F}from"./chunk-hzfd8cz0.js";import G from"fs";import q from"path";import{createHash as NF}from"crypto";_F();function u(Q){return NF("sha256").update(Q).digest("hex").slice(0,8)}function c(Q=!1){let z=Q?d():l(),Z=u(z);return{content:z,filename:`runtime.${Z}.js`,hash:Z}}function a(){let Q=h(),z=u(Q);return{content:Q,filename:`router.${z}.js`,hash:z}}function bF(Q){return{runtimeTag:Q.runtime?`<script src="/__stx/${Q.runtime.filename}"></script>`:"",routerTag:Q.router?`<script src="/__stx/${Q.router.filename}"></script>`:"",cssTag:Q.css?`<link rel="stylesheet" href="/__stx/${Q.css.filename}">`:""}}import n from"path";import{createHash as OF}from"crypto";function TF(Q={}){let z=new Set;return{context:new Proxy(Q,{get(X,F){if(F in X)return X[F];if(typeof F==="string"&&!F.startsWith("__"))z.add(F);return},has(X,F){if(F in X)return!0;if(typeof F==="string"&&!F.startsWith("__"))z.add(F);return!1}}),accessedKeys:z}}async function FF(Q,z,Z={}){let X=n.resolve(Q),F=await Bun.file(X).text(),U=OF("sha256").update(F).digest("hex").slice(0,16);p();let w={};try{w=await M(Z.configDir)}catch{}let H=[],V=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k;while((k=V.exec(F))!==null){let E=k[1];if(/\bserver\b/.test(E))H.push(k[2])}let W=new Set(H.flatMap((E)=>e(E))),{context:_}=TF({__filename:X,__dirname:n.dirname(X),__stx_serverDeclared:W}),N=new Set,x={...o,...w,...Z,buildMode:"compile",strict:!1},I=await r(F,_,X,x,N),O=t(I),j=i();return{route:z,sourceFile:Q,html:I,fragment:O,placeholders:j,hasServerScripts:H.length>0,serverScriptContent:H,dependencies:Array.from(N),contentHash:U,status:s(F),streamTemplates:_.__streamTemplates}}var MF=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function JF(Q,z){let Z=0,X=0;if(!G.existsSync(Q))return{copied:Z,bytes:X};G.mkdirSync(z,{recursive:!0});function F(U,w){let H=G.readdirSync(U,{withFileTypes:!0});for(let V of H){if(MF.has(V.name))continue;let k=q.join(U,V.name),W=q.join(w,V.name);if(V.isDirectory())G.mkdirSync(W,{recursive:!0}),F(k,W);else if(V.isFile()){if(G.existsSync(W))continue;G.copyFileSync(k,W),Z++,X+=G.statSync(W).size}}}return F(Q,z),{copied:Z,bytes:X}}async function qJ(Q={}){let z=Date.now(),Z=q.resolve(Q.root||process.cwd()),X=q.resolve(Z,Q.outputDir||".output");console.log("[stx build] Starting production build...");let F=await M(Z),U=q.resolve(Z,Q.componentsDir??F.componentsDir??"components"),w=q.resolve(Z,Q.partialsDir??F.partialsDir??"partials"),H=q.resolve(Z,Q.layoutsDir??F.layoutsDir??"layouts"),V=Q.publicDir??F.publicDir??"public",k=F.app?.head||{},W=F.app?.colorMode,_=F.router?.container||"main",N=Q.routeRules??F.routeRules??{},x=BF(N),I=Q.serverApi??F.serverApi,O=typeof I==="object"?I:{};if(I)YF(Z,O);if(F.runtimeConfig)QF(F.runtimeConfig,{});if(G.existsSync(X))G.rmSync(X,{recursive:!0});let j=[q.join(X,"public","__stx"),q.join(X,"public","assets"),q.join(X,"server","pages"),q.join(X,"server","fragments")];for(let Y of j)G.mkdirSync(Y,{recursive:!0});console.log("[stx build] Discovering routes...");let E=zF(Z,{pagesDirs:F._layerPageDirs}),LF=["components","layouts","partials"],y=E.filter((Y)=>{return!LF.some((B)=>Y.pattern.startsWith(`/${B}/`)||Y.pattern===`/${B}`)});console.log(`[stx build] Found ${y.length} page routes (${E.length-y.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let L=c(Q.debug),K=a();await Bun.write(q.join(X,"public","__stx",L.filename),L.content),await Bun.write(q.join(X,"public","__stx",K.filename),K.content),console.log(`[stx build] Runtime: ${L.filename} (${(L.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${K.filename} (${(K.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let R=[],v=[];for(let Y of y){let B=x(Y.pattern),b=B.rendering==="prerender";if(b&&(Y.pattern.includes(":")||Y.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${Y.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let J=await FF(Y.filePath,Y.pattern,{configDir:Z,componentsDir:U,partialsDir:w,layoutsDir:H,debug:Q.debug});if(R.push(J),J.html=J.html.replace(/runtime\.__STX_HASH__\.js/g,L.filename).replace(/router\.__STX_HASH__\.js/g,K.filename),J.html=VF(J.html,k,{bodyScripts:[`<script src="/__stx/${K.filename}"></script>`],...W&&{colorMode:W}}),W)J.html=$F(J.html,W);if(k.htmlAttrs)J.html=GF(J.html,k.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(J.html)){let $=J.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if($&&$[1]){let m=$[1];J.html=J.html.replace(" "+m,""),J.html=J.html.replace(/<body([^>]*)>/,`<body$1 ${m}>`)}}if(J.html=J.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),J.html=await qF(J.html),b){let $=await EF(J,{params:{},request:new Request(`http://stx.build${Y.pattern}`),method:"GET",__stx_strict_hydration:!0});if($.redirect||$.cookies?.length||$.boundaries?.length||$.headers&&Object.keys($.headers).length)throw Error(`Prerendered route ${Y.pattern} cannot set response headers/cookies, redirect or stream`);J.html=$.html,J.status=$.status??J.status,J.hasServerScripts=!1,J.serverScriptContent=[],J.placeholders={}}J.fragment=kF(J.html,_);let C=Y.pattern==="/"?"index":Y.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),g=q.join("server","pages",`${C}.compiled.json`),f=q.join("server","fragments",`${C}.html`);await Bun.write(q.join(X,g),JSON.stringify(J,null,2)),await Bun.write(q.join(X,f),J.fragment),v.push({pattern:Y.pattern,compiledPath:g,fragmentPath:f,isDynamic:J.hasServerScripts,hasParams:Y.pattern.includes(":")||Y.pattern.includes("["),prerendered:b}),console.log(`[stx build] \u2713 ${Y.pattern}`)}catch(J){if(Object.keys(B).length)throw J;console.error(`[stx build] \u2717 ${Y.pattern}:`,J instanceof Error?J.message:J)}}let P=q.resolve(Z,V);if(G.existsSync(P)){let{copied:Y,bytes:B}=JF(P,q.join(X,"public"));if(Y>0)console.log(`[stx build] Copied ${Y} public asset${Y===1?"":"s"} (${(B/1024).toFixed(1)}KB) from ${V}/`)}let A=KF(Z);if(A){let{copied:Y,bytes:B}=JF(A,q.join(X,"public",IF));if(Y>0)console.log(`[stx build] Copied ${Y} asset${Y===1?"":"s"} (${(B/1024).toFixed(1)}KB) from ${HF}/`)}let S={runtime:L.filename,router:K.filename},T=UF(v,S,X);if(T.routeRules=N,T.routerContainer=_,I)T.apiRoutes=await ZF(Z,X,O);if(F.runtimeConfig)await Bun.write(q.join(X,"server/runtime-config.json"),JSON.stringify(F.runtimeConfig)),await WF(Z,F.runtimeConfig);if(F._layerGraph)await Bun.write(q.join(X,"server/layers.json"),JSON.stringify(XF(F._layerGraph),null,2));wF(T,X);let D=Date.now()-z;return console.log(`
3
3
  [stx build] Done in ${D}ms \u2014 ${R.length} pages compiled`),{pageCount:R.length,assets:S,outputDir:X,duration:D}}
4
4
  export{u as Rf,c as Sf,a as Tf,bF as Uf,FF as Vf,qJ as Wf};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{rw as y}from"./chunk-5ep11kvc.js";function S4(){if(typeof Notification<"u"&&Notification.permission==="granted")return!0;return!1}function jZ(){return typeof window<"u"&&typeof document<"u"}async function w4(){if(typeof Notification>"u")return!1;if(Notification.permission==="granted")return!0;if(Notification.permission==="denied")return!1;return await Notification.requestPermission()==="granted"}var g=new Map;function B4(){return`alert-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function f4(Z){switch(Z){case"info":return"&#x2139;";case"success":return"&#x2714;";case"warning":return"&#x26A0;";case"error":return"&#x2716;";default:return"&#x2139;"}}function v4(Z="top-right"){if(!jZ())throw Error("Toast container requires browser environment");try{let $=document.querySelector(`.stx-toast-container[data-position="${Z}"]`);if($)return $}catch{}let Y=document.createElement("div");Y.className=`stx-toast-container ${Z}`,Y.dataset.position=Z;try{if(document.body)document.body.appendChild(Y)}catch{}return Y}function y4(Z){let{options:Y}=Z,$=f4(Y.type),J=Y.type||"info",Q=Y.duration!==0;return`
2
+ import{sw as y}from"./chunk-hyfjnn7g.js";function S4(){if(typeof Notification<"u"&&Notification.permission==="granted")return!0;return!1}function jZ(){return typeof window<"u"&&typeof document<"u"}async function w4(){if(typeof Notification>"u")return!1;if(Notification.permission==="granted")return!0;if(Notification.permission==="denied")return!1;return await Notification.requestPermission()==="granted"}var g=new Map;function B4(){return`alert-${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function f4(Z){switch(Z){case"info":return"&#x2139;";case"success":return"&#x2714;";case"warning":return"&#x26A0;";case"error":return"&#x2716;";default:return"&#x2139;"}}function v4(Z="top-right"){if(!jZ())throw Error("Toast container requires browser environment");try{let $=document.querySelector(`.stx-toast-container[data-position="${Z}"]`);if($)return $}catch{}let Y=document.createElement("div");Y.className=`stx-toast-container ${Z}`,Y.dataset.position=Z;try{if(document.body)document.body.appendChild(Y)}catch{}return Y}function y4(Z){let{options:Y}=Z,$=f4(Y.type),J=Y.type||"info",Q=Y.duration!==0;return`
3
3
  <div class="stx-toast ${J}" data-alert-id="${Z.id}" role="alert" aria-live="polite">
4
4
  <div class="stx-toast-icon">${$}</div>
5
5
  <div class="stx-toast-content">
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{bt as Q}from"./chunk-cqp01pgs.js";import"./chunk-1czvb2wx.js";import{Bu as R}from"./chunk-gne68nyp.js";import"./chunk-5ep11kvc.js";import O from"fs";import U from"path";async function W(j,b={}){let q=Date.now(),z={total:0,passed:0,failed:0,new:0,failures:[],duration:0},K=b.snapshotDir||R(j.root,"story","snapshots");await O.promises.mkdir(K,{recursive:!0});let B=j.storyFiles;if(b.filter&&b.filter.length>0)B=B.filter((J)=>b.filter.some((G)=>J.fileName.toLowerCase().includes(G.toLowerCase())));for(let J of B)await X(J,K,b,z);return z.duration=Date.now()-q,z}async function X(j,b,q,z){let K=j.story;if(!K)return;for(let B of K.variants){z.total++;let J=U.join(b,`${j.id}-${B.id}.snap`),G=Y(B.source||""),L=await _(J);if(q.update||!L){let M={storyId:j.id,variantId:B.id,component:j.fileName,timestamp:Date.now(),hash:G};if(await O.promises.writeFile(J,JSON.stringify(M,null,2)),!L)z.new++;z.passed++}else try{let M=await O.promises.readFile(J,"utf-8"),N=JSON.parse(M);if(N.hash===G)z.passed++;else z.failed++,z.failures.push({storyId:j.id,variantId:B.id,component:j.fileName,message:"Snapshot mismatch",difference:Z(N.hash,G)})}catch(M){z.failed++,z.failures.push({storyId:j.id,variantId:B.id,component:j.fileName,message:`Error reading snapshot: ${M}`})}}}async function A(j,b={}){return(await W(j,{...b,update:!0})).total}function Y(j){let b=0;for(let q=0;q<j.length;q++){let z=j.charCodeAt(q);b=(b<<5)-b+z,b=b&b}return b.toString(16)}function Z(j,b){if(j===b)return 0;let q=Math.abs(Number.parseInt(j,16)-Number.parseInt(b,16));return Math.min(q/1e6,1)}async function _(j){try{return await O.promises.access(j),!0}catch{return!1}}function I(j){let b=[];if(b.push(""),b.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),b.push(" STX Story Visual Regression Tests"),b.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),b.push(""),j.failures.length>0){b.push(" \u274C Failures:"),b.push("");for(let q of j.failures){if(b.push(` \u2022 ${q.component} / ${q.variantId}`),b.push(` ${q.message}`),q.difference!==void 0)b.push(` Difference: ${(q.difference*100).toFixed(2)}%`);b.push("")}}if(b.push(" Summary:"),b.push(` Total: ${j.total}`),b.push(` Passed: ${j.passed} \u2713`),b.push(` Failed: ${j.failed} \u2717`),j.new>0)b.push(` New: ${j.new} \u26A1`);return b.push(` Time: ${j.duration}ms`),b.push(""),b.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),b.push(""),b.join(`
2
+ import{ct as Q}from"./chunk-caaenc3w.js";import"./chunk-amxtypkp.js";import{Cu as R}from"./chunk-gptwwv3c.js";import"./chunk-hyfjnn7g.js";import O from"fs";import U from"path";async function W(j,b={}){let q=Date.now(),z={total:0,passed:0,failed:0,new:0,failures:[],duration:0},K=b.snapshotDir||R(j.root,"story","snapshots");await O.promises.mkdir(K,{recursive:!0});let B=j.storyFiles;if(b.filter&&b.filter.length>0)B=B.filter((J)=>b.filter.some((G)=>J.fileName.toLowerCase().includes(G.toLowerCase())));for(let J of B)await X(J,K,b,z);return z.duration=Date.now()-q,z}async function X(j,b,q,z){let K=j.story;if(!K)return;for(let B of K.variants){z.total++;let J=U.join(b,`${j.id}-${B.id}.snap`),G=Y(B.source||""),L=await _(J);if(q.update||!L){let M={storyId:j.id,variantId:B.id,component:j.fileName,timestamp:Date.now(),hash:G};if(await O.promises.writeFile(J,JSON.stringify(M,null,2)),!L)z.new++;z.passed++}else try{let M=await O.promises.readFile(J,"utf-8"),N=JSON.parse(M);if(N.hash===G)z.passed++;else z.failed++,z.failures.push({storyId:j.id,variantId:B.id,component:j.fileName,message:"Snapshot mismatch",difference:Z(N.hash,G)})}catch(M){z.failed++,z.failures.push({storyId:j.id,variantId:B.id,component:j.fileName,message:`Error reading snapshot: ${M}`})}}}async function A(j,b={}){return(await W(j,{...b,update:!0})).total}function Y(j){let b=0;for(let q=0;q<j.length;q++){let z=j.charCodeAt(q);b=(b<<5)-b+z,b=b&b}return b.toString(16)}function Z(j,b){if(j===b)return 0;let q=Math.abs(Number.parseInt(j,16)-Number.parseInt(b,16));return Math.min(q/1e6,1)}async function _(j){try{return await O.promises.access(j),!0}catch{return!1}}function I(j){let b=[];if(b.push(""),b.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),b.push(" STX Story Visual Regression Tests"),b.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),b.push(""),j.failures.length>0){b.push(" \u274C Failures:"),b.push("");for(let q of j.failures){if(b.push(` \u2022 ${q.component} / ${q.variantId}`),b.push(` ${q.message}`),q.difference!==void 0)b.push(` Difference: ${(q.difference*100).toFixed(2)}%`);b.push("")}}if(b.push(" Summary:"),b.push(` Total: ${j.total}`),b.push(` Passed: ${j.passed} \u2713`),b.push(` Failed: ${j.failed} \u2717`),j.new>0)b.push(` New: ${j.new} \u26A1`);return b.push(` Time: ${j.duration}ms`),b.push(""),b.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),b.push(""),b.join(`
3
3
  `)}async function S(j,b={}){let q=performance.now(),z=[],K=0,B=0;for(let G of j.storyFiles)try{let L=await Bun.file(G.path).text(),M=await Q(L,G.path);if(M.length>0){for(let N of M)z.push({storyId:G.id,variantId:"default",component:G.component,message:`A11y: ${N.message}`,expected:"No accessibility violations",actual:`${N.type}: ${N.message} (impact: ${N.impact})`});B++}else K++}catch(L){z.push({storyId:G.id,variantId:"default",component:G.component,message:`Failed to check a11y: ${L instanceof Error?L.message:String(L)}`,expected:"File readable for a11y check",actual:"File read error"}),B++}let J=performance.now()-q;return{total:j.storyFiles.length,passed:K,failed:B,new:0,failures:z,duration:J}}export{A as updateSnapshots,W as runVisualTests,S as runA11yTests,I as formatTestResults};
@@ -5,4 +5,4 @@ import Q from"fs";import U from"path";function W(H){let v=[],j=H.pwa;if(v.push({
5
5
  `);let J=["required","recommended","optional"];for(let L of J){let N=H.checks.filter((K)=>K.category===L);if(N.length===0)continue;v.push(`
6
6
  ${L.toUpperCase()}:`);for(let K of N){let T=K.passed?"\x1B[32m\u2713\x1B[0m":"\x1B[31m\u2717\x1B[0m";if(v.push(` ${T} ${K.name}: ${K.message}`),K.details)v.push(` ${K.details}`)}}return v.push(""),v.join(`
7
7
  `)}
8
- export{W as Ok,X as Pk,Y as Qk,A as Rk,B as Sk};
8
+ export{W as Pk,X as Qk,Y as Rk,A as Sk,B as Tk};