@stacksjs/stx 0.2.817 → 0.2.818

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 (201) hide show
  1. package/dist/{chunk-pyytr30r.js → chunk-035m9ada.js} +3 -3
  2. package/dist/chunk-03mtfndv.js +2 -0
  3. package/dist/chunk-18qxd18d.js +2 -0
  4. package/dist/{chunk-d47m4qat.js → chunk-1a8qtvs1.js} +2 -2
  5. package/dist/{chunk-s9xs2ff4.js → chunk-1ae3megp.js} +5 -5
  6. package/dist/chunk-1cd0w20k.js +2 -0
  7. package/dist/{chunk-549end3k.js → chunk-1hg0zb3p.js} +2 -2
  8. package/dist/{chunk-p8wq37hd.js → chunk-1rvgv1fr.js} +5 -5
  9. package/dist/{chunk-n761hp6d.js → chunk-1tzqqr0p.js} +2 -2
  10. package/dist/{chunk-rc424p1c.js → chunk-2bnbcr22.js} +24 -24
  11. package/dist/{chunk-b5ckg7zq.js → chunk-2jn0x4sh.js} +5 -5
  12. package/dist/chunk-2kt1gqtq.js +2 -0
  13. package/dist/chunk-2vaap97d.js +2 -0
  14. package/dist/chunk-33ewq978.js +2 -0
  15. package/dist/chunk-3m342maz.js +2 -0
  16. package/dist/chunk-46sej67y.js +2 -0
  17. package/dist/{chunk-5efv1fhk.js → chunk-4fbg7gq8.js} +2 -2
  18. package/dist/{chunk-cj1p3qdh.js → chunk-4h78zypb.js} +1 -1
  19. package/dist/chunk-5zf566bv.js +2 -0
  20. package/dist/chunk-67k5q95t.js +2 -0
  21. package/dist/chunk-6e76tz09.js +2 -0
  22. package/dist/{chunk-bphwhfbd.js → chunk-6n11z33h.js} +5 -5
  23. package/dist/{chunk-7rk7wfm6.js → chunk-72jt897s.js} +13 -13
  24. package/dist/chunk-72w08sh9.js +2 -0
  25. package/dist/{chunk-agxjwnz0.js → chunk-7ac98ja7.js} +8 -8
  26. package/dist/chunk-7q79h0j4.js +2 -0
  27. package/dist/chunk-88mhhbqj.js +2 -0
  28. package/dist/{chunk-a0r4dpzs.js → chunk-8dmey36n.js} +2 -2
  29. package/dist/chunk-8gcg9maj.js +1327 -0
  30. package/dist/{chunk-gtfs96f2.js → chunk-8hfgvs0x.js} +2 -2
  31. package/dist/{chunk-cm5cp3m0.js → chunk-8wdy7kdq.js} +4 -4
  32. package/dist/{chunk-kjjvs3sc.js → chunk-9487tyfa.js} +2 -2
  33. package/dist/chunk-9736003n.js +2 -0
  34. package/dist/chunk-99zwpazg.js +2 -0
  35. package/dist/chunk-9e5gamvs.js +2 -0
  36. package/dist/{chunk-17wb2x3z.js → chunk-9egd7tx3.js} +2 -2
  37. package/dist/{chunk-5hxvhmg3.js → chunk-9gj702tw.js} +4 -4
  38. package/dist/{chunk-2ws2qe1k.js → chunk-9gwhs0gk.js} +2 -2
  39. package/dist/{chunk-rxt4jj9b.js → chunk-9tzcvsv0.js} +6 -6
  40. package/dist/{chunk-133vw0ae.js → chunk-9xd85mvm.js} +4 -4
  41. package/dist/chunk-9y1dm510.js +2 -0
  42. package/dist/{chunk-yvqe0pzk.js → chunk-a1cy78h3.js} +2 -2
  43. package/dist/{chunk-sa0nkpx9.js → chunk-a67c2xrp.js} +2 -2
  44. package/dist/chunk-abzrvxct.js +2 -0
  45. package/dist/chunk-avbvedyx.js +2 -0
  46. package/dist/{chunk-3vpgr6nk.js → chunk-b9d70mgr.js} +3 -3
  47. package/dist/chunk-bbxzkcsk.js +2 -0
  48. package/dist/chunk-c179xpsq.js +2 -0
  49. package/dist/{chunk-n9av365c.js → chunk-casvvt3k.js} +1 -1
  50. package/dist/{chunk-p5ez40kf.js → chunk-cf196sv5.js} +2 -2
  51. package/dist/chunk-cvq4bz8y.js +2 -0
  52. package/dist/{chunk-1wdv3zj2.js → chunk-d4pmddb9.js} +1 -1
  53. package/dist/chunk-dh1f8ga0.js +2 -0
  54. package/dist/{chunk-1fc6rax4.js → chunk-dpn314z2.js} +2 -2
  55. package/dist/{chunk-6cw072n5.js → chunk-dq9djbgq.js} +4 -4
  56. package/dist/{chunk-tb4wmzzd.js → chunk-e3t2bqyf.js} +5 -5
  57. package/dist/{chunk-y3p6w1e0.js → chunk-e9w8qav3.js} +5 -5
  58. package/dist/{chunk-jg9f5nqf.js → chunk-em2yy1te.js} +6 -6
  59. package/dist/chunk-em7kntfc.js +2 -0
  60. package/dist/chunk-enm79dwe.js +2 -0
  61. package/dist/{chunk-m0x96g8e.js → chunk-f6nk205v.js} +1 -1
  62. package/dist/{chunk-f54t0qar.js → chunk-fmawgk87.js} +1 -1
  63. package/dist/chunk-fvs15n0s.js +2 -0
  64. package/dist/{chunk-gqjb1y7c.js → chunk-g7mjv276.js} +2 -2
  65. package/dist/{chunk-r6dtrd7y.js → chunk-gcje06er.js} +30 -30
  66. package/dist/{chunk-1bgv727x.js → chunk-gtd6qs1r.js} +2 -2
  67. package/dist/chunk-gvthmy3a.js +2 -0
  68. package/dist/chunk-h8kbcz9t.js +2 -0
  69. package/dist/chunk-h8x56dq5.js +2 -0
  70. package/dist/{chunk-hg67a15h.js → chunk-hntm02x0.js} +3 -3
  71. package/dist/chunk-hx575xy8.js +2 -0
  72. package/dist/{chunk-dy7yccxm.js → chunk-j24psz0z.js} +7 -7
  73. package/dist/chunk-j58z3y2g.js +2 -0
  74. package/dist/chunk-j5t40n2g.js +2 -0
  75. package/dist/{chunk-nmkkfpmh.js → chunk-j65nf7mt.js} +6 -6
  76. package/dist/{chunk-kvhsdyfg.js → chunk-j8r0am39.js} +1 -1
  77. package/dist/{chunk-jtx9x3as.js → chunk-k01aftw0.js} +6 -6
  78. package/dist/{chunk-0h99mrb0.js → chunk-k3t72x38.js} +2 -2
  79. package/dist/{chunk-0svj1nfa.js → chunk-k3zcadcc.js} +2 -2
  80. package/dist/chunk-kgwdxx75.js +2 -0
  81. package/dist/{chunk-r5nt1bcx.js → chunk-mbhvf0sv.js} +2 -2
  82. package/dist/{chunk-fn3q1gtr.js → chunk-mjg9cx5a.js} +3 -3
  83. package/dist/{chunk-ccxphr19.js → chunk-mm8ak4w2.js} +2 -2
  84. package/dist/{chunk-xrd1md4j.js → chunk-mr2ke5km.js} +6 -6
  85. package/dist/chunk-n1tbc7da.js +2 -0
  86. package/dist/{chunk-4ws3yz5q.js → chunk-n4s0se11.js} +8 -8
  87. package/dist/chunk-n7dm6prj.js +2 -0
  88. package/dist/chunk-nknpr8cy.js +2 -0
  89. package/dist/{chunk-jham85mf.js → chunk-nqdh7z2d.js} +1 -1
  90. package/dist/{chunk-vbrn4w81.js → chunk-p13wg97w.js} +3 -3
  91. package/dist/chunk-pe9npaby.js +2 -0
  92. package/dist/chunk-pyz2jqph.js +2 -0
  93. package/dist/chunk-q51w24br.js +2 -0
  94. package/dist/chunk-qek9bcjt.js +2 -0
  95. package/dist/chunk-qkxx34vt.js +2 -0
  96. package/dist/{chunk-0jcady6w.js → chunk-qr14xvwb.js} +1 -1
  97. package/dist/chunk-r2v042ym.js +2 -0
  98. package/dist/{chunk-df60fpgx.js → chunk-r8ydxe4z.js} +3 -3
  99. package/dist/chunk-rjzp7za8.js +2 -0
  100. package/dist/{chunk-yts2b9d8.js → chunk-s6mte5vy.js} +11 -6
  101. package/dist/chunk-s9b49v74.js +3 -0
  102. package/dist/{chunk-vkn133cs.js → chunk-s9b6abkb.js} +2 -2
  103. package/dist/chunk-sata7rh2.js +2 -0
  104. package/dist/{chunk-pdnyhs63.js → chunk-sf4rntqj.js} +1 -1
  105. package/dist/{chunk-8h3jv8dd.js → chunk-sh1hbhhb.js} +2 -2
  106. package/dist/{chunk-ntn6bnjv.js → chunk-skht06a2.js} +1 -1
  107. package/dist/{chunk-gc7pykfq.js → chunk-swbrvrgr.js} +2 -2
  108. package/dist/{chunk-s90m43sm.js → chunk-sxad7x2s.js} +4 -4
  109. package/dist/{chunk-w6n4y2xg.js → chunk-tj6zvs8f.js} +2 -2
  110. package/dist/chunk-tmcgpf68.js +2 -0
  111. package/dist/chunk-tsb5h4e2.js +2 -0
  112. package/dist/chunk-v8h2kns0.js +2 -0
  113. package/dist/{chunk-ncyjaxyz.js → chunk-vmxzktdr.js} +1 -1
  114. package/dist/chunk-vpazz8ca.js +2 -0
  115. package/dist/{chunk-5gxneecs.js → chunk-vtt2dec3.js} +3 -3
  116. package/dist/chunk-vyw40ym7.js +2 -0
  117. package/dist/chunk-whq40bdm.js +2 -0
  118. package/dist/chunk-x15hrtmt.js +2 -0
  119. package/dist/{chunk-fcvyk047.js → chunk-x34me5ar.js} +7 -7
  120. package/dist/{chunk-0ekdbagy.js → chunk-xc7nynb9.js} +2 -2
  121. package/dist/chunk-xha2gt0n.js +2 -0
  122. package/dist/{chunk-hhazm0cs.js → chunk-y3zjmv9e.js} +3 -3
  123. package/dist/chunk-ydt1pbhx.js +2 -0
  124. package/dist/chunk-ymypc1rp.js +709 -0
  125. package/dist/chunk-z8ywxqqg.js +2 -0
  126. package/dist/{chunk-crmxg1c0.js → chunk-zgq8bfaw.js} +4 -4
  127. package/dist/{chunk-e39nkbt4.js → chunk-zhvmcj78.js} +4 -4
  128. package/dist/{chunk-2p3eaj16.js → chunk-zme16hcr.js} +3 -3
  129. package/dist/{chunk-sphc7xzx.js → chunk-znx5m1jv.js} +1 -1
  130. package/dist/chunk-zwp7n01x.js +2 -0
  131. package/dist/cli.js +12 -12
  132. package/dist/client/signals-expression-runtime.js +6 -2
  133. package/dist/client/signals-public-api-runtime.js +1 -0
  134. package/dist/craft-entry.js +2 -2
  135. package/dist/craft.js +2 -2
  136. package/dist/process.js +2 -2
  137. package/dist/pwa.js +3 -3
  138. package/dist/reactive.d.ts +12 -2
  139. package/dist/reactive.js +69 -32
  140. package/dist/ssg.js +10 -10
  141. package/dist/utils.js +6 -1
  142. package/package.json +5 -5
  143. package/dist/chunk-0yjm4j26.js +0 -2
  144. package/dist/chunk-1kz70290.js +0 -2
  145. package/dist/chunk-1rwfgmmk.js +0 -2
  146. package/dist/chunk-2k3qtmn8.js +0 -2
  147. package/dist/chunk-2vget8rh.js +0 -2
  148. package/dist/chunk-3e85etrf.js +0 -2
  149. package/dist/chunk-3eqs0rpv.js +0 -2
  150. package/dist/chunk-3ftaegqg.js +0 -2
  151. package/dist/chunk-3jd5ak8h.js +0 -2
  152. package/dist/chunk-4ypwqrj2.js +0 -2
  153. package/dist/chunk-5eqna31h.js +0 -2
  154. package/dist/chunk-6a97a9wk.js +0 -2
  155. package/dist/chunk-7agp0wj2.js +0 -2
  156. package/dist/chunk-7hch54b2.js +0 -2
  157. package/dist/chunk-7pb9fepg.js +0 -2
  158. package/dist/chunk-8g8h2xwz.js +0 -2
  159. package/dist/chunk-9mtw71xy.js +0 -2
  160. package/dist/chunk-9ttf7k5e.js +0 -2
  161. package/dist/chunk-9wmjmas8.js +0 -2
  162. package/dist/chunk-a350jjd3.js +0 -2
  163. package/dist/chunk-aqydav9y.js +0 -2
  164. package/dist/chunk-ar7w1kx0.js +0 -2
  165. package/dist/chunk-aya8nv31.js +0 -2
  166. package/dist/chunk-b9ntt41z.js +0 -2
  167. package/dist/chunk-bj6ax0he.js +0 -2
  168. package/dist/chunk-cxpnkgvw.js +0 -2
  169. package/dist/chunk-d3gncxq1.js +0 -2
  170. package/dist/chunk-da886asf.js +0 -2
  171. package/dist/chunk-dnemxdvy.js +0 -2
  172. package/dist/chunk-dnqt6y8v.js +0 -3
  173. package/dist/chunk-f0bwetnx.js +0 -421
  174. package/dist/chunk-gzhrtymg.js +0 -1592
  175. package/dist/chunk-h9yvb9qn.js +0 -2
  176. package/dist/chunk-hsmwzzy2.js +0 -2
  177. package/dist/chunk-jsvc264s.js +0 -2
  178. package/dist/chunk-k98nt4pk.js +0 -2
  179. package/dist/chunk-ka1hrt56.js +0 -2
  180. package/dist/chunk-m477m5dp.js +0 -2
  181. package/dist/chunk-mkr46mzz.js +0 -2
  182. package/dist/chunk-mmyrdbxx.js +0 -2
  183. package/dist/chunk-p4f1hrvn.js +0 -2
  184. package/dist/chunk-py244ymg.js +0 -2
  185. package/dist/chunk-rp6b7awz.js +0 -2
  186. package/dist/chunk-rqfg21xk.js +0 -2
  187. package/dist/chunk-rxc1076r.js +0 -2
  188. package/dist/chunk-rzwyaqgg.js +0 -2
  189. package/dist/chunk-s5pegavh.js +0 -2
  190. package/dist/chunk-sj4vw93g.js +0 -2
  191. package/dist/chunk-snfjvd94.js +0 -2
  192. package/dist/chunk-syvsj91a.js +0 -2
  193. package/dist/chunk-tzb0n60s.js +0 -2
  194. package/dist/chunk-w8xvkbt9.js +0 -2
  195. package/dist/chunk-x5rt4kpx.js +0 -2
  196. package/dist/chunk-xbknqp19.js +0 -2
  197. package/dist/chunk-xgqyzkt2.js +0 -2
  198. package/dist/chunk-yd0074ks.js +0 -2
  199. package/dist/chunk-yd1zsy7t.js +0 -2
  200. package/dist/chunk-yjezsy4p.js +0 -2
  201. package/dist/chunk-yjvwp1s6.js +0 -2
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{f,d}from"./chunk-7rk7wfm6.js";import{J,O,p}from"./chunk-f0bwetnx.js";function B(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var N=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function k(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function Z(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);n=g===-1?t.length:g+3;continue}let a=k(t,s+1);if(a===-1)return-1;let u=t.slice(s,a),c=u.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(c&&c[2].toLowerCase()===r){if(c[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(u))e++}n=a}return-1}function L(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[2].toLowerCase();if(u[1]==="/"){let l=i.lastIndexOf(c);if(l!==-1)i.splice(l);e=s;continue}let g=/\/\s*>$/.test(a),m=i.length===0?a.match(r):null;if(m){let l=m[1]||m[2],h=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),S=g||N.has(c)?-1:Z(t,c,s);if(S===-1)o.push({start:n,end:s,slotName:l,element:h}),e=s;else o.push({start:n,end:S,slotName:l,element:h+t.slice(s,S)}),e=S;continue}if(!g&&!N.has(c)){if(i.push(c),c==="script"||c==="style"){let l=t.toLowerCase().indexOf(`</${c}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function j(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[1]==="/",g=u[2].toLowerCase();if(c){let l=i.lastIndexOf(g);if(l!==-1)i.splice(l);e=s;continue}if(g==="template"&&i.length===0){let l=a.match(r);if(l){let h=B(t,s);if(h!==-1){let S=l[1]||l[2]||l[3];o.push({start:n,end:h,slotName:S,content:t.slice(s,h-11).trim(),propsBinding:l[4]||void 0}),e=h;continue}}}if(!/\/\s*>$/.test(a)&&!N.has(g)){if(i.push(g),g==="script"||g==="style"){let l=t.toLowerCase().indexOf(`</${g}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function Fl(t){let o={default:"",named:new Map},i=t,r=j(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=L(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function gm(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function zl(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r},a=new Set,u=new Set;if(n.startsWith("{")&&n.endsWith("}")){let c=n.slice(1,-1).split(",").map((g)=>g.trim()).filter(Boolean);for(let g of c){let[m,l]=g.split(":").map((S)=>S.trim()),h=l||m;if(s[h]=o[m],o[m]!==void 0)u.add(h);else a.add(h)}}else if(s[n]=o,Object.values(o).some((c)=>c===void 0))a.add(n);else u.add(n);e=I(e,s,a,u)}return e}function I(t,o,i,r){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(e,n)=>{try{let s=n.trim();if(O(s,i))return e;if(Array.isArray(o.__stx_preserved_client_expressions)&&o.__stx_preserved_client_expressions.includes(s)&&!O(s,r))return e;let a=C(s,o);if(a===void 0)return e;return p(String(a??""))}catch{return`{{ ${n} }}`}})}function C(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!f(t))return;return d(t,Object.keys(o))(...Object.values(o))}catch{return}}async function Hl(t,o,i,r){let e=t;e=await W(e,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(a,u,c,g)=>{let m=o.named.get(u),l=g?.trim()||"",h=c||"",S={},E=[],M=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,b;while((b=M.exec(h))!==null){let w=b[1],x=b[2];S[w]=C(x,i),E.push([w,x])}if(r!==void 0&&m?.propsBinding&&Object.values(S).some((w)=>w===void 0)){let w=m.propsBinding.trim(),x=J(`${w} in []`),y="__stx_slot_props";while(x.includes(y))y+="_";let v=E.map(([A,z])=>{let R=S[A],_;try{_=R===void 0?void 0:JSON.stringify(R)}catch{}return`${JSON.stringify(A)}:(${_??z})`}).join(","),P=p(JSON.stringify({binding:w,names:x,owner:r}));return`<template :for="${p(`${y} in [{${v}}]`)}" data-stx-slot-binding="${encodeURIComponent(w)}" data-stx-slot-scope="${P}">${m.content}</template>`}return await zl(m,S,l,i)});let s=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return e=e.replace(s,(a,u,c)=>{if(/\bname\s*=/.test(u||""))return a;let g=c?.trim()||"";return o.default||g}),e}async function W(t,o,i){let r=[],e=[];t.replace(o,(a,...u)=>{let c=u[u.length-2];return e.push({match:a,index:c}),r.push(i(a,...u.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:u,index:c}=e[a];s=s.slice(0,c)+n[a]+s.slice(c+u.length)}return s}function mm(t){let o=Fl(t);return{defaultSlot:o.default,namedSlots:o.named}}async function hm(t,o,i,r,e){return await Hl(t,{default:o,named:i},r,e)}
3
- export{Fl,gm,zl,Hl,mm,hm};
2
+ import{f,d}from"./chunk-72jt897s.js";import{J,O,p}from"./chunk-ymypc1rp.js";function B(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var N=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function k(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function Z(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);n=g===-1?t.length:g+3;continue}let a=k(t,s+1);if(a===-1)return-1;let u=t.slice(s,a),c=u.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(c&&c[2].toLowerCase()===r){if(c[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(u))e++}n=a}return-1}function L(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[2].toLowerCase();if(u[1]==="/"){let l=i.lastIndexOf(c);if(l!==-1)i.splice(l);e=s;continue}let g=/\/\s*>$/.test(a),m=i.length===0?a.match(r):null;if(m){let l=m[1]||m[2],h=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),S=g||N.has(c)?-1:Z(t,c,s);if(S===-1)o.push({start:n,end:s,slotName:l,element:h}),e=s;else o.push({start:n,end:S,slotName:l,element:h+t.slice(s,S)}),e=S;continue}if(!g&&!N.has(c)){if(i.push(c),c==="script"||c==="style"){let l=t.toLowerCase().indexOf(`</${c}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function j(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let l=t.indexOf("-->",n+4);e=l===-1?t.length:l+3;continue}let s=k(t,n+1);if(s===-1)break;let a=t.slice(n,s),u=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!u){e=s;continue}let c=u[1]==="/",g=u[2].toLowerCase();if(c){let l=i.lastIndexOf(g);if(l!==-1)i.splice(l);e=s;continue}if(g==="template"&&i.length===0){let l=a.match(r);if(l){let h=B(t,s);if(h!==-1){let S=l[1]||l[2]||l[3];o.push({start:n,end:h,slotName:S,content:t.slice(s,h-11).trim(),propsBinding:l[4]||void 0}),e=h;continue}}}if(!/\/\s*>$/.test(a)&&!N.has(g)){if(i.push(g),g==="script"||g==="style"){let l=t.toLowerCase().indexOf(`</${g}>`,s);if(l!==-1){e=l;continue}}}e=s}return o}function zl(t){let o={default:"",named:new Map},i=t,r=j(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=L(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function mm(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function Hl(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r},a=new Set,u=new Set;if(n.startsWith("{")&&n.endsWith("}")){let c=n.slice(1,-1).split(",").map((g)=>g.trim()).filter(Boolean);for(let g of c){let[m,l]=g.split(":").map((S)=>S.trim()),h=l||m;if(s[h]=o[m],o[m]!==void 0)u.add(h);else a.add(h)}}else if(s[n]=o,Object.values(o).some((c)=>c===void 0))a.add(n);else u.add(n);e=I(e,s,a,u)}return e}function I(t,o,i,r){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(e,n)=>{try{let s=n.trim();if(O(s,i))return e;if(Array.isArray(o.__stx_preserved_client_expressions)&&o.__stx_preserved_client_expressions.includes(s)&&!O(s,r))return e;let a=C(s,o);if(a===void 0)return e;return p(String(a??""))}catch{return`{{ ${n} }}`}})}function C(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!f(t))return;return d(t,Object.keys(o))(...Object.values(o))}catch{return}}async function Vl(t,o,i,r){let e=t;e=await W(e,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(a,u,c,g)=>{let m=o.named.get(u),l=g?.trim()||"",h=c||"",S={},E=[],M=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,b;while((b=M.exec(h))!==null){let w=b[1],x=b[2];S[w]=C(x,i),E.push([w,x])}if(r!==void 0&&m?.propsBinding&&Object.values(S).some((w)=>w===void 0)){let w=m.propsBinding.trim(),x=J(`${w} in []`),y="__stx_slot_props";while(x.includes(y))y+="_";let v=E.map(([A,z])=>{let R=S[A],_;try{_=R===void 0?void 0:JSON.stringify(R)}catch{}return`${JSON.stringify(A)}:(${_??z})`}).join(","),P=p(JSON.stringify({binding:w,names:x,owner:r}));return`<template :for="${p(`${y} in [{${v}}]`)}" data-stx-slot-binding="${encodeURIComponent(w)}" data-stx-slot-scope="${P}">${m.content}</template>`}return await Hl(m,S,l,i)});let s=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return e=e.replace(s,(a,u,c)=>{if(/\bname\s*=/.test(u||""))return a;let g=c?.trim()||"";return o.default||g}),e}async function W(t,o,i){let r=[],e=[];t.replace(o,(a,...u)=>{let c=u[u.length-2];return e.push({match:a,index:c}),r.push(i(a,...u.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:u,index:c}=e[a];s=s.slice(0,c)+n[a]+s.slice(c+u.length)}return s}function hm(t){let o=zl(t);return{defaultSlot:o.default,namedSlots:o.named}}async function ym(t,o,i,r,e){return await Vl(t,{default:o,named:i},r,e)}
3
+ export{zl,mm,Hl,Vl,hm,ym};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Wl}from"./chunk-s9b6abkb.js";export{Wl as rewriteImagesWithSiblings};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{m,gi,Wc,qc,ag,cg,lg,ug,dg,Vs,pg,je,Y,Be,fg,Cr,gg,Gc,Jc,yi,Fe,s,bn,Yc,h,fe,Gh}from"./chunk-ymypc1rp.js";import"./chunk-sf4rntqj.js";import"./chunk-m7hfcxt3.js";import"./chunk-72jt897s.js";import"./chunk-r9e0r6jx.js";import"./chunk-1tzqqr0p.js";export{Jc as SIGNAL_COMPOSABLE_CALL,fe as clearComponentCache,yi as componentClientSignalNames,gi as convertToCommonJS,h as createDetailedErrorMessage,dg as extractDirectiveNames,Wc as extractScriptFromTemplate,m as extractVariables,s as fileExists,Gh as getComponentCacheStats,cg as getPositionInfo,Y as getSharedTranspiler,Yc as getSourceLineInfo,ug as hasDirectives,qc as hasVariables,gg as isHydrateTrigger,pg as isJavaScriptScript,Fe as renderComponentWithSlot,bn as resolveTemplatePath,fg as scopeOnRootElement,Vs as scopeSequenceKey,je as shouldTranspileTypeScript,Gc as slotContentHasExpressions,Be as transpileTypeScript,Cr as userComponentFileExists,lg as validateDirective,ag as validateTemplate};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ca,Ea,Ta,$a,Sh}from"./chunk-2bnbcr22.js";import"./chunk-gcje06er.js";import"./chunk-mm8ak4w2.js";import"./chunk-baj6w8ja.js";import"./chunk-8gcg9maj.js";import"./chunk-9tzcvsv0.js";import"./chunk-7ac98ja7.js";import"./chunk-c84pxd2k.js";import"./chunk-r8ydxe4z.js";import"./chunk-s9b49v74.js";import"./chunk-e9w8qav3.js";import"./chunk-f6nk205v.js";import"./chunk-x34me5ar.js";import"./chunk-9xd85mvm.js";import"./chunk-fmawgk87.js";import"./chunk-swbrvrgr.js";import"./chunk-j65nf7mt.js";import"./chunk-casvvt3k.js";import"./chunk-9gwhs0gk.js";import"./chunk-t2sg2tp2.js";import"./chunk-em2yy1te.js";import"./chunk-gtd6qs1r.js";import"./chunk-ymypc1rp.js";import"./chunk-sf4rntqj.js";import"./chunk-m7hfcxt3.js";import"./chunk-72jt897s.js";import"./chunk-r9e0r6jx.js";import"./chunk-1tzqqr0p.js";export{Ca as buildNative,Sh as default,Ea as findCraftBinary,$a as getAvailableFormats,Ta as getAvailableTargets};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- var f=null,D=[],v=0,g=new Set;function x(){return f}function S(e){let n=f;return D.push(e),f=e,n}function h(e){D.pop(),f=e}var A=new WeakMap;function w(e,n){A.set(e,n)}function p(e,n){for(let r of e){let i=A.get(r);if(i)i(n);else n.add(r)}}function b(e){if(v>0){p(e,g);return}let n=new Set;p(e,n);for(let r of n)r()}function C(e){v++;try{e()}finally{if(v--,v===0){let n=[...g];g.clear();for(let r of n)r()}}}function m(e){let n=f;f=null;try{return e()}finally{f=n}}var k=[],T=[];function le(e){let n=e,r=new Set,i=new Set,o=()=>{let t=x();if(t)i.add(t);return n};return o.set=(t)=>{if(!Object.is(t,n)){let c=n;n=t,r.forEach((u)=>{try{u(n,c)}catch(l){console.error("[stx] subscriber error:",l)}}),b(i)}},o.update=(t)=>{o.set(t(n))},o.subscribe=(t)=>(r.add(t),()=>r.delete(t)),Object.defineProperty(o,"_isSignal",{value:!0,writable:!1}),Object.defineProperty(o,"value",{get:()=>o(),set:(t)=>o.set(t),configurable:!0}),o}function Vn(e,n={}){let r,i=!0,o=!1,t=new Set,c=typeof n.equals==="function"?n.equals:null,u=()=>{let s=S(d);try{r=e(),o=!0}finally{h(s)}i=!1},l=()=>{let s=r,y=o;try{u()}catch{return i=!0,!0}return!y||!c(s,r)},d=()=>{if(i)return;if(c&&t.size){if(l())b(t);return}i=!0,b(t)};w(d,(s)=>{if(i)return;if(c&&t.size){if(l())p(t,s);return}i=!0,p(t,s)});let a=()=>{let s=x();if(s)t.add(s);if(i)u();return r};return Object.defineProperty(a,"_isDerived",{value:!0,writable:!1}),Object.defineProperty(a,"value",{get:()=>a(),configurable:!0}),a}function dh(e,n=Object.is){return Vn(e,{equals:n})}function Un(e,n={}){let r,i=!1,o=()=>{if(i)return;if(r){let c=r;r=void 0;try{c()}catch(u){console.error("[stx] effect cleanup error:",u)}}let t=S(o);try{let c=e();r=typeof c==="function"?c:void 0}catch(c){i=!0,console.error("[stx] effect error (the effect is disposed):",c)}finally{h(t)}};if(n.immediate!==!1)o();return()=>{if(i=!0,r){let t=r;r=void 0,t()}}}function vo(e){C(e)}function Gr(e){k.push(e)}function Jr(e){T.push(e)}function ph(){O(k,"onMount",T)}function fh(){O(T,"onDestroy")}function O(e,n,r){let i=e.splice(0,e.length);for(let o of i)try{let t=o();if(r&&typeof t==="function")r.push(t)}catch(t){console.error(`[stx] ${n} callback threw:`,t)}}function gh(){return{mount:k.length,destroy:T.length}}function Wn(e){return typeof e==="function"&&e._isSignal===!0}function qn(e){return typeof e==="function"&&e._isDerived===!0}function xo(e){if(Wn(e)||qn(e))return m(()=>e());return e}function Yr(e){return m(e)}function mh(e,n){let r=typeof e==="function"?e:()=>e,i=le([]),o=Vn(()=>i().reduce((u,l)=>n(u,l.action),r())),t=!1;return Un(()=>{if(r(),!t){t=!0;return}if(Yr(()=>i().length))i.set([])}),[o,(u,l)=>{let d={action:u};i.set([...i(),d]);let a=()=>{let s=i().filter((y)=>y!==d);if(s.length!==i().length)i.set(s)};if(l&&typeof l.then==="function")Promise.resolve(l).then(a,a);return a}]}
3
- export{le,Vn,dh,Un,vo,Gr,Jr,ph,fh,gh,Wn,qn,xo,Yr,mh};
2
+ var f=null,D=[],v=0,g=new Set;function x(){return f}function S(e){let n=f;return D.push(e),f=e,n}function h(e){D.pop(),f=e}var A=new WeakMap;function w(e,n){A.set(e,n)}function p(e,n){for(let r of e){let i=A.get(r);if(i)i(n);else n.add(r)}}function b(e){if(v>0){p(e,g);return}let n=new Set;p(e,n);for(let r of n)r()}function C(e){v++;try{e()}finally{if(v--,v===0){let n=[...g];g.clear();for(let r of n)r()}}}function m(e){let n=f;f=null;try{return e()}finally{f=n}}var k=[],T=[];function le(e){let n=e,r=new Set,i=new Set,o=()=>{let t=x();if(t)i.add(t);return n};return o.set=(t)=>{if(!Object.is(t,n)){let c=n;n=t,r.forEach((u)=>{try{u(n,c)}catch(l){console.error("[stx] subscriber error:",l)}}),b(i)}},o.update=(t)=>{o.set(t(n))},o.subscribe=(t)=>(r.add(t),()=>r.delete(t)),Object.defineProperty(o,"_isSignal",{value:!0,writable:!1}),Object.defineProperty(o,"value",{get:()=>o(),set:(t)=>o.set(t),configurable:!0}),o}function Vn(e,n={}){let r,i=!0,o=!1,t=new Set,c=typeof n.equals==="function"?n.equals:null,u=()=>{let s=S(d);try{r=e(),o=!0}finally{h(s)}i=!1},l=()=>{let s=r,y=o;try{u()}catch{return i=!0,!0}return!y||!c(s,r)},d=()=>{if(i)return;if(c&&t.size){if(l())b(t);return}i=!0,b(t)};w(d,(s)=>{if(i)return;if(c&&t.size){if(l())p(t,s);return}i=!0,p(t,s)});let a=()=>{let s=x();if(s)t.add(s);if(i)u();return r};return Object.defineProperty(a,"_isDerived",{value:!0,writable:!1}),Object.defineProperty(a,"value",{get:()=>a(),configurable:!0}),a}function ph(e,n=Object.is){return Vn(e,{equals:n})}function Un(e,n={}){let r,i=!1,o=()=>{if(i)return;if(r){let c=r;r=void 0;try{c()}catch(u){console.error("[stx] effect cleanup error:",u)}}let t=S(o);try{let c=e();r=typeof c==="function"?c:void 0}catch(c){i=!0,console.error("[stx] effect error (the effect is disposed):",c)}finally{h(t)}};if(n.immediate!==!1)o();return()=>{if(i=!0,r){let t=r;r=void 0,t()}}}function vo(e){C(e)}function Gr(e){k.push(e)}function Jr(e){T.push(e)}function fh(){O(k,"onMount",T)}function gh(){O(T,"onDestroy")}function O(e,n,r){let i=e.splice(0,e.length);for(let o of i)try{let t=o();if(r&&typeof t==="function")r.push(t)}catch(t){console.error(`[stx] ${n} callback threw:`,t)}}function mh(){return{mount:k.length,destroy:T.length}}function Wn(e){return typeof e==="function"&&e._isSignal===!0}function qn(e){return typeof e==="function"&&e._isDerived===!0}function xo(e){if(Wn(e)||qn(e))return m(()=>e());return e}function Yr(e){return m(e)}function hh(e,n){let r=typeof e==="function"?e:()=>e,i=le([]),o=Vn(()=>i().reduce((u,l)=>n(u,l.action),r())),t=!1;return Un(()=>{if(r(),!t){t=!0;return}if(Yr(()=>i().length))i.set([])}),[o,(u,l)=>{let d={action:u};i.set([...i(),d]);let a=()=>{let s=i().filter((y)=>y!==d);if(s.length!==i().length)i.set(s)};if(l&&typeof l.then==="function")Promise.resolve(l).then(a,a);return a}]}
3
+ export{le,Vn,ph,Un,vo,Gr,Jr,fh,gh,mh,Wn,qn,xo,Yr,hh};
@@ -1,9 +1,9 @@
1
1
  // @bun
2
2
  import R from"path";var O=/__stxModules\["((?:[^"\\]|\\.)*)"\]/g;function Lr(...g){let d=new Set;for(let c of g){if(!c||!c.includes("__stxModules["))continue;for(let s of c.matchAll(O))try{d.add(JSON.parse(`"${s[1]}"`))}catch{}}return[...d].sort()}function so(...g){let d=new Map,c=(s,e)=>{let r=d.get(s);if(r===null)return;if(e===null){d.set(s,null);return}let n=r??new Set;for(let i of e)n.add(i);d.set(s,n)};for(let s of g){if(!s||!s.includes("__stxModules["))continue;let e=[];for(let n of s.matchAll(/([\w$]+)\s*=\s*globalThis\.__stxModules\s*&&\s*globalThis\.__stxModules\["((?:[^"\\]|\\.)*)"\]/g)){let i;try{i=JSON.parse(`"${n[2]}"`)}catch{continue}e.push({variable:n[1],id:i,start:n.index+n[0].length,end:s.length})}let r=s.match(/__stxModules\["(?:[^"\\]|\\.)*"\]/g)?.length??0;if(e.length===0||r!==e.length){for(let n of Lr(s))c(n,null);continue}for(let[n,i]of e.entries()){let p=e.slice(n+1).find((h)=>h.variable===i.variable);i.end=p?p.start:s.length}for(let n of e){let i=new Set,p=!1,h=n.variable.replace(/[$]/g,"\\$&"),o=s.slice(n.start,n.end);for(let l of o.matchAll(new RegExp(`(?<![\\w$.])${h}(?![\\w$])`,"g"))){let f=o.slice(l.index+n.variable.length,l.index+n.variable.length+200),a=/^\s*\[\s*(["'])([A-Za-z_$][\w$]*)\1\s*\]/.exec(f)??/^\s*\.\s*([A-Za-z_$][\w$]*)/.exec(f);if(a){i.add(a[a.length-1]);continue}if(/^\s*[!=]==?\s*(?:undefined|void 0)\b/.test(f))continue;p=!0;break}c(n.id,p?null:i)}}return d}function v(g,d,c){let s=[],e=[];return g.forEach((r,n)=>{let i=r.startsWith("npm:")?r.slice(4):R.resolve(d,r),p=`__stxRegistered${n}`,h=JSON.stringify(r),o=c?.get(r);if(o&&[...o].every((l)=>/^[A-Za-z_$][\w$]*$/.test(l))){let l=[...o].sort(),f=l.map((m,_)=>`${m} as ${p}_${_}`);s.push(l.length>0?`import { ${f.join(", ")} } from ${JSON.stringify(i)};`:`import ${JSON.stringify(i)};`);let a=l.map((m,_)=>`get ${JSON.stringify(m)}() { return ${p}_${_}; }`).join(", ");e.push(`if (!globalThis.__stxModules[${h}]) globalThis.__stxModules[${h}] = { ${a} };`);return}s.push(`import * as ${p} from ${JSON.stringify(i)};`),e.push(`if (!globalThis.__stxModules[${h}]) globalThis.__stxModules[${h}] = ${p};`)}),[...s,"globalThis.__stxModules = globalThis.__stxModules || {};",...e].join(`
3
- `)}async function jg(g,d={}){if(g.length===0)return null;let c=process.cwd(),s=v(g,c,d.names),e;try{let{bundleClientScript:l}=await import("./chunk-yjvwp1s6.js"),f=()=>l(s,R.join(c,".stx-module-registry.ts"),{projectRoot:c,minify:d.minify,externalizeUserModules:!1,collectInputs:d.collectInputs,throwOnFailure:!0});try{e=await f()}catch(a){if(!d.names)throw a;s=v(g,c,void 0),e=await f()}}catch(l){let{formatBuildFailure:f}=await import("./chunk-0jvrzpfs.js"),a=f(l);console.warn(`[stx] could not build the page module registry (#1957): ${a}`);let m=`[stx] the page module registry did not build, so ${g.join(", ")} cannot load (#1957): ${a}`;return`;console.error(${JSON.stringify(m)});`}let{transformAutoImports:r,generateAutoImportDestructuring:n}=await import("./chunk-2vget8rh.js"),i=r(e),p=n(i.stxImports,i.browserImports),{transformStoreImports:h}=await import("./chunk-g4sdthck.js");e=h(i.code);let o=JSON.stringify(new Bun.CryptoHasher("md5").update(s).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${o}]) return;`,` __stxBundles[${o}] = true;`,p,e,"})();"].join(`
3
+ `)}async function Bg(g,d={}){if(g.length===0)return null;let c=process.cwd(),s=v(g,c,d.names),e;try{let{bundleClientScript:l}=await import("./chunk-h8x56dq5.js"),f=()=>l(s,R.join(c,".stx-module-registry.ts"),{projectRoot:c,minify:d.minify,externalizeUserModules:!1,collectInputs:d.collectInputs,throwOnFailure:!0});try{e=await f()}catch(a){if(!d.names)throw a;s=v(g,c,void 0),e=await f()}}catch(l){let{formatBuildFailure:f}=await import("./chunk-0jvrzpfs.js"),a=f(l);console.warn(`[stx] could not build the page module registry (#1957): ${a}`);let m=`[stx] the page module registry did not build, so ${g.join(", ")} cannot load (#1957): ${a}`;return`;console.error(${JSON.stringify(m)});`}let{transformAutoImports:r,generateAutoImportDestructuring:n}=await import("./chunk-2kt1gqtq.js"),i=r(e),p=n(i.stxImports,i.browserImports),{transformStoreImports:h}=await import("./chunk-g4sdthck.js");e=h(i.code);let o=JSON.stringify(new Bun.CryptoHasher("md5").update(s).digest("hex").slice(0,12));return[";(function() {"," var __stxBundles = globalThis.__stxModuleBundles || (globalThis.__stxModuleBundles = {});",` if (__stxBundles[${o}]) return;`,` __stxBundles[${o}] = true;`,p,e,"})();"].join(`
4
4
  `)}var P=/^import(?:[ \t]*(\{[^}]*\})[ \t]*from|[ \t]*\*[ \t]*as[ \t]+([\w$]+)[ \t]+from)?[ \t]*["']\.\/(chunk-[\w-]+)\.js["'][ \t]*;?[ \t]*$/gm,j=/^export\s*\{([^}]*)\}\s*;?[ \t]*$/gm,I=new Set(["__preload","__chunks"]),N=/^("[^"]*"|[\w$]+)(?:\s+as\s+("[^"]*"|[\w$]+))?$/;function J(g){let d=[],c=[],s=!0,r=g.replace(/^var __chunkGraphs;[\s\S]*?^var __chunks = [\s\S]*?^\};[ \t]*\n?/m,"").replace(/^__chunks\(import\.meta\.url,[^\n]*\);[ \t]*\n?/gm,"").replace(P,(h,o,l,f)=>{let a=`__stxChunkExports${d.length}`;if(d.push(f),c.push(`var ${a} = __stxChunk(${JSON.stringify(f)});`),l)c.push(`var ${l} = ${a};`);else if(o)for(let m of o.slice(1,-1).split(",")){let _=m.trim();if(!_)continue;let w=N.exec(_);if(!w){s=!1;continue}if(I.has(w[1]))continue;let M=w[1].startsWith('"')?JSON.parse(w[1]):w[1],t=w[2]??w[1];if(t.startsWith('"')){s=!1;continue}c.push(`var ${t} = ${a}[${JSON.stringify(M)}];`)}return""});if(!s)throw Error("an import it does not read");let n=[];r=r.replace(/\(\s*__preload\([^)]*\)\s*,\s*import\(\s*["']\.\/(chunk-[\w-]+)\.js["']\s*\)\s*\)|\bimport\(\s*["']\.\/(chunk-[\w-]+)\.js["']\s*\)/g,(h,o,l)=>{let f=o??l;return n.push(f),`Promise.resolve().then(function () { return __stxChunk(${JSON.stringify(f)}); })`});let i=[];r=r.replace(j,(h,o)=>{for(let l of o.split(",")){let f=l.trim();if(!f)continue;let a=N.exec(f);if(!a||a[1].startsWith('"')){s=!1;continue}if(I.has(a[1]))continue;let m=a[2]??a[1];i.push([a[1],m.startsWith('"')?JSON.parse(m):m])}return""});let p=[/\bimport\.meta\b/,/\b__chunks\b/,/\b__preload\b/,/^\s*export\s+(?:default\b|const\b|let\b|var\b|function\b|class\b|async\b|\*|\{)/m,/\bfrom\s*["']\.\/chunk-/,/^\s*import\s*["']\.\/chunk-/m].find((h)=>h.test(r));if(!s||p)throw Error(`${p?`${p.source} is left in it`:"an export it does not read"}`);return{reads:c.join(`
5
- `),chunks:d,lazy:n,body:r,exports:i}}function _l(g){if(/\bexport\s+(?:let|var)\b/.test(g))return!0;if(g.length/Math.max(1,g.split(`
6
- `).length)>200)return!1;for(let d of g.matchAll(/\bexport\s*\{([^}]*)\}(?!\s*from\b)/g))for(let c of d[1].split(",")){let s=c.trim().split(/\s+as\s+/)[0].trim();if(!/^[A-Za-z_$][\w$]*$/.test(s))continue;let e=s.replace(/[$]/g,"\\$&");if(!new RegExp(`(?<![\\w$.])(?:let|var)\\s+${e}(?![\\w$])`,"g").test(g))continue;let n=new RegExp(`(?<![\\w$.])${e}\\s*(?:=(?![=>])|[-+*/%&|^]=|\\*\\*=|<<=|>>>?=|&&=|\\|\\|=|\\?\\?=|\\+\\+|--)|(?:\\+\\+|--)\\s*${e}(?![\\w$])`,"g"),i=new RegExp(`(?<![\\w$.])(?:let|var|const)\\s+${e}\\s*=`,"g");if((g.match(n)?.length??0)>(g.match(i)?.length??0))return!0}return!1}async function oo(g,d={}){let c=g.filter((e)=>e.ids.length>0);if(c.length===0)return{chunks:new Map,routes:new Map,reads:new Map};let s=process.cwd();try{let{bundleClientEntriesSplit:e}=await import("./chunk-yjvwp1s6.js"),r=[],n=await e(new Map(c.map((t)=>[t.name,v(t.ids,s,t.names)])),{projectRoot:s,filePath:R.join(s,".stx-module-registry.ts"),collectInputs:r});d.collectInputs?.push(...r);let{transformAutoImports:i,generateAutoImportDestructuring:p}=await import("./chunk-2vget8rh.js"),{transformStoreImports:h}=await import("./chunk-g4sdthck.js"),o=new Map;for(let[t,u]of[...n.chunks,...n.entries])try{o.set(t,J(u))}catch(b){throw Error(`cannot read ${t}: ${b instanceof Error?b.message:String(b)}`)}for(let[t,u]of[...n.chunks,...n.entries])if(/\b__esm\(/.test(u))throw Error(`${t} initialises a module lazily`);for(let t of r)if(/\.(?:[cm]?[jt]sx?)$/.test(t)&&_l(await Bun.file(t).text()))throw Error(`${t} exports a binding that changes after it is read`);let l=new Set,f=new Set,a=(t)=>{if(f.has(t))return;if(l.has(t))throw Error(`the chunks import each other (${t})`);l.add(t);for(let u of o.get(t)?.chunks??[]){if(!o.has(u))throw Error(`${t} imports ${u}, which was not built`);a(u)}for(let u of o.get(t)?.lazy??[])if(!o.has(u))throw Error(`${t} imports ${u}, which was not built`);l.delete(t),f.add(t)};for(let t of o.keys())a(t);let m=(t)=>{let u=i(t.body);return{prelude:p(u.stxImports,u.browserImports),body:h(u.code)}},_=new Map;for(let t of n.chunks.keys()){let u=o.get(t),{prelude:b,body:k}=m(u),y=u.exports.map(([S,x])=>`get ${JSON.stringify(x)}() { return ${S}; }`).join(", ");_.set(t,`function (__stxChunk) {
5
+ `),chunks:d,lazy:n,body:r,exports:i}}function Cl(g){if(/\bexport\s+(?:let|var)\b/.test(g))return!0;if(g.length/Math.max(1,g.split(`
6
+ `).length)>200)return!1;for(let d of g.matchAll(/\bexport\s*\{([^}]*)\}(?!\s*from\b)/g))for(let c of d[1].split(",")){let s=c.trim().split(/\s+as\s+/)[0].trim();if(!/^[A-Za-z_$][\w$]*$/.test(s))continue;let e=s.replace(/[$]/g,"\\$&");if(!new RegExp(`(?<![\\w$.])(?:let|var)\\s+${e}(?![\\w$])`,"g").test(g))continue;let n=new RegExp(`(?<![\\w$.])${e}\\s*(?:=(?![=>])|[-+*/%&|^]=|\\*\\*=|<<=|>>>?=|&&=|\\|\\|=|\\?\\?=|\\+\\+|--)|(?:\\+\\+|--)\\s*${e}(?![\\w$])`,"g"),i=new RegExp(`(?<![\\w$.])(?:let|var|const)\\s+${e}\\s*=`,"g");if((g.match(n)?.length??0)>(g.match(i)?.length??0))return!0}return!1}async function oo(g,d={}){let c=g.filter((e)=>e.ids.length>0);if(c.length===0)return{chunks:new Map,routes:new Map,reads:new Map};let s=process.cwd();try{let{bundleClientEntriesSplit:e}=await import("./chunk-h8x56dq5.js"),r=[],n=await e(new Map(c.map((t)=>[t.name,v(t.ids,s,t.names)])),{projectRoot:s,filePath:R.join(s,".stx-module-registry.ts"),collectInputs:r});d.collectInputs?.push(...r);let{transformAutoImports:i,generateAutoImportDestructuring:p}=await import("./chunk-2kt1gqtq.js"),{transformStoreImports:h}=await import("./chunk-g4sdthck.js"),o=new Map;for(let[t,u]of[...n.chunks,...n.entries])try{o.set(t,J(u))}catch(b){throw Error(`cannot read ${t}: ${b instanceof Error?b.message:String(b)}`)}for(let[t,u]of[...n.chunks,...n.entries])if(/\b__esm\(/.test(u))throw Error(`${t} initialises a module lazily`);for(let t of r)if(/\.(?:[cm]?[jt]sx?)$/.test(t)&&Cl(await Bun.file(t).text()))throw Error(`${t} exports a binding that changes after it is read`);let l=new Set,f=new Set,a=(t)=>{if(f.has(t))return;if(l.has(t))throw Error(`the chunks import each other (${t})`);l.add(t);for(let u of o.get(t)?.chunks??[]){if(!o.has(u))throw Error(`${t} imports ${u}, which was not built`);a(u)}for(let u of o.get(t)?.lazy??[])if(!o.has(u))throw Error(`${t} imports ${u}, which was not built`);l.delete(t),f.add(t)};for(let t of o.keys())a(t);let m=(t)=>{let u=i(t.body);return{prelude:p(u.stxImports,u.browserImports),body:h(u.code)}},_=new Map;for(let t of n.chunks.keys()){let u=o.get(t),{prelude:b,body:k}=m(u),y=u.exports.map(([S,x])=>`get ${JSON.stringify(x)}() { return ${S}; }`).join(", ");_.set(t,`function (__stxChunk) {
7
7
  ${b}
8
8
  ${u.reads}
9
9
  ${k}
@@ -14,4 +14,4 @@ ${b}
14
14
  ${u.reads}
15
15
  ${k}
16
16
  })();`);let y=new Set,S=(x)=>{if(y.has(x))return;y.add(x);let E=o.get(x);for(let A of[...E.chunks,...E.lazy])S(A)};for(let x of[...u.chunks,...u.lazy])S(x);M.set(t,[...y].sort())}return{chunks:_,routes:w,reads:M}}catch(e){let{formatBuildFailure:r}=await import("./chunk-0jvrzpfs.js");return console.warn(`[stx] could not share the native routes' modules, building each route's alone: ${r(e)}`),null}}
17
- export{Lr,so,jg,_l,oo};
17
+ export{Lr,so,Bg,Cl,oo};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{existsSync as g,statSync as p}from"fs";import e from"path";var w=/[*?[\]{}]/;function Ff(o){return w.test(o)}async function Jo(o,n={}){let i=n.cwd??process.cwd(),u=n.recursive!==!1,l=n.ignorePaths??[],c=globalThis.Bun.Glob,a=new Set,r=(t)=>{if(t.includes(`${e.sep}node_modules${e.sep}`)||t.includes(`${e.sep}dist${e.sep}`))return;if(l.some((s)=>s&&t.includes(e.normalize(s))))return;a.add(t)},d=async(t)=>{try{for await(let s of new c(t).scan({cwd:i,absolute:!0}))r(s)}catch{}};for(let t of o){if(!t)continue;if(Ff(t)){await d(t);continue}let s=e.resolve(i,t);if(!g(s))continue;if(p(s).isDirectory()){for await(let f of new c(u?"**/*.stx":"*.stx").scan({cwd:s,absolute:!0}))r(f);continue}r(s)}return[...a].sort()}
3
- export{Ff,Jo};
2
+ import{existsSync as g,statSync as p}from"fs";import e from"path";var w=/[*?[\]{}]/;function zf(o){return w.test(o)}async function Jo(o,n={}){let i=n.cwd??process.cwd(),u=n.recursive!==!1,l=n.ignorePaths??[],c=globalThis.Bun.Glob,a=new Set,r=(t)=>{if(t.includes(`${e.sep}node_modules${e.sep}`)||t.includes(`${e.sep}dist${e.sep}`))return;if(l.some((s)=>s&&t.includes(e.normalize(s))))return;a.add(t)},d=async(t)=>{try{for await(let s of new c(t).scan({cwd:i,absolute:!0}))r(s)}catch{}};for(let t of o){if(!t)continue;if(zf(t)){await d(t);continue}let s=e.resolve(i,t);if(!g(s))continue;if(p(s).isDirectory()){for await(let f of new c(u?"**/*.stx":"*.stx").scan({cwd:s,absolute:!0}))r(f);continue}r(s)}return[...a].sort()}
3
+ export{zf,Jo};
@@ -1,12 +1,12 @@
1
1
  // @bun
2
- import{b,x,pi,fn}from"./chunk-f0bwetnx.js";import{Xo}from"./chunk-gc7pykfq.js";import{c}from"./chunk-0rjcbqk3.js";import F from"fs";import d from"path";import{hasLocalConfig as he}from"bunfig";var bt={fg:{light:"neutral-900",dark:"neutral-100",description:"Primary text"},"fg-strong":{light:"neutral-700",dark:"neutral-300",description:"Labels, secondary headings"},"fg-muted":{light:"neutral-600",dark:"neutral-400",description:"Supporting text"},"fg-soft":{light:"neutral-500",dark:"neutral-400",description:"De-emphasised text"},"fg-subtle":{light:"neutral-400",dark:"neutral-500",description:"Recessive, non-essential text"},surface:{light:"neutral-50",dark:"neutral-800",description:"Page and panel background"},"surface-raised":{light:"neutral-100",dark:"neutral-700",description:"Cards, popovers"},"surface-sunken":{light:"neutral-200",dark:"neutral-700",description:"Wells, track backgrounds"},panel:{light:"white",dark:"neutral-800",description:"Card, menu, dialog surface"},field:{light:"white",dark:"neutral-700",description:"Form control surface"},page:{light:"neutral-50",dark:"neutral-900",description:"Page background, behind panels"},content:{light:"white",dark:"neutral-900",description:"Content area under a chrome header - a table or list body"},"surface-hover":{light:"neutral-100",dark:"neutral-700",description:"Row or item highlight on a page or panel"},"surface-raised-hover":{light:"neutral-200",dark:"neutral-600",description:"Raised surface, hovered"},"surface-sunken-hover":{light:"neutral-300",dark:"neutral-600",description:"Sunken surface, hovered"},"field-hover":{light:"neutral-50",dark:"neutral-600",description:"Form control surface, hovered"},link:{light:"blue-500",dark:"blue-400",description:"Hyperlink"},"link-hover":{light:"blue-600",dark:"blue-300",description:"Hyperlink, hovered"},inverse:{light:"neutral-900",dark:"neutral-700",description:"Tooltip bubble, inverted surface"},"inverse-ink":{light:"white",dark:"white",description:"Text on an inverted surface"},line:{light:"neutral-200",dark:"neutral-700",description:"Default border, divider"},"line-strong":{light:"neutral-300",dark:"neutral-600",description:"Input border, focus ring track"},"line-hover":{light:"neutral-400",dark:"neutral-500",description:"Border of a hovered control"},accent:{light:"blue-600",dark:"blue-400",description:"Primary action, selected state"},info:{light:"cyan-600",dark:"cyan-400",description:"Informational emphasis"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-600",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"blue-500",dark:"blue-600",description:"Primary button fill"},"info-solid":{light:"cyan-500",dark:"cyan-600",description:"Informational fill"},"danger-solid":{light:"red-500",dark:"red-600",description:"Destructive button fill"},"success-solid":{light:"green-500",dark:"green-600",description:"Confirmation fill"},"warning-solid":{light:"yellow-500",dark:"yellow-600",description:"Caution fill"},"accent-solid-hover":{light:"blue-600",dark:"blue-700",description:"Primary button fill, hovered"},"info-solid-hover":{light:"cyan-600",dark:"cyan-700",description:"Informational fill, hovered"},"danger-solid-hover":{light:"red-600",dark:"red-700",description:"Destructive fill, hovered"},"success-solid-hover":{light:"green-600",dark:"green-700",description:"Confirmation fill, hovered"},"warning-solid-hover":{light:"yellow-600",dark:"yellow-700",description:"Caution fill, hovered"},"accent-ink":{light:"white",dark:"white",description:"Text on a primary fill"},"info-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on an informational fill"},"danger-ink":{light:"white",dark:"white",description:"Text on a destructive fill"},"success-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a confirmation fill"},"warning-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a caution fill"},"accent-soft":{light:"blue-100",dark:"blue-900",description:"Tinted primary fill"},"accent-soft-ink":{light:"blue-800",dark:"blue-200",description:"Text on a tinted primary fill"},"info-soft":{light:"cyan-100",dark:"cyan-900",description:"Tinted informational fill"},"info-soft-ink":{light:"cyan-800",dark:"cyan-200",description:"Text on a tinted informational fill"},"danger-soft":{light:"red-100",dark:"red-900",description:"Tinted destructive fill"},"danger-soft-ink":{light:"red-800",dark:"red-200",description:"Text on a tinted destructive fill"},"success-soft":{light:"green-100",dark:"green-900",description:"Tinted confirmation fill"},"success-soft-ink":{light:"green-800",dark:"green-200",description:"Text on a tinted confirmation fill"},"warning-soft":{light:"yellow-100",dark:"yellow-900",description:"Tinted caution fill"},"warning-soft-ink":{light:"yellow-800",dark:"yellow-200",description:"Text on a tinted caution fill"},secondary:{light:"purple-600",dark:"purple-400",description:"Secondary emphasis"},"secondary-solid":{light:"purple-500",dark:"purple-600",description:"Secondary fill"},"secondary-solid-hover":{light:"purple-600",dark:"purple-700",description:"Secondary fill, hovered"},"secondary-ink":{light:"white",dark:"white",description:"Text on a secondary fill"},"secondary-soft":{light:"purple-100",dark:"purple-900",description:"Tinted secondary fill"},"secondary-soft-ink":{light:"purple-800",dark:"purple-200",description:"Text on a tinted secondary fill"},"danger-fg":{light:"red-900",dark:"red-300",description:"Text in a field with an error"},"danger-fg-subtle":{light:"red-300",dark:"red-500",description:"Recessive text in a field with an error"},"danger-line":{light:"red-300",dark:"red-600",description:"Border of a field with an error"},"danger-focus":{light:"red-500",dark:"red-400",description:"Focus ring of a field with an error"}};function Xe(n){return`--stx-${n}`}function _(n,t){let s=t.lastIndexOf("-");if(s===-1)return typeof n[t]==="string"?n[t]:void 0;let r=n[t.slice(0,s)];if(!r||typeof r!=="object")return;let i=r[t.slice(s+1)];return typeof i==="string"?i:void 0}var be=/^(?:#[\da-f]{3,8}|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|var)\(.*\)|white|black|transparent|currentcolor)$/i;function q(n,t){let s=t.trim();return _(n,s)??(be.test(s)?s:void 0)}function ee(n={}){return[...Object.keys(n.roles??{}).filter((t)=>!bt[t]).map((t)=>`roles.${t}`),...Object.keys(n.shapes??{}).filter((t)=>!ye[t]).map((t)=>`shapes.${t}`),...Object.keys(n.density??{}).filter((t)=>!Ae[t]).map((t)=>`density.${t}`)]}function te(n){let t={};for(let[s,r]of Object.entries(bt)){let i=_(n,r.light);if(i===void 0)continue;t[s]=`var(${Xe(s)}, ${i})`}return t}function ne(n,t={}){let s=[],r=[];for(let[i,l]of Object.entries(bt)){let a=t[i],g=typeof a==="string"?a:a?.light,o=typeof a==="string"?a:a?.dark,f=g&&q(n,g)||_(n,l.light),h=o&&q(n,o)||_(n,l.dark);if(f===void 0)continue;if(s.push(` ${Xe(i)}: ${f};`),h!==void 0)r.push(` ${Xe(i)}: ${h};`)}if(s.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...s,"}",".dark {",...r,"}",""].join(`
2
+ import{b,S,pi,fn}from"./chunk-ymypc1rp.js";import{Xo}from"./chunk-swbrvrgr.js";import{c}from"./chunk-0rjcbqk3.js";import F from"fs";import d from"path";import{hasLocalConfig as he}from"bunfig";var bt={fg:{light:"neutral-900",dark:"neutral-100",description:"Primary text"},"fg-strong":{light:"neutral-700",dark:"neutral-300",description:"Labels, secondary headings"},"fg-muted":{light:"neutral-600",dark:"neutral-400",description:"Supporting text"},"fg-soft":{light:"neutral-500",dark:"neutral-400",description:"De-emphasised text"},"fg-subtle":{light:"neutral-400",dark:"neutral-500",description:"Recessive, non-essential text"},surface:{light:"neutral-50",dark:"neutral-800",description:"Page and panel background"},"surface-raised":{light:"neutral-100",dark:"neutral-700",description:"Cards, popovers"},"surface-sunken":{light:"neutral-200",dark:"neutral-700",description:"Wells, track backgrounds"},panel:{light:"white",dark:"neutral-800",description:"Card, menu, dialog surface"},field:{light:"white",dark:"neutral-700",description:"Form control surface"},page:{light:"neutral-50",dark:"neutral-900",description:"Page background, behind panels"},content:{light:"white",dark:"neutral-900",description:"Content area under a chrome header - a table or list body"},"surface-hover":{light:"neutral-100",dark:"neutral-700",description:"Row or item highlight on a page or panel"},"surface-raised-hover":{light:"neutral-200",dark:"neutral-600",description:"Raised surface, hovered"},"surface-sunken-hover":{light:"neutral-300",dark:"neutral-600",description:"Sunken surface, hovered"},"field-hover":{light:"neutral-50",dark:"neutral-600",description:"Form control surface, hovered"},link:{light:"blue-500",dark:"blue-400",description:"Hyperlink"},"link-hover":{light:"blue-600",dark:"blue-300",description:"Hyperlink, hovered"},inverse:{light:"neutral-900",dark:"neutral-700",description:"Tooltip bubble, inverted surface"},"inverse-ink":{light:"white",dark:"white",description:"Text on an inverted surface"},line:{light:"neutral-200",dark:"neutral-700",description:"Default border, divider"},"line-strong":{light:"neutral-300",dark:"neutral-600",description:"Input border, focus ring track"},"line-hover":{light:"neutral-400",dark:"neutral-500",description:"Border of a hovered control"},accent:{light:"blue-600",dark:"blue-400",description:"Primary action, selected state"},info:{light:"cyan-600",dark:"cyan-400",description:"Informational emphasis"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-600",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"blue-500",dark:"blue-600",description:"Primary button fill"},"info-solid":{light:"cyan-500",dark:"cyan-600",description:"Informational fill"},"danger-solid":{light:"red-500",dark:"red-600",description:"Destructive button fill"},"success-solid":{light:"green-500",dark:"green-600",description:"Confirmation fill"},"warning-solid":{light:"yellow-500",dark:"yellow-600",description:"Caution fill"},"accent-solid-hover":{light:"blue-600",dark:"blue-700",description:"Primary button fill, hovered"},"info-solid-hover":{light:"cyan-600",dark:"cyan-700",description:"Informational fill, hovered"},"danger-solid-hover":{light:"red-600",dark:"red-700",description:"Destructive fill, hovered"},"success-solid-hover":{light:"green-600",dark:"green-700",description:"Confirmation fill, hovered"},"warning-solid-hover":{light:"yellow-600",dark:"yellow-700",description:"Caution fill, hovered"},"accent-ink":{light:"white",dark:"white",description:"Text on a primary fill"},"info-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on an informational fill"},"danger-ink":{light:"white",dark:"white",description:"Text on a destructive fill"},"success-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a confirmation fill"},"warning-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a caution fill"},"accent-soft":{light:"blue-100",dark:"blue-900",description:"Tinted primary fill"},"accent-soft-ink":{light:"blue-800",dark:"blue-200",description:"Text on a tinted primary fill"},"info-soft":{light:"cyan-100",dark:"cyan-900",description:"Tinted informational fill"},"info-soft-ink":{light:"cyan-800",dark:"cyan-200",description:"Text on a tinted informational fill"},"danger-soft":{light:"red-100",dark:"red-900",description:"Tinted destructive fill"},"danger-soft-ink":{light:"red-800",dark:"red-200",description:"Text on a tinted destructive fill"},"success-soft":{light:"green-100",dark:"green-900",description:"Tinted confirmation fill"},"success-soft-ink":{light:"green-800",dark:"green-200",description:"Text on a tinted confirmation fill"},"warning-soft":{light:"yellow-100",dark:"yellow-900",description:"Tinted caution fill"},"warning-soft-ink":{light:"yellow-800",dark:"yellow-200",description:"Text on a tinted caution fill"},secondary:{light:"purple-600",dark:"purple-400",description:"Secondary emphasis"},"secondary-solid":{light:"purple-500",dark:"purple-600",description:"Secondary fill"},"secondary-solid-hover":{light:"purple-600",dark:"purple-700",description:"Secondary fill, hovered"},"secondary-ink":{light:"white",dark:"white",description:"Text on a secondary fill"},"secondary-soft":{light:"purple-100",dark:"purple-900",description:"Tinted secondary fill"},"secondary-soft-ink":{light:"purple-800",dark:"purple-200",description:"Text on a tinted secondary fill"},"danger-fg":{light:"red-900",dark:"red-300",description:"Text in a field with an error"},"danger-fg-subtle":{light:"red-300",dark:"red-500",description:"Recessive text in a field with an error"},"danger-line":{light:"red-300",dark:"red-600",description:"Border of a field with an error"},"danger-focus":{light:"red-500",dark:"red-400",description:"Focus ring of a field with an error"}};function Xe(n){return`--stx-${n}`}function _(n,t){let s=t.lastIndexOf("-");if(s===-1)return typeof n[t]==="string"?n[t]:void 0;let r=n[t.slice(0,s)];if(!r||typeof r!=="object")return;let i=r[t.slice(s+1)];return typeof i==="string"?i:void 0}var be=/^(?:#[\da-f]{3,8}|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|var)\(.*\)|white|black|transparent|currentcolor)$/i;function q(n,t){let s=t.trim();return _(n,s)??(be.test(s)?s:void 0)}function ee(n={}){return[...Object.keys(n.roles??{}).filter((t)=>!bt[t]).map((t)=>`roles.${t}`),...Object.keys(n.shapes??{}).filter((t)=>!ye[t]).map((t)=>`shapes.${t}`),...Object.keys(n.density??{}).filter((t)=>!Ae[t]).map((t)=>`density.${t}`)]}function te(n){let t={};for(let[s,r]of Object.entries(bt)){let i=_(n,r.light);if(i===void 0)continue;t[s]=`var(${Xe(s)}, ${i})`}return t}function ne(n,t={}){let s=[],r=[];for(let[i,l]of Object.entries(bt)){let a=t[i],g=typeof a==="string"?a:a?.light,o=typeof a==="string"?a:a?.dark,f=g&&q(n,g)||_(n,l.light),h=o&&q(n,o)||_(n,l.dark);if(f===void 0)continue;if(s.push(` ${Xe(i)}: ${f};`),h!==void 0)r.push(` ${Xe(i)}: ${h};`)}if(s.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...s,"}",".dark {",...r,"}",""].join(`
3
3
  `)}var ye={control:{value:"0.375rem",description:"Buttons, inputs, selects \u2014 rounded-md"},panel:{value:"0.5rem",description:"Cards, dialogs, menus \u2014 rounded-lg"},pill:{value:"9999px",description:"Chips and badges, which are pill-shaped by intent"}};function an(n){return`--stx-radius-${n}`}function se(){let n={};for(let[t,s]of Object.entries(ye))n[t]=`var(${an(t)}, ${s.value})`;return n}function re(n={}){return["/* stx shape tokens \u2014 a radius by what the thing is. */",":root {",...Object.entries(ye).map(([t,s])=>` ${an(t)}: ${n[t]??s.value};`),"}",""].join(`
4
4
  `)}var Ae={"control-px":{value:"1rem",description:"Inline padding of a md text control \u2014 px-4"},"control-py":{value:"0.5rem",description:"Block padding of a md text control \u2014 py-2"},"control-text":{value:"1rem",description:"Font size of a md text control \u2014 text-base"},"control-leading":{value:"1.5rem",description:"Line height of a md text control \u2014 text-base"},"cell-px":{value:"1.5rem",description:"Inline padding of every table cell, header or body \u2014 px-6"},"cell-py":{value:"1rem",description:"Block padding of a body cell \u2014 py-4"},"cell-text":{value:"0.875rem",description:"Font size of a body cell \u2014 text-sm"},"cell-leading":{value:"1.25rem",description:"Line height of a body cell \u2014 text-sm"},"cell-head-py":{value:"0.75rem",description:"Block padding of a header cell \u2014 py-3"},"cell-head-text":{value:"0.75rem",description:"Font size of a header cell \u2014 text-xs"},"cell-head-leading":{value:"1rem",description:"Line height of a header cell \u2014 text-xs"}},nr={"control-x":"control-px","control-y":"control-py","cell-x":"cell-px","cell-y":"cell-py","cell-head-y":"cell-head-py"},rr={control:{size:"control-text",leading:"control-leading"},cell:{size:"cell-text",leading:"cell-leading"},"cell-head":{size:"cell-head-text",leading:"cell-head-leading"}};function Ge(n){return`--stx-${n}`}function V(n){let t=Ae[n];if(!t)throw Error(`[stx] unknown density token "${n}"`);return`var(${Ge(n)}, ${t.value})`}function ie(){let n={};for(let[t,s]of Object.entries(nr))n[t]=V(s);return n}function oe(){let n={};for(let[t,{size:s,leading:r}]of Object.entries(rr))n[t]=[V(s),{lineHeight:V(r)}];return n}function ce(n={}){return["/* stx density tokens \u2014 how much room a control or a table cell takes. */",":root {",...Object.entries(Ae).map(([t,s])=>` ${Ge(t)}: ${n[t]??s.value};`),"}",""].join(`
5
5
  `)}function ae(n){return typeof n==="object"&&n!==null&&!Array.isArray(n)}function W(n,t){let s={...n};for(let[r,i]of Object.entries(t))s[r]=ae(i)&&ae(s[r])?W(s[r],i):i;return s}function le(n,t){if(!t.fonts)return"";let s=new n({...t.config,fonts:t.fonts,cssVariables:!1}).toCSS(!1,t.minify);return s&&!t.minify?`${s}
6
- `:s}function de(n={},t={}){let s=n.theme||{},r=t.theme||{},{extend:i,...l}=r,{extend:a,...g}=s,o=g.colors||{};g.colors={...o,...te(o)};let f=g.borderRadius||{};g.borderRadius={...f,...se()};let h=g.spacing||{};g.spacing={...h,...ie()};let K=g.fontSize||{};g.fontSize={...K,...oe()};let R=W(g,l),m=W(a||{},i||{});if(Object.keys(m).length>0)R.extend=m;let P=[...n.safelist||[],...t.safelist||[]],M={...n.shortcuts||{},...t.shortcuts||{}},D=[...n.preflights||[],...t.preflights||[]],{fonts:U,...O}=n,{fonts:N,roles:T,shapes:I,density:k,...w}=t,u={roles:T,shapes:I,density:k},j=N??U;return{config:{...O,...w,theme:R,safelist:P,shortcuts:M,...D.length>0?{preflights:D}:{},content:[],output:""},safelist:P,shortcuts:M,includePreflight:t.preflight!==!1,minify:t.minify===!0,tokenCSS:ne({...o,...R.colors},T)+re(I)+ce(k),unknownRoles:ee(u),...j?{fonts:j}:{}}}var e={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};import B from"fs";import ve from"path";var $e=256,C=new Map,ge=(n)=>Bun.hash(n).toString(16).padStart(16,"0").slice(0,16),fe=(n)=>c(process.cwd(),"css-assets",`${n}.css`);function z(n,t){if(C.delete(n),C.set(n,t),C.size>$e)C.delete(C.keys().next().value)}function ue(n){let t=ge(n),s=fe(t);if(C.has(s))return z(s,n),t;let r;try{let i;try{i=B.readFileSync(s,"utf8")}catch{}if(i!==n)B.mkdirSync(ve.dirname(s),{recursive:!0}),r=`${s}.${process.pid}.${crypto.randomUUID()}.tmp`,B.writeFileSync(r,n,{flag:"wx"}),B.renameSync(r,s);return z(s,n),t}catch{return}finally{if(r)try{B.unlinkSync(r)}catch{}}}function Ef(n){if(!/^[a-f0-9]{16}$/.test(n))return;let t=fe(n),s=C.get(t);if(s!==void 0)return z(t,s),s;try{let r=B.readFileSync(t,"utf8");if(ge(r)!==n)return;return z(t,r),r}catch{return}}function pe(){C.clear()}var p=null,G="";function me(n){try{let t=n.startsWith("file:")?new URL(n).pathname:n;G=`${t}@${Math.trunc(F.statSync(t).mtimeMs)}`}catch{G=n}}var Y=!1,v=null,A="",E=!1,Re=256,S=new Map,L=null,Se=null,H=new Map,xe=new Set;function X(n){return Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)}function Q(n,t){if(S.has(n))S.delete(n);else if(S.size>=Re)S.delete(S.keys().next().value);S.set(n,t)}async function Te(n,t=L){if(!t)return null;try{let s=Bun.file(d.join(t,`cw-${X(n)}.css`));if(!await s.exists())return null;return await s.text()}catch{return null}}async function je(n,t,s=L){if(!s)return;try{if(!F.existsSync(s))F.mkdirSync(s,{recursive:!0});await Bun.write(d.join(s,`cw-${X(n)}.css`),t)}catch{}}async function ke(n){try{let t=await import(n);if(t&&t.CSSGenerator)return{CSSGenerator:t.CSSGenerator,config:t.config,build:t.build,defaultConfig:t.defaultConfig,extractClasses:t.extractClasses}}catch{}return null}var Be=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],Ee=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function Pe(){let n=[],t=process.cwd();while(t!==d.dirname(t)){for(let s of["node_modules","pantry"])for(let r of Be)n.push(d.join(t,s,...r));t=d.dirname(t)}return n}function De(){let n=[],t=process.env.HOME||process.env.USERPROFILE||"",s=[t&&d.join(t,"Code","Tools","ts-css"),t&&d.join(t,"Code","Tools","crosswind"),t&&d.join(t,"repos","stacks-org","ts-css"),t&&d.join(t,"repos","stacks-org","crosswind"),d.join(process.cwd(),"..","ts-css"),d.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let r of s)n.push(d.join(r,"packages","toolkit","dist","engine","index.js")),n.push(d.join(r,"packages","toolkit","src","engine","index.ts"));if(t)n.push(d.join(t,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return n}async function sc(){if(Y)return p;Y=!0;try{let n=async(i)=>{for(let l of i){if(!await Bun.file(l).exists())continue;let a=await ke(l);if(a){if(me(l),!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded from ${d.dirname(d.dirname(l))}`);return a}}return null};if(process.env.CROSSWIND_SRC){let i=d.resolve(process.env.CROSSWIND_SRC),l=await n([i]);if(!l)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${i}`);return p=l,p}let t=await n(Pe());if(t)return p=t,p;let s=Ee;for(let i of s){let l=await ke(i);if(l){p=l;try{me(import.meta.resolve(i))}catch{G=i}if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded`);return p}}let r=await n(De());if(r)return p=r,p;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${e.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${e.reset}`),console.warn(`${e.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${e.reset}`),null}}function Ch(){J.clear(),p=null,Y=!1,v=null,A="",S.clear(),pe(),Se=null,H.clear()}var Ce=!1;async function oc(n){try{let t=he({name:"css",cwd:n})?"css":he({name:"crosswind",cwd:n})?"crosswind":null;if(!t)return null;if(t==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!Ce)Ce=!0,console.warn(`${e.yellow}[ts-css]${e.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:s}=await import("bunfig"),r=await s({name:t,cwd:n,defaultConfig:{},checkEnv:!1,verbose:!1});if(!r?.path||!r.config||Object.keys(r.config).length===0)return null;let i=d.relative(n,r.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} Loaded config from ${i||r.path}`);return r.config}catch(t){if(t instanceof Error&&t.name==="ConfigNotFoundError")return null;return console.warn(`${e.yellow}[ts-css]${e.reset} Failed to load css config:`,t instanceof Error?t.message:t),null}}async function Tf(n){let t=null;try{let{loadStxConfig:s}=await import("./chunk-ka1hrt56.js"),r=await s(n);if(r.css)if(typeof r.css==="string"){let i=d.isAbsolute(r.css)?r.css:d.resolve(n,r.css);if(await Bun.file(i).exists()){let l=await import(i);t=l.default||l,console.log(`${e.green}[ts-css]${e.reset} Loaded config from stx.config.ts \u2192 ${r.css}`)}}else{if(t={...r.css,content:r.css.content||[],preflight:r.css.preflight??!0,minify:r.css.minify??!1},r.css.config){let i=d.isAbsolute(r.css.config)?r.css.config:d.resolve(n,r.css.config);if(await Bun.file(i).exists()){let l=await import(i);t={...l.default||l,...t}}}console.log(`${e.green}[ts-css]${e.reset} Using inline CSS config from stx.config.ts`)}}catch{}return t||await oc(n)}function $f(n){try{let t=new WeakSet;return X(JSON.stringify(n??{},(s,r)=>{if(typeof r==="function")return`[fn]${String(r)}`;if(typeof r==="object"&&r!==null){if(t.has(r))return"[circular]";t.add(r)}return r})??"")}catch{return"unhashable"}}async function cn(n){if(E)return A;E=!0;try{let t=await sc();if(!t||!t.build)return E=!1,"";if(!v)v=await oc(n);if(!v)return E=!1,"";let s=t.defaultConfig?.theme||{},r=v.theme||{},i={...t.defaultConfig,...v,theme:{...s,...r,extend:{...s.extend||{},...r.extend||{}}}},l=performance.now(),a=await t.build(i),g=performance.now()-l;if(A=a.css,console.log(`${e.cyan}[ts-css]${e.reset} Built ${a.classes.size} classes in ${g.toFixed(1)}ms`),i.output){let o=d.isAbsolute(i.output)?i.output:d.join(n,i.output),f=d.dirname(o);if(!F.existsSync(f))F.mkdirSync(f,{recursive:!0});await Bun.write(o,a.css)}return E=!1,a.css}catch(t){return console.error(`${e.red}[ts-css]${e.reset} Build error:`,t),E=!1,A}}async function sr(n){v=null,await cn(n)}function Eh(){return A}function Rf(n){let t=new Set,s=/class\s*=\s*["']([^"']+)["']/gi,r=s.exec(n);while(r!==null){for(let a of r[1].split(/\s+/))if(a.trim())t.add(a.trim());r=s.exec(n)}let i=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,l=i.exec(n);while(l!==null){let a=l[1].match(/'([^']+)'/g);if(a){for(let g of a)for(let o of g.slice(1,-1).split(/\s+/))if(o.trim())t.add(o.trim())}l=i.exec(n)}return t}var J=b(64);async function Af(n,t){let s=()=>H.get(t?d.resolve(t):process.cwd())?.fingerprint??null,r=J.get(x(n,t,s()));if(r!==void 0)return r;let i=await Oe(n,t);if(i)J.set(x(n,t,s()),i);return i}function*we(n){yield n;let t=new Set;for(let s of n.matchAll(/\/_stx\/modules\.([0-9a-f]{16})\.js/g)){let r=s[1];if(t.has(r))continue;t.add(r);let i=Xo(r);if(i)yield i}}function Th(n){return[...we(n)].join(`
7
- `)}async function Oe(n,t){try{let s=await sc();if(!s)return"";let r=new Set;for(let u of we(n)){let j=typeof s.extractClasses==="function"?s.extractClasses(u):Rf(u);for(let Z of j)r.add(Z)}if(r.size===0)return"";let i=t?d.resolve(t):process.cwd(),l=c(i,"cache");if(!L)L=l;let a=H.get(i);if(!a){let u=await Tf(i);a={config:u,fingerprint:$f(u)},H.set(i,a),Se=a.fingerprint}let g=[...r].sort().join(" "),o=`${G}::${a.fingerprint||"default"}::${g}`,f=S.get(o);if(f!==void 0)return Q(o,f),f;let h=await Te(o,l);if(h!==null)return Q(o,h),h;let K=s.defaultConfig||s.config,R=a.config||{},m=de(K,R),{safelist:P,includePreflight:M,minify:D,tokenCSS:U}=m;if(m.unknownRoles.length>0&&!xe.has(i))xe.add(i),console.warn(`${e.yellow}[ts-css]${e.reset} No stx role for ${m.unknownRoles.join(", ")} - these keep the stock value. Role names: semanticTokenNames() in @stacksjs/stx/theme-tokens.`);let O=m.config,N=new s.CSSGenerator(O),T=O.shortcuts||R.shortcuts||{},I=Object.keys(T).filter((u)=>r.has(u)||P.includes(u));for(let u of P)if(!T[u])N.generate(u);for(let u of r)if(!T[u])N.generate(u);let k="";if(I.length>0){let u=new s.CSSGenerator(O);for(let j of I)u.generate(j);if(k=u.toCSS(!1,D),k&&!k.endsWith(`
8
- `))k+=`
9
- `}let w=k+N.toCSS(M,D);return w=le(s.CSSGenerator,m)+U+w,Q(o,w),je(o,w,l),w}catch(s){return console.warn("Failed to generate Css CSS:",s),""}}async function y(n,t,s=!1,r=!1){let i=await Af(n,t);if(!i)return r?fn(n):n;let l=s?ue(i):void 0,a=l?`<link data-css="generated" rel="stylesheet" href="/_stx/css.${l}.css">`:`<style data-css="generated">
6
+ `:s}function de(n={},t={}){let s=n.theme||{},r=t.theme||{},{extend:i,...l}=r,{extend:a,...g}=s,o=g.colors||{};g.colors={...o,...te(o)};let f=g.borderRadius||{};g.borderRadius={...f,...se()};let h=g.spacing||{};g.spacing={...h,...ie()};let K=g.fontSize||{};g.fontSize={...K,...oe()};let R=W(g,l),m=W(a||{},i||{});if(Object.keys(m).length>0)R.extend=m;let P=[...n.safelist||[],...t.safelist||[]],M={...n.shortcuts||{},...t.shortcuts||{}},D=[...n.preflights||[],...t.preflights||[]],{fonts:U,...O}=n,{fonts:N,roles:T,shapes:I,density:x,...w}=t,u={roles:T,shapes:I,density:x},j=N??U;return{config:{...O,...w,theme:R,safelist:P,shortcuts:M,...D.length>0?{preflights:D}:{},content:[],output:""},safelist:P,shortcuts:M,includePreflight:t.preflight!==!1,minify:t.minify===!0,tokenCSS:ne({...o,...R.colors},T)+re(I)+ce(x),unknownRoles:ee(u),...j?{fonts:j}:{}}}var e={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};import B from"fs";import ve from"path";var $e=256,k=new Map,ge=(n)=>Bun.hash(n).toString(16).padStart(16,"0").slice(0,16),fe=(n)=>c(process.cwd(),"css-assets",`${n}.css`);function z(n,t){if(k.delete(n),k.set(n,t),k.size>$e)k.delete(k.keys().next().value)}function ue(n){let t=ge(n),s=fe(t);if(k.has(s))return z(s,n),t;let r;try{let i;try{i=B.readFileSync(s,"utf8")}catch{}if(i!==n)B.mkdirSync(ve.dirname(s),{recursive:!0}),r=`${s}.${process.pid}.${crypto.randomUUID()}.tmp`,B.writeFileSync(r,n,{flag:"wx"}),B.renameSync(r,s);return z(s,n),t}catch{return}finally{if(r)try{B.unlinkSync(r)}catch{}}}function Tf(n){if(!/^[a-f0-9]{16}$/.test(n))return;let t=fe(n),s=k.get(t);if(s!==void 0)return z(t,s),s;try{let r=B.readFileSync(t,"utf8");if(ge(r)!==n)return;return z(t,r),r}catch{return}}function pe(){k.clear()}var p=null,G="";function me(n){try{let t=n.startsWith("file:")?new URL(n).pathname:n;G=`${t}@${Math.trunc(F.statSync(t).mtimeMs)}`}catch{G=n}}var Y=!1,v=null,A="",E=!1,Re=256,C=new Map,L=null,Se=null,H=new Map,xe=new Set;function X(n){return Bun.hash(n).toString(16).padStart(16,"0").slice(0,16)}function Q(n,t){if(C.has(n))C.delete(n);else if(C.size>=Re)C.delete(C.keys().next().value);C.set(n,t)}async function Te(n,t=L){if(!t)return null;try{let s=Bun.file(d.join(t,`cw-${X(n)}.css`));if(!await s.exists())return null;return await s.text()}catch{return null}}async function je(n,t,s=L){if(!s)return;try{if(!F.existsSync(s))F.mkdirSync(s,{recursive:!0});await Bun.write(d.join(s,`cw-${X(n)}.css`),t)}catch{}}async function ke(n){try{let t=await import(n);if(t&&t.CSSGenerator)return{CSSGenerator:t.CSSGenerator,config:t.config,build:t.build,defaultConfig:t.defaultConfig,extractClasses:t.extractClasses}}catch{}return null}var Be=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],Ee=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function Pe(){let n=[],t=process.cwd();while(t!==d.dirname(t)){for(let s of["node_modules","pantry"])for(let r of Be)n.push(d.join(t,s,...r));t=d.dirname(t)}return n}function De(){let n=[],t=process.env.HOME||process.env.USERPROFILE||"",s=[t&&d.join(t,"Code","Tools","ts-css"),t&&d.join(t,"Code","Tools","crosswind"),t&&d.join(t,"repos","stacks-org","ts-css"),t&&d.join(t,"repos","stacks-org","crosswind"),d.join(process.cwd(),"..","ts-css"),d.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let r of s)n.push(d.join(r,"packages","toolkit","dist","engine","index.js")),n.push(d.join(r,"packages","toolkit","src","engine","index.ts"));if(t)n.push(d.join(t,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return n}async function sc(){if(Y)return p;Y=!0;try{let n=async(i)=>{for(let l of i){if(!await Bun.file(l).exists())continue;let a=await ke(l);if(a){if(me(l),!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded from ${d.dirname(d.dirname(l))}`);return a}}return null};if(process.env.CROSSWIND_SRC){let i=d.resolve(process.env.CROSSWIND_SRC),l=await n([i]);if(!l)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${i}`);return p=l,p}let t=await n(Pe());if(t)return p=t,p;let s=Ee;for(let i of s){let l=await ke(i);if(l){p=l;try{me(import.meta.resolve(i))}catch{G=i}if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded`);return p}}let r=await n(De());if(r)return p=r,p;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${e.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${e.reset}`),console.warn(`${e.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${e.reset}`),null}}function Eh(){J.clear(),p=null,Y=!1,v=null,A="",C.clear(),pe(),Se=null,H.clear()}var Ce=!1;async function oc(n){try{let t=he({name:"css",cwd:n})?"css":he({name:"crosswind",cwd:n})?"crosswind":null;if(!t)return null;if(t==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!Ce)Ce=!0,console.warn(`${e.yellow}[ts-css]${e.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:s}=await import("bunfig"),r=await s({name:t,cwd:n,defaultConfig:{},checkEnv:!1,verbose:!1});if(!r?.path||!r.config||Object.keys(r.config).length===0)return null;let i=d.relative(n,r.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} Loaded config from ${i||r.path}`);return r.config}catch(t){if(t instanceof Error&&t.name==="ConfigNotFoundError")return null;return console.warn(`${e.yellow}[ts-css]${e.reset} Failed to load css config:`,t instanceof Error?t.message:t),null}}async function $f(n){let t=null;try{let{loadStxConfig:s}=await import("./chunk-fvs15n0s.js"),r=await s(n);if(r.css)if(typeof r.css==="string"){let i=d.isAbsolute(r.css)?r.css:d.resolve(n,r.css);if(await Bun.file(i).exists()){let l=await import(i);t=l.default||l,console.log(`${e.green}[ts-css]${e.reset} Loaded config from stx.config.ts \u2192 ${r.css}`)}}else{if(t={...r.css,content:r.css.content||[],preflight:r.css.preflight??!0,minify:r.css.minify??!1},r.css.config){let i=d.isAbsolute(r.css.config)?r.css.config:d.resolve(n,r.css.config);if(await Bun.file(i).exists()){let l=await import(i);t={...l.default||l,...t}}}console.log(`${e.green}[ts-css]${e.reset} Using inline CSS config from stx.config.ts`)}}catch{}return t||await oc(n)}function Rf(n){try{let t=new WeakSet;return X(JSON.stringify(n??{},(s,r)=>{if(typeof r==="function")return`[fn]${String(r)}`;if(typeof r==="object"&&r!==null){if(t.has(r))return"[circular]";t.add(r)}return r})??"")}catch{return"unhashable"}}async function cn(n){if(E)return A;E=!0;try{let t=await sc();if(!t||!t.build)return E=!1,"";if(!v)v=await oc(n);if(!v)return E=!1,"";let s=t.defaultConfig?.theme||{},r=v.theme||{},i={...t.defaultConfig,...v,theme:{...s,...r,extend:{...s.extend||{},...r.extend||{}}}},l=performance.now(),a=await t.build(i),g=performance.now()-l;if(A=a.css,console.log(`${e.cyan}[ts-css]${e.reset} Built ${a.classes.size} classes in ${g.toFixed(1)}ms`),i.output){let o=d.isAbsolute(i.output)?i.output:d.join(n,i.output),f=d.dirname(o);if(!F.existsSync(f))F.mkdirSync(f,{recursive:!0});await Bun.write(o,a.css)}return E=!1,a.css}catch(t){return console.error(`${e.red}[ts-css]${e.reset} Build error:`,t),E=!1,A}}async function sr(n){v=null,await cn(n)}function Th(){return A}function Af(n){let t=new Set,s=/class\s*=\s*["']([^"']+)["']/gi,r=s.exec(n);while(r!==null){for(let a of r[1].split(/\s+/))if(a.trim())t.add(a.trim());r=s.exec(n)}let i=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,l=i.exec(n);while(l!==null){let a=l[1].match(/'([^']+)'/g);if(a){for(let g of a)for(let o of g.slice(1,-1).split(/\s+/))if(o.trim())t.add(o.trim())}l=i.exec(n)}return t}var J=b(64);async function Pf(n,t){let s=()=>H.get(t?d.resolve(t):process.cwd())?.fingerprint??null,r=J.get(S(n,t,s()));if(r!==void 0)return r;let i=await Oe(n,t);if(i)J.set(S(n,t,s()),i);return i}function*we(n){yield n;let t=new Set;for(let s of n.matchAll(/\/_stx\/modules\.([0-9a-f]{16})\.js/g)){let r=s[1];if(t.has(r))continue;t.add(r);let i=Xo(r);if(i)yield i}}function $h(n){return[...we(n)].join(`
7
+ `)}async function Oe(n,t){try{let s=await sc();if(!s)return"";let r=new Set;for(let u of we(n)){let j=typeof s.extractClasses==="function"?s.extractClasses(u):Af(u);for(let Z of j)r.add(Z)}if(r.size===0)return"";let i=t?d.resolve(t):process.cwd(),l=c(i,"cache");if(!L)L=l;let a=H.get(i);if(!a){let u=await $f(i);a={config:u,fingerprint:Rf(u)},H.set(i,a),Se=a.fingerprint}let g=[...r].sort().join(" "),o=`${G}::${a.fingerprint||"default"}::${g}`,f=C.get(o);if(f!==void 0)return Q(o,f),f;let h=await Te(o,l);if(h!==null)return Q(o,h),h;let K=s.defaultConfig||s.config,R=a.config||{},m=de(K,R),{safelist:P,includePreflight:M,minify:D,tokenCSS:U}=m;if(m.unknownRoles.length>0&&!xe.has(i))xe.add(i),console.warn(`${e.yellow}[ts-css]${e.reset} No stx role for ${m.unknownRoles.join(", ")} - these keep the stock value. Role names: semanticTokenNames() in @stacksjs/stx/theme-tokens.`);let O=m.config,N=new s.CSSGenerator(O),T=O.shortcuts||R.shortcuts||{},I=Object.keys(T).filter((u)=>r.has(u)||P.includes(u));for(let u of P)if(!T[u])N.generate(u);for(let u of r)if(!T[u])N.generate(u);let x="";if(I.length>0){let u=new s.CSSGenerator(O);for(let j of I)u.generate(j);if(x=u.toCSS(!1,D),x&&!x.endsWith(`
8
+ `))x+=`
9
+ `}let w=x+N.toCSS(M,D);return w=le(s.CSSGenerator,m)+U+w,Q(o,w),je(o,w,l),w}catch(s){return console.warn("Failed to generate Css CSS:",s),""}}async function y(n,t,s=!1,r=!1){let i=await Pf(n,t);if(!i)return r?fn(n):n;let l=s?ue(i):void 0,a=l?`<link data-css="generated" rel="stylesheet" href="/_stx/css.${l}.css">`:`<style data-css="generated">
10
10
  ${i}
11
11
  </style>`;if(r)return Ne(n,a);let g=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(g.test(n)){let o=!1;return n.replace(g,()=>{if(o)return"";return o=!0,a})}if(n.includes("</head>"))return n.replace("</head>",`${a}
12
12
  </head>`);if(n.includes("<body"))return n.replace(/<body([^>]*)>/,`<body$1>
@@ -15,4 +15,4 @@ ${a}`);return a+n}function Ne(n,t){let s=pi(n).map((o)=>({...o,replacement:""}))
15
15
  ${t}`});else s.push({start:0,end:0,replacement:t})}}s.sort((o,f)=>o.start-f.start||o.end-f.end);for(let o=1;o<s.length;o++)if(s[o].start<s[o-1].end)return Ie(fn(n),t);let l=Array(s.length*2+1),a=0,g=0;for(let o of s)l[g++]=n.slice(a,o.start),l[g++]=o.replacement,a=o.end;return l[g]=n.slice(a),l.join("")}function Ie(n,t){let s=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(s.test(n)){let r=!1;return n.replace(s,()=>{if(r)return"";return r=!0,t})}if(n.includes("</head>"))return n.replace("</head>",`${t}
16
16
  </head>`);if(n.includes("<body"))return n.replace(/<body([^>]*)>/,`<body$1>
17
17
  ${t}`);return t+n}
18
- export{bt,Xe,ye,an,Ae,nr,rr,Ge,e,Ef,sc,Ch,oc,Tf,$f,cn,sr,Eh,Rf,Af,Th,y};
18
+ export{bt,Xe,ye,an,Ae,nr,rr,Ge,e,Tf,sc,Eh,oc,$f,Rf,cn,sr,Th,Af,Pf,$h,y};
@@ -1,14 +1,14 @@
1
1
  // @bun
2
- import{fr}from"./chunk-1bgv727x.js";import{Tr}from"./chunk-7rk7wfm6.js";import{a}from"./chunk-nmkkfpmh.js";import{j,Ye}from"./chunk-cmnze7at.js";import{dc}from"./chunk-6s9bk98p.js";var p=/<style\b[^>]*>/iy,x=/<\/style>/gi,R=/<script\b[^>]*>/iy,b=/<template(?=[\s>/])[^>]*>/iy,S=/<\/template\s*>/iy;function ar(e){let r=0,t=0,s=-1;while(r<e.length){let n=e.indexOf("<",r);if(n===-1)return-1;if(e.startsWith("<!--",n)){let d=e.indexOf("-->",n+4);r=d===-1?e.length:d+3;continue}p.lastIndex=n;let c=p.exec(e);if(c){x.lastIndex=n+c[0].length;let d=x.exec(e);r=d===null?e.length:d.index+8;continue}b.lastIndex=n;let o=b.exec(e);if(o){if(t===0)s=n;t++,r=n+o[0].length;continue}S.lastIndex=n;let u=S.exec(e);if(u){if(t>0)t--;r=n+u[0].length;continue}if(R.lastIndex=n,R.test(e))return t>0?s:n;r=n+1}return-1}function X(e,r={}){return new fr(e,r).routes}import w from"path";var y=new Map;async function h(e,r){let t=e,s=r;if(!t||!s)try{let u=await a();t||=u?.pagesDir||"pages",s||=u?.root||"."}catch{t||="pages",s||="."}let n=w.isAbsolute(t)?t:w.join(s,t),c=y.get(n);if(c)return c;let o=[];try{o=X(".",{pagesDir:n,emit:!1}).map((u)=>u.regex.source).filter(Boolean)}catch{o=[]}return y.set(n,o),o}function O(e){return e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function g(e){return O(JSON.stringify(e))}function be(e){return e.includes("data-stx-runtime")}function lc(e){let r=/window\.stx\s*\.\s*[A-Za-z_$]|\}\s*=\s*window\.stx\s*;/g;for(let t=r.exec(e);t!==null;t=r.exec(e)){let s=e.slice(Math.max(0,t.index-80),t.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(s))continue;return!0}return!1}function l(e,r){let t=ar(e),s=e.search(/<!doctype\b/i);if(t!==-1&&(s===-1||t>s))return e.slice(0,t)+r+`
2
+ import{fr}from"./chunk-gtd6qs1r.js";import{Tr}from"./chunk-72jt897s.js";import{a}from"./chunk-j65nf7mt.js";import{j,Ye}from"./chunk-cmnze7at.js";import{dc}from"./chunk-6s9bk98p.js";var p=/<style\b[^>]*>/iy,x=/<\/style>/gi,R=/<script\b[^>]*>/iy,b=/<template(?=[\s>/])[^>]*>/iy,S=/<\/template\s*>/iy;function ar(e){let r=0,t=0,s=-1;while(r<e.length){let n=e.indexOf("<",r);if(n===-1)return-1;if(e.startsWith("<!--",n)){let d=e.indexOf("-->",n+4);r=d===-1?e.length:d+3;continue}p.lastIndex=n;let c=p.exec(e);if(c){x.lastIndex=n+c[0].length;let d=x.exec(e);r=d===null?e.length:d.index+8;continue}b.lastIndex=n;let o=b.exec(e);if(o){if(t===0)s=n;t++,r=n+o[0].length;continue}S.lastIndex=n;let u=S.exec(e);if(u){if(t>0)t--;r=n+u[0].length;continue}if(R.lastIndex=n,R.test(e))return t>0?s:n;r=n+1}return-1}function X(e,r={}){return new fr(e,r).routes}import w from"path";var y=new Map;async function h(e,r){let t=e,s=r;if(!t||!s)try{let u=await a();t||=u?.pagesDir||"pages",s||=u?.root||"."}catch{t||="pages",s||="."}let n=w.isAbsolute(t)?t:w.join(s,t),c=y.get(n);if(c)return c;let o=[];try{o=X(".",{pagesDir:n,emit:!1}).map((u)=>u.regex.source).filter(Boolean)}catch{o=[]}return y.set(n,o),o}function O(e){return e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function g(e){return O(JSON.stringify(e))}function be(e){return e.includes("data-stx-runtime")}function lc(e){let r=/window\.stx\s*\.\s*[A-Za-z_$]|\}\s*=\s*window\.stx\s*;/g;for(let t=r.exec(e);t!==null;t=r.exec(e)){let s=e.slice(Math.max(0,t.index-80),t.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(s))continue;return!0}return!1}function l(e,r){let t=ar(e),s=e.search(/<!doctype\b/i);if(t!==-1&&(s===-1||t>s))return e.slice(0,t)+r+`
3
3
  `+e.slice(t);let n=Tr(e);if(n!==null)return`${e.slice(0,n)}
4
4
  ${r}${e.slice(n)}`;if(e.includes("</head>")){let o=e.indexOf("</head>");return e.slice(0,o)+r+`
5
5
  `+e.slice(o)}if(j(e))return Ye(e,(o)=>`${o}
6
6
  ${r}`);return`${r}
7
- ${e}`}async function cr(e,r){if(e.includes("data-stx-runtime")||e.includes("window.stx.state")||e.includes("STX Signals Runtime"))return e;if(r.buildMode==="serve"){let{getServeClientAsset:n}=await import("./chunk-1kz70290.js"),{url:c}=await n("runtime",r.debug===!0);return l(e,`<script data-stx-runtime src="${c}"></script>`)}if(r.buildMode==="compile")return l(e,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:t}=await import("./chunk-1kz70290.js"),s=await t(r.debug);return l(e,`<script data-stx-scoped data-stx-runtime>${s}</script>`)}function m(e){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(e)}function uc(e){if(e.includes("data-stx-tooltip-runtime")||!m(e))return e;let r=`<script data-stx-scoped data-stx-tooltip-runtime>${dc()}</script>`,t=e.lastIndexOf("</body>");if(t===-1)return`${e}
7
+ ${e}`}async function cr(e,r){if(e.includes("data-stx-runtime")||e.includes("window.stx.state")||e.includes("STX Signals Runtime"))return e;if(r.buildMode==="serve"){let{getServeClientAsset:n}=await import("./chunk-67k5q95t.js"),{url:c}=await n("runtime",r.debug===!0);return l(e,`<script data-stx-runtime src="${c}"></script>`)}if(r.buildMode==="compile")return l(e,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:t}=await import("./chunk-67k5q95t.js"),s=await t(r.debug);return l(e,`<script data-stx-scoped data-stx-runtime>${s}</script>`)}function m(e){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(e)}function uc(e){if(e.includes("data-stx-tooltip-runtime")||!m(e))return e;let r=`<script data-stx-scoped data-stx-tooltip-runtime>${dc()}</script>`,t=e.lastIndexOf("</body>");if(t===-1)return`${e}
8
8
  ${r}`;return`${e.slice(0,t)}${r}
9
- ${e.slice(t)}`}var E=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function C(e){return E.test(e)||e.includes("__stxRouter)return")||e.includes("__stxRouter=true")}async function we(e,r){if(!e.includes("</body>"))return e;if(C(e))return e;let t=r?.router,s="",n="";{let i={};if(t){if(t.container)i.container=t.container;if(t.interceptAllLinks!==void 0)i.interceptAllLinks=t.interceptAllLinks;if(t.progress!==void 0)i.progress=t.progress;if(t.viewTransitions!==void 0)i.viewTransitions=t.viewTransitions;if(t.viewTransitionDuration!==void 0)i.viewTransitionDuration=t.viewTransitionDuration;if(t.viewTransitionEasing!==void 0)i.viewTransitionEasing=t.viewTransitionEasing;if(t.scrollToTop!==void 0)i.scrollToTop=t.scrollToTop;if(t.scrollRestoration!==void 0)i.scrollRestoration=t.scrollRestoration;if(t.prefetch!==void 0)i.prefetch=t.prefetch;if(t.cache!==void 0)i.cache=t.cache;if(t.progressColor!==void 0)i.progressColor=t.progressColor;if(t.progressHeight!==void 0)i.progressHeight=t.progressHeight;if(t.prefetchVisible!==void 0)i.prefetchVisible=t.prefetchVisible;if(t.prefetchVisibleMax!==void 0)i.prefetchVisibleMax=t.prefetchVisibleMax;if(t.prefetchBudgetBytes!==void 0)i.prefetchBudgetBytes=t.prefetchBudgetBytes;if(t.keepOpening!==void 0)i.keepOpening=t.keepOpening}try{let f=await h(r?.pagesDir,r?.root);if(f.length>0)if(r?.buildMode==="serve"){let{registerServeModuleBundle:T}=await import("./chunk-1kz70290.js");n=`<script data-stx-owned-routes src="${T(`(window.__stxRouterConfig=window.__stxRouterConfig||{}).ownedRoutes=${g(f)};
9
+ ${e.slice(t)}`}var E=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function C(e){return E.test(e)||e.includes("__stxRouter)return")||e.includes("__stxRouter=true")}async function we(e,r){if(!e.includes("</body>"))return e;if(C(e))return e;let t=r?.router,s="",n="";{let i={};if(t){if(t.container)i.container=t.container;if(t.interceptAllLinks!==void 0)i.interceptAllLinks=t.interceptAllLinks;if(t.progress!==void 0)i.progress=t.progress;if(t.viewTransitions!==void 0)i.viewTransitions=t.viewTransitions;if(t.viewTransitionDuration!==void 0)i.viewTransitionDuration=t.viewTransitionDuration;if(t.viewTransitionEasing!==void 0)i.viewTransitionEasing=t.viewTransitionEasing;if(t.scrollToTop!==void 0)i.scrollToTop=t.scrollToTop;if(t.scrollRestoration!==void 0)i.scrollRestoration=t.scrollRestoration;if(t.prefetch!==void 0)i.prefetch=t.prefetch;if(t.cache!==void 0)i.cache=t.cache;if(t.progressColor!==void 0)i.progressColor=t.progressColor;if(t.progressHeight!==void 0)i.progressHeight=t.progressHeight;if(t.prefetchVisible!==void 0)i.prefetchVisible=t.prefetchVisible;if(t.prefetchVisibleMax!==void 0)i.prefetchVisibleMax=t.prefetchVisibleMax;if(t.prefetchBudgetBytes!==void 0)i.prefetchBudgetBytes=t.prefetchBudgetBytes;if(t.keepOpening!==void 0)i.keepOpening=t.keepOpening}try{let f=await h(r?.pagesDir,r?.root);if(f.length>0)if(r?.buildMode==="serve"){let{registerServeModuleBundle:T}=await import("./chunk-67k5q95t.js");n=`<script data-stx-owned-routes src="${T(`(window.__stxRouterConfig=window.__stxRouterConfig||{}).ownedRoutes=${g(f)};
10
10
  `)}"></script>
11
11
  `}else i.ownedRoutes=f}catch{}if(Object.keys(i).length>0)s=`<script>window.__stxRouterConfig=${g(i)};</script>
12
- `}let{getCachedRouterScript:c,getServeClientAsset:o}=await import("./chunk-1kz70290.js"),u=r?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':r?.buildMode==="serve"?`<script data-stx-router src="${(await o("router")).url}"></script>`:`<script data-stx-router>${await c()}</script>`,d=e.lastIndexOf("</body>");return e.slice(0,d)+s+n+u+`
12
+ `}let{getCachedRouterScript:c,getServeClientAsset:o}=await import("./chunk-67k5q95t.js"),u=r?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':r?.buildMode==="serve"?`<script data-stx-router src="${(await o("router")).url}"></script>`:`<script data-stx-router>${await c()}</script>`,d=e.lastIndexOf("</body>");return e.slice(0,d)+s+n+u+`
13
13
  </body>`+e.slice(d+7)}
14
14
  export{ar,X,be,lc,cr,uc,we};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{$l,Wg}from"./chunk-tj6zvs8f.js";export{$l as captureScreenshot,Wg as captureScreenshots};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{tt}from"./chunk-1bgv727x.js";import{ht,Hn}from"./chunk-yts2b9d8.js";import{$r,Rr,Ar,Ir,_e}from"./chunk-7rk7wfm6.js";import{Me,gn,Yc,Zc}from"./chunk-f0bwetnx.js";import{N}from"./chunk-m7hfcxt3.js";import{vi}from"./chunk-pdnyhs63.js";import{y}from"./chunk-rxt4jj9b.js";import{i}from"./chunk-gzhrtymg.js";import{B,a}from"./chunk-nmkkfpmh.js";import{Sc}from"./chunk-t2sg2tp2.js";import{Pn,We,Ee,la,ua,In}from"./chunk-jtx9x3as.js";import{on,Po}from"./chunk-vbrn4w81.js";import{On}from"./chunk-j3st59hv.js";import{Zt,Yn,Zn}from"./chunk-ndjmt3vg.js";import{X}from"./chunk-133vw0ae.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:Ir,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=Ar(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=$r(t.html,u);if(g.htmlAttrs)t.html=Rr(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-gtd6qs1r.js";import{ht,Hn}from"./chunk-s6mte5vy.js";import{$r,Rr,Ar,Ir,_e}from"./chunk-72jt897s.js";import{Me,gn,Zc,Qc}from"./chunk-ymypc1rp.js";import{N}from"./chunk-m7hfcxt3.js";import{vi}from"./chunk-sf4rntqj.js";import{y}from"./chunk-9tzcvsv0.js";import{i}from"./chunk-8gcg9maj.js";import{B,a}from"./chunk-j65nf7mt.js";import{Sc}from"./chunk-t2sg2tp2.js";import{Pn,We,Ee,la,ua,In}from"./chunk-k01aftw0.js";import{on,Po}from"./chunk-p13wg97w.js";import{On}from"./chunk-j3st59hv.js";import{Zt,Yn,Zn}from"./chunk-ndjmt3vg.js";import{X}from"./chunk-9xd85mvm.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);Zc();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=Qc();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 nm(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:Ir,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=Ar(t.html,g,{bodyScripts:[`<script src="/__stx/${x.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=$r(t.html,u);if(g.htmlAttrs)t.html=Rr(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
- export{tm};
4
+ export{nm};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{lt,ut,dt}from"./chunk-7qk4exw1.js";import"./chunk-n761hp6d.js";import"./chunk-r9e0r6jx.js";import"./chunk-7rk7wfm6.js";import{m}from"./chunk-f0bwetnx.js";import"./chunk-m7hfcxt3.js";import"./chunk-pdnyhs63.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-1tzqqr0p.js";import"./chunk-r9e0r6jx.js";import"./chunk-72jt897s.js";import{m}from"./chunk-ymypc1rp.js";import"./chunk-m7hfcxt3.js";import"./chunk-sf4rntqj.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-xbknqp19.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-xbknqp19.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-enm79dwe.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-enm79dwe.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"}">
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{bm,wm,vm,xm,Sm}from"./chunk-sxad7x2s.js";export{wm as defineAsyncComponent,xm as generateAsyncComponentCSS,Sm as generateAsyncComponentRuntime,vm as isAsyncComponent,bm as processAsyncDirectives};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Qm,eh,th,nh,rh}from"./chunk-e3t2bqyf.js";export{eh as createSSRSuspense,nh as generateSuspenseCSS,rh as generateSuspenseRuntime,Qm as processSuspenseDirectives,th as renderSSRSuspense};
@@ -1,12 +1,12 @@
1
1
  // @bun
2
- function o(t,i){let n=t[i],e=i+1;while(e<t.length){if(t[e]==="\\"){e+=2;continue}if(t[e]===n)return e+1;e++}return t.length}function b(t,i){let n=i+1;while(n<t.length){if(t[n]==="\\"){n+=2;continue}if(t[n]==="`")return n+1;if(t[n]==="$"&&t[n+1]==="{"){if(n=el(t,n+2),n<t.length)n++;continue}n++}return t.length}function el(t,i){let n=1,e=i,s="{",f="";while(e<t.length){let l=t[e];if(l==="\\"){e+=2;continue}if(l==='"'||l==="'"){e=o(t,e),s=h,f="";continue}if(l==="`"){e=b(t,e),s=h,f="";continue}if(l==="/"&&t[e+1]==="/"){while(e<t.length&&t[e]!==`
2
+ function o(t,i){let n=t[i],e=i+1;while(e<t.length){if(t[e]==="\\"){e+=2;continue}if(t[e]===n)return e+1;e++}return t.length}function b(t,i){let n=i+1;while(n<t.length){if(t[n]==="\\"){n+=2;continue}if(t[n]==="`")return n+1;if(t[n]==="$"&&t[n+1]==="{"){if(n=tl(t,n+2),n<t.length)n++;continue}n++}return t.length}function tl(t,i){let n=1,e=i,s="{",f="";while(e<t.length){let l=t[e];if(l==="\\"){e+=2;continue}if(l==='"'||l==="'"){e=o(t,e),s=h,f="";continue}if(l==="`"){e=b(t,e),s=h,f="";continue}if(l==="/"&&t[e+1]==="/"){while(e<t.length&&t[e]!==`
3
3
  `)e++;continue}if(l==="/"&&t[e+1]==="*"){e+=2;while(e<t.length&&t.slice(e,e+2)!=="*/")e++;e+=2;continue}if(l==="/"&&a(s,f)){let u=w(t,e);if(u!==-1){e=u,s=h,f="";continue}}if(l==="{")n++;else if(l==="}"){if(n--,n===0)return e}if(/[\w$]/.test(l))f=/[\w$]/.test(s)?f+l:l,s=l;else if(!/\s/.test(l))s=l,f="";e++}return t.length}var m=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]);function a(t,i){if(i)return m.has(i);return!(t===")"||t==="]"||t===h)}var h="\x00";function w(t,i){let n=i+1,e=!1;while(n<t.length){let s=t[n];if(s===`
4
4
  `)return-1;if(s==="\\"){n+=2;continue}if(s==="[")e=!0;else if(s==="]")e=!1;else if(s==="/"&&!e){n++;while(n<t.length&&/[a-z]/i.test(t[n]))n++;return n}n++}return-1}function r(t){let i="",n=0,e="",s="";while(n<t.length){let f=t.slice(n,n+2);if(f==="//"){while(n<t.length&&t[n]!==`
5
5
  `)i+=" ",n++;continue}if(f==="/*"){while(n<t.length&&t.slice(n,n+2)!=="*/")i+=t[n]===`
6
6
  `?`
7
7
  `:" ",n++;i+=" ",n+=2;continue}let l=t[n];if(l==='"'||l==="'"){let u=l;i+=" ",n++;while(n<t.length&&t[n]!==u){if(t[n]==="\\"){i+=" ",n+=2;continue}i+=t[n]===`
8
8
  `?`
9
- `:" ",n++}i+=" ",n++,e=h,s="";continue}if(l==="/"&&a(e,s)){let u=w(t,n);if(u!==-1){i+=`/${" ".repeat(u-n-2)}/`,n=u,e=h,s="";continue}}if(l==="`"){i+=" ",n++;while(n<t.length&&t[n]!=="`"){if(t[n]==="\\"){i+=" ",n+=2;continue}if(t[n]==="$"&&t[n+1]==="{"){let u=n+2,g=el(t,u);if(i+=" ",i+=r(t.slice(u,g)),g<t.length)i+=" ";n=g+1;continue}i+=t[n]===`
9
+ `:" ",n++}i+=" ",n++,e=h,s="";continue}if(l==="/"&&a(e,s)){let u=w(t,n);if(u!==-1){i+=`/${" ".repeat(u-n-2)}/`,n=u,e=h,s="";continue}}if(l==="`"){i+=" ",n++;while(n<t.length&&t[n]!=="`"){if(t[n]==="\\"){i+=" ",n+=2;continue}if(t[n]==="$"&&t[n+1]==="{"){let u=n+2,g=tl(t,u);if(i+=" ",i+=r(t.slice(u,g)),g<t.length)i+=" ";n=g+1;continue}i+=t[n]===`
10
10
  `?`
11
11
  `:" ",n++}i+=" ",n++,e=h,s="";continue}if(i+=l,n++,/[\w$]/.test(l))s=/[\w$]/.test(e)?s+l:l,e=l;else if(!/\s/.test(l))e=l,s=""}return i}function ge(t){let i=new Uint16Array(t.length),n=0,e=!0;for(let s=0;s<t.length;s++){let f=t[s];if(f===")"||f==="]"||f==="}")if(n===0)e=!1;else n--;if(i[s]=n,f==="("||f==="["||f==="{")n++}return{depths:i,balanced:e&&n===0}}
12
- export{el,r,ge};
12
+ export{tl,r,ge};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{sh,bo,oh,ih,ah,ch}from"./chunk-zgq8bfaw.js";import"./chunk-vtt2dec3.js";import"./chunk-p13wg97w.js";import"./chunk-7sh9fa3q.js";import"./chunk-x34me5ar.js";import"./chunk-9xd85mvm.js";import"./chunk-fmawgk87.js";import"./chunk-j65nf7mt.js";import"./chunk-casvvt3k.js";import"./chunk-9gwhs0gk.js";import"./chunk-t2sg2tp2.js";import"./chunk-em2yy1te.js";import"./chunk-gtd6qs1r.js";import"./chunk-ymypc1rp.js";import"./chunk-sf4rntqj.js";import"./chunk-m7hfcxt3.js";import"./chunk-72jt897s.js";import"./chunk-r9e0r6jx.js";import"./chunk-1tzqqr0p.js";export{ch as clearStoreCache,sh as getStoreScript,ah as getStoreScriptFor,ih as pageStoresAll,bo as storesRead,oh as storesReadInFiles};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ve,Us,mg,Jh,hg,Yh,Mt,p,U,Z,wn,Se,yg,wi,bg,Zh,_,wg,Qh,R,ey}from"./chunk-ymypc1rp.js";import"./chunk-sf4rntqj.js";import"./chunk-m7hfcxt3.js";import"./chunk-72jt897s.js";import"./chunk-r9e0r6jx.js";import"./chunk-1tzqqr0p.js";export{wg as applyFilters,Yh as clearCustomFilters,yg as clientLoopScopes,Us as defaultFilters,wn as escapeAttributeValue,p as escapeHtml,U as escapeHtmlValue,Z as escapeInterpolatedHtmlValue,R as evaluateExpression,ve as findMustacheEnd,hg as getAllFilters,bg as interpolateScriptAttributes,wi as interpolateScriptExpressions,Zh as interpolateScriptsInTemplate,_ as processExpressions,mg as registerFilter,Jh as registerFilters,Mt as replaceInterpolations,Qh as resetRejectedExpressionWarnings,ey as unescapeHtml,Se as usesSignalsInScript};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{A,t,l}from"./chunk-7rk7wfm6.js";import{Z}from"./chunk-f0bwetnx.js";import{Jo}from"./chunk-2ws2qe1k.js";import C from"path";var L;async function W(){if(L!==void 0)return L;try{let e=await import("@stacksjs/ts-i18n");L=e.loadLocale??null}catch{L=null}return L}var P={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},k={},v={},R={};function J(e,s=0){if(s<=0)return!1;return Date.now()-e.loadedAt>s}async function G(e,s){if({...P,...s.i18n}.cache&&k[e]){let r=k[e],o=s.i18n?.cacheMaxAge??0;if(!J(r,o))return r.translations}if(v[e]?.state==="loading")return v[e].promise;R[e]="loading";let n=T(e,s).then((r)=>(R[e]="loaded",delete v[e],r)).catch((r)=>{throw R[e]="error",v[e]={promise:n,state:"error",error:r instanceof Error?r:Error(String(r))},r});return v[e]={promise:n,state:"loading"},n}async function T(e,s){let i={...P,...s.i18n},n=C.isAbsolute(i.translationsDir)?i.translationsDir:C.resolve(s.root||process.cwd(),i.translationsDir);try{let r=await W(),o=r?await r(e,{translationsDir:n,defaultLocale:i.defaultLocale,sources:te(i.format)}):await Y(e,i,n);if(o===void 0){let u=e!==i.defaultLocale?await T(i.defaultLocale,s):{};if(i.cache)k[e]={translations:u,loadedAt:Date.now(),locale:e};return u}let c=o;if(i.cache)k[e]={translations:c,loadedAt:Date.now(),locale:e};return c}catch(r){if(s.debug)console.error(`Error loading translation file for locale "${e}":`,r);if(e!==i.defaultLocale)return T(i.defaultLocale,s);return{}}}async function Y(e,s,i){let n=C.join(i,`${e}${Q(s.format)}`);try{let r=await import(n);return r.default||r}catch(r){try{let o=await Bun.file(n).text();if(s.format==="yaml"||s.format==="yml")return X(o);if(s.format==="json")return JSON.parse(o);throw r}catch{return}}}function Q(e){switch(e){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function X(e){let s={},i=e.split(`
2
+ import{A,t,l}from"./chunk-72jt897s.js";import{Z}from"./chunk-ymypc1rp.js";import{Jo}from"./chunk-9gwhs0gk.js";import C from"path";var L;async function W(){if(L!==void 0)return L;try{let e=await import("@stacksjs/ts-i18n");L=e.loadLocale??null}catch{L=null}return L}var P={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},k={},v={},R={};function J(e,s=0){if(s<=0)return!1;return Date.now()-e.loadedAt>s}async function G(e,s){if({...P,...s.i18n}.cache&&k[e]){let r=k[e],o=s.i18n?.cacheMaxAge??0;if(!J(r,o))return r.translations}if(v[e]?.state==="loading")return v[e].promise;R[e]="loading";let n=T(e,s).then((r)=>(R[e]="loaded",delete v[e],r)).catch((r)=>{throw R[e]="error",v[e]={promise:n,state:"error",error:r instanceof Error?r:Error(String(r))},r});return v[e]={promise:n,state:"loading"},n}async function T(e,s){let i={...P,...s.i18n},n=C.isAbsolute(i.translationsDir)?i.translationsDir:C.resolve(s.root||process.cwd(),i.translationsDir);try{let r=await W(),o=r?await r(e,{translationsDir:n,defaultLocale:i.defaultLocale,sources:te(i.format)}):await Y(e,i,n);if(o===void 0){let u=e!==i.defaultLocale?await T(i.defaultLocale,s):{};if(i.cache)k[e]={translations:u,loadedAt:Date.now(),locale:e};return u}let c=o;if(i.cache)k[e]={translations:c,loadedAt:Date.now(),locale:e};return c}catch(r){if(s.debug)console.error(`Error loading translation file for locale "${e}":`,r);if(e!==i.defaultLocale)return T(i.defaultLocale,s);return{}}}async function Y(e,s,i){let n=C.join(i,`${e}${Q(s.format)}`);try{let r=await import(n);return r.default||r}catch(r){try{let o=await Bun.file(n).text();if(s.format==="yaml"||s.format==="yml")return X(o);if(s.format==="json")return JSON.parse(o);throw r}catch{return}}}function Q(e){switch(e){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function X(e){let s={},i=e.split(`
3
3
  `),n=[{obj:s,indent:-1}];for(let r of i){let o=r.replace(/#.*$/,"").trimEnd();if(!o.trim())continue;let c=o.search(/\S/);if(c===-1)continue;while(n.length>1&&n[n.length-1].indent>=c)n.pop();let u=n[n.length-1].obj,a=o.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(a){let[,,g,p]=a,f=g.trim(),m=p.trim();if(m==="")u[f]={},n.push({obj:u[f],indent:c});else u[f]=ee(m)}}return s}function ee(e){if(e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1);let s=e.toLowerCase();if(s==="true"||s==="yes")return!0;if(s==="false"||s==="no")return!1;if(s==="null"||s==="~")return null;let i=Number(e);if(!Number.isNaN(i)&&e!=="")return i;return e}function te(e){switch(e){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function re(e,s){return G(e,s)}function ne(e,s){for(let i of e){let n=i.trim(),r=n.match(/^\{(\d+)\}\s*(.*)$/);if(r){let c=Number.parseInt(r[1],10);if(s===c)return r[2];continue}let o=n.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(o){let c=Number.parseInt(o[1],10),u=o[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(o[2],10);if(s>=c&&s<=u)return o[3];continue}}if(e.length===2)return s===1?e[0].trim():e[1].trim();if(s<e.length)return e[s].trim();return e[e.length-1].trim()}function ie(e,s={}){return j(e,s)}function j(e,s){let i="",n=0;while(n<e.length)if(e[n]==="{"){let r=se(e,n);if(r===-1){i+=e[n],n++;continue}let o=e.slice(n+1,r);i+=ae(o,s),n=r+1}else if(e[n]==="'"&&n+1<e.length)if(e[n+1]==="'")i+="'",n+=2;else if(e[n+1]==="{"||e[n+1]==="}")i+=e[n+1],n+=2;else i+=e[n],n++;else i+=e[n],n++;return i}function se(e,s){let i=0;for(let n=s;n<e.length;n++)if(e[n]==="{")i++;else if(e[n]==="}"){if(i--,i===0)return n}return-1}function ae(e,s){let i=oe(e);if(i.length===0)return`{${e}}`;let n=i[0].trim(),r=s[n];if(i.length===1)return r!==void 0?String(r):`{${n}}`;switch(i[1].trim().toLowerCase()){case"plural":return le(r,i.slice(2).join(","),s);case"select":return ue(r,i.slice(2).join(","));case"selectordinal":return de(r,i.slice(2).join(","));case"number":return pe(r,i[2]?.trim());case"date":return fe(r,i[2]?.trim());case"time":return me(r,i[2]?.trim());default:return r!==void 0?String(r):`{${e}}`}}function oe(e){let s=[],i="",n=0;for(let r=0;r<e.length;r++){let o=e[r];if(o==="{")n++,i+=o;else if(o==="}")n--,i+=o;else if(o===","&&n===0)s.push(i),i="";else i+=o}if(i)s.push(i);return s}function le(e,s,i){let n=Number(e)||0,r=I(s),o=`=${n}`;if(r[o])return E(r[o],n,i);let c=ce(n);if(r[c])return E(r[c],n,i);if(r.other)return E(r.other,n,i);return String(n)}function E(e,s,i){let n=e.replace(/#/g,String(s));return j(n,i)}function ce(e){let s=Math.abs(e),i=Math.floor(s),n=String(e).includes(".")?String(e).split(".")[1].length:0;if(i===1&&n===0)return"one";return"other"}function ue(e,s){let i=String(e||""),n=I(s);if(n[i])return n[i];return n.other||String(e)}function de(e,s){let i=Number(e)||0,n=I(s),r=ge(i);if(n[r])return n[r].replace(/#/g,String(i));if(n.other)return n.other.replace(/#/g,String(i));return String(i)}function ge(e){let s=Math.abs(e),i=s%10,n=s%100;if(i===1&&n!==11)return"one";if(i===2&&n!==12)return"two";if(i===3&&n!==13)return"few";return"other"}function I(e){let s={},i=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,n=i.exec(e);while(n!==null)s[n[1]]=n[2],n=i.exec(e);return s}function pe(e,s){let i=Number(e);if(Number.isNaN(i))return String(e);switch(s){case"integer":return Math.floor(i).toLocaleString();case"percent":return`${(i*100).toFixed(0)}%`;case"currency":return i.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return i.toLocaleString()}}function fe(e,s){let i=e instanceof Date?e:new Date(String(e));if(Number.isNaN(i.getTime()))return String(e);let n={};switch(s){case"short":n.dateStyle="short";break;case"medium":n.dateStyle="medium";break;case"long":n.dateStyle="long";break;case"full":n.dateStyle="full";break;default:n.dateStyle="medium"}return i.toLocaleDateString(void 0,n)}function me(e,s){let i=e instanceof Date?e:new Date(String(e));if(Number.isNaN(i.getTime()))return String(e);let n={};switch(s){case"short":n.timeStyle="short";break;case"medium":n.timeStyle="medium";break;case"long":n.timeStyle="long";break;case"full":n.timeStyle="full";break;default:n.timeStyle="short"}return i.toLocaleTimeString(void 0,n)}function be(e){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test(e)}function O(e,s,i=!0,n={}){let r=e.split("."),o=s;for(let u of r){if(o===void 0||o===null)break;o=o[u]}if(o===void 0||o===null)return i?e:"";let c=String(o);if(be(c))return ie(c,n);if(c.includes("|")&&"count"in n){let u=Number(n.count),a=c.split("|");c=ne(a,u)}for(let[u,a]of Object.entries(n)){let g=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");c=c.replace(new RegExp(`:${g}`,"g"),()=>String(a))}return c}var D=new Set(["ar","arc","ckb","dv","fa","he","khw","ks","nqo","prs","ps","sd","syr","ug","ur","uz-af","yi"]),he=new Set(["adlm","arab","aran","hebr","nkoo","rohg","syrc","thaa","yezi"]);function q(e){if(!e)return"ltr";let s=e.trim().toLowerCase().replace(/_/g,"-").split("-"),i=s[0];if(!i)return"ltr";let n=s[1]?.length===4?s[1]:void 0;if(n)return he.has(n)?"rtl":"ltr";if(s.length>1&&D.has(`${i}-${s[1]}`))return"rtl";return D.has(i)?"rtl":"ltr"}async function mc(e,s,i,n){let r=e,o=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,c={...P,...n.i18n},u=await re(c.locale,n);s.__translations=u,s.__locale=c.locale,s.__i18nConfig=c,r=await F(r,o,async(p,f,m,w,h)=>{try{let b={};if(m)try{let d=[()=>JSON.parse(m),()=>{let x=`{"data":${m}}`,S=JSON.parse(x);return typeof S.data==="object"?S.data:{}},()=>A(m,s)];for(let x of d)try{if(b=x(),Object.keys(b).length>0)break}catch{}}catch(d){if(n.debug)console.error("Error parsing parameters for @translate directive:",d)}let y=O(f,u,c.fallbackToKey,b);return y?Z(r,h,y,!1,p.length):w.trim()}catch(b){if(n.debug)console.error("Error processing @translate directive:",b);return l("Translate",`Error in @translate('${f}'): ${b instanceof Error?b.message:String(b)}`,t.EVALUATION_ERROR)}});let a=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(n.debug){console.warn(`Processing translations in template. Sections: ${r.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let p=[...r.matchAll(a)];console.warn(`Found ${p.length} @translate matches`),p.forEach((f,m)=>console.warn(`Match ${m}: ${f[0]}, Key: ${f[1]}, Params: ${f[2]||"none"}`))}return r=await F(r,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(p,f,m,w)=>{try{let h={};if(m)try{let b=[()=>JSON.parse(m),()=>{let y=`{"data":${m}}`,d=JSON.parse(y);return typeof d.data==="object"?d.data:{}},()=>A(m,s)];for(let y of b)try{if(h=y(),Object.keys(h).length>0)break}catch{}}catch(b){if(n.debug)console.error("Error parsing parameters for @translate directive:",b)}return Z(r,w,O(f,u,c.fallbackToKey,h),!1,p.length)}catch(h){if(n.debug)console.error("Error processing @translate directive:",h);return l("Translate",`Error in @translate('${f}'): ${h instanceof Error?h.message:String(h)}`,t.EVALUATION_ERROR)}}),r}async function F(e,s,i){let n=[];return e.replace(s,(o,...c)=>{let u=i(o,...c).then((a)=>({match:o,replacement:a}));return n.push(u),o}),(await Promise.all(n)).reduce((o,{match:c,replacement:u})=>o.replace(c,()=>u),e)}function _(e,s){if(!e||q(e)!=="rtl")return!1;return!s||s.trim().toLowerCase()!=="rtl"}function V(e){if(!e)return!1;return e.trim().split(/\s+/)[0]?.toLowerCase()==="presentation"||e.trim().split(/\s+/)[0]?.toLowerCase()==="none"}function U(e,s){let i=new RegExp(`\\b${s}\\s*=\\s*("([^"]*)"|'([^']*)'|([^\\s>]+))`,"i").exec(e);if(!i)return null;return i[2]??i[3]??i[4]??null}function hc(e,s,i,n){let r=e;r=r.replace(/@a11y\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(c,u,a)=>{let p={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[u]||"Make this element accessible";return`<!-- a11y-hint: ${a||p} -->`});let o=/@screenReader\(([^@]*)\)@endScreenReader/g;return r=r.replace(o,(c,u)=>`<span class="sr-only">${u.trim()}</span>`),r=r.replace(/@ariaDescribe\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(c,u,a)=>`<span id="${`desc-${u}`}" class="sr-only">${a}</span>`),r}function ye(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function xe(e){let s=new Map,i=e.replace(/<(\/?)([A-Z][\w:.-]*)(?=[\s/>])/g,(r,o,c)=>{let u=s.get(c);if(!u)u=`stx-a11y-component-${s.size}`,s.set(c,u);return`<${o}${u}`}),n=new Map([...s.entries()].map(([r,o])=>[o,r]));return{protectedSource:i,restore:(r)=>r.replace(/<(\/?)(stx-a11y-component-\d+)(?=[\s/>])/g,(o,c,u)=>{let a=n.get(u);return a?`<${c}${a}`:o})}}function we(e,s){let i=[],n=/<img\s+([^>]*)>/gi,r;r=n.exec(e);while(r!==null){let d=r[1];if(!/\balt\s*=/i.test(d))i.push({type:"missing-alt",element:r[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});r=n.exec(e)}let o=/<button([^>]*)>\s*<\/button>/gi;r=o.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))i.push({type:"missing-accessible-name",element:r[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});r=o.exec(e)}let c=/<a\s+([^>]*)>\s*<\/a>/gi;r=c.exec(e);while(r!==null){let d=r[1];if(!/\baria-label\s*=/i.test(d)&&!/\btitle\s*=/i.test(d))i.push({type:"link-missing-text",element:r[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});r=c.exec(e)}let u=/<(input|select|textarea)\s+([^>]*)>/gi;r=u.exec(e);while(r!==null){let d=r[2];if(/\btype\s*=\s*["']hidden["']/i.test(d)){r=u.exec(e);continue}let x=/\baria-label\s*=/i.test(d)||/\baria-labelledby\s*=/i.test(d),S=d.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!x){let B=S&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${S[1]}["']`,"i").test(e),M=r.index,N=e.substring(0,M),Se=e.substring(M),H=(N.match(/<label\b/gi)||[]).length,z=(N.match(/<\/label>/gi)||[]).length,K=H>z;if(!B&&!K)i.push({type:"input-missing-label",element:r[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}r=u.exec(e)}let a=/<h([1-6])[^>]*>/gi,g=[];r=a.exec(e);while(r!==null)g.push(Number.parseInt(r[1],10)),r=a.exec(e);let p=0;for(let d of g){if(p>0&&d>p+1)i.push({type:"heading-skip",element:`<h${d}>`,message:`Heading level skipped from h${p} to h${d}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});p=d}if(/<html\b/i.test(e)&&!/<html[^>]*\slang\s*=/i.test(e))i.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let f=e.match(/<html\b([^>]*)>/i);if(f&&_(U(f[1],"lang"),U(f[1],"dir")))i.push({type:"missing-dir",element:f[0].substring(0,100),message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});let m=/<table([^>]*)>([\s\S]*?)<\/table>/gi;r=m.exec(e);while(r!==null){let d=r[2];if(!V(U(r[1],"role"))&&!/<th\b/i.test(d))i.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});r=m.exec(e)}let w=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;r=w.exec(e);while(r!==null){if(!/\bmuted\b/i.test(r[0]))i.push({type:"autoplay-audio",element:`<${r[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});r=w.exec(e)}let h=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;r=h.exec(e);while(r!==null)i.push({type:"positive-tabindex",element:`tabindex="${r[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),r=h.exec(e);let b=/<iframe\s+([^>]*)>/gi;r=b.exec(e);while(r!==null){let d=r[1];if(!/\btitle\s*=/i.test(d)&&!/\baria-label\s*=/i.test(d))i.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});r=b.exec(e)}let y=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;r=y.exec(e);while(r!==null){let d=r[1].toLowerCase(),x=r[2];if(d!=="button"&&!/\btabindex\s*=/i.test(x))i.push({type:"button-not-focusable",element:r[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});r=y.exec(e)}return i}async function Ae(e,s){let{protectedSource:i}=xe(e);if(!ye())return we(i,s);let n=[];try{let r=globalThis.document.createElement("div");r.innerHTML=i,r.querySelectorAll("img").forEach((a)=>{if(!a.hasAttribute("alt"))n.push({type:"missing-alt",element:`<${a.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),r.querySelectorAll('button, a, [role="button"]').forEach((a)=>{if(!(a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby")||a.textContent&&a.textContent.trim().length>0))n.push({type:"missing-accessible-name",element:`<${a.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),r.querySelectorAll("input, select, textarea").forEach((a)=>{let g=a.getAttribute("id"),p=g&&r.querySelector(`label[for="${g}"]`),f=a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby"),m=a.closest("label")!==null;if(!p&&!f&&!m)n.push({type:"input-missing-label",element:`<${a.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let o=Array.from(r.querySelectorAll("h1, h2, h3, h4, h5, h6")),c=0;for(let a of o){let g=Number.parseInt(a.tagName.charAt(1));if(c>0&&g>c+1)n.push({type:"heading-skip",element:`<${a.outerHTML}>`,message:`Heading level skipped from h${c} to h${g}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});c=g}let u=r.querySelector("html");if(i.includes("<html")&&u&&!u.hasAttribute("lang"))n.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(u&&_(u.getAttribute("lang"),u.getAttribute("dir")))n.push({type:"missing-dir",element:"<html>",message:'Document language is right-to-left but dir="rtl" is not set',impact:"serious",help:'Add dir="rtl" to the html element so the layout mirrors the text',helpUrl:"https://www.w3.org/International/questions/qa-html-dir"});if(r.querySelectorAll("a").forEach((a)=>{let g=a.textContent&&a.textContent.trim().length>0,p=a.hasAttribute("aria-label")||a.hasAttribute("aria-labelledby"),f=a.hasAttribute("title"),m=a.querySelector("img[alt]");if(!g&&!p&&!f&&!m)n.push({type:"link-missing-text",element:`<${a.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),i.includes("<nav")||i.includes("<header")){if(!r.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&r.querySelectorAll("a").length>5)n.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(r.querySelectorAll("table").forEach((a)=>{if(V(a.getAttribute("role")))return;let g=a.querySelector("caption");if(!a.querySelector("th"))n.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!g&&!a.hasAttribute("aria-label")&&!a.hasAttribute("aria-labelledby"))n.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),r.querySelectorAll('[style*="color"]').forEach((a)=>{let g=a.getAttribute("style")||"";if(g.includes("color:")&&!g.includes("background"))n.push({type:"potential-contrast-issue",element:`<${a.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),r.querySelectorAll("video[autoplay], audio[autoplay]").forEach((a)=>{if(!a.hasAttribute("muted"))n.push({type:"autoplay-audio",element:`<${a.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),r.querySelectorAll("[tabindex]").forEach((a)=>{if(Number.parseInt(a.getAttribute("tabindex")||"0")>0)n.push({type:"positive-tabindex",element:`<${a.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),r.querySelectorAll('[role="button"]').forEach((a)=>{if(!a.hasAttribute("tabindex"))n.push({type:"button-not-focusable",element:`<${a.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),i.includes("<body")&&!r.querySelector('main, [role="main"]'))n.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});r.querySelectorAll("iframe").forEach((a)=>{if(!a.hasAttribute("title")&&!a.hasAttribute("aria-label"))n.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(r){console.error(`Error checking accessibility in ${s}:`,r)}return n}async function yc(e,s={}){let i={},{recursive:n=!0,ignorePaths:r=[]}=s,o=Array.isArray(e)?e:[e],c=await Jo(o,{recursive:n,ignorePaths:r}),u=[];for(let a of c)try{let g=await Bun.file(a).text();if(a.endsWith("good-a11y.stx"))continue;let p=await Ae(g,a);if(u.push(a),p.length>0)i[a]=p}catch(g){console.error(`Error scanning ${a}:`,g)}return{results:i,scannedFiles:u}}var bc={name:"a11y",handler:(e,s,i,n)=>{if(!s.length)return e;let r=s[0].replace(/['"]/g,""),o=s.length>1?s[1].replace(/['"]/g,""):"",u={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[r]||"Make this element accessible";return`<!-- a11y-hint: ${o||u} -->${e}`},hasEndTag:!1},wc={name:"screenReader",handler:(e)=>`<span class="sr-only">${e}</span>`,hasEndTag:!0};
4
4
  export{mc,hc,yc,bc,wc};