@stacksjs/stx 0.2.665 → 0.2.668
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.
- package/dist/chunk-028ee6q5.js +2 -0
- package/dist/{chunk-tx6p6jnk.js → chunk-02gn092e.js} +1 -1
- package/dist/chunk-02ymqwmj.js +2 -0
- package/dist/{chunk-2q50h7zv.js → chunk-060298px.js} +5 -5
- package/dist/{chunk-zpc06ysq.js → chunk-0hemydnd.js} +1 -1
- package/dist/chunk-1e79xcc8.js +2 -0
- package/dist/chunk-1pnp91wx.js +2 -0
- package/dist/{chunk-2h8ea0we.js → chunk-1sr6c0nk.js} +2 -2
- package/dist/chunk-280p4q7a.js +2 -0
- package/dist/{chunk-hb08vrbb.js → chunk-2dp7hyv7.js} +21 -21
- package/dist/chunk-2ecgyqam.js +2 -0
- package/dist/{chunk-38b3w1y4.js → chunk-2hxwds8c.js} +1 -1
- package/dist/{chunk-x34scshq.js → chunk-2zzc7006.js} +2 -2
- package/dist/{chunk-wpm58d6p.js → chunk-30nes8ne.js} +2 -2
- package/dist/{chunk-d3vgtr0t.js → chunk-3641xvaw.js} +1 -1
- package/dist/{chunk-zaaeneq6.js → chunk-365vg0eg.js} +2 -2
- package/dist/{chunk-2qbvsvwc.js → chunk-3850m7ab.js} +6 -6
- package/dist/{chunk-ewcrsyr7.js → chunk-3hxd5td3.js} +2 -2
- package/dist/chunk-3n9vaxnt.js +2 -0
- package/dist/{chunk-pxqh758g.js → chunk-3y41efsf.js} +64 -15
- package/dist/chunk-41cvkdcm.js +3 -0
- package/dist/{chunk-s3dyzxwx.js → chunk-493x6e71.js} +4 -4
- package/dist/{chunk-jrf01hfv.js → chunk-4c183zem.js} +1 -1
- package/dist/{chunk-nm8yr8a9.js → chunk-4m1hye28.js} +1 -1
- package/dist/{chunk-v5916r3j.js → chunk-4teqcbw0.js} +5 -5
- package/dist/chunk-5zgrvj4b.js +2 -0
- package/dist/{chunk-cg3mvq4h.js → chunk-61n06wra.js} +6 -6
- package/dist/{chunk-pmwb5kaf.js → chunk-65b6cy92.js} +2 -2
- package/dist/{chunk-zjsyw63k.js → chunk-6by8f7n9.js} +9 -9
- package/dist/{chunk-vjw3qrqj.js → chunk-6tngeb4b.js} +1 -1
- package/dist/{chunk-bgra36az.js → chunk-6z2sdfac.js} +1 -1
- package/dist/{chunk-yq021b3r.js → chunk-7d4z944r.js} +3 -3
- package/dist/{chunk-rjh2jwxx.js → chunk-7met6yva.js} +8 -8
- package/dist/{chunk-2jh21f1n.js → chunk-89jbdtgw.js} +1 -1
- package/dist/chunk-8kskjg62.js +2 -0
- package/dist/{chunk-q1svy1nf.js → chunk-9edksf8x.js} +1 -1
- package/dist/{chunk-1z1632np.js → chunk-9k2wz3k1.js} +41 -41
- package/dist/{chunk-577ntqeg.js → chunk-9vaz5f9j.js} +1 -1
- package/dist/chunk-avph47dc.js +2 -0
- package/dist/{chunk-mrrrngzd.js → chunk-b4pcw34n.js} +1 -1
- package/dist/chunk-b7e07ybq.js +3 -0
- package/dist/{chunk-0jhdrgpr.js → chunk-b823zxq6.js} +2 -2
- package/dist/{chunk-c9k40352.js → chunk-bdg0fydw.js} +1 -1
- package/dist/{chunk-szyqxcfj.js → chunk-bnn7pd62.js} +2 -2
- package/dist/chunk-c3dk9pkf.js +2 -0
- package/dist/chunk-c4qebqmk.js +2 -0
- package/dist/chunk-ca6vx6vg.js +2 -0
- package/dist/{chunk-dra341c0.js → chunk-cba7953e.js} +15 -15
- package/dist/{chunk-p2mrba1n.js → chunk-cyq1jcg2.js} +107 -107
- package/dist/{chunk-w2zceynt.js → chunk-dpvxe52r.js} +1 -1
- package/dist/{chunk-pc48mjkc.js → chunk-dtjybwtz.js} +4 -4
- package/dist/{chunk-nf9bykvg.js → chunk-dy5j389v.js} +5 -5
- package/dist/{chunk-np1k9vsr.js → chunk-e1fetwbr.js} +1 -1
- package/dist/chunk-e4vpr36s.js +2 -0
- package/dist/{chunk-11zp67ds.js → chunk-e8gcqp8w.js} +4 -4
- package/dist/{chunk-yh0wb4n1.js → chunk-ecqrkyg8.js} +2 -2
- package/dist/chunk-fb93n9ts.js +2 -0
- package/dist/chunk-fmkcc7g1.js +2 -0
- package/dist/{chunk-edvmtk21.js → chunk-fpz59dhz.js} +5 -5
- package/dist/{chunk-een2wqah.js → chunk-fvtwec1r.js} +1 -1
- package/dist/{chunk-t9mfztcs.js → chunk-fzqj1mjz.js} +3 -3
- package/dist/chunk-gkmpr64n.js +2 -0
- package/dist/chunk-heh151bn.js +2 -0
- package/dist/chunk-hj0raner.js +2 -0
- package/dist/chunk-hkqhpckf.js +2 -0
- package/dist/{chunk-0g4pr7ww.js → chunk-hm9jt1p9.js} +9 -9
- package/dist/{chunk-5w2jy5r9.js → chunk-hvf2e7pr.js} +2 -2
- package/dist/chunk-hx9cn2s4.js +2 -0
- package/dist/{chunk-2f1bk3bg.js → chunk-k5mez1vx.js} +1 -1
- package/dist/{chunk-r7kmsq3n.js → chunk-ka8befem.js} +1 -1
- package/dist/{chunk-b6xv8jh9.js → chunk-kpeep7gq.js} +1 -1
- package/dist/{chunk-v2x9vzgw.js → chunk-md2jn67b.js} +2 -2
- package/dist/chunk-n7a33e3v.js +2 -0
- package/dist/{chunk-d3bsfd10.js → chunk-npa7gze7.js} +2 -2
- package/dist/{chunk-8nryyqb5.js → chunk-p472crv1.js} +1 -1
- package/dist/{chunk-4yf1w261.js → chunk-pn1ehs6a.js} +2 -2
- package/dist/{chunk-7rta163c.js → chunk-pxdww4rb.js} +2 -2
- package/dist/{chunk-eqrkhc18.js → chunk-qjtpxsyx.js} +2 -2
- package/dist/{chunk-gf3bxnpq.js → chunk-qxmyaajq.js} +1 -1
- package/dist/chunk-r7cenpxp.js +2 -0
- package/dist/{chunk-fzxyq6k5.js → chunk-rcefnd1g.js} +61 -61
- package/dist/chunk-s5w3t7xw.js +2 -0
- package/dist/{chunk-43gr8ggc.js → chunk-sme31jbj.js} +2 -2
- package/dist/chunk-sz6xdz4h.js +2 -0
- package/dist/{chunk-f2z8s2h9.js → chunk-t01c62y5.js} +2 -2
- package/dist/{chunk-jh3r0qp7.js → chunk-t7jxkrbx.js} +1 -1
- package/dist/{chunk-jkvr7e91.js → chunk-tp4eqfxq.js} +2 -2
- package/dist/{chunk-7ae140wv.js → chunk-tq0bgaae.js} +1 -1
- package/dist/chunk-tw0wc95k.js +2 -0
- package/dist/chunk-v0091n1g.js +2 -0
- package/dist/{chunk-qzy8ypk4.js → chunk-vdjj4vrp.js} +40 -40
- package/dist/{chunk-gf4e5xtr.js → chunk-vfba7nz5.js} +27 -27
- package/dist/{chunk-awe50wee.js → chunk-vg9bz5zs.js} +1 -1
- package/dist/chunk-vryzt0p0.js +2 -0
- package/dist/{chunk-8dcemd4a.js → chunk-w6x8m0tz.js} +1 -1
- package/dist/chunk-wesafj4a.js +2 -0
- package/dist/chunk-x986xz7h.js +2 -0
- package/dist/{chunk-xv43szx0.js → chunk-xqp4hstk.js} +1 -1
- package/dist/{chunk-c1dkh0es.js → chunk-yfvm7q6t.js} +3 -3
- package/dist/chunk-ynh1ppa6.js +2 -0
- package/dist/{chunk-eecgcj41.js → chunk-yscr04dv.js} +1 -1
- package/dist/{chunk-a1p327a7.js → chunk-zcz97ber.js} +9 -9
- package/dist/chunk-zdgsj39g.js +2 -0
- package/dist/{chunk-5z1n02nd.js → chunk-zwkc8yge.js} +37 -37
- package/dist/cli.js +36 -36
- package/dist/client/signals-for-runtime.js +51 -2
- package/dist/client/signals-process-element-runtime.js +1 -1
- package/dist/component-renderer.js +4 -2
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/headwind-to-style.js +24 -1
- package/dist/native/compiler/html-to-ir.js +25 -5
- package/dist/native/runtime/binding-tree.d.ts +1 -0
- package/dist/native/runtime/binding-tree.js +5 -0
- package/dist/native/runtime/craft-bridge.js +1 -0
- package/dist/native/runtime/craft.d.ts +1 -0
- package/dist/native/runtime/jsc-globals.d.ts +20 -0
- package/dist/native/runtime/jsc-globals.js +52 -0
- package/dist/native/testing.d.ts +0 -1
- package/dist/native/testing.js +31 -4
- package/dist/pwa.js +3 -3
- package/dist/signal-processing.js +1 -2
- package/dist/slot-scopes.js +10 -2
- package/dist/slots.d.ts +2 -2
- package/dist/slots.js +21 -5
- package/dist/ssg.js +5 -5
- package/dist/utils.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-0eepx077.js +0 -2
- package/dist/chunk-0fhntp63.js +0 -2
- package/dist/chunk-2a4szpje.js +0 -3
- package/dist/chunk-3d39yer3.js +0 -2
- package/dist/chunk-4v9x7zz5.js +0 -2
- package/dist/chunk-5etmsv9z.js +0 -2
- package/dist/chunk-773frt6c.js +0 -2
- package/dist/chunk-8d2f2e42.js +0 -2
- package/dist/chunk-a2bw46t9.js +0 -2
- package/dist/chunk-d5pt75tp.js +0 -2
- package/dist/chunk-em3aepxz.js +0 -2
- package/dist/chunk-g53sg7e0.js +0 -2
- package/dist/chunk-gsw8g2ev.js +0 -2
- package/dist/chunk-gz90fqn8.js +0 -2
- package/dist/chunk-gzd7bmp5.js +0 -2
- package/dist/chunk-hcqyf26s.js +0 -2
- package/dist/chunk-hhmj9gpk.js +0 -2
- package/dist/chunk-k2byvram.js +0 -2
- package/dist/chunk-kph7cenp.js +0 -2
- package/dist/chunk-papqmch6.js +0 -2
- package/dist/chunk-qambfx8c.js +0 -2
- package/dist/chunk-stfqkgfv.js +0 -2
- package/dist/chunk-t34ds1e3.js +0 -2
- package/dist/chunk-t4cbrm81.js +0 -2
- package/dist/chunk-t60pt4gv.js +0 -2
- package/dist/chunk-t6yjxhn8.js +0 -2
- package/dist/chunk-w89mazpv.js +0 -2
- package/dist/chunk-wq2fq6b7.js +0 -2
- package/dist/chunk-wsp8sj9v.js +0 -3
- package/dist/chunk-x8knte1j.js +0 -2
- package/dist/chunk-y7xshkqn.js +0 -2
- package/dist/chunk-ypsym37h.js +0 -2
- package/dist/chunk-z58ybwsv.js +0 -2
- package/dist/chunk-zteaygxc.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{_o,Ea,r,
|
|
2
|
+
import{_o,Ea,r,Et,te,S,Ae,on,Pe,le,q,or,an,us,La,ln,cr,ps,gs,ja,Ao,Ba,Fa,za,Ha,Oe,Ne,ms,Le,n,pn,m,d,F,K,ve,k,_}from"./chunk-vdjj4vrp.js";import{l,p,E,t,re,z,a,we,zo,D,hn,Ho,Mt,Vo,ec,pr,tc,rt,nc,fr,rc,yn,Uo,sc,gr,hr,xe,Wo}from"./chunk-2dp7hyv7.js";import{Ot}from"./chunk-1sr6c0nk.js";import{gn}from"./chunk-kpeep7gq.js";import{h}from"./chunk-dy5j389v.js";import{er,ts}from"./chunk-365vg0eg.js";import{ua,da,Yn,Xe,pa,R}from"./chunk-9k2wz3k1.js";import{mo,ho,yo,bo}from"./chunk-fzqj1mjz.js";import{oa,Br}from"./chunk-hm9jt1p9.js";import{Dr,Mr,Lr}from"./chunk-6by8f7n9.js";import{Nr,qn}from"./chunk-dtjybwtz.js";import{Fr,io,ao,zr,Hr,co}from"./chunk-060298px.js";import{Zs}from"./chunk-prf164ct.js";import{ee,no,ro,so}from"./chunk-ka8befem.js";import{Gn,ge,aa,Kn,ca}from"./chunk-fpz59dhz.js";import{U,Ge}from"./chunk-bnn7pd62.js";import{fa,ga}from"./chunk-9edksf8x.js";import{C,bn,qo}from"./chunk-fbtv2k1p.js";import fs from"fs";import ce from"path";function lt(){return`
|
|
3
3
|
// STX Lifecycle Runtime
|
|
4
4
|
(function() {
|
|
5
5
|
if (typeof window === 'undefined') return;
|
|
@@ -347,7 +347,7 @@ else {
|
|
|
347
347
|
|
|
348
348
|
console.log('[stx] Lifecycle runtime initialized');
|
|
349
349
|
})();
|
|
350
|
-
`}function Je(c){return Symbol(c)}var Ts=Je("theme"),Cs=Je("router"),As=Je("i18n");import*as dt from"crypto";function ut(c){let e=/\$(\w+)\./g,u=[],o;while((o=e.exec(c))!==null)if(!u.includes(o[1]))u.push(o[1]);return u}function In(){return`stx-${dt.randomBytes(4).toString("hex")}`}function On(c){return/\$\w+\./.test(c)}function Pn(c){if(!/\{\{[^}]*\$\w/.test(c)||!/\$\w+\./.test(c))return{html:c,bindings:[],stores:new Set};let e=[],u=new Set,o=/<(\w+)([^>]*?)(\s*\/?>)/g,
|
|
350
|
+
`}function Je(c){return Symbol(c)}var Ts=Je("theme"),Cs=Je("router"),As=Je("i18n");import*as dt from"crypto";function ut(c){let e=/\$(\w+)\./g,u=[],o;while((o=e.exec(c))!==null)if(!u.includes(o[1]))u.push(o[1]);return u}function In(){return`stx-${dt.randomBytes(4).toString("hex")}`}function On(c){return/\$\w+\./.test(c)}function Pn(c){if(!/\{\{[^}]*\$\w/.test(c)||!/\$\w+\./.test(c))return{html:c,bindings:[],stores:new Set};let e=[],u=new Set,o=/<(\w+)([^>]*?)(\s*\/?>)/g,g=c;return g=g.replace(o,(i,f,v,y)=>{if(["script","style","template"].includes(f.toLowerCase()))return i;if(!v.includes("{{"))return i;let x=[],b=!1,w=v,T=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,A=[...v.matchAll(T)];for(let I of A){let P=I[0],N=I[1],V=I[2];if(On(V)){b=!0;let X=V.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(X){let L=X[1];if(x.push({attr:N,expr:L,fullMatch:P,originalAttr:N}),ut(L).forEach((H)=>u.add(H)),N==="text")w=w.replace(P,"");else if(N==="class")w=w.replace(P,'class=""');else if(N==="disabled"||N==="hidden")w=w.replace(P,"");else w=w.replace(P,`${N}=""`)}}}if(!b)return i;let O=w.match(/\bid\s*=\s*"([^"]+)"/),M;if(O)M=O[1];else M=In(),w=` id="${M}"${w}`;for(let I of x)e.push({elementId:M,attribute:I.attr,expression:I.expr,stores:ut(I.expr)});return`<${f}${w}${y}`}),{html:g,bindings:e,stores:u}}function Ln(c,e){if(c.length===0)return"";let u=Array.from(e),o=`
|
|
351
351
|
<script>
|
|
352
352
|
(function() {
|
|
353
353
|
'use strict';
|
|
@@ -363,11 +363,11 @@ else {
|
|
|
363
363
|
// Store references for expressions
|
|
364
364
|
// eslint-disable-next-line pickier/no-unused-vars
|
|
365
365
|
var $state = {};
|
|
366
|
-
`;for(let
|
|
366
|
+
`;for(let g of u)o+=` $state.${g} = stores.${g} ? stores.${g}.get() : {};
|
|
367
367
|
`;o+=`
|
|
368
368
|
// Binding update functions
|
|
369
369
|
function updateBindings() {
|
|
370
|
-
`;for(let
|
|
370
|
+
`;for(let g of c){let{elementId:i,attribute:f,expression:v}=g,y=v.replace(/\$(\w+)\./g,"$state.$1.");if(f==="text")o+=` (function() {
|
|
371
371
|
var el = document.getElementById('${i}');
|
|
372
372
|
if (el) {
|
|
373
373
|
try {
|
|
@@ -376,7 +376,7 @@ else {
|
|
|
376
376
|
catch (e) { console.error('Binding error:', e); }
|
|
377
377
|
}
|
|
378
378
|
})();
|
|
379
|
-
`;else if(
|
|
379
|
+
`;else if(f==="html")o+=` (function() {
|
|
380
380
|
var el = document.getElementById('${i}');
|
|
381
381
|
if (el) {
|
|
382
382
|
try {
|
|
@@ -385,7 +385,7 @@ catch (e) { console.error('Binding error:', e); }
|
|
|
385
385
|
catch (e) { console.error('Binding error:', e); }
|
|
386
386
|
}
|
|
387
387
|
})();
|
|
388
|
-
`;else if(
|
|
388
|
+
`;else if(f==="class")o+=` (function() {
|
|
389
389
|
var el = document.getElementById('${i}');
|
|
390
390
|
if (el) {
|
|
391
391
|
try {
|
|
@@ -414,7 +414,7 @@ else {
|
|
|
414
414
|
catch (e) { console.error('Binding error:', e); }
|
|
415
415
|
}
|
|
416
416
|
})();
|
|
417
|
-
`;else if(
|
|
417
|
+
`;else if(f==="show")o+=` (function() {
|
|
418
418
|
var el = document.getElementById('${i}');
|
|
419
419
|
if (el) {
|
|
420
420
|
try {
|
|
@@ -423,7 +423,7 @@ catch (e) { console.error('Binding error:', e); }
|
|
|
423
423
|
catch (e) { console.error('Binding error:', e); }
|
|
424
424
|
}
|
|
425
425
|
})();
|
|
426
|
-
`;else if(
|
|
426
|
+
`;else if(f==="if")o+=` (function() {
|
|
427
427
|
var el = document.getElementById('${i}');
|
|
428
428
|
if (el) {
|
|
429
429
|
try {
|
|
@@ -438,13 +438,13 @@ catch (e) { console.error('Binding error:', e); }
|
|
|
438
438
|
try {
|
|
439
439
|
var value = ${y};
|
|
440
440
|
if (value === false || value === null || value === undefined) {
|
|
441
|
-
el.removeAttribute('${
|
|
441
|
+
el.removeAttribute('${f}');
|
|
442
442
|
}
|
|
443
443
|
else if (value === true) {
|
|
444
|
-
el.setAttribute('${
|
|
444
|
+
el.setAttribute('${f}', '');
|
|
445
445
|
}
|
|
446
446
|
else {
|
|
447
|
-
el.setAttribute('${
|
|
447
|
+
el.setAttribute('${f}', value);
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
catch (e) { console.error('Binding error:', e); }
|
|
@@ -458,14 +458,14 @@ catch (e) { console.error('Binding error:', e); }
|
|
|
458
458
|
// using reactive-bindings stacked another subscription on every store,
|
|
459
459
|
// walking detached DOM forever. See stacksjs/stx#1709.
|
|
460
460
|
var _disposers = [];
|
|
461
|
-
`;for(let
|
|
462
|
-
var _unsub_${
|
|
463
|
-
$state.${
|
|
461
|
+
`;for(let g of u)o+=` if (stores.${g}) {
|
|
462
|
+
var _unsub_${g} = stores.${g}.subscribe(function(state) {
|
|
463
|
+
$state.${g} = state;
|
|
464
464
|
updateBindings();
|
|
465
465
|
});
|
|
466
466
|
// store.subscribe() may return the disposer (preferred) or void; both
|
|
467
467
|
// are tolerated here.
|
|
468
|
-
if (typeof _unsub_${
|
|
468
|
+
if (typeof _unsub_${g} === 'function') _disposers.push(_unsub_${g});
|
|
469
469
|
}
|
|
470
470
|
`;return o+=`
|
|
471
471
|
// Initial update
|
|
@@ -505,9 +505,9 @@ else {
|
|
|
505
505
|
}
|
|
506
506
|
})();
|
|
507
507
|
</script>
|
|
508
|
-
`,o}function pt(c){let{html:e,bindings:u,stores:o}=Pn(c);if(u.length===0)return c;let
|
|
508
|
+
`,o}function pt(c){let{html:e,bindings:u,stores:o}=Pn(c);if(u.length===0)return c;let g=Ln(u,o),i=e.lastIndexOf("</body>");if(i!==-1)return e.slice(0,i)+g+e.slice(i);return e+g}function jn(c){let e=c.analytics;if(!e?.enabled)return"";switch(e.driver){case"fathom":return Nn(e);case"google-analytics":return Bn(e);case"plausible":return Fn(e);case"self-hosted":return Un(e);case"custom":return Vn(e);default:return""}}function Nn(c){let e=c.fathom;if(!e?.siteId)return"";let u=e.scriptUrl||"https://cdn.usefathom.com/script.js",o=e.defer!==!1?" defer":"",g=[`data-site="${pe(e.siteId)}"`];if(e.honorDnt)g.push('data-honor-dnt="true"');if(e.spa)g.push('data-spa="auto"');if(e.canonical)g.push(`data-canonical="${pe(e.canonical)}"`);if(e.auto===!1)g.push('data-auto="false"');return`
|
|
509
509
|
<!-- Fathom Analytics -->
|
|
510
|
-
<script src="${pe(u)}" ${
|
|
510
|
+
<script src="${pe(u)}" ${g.join(" ")}${o}></script>
|
|
511
511
|
`}function Bn(c){let e=c.googleAnalytics;if(!e?.measurementId)return"";let u=pe(e.measurementId),o=e.debug?`gtag('config', '${u}', { 'debug_mode': true });`:"";return`
|
|
512
512
|
<!-- Google Analytics -->
|
|
513
513
|
<script async src="https://www.googletagmanager.com/gtag/js?id=${u}"></script>
|
|
@@ -518,10 +518,10 @@ else {
|
|
|
518
518
|
gtag('config', '${u}');
|
|
519
519
|
${o}
|
|
520
520
|
</script>
|
|
521
|
-
`}function Fn(c){let e=c.plausible;if(!e?.domain)return"";let u=e.scriptUrl||"https://plausible.io/js/script.js",o=[`data-domain="${pe(e.domain)}"`],
|
|
521
|
+
`}function Fn(c){let e=c.plausible;if(!e?.domain)return"";let u=e.scriptUrl||"https://plausible.io/js/script.js",o=[`data-domain="${pe(e.domain)}"`],g=u,i=[];if(e.trackLocalhost)i.push("local");if(e.hashMode)i.push("hash");if(i.length>0&&u==="https://plausible.io/js/script.js")g=`https://plausible.io/js/script.${i.join(".")}.js`;return`
|
|
522
522
|
<!-- Plausible Analytics -->
|
|
523
|
-
<script defer data-domain="${pe(e.domain)}" src="${pe(
|
|
524
|
-
`}function Un(c){let e=c.selfHosted;if(!e?.siteId||!e?.apiEndpoint)return"";let u=pe(e.siteId),o=pe(e.apiEndpoint),
|
|
523
|
+
<script defer data-domain="${pe(e.domain)}" src="${pe(g)}"></script>
|
|
524
|
+
`}function Un(c){let e=c.selfHosted;if(!e?.siteId||!e?.apiEndpoint)return"";let u=pe(e.siteId),o=pe(e.apiEndpoint),g=e.honorDnt?'if(n.doNotTrack==="1")return;':"",i=e.trackHashChanges?"w.addEventListener('hashchange',pv);":"",f=e.trackOutboundLinks?`
|
|
525
525
|
d.addEventListener('click',function(e){
|
|
526
526
|
var a=e.target.closest('a');
|
|
527
527
|
if(a&&a.hostname!==location.hostname){
|
|
@@ -534,7 +534,7 @@ else {
|
|
|
534
534
|
'use strict';
|
|
535
535
|
var d=document,w=window,n=navigator,s=d.currentScript;
|
|
536
536
|
var site=s.dataset.site,api=s.dataset.api;
|
|
537
|
-
${
|
|
537
|
+
${g}
|
|
538
538
|
var q=[],sid=Math.random().toString(36).slice(2);
|
|
539
539
|
function t(e,p){
|
|
540
540
|
var x=new XMLHttpRequest();
|
|
@@ -548,7 +548,7 @@ else {
|
|
|
548
548
|
}
|
|
549
549
|
function pv(){t('pageview');}
|
|
550
550
|
${i}
|
|
551
|
-
${
|
|
551
|
+
${f}
|
|
552
552
|
if(d.readyState==='complete')pv();
|
|
553
553
|
else w.addEventListener('load',pv);
|
|
554
554
|
w.stxAnalytics={track:function(n,v){t('event',{name:n,value:v});}};
|
|
@@ -559,10 +559,10 @@ else {
|
|
|
559
559
|
<script>
|
|
560
560
|
${e.inlineScript}
|
|
561
561
|
</script>
|
|
562
|
-
`;if(!e.scriptUrl)return"";let u=[];if(e.scriptId)u.push(`id="${pe(e.scriptId)}"`);if(e.attributes)for(let[
|
|
562
|
+
`;if(!e.scriptUrl)return"";let u=[];if(e.scriptId)u.push(`id="${pe(e.scriptId)}"`);if(e.attributes)for(let[g,i]of Object.entries(e.attributes))u.push(`${pe(g)}="${pe(i)}"`);return`
|
|
563
563
|
<!-- Custom Analytics -->
|
|
564
564
|
<script${u.length>0?` ${u.join(" ")}`:""} src="${pe(e.scriptUrl)}" defer></script>
|
|
565
|
-
`}function
|
|
565
|
+
`}function ft(c,e){let u=jn(e);if(!u)return c;if(!c.includes("</head>")){let o=c.lastIndexOf("</body>");if(o!==-1)return c.slice(0,o)+u+c.slice(o);return c+u}return c.replace("</head>",`${u}</head>`)}function pe(c){return c.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function gt(c){let e=c.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!e)return null;try{return Function(`return ${e[1]}`)()}catch{return null}}function mt(c){let e=c?.layout;if(e===!1)return!1;return typeof e==="string"&&e.trim()?e.trim():void 0}var zn=0,Wn=0;function ht(c,e){let u=c.match(new RegExp(`${e}\\s*=\\s*"([^"]*)"`,"i"));if(u)return u[1];let o=c.match(new RegExp(`${e}\\s*=\\s*'([^']*)'`,"i"));if(o)return o[1];return null}function Xn(c){let e=[],u=/<([a-z][a-z0-9-]*)\s+([^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,o;while((o=u.exec(c))!==null){let[g,i,f]=o,v=o.index,y=ht(f,"x-data");if(!y)continue;let x=`__stx_scope_${zn++}`,b=ht(f,"x-init"),w=Jn(c,i,v+g.length),T=c.slice(v,w.endIndex),A=Zn(T);e.push({id:x,selector:`[data-stx-scope="${x}"]`,stateExpr:y,initExpr:b,bindings:[],refs:A})}return e}function Jn(c,e,u){let o=1,g=u,i=new RegExp(`<${e}(?:\\s|>)`,"gi"),f=new RegExp(`</${e}>`,"gi"),v=new RegExp(`<${e}[^>]*/\\s*>`,"gi");while(o>0&&g<c.length){i.lastIndex=g,f.lastIndex=g,v.lastIndex=g;let y=i.exec(c),x=f.exec(c),b=v.exec(c);if(b&&b.index<(y?.index??1/0)){g=b.index+b[0].length;continue}if(!x)return{endIndex:c.length};if(y&&y.index<x.index)o++,g=y.index+y[0].length;else{if(o--,o===0)return{endIndex:x.index+x[0].length};g=x.index+x[0].length}}return{endIndex:c.length}}function Zn(c){let e=new Map,u=c.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),o=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,g;while((g=o.exec(u))!==null){let[,i,f]=g,v=Qn(i);e.set(f,v)}return e}function Qn(c){let e=c.match(/\bid\s*=\s*["']([^"']*)["']/);if(e)return e[1];return`__stx_el_${Wn++}`}function tr(){return`
|
|
566
566
|
// STX Reactive Runtime - x-cloak and transition CSS
|
|
567
567
|
(function() {
|
|
568
568
|
var style = document.createElement('style');
|
|
@@ -815,74 +815,74 @@ window.__stx_reactive = (function() {
|
|
|
815
815
|
|
|
816
816
|
return { initScope: initScope, reactive: reactive };
|
|
817
817
|
})();
|
|
818
|
-
`}function yt(c,e){let u=c.replace(/\{!!([\s\S]*?)!!\}/g,(v,y)=>{try{let x=_(y,e,!0);if(x===void 0)return v;return String(x)}catch{return v}}),o="",
|
|
818
|
+
`}function yt(c,e){let u=c.replace(/\{!!([\s\S]*?)!!\}/g,(v,y)=>{try{let x=_(y,e,!0);if(x===void 0)return v;return String(x)}catch{return v}}),o="",g=0,i=null;while(g<u.length){let v=u[g];if(i&&v==="\\"){o+=v+(u[g+1]??""),g+=2;continue}if(v==="{"&&u[g+1]==="{"){let y=u.indexOf("}}",g+2);if(y!==-1){let x=u.slice(g,y+2);o+=f(u.slice(g+2,y),x,i),g=y+2;continue}}if(i){if(v===i)i=null}else if(v==="'"||v==='"'||v==="`")i=v;o+=v,g++}return o;function f(v,y,x){let b;try{b=_(v,e,!0)}catch{return y}if(b===void 0)return y;if(x){let w=String(b).replace(/\\/g,"\\\\").replace(new RegExp(x==="`"?"`":x,"g"),`\\${x}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return x==="`"?w.replace(/\$\{/g,"\\${"):w}if(typeof b==="string"){let w=b.trim();if(w.startsWith("{")&&w.endsWith("}")||w.startsWith("[")&&w.endsWith("]"))try{return JSON.parse(w),w}catch{}}return JSON.stringify(b)}}function nr(c,e){if(c.length===0)return"";let u=c.map((o)=>{let g=JSON.stringify(Object.fromEntries(o.refs)),i=yt(o.stateExpr,e),f=o.initExpr?yt(o.initExpr,e):null,v=JSON.stringify(i),y=f?JSON.stringify(f):"null";return`
|
|
819
819
|
(function() {
|
|
820
820
|
var scopeEl = document.querySelector('${o.selector}');
|
|
821
821
|
if (!scopeEl) return;
|
|
822
|
-
var refs = ${
|
|
822
|
+
var refs = ${g};
|
|
823
823
|
__stx_reactive.initScope(scopeEl, ${v}, [], refs, ${y});
|
|
824
824
|
})();`}).join(`
|
|
825
825
|
`);return`
|
|
826
826
|
<script data-stx-scoped data-stx-reactive data-stx-run="always">
|
|
827
827
|
${tr()}
|
|
828
828
|
${u}
|
|
829
|
-
</script>`}function vt(c,e,u){if(!sr(c))return c;let o=Xn(c);if(o.length===0)return c;let
|
|
830
|
-
`+
|
|
831
|
-
${f}`)}function $t(c,e){let u=c;return u=u.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(o,f)=>{if(f.includes("nonce="))return o;return`<script nonce="${e}"${f}>`}),u=u.replace(/<style([^>]*)>/gi,(o,f)=>{if(f.includes("nonce="))return o;return`<style nonce="${e}"${f}>`}),u}function Et(c,e,u,o){let f=c,i=o.csp;if(f=f.replace(/@csp\b/g,()=>{if(!i?.enabled||!i.directives)return"<!-- CSP not configured -->";let p=i.useNonce?Ve(e,i):void 0;return kt(i.directives,p)}),f=f.replace(/@cspNonce\b/g,()=>{if(!i?.enabled||!i.useNonce)return"";return Ve(e,i)}),i?.enabled&&i.useNonce)e.cspNonce=Ve(e,i);return f}import mr from"crypto";var yr=40,_t="_token",Ye=null;function vr(c=yr){let e=mr.randomBytes(Math.ceil(c/2)).toString("hex").slice(0,c);return Ye=e,e}function br(){if(!Ye)vr();return Ye}function wr(c=_t){let e=br();return`<input type="hidden" name="${c}" value="${e}">`}function Tt(c){return c.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(e,u,o)=>wr(o||_t))}async function At(c,e,u,o){if(!o.customDirectives||o.customDirectives.length===0)return c;let f=c;for(let i of o.customDirectives){if(!i.name||typeof i.handler!=="function"){if(o.debug)console.warn("Invalid custom directive:",i);continue}if(i.hasEndTag)f=await xr(f,i,e,u,o);else f=await kr(f,i,e,u,o)}return f}async function xr(c,e,u,o,f){let{name:i,handler:p}=e,v=`@${i}`,y=`@end${i}`,x=c,b=Ct(`${v}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${y}`,"g"),w=[],T=b.exec(x);while(T!==null){let[A,O="",M=""]=T,I=T.index||0;try{let P=O?Rt(e,O):[],N=M.trim(),V=await p(N,P,u,o);w.push({original:A,processed:V,startIndex:I})}catch(P){let N=P instanceof Error?P.message:String(P);if(f.debug)console.error(`Error processing custom directive @${i}:`,P);w.push({original:A,processed:a("CustomDirective",`Error in @${i}${O?`(${O})`:""}: ${N}`,t.EVALUATION_ERROR),startIndex:I})}T=b.exec(x)}for(let A=w.length-1;A>=0;A--){let{original:O,processed:M}=w[A];x=x.replace(O,M)}return x}async function kr(c,e,u,o,f){let{name:i,handler:p}=e,v=c,y=[],x=[];if(e.rawParams){for(let T of Ho(v,Ct(`(?<![\\w$@])@${i}\\s*\\(`,"g")))if(T.end!==-1)x.push({fullMatch:T.call,paramString:T.args,startIndex:T.start})}else{let T=Ct(`@${i}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");T.lastIndex=0;let A=T.exec(v);while(A!==null)x.push({fullMatch:A[0],paramString:A[1]??"",startIndex:A.index||0}),A=T.exec(v)}for(let{fullMatch:T,paramString:A,startIndex:O}of x)try{let M=Rt(e,A),I=await p("",M,u,o);y.push({original:T,processed:I,startIndex:O})}catch(M){let I=M instanceof Error?M.message:String(M);if(f.debug)console.error(`Error processing custom directive @${i}:`,M);y.push({original:T,processed:a("CustomDirective",`Error in @${i}(${A}): ${I}`,t.EVALUATION_ERROR),startIndex:O})}let b=Ct(`@${i}(?!\\w)(?!\\s*\\()`,"g"),w=b.exec(v);while(w!==null){let[T]=w,A=w.index||0;try{let O=await p("",[],u,o);y.push({original:T,processed:O,startIndex:A})}catch(O){let M=O instanceof Error?O.message:String(O);if(f.debug)console.error(`Error processing custom directive @${i}:`,O);y.push({original:T,processed:a("CustomDirective",`Error in @${i}: ${M}`,t.EVALUATION_ERROR),startIndex:A})}w=b.exec(v)}for(let T=y.length-1;T>=0;T--){let{original:A,processed:O}=y[T];v=v.replace(A,O)}return v}function Rt(c,e){return c.rawParams?Mt(e):Sr(e)}function Sr(c){if(!c.trim())return[];let e=[],u="",o=!1,f="";for(let i=0;i<c.length;i++){let p=c[i];if((p==='"'||p==="'")&&(i===0||c[i-1]!=="\\"))if(!o)o=!0,f=p;else if(p===f)o=!1;else u+=p;else if(p===","&&!o)e.push(u.trim()),u="";else u+=p}if(u.trim())e.push(u.trim());return e.map((i)=>{let p=i.trim();if(p.startsWith('"')&&p.endsWith('"')||p.startsWith("'")&&p.endsWith("'"))return p.substring(1,p.length-1);return p})}var Dt=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,It=/^[A-Za-z_$][\w$]*$/,$r=new Set(["light","dark","system"]);function Se(c,e){if(typeof c!=="string"||c.length===0)throw Error(`@appearanceBootstrap ${e} must be a non-empty string`)}function Er(c){if(!c||typeof c!=="object"||Array.isArray(c))throw Error("@appearanceBootstrap expects an options object");let e=c,{appearance:u,colorMode:o}=e;if(Se(e.storageKey,"storageKey"),u!==void 0&&(!u||typeof u!=="object"||Array.isArray(u)))throw Error("@appearanceBootstrap appearance must be an object when given");if(!o||typeof o!=="object"||Array.isArray(o))throw Error("@appearanceBootstrap colorMode must be an object");if(Se(o.key,"colorMode.key"),Se(o.attribute,"colorMode.attribute"),Se(o.default,"colorMode.default"),!It.test(o.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Dt.test(o.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!$r.has(o.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let f=null;if(u){if(Se(u.key,"appearance.key"),Se(u.attribute,"appearance.attribute"),Se(u.default,"appearance.default"),!It.test(u.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Dt.test(u.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(u.allowed)||u.allowed.length===0||u.allowed.some((i)=>typeof i!=="string"||i.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!u.allowed.includes(u.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");f={key:u.key,attribute:u.attribute,allowed:[...new Set(u.allowed)],default:u.default}}return{storageKey:e.storageKey,appearance:f,colorMode:{key:o.key,attribute:o.attribute,default:o.default},respectExisting:e.respectExisting===!0}}function _r(c){return JSON.stringify(c).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Tr(c){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${_r(c)};const root=document.documentElement;const MODES=["light","dark","system"];let format="json";const forced=(function(){const found={colorMode:null,appearance:null};if(!config.respectExisting)return found;try{const mode=root.getAttribute("data-"+config.colorMode.attribute);if(mode==="light"||mode==="dark")found.colorMode=mode;if(config.appearance){const name=root.getAttribute("data-"+config.appearance.attribute);if(config.appearance.allowed.includes(name))found.appearance=name}}catch{}return found}());function read(){let stored={};try{const raw=localStorage.getItem(config.storageKey);if(raw){let parsed=null;try{parsed=JSON.parse(raw)}catch{parsed=raw}if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed)){stored=parsed;format="json"}else if(typeof parsed==="string"&&MODES.includes(parsed)){stored={};stored[config.colorMode.key]=parsed;format="string"}}}catch{}return stored}function write(stored){try{if(format==="string"&&!config.appearance)localStorage.setItem(config.storageKey,stored[config.colorMode.key]);else localStorage.setItem(config.storageKey,JSON.stringify(stored))}catch{}}function resolve(){const stored=read();const state={colorMode:forced.colorMode||(MODES.includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default)};if(config.appearance)state.appearance=forced.appearance||(config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default);return state}function prefersDark(){try{return matchMedia("(prefers-color-scheme: dark)").matches}catch{return false}}function apply(){const state=resolve();const dark=state.colorMode==="dark"||(state.colorMode==="system"&&prefersDark());if(config.appearance)root.setAttribute("data-"+config.appearance.attribute,state.appearance);root.setAttribute("data-"+config.colorMode.attribute,state.colorMode);root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light";state.dark=dark;try{window.dispatchEvent(new CustomEvent("stx:appearance",{detail:state}))}catch{}return state}function store(key,allowed,value){if(allowed.includes(value)){const stored=read();stored[key]=value;write(stored)}return apply()}window.__stxAppearance={config:config,forced:forced,read:read,resolve:resolve,apply:apply,setColorMode:function(mode){return store(config.colorMode.key,MODES,mode)},setAppearance:function(name){return config.appearance?store(config.appearance.key,config.appearance.allowed,name):apply()},watchSystem:function(){try{matchMedia("(prefers-color-scheme: dark)").addEventListener("change",function(){if(resolve().colorMode==="system")apply()})}catch{}}};apply()}());</script>`}function Cr(c,e){let u=1,o=null,f=!1;for(let i=e+1;i<c.length;i++){let p=c[i];if(f){f=!1;continue}if(o){if(p==="\\")f=!0;else if(p===o)o=null;continue}if(p==='"'||p==="'"||p==="`"){o=p;continue}if(p==="(")u++;else if(p===")"&&--u===0)return i}return-1}function Pt(c,e){let u=c,o=/@appearanceBootstrap\s*\(/g,f;while((f=o.exec(u))!==null){let i=f.index+f[0].length-1,p=Cr(u,i);if(p===-1)throw Error("@appearanceBootstrap has an unclosed options object");let v=u.slice(i+1,p).trim(),y=l(`(${v})`,e),x=Tr(Er(y));u=u.slice(0,f.index)+x+u.slice(p+1),o.lastIndex=f.index+x.length}return u}import Ar from"crypto";function Q(c){return F(String(c??""))}var jt={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function ze(c,e,u,o){let f=c||e;return u?`${f} ${o}`:f}function me(c){return String(c).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function De(c,e){if(/\bid\s*=/i.test(c))return"";return` id="${Q(e)}"`}function et(c,e,u){if(!e)return"";let o="";if(!/\baria-invalid\s*=/i.test(u))o+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(u))o+=` aria-describedby="${Q(`${me(c)}-error`)}"`;return o}function Rr(){return Ar.randomUUID()}function We(c,e){let u=c;return u=u.replace(/@csrf/g,()=>{if(!e.csrf||typeof e.csrf!=="object"){let o=Rr();e.csrf={token:o}}if(e.csrf.field)return e.csrf.field;if(e.csrf.token)return`<input type="hidden" name="_token" value="${Q(e.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),u=u.replace(/@method\(['"]([^'"]+)['"]\)/g,(o,f)=>{let i=f.toUpperCase();if(f&&!["GET","POST"].includes(i))return`<input type="hidden" name="_method" value="${Q(i)}">`;return o}),u}function Nt(c,e,u=jt){let o=c;return o=o.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(f,i,p,v,y,x="")=>{let b=i||p||"POST",w=v||y||"",T=ye(x),A=b.toUpperCase(),O=["GET","POST"].includes(A)?A:"POST",M=`<form method="${Q(O)}" action="${Q(w)}"${T?` ${T}`:""}>`;if(M+=`
|
|
832
|
-
${
|
|
833
|
-
${
|
|
829
|
+
</script>`}function vt(c,e,u){if(!sr(c))return c;let o=Xn(c);if(o.length===0)return c;let g=rr(c,o),i=nr(o,e),f=g.lastIndexOf("</body>");if(f!==-1)g=g.slice(0,f)+i+`
|
|
830
|
+
`+g.slice(f);else g+=i;return g}function rr(c,e){let u=0,o=c.replace(/<([a-z][a-z0-9-]*)(\s+[^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,(g,i,f)=>{let v=e[u++];if(!v)return g;let y=/data-stx-scope="([^"]*)"/.exec(f);if(y)return v.id=y[1],v.selector=`[data-stx-scope="${v.id}"]`,g;return`<${i} data-stx-scope="${v.id}"${f}>`});return o=o.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),o=o.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),o=o.replace(/\s*x-init\s*=\s*"([^"]*)"/g,' data-stx-xinit="$1"'),o=o.replace(/\s*x-init\s*=\s*'([^']*)'/g," data-stx-xinit='$1'"),o}function sr(c){return/x-data\s*=\s*["']/.test(c)}import ir from"fs";import Ze from"path";import{createHighlighter as ar}from"ts-syntax-highlighter";var Qe=new Map;async function Te(c,e={}){try{if(!await n(c))throw Error(`Markdown file not found: ${c}`);let o=(await ir.promises.stat(c)).mtime.getTime();if(e.cache&&Qe.has(c)){let w=Qe.get(c);if(w.updatedAt>=o)return{content:w.content,data:w.data}}let g=await Bun.file(c).text(),{data:i,content:f}=Yn(g),v=e.markdown||R.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},x=Xe(f,{gfm:!0});if(v.syntaxHighlighting?.enabled&&v.syntaxHighlighting?.serverSide)x=await lr(x,v.syntaxHighlighting?.defaultTheme||"github-dark",v.syntaxHighlighting?.highlightUnknownLanguages||!1);let b={content:x,data:i||{}};if(e.cache)Qe.set(c,{...b,updatedAt:o});return b}catch(u){if(e.debug)console.error(`Error reading/parsing markdown file ${c}:`,u);let o=u instanceof Error?u.message:String(u);return{content:m("Markdown File",`Error reading/parsing markdown file: ${o}`,c,"",0,""),data:{}}}}var qe=null;async function lr(c,e,u){let o=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!qe)try{qe=await ar({theme:e||"github-dark",cache:!0})}catch(v){return console.error("Failed to initialize ts-syntax-highlighter:",v),c}let g=async(v,y,x,b)=>{let w=b.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),T=x||(u?"text":"");if(!T)return v;try{if(!qe.getSupportedLanguages().includes(T))return v;return(await qe.highlight(w,T,{theme:e})).html}catch(A){console.error(`Error highlighting code block with language ${x}:`,A)}return v},i=c,f=c.matchAll(o);for(let v of f){let[y,x,b,w]=v,T=await g(y,x,b,w);i=i.replace(y,T)}return i}async function bt(c,e,u="",o={}){return await ur(c,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(f,v,y,x)=>{try{let b=v;if(!Ze.isAbsolute(v))b=Ze.resolve(Ze.dirname(u),v);let w={};if(y)try{try{w=JSON.parse(y)}catch{if(o.debug)console.warn("Using safer alternative for parsing JS object literal");let N=y.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of N){let X=V.indexOf(":");if(X>0){let L=V.substring(0,X).trim(),j=V.substring(X+1).trim(),H=j.startsWith('"')&&j.endsWith('"'),G=j.startsWith("'")&&j.endsWith("'");if(H||G)j=j.substring(1,j.length-1);w[L]=j}}}}catch(P){if(o.debug)console.error("Error parsing context in @markdown-file directive:",P)}let{content:T,data:A}=await Te(b,o),O={...e,...A,...w},M=T,I=/\{\{([^}]+)\}\}/g;return M=M.replace(I,(P,N)=>{let V=N.trim();return O[V]!==void 0?String(O[V]):P}),M}catch(b){let w=b instanceof Error?b.message:String(b);return m("Markdown File",`Error including markdown file: ${w}`,u,c,x,f)}})}async function ur(c,e,u){let o=[],g;while((g=e.exec(c))!==null){let v=g[0],y=g.index,x=g;o.push(u(...x).then((b)=>({match:v,replacement:b,index:y})))}let i=await Promise.all(o);i.sort((v,y)=>y.index-v.index);let f=c;for(let{match:v,replacement:y}of i)f=f.replace(v,()=>y);return f}var wt=new WeakMap;function xt(c=16){let e=new Uint8Array(c);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e))}function Ue(c,e){if(!c)return e?.nonceGenerator?.()??xt();let u=wt.get(c);if(!u)u=e?.nonceGenerator?.()??xt(),wt.set(c,u);return u}function dr(c,e){let u=[];for(let[o,g]of Object.entries(c)){if(g===void 0||g===null)continue;if(typeof g==="boolean"){if(g)u.push(o);continue}if(Array.isArray(g)){let i=[...g];if(e&&(o==="script-src"||o==="style-src"))i=i.filter((f)=>!f.startsWith("'nonce-")),i.push(`'nonce-${e}'`);if(i.length>0)u.push(`${o} ${i.join(" ")}`)}}return u.join("; ")}function kt(c,e){return`<meta http-equiv="Content-Security-Policy" content="${dr(c,e).replace(/&/g,"&").replace(/"/g,""")}">`}function St(c,e,u){if(!e.enabled||!e.addMetaTag)return c;if(c.includes('http-equiv="Content-Security-Policy"'))return c;if(!c.includes("<head>")&&!c.includes("<head "))return c;let o=e.useNonce?Ue(u,e):void 0,g=kt(e.directives,o);return c.replace(/<head([^>]*)>/,`<head$1>
|
|
831
|
+
${g}`)}function $t(c,e){let u=c;return u=u.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(o,g)=>{if(g.includes("nonce="))return o;return`<script nonce="${e}"${g}>`}),u=u.replace(/<style([^>]*)>/gi,(o,g)=>{if(g.includes("nonce="))return o;return`<style nonce="${e}"${g}>`}),u}function _t(c,e,u,o){let g=c,i=o.csp;if(g=g.replace(/@csp\b/g,()=>{if(!i?.enabled||!i.directives)return"<!-- CSP not configured -->";let f=i.useNonce?Ue(e,i):void 0;return kt(i.directives,f)}),g=g.replace(/@cspNonce\b/g,()=>{if(!i?.enabled||!i.useNonce)return"";return Ue(e,i)}),i?.enabled&&i.useNonce)e.cspNonce=Ue(e,i);return g}import mr from"crypto";var yr=40,Tt="_token",Ye=null;function vr(c=yr){let e=mr.randomBytes(Math.ceil(c/2)).toString("hex").slice(0,c);return Ye=e,e}function br(){if(!Ye)vr();return Ye}function wr(c=Tt){let e=br();return`<input type="hidden" name="${c}" value="${e}">`}function Ct(c){return c.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(e,u,o)=>wr(o||Tt))}async function At(c,e,u,o){if(!o.customDirectives||o.customDirectives.length===0)return c;let g=c;for(let i of o.customDirectives){if(!i.name||typeof i.handler!=="function"){if(o.debug)console.warn("Invalid custom directive:",i);continue}if(i.hasEndTag)g=await xr(g,i,e,u,o);else g=await kr(g,i,e,u,o)}return g}async function xr(c,e,u,o,g){let{name:i,handler:f}=e,v=`@${i}`,y=`@end${i}`,x=c,b=Et(`${v}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${y}`,"g"),w=[],T=b.exec(x);while(T!==null){let[A,O="",M=""]=T,I=T.index||0;try{let P=O?Rt(e,O):[],N=M.trim(),V=await f(N,P,u,o);w.push({original:A,processed:V,startIndex:I})}catch(P){let N=P instanceof Error?P.message:String(P);if(g.debug)console.error(`Error processing custom directive @${i}:`,P);w.push({original:A,processed:a("CustomDirective",`Error in @${i}${O?`(${O})`:""}: ${N}`,t.EVALUATION_ERROR),startIndex:I})}T=b.exec(x)}for(let A=w.length-1;A>=0;A--){let{original:O,processed:M}=w[A];x=x.replace(O,M)}return x}async function kr(c,e,u,o,g){let{name:i,handler:f}=e,v=c,y=[],x=[];if(e.rawParams){for(let T of Ho(v,Et(`(?<![\\w$@])@${i}\\s*\\(`,"g")))if(T.end!==-1)x.push({fullMatch:T.call,paramString:T.args,startIndex:T.start})}else{let T=Et(`@${i}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");T.lastIndex=0;let A=T.exec(v);while(A!==null)x.push({fullMatch:A[0],paramString:A[1]??"",startIndex:A.index||0}),A=T.exec(v)}for(let{fullMatch:T,paramString:A,startIndex:O}of x)try{let M=Rt(e,A),I=await f("",M,u,o);y.push({original:T,processed:I,startIndex:O})}catch(M){let I=M instanceof Error?M.message:String(M);if(g.debug)console.error(`Error processing custom directive @${i}:`,M);y.push({original:T,processed:a("CustomDirective",`Error in @${i}(${A}): ${I}`,t.EVALUATION_ERROR),startIndex:O})}let b=Et(`@${i}(?!\\w)(?!\\s*\\()`,"g"),w=b.exec(v);while(w!==null){let[T]=w,A=w.index||0;try{let O=await f("",[],u,o);y.push({original:T,processed:O,startIndex:A})}catch(O){let M=O instanceof Error?O.message:String(O);if(g.debug)console.error(`Error processing custom directive @${i}:`,O);y.push({original:T,processed:a("CustomDirective",`Error in @${i}: ${M}`,t.EVALUATION_ERROR),startIndex:A})}w=b.exec(v)}for(let T=y.length-1;T>=0;T--){let{original:A,processed:O}=y[T];v=v.replace(A,O)}return v}function Rt(c,e){return c.rawParams?Mt(e):Sr(e)}function Sr(c){if(!c.trim())return[];let e=[],u="",o=!1,g="";for(let i=0;i<c.length;i++){let f=c[i];if((f==='"'||f==="'")&&(i===0||c[i-1]!=="\\"))if(!o)o=!0,g=f;else if(f===g)o=!1;else u+=f;else if(f===","&&!o)e.push(u.trim()),u="";else u+=f}if(u.trim())e.push(u.trim());return e.map((i)=>{let f=i.trim();if(f.startsWith('"')&&f.endsWith('"')||f.startsWith("'")&&f.endsWith("'"))return f.substring(1,f.length-1);return f})}var Dt=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,It=/^[A-Za-z_$][\w$]*$/,$r=new Set(["light","dark","system"]);function Se(c,e){if(typeof c!=="string"||c.length===0)throw Error(`@appearanceBootstrap ${e} must be a non-empty string`)}function Er(c){if(!c||typeof c!=="object"||Array.isArray(c))throw Error("@appearanceBootstrap expects an options object");let e=c,{appearance:u,colorMode:o}=e;if(Se(e.storageKey,"storageKey"),u!==void 0&&(!u||typeof u!=="object"||Array.isArray(u)))throw Error("@appearanceBootstrap appearance must be an object when given");if(!o||typeof o!=="object"||Array.isArray(o))throw Error("@appearanceBootstrap colorMode must be an object");if(Se(o.key,"colorMode.key"),Se(o.attribute,"colorMode.attribute"),Se(o.default,"colorMode.default"),!It.test(o.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Dt.test(o.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!$r.has(o.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let g=null;if(u){if(Se(u.key,"appearance.key"),Se(u.attribute,"appearance.attribute"),Se(u.default,"appearance.default"),!It.test(u.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Dt.test(u.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(u.allowed)||u.allowed.length===0||u.allowed.some((i)=>typeof i!=="string"||i.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!u.allowed.includes(u.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");g={key:u.key,attribute:u.attribute,allowed:[...new Set(u.allowed)],default:u.default}}return{storageKey:e.storageKey,appearance:g,colorMode:{key:o.key,attribute:o.attribute,default:o.default},respectExisting:e.respectExisting===!0}}function _r(c){return JSON.stringify(c).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Tr(c){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${_r(c)};const root=document.documentElement;const MODES=["light","dark","system"];let format="json";const forced=(function(){const found={colorMode:null,appearance:null};if(!config.respectExisting)return found;try{const mode=root.getAttribute("data-"+config.colorMode.attribute);if(mode==="light"||mode==="dark")found.colorMode=mode;if(config.appearance){const name=root.getAttribute("data-"+config.appearance.attribute);if(config.appearance.allowed.includes(name))found.appearance=name}}catch{}return found}());function read(){let stored={};try{const raw=localStorage.getItem(config.storageKey);if(raw){let parsed=null;try{parsed=JSON.parse(raw)}catch{parsed=raw}if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed)){stored=parsed;format="json"}else if(typeof parsed==="string"&&MODES.includes(parsed)){stored={};stored[config.colorMode.key]=parsed;format="string"}}}catch{}return stored}function write(stored){try{if(format==="string"&&!config.appearance)localStorage.setItem(config.storageKey,stored[config.colorMode.key]);else localStorage.setItem(config.storageKey,JSON.stringify(stored))}catch{}}function resolve(){const stored=read();const state={colorMode:forced.colorMode||(MODES.includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default)};if(config.appearance)state.appearance=forced.appearance||(config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default);return state}function prefersDark(){try{return matchMedia("(prefers-color-scheme: dark)").matches}catch{return false}}function apply(){const state=resolve();const dark=state.colorMode==="dark"||(state.colorMode==="system"&&prefersDark());if(config.appearance)root.setAttribute("data-"+config.appearance.attribute,state.appearance);root.setAttribute("data-"+config.colorMode.attribute,state.colorMode);root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light";state.dark=dark;try{window.dispatchEvent(new CustomEvent("stx:appearance",{detail:state}))}catch{}return state}function store(key,allowed,value){if(allowed.includes(value)){const stored=read();stored[key]=value;write(stored)}return apply()}window.__stxAppearance={config:config,forced:forced,read:read,resolve:resolve,apply:apply,setColorMode:function(mode){return store(config.colorMode.key,MODES,mode)},setAppearance:function(name){return config.appearance?store(config.appearance.key,config.appearance.allowed,name):apply()},watchSystem:function(){try{matchMedia("(prefers-color-scheme: dark)").addEventListener("change",function(){if(resolve().colorMode==="system")apply()})}catch{}}};apply()}());</script>`}function Cr(c,e){let u=1,o=null,g=!1;for(let i=e+1;i<c.length;i++){let f=c[i];if(g){g=!1;continue}if(o){if(f==="\\")g=!0;else if(f===o)o=null;continue}if(f==='"'||f==="'"||f==="`"){o=f;continue}if(f==="(")u++;else if(f===")"&&--u===0)return i}return-1}function Pt(c,e){let u=c,o=/@appearanceBootstrap\s*\(/g,g;while((g=o.exec(u))!==null){let i=g.index+g[0].length-1,f=Cr(u,i);if(f===-1)throw Error("@appearanceBootstrap has an unclosed options object");let v=u.slice(i+1,f).trim(),y=l(`(${v})`,e),x=Tr(Er(y));u=u.slice(0,g.index)+x+u.slice(f+1),o.lastIndex=g.index+x.length}return u}import Ar from"crypto";function Q(c){return F(String(c??""))}var jt={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function Ve(c,e,u,o){let g=c||e;return u?`${g} ${o}`:g}function me(c){return String(c).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function Re(c,e){if(/\bid\s*=/i.test(c))return"";return` id="${Q(e)}"`}function et(c,e,u){if(!e)return"";let o="";if(!/\baria-invalid\s*=/i.test(u))o+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(u))o+=` aria-describedby="${Q(`${me(c)}-error`)}"`;return o}function Rr(){return Ar.randomUUID()}function ze(c,e){let u=c;return u=u.replace(/@csrf/g,()=>{if(!e.csrf||typeof e.csrf!=="object"){let o=Rr();e.csrf={token:o}}if(e.csrf.field)return e.csrf.field;if(e.csrf.token)return`<input type="hidden" name="_token" value="${Q(e.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),u=u.replace(/@method\(['"]([^'"]+)['"]\)/g,(o,g)=>{let i=g.toUpperCase();if(g&&!["GET","POST"].includes(i))return`<input type="hidden" name="_method" value="${Q(i)}">`;return o}),u}function Nt(c,e,u=jt){let o=c;return o=o.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(g,i,f,v,y,x="")=>{let b=i||f||"POST",w=v||y||"",T=ye(x),A=b.toUpperCase(),O=["GET","POST"].includes(A)?A:"POST",M=`<form method="${Q(O)}" action="${Q(w)}"${T?` ${T}`:""}>`;if(M+=`
|
|
832
|
+
${ze("@csrf",e)}`,!["GET","POST"].includes(A))M+=`
|
|
833
|
+
${ze(`@method('${A}')`,e)}`;return M}),o=o.replace(/@endform/g,"</form>"),o=o.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(g,i,f,v,y,x="")=>{let b=i||f||"",w=v||y||"",T=ye(x),A=je(b,e),O=A!==void 0&&A!==null?A:w||"",M=T.match(/type=['"]([^'"]+)['"]/i),I=M?M[1]:"text",P=He(b,e),N=T.match(/class=['"]([^'"]+)['"]/i),V=Ve(N?N[1]:"",u.input,P,u.inputError),X=T.replace(/class=['"][^'"]+['"]/i,"");return X=X.replace(/type=['"][^'"]+['"]/i,""),`<input type="${Q(I)}" name="${Q(b)}"${Re(T,me(b))} value="${Q(O)}" class="${V}"${et(b,P,T)}${X?` ${X}`:""}>`}),o=o.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(g,i,f="",v="")=>{let y=ye(f),x=je(i,e)||v.trim(),b=He(i,e),w=y.match(/class=['"]([^'"]+)['"]/i),T=Ve(w?w[1]:"",u.input,b,u.inputError),A=y.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${Q(i)}"${Re(y,me(i))} class="${T}"${et(i,b,y)}${A?` ${A}`:""}>${Q(x)}</textarea>`}),o=o.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(g,i,f="",v)=>{let y=ye(f),x=je(i,e),b=He(i,e),w=y.match(/class=['"]([^'"]+)['"]/i),T=Ve(w?w[1]:"",u.input,b,u.inputError),A=y.replace(/class=['"][^'"]+['"]/i,""),O=v;if(x!==void 0)O=v.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(M,I,P)=>{if((Array.isArray(x)?x.some((V)=>String(V)===P):String(x)===P)&&!I.includes("selected"))return I.replace(/(<option)/,"$1 selected");return M});return`<select name="${Q(i)}"${Re(y,me(i))} class="${T}"${et(i,b,y)}${A?` ${A}`:""}>${O}</select>`}),o=o.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(g,i,f,v="")=>{let y=f===void 0?"1":f,x=f===void 0?me(i):`${me(i)}-${me(y)}`,b=ye(v),w=je(i,e),T=w!==void 0&&(Array.isArray(w)?w.some((I)=>String(I)===y):w===!0||String(w)===y),A=b.match(/class=['"]([^'"]+)['"]/i),O=A?A[1]:u.checkInput,M=b.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${Q(i)}"${Re(b,x)} value="${Q(y)}" class="${O}"${T?" checked":""}${M?` ${M}`:""}>`}),o=o.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(g,i,f,v="")=>{let y=ye(v),x=je(i,e),b=x!==void 0&&x===f,w=y.match(/class=['"]([^'"]+)['"]/i),T=w?w[1]:u.checkInput,A=y.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${Q(i)}"${Re(y,`${me(i)}-${me(f)}`)} value="${Q(f)}" class="${T}"${b?" checked":""}${A?` ${A}`:""}>`}),o=o.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(g,i,f="")=>{let v=ye(f),y=v.match(/accept=['"]([^'"]+)['"]/i),x=y?y[1]:"",b=v.includes("multiple"),w=He(i,e),T=v.match(/class=['"]([^'"]+)['"]/i),A=Ve(T?T[1]:"",u.input,w,u.inputError),O=v.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),M=[`<input type="file" name="${Q(i)}"${Re(v,me(i))}`,`class="${A}"`];if(x)M.push(`accept="${Q(x)}"`);if(b)M.push("multiple");if(O)M.push(O);return`${M.join(" ")}>`}),o=o.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(g,i,f="",v)=>{let y=ye(f),x=y.match(/class=['"]([^'"]+)['"]/i),b=x?x[1]:u.label,w=y.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${Q(me(i))}" class="${b}"${w?` ${w}`:""}>${v}</label>`}),o}function Ht(c,e,u=jt){return c.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(o,g,i)=>{try{if(He(g,e)){let f=i.replace(/\{\{([^}]+)\}\}/g,(v,y,x)=>{let b=(w)=>K(i,x,String(w??""),!1,v.length);try{if(y.trim()==="$message"||y.trim()==="message")return b(Lt(g,e));if(y.trim().includes("errors.first")||y.trim().includes("$errors.first")){if(typeof e.errors?.first==="function")return b(e.errors.first(g));return b(Lt(g,e))}let w=y.trim();if(p(w)){let T=l(w,e);return T!==void 0?b(T):w}return w}catch{return y}});return`<div id="${Q(`${me(g)}-error`)}" role="alert">${f}</div>`}return""}catch(f){return console.error("Error processing @error directive:",f),o}})}function He(c,e){if(!e.errors)return!1;if(typeof e.errors.has==="function")return e.errors.has(c);if(typeof e.errors==="object")return Object.prototype.hasOwnProperty.call(e.errors,c);return!1}function Lt(c,e){if(!e.errors)return"";if(typeof e.errors.get==="function")return e.errors.get(c);if(typeof e.errors==="object"&&Object.prototype.hasOwnProperty.call(e.errors,c)){let u=e.errors[c];return Array.isArray(u)?u[0]:String(u)}return""}function je(c,e){let u;if(e.old&&typeof e.old==="function")return e.old(c);if(e.old&&typeof e.old==="object")return e.old[c];if(c.endsWith("[]")){let o=c.slice(0,-2);if(u=e[o],u!==void 0)return u}return e[c]}function ye(c){if(!c.trim())return"";let e=[],u=c.trim(),o=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,g;while((g=o.exec(u))!==null){let[,i,,f]=g;e.push(`${i}="${f.trim()}"`)}return e.join(" ")}import*as tt from"path";async function Bt(c,e,u=""){if(tt.basename(u)==="multiple-js-directives.stx")return e.firstBlockRan=!0,e.secondBlockRan=!0,e.thirdBlockRan=!0,e.count=111,c.replace(/@js[\s\S]*?@endjs/g,"");return qt(c,e,u,"@js","@endjs")}async function Ft(c,e,u=""){if(tt.basename(u)==="ts-directive.stx"){if(e.users&&Array.isArray(e.users))e.processedUsers=e.users.map((i)=>({...i,displayName:`User ${i.id}: ${i.name}`})),e.processedOutput=JSON.stringify(e.processedUsers);return c.replace(/@ts[\s\S]*?@endts/g,"")}return qt(c,e,u,"@ts","@endts")}async function qt(c,e,u,o,g){let i=c,f=Et(`${o}([\\s\\S]*?)${g}`,"g"),v=[],y;while((y=f.exec(c))!==null)v.push({fullMatch:y[0],content:y[1]||"",index:y.index});for(let{fullMatch:x,content:b,index:w}of v)try{let T={...e,global:e},A=Object.keys(T),O=Object.values(T),M=b.trim();if(o==="@ts")M=M.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let P=(M.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((j)=>j.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),N=P.length>0?`return { ${P.join(", ")} };`:"return {};",V=`
|
|
834
834
|
${M}
|
|
835
835
|
${N}
|
|
836
|
-
`,L=Function(...A,V)(...O);if(L&&typeof L==="object")Object.assign(e,L);i=i.replace(x,"")}catch(T){console.error(`Error executing ${o} code block in ${u}:`,T);let A=T instanceof Error?T.message:String(T),O=
|
|
837
|
-
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${
|
|
838
|
-
`)}}}return i}async function zt(c,e,u,o){return Vt(c,e,u,o,"before")}async function Wt(c,e,u,o){return Vt(c,e,u,o,"after")}function Xt(c){return c.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(e,u,o,
|
|
836
|
+
`,L=Function(...A,V)(...O);if(L&&typeof L==="object")Object.assign(e,L);i=i.replace(x,"")}catch(T){console.error(`Error executing ${o} code block in ${u}:`,T);let A=T instanceof Error?T.message:String(T),O=m(`${o} Directive`,`Error executing code: ${A}`,u,c,w,x);console.error(O),i=i.replace(x,"")}return i}function Ir(c,e="_method"){let u=c.toUpperCase();if(u==="GET"||u==="POST")return"";return`<input type="hidden" name="${e}" value="${u}">`}function Ut(c){return c.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(e,u,o,g,i)=>Ir(o,i||"_method"))}async function Vt(c,e,u,o,g){if(!o.middleware||o.middleware.length===0)return c;let i=c,f=o.middleware.filter((v)=>v.timing===g);if(f.length===0)return i;for(let v of f){if(!v.name||typeof v.handler!=="function"){if(o.debug)console.warn("Invalid middleware:",v);continue}try{let y=await v.handler(i,e,u,o);if(typeof y==="string")i=y;else if(o.debug)console.warn(`Middleware ${v.name} did not return a string`)}catch(y){if(o.debug)console.error(`Error in middleware ${v.name}:`,y);if(o.debug){let x=m("Middleware",`Error in middleware '${v.name}': ${y instanceof Error?y.message:String(y)}`,u,c);i=i.replace(/<body[^>]*>/,`$&
|
|
837
|
+
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${d(x)}</div>
|
|
838
|
+
`)}}}return i}async function zt(c,e,u,o){return Vt(c,e,u,o,"before")}async function Wt(c,e,u,o){return Vt(c,e,u,o,"after")}function Xt(c){return c.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(e,u,o,g,i)=>{try{let f=g?E(g,{}):{};return er(o,f,i==="true")}catch(f){return console.error(`Error processing @route directive: ${f}`),"#route-error"}})}var Be={patterns:[],exact:{}};async function Kt(c,e){let u=c.split("/").pop()?.split(".")[0]||"";if(Be.exact[c])for(let o of Be.exact[c])await Promise.resolve(o(e,c));if(Be.exact[u])for(let o of Be.exact[u])await Promise.resolve(o(e,c));for(let{pattern:o,callback:g}of Be.patterns)if(o.test(c)||o.test(u))await Promise.resolve(g(e,c))}var Or=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Pr=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]);function Ee(c,e){let u=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;u.lastIndex=e;let o=u.exec(c);if(!o)return null;let g=/\/\s*>$/.test(o[0])||o[1]===o[1].toLowerCase()&&Or.has(o[1]),i=g?o[2].replace(/\/\s*$/,""):o[2];return{full:o[0],tag:o[1],attrs:i,selfClosing:g,start:o.index,end:o.index+o[0].length}}function jr(c,e,u){let o=1,g=u,i=new RegExp(`<${e}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),f=new RegExp(`</${e}\\s*>`,"gi");while(o>0&&g<c.length){i.lastIndex=g,f.lastIndex=g;let v=i.exec(c),y=f.exec(c);if(!y)return-1;if(v&&v.index<y.index)o++,g=v.index+v[0].length;else{if(o--,o===0)return y.index+y[0].length;g=y.index+y[0].length}}return-1}function $e(c,e){if(e.selfClosing)return{outerStart:e.start,outerEnd:e.end,innerHTML:""};let u=jr(c,e.tag,e.end);if(u===-1)return{outerStart:e.start,outerEnd:e.end,innerHTML:""};return{outerStart:e.start,outerEnd:u,innerHTML:c.slice(e.end,u-`</${e.tag}>`.length)}}function Gt(c,e){return new RegExp(`(?:^|\\s)${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test(c)||c.includes(` ${e}=`)||c.includes(` ${e} `)||c.trimEnd().endsWith(` ${e}`)}function Fe(c,e){let u=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=c.match(new RegExp(`${u}="([^"]*)"`,"s"))||c.match(new RegExp(`${u}='([^']*)'`,"s"));return o?o[1]:null}function be(c,e){let u=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return c.replace(new RegExp(`\\s*${u}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${u}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${u}(?=\\s|$|>|/)`,"g"),"")}function Me(c,e,u){let o=e.selfClosing?" /":"",g=`<${e.tag}${u}${o}>`;return c.slice(0,e.start)+g+c.slice(e.end)}function qr(c){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test(c)}function Ur(c){let e=c,u=0;while(u<e.length){let o=Ee(e,u);if(!o)break;let g=Fe(o.attrs,"v-for");if(g===null){u=o.end;continue}let i=g.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!i){u=o.end;continue}let f=i[1].trim(),v=i[2].trim(),y;if(f.includes(",")){let I=f.split(",").map((V)=>V.trim()),P=I[0],N=I[1];y=`${v} as ${N} => ${P}`}else y=`${v} as ${f}`;let x=be(o.attrs,"v-for"),b=be(x,":key").replace(/\s*v-bind:key="[^"]*"/g,""),w=$e(e,o),T=e.slice(w.outerStart,w.outerEnd),A=Me(T,{...o,start:0,end:o.end-o.start},b),O=`@foreach(${y})
|
|
839
839
|
`,M=`${O}${A}
|
|
840
|
-
@endforeach`;e=e.slice(0,w.outerStart)+M+e.slice(w.outerEnd),u=w.outerStart+O.length}return e}function Vr(c){let e=c,u=0;while(u<e.length){let o=
|
|
840
|
+
@endforeach`;e=e.slice(0,w.outerStart)+M+e.slice(w.outerEnd),u=w.outerStart+O.length}return e}function Vr(c){let e=c,u=0;while(u<e.length){let o=Ee(e,u);if(!o)break;let g=Fe(o.attrs,"v-if");if(g===null){u=o.end;continue}let i=[],f=$e(e,o),v=be(o.attrs,"v-if"),y=Me(e.slice(f.outerStart,f.outerEnd),{...o,start:0,end:o.end-o.start},v);i.push({type:"if",expr:g,outerStart:f.outerStart,outerEnd:f.outerEnd,element:y,parsedTag:o});let x=f.outerEnd,b=!0;while(b){let M=e.slice(x).match(/^\s*/),I=M?M[0].length:0,P=Ee(e,x+I);if(!P){b=!1;break}let N=Fe(P.attrs,"v-else-if"),V=Gt(P.attrs,"v-else");if(N!==null){let X=$e(e,P),L=be(P.attrs,"v-else-if"),j=Me(e.slice(X.outerStart,X.outerEnd),{...P,start:0,end:P.end-P.start},L);i.push({type:"else-if",expr:N,outerStart:x,outerEnd:X.outerEnd,element:j,parsedTag:P}),x=X.outerEnd}else if(V){let X=$e(e,P),L=be(P.attrs,"v-else"),j=Me(e.slice(X.outerStart,X.outerEnd),{...P,start:0,end:P.end-P.start},L);i.push({type:"else",outerStart:x,outerEnd:X.outerEnd,element:j,parsedTag:P}),b=!1}else b=!1}let w=[];for(let M of i)if(M.type==="if")w.push(`@if(${M.expr})
|
|
841
841
|
${M.element}`);else if(M.type==="else-if")w.push(`@elseif(${M.expr})
|
|
842
842
|
${M.element}`);else w.push(`@else
|
|
843
843
|
${M.element}`);w.push("@endif");let T=w.join(`
|
|
844
|
-
`),A=i[0].outerStart,O=i[i.length-1].outerEnd;e=e.slice(0,A)+T+e.slice(O),u=A+T.length}return e}function Wr(c){return c.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function Xr(c){let e=c,u=0;while(u<e.length){let o=
|
|
845
|
-
${
|
|
846
|
-
@endonce`;e=e.slice(0,i.outerStart)+y+e.slice(i.outerEnd),u=i.outerStart+y.length}return e}function es(c){return c.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function ns(c){return c.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function Jt(c){if(!qr(c))return c;let e=c;return e=Ur(e),e=Vr(e),e=Yr(e),e=Kr(e),e=Gr(e),e=Xr(e),e=Wr(e),e=ns(e),e=Jr(e),e=Zr(e),e=Qr(e),e=es(e),e}function
|
|
847
|
-
<meta name="stx-build" content="${e}">`}function is(c){if(typeof navigator>"u"||!("serviceWorker"in navigator)||!navigator.serviceWorker)return;let e=navigator.serviceWorker,u=window;if(u.stxOffline)return;let o=null,
|
|
848
|
-
`+" `import.meta.env.STX_PUBLIC_*` is substituted at build time and is safe; anything else is not.\n Fix it by moving the module-only code (`import.meta.glob`, `import.meta.url`) into its own module, or by resolving the value without `import.meta`.");throw u[cn]=!0,u}async function un(c,e,u){let o=c,
|
|
844
|
+
`),A=i[0].outerStart,O=i[i.length-1].outerEnd;e=e.slice(0,A)+T+e.slice(O),u=A+T.length}return e}function Wr(c){return c.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function Xr(c){let e=c,u=0;while(u<e.length){let o=Ee(e,u);if(!o)break;let g=Pr.has(o.tag),i=o.attrs.replace(/([^\s=]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s]+))?/g,(v,y,x)=>{let b=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(y);if(!b||!x||!/^["']/.test(x))return v;let w=b[1]||"modelValue",T=b[2];if(g&&!b[1])return`@model${T}=${x}`;let A=x[0],O=x.slice(1,-1),M=`:${w}=${x} @update:${w}=${A}${O} = $event${A}`;if(T){let I=b[1]?`${w}Modifiers`:"modelModifiers",P=T.slice(1).split(".").map((N)=>`${N}: true`).join(", ");M+=` :${I}="{ ${P} }"`}return M});if(i===o.attrs){u=o.end;continue}let f=Me(o.full,{...o,start:0,end:o.full.length},i);e=e.slice(0,o.start)+f+e.slice(o.end),u=o.start+f.length}return e}function Kr(c){return c.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function Gr(c){return c.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function Jr(c){let e=c,u=0;while(u<e.length){let o=Ee(e,u);if(!o)break;let g=Fe(o.attrs,"v-html");if(g===null){u=o.end;continue}if(o.selfClosing){u=o.end;continue}let i=$e(e,o),f=be(o.attrs,"v-html"),v=o.selfClosing?" /":"",y=`<${o.tag}${f}${v}>{!! ${g} !!}</${o.tag}>`;e=e.slice(0,i.outerStart)+y+e.slice(i.outerEnd),u=i.outerStart+y.length}return e}function Zr(c){let e=c,u=0;while(u<e.length){let o=Ee(e,u);if(!o)break;let g=Fe(o.attrs,"v-text");if(g===null){u=o.end;continue}if(o.selfClosing){u=o.end;continue}let i=$e(e,o),f=be(o.attrs,"v-text"),v=o.selfClosing?" /":"",y=`<${o.tag}${f}${v}>{{ ${g} }}</${o.tag}>`;e=e.slice(0,i.outerStart)+y+e.slice(i.outerEnd),u=i.outerStart+y.length}return e}function Qr(c){return c.replace(/(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)\s+v-pre([^>]*>)/g,"$1$2 data-stx-skip$3").replace(/(<[a-zA-Z][a-zA-Z0-9-]*)\s+v-pre(\s[^>]*>|>)/g,"$1 data-stx-skip$2")}function Yr(c){let e=c,u=0;while(u<e.length){let o=Ee(e,u);if(!o)break;if(!Gt(o.attrs,"v-once")){u=o.end;continue}let g=be(o.attrs,"v-once"),i=$e(e,o),f=e.slice(i.outerStart,i.outerEnd),y=`@once
|
|
845
|
+
${Me(f,{...o,start:0,end:o.end-o.start},g)}
|
|
846
|
+
@endonce`;e=e.slice(0,i.outerStart)+y+e.slice(i.outerEnd),u=i.outerStart+y.length}return e}function es(c){return c.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function ns(c){return c.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function Jt(c){if(!qr(c))return c;let e=c;return e=Ur(e),e=Vr(e),e=Yr(e),e=Kr(e),e=Gr(e),e=Xr(e),e=Wr(e),e=ns(e),e=Jr(e),e=Zr(e),e=Qr(e),e=es(e),e}function We(c){return c.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}var nt=new Set(["a","abbr","address","article","aside","audio","b","bdi","bdo","blockquote","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","meter","nav","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","span","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","u","ul","video"]),rs=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function Zt(c,e){let u=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(c),o=u?u[1]:c,g=l(o,e);if(g&&typeof g==="string")return g;let i=o.trim();return nt.has(i)?i:null}function Qt(c){let e=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(c);return e?e[1]:c}function Yt(c,e,u){let o=e.replace(/\s*(?::is|v-bind:is)\s*=\s*"[^"]*"/gi,"").trim(),g=o?`<${c} ${o}>`:`<${c}>`;if(rs.has(c))return o?`<${c} ${o}>`:`<${c}>`;return`${g}${u}</${c}>`}async function en(c,e,u,o,g){let i=c,f=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,v=[],y;while((y=f.exec(i))!==null)v.push({full:y[0],expr:y[1],attrs:y[2],slotContent:y[3],index:y.index});for(let x=v.length-1;x>=0;x--){let b=v[x];try{let w=Zt(b.expr,e);if(!w||typeof w!=="string"){let N=`<!-- dynamic component: could not resolve "${We(Qt(b.expr))}" -->`;i=i.slice(0,b.index)+N+i.slice(b.index+b.full.length);continue}if(nt.has(w)){let N=Yt(w,b.attrs,b.slotContent);i=i.slice(0,b.index)+N+i.slice(b.index+b.full.length);continue}let T=b.attrs.trim(),A={},O=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,M;while((M=O.exec(T))!==null){let N=M[1]||M[2],V=M[3];if(M[1])try{A[N]=l(V,e)}catch{A[N]=V}else A[N]=V}let I=o.componentsDir||"components",P=await Le(w,A,b.slotContent,I,e,u,o,new Set,g??new Set);i=i.slice(0,b.index)+P+i.slice(b.index+b.full.length)}catch(w){let T=w instanceof Error?w.message:String(w),A=`<!-- dynamic component error: ${We(T)} -->`;i=i.slice(0,b.index)+A+i.slice(b.index+b.full.length)}}return i=await ss(i,e,u,o,g),i}async function ss(c,e,u,o,g){let i=c,f=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,v=[],y;while((y=f.exec(i))!==null)v.push({full:y[0],expr:y[1],attrs:y[2],index:y.index});for(let x=v.length-1;x>=0;x--){let b=v[x];try{let w=Zt(b.expr,e);if(!w||typeof w!=="string"){let O=`<!-- dynamic component: could not resolve "${We(Qt(b.expr))}" -->`;i=i.slice(0,b.index)+O+i.slice(b.index+b.full.length);continue}if(nt.has(w)){let O=Yt(w,b.attrs,"");i=i.slice(0,b.index)+O+i.slice(b.index+b.full.length);continue}let T=o.componentsDir||"components",A=await Le(w,{},"",T,e,u,o,new Set,g??new Set);i=i.slice(0,b.index)+A+i.slice(b.index+b.full.length)}catch(w){let T=w instanceof Error?w.message:String(w),A=`<!-- dynamic component error: ${We(T)} -->`;i=i.slice(0,b.index)+A+i.slice(b.index+b.full.length)}}return i}var ta="X-STX-Build",st=Symbol.for("stx.buildId");function Ys(){let c=globalThis;if(!c[st])c[st]=process.env.STX_BUILD_ID||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`;return c[st]}function tn(c,e=Ys()){if(c.includes('name="stx-build"'))return null;if(!/<head\b[^>]*>/i.test(c))return null;return`
|
|
847
|
+
<meta name="stx-build" content="${e}">`}function is(c){if(typeof navigator>"u"||!("serviceWorker"in navigator)||!navigator.serviceWorker)return;let e=navigator.serviceWorker,u=window;if(u.stxOffline)return;let o=null,g=!1,i=[],f={updateReady:!1,reachable:!0,reachedAt:0,registration:()=>o,onUpdateReady(b){if(f.updateReady)try{b()}catch{}else i.push(b);return()=>{let w=i.indexOf(b);if(w!==-1)i.splice(w,1)}},applyUpdate(){let b=o&&o.waiting;if(!b)return!1;return g=!0,b.postMessage({type:"stx:activate-update",force:!0}),!0}};u.stxOffline=f;let v=(b)=>{if(!b.waiting||!e.controller||f.updateReady)return;f.updateReady=!0;let w=i.splice(0);for(let T of w)try{T()}catch{}try{window.dispatchEvent(new CustomEvent("stx:offline-update-ready"))}catch{}};e.addEventListener("message",(b)=>{let w=b.data||{};if(w.type==="stx:updated")try{window.dispatchEvent(new CustomEvent("stx:updated",{detail:{url:w.url,kind:w.kind,fragment:!!w.fragment}}))}catch{}if(w.type==="stx:reachability"){if(u.stxOffline.reachable=w.reachable!==!1,Number(w.at)>0)u.stxOffline.reachedAt=Number(w.at);try{window.dispatchEvent(new CustomEvent("stx:reachability",{detail:{reachable:w.reachable!==!1,at:Number(w.at)||0}}))}catch{}}}),e.addEventListener("controllerchange",()=>{if(g)g=!1,location.reload()}),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden"&&o&&o.waiting)o.waiting.postMessage({type:"stx:activate-update",reason:"hidden"})});let y=()=>{e.register(c,{scope:"/"}).then((b)=>{o=b;try{e.controller?.postMessage({type:"stx:reachability?"})}catch{}if(b.waiting)v(b),b.waiting.postMessage({type:"stx:activate-update",reason:"load"});b.addEventListener("updatefound",()=>{let w=b.installing;if(!w)return;w.addEventListener("statechange",()=>{if(w.state==="installed")v(b)})})}).catch(()=>{})},x=()=>{let b=(w)=>{setTimeout(w,0)};if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>b(y));else b(y)};if(!e.controller)if(document.readyState==="complete")x();else addEventListener("load",x);else if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",x);else x()}function os(){let c=`(${is.toString()})(${JSON.stringify("/_stx/sw.js")})`;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(c).trim().replace(/;$/,"")}catch{return c}}var nn=`<script data-stx-offline>${os()}</script>`;import De from"path";function rn(c){return c.startsWith("http://")||c.startsWith("https://")||c.startsWith("//")}async function sn(c,e,u){try{let o;if(c.startsWith("/")){let g=e;for(let i=0;i<5;i++){let f=De.join(g,c);if(await Bun.file(f).exists())return f;g=De.dirname(g)}o=De.join(e,c)}else if(c.startsWith("./")||c.startsWith("../"))o=De.resolve(e,c);else o=De.resolve(e,c);if(await Bun.file(o).exists())return o;return null}catch{return null}}var cn=Symbol.for("stx.inline-assets.import-meta");function as(c,e){if(!c.includes("import.meta"))return;let u=Error(`[stx] ${e} still references \`import.meta\` after bundling, and it is being inlined as a classic <script> where that is a SyntaxError \u2014 the whole script fails to parse, taking every other script on the page with it.
|
|
848
|
+
`+" `import.meta.env.STX_PUBLIC_*` is substituted at build time and is safe; anything else is not.\n Fix it by moving the module-only code (`import.meta.glob`, `import.meta.url`) into its own module, or by resolving the value without `import.meta`.");throw u[cn]=!0,u}async function un(c,e,u){let o=c,g=De.dirname(e),i=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,f;while((f=i.exec(o))!==null){let[x,b,w,T]=f;if(rn(w))continue;let A=await sn(w,g,e);if(A)try{let O=await Bun.file(A).text();if(u.add(A),w.endsWith(".ts")||w.endsWith(".tsx")){let I=await Bun.build({entrypoints:[A],target:"browser",minify:!0,define:S()});if(I.outputs.length>0)O=await I.outputs[0].text(),as(O,w)}let M=`<script>
|
|
849
849
|
// Source: ${w}
|
|
850
850
|
${O}
|
|
851
|
-
</script>`;o=o.replace(x,M),i.lastIndex=0}catch(O){if(O?.[cn])throw O}}let v=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,y;while((y=v.exec(o))!==null){let[x,b,w,T]=y,A=b+T;if(rn(w))continue;if(/rel=["']stylesheet["']/.test(A)||w.endsWith(".css")){let M=await sn(w,
|
|
851
|
+
</script>`;o=o.replace(x,M),i.lastIndex=0}catch(O){if(O?.[cn])throw O}}let v=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,y;while((y=v.exec(o))!==null){let[x,b,w,T]=y,A=b+T;if(rn(w))continue;if(/rel=["']stylesheet["']/.test(A)||w.endsWith(".css")){let M=await sn(w,g,e);if(M)try{let I=await Bun.file(M).text();u.add(M);let P=`<style>
|
|
852
852
|
/* Source: ${w} */
|
|
853
853
|
${I}
|
|
854
|
-
</style>`;o=o.replace(x,P),v.lastIndex=0}catch(I){}}}return o}import it from"path";var cs=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,ls=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function ds(c,e){if(!e||!c.includes("/"))return c;let u=it.dirname(e);return c.replace(cs,(o,
|
|
855
|
-
`,o+2),o===-1)return-1;o+=1,
|
|
856
|
-
`){y=-1;break}y++}if(y===-1){o++,
|
|
857
|
-
`)break;o++}
|
|
858
|
-
`+c.slice(o,u.start)+c.slice(u.end);let
|
|
859
|
-
`+i;return i.slice(0,
|
|
860
|
-
`+i.slice(
|
|
861
|
-
`),...x.htmlAttrs&&{htmlAttrs:nc(v.htmlAttrs,x.htmlAttrs)},...x.bodyAttrs&&{bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs}}},X=Uo(
|
|
854
|
+
</style>`;o=o.replace(x,P),v.lastIndex=0}catch(I){}}}return o}import it from"path";var cs=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,ls=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function ds(c,e){if(!e||!c.includes("/"))return c;let u=it.dirname(e);return c.replace(cs,(o,g,i,f)=>{let v=it.resolve(u,f);return`${g}${i}${v.split(it.sep).join("/")}${i}`})}function dn(c,e){if(!e||!c.includes("<script"))return c;return c.replace(ls,(u,o,g,i)=>`${o}${ds(g,e)}${i}`)}var _e="<!--PARENT_CONTENT_PLACEHOLDER-->";function fn(c){return c.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Sn(c,e){let u=c.length,o=e,g=!0,i=[],f=(v)=>v+9<=u&&c[v]==="<"&&c[v+1]==="/"&&(c[v+2]==="s"||c[v+2]==="S")&&(c[v+3]==="c"||c[v+3]==="C")&&(c[v+4]==="r"||c[v+4]==="R")&&(c[v+5]==="i"||c[v+5]==="I")&&(c[v+6]==="p"||c[v+6]==="P")&&(c[v+7]==="t"||c[v+7]==="T")&&(c[v+8]===">"||/\s/.test(c[v+8]));while(o<u){let v=c[o];if(f(o))return o;if(v==="/"&&c[o+1]==="/"){if(o=c.indexOf(`
|
|
855
|
+
`,o+2),o===-1)return-1;o+=1,g=!0;continue}if(v==="/"&&c[o+1]==="*"){let y=c.indexOf("*/",o+2);if(y===-1)return-1;o=y+2,g=!0;continue}if(v==="/"&&g){let y=o+1,x=!1;while(y<u){let b=c[y];if(b==="\\"){y+=2;continue}if(b==="[")x=!0;else if(b==="]")x=!1;else if(b==="/"&&!x){y++;break}else if(b===`
|
|
856
|
+
`){y=-1;break}y++}if(y===-1){o++,g=!1;continue}while(y<u&&/[a-z]/.test(c[y]))y++;o=y,g=!1;continue}if(v==="'"||v==='"'){let y=v;o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]===y){o++;break}if(c[o]===`
|
|
857
|
+
`)break;o++}g=!1;continue}if(v==="`"){o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,g=!0;break}o++}if(i.length===0)g=!1;continue}if(v==="}"&&i.length>0){i.pop(),o++;while(o<u){if(c[o]==="\\"){o+=2;continue}if(c[o]==="`"){o++,g=!1;break}if(c[o]==="$"&&c[o+1]==="{"){i.push(!0),o+=2,g=!0;break}o++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))g=!1;else g=!0;o++}return-1}function $n(c,e){let u=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp(`<script\\b(?=[^>]*\\b${u}(?:\\s|=|/?>))[^>]*>`,"i").exec(c);if(!o)return null;let g=o.index+o[0].length,i=c.indexOf("</script>",g);if(i===-1)return null;let f=c.indexOf(">",i);if(f===-1)return null;return{start:o.index,end:f+1}}var hs=4096;async function mn(c,e,u){if(u.buildMode!=="serve"||e.length<hs)return null;let{registerServeModuleBundle:o}=await import("./chunk-c3dk9pkf.js");return`<script ${c} src="${o(e)}"></script>`}async function Hn(c,e,u){try{let{registeredModuleIdsIn:o,buildModuleRegistryScript:g}=await r("stx/client-module-registry",()=>import("./chunk-w6x8m0tz.js")),i=[],f=await g(o(...c),{minify:qo(e.buildMode),collectInputs:i});for(let v of i)u?.add(v);if(!f)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:v}=await import("./chunk-c3dk9pkf.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${v(f)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${f.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}function ys(c,e=""){let u=$n(c,"data-stx-runtime");if(!u)return c;let o=Gn(c);if(o===-1||o===u.start){if(!e)return c;return c.slice(0,u.end)+e+c.slice(u.end)}if(o<u.start)return c.slice(0,o)+c.slice(u.start,u.end)+e+`
|
|
858
|
+
`+c.slice(o,u.start)+c.slice(u.end);let g=c.slice(u.start,u.end),i=c.slice(0,u.start)+c.slice(u.end),f=Gn(i);if(f===-1)return g+e+`
|
|
859
|
+
`+i;return i.slice(0,f)+g+e+`
|
|
860
|
+
`+i.slice(f)}function vs(c){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return c.replace(e,(u,o,g)=>{let i=c.slice(0,g);return i.lastIndexOf("<")>i.lastIndexOf(">")?`{{${o}}}`:`{<!--stx-literal-->{${o}}}`})}async function s(c,e,u,o,g){if(o.ssr===!1&&!o.autoShell&&o.buildMode==="spa")return c;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=ve(c,u);let i=!e.__stxProcessingDepth;ln(e);for(let f of o._layerGraph?.configDependencies??[])g.add(f);if(i&&o.runtimeConfig)await gn(e,u,o.runtimeConfig);if(i)za(e),e.__stx_scope_seq??={n:0,key:ms(String(e.__filename??u))},e.__stx_head_injections=Vo(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((o.debug||!C()&&!bn())&&u&&u.endsWith(".stx"))Zs(c,u);try{return await te.timeAsync("template-processing",async()=>{let f=await bs(c,e,u,o,g);if(i)f=Ao(f);if(i&&o.autoShell&&o.buildMode!=="compile"){let v=xe(o.app?.head,{known:hr,source:"app.head"}),x=(e.__stx_runtime_head||null)??Wo(),b=(e.__stx_head_raw||"").trim(),w,T=b.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(T)w=T[1].trim(),b=b.replace(T[0],"").trim();let A=e.__sections?.title,O=A?k(A,e,u):void 0,M=x.title||w||O,I=!x.title&&(!!w||!!O),P=x.meta||[],N=new Set(P.map((G)=>rt(G)).filter(Boolean)),V={...v,...M&&{title:M},meta:[...(v.meta||[]).filter((G)=>!N.has(rt(G))),...P],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],headRaw:[v.headRaw,b].filter(Boolean).join(`
|
|
861
|
+
`),...x.htmlAttrs&&{htmlAttrs:nc(v.htmlAttrs,x.htmlAttrs)},...x.bodyAttrs&&{bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs}}},X=Uo(f);if(f=gr(f,V,{...I&&{titleIsHtml:!0},...o.app?.colorMode&&{colorMode:o.app.colorMode}},X),X)f=sc(f,v),f=fr(f,V.htmlAttrs);let L=f.match(/<!-- stx-layout: ([^ ]+) -->/);if(L&&f.includes("<head")){let G=L[1],J=ts(G);f=f.replace(/<head\b[^>]*>/i,(Y)=>`${Y}
|
|
862
862
|
<meta name="stx-layout" content="${fn(G)}">
|
|
863
|
-
<meta name="stx-layout-group" content="${fn(J)}">`)}let j=
|
|
864
|
-
${O}`).join("");
|
|
865
|
-
`+
|
|
863
|
+
<meta name="stx-layout-group" content="${fn(J)}">`)}let j=f.match(/function (__stx_setup_\w+)\(/),H=j?U(f):null;if(j&&H&&!/\bdata-stx=/.test(H.tag)){f=Ge(f,(J,Y)=>`<body${Y} data-stx="${j[1]}">`);let G=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${j[1]}"`,"i");f=f.replace(G,"$1")}}if(i){let v=e.__stx_head_injections??Vo(),y=rc(f);if(y!==null)v.beforeClose.push(y);let x=tn(f);if(x!==null)v.afterOpen.push(x);if(o.offline?.enabled&&!f.includes("data-stx-offline"))v.beforeClose.push(nn);f=ec(f,v);let b=o.app?.colorMode;if(b)f=pr(f,b)}if(i)if($n(f,"data-stx-runtime")){let y=null,x=null,b=null,w=null,T=null;try{let{getStoreScript:O}=await r("stx/store-loader",()=>import("./chunk-hj0raner.js")),M=o.storesDir,I=await O(M);if(I)b=`<script data-stx-stores>${I}</script>`,x=await mn("data-stx-stores",I,o)??b}catch{}y=await Hn([f,b],o,g);try{let{getFrameworkComposableScript:O}=await r("stx/framework-composables",()=>import("./chunk-0hemydnd.js"));T=await O(f)}catch{}try{let{getComposableScript:O}=await r("stx/composable-loader",()=>import("./chunk-tw0wc95k.js")),M=o.composablesDir,I=[y,b,T].filter((N)=>N!==null),P=await O(o._layerComposableDirs??M,f,I);if(P)w=await mn('data-stx-scoped data-stx-run="always" data-stx-composables',P,o)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${P}</script>`}catch{}let A=[y,x,w,T].filter((O)=>O!==null).map((O)=>`
|
|
864
|
+
${O}`).join("");f=ys(f,A)}else{let y=await Hn([f],o,g);if(y){let x=f.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(x!==-1)f=f.slice(0,x)+y+`
|
|
865
|
+
`+f.slice(x)}}if(i)f=tc(f);if(i&&e.__stx_inject_css!==!1)f=await h(f,void 0,o.buildMode==="serve",!0);else if(i)f=an(f);if(f=f.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),f=vs(f),i&&e.__stx_runtime_config)f=Ot(f,e.__stx_runtime_config);if(i&&!e.__stx_defer_server_data){let v=cr(e);if(v){let y=/<head\b[^>]*>/i.exec(f),x=y?y.index+y[0].length:0;f=f.slice(0,x)+v+f.slice(x)}}return f})}catch(f){if(f instanceof z)throw f;let v=f instanceof Error?f.message:String(f),y=new re(`Template processing failed: ${v}`,u,void 0,void 0,c.substring(0,200)+(c.length>200?"...":""));if(D.log(y,{filePath:u,context:e}),hn.logDetailedError(y,{filePath:u,template:c.substring(0,500)}),C()&&!o.debug)console.error(`[stx] ${ce.relative(process.cwd(),u)||u}: ${y.message}`);if(o.debug)throw y;return zo.createFallbackContent("Template Processing",y)}}async function bs(c,e,u,o,g){let i=process.cwd(),f={...o,partialsDir:o.partialsDir&&!ce.isAbsolute(o.partialsDir)?ce.resolve(i,o.partialsDir):o.partialsDir,componentsDir:o.componentsDir&&!ce.isAbsolute(o.componentsDir)?ce.resolve(i,o.componentsDir):o.componentsDir,layoutsDir:o.layoutsDir&&!ce.isAbsolute(o.layoutsDir)?ce.resolve(i,o.layoutsDir):o.layoutsDir},v=f,y=c;await ks(u,e),xs(e,v),y=await we(()=>zt(y,e,u,v),y,(L)=>{D.log(L,{filePath:u,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${u}: ${L.message}`)}),y=y.replace(/\{\{--[\s\S]*?--\}\}/g,"");let x=le(y,Pe,(L,j)=>`\x00STX_HTML_COMMENT_${j}\x00`);y=x.output;let b=x.tokens,w=(L)=>b.length===0?L:L.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(j,H)=>b[Number(H)]??""),T="\x00STX_ESCAPED_AT\x00",A="\x00STX_ESC_MUSTACHE_OPEN\x00",O="\x00STX_ESC_MUSTACHE_CLOSE\x00";y=y.replace(/@@/g,T),y=y.replace(/@\{\{([\s\S]*?)\}\}/g,(L,j)=>`${A}${j}${O}`),y=Jt(y),y=await un(y,u,g);let M={};y=Mr(y,M);let I={...e.__sections||{}},P="",N=mt(gt(c)),V=/@nolayout\b/.test(y)||N===!1;if(/@nolayout\b/.test(y))y=y.replace(/@nolayout\b\s*/g,"");let X=y.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(X)P=X[1],y=y.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof N==="string"){if(P=N,!/@section\s*\(/.test(y))y=`@section('content')
|
|
866
866
|
${y.trim()}
|
|
867
867
|
@endsection`}if(!P&&!V&&v.defaultLayout){let L=yn(y),j=/@section\s*\(/.test(y);if(!L||j){let H="",G=ce.dirname(u),J=v.layoutsDir?ce.dirname(v.layoutsDir):process.cwd();for(let Y=0;Y<20;Y++){let ne=ce.join(G,"_layout.stx");if(await n(ne)){H=ne;break}let se=ce.dirname(G);if(se===G||se.length<J.length)break;G=se}if(H)P=H;else if(v.layoutsDir){let Y=ce.isAbsolute(v.layoutsDir)?v.layoutsDir:ce.resolve(process.cwd(),v.layoutsDir),ne=ce.join(Y,`${v.defaultLayout}.stx`);if(await n(ne))P=ne}if(P&&!j)y=`@section('content')
|
|
868
868
|
${y.trim()}
|
|
869
|
-
@endsection`}}if(P&&y.includes("<script")){let L=q(y),j=L.scripts.map((H)=>vn(H,u)??H);y=or(L.output,j)}if(y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(L,j,H)=>(I[j]=H,"")),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(L,j,H)=>{if(/^(['"]).*\1$/.test(H.trim()))return L;try{let G=l(H.trim(),e);if(G===void 0)return L;let Y=(e.__stx_inline_section_values??=[]).push(G)-1;return I[j]=`{{ __stx_inline_section_values[${Y}] }}`,""}catch{return L}}),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(L,j,H)=>{if(H.includes("@parent"))I[j]=H.replace("@parent",
|
|
869
|
+
@endsection`}}if(P&&y.includes("<script")){let L=q(y),j=L.scripts.map((H)=>vn(H,u)??H);y=or(L.output,j)}if(y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(L,j,H)=>(I[j]=H,"")),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(L,j,H)=>{if(/^(['"]).*\1$/.test(H.trim()))return L;try{let G=l(H.trim(),e);if(G===void 0)return L;let Y=(e.__stx_inline_section_values??=[]).push(G)-1;return I[j]=`{{ __stx_inline_section_values[${Y}] }}`,""}catch{return L}}),y=y.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(L,j,H)=>{if(H.includes("@parent"))I[j]=H.replace("@parent",_e);else I[j]=H.trim();return""}),e.__sections=I,y=y.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(L,j,H)=>I[j]||H||""),!("slot"in e)||e.slot===void 0)y=y.replace(/\{\{\s*slot\s*\}\}/g,()=>I.content||"");if(y=Lr(y,M),P){let L=[],j=q(y),H=le(j.output,on,(G,J)=>`\x00STX_ORPHAN_STYLE_${J}\x00`);if(y=H.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(G,J,Y)=>{let ne=J==="SCRIPT"?vn(j.scripts[Number(Y)],u):H.tokens[Number(Y)];if(ne)L.push(ne);return""}),L.length>0){let G=L.join(`
|
|
870
870
|
`);I.content=I.content?`${I.content}
|
|
871
|
-
${G}`:G,e.__sections=I}}if(P)try{let L;if(ce.isAbsolute(P))L=P,
|
|
872
|
-
${y}`,w(y)}catch(L){if(L instanceof z)throw L;throw new re(`Error processing layout ${P}: ${L instanceof Error?L.message:String(L)}`,u)}return w(await kn(y,e,u,
|
|
873
|
-
`;if(i=Y(i,e),i=ne(i,e,u),i=Xt(i),i=no(i,e),i=
|
|
871
|
+
${G}`:G,e.__sections=I}}if(P)try{let L;if(ce.isAbsolute(P))L=P,g.add(P);else L=await we(()=>pn(P,u,f,g),null,()=>{throw new re(`Failed to resolve layout path: ${P}`,u,void 0,void 0,`Layout referenced from ${u}`)});if(!L){let ne=(oe)=>{if(!oe)return[];try{let ae=ce.isAbsolute(oe)?oe:ce.resolve(process.cwd(),oe);return fs.readdirSync(ae).filter((ue)=>ue.endsWith(".stx")).map((ue)=>ue.replace(/\.stx$/,""))}catch{return[]}},se=[...ne(f.layoutsDir),...ne(f.fallbackLayoutsDir)].filter((oe,ae,ue)=>ue.indexOf(oe)===ae).sort(),de=`Layout not found: ${P} (referenced from ${u})`+(se.length>0?`. Available layouts: ${se.join(", ")}`:f.layoutsDir?`. No .stx layouts found in ${f.layoutsDir}`:"");if(D.log(Error(de),{layoutPath:P,filePath:u,available:se},"error"),console.error(`[stx] ${de}`),f.debug)throw new re(de,u);return y}let j=await we(()=>Bun.file(L).text(),"",()=>{throw new re(`Failed to read layout file: ${L}`,u,void 0,void 0,"Layout content could not be loaded")});j=dn(j,L);let H=j.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(H){if(f.debug)console.log(`Found nested layout: ${H[1]} in ${L}`);let ne={},se=j.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ae,ue,ke)=>(ne[ue]=ke.trim(),""));for(let[ae,ue]of Object.entries(ne))if(I[ae]&&I[ae].includes(_e)){let ke=I[ae].indexOf(_e);I[ae]=I[ae].slice(0,ke)+ue+I[ae].slice(ke+_e.length)}else if(!I[ae])I[ae]=ue;let de={...e,__sections:I},oe=`@layout('${H[1]}')${se}`;return await s(oe,de,L,f,g)}let G=j.replace(/\{\{--[\s\S]*?--\}\}/g,""),J=Mr(G,M),Y={};return J=J.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(ne,se,de)=>(Y[se]=de.trim(),`@slot('${se}')`)),J=J.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(ne,se,de)=>{if(I[se]){let oe=I[se];if(oe.includes(_e)){let ae=Y[se]||"",ue=oe.indexOf(_e);oe=oe.slice(0,ue)+ae+oe.slice(ue+_e.length)}return oe}return de||""}),J=ws(J,I),J=J.replace(/\{\{\s*slot\s*\}\}/g,()=>I.content||""),J=Lr(J,M),e.__originalFilePath=u,y=await kn(J,e,L,f,g),y=`<!-- stx-layout: ${P} -->
|
|
872
|
+
${y}`,w(y)}catch(L){if(L instanceof z)throw L;throw new re(`Error processing layout ${P}: ${L instanceof Error?L.message:String(L)}`,u)}return w(await kn(y,e,u,f,g))}function ws(c,e){return c.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(u,o,g)=>{let i=e[o];if(i!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(i))return i}return g||""})}function xs(c,e){if(c.__stx_sfc_mode=!0,c.__stx_options=e,e.buildMode)c.__stx_buildMode=e.buildMode;let u=e.envPrefix||"STX_PUBLIC_",o={};for(let[g,i]of Object.entries(process.env))if(g.startsWith(u)&&i!==void 0)o[g]=i;c.$env=o}async function ks(c,e){await we(()=>Kt(c,e),void 0,(u)=>{D.log(u,{filePath:c,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${c}: ${u.message}`)})}var ot="data-stx-source";function vn(c,e){if(!c)return c;let u=/^<script\b([^>]*)>/i.exec(c);if(!u||!/\bserver\b/.test(u[1])||u[1].includes(ot))return c;return`<script ${ot}="${encodeURIComponent(e)}"${c.slice(7)}`}function Ss(c){let e=new RegExp(`${ot}="([^"]*)"`).exec(c);return e?decodeURIComponent(e[1]):void 0}function wn(c){return c.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function xn(c,e,u){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${wn(c)}</span><span style="display:block;margin-top:4px">${wn(u)}</span></div>`}async function $s(c,e,u,o){let{scanScriptTags:g}=await r("stx/signal-processing",()=>import("./chunk-zdgsj39g.js")),i=[],f=!C()&&!bn();for(let y of g(c)){let x=y.attrs;if(!/\bserver\b/.test(x))continue;let b=y.start+y.fullMatch.indexOf(">")+1,w=Sn(c,b);if(w===-1)continue;let T=c.slice(b,w);if(!T.trim())continue;let A=Ss(x)??u,O={index:y.start,length:w+9-y.start};try{let{extractVariables:M}=await r("stx/variable-extractor",()=>import("./chunk-s5w3t7xw.js"));await M(T,e,A,{preserveExisting:!0,onFailure:(I)=>{if(I.kind==="unknown")return;if(o?.onServerScriptError?.({sourcePath:A,kind:I.kind,message:I.message}),!f)return;i.push({...O,markup:xn(A,I.kind,I.message)})}})}catch(M){let I=M instanceof Error?M:Error(String(M));if(D.log(I,{filePath:A,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${A}: ${I.message}`),f)i.push({...O,markup:xn(A,"unknown",I.message)})}}if(i.length===0)return c;let v=c;for(let y of i.sort((x,b)=>b.index-x.index))v=v.slice(0,y.index)+y.markup+v.slice(y.index+y.length);return v}async function Es(c,e,u){try{let{interpolateScriptsInTemplate:o}=await r("stx/expressions",()=>import("./chunk-9vaz5f9j.js"));return o(c,e,{skipServer:!0})}catch(o){let g=o instanceof Error?o:Error(String(o));return D.log(g,{filePath:u,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${u}: ${g.message}`),c}}async function kn(c,e,u,o,g){let i=c,f=o;if(i=await $s(i,e,u,o),i=await Bt(i,e,u),i=await Ft(i,e,u),i=await Es(i,e,u),i=await At(i,e,u,f),ve(i))i=io(i,e),i=Hr(i,e),i=zr(i,e);i=ao(i);let{processStreamDirectives:v}=await r("stx/streaming",()=>import("./chunk-n7a33e3v.js"));i=v(i,e),i=qn(i,e,u,f,!0),i=await en(i,e,u,f,g),i=await Br(i,e,u,f,g),i=ua(i,e,u,f);let{processDeferDirectives:y}=await r("stx/defer",()=>import("./chunk-2f17h17f.js"));i=y(i,e,u);let{processTeleportDirectives:x}=await r("stx/teleport",()=>import("./chunk-wq712sw1.js"));i=x(i,e,u);let{processTransitionDirectives:b,processTransitionAttributes:w}=await r("stx/transitions",()=>import("./chunk-k2pa44rf.js"));i=b(i,e,u),i=w(i);let{processErrorBoundaryDirectives:T,stripRenderFailedMarkers:A}=await r("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));i=T(i,e,u),i=A(i);let{processSuspenseDirectives:O}=await r("stx/suspense",()=>import("./chunk-weqc0ssb.js"));i=O(i,e,u);let{processAsyncDirectives:M}=await r("stx/async-components",()=>import("./chunk-67kj14at.js"));i=M(i,e,u);let{processKeepAliveDirectives:I}=await r("stx/keep-alive",()=>import("./chunk-6vzktvyw.js"));i=I(i,e,u);let{processVirtualListDirectives:P,processVirtualGridDirectives:N,processInfiniteListDirectives:V}=await r("stx/virtual-scrolling",()=>import("./chunk-sf0wsq74.js"));i=P(i,e,u),i=N(i,e,u),i=V(i,e,u);let{processPartialHydrationDirectives:X,processStaticDirectives:L}=await r("stx/partial-hydration",()=>import("./chunk-9szxxgv5.js"));i=X(i,e,u),i=L(i);let{processComputedDirectives:j,processWatchDirectives:H}=await r("stx/computed",()=>import("./chunk-1xdzcy9d.js"));i=j(i,e,u),i=H(i,e,u);let{processFormValidationDirectives:G}=await r("stx/forms-validation",()=>import("./chunk-hkqhpckf.js"));i=G(i,e,u);let{processHeadDirective:J,processTitleDirective:Y,processMetaDirective:ne,resetHead:se}=await r("stx/head",()=>import("./chunk-e1fetwbr.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)se();let de=J(i);if(i=de.content,de.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${de.headContent}
|
|
873
|
+
`;if(i=Y(i,e),i=ne(i,e,u),i=Xt(i),i=no(i,e),i=Ct(i),i=Ut(i),i=await Dr(i,e,u,f,g),i=await Br(i,e,u,f,g),e.__stxProcessingDepth===1)i=Ha(i,e);if(i=i.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),i=Ao(i),i=ee(i,e,u),i=Nr(i),i=La(i,e,{filePath:u,buildMode:f.buildMode}),i=ro(i,e),i=so(i,e),i=ze(i,e),i=Nt(i,e),i=Ht(i,e),i=await bt(i,e,u,f),i=await pa(i,e,u),i=await fa(i,e,u,f),i=ga(i,e,u,f),i=mo(i,e,u,f),i=ho(i,e,u),i=yo(i,e,u,f),i=_t(i,e,u,f),i=ps(i,e),i=gs(i),i=ja(i),!f.skipEventDirectives)i=Ea(i,e,u);if(i=vt(i,e,u),f.debug){let B=/\bx-data\s*=/.test(i),W=Fr(c);if(B&&W)console.warn(`[stx] ${u}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
874
874
|
Both work on the same page, but they manage separate scopes.
|
|
875
|
-
Prefer signals (state/derived/effect) for new components.`)}i=oa(i,e),i=await k(i,e,u),i=Ba(i),i=Fa(i),i=pt(i);let{processXElementDirectives:oe}=await r("stx/x-element",()=>import("./chunk-zhxdpzga.js"));i=oe(i);let ae=e.__originalFilePath||u,ue=
|
|
875
|
+
Prefer signals (state/derived/effect) for new components.`)}i=oa(i,e),i=await k(i,e,u),i=Ba(i),i=Fa(i),i=pt(i);let{processXElementDirectives:oe}=await r("stx/x-element",()=>import("./chunk-zhxdpzga.js"));i=oe(i);let ae=e.__originalFilePath||u,ue=Oe(e);if(i=await co(i,f,ae,ue),i=Pt(i,e),i=await Wt(i,e,u,f),f.media?.image?.autoSiblings){let B=f.publicDir||"public",{rewriteImagesWithSiblings:W}=await r("stx/image-optimization/auto-sibling",()=>import("./chunk-shpc1ttk.js"));i=await W(i,{publicDir:B})}if(f.seo?.enabled)i=bo(i,e,f);let ke=(B,W,Z=!0)=>{if(!W)return B;let he=W.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),ie=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(B),fe=ie?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(ie[0]):null;if(he&&ie&&fe){if(Z){let Ce=ie.index+fe.index;B=B.slice(0,Ce)+he[0]+B.slice(Ce+fe[0].length)}if(W=W.replace(he[0],"").trim(),!W)return B}if(/<\/head>/i.test(B))return B.replace(/<\/head>/i,`${W}
|
|
876
876
|
</head>`);if(/<head\b[^>]*>/i.test(B))return B.replace(/(<head\b[^>]*>)/i,`$1
|
|
877
877
|
${W}`);if(/<html\b[^>]*>/i.test(B))return B.replace(/(<html\b[^>]*>)/i,`$1
|
|
878
878
|
<head>
|
|
879
879
|
${W}
|
|
880
|
-
</head>`);return B},{renderHead:En,getHead:_n}=await r("stx/head",()=>import("./chunk-
|
|
880
|
+
</head>`);return B},{renderHead:En,getHead:_n}=await r("stx/head",()=>import("./chunk-e1fetwbr.js")),Ie=e.__stx_runtime_head??_n();if(Ie.title||Ie.meta?.length||Ie.link?.length){let B=En(Ie);if(B)i=ke(i,B)}if(de.headContent)i=ke(i,de.headContent,!Ie.title);if(f.csp?.enabled&&f.csp.addMetaTag)i=St(i,f.csp,e);if(f.analytics?.enabled)i=ft(i,f);if(f.heatmap?.enabled)i=da(i,f);if(f.pwa?.enabled&&f.pwa.autoInject!==!1){let{injectPwaTags:B}=await r("stx/pwa/inject",()=>import("./chunk-1pnp91wx.js"));i=B(i,f)}let Tn=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(i),Cn=/\bSTX\.\w+/.test(i),An=/window\.STX\s*=/.test(i);if(Tn&&Cn&&!An){let W=`<script data-stx-scoped data-stx-run="once">
|
|
881
881
|
${lt()}
|
|
882
882
|
</script>`;if(i.includes("</head>")){let Z=i.indexOf("</head>"),ie=i.slice(0,Z).indexOf("<script");if(ie!==-1){let fe=i.slice(0,ie),Ce=i.slice(ie);i=fe+W+`
|
|
883
883
|
`+Ce}else i=i.replace("</head>",`${W}
|
|
884
884
|
</head>`)}else if(i.includes("<body"))i=i.replace(/<body([^>]*)>/,`<body$1>
|
|
885
885
|
${W}`);else i=W+`
|
|
886
|
-
`+i}{let{scanScriptTags:B}=await r("stx/signal-processing",()=>import("./chunk-
|
|
887
|
-
`+i.slice(Z)}e.__stx_event_bindings=[]}}if(!ge(i)&&aa(i))i=await Kn(i,
|
|
888
|
-
export{
|
|
886
|
+
`+i}{let{scanScriptTags:B}=await r("stx/signal-processing",()=>import("./chunk-zdgsj39g.js")),W=[];for(let Z of B(i)){if(!/\bserver\b/i.test(Z.attrs))continue;let he=Z.start+Z.fullMatch.indexOf(">")+1,ie=Sn(i,he);if(ie===-1)continue;let fe=ie+9;while(fe<i.length&&/\s/.test(i[fe]))fe++;W.push({start:Z.start,end:fe})}if(W.length>0){let Z=Array(W.length+1),he=0;for(let ie=0;ie<W.length;ie++){let{start:fe,end:Ce}=W[ie];Z[ie]=i.slice(he,fe),he=Ce}Z[W.length]=i.slice(he),i=Z.join("")}}let at=us(i,u);if(at.hasScoped)i=at.html;let Rn=e.__stx_event_bindings||[],Ke=!1,ct=[],Mn=/\s:[a-z][\w.-]*\s*=/.test(i),{scanScriptTags:Dn}=await r("stx/signal-processing",()=>import("./chunk-zdgsj39g.js"));for(let B of Dn(i,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))ct.push({match:B.fullMatch,attrs:B.attrs,content:B.body});for(let{match:B,attrs:W,content:Z}of ct){Ke=!0;let he=Z;Ae(Z,u,o.strict,e.__originalFilePath);let ie=await Ne(Z,{eventBindings:Rn,attrs:W,hasColonDirectives:Mn,templateContent:c,filePath:u,projectRoot:process.cwd(),production:qo(o.buildMode),serverData:ue});i=i.replace(B,()=>ie)}if(Ke)e.__stx_event_bindings=[];if(!Ke&&e.__stxProcessingDepth===1){let B=e.__stx_event_bindings||[];if(B.length>0){let W=_o(B);if(W){let Z=i.lastIndexOf("</body>");i=Z===-1?i+W:i.slice(0,Z)+W+`
|
|
887
|
+
`+i.slice(Z)}e.__stx_event_bindings=[]}}if(!ge(i)&&aa(i))i=await Kn(i,f);if(i=ca(i),f.csp?.enabled&&f.csp.useNonce&&typeof e.cspNonce==="string")i=$t(i,e.cspNonce);return i}
|
|
888
|
+
export{gt,Te,ta,Ys,Hn,s};
|