@stacksjs/stx 0.2.336 → 0.2.338

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 (197) hide show
  1. package/dist/app-shell.js +9 -8
  2. package/dist/{chunk-9v0fsdsf.js → chunk-066yt1hy.js} +1 -1
  3. package/dist/{chunk-eth22r93.js → chunk-0xgc5t3y.js} +1 -1
  4. package/dist/{chunk-vd5xvsnv.js → chunk-18018jkn.js} +1 -1
  5. package/dist/{chunk-5tefa8qb.js → chunk-1vb2rj09.js} +2 -2
  6. package/dist/chunk-1wsewc5h.js +2 -0
  7. package/dist/{chunk-p1hy2bwn.js → chunk-1yj4xd6n.js} +3 -3
  8. package/dist/{chunk-fqq5k9ve.js → chunk-1z1efvtw.js} +1 -1
  9. package/dist/{chunk-cdqx2c2h.js → chunk-22hch2me.js} +1 -1
  10. package/dist/{chunk-kpeqn5tx.js → chunk-2gc4cevb.js} +1 -1
  11. package/dist/{chunk-mgmn1vxy.js → chunk-39xtzfzf.js} +1 -1
  12. package/dist/{chunk-zsnrcbw1.js → chunk-3cjvqa0s.js} +2 -2
  13. package/dist/chunk-3sgdth20.js +2 -0
  14. package/dist/chunk-41dfsdy9.js +2 -0
  15. package/dist/{chunk-ymrxpwr8.js → chunk-46tmg3k4.js} +2 -2
  16. package/dist/{chunk-e1sxe3q4.js → chunk-4904n5v0.js} +2 -2
  17. package/dist/chunk-4cw0s9f4.js +4 -0
  18. package/dist/chunk-4jj4kk18.js +2 -0
  19. package/dist/chunk-4np12rj1.js +2 -0
  20. package/dist/chunk-4pcjt99d.js +2 -0
  21. package/dist/{chunk-dvvx1wny.js → chunk-57atgbyq.js} +1 -1
  22. package/dist/chunk-58j32d7n.js +2 -0
  23. package/dist/{chunk-hyfjnn7g.js → chunk-5g6rprcy.js} +1 -1
  24. package/dist/{chunk-mm59b0gg.js → chunk-5qsg9q46.js} +1 -1
  25. package/dist/{chunk-m8kezfrt.js → chunk-5r7gfwpj.js} +5 -5
  26. package/dist/chunk-799s9mwc.js +47 -0
  27. package/dist/{chunk-yxppshfd.js → chunk-7a21q2q4.js} +1 -1
  28. package/dist/chunk-7d74am4w.js +2 -0
  29. package/dist/chunk-7ngnyy5k.js +2 -0
  30. package/dist/{chunk-r8rbf28v.js → chunk-7r79j1hs.js} +1 -1
  31. package/dist/{chunk-cr8v8k53.js → chunk-7r9vgzg4.js} +1 -1
  32. package/dist/{chunk-xwxdwqn9.js → chunk-7we3xfde.js} +1 -1
  33. package/dist/{chunk-fr66xp8q.js → chunk-823h67tv.js} +1 -1
  34. package/dist/{chunk-42en0cxm.js → chunk-86v2rps7.js} +1 -1
  35. package/dist/{chunk-xz3evxqp.js → chunk-8bxtvsgm.js} +1 -1
  36. package/dist/{chunk-09jdvqhg.js → chunk-8cg15rr7.js} +2 -2
  37. package/dist/chunk-95t7pked.js +2 -0
  38. package/dist/{chunk-xdmb578h.js → chunk-97ej3abh.js} +1 -1
  39. package/dist/{chunk-kw98dfza.js → chunk-9btdax2s.js} +1 -1
  40. package/dist/{chunk-pbexz0d4.js → chunk-9bvgzqw1.js} +2 -2
  41. package/dist/{chunk-te6qym2g.js → chunk-9jc2z17q.js} +2 -2
  42. package/dist/chunk-9m5sxaen.js +2 -0
  43. package/dist/{chunk-tjag2cmm.js → chunk-a26hcag1.js} +1 -1
  44. package/dist/chunk-a3m7mgjc.js +2 -0
  45. package/dist/{chunk-9368t9jm.js → chunk-a959m68j.js} +1 -1
  46. package/dist/{chunk-fkdnfjc2.js → chunk-aftqqqcg.js} +2 -2
  47. package/dist/chunk-aved735s.js +64 -0
  48. package/dist/{chunk-q0g5c39d.js → chunk-ay336sqb.js} +1 -1
  49. package/dist/{chunk-cvphepjb.js → chunk-b3pn6dh5.js} +1 -1
  50. package/dist/{chunk-5swem3qy.js → chunk-b4cabzk9.js} +1 -1
  51. package/dist/{chunk-ej8mv2k6.js → chunk-bgrkxzr7.js} +1 -1
  52. package/dist/{chunk-2cm03y4y.js → chunk-d3kjaae0.js} +1 -1
  53. package/dist/chunk-d7zxg9bp.js +16 -0
  54. package/dist/{chunk-1ebyt1ba.js → chunk-dekxwgc2.js} +1 -1
  55. package/dist/chunk-dvafkj8w.js +2 -0
  56. package/dist/chunk-e3rgky2r.js +3747 -0
  57. package/dist/{chunk-t41aaehf.js → chunk-e4g8wz6t.js} +1 -1
  58. package/dist/chunk-e9y48d60.js +2 -0
  59. package/dist/{chunk-pbzdjhp8.js → chunk-eq2j7w8p.js} +1 -1
  60. package/dist/chunk-f08ttkqr.js +2 -0
  61. package/dist/{chunk-4jdj52c5.js → chunk-f6sejeg3.js} +1 -1
  62. package/dist/chunk-fha0nyet.js +2 -0
  63. package/dist/{chunk-6k8h1fj1.js → chunk-fjrkyhm7.js} +1 -1
  64. package/dist/chunk-fw56y3cb.js +30 -0
  65. package/dist/chunk-fx5m9d3t.js +2 -0
  66. package/dist/{chunk-mwh3ymwc.js → chunk-g6czgcg4.js} +1 -1
  67. package/dist/chunk-gtfcw1gc.js +12 -0
  68. package/dist/chunk-gz539gk6.js +2 -0
  69. package/dist/chunk-h0y4mb2m.js +2 -0
  70. package/dist/chunk-hfzv07az.js +3 -0
  71. package/dist/{chunk-nat3actx.js → chunk-hrdd26r4.js} +1 -1
  72. package/dist/{chunk-cdsbxghb.js → chunk-jkyvk4x6.js} +1 -1
  73. package/dist/{chunk-4ty8j3xn.js → chunk-jx03a693.js} +1 -1
  74. package/dist/{chunk-vvd659y4.js → chunk-k3dtvay1.js} +1 -1
  75. package/dist/chunk-kawdj1j7.js +2 -0
  76. package/dist/{chunk-d4etph79.js → chunk-kdhrk7x5.js} +1 -1
  77. package/dist/chunk-kdwerx8e.js +2 -0
  78. package/dist/{chunk-n66k2v2q.js → chunk-kermxyfe.js} +2 -2
  79. package/dist/{chunk-x7yc7e9v.js → chunk-m11pb9cx.js} +1 -1
  80. package/dist/{chunk-k6ky5et7.js → chunk-m1p2n3nf.js} +1 -1
  81. package/dist/chunk-m46edxtt.js +3 -0
  82. package/dist/chunk-meqz313r.js +2 -0
  83. package/dist/{chunk-q05eh1n4.js → chunk-mnyehz4t.js} +2 -2
  84. package/dist/{chunk-0vv5s039.js → chunk-mys0rat0.js} +1 -1
  85. package/dist/chunk-n0a55zv2.js +2 -0
  86. package/dist/{chunk-7kw3grq5.js → chunk-nf7k53ap.js} +1 -1
  87. package/dist/{chunk-kffndzch.js → chunk-nhbc464j.js} +3 -3
  88. package/dist/{chunk-1hzgxk2m.js → chunk-nvp546bb.js} +1 -1
  89. package/dist/chunk-p1cddybx.js +2 -0
  90. package/dist/chunk-q0srntf6.js +2 -0
  91. package/dist/chunk-q3g4yf5r.js +2 -0
  92. package/dist/{chunk-c2ta859c.js → chunk-q9ckfwhh.js} +1 -1
  93. package/dist/chunk-qhdp0ycf.js +2 -0
  94. package/dist/{chunk-y4nzmkea.js → chunk-qsbjtp60.js} +1 -1
  95. package/dist/{chunk-1tva0f8f.js → chunk-qtc28zy1.js} +1 -1
  96. package/dist/{chunk-2vgkc0kg.js → chunk-r10fypcd.js} +1 -1
  97. package/dist/chunk-rkykwy3z.js +2 -0
  98. package/dist/{chunk-64djh88a.js → chunk-sqvqwd0p.js} +1 -1
  99. package/dist/{chunk-67bh5vrj.js → chunk-stbns4bg.js} +1 -1
  100. package/dist/chunk-szfk6pw6.js +2 -0
  101. package/dist/{chunk-amxtypkp.js → chunk-t00ga194.js} +1 -1
  102. package/dist/chunk-temapbqe.js +2 -0
  103. package/dist/{chunk-9kxfz708.js → chunk-tr1174hz.js} +1 -1
  104. package/dist/{chunk-q85qp5we.js → chunk-tr41gn5j.js} +1 -1
  105. package/dist/{chunk-crj19mqr.js → chunk-tr9ynxdw.js} +1 -1
  106. package/dist/{chunk-71y3bhcw.js → chunk-tsmdmf5h.js} +123 -37
  107. package/dist/{chunk-gptwwv3c.js → chunk-vaggjvsm.js} +1 -1
  108. package/dist/{chunk-ya5m5vbn.js → chunk-vgfd9582.js} +1 -1
  109. package/dist/chunk-vgfnre7b.js +2 -0
  110. package/dist/{chunk-n9c975db.js → chunk-vhzc08aa.js} +1 -1
  111. package/dist/{chunk-08w4gtyf.js → chunk-vm5jbgb1.js} +3 -3
  112. package/dist/{chunk-drqdc0mh.js → chunk-vxt5c5aq.js} +1 -1
  113. package/dist/{chunk-hzfd8cz0.js → chunk-w0hzaka3.js} +78 -67
  114. package/dist/{chunk-yk6446kr.js → chunk-w72v0ab1.js} +2 -2
  115. package/dist/{chunk-c65yrgck.js → chunk-wakb8z5q.js} +10 -10
  116. package/dist/{chunk-q569zmrr.js → chunk-wb90259a.js} +1 -1
  117. package/dist/chunk-x01sw9wy.js +2 -0
  118. package/dist/{chunk-dfejgnny.js → chunk-x48crnwa.js} +1 -1
  119. package/dist/{chunk-24b4711v.js → chunk-x4vhn880.js} +1 -1
  120. package/dist/{chunk-j2dj21ay.js → chunk-xe6zmdfq.js} +1 -1
  121. package/dist/chunk-y8vj3rtt.js +2 -0
  122. package/dist/chunk-yj1dxdfr.js +2 -0
  123. package/dist/{chunk-wx5zf66r.js → chunk-yne23w3c.js} +1 -1
  124. package/dist/{chunk-zz8qgqa1.js → chunk-ypzm47q3.js} +2 -2
  125. package/dist/chunk-z07knk3p.js +2 -0
  126. package/dist/{chunk-27xfkzks.js → chunk-zj039s33.js} +1 -1
  127. package/dist/{chunk-c79nfdyj.js → chunk-zk6ghjnj.js} +1 -1
  128. package/dist/chunk-zt4pf776.js +2 -0
  129. package/dist/{chunk-4k0ce745.js → chunk-zye9r15n.js} +2 -2
  130. package/dist/chunk-zzfpwxpp.js +2 -0
  131. package/dist/cli.js +14 -14
  132. package/dist/component-contract-checks.d.ts +18 -15
  133. package/dist/component-contract.d.ts +6 -14
  134. package/dist/craft-entry.js +1 -1
  135. package/dist/craft.js +1 -1
  136. package/dist/database.js +1 -1
  137. package/dist/expressions.d.ts +45 -0
  138. package/dist/expressions.js +60 -11
  139. package/dist/includes.js +4 -0
  140. package/dist/loops.js +10 -0
  141. package/dist/pwa.js +2 -2
  142. package/dist/server-components.js +2 -1
  143. package/dist/signals.js +121 -35
  144. package/dist/slots.js +86 -12
  145. package/dist/ssg.js +2 -2
  146. package/dist/stx-virtual-ts.d.ts +205 -95
  147. package/dist/template-syntax-escape.d.ts +36 -0
  148. package/dist/template-syntax-escape.js +8 -0
  149. package/dist/utils.js +9 -2
  150. package/dist/variable-extractor.d.ts +1 -0
  151. package/dist/variable-extractor.js +8 -0
  152. package/dist/visual-testing.js +1 -1
  153. package/package.json +8 -8
  154. package/dist/chunk-046dp691.js +0 -2
  155. package/dist/chunk-1brnvyhv.js +0 -2
  156. package/dist/chunk-3ntf8f5e.js +0 -2
  157. package/dist/chunk-4tnxnzja.js +0 -2
  158. package/dist/chunk-63yfp05p.js +0 -2
  159. package/dist/chunk-7y4eqkv4.js +0 -2
  160. package/dist/chunk-7ywnkv1f.js +0 -2
  161. package/dist/chunk-80zj5516.js +0 -2
  162. package/dist/chunk-8730k51r.js +0 -2
  163. package/dist/chunk-907qxn09.js +0 -2
  164. package/dist/chunk-9fcq5x2r.js +0 -2
  165. package/dist/chunk-a97tp43x.js +0 -2
  166. package/dist/chunk-atw841yx.js +0 -2
  167. package/dist/chunk-c1m1gng4.js +0 -2
  168. package/dist/chunk-caaenc3w.js +0 -60
  169. package/dist/chunk-dbfq77qe.js +0 -4
  170. package/dist/chunk-dnesmvvb.js +0 -2
  171. package/dist/chunk-eg8ksaft.js +0 -2
  172. package/dist/chunk-ewsx2qxm.js +0 -2
  173. package/dist/chunk-farwrdr2.js +0 -3
  174. package/dist/chunk-fcenm8n1.js +0 -2
  175. package/dist/chunk-gbz6pfs8.js +0 -2
  176. package/dist/chunk-gdbkqatx.js +0 -43
  177. package/dist/chunk-jnahcd4d.js +0 -2
  178. package/dist/chunk-ke88kpva.js +0 -30
  179. package/dist/chunk-krpkfndf.js +0 -3
  180. package/dist/chunk-kxtqbrfr.js +0 -3759
  181. package/dist/chunk-m1yrakpk.js +0 -2
  182. package/dist/chunk-q2hvne0v.js +0 -2
  183. package/dist/chunk-qpbk50xd.js +0 -2
  184. package/dist/chunk-rxdd3k6n.js +0 -2
  185. package/dist/chunk-ssd10kje.js +0 -2
  186. package/dist/chunk-szx6pxh3.js +0 -2
  187. package/dist/chunk-tpmgq2dx.js +0 -12
  188. package/dist/chunk-tte4m2s9.js +0 -2
  189. package/dist/chunk-v7gjsb3f.js +0 -2
  190. package/dist/chunk-vv289x82.js +0 -2
  191. package/dist/chunk-vx6mxybh.js +0 -2
  192. package/dist/chunk-x510wr8z.js +0 -2
  193. package/dist/chunk-x95sxapm.js +0 -2
  194. package/dist/chunk-xjrhzkx2.js +0 -2
  195. package/dist/chunk-y1x2ebhv.js +0 -2
  196. package/dist/chunk-yvec3f1c.js +0 -2
  197. package/dist/chunk-yzxm75jp.js +0 -2
package/dist/app-shell.js CHANGED
@@ -2,20 +2,21 @@ var {require}=import.meta;import path from "node:path";
2
2
  import { classifyAllScripts } from "./script-classifier.js";
3
3
  import { startsDocument } from "./document-shell.js";
4
4
  import { findContainerRegion } from "./fragment-container.js";
5
+ import { isDevelopment } from "./env.js";
5
6
  import { isSpaNavRequest } from "./spa-nav.js";
6
7
  export { extractLayoutMetadata } from "stx-router/layout-metadata";
7
- const PAGE_HEAD_MARKER = "stx-page-head:", PAGE_HEAD_MARKER_RE = /<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/;
8
- let _cachedRouterScript = null;
8
+ const PAGE_HEAD_MARKER = "stx-page-head:", PAGE_HEAD_MARKER_RE = /<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/, _cachedRouterScripts = { dev: null, prod: null };
9
9
  function getRouterScriptCached() {
10
- if (_cachedRouterScript !== null)
11
- return _cachedRouterScript;
10
+ const variant = isDevelopment() ? "dev" : "prod", cached = _cachedRouterScripts[variant];
11
+ if (cached !== null)
12
+ return cached;
12
13
  try {
13
- const { getRouterScript } = require("stx-router");
14
- _cachedRouterScript = `<script>${getRouterScript()}</script>`;
14
+ const router = require("stx-router"), generate = variant === "dev" && typeof router.getRouterScriptDev === "function" ? router.getRouterScriptDev : router.getRouterScript;
15
+ _cachedRouterScripts[variant] = `<script>${generate()}</script>`;
15
16
  } catch {
16
- _cachedRouterScript = "";
17
+ _cachedRouterScripts[variant] = "";
17
18
  }
18
- return _cachedRouterScript;
19
+ return _cachedRouterScripts[variant];
19
20
  }
20
21
  export async function detectShell(appDir, shellConfig) {
21
22
  if (shellConfig === !1)
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-hyfjnn7g.js";import v from"fs";import H from"path";import{gzipSync as z}from"zlib";import{createHash as g}from"crypto";var D={".js":"js",".mjs":"js",".cjs":"js",".ts":"js",".jsx":"js",".tsx":"js",".css":"css",".scss":"css",".sass":"css",".less":"css",".html":"html",".htm":"html",".png":"image",".jpg":"image",".jpeg":"image",".gif":"image",".svg":"image",".webp":"image",".avif":"image",".ico":"image",".woff":"font",".woff2":"font",".ttf":"font",".eot":"font",".otf":"font"},b=[/node_modules/,/vendor/,/bower_components/,/\.min\./],B=[/index\.(js|ts|html)$/,/main\.(js|ts)$/,/app\.(js|ts)$/,/entry\.(js|ts)$/];async function L(X,Z={}){let{includeSourceMaps:Q=!1,parseImports:$=!0,detectDuplicates:U=!0,topModulesCount:K=20}=Z;if(!v.existsSync(X))throw Error(`Build directory not found: ${X}`);if(!v.statSync(X).isDirectory())throw Error(`Not a directory: ${X}`);let q=await k(X,Q),J=[],F=[];for(let A of q)try{let O=await f(A,X,$);J.push(O)}catch(O){F.push(`Failed to process ${A}: ${O}`)}let Y=c(J,X),V=J.reduce((A,O)=>A+O.size,0),_=J.reduce((A,O)=>A+O.gzipSize,0),w=m(J),G=U?p(J):[],C=[...J].sort((A,O)=>O.size-A.size).slice(0,K);return{timestamp:Date.now(),buildDir:H.resolve(X),chunks:Y,totalSize:V,totalGzipSize:_,moduleCount:J.length,duplicates:G,byType:w,largestModules:C,warnings:F}}async function k(X,Z){let Q=[];async function $(U){let K=await v.promises.readdir(U,{withFileTypes:!0});for(let j of K){let q=H.join(U,j.name);if(j.isDirectory()){if(!j.name.startsWith(".")&&j.name!=="node_modules")await $(q)}else if(j.isFile()){if(!Z&&j.name.endsWith(".map"))continue;Q.push(q)}}}return await $(X),Q}async function f(X,Z,Q){let $=await v.promises.readFile(X),U=H.relative(Z,X),K=H.extname(X).toLowerCase(),j=$.length,q=y($),J=h($,K),F=g("md5").update($).digest("hex").slice(0,8),Y=D[K]||"other",V=[];if(Q&&Y==="js")V.push(...d($.toString("utf-8")));return{id:U,path:U,size:j,gzipSize:q,parsedSize:J,extension:K,type:Y,imports:V,importedBy:[],hash:F}}function y(X){try{let Z=z(X,{level:9}).length;return Math.min(Z,X.length)}catch{return X.length}}function h(X,Z){if(Z.includes(".min.")||X.length<1000)return X.length;let $=D[Z];if($==="js")return Math.round(X.length*0.6);if($==="css")return Math.round(X.length*0.7);return X.length}function d(X){let Z=[],Q=/import\s+(?:[\w*{}\s,]+\s+from\s+)?['"]([^'"]+)['"]/g,$;while(($=Q.exec(X))!==null)Z.push($[1]);let U=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while(($=U.exec(X))!==null)Z.push($[1]);let K=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while(($=K.exec(X))!==null)Z.push($[1]);return[...new Set(Z)]}function c(X,Z){let Q=new Map;for(let U of X){let K=U.path.split(H.sep),j;if(K.length===1)j=H.basename(U.path,U.extension);else j=K[0];let q=Q.get(j)||[];q.push(U),Q.set(j,q)}let $=[];for(let[U,K]of Q){let j=K.reduce((Y,V)=>Y+V.size,0),q=K.reduce((Y,V)=>Y+V.gzipSize,0),J=K.some((Y)=>B.some((V)=>V.test(Y.path))),F=K.some((Y)=>b.some((V)=>V.test(Y.path)));$.push({name:U,files:K.map((Y)=>Y.path),modules:K,size:j,gzipSize:q,isEntry:J,isVendor:F})}return $.sort((U,K)=>K.size-U.size)}function m(X){let Z={js:{count:0,size:0,gzipSize:0},css:{count:0,size:0,gzipSize:0},html:{count:0,size:0,gzipSize:0},image:{count:0,size:0,gzipSize:0},font:{count:0,size:0,gzipSize:0},other:{count:0,size:0,gzipSize:0}};for(let Q of X)Z[Q.type].count++,Z[Q.type].size+=Q.size,Z[Q.type].gzipSize+=Q.gzipSize;return Z}function p(X){let Z=new Map;for(let $ of X){let U=Z.get($.hash)||[];U.push($),Z.set($.hash,U)}let Q=[];for(let[,$]of Z)if($.length>1){let U=$[0];Q.push({path:U.path,count:$.length,wastedBytes:U.size*($.length-1),locations:$.map((K)=>K.path)})}return Q.sort(($,U)=>U.wastedBytes-$.wastedBytes)}function W(X){if(X<1024)return`${X} B`;if(X<1048576)return`${(X/1024).toFixed(2)} KB`;return`${(X/1048576).toFixed(2)} MB`}function I(X){let Z=X.match(/^([\d.]+)\s*(B|KB|MB|GB)?$/i);if(!Z)return 0;let Q=Number.parseFloat(Z[1]);switch((Z[2]||"B").toUpperCase()){case"KB":return Q*1024;case"MB":return Q*1024*1024;case"GB":return Q*1024*1024*1024;default:return Q}}function E(X,Z){if(Z===0)return"0%";return`${(X/Z*100).toFixed(1)}%`}function R(X,Z){switch(Z.format){case"json":return u(X,Z);case"markdown":return l(X,Z);case"text":default:return r(X,Z)}}function u(X,Z){let Q=N(X,Z);return JSON.stringify({timestamp:X.timestamp,buildDir:X.buildDir,summary:{totalSize:X.totalSize,totalSizeFormatted:W(X.totalSize),totalGzipSize:X.totalGzipSize,totalGzipSizeFormatted:W(X.totalGzipSize),moduleCount:X.moduleCount,chunkCount:X.chunks.length,duplicateCount:X.duplicates.length},byType:Object.fromEntries(Object.entries(X.byType).map(([$,U])=>[$,{...U,sizeFormatted:W(U.size),gzipSizeFormatted:W(U.gzipSize)}])),chunks:X.chunks.map(($)=>({name:$.name,size:$.size,sizeFormatted:W($.size),gzipSize:$.gzipSize,gzipSizeFormatted:W($.gzipSize),moduleCount:$.modules.length,isEntry:$.isEntry,isVendor:$.isVendor})),largestModules:X.largestModules.slice(0,Z.topModules||10).map(($)=>({path:$.path,size:$.size,sizeFormatted:W($.size),gzipSize:$.gzipSize,gzipSizeFormatted:W($.gzipSize),type:$.type})),duplicates:X.duplicates,analysis:Q,warnings:X.warnings},null,2)}function r(X,Z){let Q=[],$=Z.showGzip!==!1;if(Q.push(""),Q.push("Bundle Analysis Report"),Q.push("\u2550".repeat(50)),Q.push(""),Q.push("Summary"),Q.push("\u2500".repeat(50)),$)Q.push(`Total Size: ${W(X.totalSize)} (${W(X.totalGzipSize)} gzip)`);else Q.push(`Total Size: ${W(X.totalSize)}`);if(Q.push(`Modules: ${X.moduleCount}`),Q.push(`Chunks: ${X.chunks.length}`),X.duplicates.length>0)Q.push(`Duplicates: ${X.duplicates.length}`);if(Q.push(""),Z.threshold&&X.totalSize>Z.threshold)Q.push(`\u26A0\uFE0F Bundle exceeds threshold of ${W(Z.threshold)}!`),Q.push("");Q.push("Size by Type"),Q.push("\u2500".repeat(50));let U=["js","css","html","image","font","other"];for(let j of U){let q=X.byType[j];if(q.count>0){let J=E(q.size,X.totalSize),F=$?` (${W(q.gzipSize)} gzip)`:"";Q.push(` ${j.padEnd(8)} ${W(q.size).padStart(12)}${F} ${J.padStart(6)} (${q.count} files)`)}}Q.push(""),Q.push("Chunks"),Q.push("\u2500".repeat(50));for(let j of X.chunks.slice(0,10)){let q=[];if(j.isEntry)q.push("entry");if(j.isVendor)q.push("vendor");let J=q.length>0?` [${q.join(", ")}]`:"",F=$?` (${W(j.gzipSize)} gzip)`:"";Q.push(` ${j.name.padEnd(20)} ${W(j.size).padStart(12)}${F}${J}`)}if(X.chunks.length>10)Q.push(` ... and ${X.chunks.length-10} more chunks`);Q.push("");let K=Z.topModules||10;Q.push(`Largest Modules (Top ${K})`),Q.push("\u2500".repeat(50));for(let j=0;j<Math.min(K,X.largestModules.length);j++){let q=X.largestModules[j],J=$?` (${W(q.gzipSize)} gzip)`:"";Q.push(` ${(j+1).toString().padStart(2)}. ${q.path}`),Q.push(` ${W(q.size)}${J}`)}if(Q.push(""),X.duplicates.length>0){Q.push("Duplicate Modules"),Q.push("\u2500".repeat(50));for(let j of X.duplicates.slice(0,5))Q.push(` ${j.path}`),Q.push(` ${j.count} copies, wasting ${W(j.wastedBytes)}`);if(X.duplicates.length>5)Q.push(` ... and ${X.duplicates.length-5} more duplicates`);Q.push("")}if(Z.recommendations!==!1){let j=N(X,Z);if(j.recommendations.length>0){Q.push("Recommendations"),Q.push("\u2500".repeat(50));for(let q of j.recommendations.slice(0,5)){let J=q.impact==="high"?"\u26A1":q.impact==="medium"?"\uD83D\uDCCA":"\uD83D\uDCA1";Q.push(` ${J} ${q.title}`),Q.push(` ${q.description}`)}Q.push("")}}if(X.warnings.length>0){Q.push("Warnings"),Q.push("\u2500".repeat(50));for(let j of X.warnings)Q.push(` \u26A0\uFE0F ${j}`);Q.push("")}return Q.join(`
2
+ import"./chunk-5g6rprcy.js";import v from"fs";import H from"path";import{gzipSync as z}from"zlib";import{createHash as g}from"crypto";var D={".js":"js",".mjs":"js",".cjs":"js",".ts":"js",".jsx":"js",".tsx":"js",".css":"css",".scss":"css",".sass":"css",".less":"css",".html":"html",".htm":"html",".png":"image",".jpg":"image",".jpeg":"image",".gif":"image",".svg":"image",".webp":"image",".avif":"image",".ico":"image",".woff":"font",".woff2":"font",".ttf":"font",".eot":"font",".otf":"font"},b=[/node_modules/,/vendor/,/bower_components/,/\.min\./],B=[/index\.(js|ts|html)$/,/main\.(js|ts)$/,/app\.(js|ts)$/,/entry\.(js|ts)$/];async function L(X,Z={}){let{includeSourceMaps:Q=!1,parseImports:$=!0,detectDuplicates:U=!0,topModulesCount:K=20}=Z;if(!v.existsSync(X))throw Error(`Build directory not found: ${X}`);if(!v.statSync(X).isDirectory())throw Error(`Not a directory: ${X}`);let q=await k(X,Q),J=[],F=[];for(let A of q)try{let O=await f(A,X,$);J.push(O)}catch(O){F.push(`Failed to process ${A}: ${O}`)}let Y=c(J,X),V=J.reduce((A,O)=>A+O.size,0),_=J.reduce((A,O)=>A+O.gzipSize,0),w=m(J),G=U?p(J):[],C=[...J].sort((A,O)=>O.size-A.size).slice(0,K);return{timestamp:Date.now(),buildDir:H.resolve(X),chunks:Y,totalSize:V,totalGzipSize:_,moduleCount:J.length,duplicates:G,byType:w,largestModules:C,warnings:F}}async function k(X,Z){let Q=[];async function $(U){let K=await v.promises.readdir(U,{withFileTypes:!0});for(let j of K){let q=H.join(U,j.name);if(j.isDirectory()){if(!j.name.startsWith(".")&&j.name!=="node_modules")await $(q)}else if(j.isFile()){if(!Z&&j.name.endsWith(".map"))continue;Q.push(q)}}}return await $(X),Q}async function f(X,Z,Q){let $=await v.promises.readFile(X),U=H.relative(Z,X),K=H.extname(X).toLowerCase(),j=$.length,q=y($),J=h($,K),F=g("md5").update($).digest("hex").slice(0,8),Y=D[K]||"other",V=[];if(Q&&Y==="js")V.push(...d($.toString("utf-8")));return{id:U,path:U,size:j,gzipSize:q,parsedSize:J,extension:K,type:Y,imports:V,importedBy:[],hash:F}}function y(X){try{let Z=z(X,{level:9}).length;return Math.min(Z,X.length)}catch{return X.length}}function h(X,Z){if(Z.includes(".min.")||X.length<1000)return X.length;let $=D[Z];if($==="js")return Math.round(X.length*0.6);if($==="css")return Math.round(X.length*0.7);return X.length}function d(X){let Z=[],Q=/import\s+(?:[\w*{}\s,]+\s+from\s+)?['"]([^'"]+)['"]/g,$;while(($=Q.exec(X))!==null)Z.push($[1]);let U=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while(($=U.exec(X))!==null)Z.push($[1]);let K=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while(($=K.exec(X))!==null)Z.push($[1]);return[...new Set(Z)]}function c(X,Z){let Q=new Map;for(let U of X){let K=U.path.split(H.sep),j;if(K.length===1)j=H.basename(U.path,U.extension);else j=K[0];let q=Q.get(j)||[];q.push(U),Q.set(j,q)}let $=[];for(let[U,K]of Q){let j=K.reduce((Y,V)=>Y+V.size,0),q=K.reduce((Y,V)=>Y+V.gzipSize,0),J=K.some((Y)=>B.some((V)=>V.test(Y.path))),F=K.some((Y)=>b.some((V)=>V.test(Y.path)));$.push({name:U,files:K.map((Y)=>Y.path),modules:K,size:j,gzipSize:q,isEntry:J,isVendor:F})}return $.sort((U,K)=>K.size-U.size)}function m(X){let Z={js:{count:0,size:0,gzipSize:0},css:{count:0,size:0,gzipSize:0},html:{count:0,size:0,gzipSize:0},image:{count:0,size:0,gzipSize:0},font:{count:0,size:0,gzipSize:0},other:{count:0,size:0,gzipSize:0}};for(let Q of X)Z[Q.type].count++,Z[Q.type].size+=Q.size,Z[Q.type].gzipSize+=Q.gzipSize;return Z}function p(X){let Z=new Map;for(let $ of X){let U=Z.get($.hash)||[];U.push($),Z.set($.hash,U)}let Q=[];for(let[,$]of Z)if($.length>1){let U=$[0];Q.push({path:U.path,count:$.length,wastedBytes:U.size*($.length-1),locations:$.map((K)=>K.path)})}return Q.sort(($,U)=>U.wastedBytes-$.wastedBytes)}function W(X){if(X<1024)return`${X} B`;if(X<1048576)return`${(X/1024).toFixed(2)} KB`;return`${(X/1048576).toFixed(2)} MB`}function I(X){let Z=X.match(/^([\d.]+)\s*(B|KB|MB|GB)?$/i);if(!Z)return 0;let Q=Number.parseFloat(Z[1]);switch((Z[2]||"B").toUpperCase()){case"KB":return Q*1024;case"MB":return Q*1024*1024;case"GB":return Q*1024*1024*1024;default:return Q}}function E(X,Z){if(Z===0)return"0%";return`${(X/Z*100).toFixed(1)}%`}function R(X,Z){switch(Z.format){case"json":return u(X,Z);case"markdown":return l(X,Z);case"text":default:return r(X,Z)}}function u(X,Z){let Q=N(X,Z);return JSON.stringify({timestamp:X.timestamp,buildDir:X.buildDir,summary:{totalSize:X.totalSize,totalSizeFormatted:W(X.totalSize),totalGzipSize:X.totalGzipSize,totalGzipSizeFormatted:W(X.totalGzipSize),moduleCount:X.moduleCount,chunkCount:X.chunks.length,duplicateCount:X.duplicates.length},byType:Object.fromEntries(Object.entries(X.byType).map(([$,U])=>[$,{...U,sizeFormatted:W(U.size),gzipSizeFormatted:W(U.gzipSize)}])),chunks:X.chunks.map(($)=>({name:$.name,size:$.size,sizeFormatted:W($.size),gzipSize:$.gzipSize,gzipSizeFormatted:W($.gzipSize),moduleCount:$.modules.length,isEntry:$.isEntry,isVendor:$.isVendor})),largestModules:X.largestModules.slice(0,Z.topModules||10).map(($)=>({path:$.path,size:$.size,sizeFormatted:W($.size),gzipSize:$.gzipSize,gzipSizeFormatted:W($.gzipSize),type:$.type})),duplicates:X.duplicates,analysis:Q,warnings:X.warnings},null,2)}function r(X,Z){let Q=[],$=Z.showGzip!==!1;if(Q.push(""),Q.push("Bundle Analysis Report"),Q.push("\u2550".repeat(50)),Q.push(""),Q.push("Summary"),Q.push("\u2500".repeat(50)),$)Q.push(`Total Size: ${W(X.totalSize)} (${W(X.totalGzipSize)} gzip)`);else Q.push(`Total Size: ${W(X.totalSize)}`);if(Q.push(`Modules: ${X.moduleCount}`),Q.push(`Chunks: ${X.chunks.length}`),X.duplicates.length>0)Q.push(`Duplicates: ${X.duplicates.length}`);if(Q.push(""),Z.threshold&&X.totalSize>Z.threshold)Q.push(`\u26A0\uFE0F Bundle exceeds threshold of ${W(Z.threshold)}!`),Q.push("");Q.push("Size by Type"),Q.push("\u2500".repeat(50));let U=["js","css","html","image","font","other"];for(let j of U){let q=X.byType[j];if(q.count>0){let J=E(q.size,X.totalSize),F=$?` (${W(q.gzipSize)} gzip)`:"";Q.push(` ${j.padEnd(8)} ${W(q.size).padStart(12)}${F} ${J.padStart(6)} (${q.count} files)`)}}Q.push(""),Q.push("Chunks"),Q.push("\u2500".repeat(50));for(let j of X.chunks.slice(0,10)){let q=[];if(j.isEntry)q.push("entry");if(j.isVendor)q.push("vendor");let J=q.length>0?` [${q.join(", ")}]`:"",F=$?` (${W(j.gzipSize)} gzip)`:"";Q.push(` ${j.name.padEnd(20)} ${W(j.size).padStart(12)}${F}${J}`)}if(X.chunks.length>10)Q.push(` ... and ${X.chunks.length-10} more chunks`);Q.push("");let K=Z.topModules||10;Q.push(`Largest Modules (Top ${K})`),Q.push("\u2500".repeat(50));for(let j=0;j<Math.min(K,X.largestModules.length);j++){let q=X.largestModules[j],J=$?` (${W(q.gzipSize)} gzip)`:"";Q.push(` ${(j+1).toString().padStart(2)}. ${q.path}`),Q.push(` ${W(q.size)}${J}`)}if(Q.push(""),X.duplicates.length>0){Q.push("Duplicate Modules"),Q.push("\u2500".repeat(50));for(let j of X.duplicates.slice(0,5))Q.push(` ${j.path}`),Q.push(` ${j.count} copies, wasting ${W(j.wastedBytes)}`);if(X.duplicates.length>5)Q.push(` ... and ${X.duplicates.length-5} more duplicates`);Q.push("")}if(Z.recommendations!==!1){let j=N(X,Z);if(j.recommendations.length>0){Q.push("Recommendations"),Q.push("\u2500".repeat(50));for(let q of j.recommendations.slice(0,5)){let J=q.impact==="high"?"\u26A1":q.impact==="medium"?"\uD83D\uDCCA":"\uD83D\uDCA1";Q.push(` ${J} ${q.title}`),Q.push(` ${q.description}`)}Q.push("")}}if(X.warnings.length>0){Q.push("Warnings"),Q.push("\u2500".repeat(50));for(let j of X.warnings)Q.push(` \u26A0\uFE0F ${j}`);Q.push("")}return Q.join(`
3
3
  `)}function l(X,Z){let Q=[],$=Z.showGzip!==!1;if(Q.push("# Bundle Analysis Report"),Q.push(""),Q.push(`Generated: ${new Date(X.timestamp).toISOString()}`),Q.push(""),Q.push("## Summary"),Q.push(""),Q.push("| Metric | Value |"),Q.push("|--------|-------|"),Q.push(`| Total Size | ${W(X.totalSize)} |`),$)Q.push(`| Gzip Size | ${W(X.totalGzipSize)} |`);Q.push(`| Modules | ${X.moduleCount} |`),Q.push(`| Chunks | ${X.chunks.length} |`),Q.push(`| Duplicates | ${X.duplicates.length} |`),Q.push(""),Q.push("## Size by Type"),Q.push(""),Q.push("| Type | Size | Gzip | % | Files |"),Q.push("|------|------|------|---|-------|");let U=["js","css","html","image","font","other"];for(let j of U){let q=X.byType[j];if(q.count>0)Q.push(`| ${j} | ${W(q.size)} | ${W(q.gzipSize)} | ${E(q.size,X.totalSize)} | ${q.count} |`)}Q.push(""),Q.push("## Chunks"),Q.push(""),Q.push("| Name | Size | Gzip | Modules | Type |"),Q.push("|------|------|------|---------|------|");for(let j of X.chunks.slice(0,15)){let q=j.isEntry?"Entry":j.isVendor?"Vendor":"-";Q.push(`| ${j.name} | ${W(j.size)} | ${W(j.gzipSize)} | ${j.modules.length} | ${q} |`)}Q.push("");let K=Z.topModules||10;Q.push(`## Largest Modules (Top ${K})`),Q.push(""),Q.push("| # | Path | Size | Gzip |"),Q.push("|---|------|------|------|");for(let j=0;j<Math.min(K,X.largestModules.length);j++){let q=X.largestModules[j];Q.push(`| ${j+1} | \`${q.path}\` | ${W(q.size)} | ${W(q.gzipSize)} |`)}if(Q.push(""),X.duplicates.length>0){Q.push("## Duplicates"),Q.push(""),Q.push("| Path | Copies | Wasted |"),Q.push("|------|--------|--------|");for(let j of X.duplicates.slice(0,10))Q.push(`| \`${j.path}\` | ${j.count} | ${W(j.wastedBytes)} |`);Q.push("")}if(Z.recommendations!==!1){let j=N(X,Z);if(j.recommendations.length>0){Q.push("## Recommendations"),Q.push("");for(let q of j.recommendations)Q.push(`### ${q.title}`),Q.push(""),Q.push(q.description),Q.push(""),Q.push(`- **Impact:** ${q.impact}`),Q.push(`- **Effort:** ${q.effort}`),Q.push("")}}return Q.join(`
4
4
  `)}function N(X,Z){let Q=[],$=[];if(Z.threshold&&X.totalSize>Z.threshold)Q.push({severity:"error",message:`Bundle size (${W(X.totalSize)}) exceeds threshold (${W(Z.threshold)})`});if(X.totalSize>1048576)Q.push({severity:"warning",message:`Bundle is over 1MB (${W(X.totalSize)})`,details:"Large bundles can significantly impact load time"});if(X.duplicates.length>0){let q=X.duplicates.reduce((J,F)=>J+F.wastedBytes,0);Q.push({severity:"warning",message:`${X.duplicates.length} duplicate modules found, wasting ${W(q)}`}),$.push({title:"Remove Duplicate Modules",description:"Consider using import aliases or ensuring consistent package versions to eliminate duplicates.",impact:"medium",effort:"low"})}if(X.byType.js.size/X.totalSize>0.8&&X.totalSize>512000)$.push({title:"Code Splitting",description:"Over 80% of your bundle is JavaScript. Consider splitting code by route or feature.",impact:"high",effort:"medium"});let K=X.largestModules.filter((q)=>q.size>102400);if(K.length>0){Q.push({severity:"info",message:`${K.length} modules are over 100KB`});for(let q of K){if(q.path.includes("lodash")&&!q.path.includes("lodash-es"))$.push({title:"Use lodash-es instead of lodash",description:"lodash-es supports tree-shaking and can significantly reduce bundle size.",impact:"high",effort:"low"});if(q.path.includes("moment"))$.push({title:"Replace moment.js",description:"Consider using date-fns or dayjs for smaller date handling libraries.",impact:"high",effort:"medium"})}}if(X.byType.image.size>512000)$.push({title:"Optimize Images",description:`Images account for ${W(X.byType.image.size)}. Consider using WebP/AVIF formats and responsive images.`,impact:"high",effort:"low"});let j=100;if(X.totalSize>1048576)j-=20;else if(X.totalSize>512000)j-=10;if(j-=Math.min(20,X.duplicates.length*2),j-=Math.min(15,K.length*3),Z.threshold&&X.totalSize>Z.threshold)j-=25;return{score:Math.max(0,j),issues:Q,recommendations:$}}var i={lodash:{alternative:"lodash-es or individual imports",savings:"~70%"},moment:{alternative:"date-fns or dayjs",savings:"~90%"},"chart.js":{alternative:"chart.js with tree-shaking",savings:"~50%"},"highlight.js":{alternative:"Selective language imports",savings:"~80%"},fontawesome:{alternative:"Individual icon imports",savings:"~90%"},"material-ui":{alternative:"Named imports from @mui/*",savings:"~60%"}};function n(X){for(let[Z,Q]of Object.entries(i))if(X.includes(Z))return{title:`Optimize ${Z}`,description:`Consider using ${Q.alternative}. Potential savings: ${Q.savings}`,impact:"high",effort:"low"};return null}var o={default:{js:"#f7df1e",css:"#264de4",html:"#e34c26",image:"#4caf50",font:"#9c27b0",other:"#607d8b",vendor:"#ff5722"},pastel:{js:"#fff3b0",css:"#b0d4ff",html:"#ffb0b0",image:"#b0ffb0",font:"#e0b0ff",other:"#d0d0d0",vendor:"#ffcfb0"},monochrome:{js:"#333333",css:"#555555",html:"#777777",image:"#999999",font:"#bbbbbb",other:"#dddddd",vendor:"#444444"}};function x(X,Z={}){let{title:Q="Bundle Analysis",gzip:$=!0,colorScheme:U="default"}=Z,K=o[U],j=a(X),q=JSON.stringify(j);return`<!DOCTYPE html>
5
5
  <html lang="en">
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-hyfjnn7g.js";function F(){return`<script data-stx-scoped data-stx-x-element-runtime data-stx-run="always">
2
+ import"./chunk-5g6rprcy.js";function F(){return`<script data-stx-scoped data-stx-x-element-runtime data-stx-run="always">
3
3
  (function() {
4
4
  'use strict';
5
5
 
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  import{createHash as Y}from"crypto";import{readFile as M,stat as w}from"fs/promises";async function G(q){try{let z=await M(q);return Y("sha256").update(z).digest("hex").slice(0,16)}catch{return""}}function u(q){return Y("sha256").update(q).digest("hex").slice(0,16)}function $(q){return Y("sha256").update(q).digest("hex").slice(0,16)}function X(q,z){let B=JSON.stringify(z,Object.keys(z).sort());return`${$(q)}-${$(B)}`}async function Z(q){try{return(await w(q)).mtimeMs}catch{return 0}}async function b(q){try{return await w(q),!0}catch{return!1}}import{mkdir as S,readFile as V,writeFile as E,readdir as A,rm as _,stat as j}from"fs/promises";import{join as U,dirname as x}from"path";var R=new Map,W={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500};async function F(q){try{await S(q,{recursive:!0})}catch{}}function K(q,z,B){return U(q,B,`${z}.json`)}async function v(q,z,B){if((Date.now()-q.createdAt)/86400000>B)return!1;if(await Z(z)!==q.srcMtime)return!1;return!0}async function g(q,z,B,J=W){if(!J.enabled)return null;let I=X(q,z),L=R.get(I);if(L){if(await v(L,q,J.maxAge))return L.lastAccessedAt=Date.now(),L.data;R.delete(I)}let Q=K(J.directory,I,B);if(await b(Q))try{let N=await V(Q,"utf-8"),O=JSON.parse(N);if(await v(O,q,J.maxAge))return O.lastAccessedAt=Date.now(),R.set(I,O),O.data}catch{}return null}async function l(q,z,B,J,I=W){if(!I.enabled)return;let L=X(q,z),Q=await G(q),N=await Z(q),O={key:L,src:q,srcHash:Q,srcMtime:N,optionsHash:X("",z),data:B,createdAt:Date.now(),lastAccessedAt:Date.now()};R.set(L,O);let T=K(I.directory,L,J);try{await F(x(T)),await E(T,JSON.stringify(O,null,2))}catch(H){console.warn(`[stx-media] Failed to write cache: ${H}`)}}async function m(q,z=W){if(q==="all")R.clear();else R.clear();let B=q==="all"?["image","video"]:[q];for(let J of B){let I=U(z.directory,J);try{await _(I,{recursive:!0,force:!0})}catch{}}}async function y(q=W){let z={memoryEntries:R.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let B of["image","video"]){let J=U(q.directory,B);try{let I=await A(J);z.diskEntries[B]=I.length;for(let L of I){let Q=U(J,L),N=await j(Q);z.totalSizeMB+=N.size/1048576}}catch{}}return z}async function f(q=W){let z=0,B=q.maxAge*24*60*60*1000;for(let J of["image","video"]){let I=U(q.directory,J);try{let L=await A(I);for(let Q of L){let N=U(I,Q);try{let O=await V(N,"utf-8"),T=JSON.parse(O);if(Date.now()-T.createdAt>B)await _(N),R.delete(T.key),z++}catch{await _(N).catch(()=>{}),z++}}}catch{}}return z}
3
- export{G as th,u as uh,$ as vh,X as wh,Z as xh,b as yh,g as zh,l as Ah,m as Bh,y as Ch,f as Dh};
3
+ export{G as ih,u as jh,$ as kh,X as lh,Z as mh,b as nh,g as oh,l as ph,m as qh,y as rh,f as sh};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{Gj as _}from"./chunk-t41aaehf.js";function Y(q,z){let B={};for(let C of q)B[C]=_(z(C));return new Proxy({},{get:(C,G)=>B[G]?.(),set:(C,G,L)=>{if(B[G])B[G].set(L);else B[G]=_(L);return!0},has:(C,G)=>(G in B),deleteProperty:(C,G)=>{return delete B[G],!0},ownKeys:()=>Reflect.ownKeys(B),getOwnPropertyDescriptor:(C,G)=>(G in B)?{enumerable:!0,configurable:!0,writable:!0,value:B[G]()}:void 0})}function T(q,z){let B={};for(let C of z)B[C]=q[C];return B}function $(q,z){let B=Object.keys(q),C=Y(B,(I)=>z?.[I]??q[I].getDefaultValue()),G=Y(B,()=>[]),L=Y(B,()=>!1),W=Y(B,()=>!1),X=Y(B,()=>!1),J=_(!1);async function M(I){X[I]=!0;let Q=await q[I].validate(C[I],C);return G[I]=Q,X[I]=!1,Q.length===0}async function O(){J.set(!0);let I=await Promise.all(B.map(M));return J.set(!1),I.every(Boolean)}function j(){for(let I of B)C[I]=z?.[I]??q[I].getDefaultValue(),G[I]=[],L[I]=!1,W[I]=!1}function A(I){for(let Q of B)if(Q in I)C[Q]=I[Q],W[Q]=!0}function H(I,Q){C[I]=Q,W[I]=!0}function K(I,Q=!0){if(L[I]=Q,Q)M(I)}function U(I){return{value:C[I],errors:G[I],touched:L[I],dirty:W[I],valid:G[I].length===0,validating:X[I]}}function k(I){return async(Q)=>{Q?.preventDefault?.();for(let N of B)L[N]=!0;if(await O())await I(T(C,B))}}return{values:C,errors:G,touched:L,dirty:W,get isValid(){return B.every((I)=>G[I].length===0)},get isValidating(){return J()||B.some((I)=>X[I])},get isDirty(){return B.some((I)=>W[I])},validate:O,validateField:M,reset:j,setValues:A,setFieldValue:H,setFieldTouched:K,getFieldState:U,handleSubmit:k}}var E=$;class Z{rules=[];defaultValue="";addRule(q){let z=new Z;return z.rules=[...this.rules,q],z.defaultValue=this.defaultValue,z}required(q="This field is required"){return this.addRule({name:"required",message:q,validate:(z)=>{if(z===null||z===void 0)return q;if(typeof z==="string"&&z.trim()==="")return q;if(Array.isArray(z)&&z.length===0)return q;return!0}})}email(q="Please enter a valid email"){return this.addRule({name:"email",message:q,validate:(z)=>{if(!z)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(z))||q}})}url(q="Please enter a valid URL"){return this.addRule({name:"url",message:q,validate:(z)=>{if(!z)return!0;try{return new URL(String(z)),!0}catch{return q}}})}min(q,z){let B=z||`Must be at least ${q} characters`;return this.addRule({name:"min",message:B,validate:(C)=>{if(!C)return!0;return String(C).length>=q||B}})}max(q,z){let B=z||`Must be no more than ${q} characters`;return this.addRule({name:"max",message:B,validate:(C)=>{if(!C)return!0;return String(C).length<=q||B}})}length(q,z,B){let C=B||`Must be between ${q} and ${z} characters`;return this.addRule({name:"length",message:C,validate:(G)=>{if(!G)return!0;let L=String(G).length;return L>=q&&L<=z||C}})}pattern(q,z="Invalid format"){return this.addRule({name:"pattern",message:z,validate:(B)=>{if(!B)return!0;return q.test(String(B))||z}})}hasUppercase(q="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,q)}hasLowercase(q="Must contain a lowercase letter"){return this.pattern(/[a-z]/,q)}hasNumber(q="Must contain a number"){return this.pattern(/\d/,q)}hasSpecial(q="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,q)}alphanumeric(q="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,q)}startsWithLetter(q="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,q)}noSpaces(q="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:q,validate:(z)=>{if(!z)return!0;return!String(z).includes(" ")||q}})}number(q="Must be a number"){let z=this.addRule({name:"number",message:q,validate:(B)=>{if(!B&&B!==0)return!0;return!Number.isNaN(Number(B))||q}});return z.defaultValue=0,z}integer(q="Must be a whole number"){return this.addRule({name:"integer",message:q,validate:(z)=>{if(!z&&z!==0)return!0;return Number.isInteger(Number(z))||q}})}positive(q="Must be a positive number"){return this.addRule({name:"positive",message:q,validate:(z)=>{if(!z&&z!==0)return!0;return Number(z)>0||q}})}negative(q="Must be a negative number"){return this.addRule({name:"negative",message:q,validate:(z)=>{if(!z&&z!==0)return!0;return Number(z)<0||q}})}minValue(q,z){let B=z||`Must be at least ${q}`;return this.addRule({name:"minValue",message:B,validate:(C)=>{if(!C&&C!==0)return!0;return Number(C)>=q||B}})}maxValue(q,z){let B=z||`Must be no more than ${q}`;return this.addRule({name:"maxValue",message:B,validate:(C)=>{if(!C&&C!==0)return!0;return Number(C)<=q||B}})}between(q,z,B){let C=B||`Must be between ${q} and ${z}`;return this.addRule({name:"between",message:C,validate:(G)=>{if(!G&&G!==0)return!0;let L=Number(G);return L>=q&&L<=z||C}})}matches(q,z){let B=z||`Must match ${q}`;return this.addRule({name:"matches",message:B,validate:(C,G)=>{if(!G)return!0;return C===G[q]||B}})}oneOf(q,z){let B=z||`Must be one of: ${q.join(", ")}`;return this.addRule({name:"oneOf",message:B,validate:(C)=>{if(!C)return!0;return q.includes(C)||B}})}notOneOf(q,z){let B=z||`Cannot be one of: ${q.join(", ")}`;return this.addRule({name:"notOneOf",message:B,validate:(C)=>{if(!C)return!0;return!q.includes(C)||B}})}date(q="Must be a valid date"){return this.addRule({name:"date",message:q,validate:(z)=>{if(!z)return!0;let B=new Date(String(z));return!Number.isNaN(B.getTime())||q}})}before(q,z){let B=new Date(q),C=z||`Must be before ${B.toLocaleDateString()}`;return this.addRule({name:"before",message:C,validate:(G)=>{if(!G)return!0;return new Date(String(G))<B||C}})}after(q,z){let B=new Date(q),C=z||`Must be after ${B.toLocaleDateString()}`;return this.addRule({name:"after",message:C,validate:(G)=>{if(!G)return!0;return new Date(String(G))>B||C}})}custom(q,z="Invalid value"){return this.addRule({name:"custom",message:z,validate:q})}async(q,z="Invalid value"){return this.addRule({name:"async",message:z,async:!0,validate:q})}when(q,z){let B=new Z;B.rules=[...this.rules],B.defaultValue=this.defaultValue;for(let C of z.getRules())B.rules.push({...C,validate:(G,L)=>{if(!q(G,L||{}))return!0;return C.validate(G,L)}});return B}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(q){let z=new Z;return z.rules=[...this.rules],z.defaultValue=q,z}async validate(q,z){let B=[];for(let C of this.rules){let G=await C.validate(q,z);if(G!==!0)B.push(G)}return B}validateSync(q,z){let B=[];for(let C of this.rules){if(C.async)continue;let G=C.validate(q,z);if(G!==!0)B.push(G)}return B}}var y=new Z;function w(q,z,B){let C=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return q.replace(C,(G,L,W)=>{try{let X=L.trim().split("."),J=z;for(let O of X)if(J&&typeof J==="object"&&O in J)J=J[O];else return"";let M=J;if(!M||!Array.isArray(M)||M.length===0)return"";return M.map((O)=>{return W.replace(/\{\{\s*message\s*\}\}/g,O)}).join(`
2
+ import{vj as _}from"./chunk-e4g8wz6t.js";function Y(q,z){let B={};for(let C of q)B[C]=_(z(C));return new Proxy({},{get:(C,G)=>B[G]?.(),set:(C,G,L)=>{if(B[G])B[G].set(L);else B[G]=_(L);return!0},has:(C,G)=>(G in B),deleteProperty:(C,G)=>{return delete B[G],!0},ownKeys:()=>Reflect.ownKeys(B),getOwnPropertyDescriptor:(C,G)=>(G in B)?{enumerable:!0,configurable:!0,writable:!0,value:B[G]()}:void 0})}function T(q,z){let B={};for(let C of z)B[C]=q[C];return B}function $(q,z){let B=Object.keys(q),C=Y(B,(I)=>z?.[I]??q[I].getDefaultValue()),G=Y(B,()=>[]),L=Y(B,()=>!1),W=Y(B,()=>!1),X=Y(B,()=>!1),J=_(!1);async function M(I){X[I]=!0;let Q=await q[I].validate(C[I],C);return G[I]=Q,X[I]=!1,Q.length===0}async function O(){J.set(!0);let I=await Promise.all(B.map(M));return J.set(!1),I.every(Boolean)}function j(){for(let I of B)C[I]=z?.[I]??q[I].getDefaultValue(),G[I]=[],L[I]=!1,W[I]=!1}function A(I){for(let Q of B)if(Q in I)C[Q]=I[Q],W[Q]=!0}function H(I,Q){C[I]=Q,W[I]=!0}function K(I,Q=!0){if(L[I]=Q,Q)M(I)}function U(I){return{value:C[I],errors:G[I],touched:L[I],dirty:W[I],valid:G[I].length===0,validating:X[I]}}function k(I){return async(Q)=>{Q?.preventDefault?.();for(let N of B)L[N]=!0;if(await O())await I(T(C,B))}}return{values:C,errors:G,touched:L,dirty:W,get isValid(){return B.every((I)=>G[I].length===0)},get isValidating(){return J()||B.some((I)=>X[I])},get isDirty(){return B.some((I)=>W[I])},validate:O,validateField:M,reset:j,setValues:A,setFieldValue:H,setFieldTouched:K,getFieldState:U,handleSubmit:k}}var E=$;class Z{rules=[];defaultValue="";addRule(q){let z=new Z;return z.rules=[...this.rules,q],z.defaultValue=this.defaultValue,z}required(q="This field is required"){return this.addRule({name:"required",message:q,validate:(z)=>{if(z===null||z===void 0)return q;if(typeof z==="string"&&z.trim()==="")return q;if(Array.isArray(z)&&z.length===0)return q;return!0}})}email(q="Please enter a valid email"){return this.addRule({name:"email",message:q,validate:(z)=>{if(!z)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(z))||q}})}url(q="Please enter a valid URL"){return this.addRule({name:"url",message:q,validate:(z)=>{if(!z)return!0;try{return new URL(String(z)),!0}catch{return q}}})}min(q,z){let B=z||`Must be at least ${q} characters`;return this.addRule({name:"min",message:B,validate:(C)=>{if(!C)return!0;return String(C).length>=q||B}})}max(q,z){let B=z||`Must be no more than ${q} characters`;return this.addRule({name:"max",message:B,validate:(C)=>{if(!C)return!0;return String(C).length<=q||B}})}length(q,z,B){let C=B||`Must be between ${q} and ${z} characters`;return this.addRule({name:"length",message:C,validate:(G)=>{if(!G)return!0;let L=String(G).length;return L>=q&&L<=z||C}})}pattern(q,z="Invalid format"){return this.addRule({name:"pattern",message:z,validate:(B)=>{if(!B)return!0;return q.test(String(B))||z}})}hasUppercase(q="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,q)}hasLowercase(q="Must contain a lowercase letter"){return this.pattern(/[a-z]/,q)}hasNumber(q="Must contain a number"){return this.pattern(/\d/,q)}hasSpecial(q="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,q)}alphanumeric(q="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,q)}startsWithLetter(q="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,q)}noSpaces(q="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:q,validate:(z)=>{if(!z)return!0;return!String(z).includes(" ")||q}})}number(q="Must be a number"){let z=this.addRule({name:"number",message:q,validate:(B)=>{if(!B&&B!==0)return!0;return!Number.isNaN(Number(B))||q}});return z.defaultValue=0,z}integer(q="Must be a whole number"){return this.addRule({name:"integer",message:q,validate:(z)=>{if(!z&&z!==0)return!0;return Number.isInteger(Number(z))||q}})}positive(q="Must be a positive number"){return this.addRule({name:"positive",message:q,validate:(z)=>{if(!z&&z!==0)return!0;return Number(z)>0||q}})}negative(q="Must be a negative number"){return this.addRule({name:"negative",message:q,validate:(z)=>{if(!z&&z!==0)return!0;return Number(z)<0||q}})}minValue(q,z){let B=z||`Must be at least ${q}`;return this.addRule({name:"minValue",message:B,validate:(C)=>{if(!C&&C!==0)return!0;return Number(C)>=q||B}})}maxValue(q,z){let B=z||`Must be no more than ${q}`;return this.addRule({name:"maxValue",message:B,validate:(C)=>{if(!C&&C!==0)return!0;return Number(C)<=q||B}})}between(q,z,B){let C=B||`Must be between ${q} and ${z}`;return this.addRule({name:"between",message:C,validate:(G)=>{if(!G&&G!==0)return!0;let L=Number(G);return L>=q&&L<=z||C}})}matches(q,z){let B=z||`Must match ${q}`;return this.addRule({name:"matches",message:B,validate:(C,G)=>{if(!G)return!0;return C===G[q]||B}})}oneOf(q,z){let B=z||`Must be one of: ${q.join(", ")}`;return this.addRule({name:"oneOf",message:B,validate:(C)=>{if(!C)return!0;return q.includes(C)||B}})}notOneOf(q,z){let B=z||`Cannot be one of: ${q.join(", ")}`;return this.addRule({name:"notOneOf",message:B,validate:(C)=>{if(!C)return!0;return!q.includes(C)||B}})}date(q="Must be a valid date"){return this.addRule({name:"date",message:q,validate:(z)=>{if(!z)return!0;let B=new Date(String(z));return!Number.isNaN(B.getTime())||q}})}before(q,z){let B=new Date(q),C=z||`Must be before ${B.toLocaleDateString()}`;return this.addRule({name:"before",message:C,validate:(G)=>{if(!G)return!0;return new Date(String(G))<B||C}})}after(q,z){let B=new Date(q),C=z||`Must be after ${B.toLocaleDateString()}`;return this.addRule({name:"after",message:C,validate:(G)=>{if(!G)return!0;return new Date(String(G))>B||C}})}custom(q,z="Invalid value"){return this.addRule({name:"custom",message:z,validate:q})}async(q,z="Invalid value"){return this.addRule({name:"async",message:z,async:!0,validate:q})}when(q,z){let B=new Z;B.rules=[...this.rules],B.defaultValue=this.defaultValue;for(let C of z.getRules())B.rules.push({...C,validate:(G,L)=>{if(!q(G,L||{}))return!0;return C.validate(G,L)}});return B}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default(q){let z=new Z;return z.rules=[...this.rules],z.defaultValue=q,z}async validate(q,z){let B=[];for(let C of this.rules){let G=await C.validate(q,z);if(G!==!0)B.push(G)}return B}validateSync(q,z){let B=[];for(let C of this.rules){if(C.async)continue;let G=C.validate(q,z);if(G!==!0)B.push(G)}return B}}var y=new Z;function w(q,z,B){let C=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return q.replace(C,(G,L,W)=>{try{let X=L.trim().split("."),J=z;for(let O of X)if(J&&typeof J==="object"&&O in J)J=J[O];else return"";let M=J;if(!M||!Array.isArray(M)||M.length===0)return"";return M.map((O)=>{return W.replace(/\{\{\s*message\s*\}\}/g,O)}).join(`
3
3
  `)}catch{return""}})}function D(q,z,B){let C=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return q.replace(C,(G,L,W)=>{try{let X=L.trim().split("."),J=z;for(let O of X)if(J&&typeof J==="object"&&O in J)J=J[O];else return"";let M=J;if(!M||!Array.isArray(M)||M.length===0)return"";return M.map((O)=>W.replace(/\{\{\s*message\s*\}\}/g,O)).join(`
4
- `)}catch{return""}})}function S(q,z,B){let C=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return q.replace(C,(G,L,W)=>{try{let X=L.trim().split("."),J=z;for(let O of X)if(J&&typeof J==="object"&&O in J)J=J[O];else return"";let M=J;if(!M||!Array.isArray(M)||M.length===0)return"";return W}catch{return""}})}function V(q,z,B){let C=q;return C=w(C,z,B),C=D(C,z,B),C=S(C,z,B),C}export{$ as $h,E as ai,Z as bi,y as ci,w as di,D as ei,S as fi,V as gi};
4
+ `)}catch{return""}})}function S(q,z,B){let C=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return q.replace(C,(G,L,W)=>{try{let X=L.trim().split("."),J=z;for(let O of X)if(J&&typeof J==="object"&&O in J)J=J[O];else return"";let M=J;if(!M||!Array.isArray(M)||M.length===0)return"";return W}catch{return""}})}function V(q,z,B){let C=q;return C=w(C,z,B),C=D(C,z,B),C=S(C,z,B),C}export{$ as Xh,E as Yh,Z as Zh,y as _h,w as $h,D as ai,S as bi,V as ci};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Hi as a,Ii as b}from"./chunk-mnyehz4t.js";import"./chunk-7we3xfde.js";import"./chunk-ypzm47q3.js";import"./chunk-1yj4xd6n.js";import"./chunk-e3rgky2r.js";import"./chunk-d7zxg9bp.js";import"./chunk-t00ga194.js";import"./chunk-hrdd26r4.js";import"./chunk-7r79j1hs.js";import"./chunk-ay336sqb.js";import"./chunk-nhbc464j.js";import"./chunk-vaggjvsm.js";import"./chunk-q9ckfwhh.js";import"./chunk-kermxyfe.js";import"./chunk-k3dtvay1.js";import"./chunk-aved735s.js";import"./chunk-799s9mwc.js";import"./chunk-7r80apc5.js";import"./chunk-2tjk867y.js";import"./chunk-t8ctvjqe.js";import"./chunk-deqnt1w5.js";import"./chunk-w0hzaka3.js";import"./chunk-wb90259a.js";import"./chunk-5g6rprcy.js";export{a as getStoreScript,b as clearStoreCache};
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import{su as x}from"./chunk-r8rbf28v.js";import{Cu as A}from"./chunk-gptwwv3c.js";import{Gu as T,Ku as q}from"./chunk-vvd659y4.js";import{Dv as C,iw as y}from"./chunk-hzfd8cz0.js";import{sw as P}from"./chunk-hyfjnn7g.js";y();import H from"fs";import $ from"path";import{pathToFileURL as b}from"url";var R=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],O=new Set;function N(J,Y={}){let K=$.resolve(J,Y.dir??"server/api"),Q=[],Z=new Map;if(!H.existsSync(K))return Q;let B=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:K})).sort();for(let z of B){if(z.endsWith(".d.ts"))continue;let W=z.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),I=W.pop(),X=I.lastIndexOf("."),_=X>=0?I.slice(X+1):"get",F=_.toUpperCase();if(!R.includes(F)||_!==_.toLowerCase())throw Error(`Unsupported API method suffix in ${z}; use ${R.map((k)=>k.toLowerCase()).join(", ")}`);if(X>=0)I=I.slice(0,X);if(I!=="index")W.push(I);let G=new Set,j=W.map((k,S)=>{let E=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(k);if(E){if(G.has(E[2])||E[1]&&S!==W.length-1)throw Error(`Invalid API parameter in ${z}`);return G.add(E[2]),`:${E[2]}${E[1]?"*":""}`}if(!/^[\w-]+$/.test(k))throw Error(`Unsupported API path segment ${k} in ${z}`);return k}),U=`/api${j.length?`/${j.join("/")}`:""}`,L=`${F} ${U.replace(/:\w+/g,":param")}`;if(Z.has(L))throw Error(`Ambiguous API route ${F} ${U}: ${Z.get(L)} and ${z}`);Z.set(L,z);let M=$.join(K,z);O.add($.resolve(M)),O.add(H.realpathSync(M)),Q.push({pattern:U,method:F,filePath:M})}return Q.sort((z,V)=>{let W=z.pattern.split("/"),I=V.pattern.split("/"),X=(_)=>_?.endsWith("*")?0:_?.startsWith(":")?1:2;for(let _=0;_<Math.max(W.length,I.length);_++){let F=X(I[_])-X(W[_]);if(F)return F}return z.pattern.localeCompare(V.pattern)||z.method.localeCompare(V.method)})}async function w(J,Y){let K=A(J,"api-types.d.ts"),Q=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let B of Y){let z=`./${$.relative($.dirname(K),B.filePath).replace(/\\/g,"/")}`,{params:V}=C(B.pattern);Q.push(` ${JSON.stringify(`${B.method} ${B.pattern}`)}: { params: { ${V.map((W)=>`${JSON.stringify(W)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(z)}).default>> }`)}Q.push(" }","}","export {}","");let Z=Q.join(`
2
+ import{ms as x}from"./chunk-7r79j1hs.js";import{mt as A}from"./chunk-vaggjvsm.js";import{Ct as T,Gt as q}from"./chunk-k3dtvay1.js";import{Dv as C,jw as y}from"./chunk-w0hzaka3.js";import{tw as P}from"./chunk-5g6rprcy.js";y();import H from"fs";import $ from"path";import{pathToFileURL as b}from"url";var R=["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"],O=new Set;function N(J,Y={}){let K=$.resolve(J,Y.dir??"server/api"),Q=[],Z=new Map;if(!H.existsSync(K))return Q;let B=Array.from(new Bun.Glob("**/*.{ts,js,mts,mjs}").scanSync({cwd:K})).sort();for(let z of B){if(z.endsWith(".d.ts"))continue;let W=z.replace(/\.(?:ts|js|mts|mjs)$/,"").split("/"),I=W.pop(),X=I.lastIndexOf("."),_=X>=0?I.slice(X+1):"get",F=_.toUpperCase();if(!R.includes(F)||_!==_.toLowerCase())throw Error(`Unsupported API method suffix in ${z}; use ${R.map((k)=>k.toLowerCase()).join(", ")}`);if(X>=0)I=I.slice(0,X);if(I!=="index")W.push(I);let G=new Set,j=W.map((k,S)=>{let E=/^\[(\.\.\.)?([A-Za-z_]\w*)\]$/.exec(k);if(E){if(G.has(E[2])||E[1]&&S!==W.length-1)throw Error(`Invalid API parameter in ${z}`);return G.add(E[2]),`:${E[2]}${E[1]?"*":""}`}if(!/^[\w-]+$/.test(k))throw Error(`Unsupported API path segment ${k} in ${z}`);return k}),U=`/api${j.length?`/${j.join("/")}`:""}`,L=`${F} ${U.replace(/:\w+/g,":param")}`;if(Z.has(L))throw Error(`Ambiguous API route ${F} ${U}: ${Z.get(L)} and ${z}`);Z.set(L,z);let M=$.join(K,z);O.add($.resolve(M)),O.add(H.realpathSync(M)),Q.push({pattern:U,method:F,filePath:M})}return Q.sort((z,V)=>{let W=z.pattern.split("/"),I=V.pattern.split("/"),X=(_)=>_?.endsWith("*")?0:_?.startsWith(":")?1:2;for(let _=0;_<Math.max(W.length,I.length);_++){let F=X(I[_])-X(W[_]);if(F)return F}return z.pattern.localeCompare(V.pattern)||z.method.localeCompare(V.method)})}async function w(J,Y){let K=A(J,"api-types.d.ts"),Q=["// Generated by stx. Include this file in tsconfig.json.","declare module '@stacksjs/stx/api-client' {"," interface KnownApiRoutes {"];for(let B of Y){let z=`./${$.relative($.dirname(K),B.filePath).replace(/\\/g,"/")}`,{params:V}=C(B.pattern);Q.push(` ${JSON.stringify(`${B.method} ${B.pattern}`)}: { params: { ${V.map((W)=>`${JSON.stringify(W)}: string`).join("; ")} }; response: Awaited<ReturnType<typeof import(${JSON.stringify(z)}).default>> }`)}Q.push(" }","}","export {}","");let Z=Q.join(`
3
3
  `);if(!await Bun.file(K).exists()||await Bun.file(K).text()!==Z)await Bun.write(K,Z);return K}async function p(J,Y,K={}){let Q=N(J,K);await w(J,Q);let Z=[];for(let B of Q){let z=await Bun.build({entrypoints:[B.filePath],target:"bun",format:"esm",minify:!1,splitting:!1});if(!z.success)throw Error(`API build failed for ${B.filePath}: ${z.logs.join(`
4
- `)}`);let V=z.outputs.find((X)=>X.kind==="entry-point");if(!V)throw Error(`No API bundle for ${B.filePath}`);if(z.outputs.length!==1)throw Error(`API endpoint ${B.filePath} emits assets; package those explicitly instead`);let I=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await V.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write($.join(Y,I),V),Z.push({...B,filePath:I})}return Z}function D(J,Y){let K=J.map((Q)=>({route:Q,...C(Q.pattern)}));return async(Q)=>{let Z=new URL(Q.url).pathname,B=K.filter((G)=>G.regex.test(Z));if(!B.length)return null;let z=B[0].route.pattern,V=(G)=>G.replace(/:\w+/g,":param"),W=B.filter((G)=>V(G.route.pattern)===V(z)),I=Q.method,X=W.find((G)=>G.route.method===I)??(I==="HEAD"?W.find((G)=>G.route.method==="GET"):void 0);if(!X){let G=new Set(W.map((j)=>j.route.method));if(G.has("GET"))G.add("HEAD");return G.add("OPTIONS"),new Response(null,{status:I==="OPTIONS"?204:405,headers:{Allow:Array.from(G).sort().join(", ")}})}let _=X.regex.exec(Z),F=Object.create(null);try{X.params.forEach((G,j)=>{F[G]=decodeURIComponent(_[j+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let G=await Y(X.route);if(typeof G!=="function")throw Error(`API endpoint ${X.route.filePath} must default-export a handler`);let j=await G(Q,{params:F}),U=j instanceof Response?j:j===void 0?new Response(null,{status:204}):Response.json(j);if(I==="HEAD")return new Response(null,{status:U.status,headers:U.headers});return U}catch(G){return console.error(`[stx] API error for ${I} ${z}:`,G),Response.json({error:"Internal Server Error"},{status:500})}}}function l(J,Y){return D(Y,async(K)=>(await import(b($.resolve(J,K.filePath)).href)).default)}async function s(J,Y){if(!Y)return async()=>null;let K=Y===!0?{}:Y,Q=N(J,K);return await w(J,Q),async(Z)=>{if(!new URL(Z.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let B=N(J,K);await w(J,B);let{loadStxConfig:z}=await import("./chunk-ssd10kje.js"),V=q((await z(J)).runtimeConfig);return await T(V,()=>D(B,async(W)=>{let I=await Bun.build({entrypoints:[W.filePath],target:"bun",format:"esm",splitting:!1});if(!I.success)throw Error(I.logs.join(`
4
+ `)}`);let V=z.outputs.find((X)=>X.kind==="entry-point");if(!V)throw Error(`No API bundle for ${B.filePath}`);if(z.outputs.length!==1)throw Error(`API endpoint ${B.filePath} emits assets; package those explicitly instead`);let I=`server/api/endpoint-${new Bun.CryptoHasher("sha256").update(await V.arrayBuffer()).digest("hex").slice(0,20)}.mjs`;await Bun.write($.join(Y,I),V),Z.push({...B,filePath:I})}return Z}function D(J,Y){let K=J.map((Q)=>({route:Q,...C(Q.pattern)}));return async(Q)=>{let Z=new URL(Q.url).pathname,B=K.filter((G)=>G.regex.test(Z));if(!B.length)return null;let z=B[0].route.pattern,V=(G)=>G.replace(/:\w+/g,":param"),W=B.filter((G)=>V(G.route.pattern)===V(z)),I=Q.method,X=W.find((G)=>G.route.method===I)??(I==="HEAD"?W.find((G)=>G.route.method==="GET"):void 0);if(!X){let G=new Set(W.map((j)=>j.route.method));if(G.has("GET"))G.add("HEAD");return G.add("OPTIONS"),new Response(null,{status:I==="OPTIONS"?204:405,headers:{Allow:Array.from(G).sort().join(", ")}})}let _=X.regex.exec(Z),F=Object.create(null);try{X.params.forEach((G,j)=>{F[G]=decodeURIComponent(_[j+1])})}catch{return new Response("Invalid URL parameter encoding",{status:400})}try{let G=await Y(X.route);if(typeof G!=="function")throw Error(`API endpoint ${X.route.filePath} must default-export a handler`);let j=await G(Q,{params:F}),U=j instanceof Response?j:j===void 0?new Response(null,{status:204}):Response.json(j);if(I==="HEAD")return new Response(null,{status:U.status,headers:U.headers});return U}catch(G){return console.error(`[stx] API error for ${I} ${z}:`,G),Response.json({error:"Internal Server Error"},{status:500})}}}function l(J,Y){return D(Y,async(K)=>(await import(b($.resolve(J,K.filePath)).href)).default)}async function s(J,Y){if(!Y)return async()=>null;let K=Y===!0?{}:Y,Q=N(J,K);return await w(J,Q),async(Z)=>{if(!new URL(Z.url).pathname.match(/^\/api(?:\/|$)/))return null;try{let B=N(J,K);await w(J,B);let{loadStxConfig:z}=await import("./chunk-7d74am4w.js"),V=q((await z(J)).runtimeConfig);return await T(V,()=>D(B,async(W)=>{let I=await Bun.build({entrypoints:[W.filePath],target:"bun",format:"esm",splitting:!1});if(!I.success)throw Error(I.logs.join(`
5
5
  `));let X=I.outputs.find((_)=>_.kind==="entry-point");if(!X||I.outputs.length!==1)throw Error(`Unsupported API bundle output: ${W.filePath}`);return(await import(`data:text/javascript;base64,${Buffer.from(await X.text()).toString("base64")}`)).default})(Z))}catch(B){return console.error("[stx] API discovery failed:",B),Response.json({error:"API discovery failed; check the server log"},{status:500})}}}function u(J,Y,K){if(x(J))return!0;let Q=/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/;if(Q.test($.basename(J)))return!0;try{if(Q.test($.basename(H.realpathSync(J))))return!0}catch{}if(O.has($.resolve(J)))return!0;if(!K)return!1;let Z=$.resolve(Y,typeof K==="object"?K.dir??"server/api":"server/api"),B=(V)=>{try{return H.realpathSync(V)}catch{return $.resolve(V)}},z=B(J);return[Z,$.resolve(Y,"server"),$.resolve(Y,".output/server")].some((V)=>{let W=B(V);return z===W||z.startsWith(`${W}${$.sep}`)})}
6
- export{N as wl,w as xl,p as yl,D as zl,l as Al,s as Bl,u as Cl};
6
+ export{N as ll,w as ml,p as nl,D as ol,l as pl,s as ql,u as rl};
@@ -81,4 +81,4 @@ else {
81
81
  </div>
82
82
  ${U}
83
83
  `})}
84
- export{_ as ii};
84
+ export{_ as hi};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Jg as a,Kg as b,Lg as c,Mg as d,Ng as e,Og as f,Pg as g,Qg as h,Rg as i,Sg as j,Tg as k,Ug as l}from"./chunk-xz3evxqp.js";import"./chunk-hyfjnn7g.js";export{g as toUsers,f as toUser,c as stopBroadcasting,b as startBroadcasting,d as loadChannels,a as getBroadcastServer,j as channel,h as broadcastPrivate,i as broadcastPresence,e as broadcast,l as BroadcastServer,k as Broadcast};
2
+ import{Ag as c,Bg as d,Cg as e,Dg as f,Eg as g,Fg as h,Gg as i,Hg as j,Ig as k,Jg as l,yg as a,zg as b}from"./chunk-8bxtvsgm.js";import"./chunk-5g6rprcy.js";export{g as toUsers,f as toUser,c as stopBroadcasting,b as startBroadcasting,d as loadChannels,a as getBroadcastServer,j as channel,h as broadcastPrivate,i as broadcastPresence,e as broadcast,l as BroadcastServer,k as Broadcast};
@@ -1,5 +1,5 @@
1
1
  // @bun
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`
2
+ import{tw as y}from"./chunk-5g6rprcy.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{Hg as I}from"./chunk-dvvx1wny.js";import{Dr as H}from"./chunk-kxtqbrfr.js";import{sw as G}from"./chunk-hyfjnn7g.js";import L from"path";async function Q(k={}){let J=performance.now(),A=k.root||process.cwd(),j=await H(A),B=k.ssr?.routeRules??j.routeRules??{};if(I(B),!j.ssr&&Object.keys(B).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!j.ssr&&(k.ssr?.serverApi??j.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let q=j.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${q.toUpperCase()}${j.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let D,E;if(q==="ssg"){let{generateStaticSite:z}=await import("./ssg.js");D=await z({pagesDir:L.join(j.root||".",j.pagesDir||j.build?.pagesDir||"pages"),publicDir:j.publicDir||j.build?.publicDir||"public",outputDir:j.build?.outputDir||"dist",generate404:j.build?.generate404??!0,minify:j.build?.minify??!0,cleanOutput:j.build?.cleanOutput??!0,router:j.router,...k.ssg})}else{let{buildForProduction:z}=await import("./chunk-yvec3f1c.js");E=await z({root:A,outputDir:".output",debug:k.debug,...k.ssr})}let K=Math.round(performance.now()-J);return{mode:q,ssg:D,ssr:E,duration:K}}
2
+ import{wg as I}from"./chunk-57atgbyq.js";import{rr as H}from"./chunk-e3rgky2r.js";import{tw as G}from"./chunk-5g6rprcy.js";import L from"path";async function Q(k={}){let J=performance.now(),A=k.root||process.cwd(),j=await H(A),B=k.ssr?.routeRules??j.routeRules??{};if(I(B),!j.ssr&&Object.keys(B).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!j.ssr&&(k.ssr?.serverApi??j.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let q=j.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${q.toUpperCase()}${j.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let D,E;if(q==="ssg"){let{generateStaticSite:z}=await import("./ssg.js");D=await z({pagesDir:L.join(j.root||".",j.pagesDir||j.build?.pagesDir||"pages"),publicDir:j.publicDir||j.build?.publicDir||"public",outputDir:j.build?.outputDir||"dist",generate404:j.build?.generate404??!0,minify:j.build?.minify??!0,cleanOutput:j.build?.cleanOutput??!0,router:j.router,...k.ssg})}else{let{buildForProduction:z}=await import("./chunk-zt4pf776.js");E=await z({root:A,outputDir:".output",debug:k.debug,...k.ssr})}let K=Math.round(performance.now()-J);return{mode:q,ssg:D,ssr:E,duration:K}}
3
3
  export{Q as Ue};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{pw as W,qw as k,rw as G}from"./chunk-hyfjnn7g.js";import A from"fs";import B from"path";function h(j){let q=0;for(let K=0;K<j.length;K++){let Q=j[K];q=(q<<5)-q+Q,q=q&q}return Math.abs(q).toString(16).padStart(8,"0")}function u(j,q){let K=B.basename(j);for(let Q of q)if(Q.startsWith("*.")){let Y=Q.slice(1);if(K.endsWith(Y))return!0}else if(Q.includes("*")){let Y=new RegExp(`^${Q.replace(/\*/g,".*")}$`);if(Y.test(K)||Y.test(j))return!0}else if(K===Q||j.includes(Q))return!0;return!1}function f(j,q,K){let Q=B.extname(j).toLowerCase(),Y=l[Q],X=(K.maxFileSizeKB||500)*1024;if(q>X)return!1;if(K.exclude&&u(j,K.exclude))return!1;if(K.include&&K.include.length>0){for(let Z of K.include)if(Z.startsWith("*.")){if(j.endsWith(Z.slice(1)))return!0}else if(j.includes(Z))return!0}if(Y&&K[Y]===!0)return!0;if(!Y)return!1;return!1}function T(j,q,K,Q){let Y=A.readdirSync(j,{withFileTypes:!0});for(let X of Y){let Z=B.join(j,X.name);if(X.isDirectory()){if(["node_modules",".git",".stx"].includes(X.name))continue;T(Z,q,K,Q)}else if(X.isFile()){let O=A.statSync(Z),_=B.relative(q,Z);if(f(_,O.size,K)){let $=A.readFileSync(Z),L=h($),V=`/${_.replace(/\\/g,"/")}`;Q.push({url:V,revision:L,size:O.size})}}}}function U(j,q){let K=q.pwa?.precache,Q=[];if(!K?.enabled)return{entries:[],totalSize:0,fileCount:0};if(!A.existsSync(j))return{entries:[],totalSize:0,fileCount:0};T(j,j,K,Q),Q.sort((X,Z)=>X.url.localeCompare(Z.url));let Y=Q.reduce((X,Z)=>X+Z.size,0);return{entries:Q,totalSize:Y,fileCount:Q.length}}function J(j){if(j.entries.length===0)return"[]";return`[
2
+ import{qw as W,rw as k,sw as G}from"./chunk-5g6rprcy.js";import A from"fs";import B from"path";function h(j){let q=0;for(let K=0;K<j.length;K++){let Q=j[K];q=(q<<5)-q+Q,q=q&q}return Math.abs(q).toString(16).padStart(8,"0")}function u(j,q){let K=B.basename(j);for(let Q of q)if(Q.startsWith("*.")){let Y=Q.slice(1);if(K.endsWith(Y))return!0}else if(Q.includes("*")){let Y=new RegExp(`^${Q.replace(/\*/g,".*")}$`);if(Y.test(K)||Y.test(j))return!0}else if(K===Q||j.includes(Q))return!0;return!1}function f(j,q,K){let Q=B.extname(j).toLowerCase(),Y=l[Q],X=(K.maxFileSizeKB||500)*1024;if(q>X)return!1;if(K.exclude&&u(j,K.exclude))return!1;if(K.include&&K.include.length>0){for(let Z of K.include)if(Z.startsWith("*.")){if(j.endsWith(Z.slice(1)))return!0}else if(j.includes(Z))return!0}if(Y&&K[Y]===!0)return!0;if(!Y)return!1;return!1}function T(j,q,K,Q){let Y=A.readdirSync(j,{withFileTypes:!0});for(let X of Y){let Z=B.join(j,X.name);if(X.isDirectory()){if(["node_modules",".git",".stx"].includes(X.name))continue;T(Z,q,K,Q)}else if(X.isFile()){let O=A.statSync(Z),_=B.relative(q,Z);if(f(_,O.size,K)){let $=A.readFileSync(Z),L=h($),V=`/${_.replace(/\\/g,"/")}`;Q.push({url:V,revision:L,size:O.size})}}}}function U(j,q){let K=q.pwa?.precache,Q=[];if(!K?.enabled)return{entries:[],totalSize:0,fileCount:0};if(!A.existsSync(j))return{entries:[],totalSize:0,fileCount:0};T(j,j,K,Q),Q.sort((X,Z)=>X.url.localeCompare(Z.url));let Y=Q.reduce((X,Z)=>X+Z.size,0);return{entries:Q,totalSize:Y,fileCount:Q.length}}function J(j){if(j.entries.length===0)return"[]";return`[
3
3
  ${j.entries.map((K)=>` { url: '${K.url}', revision: '${K.revision}' }`).join(`,
4
4
  `)}
5
5
  ]`}function E(j){if(j<1024)return`${j} B`;if(j<1048576)return`${(j/1024).toFixed(1)} KB`;return`${(j/1048576).toFixed(2)} MB`}var l;var F=G(()=>{l={".html":"includeHtml",".htm":"includeHtml",".js":"includeJs",".mjs":"includeJs",".css":"includeCss",".png":"includeImages",".jpg":"includeImages",".jpeg":"includeImages",".gif":"includeImages",".webp":"includeImages",".svg":"includeImages",".ico":"includeImages",".woff":"includeFonts",".woff2":"includeFonts",".ttf":"includeFonts",".eot":"includeFonts",".otf":"includeFonts"}});function g(j){let q={"cache-first":{className:"CacheFirst",importFrom:"workbox-strategies"},"network-first":{className:"NetworkFirst",importFrom:"workbox-strategies"},"stale-while-revalidate":{className:"StaleWhileRevalidate",importFrom:"workbox-strategies"},"network-only":{className:"NetworkOnly",importFrom:"workbox-strategies"},"cache-only":{className:"CacheOnly",importFrom:"workbox-strategies"}};return q[j]||q["network-first"]}function R(j){return g(j).className}function M(j){let q=j.pwa;if(!q?.enabled)return"";let K=q.routes||[],Q=q.cacheStorage,Y=[];for(let X of K){let Z=R(X.strategy),O=[];if(X.maxAgeSeconds||X.maxEntries||Q?.maxEntries){let $=X.maxEntries||Q?.maxEntries||100,L=X.maxAgeSeconds||(Q?.maxAge?Q.maxAge*24*60*60:void 0);O.push(`new ExpirationPlugin({
@@ -1191,4 +1191,4 @@ if ('serviceWorker' in navigator) {
1191
1191
  });
1192
1192
  }
1193
1193
  </script>`}function Vj(){return'<link rel="manifest" href="/manifest.json">'}function Aj(j){return`<meta name="theme-color" content="${N(j)}">`}function N(j){return j.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}
1194
- export{U as Uk,J as Vk,E as Wk,F as Xk,w as Yk,z as Zk,y as _k,qj as $k,H as al,I as bl,Lj as cl,Uj as dl,Vj as el,Aj as fl};
1194
+ export{U as Jk,J as Kk,E as Lk,F as Mk,w as Nk,z as Ok,y as Pk,qj as Qk,H as Rk,I as Sk,Lj as Tk,Uj as Uk,Vj as Vk,Aj as Wk};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{jk as a,kk as b,lk as c,mk as d}from"./chunk-9jc2z17q.js";import"./chunk-vm5jbgb1.js";import"./chunk-e3rgky2r.js";import"./chunk-d7zxg9bp.js";import"./chunk-t00ga194.js";import"./chunk-hrdd26r4.js";import"./chunk-7r79j1hs.js";import"./chunk-ay336sqb.js";import"./chunk-nhbc464j.js";import"./chunk-vaggjvsm.js";import"./chunk-q9ckfwhh.js";import"./chunk-kermxyfe.js";import"./chunk-k3dtvay1.js";import"./chunk-aved735s.js";import"./chunk-799s9mwc.js";import"./chunk-7r80apc5.js";import"./chunk-2tjk867y.js";import"./chunk-t8ctvjqe.js";import"./chunk-deqnt1w5.js";import"./chunk-w0hzaka3.js";import"./chunk-wb90259a.js";import"./chunk-5g6rprcy.js";export{b as getAvailableTargets,c as getAvailableFormats,d as default,a as buildNative};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{No as a,Oo as b,Po as c}from"./chunk-e3rgky2r.js";import"./chunk-d7zxg9bp.js";import"./chunk-t00ga194.js";import"./chunk-hrdd26r4.js";import"./chunk-7r79j1hs.js";import"./chunk-ay336sqb.js";import"./chunk-nhbc464j.js";import"./chunk-vaggjvsm.js";import"./chunk-q9ckfwhh.js";import"./chunk-kermxyfe.js";import"./chunk-k3dtvay1.js";import"./chunk-aved735s.js";import"./chunk-799s9mwc.js";import"./chunk-7r80apc5.js";import"./chunk-2tjk867y.js";import"./chunk-t8ctvjqe.js";import"./chunk-deqnt1w5.js";import"./chunk-w0hzaka3.js";import"./chunk-wb90259a.js";import"./chunk-5g6rprcy.js";export{b as reportDeferredLoopWarnings,c as processLoops,a as parseLoopBinding};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Br as g,Fm as O,To as R,eq as H,wq as x}from"./chunk-kxtqbrfr.js";import b from"path";var v={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},M=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var T=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function f(q){let B=[],Q=0,G;T.lastIndex=0;while((G=T.exec(q))!==null){if(G.index>Q){let X=q.slice(Q,G.index);if(X.trim())B.push({type:B.length===0?"shell":"content",content:X})}let J=G[1],K=G[2];B.push({type:"suspense",name:J,content:K}),Q=G.index+G[0].length}if(Q<q.length){let J=q.slice(Q);if(J.trim())B.push({type:B.length===0?"shell":"content",content:J})}if(B.length===0)B.push({type:"shell",content:q});return B}async function r(q,B={},Q={}){let G={...g,...Q,streaming:{...v,...Q.streaming}},J=G.streaming?.bufferSize||16384;return new ReadableStream({async start(K){try{let X=await Bun.file(q).text(),z=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),L=z?z[1]:"",Y=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),j={...B,__filename:q,__dirname:b.dirname(q)};if(L.trim())await R(L,j,q);let D=f(Y),$=new Set;if(!D.some((w)=>w.type==="suspense")){let w=G.streaming?.strategy||"auto",U=new RegExp(M.source,"g");if(!(w!=="manual"&&U.test(Y))){let F=await H(Y,j,q,G,$);for(let V=0;V<F.length;V+=J)K.enqueue(F.slice(V,V+J)),await new Promise((W)=>setTimeout(W,0))}else{let F=[],V=new RegExp(M.source,"g"),W;while((W=V.exec(Y))!==null)F.push({name:W[1],content:W[2],start:W.index,end:W.index+W[0].length});let y=0;for(let A of F){if(A.start>y){let k=Y.slice(y,A.start);if(k.trim()){let E=await H(k,j,q,G,$);K.enqueue(E),await new Promise((S)=>setTimeout(S,0))}}let I=await H(A.content,j,q,G,$);K.enqueue(I),await new Promise((k)=>setTimeout(k,0)),y=A.end}if(y<Y.length){let A=Y.slice(y);if(A.trim()){let I=await H(A,j,q,G,$);K.enqueue(I)}}}}else{let w=new Map;for(let Z of D)if(Z.type==="shell"||Z.type==="content"){let F=await H(Z.content,j,q,G,$);K.enqueue(F)}else if(Z.type==="suspense"&&Z.name){let F=`stx-suspense-${Z.name}`;K.enqueue(`<div id="${F}" data-suspense="${Z.name}" style="display:contents;">
2
+ import{Ho as R,Jp as H,kq as x,pr as g,wm as O}from"./chunk-e3rgky2r.js";import b from"path";var v={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},M=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var T=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function f(q){let B=[],Q=0,G;T.lastIndex=0;while((G=T.exec(q))!==null){if(G.index>Q){let X=q.slice(Q,G.index);if(X.trim())B.push({type:B.length===0?"shell":"content",content:X})}let J=G[1],K=G[2];B.push({type:"suspense",name:J,content:K}),Q=G.index+G[0].length}if(Q<q.length){let J=q.slice(Q);if(J.trim())B.push({type:B.length===0?"shell":"content",content:J})}if(B.length===0)B.push({type:"shell",content:q});return B}async function r(q,B={},Q={}){let G={...g,...Q,streaming:{...v,...Q.streaming}},J=G.streaming?.bufferSize||16384;return new ReadableStream({async start(K){try{let X=await Bun.file(q).text(),z=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),L=z?z[1]:"",Y=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),j={...B,__filename:q,__dirname:b.dirname(q)};if(L.trim())await R(L,j,q);let D=f(Y),$=new Set;if(!D.some((w)=>w.type==="suspense")){let w=G.streaming?.strategy||"auto",U=new RegExp(M.source,"g");if(!(w!=="manual"&&U.test(Y))){let F=await H(Y,j,q,G,$);for(let V=0;V<F.length;V+=J)K.enqueue(F.slice(V,V+J)),await new Promise((W)=>setTimeout(W,0))}else{let F=[],V=new RegExp(M.source,"g"),W;while((W=V.exec(Y))!==null)F.push({name:W[1],content:W[2],start:W.index,end:W.index+W[0].length});let y=0;for(let A of F){if(A.start>y){let k=Y.slice(y,A.start);if(k.trim()){let E=await H(k,j,q,G,$);K.enqueue(E),await new Promise((S)=>setTimeout(S,0))}}let I=await H(A.content,j,q,G,$);K.enqueue(I),await new Promise((k)=>setTimeout(k,0)),y=A.end}if(y<Y.length){let A=Y.slice(y);if(A.trim()){let I=await H(A,j,q,G,$);K.enqueue(I)}}}}else{let w=new Map;for(let Z of D)if(Z.type==="shell"||Z.type==="content"){let F=await H(Z.content,j,q,G,$);K.enqueue(F)}else if(Z.type==="suspense"&&Z.name){let F=`stx-suspense-${Z.name}`;K.enqueue(`<div id="${F}" data-suspense="${Z.name}" style="display:contents;">
3
3
  <template data-suspense-fallback>Loading...</template>
4
4
  </div>`),w.set(Z.name,H(Z.content,j,q,G,$))}K.enqueue(`
5
5
  <script>
@@ -191,4 +191,4 @@ else {
191
191
  stx.hydrate();
192
192
  }
193
193
  })();`}
194
- export{r as Xi,N as Yi,C as Zi,s as _i,a as $i,o as aj,n as bj,e as cj,d as dj,h as ej,t as fj,qq as gj,Bq as hj,Gq as ij};
194
+ export{r as Mi,N as Ni,C as Oi,s as Pi,a as Qi,o as Ri,n as Si,e as Ti,d as Ui,h as Vi,t as Wi,qq as Xi,Bq as Yi,Gq as Zi};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{iw as y}from"./chunk-hzfd8cz0.js";import N from"fs";import B from"path";var Y="_stx";function L(M){return Bun.hash(M).toString(16).slice(0,8)}function T(M){let C=[],v=(q)=>{for(let g of N.readdirSync(q,{withFileTypes:!0})){let j=B.join(q,g.name);if(g.isDirectory())v(j);else if(g.isFile()&&j.endsWith(".html"))C.push(j)}};if(N.existsSync(M))v(M);return C}var S=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(M)=>`<script data-stx-runtime src="${M}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(M)=>`<script data-stx-router src="${M}"></script>`},{pattern:/<style\b([^>]*\bdata-css=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"css",extension:"css",contentType:"text/css; charset=utf-8",replace:(M)=>`<link data-css="generated" rel="stylesheet" href="${M}">`}];function _(M,C=`/${Y}`){let v=[],q=new Set,g=0,j=M;for(let G of S)j=j.replace(G.pattern,(R,K,W)=>{if(/\b(?:src|href)\s*=/.test(K)||!W.trim())return R;let Q=`${G.prefix}.${L(W)}.${G.extension}`;if(!q.has(Q))q.add(Q),v.push({filename:Q,contents:W,contentType:G.contentType});return g+=W.length,G.replace(`${C}/${Q}`)});return{html:j,assets:v,bytesInlined:g}}function a(M){let C={pages:0,assets:0,bytesInlined:0},v=B.join(M,Y),q=new Set;for(let g of T(M)){let j=N.readFileSync(g,"utf8"),{html:G,assets:R,bytesInlined:K}=_(j);if(G===j)continue;for(let W of R){if(q.has(W.filename))continue;q.add(W.filename),N.mkdirSync(v,{recursive:!0}),N.writeFileSync(B.join(v,W.filename),W.contents),C.assets++}N.writeFileSync(g,G),C.bytesInlined+=K,C.pages++}return C}import z from"fs";import P from"path";var I=1024,E=/<(script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi,d=new Set(["","module","text/javascript","application/javascript","module/javascript"]);function b(M){return Bun.hash(M).toString(16).slice(0,8)}function p(M){let C=[],v=(q)=>{for(let g of z.readdirSync(q,{withFileTypes:!0})){let j=P.join(q,g.name);if(g.isDirectory())v(j);else if(g.isFile()&&j.endsWith(".html"))C.push(j)}};if(z.existsSync(M))v(M);return C}function D(M,C){let v=M.match(new RegExp(`\\b${C}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i"));if(!v)return;return v[2]??v[3]??v[4]??""}function m(M,C,v){if(v.length<I)return!1;if(/\b(?:src|href)\s*=/i.test(C))return!1;if(M.toLowerCase()==="script"){if(!d.has((D(C,"type")??"").trim().toLowerCase()))return!1;return!0}return!0}function o(M){let C=[];for(let v of M.matchAll(/<template\b[^>]*>[\s\S]*?<\/template>/gi))C.push([v.index,v.index+v[0].length]);return C}function s(M){let C={pages:0,assets:0,bytesInlined:0},v=p(M);if(v.length<2)return C;let q=new Map,g=new Map;for(let Q of v){let O=z.readFileSync(Q,"utf8");q.set(Q,O);let x=o(O);for(let U of O.matchAll(E)){let[w,V,J,$]=U;if(!m(V,J,$))continue;if(x.some(([A,k])=>U.index>=A&&U.index<k))continue;let H=`${V.toLowerCase()}\x00${$}`,X=g.get(H);if(X)X.push({file:Q,whole:w,tag:V,attrs:J,body:$});else g.set(H,[{file:Q,whole:w,tag:V,attrs:J,body:$}])}}let j=[...g.values()].filter((Q)=>new Set(Q.map((O)=>O.file)).size>1);if(j.length===0)return C;let G=P.join(M,Y),R=new Map(q),K=new Map,W=[];for(let Q of j){let{tag:O,body:x}=Q[0],U=O.toLowerCase()==="script",w=`${U?"chunk":"style"}.${b(x)}.${U?"js":"css"}`;W.push({filename:w,contents:x,contentType:U?"text/javascript; charset=utf-8":"text/css; charset=utf-8"});let V=`/${Y}/${w}`;for(let J of Q){let $=U?`<script${J.attrs} src="${V}"></script>`:`<link${J.attrs} rel="stylesheet" href="${V}">`,H=R.get(J.file),X=H.replace(J.whole,()=>$);if(X===H)continue;R.set(J.file,X),K.set(J.file,(K.get(J.file)??0)+J.body.length)}}z.mkdirSync(G,{recursive:!0});for(let Q of W)z.writeFileSync(P.join(G,Q.filename),Q.contents),C.assets++;for(let[Q,O]of R){if(O===q.get(Q))continue;z.writeFileSync(Q,O),C.pages++,C.bytesInlined+=K.get(Q)??0}return C}y();import Z from"fs";import F from"path";var h="layout-types.d.ts";function f(M){let C=[],v=(q,g)=>{let j;try{j=Z.readdirSync(q,{withFileTypes:!0})}catch{return}for(let G of j){if(G.name.startsWith("."))continue;let R=F.join(q,G.name);if(G.isDirectory())v(R,g?`${g}/${G.name}`:G.name);else if(G.isFile()&&G.name.endsWith(".stx")&&G.name!=="_layout.stx"){let K=G.name.slice(0,-4);C.push(g?`${g}/${K}`:K)}}};return v(M,""),C.sort()}function c(M){let C=["// Auto-generated by stx \u2014 do not edit.","//","// Makes `definePageMeta({ layout })` reject a name with no layout behind it.","// Include this file in your tsconfig (it lives in the stx state directory,","// `.stx/` by default) for the check to apply.",""];if(M.length===0)return C.push("// No layouts found \u2014 `layout` stays typed as `string`.","export {}",""),C.join(`
2
+ import{jw as y}from"./chunk-w0hzaka3.js";import N from"fs";import B from"path";var Y="_stx";function L(M){return Bun.hash(M).toString(16).slice(0,8)}function T(M){let C=[],v=(q)=>{for(let g of N.readdirSync(q,{withFileTypes:!0})){let j=B.join(q,g.name);if(g.isDirectory())v(j);else if(g.isFile()&&j.endsWith(".html"))C.push(j)}};if(N.existsSync(M))v(M);return C}var S=[{pattern:/<script\b([^>]*\bdata-stx-runtime\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"runtime",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(M)=>`<script data-stx-runtime src="${M}"></script>`},{pattern:/<script\b([^>]*\bdata-stx-router\b[^>]*)>([\s\S]*?)<\/script>/gi,prefix:"router",extension:"js",contentType:"text/javascript; charset=utf-8",replace:(M)=>`<script data-stx-router src="${M}"></script>`},{pattern:/<style\b([^>]*\bdata-css=(?:"generated"|'generated')[^>]*)>([\s\S]*?)<\/style>/gi,prefix:"css",extension:"css",contentType:"text/css; charset=utf-8",replace:(M)=>`<link data-css="generated" rel="stylesheet" href="${M}">`}];function _(M,C=`/${Y}`){let v=[],q=new Set,g=0,j=M;for(let G of S)j=j.replace(G.pattern,(R,K,W)=>{if(/\b(?:src|href)\s*=/.test(K)||!W.trim())return R;let Q=`${G.prefix}.${L(W)}.${G.extension}`;if(!q.has(Q))q.add(Q),v.push({filename:Q,contents:W,contentType:G.contentType});return g+=W.length,G.replace(`${C}/${Q}`)});return{html:j,assets:v,bytesInlined:g}}function a(M){let C={pages:0,assets:0,bytesInlined:0},v=B.join(M,Y),q=new Set;for(let g of T(M)){let j=N.readFileSync(g,"utf8"),{html:G,assets:R,bytesInlined:K}=_(j);if(G===j)continue;for(let W of R){if(q.has(W.filename))continue;q.add(W.filename),N.mkdirSync(v,{recursive:!0}),N.writeFileSync(B.join(v,W.filename),W.contents),C.assets++}N.writeFileSync(g,G),C.bytesInlined+=K,C.pages++}return C}import z from"fs";import P from"path";var I=1024,E=/<(script|style)\b([^>]*)>([\s\S]*?)<\/\1>/gi,d=new Set(["","module","text/javascript","application/javascript","module/javascript"]);function b(M){return Bun.hash(M).toString(16).slice(0,8)}function p(M){let C=[],v=(q)=>{for(let g of z.readdirSync(q,{withFileTypes:!0})){let j=P.join(q,g.name);if(g.isDirectory())v(j);else if(g.isFile()&&j.endsWith(".html"))C.push(j)}};if(z.existsSync(M))v(M);return C}function D(M,C){let v=M.match(new RegExp(`\\b${C}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i"));if(!v)return;return v[2]??v[3]??v[4]??""}function m(M,C,v){if(v.length<I)return!1;if(/\b(?:src|href)\s*=/i.test(C))return!1;if(M.toLowerCase()==="script"){if(!d.has((D(C,"type")??"").trim().toLowerCase()))return!1;return!0}return!0}function o(M){let C=[];for(let v of M.matchAll(/<template\b[^>]*>[\s\S]*?<\/template>/gi))C.push([v.index,v.index+v[0].length]);return C}function s(M){let C={pages:0,assets:0,bytesInlined:0},v=p(M);if(v.length<2)return C;let q=new Map,g=new Map;for(let Q of v){let O=z.readFileSync(Q,"utf8");q.set(Q,O);let x=o(O);for(let U of O.matchAll(E)){let[w,V,J,$]=U;if(!m(V,J,$))continue;if(x.some(([A,k])=>U.index>=A&&U.index<k))continue;let H=`${V.toLowerCase()}\x00${$}`,X=g.get(H);if(X)X.push({file:Q,whole:w,tag:V,attrs:J,body:$});else g.set(H,[{file:Q,whole:w,tag:V,attrs:J,body:$}])}}let j=[...g.values()].filter((Q)=>new Set(Q.map((O)=>O.file)).size>1);if(j.length===0)return C;let G=P.join(M,Y),R=new Map(q),K=new Map,W=[];for(let Q of j){let{tag:O,body:x}=Q[0],U=O.toLowerCase()==="script",w=`${U?"chunk":"style"}.${b(x)}.${U?"js":"css"}`;W.push({filename:w,contents:x,contentType:U?"text/javascript; charset=utf-8":"text/css; charset=utf-8"});let V=`/${Y}/${w}`;for(let J of Q){let $=U?`<script${J.attrs} src="${V}"></script>`:`<link${J.attrs} rel="stylesheet" href="${V}">`,H=R.get(J.file),X=H.replace(J.whole,()=>$);if(X===H)continue;R.set(J.file,X),K.set(J.file,(K.get(J.file)??0)+J.body.length)}}z.mkdirSync(G,{recursive:!0});for(let Q of W)z.writeFileSync(P.join(G,Q.filename),Q.contents),C.assets++;for(let[Q,O]of R){if(O===q.get(Q))continue;z.writeFileSync(Q,O),C.pages++,C.bytesInlined+=K.get(Q)??0}return C}y();import Z from"fs";import F from"path";var h="layout-types.d.ts";function f(M){let C=[],v=(q,g)=>{let j;try{j=Z.readdirSync(q,{withFileTypes:!0})}catch{return}for(let G of j){if(G.name.startsWith("."))continue;let R=F.join(q,G.name);if(G.isDirectory())v(R,g?`${g}/${G.name}`:G.name);else if(G.isFile()&&G.name.endsWith(".stx")&&G.name!=="_layout.stx"){let K=G.name.slice(0,-4);C.push(g?`${g}/${K}`:K)}}};return v(M,""),C.sort()}function c(M){let C=["// Auto-generated by stx \u2014 do not edit.","//","// Makes `definePageMeta({ layout })` reject a name with no layout behind it.","// Include this file in your tsconfig (it lives in the stx state directory,","// `.stx/` by default) for the check to apply.",""];if(M.length===0)return C.push("// No layouts found \u2014 `layout` stays typed as `string`.","export {}",""),C.join(`
3
3
  `);return C.push("declare module '@stacksjs/stx' {"," interface KnownLayouts {",...M.map((v)=>` '${v}': true`)," }","}","","export {}",""),C.join(`
4
4
  `)}function HM(M,C){if(!M)return[];let v=F.isAbsolute(M)?M:F.resolve(process.cwd(),M),q=f(v),g=c(q),j=F.join(C,h);try{if(Z.existsSync(j)&&Z.readFileSync(j,"utf8")===g)return q;Z.mkdirSync(C,{recursive:!0}),Z.writeFileSync(j,g)}catch{}return q}
5
- export{Y as Ek,_ as Fk,a as Gk,s as Hk,h as Ik,f as Jk,c as Kk,HM as Lk};
5
+ export{Y as tk,_ as uk,a as vk,s as wk,h as xk,f as yk,c as zk,HM as Ak};
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{ig as e,kg as kF,lg as UF,mg as wF,ug as EF}from"./chunk-fw56y3cb.js";import{xg as BF}from"./chunk-57atgbyq.js";import{nj as l,oj as d}from"./chunk-tsmdmf5h.js";import{Bk as HF,Ck as IF,Dk as KF}from"./chunk-f6sejeg3.js";import{ll as YF,nl as ZF}from"./chunk-1yj4xd6n.js";import{Fp as VF,Jp as r,Op as o,Sm as s,io as zF,ip as $F,jm as p,lm as i,pr as t,rr as M,xp as GF}from"./chunk-e3rgky2r.js";import{rs as XF}from"./chunk-7r79j1hs.js";import{ht as qF}from"./chunk-nhbc464j.js";import{Bt as WF}from"./chunk-kermxyfe.js";import{Gt as QF}from"./chunk-k3dtvay1.js";import{gw as h,jw as _F}from"./chunk-w0hzaka3.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)=>o(E))),{context:_}=TF({__filename:X,__dirname:n.dirname(X),__stx_serverDeclared:W}),N=new Set,x={...t,...w,...Z,buildMode:"compile",strict:!1},I=await r(F,_,X,x,N),O=e(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
+ [stx build] Done in ${D}ms \u2014 ${R.length} pages compiled`),{pageCount:R.length,assets:S,outputDir:X,duration:D}}
4
+ export{u as Rf,c as Sf,a as Tf,bF as Uf,FF as Vf,qJ as Wf};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Qo as a,Ro as b,So as c,To as d,Uo as e,Vo as f,Wo as g}from"./chunk-e3rgky2r.js";import"./chunk-d7zxg9bp.js";import"./chunk-t00ga194.js";import"./chunk-hrdd26r4.js";import"./chunk-7r79j1hs.js";import"./chunk-ay336sqb.js";import"./chunk-nhbc464j.js";import"./chunk-vaggjvsm.js";import"./chunk-q9ckfwhh.js";import"./chunk-kermxyfe.js";import"./chunk-k3dtvay1.js";import"./chunk-aved735s.js";import"./chunk-799s9mwc.js";import"./chunk-7r80apc5.js";import"./chunk-2tjk867y.js";import"./chunk-t8ctvjqe.js";import"./chunk-deqnt1w5.js";import"./chunk-w0hzaka3.js";import"./chunk-wb90259a.js";import"./chunk-5g6rprcy.js";export{a as resetUnscopedSignalWarnings,g as processStackReplacements,f as processStackPushDirectives,e as processIncludes,b as partialsCache,c as onceStore,d as clearOnceStore};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Am as l,Bm as m,Cm as n,Dm as o,Em as p,Fm as q,Gm as r,pm as a,qm as b,rm as c,sm as d,tm as e,um as f,vm as g,wm as h,xm as i,ym as j,zm as k}from"./chunk-e3rgky2r.js";import"./chunk-d7zxg9bp.js";import"./chunk-t00ga194.js";import"./chunk-hrdd26r4.js";import"./chunk-7r79j1hs.js";import"./chunk-ay336sqb.js";import"./chunk-nhbc464j.js";import"./chunk-vaggjvsm.js";import"./chunk-q9ckfwhh.js";import"./chunk-kermxyfe.js";import"./chunk-k3dtvay1.js";import"./chunk-aved735s.js";import"./chunk-799s9mwc.js";import"./chunk-7r80apc5.js";import"./chunk-2tjk867y.js";import"./chunk-t8ctvjqe.js";import"./chunk-deqnt1w5.js";import"./chunk-w0hzaka3.js";import"./chunk-wb90259a.js";import"./chunk-5g6rprcy.js";export{j as usesSignalsInScript,r as unescapeHtml,p as resetRejectedExpressionWarnings,g as replaceInterpolations,c as registerFilters,b as registerFilter,n as processExpressions,m as interpolateScriptsInTemplate,k as interpolateScriptExpressions,l as interpolateScriptAttributes,d as getAllFilters,f as findMustacheEnd,q as evaluateExpression,i as escapeHtmlValue,h as escapeHtml,a as defaultFilters,e as clearCustomFilters,o as applyFilters};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Co as a,Do as b,Eo as c,Fo as d,Go as e,Ho as f,Io as g,Jo as h,Ko as i,Lo as j,Mo as k}from"./chunk-e3rgky2r.js";import"./chunk-d7zxg9bp.js";import"./chunk-t00ga194.js";import"./chunk-hrdd26r4.js";import"./chunk-7r79j1hs.js";import"./chunk-ay336sqb.js";import"./chunk-nhbc464j.js";import"./chunk-vaggjvsm.js";import"./chunk-q9ckfwhh.js";import"./chunk-kermxyfe.js";import"./chunk-k3dtvay1.js";import"./chunk-aved735s.js";import"./chunk-799s9mwc.js";import"./chunk-7r80apc5.js";import"./chunk-2tjk867y.js";import"./chunk-t8ctvjqe.js";import"./chunk-deqnt1w5.js";import"./chunk-w0hzaka3.js";import"./chunk-wb90259a.js";import"./chunk-5g6rprcy.js";export{b as stripTypeScript,i as splitDeclaration,d as isSyntaxFailure,c as isModuleResolutionFailure,e as isMissingBindingFailure,g as isCompleteImport,k as hasVariables,f as extractVariables,j as extractScriptFromTemplate,h as convertToCommonJS,a as STX_ENGINE_BINDING_NAMES};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  function E(z){if(!z.startsWith("/")||/[?#\\]/.test(z))throw Error(`Invalid route rule pattern: ${z}`);let w=z==="/"?[]:z.slice(1).split("/");if(w.some((q,j)=>!q||q.includes("*")&&q!=="*"&&q!=="**"||q==="**"&&j!==w.length-1||q.startsWith(":")&&!/^:[\w]+$/.test(q)))throw Error(`Unsupported route rule pattern: ${z}`);return w}function F(z){for(let[w,q]of Object.entries(z)){if(E(w),!q||typeof q!=="object"||Object.keys(q).some((j)=>j!=="rendering"&&j!=="cache"))throw Error(`Unsupported route rule for ${w}`);if(q.rendering!==void 0&&q.rendering!=="prerender"&&q.rendering!=="dynamic")throw Error(`Unsupported rendering mode for ${w}`);if(q.cache!==void 0&&q.cache!==!1){let j=q.cache;if(!j||j.public!==!0||Object.keys(j).some((x)=>!["public","maxAge","swr"].includes(x))||!Number.isFinite(j.maxAge)||j.maxAge<=0||j.swr!==void 0&&(!Number.isFinite(j.swr)||j.swr<0))throw Error(`Route cache for ${w} requires public: true, maxAge > 0 and swr >= 0`);if(q.rendering==="prerender")throw Error(`Prerendered route ${w} cannot revalidate; use dynamic rendering with cache`)}}}function G(z={}){F(z);let w=(j)=>j==="**"?0:j==="*"?1:j.startsWith(":")?2:3,q=Object.entries(z).map(([j,x])=>({pattern:j,parts:E(j),rule:x}));return q.sort((j,x)=>{for(let A=0;A<Math.max(j.parts.length,x.parts.length);A++){let B=(x.parts[A]===void 0?4:w(x.parts[A]))-(j.parts[A]===void 0?4:w(j.parts[A]));if(B)return B}return j.pattern.localeCompare(x.pattern)}),(j)=>{let x=j==="/"?[]:j.replace(/\/$/,"").slice(1).split("/");return q.find(({parts:A})=>A.every((B,D)=>B==="**"||x[D]!==void 0&&(B==="*"||B.startsWith(":")||B===x[D]))&&(A.at(-1)==="**"||A.length===x.length))?.rule??{}}}
3
- export{F as Hg,G as Ig};
3
+ export{F as wg,G as xg};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{yf as a,zf as b}from"./chunk-m11pb9cx.js";import"./chunk-xe6zmdfq.js";import"./chunk-5g6rprcy.js";export{a as handleImageRequest,b as createImageHandler};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
2
  var{defineProperty:e,getOwnPropertyNames:g,getOwnPropertyDescriptor:h}=Object,i=Object.prototype.hasOwnProperty;function j(a){return this[a]}var m=(a)=>{var b=(f??=new WeakMap).get(a),c;if(b)return b;if(b=e({},"__esModule",{value:!0}),a&&typeof a==="object"||typeof a==="function"){for(var d of g(a))if(!i.call(b,d))e(b,d,{get:j.bind(a,d),enumerable:!(c=h(a,d))||c.enumerable})}return f.set(a,b),b},f;var k=(a)=>a;function l(a,b){this[a]=k.bind(null,b)}var n=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0,configurable:!0,set:l.bind(b,c)})};var o=(a,b)=>()=>(a&&(b=a(a=0)),b);var p=import.meta.require;
3
- export{m as pw,n as qw,o as rw,p as sw};
3
+ export{m as qw,n as rw,o as sw,p as tw};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ih as a,jh as b,kh as c,lh as d,mh as e,nh as f,oh as g,ph as h,qh as i,rh as j,sh as k}from"./chunk-yk6446kr.js";import"./chunk-vd5xvsnv.js";import"./chunk-hyfjnn7g.js";export{c as setCachedVideoResult,k as processVideo,b as getCachedVideoResult,f as generateThumbnails,g as generateSpriteSheet,e as generatePoster,h as generateHLSManifest,i as generateDASHManifest,d as clearVideoCache,j as analyzeVideo,a as VideoProcessorCache};
2
+ import{$g as c,Zg as a,_g as b,ah as d,bh as e,ch as f,dh as g,eh as h,fh as i,gh as j,hh as k}from"./chunk-w72v0ab1.js";import"./chunk-18018jkn.js";import"./chunk-5g6rprcy.js";export{c as setCachedVideoResult,k as processVideo,b as getCachedVideoResult,f as generateThumbnails,g as generateSpriteSheet,e as generatePoster,h as generateHLSManifest,i as generateDASHManifest,d as clearVideoCache,j as analyzeVideo,a as VideoProcessorCache};
@@ -1,17 +1,17 @@
1
1
  // @bun
2
- import{Xf as v,Yf as t,Zf as e,ag as HH,bg as KH,cg as QH,dg as YH,eg as ZH,fg as $H}from"./chunk-gdbkqatx.js";import{Ri as s}from"./chunk-4k0ce745.js";import{Dr as i,gm as a}from"./chunk-kxtqbrfr.js";import{Cu as h}from"./chunk-gptwwv3c.js";import{gv as f}from"./chunk-deqnt1w5.js";import{existsSync as jH,readFileSync as WH}from"fs";import z from"path";function AH(Q,K="",V=""){let L=Q.startLine>1?`
3
- `.repeat(Q.startLine-1):"",U=e(t(Q.code)),X=Q.kind==="client"||Q.kind==="plain"?KH(K,Q.code):"";return YH(`${L+U}
2
+ import{ei as s}from"./chunk-zye9r15n.js";import{Kp as v,Lp as i,Mp as t,Pp as e,Qp as HH,Rp as KH,Sp as QH,Tp as YH,Up as ZH,Xl as a,rr as $H}from"./chunk-e3rgky2r.js";import{mt as h}from"./chunk-vaggjvsm.js";import{gv as f}from"./chunk-deqnt1w5.js";import{existsSync as jH,readFileSync as WH}from"fs";import z from"path";function AH(Q,K="",V=""){let L=Q.startLine>1?`
3
+ `.repeat(Q.startLine-1):"",U=t(i(Q.code)),X=Q.kind==="client"||Q.kind==="plain"?HH(K,Q.code):"";return QH(`${L+U}
4
4
  ${X}
5
5
  export {}
6
6
  `,V)}function MH(Q){let K=Q.length>0?z.dirname(z.resolve(Q[0])):process.cwd();try{Bun.resolveSync("@stacksjs/stx",K)}catch{return""}return["// Generated \u2014 `stx` is the virtual specifier client-script.ts strips.","declare module 'stx' {"," export * from '@stacksjs/stx'","}"].join(`
7
7
  `)}var UH=new Set(["name","status","length","location","history","origin","closed","close","open","focus","blur","print","scroll","scrollTo","scrollBy","stop","top","parent","self","frames","event","external","menubar","toolbar"]);function IH(Q){if(Q.length===0)return"";let K=["// Generated \u2014 the composables the runtime publishes as bare globals."],V=new Set(f),L=[];for(let{file:U,names:X}of Q){let W=JSON.stringify(U.replace(/\\/g,"/").replace(/\.ts$/,""));L.push(` export * from ${W}`);for(let A of X){if(V.has(A)||UH.has(A))continue;V.add(A),K.push(`declare const ${A}: typeof import(${W})[${JSON.stringify(A)}]`)}}return K.push("declare module '@composables' {",...L,"}"),K.join(`
8
8
  `)}function r(Q,K,V){return`${Q}.__stx_${K}${V}.ts`}function SH(Q){return Q.replace(/\.__stx_(?:server|client|plain|template)\d+\.ts$/,"")}function LH(){for(let Q of[z.resolve(import.meta.dir,"..","stx.d.ts"),z.resolve(import.meta.dir,"..","..","stx.d.ts")])if(jH(Q))return Q;return null}var NH=/^(.*?)\((\d+),(\d+)\):\s+(error|warning)\s+TS(\d+):\s+(.*)$/;function RH(Q){return Q>=1000&&Q<2000}function EH(Q){let K=z.resolve(Q),V;for(;;){let Z=z.join(K,"tsconfig.json");if(jH(Z)){V=Z;break}let $=z.dirname(K);if($===K)break;K=$}if(!V)return{};let L=(Z)=>{let $="",M=!1,B=!1;for(let j=0;j<Z.length;j++){let q=Z[j];if(M){if($+=q,B)B=!1;else if(q==="\\")B=!0;else if(q==='"')M=!1;continue}if(q==='"'){M=!0,$+=q;continue}if(q==="/"&&Z[j+1]==="/"){while(j<Z.length&&Z[j]!==`
9
9
  `)j++;$+=`
10
- `;continue}if(q==="/"&&Z[j+1]==="*"){j+=2;while(j<Z.length&&!(Z[j]==="*"&&Z[j+1]==="/"))j++;j++;continue}$+=q}return $.replace(/,(\s*[}\]])/g,"$1")},U=new Set,X=V,W,A,R=V;while(X&&!U.has(X)){U.add(X);let Z;try{Z=JSON.parse(L(WH(X,"utf8")))}catch{break}let $=Z?.compilerOptions??{};if(!W&&$.paths&&typeof $.paths==="object")W=$.paths,R=X;if(!A&&typeof $.baseUrl==="string")A=z.resolve(z.dirname(X),$.baseUrl);if(W&&A)break;X=typeof Z?.extends==="string"?z.resolve(z.dirname(X),Z.extends.endsWith(".json")?Z.extends:`${Z.extends}.json`):void 0}if(!W)return{};let y=A??z.dirname(R),O={};for(let[Z,$]of Object.entries(W)){if(!Array.isArray($))continue;O[Z]=$.map((M)=>typeof M==="string"&&!z.isAbsolute(M)?z.resolve(y,M):M)}return{paths:O}}async function DH(Q,K={}){let V=K.client!==!1,L=K.server!==!1,U=K.templates!==!1,X=K.componentsDir??(U?(await i()).componentsDir:void 0),W=new Map,A=new Map,R=[],y=0,O=0,Z=LH();for(let H of Q){let Y=await Bun.file(H).text(),G=v(Y).filter((J)=>{if(J.kind==="server")return L;return V}),I=v(Y).filter((J)=>J.kind==="server").map((J)=>J.code).join(`
11
- `);if(V&&I){let J=G.filter((F)=>F.kind!=="server"),_=[...new Set(J.flatMap((F)=>QH(I,F.code)))];if(_.length>0)A.set(H,{names:_,line:J[0].startLine,kind:J[0].kind})}let E=z.dirname(z.resolve(H)),N=U?ZH(Y,{runtimeGlobals:!Z,originDir:E,filePath:z.resolve(H),componentsDir:X}):null,C=N?[...N.lineMap.values()].filter((J)=>J.expression).length:0;if(G.length===0&&C===0)continue;if(R.push(H),y+=G.length,O+=C,G.forEach((J,_)=>{W.set(r(H,J.kind,_),{source:AH(J,I,E),origin:H,kind:J.kind})}),N&&C>0)W.set(r(H,"template",0),{source:N.text,origin:H,kind:"template",virtual:N})}if(W.size===0)return{diagnostics:[],checkedFiles:R,blockCount:0,expressionCount:0};let $=(K.extraLibs??[]).map((H)=>z.resolve(H));if(Z)$.push(Z);let M=`${h()}/typecheck/__stx_globals.d.ts`,B=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",HH(),...Z?[]:["declare const window: any",...f.map((H)=>`declare const ${H}: any`)],["// Generated \u2014 the names stx auto-imports from @stacksjs/browser.",...a.map((H)=>`declare const ${H}: any`)].join(`
10
+ `;continue}if(q==="/"&&Z[j+1]==="*"){j+=2;while(j<Z.length&&!(Z[j]==="*"&&Z[j+1]==="/"))j++;j++;continue}$+=q}return $.replace(/,(\s*[}\]])/g,"$1")},U=new Set,X=V,W,A,R=V;while(X&&!U.has(X)){U.add(X);let Z;try{Z=JSON.parse(L(WH(X,"utf8")))}catch{break}let $=Z?.compilerOptions??{};if(!W&&$.paths&&typeof $.paths==="object")W=$.paths,R=X;if(!A&&typeof $.baseUrl==="string")A=z.resolve(z.dirname(X),$.baseUrl);if(W&&A)break;X=typeof Z?.extends==="string"?z.resolve(z.dirname(X),Z.extends.endsWith(".json")?Z.extends:`${Z.extends}.json`):void 0}if(!W)return{};let y=A??z.dirname(R),O={};for(let[Z,$]of Object.entries(W)){if(!Array.isArray($))continue;O[Z]=$.map((M)=>typeof M==="string"&&!z.isAbsolute(M)?z.resolve(y,M):M)}return{paths:O}}async function DH(Q,K={}){let V=K.client!==!1,L=K.server!==!1,U=K.templates!==!1,X=K.componentsDir??(U?(await $H()).componentsDir:void 0),W=new Map,A=new Map,R=[],y=0,O=0,Z=LH();for(let H of Q){let Y=await Bun.file(H).text(),G=v(Y).filter((J)=>{if(J.kind==="server")return L;return V}),I=v(Y).filter((J)=>J.kind==="server").map((J)=>J.code).join(`
11
+ `);if(V&&I){let J=G.filter((F)=>F.kind!=="server"),_=[...new Set(J.flatMap((F)=>KH(I,F.code)))];if(_.length>0)A.set(H,{names:_,line:J[0].startLine,kind:J[0].kind})}let E=z.dirname(z.resolve(H)),N=U?YH(Y,{runtimeGlobals:!Z,originDir:E,filePath:z.resolve(H),componentsDir:X}):null,C=N?[...N.lineMap.values()].filter((J)=>J.expression).length:0;if(G.length===0&&C===0)continue;if(R.push(H),y+=G.length,O+=C,G.forEach((J,_)=>{W.set(r(H,J.kind,_),{source:AH(J,I,E),origin:H,kind:J.kind})}),N&&C>0)W.set(r(H,"template",0),{source:N.text,origin:H,kind:"template",virtual:N})}if(W.size===0)return{diagnostics:[],checkedFiles:R,blockCount:0,expressionCount:0};let $=(K.extraLibs??[]).map((H)=>z.resolve(H));if(Z)$.push(Z);let M=`${h()}/typecheck/__stx_globals.d.ts`,B=["// Generated \u2014 the context serve.ts injects into <script server> blocks.",e(),...Z?[]:["declare const window: any",...f.map((H)=>`declare const ${H}: any`)],["// Generated \u2014 the names stx auto-imports from @stacksjs/browser.",...a.map((H)=>`declare const ${H}: any`)].join(`
12
12
  `),MH(Q),IH(await s())].filter(Boolean).join(`
13
13
  `),j=`${h()}/typecheck`;await Bun.$`rm -rf ${j}`.quiet().nothrow(),await Bun.$`mkdir -p ${j}`.quiet().nothrow(),await Bun.write(M,B);let q=new Map,zH=0;for(let[H,Y]of W){let G=`${zH++}_${H.replace(/[^\w.-]+/g,"_")}`;await Bun.write(`${j}/${G}`,Y.source),q.set(G,Y)}let JH={target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,allowJs:!0,esModuleInterop:!0,resolveJsonModule:!0,lib:["ESNext","DOM","DOM.Iterable"],types:[],...EH(Q.length>0?z.dirname(z.resolve(Q[0])):process.cwd()),...K.compilerOptions??{}},k=async(H,Y)=>{let G=`${j}/tsconfig${Y===1?"":`.${Y}`}.json`;await Bun.write(G,JSON.stringify({compilerOptions:JH,files:H.map((E)=>`${j}/${E}`).concat(M,...$)},null,2));let I=Bun.spawnSync(["bun","x","tsc","-p",G,"--pretty","false"],{stdout:"pipe",stderr:"pipe"});return{output:new TextDecoder().decode(I.stdout)+new TextDecoder().decode(I.stderr),exitCode:I.exitCode??0}},m=await k([...q.keys()],1),b=m.output,S=[],u=m.exitCode,d=0,VH=new Set($.map((H)=>H.split("/").pop())),p=0,P=new Set,l=(H)=>{for(let Y of H.replace(/\n[\t ]+([^\n]*)/g," $1").split(`
14
- `)){let G=Y.match(NH);if(!G)continue;if(d++,VH.has(G[1].split("/").pop()))p++;let[,I,E,N,C,J,_]=G,F=I.split("/").pop(),w=q.get(F);if(!w)continue;if(RH(Number(J)))P.add(F);let g=Number(E),x=Number(N),o;if(w.virtual){let T=$H(w.virtual,g,x);if(!T?.expression)continue;if(Number(J)===2774)continue;g=T.line,x=T.column,o=T.expression.code.trim()}S.push({file:w.origin,line:g,column:x,code:Number(J),message:_,category:C==="error"?"error":"warning",blockKind:w.kind,expression:o})}};l(b);let XH=d,qH=p;if(P.size>0&&P.size<q.size){let H=[...q.keys()].filter((Y)=>!P.has(Y));l((await k(H,2)).output)}if(V)for(let[H,Y]of A){if(Y.names.length===0)continue;S.push({file:H,line:Y.line,column:1,code:0,message:`${Y.names.length===1?"1 value reaches":`${Y.names.length} values reach`} this block on the implicit bridge and ${Y.names.length===1?"is":"are"} untyped: ${Y.names.join(", ")}. Declare them with defineClientPayload({ ${Y.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:Y.kind})}let c=new Set,D=S.filter((H)=>{let Y=`${H.file}:${H.line}:${H.column}:${H.code}:${H.message}`;if(c.has(Y))return!1;return c.add(Y),!0});D.sort((H,Y)=>H.file.localeCompare(Y.file)||H.line-Y.line||H.column-Y.column);let n=qH>0&&D.length===0,GH=n||u!==0&&XH===0?`${n?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${u} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
14
+ `)){let G=Y.match(NH);if(!G)continue;if(d++,VH.has(G[1].split("/").pop()))p++;let[,I,E,N,C,J,_]=G,F=I.split("/").pop(),w=q.get(F);if(!w)continue;if(RH(Number(J)))P.add(F);let g=Number(E),x=Number(N),o;if(w.virtual){let T=ZH(w.virtual,g,x);if(!T?.expression)continue;if(Number(J)===2774)continue;g=T.line,x=T.column,o=T.expression.code.trim()}S.push({file:w.origin,line:g,column:x,code:Number(J),message:_,category:C==="error"?"error":"warning",blockKind:w.kind,expression:o})}};l(b);let XH=d,qH=p;if(P.size>0&&P.size<q.size){let H=[...q.keys()].filter((Y)=>!P.has(Y));l((await k(H,2)).output)}if(V)for(let[H,Y]of A){if(Y.names.length===0)continue;S.push({file:H,line:Y.line,column:1,code:0,message:`${Y.names.length===1?"1 value reaches":`${Y.names.length} values reach`} this block on the implicit bridge and ${Y.names.length===1?"is":"are"} untyped: ${Y.names.join(", ")}. Declare them with defineClientPayload({ ${Y.names.join(", ")} }) in the server block to have them checked.`,category:"warning",blockKind:Y.kind})}let c=new Set,D=S.filter((H)=>{let Y=`${H.file}:${H.line}:${H.column}:${H.code}:${H.message}`;if(c.has(Y))return!1;return c.add(Y),!0});D.sort((H,Y)=>H.file.localeCompare(Y.file)||H.line-Y.line||H.column-Y.column);let n=qH>0&&D.length===0,GH=n||u!==0&&XH===0?`${n?"a file passed with --lib has errors of its own, so nothing in your code was checked":`tsc exited ${u} without reporting any diagnostic, so nothing was checked`}. `+"A syntax error in an ambient declaration file does this \u2014 skipLibCheck suppresses "+`SEMANTIC diagnostics only. tsc said:
15
15
  ${b.trim().split(`
16
16
  `).slice(0,12).join(`
17
17
  `)||"(no output)"}`:void 0;return{diagnostics:D,checkedFiles:R,blockCount:y,expressionCount:O,failure:GH}}function gH(Q){return Q.map((K)=>{let V=K.blockKind==="template"?`[template: ${K.expression??""}]`:`[${K.blockKind==="plain"?"<script>":`<script ${K.blockKind}>`}]`;return`${K.file}:${K.line}:${K.column} ${K.category} TS${K.code} ${K.message} ${V}`}).join(`
@@ -0,0 +1,47 @@
1
+ // @bun
2
+ import{tw as z}from"./chunk-5g6rprcy.js";var Vq={1001:{message:"Unclosed directive: {{directive}}",help:"Make sure to close the directive with the appropriate end tag"},1002:{message:"Unclosed expression at position {{position}}",help:"Check for missing closing braces }}"},1003:{message:"Invalid directive syntax: {{directive}}",help:"Review the directive documentation for correct syntax"},1004:{message:"Malformed expression: {{expression}}",help:"Check for syntax errors in your expression"},1005:{message:"Unexpected token: {{token}}",help:"Remove or fix the unexpected token"},1101:{message:"Undefined variable: {{variable}}",help:"Make sure the variable is defined in the template context"},1102:{message:"Type error: {{details}}",help:"Check that you are using the correct types"},1103:{message:"Evaluation error: {{details}}",help:"Review the expression for errors"},1104:{message:"Infinite loop detected in {{location}}",help:"Check your loop conditions"},1105:{message:"Circular reference detected: {{path}}",help:"Remove the circular dependency"},1201:{message:"Unsafe expression blocked: {{expression}}",help:"This expression contains potentially dangerous code"},1202:{message:"Path traversal attempt blocked: {{path}}",help:"Use only relative paths within allowed directories"},1203:{message:"Potential XSS attempt blocked",help:"Sanitize user input before rendering"},1204:{message:"Code injection attempt blocked: {{code}}",help:"Avoid executing dynamic code"},1205:{message:"Prohibited DOM API usage: {{api}}",help:"Use STX.useRefs(), STX.useRef(), STX.el() and other STX helpers instead of direct DOM manipulation"},1301:{message:"File not found: {{path}}",help:"Check that the file exists and the path is correct"},1302:{message:"Error reading file: {{path}}",help:"Check file permissions and encoding"},1303:{message:"Invalid file path: {{path}}",help:"Use a valid file path"},1304:{message:"Permission denied: {{path}}",help:"Check file permissions"},1401:{message:"Invalid configuration: {{details}}",help:"Review your stx.config.ts file"},1402:{message:"Missing required configuration: {{key}}",help:"Add the required configuration option"},1403:{message:"Deprecated configuration: {{key}}",help:"Update to the new configuration format"},1501:{message:"Component not found: {{name}}",help:"Check that the component exists in your components directory"},1502:{message:"Invalid props for component {{name}}: {{details}}",help:"Check the component prop requirements"},1503:{message:"Error rendering component {{name}}: {{details}}",help:"Check the component template for errors"},1601:{message:"Filter not found: {{filter}}",help:"Register the filter or check the filter name"},1602:{message:"Invalid arguments for filter {{filter}}: {{details}}",help:"Check the filter documentation for correct arguments"},1603:{message:"Expression evaluation timed out",help:"Simplify the expression or increase the timeout"}},L={},u="en";function Gq(q){u=q}function Bq(){return u}function Hq(q){L={...L,...q}}function Wq(){L={}}function f(q,J={}){let Q=L[q]||Vq[q]||{message:`Unknown error (code: ${q})`},Z=Q.message,$=Q.help;for(let[X,V]of Object.entries(J)){let Y=`{{${X}}}`;if(Z=Z.replace(new RegExp(Y,"g"),V),$)$=$.replace(new RegExp(Y,"g"),V)}return{message:Z,help:$}}function Mq(q,J={}){let{message:Q,help:Z}=f(q,J);return Z?`${Q}
3
+ Help: ${Z}`:Q}var w={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603};function S(q){for(let[J,Q]of Object.entries(w))if(Q===q)return J;return}function Iq(){return!1}function k(){return!Iq()||process.env.STX_DEBUG==="true"}function aq(){return!1}import wq from"path";var x={showRelativePaths:!1,enableAutoRecovery:k(),logRecoveryWarnings:!0},D={...x};function Fq(q){D={...D,...q}}function _(){return{...D}}function jq(){D={...x}}function N(q){if(!D.showRelativePaths||!q)return q;let J=D.baseDir||process.cwd();try{let Q=wq.relative(J,q);return Q.startsWith("..")?q:Q}catch{return q}}class U extends Error{code;filePath;line;column;context;numericCode;constructor(q,J,Q,Z,$,X,V){super(q);this.code=J;this.filePath=Q;this.line=Z;this.column=$;this.context=X;if(this.name="StxError",this.numericCode=V||w.EVALUATION_ERROR,this.filePath)this.filePath=N(this.filePath)}}class m extends U{constructor(q,J,Q,Z,$,X){super(q,"stx_SYNTAX_ERROR",J,Q,Z,$,X||w.INVALID_DIRECTIVE_SYNTAX);this.name="StxSyntaxError"}}class c extends U{constructor(q,J,Q,Z,$,X){super(q,"stx_RUNTIME_ERROR",J,Q,Z,$,X||w.EVALUATION_ERROR);this.name="StxRuntimeError"}}class d extends U{constructor(q,J,Q,Z,$,X){super(q,"stx_SECURITY_ERROR",J,Q,Z,$,X||w.UNSAFE_EXPRESSION);this.name="StxSecurityError"}}class p extends U{constructor(q,J,Q,Z,$,X){super(q,"stx_FILE_ERROR",J,Q,Z,$,X||w.FILE_NOT_FOUND);this.name="StxFileError"}}class l extends U{isFatal=!0;constructor(q,J,Q,Z,$,X){super(q,"stx_VALIDATION_ERROR",J,Q,Z,$,X||w.DOM_API_VIOLATION);this.name="StxValidationError"}}function P(q){let{type:J,message:Q,code:Z,filePath:$,line:X,column:V,template:Y,offset:B,snippet:G,suggestion:H,format:W="text"}=q,M=X,I=V;if(!M&&Y&&B!==void 0){let y=s(Y,B);M=y.line,I=y.column}let j=$?N($):void 0,Yq=Z?S(Z):void 0,K={type:J,code:Z,codeName:Yq,message:Q,filePath:j,line:M,column:I,snippet:G,suggestion:H,timestamp:new Date().toISOString()},O;switch(W){case"html":O=Dq(K);break;case"json":O=JSON.stringify(K,null,2);break;case"console":O=Kq(K,Y,B);break;case"text":default:O=Uq(K,Y,B);break}return{formatted:O,data:K}}function Uq(q,J,Q){let Z=[],$=q.code?` [${q.codeName||q.code}]`:"";if(Z.push(`[${q.type} Error${$}]`),q.filePath){let X=q.filePath;if(q.line){if(X+=`:${q.line}`,q.column)X+=`:${q.column}`}Z.push(`at ${X}`)}if(Z.push(`
4
+ ${q.message}`),J&&q.line){let X=Oq(J,q.line,2);if(X)Z.push(`
5
+ ${X}`)}if(q.snippet)Z.push(`
6
+ Snippet: ${q.snippet}`);if(q.suggestion)Z.push(`
7
+ Suggestion: ${q.suggestion}`);return Z.join(" ")}function Dq(q){let J=q.code?` [${q.code}]`:"",Q=q.filePath?` in ${q.filePath}${q.line?`:${q.line}`:""}`:"",Z=`<!-- [${q.type} Error${J}]${Q}: ${o(q.message)}`;if(q.suggestion)Z+=` | Suggestion: ${o(q.suggestion)}`;return Z+=" -->",Z}function Kq(q,J,Q){let G=[],H=q.code?` [${q.codeName||q.code}]`:"";if(G.push(`\x1B[1m${"\x1B[31m"}\u2501\u2501\u2501 ${q.type} Error${H} \u2501\u2501\u2501${"\x1B[0m"}`),q.filePath){let W=`\x1B[36m${q.filePath}\x1B[0m`;if(q.line){if(W+=`\x1B[90m:${q.line}\x1B[0m`,q.column)W+=`\x1B[90m:${q.column}\x1B[0m`}G.push(`
8
+ \x1B[90mat\x1B[0m ${W}`)}if(G.push(`
9
+
10
+ ${q.message}`),J&&q.line){let W=kq(J,q.line,2);if(W)G.push(`
11
+
12
+ \x1B[90mContext:\x1B[0m
13
+ ${W}`)}if(q.suggestion)G.push(`
14
+
15
+ \x1B[33mSuggestion:\x1B[0m ${q.suggestion}`);return G.push(`
16
+ ${"\x1B[31m"}\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${"\x1B[0m"}`),G.join("")}function Oq(q,J,Q){let Z=q.split(`
17
+ `),$=Math.max(0,J-Q-1),X=Math.min(Z.length-1,J+Q-1),V=[];for(let Y=$;Y<=X;Y++){let B=(Y+1).toString().padStart(4),G=Y===J-1?">":" ";V.push(`${G}${B} | ${Z[Y]}`)}return V.join(`
18
+ `)}function kq(q,J,Q){let Z=q.split(`
19
+ `),$=Math.max(0,J-Q-1),X=Math.min(Z.length-1,J+Q-1),V="\x1B[90m",Y="\x1B[31m",B="\x1B[0m",G=[];for(let H=$;H<=X;H++){let W=(H+1).toString().padStart(4),M=H===J-1,I=M?"\x1B[31m>\x1B[0m":" ",j=M?`\x1B[31m${Z[H]}\x1B[0m`:`\x1B[90m${Z[H]}\x1B[0m`;G.push(`${I}\x1B[90m${W}\x1B[0m | ${j}`)}return G.join(`
20
+ `)}function o(q){return q.replace(/--/g,"- -").replace(/>/g,"&gt;")}function s(q,J){let Z=q.substring(0,J).split(`
21
+ `);return{line:Z.length,column:Z[Z.length-1].length}}function zq(q,J,Q){return P({type:q,message:J,code:Q,format:"html"}).formatted}function Lq(q,J,Q,Z,$){return P({type:q,message:J,code:$,filePath:Q,line:Z,format:"console"}).formatted}function _q(q,J,Q){let Z=Q.template.split(`
22
+ `),$=s(Q.template,Q.offset),X=`[${q} Error at line ${$.line} in ${Q.filePath}]: ${J}
23
+
24
+ `,V=Math.max(0,$.line-3),Y=Math.min(Z.length-1,$.line+2);X+=`Context:
25
+ `;for(let B=V;B<=Y;B++){let G=B+1,H=Z[B]||"",W=B===$.line-1?">":" ";X+=`${W} ${G.toString().padStart(3)}: ${H}
26
+ `}if($.line-1<Z.length){let B=" ".repeat($.column+5);X+=`${B}^
27
+ `}return X}function Nq(q,J,Q){try{return q()}catch(Z){if(Q&&Z instanceof Error)Q(Z);return J}}async function Tq(q,J,Q){try{return await q()}catch(Z){if(Q&&Z instanceof Error)Q(Z);return J}}var Aq={isEnabled(){return _().enableAutoRecovery},fixCommonSyntaxErrors(q){let J=_();if(!J.enableAutoRecovery)return{fixed:q,fixes:[]};let Q=q,Z=[],$=(Q.match(/\{\{/g)||[]).length,X=(Q.match(/\}\}/g)||[]).length;if($>X){let Y=$-X;Q+="}}".repeat(Y),Z.push(`Added ${Y} missing closing braces '}}'`)}let V=["if","foreach","for","switch","section"];for(let Y of V){let B=(Q.match(new RegExp(`@${Y}\\b`,"g"))||[]).length,G=(Q.match(new RegExp(`@end${Y}\\b`,"g"))||[]).length;if(B>G){let H=B-G;for(let W=0;W<H;W++)Q+=`
28
+ @end${Y}`;Z.push(`Added ${H} missing @end${Y}`)}}if(Z.length>0&&J.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),Z.forEach((Y)=>console.warn(` - ${Y}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:Q,fixes:Z}},createFallbackContent(q,J){if(k())return`<!-- ${q} failed: ${J.message} -->`;return"<!-- stx rendering error -->"}};class C{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor(q={}){this.maxErrors=q.maxErrors??1000,this.enableFileLogging=q.enableFileLogging??!1,this.logFilePath=q.logFilePath??".stx/errors.log",this.logFormat=q.logFormat??"json",this.maxFileSize=q.maxFileSize??10485760,this.maxLogFiles=q.maxLogFiles??5,this.minLevel=q.minLevel??"all"}configure(q){if(q.maxErrors!==void 0)this.maxErrors=q.maxErrors;if(q.enableFileLogging!==void 0)this.enableFileLogging=q.enableFileLogging;if(q.logFilePath!==void 0)this.logFilePath=q.logFilePath;if(q.logFormat!==void 0)this.logFormat=q.logFormat;if(q.maxFileSize!==void 0)this.maxFileSize=q.maxFileSize;if(q.maxLogFiles!==void 0)this.maxLogFiles=q.maxLogFiles;if(q.minLevel!==void 0)this.minLevel=q.minLevel}log(q,J,Q="error"){let Z={timestamp:new Date,error:q,context:J,level:Q};if(this.errors.push(Z),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(Q))this.writeToFile(Z)}shouldLog(q){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return q==="error"||q==="warning";if(this.minLevel==="error")return q==="error";return!0}formatEntry(q){if(this.logFormat==="json")return JSON.stringify({timestamp:q.timestamp.toISOString(),level:q.level||"error",type:q.error.constructor.name,message:q.error.message,stack:q.error.stack,context:q.context});let J=[`[${q.timestamp.toISOString()}] [${(q.level||"error").toUpperCase()}] ${q.error.constructor.name}: ${q.error.message}`];if(q.error.stack)J.push(` Stack: ${q.error.stack.split(`
29
+ `).slice(1).join(`
30
+ `)}`);if(q.context)J.push(` Context: ${JSON.stringify(q.context)}`);return J.join(`
31
+ `)}writeToFile(q){this.writeQueue=this.writeQueue.then(async()=>{try{let J=await import("fs"),Z=(await import("path")).dirname(this.logFilePath);if(!J.existsSync(Z))J.mkdirSync(Z,{recursive:!0});await this.rotateIfNeeded(J);let $=`${this.formatEntry(q)}
32
+ `;J.appendFileSync(this.logFilePath,$,"utf-8")}catch(J){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",J)}})}async rotateIfNeeded(q){try{if(!q.existsSync(this.logFilePath))return;if(q.statSync(this.logFilePath).size<this.maxFileSize)return;for(let Q=this.maxLogFiles-1;Q>=1;Q--){let Z=`${this.logFilePath}.${Q}`,$=`${this.logFilePath}.${Q+1}`;if(q.existsSync(Z))if(Q>=this.maxLogFiles-1)q.unlinkSync(Z);else q.renameSync(Z,$)}if(this.maxLogFiles<=1)q.writeFileSync(this.logFilePath,"");else q.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(J){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",J)}}getRecentErrors(q=10){return this.errors.slice(-q)}getErrorsByType(q){return this.errors.filter((J)=>J.error.constructor.name===q)}getErrorsByLevel(q){return this.errors.filter((J)=>J.level===q)}clear(){this.errors.length=0}async clearLogFile(){try{let q=await import("fs");if(q.existsSync(this.logFilePath))q.writeFileSync(this.logFilePath,"","utf-8")}catch(q){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",q)}}getStats(){let q={},J={error:0,warning:0,info:0};for(let Q of this.errors){let Z=Q.error.constructor.name;q[Z]=(q[Z]||0)+1;let $=Q.level||"error";J[$]=(J[$]||0)+1}return{total:this.errors.length,byType:q,byLevel:J}}async exportToFile(q,J="json"){let Q=await import("fs"),$=(await import("path")).dirname(q);if(!Q.existsSync($))Q.mkdirSync($,{recursive:!0});if(J==="json"){let X=this.errors.map((V)=>({timestamp:V.timestamp.toISOString(),level:V.level||"error",type:V.error.constructor.name,message:V.error.message,stack:V.error.stack,context:V.context}));Q.writeFileSync(q,JSON.stringify(X,null,2),"utf-8")}else{let X=this.errors.map((V)=>this.formatEntry(V));Q.writeFileSync(q,X.join(`
33
+
34
+ `),"utf-8")}}async flush(){await this.writeQueue}}var Rq=new C,bq={isDevelopment(){return k()},logDetailedError(q,J){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",q.message),console.error("Stack:",q.stack),J)console.error("Context:",J);console.error("========================")},createErrorReport(q,J){let Q=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${q.message}`,`Type: ${q.constructor.name}`,`Stack: ${q.stack}`];if(J)Q.push(`Context: ${JSON.stringify(J,null,2)}`);return Q.push("========================"),Q.join(`
35
+ `)}};import g from"path";var v={isValidFilePath(q,J){let Q=q.replace(/\\/g,"/");if(Q.includes("\x00"))return!1;if(Q.includes("../")||Q.includes("..\\")||Q===".."||Q.startsWith("../")||Q.endsWith("/..")||Q.includes("/..\\")||Q.includes("\\../"))return!1;if(/^[a-z][a-z0-9+.-]*:/i.test(Q))return!1;if(Q.startsWith("/")){if(["/etc/","/root/","/var/","/usr/","/bin/","/sbin/","/proc/","/sys/","/dev/","/boot/","/home/","/private/","/Library/","/System/"].some((X)=>Q===X.slice(0,-1)||Q.startsWith(X)))return!1}if(/^[a-z]:/i.test(Q)){if(["Windows/","Windows\\","System32/","System32\\","Program Files/","Program Files\\"].some((X)=>Q.includes(X)))return!1}if(J){let $=g.resolve(J,q),X=g.resolve(J);if(!$.startsWith(X+g.sep)&&$!==X)return!1}return!0},isValidVariableName(q){return/^[a-z_$]\w*$/i.test(q)},isValidDirectiveName(q){return/^[a-z][\w-]*$/i.test(q)},isSafeContent(q){return![/<script[^>]*>[\s\S]*?<\/script>/i,/javascript:/i,/data:text\/html/i,/vbscript:/i,/on\w+\s*=/i].some((Q)=>Q.test(q))}};function Sq(q){let J={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return q.replace(/[&<>"']/g,(Q)=>J[Q]||Q)}function T(q,J={}){let{allowHtml:Q=!1,maxLength:Z=1e4,allowSpecialChars:$=!0,customSanitizer:X}=J,V=[],Y=q,B=!1;if(X){let H=X(Y);if(H!==Y)Y=H,B=!0}if(Y.includes("\x00"))Y=Y.replace(/\0/g,""),B=!0,V.push("Null bytes removed from parameter");if(Y.length>Z)Y=Y.substring(0,Z),B=!0,V.push(`Parameter truncated to ${Z} characters`);if(!Q&&/<[^>]+>/.test(Y))Y=Sq(Y),B=!0,V.push("HTML content was escaped");let G=[{pattern:/javascript:/gi,replacement:"",name:"javascript: URI"},{pattern:/vbscript:/gi,replacement:"",name:"vbscript: URI"},{pattern:/data:text\/html/gi,replacement:"",name:"data:text/html URI"}];for(let{pattern:H,replacement:W,name:M}of G)if(H.test(Y))Y=Y.replace(H,W),B=!0,V.push(`Removed ${M} from parameter`);if(!$){let H=Y;if(Y=Y.split("").filter((W)=>{let M=W.charCodeAt(0);return M>=32&&M!==127}).join(""),Y!==H)B=!0,V.push("Control characters removed")}return{value:Y,modified:B,warnings:V}}function Pq(q,J){let Q=q.replace(/\0/g,"");Q=Q.replace(/\\/g,"/"),Q=Q.replace(/^[a-z][a-z0-9+.-]*:/i,"");while(Q.includes("../")||Q.includes("./"))Q=Q.replace(/\.\.\//g,"").replace(/\.\//g,"");if(!v.isValidFilePath(Q,J))return null;return Q}function Cq(q){let J=[],Q=q.trim(),Z=Q!==q,$=[{pattern:/\beval\s*\(/gi,name:"eval()"},{pattern:/\bFunction\s*\(/gi,name:"Function()"},{pattern:/\bsetTimeout\s*\(/gi,name:"setTimeout()"},{pattern:/\bsetInterval\s*\(/gi,name:"setInterval()"},{pattern:/\bimport\s*\(/gi,name:"dynamic import()"},{pattern:/\brequire\s*\(/gi,name:"require()"},{pattern:/\b__proto__\b/gi,name:"__proto__"},{pattern:/\bconstructor\b/gi,name:"constructor"},{pattern:/\bprototype\b/gi,name:"prototype"}];for(let{pattern:X,name:V}of $)if(X.test(Q))J.push(`Potentially dangerous pattern detected: ${V}`);if(Q.includes("\x00"))Q=Q.replace(/\0/g,""),Z=!0,J.push("Null bytes removed from expression");return{value:Q,modified:Z,warnings:J}}function gq(q,J={}){return q.map((Q)=>T(Q,J))}function r(q){let J={};for(let[Q,Z]of Object.entries(q)){if(!v.isValidVariableName(Q))continue;if(typeof Z==="string"){let $=T(Z);J[Q]=$.value}else if(Array.isArray(Z))J[Q]=Z.map(($)=>typeof $==="string"?T($).value:$);else if(typeof Z==="object"&&Z!==null)J[Q]=r(Z);else J[Q]=Z}return J}var vq={maxSanitizeDepth:10,allowBracketNotation:!1},e={...vq};var R=/\bnew\s+/,b="__stx_safe_ctors",qq=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,R,/\bdelete\s+/,/\bthis\b/],hq=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",b]),Jq=new Set(["__proto__","constructor","prototype"]),Eq=/[\w)\]]\s*\[\s*['"]/;function Qq(q){let J="",Q=[],Z=null,$=!1;for(let X=0;X<q.length;X++){let V=q[X];if($){$=!1;continue}if(V==="\\"&&Z){$=!0;continue}if(Z){if(Z==="`"&&V==="$"&&X+1<q.length&&q[X+1]==="{"){let Y=1;X+=2;while(X<q.length&&Y>0){if(q[X]==="{")Y++;else if(q[X]==="}")Y--;if(Y>0)J+=q[X],Q.push(X),X++}continue}if(V===Z)Z=null;continue}if(V==='"'||V==="'"||V==="`"){Z=V;continue}J+=V,Q.push(X)}return{text:J,map:Q}}function yq(q){return Qq(q).text}var Zq=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],$q=(()=>{let q={Date,URL,URLSearchParams},J=Intl;for(let Q of Zq)if(typeof J[Q]==="function")q[`Intl_${Q}`]=J[Q];return Object.freeze(Object.assign(Object.create(null),q))})(),uq=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,n=/(?<![\w$])new(?![\w$])/g,i=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Zq.join(",")}}() are allowed`;function fq(q){let{text:J,map:Q}=Qq(q),Z=[];n.lastIndex=0;let $;while(($=n.exec(J))!==null){let V=$.index;if(/(?<!\.)\.\s*$/.test(J.slice(0,V)))continue;let Y=uq.exec(J.slice(V)),B=Y?.[3],G=!Y?null:B?`Intl_${B}`:Y[2];if(!Y||!G||!(G in $q))throw new F(`matched /${R.source}/; ${i}`,q);let H=V+Y[0].length,W=Q[V],M=Q[H-1]+1;if(q.slice(W,M)!==J.slice(V,H))throw new F(`matched /${R.source}/; ${i}`,q);let I=W+3+Y[1].length;Z.push({start:I,end:I+Y[2].length,key:G})}let X=q;for(let V=Z.length-1;V>=0;V--){let Y=Z[V];X=`${X.slice(0,Y.start)}${b}.${Y.key}${X.slice(Y.end)}`}return{source:X,usesSafeConstructors:Z.length>0}}class F extends Error{rule;expression;constructor(q,J,Q){super(Q??`Potentially unsafe expression (${q}): ${J}`);this.name="UnsafeExpressionError",this.rule=q,this.expression=J}}function KJ(q){try{return E(q),null}catch(J){return J instanceof F?J.rule:J instanceof Error?J.message:String(J)}}function xq(q,J){let Q=/[$A-Z_a-z][$\w]*/g,Z;while((Z=Q.exec(q))!==null){let $=Z[0],X=q[Z.index-1];if(hq.has($))throw new F(`matched /\\b${$}\\b/; identifier ${$}`,J);if(X==="."&&Jq.has($))throw new F(`matched /.${$}/; property ${$}`,J)}}function mq(q){let J=/\[\s*(['"])(.*?)\1\s*\]/g,Q;while((Q=J.exec(q))!==null){let Z=Q[2];if(!Jq.has(Z))continue;let $=q.slice(0,Q.index).match(/\S(?=\s*$)/)?.[0],X=q.slice(Q.index+Q[0].length).match(/^\s*(\S)/)?.[1];if(!(($==="{"||$===",")&&X===":"))throw new F(`bracket key ${Q[2]}`,q)}}function E(q){let J=q.trim(),Q=yq(J);xq(Q,J),mq(J);for(let Z of qq){if(Z===R)continue;if(Z.test(Q))throw new F(`matched /${Z.source}/`,J)}if(!e.allowBracketNotation&&Eq.test(J))throw new F("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",J,`Bracket notation with strings not allowed: ${J}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);return fq(J)}function cq(q){return E(q),q.trim()}function dq(q){let J={};J.Math=Math,J.JSON=JSON,J.Date=Date,J.String=String,J.Number=Number,J.Boolean=Boolean,J.Array=Array,J.parseInt=Number.parseInt,J.parseFloat=Number.parseFloat,J.isNaN=Number.isNaN,J.isFinite=Number.isFinite,J.encodeURIComponent=encodeURIComponent,J.decodeURIComponent=decodeURIComponent;for(let[Q,Z]of Object.entries(q)){if(Q.startsWith("__")||qq.some(($)=>$.test(Q)))continue;if(Z&&typeof Z==="object"&&!Array.isArray(Z))J[Q]=h(Z);else J[Q]=Z}return J}function h(q,J=0){if(J>=e.maxSanitizeDepth)return"[Object too deep]";if(q===null||typeof q!=="object")return q;if(Array.isArray(q))return q.map((Z)=>h(Z,J+1));if(q instanceof Date||q instanceof RegExp||q instanceof Map||q instanceof Set||q instanceof Error)return q;let Q={};for(let[Z,$]of Object.entries(q)){if(Z.startsWith("__")||Z==="constructor"||Z==="prototype")continue;if($&&typeof $==="object")Q[Z]=h($,J+1);else Q[Z]=$}return Q}function pq(q,J){try{let Q=dq(J),Z=Object.keys(Q),$=Object.values(Q);return rq(q,Z)(...$)}catch{return}}function OJ(q){try{return cq(q),!0}catch{return!1}}function kJ(q,J){try{let Q=pq(q,J);if(Q&&typeof Q==="object"&&!Array.isArray(Q))return Q;return{}}catch{return{}}}var Xq=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),lq=2000,A=new Map;function a(q,J){let Q=`${q.join(",")}\x00${J}`,Z=A.get(Q);if(Z)return Z;let $=Function(...q,J);if(A.size>=lq)A.clear();return A.set(Q,$),$}function zJ(q){return q.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g,"$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g)||[]}var oq=/^[A-Za-z_$][\w$]*$/;function sq(q){return oq.test(q)&&!Xq.has(q)}function rq(q,J){let{source:Q,usesSafeConstructors:Z}=E(q),$=[];for(let G=0;G<J.length;G++){if(!sq(J[G]))continue;if(J[G]===b)continue;$.push({key:J[G],index:G})}$.sort((G,H)=>G.key.localeCompare(H.key));let X=$.map((G)=>G.key),V=$.map((G)=>G.index),Y=`
36
+ 'use strict';
37
+ try {
38
+ return ${Q};
39
+ }
40
+ catch (e) {
41
+ if (e instanceof TypeError) {
42
+ return undefined;
43
+ }
44
+ throw e;
45
+ }
46
+ `;return nq(Z?(G)=>{let H=a([b,...X,...G],Y);return(...W)=>H($q,...W)}:(G)=>a([...X,...G],Y),X,J,$,V)}function nq(q,J,Q,Z,$){let X=q([]),V=Z.every((B,G)=>B.index===G);if(J.length===Q.length&&V)return t(X,J,q);return t((...B)=>{let G=Array($.length);for(let H=0;H<$.length;H++)G[H]=B[$[H]];return X(...G)},J,q,(B)=>{X=q(B)})}function t(q,J,Q,Z){let X=/^(\w+) is not defined$/,V=q,Y=[],B=new Set(J);return(...G)=>{for(let H=0;H<=8;H++)try{return V(...G)}catch(W){let M=W instanceof Error?W.message:"",I=X.exec(M);if(!(W instanceof ReferenceError)||!I)return;let j=I[1];if(B.has(j)||Xq.has(j))return;if(B.add(j),Y.push(j),Z)Z(Y);else V=Q(Y)}return}}function LJ(q){let J=q.trim(),Q=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let Z of Q)if(Z.test(J))return!1;return!0}
47
+ export{Gq as Vt,Bq as Wt,Hq as Xt,Wq as Yt,f as Zt,Mq as _t,w as $t,S as au,Iq as bu,k as cu,aq as du,Fq as eu,_ as fu,jq as gu,N as hu,U as iu,m as ju,c as ku,d as lu,p as mu,l as nu,P as ou,zq as pu,Lq as qu,_q as ru,Nq as su,Tq as tu,Aq as uu,C as vu,Rq as wu,bq as xu,v as yu,T as zu,Pq as Au,Cq as Bu,gq as Cu,r as Du,KJ as Eu,cq as Fu,pq as Gu,OJ as Hu,kJ as Iu,zJ as Ju,sq as Ku,rq as Lu,LJ as Mu};