@stacksjs/stx 0.2.810 → 0.2.811

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 (81) hide show
  1. package/dist/{chunk-jmzxgp9p.js → chunk-15hfs2cp.js} +1 -1
  2. package/dist/{chunk-yehy1zs5.js → chunk-161n5e5y.js} +5 -5
  3. package/dist/{chunk-qyqebgw2.js → chunk-16p71jmw.js} +2 -2
  4. package/dist/{chunk-j68h08nm.js → chunk-1jr259ct.js} +1 -1
  5. package/dist/{chunk-93rd9wf9.js → chunk-1jwqjdk7.js} +1 -1
  6. package/dist/chunk-20bcj7cm.js +2 -0
  7. package/dist/{chunk-h8mqh8ds.js → chunk-20qn18ry.js} +2 -2
  8. package/dist/{chunk-damrq7b8.js → chunk-390v4dv9.js} +1 -1
  9. package/dist/{chunk-87c3w0xd.js → chunk-3affwe7d.js} +1 -1
  10. package/dist/{chunk-x8663zag.js → chunk-3fq9v4a4.js} +1 -1
  11. package/dist/{chunk-x0s53atg.js → chunk-3hzdpc0m.js} +1 -1
  12. package/dist/chunk-3tf2wwwt.js +2 -0
  13. package/dist/{chunk-prj88r9z.js → chunk-3y6jhcrb.js} +1 -1
  14. package/dist/{chunk-gmqtk1wn.js → chunk-41n0qrc0.js} +1 -1
  15. package/dist/chunk-45bh5bjj.js +2 -0
  16. package/dist/{chunk-4k42f3ca.js → chunk-4664b8rv.js} +1 -1
  17. package/dist/{chunk-ge9fbfd0.js → chunk-49xn95m7.js} +1 -1
  18. package/dist/chunk-4jmzw6kg.js +2 -0
  19. package/dist/{chunk-frq9x6th.js → chunk-5ffzbq9r.js} +2 -2
  20. package/dist/{chunk-f1wwn3tg.js → chunk-66mz8bf3.js} +1 -1
  21. package/dist/{chunk-r81yx50m.js → chunk-6ct3hhae.js} +1 -1
  22. package/dist/{chunk-d2nd3608.js → chunk-6nskg4sx.js} +1 -1
  23. package/dist/{chunk-np3rrzg4.js → chunk-7d1kx4zz.js} +1 -1
  24. package/dist/{chunk-xz1qz9b9.js → chunk-7vqhm1rx.js} +1 -1
  25. package/dist/{chunk-hv5wqtq6.js → chunk-8aw5chnj.js} +1 -1
  26. package/dist/{chunk-ry9fpa1j.js → chunk-aak95hpm.js} +1 -1
  27. package/dist/{chunk-h7h38k0r.js → chunk-agcfhj1v.js} +1 -1
  28. package/dist/{chunk-6df7h4ay.js → chunk-c84fwzfq.js} +4 -4
  29. package/dist/{chunk-yd0b6am5.js → chunk-cm23d335.js} +1 -1
  30. package/dist/{chunk-merxtsaf.js → chunk-cx2bwpfj.js} +1 -1
  31. package/dist/{chunk-gdc9s90b.js → chunk-cxf2pdjk.js} +1 -1
  32. package/dist/{chunk-0d2wgdv3.js → chunk-ds9c47sj.js} +1 -1
  33. package/dist/{chunk-9k4fvbrz.js → chunk-e3qkbq8g.js} +1 -1
  34. package/dist/chunk-ehmy6gyb.js +2 -0
  35. package/dist/{chunk-1dvj9fk1.js → chunk-evnznyg7.js} +1 -1
  36. package/dist/chunk-ez0d7fpw.js +2 -0
  37. package/dist/{chunk-0z96accg.js → chunk-f33wwacc.js} +4 -4
  38. package/dist/{chunk-s04bbm66.js → chunk-fg20p7by.js} +1 -1
  39. package/dist/{chunk-ezdj63ds.js → chunk-j54ph3jm.js} +2 -2
  40. package/dist/{chunk-rmbm30ew.js → chunk-jd1mvgwb.js} +3 -3
  41. package/dist/{chunk-hn5tnxk1.js → chunk-jf0cn7e2.js} +2 -2
  42. package/dist/chunk-jqhcst3j.js +2 -0
  43. package/dist/chunk-jvs9g0c0.js +2 -0
  44. package/dist/{chunk-yfpm91fg.js → chunk-k11bkgx6.js} +1 -1
  45. package/dist/{chunk-ftfvezbd.js → chunk-kfgbk0x9.js} +1 -1
  46. package/dist/{chunk-9pcrtvje.js → chunk-kr5jhk30.js} +1 -1
  47. package/dist/{chunk-nv77aaqa.js → chunk-m76jbcey.js} +6 -6
  48. package/dist/{chunk-6tefkmq9.js → chunk-mfnyqcfg.js} +1 -1
  49. package/dist/{chunk-gqse3ae0.js → chunk-mt7d37jh.js} +1 -1
  50. package/dist/{chunk-stdbnr1p.js → chunk-n15eyqcr.js} +1 -1
  51. package/dist/{chunk-61j62gya.js → chunk-n9pbkj5v.js} +1 -1
  52. package/dist/{chunk-af54x4dj.js → chunk-ncmdmgrj.js} +1 -1
  53. package/dist/{chunk-h8p8ekbk.js → chunk-nk51w4tw.js} +1 -1
  54. package/dist/chunk-p8eg9kne.js +2 -0
  55. package/dist/{chunk-bkjfbhyp.js → chunk-peabdz2j.js} +1 -1
  56. package/dist/chunk-pmrkv7v3.js +2 -0
  57. package/dist/{chunk-knpzhqns.js → chunk-q4efhj8q.js} +1 -1
  58. package/dist/{chunk-43g83xk1.js → chunk-s1w9nxws.js} +1 -1
  59. package/dist/{chunk-awvgv3wx.js → chunk-vt5nrrax.js} +4 -4
  60. package/dist/{chunk-09dfp38y.js → chunk-vz5beayx.js} +1 -1
  61. package/dist/{chunk-q0em38za.js → chunk-w050qx5j.js} +2 -2
  62. package/dist/{chunk-t8njsjr9.js → chunk-y3jx43d7.js} +4 -4
  63. package/dist/chunk-y6pyr4km.js +3 -0
  64. package/dist/{chunk-vqry8gqr.js → chunk-zfes9kn1.js} +1 -1
  65. package/dist/cli.js +7 -7
  66. package/dist/craft-entry.js +1 -1
  67. package/dist/craft.js +1 -1
  68. package/dist/pwa.js +1 -1
  69. package/dist/ssg.js +2 -2
  70. package/package.json +5 -5
  71. package/dist/chunk-0khbjbvg.js +0 -2
  72. package/dist/chunk-1xj0vmrs.js +0 -2
  73. package/dist/chunk-32wcsw1n.js +0 -2
  74. package/dist/chunk-51q4z1g6.js +0 -2
  75. package/dist/chunk-6k0273zm.js +0 -2
  76. package/dist/chunk-e2ywh4ax.js +0 -2
  77. package/dist/chunk-jye7txe4.js +0 -3
  78. package/dist/chunk-kgw99r6d.js +0 -2
  79. package/dist/chunk-p6b21gkk.js +0 -2
  80. package/dist/chunk-x293v8r5.js +0 -2
  81. package/dist/chunk-zmtggvf0.js +0 -2
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import"./chunk-gebb12ak.js";import"./chunk-ybjfr7e8.js";import"./chunk-r9e0r6jx.js";import"./chunk-nv77aaqa.js";import"./chunk-m7hfcxt3.js";import"./chunk-ftfvezbd.js";import"./chunk-2ws2qe1k.js";import"./chunk-93rd9wf9.js";import{c}from"./chunk-0rjcbqk3.js";import u from"fs";import l from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||c(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=l.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),m=JSON.parse(p);if(m.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
2
+ import"./chunk-gebb12ak.js";import"./chunk-ybjfr7e8.js";import"./chunk-r9e0r6jx.js";import"./chunk-m76jbcey.js";import"./chunk-m7hfcxt3.js";import"./chunk-kfgbk0x9.js";import"./chunk-2ws2qe1k.js";import"./chunk-1jwqjdk7.js";import{c}from"./chunk-0rjcbqk3.js";import u from"fs";import l from"path";async function d(e,t={}){let s=Date.now(),n={total:0,passed:0,failed:0,new:0,failures:[],duration:0},i=t.snapshotDir||c(e.root,"story","snapshots");await u.promises.mkdir(i,{recursive:!0});let r=e.storyFiles;if(t.filter&&t.filter.length>0)r=r.filter((a)=>t.filter.some((o)=>a.fileName.toLowerCase().includes(o.toLowerCase())));for(let a of r)await h(a,i,t,n);return n.duration=Date.now()-s,n}async function h(e,t,s,n){let i=e.story;if(!i)return;for(let r of i.variants){n.total++;let a=l.join(t,`${e.id}-${r.id}.snap`),o=g(r.source||""),f=await w(a);if(s.update||!f){let p={storyId:e.id,variantId:r.id,component:e.fileName,timestamp:Date.now(),hash:o};if(await u.promises.writeFile(a,JSON.stringify(p,null,2)),!f)n.new++;n.passed++}else try{let p=await u.promises.readFile(a,"utf-8"),m=JSON.parse(p);if(m.hash===o)n.passed++;else n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:"Snapshot mismatch",difference:y(m.hash,o)})}catch(p){n.failed++,n.failures.push({storyId:e.id,variantId:r.id,component:e.fileName,message:`Error reading snapshot: ${p}`})}}}async function x(e,t={}){return(await d(e,{...t,update:!0})).total}function g(e){let t=0;for(let s=0;s<e.length;s++){let n=e.charCodeAt(s);t=(t<<5)-t+n,t=t&t}return t.toString(16)}function y(e,t){if(e===t)return 0;let s=Math.abs(Number.parseInt(e,16)-Number.parseInt(t,16));return Math.min(s/1e6,1)}async function w(e){try{return await u.promises.access(e),!0}catch{return!1}}function F(e){let t=[];if(t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(" STX Story Visual Regression Tests"),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),e.failures.length>0){t.push(" \u274C Failures:"),t.push("");for(let s of e.failures){if(t.push(` \u2022 ${s.component} / ${s.variantId}`),t.push(` ${s.message}`),s.difference!==void 0)t.push(` Difference: ${(s.difference*100).toFixed(2)}%`);t.push("")}}if(t.push(" Summary:"),t.push(` Total: ${e.total}`),t.push(` Passed: ${e.passed} \u2713`),t.push(` Failed: ${e.failed} \u2717`),e.new>0)t.push(` New: ${e.new} \u26A1`);return t.push(` Time: ${e.duration}ms`),t.push(""),t.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),t.push(""),t.join(`
3
3
  `)}export{F as formatTestResults,d as runVisualTests,x as updateSnapshots};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Kg}from"./chunk-66mz8bf3.js";import"./chunk-jd1mvgwb.js";import"./chunk-vz5beayx.js";import"./chunk-3y6jhcrb.js";import"./chunk-y6pyr4km.js";import"./chunk-f33wwacc.js";import"./chunk-20qn18ry.js";import"./chunk-1jwqjdk7.js";import"./chunk-2ws2qe1k.js";import"./chunk-vbc8a8fh.js";import"./chunk-3z0e637x.js";import"./chunk-bmkm1c8s.js";import"./chunk-m76jbcey.js";import"./chunk-kfgbk0x9.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{Kg as startProductionServer};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Rc,s,fe}from"./chunk-nv77aaqa.js";import{nt}from"./chunk-5emrarpf.js";import{c}from"./chunk-0rjcbqk3.js";import o from"fs";import l from"path";var Df=new Map,m=new Map;async function Oh(e){let n;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(r){n=r;break}throw m.delete(e),Error(`File not found: ${e}${n?` (${n.message})`:""}`)}function Nh(e){m.delete(e)}function Mh(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function Dh(e){x=e}async function Lf(e=!1){let t=x??await import("./chunk-1ydz2w3t.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function jf(){if(S===null){let{getRouterScript:e}=await import("./chunk-qckgv0vz.js");S=e()}return S}var y={};async function Lh(e,t=!1){let n=e==="runtime"?await Lf(t):await jf(),i=e==="runtime"&&t?"runtime-debug":e,r=y[i];if(!r||r.content!==n)r={content:n,hash:Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)},y[i]=r;return{content:n,hash:r.hash,url:`/_stx/${e}.${r.hash}.js`}}var E=500,T=33554432,u=new Map,p=0;function C(e){return c(process.cwd(),"module-bundles",`${e}.js`)}function jh(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),n=u.get(t),i=n!==void 0;if(i)u.delete(t),p-=n.length*2;u.set(t,e),p+=e.length*2;while(u.size>1&&(u.size>E||p>T)){let r=u.keys().next().value;p-=u.get(r).length*2,u.delete(r)}if(!i)try{let r=C(t);if(!o.existsSync(r))o.mkdirSync(l.dirname(r),{recursive:!0}),o.writeFileSync(r,e)}catch{}return`/_stx/modules.${t}.js`}function Xo(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function Bh(){m.clear(),fe(),Rc(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((n)=>({name:n.name,timing:n.timing,handler:String(n.handler)})),customDirectives:(e.customDirectives??[]).map((n)=>({name:n.name,hasEndTag:n.hasEndTag===!0,rawParams:n.rawParams===!0,handler:String(n.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function lr(e,t){try{if(!t.cachePath)return null;let n=l.resolve(t.cachePath),i=l.join(n,`${vs(e)}.html`),r=l.join(n,`${vs(e)}.meta.json`);if(!await s(i)||!await s(r))return null;let g=await Bun.file(r).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==nt())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await s(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(n){return console.warn(`Cache error for ${e}:`,n),null}}async function ur(e,t,n,i){try{if(!i.cachePath)return;let r=l.resolve(i.cachePath);await o.promises.mkdir(r,{recursive:!0});let g=l.join(r,`${vs(e)}.html`),a=l.join(r,`${vs(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(n),cacheVersion:i.cacheVersion,engine:nt(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),Df.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:n})}catch(r){console.warn(`Failed to cache template ${e}:`,r)}}var _=16;function vs(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
2
+ import{Rc,s,fe}from"./chunk-m76jbcey.js";import{nt}from"./chunk-5emrarpf.js";import{c}from"./chunk-0rjcbqk3.js";import o from"fs";import l from"path";var Df=new Map,m=new Map;async function Oh(e){let n;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(r){n=r;break}throw m.delete(e),Error(`File not found: ${e}${n?` (${n.message})`:""}`)}function Nh(e){m.delete(e)}function Mh(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function Dh(e){x=e}async function Lf(e=!1){let t=x??await import("./chunk-1ydz2w3t.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function jf(){if(S===null){let{getRouterScript:e}=await import("./chunk-qckgv0vz.js");S=e()}return S}var y={};async function Lh(e,t=!1){let n=e==="runtime"?await Lf(t):await jf(),i=e==="runtime"&&t?"runtime-debug":e,r=y[i];if(!r||r.content!==n)r={content:n,hash:Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)},y[i]=r;return{content:n,hash:r.hash,url:`/_stx/${e}.${r.hash}.js`}}var E=500,T=33554432,u=new Map,p=0;function C(e){return c(process.cwd(),"module-bundles",`${e}.js`)}function jh(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),n=u.get(t),i=n!==void 0;if(i)u.delete(t),p-=n.length*2;u.set(t,e),p+=e.length*2;while(u.size>1&&(u.size>E||p>T)){let r=u.keys().next().value;p-=u.get(r).length*2,u.delete(r)}if(!i)try{let r=C(t);if(!o.existsSync(r))o.mkdirSync(l.dirname(r),{recursive:!0}),o.writeFileSync(r,e)}catch{}return`/_stx/modules.${t}.js`}function Xo(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function Bh(){m.clear(),fe(),Rc(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((n)=>({name:n.name,timing:n.timing,handler:String(n.handler)})),customDirectives:(e.customDirectives??[]).map((n)=>({name:n.name,hasEndTag:n.hasEndTag===!0,rawParams:n.rawParams===!0,handler:String(n.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function lr(e,t){try{if(!t.cachePath)return null;let n=l.resolve(t.cachePath),i=l.join(n,`${vs(e)}.html`),r=l.join(n,`${vs(e)}.meta.json`);if(!await s(i)||!await s(r))return null;let g=await Bun.file(r).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==nt())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await s(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(n){return console.warn(`Cache error for ${e}:`,n),null}}async function ur(e,t,n,i){try{if(!i.cachePath)return;let r=l.resolve(i.cachePath);await o.promises.mkdir(r,{recursive:!0});let g=l.join(r,`${vs(e)}.html`),a=l.join(r,`${vs(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(n),cacheVersion:i.cacheVersion,engine:nt(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),Df.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:n})}catch(r){console.warn(`Failed to cache template ${e}:`,r)}}var _=16;function vs(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
3
3
  export{Df,Oh,Nh,Mh,Dh,Lf,jf,Lh,jh,Xo,Bh,lr,ur,vs};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{er,$e}from"./chunk-7sh9fa3q.js";import{H,b,br,Ls,C}from"./chunk-nv77aaqa.js";import{a,I}from"./chunk-h8mqh8ds.js";import{Oo}from"./chunk-prj88r9z.js";import{nt}from"./chunk-5emrarpf.js";import{c}from"./chunk-0rjcbqk3.js";import{r,ge}from"./chunk-3vpgr6nk.js";import p from"path";import B from"fs";import{AsyncLocalStorage as xt}from"async_hooks";import{randomUUID as yt}from"crypto";var $t=11;function W(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(p.basename(t))||Oo(t,e,n)}var at=2;function wf(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?p.resolve(e):c(t,"bundle-cache")}function st(t,e){let n=t;for(let i of wt(e))if(i!==p.sep)n=n.split(i).join("\x00root");return n}var rt=new Map;function wt(t){let e=p.resolve(t),n=rt.get(e);if(!n){let i=e;try{i=B.realpathSync(e)}catch{}n=[...new Set([e,i])].sort((l,d)=>d.length-l.length),rt.set(e,n)}return n}function bt(t,e){try{let n=B.statSync(t),i=p.resolve(e),l=t.startsWith(`${i}${p.sep}`);return{path:l?p.relative(i,t):t,...l?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(B.readFileSync(t)).toString(36)}}catch{return null}}function ct(t,e){return t.inRoot?p.join(p.resolve(e),t.path):t.path}function St(t,e){for(let n of t){let i=ct(n,e);try{let l=B.statSync(i);if(l.size!==n.size)return!1;if(l.mtimeMs!==n.mtimeMs&&Bun.hash(B.readFileSync(i)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var lt=new Map,vt=100;function vf(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function jt(t){let e=G.get(t)??0;if(e>0&&e<vt){G.set(t,e+1);return}G.set(t,1);try{let n=(await B.promises.readdir(t)).filter((o)=>o.endsWith(".js")),i=vf();if(n.length<=i)return;let d=(await Promise.all(n.map(async(o)=>{try{return{name:o,at:(await B.promises.stat(p.join(t,o))).mtimeMs}}catch{return null}}))).filter((o)=>o!==null);d.sort((o,w)=>w.at-o.at);for(let o of d.slice(i)){let w=o.name.slice(0,-3);await B.promises.rm(p.join(t,`${w}.js`),{force:!0}),await B.promises.rm(p.join(t,`${w}.deps.json`),{force:!0})}A("pruned bundle cache to",i,"entries")}catch{}}function he(t){return lt.get(t)??[]}function Z(t,e){if(t)lt.set(t,e)}function xf(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function A(...t){if(xf())console.log("[stx:bundler]",...t)}var K=[];function ec(t,e,n){K.push({filePath:t||"<inline>",message:e,details:n})}function en(){return K.slice()}function tn(){K.length=0}var Q;function Sh(t){Q=t}function tc(){if(Q)return Q;try{let t=I.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Y=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function nn(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let l=n[1];if(!Y.some((o)=>o.test(l)))return A("detected user import:",l),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=i.exec(t))!==null){let l=n[1];if(/\.css(?:\?.*)?$/.test(l))continue;if(!Y.some((o)=>o.test(l)))return A("detected side-effect import:",l),!0}return!1}var Qn="stx-module:",Bt=/\.(?:[cm]?[jt]sx?|json)$/i;function Sf(t,e){return p.relative(t,e).split(p.sep).join("/")}function kf(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,i,l,d)=>{let o=e.get(d);return o&&!d.startsWith(Qn)?`${i}${l}${o}${l}`:n})}function _f(t,e){let n=0,i=(d)=>{let o=`__stxMod${n++}`,w=JSON.stringify(d);return e.push(`var ${o} = globalThis.__stxModules && globalThis.__stxModules[${w}];`,`if (${o} === undefined) throw new Error("[stx] module " + ${JSON.stringify(w)} + " is not registered on this page (#1957)");`),o},l=(d,o)=>{for(let w of d.split(",")){let D=w.trim();if(!D)continue;let M=D.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!M)continue;let S=M[1].startsWith('"')?JSON.parse(M[1]):M[1],f=M[2]??S;e.push(`var ${f} = ${o}[${JSON.stringify(S)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(d,o,w)=>{let D=w.slice(Qn.length),M=i(D),S=o.trim(),f=S.match(/^([\w$]+)\s*(?:,\s*|$)/);if(f&&!S.startsWith("{")&&!S.startsWith("*"))e.push(`var ${f[1]} = ${M}.default;`),S=S.slice(f[0].length).trim();let v=S.match(/^\*\s*as\s+([\w$]+)$/);if(v)e.push(`var ${v[1]} = ${M};`);else if(S.startsWith("{"))l(S.replace(/^\{|\}$/g,""),M);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(d,o)=>(i(o.slice(Qn.length)),"")),t}function it(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,p.join(t,"index.ts"),p.join(t,"index.tsx"),p.join(t,"index.js"),p.join(t,"index.mjs")];for(let n of e)try{if(B.existsSync(n)&&B.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var X=new xt;function os(t,e){let n=new Bun.CryptoHasher("md5");for(let[i,l]of[...t].sort(([d],[o])=>d<o?-1:d>o?1:0))n.update(`${i}\x00${l}\x00`);return X.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function rn(){return X.getStore()?.key??""}function ut(t,e,n,i,l,d,o=new Map,w,D,M){let S=new Map([[n,i],...M??[]]),f=(j)=>j!==void 0&&S.has(j),v=(j,s,u)=>{if(W(s,t,w))return null;if(!d||!f(j)||!Bt.test(s))return null;try{if(!B.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}l.add(s);let E=`${Qn}${Sf(process.cwd(),s)}`;return o.set(u,E),{path:E,external:!0}},y=(j,s)=>{let u=f(j)?e:p.dirname(j),E=p.resolve(u,s);return it(E)??E};return{name:"stx-client-bundle",setup(j){if(j.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),j.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),j.onResolve({filter:/^\//},(s)=>{if(f(s.path))return{path:s.path};let u=it(s.path);if(u){let E=v(s.importer,u,s.path);if(E)return E;if(!f(u))l.add(u);return{path:u}}return{path:s.path,external:!0}}),j.onResolve({filter:/^\.\.?\//},(s)=>{let u=y(s.importer,s.path),E=v(s.importer,u,s.path);if(E)return E;return l.add(u),{path:u}}),j.onResolve({filter:/^[@~]\//},(s)=>{let u=p.resolve(t,s.path.slice(2)),E=[u,`${u}.ts`,`${u}.tsx`,`${u}.js`,`${u}.mjs`,`${u}.jsx`,p.join(u,"index.ts"),p.join(u,"index.tsx"),p.join(u,"index.js"),p.join(u,"index.mjs")];for(let h of E)if(B.existsSync(h)&&B.statSync(h,{throwIfNoEntry:!1})?.isFile()){let O=v(s.importer,h,s.path);if(O)return O;return A(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",h),l.add(h),{path:h}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:u}}),d)j.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(!f(s.importer))return;let u=`${Qn}npm:${s.path}`;return o.set(s.path,u),{path:u,external:!0}});j.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(S.has(s.path))return{contents:S.get(s.path),loader:"ts"};if(W(s.path,t,w))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let u=p.extname(s.path).toLowerCase(),E=u===".json"?"json":u===".tsx"?"tsx":u===".jsx"?"jsx":u===".ts"||u===".mts"||u===".cts"?"ts":"js";if(!f(s.path))l.add(s.path);let h=D?.get(s.path);if(h!==void 0)return{contents:h,loader:"js"};return{contents:B.readFileSync(s.path,"utf8"),loader:E}})}}}var q=new Map,P=b(64),ot=Symbol.for("stx.client-bundle-build-queue");function Cf(t){let e=globalThis,i=(e[ot]??Promise.resolve()).then(t,t);return e[ot]=i.then(()=>{return},()=>{return}),i}async function sn(t,e,n={}){let i=n.projectRoot||process.cwd(),l=(await a(i)).serverApi,d=n.minify??!1,o=n.externalizeUserModules??!0,w=n.expose?.length?[...new Set(n.expose)].sort():void 0,D=n.cacheDir||wf(i),M=X.getStore(),S=new Bun.CryptoHasher("md5");S.update(`${$t}\x00${nt()}\x00${JSON.stringify(l??!1)}\x00${o?"registry":"inline"}\x00${w?w.join(","):"*"}\x00${d?"minified":"readable"}\x00${M?.key??""}\x00${st(t,i)}\x00${st(e,i)}`);let f=S.digest("hex").slice(0,12),v=p.join(D,`${f}.js`),y=P.get(v);if(y){if(Ls(y.files)&&y.files.every((h)=>!W(h.path,i,l))){A("memo hit:",f);let h=y.files.map((O)=>O.path);return Z(e,h),n.collectInputs?.push(...h),y.code}P.delete(v),A("memo invalidated by dep change:",f)}let j=p.join(D,`${f}.deps.json`),s=Bun.file(v);if(await s.exists()){let h=Bun.file(j),O=!1,k=null;if(await h.exists())try{let N=JSON.parse(await h.text());if(N.metadataVersion===at&&Array.isArray(N.files)&&St(N.files,i))k=br(N.files.map((g)=>ct(g,i))),O=k.length===N.files.length&&!k.some((g)=>W(g.path,i,l))}catch{O=!1}if(O){if(A("cache hit:",f),k)Z(e,k.map((U)=>U.path)),n.collectInputs?.push(...k.map((U)=>U.path));let N=await s.text(),g=new Date;if(B.promises.utimes(v,g,g).catch(()=>{}),k)P.set(v,{code:N,files:k});return N}A("cache invalidated by dep change:",f)}let u=q.get(f);if(u){let h=await u;if(n.collectInputs)n.collectInputs.push(...(P.get(v)?.files??[]).map((O)=>O.path));return h}let E=Cf(()=>Et(t,e,{projectRoot:i,minify:d,cacheDir:D,hash:f,cachePath:v,depsPath:j,collectInputs:n.collectInputs,externalizeUserModules:o,serverApi:l,expose:w,throwOnFailure:n.throwOnFailure,substitutes:M?.modules}));q.set(f,E);try{return await E}finally{q.delete(f)}}function nc(t){return`${t}-${process.pid}-${yt()}`}async function kh(t,e){let{projectRoot:n}=e,i=nc(new Bun.CryptoHasher("md5").update([...t.keys()].join("\x00")).digest("hex").slice(0,12)),l=p.join(c(n,"bundle-tmp"),"out",i);B.mkdirSync(l,{recursive:!0});let d=new Map,o=new Map,w=0;for(let[f,v]of t){let y=p.join(n,`.stx-split-${i}-${w++}.ts`);d.set(y,v),o.set(p.basename(y).replace(/\.ts$/,""),f)}let[D,M]=[...d][0],S=new Set;try{let f=await Bun.build({entrypoints:[...d.keys()],outdir:l,target:"browser",format:"esm",splitting:!0,minify:!1,naming:{entry:"[name].js",chunk:"chunk-[hash].js"},plugins:[ut(n,p.dirname(e.filePath),D,M,S,!1,new Map,void 0,X.getStore()?.modules,d)],define:{"process.env.NODE_ENV":'"development"',...C()},root:n});if(!f.success)throw Error(f.logs.filter((y)=>y.level==="error").map((y)=>y.message).join(", ")||"Unable to bundle the entries");let v={entries:new Map,chunks:new Map};for(let y of f.outputs){let j=p.basename(y.path);if(y.kind==="entry-point"){let s=o.get(j.replace(/\.js$/,""));if(s!==void 0)v.entries.set(s,await y.text())}else if(y.kind==="chunk")v.chunks.set(j.replace(/\.js$/,""),await y.text())}return e.collectInputs?.push(...S),v}finally{try{B.rmSync(l,{recursive:!0,force:!0})}catch{}}}async function Et(t,e,n){let{projectRoot:i,minify:l,cacheDir:d,hash:o,cachePath:w,depsPath:D,externalizeUserModules:M}=n,S=c(i,"bundle-tmp"),f=nc(o),v=p.join(i,`.stx-client-${f}.ts`),y=p.join(S,"out",f);B.mkdirSync(y,{recursive:!0});let j=p.dirname(e),s=new Set,u=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,E=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,h=r(t),{depths:O,balanced:k}=ge(h),N=(R)=>!k||O[R]===0,g;while((g=u.exec(h))!==null){if(g[1])continue;if(!N(g.index))continue;if(g[2])g[2].split(",").forEach((R)=>{let m=_t(R);if(m)s.add(m)});else if(g[3])s.add(g[3])}while((g=E.exec(h))!==null){if(g[1])continue;if(!N(g.index))continue;s.add(g[2])}let U=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=U.exec(h))!==null){if(!N(g.index))continue;let R=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(R&&Y.some((m)=>m.test(R)))continue;if(g[1])s.add(g[1]);if(g[2])s.add(g[2]);for(let m of(g[3]??"").split(",")){let _=m.trim();if(!_||/^type\s/.test(_))continue;let L=/\bas\s+(\w+)\s*$/.exec(_)?.[1]??/^\w+$/.exec(_)?.[0];if(L)s.add(L)}}for(let R of h.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let m of R[1].split(",")){let _=/\bas\s+(\w+)\s*$/.exec(m)?.[1]??/^\s*(\w+)\s*$/.exec(m)?.[1];if(_)s.delete(_)}let pt=s.size>0?`
2
+ import{er,$e}from"./chunk-7sh9fa3q.js";import{H,b,br,Ls,C}from"./chunk-m76jbcey.js";import{a,I}from"./chunk-20qn18ry.js";import{Oo}from"./chunk-3y6jhcrb.js";import{nt}from"./chunk-5emrarpf.js";import{c}from"./chunk-0rjcbqk3.js";import{r,ge}from"./chunk-3vpgr6nk.js";import p from"path";import B from"fs";import{AsyncLocalStorage as xt}from"async_hooks";import{randomUUID as yt}from"crypto";var $t=11;function W(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(p.basename(t))||Oo(t,e,n)}var at=2;function wf(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?p.resolve(e):c(t,"bundle-cache")}function st(t,e){let n=t;for(let i of wt(e))if(i!==p.sep)n=n.split(i).join("\x00root");return n}var rt=new Map;function wt(t){let e=p.resolve(t),n=rt.get(e);if(!n){let i=e;try{i=B.realpathSync(e)}catch{}n=[...new Set([e,i])].sort((l,d)=>d.length-l.length),rt.set(e,n)}return n}function bt(t,e){try{let n=B.statSync(t),i=p.resolve(e),l=t.startsWith(`${i}${p.sep}`);return{path:l?p.relative(i,t):t,...l?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(B.readFileSync(t)).toString(36)}}catch{return null}}function ct(t,e){return t.inRoot?p.join(p.resolve(e),t.path):t.path}function St(t,e){for(let n of t){let i=ct(n,e);try{let l=B.statSync(i);if(l.size!==n.size)return!1;if(l.mtimeMs!==n.mtimeMs&&Bun.hash(B.readFileSync(i)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var lt=new Map,vt=100;function vf(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function jt(t){let e=G.get(t)??0;if(e>0&&e<vt){G.set(t,e+1);return}G.set(t,1);try{let n=(await B.promises.readdir(t)).filter((o)=>o.endsWith(".js")),i=vf();if(n.length<=i)return;let d=(await Promise.all(n.map(async(o)=>{try{return{name:o,at:(await B.promises.stat(p.join(t,o))).mtimeMs}}catch{return null}}))).filter((o)=>o!==null);d.sort((o,w)=>w.at-o.at);for(let o of d.slice(i)){let w=o.name.slice(0,-3);await B.promises.rm(p.join(t,`${w}.js`),{force:!0}),await B.promises.rm(p.join(t,`${w}.deps.json`),{force:!0})}A("pruned bundle cache to",i,"entries")}catch{}}function he(t){return lt.get(t)??[]}function Z(t,e){if(t)lt.set(t,e)}function xf(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function A(...t){if(xf())console.log("[stx:bundler]",...t)}var K=[];function ec(t,e,n){K.push({filePath:t||"<inline>",message:e,details:n})}function en(){return K.slice()}function tn(){K.length=0}var Q;function Sh(t){Q=t}function tc(){if(Q)return Q;try{let t=I.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Y=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function nn(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let l=n[1];if(!Y.some((o)=>o.test(l)))return A("detected user import:",l),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=i.exec(t))!==null){let l=n[1];if(/\.css(?:\?.*)?$/.test(l))continue;if(!Y.some((o)=>o.test(l)))return A("detected side-effect import:",l),!0}return!1}var Qn="stx-module:",Bt=/\.(?:[cm]?[jt]sx?|json)$/i;function Sf(t,e){return p.relative(t,e).split(p.sep).join("/")}function kf(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,i,l,d)=>{let o=e.get(d);return o&&!d.startsWith(Qn)?`${i}${l}${o}${l}`:n})}function _f(t,e){let n=0,i=(d)=>{let o=`__stxMod${n++}`,w=JSON.stringify(d);return e.push(`var ${o} = globalThis.__stxModules && globalThis.__stxModules[${w}];`,`if (${o} === undefined) throw new Error("[stx] module " + ${JSON.stringify(w)} + " is not registered on this page (#1957)");`),o},l=(d,o)=>{for(let w of d.split(",")){let D=w.trim();if(!D)continue;let M=D.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!M)continue;let S=M[1].startsWith('"')?JSON.parse(M[1]):M[1],f=M[2]??S;e.push(`var ${f} = ${o}[${JSON.stringify(S)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(d,o,w)=>{let D=w.slice(Qn.length),M=i(D),S=o.trim(),f=S.match(/^([\w$]+)\s*(?:,\s*|$)/);if(f&&!S.startsWith("{")&&!S.startsWith("*"))e.push(`var ${f[1]} = ${M}.default;`),S=S.slice(f[0].length).trim();let v=S.match(/^\*\s*as\s+([\w$]+)$/);if(v)e.push(`var ${v[1]} = ${M};`);else if(S.startsWith("{"))l(S.replace(/^\{|\}$/g,""),M);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(d,o)=>(i(o.slice(Qn.length)),"")),t}function it(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,p.join(t,"index.ts"),p.join(t,"index.tsx"),p.join(t,"index.js"),p.join(t,"index.mjs")];for(let n of e)try{if(B.existsSync(n)&&B.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var X=new xt;function os(t,e){let n=new Bun.CryptoHasher("md5");for(let[i,l]of[...t].sort(([d],[o])=>d<o?-1:d>o?1:0))n.update(`${i}\x00${l}\x00`);return X.run({modules:t,key:n.digest("hex").slice(0,12)},e)}function rn(){return X.getStore()?.key??""}function ut(t,e,n,i,l,d,o=new Map,w,D,M){let S=new Map([[n,i],...M??[]]),f=(j)=>j!==void 0&&S.has(j),v=(j,s,u)=>{if(W(s,t,w))return null;if(!d||!f(j)||!Bt.test(s))return null;try{if(!B.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}l.add(s);let E=`${Qn}${Sf(process.cwd(),s)}`;return o.set(u,E),{path:E,external:!0}},y=(j,s)=>{let u=f(j)?e:p.dirname(j),E=p.resolve(u,s);return it(E)??E};return{name:"stx-client-bundle",setup(j){if(j.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),j.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),j.onResolve({filter:/^\//},(s)=>{if(f(s.path))return{path:s.path};let u=it(s.path);if(u){let E=v(s.importer,u,s.path);if(E)return E;if(!f(u))l.add(u);return{path:u}}return{path:s.path,external:!0}}),j.onResolve({filter:/^\.\.?\//},(s)=>{let u=y(s.importer,s.path),E=v(s.importer,u,s.path);if(E)return E;return l.add(u),{path:u}}),j.onResolve({filter:/^[@~]\//},(s)=>{let u=p.resolve(t,s.path.slice(2)),E=[u,`${u}.ts`,`${u}.tsx`,`${u}.js`,`${u}.mjs`,`${u}.jsx`,p.join(u,"index.ts"),p.join(u,"index.tsx"),p.join(u,"index.js"),p.join(u,"index.mjs")];for(let h of E)if(B.existsSync(h)&&B.statSync(h,{throwIfNoEntry:!1})?.isFile()){let O=v(s.importer,h,s.path);if(O)return O;return A(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",h),l.add(h),{path:h}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:u}}),d)j.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(!f(s.importer))return;let u=`${Qn}npm:${s.path}`;return o.set(s.path,u),{path:u,external:!0}});j.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(S.has(s.path))return{contents:S.get(s.path),loader:"ts"};if(W(s.path,t,w))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let u=p.extname(s.path).toLowerCase(),E=u===".json"?"json":u===".tsx"?"tsx":u===".jsx"?"jsx":u===".ts"||u===".mts"||u===".cts"?"ts":"js";if(!f(s.path))l.add(s.path);let h=D?.get(s.path);if(h!==void 0)return{contents:h,loader:"js"};return{contents:B.readFileSync(s.path,"utf8"),loader:E}})}}}var q=new Map,P=b(64),ot=Symbol.for("stx.client-bundle-build-queue");function Cf(t){let e=globalThis,i=(e[ot]??Promise.resolve()).then(t,t);return e[ot]=i.then(()=>{return},()=>{return}),i}async function sn(t,e,n={}){let i=n.projectRoot||process.cwd(),l=(await a(i)).serverApi,d=n.minify??!1,o=n.externalizeUserModules??!0,w=n.expose?.length?[...new Set(n.expose)].sort():void 0,D=n.cacheDir||wf(i),M=X.getStore(),S=new Bun.CryptoHasher("md5");S.update(`${$t}\x00${nt()}\x00${JSON.stringify(l??!1)}\x00${o?"registry":"inline"}\x00${w?w.join(","):"*"}\x00${d?"minified":"readable"}\x00${M?.key??""}\x00${st(t,i)}\x00${st(e,i)}`);let f=S.digest("hex").slice(0,12),v=p.join(D,`${f}.js`),y=P.get(v);if(y){if(Ls(y.files)&&y.files.every((h)=>!W(h.path,i,l))){A("memo hit:",f);let h=y.files.map((O)=>O.path);return Z(e,h),n.collectInputs?.push(...h),y.code}P.delete(v),A("memo invalidated by dep change:",f)}let j=p.join(D,`${f}.deps.json`),s=Bun.file(v);if(await s.exists()){let h=Bun.file(j),O=!1,k=null;if(await h.exists())try{let N=JSON.parse(await h.text());if(N.metadataVersion===at&&Array.isArray(N.files)&&St(N.files,i))k=br(N.files.map((g)=>ct(g,i))),O=k.length===N.files.length&&!k.some((g)=>W(g.path,i,l))}catch{O=!1}if(O){if(A("cache hit:",f),k)Z(e,k.map((U)=>U.path)),n.collectInputs?.push(...k.map((U)=>U.path));let N=await s.text(),g=new Date;if(B.promises.utimes(v,g,g).catch(()=>{}),k)P.set(v,{code:N,files:k});return N}A("cache invalidated by dep change:",f)}let u=q.get(f);if(u){let h=await u;if(n.collectInputs)n.collectInputs.push(...(P.get(v)?.files??[]).map((O)=>O.path));return h}let E=Cf(()=>Et(t,e,{projectRoot:i,minify:d,cacheDir:D,hash:f,cachePath:v,depsPath:j,collectInputs:n.collectInputs,externalizeUserModules:o,serverApi:l,expose:w,throwOnFailure:n.throwOnFailure,substitutes:M?.modules}));q.set(f,E);try{return await E}finally{q.delete(f)}}function nc(t){return`${t}-${process.pid}-${yt()}`}async function kh(t,e){let{projectRoot:n}=e,i=nc(new Bun.CryptoHasher("md5").update([...t.keys()].join("\x00")).digest("hex").slice(0,12)),l=p.join(c(n,"bundle-tmp"),"out",i);B.mkdirSync(l,{recursive:!0});let d=new Map,o=new Map,w=0;for(let[f,v]of t){let y=p.join(n,`.stx-split-${i}-${w++}.ts`);d.set(y,v),o.set(p.basename(y).replace(/\.ts$/,""),f)}let[D,M]=[...d][0],S=new Set;try{let f=await Bun.build({entrypoints:[...d.keys()],outdir:l,target:"browser",format:"esm",splitting:!0,minify:!1,naming:{entry:"[name].js",chunk:"chunk-[hash].js"},plugins:[ut(n,p.dirname(e.filePath),D,M,S,!1,new Map,void 0,X.getStore()?.modules,d)],define:{"process.env.NODE_ENV":'"development"',...C()},root:n});if(!f.success)throw Error(f.logs.filter((y)=>y.level==="error").map((y)=>y.message).join(", ")||"Unable to bundle the entries");let v={entries:new Map,chunks:new Map};for(let y of f.outputs){let j=p.basename(y.path);if(y.kind==="entry-point"){let s=o.get(j.replace(/\.js$/,""));if(s!==void 0)v.entries.set(s,await y.text())}else if(y.kind==="chunk")v.chunks.set(j.replace(/\.js$/,""),await y.text())}return e.collectInputs?.push(...S),v}finally{try{B.rmSync(l,{recursive:!0,force:!0})}catch{}}}async function Et(t,e,n){let{projectRoot:i,minify:l,cacheDir:d,hash:o,cachePath:w,depsPath:D,externalizeUserModules:M}=n,S=c(i,"bundle-tmp"),f=nc(o),v=p.join(i,`.stx-client-${f}.ts`),y=p.join(S,"out",f);B.mkdirSync(y,{recursive:!0});let j=p.dirname(e),s=new Set,u=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,E=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,h=r(t),{depths:O,balanced:k}=ge(h),N=(R)=>!k||O[R]===0,g;while((g=u.exec(h))!==null){if(g[1])continue;if(!N(g.index))continue;if(g[2])g[2].split(",").forEach((R)=>{let m=_t(R);if(m)s.add(m)});else if(g[3])s.add(g[3])}while((g=E.exec(h))!==null){if(g[1])continue;if(!N(g.index))continue;s.add(g[2])}let U=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=U.exec(h))!==null){if(!N(g.index))continue;let R=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(R&&Y.some((m)=>m.test(R)))continue;if(g[1])s.add(g[1]);if(g[2])s.add(g[2]);for(let m of(g[3]??"").split(",")){let _=m.trim();if(!_||/^type\s/.test(_))continue;let L=/\bas\s+(\w+)\s*$/.exec(_)?.[1]??/^\w+$/.exec(_)?.[0];if(L)s.add(L)}}for(let R of h.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let m of R[1].split(",")){let _=/\bas\s+(\w+)\s*$/.exec(m)?.[1]??/^\s*(\w+)\s*$/.exec(m)?.[1];if(_)s.delete(_)}let pt=s.size>0?`
3
3
  export { ${[...s].join(", ")} }`:"";A("bundling:",o,"from:",p.basename(e));let tt=new Set,et=new Map;try{let R=await Bun.build({entrypoints:[v],outdir:y,target:"browser",format:"esm",minify:l?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[ut(i,j,v,t+pt,tt,M,et,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":l?'"production"':'"development"',...C()},root:i});if(!R.success){let F=R.logs.filter((T)=>T.level==="error").map((T)=>T.message).join(", ")||`Unable to bundle ${p.basename(e)}`,z=er(R.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",F),ec(e||"",F,z),n.throwOnFailure||tc()==="error")throw Error(F);return t}let m="";for(let x of R.outputs){m=await x.text();break}let _=[];for(let x of m.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let F of x[1].split(",")){let z=F.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(z){_.push([z[2],z[1]]);continue}let T=F.trim();if(/^[A-Za-z_$][\w$]*$/.test(T))_.push([T,T])}if(n.expose){let x=new Set(n.expose);for(let F=_.length-1;F>=0;F--)if(!x.has(_[F][0]))_.splice(F,1)}let L=[];m=_f(kf(m,et),L);let dt=m.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(m=m.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),l&&m)try{m=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(m)}catch{}let V=`__stxBundle_${o}`,ft=new Set(H(t,!0).split(",").map((x)=>x.trim())),mt=_.map(([x,F])=>`get ${JSON.stringify(x)}() { return ${F} }${ft.has(x)?`, set ${JSON.stringify(x)}(__stxValue_${F}) { ${F} = __stxValue_${F} }`:""}`).join(", "),gt=_.map(([x])=>`var ${x} = undefined;`).join(`
4
4
  `),ht=_.map(([x])=>`${x} = ${V}[${JSON.stringify(x)}];`).join(`
5
5
  `);if(m=`${dt.join(`
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{tm}from"./chunk-aak95hpm.js";import"./chunk-jd1mvgwb.js";import"./chunk-gb3tv53p.js";import"./chunk-vz5beayx.js";import"./chunk-3y6jhcrb.js";import"./chunk-c84fwzfq.js";import"./chunk-j54ph3jm.js";import"./chunk-y3jx43d7.js";import"./chunk-c84pxd2k.js";import"./chunk-kr5jhk30.js";import"./chunk-y6pyr4km.js";import"./chunk-q4efhj8q.js";import"./chunk-y7sf7aj0.js";import"./chunk-jf0cn7e2.js";import"./chunk-f33wwacc.js";import"./chunk-1carv1dw.js";import"./chunk-4664b8rv.js";import"./chunk-20qn18ry.js";import"./chunk-1jwqjdk7.js";import"./chunk-2ws2qe1k.js";import"./chunk-vbc8a8fh.js";import"./chunk-3z0e637x.js";import"./chunk-bmkm1c8s.js";import"./chunk-m76jbcey.js";import"./chunk-kfgbk0x9.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{tm as buildForProduction};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{lt,ut,dt}from"./chunk-7qk4exw1.js";import"./chunk-ybjfr7e8.js";import"./chunk-r9e0r6jx.js";import"./chunk-gebb12ak.js";import{m}from"./chunk-nv77aaqa.js";import"./chunk-m7hfcxt3.js";import"./chunk-ftfvezbd.js";import{Vt,no,Ut,Vi,ct,Ui,ro,Wt,qi,qt}from"./chunk-rpen41w3.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Ui("Config file changed, restarting...");try{await e.onChange()}catch(p){ct(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",pt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:pt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:mt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function mt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
2
+ import{lt,ut,dt}from"./chunk-7qk4exw1.js";import"./chunk-ybjfr7e8.js";import"./chunk-r9e0r6jx.js";import"./chunk-gebb12ak.js";import{m}from"./chunk-m76jbcey.js";import"./chunk-m7hfcxt3.js";import"./chunk-kfgbk0x9.js";import{Vt,no,Ut,Vi,ct,Ui,ro,Wt,qi,qt}from"./chunk-rpen41w3.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{Ui("Config file changed, restarting...");try{await e.onChange()}catch(p){ct(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:at(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),g=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:g}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function at(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var it=".stx/story/bookmarks.json",pt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,it),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:pt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:mt(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function mt(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
3
3
  <script>
4
4
  (function() {
5
5
  const ws = new WebSocket('${t}');
@@ -556,7 +556,7 @@ window.__stxPerformance = {
556
556
 
557
557
  window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
558
558
  </script>
559
- `}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-1xj0vmrs.js"),p={},g=h(n);if(g)try{await m(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),u=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await m(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-1xj0vmrs.js"),c={...r},n=h(e);if(n)try{await m(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
559
+ `}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-ez0d7fpw.js"),p={},g=h(n);if(g)try{await m(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),u=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:u,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await m(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-ez0d7fpw.js"),c={...r},n=h(e);if(n)try{await m(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
560
560
  `)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
561
561
  `)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function rt(t,e){let r=await Wt(t);ut(t,r);let s=qt(t.config,r);dt(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),g=`http://${o}:${e.port}`,y=qi(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let u=await Wt(t);ut(t,u);let f=qt(t.config,u);if(dt(t,f),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=g;try{let{exec:l}=await import("child_process"),u=process.platform;l(`${u==="darwin"?"open":u==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:g,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],g=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((u)=>u.id===p);if(!l)return new Response("Story not found",{status:404});try{let u=await Y(t,l,g,y);return Response.json({html:u.html,css:u.css,js:u.js,errors:u.errors,duration:u.duration})}catch(u){return Response.json({html:"",css:"",js:"",errors:[u instanceof Error?u.message:String(u)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((g)=>g.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
562
562
  <html lang="en" class="${r.darkClass||"dark"}">
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{ze,N,Dt}from"./chunk-m7hfcxt3.js";import{R}from"./chunk-gebb12ak.js";import{ft,Ce,L,qe,Ee,da,ho,pa,In}from"./chunk-rmbm30ew.js";import{St,ue,et}from"./chunk-bmkm1c8s.js";import{Io}from"./chunk-prj88r9z.js";import{On}from"./chunk-j3st59hv.js";import{be}from"./chunk-0z96accg.js";import Z from"fs";import P from"path";var{serve:ce}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((a)=>e.startsWith(a)))return!1;return te.some((a)=>e.startsWith(a))}function oe(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ae(t){if(!t)return null;let e=oe(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ie(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[a,r]of H){if(U<=Y)break;H.delete(a),U-=r.length}}async function $n(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let r=ae(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(i.length<(a.threshold??re))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=H.get(g);if(!l)l=r==="br"?await K(i,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await ee(i),ie(g,l);if(l.length>=i.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new R(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",L(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Ce(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await a();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((C)=>C.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((C)=>C!=="x-stx-router"&&C!=="accept-encoding"))return null;let E=await s.clone().arrayBuffer();if(E.byteLength>1048576)return null;s.headers.set("Vary",L(s.headers.get("Vary")).Vary);let n={body:E,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return i();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let M=await v;return M?l(M):i()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function Kg(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=da(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let i=On(r.routeRules),f=new G,h=Io(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?N(l):void 0,b=new Map,k=new Map,v=new Map,M=new Map;for(let n of r.routes)try{let C=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(C).text());if(m)c.html=Dt(c.html,m);b.set(n.pattern,c),v.set(n.pattern,et(c.html)),M.set(n.pattern,be(c.html));let X=P.join(e,n.fragmentPath);if(qe(c.html,r.routerContainer||"main")&&await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Dt(A,m):A)}}catch(C){console.warn(`[stx] Failed to load route ${n.pattern}:`,C)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:C,params:c}=ue(n.pattern,{page:!0});S.push({regex:C,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ce({port:a,async fetch(n){return $n(n,await ze(m??N(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let y=P.extname(u).toLowerCase(),B=pe[y]||"application/octet-stream",_=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":B,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=Ce(n),w=null,q={};if(w=s.get(c)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let o=c.match(p);if(o){w=d,u.forEach((y,B)=>{q[y]=o[B+1]});break}}if(!w){let p=St(c)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=i(c),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=k.get(w.pattern);if(o){let y=v.get(w.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...M.has(w.pattern)?{"X-STX-Runtime":M.get(w.pattern)?"true":"false"}:{},...y?{"X-STX-Layout":y.layout,"X-STX-Layout-Group":y.group}:{},...L(),...O.cache?{}:{"Cache-Control":ft}}})}}let d=ho(n.method),u=b.get(w.pattern);if(!u){let o=s.get("/500")||null;if(o){let y=b.get(o.pattern);if(y)return new Response(y.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...L(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:y,redirect:B,cookies:_,status:I,headers:D}=await In(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return pa(B,_,D);if(y&&y.length>0){let{renderStreamingPage:T,streamToResponse:z}=await import("./chunk-6tefkmq9.js"),j=new Headers({...L(),...D,"Cache-Control":"private, no-store"});for(let V of _??[])j.append("Set-Cookie",V);if(A&&!d&&qe(o,r.routerContainer||"main")){let V=et(o);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",be(o)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(T(A&&!d&&qe(o,r.routerContainer||"main")?Ee(o,r.routerContainer||"main",!0):o,y,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let x=new Headers({"Content-Type":"text/html",...L(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of _??[])x.append("Set-Cookie",T);for(let[T,z]of Object.entries(D??{}))x.set(T,z);if(x.set("Vary",L(x.get("Vary")).Vary),A&&!d&&qe(o,r.routerContainer||"main")){let T=et(o);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",be(o)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(Ee(o,r.routerContainer||"main",!0),{status:I??u.status??200,headers:x})}return new Response(o,{status:I??u.status??200,headers:x})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${E.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:E.port,stop:()=>{f.invalidate(),E.stop()},invalidate:(n)=>f.invalidate(n)}}
2
+ import{ze,N,Dt}from"./chunk-m7hfcxt3.js";import{R}from"./chunk-gebb12ak.js";import{ft,Ce,L,qe,Ee,da,ho,pa,In}from"./chunk-jd1mvgwb.js";import{St,ue,et}from"./chunk-bmkm1c8s.js";import{Io}from"./chunk-3y6jhcrb.js";import{On}from"./chunk-j3st59hv.js";import{be}from"./chunk-f33wwacc.js";import Z from"fs";import P from"path";var{serve:ce}=globalThis.Bun;import F from"zlib";import{promisify as Q}from"util";var K=Q(F.brotliCompress),ee=Q(F.gzip),te=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],ne=["text/event-stream","multipart/x-mixed-replace"],re=1024;function se(t){if(!t)return!1;let e=t.toLowerCase();if(ne.some((a)=>e.startsWith(a)))return!1;return te.some((a)=>e.startsWith(a))}function oe(t){let e=new Map;for(let a of t.split(",")){let[r,...i]=a.trim().split(";"),f=r.trim().toLowerCase();if(!f)continue;let h=1;for(let g of i){let l=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(g);if(!l)continue;let m=Number.parseFloat(l[1]);if(Number.isFinite(m))h=m}e.set(f,h)}return e}function ae(t){if(!t)return null;let e=oe(t),a=e.get("*"),r=(i)=>e.get(i)??a??0;if(r("br")>0)return"br";if(r("gzip")>0)return"gzip";return null}var Y=33554432,H=new Map,U=0;function ie(t,e){if(e.length>Y/8)return;H.set(t,e),U+=e.length;for(let[a,r]of H){if(U<=Y)break;H.delete(a),U-=r.length}}async function $n(t,e,a={}){if(e.headers.get("content-encoding"))return e;if(e.status===204||e.status===304||!e.body)return e;if(!se(e.headers.get("content-type")))return e;let r=ae(t.headers.get("accept-encoding"));if(!r)return e;let i;try{i=new Uint8Array(await e.arrayBuffer())}catch{return e}let f=()=>new Response(i,{status:e.status,statusText:e.statusText,headers:J(e.headers)});if(i.length<(a.threshold??re))return f();try{let h=a.quality??5,g=`${r}:${h}:${i.length}:${Bun.hash(i)}`,l=H.get(g);if(!l)l=r==="br"?await K(i,{params:{[F.constants.BROTLI_PARAM_QUALITY]:h,[F.constants.BROTLI_PARAM_SIZE_HINT]:i.length}}):await ee(i),ie(g,l);if(l.length>=i.length)return f();let m=J(e.headers);return m.set("Content-Encoding",r),m.set("Content-Length",String(l.length)),new Response(l,{status:e.status,statusText:e.statusText,headers:m})}catch{return f()}}function J(t){let e=new Headers(t),a=e.get("Vary");if(!a)return e.set("Vary","Accept-Encoding"),e;if(!a.split(",").some((i)=>i.trim().toLowerCase()==="accept-encoding"))e.set("Vary",`${a}, Accept-Encoding`);return e}class G{now;entries=new R(1000,{maxBytes:33554432,sizeOf:(t)=>t.body.byteLength+JSON.stringify(t.headers).length*2});pending=new Map;generation=0;constructor(t=Date.now){this.now=t}invalidate(t){this.generation++,this.pending.clear();for(let e of Array.from(this.entries.keys()))if(t===void 0||this.entries.get(e)?.path===t)this.entries.delete(e)}async respond(t,e,a){let r,i=async()=>{let s=r??await a();return s.headers.set("Cache-Control","private, no-store"),s.headers.set("Vary",L(s.headers.get("Vary")).Vary),s};if(!e||t.method!=="GET"||t.headers.has("Cookie")||t.headers.has("Authorization")||t.headers.has("Range"))return i();let f=new URL(t.url),h=`${f.origin}${f.pathname}${f.search}|${Ce(t)?"fragment":"document"}`,g=this.entries.get(h),l=(s)=>{let S=new Headers(s.headers);return S.set("Cache-Control","private, no-store"),S.set("Age",String(Math.max(0,Math.floor((this.now()-s.created)/1000)))),new Response(s.body.slice(0),{headers:S})},m=g?(this.now()-g.created)/1000:1/0;if(g&&m<e.maxAge)return l(g);let b=this.generation,k=async()=>{let s=await a();r=s;let S=(s.headers.get("Vary")??"").toLowerCase().split(",").map((C)=>C.trim()).filter(Boolean);if(s.status!==200||s.headers.has("Set-Cookie")||/(?:private|no-store|no-cache)/i.test(s.headers.get("Cache-Control")??"")||S.some((C)=>C!=="x-stx-router"&&C!=="accept-encoding"))return null;let E=await s.clone().arrayBuffer();if(E.byteLength>1048576)return null;s.headers.set("Vary",L(s.headers.get("Vary")).Vary);let n={body:E,headers:Array.from(s.headers.entries()),created:this.now(),path:f.pathname};if(this.generation===b)this.entries.set(h,n);return n},v=this.pending.get(h);if(!v){if(this.pending.size>=1000)return i();v=k().finally(()=>{if(this.pending.get(h)===v)this.pending.delete(h)}),this.pending.set(h,v)}if(g&&m<e.maxAge+(e.swr??0))return v.catch(()=>{}),l(g);let M=await v;return M?l(M):i()}}var pe={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function Kg(t={}){let e=P.resolve(t.outputDir||".output"),a=t.port??3000,r=da(e);if(!r)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${r.routes.length} routes...`);let i=On(r.routeRules),f=new G,h=Io(e,r.apiRoutes??[]),g=Bun.file(P.join(e,"server/runtime-config.json")),l=t.runtimeConfig??(await g.exists()?await g.json():void 0),m=l?N(l):void 0,b=new Map,k=new Map,v=new Map,M=new Map;for(let n of r.routes)try{let C=P.join(e,n.compiledPath),c=JSON.parse(await Bun.file(C).text());if(m)c.html=Dt(c.html,m);b.set(n.pattern,c),v.set(n.pattern,et(c.html)),M.set(n.pattern,be(c.html));let X=P.join(e,n.fragmentPath);if(qe(c.html,r.routerContainer||"main")&&await Bun.file(X).exists()){let A=await Bun.file(X).text();k.set(n.pattern,m?Dt(A,m):A)}}catch(C){console.warn(`[stx] Failed to load route ${n.pattern}:`,C)}let s=new Map,S=[];for(let n of r.routes)if(n.hasParams){let{regex:C,params:c}=ue(n.pattern,{page:!0});S.push({regex:C,route:n,paramNames:c})}else s.set(n.pattern,n);let E=ce({port:a,async fetch(n){return $n(n,await ze(m??N(),async()=>{let c=new URL(n.url).pathname;if(t.onRequest){let p=await t.onRequest(n);if(p)return p}if(t.apiRouter){let p=await t.apiRouter.handleRequest(n);if(p.status!==404)return p}if(t.apiRoutes?.[c])return t.apiRoutes[c](n);let X=await h(n);if(X)return X;if((n.method==="GET"||n.method==="HEAD")&&c!=="/"){let p=P.resolve(e,"public"),d;try{d=decodeURIComponent(c)}catch{d=c}if(!d.includes("\x00")){let u=P.resolve(p,`.${d}`);if(u===p||u.startsWith(`${p}${P.sep}`))try{if(Z.existsSync(u)&&Z.statSync(u).isFile()){let y=P.extname(u).toLowerCase(),B=pe[y]||"application/octet-stream",_=c.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(c);return new Response(Bun.file(u),{headers:{"Content-Type":B,"Cache-Control":_?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let A=Ce(n),w=null,q={};if(w=s.get(c)||null,!w)for(let{regex:p,route:d,paramNames:u}of S){let o=c.match(p);if(o){w=d,u.forEach((y,B)=>{q[y]=o[B+1]});break}}if(!w){let p=St(c)?null:s.get("/404")||null;if(p){let d=b.get(p.pattern);if(d)return new Response(d.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain; charset=utf-8"}})}let O=i(c),W=Object.keys(O).length>0;return f.respond(n,O.cache,async()=>{let p=b.get(w.pattern);if(A&&n.method==="GET"&&p&&!p.hasServerScripts&&Object.keys(p.placeholders).length===0){let o=k.get(w.pattern);if(o){let y=v.get(w.pattern);return new Response(o,{status:p.status??200,headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...M.has(w.pattern)?{"X-STX-Runtime":M.get(w.pattern)?"true":"false"}:{},...y?{"X-STX-Layout":y.layout,"X-STX-Layout-Group":y.group}:{},...L(),...O.cache?{}:{"Cache-Control":ft}}})}}let d=ho(n.method),u=b.get(w.pattern);if(!u){let o=s.get("/500")||null;if(o){let y=b.get(o.pattern);if(y)return new Response(y.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(w.prerendered&&d)return new Response("Prerendered pages do not accept actions",{status:405,headers:{Allow:"GET, HEAD"}});if(!d&&!u.hasServerScripts&&Object.keys(u.placeholders).length===0)return new Response(u.html,{status:u.status??200,headers:{"Content-Type":"text/html",...L(),"Cache-Control":"public, max-age=60"}});try{let{html:o,boundaries:y,redirect:B,cookies:_,status:I,headers:D}=await In(u,{params:q,request:n,method:n.method,__stx_strict_hydration:W,__stx_runtime_config:m});if(B)return pa(B,_,D);if(y&&y.length>0){let{renderStreamingPage:T,streamToResponse:z}=await import("./chunk-mfnyqcfg.js"),j=new Headers({...L(),...D,"Cache-Control":"private, no-store"});for(let V of _??[])j.append("Set-Cookie",V);if(A&&!d&&qe(o,r.routerContainer||"main")){let V=et(o);j.set("X-STX-Fragment","true"),j.set("X-STX-Runtime",be(o)?"true":"false"),j.set("X-STX-Layout",V.layout),j.set("X-STX-Layout-Group",V.group)}return z(T(A&&!d&&qe(o,r.routerContainer||"main")?Ee(o,r.routerContainer||"main",!0):o,y,{timeoutMs:30000}),{status:I??u.status??200,headers:j})}let x=new Headers({"Content-Type":"text/html",...L(),...O.cache?{}:{"Cache-Control":"private, no-store"}});for(let T of _??[])x.append("Set-Cookie",T);for(let[T,z]of Object.entries(D??{}))x.set(T,z);if(x.set("Vary",L(x.get("Vary")).Vary),A&&!d&&qe(o,r.routerContainer||"main")){let T=et(o);return x.set("X-STX-Fragment","true"),x.set("X-STX-Runtime",be(o)?"true":"false"),x.set("X-STX-Layout",T.layout),x.set("X-STX-Layout-Group",T.group),new Response(Ee(o,r.routerContainer||"main",!0),{status:I??u.status??200,headers:x})}return new Response(o,{status:I??u.status??200,headers:x})}catch(o){if(console.error(`[stx] Hydration error for ${c}:`,o),W)return new Response("Internal Server Error",{status:500});return new Response(u.html,{headers:{"Content-Type":"text/html"}})}})}))}});return console.log(`[stx] Production server running at http://localhost:${E.port}`),console.log(`[stx] Serving ${r.routes.length} routes (${b.size} pre-loaded)`),{port:E.port,stop:()=>{f.invalidate(),E.stop()},invalidate:(n)=>f.invalidate(n)}}
3
3
  export{$n,Kg};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{xe,Pt,ci,js,Pc,Ic,Oc,Nc,_r,ui,Mc,Dc,di,hn}from"./chunk-nv77aaqa.js";import{k}from"./chunk-ybjfr7e8.js";import{a}from"./chunk-h8mqh8ds.js";import{wo}from"./chunk-d2nd3608.js";import{c}from"./chunk-0rjcbqk3.js";import{existsSync as B,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=hn.filter((e)=>!ge.has(e)).sort(),te=[...k].sort(),he=[...new Set([...ee,...te])].sort(),be=new Set(ee),ye=new Set(te),Se=new Set(he),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function ke(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let s=[];for(let d of t){if(d.offset===void 0)continue;let i=d.kind==="server"?be:ye;Y.lastIndex=0;for(let l of d.code.matchAll(Y)){let g=l.index+l[0].indexOf("{")+1;for(let u of l[1].matchAll(/[^,]+/g)){let y=u[0];if(/^\s*type\s/.test(y))continue;let b=/^\s*([A-Za-z_$][\w$]*)/.exec(y);if(!b)continue;let r=b[1];if(!Se.has(r)||i.has(r))continue;let p=d.offset+g+u.index+b[0].length-r.length,f=e.slice(0,p),T=f.split(`
2
+ import{xe,Pt,ci,js,Pc,Ic,Oc,Nc,_r,ui,Mc,Dc,di,hn}from"./chunk-m76jbcey.js";import{k}from"./chunk-ybjfr7e8.js";import{a}from"./chunk-20qn18ry.js";import{wo}from"./chunk-6nskg4sx.js";import{c}from"./chunk-0rjcbqk3.js";import{existsSync as B,readFileSync as K}from"fs";import h from"path";var ge=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),ee=hn.filter((e)=>!ge.has(e)).sort(),te=[...k].sort(),he=[...new Set([...ee,...te])].sort(),be=new Set(ee),ye=new Set(te),Se=new Set(he),Y=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function ke(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ne(e,t){let s=[];for(let d of t){if(d.offset===void 0)continue;let i=d.kind==="server"?be:ye;Y.lastIndex=0;for(let l of d.code.matchAll(Y)){let g=l.index+l[0].indexOf("{")+1;for(let u of l[1].matchAll(/[^,]+/g)){let y=u[0];if(/^\s*type\s/.test(y))continue;let b=/^\s*([A-Za-z_$][\w$]*)/.exec(y);if(!b)continue;let r=b[1];if(!Se.has(r)||i.has(r))continue;let p=d.offset+g+u.index+b[0].length-r.length,f=e.slice(0,p),T=f.split(`
3
3
  `).length;s.push({line:T,column:p-(f.lastIndexOf(`
4
4
  `)+1)+1,offset:p,length:r.length,name:r,kind:d.kind,message:ke(r,d.kind)})}}}return s}import E from"path";var we="@stacksjs/stx-typescript-plugin";function $e(e,t){let s=E.resolve(e);for(;;){let d=E.join(s,"tsconfig.json");if(t(d))return d;let i=E.dirname(s);if(i===s)return;s=i}}function ie(e,t,s){let d=$e(e,s);if(!d)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let u=t(g);if(!u)return;let y=u.compilerOptions?.plugins;if(Array.isArray(y)){let r=y.find((f)=>f?.name===we),p=Array.isArray(r?.libs)?r.libs.filter((f)=>typeof f==="string"):[];return r?{configPath:g,libs:p.map((f)=>E.resolve(E.dirname(g),f))}:null}let b=typeof u.extends==="string"?[u.extends]:Array.isArray(u.extends)?u.extends:[];for(let r of[...b].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let p=E.resolve(E.dirname(g),r.endsWith(".json")?r:`${r}.json`),f=l(p);if(f!==void 0)return f}return};return l(d)??void 0}function oa(e,t="",s=""){let d=e.startLine>1?`
5
5
  `.repeat(e.startLine-1):"",i=ci(ui(e)+e.code,t),l=js(i.code),g=e.kind==="client"||e.kind==="plain"?Oc(t,e.code):"",u=(d+l).split(`
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Ie,b,x,C,Y}from"./chunk-nv77aaqa.js";import{k}from"./chunk-ybjfr7e8.js";import{P,En}from"./chunk-r9e0r6jx.js";import{a}from"./chunk-h8mqh8ds.js";import{he,nn,rn,sn}from"./chunk-ge9fbfd0.js";import{wt}from"./chunk-hn5tnxk1.js";import{mt,zn,Gt,ce}from"./chunk-tsvnhc0c.js";import{E,Cn}from"./chunk-c5vzr1va.js";import h from"path";var v=new Map,A=new Map,I=b(64),F=new Map,V=["composables","functions"];function H(e){let s=h.basename(e,".ts");return s==="index"||s==="types"||e.endsWith(".d.ts")}async function ee(e){if(e)return h.resolve(e);let s=`<default>:${process.cwd()}`,r=F.get(s);if(r!==void 0)return r;let t=await te();if(t!==null)F.set(s,t);return t}async function te(){let e=await a(),s=e.root||process.cwd(),r=e.composablesDir;if(r)return h.resolve(s,r);for(let t of V){let n=h.resolve(s,t);try{let c=new Bun.Glob("**/*.ts");for await(let i of c.scan({cwd:n,absolute:!0}))if(!H(i))return n}catch{}}return null}async function W(e){let s=Array.isArray(e)?e:e?[h.resolve(e)]:(await a())._layerComposableDirs??[await ee()].filter((t)=>!!t),r=new Map;for(let t of s){let n=new Bun.Glob("**/*.ts");try{for await(let c of n.scan({cwd:t,absolute:!0})){let i=h.relative(t,c);if(!H(c)&&!r.has(i))r.set(i,c)}}catch{}}return{key:s.join("\x00"),files:[...r.values()].sort()}}async function wo(e){let{files:s}=await W(e),r=Y({loader:"ts",target:"browser",define:C()}),t=[];for(let n of s)try{let c=await Bun.file(n).text(),i=r.scan(c).exports.filter((u)=>u!=="default");if(i.length>0)t.push({file:n,names:i})}catch{}return t}function ne(e,s){return new RegExp(`\\b${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(e)}function R(e,s){let r=new Set(e.match(/\w+/g)),t=new Set;for(let n of s)if(/^\w+$/.test(n)?r.has(n):ne(e,n))t.add(n);return t}var J=b(64);function X(e,s){let r=x(e,s.size),t=J.get(r);if(t)return t;let n;try{n=Ie(e,s)}catch{n=R(e,s)}let c=[...e.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...e.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let i of c)for(let u of i[1].split(",")){let f=u.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(f&&s.has(f))n.add(f)}return J.set(r,n),n}function se(e){return!e||/^(?:module|(?:text|application)\/(?:java|ecma)script|application\/stx-[\w-]+)$/i.test(e)}var L=b(256);function oe(e,s){let r=new Set(s),t="",n=0,c=new Set;for(let i of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi)){t+=e.slice(n,i.index),n=i.index+i[0].length;let u=i[1]??"",f=i[2]??"",d=/\btype\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(u),m=d?(d[1]??d[2]??d[3]??"").trim():void 0;if(!se(m)){if(!/json/i.test(m??""))t+=` ${f} `;continue}let y=R(f,r);if(y.size===0)continue;let _=x(f,[...y].sort().join(",")),w=L.get(_);if(!w)w=X(f,y),L.set(_,w);for(let B of w)c.add(B)}t+=e.slice(n);for(let i of R(t,r))c.add(i);return c}function ie(e,s,r){let t=new Map;for(let{file:f,names:d}of e)for(let m of d)if(!t.has(m))t.set(m,f);let n=new Set(t.keys()),c=(f)=>{let d=[];for(let m of X(f,n))d.push(t.get(m));return d},i=new Set,u=r.flatMap((f,d)=>d===0?[...oe(f,t.keys())].map((m)=>t.get(m)):c(f));while(u.length>0){let f=[];for(let d of u){if(i.has(d))continue;i.add(d);for(let m of c(s.get(d)??""))if(!i.has(m))f.push(m)}u=f}return i}async function ch(e,s,r,t){let{key:n,files:c}=await W(e);if(!n)return null;let i=()=>[...new Set([...c,...c.flatMap((o)=>he(o))])],u=mt(i());if(c.length===0)return ce(v,n,u,""),null;c.sort();let f=Y({loader:"ts",target:"browser",define:C()}),d=Gt(A,n,u);if(!d){let o=new Map,l=[];for(let p of c)try{let S=await Bun.file(p).text();o.set(p,S);let g=f.scan(S).exports.filter((Q)=>Q!=="default");if(g.length>0)l.push({file:p,names:g})}catch{o.set(p,"")}d=ce(A,n,u,{codeByFile:o,modules:l})}let{codeByFile:m,modules:y}=d,_;if(s===void 0)_=new Set(c);else{let o=r?[s,...r]:[s],l=x(o.join("\x00"),n,o.length,u),p=I.get(l);if(_=p??ie(y,m,o),!p)I.set(l,_)}if(_.size===0)return null;let w=c.filter((o)=>_.has(o)),B=()=>{if(!t)return;for(let o of w)t.push(o,...he(o))},N=`${n}\x00${w.join("\x00")}\x00${rn()}`,U=Gt(v,N,u);if(U!==void 0)return B(),U||null;let D=[],M=new Set,T=new Set;for(let o of w)try{let l=m.get(o)??await Bun.file(o).text(),p=h.basename(o,".ts");for(let g of l.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(g[1])T.add(g[1]);let S=[];try{for(let g of f.scan(l).exports)if(g!=="default")M.add(g),S.push(g)}catch{}if(l=P(l),nn(l))l=await sn(l,o,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:S}),l=wt(l);l=En(l),l=l.replace(/^export\s+(default\s+)?/gm,""),l=f.transformSync(l),D.push(`// Composable: ${p}
2
+ import{Ie,b,x,C,Y}from"./chunk-m76jbcey.js";import{k}from"./chunk-ybjfr7e8.js";import{P,En}from"./chunk-r9e0r6jx.js";import{a}from"./chunk-20qn18ry.js";import{he,nn,rn,sn}from"./chunk-49xn95m7.js";import{wt}from"./chunk-jf0cn7e2.js";import{mt,zn,Gt,ce}from"./chunk-tsvnhc0c.js";import{E,Cn}from"./chunk-c5vzr1va.js";import h from"path";var v=new Map,A=new Map,I=b(64),F=new Map,V=["composables","functions"];function H(e){let s=h.basename(e,".ts");return s==="index"||s==="types"||e.endsWith(".d.ts")}async function ee(e){if(e)return h.resolve(e);let s=`<default>:${process.cwd()}`,r=F.get(s);if(r!==void 0)return r;let t=await te();if(t!==null)F.set(s,t);return t}async function te(){let e=await a(),s=e.root||process.cwd(),r=e.composablesDir;if(r)return h.resolve(s,r);for(let t of V){let n=h.resolve(s,t);try{let c=new Bun.Glob("**/*.ts");for await(let i of c.scan({cwd:n,absolute:!0}))if(!H(i))return n}catch{}}return null}async function W(e){let s=Array.isArray(e)?e:e?[h.resolve(e)]:(await a())._layerComposableDirs??[await ee()].filter((t)=>!!t),r=new Map;for(let t of s){let n=new Bun.Glob("**/*.ts");try{for await(let c of n.scan({cwd:t,absolute:!0})){let i=h.relative(t,c);if(!H(c)&&!r.has(i))r.set(i,c)}}catch{}}return{key:s.join("\x00"),files:[...r.values()].sort()}}async function wo(e){let{files:s}=await W(e),r=Y({loader:"ts",target:"browser",define:C()}),t=[];for(let n of s)try{let c=await Bun.file(n).text(),i=r.scan(c).exports.filter((u)=>u!=="default");if(i.length>0)t.push({file:n,names:i})}catch{}return t}function ne(e,s){return new RegExp(`\\b${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(e)}function R(e,s){let r=new Set(e.match(/\w+/g)),t=new Set;for(let n of s)if(/^\w+$/.test(n)?r.has(n):ne(e,n))t.add(n);return t}var J=b(64);function X(e,s){let r=x(e,s.size),t=J.get(r);if(t)return t;let n;try{n=Ie(e,s)}catch{n=R(e,s)}let c=[...e.matchAll(/(?:const|let|var)\s*\{([^}]*)\}\s*=\s*window\.__composables\u0008/g),...e.matchAll(/import\s*\{([^}]*)\}\s*from\s*['"]@composables['"]/g)];for(let i of c)for(let u of i[1].split(",")){let f=u.trim().split(/\s*(?::|\u0008as\u0008)\s*/)[0];if(f&&s.has(f))n.add(f)}return J.set(r,n),n}function se(e){return!e||/^(?:module|(?:text|application)\/(?:java|ecma)script|application\/stx-[\w-]+)$/i.test(e)}var L=b(256);function oe(e,s){let r=new Set(s),t="",n=0,c=new Set;for(let i of e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi)){t+=e.slice(n,i.index),n=i.index+i[0].length;let u=i[1]??"",f=i[2]??"",d=/\btype\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i.exec(u),m=d?(d[1]??d[2]??d[3]??"").trim():void 0;if(!se(m)){if(!/json/i.test(m??""))t+=` ${f} `;continue}let y=R(f,r);if(y.size===0)continue;let _=x(f,[...y].sort().join(",")),w=L.get(_);if(!w)w=X(f,y),L.set(_,w);for(let B of w)c.add(B)}t+=e.slice(n);for(let i of R(t,r))c.add(i);return c}function ie(e,s,r){let t=new Map;for(let{file:f,names:d}of e)for(let m of d)if(!t.has(m))t.set(m,f);let n=new Set(t.keys()),c=(f)=>{let d=[];for(let m of X(f,n))d.push(t.get(m));return d},i=new Set,u=r.flatMap((f,d)=>d===0?[...oe(f,t.keys())].map((m)=>t.get(m)):c(f));while(u.length>0){let f=[];for(let d of u){if(i.has(d))continue;i.add(d);for(let m of c(s.get(d)??""))if(!i.has(m))f.push(m)}u=f}return i}async function ch(e,s,r,t){let{key:n,files:c}=await W(e);if(!n)return null;let i=()=>[...new Set([...c,...c.flatMap((o)=>he(o))])],u=mt(i());if(c.length===0)return ce(v,n,u,""),null;c.sort();let f=Y({loader:"ts",target:"browser",define:C()}),d=Gt(A,n,u);if(!d){let o=new Map,l=[];for(let p of c)try{let S=await Bun.file(p).text();o.set(p,S);let g=f.scan(S).exports.filter((Q)=>Q!=="default");if(g.length>0)l.push({file:p,names:g})}catch{o.set(p,"")}d=ce(A,n,u,{codeByFile:o,modules:l})}let{codeByFile:m,modules:y}=d,_;if(s===void 0)_=new Set(c);else{let o=r?[s,...r]:[s],l=x(o.join("\x00"),n,o.length,u),p=I.get(l);if(_=p??ie(y,m,o),!p)I.set(l,_)}if(_.size===0)return null;let w=c.filter((o)=>_.has(o)),B=()=>{if(!t)return;for(let o of w)t.push(o,...he(o))},N=`${n}\x00${w.join("\x00")}\x00${rn()}`,U=Gt(v,N,u);if(U!==void 0)return B(),U||null;let D=[],M=new Set,T=new Set;for(let o of w)try{let l=m.get(o)??await Bun.file(o).text(),p=h.basename(o,".ts");for(let g of l.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(g[1])T.add(g[1]);let S=[];try{for(let g of f.scan(l).exports)if(g!=="default")M.add(g),S.push(g)}catch{}if(l=P(l),nn(l))l=await sn(l,o,{projectRoot:process.cwd(),externalizeUserModules:!1,expose:S}),l=wt(l);l=En(l),l=l.replace(/^export\s+(default\s+)?/gm,""),l=f.transformSync(l),D.push(`// Composable: ${p}
3
3
  ${l.trim()}`)}catch(l){console.warn(`[stx] Failed to load composable ${o}:`,l)}if(D.length===0||M.size===0)return ce(v,N,u,""),null;let Z=[...M].map((o)=>` try { if (!(${JSON.stringify(o)} in __c)) __c[${JSON.stringify(o)}] = ${o}; } catch (e) {}`).join(`
4
4
  `),z=JSON.stringify([...M]),j=D.join(`
5
5
 
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Lo,jo,Bo,Ah,us,Ph}from"./chunk-9pcrtvje.js";export{us as clearImageDeliveryCatalog,Ah as deliveredImage,Bo as efficientDeliverySources,Lo as getImageDelivery,jo as isTransparentImage,Ph as prepareImageDelivery};
2
+ import{Lo,jo,Bo,Ah,us,Ph}from"./chunk-kr5jhk30.js";export{us as clearImageDeliveryCatalog,Ah as deliveredImage,Bo as efficientDeliverySources,Lo as getImageDelivery,jo as isTransparentImage,Ph as prepareImageDelivery};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{a}from"./chunk-h8mqh8ds.js";import{yo}from"./chunk-j3st59hv.js";import p from"path";async function qg(t={}){let l=performance.now(),s=t.root||process.cwd(),e=await a(s),o=t.ssr?.routeRules??e.routeRules??{};if(yo(o),!e.ssr&&Object.keys(o).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let u,n;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");u=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-51q4z1g6.js");n=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let d=Math.round(performance.now()-l);return{mode:r,ssg:u,ssr:n,duration:d}}
2
+ import{a}from"./chunk-20qn18ry.js";import{yo}from"./chunk-j3st59hv.js";import p from"path";async function qg(t={}){let l=performance.now(),s=t.root||process.cwd(),e=await a(s),o=t.ssr?.routeRules??e.routeRules??{};if(yo(o),!e.ssr&&Object.keys(o).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let u,n;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");u=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-4jmzw6kg.js");n=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let d=Math.round(performance.now()-l);return{mode:r,ssg:u,ssr:n,duration:d}}
3
3
  export{qg};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{qg}from"./chunk-xz1qz9b9.js";import"./chunk-h8mqh8ds.js";import"./chunk-93rd9wf9.js";import"./chunk-2ws2qe1k.js";import"./chunk-vbc8a8fh.js";import"./chunk-3z0e637x.js";import"./chunk-bmkm1c8s.js";import"./chunk-nv77aaqa.js";import"./chunk-ftfvezbd.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{qg as buildApp};
2
+ import{qg}from"./chunk-7vqhm1rx.js";import"./chunk-20qn18ry.js";import"./chunk-1jwqjdk7.js";import"./chunk-2ws2qe1k.js";import"./chunk-vbc8a8fh.js";import"./chunk-3z0e637x.js";import"./chunk-bmkm1c8s.js";import"./chunk-m76jbcey.js";import"./chunk-kfgbk0x9.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{qg as buildApp};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{tt}from"./chunk-bmkm1c8s.js";import{ht,Hn}from"./chunk-gb3tv53p.js";import{Rr,Ar,Pr,Or,_e}from"./chunk-gebb12ak.js";import{Me,gn,Yc,Zc}from"./chunk-nv77aaqa.js";import{N}from"./chunk-m7hfcxt3.js";import{vi}from"./chunk-ftfvezbd.js";import{y}from"./chunk-ezdj63ds.js";import{i}from"./chunk-6df7h4ay.js";import{B,a}from"./chunk-h8mqh8ds.js";import{Sc}from"./chunk-vbc8a8fh.js";import{Pn,We,Ee,la,ua,In}from"./chunk-rmbm30ew.js";import{on,Po}from"./chunk-prj88r9z.js";import{On}from"./chunk-j3st59hv.js";import{Zt,Yn,Zn}from"./chunk-ndjmt3vg.js";import{X}from"./chunk-0z96accg.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function W(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function J(n=!1){let l=n?Hn():ht(),o=W(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function U(){let n=tt(),l=W(n);return{content:n,filename:`router.${l}.js`,hash:l}}import V from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function q(n,l,o={}){let r=V.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);Yc();let _={};try{_=await a(o.configDir)}catch{}let h=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))h.push(g[2])}let u=new Set(h.flatMap((R)=>Me(R))),{context:D}=te({__filename:r,__dirname:V.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...B,..._,...o,buildMode:"compile",strict:!1},b=await i(e,D,r,T,A),w=Pn(b)+We(b),j=Zc();return{route:l,sourceFile:n,html:b,fragment:w,placeholders:j,hasServerScripts:h.length>0,serverScriptContent:h,dependencies:Array.from(A),contentHash:S,status:gn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let h=m.readdirSync(S,{withFileTypes:!0});for(let d of h){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function tm(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),h=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=_e(e.app?.head,{known:Or,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=On(A),b=n.serverApi??e.serverApi,w=typeof b==="object"?b:{};if(b)on(o,w);if(e.runtimeConfig)N(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let j=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of j)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=X(o,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],P=R.filter((s)=>!Y.some((f)=>s.pattern.startsWith(`/${f}/`)||s.pattern===`/${f}`));console.log(`[stx build] Found ${P.length} page routes (${R.length-P.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=J(n.debug),x=U();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],H=[];for(let s of P){let f=T(s.pattern),O=f.rendering==="prerender";if(O&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await q(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:h,debug:n.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Pr(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Rr(t.html,u);if(g.htmlAttrs)t.html=Ar(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let I=p[1];t.html=t.html.replace(" "+I,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${I}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await y(t.html),O){let p=await In(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Ee(t.html,D,!0);let L=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),G=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,G),t.fragment),H.push({pattern:s.pattern,compiledPath:z,fragmentPath:G,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(f).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let k=c.resolve(o,d);if(m.existsSync(k)){let{copied:s,bytes:f}=Z(k,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${d}/`)}let E=Zn(o);if(E){let{copied:s,bytes:f}=Z(E,c.join(r,"public",Yn));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${Zt}/`)}let F={runtime:v.filename,router:x.filename},C=la(H,F,r);if(C.routeRules=A,C.routerContainer=D,b)C.apiRoutes=await Po(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await vi(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Sc(e._layerGraph),null,2));ua(C,r);let K=Date.now()-l;return console.log(`
2
+ import{tt}from"./chunk-bmkm1c8s.js";import{ht,Hn}from"./chunk-gb3tv53p.js";import{Rr,Ar,Pr,Or,_e}from"./chunk-gebb12ak.js";import{Me,gn,Yc,Zc}from"./chunk-m76jbcey.js";import{N}from"./chunk-m7hfcxt3.js";import{vi}from"./chunk-kfgbk0x9.js";import{y}from"./chunk-j54ph3jm.js";import{i}from"./chunk-c84fwzfq.js";import{B,a}from"./chunk-20qn18ry.js";import{Sc}from"./chunk-vbc8a8fh.js";import{Pn,We,Ee,la,ua,In}from"./chunk-jd1mvgwb.js";import{on,Po}from"./chunk-3y6jhcrb.js";import{On}from"./chunk-j3st59hv.js";import{Zt,Yn,Zn}from"./chunk-ndjmt3vg.js";import{X}from"./chunk-f33wwacc.js";import m from"fs";import c from"path";import{createHash as Q}from"crypto";function W(n){return Q("sha256").update(n).digest("hex").slice(0,8)}function J(n=!1){let l=n?Hn():ht(),o=W(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function U(){let n=tt(),l=W(n);return{content:n,filename:`router.${l}.js`,hash:l}}import V from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function q(n,l,o={}){let r=V.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);Yc();let _={};try{_=await a(o.configDir)}catch{}let h=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))h.push(g[2])}let u=new Set(h.flatMap((R)=>Me(R))),{context:D}=te({__filename:r,__dirname:V.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...B,..._,...o,buildMode:"compile",strict:!1},b=await i(e,D,r,T,A),w=Pn(b)+We(b),j=Zc();return{route:l,sourceFile:n,html:b,fragment:w,placeholders:j,hasServerScripts:h.length>0,serverScriptContent:h,dependencies:Array.from(A),contentHash:S,status:gn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function Z(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let h=m.readdirSync(S,{withFileTypes:!0});for(let d of h){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function tm(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),h=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=_e(e.app?.head,{known:Or,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=On(A),b=n.serverApi??e.serverApi,w=typeof b==="object"?b:{};if(b)on(o,w);if(e.runtimeConfig)N(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let j=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of j)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=X(o,{pagesDirs:e._layerPageDirs}),Y=["components","layouts","partials"],P=R.filter((s)=>!Y.some((f)=>s.pattern.startsWith(`/${f}/`)||s.pattern===`/${f}`));console.log(`[stx build] Found ${P.length} page routes (${R.length-P.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=J(n.debug),x=U();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",x.filename),x.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${x.filename} (${(x.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],H=[];for(let s of P){let f=T(s.pattern),O=f.rendering==="prerender";if(O&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await q(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:h,debug:n.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,x.filename),t.html=Pr(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Rr(t.html,u);if(g.htmlAttrs)t.html=Ar(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let I=p[1];t.html=t.html.replace(" "+I,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${I}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await y(t.html),O){let p=await In(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Ee(t.html,D,!0);let L=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),z=c.join("server","pages",`${L}.compiled.json`),G=c.join("server","fragments",`${L}.html`);await Bun.write(c.join(r,z),JSON.stringify(t,null,2)),await Bun.write(c.join(r,G),t.fragment),H.push({pattern:s.pattern,compiledPath:z,fragmentPath:G,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(f).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let k=c.resolve(o,d);if(m.existsSync(k)){let{copied:s,bytes:f}=Z(k,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${d}/`)}let E=Zn(o);if(E){let{copied:s,bytes:f}=Z(E,c.join(r,"public",Yn));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(f/1024).toFixed(1)}KB) from ${Zt}/`)}let F={runtime:v.filename,router:x.filename},C=la(H,F,r);if(C.routeRules=A,C.routerContainer=D,b)C.apiRoutes=await Po(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await vi(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Sc(e._layerGraph),null,2));ua(C,r);let K=Date.now()-l;return console.log(`
3
3
  [stx build] Done in ${K}ms \u2014 ${M.length} pages compiled`),{pageCount:M.length,assets:F,outputDir:r,duration:K}}
4
4
  export{tm};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{B,Bf,Go,a,I,Fh,zh}from"./chunk-h8mqh8ds.js";import"./chunk-93rd9wf9.js";import"./chunk-2ws2qe1k.js";import"./chunk-vbc8a8fh.js";import"./chunk-3z0e637x.js";import"./chunk-bmkm1c8s.js";import"./chunk-nv77aaqa.js";import"./chunk-ftfvezbd.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{I as config,B as defaultConfig,Fh as defineStxConfig,Go as discoverConfig,a as loadStxConfig,Bf as resolveStxDirectories,zh as validateConfig};
2
+ import{B,Bf,Go,a,I,Fh,zh}from"./chunk-20qn18ry.js";import"./chunk-1jwqjdk7.js";import"./chunk-2ws2qe1k.js";import"./chunk-vbc8a8fh.js";import"./chunk-3z0e637x.js";import"./chunk-bmkm1c8s.js";import"./chunk-m76jbcey.js";import"./chunk-kfgbk0x9.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{I as config,B as defaultConfig,Fh as defineStxConfig,Go as discoverConfig,a as loadStxConfig,Bf as resolveStxDirectories,zh as validateConfig};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Lt,ie,u,f,A,t,ae,q,l,ke,ki,F,Sn,_i,Ft,Ci,rl,Rr,sl,it,ol,Ar,il,kn,Ei,al,Pr,Or,_e,Ti}from"./chunk-gebb12ak.js";import{ai,$c,o,C,Oe,pn,Ne,pe,G,vr,fn,Bs,jc,mn,Cr,zs,Hs,Bc,fi,Fc,zc,Hc,Vc,De,Le,Vs,Fe,s,bn,h,p,U,Z,Se,_,T}from"./chunk-nv77aaqa.js";import{Dt}from"./chunk-m7hfcxt3.js";import{vn}from"./chunk-ftfvezbd.js";import{y}from"./chunk-ezdj63ds.js";import{gr,Ps}from"./chunk-bmkm1c8s.js";import{pc,fc,dr,Qe,gc,I}from"./chunk-h8mqh8ds.js";import{Zo,Qo,ei,ti}from"./chunk-3z0e637x.js";import{ac,ds}from"./chunk-9pcrtvje.js";import{as,cs,ls}from"./chunk-t8njsjr9.js";import{ms,Uo,Wo,hs,ys,qo}from"./chunk-hn5tnxk1.js";import{ps,or}from"./chunk-knpzhqns.js";import{Do}from"./chunk-c84pxd2k.js";import{se,Fo,zo,Ho}from"./chunk-y7sf7aj0.js";import{ar,be,lc,cr,uc}from"./chunk-0z96accg.js";import{j,Ye}from"./chunk-cmnze7at.js";import{mc,hc}from"./chunk-93rd9wf9.js";import{E,_n,$i}from"./chunk-c5vzr1va.js";import us from"fs";import ce from"path";function dt(){return`
2
+ import{Lt,ie,u,f,A,t,ae,q,l,ke,ki,F,Sn,_i,Ft,Ci,rl,Rr,sl,it,ol,Ar,il,kn,Ei,al,Pr,Or,_e,Ti}from"./chunk-gebb12ak.js";import{ai,$c,o,C,Oe,pn,Ne,pe,G,vr,fn,Bs,jc,mn,Cr,zs,Hs,Bc,fi,Fc,zc,Hc,Vc,De,Le,Vs,Fe,s,bn,h,p,U,Z,Se,_,T}from"./chunk-m76jbcey.js";import{Dt}from"./chunk-m7hfcxt3.js";import{vn}from"./chunk-kfgbk0x9.js";import{y}from"./chunk-j54ph3jm.js";import{gr,Ps}from"./chunk-bmkm1c8s.js";import{pc,fc,dr,Qe,gc,I}from"./chunk-20qn18ry.js";import{Zo,Qo,ei,ti}from"./chunk-3z0e637x.js";import{ac,ds}from"./chunk-kr5jhk30.js";import{as,cs,ls}from"./chunk-y3jx43d7.js";import{ms,Uo,Wo,hs,ys,qo}from"./chunk-jf0cn7e2.js";import{ps,or}from"./chunk-q4efhj8q.js";import{Do}from"./chunk-c84pxd2k.js";import{se,Fo,zo,Ho}from"./chunk-y7sf7aj0.js";import{ar,be,lc,cr,uc}from"./chunk-f33wwacc.js";import{j,Ye}from"./chunk-cmnze7at.js";import{mc,hc}from"./chunk-1jwqjdk7.js";import{E,_n,$i}from"./chunk-c5vzr1va.js";import us from"fs";import ce from"path";function dt(){return`
3
3
  // STX Lifecycle Runtime
4
4
  (function() {
5
5
  if (typeof window === 'undefined') return;
@@ -1558,7 +1558,7 @@ ${M}
1558
1558
  </style>`;a=a.replace(x,O),v.lastIndex=0}catch(M){}}}return a}import ot from"path";var rs=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,ss=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function os(r,e){if(!e||!r.includes("/"))return r;let c=ot.dirname(e);return r.replace(rs,(a,d,n,g)=>{let v=ot.resolve(c,g);return`${d}${n}${v.split(ot.sep).join("/")}${n}`})}function un(r,e){if(!e||!r.includes("<script"))return r;return r.replace(ss,(c,a,d,n)=>`${a}${os(d,e)}${n}`)}var Te="<!--PARENT_CONTENT_PLACEHOLDER-->";function dn(r){return r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function En(r,e){let c=r.length,a=e,d=!0,n=[],g=(v)=>v+9<=c&&r[v]==="<"&&r[v+1]==="/"&&(r[v+2]==="s"||r[v+2]==="S")&&(r[v+3]==="c"||r[v+3]==="C")&&(r[v+4]==="r"||r[v+4]==="R")&&(r[v+5]==="i"||r[v+5]==="I")&&(r[v+6]==="p"||r[v+6]==="P")&&(r[v+7]==="t"||r[v+7]==="T")&&(r[v+8]===">"||/\s/.test(r[v+8]));while(a<c){let v=r[a];if(g(a))return a;if(v==="/"&&r[a+1]==="/"){if(a=r.indexOf(`
1559
1559
  `,a+2),a===-1)return-1;a+=1,d=!0;continue}if(v==="/"&&r[a+1]==="*"){let m=r.indexOf("*/",a+2);if(m===-1)return-1;a=m+2,d=!0;continue}if(v==="/"&&d){let m=a+1,x=!1;while(m<c){let b=r[m];if(b==="\\"){m+=2;continue}if(b==="[")x=!0;else if(b==="]")x=!1;else if(b==="/"&&!x){m++;break}else if(b===`
1560
1560
  `){m=-1;break}m++}if(m===-1){a++,d=!1;continue}while(m<c&&/[a-z]/.test(r[m]))m++;a=m,d=!1;continue}if(v==="'"||v==='"'){let m=v;a++;while(a<c){if(r[a]==="\\"){a+=2;continue}if(r[a]===m){a++;break}if(r[a]===`
1561
- `)break;a++}d=!1;continue}if(v==="`"){a++;while(a<c){if(r[a]==="\\"){a+=2;continue}if(r[a]==="`"){a++;break}if(r[a]==="$"&&r[a+1]==="{"){n.push(!0),a+=2,d=!0;break}a++}if(n.length===0)d=!1;continue}if(v==="}"&&n.length>0){n.pop(),a++;while(a<c){if(r[a]==="\\"){a+=2;continue}if(r[a]==="`"){a++,d=!1;break}if(r[a]==="$"&&r[a+1]==="{"){n.push(!0),a+=2,d=!0;break}a++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))d=!1;else d=!0;a++}return-1}function Tn(r,e){let c=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${c}(?:\\s|=|/?>))[^>]*>`,"i").exec(r);if(!a)return null;let d=a.index+a[0].length,n=r.indexOf("</script>",d);if(n===-1)return null;let g=r.indexOf(">",n);if(g===-1)return null;return{start:a.index,end:g+1}}var fs=4096;async function at(r,e,c){if(c.buildMode!=="serve"||e.length<fs)return null;let{registerServeModuleBundle:a}=await import("./chunk-af54x4dj.js");return`<script ${r} src="${a(e)}"></script>`}async function tr(r,e,c,a){try{let{registeredModuleIdsIn:d,buildModuleRegistryScript:n}=await o("stx/client-module-registry",()=>import("./chunk-j68h08nm.js")),g=[],v=await n(d(...r),{minify:$i(e.buildMode,e.minifyClient),collectInputs:g});for(let m of g)c?.add(m);if(a)a.inputs=g,a.code=v??void 0;if(!v)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:m}=await import("./chunk-af54x4dj.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${m(v)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${v.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}async function gs(r,e,c,a){let d={modulesTag:null,modulesCode:null,storeTag:null,storeCode:null,composableTag:null,composableCode:null,frameworkScript:null};try{let{getFrameworkComposableScript:S}=await o("stx/framework-composables",()=>import("./chunk-61j62gya.js"));d.frameworkScript=await S(r)}catch{}let n=null;try{n=await o("stx/store-loader",()=>import("./chunk-e2ywh4ax.js"))}catch{}let g=e.storesDir,v=!!a.__stx_native_screen||(n?.pageStoresAll()??!0),m=v?"":r.replace(/<script\b[^>]*\bdata-stx-(?:runtime|router|hmr)\b[^>]*>[\s\S]*?<\/script>/gi,""),x=[],b=[],w=null;for(let S=0;S<8;S++){let k=null,D="",R=!1;try{if(n){let H=v?await n.getStoreScript(g).then((V)=>V?{code:V,stores:["*"],functions:null}:null):await n.getStoreScriptFor(g,[m],{reads:n.storesReadInFiles([...x,...b]),runOnce:!0});if(H)k=H.code,D=H.stores.join(","),R=!!H.functions&&!v}}catch{}if(w!==null&&D===w)break;w=D;let M=R?'data-stx-scoped data-stx-run="always" data-stx-stores':"data-stx-stores",O=k?`<script ${M}>${k}</script>`:null;d.storeCode=k,d.storeTag=k?await at(M,k,e)??O:null;let N={};d.modulesTag=await tr([r,O],e,c,N),d.modulesCode=N.code??null,x=N.inputs??[],d.composableTag=null,d.composableCode=null,b=[];try{let{getComposableScript:H}=await o("stx/composable-loader",()=>import("./chunk-zmtggvf0.js")),V=e.composablesDir,P=[d.modulesCode??d.modulesTag,O,d.frameworkScript].filter((B)=>B!==null),L=await H(e._layerComposableDirs??V,r,P,b);if(L)d.composableCode=L,d.composableTag=await at('data-stx-scoped data-stx-run="always" data-stx-composables',L,e)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${L}</script>`}catch{}if(v||!n)break}return d}async function vs(r,e,c,a={}){let{withModuleSubstitutes:d,moduleSubstitutionKey:n}=await import("./chunk-9k4fvbrz.js"),g=await import("./chunk-cbx7qght.js"),{messages:v,webModules:m}=e,x=null,b=null,w=n()===""&&!a.__stx_native_screen;if(v&&g.pageMessagesEnabled(e)&&w)try{x=await g.loadPageMessages(process.cwd(),v)}catch(M){bs(M)}if(m&&Object.keys(m).length&&w)try{b=await(await import("./chunk-bfm5cedw.js")).loadWebModules(process.cwd(),m)}catch(M){ws(M)}let S=new Map([...b??[],...x?.stubs??[]]),k=()=>gs(r,e,c,a),D=S.size?await d(S,k):await k(),R=null;if(x){let M=g.messageAreasIn(D.modulesCode,D.storeCode,D.composableCode),O=g.pageMessagesScript(x,g.pageLanguages(r,x),M);if(O)R=await at('data-stx-scoped data-stx-run="always" data-stx-messages',O,e)??`<script data-stx-scoped data-stx-run="always" data-stx-messages>${O.replace(/<\/script/gi,"<\\/script")}</script>`}return[R,D.modulesTag,D.storeTag,D.composableTag,D.frameworkScript].filter((M)=>M!==null)}var gn=!1;function bs(r){if(gn)return;gn=!0,console.warn(`[stx] messages: ${r instanceof Error?r.message:String(r)}; pages ship every language`)}var hn=!1;function ws(r){if(hn)return;hn=!0,console.warn(`[stx] ${r instanceof Error?r.message:String(r)}; pages bundle the real modules`)}function xs(r,e=""){let c=Tn(r,"data-stx-runtime");if(!c)return r;let a=ar(r);if(a===-1||a===c.start){if(!e)return r;return r.slice(0,c.end)+e+r.slice(c.end)}if(a<c.start)return r.slice(0,a)+r.slice(c.start,c.end)+e+`
1561
+ `)break;a++}d=!1;continue}if(v==="`"){a++;while(a<c){if(r[a]==="\\"){a+=2;continue}if(r[a]==="`"){a++;break}if(r[a]==="$"&&r[a+1]==="{"){n.push(!0),a+=2,d=!0;break}a++}if(n.length===0)d=!1;continue}if(v==="}"&&n.length>0){n.pop(),a++;while(a<c){if(r[a]==="\\"){a+=2;continue}if(r[a]==="`"){a++,d=!1;break}if(r[a]==="$"&&r[a+1]==="{"){n.push(!0),a+=2,d=!0;break}a++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))d=!1;else d=!0;a++}return-1}function Tn(r,e){let c=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${c}(?:\\s|=|/?>))[^>]*>`,"i").exec(r);if(!a)return null;let d=a.index+a[0].length,n=r.indexOf("</script>",d);if(n===-1)return null;let g=r.indexOf(">",n);if(g===-1)return null;return{start:a.index,end:g+1}}var fs=4096;async function at(r,e,c){if(c.buildMode!=="serve"||e.length<fs)return null;let{registerServeModuleBundle:a}=await import("./chunk-ncmdmgrj.js");return`<script ${r} src="${a(e)}"></script>`}async function tr(r,e,c,a){try{let{registeredModuleIdsIn:d,buildModuleRegistryScript:n}=await o("stx/client-module-registry",()=>import("./chunk-1jr259ct.js")),g=[],v=await n(d(...r),{minify:$i(e.buildMode,e.minifyClient),collectInputs:g});for(let m of g)c?.add(m);if(a)a.inputs=g,a.code=v??void 0;if(!v)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:m}=await import("./chunk-ncmdmgrj.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${m(v)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${v.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}async function gs(r,e,c,a){let d={modulesTag:null,modulesCode:null,storeTag:null,storeCode:null,composableTag:null,composableCode:null,frameworkScript:null};try{let{getFrameworkComposableScript:S}=await o("stx/framework-composables",()=>import("./chunk-n9pbkj5v.js"));d.frameworkScript=await S(r)}catch{}let n=null;try{n=await o("stx/store-loader",()=>import("./chunk-20bcj7cm.js"))}catch{}let g=e.storesDir,v=!!a.__stx_native_screen||(n?.pageStoresAll()??!0),m=v?"":r.replace(/<script\b[^>]*\bdata-stx-(?:runtime|router|hmr)\b[^>]*>[\s\S]*?<\/script>/gi,""),x=[],b=[],w=null;for(let S=0;S<8;S++){let k=null,D="",R=!1;try{if(n){let H=v?await n.getStoreScript(g).then((V)=>V?{code:V,stores:["*"],functions:null}:null):await n.getStoreScriptFor(g,[m],{reads:n.storesReadInFiles([...x,...b]),runOnce:!0});if(H)k=H.code,D=H.stores.join(","),R=!!H.functions&&!v}}catch{}if(w!==null&&D===w)break;w=D;let M=R?'data-stx-scoped data-stx-run="always" data-stx-stores':"data-stx-stores",O=k?`<script ${M}>${k}</script>`:null;d.storeCode=k,d.storeTag=k?await at(M,k,e)??O:null;let N={};d.modulesTag=await tr([r,O],e,c,N),d.modulesCode=N.code??null,x=N.inputs??[],d.composableTag=null,d.composableCode=null,b=[];try{let{getComposableScript:H}=await o("stx/composable-loader",()=>import("./chunk-ehmy6gyb.js")),V=e.composablesDir,P=[d.modulesCode??d.modulesTag,O,d.frameworkScript].filter((B)=>B!==null),L=await H(e._layerComposableDirs??V,r,P,b);if(L)d.composableCode=L,d.composableTag=await at('data-stx-scoped data-stx-run="always" data-stx-composables',L,e)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${L}</script>`}catch{}if(v||!n)break}return d}async function vs(r,e,c,a={}){let{withModuleSubstitutes:d,moduleSubstitutionKey:n}=await import("./chunk-e3qkbq8g.js"),g=await import("./chunk-cbx7qght.js"),{messages:v,webModules:m}=e,x=null,b=null,w=n()===""&&!a.__stx_native_screen;if(v&&g.pageMessagesEnabled(e)&&w)try{x=await g.loadPageMessages(process.cwd(),v)}catch(M){bs(M)}if(m&&Object.keys(m).length&&w)try{b=await(await import("./chunk-bfm5cedw.js")).loadWebModules(process.cwd(),m)}catch(M){ws(M)}let S=new Map([...b??[],...x?.stubs??[]]),k=()=>gs(r,e,c,a),D=S.size?await d(S,k):await k(),R=null;if(x){let M=g.messageAreasIn(D.modulesCode,D.storeCode,D.composableCode),O=g.pageMessagesScript(x,g.pageLanguages(r,x),M);if(O)R=await at('data-stx-scoped data-stx-run="always" data-stx-messages',O,e)??`<script data-stx-scoped data-stx-run="always" data-stx-messages>${O.replace(/<\/script/gi,"<\\/script")}</script>`}return[R,D.modulesTag,D.storeTag,D.composableTag,D.frameworkScript].filter((M)=>M!==null)}var gn=!1;function bs(r){if(gn)return;gn=!0,console.warn(`[stx] messages: ${r instanceof Error?r.message:String(r)}; pages ship every language`)}var hn=!1;function ws(r){if(hn)return;hn=!0,console.warn(`[stx] ${r instanceof Error?r.message:String(r)}; pages bundle the real modules`)}function xs(r,e=""){let c=Tn(r,"data-stx-runtime");if(!c)return r;let a=ar(r);if(a===-1||a===c.start){if(!e)return r;return r.slice(0,c.end)+e+r.slice(c.end)}if(a<c.start)return r.slice(0,a)+r.slice(c.start,c.end)+e+`
1562
1562
  `+r.slice(a,c.start)+r.slice(c.end);let d=r.slice(c.start,c.end),n=r.slice(0,c.start)+r.slice(c.end),g=ar(n);if(g===-1)return d+e+`
1563
1563
  `+n;return n.slice(0,g)+d+e+`
1564
1564
  `+n.slice(g)}function Ss(r){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return r.replace(e,(c,a,d)=>{let n=r.slice(0,d);return n.lastIndexOf("<")>n.lastIndexOf(">")?`{{${a}}}`:`{<!--stx-literal-->{${a}}}`})}async function i(r,e,c,a,d){if(a.ssr===!1&&!a.autoShell&&a.buildMode==="spa")return r;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=Se(r,c);let n=!e.__stxProcessingDepth;mn(e);for(let g of a._layerGraph?.configDependencies??[])d.add(g);if(n&&a.runtimeConfig)await vn(e,c,a.runtimeConfig);if(n)Hc(e),e.__stx_scope_seq??={n:0,key:Vs(String(e.__filename??c))},e.__stx_head_injections=Ci(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((a.debug||!E()&&!_n())&&c&&c.endsWith(".stx"))Do(r,c);try{return await ie.timeAsync("template-processing",async()=>{let g=await ks(r,e,c,a,d);if(n)g=fi(g);if(n&&a.autoShell&&a.buildMode!=="compile"){let v=_e(a.app?.head,{known:Or,source:"app.head"}),x=(e.__stx_runtime_head||null)??Ti(),b=(e.__stx_head_raw||"").trim(),w,S=b.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(S)w=S[1].trim(),b=b.replace(S[0],"").trim();let k=e.__sections?.title,D=k?_(k,e,c):void 0,R=x.title||w||D,M=!x.title&&(!!w||!!D),O=x.meta||[],N=new Set(O.map((X)=>it(X)).filter(Boolean)),H={...v,...R&&{title:R},meta:[...(v.meta||[]).filter((X)=>!N.has(it(X))),...O],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],headRaw:[v.headRaw,b].filter(Boolean).join(`
@@ -1573,7 +1573,7 @@ ${m.trim()}
1573
1573
  @endsection`}}if(O&&m.includes("<script")){let P=G(m),L=P.scripts.map((B)=>yn(B,c)??B);m=vr(P.output,L)}if(m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(P,L,B)=>(M[L]=B,"")),m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(P,L,B)=>{if(/^(['"]).*\1$/.test(B.trim()))return P;try{let X=u(B.trim(),e);if(X===void 0)return P;let ee=(e.__stx_inline_section_values??=[]).push(X)-1;return M[L]=`{{ __stx_inline_section_values[${ee}] }}`,""}catch{return P}}),m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(P,L,B)=>{if(B.includes("@parent"))M[L]=B.replace("@parent",Te);else M[L]=B.trim();return""}),e.__sections=M,m=m.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(P,L,B)=>M[L]||B||""),!("slot"in e)||e.slot===void 0)m=m.replace(/\{\{\s*slot\s*\}\}/g,()=>M.content||"");if(m=ls(m,R),O){let P=[],L=G(m),B=pe(L.output,pn,(X,K)=>`\x00STX_ORPHAN_STYLE_${K}\x00`);if(m=B.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(X,K,ee)=>{let te=K==="SCRIPT"?yn(L.scripts[Number(ee)],c):B.tokens[Number(ee)];if(te)P.push(te);return""}),P.length>0){let X=P.join(`
1574
1574
  `);M.content=M.content?`${M.content}
1575
1575
  ${X}`:X,e.__sections=M}}if(O)try{let P;if(ce.isAbsolute(O))P=O,d.add(O);else P=await ke(()=>bn(O,c,g,d),null,()=>{throw new ae(`Failed to resolve layout path: ${O}`,c,void 0,void 0,`Layout referenced from ${c}`)});if(!P){let te=(J)=>{if(!J)return[];try{let me=ce.isAbsolute(J)?J:ce.resolve(process.cwd(),J);return us.readdirSync(me).filter((we)=>we.endsWith(".stx")).map((we)=>we.replace(/\.stx$/,""))}catch{return[]}},ne=[...te(g.layoutsDir),...te(g.fallbackLayoutsDir)].filter((J,me,we)=>we.indexOf(J)===me).sort(),le=[g.layoutsDir,g.fallbackLayoutsDir].filter((J)=>typeof J==="string"&&J.length>0),de=le.length>0?` Searched: ${le.join(", ")} (set \`layoutsDir\` to look elsewhere).`:"",oe=`Layout not found: ${O} (referenced from ${c})`+(ne.length>0?`. Available layouts: ${ne.join(", ")}`:g.layoutsDir?`. No .stx layouts found in ${g.layoutsDir}`:"")+de;if(F.log(Error(oe),{layoutPath:O,filePath:c,available:ne},"error"),console.error(`[stx] ${oe}`),g.debug)throw new ae(oe,c);return m}let L=await ke(()=>Bun.file(P).text(),"",()=>{throw new ae(`Failed to read layout file: ${P}`,c,void 0,void 0,"Layout content could not be loaded")});L=un(L,P);let B=L.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(B){if(g.debug)console.log(`Found nested layout: ${B[1]} in ${P}`);let te={},ne=L.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(oe,J,me)=>(te[J]=me.trim(),""));for(let[oe,J]of Object.entries(te))if(M[oe]&&M[oe].includes(Te)){let me=M[oe].indexOf(Te);M[oe]=M[oe].slice(0,me)+J+M[oe].slice(me+Te.length)}else if(!M[oe])M[oe]=J;let le={...e,__sections:M},de=`@layout('${B[1]}')${ne}`;return await i(de,le,P,g,d)}let X=L.replace(/\{\{--[\s\S]*?--\}\}/g,""),K=cs(X,R),ee={};return K=K.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(te,ne,le)=>(ee[ne]=le.trim(),`@slot('${ne}')`)),K=K.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(te,ne,le)=>{if(M[ne]){let de=M[ne];if(de.includes(Te)){let oe=ee[ne]||"",J=de.indexOf(Te);de=de.slice(0,J)+oe+de.slice(J+Te.length)}return de}return le||""}),K=$s(K,M),K=K.replace(/\{\{\s*slot\s*\}\}/g,()=>M.content||""),K=ls(K,R),e.__originalFilePath=c,m=await $n(K,e,P,g,d),m=`<!-- stx-layout: ${O} -->
1576
- ${m}`,w(m)}catch(P){if(P instanceof q)throw P;throw new ae(`Error processing layout ${O}: ${P instanceof Error?P.message:String(P)}`,c)}return w(await $n(m,e,c,g,d))}function $s(r,e){return r.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(c,a,d)=>{let n=e[a];if(n!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(n))return n}return d||""})}function Es(r,e){if(r.__stx_sfc_mode=!0,r.__stx_options=e,e.buildMode)r.__stx_buildMode=e.buildMode;let c=e.envPrefix||"STX_PUBLIC_",a={};for(let[d,n]of Object.entries(process.env))if(d.startsWith(c)&&n!==void 0)a[d]=n;r.$env=a}async function _s(r,e){await ke(()=>Jt(r,e),void 0,(c)=>{F.log(c,{filePath:r,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${r}: ${c.message}`)})}var ct="data-stx-source";function yn(r,e){if(!r)return r;let c=/^<script\b([^>]*)>/i.exec(r);if(!c||!/\bserver\b/.test(c[1])||c[1].includes(ct))return r;return`<script ${ct}="${encodeURIComponent(e)}"${r.slice(7)}`}function Ts(r){let e=new RegExp(`${ct}="([^"]*)"`).exec(r);return e?decodeURIComponent(e[1]):void 0}function wn(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function xn(r,e,c){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a &lt;script server&gt; ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${wn(r)}</span><span style="display:block;margin-top:4px">${wn(c)}</span></div>`}async function Cs(r,e,c,a){let{scanScriptTags:d}=await o("stx/signal-processing",()=>import("./chunk-gqse3ae0.js")),n=[],g=!E()&&!_n();for(let m of d(r)){let x=m.attrs;if(!/\bserver\b/.test(x))continue;let b=m.start+m.fullMatch.indexOf(">")+1,w=En(r,b);if(w===-1)continue;let S=r.slice(b,w);if(!S.trim())continue;let k=Ts(x)??c,D={index:m.start,length:w+9-m.start};try{let{extractVariables:R}=await o("stx/variable-extractor",()=>import("./chunk-merxtsaf.js"));await R(S,e,k,{preserveExisting:!0,onFailure:(M)=>{if(M.kind==="unknown")return;if(a?.onServerScriptError?.({sourcePath:k,kind:M.kind,message:M.message}),!g)return;n.push({...D,markup:xn(k,M.kind,M.message)})}})}catch(R){let M=R instanceof Error?R:Error(String(R));if(F.log(M,{filePath:k,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${k}: ${M.message}`),g)n.push({...D,markup:xn(k,"unknown",M.message)})}}if(n.length===0)return r;let v=r;for(let m of n.sort((x,b)=>b.index-x.index))v=v.slice(0,m.index)+m.markup+v.slice(m.index+m.length);return v}async function As(r,e,c){try{let{interpolateScriptsInTemplate:a}=await o("stx/expressions",()=>import("./chunk-gdc9s90b.js"));return a(r,e,{skipServer:!0})}catch(a){let d=a instanceof Error?a:Error(String(a));return F.log(d,{filePath:c,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${c}: ${d.message}`),r}}async function $n(r,e,c,a,d){let n=r,g=a;if(n=await Cs(n,e,c,a),n=await qt(n,e,c),n=await Ut(n,e,c),n=await As(n,e,c),n=await Rt(n,e,c,g),Se(n))n=Uo(n,e),n=ys(n,e),n=hs(n,e);n=Wo(n);let{processStreamDirectives:v}=await o("stx/streaming",()=>import("./chunk-6tefkmq9.js"));n=v(n,e),n=or(n,e,c,g,!0),n=await nn(n,e,c,g,d),n=await ds(n,e,c,g,d),n=pc(n,e,c,g);let{processDeferDirectives:m}=await o("stx/defer",()=>import("./chunk-bj6ax0he.js"));n=m(n,e,c);let{processTeleportDirectives:x}=await o("stx/teleport",()=>import("./chunk-rxc1076r.js"));n=x(n,e,c);let{processTransitionDirectives:b,processTransitionAttributes:w}=await o("stx/transitions",()=>import("./chunk-d3gncxq1.js"));n=b(n,e,c),n=w(n);let{processErrorBoundaryDirectives:S,stripRenderFailedMarkers:k}=await o("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));n=S(n,e,c),n=k(n);let{processSuspenseDirectives:D}=await o("stx/suspense",()=>import("./chunk-1rwfgmmk.js"));n=D(n,e,c);let{processAsyncDirectives:R}=await o("stx/async-components",()=>import("./chunk-xgqyzkt2.js"));n=R(n,e,c);let{processKeepAliveDirectives:M}=await o("stx/keep-alive",()=>import("./chunk-cxpnkgvw.js"));n=M(n,e,c);let{processVirtualListDirectives:O,processVirtualGridDirectives:N,processInfiniteListDirectives:H}=await o("stx/virtual-scrolling",()=>import("./chunk-tzb0n60s.js"));n=O(n,e,c),n=N(n,e,c),n=H(n,e,c);let{processPartialHydrationDirectives:V,processStaticDirectives:P}=await o("stx/partial-hydration",()=>import("./chunk-da886asf.js"));n=V(n,e,c),n=P(n);let{processComputedDirectives:L,processWatchDirectives:B}=await o("stx/computed",()=>import("./chunk-1xdzcy9d.js"));n=L(n,e,c),n=B(n,e,c);let{processFormValidationDirectives:X}=await o("stx/forms-validation",()=>import("./chunk-damrq7b8.js"));n=X(n,e,c);let{processHeadDirective:K,processTitleDirective:ee,processMetaDirective:te,resetHead:ne}=await o("stx/head",()=>import("./chunk-ycr9bkww.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)ne();let le=K(n);if(n=le.content,le.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${le.headContent}
1576
+ ${m}`,w(m)}catch(P){if(P instanceof q)throw P;throw new ae(`Error processing layout ${O}: ${P instanceof Error?P.message:String(P)}`,c)}return w(await $n(m,e,c,g,d))}function $s(r,e){return r.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(c,a,d)=>{let n=e[a];if(n!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(n))return n}return d||""})}function Es(r,e){if(r.__stx_sfc_mode=!0,r.__stx_options=e,e.buildMode)r.__stx_buildMode=e.buildMode;let c=e.envPrefix||"STX_PUBLIC_",a={};for(let[d,n]of Object.entries(process.env))if(d.startsWith(c)&&n!==void 0)a[d]=n;r.$env=a}async function _s(r,e){await ke(()=>Jt(r,e),void 0,(c)=>{F.log(c,{filePath:r,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${r}: ${c.message}`)})}var ct="data-stx-source";function yn(r,e){if(!r)return r;let c=/^<script\b([^>]*)>/i.exec(r);if(!c||!/\bserver\b/.test(c[1])||c[1].includes(ct))return r;return`<script ${ct}="${encodeURIComponent(e)}"${r.slice(7)}`}function Ts(r){let e=new RegExp(`${ct}="([^"]*)"`).exec(r);return e?decodeURIComponent(e[1]):void 0}function wn(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function xn(r,e,c){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a &lt;script server&gt; ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${wn(r)}</span><span style="display:block;margin-top:4px">${wn(c)}</span></div>`}async function Cs(r,e,c,a){let{scanScriptTags:d}=await o("stx/signal-processing",()=>import("./chunk-mt7d37jh.js")),n=[],g=!E()&&!_n();for(let m of d(r)){let x=m.attrs;if(!/\bserver\b/.test(x))continue;let b=m.start+m.fullMatch.indexOf(">")+1,w=En(r,b);if(w===-1)continue;let S=r.slice(b,w);if(!S.trim())continue;let k=Ts(x)??c,D={index:m.start,length:w+9-m.start};try{let{extractVariables:R}=await o("stx/variable-extractor",()=>import("./chunk-cx2bwpfj.js"));await R(S,e,k,{preserveExisting:!0,onFailure:(M)=>{if(M.kind==="unknown")return;if(a?.onServerScriptError?.({sourcePath:k,kind:M.kind,message:M.message}),!g)return;n.push({...D,markup:xn(k,M.kind,M.message)})}})}catch(R){let M=R instanceof Error?R:Error(String(R));if(F.log(M,{filePath:k,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${k}: ${M.message}`),g)n.push({...D,markup:xn(k,"unknown",M.message)})}}if(n.length===0)return r;let v=r;for(let m of n.sort((x,b)=>b.index-x.index))v=v.slice(0,m.index)+m.markup+v.slice(m.index+m.length);return v}async function As(r,e,c){try{let{interpolateScriptsInTemplate:a}=await o("stx/expressions",()=>import("./chunk-cxf2pdjk.js"));return a(r,e,{skipServer:!0})}catch(a){let d=a instanceof Error?a:Error(String(a));return F.log(d,{filePath:c,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${c}: ${d.message}`),r}}async function $n(r,e,c,a,d){let n=r,g=a;if(n=await Cs(n,e,c,a),n=await qt(n,e,c),n=await Ut(n,e,c),n=await As(n,e,c),n=await Rt(n,e,c,g),Se(n))n=Uo(n,e),n=ys(n,e),n=hs(n,e);n=Wo(n);let{processStreamDirectives:v}=await o("stx/streaming",()=>import("./chunk-mfnyqcfg.js"));n=v(n,e),n=or(n,e,c,g,!0),n=await nn(n,e,c,g,d),n=await ds(n,e,c,g,d),n=pc(n,e,c,g);let{processDeferDirectives:m}=await o("stx/defer",()=>import("./chunk-bj6ax0he.js"));n=m(n,e,c);let{processTeleportDirectives:x}=await o("stx/teleport",()=>import("./chunk-rxc1076r.js"));n=x(n,e,c);let{processTransitionDirectives:b,processTransitionAttributes:w}=await o("stx/transitions",()=>import("./chunk-d3gncxq1.js"));n=b(n,e,c),n=w(n);let{processErrorBoundaryDirectives:S,stripRenderFailedMarkers:k}=await o("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));n=S(n,e,c),n=k(n);let{processSuspenseDirectives:D}=await o("stx/suspense",()=>import("./chunk-1rwfgmmk.js"));n=D(n,e,c);let{processAsyncDirectives:R}=await o("stx/async-components",()=>import("./chunk-xgqyzkt2.js"));n=R(n,e,c);let{processKeepAliveDirectives:M}=await o("stx/keep-alive",()=>import("./chunk-cxpnkgvw.js"));n=M(n,e,c);let{processVirtualListDirectives:O,processVirtualGridDirectives:N,processInfiniteListDirectives:H}=await o("stx/virtual-scrolling",()=>import("./chunk-tzb0n60s.js"));n=O(n,e,c),n=N(n,e,c),n=H(n,e,c);let{processPartialHydrationDirectives:V,processStaticDirectives:P}=await o("stx/partial-hydration",()=>import("./chunk-da886asf.js"));n=V(n,e,c),n=P(n);let{processComputedDirectives:L,processWatchDirectives:B}=await o("stx/computed",()=>import("./chunk-1xdzcy9d.js"));n=L(n,e,c),n=B(n,e,c);let{processFormValidationDirectives:X}=await o("stx/forms-validation",()=>import("./chunk-390v4dv9.js"));n=X(n,e,c);let{processHeadDirective:K,processTitleDirective:ee,processMetaDirective:te,resetHead:ne}=await o("stx/head",()=>import("./chunk-ycr9bkww.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)ne();let le=K(n);if(n=le.content,le.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${le.headContent}
1577
1577
  `;if(n=ee(n,e),n=te(n,e,c),n=Gt(n),n=Fo(n,e),n=At(n),n=zt(n),n=await as(n,e,c,g,d),n=await ds(n,e,c,g,d),n=n.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),n=fi(n),n=se(n,e,c),n=ps(n),e.__stxProcessingDepth===1)n=Vc(n,e);if(n=jc(n,e,{filePath:c,buildMode:g.buildMode}),n=zo(n,e),n=Ho(n,e),n=We(n,e),n=Ht(n,e),n=Bt(n,e),n=await xt(n,e,c,g),n=await gc(n,e,c),n=await mc(n,e,c,g),n=hc(n,e,c,g),n=Zo(n,e,c,g),n=Qo(n,e,c),n=ei(n,e,c,g),n=Tt(n,e,c,g),n=zs(n,e),n=Hs(n),n=Bc(n),!g.skipEventDirectives)n=$c(n,e,c);if(n=wt(n,e,c),g.debug){let z=/\bx-data\s*=/.test(n),W=ms(r);if(z&&W)console.warn(`[stx] ${c}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
1578
1578
  Both work on the same page, but they manage separate scopes.
1579
1579
  Prefer signals (state/derived/effect) for new components.`)}n=ac(n,e),n=await _(n,e,c),n=Fc(n),n=zc(n),n=gt(n);let{processXElementDirectives:de}=await o("stx/x-element",()=>import("./chunk-zhxdpzga.js"));n=de(n);let oe=e.__originalFilePath||c,J=De(e);if(n=await qo(n,g,oe,J),n=Pt(n,e),n=await Kt(n,e,c,g),g.media?.image?.autoSiblings){let z=g.publicDir||"public",{rewriteImagesWithSiblings:W}=await o("stx/image-optimization/auto-sibling",()=>import("./chunk-9wmjmas8.js"));n=await W(n,{publicDir:z})}if(g.seo?.enabled)n=ti(n,e,g);let me=(z,W,Q=!0)=>{if(!W)return z;let he=W.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),re=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(z),fe=re?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(re[0]):null;if(he&&re&&fe){if(Q){let Ce=re.index+fe.index;z=z.slice(0,Ce)+he[0]+z.slice(Ce+fe[0].length)}if(W=W.replace(he[0],"").trim(),!W)return z}if(/<\/head>/i.test(z))return z.replace(/<\/head>/i,`${W}
@@ -1587,6 +1587,6 @@ ${dt()}
1587
1587
  `+Ce}else n=n.replace("</head>",`${W}
1588
1588
  </head>`)}else if(n.includes("<body"))n=n.replace(/<body([^>]*)>/,`<body$1>
1589
1589
  ${W}`);else n=W+`
1590
- `+n}{let{scanScriptTags:z}=await o("stx/signal-processing",()=>import("./chunk-gqse3ae0.js")),W=[];for(let Q of z(n)){if(!/\bserver\b/i.test(Q.attrs))continue;let he=Q.start+Q.fullMatch.indexOf(">")+1,re=En(n,he);if(re===-1)continue;let fe=re+9;while(fe<n.length&&/\s/.test(n[fe]))fe++;W.push({start:Q.start,end:fe})}if(W.length>0){let Q=Array(W.length+1),he=0;for(let re=0;re<W.length;re++){let{start:fe,end:Ce}=W[re];Q[re]=n.slice(he,fe),he=Ce}Q[W.length]=n.slice(he),n=Q.join("")}}let lt=Bs(n,c);if(lt.hasScoped)n=lt.html;let Dn=e.__stx_event_bindings||[],Ke=!1,ut=[],In=/\s:[a-z][\w.-]*\s*=/.test(n),{scanScriptTags:On}=await o("stx/signal-processing",()=>import("./chunk-gqse3ae0.js"));for(let z of On(n,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))ut.push({match:z.fullMatch,attrs:z.attrs,content:z.body});for(let{match:z,attrs:W,content:Q}of ut){Ke=!0;let he=Q;Oe(Q,c,a.strict,e.__originalFilePath);let re=await Le(Q,{eventBindings:Dn,attrs:W,hasColonDirectives:In,templateContent:r,filePath:c,projectRoot:process.cwd(),production:$i(a.buildMode,a.minifyClient),serverData:J});n=n.replace(z,()=>re)}if(Ke)e.__stx_event_bindings=[];if(!Ke&&e.__stxProcessingDepth===1){let z=e.__stx_event_bindings||[];if(z.length>0){let W=ai(z);if(W){let Q=n.lastIndexOf("</body>");n=Q===-1?n+W:n.slice(0,Q)+W+`
1590
+ `+n}{let{scanScriptTags:z}=await o("stx/signal-processing",()=>import("./chunk-mt7d37jh.js")),W=[];for(let Q of z(n)){if(!/\bserver\b/i.test(Q.attrs))continue;let he=Q.start+Q.fullMatch.indexOf(">")+1,re=En(n,he);if(re===-1)continue;let fe=re+9;while(fe<n.length&&/\s/.test(n[fe]))fe++;W.push({start:Q.start,end:fe})}if(W.length>0){let Q=Array(W.length+1),he=0;for(let re=0;re<W.length;re++){let{start:fe,end:Ce}=W[re];Q[re]=n.slice(he,fe),he=Ce}Q[W.length]=n.slice(he),n=Q.join("")}}let lt=Bs(n,c);if(lt.hasScoped)n=lt.html;let Dn=e.__stx_event_bindings||[],Ke=!1,ut=[],In=/\s:[a-z][\w.-]*\s*=/.test(n),{scanScriptTags:On}=await o("stx/signal-processing",()=>import("./chunk-mt7d37jh.js"));for(let z of On(n,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))ut.push({match:z.fullMatch,attrs:z.attrs,content:z.body});for(let{match:z,attrs:W,content:Q}of ut){Ke=!0;let he=Q;Oe(Q,c,a.strict,e.__originalFilePath);let re=await Le(Q,{eventBindings:Dn,attrs:W,hasColonDirectives:In,templateContent:r,filePath:c,projectRoot:process.cwd(),production:$i(a.buildMode,a.minifyClient),serverData:J});n=n.replace(z,()=>re)}if(Ke)e.__stx_event_bindings=[];if(!Ke&&e.__stxProcessingDepth===1){let z=e.__stx_event_bindings||[];if(z.length>0){let W=ai(z);if(W){let Q=n.lastIndexOf("</body>");n=Q===-1?n+W:n.slice(0,Q)+W+`
1591
1591
  `+n.slice(Q)}e.__stx_event_bindings=[]}}if(!be(n)&&lc(n))n=await cr(n,g);if(n=uc(n),g.csp?.enabled&&g.csp.useNonce&&typeof e.cspNonce==="string")n=_t(n,e.cspNonce);return n}
1592
1592
  export{yt,Re,rc,is,No,Mo,tr,i};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{m,h,p}from"./chunk-nv77aaqa.js";import{B}from"./chunk-h8mqh8ds.js";import{i}from"./chunk-6df7h4ay.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Om(e,t={},o={}){let n={...B,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await i(c,y,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((f)=>setTimeout(f,0))}else{let u=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)u.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await i(I,y,e,n,l);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await i(_.content,y,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,y,e,n,l);r.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,y,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
2
+ import{m,h,p}from"./chunk-m76jbcey.js";import{B}from"./chunk-20qn18ry.js";import{i}from"./chunk-c84fwzfq.js";import k from"path";var q={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},T=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var M=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function H(e){let t=[],o=0,n;M.lastIndex=0;while((n=M.exec(e))!==null){if(n.index>o){let a=e.slice(o,n.index);if(a.trim())t.push({type:t.length===0?"shell":"content",content:a})}let s=n[1],r=n[2];t.push({type:"suspense",name:s,content:r}),o=n.index+n[0].length}if(o<e.length){let s=e.slice(o);if(s.trim())t.push({type:t.length===0?"shell":"content",content:s})}if(t.length===0)t.push({type:"shell",content:e});return t}async function Om(e,t={},o={}){let n={...B,...o,streaming:{...q,...o.streaming}},s=n.streaming?.bufferSize||16384;return new ReadableStream({async start(r){try{let a=await Bun.file(e).text(),S=a.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),g=S?S[1]:"",c=a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y={...t,__filename:e,__dirname:k.dirname(e)};if(g.trim())await m(g,y,e);let E=H(c),l=new Set;if(!E.some((w)=>w.type==="suspense")){let w=n.streaming?.strategy||"auto",x=new RegExp(T.source,"g");if(!(w!=="manual"&&x.test(c))){let u=await i(c,y,e,n,l);for(let b=0;b<u.length;b+=s)r.enqueue(u.slice(b,b+s)),await new Promise((f)=>setTimeout(f,0))}else{let u=[],b=new RegExp(T.source,"g"),f;while((f=b.exec(c))!==null)u.push({name:f[1],content:f[2],start:f.index,end:f.index+f[0].length});let v=0;for(let _ of u){if(_.start>v){let I=c.slice(v,_.start);if(I.trim()){let O=await i(I,y,e,n,l);r.enqueue(O),await new Promise((D)=>setTimeout(D,0))}}let C=await i(_.content,y,e,n,l);r.enqueue(C),await new Promise((I)=>setTimeout(I,0)),v=_.end}if(v<c.length){let _=c.slice(v);if(_.trim()){let C=await i(_,y,e,n,l);r.enqueue(C)}}}}else{let w=new Map;for(let d of E)if(d.type==="shell"||d.type==="content"){let u=await i(d.content,y,e,n,l);r.enqueue(u)}else if(d.type==="suspense"&&d.name){let u=`stx-suspense-${d.name}`;r.enqueue(`<div id="${u}" data-suspense="${d.name}" style="display:contents;">
3
3
  <template data-suspense-fallback>Loading...</template>
4
4
  </div>`),w.set(d.name,i(d.content,y,e,n,l))}r.enqueue(`
5
5
  <script>
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{hn,Yf,Zf,Qf,eg,tg,m,ng,gi,rg,Uc,Wc}from"./chunk-nv77aaqa.js";import"./chunk-ftfvezbd.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{hn as STX_ENGINE_BINDING_NAMES,gi as convertToCommonJS,Uc as extractScriptFromTemplate,m as extractVariables,Wc as hasVariables,ng as isCompleteImport,tg as isMissingBindingFailure,Qf as isModuleResolutionFailure,eg as isSyntaxFailure,rg as splitDeclaration,Yf as stripTypeScript,Zf as withoutStxReferrer};
2
+ import{hn,Yf,Zf,Qf,eg,tg,m,ng,gi,rg,Uc,Wc}from"./chunk-m76jbcey.js";import"./chunk-kfgbk0x9.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{hn as STX_ENGINE_BINDING_NAMES,gi as convertToCommonJS,Uc as extractScriptFromTemplate,m as extractVariables,Wc as hasVariables,ng as isCompleteImport,tg as isMissingBindingFailure,Qf as isModuleResolutionFailure,eg as isSyntaxFailure,rg as splitDeclaration,Yf as stripTypeScript,Zf as withoutStxReferrer};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ve,Us,gg,Gh,mg,Jh,Mt,p,U,Z,wn,Se,hg,wi,yg,Yh,_,bg,Zh,T,Qh}from"./chunk-nv77aaqa.js";import"./chunk-ftfvezbd.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{bg as applyFilters,Jh as clearCustomFilters,hg as clientLoopScopes,Us as defaultFilters,wn as escapeAttributeValue,p as escapeHtml,U as escapeHtmlValue,Z as escapeInterpolatedHtmlValue,T as evaluateExpression,ve as findMustacheEnd,mg as getAllFilters,yg as interpolateScriptAttributes,wi as interpolateScriptExpressions,Yh as interpolateScriptsInTemplate,_ as processExpressions,gg as registerFilter,Gh as registerFilters,Mt as replaceInterpolations,Zh as resetRejectedExpressionWarnings,Qh as unescapeHtml,Se as usesSignalsInScript};
2
+ import{ve,Us,gg,Gh,mg,Jh,Mt,p,U,Z,wn,Se,hg,wi,yg,Yh,_,bg,Zh,T,Qh}from"./chunk-m76jbcey.js";import"./chunk-kfgbk0x9.js";import"./chunk-m7hfcxt3.js";import"./chunk-gebb12ak.js";import"./chunk-r9e0r6jx.js";import"./chunk-ybjfr7e8.js";export{bg as applyFilters,Jh as clearCustomFilters,hg as clientLoopScopes,Us as defaultFilters,wn as escapeAttributeValue,p as escapeHtml,U as escapeHtmlValue,Z as escapeInterpolatedHtmlValue,T as evaluateExpression,ve as findMustacheEnd,mg as getAllFilters,yg as interpolateScriptAttributes,wi as interpolateScriptExpressions,Yh as interpolateScriptsInTemplate,_ as processExpressions,gg as registerFilter,Gh as registerFilters,Mt as replaceInterpolations,Zh as resetRejectedExpressionWarnings,Qh as unescapeHtml,Se as usesSignalsInScript};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{_}from"./chunk-nv77aaqa.js";import{i}from"./chunk-6df7h4ay.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
2
+ import{_}from"./chunk-m76jbcey.js";import{i}from"./chunk-c84fwzfq.js";import p from"fs";import g from"path";import*as y from"readline";var e={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},u={help:{description:"Show available commands",usage:"help [command]",handler:async(t,o)=>{if(t[0]&&u[t[0]]){let n=u[t[0]];console.log(`
3
3
  ${e.bold}${t[0]}${e.reset} - ${n.description}`),console.log(` Usage: ${e.cyan}${n.usage}${e.reset}
4
4
  `)}else{console.log(`
5
5
  ${e.bold}Available Commands:${e.reset}