@stacksjs/stx 0.2.655 → 0.2.656

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 (136) hide show
  1. package/dist/{chunk-hyd0s2ew.js → chunk-0gqmp9sa.js} +2 -2
  2. package/dist/{chunk-48acjmeg.js → chunk-0jhdrgpr.js} +2 -2
  3. package/dist/{chunk-dpz9tx1f.js → chunk-1z1fmda6.js} +1 -1
  4. package/dist/chunk-26qc9v36.js +2 -0
  5. package/dist/{chunk-dwe2dedz.js → chunk-27v1ehy0.js} +1 -1
  6. package/dist/{chunk-ajgxj2t9.js → chunk-2h92dm3t.js} +3 -3
  7. package/dist/{chunk-46w53nj5.js → chunk-2jh21f1n.js} +1 -1
  8. package/dist/chunk-2qf9vt7y.js +2 -0
  9. package/dist/{chunk-kgbf3z87.js → chunk-31yb0253.js} +4 -4
  10. package/dist/chunk-3p7xp7de.js +2 -0
  11. package/dist/{chunk-g3xcyqb8.js → chunk-5cyznacz.js} +1 -1
  12. package/dist/{chunk-j2bkjtp3.js → chunk-5w2jy5r9.js} +4 -4
  13. package/dist/chunk-67rvd6qy.js +2 -0
  14. package/dist/{chunk-j6f9ffmc.js → chunk-6c2pvrw8.js} +1 -1
  15. package/dist/{chunk-4qwvqbzf.js → chunk-7rta163c.js} +2 -2
  16. package/dist/{chunk-4t0nz925.js → chunk-80fkh83p.js} +1 -1
  17. package/dist/{chunk-eyrkpf0q.js → chunk-889evdcy.js} +12 -12
  18. package/dist/{chunk-znnfjxph.js → chunk-8d2f2e42.js} +1 -1
  19. package/dist/{chunk-wh838rdh.js → chunk-8nryyqb5.js} +1 -1
  20. package/dist/chunk-9c3cq8ks.js +2 -0
  21. package/dist/chunk-9q23eed0.js +2 -0
  22. package/dist/chunk-a2bw46t9.js +2 -0
  23. package/dist/{chunk-pb5k6sbj.js → chunk-a2dnv6n9.js} +1 -1
  24. package/dist/{chunk-8ftpzhx4.js → chunk-ajjcp56c.js} +3 -3
  25. package/dist/{chunk-vngnface.js → chunk-aprhqxky.js} +3 -3
  26. package/dist/chunk-b4fd2dtk.js +2 -0
  27. package/dist/chunk-bpm8tyvc.js +2 -0
  28. package/dist/{chunk-a2a74f6c.js → chunk-c9k40352.js} +1 -1
  29. package/dist/{chunk-0mr9wx5c.js → chunk-cjj9b9wf.js} +2 -2
  30. package/dist/chunk-da6qbwqs.js +2 -0
  31. package/dist/chunk-dknd9nhz.js +2 -0
  32. package/dist/{chunk-k6jq6a19.js → chunk-ds3qn1ty.js} +1 -1
  33. package/dist/{chunk-3gaggdvz.js → chunk-dv7dm5z1.js} +20 -20
  34. package/dist/{chunk-z7s1aqyn.js → chunk-e7z85137.js} +1 -1
  35. package/dist/{chunk-c9b0cme2.js → chunk-eecgcj41.js} +1 -1
  36. package/dist/chunk-fbtv2k1p.js +3 -0
  37. package/dist/chunk-fjqphdvp.js +2 -0
  38. package/dist/{chunk-bzpf3qtz.js → chunk-g96m1a69.js} +1 -1
  39. package/dist/{chunk-hjmnsa6a.js → chunk-gf3bxnpq.js} +1 -1
  40. package/dist/{chunk-vmn2b6p6.js → chunk-gz90fqn8.js} +1 -1
  41. package/dist/{chunk-50pkybyn.js → chunk-gzd7bmp5.js} +1 -1
  42. package/dist/{chunk-4e0z858k.js → chunk-hb08vrbb.js} +1 -1
  43. package/dist/{chunk-y4nhcrf1.js → chunk-hzjvpcmj.js} +109 -94
  44. package/dist/chunk-j2hkxwjy.js +2 -0
  45. package/dist/{chunk-5c14xpmg.js → chunk-jf17b7y9.js} +1 -1
  46. package/dist/{chunk-jc64acnb.js → chunk-jfmjw734.js} +2 -2
  47. package/dist/{chunk-xdgvb5a5.js → chunk-jrf01hfv.js} +1 -1
  48. package/dist/{chunk-8bad437f.js → chunk-jvv9p6v6.js} +1 -1
  49. package/dist/{chunk-86phdm37.js → chunk-k9amsnfj.js} +4 -4
  50. package/dist/chunk-kg54zsda.js +2 -0
  51. package/dist/chunk-kpycf9tz.js +2 -0
  52. package/dist/{chunk-cah391jn.js → chunk-mz1npbyk.js} +1 -1
  53. package/dist/chunk-ne72vxmc.js +2 -0
  54. package/dist/{chunk-pc74fca2.js → chunk-nn138y2w.js} +3 -3
  55. package/dist/{chunk-cq40n7ak.js → chunk-np1k9vsr.js} +1 -1
  56. package/dist/{chunk-yr9shdxa.js → chunk-p314pg80.js} +1 -1
  57. package/dist/chunk-p7096wfv.js +2 -0
  58. package/dist/{chunk-qmvwc88h.js → chunk-p7bqzhe1.js} +1 -1
  59. package/dist/{chunk-en8jgavy.js → chunk-pxqh758g.js} +81 -19
  60. package/dist/chunk-qc5wyxvc.js +2 -0
  61. package/dist/{chunk-d0nsehz6.js → chunk-qkasqamj.js} +1 -1
  62. package/dist/{chunk-sfn7f9dm.js → chunk-qkq8at1r.js} +1 -1
  63. package/dist/{chunk-8gewq710.js → chunk-r7kmsq3n.js} +1 -1
  64. package/dist/{chunk-nsxecff6.js → chunk-rccpf74y.js} +1 -1
  65. package/dist/{chunk-d4tf0tfn.js → chunk-rjh2jwxx.js} +4 -4
  66. package/dist/chunk-s2qv0y4x.js +2 -0
  67. package/dist/{chunk-fn6x5b29.js → chunk-sdknbvh8.js} +1 -1
  68. package/dist/{chunk-khvc43pq.js → chunk-t2pzy3x1.js} +2 -2
  69. package/dist/{chunk-h09a03ay.js → chunk-t9mfztcs.js} +4 -4
  70. package/dist/{chunk-nfafd1zr.js → chunk-teahew39.js} +4 -4
  71. package/dist/{chunk-9y2ncrnq.js → chunk-v2x9vzgw.js} +2 -2
  72. package/dist/{chunk-sj0rrn72.js → chunk-v3kc2anv.js} +1 -1
  73. package/dist/{chunk-njmdbz8t.js → chunk-v5r6abrq.js} +1 -1
  74. package/dist/{chunk-ez2kr2k1.js → chunk-vm26nak1.js} +1 -1
  75. package/dist/chunk-vmzkbdmp.js +2 -0
  76. package/dist/{chunk-6598d3m6.js → chunk-vqc4h16r.js} +2 -2
  77. package/dist/{chunk-qygynhzc.js → chunk-w2zceynt.js} +1 -1
  78. package/dist/chunk-weqc0ssb.js +2 -0
  79. package/dist/chunk-wp0jtntj.js +54 -0
  80. package/dist/{chunk-n5xp0sad.js → chunk-x2wgczak.js} +1 -1
  81. package/dist/{chunk-42hjga3m.js → chunk-x5777qkq.js} +2 -2
  82. package/dist/chunk-xesyd9nx.js +2 -0
  83. package/dist/{chunk-nttspz8c.js → chunk-xv43szx0.js} +4 -4
  84. package/dist/{chunk-00m5t5kj.js → chunk-y4waj1p4.js} +2 -2
  85. package/dist/chunk-yb89cj9s.js +2 -0
  86. package/dist/{chunk-mgj34bbg.js → chunk-yh0wb4n1.js} +1 -1
  87. package/dist/chunk-ypsym37h.js +2 -0
  88. package/dist/{chunk-4nbq7mnp.js → chunk-yq021b3r.js} +4 -4
  89. package/dist/{chunk-049nrn61.js → chunk-yr34z9ey.js} +1 -1
  90. package/dist/{chunk-qrt8b179.js → chunk-zaaeneq6.js} +2 -2
  91. package/dist/{chunk-tdnp94kz.js → chunk-zaj65qc1.js} +2 -2
  92. package/dist/{chunk-m6tqbxjx.js → chunk-zfeq5h13.js} +2 -2
  93. package/dist/{chunk-dxk5sqtv.js → chunk-zhf01af3.js} +2 -2
  94. package/dist/{chunk-ra1kfa6e.js → chunk-zyv28182.js} +1 -1
  95. package/dist/cli.js +11 -11
  96. package/dist/client/signals-dom-ready-runtime.js +2 -2
  97. package/dist/client/signals-effect-runtime.js +22 -9
  98. package/dist/client/signals-lifecycle-runtime.js +15 -0
  99. package/dist/client/signals-manifest-hydration-runtime.js +8 -1
  100. package/dist/client/signals-mount-runtime.js +16 -4
  101. package/dist/client/signals-public-api-runtime.js +1 -0
  102. package/dist/client/signals-scope-disposal-runtime.js +14 -0
  103. package/dist/client/signals-spa-load-runtime.js +2 -2
  104. package/dist/craft-entry.js +1 -1
  105. package/dist/craft.js +1 -1
  106. package/dist/includes.js +9 -0
  107. package/dist/pwa.js +3 -3
  108. package/dist/ssg.js +12 -12
  109. package/dist/utils.js +15 -0
  110. package/package.json +5 -5
  111. package/dist/chunk-02qt18vt.js +0 -2
  112. package/dist/chunk-0bc2f2qb.js +0 -2
  113. package/dist/chunk-20mme81e.js +0 -2
  114. package/dist/chunk-3ewa10ak.js +0 -2
  115. package/dist/chunk-3msbc4zj.js +0 -2
  116. package/dist/chunk-3q3gsr7m.js +0 -2
  117. package/dist/chunk-3qe83ymq.js +0 -2
  118. package/dist/chunk-49n9hrb1.js +0 -2
  119. package/dist/chunk-4gge63vp.js +0 -2
  120. package/dist/chunk-6bn5t1cc.js +0 -2
  121. package/dist/chunk-edz1h5f9.js +0 -2
  122. package/dist/chunk-evqwz50x.js +0 -2
  123. package/dist/chunk-fw8mf9xd.js +0 -2
  124. package/dist/chunk-hg4y1p7w.js +0 -2
  125. package/dist/chunk-j3472s37.js +0 -3
  126. package/dist/chunk-js23p89e.js +0 -2
  127. package/dist/chunk-jw0q2f5e.js +0 -49
  128. package/dist/chunk-jzejh7ch.js +0 -2
  129. package/dist/chunk-ktk8zm60.js +0 -2
  130. package/dist/chunk-m2vpa496.js +0 -2
  131. package/dist/chunk-qszk2tcw.js +0 -2
  132. package/dist/chunk-r95kmjj1.js +0 -2
  133. package/dist/chunk-vstv3ncc.js +0 -2
  134. package/dist/chunk-wv541wm9.js +0 -2
  135. package/dist/chunk-x5v00zg4.js +0 -2
  136. package/dist/chunk-zrqremja.js +0 -2
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Zt,Gs,Ks,Xs,sp,Js}from"./chunk-0mr9wx5c.js";import"./chunk-04kg16qs.js";import"./chunk-qrt8b179.js";import"./chunk-2h8ea0we.js";export{Ks as buildServerApi,sp as createServerApi,Zt as discoverServerApi,Gs as generateApiTypes,Js as isServerApiSource,Xs as productionApiDispatcher};
2
+ import{Zt,Gs,Ks,Xs,sp,Js}from"./chunk-cjj9b9wf.js";import"./chunk-04kg16qs.js";import"./chunk-zaaeneq6.js";import"./chunk-2h8ea0we.js";export{Ks as buildServerApi,sp as createServerApi,Zt as discoverServerApi,Gs as generateApiTypes,Js as isServerApiSource,Xs as productionApiDispatcher};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{l,d,Qa,u,t,a}from"./chunk-4e0z858k.js";import{Ge,ht,tn,lo}from"./chunk-wh838rdh.js";function L(w,e){try{let h=w.trim();if(d(h))return u(h,Object.keys(e))(...Object.values(e));else return l(h,e)}catch{return!1}}function Q(w,e,h){let n=w,v=!0;while(v){v=!1;let p=n.match(/@switch\s*\(/);if(!p||p.index===void 0)break;let b=p.index,s=lo(n,b);if(!s)break;try{let o;if(d(s.expression))o=u(s.expression,Object.keys(e))(...Object.values(e));else o=l(s.expression,e);let r="",g=!1;for(let i of s.cases)if(i.type==="default"){if(!g)r=i.content.trim()}else try{let y;if(i.value&&d(i.value))y=u(i.value,Object.keys(e))(...Object.values(e));else if(i.value)y=l(i.value,e);if(o===y){r=i.content.trim(),g=!0;break}}catch{continue}n=n.substring(0,b)+r+n.substring(s.end),v=!0}catch(o){let r=o instanceof Error?o.message:String(o),g=a("Switch",`Error evaluating @switch expression: ${r}`,t.EVALUATION_ERROR);n=n.substring(0,b)+g+n.substring(s.end);break}}return n}function H(w){let e=[];return{masked:w.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(n)=>(e.push(n),`\x00stx-script-${e.length-1}\x00`)),scripts:e}}function J(w,e){if(e.length===0)return w;return w.replace(/\u0000stx-script-(\d+)\u0000/g,(h,n)=>e[Number(n)]??h)}function ee(w,e,h){let{masked:n,scripts:v}=H(w);return J(K(n,e,h),v)}function K(w,e,h){let n=w;n=Q(n,e,h);{let p=!0;while(p){p=!1;let b=n.match(/@unless\s*\(/);if(!b||b.index===void 0)break;let s=b.index,o=Ge(n,s+7);if(!o)break;let r=o.endPos,g=ht(n,"unless","endunless",r);if(g===-1){console.warn(`[stx] @unless directive at position ${s} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let i=n.slice(r,g),y=o.expression,m=-1;{let x=0,k=/@(?:if|unless)\s*\(/g,f=/@(?:endif|endunless)(?![a-z])/g,E=/@else(?![a-z])/g,S=[],C;while((C=k.exec(i))!==null)S.push({pos:C.index,type:"open"});while((C=f.exec(i))!==null)S.push({pos:C.index,type:"close"});while((C=E.exec(i))!==null)S.push({pos:C.index,type:"else"});S.sort((P,R)=>P.pos-R.pos);for(let P of S)if(P.type==="open")x++;else if(P.type==="close")x--;else if(P.type==="else"&&x===0){m=P.pos;break}}let c;if(m!==-1){let x=i.slice(0,m),k=i.slice(m+5);c=`@if (${y})${k}@else ${x}@endif`}else c=`@if (!(${y}))${i}@endif`;n=n.substring(0,s)+c+n.substring(g+10),p=!0}}n=ro(n,e,h),n=so(n,e,h),n=no(n,e);let v=()=>{let p=tn(n);if(p.length===0)return!1;let b=Array(p.length);for(let r=p.length-1;r>=0;r--){let g=p[r];try{let i="",y=!1;for(let m of g.branches){if(y)break;if(m.type==="else")i=m.content,y=!0;else try{if(m.condition?Qa(m.condition,e):!1)i=m.content,y=!0}catch(c){i=a(m.type==="if"?"If":"Elseif",`Error in @${m.type}(${m.condition}): ${c instanceof Error?c.message:String(c)}`,t.EVALUATION_ERROR),y=!0}}b[r]=i}catch(i){let y=i instanceof Error?i.message:String(i);b[r]=a("If",`Error processing @if block: ${y}`,t.EVALUATION_ERROR)}}let s=Array(p.length*2+1),o=0;for(let r=0;r<p.length;r++){let g=p[r];s[r*2]=n.slice(o,g.start),s[r*2+1]=b[r],o=g.end}return s[p.length*2]=n.slice(o),n=s.join(""),!0};while(!0){let p=n;if(!v())break;if(n===p)break}return n}function q(w){let e=0;while(e<w.length&&/\s/.test(w[e]))e++;if(w[e]!=="(")return null;e++;while(e<w.length&&/\s/.test(w[e]))e++;let h=w[e];if(h!=="'"&&h!=='"')return null;e++;let n=[];while(e<w.length){let v=w[e];if(v==="\\"&&e+1<w.length){n.push(w[e+1]),e+=2;continue}if(v===h){e++;break}n.push(v),e++}while(e<w.length&&/\s/.test(w[e]))e++;if(w[e]!==")")return null;return e++,{value:n.join(""),consumed:e}}function no(w,e){let h=w;function n(s,o,r,g){let i=1,y=g,m=new RegExp(`@${o}(?:\\s*\\(|\\s|$)`,"g"),c=new RegExp(`@${r}(?![a-z])`,"g");while(y<s.length&&i>0){m.lastIndex=y,c.lastIndex=y;let x=m.exec(s),k=c.exec(s),f=x?x.index:1/0,E=k?k.index:1/0;if(f<E)i++,y=f+x[0].length;else if(E<1/0){if(i--,i===0)return E;y=E+k[0].length}else break}return-1}function v(s,o,r){let g=0,i=new RegExp(`@${o}(?:\\s*\\(|\\s|$)`,"g"),y=new RegExp(`@${r}(?![a-z])`,"g"),m=/@else(?![a-z])/g,c=[],x;while((x=i.exec(s))!==null)c.push({pos:x.index,type:"open"});while((x=y.exec(s))!==null)c.push({pos:x.index,type:"close"});while((x=m.exec(s))!==null)c.push({pos:x.index,type:"else"});c.sort((k,f)=>k.pos-f.pos);for(let k of c)if(k.type==="open")g++;else if(k.type==="close")g--;else if(k.type==="else"&&g===0)return k.pos;return-1}{let s=!0;while(s){s=!1;let o=h.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!o||o.index===void 0)break;let r=o.index,g,i,y=h.slice(r+5),m=q(y);if(m)g=m.value,i=r+5+m.consumed;else i=r+5;let c=n(h,"auth","endauth",i);if(c===-1){console.warn(`[stx] @auth directive at position ${r} has no matching @endauth \u2014 the block was skipped.`);break}let x=h.slice(i,c),k=v(x,"auth","endauth"),f;if(!e.auth)f=!1;else f=g?L(`auth?.check && auth?.user?.[${g}]`,e):L("auth?.check",e);let E;if(k!==-1){let S=x.slice(0,k),C=x.slice(k+5);E=f?S:C}else E=f?x:"";h=h.substring(0,r)+E+h.substring(c+8),s=!0}}{let s=!0;while(s){s=!1;let o=h.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!o||o.index===void 0)break;let r=o.index,g,i,y=h.slice(r+6),m=q(y);if(m)g=m.value,i=r+6+m.consumed;else i=r+6;let c=n(h,"guest","endguest",i);if(c===-1){console.warn(`[stx] @guest directive at position ${r} has no matching @endguest \u2014 the block was skipped.`);break}let x=h.slice(i,c),k=v(x,"guest","endguest"),f;if(!e.auth)f=!0;else f=g?L(`!auth?.check || !auth?.user?.[${g}]`,e):L("!auth?.check",e);let E;if(k!==-1){let S=x.slice(0,k),C=x.slice(k+5);E=f?S:C}else E=f?x:"";h=h.substring(0,r)+E+h.substring(c+9),s=!0}}function p(s,o,r){if(e.userCan&&typeof e.userCan[s]==="boolean")return e.userCan[s];if(e.permissions?.check&&typeof e.permissions.check==="function")try{let g=[s];if(o)g.push(o);if(r){let i=L(r,e);g.push(i)}return e.permissions.check(...g)}catch{return!1}return!1}function b(s){let o=s.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!o)return null;return{ability:o[1],type:o[2],id:o[3]?.trim(),paramsEnd:o[0].length}}for(let s of["can","cannot"]){let o=`end${s}`,r=s==="can"?"elsecan":"elsecannot",g=!0;while(g){g=!1;let i=h.match(new RegExp(`@${s}\\s*\\(`));if(!i||i.index===void 0)break;let y=i.index,m=h.slice(y+`@${s}`.length),c=b(m);if(!c)break;let x=y+`@${s}`.length+c.paramsEnd,k=n(h,s,o,x);if(k===-1){console.warn(`[stx] @${s} directive at position ${y} has no matching @${o} \u2014 the block was skipped.`);break}let f=h.slice(x,k),E=[],S=0,C=new RegExp(`@${s}\\s*\\(`,"g"),P=new RegExp(`@${o}(?![a-z])`,"g"),R=new RegExp(`@${r}\\s*\\(`,"g"),T=/@else(?![a-z])/g,_=[],M;while((M=C.exec(f))!==null)_.push({pos:M.index,type:"open"});while((M=P.exec(f))!==null)_.push({pos:M.index,type:"close"});while((M=R.exec(f))!==null)_.push({pos:M.index,type:"elseDirective"});while((M=T.exec(f))!==null)_.push({pos:M.index,type:"else"});_.sort((A,z)=>A.pos-z.pos);for(let A of _){if(A.type==="open"){S++;continue}if(A.type==="close"){S--;continue}if(S===0)E.push(A)}let I=[],F=0;for(let A=0;A<E.length;A++){let z=E[A];if(I.push({content:f.slice(F,z.pos),ability:void 0}),z.type==="elseDirective"){let D=f.slice(z.pos+`@${r}`.length),B=b(D);if(B){I[I.length-1]={content:f.slice(F,z.pos)},F=z.pos+`@${r}`.length+B.paramsEnd,I.push({content:"",ability:B.ability,type:B.type,id:B.id}),I.pop();let G=E[A+1],U=G?G.pos:f.length;I.push({content:f.slice(F,U),ability:B.ability,type:B.type,id:B.id}),F=U}}else F=z.pos+5}if(F<f.length){let A=I[I.length-1];if(E.length>0&&E[E.length-1].type==="else")I.push({content:f.slice(F),isFinalElse:!0});else if(I.length===0)I.push({content:f.slice(F)})}let O=p(c.ability,c.type,c.id),j=s==="can"?O:!O,V="";if(j)V=I[0]?.content||"";else{let A=!1;for(let z=1;z<I.length;z++){let D=I[z];if(D.isFinalElse){V=D.content,A=!0;break}if(D.ability){let B=p(D.ability,D.type,D.id);if(s==="can"?B:!B){V=D.content,A=!0;break}}}if(!A&&I.length>0){let z=I[I.length-1];if(z.isFinalElse)V=z.content}}h=h.substring(0,y)+V+h.substring(k+`@${o}`.length),g=!0}}return h}function ro(w,e,h){let n=w;function v(p,b,s,o,r){let g=!0;while(g){g=!1;let i=new RegExp(`@${b}\\s*\\(`),y=p.match(i);if(!y||y.index===void 0)break;let m=y.index,c=Ge(p,m+`@${b}`.length);if(!c)break;let x=c.endPos,k=ht(p,b,s,x);if(k===-1){console.warn(`[stx] @${b} directive at position ${m} has no matching @${s} \u2014 the block was skipped.`);break}let f=p.slice(x,k),E=c.expression,S=-1,C=0,P=0;while(P<f.length){let R=f.indexOf("@",P);if(R===-1)break;let T=f.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(T)){C++,P=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(T)){C--,P=R+1;continue}if(C===0&&/^@else(?![a-z])/.test(T)){S=R;break}P=R+1}try{let R=o(E.trim()),T;if(S!==-1){let _=f.slice(0,S),M=f.slice(S+5);T=R?_:M}else T=R?f:"";p=p.substring(0,m)+T+p.substring(k+`@${s}`.length),g=!0}catch(R){let T=R instanceof Error?R.message:String(R),_=a(r,`Error processing @${b} directive: ${T}`,t.EVALUATION_ERROR);p=p.substring(0,m)+_+p.substring(k+`@${s}`.length);break}}return p}return n=v(n,"isset","endisset",(p)=>{let b=L(p,e);return b!==void 0&&b!==null},"Isset"),n=v(n,"empty","endempty",(p)=>{let b=L(p,e);return b===void 0||b===null||b===""||b===0||b===!1||Array.isArray(b)&&b.length===0||typeof b==="object"&&b!==null&&Object.keys(b).length===0},"Empty"),n}function so(w,e,h){let n=w,v="development";function p(b,s,o,r){let g=new RegExp(`@${s}(?![a-z])`,"g"),i=new RegExp(`@${o}(?![a-z])`,"g"),y=new RegExp(`^@${s}(?![a-z])`),m=new RegExp(`^@${o}(?![a-z])`),c=b,x=!0;while(x){x=!1,g.lastIndex=0;let k=g.exec(c);if(!k)break;let f=k.index,E=f+k[0].length;if(s==="env"){let O=c.substring(E).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!O)break;E+=O[0].length,r=v===O[2]}let S=1,C=E,P=-1;while(S>0&&C<c.length){g.lastIndex=C,i.lastIndex=C;let O=g.exec(c),j=i.exec(c),V=O?O.index:1/0,A=j?j.index:1/0;if(V<A)S++,C=V+O[0].length;else if(A<1/0){if(S--,S===0){P=A;break}C=A+j[0].length}else break}if(P===-1){console.warn(`[stx] @${s} directive at position ${f} has no matching @${o} \u2014 the block was skipped.`);break}let R=c.substring(E,P),T=-1,_=0,M=0;while(M<R.length){let O=R.indexOf("@",M);if(O===-1)break;let j=R.substring(O);if(y.test(j)){_++,M=O+1;continue}if(m.test(j)){_--,M=O+1;continue}if(_===0&&/^@else(?![a-z])/.test(j)){T=O;break}M=O+1}let I;if(T!==-1){let O=R.slice(0,T),j=R.slice(T+5);I=r?O:j}else I=r?R:"";let F=`@${o}`.length;c=c.substring(0,f)+I+c.substring(P+F),x=!0}return c}return n=p(n,"env","endenv",!1),n=p(n,"production","endproduction",v==="production"),n=p(n,"development","enddevelopment",v==="development"),n=p(n,"staging","endstaging",v==="staging"),n=p(n,"testing","endtesting",v==="testing"),n}
2
+ import{l,d,Qa,u,t,a}from"./chunk-hb08vrbb.js";import{Ge,ht,tn,lo}from"./chunk-8nryyqb5.js";function L(w,e){try{let h=w.trim();if(d(h))return u(h,Object.keys(e))(...Object.values(e));else return l(h,e)}catch{return!1}}function Q(w,e,h){let n=w,v=!0;while(v){v=!1;let p=n.match(/@switch\s*\(/);if(!p||p.index===void 0)break;let b=p.index,s=lo(n,b);if(!s)break;try{let o;if(d(s.expression))o=u(s.expression,Object.keys(e))(...Object.values(e));else o=l(s.expression,e);let r="",g=!1;for(let i of s.cases)if(i.type==="default"){if(!g)r=i.content.trim()}else try{let y;if(i.value&&d(i.value))y=u(i.value,Object.keys(e))(...Object.values(e));else if(i.value)y=l(i.value,e);if(o===y){r=i.content.trim(),g=!0;break}}catch{continue}n=n.substring(0,b)+r+n.substring(s.end),v=!0}catch(o){let r=o instanceof Error?o.message:String(o),g=a("Switch",`Error evaluating @switch expression: ${r}`,t.EVALUATION_ERROR);n=n.substring(0,b)+g+n.substring(s.end);break}}return n}function H(w){let e=[];return{masked:w.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(n)=>(e.push(n),`\x00stx-script-${e.length-1}\x00`)),scripts:e}}function J(w,e){if(e.length===0)return w;return w.replace(/\u0000stx-script-(\d+)\u0000/g,(h,n)=>e[Number(n)]??h)}function ee(w,e,h){let{masked:n,scripts:v}=H(w);return J(K(n,e,h),v)}function K(w,e,h){let n=w;n=Q(n,e,h);{let p=!0;while(p){p=!1;let b=n.match(/@unless\s*\(/);if(!b||b.index===void 0)break;let s=b.index,o=Ge(n,s+7);if(!o)break;let r=o.endPos,g=ht(n,"unless","endunless",r);if(g===-1){console.warn(`[stx] @unless directive at position ${s} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let i=n.slice(r,g),y=o.expression,m=-1;{let x=0,k=/@(?:if|unless)\s*\(/g,f=/@(?:endif|endunless)(?![a-z])/g,E=/@else(?![a-z])/g,S=[],C;while((C=k.exec(i))!==null)S.push({pos:C.index,type:"open"});while((C=f.exec(i))!==null)S.push({pos:C.index,type:"close"});while((C=E.exec(i))!==null)S.push({pos:C.index,type:"else"});S.sort((P,R)=>P.pos-R.pos);for(let P of S)if(P.type==="open")x++;else if(P.type==="close")x--;else if(P.type==="else"&&x===0){m=P.pos;break}}let c;if(m!==-1){let x=i.slice(0,m),k=i.slice(m+5);c=`@if (${y})${k}@else ${x}@endif`}else c=`@if (!(${y}))${i}@endif`;n=n.substring(0,s)+c+n.substring(g+10),p=!0}}n=ro(n,e,h),n=so(n,e,h),n=no(n,e);let v=()=>{let p=tn(n);if(p.length===0)return!1;let b=Array(p.length);for(let r=p.length-1;r>=0;r--){let g=p[r];try{let i="",y=!1;for(let m of g.branches){if(y)break;if(m.type==="else")i=m.content,y=!0;else try{if(m.condition?Qa(m.condition,e):!1)i=m.content,y=!0}catch(c){i=a(m.type==="if"?"If":"Elseif",`Error in @${m.type}(${m.condition}): ${c instanceof Error?c.message:String(c)}`,t.EVALUATION_ERROR),y=!0}}b[r]=i}catch(i){let y=i instanceof Error?i.message:String(i);b[r]=a("If",`Error processing @if block: ${y}`,t.EVALUATION_ERROR)}}let s=Array(p.length*2+1),o=0;for(let r=0;r<p.length;r++){let g=p[r];s[r*2]=n.slice(o,g.start),s[r*2+1]=b[r],o=g.end}return s[p.length*2]=n.slice(o),n=s.join(""),!0};while(!0){let p=n;if(!v())break;if(n===p)break}return n}function q(w){let e=0;while(e<w.length&&/\s/.test(w[e]))e++;if(w[e]!=="(")return null;e++;while(e<w.length&&/\s/.test(w[e]))e++;let h=w[e];if(h!=="'"&&h!=='"')return null;e++;let n=[];while(e<w.length){let v=w[e];if(v==="\\"&&e+1<w.length){n.push(w[e+1]),e+=2;continue}if(v===h){e++;break}n.push(v),e++}while(e<w.length&&/\s/.test(w[e]))e++;if(w[e]!==")")return null;return e++,{value:n.join(""),consumed:e}}function no(w,e){let h=w;function n(s,o,r,g){let i=1,y=g,m=new RegExp(`@${o}(?:\\s*\\(|\\s|$)`,"g"),c=new RegExp(`@${r}(?![a-z])`,"g");while(y<s.length&&i>0){m.lastIndex=y,c.lastIndex=y;let x=m.exec(s),k=c.exec(s),f=x?x.index:1/0,E=k?k.index:1/0;if(f<E)i++,y=f+x[0].length;else if(E<1/0){if(i--,i===0)return E;y=E+k[0].length}else break}return-1}function v(s,o,r){let g=0,i=new RegExp(`@${o}(?:\\s*\\(|\\s|$)`,"g"),y=new RegExp(`@${r}(?![a-z])`,"g"),m=/@else(?![a-z])/g,c=[],x;while((x=i.exec(s))!==null)c.push({pos:x.index,type:"open"});while((x=y.exec(s))!==null)c.push({pos:x.index,type:"close"});while((x=m.exec(s))!==null)c.push({pos:x.index,type:"else"});c.sort((k,f)=>k.pos-f.pos);for(let k of c)if(k.type==="open")g++;else if(k.type==="close")g--;else if(k.type==="else"&&g===0)return k.pos;return-1}{let s=!0;while(s){s=!1;let o=h.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!o||o.index===void 0)break;let r=o.index,g,i,y=h.slice(r+5),m=q(y);if(m)g=m.value,i=r+5+m.consumed;else i=r+5;let c=n(h,"auth","endauth",i);if(c===-1){console.warn(`[stx] @auth directive at position ${r} has no matching @endauth \u2014 the block was skipped.`);break}let x=h.slice(i,c),k=v(x,"auth","endauth"),f;if(!e.auth)f=!1;else f=g?L(`auth?.check && auth?.user?.[${g}]`,e):L("auth?.check",e);let E;if(k!==-1){let S=x.slice(0,k),C=x.slice(k+5);E=f?S:C}else E=f?x:"";h=h.substring(0,r)+E+h.substring(c+8),s=!0}}{let s=!0;while(s){s=!1;let o=h.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!o||o.index===void 0)break;let r=o.index,g,i,y=h.slice(r+6),m=q(y);if(m)g=m.value,i=r+6+m.consumed;else i=r+6;let c=n(h,"guest","endguest",i);if(c===-1){console.warn(`[stx] @guest directive at position ${r} has no matching @endguest \u2014 the block was skipped.`);break}let x=h.slice(i,c),k=v(x,"guest","endguest"),f;if(!e.auth)f=!0;else f=g?L(`!auth?.check || !auth?.user?.[${g}]`,e):L("!auth?.check",e);let E;if(k!==-1){let S=x.slice(0,k),C=x.slice(k+5);E=f?S:C}else E=f?x:"";h=h.substring(0,r)+E+h.substring(c+9),s=!0}}function p(s,o,r){if(e.userCan&&typeof e.userCan[s]==="boolean")return e.userCan[s];if(e.permissions?.check&&typeof e.permissions.check==="function")try{let g=[s];if(o)g.push(o);if(r){let i=L(r,e);g.push(i)}return e.permissions.check(...g)}catch{return!1}return!1}function b(s){let o=s.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!o)return null;return{ability:o[1],type:o[2],id:o[3]?.trim(),paramsEnd:o[0].length}}for(let s of["can","cannot"]){let o=`end${s}`,r=s==="can"?"elsecan":"elsecannot",g=!0;while(g){g=!1;let i=h.match(new RegExp(`@${s}\\s*\\(`));if(!i||i.index===void 0)break;let y=i.index,m=h.slice(y+`@${s}`.length),c=b(m);if(!c)break;let x=y+`@${s}`.length+c.paramsEnd,k=n(h,s,o,x);if(k===-1){console.warn(`[stx] @${s} directive at position ${y} has no matching @${o} \u2014 the block was skipped.`);break}let f=h.slice(x,k),E=[],S=0,C=new RegExp(`@${s}\\s*\\(`,"g"),P=new RegExp(`@${o}(?![a-z])`,"g"),R=new RegExp(`@${r}\\s*\\(`,"g"),T=/@else(?![a-z])/g,_=[],M;while((M=C.exec(f))!==null)_.push({pos:M.index,type:"open"});while((M=P.exec(f))!==null)_.push({pos:M.index,type:"close"});while((M=R.exec(f))!==null)_.push({pos:M.index,type:"elseDirective"});while((M=T.exec(f))!==null)_.push({pos:M.index,type:"else"});_.sort((A,z)=>A.pos-z.pos);for(let A of _){if(A.type==="open"){S++;continue}if(A.type==="close"){S--;continue}if(S===0)E.push(A)}let I=[],F=0;for(let A=0;A<E.length;A++){let z=E[A];if(I.push({content:f.slice(F,z.pos),ability:void 0}),z.type==="elseDirective"){let D=f.slice(z.pos+`@${r}`.length),B=b(D);if(B){I[I.length-1]={content:f.slice(F,z.pos)},F=z.pos+`@${r}`.length+B.paramsEnd,I.push({content:"",ability:B.ability,type:B.type,id:B.id}),I.pop();let G=E[A+1],U=G?G.pos:f.length;I.push({content:f.slice(F,U),ability:B.ability,type:B.type,id:B.id}),F=U}}else F=z.pos+5}if(F<f.length){let A=I[I.length-1];if(E.length>0&&E[E.length-1].type==="else")I.push({content:f.slice(F),isFinalElse:!0});else if(I.length===0)I.push({content:f.slice(F)})}let O=p(c.ability,c.type,c.id),j=s==="can"?O:!O,V="";if(j)V=I[0]?.content||"";else{let A=!1;for(let z=1;z<I.length;z++){let D=I[z];if(D.isFinalElse){V=D.content,A=!0;break}if(D.ability){let B=p(D.ability,D.type,D.id);if(s==="can"?B:!B){V=D.content,A=!0;break}}}if(!A&&I.length>0){let z=I[I.length-1];if(z.isFinalElse)V=z.content}}h=h.substring(0,y)+V+h.substring(k+`@${o}`.length),g=!0}}return h}function ro(w,e,h){let n=w;function v(p,b,s,o,r){let g=!0;while(g){g=!1;let i=new RegExp(`@${b}\\s*\\(`),y=p.match(i);if(!y||y.index===void 0)break;let m=y.index,c=Ge(p,m+`@${b}`.length);if(!c)break;let x=c.endPos,k=ht(p,b,s,x);if(k===-1){console.warn(`[stx] @${b} directive at position ${m} has no matching @${s} \u2014 the block was skipped.`);break}let f=p.slice(x,k),E=c.expression,S=-1,C=0,P=0;while(P<f.length){let R=f.indexOf("@",P);if(R===-1)break;let T=f.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(T)){C++,P=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(T)){C--,P=R+1;continue}if(C===0&&/^@else(?![a-z])/.test(T)){S=R;break}P=R+1}try{let R=o(E.trim()),T;if(S!==-1){let _=f.slice(0,S),M=f.slice(S+5);T=R?_:M}else T=R?f:"";p=p.substring(0,m)+T+p.substring(k+`@${s}`.length),g=!0}catch(R){let T=R instanceof Error?R.message:String(R),_=a(r,`Error processing @${b} directive: ${T}`,t.EVALUATION_ERROR);p=p.substring(0,m)+_+p.substring(k+`@${s}`.length);break}}return p}return n=v(n,"isset","endisset",(p)=>{let b=L(p,e);return b!==void 0&&b!==null},"Isset"),n=v(n,"empty","endempty",(p)=>{let b=L(p,e);return b===void 0||b===null||b===""||b===0||b===!1||Array.isArray(b)&&b.length===0||typeof b==="object"&&b!==null&&Object.keys(b).length===0},"Empty"),n}function so(w,e,h){let n=w,v="development";function p(b,s,o,r){let g=new RegExp(`@${s}(?![a-z])`,"g"),i=new RegExp(`@${o}(?![a-z])`,"g"),y=new RegExp(`^@${s}(?![a-z])`),m=new RegExp(`^@${o}(?![a-z])`),c=b,x=!0;while(x){x=!1,g.lastIndex=0;let k=g.exec(c);if(!k)break;let f=k.index,E=f+k[0].length;if(s==="env"){let O=c.substring(E).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!O)break;E+=O[0].length,r=v===O[2]}let S=1,C=E,P=-1;while(S>0&&C<c.length){g.lastIndex=C,i.lastIndex=C;let O=g.exec(c),j=i.exec(c),V=O?O.index:1/0,A=j?j.index:1/0;if(V<A)S++,C=V+O[0].length;else if(A<1/0){if(S--,S===0){P=A;break}C=A+j[0].length}else break}if(P===-1){console.warn(`[stx] @${s} directive at position ${f} has no matching @${o} \u2014 the block was skipped.`);break}let R=c.substring(E,P),T=-1,_=0,M=0;while(M<R.length){let O=R.indexOf("@",M);if(O===-1)break;let j=R.substring(O);if(y.test(j)){_++,M=O+1;continue}if(m.test(j)){_--,M=O+1;continue}if(_===0&&/^@else(?![a-z])/.test(j)){T=O;break}M=O+1}let I;if(T!==-1){let O=R.slice(0,T),j=R.slice(T+5);I=r?O:j}else I=r?R:"";let F=`@${o}`.length;c=c.substring(0,f)+I+c.substring(P+F),x=!0}return c}return n=p(n,"env","endenv",!1),n=p(n,"production","endproduction",v==="production"),n=p(n,"development","enddevelopment",v==="development"),n=p(n,"staging","endstaging",v==="staging"),n=p(n,"testing","endtesting",v==="testing"),n}
3
3
  export{ee,no,ro,so};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{lc,uc}from"./chunk-4qwvqbzf.js";import{j,ss,os,is,So,ko,sr,Ae,le,q,cs,ne,Tt,ue,Ze,ir,To,lr,Me,n,m,F,fn}from"./chunk-y4nhcrf1.js";import{d,E,et,u}from"./chunk-4e0z858k.js";import{ee}from"./chunk-8gewq710.js";import{o}from"./chunk-egg54kd0.js";import{p}from"./chunk-2a4szpje.js";import{createHash as St}from"crypto";import Y from"fs";import J from"path";import{decode as sn,generateThumbHash as on}from"ts-images";import{createImageDeliveryCatalog as ht}from"ts-images/delivery";import Be from"fs";function Se(e,t,r){let s=Buffer.alloc(r),i=Be.readSync(e,s,0,r,t);return s.subarray(0,i)}function Te(e){if(e.length<25)return!1;let t=(s,i)=>String.fromCharCode(...e.subarray(s,i));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let r=t(12,16);if(r==="VP8X")return(e[20]&16)!==0;if(r==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function De(e){let t;try{t=Be.openSync(e,"r");let r=Se(t,0,33);if(r.length>=3&&r[0]===255&&r[1]===216&&r[2]===255)return"none";if(r.length>=26&&r[0]===137&&r.toString("latin1",1,4)==="PNG"){let s=r[25];if(s===4||s===6)return"possible";let i=8;for(let a=0;a<64;a++){let c=Se(t,i,8);if(c.length<8)return"unknown";let f=c.toString("latin1",4,8);if(f==="tRNS")return"possible";if(f==="IDAT"||f==="IEND")return"none";i+=12+c.readUInt32BE(0)}return"unknown"}if(r.length>=25&&r.toString("latin1",0,4)==="RIFF"&&r.toString("latin1",8,12)==="WEBP"){if(Te(r))return"possible";let s=r.toString("latin1",12,16);return s==="VP8 "||s==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)Be.closeSync(t)}}import Jt from"fs";import Ce from"os";import{join as ft}from"path";import{fileURLToPath as dt}from"url";import{Worker as gt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Ce.availableParallelism==="function"?Ce.availableParallelism():Ce.cpus().length){return Math.max(1,Math.min(2,e-1))}var Re=0,pt=[];async function Qt(){if(Re<Yt()){Re++;return}await new Promise((e)=>pt.push(e)),Re++}function en(){Re--,pt.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let r=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(r.protocol==="file:"&&Jt.existsSync(dt(r)))return dt(r)}catch{}try{let r=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return r&&rn(r)?r:void 0}catch{return}}function rn(e,t=process.env){let r=e.replace(/\\/g,"/");if(r.split("/").some((i)=>/@\d[^/]*@@@\d+$/.test(i)))return!1;return![t.BUN_INSTALL_CACHE_DIR,ft(t.BUN_INSTALL||ft(Ce.homedir(),".bun"),"install","cache")].filter((i)=>!!i).map((i)=>`${i.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((i)=>r.startsWith(i))}var mt=!1;function me(e){if(!mt)mt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function je(e){return e instanceof Error?e.message:String(e)}async function Le(e,t){if(typeof gt!=="function")return me("node:worker_threads has no Worker in this runtime");let r=nn();if(!r)return me("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((s,i)=>{let a;try{a=new gt(r)}catch(h){s(me(`could not start ${r}: ${je(h)}`));return}let c=!1,f=!1,l=(h)=>{if(f)return;f=!0,h(),a.terminate()};a.on("message",(h)=>{if(h.type==="ready"){c=!0,a.postMessage({task:e,args:t});return}if(h.type==="result"){l(()=>s(h.value));return}let v=Error(h.error?.message??"image worker failed");if(h.error?.name)v.name=h.error.name;if(h.error?.stack)v.stack=h.error.stack;l(()=>i(v))}),a.on("error",(h)=>{l(()=>c?i(h instanceof Error?h:Error(je(h)||"image worker crashed")):s(me(`the worker failed before it was ready: ${je(h)}`)))}),a.on("exit",(h)=>{l(()=>c?i(Error("image worker exited before it finished")):s(me(`the worker exited with code ${h} before it was ready`)))})})}finally{en()}}var an=new Set([".avif",".jpeg",".jpg",".png",".webp"]),cn=[320,640,960,1280,1920],pe="/_stx/images",ln=`stx:${pe}:alpha-1`,un=`stx:${pe}:opaque-1`,dn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function gn(e,t){let r=J.dirname(Bun.resolveSync(e,t));while(r!==J.dirname(r)){let s=J.join(r,"package.json");if(Y.existsSync(s)){let i=JSON.parse(Y.readFileSync(s,"utf8"));if(i.name===e)return i.version}r=J.dirname(r)}return}function yt(){if(Pe!==void 0)return Pe;let e;try{e=J.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=dn.map((t)=>{let r;try{r=e?gn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${r??"unknown"}`}).join("+"),Pe}var xt=Symbol.for("stx.image-delivery");function he(){let e=globalThis;return e[xt]??={catalog:new Map,transparent:new Set},e[xt]}var bt=new Set;function mn(e){return`/${e.split(J.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=J.extname(e),r=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),s=St("sha256").update(e).digest("hex").slice(0,8);return`${r||"image"}-${s}`}function vt(e,t=`stx:${pe}`){let r=(s)=>`${pe}/${s.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(s){let i=J.join(e,s);try{let a=await Y.promises.stat(i);return a.size>0?{bytes:a.size,path:i,url:r(s)}:null}catch{return null}},async write(s,i){let a=J.join(e,s);await Y.promises.mkdir(J.dirname(a),{recursive:!0});let c=`${a}.${process.pid}.tmp`;return await Y.promises.writeFile(c,i),await Y.promises.rename(c,a),{bytes:i.byteLength,path:a,url:r(s)}},url:r}}async function Ct(e,t=e){let r=await Y.promises.readdir(t,{withFileTypes:!0});r.sort((i,a)=>i.name.localeCompare(a.name));let s=[];for(let i of r){let a=J.join(t,i.name);if(i.isDirectory()){s.push(...await Ct(e,a));continue}if(!i.isFile()||!an.has(J.extname(i.name).toLowerCase()))continue;s.push({absolutePath:a,relativePath:J.relative(e,a)})}return s}function wt(e,t){return e.map((r)=>({key:mn(r.relativePath),input:r.absolutePath,name:pn(r.relativePath),...hn(r.absolutePath)?{options:{storage:t}}:{}}))}function hn(e){return De(e)==="possible"}function yn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,i])=>i.fallback.format==="png"),r=new Set,s=8;for(let i=0;i<t.length;i+=8)await Promise.all(t.slice(i,i+8).map(async([a,c])=>{let f=c.variants.filter((l)=>l.format==="png").sort((l,h)=>l.width-h.width)[0];try{let l=await sn(new Uint8Array(await Y.promises.readFile(f?.path??c.fallback.path)));if(yn(l.data))r.add(a)}catch{r.add(a)}}));return r}function bn(e,t){let r=[];for(let s of t){let i=e[s],a=i?.variants.filter((f)=>f.format==="webp")??[];if(!i||a.length===0)continue;if(!a.some((f)=>{let l;try{return l=Y.openSync(f.path,"r"),!Te(Se(l,0,32))}catch{return!0}finally{if(l!==void 0)Y.closeSync(l)}}))continue;if(i.variants=i.variants.filter((f)=>f.format!=="webp"),delete i.sources.webp,r.push(s),!bt.has(s))bt.add(s),console.warn(`[stx-images] ${s} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return r}async function vn(e){let t=[],r=8;for(let s=0;s<e.length;s+=8){let i=e.slice(s,s+8),a=await Promise.all(i.map(async(c)=>{try{return await on(c.absolutePath),c}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${c.relativePath}`),null}}));t.push(...a.filter((c)=>c!==null))}return t}function ze(e){return J.join(e,"undecodable.json")}function wn(e){try{let t=Y.readFileSync(ze(e),"utf-8"),r=JSON.parse(t);return r&&typeof r==="object"?r:{}}catch{return{}}}function $n(e,t){try{Y.mkdirSync(J.dirname(ze(e)),{recursive:!0}),Y.writeFileSync(ze(e),JSON.stringify(t))}catch{}}function $t(e){try{let t=Y.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function Rt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Qs(e){let t=Rt(e);return t?he().catalog.get(t):void 0}function eo(e){let t=Rt(e);return t?he().transparent.has(t):!1}function to(e){let t=(s)=>e.variants.filter((i)=>i.format===s).reduce((i,a)=>i+a.bytes,0),r=t(e.fallback.format);return["avif","webp"].map((s)=>({format:s,srcset:e.sources[s]||"",bytes:t(s)})).filter((s)=>s.srcset&&s.bytes>0&&s.bytes<r).sort((s,i)=>s.bytes-i.bytes).map(({format:s,srcset:i})=>({format:s,srcset:i}))}function dp(e){let t=Qs(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:to(t).map(({format:r,srcset:s})=>({type:`image/${r}`,srcset:s})),width:t.source.width,height:t.source.height,placeholder:eo(e)?void 0:t.placeholder?.dataUrl}}function jr(){let e=he();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=he();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function pp(e,t,r={}){if(!e||!Y.existsSync(e))return jr(),{count:0,fingerprint:""};if(r.offThread){let g=await Le("delivery",{publicDir:e,outputDir:t});if(g!==ke)return Sn(g.state),g.result}let s=await Ct(e);if(s.length===0)return jr(),{count:0,fingerprint:""};let i=wn(t),a=s.filter((g)=>{let b=i[g.relativePath];if(!b)return!0;let w=$t(g.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(a.length===0)return jr(),{count:0,fingerprint:""};let c=vt(J.join(t,"_stx","images"),`${ln}:${yt()}`),f={outDir:J.join(t,"_stx","images"),storage:vt(J.join(t,"_stx","images"),`${un}:${yt()}`),baseUrl:pe,widths:cn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},l=a,h;try{h=await ht({...f,entries:wt(a,c)})}catch(g){if(l=await vn(a),l.length===a.length)throw g;let b=new Set(l.map((C)=>C.relativePath)),w=!1;for(let C of a){if(b.has(C.relativePath))continue;let k=$t(C.absolutePath);if(!k)continue;i[C.relativePath]=k,w=!0}if(w)$n(t,i);if(l.length===0)return jr(),{count:0,fingerprint:""};h=await ht({...f,entries:wt(l,c)})}let v=await xn(h.entries),y=bn(h.entries,v),S=he();S.catalog=new Map(Object.entries(h.entries)),S.transparent=v;let x=v.size===0&&y.length===0?h.fingerprint:St("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:y.sort()})).digest("hex");return{count:l.length,fingerprint:x}}class At{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,r,s){let i=So(e,s);if(i!==void 0)return i;for(let a of ko(e,t,r,s))if(await n(a))return a;return null}}var ae=new At;function R(e){return F(e)}var re="\x00stx-boolean-attribute";function Ue(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function We(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Cn.has(t)}function se(e,t){let r=[];for(let[s,i]of Object.entries(e.static)){if(t.has(s))continue;let a=e.staticNames?.[s]??s;if(typeof i==="boolean"){if(i)r.push(m(a));continue}if(i===re){r.push(m(a));continue}r.push(`${m(a)}="${fn(a,Ue(String(i)))}"`)}return r}function ie(e,t){let r=[];for(let[s,i]of Object.entries(e.serverDynamic??{})){if(t.has(s))continue;if(i===null||i===void 0||i===!1)continue;let a=e.serverDynamicNames?.[s]??s;if(i===!0){r.push(m(a));continue}if(typeof i==="object")continue;r.push(`${m(a)}="${fn(a,Ue(String(i)))}"`)}return r}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Fe={name:"StxLink",aliases:["stx-link"],render(e,t,r){let s=Rn(e),i=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),a=typeof e.static.activeClass==="string"?e.static.activeClass:"active",c=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",f=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,l=[];if(s.reactive)l.push(`:href="${R(s.value)}"`);else l.push(`href="${R(sr(s.value,"navigable"))}"`);if(i)l.push(`class="${R(i)}"`);if(l.push("data-stx-link"),l.push(`data-stx-active-class="${R(a)}"`),l.push(`data-stx-exact-active-class="${R(c)}"`),f)l.push("data-stx-prefetch");let h=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(h)l.push(`data-stx-active-match="${R(h)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return l.push(...se(e,v)),l.push(...ie(e,v)),`<a ${l.join(" ")}>${t}</a>`}};var An=new Map;function He(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return An.get(t)}var kn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},qe=[320,640,768,1024,1280,1536,1920];function G(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let r=e.static[t];if(typeof r==="string")return r;return}function _e(e,t,r=!1){let s=e.serverDynamic[t];if(s!==void 0)return s!==!1&&s!=="false";let i=e.static[t];if(i!==void 0)return i!=="false"&&i!==!1;return r}function Xe(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),r=[];for(let s of t)if(s.includes(":")){let[i,a]=s.split(":"),c=kn[i];if(c)r.push(`(max-width: ${c}px) ${a}`);else{let f=Number.parseInt(i);if(!Number.isNaN(f))r.push(`(max-width: ${f}px) ${a}`)}}else r.push(s);return r.join(", ")}function Ve(e,t,r,s){return t.map((i)=>`${ye(e,i,void 0,r,s)} ${i}w`).join(", ")}function Pn(e,t,r,s,i){return t.map((a)=>{let c=r?r*a:void 0;return`${ye(e,c,void 0,s,i)} ${a}x`}).join(", ")}function ye(e,t,r,s,i){if(!s||s==="local"||s==="static")return e;if(s==="cloudinary"){let a=[];if(t)a.push(`w_${t}`);if(r)a.push(`h_${r}`);if(i)a.push(`f_${i}`);a.push("q_auto");let c=a.join(",");return e.replace("/upload/",`/upload/${c}/`)}if(s==="imgix"){let a=new URLSearchParams;if(t)a.set("w",String(t));if(r)a.set("h",String(r));if(i)a.set("fm",i);a.set("auto","format");let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}if(s==="bunny"){let a=new URLSearchParams;if(t)a.set("width",String(t));if(r)a.set("height",String(r));if(i)a.set("format",i);let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function In(e,t,r="#e5e7eb"){let s=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${r}"/></svg>`;return`data:image/svg+xml;base64,${btoa(s)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,r){let s=G(e,"src")||"",i=Qs(s),a=G(e,"alt")||"",c=G(e,"width")||(i?String(i.source.width):void 0),f=G(e,"height")||(i?String(i.source.height):void 0),l=G(e,"sizes"),h=G(e,"srcset"),v=G(e,"densities"),y=G(e,"format"),S=eo(s)||He(s)?.transparent===!0,x=G(e,"placeholder")||(i&&!S?"thumbhash":void 0),g=G(e,"placeholderColor")||"#e5e7eb",b=G(e,"provider"),w=G(e,"class")||G(e,"className")||"",C=G(e,"style")||"",k=G(e,"objectFit")||G(e,"fit"),A=G(e,"objectPosition")||G(e,"position"),I=G(e,"quality"),U=_e(e,"lazy",!0),M=_e(e,"preload",!1),L=_e(e,"priority",!1),X=G(e,"loading"),N=G(e,"decoding")||"async",_=!!i||_e(e,"picture",!1)||!!y,O=c?Number.parseInt(c):void 0,B=f?Number.parseInt(f):void 0,z=h||"",V="";if(i)z=i.sources[i.fallback.format]||"",V=l?Xe(l):"100vw";else if(!z&&l&&b&&b!=="local"&&b!=="static")z=Ve(s,qe,b,y),V=Xe(l);else if(!z&&v){let P=v.split(/\s+/).map((H)=>Number.parseFloat(H.replace("x","")));z=Pn(s,P,O,b,y)}else if(l)V=Xe(l);let D=[];if(C)D.push(C);if(k)D.push(`object-fit:${k}`);if(A)D.push(`object-position:${A}`);if(O&&B)D.push(`aspect-ratio:${O}/${B}`);let W=[],oe=x==="blur"||x==="color"||x==="thumbhash";if(oe&&!S){let P=i?.placeholder?{dataUrl:i.placeholder.dataUrl,color:g}:He(s);if(P&&x==="color")D.push(`background-color:${P.color}`),W.push("backgroundColor");else if(P)D.push(`background-color:${P.color}`),D.push(`background-image:url(${P.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundColor","backgroundImage");else{let H=In(O||16,B||9,g);D.push(`background-image:url(${H})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!oe&&x&&x!=="empty"&&x!=="none")D.push(`background-image:url(${R(x)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage");let ve=i?.fallback.url||ye(s,O,B,b,y),K=[];if(K.push(`src="${R(sr(ve,"fetched"))}"`),K.push(`alt="${R(a)}"`),c)K.push(`width="${R(c)}"`);if(f)K.push(`height="${R(f)}"`);let te=X||(L||M?"eager":U?"lazy":"");if(te)K.push(`loading="${R(te)}"`);if(L)K.push('fetchpriority="high"');if(K.push(`decoding="${R(N)}"`),w)K.push(`class="${R(w)}"`);if(D.length>0)K.push(`style="${R(D.join(";"))}"`);if(z)K.push(`srcset="${R(sr(z,"fetched"))}"`);if(V)K.push(`sizes="${R(V)}"`);let we=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(W.length>0){let P=typeof e.static.onload==="string"?e.static.onload:"",H=_n(W)+(P?`;${P}`:"");K.push(`onload="${R(H)}"`),we.add("onload")}K.push(...se(e,we)),K.push(...ie(e,we));let T=`<img ${K.join(" ")} />`,Z="";if(M){let H=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${R(ve)}"${H?` type="${H}"`:""}${z?` imagesrcset="${R(z)}"`:""}${V?` imagesizes="${R(V)}"`:""} />
2
+ import{lc,uc}from"./chunk-7rta163c.js";import{j,ss,os,is,So,ko,sr,Ae,le,q,cs,ne,Tt,ue,Ze,ir,To,lr,Me,n,m,F,fn}from"./chunk-hzjvpcmj.js";import{d,E,et,u}from"./chunk-hb08vrbb.js";import{ee}from"./chunk-r7kmsq3n.js";import{o}from"./chunk-egg54kd0.js";import{p}from"./chunk-2a4szpje.js";import{createHash as St}from"crypto";import Y from"fs";import J from"path";import{decode as sn,generateThumbHash as on}from"ts-images";import{createImageDeliveryCatalog as ht}from"ts-images/delivery";import Be from"fs";function Se(e,t,r){let s=Buffer.alloc(r),i=Be.readSync(e,s,0,r,t);return s.subarray(0,i)}function Te(e){if(e.length<25)return!1;let t=(s,i)=>String.fromCharCode(...e.subarray(s,i));if(t(0,4)!=="RIFF"||t(8,12)!=="WEBP")return!1;let r=t(12,16);if(r==="VP8X")return(e[20]&16)!==0;if(r==="VP8L")return((e[21]|e[22]<<8|e[23]<<16|e[24]<<24)>>>28&1)===1;return!1}function De(e){let t;try{t=Be.openSync(e,"r");let r=Se(t,0,33);if(r.length>=3&&r[0]===255&&r[1]===216&&r[2]===255)return"none";if(r.length>=26&&r[0]===137&&r.toString("latin1",1,4)==="PNG"){let s=r[25];if(s===4||s===6)return"possible";let i=8;for(let a=0;a<64;a++){let c=Se(t,i,8);if(c.length<8)return"unknown";let f=c.toString("latin1",4,8);if(f==="tRNS")return"possible";if(f==="IDAT"||f==="IEND")return"none";i+=12+c.readUInt32BE(0)}return"unknown"}if(r.length>=25&&r.toString("latin1",0,4)==="RIFF"&&r.toString("latin1",8,12)==="WEBP"){if(Te(r))return"possible";let s=r.toString("latin1",12,16);return s==="VP8 "||s==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(t!==void 0)Be.closeSync(t)}}import Jt from"fs";import Ce from"os";import{join as ft}from"path";import{fileURLToPath as dt}from"url";import{Worker as gt}from"worker_threads";var ke=Symbol("stx.image-worker.unavailable");function Yt(e=typeof Ce.availableParallelism==="function"?Ce.availableParallelism():Ce.cpus().length){return Math.max(1,Math.min(2,e-1))}var Re=0,pt=[];async function Qt(){if(Re<Yt()){Re++;return}await new Promise((e)=>pt.push(e)),Re++}function en(){Re--,pt.shift()?.()}var tn="@stacksjs/stx/builtins/image-warmup-worker";function nn(e=process.cwd()){let t=import.meta.url.endsWith(".ts")?"ts":"js";try{let r=new URL(`./image-warmup-worker.${t}`,import.meta.url);if(r.protocol==="file:"&&Jt.existsSync(dt(r)))return dt(r)}catch{}try{let r=typeof Bun<"u"?Bun.resolveSync(tn,e):void 0;return r&&rn(r)?r:void 0}catch{return}}function rn(e,t=process.env){let r=e.replace(/\\/g,"/");if(r.split("/").some((i)=>/@\d[^/]*@@@\d+$/.test(i)))return!1;return![t.BUN_INSTALL_CACHE_DIR,ft(t.BUN_INSTALL||ft(Ce.homedir(),".bun"),"install","cache")].filter((i)=>!!i).map((i)=>`${i.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((i)=>r.startsWith(i))}var mt=!1;function me(e){if(!mt)mt=!0,console.warn(`[stx] image worker unavailable (${e}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return ke}function je(e){return e instanceof Error?e.message:String(e)}async function Le(e,t){if(typeof gt!=="function")return me("node:worker_threads has no Worker in this runtime");let r=nn();if(!r)return me("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Qt();try{return await new Promise((s,i)=>{let a;try{a=new gt(r)}catch(h){s(me(`could not start ${r}: ${je(h)}`));return}let c=!1,f=!1,l=(h)=>{if(f)return;f=!0,h(),a.terminate()};a.on("message",(h)=>{if(h.type==="ready"){c=!0,a.postMessage({task:e,args:t});return}if(h.type==="result"){l(()=>s(h.value));return}let v=Error(h.error?.message??"image worker failed");if(h.error?.name)v.name=h.error.name;if(h.error?.stack)v.stack=h.error.stack;l(()=>i(v))}),a.on("error",(h)=>{l(()=>c?i(h instanceof Error?h:Error(je(h)||"image worker crashed")):s(me(`the worker failed before it was ready: ${je(h)}`)))}),a.on("exit",(h)=>{l(()=>c?i(Error("image worker exited before it finished")):s(me(`the worker exited with code ${h} before it was ready`)))})})}finally{en()}}var an=new Set([".avif",".jpeg",".jpg",".png",".webp"]),cn=[320,640,960,1280,1920],pe="/_stx/images",ln=`stx:${pe}:alpha-1`,un=`stx:${pe}:opaque-1`,dn=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],Pe;function gn(e,t){let r=J.dirname(Bun.resolveSync(e,t));while(r!==J.dirname(r)){let s=J.join(r,"package.json");if(Y.existsSync(s)){let i=JSON.parse(Y.readFileSync(s,"utf8"));if(i.name===e)return i.version}r=J.dirname(r)}return}function yt(){if(Pe!==void 0)return Pe;let e;try{e=J.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return Pe=dn.map((t)=>{let r;try{r=e?gn(t,e):void 0}catch{}return`${t.replace("@stacksjs/","")}@${r??"unknown"}`}).join("+"),Pe}var xt=Symbol.for("stx.image-delivery");function he(){let e=globalThis;return e[xt]??={catalog:new Map,transparent:new Set},e[xt]}var bt=new Set;function mn(e){return`/${e.split(J.sep).map(encodeURIComponent).join("/")}`}function pn(e){let t=J.extname(e),r=e.slice(0,-t.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),s=St("sha256").update(e).digest("hex").slice(0,8);return`${r||"image"}-${s}`}function vt(e,t=`stx:${pe}`){let r=(s)=>`${pe}/${s.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:t,async stat(s){let i=J.join(e,s);try{let a=await Y.promises.stat(i);return a.size>0?{bytes:a.size,path:i,url:r(s)}:null}catch{return null}},async write(s,i){let a=J.join(e,s);await Y.promises.mkdir(J.dirname(a),{recursive:!0});let c=`${a}.${process.pid}.tmp`;return await Y.promises.writeFile(c,i),await Y.promises.rename(c,a),{bytes:i.byteLength,path:a,url:r(s)}},url:r}}async function Ct(e,t=e){let r=await Y.promises.readdir(t,{withFileTypes:!0});r.sort((i,a)=>i.name.localeCompare(a.name));let s=[];for(let i of r){let a=J.join(t,i.name);if(i.isDirectory()){s.push(...await Ct(e,a));continue}if(!i.isFile()||!an.has(J.extname(i.name).toLowerCase()))continue;s.push({absolutePath:a,relativePath:J.relative(e,a)})}return s}function wt(e,t){return e.map((r)=>({key:mn(r.relativePath),input:r.absolutePath,name:pn(r.relativePath),...hn(r.absolutePath)?{options:{storage:t}}:{}}))}function hn(e){return De(e)==="possible"}function yn(e){for(let t=3;t<e.length;t+=4)if(e[t]!==255)return!0;return!1}async function xn(e){let t=Object.entries(e).filter(([,i])=>i.fallback.format==="png"),r=new Set,s=8;for(let i=0;i<t.length;i+=8)await Promise.all(t.slice(i,i+8).map(async([a,c])=>{let f=c.variants.filter((l)=>l.format==="png").sort((l,h)=>l.width-h.width)[0];try{let l=await sn(new Uint8Array(await Y.promises.readFile(f?.path??c.fallback.path)));if(yn(l.data))r.add(a)}catch{r.add(a)}}));return r}function bn(e,t){let r=[];for(let s of t){let i=e[s],a=i?.variants.filter((f)=>f.format==="webp")??[];if(!i||a.length===0)continue;if(!a.some((f)=>{let l;try{return l=Y.openSync(f.path,"r"),!Te(Se(l,0,32))}catch{return!0}finally{if(l!==void 0)Y.closeSync(l)}}))continue;if(i.variants=i.variants.filter((f)=>f.format!=="webp"),delete i.sources.webp,r.push(s),!bt.has(s))bt.add(s),console.warn(`[stx-images] ${s} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return r}async function vn(e){let t=[],r=8;for(let s=0;s<e.length;s+=8){let i=e.slice(s,s+8),a=await Promise.all(i.map(async(c)=>{try{return await on(c.absolutePath),c}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${c.relativePath}`),null}}));t.push(...a.filter((c)=>c!==null))}return t}function ze(e){return J.join(e,"undecodable.json")}function wn(e){try{let t=Y.readFileSync(ze(e),"utf-8"),r=JSON.parse(t);return r&&typeof r==="object"?r:{}}catch{return{}}}function $n(e,t){try{Y.mkdirSync(J.dirname(ze(e)),{recursive:!0}),Y.writeFileSync(ze(e),JSON.stringify(t))}catch{}}function $t(e){try{let t=Y.statSync(e);return{mtimeMs:t.mtimeMs,size:t.size}}catch{return}}function Rt(e){if(!e||e.startsWith("data:")||e.startsWith("blob:")||/^https?:\/\//i.test(e)||e.startsWith("//"))return;let t=e.split(/[?#]/,1)[0];if(!t)return;try{return`/${t.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Qs(e){let t=Rt(e);return t?he().catalog.get(t):void 0}function eo(e){let t=Rt(e);return t?he().transparent.has(t):!1}function to(e){let t=(s)=>e.variants.filter((i)=>i.format===s).reduce((i,a)=>i+a.bytes,0),r=t(e.fallback.format);return["avif","webp"].map((s)=>({format:s,srcset:e.sources[s]||"",bytes:t(s)})).filter((s)=>s.srcset&&s.bytes>0&&s.bytes<r).sort((s,i)=>s.bytes-i.bytes).map(({format:s,srcset:i})=>({format:s,srcset:i}))}function dp(e){let t=Qs(e);if(!t)return;return{src:t.fallback.url,srcset:t.sources[t.fallback.format]||"",sources:to(t).map(({format:r,srcset:s})=>({type:`image/${r}`,srcset:s})),width:t.source.width,height:t.source.height,placeholder:eo(e)?void 0:t.placeholder?.dataUrl}}function jr(){let e=he();e.catalog=new Map,e.transparent=new Set}function Sn(e){let t=he();t.catalog=new Map(e.entries),t.transparent=new Set(e.transparent)}async function pp(e,t,r={}){if(!e||!Y.existsSync(e))return jr(),{count:0,fingerprint:""};if(r.offThread){let g=await Le("delivery",{publicDir:e,outputDir:t});if(g!==ke)return Sn(g.state),g.result}let s=await Ct(e);if(s.length===0)return jr(),{count:0,fingerprint:""};let i=wn(t),a=s.filter((g)=>{let b=i[g.relativePath];if(!b)return!0;let w=$t(g.absolutePath);return!w||w.mtimeMs!==b.mtimeMs||w.size!==b.size});if(a.length===0)return jr(),{count:0,fingerprint:""};let c=vt(J.join(t,"_stx","images"),`${ln}:${yt()}`),f={outDir:J.join(t,"_stx","images"),storage:vt(J.join(t,"_stx","images"),`${un}:${yt()}`),baseUrl:pe,widths:cn,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},l=a,h;try{h=await ht({...f,entries:wt(a,c)})}catch(g){if(l=await vn(a),l.length===a.length)throw g;let b=new Set(l.map((C)=>C.relativePath)),w=!1;for(let C of a){if(b.has(C.relativePath))continue;let k=$t(C.absolutePath);if(!k)continue;i[C.relativePath]=k,w=!0}if(w)$n(t,i);if(l.length===0)return jr(),{count:0,fingerprint:""};h=await ht({...f,entries:wt(l,c)})}let v=await xn(h.entries),y=bn(h.entries,v),S=he();S.catalog=new Map(Object.entries(h.entries)),S.transparent=v;let x=v.size===0&&y.length===0?h.fingerprint:St("sha256").update(h.fingerprint).update(JSON.stringify({transparent:[...v].sort(),droppedWebp:y.sort()})).digest("hex");return{count:l.length,fingerprint:x}}class At{builtins=new Map;registerBuiltin(e){this.builtins.set(e.name.toLowerCase(),e);for(let t of e.aliases)this.builtins.set(t.toLowerCase(),e)}isBuiltin(e){return this.builtins.has(e.toLowerCase())}getBuiltin(e){return this.builtins.get(e.toLowerCase())??null}async resolveFile(e,t,r,s){let i=So(e,s);if(i!==void 0)return i;for(let a of ko(e,t,r,s))if(await n(a))return a;return null}}var ae=new At;function R(e){return F(e)}var re="\x00stx-boolean-attribute";function Ue(e){return e.indexOf("\x00")===-1?e:e.replace(/\0/g,"")}var Cn=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function We(e){let t=e.toLowerCase();return t.startsWith("aria-")||t.startsWith("data-")||Cn.has(t)}function se(e,t){let r=[];for(let[s,i]of Object.entries(e.static)){if(t.has(s))continue;let a=e.staticNames?.[s]??s;if(typeof i==="boolean"){if(i)r.push(m(a));continue}if(i===re){r.push(m(a));continue}r.push(`${m(a)}="${fn(a,Ue(String(i)))}"`)}return r}function ie(e,t){let r=[];for(let[s,i]of Object.entries(e.serverDynamic??{})){if(t.has(s))continue;if(i===null||i===void 0||i===!1)continue;let a=e.serverDynamicNames?.[s]??s;if(i===!0){r.push(m(a));continue}if(typeof i==="object")continue;r.push(`${m(a)}="${fn(a,Ue(String(i)))}"`)}return r}function Rn(e){if(e.clientReactive.to)return{value:e.clientReactive.to,reactive:!0};if(e.serverDynamic.to!==void 0)return{value:String(e.serverDynamic.to),reactive:!1};if(typeof e.static.to==="string")return{value:e.static.to,reactive:!1};return{value:"#",reactive:!1}}var Fe={name:"StxLink",aliases:["stx-link"],render(e,t,r){let s=Rn(e),i=(typeof e.static.class==="string"?e.static.class:"")||(typeof e.static.className==="string"?e.static.className:""),a=typeof e.static.activeClass==="string"?e.static.activeClass:"active",c=typeof e.static.exactActiveClass==="string"?e.static.exactActiveClass:"exact-active",f=e.static.prefetch===!0||e.static.prefetch==="true"||e.serverDynamic.prefetch===!0,l=[];if(s.reactive)l.push(`:href="${R(s.value)}"`);else l.push(`href="${R(sr(s.value,"navigable"))}"`);if(i)l.push(`class="${R(i)}"`);if(l.push("data-stx-link"),l.push(`data-stx-active-class="${R(a)}"`),l.push(`data-stx-exact-active-class="${R(c)}"`),f)l.push("data-stx-prefetch");let h=typeof e.static.activeMatch==="string"?e.static.activeMatch.trim():"";if(h)l.push(`data-stx-active-match="${R(h)}"`);let v=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return l.push(...se(e,v)),l.push(...ie(e,v)),`<a ${l.join(" ")}>${t}</a>`}};var An=new Map;function He(e){if(!e)return;let t=e.split("?")[0].split("#")[0];return An.get(t)}var kn={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},qe=[320,640,768,1024,1280,1536,1920];function G(e,t){if(e.serverDynamic[t]!==void 0)return String(e.serverDynamic[t]);let r=e.static[t];if(typeof r==="string")return r;return}function _e(e,t,r=!1){let s=e.serverDynamic[t];if(s!==void 0)return s!==!1&&s!=="false";let i=e.static[t];if(i!==void 0)return i!=="false"&&i!==!1;return r}function Xe(e){if(e.includes("(")||e.includes(","))return e;let t=e.trim().split(/\s+/),r=[];for(let s of t)if(s.includes(":")){let[i,a]=s.split(":"),c=kn[i];if(c)r.push(`(max-width: ${c}px) ${a}`);else{let f=Number.parseInt(i);if(!Number.isNaN(f))r.push(`(max-width: ${f}px) ${a}`)}}else r.push(s);return r.join(", ")}function Ve(e,t,r,s){return t.map((i)=>`${ye(e,i,void 0,r,s)} ${i}w`).join(", ")}function Pn(e,t,r,s,i){return t.map((a)=>{let c=r?r*a:void 0;return`${ye(e,c,void 0,s,i)} ${a}x`}).join(", ")}function ye(e,t,r,s,i){if(!s||s==="local"||s==="static")return e;if(s==="cloudinary"){let a=[];if(t)a.push(`w_${t}`);if(r)a.push(`h_${r}`);if(i)a.push(`f_${i}`);a.push("q_auto");let c=a.join(",");return e.replace("/upload/",`/upload/${c}/`)}if(s==="imgix"){let a=new URLSearchParams;if(t)a.set("w",String(t));if(r)a.set("h",String(r));if(i)a.set("fm",i);a.set("auto","format");let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}if(s==="bunny"){let a=new URLSearchParams;if(t)a.set("width",String(t));if(r)a.set("height",String(r));if(i)a.set("format",i);let c=e.includes("?")?"&":"?";return`${e}${c}${a.toString()}`}return e}function _n(e){return`var s=this.style;${e.map((t)=>`s.${t}=''`).join(";")}`}function In(e,t,r="#e5e7eb"){let s=`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}"><rect width="100%" height="100%" fill="${r}"/></svg>`;return`data:image/svg+xml;base64,${btoa(s)}`}var Ge={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(e,t,r){let s=G(e,"src")||"",i=Qs(s),a=G(e,"alt")||"",c=G(e,"width")||(i?String(i.source.width):void 0),f=G(e,"height")||(i?String(i.source.height):void 0),l=G(e,"sizes"),h=G(e,"srcset"),v=G(e,"densities"),y=G(e,"format"),S=eo(s)||He(s)?.transparent===!0,x=G(e,"placeholder")||(i&&!S?"thumbhash":void 0),g=G(e,"placeholderColor")||"#e5e7eb",b=G(e,"provider"),w=G(e,"class")||G(e,"className")||"",C=G(e,"style")||"",k=G(e,"objectFit")||G(e,"fit"),A=G(e,"objectPosition")||G(e,"position"),I=G(e,"quality"),U=_e(e,"lazy",!0),M=_e(e,"preload",!1),L=_e(e,"priority",!1),X=G(e,"loading"),N=G(e,"decoding")||"async",_=!!i||_e(e,"picture",!1)||!!y,O=c?Number.parseInt(c):void 0,B=f?Number.parseInt(f):void 0,z=h||"",V="";if(i)z=i.sources[i.fallback.format]||"",V=l?Xe(l):"100vw";else if(!z&&l&&b&&b!=="local"&&b!=="static")z=Ve(s,qe,b,y),V=Xe(l);else if(!z&&v){let P=v.split(/\s+/).map((H)=>Number.parseFloat(H.replace("x","")));z=Pn(s,P,O,b,y)}else if(l)V=Xe(l);let D=[];if(C)D.push(C);if(k)D.push(`object-fit:${k}`);if(A)D.push(`object-position:${A}`);if(O&&B)D.push(`aspect-ratio:${O}/${B}`);let W=[],oe=x==="blur"||x==="color"||x==="thumbhash";if(oe&&!S){let P=i?.placeholder?{dataUrl:i.placeholder.dataUrl,color:g}:He(s);if(P&&x==="color")D.push(`background-color:${P.color}`),W.push("backgroundColor");else if(P)D.push(`background-color:${P.color}`),D.push(`background-image:url(${P.dataUrl})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundColor","backgroundImage");else{let H=In(O||16,B||9,g);D.push(`background-image:url(${H})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage")}}else if(!oe&&x&&x!=="empty"&&x!=="none")D.push(`background-image:url(${R(x)})`),D.push("background-size:cover"),D.push("background-repeat:no-repeat"),W.push("backgroundImage");let ve=i?.fallback.url||ye(s,O,B,b,y),K=[];if(K.push(`src="${R(sr(ve,"fetched"))}"`),K.push(`alt="${R(a)}"`),c)K.push(`width="${R(c)}"`);if(f)K.push(`height="${R(f)}"`);let te=X||(L||M?"eager":U?"lazy":"");if(te)K.push(`loading="${R(te)}"`);if(L)K.push('fetchpriority="high"');if(K.push(`decoding="${R(N)}"`),w)K.push(`class="${R(w)}"`);if(D.length>0)K.push(`style="${R(D.join(";"))}"`);if(z)K.push(`srcset="${R(sr(z,"fetched"))}"`);if(V)K.push(`sizes="${R(V)}"`);let we=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(W.length>0){let P=typeof e.static.onload==="string"?e.static.onload:"",H=_n(W)+(P?`;${P}`:"");K.push(`onload="${R(H)}"`),we.add("onload")}K.push(...se(e,we)),K.push(...ie(e,we));let T=`<img ${K.join(" ")} />`,Z="";if(M){let H=y==="webp"?"image/webp":y==="avif"?"image/avif":"";Z=`<link rel="preload" as="image" href="${R(ve)}"${H?` type="${H}"`:""}${z?` imagesrcset="${R(z)}"`:""}${V?` imagesizes="${R(V)}"`:""} />
3
3
  `}if(_){let P=[];if(i)for(let H of to(i))P.push(`<source type="image/${H.format}" srcset="${R(H.srcset)}"${V?` sizes="${R(V)}"`:""} />`);if(!i&&(y==="avif"||y==="auto")){let H=ye(s,O,B,b,"avif"),Q=z?Ve(s,qe,b,"avif"):`${H}`;P.push(`<source type="image/avif" srcset="${R(Q)}"${V?` sizes="${R(V)}"`:""} />`)}if(!i&&(y==="webp"||y==="auto")){let H=ye(s,O,B,b,"webp"),Q=z?Ve(s,qe,b,"webp"):`${H}`;P.push(`<source type="image/webp" srcset="${R(Q)}"${V?` sizes="${R(V)}"`:""} />`)}return`${Z}<picture>
4
4
  ${P.join(`
5
5
  `)}
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import S from"fs";import _ from"path";function Os(e){let{token:t,baseUrl:i="https://api.netlify.com/api/v1"}=e;async function s(n,r,l={}){let p=`${i}${r}`,f={Authorization:`Bearer ${t}`,"User-Agent":"stx-deploy/1.0"},u;if(l.rawBody)f["Content-Type"]=l.contentType||"application/octet-stream",u=l.rawBody;else if(l.body)f["Content-Type"]="application/json",u=JSON.stringify(l.body);let o=await fetch(p,{method:n,headers:f,body:u});if(!o.ok){let g=Error(`Netlify API error: ${o.status} ${o.statusText}`);g.status=o.status;try{let b=await o.json();g.message=b.message||g.message,g.code=b.code,g.details=b}catch{}throw g}let a=await o.text();if(!a)return{};return JSON.parse(a)}return{async getSite(n){return s("GET",`/sites/${n}`)},async listSites(){return s("GET","/sites")},async createSite(n){let r={};if(n)r.name=n;return s("POST","/sites",{body:r})},async createDeploy(n,r){let l={files:r.files,draft:r.draft??!0,async:r.async??!0};if(r.title)l.title=r.title;if(r.branch)l.branch=r.branch;if(r.functions)l.functions=r.functions;return s("POST",`/sites/${n}/deploys`,{body:l})},async uploadFile(n,r,l){let p=r.startsWith("/")?r.slice(1):r;await s("PUT",`/deploys/${n}/files/${p}`,{rawBody:l,contentType:"application/octet-stream"})},async uploadFiles(n,r){let p=[...r],f=async()=>{while(p.length>0){let o=p.shift();if(o)await this.uploadFile(n,o.path,o.content)}},u=Array.from({length:Math.min(5,r.length)},()=>f());await Promise.all(u)},async getDeploy(n){return s("GET",`/deploys/${n}`)},async waitForDeploy(n,r={}){let{timeout:l=300000,pollInterval:p=2000,onProgress:f}=r,u=Date.now();while(!0){let o=await this.getDeploy(n);if(f)f(o);if(o.state==="ready")return o;if(o.state==="error"){let a=Error(`Deploy failed: ${o.error_message||"Unknown error"}`);throw a.status=500,a.details=o,a}if(Date.now()-u>l){let a=Error(`Deploy timed out after ${l}ms`);throw a.status=408,a.details=o,a}await new Promise((a)=>setTimeout(a,p))}},async lockDeploy(n){return s("POST",`/deploys/${n}/lock`)},async unlockDeploy(n){return s("POST",`/deploys/${n}/unlock`)}}}async function bi(e){let t=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(t)).map((s)=>s.toString(16).padStart(2,"0")).join("")}async function _r(e,t={}){let{ignore:i=["node_modules",".git",".env*","*.map"]}=t,s=[],n=new Bun.Glob("**/*");for await(let r of n.scan({cwd:e,onlyFiles:!0,dot:!1})){if(i.some((a)=>{if(a.includes("*"))return new RegExp(`^${a.replace(/\*/g,".*")}$`).test(r);return r.includes(a)}))continue;let p=`${e}/${r}`,u=await Bun.file(p).arrayBuffer(),o=await bi(u);s.push({path:r,content:new Uint8Array(u),sha1:o})}return s}function Ns(e){let t={};for(let i of e)t[`/${i.path}`]=i.sha1;return t}function Ds(e,t){let i=new Set(t.map((s)=>s.startsWith("/")?s.slice(1):s));return e.filter((s)=>i.has(s.path))}function Sn(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}function Vt(e){return e.reduce((t,i)=>t+i.content.byteLength,0)}import m from"fs";import y from"path";function vi(e){let t=[];if(t.push("[build]"),t.push(` command = "${d(e.build.command)}"`),t.push(` publish = "${d(e.build.publish)}"`),e.build.functions)t.push(` functions = "${d(e.build.functions)}"`);if(e.build.edge_functions)t.push(` edge_functions = "${d(e.build.edge_functions)}"`);if(e.build.environment&&Object.keys(e.build.environment).length>0){t.push(""),t.push("[build.environment]");for(let[i,s]of Object.entries(e.build.environment))t.push(` ${i} = "${d(s)}"`)}if(e.functions){if(t.push(""),t.push("[functions]"),e.functions.directory)t.push(` directory = "${d(e.functions.directory)}"`);if(e.functions.node_bundler)t.push(` node_bundler = "${e.functions.node_bundler}"`);if(e.functions.external_node_modules&&e.functions.external_node_modules.length>0)t.push(` external_node_modules = [${e.functions.external_node_modules.map((i)=>`"${i}"`).join(", ")}]`)}if(e.edge_functions&&e.edge_functions.length>0){t.push("");for(let i of e.edge_functions)t.push("[[edge_functions]]"),t.push(` function = "${d(i.function)}"`),t.push(` path = "${d(i.path)}"`)}if(e.redirects&&e.redirects.length>0){t.push("");for(let i of e.redirects){if(t.push("[[redirects]]"),t.push(` from = "${d(i.from)}"`),t.push(` to = "${d(i.to)}"`),i.status!==void 0)t.push(` status = ${i.status}`);if(i.force!==void 0)t.push(` force = ${i.force}`);if(i.conditions&&Object.keys(i.conditions).length>0){t.push(" [redirects.conditions]");for(let[s,n]of Object.entries(i.conditions))t.push(` ${s} = "${d(n)}"`)}}}if(e.headers&&e.headers.length>0){t.push("");for(let i of e.headers){t.push("[[headers]]"),t.push(` for = "${d(i.for)}"`),t.push(" [headers.values]");for(let[s,n]of Object.entries(i.values))t.push(` ${s} = "${d(n)}"`)}}if(e.plugins&&e.plugins.length>0){t.push("");for(let i of e.plugins)if(t.push("[[plugins]]"),t.push(` package = "${d(i.package)}"`),i.inputs&&Object.keys(i.inputs).length>0){t.push(" [plugins.inputs]");for(let[s,n]of Object.entries(i.inputs))if(typeof n==="string")t.push(` ${s} = "${d(n)}"`);else if(typeof n==="boolean"||typeof n==="number")t.push(` ${s} = ${n}`)}}if(e.context&&Object.keys(e.context).length>0)for(let[i,s]of Object.entries(e.context)){if(t.push(""),t.push(`[context.${i}]`),s.command)t.push(` command = "${d(s.command)}"`);if(s.publish)t.push(` publish = "${d(s.publish)}"`);if(s.environment&&Object.keys(s.environment).length>0){t.push(` [context.${i}.environment]`);for(let[n,r]of Object.entries(s.environment))t.push(` ${n} = "${d(r)}"`)}}return t.join(`
2
+ import S from"fs";import _ from"path";function Os(e){let{token:t,baseUrl:i="https://api.netlify.com/api/v1"}=e;async function s(n,r,l={}){let p=`${i}${r}`,f={Authorization:`Bearer ${t}`,"User-Agent":"stx-deploy/1.0"},u;if(l.rawBody)f["Content-Type"]=l.contentType||"application/octet-stream",u=l.rawBody;else if(l.body)f["Content-Type"]="application/json",u=JSON.stringify(l.body);let o=await fetch(p,{method:n,headers:f,body:u});if(!o.ok){let g=Error(`Netlify API error: ${o.status} ${o.statusText}`);g.status=o.status;try{let b=await o.json();g.message=b.message||g.message,g.code=b.code,g.details=b}catch{}throw g}let a=await o.text();if(!a)return{};return JSON.parse(a)}return{async getSite(n){return s("GET",`/sites/${n}`)},async listSites(){return s("GET","/sites")},async createSite(n){let r={};if(n)r.name=n;return s("POST","/sites",{body:r})},async createDeploy(n,r){let l={files:r.files,draft:r.draft??!0,async:r.async??!0};if(r.title)l.title=r.title;if(r.branch)l.branch=r.branch;if(r.functions)l.functions=r.functions;return s("POST",`/sites/${n}/deploys`,{body:l})},async uploadFile(n,r,l){let p=r.startsWith("/")?r.slice(1):r;await s("PUT",`/deploys/${n}/files/${p}`,{rawBody:l,contentType:"application/octet-stream"})},async uploadFiles(n,r){let p=[...r],f=async()=>{while(p.length>0){let o=p.shift();if(o)await this.uploadFile(n,o.path,o.content)}},u=Array.from({length:Math.min(5,r.length)},()=>f());await Promise.all(u)},async getDeploy(n){return s("GET",`/deploys/${n}`)},async waitForDeploy(n,r={}){let{timeout:l=300000,pollInterval:p=2000,onProgress:f}=r,u=Date.now();while(!0){let o=await this.getDeploy(n);if(f)f(o);if(o.state==="ready")return o;if(o.state==="error"){let a=Error(`Deploy failed: ${o.error_message||"Unknown error"}`);throw a.status=500,a.details=o,a}if(Date.now()-u>l){let a=Error(`Deploy timed out after ${l}ms`);throw a.status=408,a.details=o,a}await new Promise((a)=>setTimeout(a,p))}},async lockDeploy(n){return s("POST",`/deploys/${n}/lock`)},async unlockDeploy(n){return s("POST",`/deploys/${n}/unlock`)}}}async function bi(e){let t=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(t)).map((s)=>s.toString(16).padStart(2,"0")).join("")}async function Cr(e,t={}){let{ignore:i=["node_modules",".git",".env*","*.map"]}=t,s=[],n=new Bun.Glob("**/*");for await(let r of n.scan({cwd:e,onlyFiles:!0,dot:!1})){if(i.some((a)=>{if(a.includes("*"))return new RegExp(`^${a.replace(/\*/g,".*")}$`).test(r);return r.includes(a)}))continue;let p=`${e}/${r}`,u=await Bun.file(p).arrayBuffer(),o=await bi(u);s.push({path:r,content:new Uint8Array(u),sha1:o})}return s}function Ns(e){let t={};for(let i of e)t[`/${i.path}`]=i.sha1;return t}function Ds(e,t){let i=new Set(t.map((s)=>s.startsWith("/")?s.slice(1):s));return e.filter((s)=>i.has(s.path))}function Sn(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;if(e<1073741824)return`${(e/1048576).toFixed(1)} MB`;return`${(e/1073741824).toFixed(1)} GB`}function Vt(e){return e.reduce((t,i)=>t+i.content.byteLength,0)}import m from"fs";import y from"path";function vi(e){let t=[];if(t.push("[build]"),t.push(` command = "${d(e.build.command)}"`),t.push(` publish = "${d(e.build.publish)}"`),e.build.functions)t.push(` functions = "${d(e.build.functions)}"`);if(e.build.edge_functions)t.push(` edge_functions = "${d(e.build.edge_functions)}"`);if(e.build.environment&&Object.keys(e.build.environment).length>0){t.push(""),t.push("[build.environment]");for(let[i,s]of Object.entries(e.build.environment))t.push(` ${i} = "${d(s)}"`)}if(e.functions){if(t.push(""),t.push("[functions]"),e.functions.directory)t.push(` directory = "${d(e.functions.directory)}"`);if(e.functions.node_bundler)t.push(` node_bundler = "${e.functions.node_bundler}"`);if(e.functions.external_node_modules&&e.functions.external_node_modules.length>0)t.push(` external_node_modules = [${e.functions.external_node_modules.map((i)=>`"${i}"`).join(", ")}]`)}if(e.edge_functions&&e.edge_functions.length>0){t.push("");for(let i of e.edge_functions)t.push("[[edge_functions]]"),t.push(` function = "${d(i.function)}"`),t.push(` path = "${d(i.path)}"`)}if(e.redirects&&e.redirects.length>0){t.push("");for(let i of e.redirects){if(t.push("[[redirects]]"),t.push(` from = "${d(i.from)}"`),t.push(` to = "${d(i.to)}"`),i.status!==void 0)t.push(` status = ${i.status}`);if(i.force!==void 0)t.push(` force = ${i.force}`);if(i.conditions&&Object.keys(i.conditions).length>0){t.push(" [redirects.conditions]");for(let[s,n]of Object.entries(i.conditions))t.push(` ${s} = "${d(n)}"`)}}}if(e.headers&&e.headers.length>0){t.push("");for(let i of e.headers){t.push("[[headers]]"),t.push(` for = "${d(i.for)}"`),t.push(" [headers.values]");for(let[s,n]of Object.entries(i.values))t.push(` ${s} = "${d(n)}"`)}}if(e.plugins&&e.plugins.length>0){t.push("");for(let i of e.plugins)if(t.push("[[plugins]]"),t.push(` package = "${d(i.package)}"`),i.inputs&&Object.keys(i.inputs).length>0){t.push(" [plugins.inputs]");for(let[s,n]of Object.entries(i.inputs))if(typeof n==="string")t.push(` ${s} = "${d(n)}"`);else if(typeof n==="boolean"||typeof n==="number")t.push(` ${s} = ${n}`)}}if(e.context&&Object.keys(e.context).length>0)for(let[i,s]of Object.entries(e.context)){if(t.push(""),t.push(`[context.${i}]`),s.command)t.push(` command = "${d(s.command)}"`);if(s.publish)t.push(` publish = "${d(s.publish)}"`);if(s.environment&&Object.keys(s.environment).length>0){t.push(` [context.${i}.environment]`);for(let[n,r]of Object.entries(s.environment))t.push(` ${n} = "${d(r)}"`)}}return t.join(`
3
3
  `)+`
4
4
  `}function d(e){return e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function Er(e){let t={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},i=y.join(e,"package.json");if(await Bun.file(i).exists())try{let u=JSON.parse(await Bun.file(i).text());if(u.scripts?.build)t.buildCommand="bun run build";let o={...u.dependencies,...u.devDependencies};if(o["@stacksjs/stx"]||o.stx)t.framework="stx"}catch{}let s=y.join(e,"stx.config.ts"),n=y.join(e,".config","stx.config.ts");if(await Bun.file(s).exists()||await Bun.file(n).exists())t.framework="stx";let r=["dist","build","out","public",".output"];for(let u of r){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.outputDir=u;break}}let l=["functions","netlify/functions","api"];for(let u of l){let o=y.join(e,u);if(m.existsSync(o)&&m.statSync(o).isDirectory()){t.functionsDir=u;break}}let p=y.join(e,"netlify","edge-functions");if(m.existsSync(p))t.edgeFunctionsDir="netlify/edge-functions";let f=y.join(e,t.outputDir||"dist");if(m.existsSync(f)){let u=m.existsSync(y.join(f,"index.html")),o=m.readdirSync(f).filter((a)=>a.endsWith(".html"));t.isSPA=u&&o.length===1}return t}function Tr(e={}){let t={build:{command:e.buildCommand||"bun run build",publish:e.outputDir||"dist"}};if(e.functionsDir)t.build.functions=e.functionsDir,t.functions={directory:e.functionsDir,node_bundler:"esbuild"};if(e.edgeFunctionsDir)t.build.edge_functions=e.edgeFunctionsDir;if(t.headers=[{for:"/*",values:{"X-Frame-Options":"DENY","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"}},{for:"/assets/*",values:{"Cache-Control":"public, max-age=31536000, immutable"}}],e.isSPA!==!1)t.redirects=[{from:"/*",to:"/index.html",status:200}];return t.context={production:{environment:{NODE_ENV:"production"}},"deploy-preview":{environment:{NODE_ENV:"development"}}},t}async function Ms(e,t){let i=await Er(e),s=t||Tr(i),n=vi(s),r=y.join(e,"netlify.toml");return await Bun.write(r,n),r}function Ls(e){return m.existsSync(y.join(e,"netlify.toml"))}async function Ru(e={}){let t=Date.now(),i=[],s=e.cwd||process.cwd(),n=(c)=>{i.push(c)},r=(c)=>{if(e.onProgress)e.onProgress(c)},l=_.resolve(s,e.directory||"dist"),p=e.token||process.env.NETLIFY_AUTH_TOKEN,f=e.siteId||process.env.NETLIFY_SITE_ID;if(!p)throw new ct(`No Netlify auth token found.
5
5
 
@@ -19,12 +19,12 @@ Find your site ID at: https://app.netlify.com/sites/YOUR_SITE/settings/general`,
19
19
 
20
20
  Run \`stx build\` first or specify a different directory with --directory`,"NO_BUILD_DIR");if(!(S.readdirSync(l).length>0))throw new ct(`Build directory is empty: ${l}
21
21
 
22
- Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if(e.dryRun){r({stage:"collect",message:"Collecting files..."});let c=await _r(l),w=Vt(c);return n(`Would deploy ${c.length} files (${Sn(w)})`),n(`From: ${l}`),n(`To: Site ${f}`),n(`Mode: ${e.production?"production":"draft"}`),{success:!0,url:`https://${f}.netlify.app (dry-run)`,deployId:"dry-run",logs:i,duration:Date.now()-t,filesUploaded:c.length,totalSize:w}}let o=Os({token:p});r({stage:"collect",message:"Verifying site..."});try{let c=await o.getSite(f);n(`Deploying to: ${c.name} (${c.url})`)}catch(c){if(c.status===404)throw new ct(`Site not found: ${f}
22
+ Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if(e.dryRun){r({stage:"collect",message:"Collecting files..."});let c=await Cr(l),w=Vt(c);return n(`Would deploy ${c.length} files (${Sn(w)})`),n(`From: ${l}`),n(`To: Site ${f}`),n(`Mode: ${e.production?"production":"draft"}`),{success:!0,url:`https://${f}.netlify.app (dry-run)`,deployId:"dry-run",logs:i,duration:Date.now()-t,filesUploaded:c.length,totalSize:w}}let o=Os({token:p});r({stage:"collect",message:"Verifying site..."});try{let c=await o.getSite(f);n(`Deploying to: ${c.name} (${c.url})`)}catch(c){if(c.status===404)throw new ct(`Site not found: ${f}
23
23
 
24
- Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw c}r({stage:"collect",message:"Collecting files..."});let a=await _r(l),g=Vt(a);if(n(`Found ${a.length} files (${Sn(g)})`),a.length===0)throw new ct(`No files found in ${l}`,"NO_FILES");let b=Ns(a);r({stage:"upload",message:"Creating deploy...",percent:0});let D=await o.createDeploy(f,{title:e.message||"Deploy from stx CLI",draft:!e.production,files:b});n(`Created deploy: ${D.id}`);let h=Ds(a,D.required||[]);if(n(`Uploading ${h.length} files...`),h.length>0){let c=0,w=Vt(h);for(let x of h){await o.uploadFile(D.id,x.path,x.content),c++;let C=Math.round(c/h.length*100);r({stage:"upload",message:`Uploading: ${x.path}`,percent:C,details:{uploaded:c,total:h.length}})}n(`Uploaded ${Sn(w)}`)}else n("All files already on CDN (no upload needed)");r({stage:"process",message:"Processing deploy..."});let N=await o.waitForDeploy(D.id,{onProgress:(c)=>{r({stage:"process",message:`Status: ${c.state}`,details:c})}}),P=Date.now()-t;if(r({stage:"done",message:"Deploy complete!"}),n(`Deploy complete in ${(P/1000).toFixed(1)}s`),n(`URL: ${N.deploy_ssl_url}`),e.production)n(`Site: ${N.ssl_url}`);if(e.open){let c=e.production?N.ssl_url:N.deploy_ssl_url;I(c)}return{success:!0,url:N.deploy_ssl_url,siteUrl:e.production?N.ssl_url:void 0,deployId:N.id,logs:i,duration:P,filesUploaded:h.length,totalSize:Vt(h)}}async function Au(e={}){let t=e.directory||process.cwd(),i;if(Ls(t))i=_.join(t,"netlify.toml");else{let s=await Er(t);i=await Ms(t,Tr(s))}if(e.siteId){let s=_.join(t,".env.local"),n="";if(await Bun.file(s).exists()){if(n=await Bun.file(s).text(),n=n.split(`
24
+ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw c}r({stage:"collect",message:"Collecting files..."});let a=await Cr(l),g=Vt(a);if(n(`Found ${a.length} files (${Sn(g)})`),a.length===0)throw new ct(`No files found in ${l}`,"NO_FILES");let b=Ns(a);r({stage:"upload",message:"Creating deploy...",percent:0});let D=await o.createDeploy(f,{title:e.message||"Deploy from stx CLI",draft:!e.production,files:b});n(`Created deploy: ${D.id}`);let h=Ds(a,D.required||[]);if(n(`Uploading ${h.length} files...`),h.length>0){let c=0,w=Vt(h);for(let x of h){await o.uploadFile(D.id,x.path,x.content),c++;let C=Math.round(c/h.length*100);r({stage:"upload",message:`Uploading: ${x.path}`,percent:C,details:{uploaded:c,total:h.length}})}n(`Uploaded ${Sn(w)}`)}else n("All files already on CDN (no upload needed)");r({stage:"process",message:"Processing deploy..."});let N=await o.waitForDeploy(D.id,{onProgress:(c)=>{r({stage:"process",message:`Status: ${c.state}`,details:c})}}),P=Date.now()-t;if(r({stage:"done",message:"Deploy complete!"}),n(`Deploy complete in ${(P/1000).toFixed(1)}s`),n(`URL: ${N.deploy_ssl_url}`),e.production)n(`Site: ${N.ssl_url}`);if(e.open){let c=e.production?N.ssl_url:N.deploy_ssl_url;I(c)}return{success:!0,url:N.deploy_ssl_url,siteUrl:e.production?N.ssl_url:void 0,deployId:N.id,logs:i,duration:P,filesUploaded:h.length,totalSize:Vt(h)}}async function Au(e={}){let t=e.directory||process.cwd(),i;if(Ls(t))i=_.join(t,"netlify.toml");else{let s=await Er(t);i=await Ms(t,Tr(s))}if(e.siteId){let s=_.join(t,".env.local"),n="";if(await Bun.file(s).exists()){if(n=await Bun.file(s).text(),n=n.split(`
25
25
  `).filter((r)=>!r.startsWith("NETLIFY_SITE_ID=")).join(`
26
26
  `),n&&!n.endsWith(`
27
27
  `))n+=`
28
28
  `}n+=`NETLIFY_SITE_ID=${e.siteId}
29
29
  `,await Bun.write(s,n)}return{configPath:i,siteId:e.siteId}}class ct extends Error{code;constructor(e,t){super(e);this.name="DeployError",this.code=t}}function I(e){let t=process.platform,i=t==="darwin"?"open":t==="win32"?"start":"xdg-open";Bun.spawn([i,e],{stdio:["ignore","ignore","ignore"]})}
30
- export{Os,bi,_r,Ns,Ds,Sn,Vt,vi,Er,Tr,Ms,Ls,Ru,Au,ct};
30
+ export{Os,bi,Cr,Ns,Ds,Sn,Vt,vi,Er,Tr,Ms,Ls,Ru,Au,ct};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Mi,tl,Pn,td,nl,rl,sl,nd}from"./chunk-mz1npbyk.js";import"./chunk-hzjvpcmj.js";import"./chunk-jf17b7y9.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Pn as Validator,tl as defineForm,nl as processErrorDirective,rl as processErrorsDirective,nd as processFormValidationDirectives,sl as processHasErrorsDirective,Mi as useForm,td as v};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Fo,vs,l,d,E,et,u,ws,t,a,w}from"./chunk-4e0z858k.js";import{he,Et,It,K,k}from"./chunk-y4nhcrf1.js";import{ee}from"./chunk-8gewq710.js";import{Ur}from"./chunk-wh838rdh.js";var ae=1000,ue=!1;function fe(n,r){let o=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",s=0,i;while((i=o.exec(n))!==null){let p=i.index+i[0].length,y=i.index+i[0].indexOf("("),m=w(n,"(",")",y);if(m===-1)continue;let c=n.slice(p,m).trim();if(!c)continue;if(!Object.keys(r).some((b)=>new RegExp(`(?:^|[^\\w$.])${b.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(c)))continue;let g;try{let b=E(c,r);if(!b||typeof b!=="object")continue;g=JSON.stringify(b)}catch{continue}e+=n.slice(s,p)+g,s=m,o.lastIndex=m}return s===0?n:e+n.slice(s)}function ge(n,r){let o=/@component\s*\(/g,e=n,s,i=[];while((s=o.exec(e))!==null){let p=s.index,y=p+s[0].length-1,m=1,c=y+1;while(c<e.length&&m>0){if(e[c]==="(")m++;else if(e[c]===")"){if(m--,m===0)break}c++}if(m!==0)continue;let f=e.substring(y+1,c),g=c+1,b=f.match(/^\s*['"]([^'"]+)['"]/);if(!b)continue;let x=b[1],h=f.slice(b[0].length),_=h.match(/^\s*,\s*/);if(!_)continue;let S=h.slice(_[0].length).trim();if(!S)continue;try{let P=E(S,r),F=JSON.stringify(P),R=`@component('${x}', ${F})`;i.push({start:p,end:g,replacement:R})}catch{continue}}for(let p=i.length-1;p>=0;p--){let{start:y,end:m,replacement:c}=i[p];e=e.substring(0,y)+c+e.substring(m)}return e}function te(n,r,o){let e=n,s=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),i;while((i=s.exec(e))!==null){let p=i.index,y=p+i[0].length-1,m=1,c=y+1,f=null,g=!1;while(c<e.length&&m>0){let h=e[c];if(g){g=!1,c++;continue}if(h==="\\"&&f){g=!0,c++;continue}if(f){if(h===f)f=null;c++;continue}if(h==='"'||h==="'"||h==="`"){f=h,c++;continue}if(h==="(")m++;else if(h===")"){if(m--,m===0)break}c++}if(m!==0)break;let b=e.substring(y+1,c),x=o(b);e=e.substring(0,p)+x+e.substring(c+1)}return e}function pe(n,r){let o=n;return o=o.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,s)=>{if(s in r)return`:${s}="${s}"`;return e}),o=o.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,s,i)=>{try{let p=Object.keys(r),y=Object.values(r);Fo(i);let c=u(i,p)(...y),f=JSON.stringify(c);if(f===void 0){if(!et(i).some((x)=>!(x in r)))return"";return e}let g=Buffer.from(f,"utf8").toString("base64");return`__stx_${s}="${g}"`}catch(p){return e}}),o}var Y="<!--__STX_BREAK__-->",G="<!--__STX_CONTINUE__-->";function se(n,r){let o=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",s=0;for(let i=o.exec(n);i;i=o.exec(n)){if(!i[1]){let c=i[0].length===3&&i[0]==="{{{"?3:2,f=i[0]==="{!!"?n.indexOf("!!}",o.lastIndex):he(n,i.index,c);if(f<0)break;o.lastIndex=f+(i[0]==="{!!"?3:c);continue}let p=o.lastIndex,y=!0,m=/^\s*\(/.exec(n.slice(p));if(m){let c=p+m[0].length-1,f=w(n,"(",")",c);if(f<0)break;p=f+1;try{let g=`!!(${n.slice(c+1,f).trim()})`;y=d(g)?Boolean(u(g,Object.keys(r))(...Object.values(r))):Boolean(l(g,r))}catch{y=!1}}if(e+=n.slice(s,i.index),y)return e+(i[1]==="break"?Y:G);s=p,o.lastIndex=p}return e+n.slice(s)}function oe(n){let r=(s)=>s.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),o="",e=0;return It(n,(s,i,p)=>(o+=ne(r(n.slice(e,p))),o+=`\${__stxRenderLoopValue(${p}, (${i}), ${s.length})}`,e=p+s.length,s)),o+ne(r(n.slice(e)))}function ie(n,r,o,e){return K(n,r,o==null?"":String(o),!1,e)}function ne(n){let r=n;return r=te(r,"@break",(o)=>{let e=o.trim();if(!ws(e))return"";return`\`; if (${e}) { break; } result += \``}),r=te(r,"@continue",(o)=>{let e=o.trim();if(!ws(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function de(n){let r=/@forelse\s*\(/g,o,e=[],s=/@foreach\s*\(/g,i=/@endforeach/g,p;while((p=s.exec(n))!==null)e.push({pos:p.index,delta:1});while((p=i.exec(n))!==null)e.push({pos:p.index,delta:-1});e.sort((f,g)=>f.pos-g.pos);let y=[],m=0;for(let f of e)m+=f.delta,y.push({pos:f.pos,depth:m});function c(f){let g=0,b=y.length-1,x=0;while(g<=b){let h=g+b>>1;if(y[h].pos<=f)x=y[h].depth,g=h+1;else b=h-1}return x}while((o=r.exec(n))!==null){if(c(o.index)>0)continue;let f=o.index,g=o.index+o[0].length-1,b=1,x=g+1,h=-1;while(x<n.length&&b>0){if(n[x]==="(")b++;else if(n[x]===")"){if(b--,b===0){h=x;break}}x++}if(h===-1)continue;let _=n.substring(g+1,h),S=Et(_);if(!S)continue;let{arrayExpr:P,itemVar:F}=S,R=h+1,N=1,U=R,v=/@forelse\s*\(/g,V=/@endforelse/g,I=-1;while(N>0&&U<n.length){v.lastIndex=U,V.lastIndex=U;let A=v.exec(n),T=V.exec(n);if(!T)break;if(A&&A.index<T.index)N++,U=A.index+A[0].length;else{if(N--,N===0){I=T.index;break}U=T.index+11}}if(I===-1)continue;let j=n.substring(R,I),z=I+11,M=-1,W=0,O=0;while(O<j.length){let A=j.indexOf("@",O);if(A===-1)break;let T=j.substring(A);if(/^@forelse\s*\(/.test(T))W++,O=A+1;else if(T.startsWith("@endforelse"))W--,O=A+11;else if(W===0&&T.startsWith("@empty")){if(j.length<=A+6||!/[a-z]/i.test(j[A+6])){M=A;break}O=A+1}else O=A+1}if(M===-1)continue;return{start:f,end:z,arrayExpr:P,itemVar:F,foreachContent:j.substring(0,M),emptyContent:j.substring(M+6)}}return null}function re(n,r){let o=n;while(!0){let e=de(o);if(!e)break;let{start:s,end:i,arrayExpr:p,itemVar:y,foreachContent:m,emptyContent:c}=e;try{let f;if(d(p))f=u(p,Object.keys(r))(...Object.values(r));else f=l(p,r);let g;if(!Array.isArray(f)||f.length===0)g=c;else g=`@foreach (${p} as ${y})${m}@endforeach`;o=o.substring(0,s)+g+o.substring(i)}catch(f){let g=f instanceof Error?f.message:String(f),b=a("Forelse",`Error in @forelse(${p} as ${y}): ${g}`,t.EVALUATION_ERROR);o=o.substring(0,s)+b+o.substring(i)}}return o}var ce="<!--stx:foreach-not-iterable:",me=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function be(n,r){return`${ce}${encodeURIComponent(n)}|${encodeURIComponent(r)}-->`}function xe(n,r){console.warn(`[stx] @foreach(${n}) in ${r}: ${n} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function Nr(n){if(!n.includes(ce))return n;return n.replace(me,(r,o,e)=>(xe(decodeURIComponent(o),decodeURIComponent(e)),""))}function qn(n,r,o,e,s=!1){let i=n;i=re(i,r);function p(c){let f=/@foreach\s*\(/g,g;while((g=f.exec(c))!==null){let b=g.index,x=g.index+g[0].length-1,h=1,_=x+1,S=-1;while(_<c.length&&h>0){if(c[_]==="(")h++;else if(c[_]===")"){if(h--,h===0){S=_;break}}_++}if(S===-1)continue;let P=c.substring(x+1,S),F=Et(P);if(!F)continue;let R=b,{arrayExpr:N,itemVar:U}=F,v=S+1,V=1,I=v,j=/@foreach\s*\(/g,z=/@endforeach/g;while(V>0&&I<c.length){j.lastIndex=I,z.lastIndex=I;let M=j.exec(c),W=z.exec(c);if(!W)break;if(M&&M.index<W.index)V++,I=M.index+M[0].length;else{if(V--,V===0){let O=c.substring(v,W.index),A=W.index+11;return{start:R,end:A,arrayExpr:N,itemVar:U,content:O}}I=W.index+11}}}return null}function y(c,f){let g=c;while(!0){let b=p(g);if(!b)break;let{start:x,end:h,arrayExpr:_,itemVar:S,content:P}=b;try{let F=_.trim(),R;if(d(F))R=u(F,Object.keys(f))(...Object.values(f));else R=l(F,f);let N=!1;if(!Array.isArray(R))if(R instanceof Map)R=Array.from(R),N=!0;else if(R instanceof Set)R=Array.from(R);else if(typeof R==="string")R=Array.from(R);else if(R&&typeof R==="object"&&!(R instanceof Date)&&!(R instanceof RegExp))R=Object.entries(R),N=!0;else{let O=be(F,o)+a("Foreach",`Error in @foreach: ${F} is not iterable`,t.TYPE_ERROR);g=g.substring(0,x)+O+g.substring(h);continue}let U=e?.loops?.useAltLoopVariable??ue,v=S.trim(),V=null,I,j=!1;if(v.includes("=>")){let O=v.split("=>").map((A)=>A.trim());if(O.length===2&&O[0]&&O[1])V=O[0],I=O[1];else I=v}else if(!v.startsWith("[")&&!v.startsWith("{")&&v.includes(",")){let O=v.split(",").map((A)=>A.trim());if(O.length===2&&O[0]&&O[1])I=O[0],V=O[1],j=!0;else I=v}else I=v;let z="",M=R,W=f[vs]??new WeakMap;for(let O=0;O<M.length;O++){let A=M[O],T={index:O,iteration:O+1,first:O===0,last:O===M.length-1,count:M.length},L={...f,loop:T,$loop:T,[vs]:W};if(I.startsWith("[")&&I.endsWith("]")){let J=I.slice(1,-1).split(",").map((B)=>B.trim());if(Array.isArray(A))J.forEach((B,D)=>{if(B)L[B]=A[D]});else L[I]=A}else if(I.startsWith("{")&&I.endsWith("}")){let J=I.slice(1,-1).split(",").map((B)=>B.trim()).filter(Boolean);if(A!==null&&typeof A==="object")J.forEach((B)=>{let D=B.indexOf(":"),q=(D===-1?B:B.slice(0,D)).trim(),Q=D===-1?q:B.slice(D+1).trim();if(q&&Q)L[Q]=A[q]});else L[I]=A}else L[I]=A;if(V)if(!j&&N&&Array.isArray(A)&&A.length===2)L[V]=A[0],L[I]=A[1];else L[V]=O;let C=re(P,L);C=qn(C,L,o,e,!0),C=ee(C,L,o),C=se(C,L);let Z=C.indexOf(Y),H=C.indexOf(G),X=Z<0?H:H<0?Z:Math.min(Z,H);if(X>=0)C=C.slice(0,X);if(C=k(C,L,o),C=pe(C,L),C=ge(C,L),C=fe(C,L),z+=C,X>=0&&X===Z)break}g=g.substring(0,x)+z+g.substring(h)}catch(F){let R=a("Foreach",`Error in @foreach(${_.trim()} as ${S.trim()}): ${F instanceof Error?F.message:String(F)}`,t.EVALUATION_ERROR);g=g.substring(0,x)+R+g.substring(h)}}return g}i=y(i,r),i=ye(i,r,o,e);let m=e?.loops?.maxWhileIterations??ae;return i=Re(i,r,m),s?i:Nr(i)}function xl(n){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(n);if(!r||/^(?:const|let|var)$/.test(r[2]))return n;return`${r[1]}let ${n.slice(r[1].length)}`}function le(n){return ws(n)}function ye(n,r,o,e){let s=n,i=!0;while(i){i=!1;let p=s.match(/@for\s*\(/);if(!p||p.index===void 0)break;let y=p.index,m=y+p[0].length-1,c=w(s,"(",")",m);if(c===-1)break;let f=xl(s.slice(m+1,c)),g=c+1,b=Ur(s.slice(y),"for","endfor");if(b.length===0)break;let x=b[0].content,h=y+b[0].end;if(!le(f)){let _=a("For",`Unsafe expression in @for: ${f}`,t.UNSAFE_EXPRESSION);s=s.substring(0,y)+_+s.substring(h),i=!0;continue}try{let _=Ee(f),S=/@(?:for|foreach|if|unless)\s*\(/.test(x);if(_.length>0&&S){let v=$e({forExpr:f,content:x,iterVarNames:_,context:r,filePath:o,options:e});s=s.substring(0,y)+v+s.substring(h),i=!0;continue}let P=Object.keys(r),F=Object.values(r),R=oe(x),U=Function(...P,"__stxRenderLoopValue",`
2
+ import{Fo,vs,l,d,E,et,u,ws,t,a,w}from"./chunk-hb08vrbb.js";import{he,Et,It,K,k}from"./chunk-hzjvpcmj.js";import{ee}from"./chunk-r7kmsq3n.js";import{Ur}from"./chunk-8nryyqb5.js";var ae=1000,ue=!1;function fe(n,r){let o=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",s=0,i;while((i=o.exec(n))!==null){let p=i.index+i[0].length,y=i.index+i[0].indexOf("("),m=w(n,"(",")",y);if(m===-1)continue;let c=n.slice(p,m).trim();if(!c)continue;if(!Object.keys(r).some((b)=>new RegExp(`(?:^|[^\\w$.])${b.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(c)))continue;let g;try{let b=E(c,r);if(!b||typeof b!=="object")continue;g=JSON.stringify(b)}catch{continue}e+=n.slice(s,p)+g,s=m,o.lastIndex=m}return s===0?n:e+n.slice(s)}function ge(n,r){let o=/@component\s*\(/g,e=n,s,i=[];while((s=o.exec(e))!==null){let p=s.index,y=p+s[0].length-1,m=1,c=y+1;while(c<e.length&&m>0){if(e[c]==="(")m++;else if(e[c]===")"){if(m--,m===0)break}c++}if(m!==0)continue;let f=e.substring(y+1,c),g=c+1,b=f.match(/^\s*['"]([^'"]+)['"]/);if(!b)continue;let x=b[1],h=f.slice(b[0].length),_=h.match(/^\s*,\s*/);if(!_)continue;let S=h.slice(_[0].length).trim();if(!S)continue;try{let P=E(S,r),F=JSON.stringify(P),R=`@component('${x}', ${F})`;i.push({start:p,end:g,replacement:R})}catch{continue}}for(let p=i.length-1;p>=0;p--){let{start:y,end:m,replacement:c}=i[p];e=e.substring(0,y)+c+e.substring(m)}return e}function te(n,r,o){let e=n,s=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),i;while((i=s.exec(e))!==null){let p=i.index,y=p+i[0].length-1,m=1,c=y+1,f=null,g=!1;while(c<e.length&&m>0){let h=e[c];if(g){g=!1,c++;continue}if(h==="\\"&&f){g=!0,c++;continue}if(f){if(h===f)f=null;c++;continue}if(h==='"'||h==="'"||h==="`"){f=h,c++;continue}if(h==="(")m++;else if(h===")"){if(m--,m===0)break}c++}if(m!==0)break;let b=e.substring(y+1,c),x=o(b);e=e.substring(0,p)+x+e.substring(c+1)}return e}function pe(n,r){let o=n;return o=o.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,s)=>{if(s in r)return`:${s}="${s}"`;return e}),o=o.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,s,i)=>{try{let p=Object.keys(r),y=Object.values(r);Fo(i);let c=u(i,p)(...y),f=JSON.stringify(c);if(f===void 0){if(!et(i).some((x)=>!(x in r)))return"";return e}let g=Buffer.from(f,"utf8").toString("base64");return`__stx_${s}="${g}"`}catch(p){return e}}),o}var Y="<!--__STX_BREAK__-->",G="<!--__STX_CONTINUE__-->";function se(n,r){let o=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",s=0;for(let i=o.exec(n);i;i=o.exec(n)){if(!i[1]){let c=i[0].length===3&&i[0]==="{{{"?3:2,f=i[0]==="{!!"?n.indexOf("!!}",o.lastIndex):he(n,i.index,c);if(f<0)break;o.lastIndex=f+(i[0]==="{!!"?3:c);continue}let p=o.lastIndex,y=!0,m=/^\s*\(/.exec(n.slice(p));if(m){let c=p+m[0].length-1,f=w(n,"(",")",c);if(f<0)break;p=f+1;try{let g=`!!(${n.slice(c+1,f).trim()})`;y=d(g)?Boolean(u(g,Object.keys(r))(...Object.values(r))):Boolean(l(g,r))}catch{y=!1}}if(e+=n.slice(s,i.index),y)return e+(i[1]==="break"?Y:G);s=p,o.lastIndex=p}return e+n.slice(s)}function oe(n){let r=(s)=>s.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),o="",e=0;return It(n,(s,i,p)=>(o+=ne(r(n.slice(e,p))),o+=`\${__stxRenderLoopValue(${p}, (${i}), ${s.length})}`,e=p+s.length,s)),o+ne(r(n.slice(e)))}function ie(n,r,o,e){return K(n,r,o==null?"":String(o),!1,e)}function ne(n){let r=n;return r=te(r,"@break",(o)=>{let e=o.trim();if(!ws(e))return"";return`\`; if (${e}) { break; } result += \``}),r=te(r,"@continue",(o)=>{let e=o.trim();if(!ws(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function de(n){let r=/@forelse\s*\(/g,o,e=[],s=/@foreach\s*\(/g,i=/@endforeach/g,p;while((p=s.exec(n))!==null)e.push({pos:p.index,delta:1});while((p=i.exec(n))!==null)e.push({pos:p.index,delta:-1});e.sort((f,g)=>f.pos-g.pos);let y=[],m=0;for(let f of e)m+=f.delta,y.push({pos:f.pos,depth:m});function c(f){let g=0,b=y.length-1,x=0;while(g<=b){let h=g+b>>1;if(y[h].pos<=f)x=y[h].depth,g=h+1;else b=h-1}return x}while((o=r.exec(n))!==null){if(c(o.index)>0)continue;let f=o.index,g=o.index+o[0].length-1,b=1,x=g+1,h=-1;while(x<n.length&&b>0){if(n[x]==="(")b++;else if(n[x]===")"){if(b--,b===0){h=x;break}}x++}if(h===-1)continue;let _=n.substring(g+1,h),S=Et(_);if(!S)continue;let{arrayExpr:P,itemVar:F}=S,R=h+1,N=1,U=R,v=/@forelse\s*\(/g,V=/@endforelse/g,I=-1;while(N>0&&U<n.length){v.lastIndex=U,V.lastIndex=U;let A=v.exec(n),T=V.exec(n);if(!T)break;if(A&&A.index<T.index)N++,U=A.index+A[0].length;else{if(N--,N===0){I=T.index;break}U=T.index+11}}if(I===-1)continue;let j=n.substring(R,I),z=I+11,M=-1,W=0,O=0;while(O<j.length){let A=j.indexOf("@",O);if(A===-1)break;let T=j.substring(A);if(/^@forelse\s*\(/.test(T))W++,O=A+1;else if(T.startsWith("@endforelse"))W--,O=A+11;else if(W===0&&T.startsWith("@empty")){if(j.length<=A+6||!/[a-z]/i.test(j[A+6])){M=A;break}O=A+1}else O=A+1}if(M===-1)continue;return{start:f,end:z,arrayExpr:P,itemVar:F,foreachContent:j.substring(0,M),emptyContent:j.substring(M+6)}}return null}function re(n,r){let o=n;while(!0){let e=de(o);if(!e)break;let{start:s,end:i,arrayExpr:p,itemVar:y,foreachContent:m,emptyContent:c}=e;try{let f;if(d(p))f=u(p,Object.keys(r))(...Object.values(r));else f=l(p,r);let g;if(!Array.isArray(f)||f.length===0)g=c;else g=`@foreach (${p} as ${y})${m}@endforeach`;o=o.substring(0,s)+g+o.substring(i)}catch(f){let g=f instanceof Error?f.message:String(f),b=a("Forelse",`Error in @forelse(${p} as ${y}): ${g}`,t.EVALUATION_ERROR);o=o.substring(0,s)+b+o.substring(i)}}return o}var ce="<!--stx:foreach-not-iterable:",me=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function be(n,r){return`${ce}${encodeURIComponent(n)}|${encodeURIComponent(r)}-->`}function xe(n,r){console.warn(`[stx] @foreach(${n}) in ${r}: ${n} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function Nr(n){if(!n.includes(ce))return n;return n.replace(me,(r,o,e)=>(xe(decodeURIComponent(o),decodeURIComponent(e)),""))}function qn(n,r,o,e,s=!1){let i=n;i=re(i,r);function p(c){let f=/@foreach\s*\(/g,g;while((g=f.exec(c))!==null){let b=g.index,x=g.index+g[0].length-1,h=1,_=x+1,S=-1;while(_<c.length&&h>0){if(c[_]==="(")h++;else if(c[_]===")"){if(h--,h===0){S=_;break}}_++}if(S===-1)continue;let P=c.substring(x+1,S),F=Et(P);if(!F)continue;let R=b,{arrayExpr:N,itemVar:U}=F,v=S+1,V=1,I=v,j=/@foreach\s*\(/g,z=/@endforeach/g;while(V>0&&I<c.length){j.lastIndex=I,z.lastIndex=I;let M=j.exec(c),W=z.exec(c);if(!W)break;if(M&&M.index<W.index)V++,I=M.index+M[0].length;else{if(V--,V===0){let O=c.substring(v,W.index),A=W.index+11;return{start:R,end:A,arrayExpr:N,itemVar:U,content:O}}I=W.index+11}}}return null}function y(c,f){let g=c;while(!0){let b=p(g);if(!b)break;let{start:x,end:h,arrayExpr:_,itemVar:S,content:P}=b;try{let F=_.trim(),R;if(d(F))R=u(F,Object.keys(f))(...Object.values(f));else R=l(F,f);let N=!1;if(!Array.isArray(R))if(R instanceof Map)R=Array.from(R),N=!0;else if(R instanceof Set)R=Array.from(R);else if(typeof R==="string")R=Array.from(R);else if(R&&typeof R==="object"&&!(R instanceof Date)&&!(R instanceof RegExp))R=Object.entries(R),N=!0;else{let O=be(F,o)+a("Foreach",`Error in @foreach: ${F} is not iterable`,t.TYPE_ERROR);g=g.substring(0,x)+O+g.substring(h);continue}let U=e?.loops?.useAltLoopVariable??ue,v=S.trim(),V=null,I,j=!1;if(v.includes("=>")){let O=v.split("=>").map((A)=>A.trim());if(O.length===2&&O[0]&&O[1])V=O[0],I=O[1];else I=v}else if(!v.startsWith("[")&&!v.startsWith("{")&&v.includes(",")){let O=v.split(",").map((A)=>A.trim());if(O.length===2&&O[0]&&O[1])I=O[0],V=O[1],j=!0;else I=v}else I=v;let z="",M=R,W=f[vs]??new WeakMap;for(let O=0;O<M.length;O++){let A=M[O],T={index:O,iteration:O+1,first:O===0,last:O===M.length-1,count:M.length},L={...f,loop:T,$loop:T,[vs]:W};if(I.startsWith("[")&&I.endsWith("]")){let J=I.slice(1,-1).split(",").map((B)=>B.trim());if(Array.isArray(A))J.forEach((B,D)=>{if(B)L[B]=A[D]});else L[I]=A}else if(I.startsWith("{")&&I.endsWith("}")){let J=I.slice(1,-1).split(",").map((B)=>B.trim()).filter(Boolean);if(A!==null&&typeof A==="object")J.forEach((B)=>{let D=B.indexOf(":"),q=(D===-1?B:B.slice(0,D)).trim(),Q=D===-1?q:B.slice(D+1).trim();if(q&&Q)L[Q]=A[q]});else L[I]=A}else L[I]=A;if(V)if(!j&&N&&Array.isArray(A)&&A.length===2)L[V]=A[0],L[I]=A[1];else L[V]=O;let C=re(P,L);C=qn(C,L,o,e,!0),C=ee(C,L,o),C=se(C,L);let Z=C.indexOf(Y),H=C.indexOf(G),X=Z<0?H:H<0?Z:Math.min(Z,H);if(X>=0)C=C.slice(0,X);if(C=k(C,L,o),C=pe(C,L),C=ge(C,L),C=fe(C,L),z+=C,X>=0&&X===Z)break}g=g.substring(0,x)+z+g.substring(h)}catch(F){let R=a("Foreach",`Error in @foreach(${_.trim()} as ${S.trim()}): ${F instanceof Error?F.message:String(F)}`,t.EVALUATION_ERROR);g=g.substring(0,x)+R+g.substring(h)}}return g}i=y(i,r),i=ye(i,r,o,e);let m=e?.loops?.maxWhileIterations??ae;return i=Re(i,r,m),s?i:Nr(i)}function xl(n){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(n);if(!r||/^(?:const|let|var)$/.test(r[2]))return n;return`${r[1]}let ${n.slice(r[1].length)}`}function le(n){return ws(n)}function ye(n,r,o,e){let s=n,i=!0;while(i){i=!1;let p=s.match(/@for\s*\(/);if(!p||p.index===void 0)break;let y=p.index,m=y+p[0].length-1,c=w(s,"(",")",m);if(c===-1)break;let f=xl(s.slice(m+1,c)),g=c+1,b=Ur(s.slice(y),"for","endfor");if(b.length===0)break;let x=b[0].content,h=y+b[0].end;if(!le(f)){let _=a("For",`Unsafe expression in @for: ${f}`,t.UNSAFE_EXPRESSION);s=s.substring(0,y)+_+s.substring(h),i=!0;continue}try{let _=Ee(f),S=/@(?:for|foreach|if|unless)\s*\(/.test(x);if(_.length>0&&S){let v=$e({forExpr:f,content:x,iterVarNames:_,context:r,filePath:o,options:e});s=s.substring(0,y)+v+s.substring(h),i=!0;continue}let P=Object.keys(r),F=Object.values(r),R=oe(x),U=Function(...P,"__stxRenderLoopValue",`
3
3
  let result = '';
4
4
  for (${f}) {
5
5
  result += \`${R}\`;
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{M,I,vr,wr,xr}from"./chunk-hvzzhkhr.js";import{resolve as k,basename as J,extname as K,join as Y}from"path";import{mkdir as Z}from"fs/promises";var N={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0};class ei{config;constructor(t={}){this.config={...N,...t}}async get(t,e){return vr(t,e,"video",this.config)}async set(t,e,a){return wr(t,e,a,"video",this.config)}async clear(){return xr("video",this.config)}updateConfig(t){this.config={...this.config,...t}}}var V=null;function T(t){if(!V)V=new ei(t);else if(t)V.updateConfig(t);return V}async function ti(t,e,a){let c=a?{directory:`${a.outputDir}/../.cache`}:{};return T(c).get(t,e)}async function ni(t,e,a,c){let r=c?{directory:`${c.outputDir}/../.cache`}:{};return T(r).set(t,e,a)}async function Cu(){return T().clear()}import{resolve as B,basename as _,extname as D,join as v}from"path";import{mkdir as A}from"fs/promises";async function L(){try{return await import("ts-videos")}catch{return null}}async function ri(t,e,a,c){let r=await L();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let n=B(t);if(!await I(n))return null;await A(a,{recursive:!0});let i=await M(n),s=_(t,D(t)),o=e.format||"webp",h=e.timestamp||0,y=`${s}-poster-${i}.${o}`,u=v(a,y),m=await r.extractThumbnails(n,{timestamps:[h],width:e.width||1280,height:e.height,format:o,quality:e.quality||85,outputDir:a,outputPattern:y.replace(`.${o}`,"")});if(m&&m.length>0){let d=m[0];return{path:u,url:`${c}/${y}`,width:d.width||e.width||1280,height:d.height||720,timestamp:h,size:d.size||0}}return null}catch(n){return console.warn(`[stx-media] Failed to generate poster: ${n}`),null}}async function si(t,e,a,c){let r=await L();if(!r)return[];try{let n=B(t);if(!await I(n))return[];await A(a,{recursive:!0});let i=await M(n),s=_(t,D(t)),o=e.format||"webp",u=(await new r.Input(n).getInfo()).duration||60,m=e.count||10,d=e.interval||u/m,g=[];for(let f=0;f<m&&f*d<u;f++)g.push(f*d);let l=await r.extractThumbnails(n,{timestamps:g,width:e.width||320,format:o,quality:e.quality||80,outputDir:a,outputPattern:`${s}-thumb-${i}`});if(l&&l.length>0)return l.map((f,b)=>({path:f.path||v(a,`${s}-thumb-${i}-${b}.${o}`),url:`${c}/${s}-thumb-${i}-${b}.${o}`,width:f.width||e.width||320,height:f.height||180,timestamp:g[b],size:f.size||0}));return[]}catch(n){return console.warn(`[stx-media] Failed to generate thumbnails: ${n}`),[]}}async function _u(t,e,a,c){let r=await L();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let n=B(t);if(!await I(n))return null;await A(a,{recursive:!0});let i=await M(n),s=_(t,D(t)),y=(await new r.Input(n).getInfo()).duration||60,u=e.columns||10,m=e.interval||5,d=e.thumbnailWidth||160,g=e.thumbnailHeight||90,l=e.format||"jpeg",f=Math.ceil(y/m),b=Math.ceil(f/u),S=`${s}-sprite-${i}.${l}`,w=v(a,S),C=[];for(let P=0;P<f;P++)C.push(P*m);let p=await r.extractThumbnails(n,{timestamps:C,width:d,height:g,format:l,quality:e.quality||70,outputDir:v(a,".temp")});if(!p||p.length===0)return null;try{let P=await import("ts-images"),x=u*d,ie=b*g,re=await P.createSprite({images:p.map((U)=>U.path),columns:u,padding:0,outputPath:w,format:l,quality:e.quality||70});return{url:`${c}/${S}`,path:w,columns:u,rows:b,thumbnailWidth:d,thumbnailHeight:g,interval:m,totalFrames:f}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(n){return console.warn(`[stx-media] Failed to generate sprite sheet: ${n}`),null}}import{resolve as F,basename as W,extname as q,join as R}from"path";import{mkdir as H,writeFile as z}from"fs/promises";async function j(){try{return await import("ts-videos")}catch{return null}}var Q=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}];async function oi(t,e,a,c,r){let n=await j();if(!n)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let i=F(t);if(!await I(i))return null;let s=await M(i),o=W(t,q(t)),h=R(a,`${o}-${s}-hls`);await H(h,{recursive:!0});let y=e.length>0?e:Q,u=r?.segmentDuration||6,g=(await new n.Input(i).getInfo()).duration||0,l=[],f=0;for(let w of y){let C=R(h,w.label);await H(C,{recursive:!0});let p=`${w.label}.m3u8`,P=R(C,p);try{let x=await n.generateHLS(i,{outputDir:C,segmentDuration:u,width:w.width,height:w.height,videoBitrate:w.bitrate,audioBitrate:w.audioBitrate,playlistName:w.label});if(x)l.push({quality:w,url:`${c}/${o}-${s}-hls/${w.label}/${p}`,path:P}),f+=x.segmentCount||Math.ceil(g/u)}catch(x){console.warn(`[stx-media] Failed to generate HLS for ${w.label}: ${x}`)}}if(l.length===0)return null;let b=R(h,"master.m3u8"),S=X(l,c,o,s);return await z(b,S),{manifestUrl:`${c}/${o}-${s}-hls/master.m3u8`,manifestPath:b,playlists:l,segmentCount:f,duration:g}}catch(i){return console.warn(`[stx-media] Failed to generate HLS manifest: ${i}`),null}}function X(t,e,a,c){let r=["#EXTM3U","#EXT-X-VERSION:3"];for(let n of t){let{quality:i}=n,s=i.bitrate+(i.audioBitrate||128000),o=`${i.width}x${i.height||Math.round(i.width*9/16)}`;r.push(`#EXT-X-STREAM-INF:BANDWIDTH=${s},RESOLUTION=${o},NAME="${i.label}"`,`${i.label}/${i.label}.m3u8`)}return r.join(`
2
+ import{M,I,vr,wr,xr}from"./chunk-hvzzhkhr.js";import{resolve as k,basename as J,extname as K,join as Y}from"path";import{mkdir as Z}from"fs/promises";var N={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0};class ei{config;constructor(t={}){this.config={...N,...t}}async get(t,e){return vr(t,e,"video",this.config)}async set(t,e,a){return wr(t,e,a,"video",this.config)}async clear(){return xr("video",this.config)}updateConfig(t){this.config={...this.config,...t}}}var V=null;function T(t){if(!V)V=new ei(t);else if(t)V.updateConfig(t);return V}async function ti(t,e,a){let c=a?{directory:`${a.outputDir}/../.cache`}:{};return T(c).get(t,e)}async function ni(t,e,a,c){let r=c?{directory:`${c.outputDir}/../.cache`}:{};return T(r).set(t,e,a)}async function _u(){return T().clear()}import{resolve as B,basename as _,extname as D,join as v}from"path";import{mkdir as A}from"fs/promises";async function L(){try{return await import("ts-videos")}catch{return null}}async function ri(t,e,a,c){let r=await L();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let n=B(t);if(!await I(n))return null;await A(a,{recursive:!0});let i=await M(n),s=_(t,D(t)),o=e.format||"webp",h=e.timestamp||0,y=`${s}-poster-${i}.${o}`,u=v(a,y),m=await r.extractThumbnails(n,{timestamps:[h],width:e.width||1280,height:e.height,format:o,quality:e.quality||85,outputDir:a,outputPattern:y.replace(`.${o}`,"")});if(m&&m.length>0){let d=m[0];return{path:u,url:`${c}/${y}`,width:d.width||e.width||1280,height:d.height||720,timestamp:h,size:d.size||0}}return null}catch(n){return console.warn(`[stx-media] Failed to generate poster: ${n}`),null}}async function si(t,e,a,c){let r=await L();if(!r)return[];try{let n=B(t);if(!await I(n))return[];await A(a,{recursive:!0});let i=await M(n),s=_(t,D(t)),o=e.format||"webp",u=(await new r.Input(n).getInfo()).duration||60,m=e.count||10,d=e.interval||u/m,g=[];for(let f=0;f<m&&f*d<u;f++)g.push(f*d);let l=await r.extractThumbnails(n,{timestamps:g,width:e.width||320,format:o,quality:e.quality||80,outputDir:a,outputPattern:`${s}-thumb-${i}`});if(l&&l.length>0)return l.map((f,b)=>({path:f.path||v(a,`${s}-thumb-${i}-${b}.${o}`),url:`${c}/${s}-thumb-${i}-${b}.${o}`,width:f.width||e.width||320,height:f.height||180,timestamp:g[b],size:f.size||0}));return[]}catch(n){return console.warn(`[stx-media] Failed to generate thumbnails: ${n}`),[]}}async function Cu(t,e,a,c){let r=await L();if(!r)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let n=B(t);if(!await I(n))return null;await A(a,{recursive:!0});let i=await M(n),s=_(t,D(t)),y=(await new r.Input(n).getInfo()).duration||60,u=e.columns||10,m=e.interval||5,d=e.thumbnailWidth||160,g=e.thumbnailHeight||90,l=e.format||"jpeg",f=Math.ceil(y/m),b=Math.ceil(f/u),S=`${s}-sprite-${i}.${l}`,w=v(a,S),C=[];for(let P=0;P<f;P++)C.push(P*m);let p=await r.extractThumbnails(n,{timestamps:C,width:d,height:g,format:l,quality:e.quality||70,outputDir:v(a,".temp")});if(!p||p.length===0)return null;try{let P=await import("ts-images"),x=u*d,ie=b*g,re=await P.createSprite({images:p.map((U)=>U.path),columns:u,padding:0,outputPath:w,format:l,quality:e.quality||70});return{url:`${c}/${S}`,path:w,columns:u,rows:b,thumbnailWidth:d,thumbnailHeight:g,interval:m,totalFrames:f}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(n){return console.warn(`[stx-media] Failed to generate sprite sheet: ${n}`),null}}import{resolve as F,basename as W,extname as q,join as R}from"path";import{mkdir as H,writeFile as z}from"fs/promises";async function j(){try{return await import("ts-videos")}catch{return null}}var Q=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}];async function oi(t,e,a,c,r){let n=await j();if(!n)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let i=F(t);if(!await I(i))return null;let s=await M(i),o=W(t,q(t)),h=R(a,`${o}-${s}-hls`);await H(h,{recursive:!0});let y=e.length>0?e:Q,u=r?.segmentDuration||6,g=(await new n.Input(i).getInfo()).duration||0,l=[],f=0;for(let w of y){let C=R(h,w.label);await H(C,{recursive:!0});let p=`${w.label}.m3u8`,P=R(C,p);try{let x=await n.generateHLS(i,{outputDir:C,segmentDuration:u,width:w.width,height:w.height,videoBitrate:w.bitrate,audioBitrate:w.audioBitrate,playlistName:w.label});if(x)l.push({quality:w,url:`${c}/${o}-${s}-hls/${w.label}/${p}`,path:P}),f+=x.segmentCount||Math.ceil(g/u)}catch(x){console.warn(`[stx-media] Failed to generate HLS for ${w.label}: ${x}`)}}if(l.length===0)return null;let b=R(h,"master.m3u8"),S=X(l,c,o,s);return await z(b,S),{manifestUrl:`${c}/${o}-${s}-hls/master.m3u8`,manifestPath:b,playlists:l,segmentCount:f,duration:g}}catch(i){return console.warn(`[stx-media] Failed to generate HLS manifest: ${i}`),null}}function X(t,e,a,c){let r=["#EXTM3U","#EXT-X-VERSION:3"];for(let n of t){let{quality:i}=n,s=i.bitrate+(i.audioBitrate||128000),o=`${i.width}x${i.height||Math.round(i.width*9/16)}`;r.push(`#EXT-X-STREAM-INF:BANDWIDTH=${s},RESOLUTION=${o},NAME="${i.label}"`,`${i.label}/${i.label}.m3u8`)}return r.join(`
3
3
  `)}async function ii(t,e,a,c,r){let n=await j();if(!n)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let i=F(t);if(!await I(i))return null;let s=await M(i),o=W(t,q(t)),h=R(a,`${o}-${s}-dash`);await H(h,{recursive:!0});let y=e.length>0?e:Q,u=r?.segmentDuration||4,m=r?.minBufferTime||2,l=(await new n.Input(i).getInfo()).duration||0,f=[],b=[];for(let p of y){let P=R(h,p.label);await H(P,{recursive:!0});try{if(await n.generateDASH(i,{outputDir:P,segmentDuration:u,width:p.width,height:p.height,videoBitrate:p.bitrate,audioBitrate:p.audioBitrate})){if(f.push({bandwidth:p.bitrate,width:p.width,height:p.height||Math.round(p.width*9/16),url:`${c}/${o}-${s}-dash/${p.label}/video`}),p.audioBitrate)b.push({bandwidth:p.audioBitrate,url:`${c}/${o}-${s}-dash/${p.label}/audio`})}}catch(x){console.warn(`[stx-media] Failed to generate DASH for ${p.label}: ${x}`)}}if(f.length===0)return null;let S=R(h,"manifest.mpd"),w=G(f,b,l,u,m);await z(S,w);let C=[{type:"video",representations:f}];if(b.length>0)C.push({type:"audio",representations:b});return{manifestUrl:`${c}/${o}-${s}-dash/manifest.mpd`,manifestPath:S,adaptationSets:C,duration:l}}catch(i){return console.warn(`[stx-media] Failed to generate DASH manifest: ${i}`),null}}function G(t,e,a,c,r){let n=E(a),i=E(r),s=`<?xml version="1.0" encoding="UTF-8"?>
4
4
  <MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
5
5
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -26,4 +26,4 @@ import{M,I,vr,wr,xr}from"./chunk-hvzzhkhr.js";import{resolve as k,basename as J,
26
26
  </Representation>
27
27
  `}s+=` </AdaptationSet>
28
28
  `}return s+=` </Period>
29
- </MPD>`,s}function E(t){let e=Math.floor(t/3600),a=Math.floor(t%3600/60),c=Math.floor(t%60),r="PT";if(e>0)r+=`${e}H`;if(a>0)r+=`${a}M`;return r+=`${c}S`,r}async function O(){try{return await import("ts-videos")}catch{return null}}function ee(t){switch(t){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function te(t){switch(t){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function wc(t){let e=await O();if(!e)return null;try{let a=k(t),r=await new e.Input(a).getInfo();return{duration:r.duration||0,width:r.width||0,height:r.height||0,frameRate:r.frameRate||0,bitrate:r.bitrate||0,codec:r.videoCodec||"",audioCodec:r.audioCodec}}catch(a){return console.warn(`[stx-media] Failed to analyze video: ${a}`),null}}async function Eu(t,e,a,c){let r=await O();if(!r)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:t,processed:!1};let n=await ti(t,e,a);if(n)return n;try{let i=k(t);if(!await I(i))return{src:t,processed:!1,errors:[`Source file not found: ${t}`]};let s=a.outputDir||"dist/videos",o=a.baseUrl||"/videos";await Z(s,{recursive:!0});let h=await M(i),y=J(t,K(t)),u={src:t,processed:!0,hash:h};c?.({percentage:5,stage:"analyzing"}),u.metadata=await wc(i)||void 0;let m={};if(e.quality)m.bitrate=ee(e.quality);if(e.platform)Object.assign(m,te(e.platform));if(e.transcode)Object.assign(m,e.transcode);if(Object.keys(m).length>0||e.process){c?.({percentage:10,stage:"transcoding"});let d=`${y}-${h}.mp4`,g=Y(s,d);try{let l=await ae(i,g,m,r,(f)=>c?.({percentage:10+f*0.5,stage:"transcoding"}));if(l)u.transcoded={path:g,url:`${o}/${d}`,duration:l.duration,size:l.size,video:{codec:m.codec||"h264",width:l.width,height:l.height,bitrate:l.bitrate,frameRate:l.frameRate},audio:l.audioCodec?{codec:m.audioCodec||"aac",bitrate:m.audioBitrate||128000,sampleRate:m.sampleRate||48000,channels:m.channels||2}:void 0}}catch(l){u.errors=u.errors||[],u.errors.push(`Transcoding failed: ${l}`)}}if(e.generatePoster){c?.({percentage:65,stage:"generating-poster"});let d=typeof e.generatePoster==="object"?e.generatePoster:{timestamp:0},g=await ri(i,d,s,o);if(g)u.poster=g}if(a.thumbnails?.enabled){c?.({percentage:70,stage:"generating-thumbnails"});let d=await si(i,a.thumbnails,s,o);if(d.length>0)u.thumbnails=d}if(e.streaming){c?.({percentage:80,stage:"generating-manifests"});let d=typeof e.streaming==="object"?e.streaming:a.streaming||{format:"hls"};if(d.format==="hls"||d.format===void 0){let g=await oi(i,d.qualities||a.streaming?.defaultQualities||[],s,o);if(g)u.streaming={...u.streaming,hls:g}}if(d.format==="dash"){let g=await ii(i,d.qualities||a.streaming?.defaultQualities||[],s,o);if(g)u.streaming={...u.streaming,dash:g}}}if(e.spriteSheet)c?.({percentage:90,stage:"generating-sprite-sheet"});return c?.({percentage:100,stage:"complete"}),await ni(t,e,u,a),u}catch(i){return{src:t,processed:!1,errors:[`Processing failed: ${i}`]}}}async function ae(t,e,a,c,r){try{let i=await new c.Conversion(t,e,{videoCodec:a.codec,videoBitrate:a.bitrate,width:a.maxWidth,height:a.maxHeight,frameRate:a.frameRate,audioCodec:a.audioCodec,audioBitrate:a.audioBitrate,sampleRate:a.sampleRate,channels:a.channels}).run((s)=>{r?.(s.percentage/100)});return{duration:i.duration||0,size:i.size||0,width:i.width||a.maxWidth||0,height:i.height||a.maxHeight||0,bitrate:i.bitrate||a.bitrate||0,frameRate:i.frameRate||a.frameRate||30,audioCodec:i.audioCodec}}catch(n){return console.error(`[stx-media] Transcoding failed: ${n}`),null}}export{ei,ti,ni,Cu,ri,si,_u,oi,ii,wc,Eu};
29
+ </MPD>`,s}function E(t){let e=Math.floor(t/3600),a=Math.floor(t%3600/60),c=Math.floor(t%60),r="PT";if(e>0)r+=`${e}H`;if(a>0)r+=`${a}M`;return r+=`${c}S`,r}async function O(){try{return await import("ts-videos")}catch{return null}}function ee(t){switch(t){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function te(t){switch(t){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function wc(t){let e=await O();if(!e)return null;try{let a=k(t),r=await new e.Input(a).getInfo();return{duration:r.duration||0,width:r.width||0,height:r.height||0,frameRate:r.frameRate||0,bitrate:r.bitrate||0,codec:r.videoCodec||"",audioCodec:r.audioCodec}}catch(a){return console.warn(`[stx-media] Failed to analyze video: ${a}`),null}}async function Eu(t,e,a,c){let r=await O();if(!r)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:t,processed:!1};let n=await ti(t,e,a);if(n)return n;try{let i=k(t);if(!await I(i))return{src:t,processed:!1,errors:[`Source file not found: ${t}`]};let s=a.outputDir||"dist/videos",o=a.baseUrl||"/videos";await Z(s,{recursive:!0});let h=await M(i),y=J(t,K(t)),u={src:t,processed:!0,hash:h};c?.({percentage:5,stage:"analyzing"}),u.metadata=await wc(i)||void 0;let m={};if(e.quality)m.bitrate=ee(e.quality);if(e.platform)Object.assign(m,te(e.platform));if(e.transcode)Object.assign(m,e.transcode);if(Object.keys(m).length>0||e.process){c?.({percentage:10,stage:"transcoding"});let d=`${y}-${h}.mp4`,g=Y(s,d);try{let l=await ae(i,g,m,r,(f)=>c?.({percentage:10+f*0.5,stage:"transcoding"}));if(l)u.transcoded={path:g,url:`${o}/${d}`,duration:l.duration,size:l.size,video:{codec:m.codec||"h264",width:l.width,height:l.height,bitrate:l.bitrate,frameRate:l.frameRate},audio:l.audioCodec?{codec:m.audioCodec||"aac",bitrate:m.audioBitrate||128000,sampleRate:m.sampleRate||48000,channels:m.channels||2}:void 0}}catch(l){u.errors=u.errors||[],u.errors.push(`Transcoding failed: ${l}`)}}if(e.generatePoster){c?.({percentage:65,stage:"generating-poster"});let d=typeof e.generatePoster==="object"?e.generatePoster:{timestamp:0},g=await ri(i,d,s,o);if(g)u.poster=g}if(a.thumbnails?.enabled){c?.({percentage:70,stage:"generating-thumbnails"});let d=await si(i,a.thumbnails,s,o);if(d.length>0)u.thumbnails=d}if(e.streaming){c?.({percentage:80,stage:"generating-manifests"});let d=typeof e.streaming==="object"?e.streaming:a.streaming||{format:"hls"};if(d.format==="hls"||d.format===void 0){let g=await oi(i,d.qualities||a.streaming?.defaultQualities||[],s,o);if(g)u.streaming={...u.streaming,hls:g}}if(d.format==="dash"){let g=await ii(i,d.qualities||a.streaming?.defaultQualities||[],s,o);if(g)u.streaming={...u.streaming,dash:g}}}if(e.spriteSheet)c?.({percentage:90,stage:"generating-sprite-sheet"});return c?.({percentage:100,stage:"complete"}),await ni(t,e,u,a),u}catch(i){return{src:t,processed:!1,errors:[`Processing failed: ${i}`]}}}async function ae(t,e,a,c,r){try{let i=await new c.Conversion(t,e,{videoCodec:a.codec,videoBitrate:a.bitrate,width:a.maxWidth,height:a.maxHeight,frameRate:a.frameRate,audioCodec:a.audioCodec,audioBitrate:a.audioBitrate,sampleRate:a.sampleRate,channels:a.channels}).run((s)=>{r?.(s.percentage/100)});return{duration:i.duration||0,size:i.size||0,width:i.width||a.maxWidth||0,height:i.height||a.maxHeight||0,bitrate:i.bitrate||a.bitrate||0,frameRate:i.frameRate||a.frameRate||30,audioCodec:i.audioCodec}}catch(n){return console.error(`[stx-media] Transcoding failed: ${n}`),null}}export{ei,ti,ni,_u,ri,si,Cu,oi,ii,wc,Eu};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{t,a,Dt,Mt,Lt,je,tt,P,xs,mr,Be}from"./chunk-4e0z858k.js";var O=/(?<![\w$@])@meta\s*\(/g,I=/(?<![\w$@])@metaTag\s*\(/g,C=/(?<![\w$@])@structuredData\s*\(/g,k=/(?<![\w$@])@seo\s*\(/g;function _(e,r){return(n)=>P(e,n,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX)}function N(e){return"property"in e?`<meta property="${l(e.property)}" content="${l(e.content)}">`:`<meta name="${l(e.name)}" content="${l(e.content)}">`}function mo(e,r,n,g){if(!e.includes("@meta"))return e;let i=Dt(e,O,(s,c)=>{let o=mr(Mt(s),r);if(o.kind==="tag")return N(o.tag);if(o.kind==="empty")return"";return P("Meta",c,o.message,n,o.code)},_("Meta",n));return i=Dt(i,I,(s,c)=>{let o=Lt(s,r);if(!o.ok)return P("MetaTag",c,o.message,n,o.code);if(o.value===void 0||o.value===null)return"";if(!tt(o.value))return P("MetaTag",c,`expected an object such as { name, content }, got ${je(o.value)}`,n,t.TYPE_ERROR);let u=o.value;if(!u.name&&!u.property&&!u.httpEquiv)return P("MetaTag",c,"the tag needs a name, property or httpEquiv",n,t.INVALID_DIRECTIVE_SYNTAX);if(u.content===void 0||u.content===null||u.content===""||u.content===!1)return"";let p="<meta";if(u.name)p+=` name="${l(u.name)}"`;if(u.property)p+=` property="${l(u.property)}"`;if(u.httpEquiv)p+=` http-equiv="${l(u.httpEquiv)}"`;return p+=` content="${l(u.content)}">`,p},_("MetaTag",n)),i}function b(e){let r=(n)=>n["@context"]?{...n}:{...n,"@context":"https://schema.org"};if(tt(e))return r(e);if(Array.isArray(e)&&e.length>0&&e.every(tt))return e.map(r);return null}function E(e){return`<script type="application/ld+json">${JSON.stringify(e).replace(/<\//g,"<\\/")}</script>`}function ho(e,r,n){if(!e.includes("@structuredData"))return e;return Dt(e,C,(g,i)=>{let s=Lt(g,r);if(!s.ok)return P("StructuredData",i,s.message,n,s.code);if(s.value===void 0||s.value===null)return"";let c=b(s.value);if(!c)return P("StructuredData",i,`expected an object or an array of objects, got ${je(s.value)}`,n,t.TYPE_ERROR);try{return E(c)}catch(o){let u=o instanceof Error?o.message:String(o);return P("StructuredData",i,`the data cannot be written as JSON: ${u}`,n,t.EVALUATION_ERROR)}},_("StructuredData",n))}var j=new Set(["title","description","keywords","robots","canonical","openGraph","twitter","structuredData"]),A={image:"openGraph.image",url:"canonical or openGraph.url",type:"openGraph.type",siteName:"openGraph.siteName",locale:"openGraph.locale",og:"openGraph",author:"@meta('author', ...)"};function yo(e,r,n,g){if(!e.includes("@seo"))return e;return Dt(e,k,(i,s)=>{if(!i.trim())return P("SEO",s,"expected an object: @seo({ title, description }) or @seo(seoVariable)",n,t.INVALID_DIRECTIVE_SYNTAX);let c=Lt(i,r);if(!c.ok)return P("SEO",s,c.message,n,c.code);if(c.value===void 0||c.value===null)return"";if(!tt(c.value))return P("SEO",s,`expected an object such as { title, description }, got ${je(c.value)}`,n,t.TYPE_ERROR);try{return L(c.value,s,n)}catch(o){let u=o instanceof Error?o.message:String(o);return P("SEO",s,`Error processing @seo directive: ${u}`,n,t.EVALUATION_ERROR)}},_("SEO",n))}function R(e,r,n,g){let i=e[r];if(i===void 0||i===null||i===!1)return;if(tt(i))return i;xs(n,`${r} must be an object, got ${je(i)}; its tags were left out`,g);return}function L(e,r,n){let g=Object.keys(e).filter((o)=>!j.has(o));if(g.length>0){let o=g.map((u)=>A[u]?`${u} (use ${A[u]})`:u).join(", ");xs(r,`@seo does not read ${o}; ${g.length===1?"it was":"they were"} ignored`,n)}let i="";if(e.title)i+=`<title>${l(e.title)}</title>
2
+ import{t,a,Dt,Mt,Lt,je,tt,P,xs,mr,Be}from"./chunk-hb08vrbb.js";var O=/(?<![\w$@])@meta\s*\(/g,I=/(?<![\w$@])@metaTag\s*\(/g,C=/(?<![\w$@])@structuredData\s*\(/g,k=/(?<![\w$@])@seo\s*\(/g;function _(e,r){return(n)=>P(e,n,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX)}function N(e){return"property"in e?`<meta property="${l(e.property)}" content="${l(e.content)}">`:`<meta name="${l(e.name)}" content="${l(e.content)}">`}function mo(e,r,n,g){if(!e.includes("@meta"))return e;let i=Dt(e,O,(s,c)=>{let o=mr(Mt(s),r);if(o.kind==="tag")return N(o.tag);if(o.kind==="empty")return"";return P("Meta",c,o.message,n,o.code)},_("Meta",n));return i=Dt(i,I,(s,c)=>{let o=Lt(s,r);if(!o.ok)return P("MetaTag",c,o.message,n,o.code);if(o.value===void 0||o.value===null)return"";if(!tt(o.value))return P("MetaTag",c,`expected an object such as { name, content }, got ${je(o.value)}`,n,t.TYPE_ERROR);let u=o.value;if(!u.name&&!u.property&&!u.httpEquiv)return P("MetaTag",c,"the tag needs a name, property or httpEquiv",n,t.INVALID_DIRECTIVE_SYNTAX);if(u.content===void 0||u.content===null||u.content===""||u.content===!1)return"";let p="<meta";if(u.name)p+=` name="${l(u.name)}"`;if(u.property)p+=` property="${l(u.property)}"`;if(u.httpEquiv)p+=` http-equiv="${l(u.httpEquiv)}"`;return p+=` content="${l(u.content)}">`,p},_("MetaTag",n)),i}function b(e){let r=(n)=>n["@context"]?{...n}:{...n,"@context":"https://schema.org"};if(tt(e))return r(e);if(Array.isArray(e)&&e.length>0&&e.every(tt))return e.map(r);return null}function E(e){return`<script type="application/ld+json">${JSON.stringify(e).replace(/<\//g,"<\\/")}</script>`}function ho(e,r,n){if(!e.includes("@structuredData"))return e;return Dt(e,C,(g,i)=>{let s=Lt(g,r);if(!s.ok)return P("StructuredData",i,s.message,n,s.code);if(s.value===void 0||s.value===null)return"";let c=b(s.value);if(!c)return P("StructuredData",i,`expected an object or an array of objects, got ${je(s.value)}`,n,t.TYPE_ERROR);try{return E(c)}catch(o){let u=o instanceof Error?o.message:String(o);return P("StructuredData",i,`the data cannot be written as JSON: ${u}`,n,t.EVALUATION_ERROR)}},_("StructuredData",n))}var j=new Set(["title","description","keywords","robots","canonical","openGraph","twitter","structuredData"]),A={image:"openGraph.image",url:"canonical or openGraph.url",type:"openGraph.type",siteName:"openGraph.siteName",locale:"openGraph.locale",og:"openGraph",author:"@meta('author', ...)"};function yo(e,r,n,g){if(!e.includes("@seo"))return e;return Dt(e,k,(i,s)=>{if(!i.trim())return P("SEO",s,"expected an object: @seo({ title, description }) or @seo(seoVariable)",n,t.INVALID_DIRECTIVE_SYNTAX);let c=Lt(i,r);if(!c.ok)return P("SEO",s,c.message,n,c.code);if(c.value===void 0||c.value===null)return"";if(!tt(c.value))return P("SEO",s,`expected an object such as { title, description }, got ${je(c.value)}`,n,t.TYPE_ERROR);try{return L(c.value,s,n)}catch(o){let u=o instanceof Error?o.message:String(o);return P("SEO",s,`Error processing @seo directive: ${u}`,n,t.EVALUATION_ERROR)}},_("SEO",n))}function R(e,r,n,g){let i=e[r];if(i===void 0||i===null||i===!1)return;if(tt(i))return i;xs(n,`${r} must be an object, got ${je(i)}; its tags were left out`,g);return}function L(e,r,n){let g=Object.keys(e).filter((o)=>!j.has(o));if(g.length>0){let o=g.map((u)=>A[u]?`${u} (use ${A[u]})`:u).join(", ");xs(r,`@seo does not read ${o}; ${g.length===1?"it was":"they were"} ignored`,n)}let i="";if(e.title)i+=`<title>${l(e.title)}</title>
3
3
  `,i+=`<meta name="title" content="${l(e.title)}">
4
4
  `;if(e.description)i+=`<meta name="description" content="${l(e.description)}">
5
5
  `;if(e.keywords){let o=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;i+=`<meta name="keywords" content="${l(o)}">
@@ -43,7 +43,7 @@ import{t,a,Dt,Mt,Lt,je,tt,P,xs,mr,Be}from"./chunk-4e0z858k.js";var O=/(?<![\w$@]
43
43
  ${y}
44
44
  `),h;return h.replace(/<head[^>]*>/,`$&
45
45
  ${y}
46
- `)}function q(e){let r=e.search(/<\/head\s*>/i);return r===-1?e:e.slice(0,r)}function v(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0*39;|&apos;/g,"'").replace(/&amp;/g,"&")}function M(e){let r=e.match(/<title(?:\s[^>]*)?>([\s\S]*?)<\/title\s*>/i);return r?v(r[1].trim()):""}function x(e){return(e.match(/<meta\s[^>]*>/gi)||[]).filter((r)=>/\sname\s*=\s*["']description["']/i.test(r))}function V(e){return x(e).length>0}function G(e){for(let r of x(e)){let n=r.match(/\scontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i),g=(n?.[1]??n?.[2]??"").trim();if(g)return v(g)}return""}function l(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var Xr={name:"meta",rawParams:!0,handler:(e,r,n,g)=>{let i=mr(r,n??{});if(i.kind==="error")return P("Meta",`@meta(${r.join(", ")})`,i.message,g,i.code);if(i.kind==="empty")return"";if(n)n.__stx_runtime_head=Be(n.__stx_runtime_head??{},{meta:[i.tag]});return""},hasEndTag:!1},Jr={name:"structuredData",handler:(e,r,n,g)=>{if(e.trim()==="")return a("StructuredData","structuredData directive requires JSON-LD content",t.INVALID_DIRECTIVE_SYNTAX);try{let i=JSON.parse(e);if(!i["@context"])i["@context"]="https://schema.org";if(!i["@type"])return a("StructuredData","structuredData requires @type property",t.INVALID_DIRECTIVE_SYNTAX);return E(i)}catch(i){let s=i instanceof Error?i.message:String(i);return a("StructuredData",s,t.EVALUATION_ERROR)}},hasEndTag:!0};function kp(){return[Xr,Jr]}function Cp(e,r){let{baseUrl:n,defaultChangefreq:g="weekly",defaultPriority:i=0.5,includeLastmod:s=!0}=r,c=n.replace(/\/$/,""),o=(m)=>m.startsWith("http")?m:`${c}${m.startsWith("/")?"":"/"}${m}`,u=e.map((m)=>{let d=o(m.loc),f=m.lastmod||(s?new Date().toISOString().split("T")[0]:void 0),D=m.changefreq||g,y=m.priority??i,h=` <url>
46
+ `)}function q(e){let r=e.search(/<\/head\s*>/i);return r===-1?e:e.slice(0,r)}function v(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0*39;|&apos;/g,"'").replace(/&amp;/g,"&")}function M(e){let r=e.match(/<title(?:\s[^>]*)?>([\s\S]*?)<\/title\s*>/i);return r?v(r[1].trim()):""}function x(e){return(e.match(/<meta\s[^>]*>/gi)||[]).filter((r)=>/\sname\s*=\s*["']description["']/i.test(r))}function V(e){return x(e).length>0}function G(e){for(let r of x(e)){let n=r.match(/\scontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i),g=(n?.[1]??n?.[2]??"").trim();if(g)return v(g)}return""}function l(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var Xr={name:"meta",rawParams:!0,handler:(e,r,n,g)=>{let i=mr(r,n??{});if(i.kind==="error")return P("Meta",`@meta(${r.join(", ")})`,i.message,g,i.code);if(i.kind==="empty")return"";if(n)n.__stx_runtime_head=Be(n.__stx_runtime_head??{},{meta:[i.tag]});return""},hasEndTag:!1},Jr={name:"structuredData",handler:(e,r,n,g)=>{if(e.trim()==="")return a("StructuredData","structuredData directive requires JSON-LD content",t.INVALID_DIRECTIVE_SYNTAX);try{let i=JSON.parse(e);if(!i["@context"])i["@context"]="https://schema.org";if(!i["@type"])return a("StructuredData","structuredData requires @type property",t.INVALID_DIRECTIVE_SYNTAX);return E(i)}catch(i){let s=i instanceof Error?i.message:String(i);return a("StructuredData",s,t.EVALUATION_ERROR)}},hasEndTag:!0};function kp(){return[Xr,Jr]}function _p(e,r){let{baseUrl:n,defaultChangefreq:g="weekly",defaultPriority:i=0.5,includeLastmod:s=!0}=r,c=n.replace(/\/$/,""),o=(m)=>m.startsWith("http")?m:`${c}${m.startsWith("/")?"":"/"}${m}`,u=e.map((m)=>{let d=o(m.loc),f=m.lastmod||(s?new Date().toISOString().split("T")[0]:void 0),D=m.changefreq||g,y=m.priority??i,h=` <url>
47
47
  <loc>${T(d)}</loc>`;for(let w of m.alternates??[])h+=`
48
48
  <xhtml:link rel="alternate" hreflang="${T(w.hreflang)}" href="${T(o(w.href))}"/>`;if(f)h+=`
49
49
  <lastmod>${f}</lastmod>`;return h+=`
@@ -53,7 +53,7 @@ ${y}
53
53
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"${e.some((m)=>m.alternates?.length)?' xmlns:xhtml="http://www.w3.org/1999/xhtml"':""}>
54
54
  ${u.join(`
55
55
  `)}
56
- </urlset>`}function _p(e,r){let n=r.replace(/\/$/,""),g=new Date().toISOString().split("T")[0];return`<?xml version="1.0" encoding="UTF-8"?>
56
+ </urlset>`}function Cp(e,r){let n=r.replace(/\/$/,""),g=new Date().toISOString().split("T")[0];return`<?xml version="1.0" encoding="UTF-8"?>
57
57
  <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
58
58
  ${e.map((s)=>{let c=s.startsWith("http")?s:`${n}${s.startsWith("/")?"":"/"}${s}`;return` <sitemap>
59
59
  <loc>${T(c)}</loc>
@@ -62,4 +62,4 @@ ${e.map((s)=>{let c=s.startsWith("http")?s:`${n}${s.startsWith("/")?"":"/"}${s}`
62
62
  `)}
63
63
  </sitemapindex>`}async function Ep(e,r){let{extensions:n=[".stx",".html",".htm"],ignore:g=["_*",".*","node_modules","components","partials","layouts"]}=r,i=[],s=n.length===1?`*${n[0]}`:`*{${n.join(",")}}`,c=new Bun.Glob(`**/${s}`);for await(let o of c.scan(e)){if(g.some((f)=>{if(f.startsWith("*"))return o.includes(f.slice(1));return o.startsWith(f)||o.includes(`/${f}`)}))continue;let p=o.replace(/\\/g,"/").replace(/index\.(stx|html|htm)$/,"").replace(/\.(stx|html|htm)$/,"");if(!p.startsWith("/"))p=`/${p}`;if(p!=="/"&&p.endsWith("/"))p=p.slice(0,-1);let m=`${e}/${o}`,d;try{let f=await Bun.file(m).stat();if(f)d=new Date(f.mtime).toISOString().split("T")[0]}catch{}i.push({loc:p||"/",lastmod:d,priority:p==="/"?1:0.5})}return i.sort((o,u)=>o.loc.localeCompare(u.loc)),i}function Yr(e){let r=[];for(let n of e.rules){if(r.push(`User-agent: ${n.userAgent}`),n.allow)for(let g of n.allow)r.push(`Allow: ${g}`);if(n.disallow)for(let g of n.disallow)r.push(`Disallow: ${g}`);if(n.crawlDelay!==void 0)r.push(`Crawl-delay: ${n.crawlDelay}`);r.push("")}if(e.sitemap){let n=Array.isArray(e.sitemap)?e.sitemap:[e.sitemap];for(let g of n)r.push(`Sitemap: ${g}`)}if(e.host)r.push(`Host: ${e.host}`);return r.join(`
64
64
  `).trim()}function Tp(e){return Yr({rules:[{userAgent:"*",allow:["/"]}],sitemap:e})}function T(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}
65
- export{mo,ho,yo,bo,Xr,Jr,kp,Cp,_p,Ep,Yr,Tp};
65
+ export{mo,ho,yo,bo,Xr,Jr,kp,_p,Cp,Ep,Yr,Tp};
@@ -1,14 +1,14 @@
1
1
  // @bun
2
- import{Qn}from"./chunk-qrt8b179.js";import{dr}from"./chunk-4e0z858k.js";import{i}from"./chunk-ajgxj2t9.js";import{U,qe}from"./chunk-szyqxcfj.js";import{la}from"./chunk-g8r0km7g.js";var p=/<style\b[^>]*>/iy,x=/<\/style>/gi,R=/<script\b[^>]*>/iy,b=/<template(?=[\s>/])[^>]*>/iy,S=/<\/template\s*>/iy;function Gn(e){let r=0,t=0,o=-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 u=p.exec(e);if(u){x.lastIndex=n+u[0].length;let d=x.exec(e);r=d===null?e.length:d.index+8;continue}b.lastIndex=n;let c=b.exec(e);if(c){if(t===0)o=n;t++,r=n+c[0].length;continue}S.lastIndex=n;let a=S.exec(e);if(a){if(t>0)t--;r=n+a[0].length;continue}if(R.lastIndex=n,R.test(e))return t>0?o:n;r=n+1}return-1}function V(e,r={}){return new Qn(e,r).routes}import w from"path";var T=new Map;async function y(e,r){let t=e,o=r;if(!t||!o)try{let a=await i();t||=a?.pagesDir||"pages",o||=a?.root||"."}catch{t||="pages",o||="."}let n=w.isAbsolute(t)?t:w.join(o,t),u=T.get(n);if(u)return u;let c=[];try{c=V(".",{pagesDir:n,emit:!1}).map((a)=>a.regex.source).filter(Boolean)}catch{c=[]}return T.set(n,c),c}function O(e){return e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function l(e){return O(JSON.stringify(e))}function ge(e){return e.includes("data-stx-runtime")}function aa(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 o=e.slice(Math.max(0,t.index-80),t.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(o))continue;return!0}return!1}function f(e,r){let t=Gn(e),o=e.search(/<!doctype\b/i);if(t!==-1&&(o===-1||t>o))return e.slice(0,t)+r+`
2
+ import{Qn}from"./chunk-zaaeneq6.js";import{dr}from"./chunk-hb08vrbb.js";import{i}from"./chunk-2h92dm3t.js";import{U,qe}from"./chunk-szyqxcfj.js";import{la}from"./chunk-g8r0km7g.js";var p=/<style\b[^>]*>/iy,x=/<\/style>/gi,R=/<script\b[^>]*>/iy,b=/<template(?=[\s>/])[^>]*>/iy,S=/<\/template\s*>/iy;function Gn(e){let r=0,t=0,o=-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 u=p.exec(e);if(u){x.lastIndex=n+u[0].length;let d=x.exec(e);r=d===null?e.length:d.index+8;continue}b.lastIndex=n;let c=b.exec(e);if(c){if(t===0)o=n;t++,r=n+c[0].length;continue}S.lastIndex=n;let a=S.exec(e);if(a){if(t>0)t--;r=n+a[0].length;continue}if(R.lastIndex=n,R.test(e))return t>0?o:n;r=n+1}return-1}function V(e,r={}){return new Qn(e,r).routes}import w from"path";var T=new Map;async function y(e,r){let t=e,o=r;if(!t||!o)try{let a=await i();t||=a?.pagesDir||"pages",o||=a?.root||"."}catch{t||="pages",o||="."}let n=w.isAbsolute(t)?t:w.join(o,t),u=T.get(n);if(u)return u;let c=[];try{c=V(".",{pagesDir:n,emit:!1}).map((a)=>a.regex.source).filter(Boolean)}catch{c=[]}return T.set(n,c),c}function O(e){return e.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function l(e){return O(JSON.stringify(e))}function ge(e){return e.includes("data-stx-runtime")}function aa(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 o=e.slice(Math.max(0,t.index-80),t.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(o))continue;return!0}return!1}function f(e,r){let t=Gn(e),o=e.search(/<!doctype\b/i);if(t!==-1&&(o===-1||t>o))return e.slice(0,t)+r+`
3
3
  `+e.slice(t);let n=dr(e);if(n!==null)return`${e.slice(0,n)}
4
4
  ${r}${e.slice(n)}`;if(e.includes("</head>")){let c=e.indexOf("</head>");return e.slice(0,c)+r+`
5
5
  `+e.slice(c)}if(U(e))return qe(e,(c)=>`${c}
6
6
  ${r}`);return`${r}
7
- ${e}`}async function Kn(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-njmdbz8t.js"),{url:u}=await n("runtime",r.debug===!0);return f(e,`<script data-stx-runtime src="${u}"></script>`)}if(r.buildMode==="compile")return f(e,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:t}=await import("./chunk-njmdbz8t.js"),o=await t(r.debug);return f(e,`<script data-stx-scoped data-stx-runtime>${o}</script>`)}function m(e){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(e)}function ca(e){if(e.includes("data-stx-tooltip-runtime")||!m(e))return e;let r=`<script data-stx-scoped data-stx-tooltip-runtime>${la()}</script>`,t=e.lastIndexOf("</body>");if(t===-1)return`${e}
7
+ ${e}`}async function Kn(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-v5r6abrq.js"),{url:u}=await n("runtime",r.debug===!0);return f(e,`<script data-stx-runtime src="${u}"></script>`)}if(r.buildMode==="compile")return f(e,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:t}=await import("./chunk-v5r6abrq.js"),o=await t(r.debug);return f(e,`<script data-stx-scoped data-stx-runtime>${o}</script>`)}function m(e){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(e)}function ca(e){if(e.includes("data-stx-tooltip-runtime")||!m(e))return e;let r=`<script data-stx-scoped data-stx-tooltip-runtime>${la()}</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 me(e,r){if(!e.includes("</body>"))return e;if(C(e))return e;let t=r?.router,o="",n="";{let s={};if(t){if(t.container)s.container=t.container;if(t.interceptAllLinks!==void 0)s.interceptAllLinks=t.interceptAllLinks;if(t.progress!==void 0)s.progress=t.progress;if(t.viewTransitions!==void 0)s.viewTransitions=t.viewTransitions;if(t.viewTransitionDuration!==void 0)s.viewTransitionDuration=t.viewTransitionDuration;if(t.viewTransitionEasing!==void 0)s.viewTransitionEasing=t.viewTransitionEasing;if(t.scrollToTop!==void 0)s.scrollToTop=t.scrollToTop;if(t.scrollRestoration!==void 0)s.scrollRestoration=t.scrollRestoration;if(t.prefetch!==void 0)s.prefetch=t.prefetch;if(t.cache!==void 0)s.cache=t.cache;if(t.progressColor!==void 0)s.progressColor=t.progressColor;if(t.progressHeight!==void 0)s.progressHeight=t.progressHeight;if(t.prefetchVisible!==void 0)s.prefetchVisible=t.prefetchVisible;if(t.prefetchVisibleMax!==void 0)s.prefetchVisibleMax=t.prefetchVisibleMax;if(t.keepOpening!==void 0)s.keepOpening=t.keepOpening}try{let g=await y(r?.pagesDir,r?.root);if(g.length>0)if(r?.buildMode==="serve"){let{registerServeModuleBundle:h}=await import("./chunk-njmdbz8t.js");n=`<script data-stx-owned-routes src="${h(`(window.__stxRouterConfig=window.__stxRouterConfig||{}).ownedRoutes=${l(g)};
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 me(e,r){if(!e.includes("</body>"))return e;if(C(e))return e;let t=r?.router,o="",n="";{let s={};if(t){if(t.container)s.container=t.container;if(t.interceptAllLinks!==void 0)s.interceptAllLinks=t.interceptAllLinks;if(t.progress!==void 0)s.progress=t.progress;if(t.viewTransitions!==void 0)s.viewTransitions=t.viewTransitions;if(t.viewTransitionDuration!==void 0)s.viewTransitionDuration=t.viewTransitionDuration;if(t.viewTransitionEasing!==void 0)s.viewTransitionEasing=t.viewTransitionEasing;if(t.scrollToTop!==void 0)s.scrollToTop=t.scrollToTop;if(t.scrollRestoration!==void 0)s.scrollRestoration=t.scrollRestoration;if(t.prefetch!==void 0)s.prefetch=t.prefetch;if(t.cache!==void 0)s.cache=t.cache;if(t.progressColor!==void 0)s.progressColor=t.progressColor;if(t.progressHeight!==void 0)s.progressHeight=t.progressHeight;if(t.prefetchVisible!==void 0)s.prefetchVisible=t.prefetchVisible;if(t.prefetchVisibleMax!==void 0)s.prefetchVisibleMax=t.prefetchVisibleMax;if(t.keepOpening!==void 0)s.keepOpening=t.keepOpening}try{let g=await y(r?.pagesDir,r?.root);if(g.length>0)if(r?.buildMode==="serve"){let{registerServeModuleBundle:h}=await import("./chunk-v5r6abrq.js");n=`<script data-stx-owned-routes src="${h(`(window.__stxRouterConfig=window.__stxRouterConfig||{}).ownedRoutes=${l(g)};
10
10
  `)}"></script>
11
11
  `}else s.ownedRoutes=g}catch{}if(Object.keys(s).length>0)o=`<script>window.__stxRouterConfig=${l(s)};</script>
12
- `}let{getCachedRouterScript:u,getServeClientAsset:c}=await import("./chunk-njmdbz8t.js"),a=r?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':r?.buildMode==="serve"?`<script data-stx-router src="${(await c("router")).url}"></script>`:`<script data-stx-router>${await u()}</script>`,d=e.lastIndexOf("</body>");return e.slice(0,d)+o+n+a+`
12
+ `}let{getCachedRouterScript:u,getServeClientAsset:c}=await import("./chunk-v5r6abrq.js"),a=r?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':r?.buildMode==="serve"?`<script data-stx-router src="${(await c("router")).url}"></script>`:`<script data-stx-router>${await u()}</script>`,d=e.lastIndexOf("</body>");return e.slice(0,d)+o+n+a+`
13
13
  </body>`+e.slice(d+7)}
14
14
  export{Gn,V,ge,aa,Kn,ca,me};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- function t(n){if(!n||typeof n!=="object")return!1;let i=n;return typeof i.message==="string"&&(i.name==="BuildMessage"||i.name==="ResolveMessage"||("position"in i))}function o(n){if(n&&typeof n==="object"&&Array.isArray(n.errors))return n.errors;return[n]}function zn(n,i){let e=[];for(let r of o(n)){if(t(r)){let s=r.position||void 0;e.push({file:i||s?.file,line:s?.line,column:s?.column,message:r.message??"",lineText:s?.lineText});continue}e.push({file:i,message:r instanceof Error?r.message:String(r)})}return e}function _e(n,i){return zn(n,i).map((e)=>{let r=e.file?`${e.file}${e.line?`:${e.line}${e.column?`:${e.column}`:""}`:""}`:"",s=e.lineText?`
2
+ function t(n){if(!n||typeof n!=="object")return!1;let i=n;return typeof i.message==="string"&&(i.name==="BuildMessage"||i.name==="ResolveMessage"||("position"in i))}function o(n){if(n&&typeof n==="object"&&Array.isArray(n.errors))return n.errors;return[n]}function zn(n,i){let e=[];for(let r of o(n)){if(t(r)){let s=r.position||void 0;e.push({file:i||s?.file,line:s?.line,column:s?.column,message:r.message??"",lineText:s?.lineText});continue}e.push({file:i,message:r instanceof Error?r.message:String(r)})}return e}function Ce(n,i){return zn(n,i).map((e)=>{let r=e.file?`${e.file}${e.line?`:${e.line}${e.column?`:${e.column}`:""}`:""}`:"",s=e.lineText?`
3
3
  ${e.lineText.trim()}`:"";return r?`${r}: ${e.message}${s}`:`${e.message}${s}`}).join(`
4
- `)}export{zn,_e};
4
+ `)}export{zn,Ce};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Ta,n,de}from"./chunk-y4nhcrf1.js";import{Ye}from"./chunk-x34scshq.js";import{c}from"./chunk-dxk5sqtv.js";import o from"fs";import l from"path";var El=new Map,m=new Map;async function gp(e){let r;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(s){r=s;break}throw m.delete(e),Error(`File not found: ${e}${r?` (${r.message})`:""}`)}function mp(e){m.delete(e)}function hp(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function yp(e){x=e}async function Tl(e=!1){let t=x??await import("./chunk-c9b0cme2.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function $l(){if(S===null){let{getRouterScript:e}=await import("./chunk-50pkybyn.js");S=e()}return S}var y={};async function bp(e,t=!1){let r=e==="runtime"?await Tl(t):await $l(),i=e==="runtime"&&t?"runtime-debug":e,s=y[i];if(!s||s.content!==r)s={content:r,hash:Bun.hash(r).toString(16).padStart(16,"0").slice(0,16)},y[i]=s;return{content:r,hash:s.hash,url:`/_stx/${e}.${s.hash}.js`}}var E=500,T=33554432,u=new Map,p=0;function C(e){return c(process.cwd(),"module-bundles",`${e}.js`)}function vp(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),r=u.get(t),i=r!==void 0;if(i)u.delete(t),p-=r.length*2;u.set(t,e),p+=e.length*2;while(u.size>1&&(u.size>E||p>T)){let s=u.keys().next().value;p-=u.get(s).length*2,u.delete(s)}if(!i)try{let s=C(t);if(!o.existsSync(s))o.mkdirSync(l.dirname(s),{recursive:!0}),o.writeFileSync(s,e)}catch{}return`/_stx/modules.${t}.js`}function uo(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function wp(){m.clear(),de(),Ta(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((r)=>({name:r.name,timing:r.timing,handler:String(r.handler)})),customDirectives:(e.customDirectives??[]).map((r)=>({name:r.name,hasEndTag:r.hasEndTag===!0,rawParams:r.rawParams===!0,handler:String(r.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Xn(e,t){try{if(!t.cachePath)return null;let r=l.resolve(t.cachePath),i=l.join(r,`${Wr(e)}.html`),s=l.join(r,`${Wr(e)}.meta.json`);if(!await n(i)||!await n(s))return null;let g=await Bun.file(s).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==Ye())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await n(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(r){return console.warn(`Cache error for ${e}:`,r),null}}async function Jn(e,t,r,i){try{if(!i.cachePath)return;let s=l.resolve(i.cachePath);await o.promises.mkdir(s,{recursive:!0});let g=l.join(s,`${Wr(e)}.html`),a=l.join(s,`${Wr(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(r),cacheVersion:i.cacheVersion,engine:Ye(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),El.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:r})}catch(s){console.warn(`Failed to cache template ${e}:`,s)}}var _=16;function Wr(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
2
+ import{Ta,n,de}from"./chunk-hzjvpcmj.js";import{Ye}from"./chunk-x34scshq.js";import{c}from"./chunk-zhf01af3.js";import o from"fs";import l from"path";var El=new Map,m=new Map;async function gp(e){let r;for(let i=0;i<3;i++)try{let g=(await o.promises.stat(e)).mtime.getTime(),a=m.get(e);if(a&&a.mtime===g)return a.content;let h=await Bun.file(e).text(),w=(await o.promises.stat(e)).mtime.getTime();if(w!==g)continue;return m.set(e,{content:h,mtime:w}),h}catch(s){r=s;break}throw m.delete(e),Error(`File not found: ${e}${r?` (${r.message})`:""}`)}function mp(e){m.delete(e)}function hp(e){for(let t of m.keys())if(t.startsWith(e))m.delete(t)}var f=null,B=null,x=null;function yp(e){x=e}async function Tl(e=!1){let t=x??await import("./chunk-eecgcj41.js");if(e)return t.generateSignalsRuntimeDev();if(f===null)f=t.generateSignalsRuntime();return f}var S=null;async function $l(){if(S===null){let{getRouterScript:e}=await import("./chunk-gzd7bmp5.js");S=e()}return S}var y={};async function bp(e,t=!1){let r=e==="runtime"?await Tl(t):await $l(),i=e==="runtime"&&t?"runtime-debug":e,s=y[i];if(!s||s.content!==r)s={content:r,hash:Bun.hash(r).toString(16).padStart(16,"0").slice(0,16)},y[i]=s;return{content:r,hash:s.hash,url:`/_stx/${e}.${s.hash}.js`}}var E=500,T=33554432,u=new Map,p=0;function C(e){return c(process.cwd(),"module-bundles",`${e}.js`)}function vp(e){let t=Bun.hash(e).toString(16).padStart(16,"0").slice(0,16),r=u.get(t),i=r!==void 0;if(i)u.delete(t),p-=r.length*2;u.set(t,e),p+=e.length*2;while(u.size>1&&(u.size>E||p>T)){let s=u.keys().next().value;p-=u.get(s).length*2,u.delete(s)}if(!i)try{let s=C(t);if(!o.existsSync(s))o.mkdirSync(l.dirname(s),{recursive:!0}),o.writeFileSync(s,e)}catch{}return`/_stx/modules.${t}.js`}function uo(e){if(!/^[0-9a-f]{16}$/.test(e))return;let t=u.get(e);if(t!==void 0)return t;try{return o.readFileSync(C(e),"utf8")}catch{return}}function wp(){m.clear(),de(),Ta(),f=null,B=null,S=null}function v(e){let t={debug:e.debug===!0,middleware:(e.middleware??[]).map((r)=>({name:r.name,timing:r.timing,handler:String(r.handler)})),customDirectives:(e.customDirectives??[]).map((r)=>({name:r.name,hasEndTag:r.hasEndTag===!0,rawParams:r.rawParams===!0,handler:String(r.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(t)).digest("hex")}async function Xn(e,t){try{if(!t.cachePath)return null;let r=l.resolve(t.cachePath),i=l.join(r,`${Wr(e)}.html`),s=l.join(r,`${Wr(e)}.meta.json`);if(!await n(i)||!await n(s))return null;let g=await Bun.file(s).text(),a=JSON.parse(g);if(a.cacheVersion!==t.cacheVersion)return null;if(a.engine!==Ye())return null;if(a.optionsSignature!==v(t))return null;if((await o.promises.stat(e)).mtime.getTime()>a.mtime)return null;for(let d of a.dependencies)if(await n(d)){if((await o.promises.stat(d)).mtime.getTime()>a.mtime)return null}else return null;return await Bun.file(i).text()}catch(r){return console.warn(`Cache error for ${e}:`,r),null}}async function Jn(e,t,r,i){try{if(!i.cachePath)return;let s=l.resolve(i.cachePath);await o.promises.mkdir(s,{recursive:!0});let g=l.join(s,`${Wr(e)}.html`),a=l.join(s,`${Wr(e)}.meta.json`),h=await o.promises.stat(e);await Bun.write(g,t);let d={sourcePath:e,mtime:h.mtime.getTime(),dependencies:Array.from(r),cacheVersion:i.cacheVersion,engine:Ye(),optionsSignature:v(i),generatedAt:Date.now()};await Bun.write(a,JSON.stringify(d,null,2)),El.set(e,{output:t,mtime:h.mtime.getTime(),dependencies:r})}catch(s){console.warn(`Failed to cache template ${e}:`,s)}}var _=16;function Wr(e){return new Bun.CryptoHasher("sha1").update(e).digest("hex").substring(0,_)}
3
3
  export{El,gp,mp,hp,yp,Tl,$l,bp,vp,uo,wp,Xn,Jn,Wr};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{El,gp,mp,hp,yp,Tl,$l,bp,vp,uo,wp,Xn,Jn,Wr}from"./chunk-sj0rrn72.js";import{Ye}from"./chunk-x34scshq.js";import"./chunk-y4nhcrf1.js";import"./chunk-5c14xpmg.js";import"./chunk-2h8ea0we.js";import"./chunk-4e0z858k.js";import"./chunk-ce6zddpf.js";import"./chunk-4qwvqbzf.js";export{yp as __setSignalsGeneratorsForTest,Ye as cacheEngineFingerprint,Jn as cacheTemplate,Xn as checkCache,wp as clearDevCaches,$l as getCachedRouterScript,Tl as getCachedSignalsRuntime,bp as getServeClientAsset,uo as getServeModuleBundle,Wr as hashFilePath,mp as invalidateFileCache,hp as invalidateFileCacheByDir,gp as readFileCached,vp as registerServeModuleBundle,El as templateCache};
2
+ import{El,gp,mp,hp,yp,Tl,$l,bp,vp,uo,wp,Xn,Jn,Wr}from"./chunk-v3kc2anv.js";import{Ye}from"./chunk-x34scshq.js";import"./chunk-hzjvpcmj.js";import"./chunk-jf17b7y9.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{yp as __setSignalsGeneratorsForTest,Ye as cacheEngineFingerprint,Jn as cacheTemplate,Xn as checkCache,wp as clearDevCaches,$l as getCachedRouterScript,Tl as getCachedSignalsRuntime,bp as getServeClientAsset,uo as getServeModuleBundle,Wr as hashFilePath,mp as invalidateFileCache,hp as invalidateFileCacheByDir,gp as readFileCached,vp as registerServeModuleBundle,El as templateCache};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-4qwvqbzf.js";import"./chunk-ce6zddpf.js";import{y,b,S,G}from"./chunk-y4nhcrf1.js";import"./chunk-4e0z858k.js";import"./chunk-2h8ea0we.js";import"./chunk-5c14xpmg.js";import f from"path";var h=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAmbientSound","useAnimationFrame","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBreathPacer","useBroadcastChannel","useBroadcastStream","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],L=new Set(h);var l=new Map,w=y(64),x=new Set,O=0,R=new Set(h);function T(){l.clear(),w.clear()}function P(n){let o=new Map;for(let r of n){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=o.get(t);if(i&&!i.endsWith(".js"))continue;o.set(t,r)}return[...o.values()].sort()}function I(n,o){let r=o.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(n)}function M(n){if(!n)return[];let o=b(n,O),r=w.get(o);if(r)return r.slice();let a=n.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of R){if(x.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),w.set(o,t),t.slice()}async function A(n,o){let r=M(n);if(r.length===0)return null;let a=o??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=G({loader:"ts",target:"browser",define:S()}),C=new Set(r),m=[],d=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=P(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let g=[];try{g=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!g.some((c)=>C.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),m.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
2
+ import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import{y,b,S,G}from"./chunk-hzjvpcmj.js";import"./chunk-hb08vrbb.js";import"./chunk-2h8ea0we.js";import"./chunk-jf17b7y9.js";import f from"path";var h=["applyOfflineUpdate","broadcast","cacheMedia","calculateDistance","canNotify","clearCookies","clearFetchCache","clearOfflineData","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","onOfflineUpdateReady","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAmbientSound","useAnimationFrame","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBreathPacer","useBroadcastChannel","useBroadcastStream","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useOutbox","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],L=new Set(h);var l=new Map,w=y(64),x=new Set,O=0,R=new Set(h);function T(){l.clear(),w.clear()}function P(n){let o=new Map;for(let r of n){let a=f.basename(r);if(a.endsWith(".d.ts"))continue;let t=a.replace(/\.[jt]s$/,"");if(t==="index")continue;if(t===a)continue;let i=o.get(t);if(i&&!i.endsWith(".js"))continue;o.set(t,r)}return[...o.values()].sort()}function I(n,o){let r=o.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${r}\\b`).test(n)}function M(n){if(!n)return[];let o=b(n,O),r=w.get(o);if(r)return r.slice();let a=n.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),t=[];for(let i of R){if(x.has(i))continue;let u=i.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${u}\\s*\\(`).test(a))t.push(i)}return t.sort(),w.set(o,t),t.slice()}async function A(n,o){let r=M(n);if(r.length===0)return null;let a=o??f.join(import.meta.dir,"composables"),t=`${a}\x00${r.join(",")}`,i=l.get(t);if(i!==void 0)return i||null;let u=G({loader:"ts",target:"browser",define:S()}),C=new Set(r),m=[],d=new Set,p=[];try{let s=new Bun.Glob("*.{ts,js}");for await(let e of s.scan({cwd:a,absolute:!0}))p.push(e)}catch{return l.set(t,""),null}p=P(p);for(let s of p){let e;try{e=await Bun.file(s).text()}catch{continue}let g=[];try{g=u.scan(e).exports.filter((c)=>c!=="default")}catch{continue}if(!g.some((c)=>C.has(c)))continue;try{e=e.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^import\s+type\s+.*$/gm,""),e=e.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),e=e.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),e=e.replace(/^export\s+default\s+/gm,""),e=e.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),m.push(`// ${f.basename(s).replace(/\.[jt]s$/,"")}
3
3
  ${u.transformSync(e).trim()}`);for(let c of g)d.add(c)}catch(c){console.warn(`[stx] framework composable ${f.basename(s)} could not be bundled:`,c)}}let v=r.filter((s)=>!d.has(s)&&!I(n,s));if(v.length>0)console.warn(`[stx] could not bundle ${v.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(m.length===0)return l.set(t,""),null;let E=[...d].map((s)=>` try { if (!(${JSON.stringify(s)} in __s)) { __s[${JSON.stringify(s)}] = ${s}; if (!(${JSON.stringify(s)} in window)) window[${JSON.stringify(s)}] = ${s}; } } catch (e) {}`).join(`
4
4
  `),k=`<script data-stx-scoped data-stx-run="always" data-stx-framework-composables>
5
5
  ;(function(){
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{N,Rl,po,i,R,xp,Sp}from"./chunk-2h92dm3t.js";import"./chunk-e7z85137.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-t9mfztcs.js";import"./chunk-zaaeneq6.js";import"./chunk-hzjvpcmj.js";import"./chunk-jf17b7y9.js";import"./chunk-2h8ea0we.js";import"./chunk-hb08vrbb.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{R as config,N as defaultConfig,xp as defineStxConfig,po as discoverConfig,i as loadStxConfig,Rl as resolveStxDirectories,Sp as validateConfig};