@stacksjs/stx 0.2.919 → 0.2.921
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-0678sab4.js +2 -0
- package/dist/chunk-0bnv0aaz.js +2 -0
- package/dist/chunk-0bvfm5h5.js +2 -0
- package/dist/chunk-0c3q5h03.js +2 -0
- package/dist/chunk-0fh84wr5.js +2 -0
- package/dist/chunk-0p9x0m5n.js +2 -0
- package/dist/{chunk-m390z8w8.js → chunk-0rq1w0xr.js} +7 -7
- package/dist/{chunk-fwxgzktt.js → chunk-1pc2p489.js} +2 -2
- package/dist/{chunk-2szhk8mh.js → chunk-29cy41z3.js} +4 -4
- package/dist/{chunk-9mack1g8.js → chunk-2d0pemtc.js} +3 -3
- package/dist/{chunk-1bf0grbf.js → chunk-2qnpr0ty.js} +3 -3
- package/dist/{chunk-fjpt8arw.js → chunk-2r2tayyd.js} +2 -2
- package/dist/chunk-2sfxj244.js +2 -0
- package/dist/{chunk-wxqay5c2.js → chunk-30d298vs.js} +1 -1
- package/dist/{chunk-d69k67bn.js → chunk-36j2drjv.js} +9 -9
- package/dist/{chunk-9gr7m3tb.js → chunk-3d0bjcn7.js} +1 -1
- package/dist/chunk-3k9d0h11.js +2 -0
- package/dist/{chunk-whnzf9hn.js → chunk-3mc9ew9r.js} +6 -6
- package/dist/chunk-43r0h76m.js +2 -0
- package/dist/{chunk-cbqe84g3.js → chunk-4f8h38xr.js} +2 -2
- package/dist/{chunk-858p3hkz.js → chunk-4jg8ddfy.js} +2 -2
- package/dist/chunk-4jh5t3rz.js +2 -0
- package/dist/{chunk-rk16391e.js → chunk-4nabpd82.js} +5 -5
- package/dist/{chunk-p3x7kwb5.js → chunk-4w203ddt.js} +6 -6
- package/dist/chunk-4y2k14ec.js +2 -0
- package/dist/chunk-57xcb1wn.js +2 -0
- package/dist/chunk-5ekbye3p.js +2 -0
- package/dist/chunk-5s1q4y2j.js +2 -0
- package/dist/chunk-6359fekc.js +2 -0
- package/dist/{chunk-wv0wsavj.js → chunk-66cz2ph7.js} +2 -2
- package/dist/{chunk-p0xqm2ne.js → chunk-7767n5k6.js} +1 -1
- package/dist/{chunk-xpsg91dh.js → chunk-78j6c3sf.js} +5 -5
- package/dist/{chunk-qtzfbv7e.js → chunk-7d0h2pa3.js} +5 -5
- package/dist/{chunk-jgtn9t5n.js → chunk-7g720sk3.js} +2 -2
- package/dist/chunk-7nshr15z.js +2 -0
- package/dist/{chunk-14df2jzs.js → chunk-875wejw1.js} +2 -2
- package/dist/chunk-8g6cmgn8.js +2 -0
- package/dist/chunk-8gfdy17b.js +2 -0
- package/dist/{chunk-fn0y9z1t.js → chunk-8vjsmyrk.js} +5 -5
- package/dist/chunk-8yx65vb0.js +2 -0
- package/dist/{chunk-09xqy448.js → chunk-90ps064x.js} +2 -2
- package/dist/chunk-91nwc581.js +2 -0
- package/dist/{chunk-yzqb7y45.js → chunk-94001bha.js} +5 -5
- package/dist/chunk-94skx5m6.js +2 -0
- package/dist/chunk-9aegppj7.js +2 -0
- package/dist/{chunk-gjyz5ma7.js → chunk-9ch2qhbw.js} +1 -1
- package/dist/{chunk-m6hrb7rm.js → chunk-9sk596tw.js} +25 -25
- package/dist/{chunk-3ftrv1f7.js → chunk-a3qb13vr.js} +20 -20
- package/dist/chunk-a5vzdhsk.js +2 -0
- package/dist/{chunk-jjq7c8s2.js → chunk-a78k8fkg.js} +2 -2
- package/dist/{chunk-txk2z7v0.js → chunk-ag07tdhn.js} +4 -4
- package/dist/{chunk-0wctbtad.js → chunk-amnfd29h.js} +3 -3
- package/dist/chunk-aqh48tyw.js +2 -0
- package/dist/{chunk-zaj3nnvv.js → chunk-avtq2p0c.js} +2 -2
- package/dist/{chunk-3kpxkjgm.js → chunk-b0kq5mzq.js} +2 -2
- package/dist/chunk-b6am4h24.js +2 -0
- package/dist/{chunk-qzqqzraq.js → chunk-b9z4nb1v.js} +6 -6
- package/dist/{chunk-d4xjwebv.js → chunk-bwnx71s8.js} +5 -5
- package/dist/{chunk-mr9pp5cf.js → chunk-c3nmjx26.js} +2 -2
- package/dist/chunk-cajg2sz0.js +2 -0
- package/dist/{chunk-3efpqm1f.js → chunk-dhx4m7mf.js} +2 -2
- package/dist/chunk-dktqmf4t.js +2 -0
- package/dist/chunk-dqwxyk1m.js +2 -0
- package/dist/chunk-e2kk1d9z.js +2 -0
- package/dist/{chunk-zrxvj3zf.js → chunk-e8aqkt1b.js} +6 -6
- package/dist/{chunk-mztjpp7m.js → chunk-e8hvbc53.js} +2 -2
- package/dist/{chunk-kk9h53xg.js → chunk-edjzm0vj.js} +3 -3
- package/dist/chunk-ee4ejnk2.js +2 -0
- package/dist/chunk-eezp4a40.js +2 -0
- package/dist/chunk-eh2ynja3.js +2 -0
- package/dist/chunk-emk29htn.js +2 -0
- package/dist/{chunk-xq5s4vc1.js → chunk-eqj8nj5c.js} +1 -1
- package/dist/{chunk-ktv65e3n.js → chunk-f8sh6289.js} +7 -7
- package/dist/{chunk-6n6kndk0.js → chunk-fb1hyhgf.js} +3 -3
- package/dist/chunk-fd0vnz09.js +2 -0
- package/dist/chunk-fyhtp2nt.js +2 -0
- package/dist/{chunk-xk7hdpq5.js → chunk-g2fxp9zp.js} +3 -3
- package/dist/chunk-gbct53j0.js +2 -0
- package/dist/{chunk-m9ta0640.js → chunk-gsm3rk4j.js} +2 -2
- package/dist/{chunk-x40j67z1.js → chunk-gt9bt8xa.js} +2 -2
- package/dist/{chunk-ft34x0h1.js → chunk-gxdy4qjj.js} +4 -4
- package/dist/chunk-gxtq25gr.js +2 -0
- package/dist/chunk-h1dnjn9g.js +2 -0
- package/dist/{chunk-yvaqgdv1.js → chunk-h7z23fpq.js} +1 -1
- package/dist/{chunk-sxrcac01.js → chunk-hakevnm1.js} +2 -2
- package/dist/chunk-hn7fv830.js +2 -0
- package/dist/chunk-hx6tr46s.js +1459 -0
- package/dist/chunk-jenk04c8.js +2 -0
- package/dist/{chunk-1baxccfq.js → chunk-jfy0r3hx.js} +24 -24
- package/dist/{chunk-9zwmfkfg.js → chunk-jh007a8k.js} +5 -5
- package/dist/chunk-jh1hdq31.js +3 -0
- package/dist/{chunk-tb4be5ct.js → chunk-jk1hzawb.js} +3 -3
- package/dist/{chunk-hht7n4zd.js → chunk-jya12bfn.js} +2 -2
- package/dist/chunk-k1qbgpfy.js +2 -0
- package/dist/chunk-kgmwja6f.js +2 -0
- package/dist/{chunk-z6nyyt3n.js → chunk-khf62zkn.js} +5 -5
- package/dist/chunk-kppj8rqa.js +2 -0
- package/dist/{chunk-514yg4dr.js → chunk-m3ra99h8.js} +6 -6
- package/dist/{chunk-qsnw0qyp.js → chunk-m8rzaqm8.js} +2 -2
- package/dist/chunk-msvphygp.js +2 -0
- package/dist/chunk-mzbejejf.js +2 -0
- package/dist/{chunk-v1x96kjr.js → chunk-nkgqhb7s.js} +7 -7
- package/dist/{chunk-9707zz6v.js → chunk-p17jeqz0.js} +2 -2
- package/dist/{chunk-2f46pcg0.js → chunk-pe5sstex.js} +2 -2
- package/dist/{chunk-vtj3dwhh.js → chunk-pqr4gn9b.js} +2 -2
- package/dist/{chunk-40j2pmnb.js → chunk-prj38cyp.js} +5 -5
- package/dist/{chunk-mn9t5fnv.js → chunk-q8snpht6.js} +2 -2
- package/dist/chunk-q99y5115.js +3 -0
- package/dist/{chunk-7axtwg1f.js → chunk-qzspvwv6.js} +2 -2
- package/dist/chunk-r02asm46.js +2 -0
- package/dist/{chunk-vf7tpgqz.js → chunk-r7zvrh58.js} +16 -16
- package/dist/{chunk-ex6dne7e.js → chunk-ra35ptjg.js} +2 -2
- package/dist/chunk-rc4712qh.js +2 -0
- package/dist/chunk-rq7sg012.js +33 -0
- package/dist/{chunk-v060015m.js → chunk-rt4gzqs9.js} +1 -1
- package/dist/chunk-rx1xw7q2.js +2 -0
- package/dist/{chunk-mnpfvxpa.js → chunk-rzmephr2.js} +30 -30
- package/dist/{chunk-0xyfs691.js → chunk-s3rhbwgf.js} +4 -4
- package/dist/{chunk-xap1f1bw.js → chunk-s6w14v6h.js} +2 -2
- package/dist/{chunk-nkbnsbb0.js → chunk-sdvv8zge.js} +2 -2
- package/dist/{chunk-3br07y64.js → chunk-sgppgy5e.js} +5 -5
- package/dist/{chunk-v1a5h1tc.js → chunk-sk7pptzf.js} +9 -9
- package/dist/{chunk-50zzar2c.js → chunk-sk8x8nw8.js} +3 -3
- package/dist/chunk-skjm3zdh.js +2 -0
- package/dist/{chunk-5fdc8pej.js → chunk-t4exh7c9.js} +7 -7
- package/dist/{chunk-3hfv217t.js → chunk-t64mp8x1.js} +6 -6
- package/dist/{chunk-neymp1bb.js → chunk-tfpd7aht.js} +3 -3
- package/dist/chunk-tsnzhke9.js +2 -0
- package/dist/{chunk-yye2pec5.js → chunk-tt6n2mx6.js} +14 -14
- package/dist/chunk-txyze88n.js +2 -0
- package/dist/chunk-v1t7sees.js +2 -0
- package/dist/{chunk-1a2c4pv8.js → chunk-vhp5hqwp.js} +10 -10
- package/dist/{chunk-1vsjmwr1.js → chunk-vn3hsx7v.js} +2 -2
- package/dist/chunk-vt410s5m.js +2 -0
- package/dist/{chunk-3tcy9r6r.js → chunk-w27j0apm.js} +14 -14
- package/dist/{chunk-2zb642qr.js → chunk-w5vxzk5j.js} +6 -6
- package/dist/chunk-w81a1e14.js +9 -0
- package/dist/{chunk-tnbzg7fd.js → chunk-wajvxzt0.js} +2 -2
- package/dist/chunk-wrva7jes.js +2 -0
- package/dist/{chunk-p4twxjfs.js → chunk-ws25jw6x.js} +3 -3
- package/dist/{chunk-m86sjbx7.js → chunk-ww24mxmd.js} +3 -3
- package/dist/chunk-xdprx6tx.js +1331 -0
- package/dist/chunk-xgv3gy1b.js +2 -0
- package/dist/chunk-xjhv5e5f.js +2 -0
- package/dist/chunk-xnvh4jk2.js +21 -0
- package/dist/chunk-xtakhmnb.js +2 -0
- package/dist/{chunk-zb6my502.js → chunk-y97g0kwc.js} +1 -1
- package/dist/chunk-y9f9d4zv.js +2 -0
- package/dist/{chunk-qda8tmk9.js → chunk-yfe380a4.js} +2 -2
- package/dist/{chunk-6x5a2w5a.js → chunk-ygtz9kc7.js} +2 -2
- package/dist/chunk-yyypc7s3.js +2 -0
- package/dist/chunk-z5j4prza.js +2 -0
- package/dist/{chunk-2jm7map2.js → chunk-z68teecy.js} +2 -2
- package/dist/cli.js +20 -20
- package/dist/composables/use-media-query.js +23 -22
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/accessibility.d.ts +1 -1
- package/dist/native/accessibility.js +5 -3
- package/dist/native/bridge/protocol.d.ts +1 -0
- package/dist/native/compiler/html-to-ir.js +14 -1
- package/dist/native/compiler/ir.d.ts +7 -0
- package/dist/native/components/primitives.d.ts +1 -0
- package/dist/native/event-names.js +4 -0
- package/dist/native/prop-names.js +3 -1
- package/dist/native/runtime/browser-renderer.js +4 -0
- package/dist/native/runtime/craft-bridge.js +1 -0
- package/dist/native/runtime/craft.d.ts +3 -0
- package/dist/native/runtime/jsc-globals.js +1 -1
- package/dist/native/runtime/native-media.js +8 -3
- package/dist/native/runtime/shared-screen.js +8 -3
- package/dist/native/testing.d.ts +2 -1
- package/dist/native/testing.js +2 -1
- package/dist/process.js +6 -3
- package/dist/pwa.js +3 -3
- package/dist/signal-processing.d.ts +2 -2
- package/dist/signal-processing.js +17 -11
- package/dist/ssg.js +9 -9
- package/dist/utils.js +2 -1
- package/dist/vue-template.d.ts +2 -0
- package/dist/vue-template.js +72 -2
- package/package.json +6 -6
- package/dist/chunk-0ebaf0pr.js +0 -2
- package/dist/chunk-0jjq552g.js +0 -2
- package/dist/chunk-15rc8t28.js +0 -2
- package/dist/chunk-1jrhjn2b.js +0 -2
- package/dist/chunk-1svffhzq.js +0 -2
- package/dist/chunk-2m4ydym0.js +0 -33
- package/dist/chunk-2mv29s6w.js +0 -9
- package/dist/chunk-3aayrnbh.js +0 -21
- package/dist/chunk-426gq0g5.js +0 -2
- package/dist/chunk-4ge80k8j.js +0 -2
- package/dist/chunk-4vdfqr64.js +0 -2
- package/dist/chunk-4yz33vzb.js +0 -2
- package/dist/chunk-4zcswx6x.js +0 -2
- package/dist/chunk-5ht628zp.js +0 -2
- package/dist/chunk-67zy5p7x.js +0 -2
- package/dist/chunk-8153bfpx.js +0 -2
- package/dist/chunk-86p0m920.js +0 -2
- package/dist/chunk-88texeh4.js +0 -2
- package/dist/chunk-8mye65n9.js +0 -2
- package/dist/chunk-8ycgk8w6.js +0 -2
- package/dist/chunk-9xcsn4pb.js +0 -2
- package/dist/chunk-a5tg553d.js +0 -2
- package/dist/chunk-agxxqjjt.js +0 -2
- package/dist/chunk-b44pvac7.js +0 -2
- package/dist/chunk-b4yp16a2.js +0 -2
- package/dist/chunk-fb63xppz.js +0 -2
- package/dist/chunk-ffqqkeye.js +0 -2
- package/dist/chunk-g1v12bjm.js +0 -2
- package/dist/chunk-gg0kkn2e.js +0 -2
- package/dist/chunk-ggg8b8n1.js +0 -2
- package/dist/chunk-ggrcg7k7.js +0 -2
- package/dist/chunk-gmn9ba8f.js +0 -3
- package/dist/chunk-gqe574d9.js +0 -2
- package/dist/chunk-hajamm16.js +0 -2
- package/dist/chunk-hg2n2264.js +0 -2
- package/dist/chunk-hxabvt31.js +0 -2
- package/dist/chunk-j3sat6vn.js +0 -2
- package/dist/chunk-j9gbnqxq.js +0 -2
- package/dist/chunk-jj2z4nxa.js +0 -2
- package/dist/chunk-k289127j.js +0 -2
- package/dist/chunk-m1hfh2t4.js +0 -2
- package/dist/chunk-m3qwqhxp.js +0 -2
- package/dist/chunk-m9smh7fs.js +0 -2
- package/dist/chunk-mhnjtc42.js +0 -2
- package/dist/chunk-n4bxb2hx.js +0 -2
- package/dist/chunk-n958bxm6.js +0 -2
- package/dist/chunk-nkr1aa5z.js +0 -2
- package/dist/chunk-p3vswt0f.js +0 -2
- package/dist/chunk-p8wnp4p1.js +0 -2
- package/dist/chunk-q3z252d9.js +0 -2
- package/dist/chunk-qfkak3jb.js +0 -2
- package/dist/chunk-rt7xy537.js +0 -2
- package/dist/chunk-rwjye578.js +0 -2
- package/dist/chunk-sbr3wg75.js +0 -1467
- package/dist/chunk-sftznswb.js +0 -2
- package/dist/chunk-tz5ktd6d.js +0 -2
- package/dist/chunk-vb609vbj.js +0 -1323
- package/dist/chunk-vtcyber4.js +0 -2
- package/dist/chunk-wq2bpt0w.js +0 -2
- package/dist/chunk-wv8zt78c.js +0 -2
- package/dist/chunk-xakqpa4z.js +0 -3
- package/dist/chunk-xy3ex6ht.js +0 -2
- package/dist/chunk-y899wtm8.js +0 -2
- package/dist/chunk-ye45znz5.js +0 -2
- package/dist/chunk-yegp50jb.js +0 -2
- package/dist/chunk-yq9aqpk8.js +0 -2
- package/dist/chunk-zt45dqfx.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{T}from"./chunk-
|
|
2
|
+
import{T}from"./chunk-a78k8fkg.js";import{se}from"./chunk-q99y5115.js";import{on,N}from"./chunk-ws25jw6x.js";import ut from"path";var n={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603};function de(e){for(let[t,r]of Object.entries(n))if(r===e)return t;return}import zt from"path";var Ut={showRelativePaths:!1,enableAutoRecovery:se(),logRecoveryWarnings:!0},me={...Ut};function B(){return{...me}}function z(e){if(!me.showRelativePaths||!e)return e;let t=me.baseDir||process.cwd();try{let r=zt.relative(t,e);return r.startsWith("..")?e:r}catch{return e}}class P extends Error{code;filePath;line;column;context;numericCode;constructor(e,t,r,i,s,o,a){super(e);this.code=t;this.filePath=r;this.line=i;this.column=s;this.context=o;if(this.name="StxError",this.numericCode=a||n.EVALUATION_ERROR,this.filePath)this.filePath=z(this.filePath)}}class le extends P{constructor(e,t,r,i,s,o){super(e,"stx_RUNTIME_ERROR",t,r,i,s,o||n.EVALUATION_ERROR);this.name="StxRuntimeError"}}class Kr extends P{constructor(e,t,r,i,s,o){super(e,"stx_FILE_ERROR",t,r,i,s,o||n.FILE_NOT_FOUND);this.name="StxFileError"}}class ne extends P{isFatal=!0;constructor(e,t,r,i,s,o){super(e,"stx_VALIDATION_ERROR",t,r,i,s,o||n.DOM_API_VIOLATION);this.name="StxValidationError"}}function Ue(e){let{type:t,message:r,code:i,filePath:s,line:o,column:a,template:c,offset:f,snippet:l,suggestion:y,format:m="text"}=e,E=o,S=a;if(!E&&c&&f!==void 0){let fe=Gt(c,f);E=fe.line,S=fe.column}let b=s?z(s):void 0,w=i?de(i):void 0,k={type:t,code:i,codeName:w,message:r,filePath:b,line:E,column:S,snippet:l,suggestion:y,timestamp:new Date().toISOString()},R;switch(m){case"html":R=Wt(k);break;case"json":R=JSON.stringify(k,null,2);break;case"console":R=Xt(k,c,f);break;case"text":default:R=Vt(k,c,f);break}return{formatted:R,data:k}}function Vt(e,t,r){let i=[],s=e.code?` [${e.codeName||e.code}]`:"";if(i.push(`[${e.type} Error${s}]`),e.filePath){let o=e.filePath;if(e.line){if(o+=`:${e.line}`,e.column)o+=`:${e.column}`}i.push(`at ${o}`)}if(i.push(`
|
|
3
3
|
${e.message}`),t&&e.line){let o=Kt(t,e.line,2);if(o)i.push(`
|
|
4
4
|
${o}`)}if(e.snippet)i.push(`
|
|
5
5
|
Snippet: ${e.snippet}`);if(e.suggestion)i.push(`
|
|
@@ -17,17 +17,17 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
17
17
|
`)}function qt(e,t,r){let i=e.split(`
|
|
18
18
|
`),s=Math.max(0,t-r-1),o=Math.min(i.length-1,t+r-1),a="\x1B[90m",c="\x1B[31m",f="\x1B[0m",l=[];for(let y=s;y<=o;y++){let m=(y+1).toString().padStart(4),E=y===t-1,S=E?"\x1B[31m>\x1B[0m":" ",b=E?`\x1B[31m${i[y]}\x1B[0m`:`\x1B[90m${i[y]}\x1B[0m`;l.push(`${S}\x1B[90m${m}\x1B[0m | ${b}`)}return l.join(`
|
|
19
19
|
`)}function ze(e){return e.replace(/--/g,"- -").replace(/>/g,">")}function Gt(e,t){let i=e.substring(0,t).split(`
|
|
20
|
-
`);return{line:i.length,column:i[i.length-1].length}}function u(e,t,r){return Ue({type:e,message:t,code:r,format:"html"}).formatted}async function
|
|
21
|
-
@end${c}`;i.push(`Added ${y} missing @end${c}`)}}if(i.length>0&&t.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),i.forEach((c)=>console.warn(` - ${c}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:r,fixes:i}},createFallbackContent(e,t){if(
|
|
20
|
+
`);return{line:i.length,column:i[i.length-1].length}}function u(e,t,r){return Ue({type:e,message:t,code:r,format:"html"}).formatted}async function De(e,t,r){try{return await e()}catch(i){if(r&&i instanceof Error)r(i);return t}}var ra={isEnabled(){return B().enableAutoRecovery},fixCommonSyntaxErrors(e){let t=B();if(!t.enableAutoRecovery)return{fixed:e,fixes:[]};let r=e,i=[],s=(r.match(/\{\{/g)||[]).length,o=(r.match(/\}\}/g)||[]).length;if(s>o){let c=s-o;r+="}}".repeat(c),i.push(`Added ${c} missing closing braces '}}'`)}let a=["if","foreach","for","switch","section"];for(let c of a){let f=(r.match(new RegExp(`@${c}\\b`,"g"))||[]).length,l=(r.match(new RegExp(`@end${c}\\b`,"g"))||[]).length;if(f>l){let y=f-l;for(let m=0;m<y;m++)r+=`
|
|
21
|
+
@end${c}`;i.push(`Added ${y} missing @end${c}`)}}if(i.length>0&&t.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),i.forEach((c)=>console.warn(` - ${c}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:r,fixes:i}},createFallbackContent(e,t){if(se())return`<!-- ${e} failed: ${t.message} -->`;return"<!-- stx rendering error -->"}};class he{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor(e={}){this.maxErrors=e.maxErrors??1000,this.enableFileLogging=e.enableFileLogging??!1,this.logFilePath=e.logFilePath??".stx/errors.log",this.logFormat=e.logFormat??"json",this.maxFileSize=e.maxFileSize??10485760,this.maxLogFiles=e.maxLogFiles??5,this.minLevel=e.minLevel??"all"}configure(e){if(e.maxErrors!==void 0)this.maxErrors=e.maxErrors;if(e.enableFileLogging!==void 0)this.enableFileLogging=e.enableFileLogging;if(e.logFilePath!==void 0)this.logFilePath=e.logFilePath;if(e.logFormat!==void 0)this.logFormat=e.logFormat;if(e.maxFileSize!==void 0)this.maxFileSize=e.maxFileSize;if(e.maxLogFiles!==void 0)this.maxLogFiles=e.maxLogFiles;if(e.minLevel!==void 0)this.minLevel=e.minLevel}log(e,t,r="error"){let i={timestamp:new Date,error:e,context:t,level:r};if(this.errors.push(i),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(r))this.writeToFile(i)}shouldLog(e){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return e==="error"||e==="warning";if(this.minLevel==="error")return e==="error";return!0}formatEntry(e){if(this.logFormat==="json")return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level||"error",type:e.error.constructor.name,message:e.error.message,stack:e.error.stack,context:e.context});let t=[`[${e.timestamp.toISOString()}] [${(e.level||"error").toUpperCase()}] ${e.error.constructor.name}: ${e.error.message}`];if(e.error.stack)t.push(` Stack: ${e.error.stack.split(`
|
|
22
22
|
`).slice(1).join(`
|
|
23
23
|
`)}`);if(e.context)t.push(` Context: ${JSON.stringify(e.context)}`);return t.join(`
|
|
24
24
|
`)}writeToFile(e){this.writeQueue=this.writeQueue.then(async()=>{try{let t=await import("fs"),r=await import("path"),i=r.dirname(this.logFilePath);if(!t.existsSync(i))t.mkdirSync(i,{recursive:!0});await this.rotateIfNeeded(t);let s=`${this.formatEntry(e)}
|
|
25
25
|
`;t.appendFileSync(this.logFilePath,s,"utf-8")}catch(t){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",t)}})}async rotateIfNeeded(e){try{if(!e.existsSync(this.logFilePath))return;if(e.statSync(this.logFilePath).size<this.maxFileSize)return;for(let r=this.maxLogFiles-1;r>=1;r--){let i=`${this.logFilePath}.${r}`,s=`${this.logFilePath}.${r+1}`;if(e.existsSync(i))if(r>=this.maxLogFiles-1)e.unlinkSync(i);else e.renameSync(i,s)}if(this.maxLogFiles<=1)e.writeFileSync(this.logFilePath,"");else e.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(t){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",t)}}getRecentErrors(e=10){return this.errors.slice(-e)}getErrorsByType(e){return this.errors.filter((t)=>t.error.constructor.name===e)}getErrorsByLevel(e){return this.errors.filter((t)=>t.level===e)}clear(){this.errors.length=0}async clearLogFile(){try{let e=await import("fs");if(e.existsSync(this.logFilePath))e.writeFileSync(this.logFilePath,"","utf-8")}catch(e){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",e)}}getStats(){let e={},t={error:0,warning:0,info:0};for(let r of this.errors){let i=r.error.constructor.name;e[i]=(e[i]||0)+1;let s=r.level||"error";t[s]=(t[s]||0)+1}return{total:this.errors.length,byType:e,byLevel:t}}async exportToFile(e,t="json"){let r=await import("fs"),i=await import("path"),s=i.dirname(e);if(!r.existsSync(s))r.mkdirSync(s,{recursive:!0});if(t==="json"){let o=this.errors.map((a)=>({timestamp:a.timestamp.toISOString(),level:a.level||"error",type:a.error.constructor.name,message:a.error.message,stack:a.error.stack,context:a.context}));r.writeFileSync(e,JSON.stringify(o,null,2),"utf-8")}else{let o=this.errors.map((a)=>this.formatEntry(a));r.writeFileSync(e,o.join(`
|
|
26
26
|
|
|
27
|
-
`),"utf-8")}}async flush(){await this.writeQueue}}var
|
|
28
|
-
`)}};class
|
|
27
|
+
`),"utf-8")}}async flush(){await this.writeQueue}}var X=new he,Fn={isDevelopment(){return se()},logDetailedError(e,t){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",e.message),console.error("Stack:",e.stack),t)console.error("Context:",t);console.error("========================")},createErrorReport(e,t){let r=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${e.message}`,`Type: ${e.constructor.name}`,`Stack: ${e.stack}`];if(t)r.push(`Context: ${JSON.stringify(t,null,2)}`);return r.push("========================"),r.join(`
|
|
28
|
+
`)}};class we{context;source;pos=0;line=1;column=0;tokens=[];constructor(e,t="template"){this.context=t;this.source=e}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let e=this.nextToken();if(e)this.tokens.push(e)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let e=this.pos,t=this.line,r=this.column,i=this.source[this.pos];if(/\s/.test(i))return this.readWhitespace(e,t,r);if(i==="/"&&this.peek(1)==="/")return this.readLineComment(e,t,r);if(i==="/"&&this.peek(1)==="*")return this.readBlockComment(e,t,r);if(i==='"'||i==="'")return this.readString(i,e,t,r);if(i==="`")return this.readTemplateString(e,t,r);if(/\d/.test(i)||i==="."&&/\d/.test(this.peek(1)||""))return this.readNumber(e,t,r);if(/[a-z_$]/i.test(i))return this.readIdentifier(e,t,r);if(this.context==="template"&&i==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:e,end:this.pos,line:t,column:r};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:e,end:this.pos,line:t,column:r};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:e,end:this.pos,line:t,column:r}}if(this.context==="template"&&i==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:e,end:this.pos,line:t,column:r};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:e,end:this.pos,line:t,column:r}}if(this.context==="template"&&i==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:e,end:this.pos,line:t,column:r};if(i==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective(e,t,r);let s=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let o of s)if(this.source.slice(this.pos,this.pos+o.length)===o)return this.advance(o.length),{type:"OPERATOR",value:o,start:e,end:this.pos,line:t,column:r};if(/[+\-*/%<>=!&|^~?:]/.test(i))return this.advance(),{type:"OPERATOR",value:i,start:e,end:this.pos,line:t,column:r};if(/[()[\]{},;.]/.test(i))return this.advance(),{type:"PUNCTUATION",value:i,start:e,end:this.pos,line:t,column:r};return this.advance(),{type:"PUNCTUATION",value:i,start:e,end:this.pos,line:t,column:r}}readWhitespace(e,t,r){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readLineComment(e,t,r){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
|
|
29
29
|
`)this.advance();return{type:"COMMENT",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readBlockComment(e,t,r){this.advance(2);while(this.pos<this.source.length-1){if(this.source[this.pos]==="*"&&this.source[this.pos+1]==="/"){this.advance(2);break}this.advance()}return{type:"COMMENT",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readString(e,t,r,i){this.advance();while(this.pos<this.source.length){let s=this.source[this.pos];if(s==="\\"){this.advance(2);continue}if(s===e){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(t,this.pos),start:t,end:this.pos,line:r,column:i}}readTemplateString(e,t,r){this.advance();let i=0,s=256;while(this.pos<this.source.length){let o=this.source[this.pos];if(o==="\\"){this.advance(2);continue}if(o==="$"&&this.peek(1)==="{"){if(i>=s){this.pos=this.source.length;break}this.advance(2),i++;continue}if(o==="{"&&i>0){i++,this.advance();continue}if(o==="}"&&i>0){i--,this.advance();continue}if(o==="`"&&i===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readNumber(e,t,r){if(this.source[this.pos]==="0"){let i=this.peek(1)?.toLowerCase();if(i==="x"||i==="o"||i==="b"){this.advance(2);while(this.pos<this.source.length&&/[\da-f_]/i.test(this.source[this.pos]))this.advance();return{type:"NUMBER",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}}while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance();if(this.source[this.pos]==="."&&(this.context==="javascript"||/\d/.test(this.peek(1)||""))){this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(/e/i.test(this.source[this.pos]||"")){if(this.advance(),/[+-]/.test(this.source[this.pos]||""))this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(this.source[this.pos]==="n")this.advance();return{type:"NUMBER",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readIdentifier(e,t,r){while(this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]))this.advance();return{type:"IDENTIFIER",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}readDirective(e,t,r){this.advance();while(this.pos<this.source.length&&/[a-z]/i.test(this.source[this.pos]))this.advance();return{type:"DIRECTIVE",value:this.source.slice(e,this.pos),start:e,end:this.pos,line:t,column:r}}advance(e=1){for(let t=0;t<e&&this.pos<this.source.length;t++){if(this.source[this.pos]===`
|
|
30
|
-
`)this.line++,this.column=0;else this.column++;this.pos++}}peek(e){return this.source[this.pos+e]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState(e){this.pos=e.pos,this.line=e.line,this.column=e.column}}function _(e,t,r,i=0){let s=0,o=i,a=null,c=0,f=!1;while(o<e.length){let l=e[o];if(a&&f){f=!1,o++;continue}if(a&&l==="\\"){f=!0,o++;continue}if(f=!1,(l==='"'||l==="'"||l==="`")&&!a){a=l,o++;continue}if(l===a&&a!=="`"){a=null,o++;continue}if(a==="`"&&l==="$"&&e[o+1]==="{"){c++,o+=2;continue}if(c>0&&l==="}"){c--,o++;continue}if(l==="`"&&a==="`"&&c===0){a=null,o++;continue}if(a){o++;continue}if(l===t)s++;else if(l===r){if(s--,s===0)return o}o++}return-1}function Dl(e,t){let r=t,i={paren:0,bracket:0,brace:0},s=null,o=0;while(r<e.length){let a=e[r];if((r>0?e[r-1]:"")==="\\"&&s){r++;continue}if((a==='"'||a==="'")&&!s){s=a,r++;continue}if(a===s&&s!=="`"){s=null,r++;continue}if(a==="`"&&!s){s="`",r++;continue}if(a==="`"&&s==="`"&&o===0){s=null,r++;continue}if(s==="`"&&a==="$"&&e[r+1]==="{"){o++,r+=2;continue}if(o>0){if(a==="{")o++;else if(a==="}")o--;r++;continue}if(s){r++;continue}if(i.paren===0&&i.bracket===0&&i.brace===0){if(e.slice(r,r+2)==="}}"||e.slice(r,r+3)==="!!}")break;if(a===","||a===";")break}if(a==="(")i.paren++;else if(a===")"){if(i.paren--,i.paren<0)break}else if(a==="[")i.bracket++;else if(a==="]"){if(i.bracket--,i.bracket<0)break}else if(a==="{")i.brace++;else if(a==="}"){if(i.brace--,i.brace<0)break}r++}return{expression:e.slice(t,r),endPos:r}}var Jt={maxSanitizeDepth:10,allowBracketNotation:!1},Je={...Jt};var G=/\bnew\s+/,Y="__stx_safe_ctors",Ze=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],he=[...Ze,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],Ve=he.map(()=>{return}),ye=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is})),Se=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,G,/\bdelete\s+/,/\bthis\b/,/\\u(?:\{[\dA-Fa-f]+\}|[\dA-Fa-f]{4})/],ke=new Set([...Ze,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",Y]),ve=new Set(["__proto__","constructor","prototype"]);function Qe(e){let t="",r=[],i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o];if(s){s=!1;continue}if(a==="\\"&&i){s=!0;continue}if(i){if(i==="`"&&a==="$"&&o+1<e.length&&e[o+1]==="{"){let c=1;o+=2;while(o<e.length&&c>0){if(e[o]==="{")c++;else if(e[o]==="}")c--;if(c>0)t+=e[o],r.push(o),o++}continue}if(a===i)i=null;continue}if(a==='"'||a==="'"||a==="`"){i=a;continue}t+=a,r.push(o)}return{text:t,map:r}}function it(e){return Qe(e).text}var st=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],ot=(()=>{let e={Date,URL,URLSearchParams},t=Intl;for(let r of st)if(typeof t[r]==="function")e[`Intl_${r}`]=t[r];return Object.freeze(Object.assign(Object.create(null),e))})(),rn=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,We=/(?<![\w$])new(?![\w$])/g,Xe=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${st.join(",")}}() are allowed`;function sn(e){let{text:t,map:r}=Qe(e),i=[];We.lastIndex=0;let s;while((s=We.exec(t))!==null){let a=s.index;if(/(?<!\.)\.\s*$/.test(t.slice(0,a)))continue;let c=rn.exec(t.slice(a)),f=c?.[3],l=!c?null:f?`Intl_${f}`:c[2];if(!c||!l||!(l in ot))throw new v(`matched /${G.source}/; ${Xe}`,e);let y=a+c[0].length,m=r[a],E=r[y-1]+1;if(e.slice(m,E)!==t.slice(a,y))throw new v(`matched /${G.source}/; ${Xe}`,e);let S=m+3+c[1].length;i.push({start:S,end:S+c[2].length,key:l})}let o=e;for(let a=i.length-1;a>=0;a--){let c=i[a];o=`${o.slice(0,c.start)}${Y}.${c.key}${o.slice(c.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class v extends Error{rule;expression;constructor(e,t,r){super(r??`Potentially unsafe expression (${e}): ${t}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=t}}function ho(e){try{return Re(e),null}catch(t){return t instanceof v?t.rule:t instanceof Error?t.message:String(t)}}function at(e,t){let r=/[$A-Z_a-z][$\w]*/g,i;while((i=r.exec(e))!==null){let s=i[0],o=e[i.index-1];if(ke.has(s))throw new v(`matched /\\b${s}\\b/; identifier ${s}`,t);if(o==="."&&ve.has(s))throw new v(`matched /.${s}/; property ${s}`,t)}}function ct(e,t=!0){let r=/(?:[$\w)\].]|\?\.)\s*\[([^\]]*)\]/g,i=new Set,s;while((s=r.exec(e))!==null){let o=s.index+s[0].indexOf("["),a=e.slice(0,o);if(/(?:^|[^$\w])(?:let|const|var)\s*$/.test(a))continue;let c=s[1].trim(),f=/^'(?:[^'\\]|\\.)*'$/.test(c),l=/^"(?:[^"\\]|\\.)*"$/.test(c);if(/^\d+$/.test(c))continue;if(f||l){let m=c.slice(1,-1);if(ve.has(m))throw new v(`bracket key ${m}`,e);if(!Je.allowBracketNotation)throw new v("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",e,`Bracket notation with strings not allowed: ${e}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);continue}if(t&&/^[$A-Z_a-z][$\w]*$/.test(c)){i.add(c);continue}throw new v("dynamic bracket notation is not allowed",e)}return[...i]}function Re(e){let t=e.trim(),r=it(t);at(r,t);let i=ct(t);for(let s of Se){if(s===G)continue;if(s.test(r))throw new v(`matched /${s.source}/`,t)}return{...sn(t),dynamicKeys:i}}function ea(e){return Re(e),e.trim()}var yo=Symbol("stx.sanitizeCache"),an=4000,V=new Map;function cn(e){let t=V.get(e);if(t===void 0){if(t=Se.some((r)=>r.test(e)),V.size>=an)V.clear();V.set(e,t)}return t}function J(e){let t={},r=e[yo];t.Math=Math,t.JSON=JSON,t.Date=Date,t.String=String,t.Number=Number,t.Boolean=Boolean,t.Array=Array,t.Object=ye,t.parseInt=Number.parseInt,t.parseFloat=Number.parseFloat,t.isNaN=Number.isNaN,t.isFinite=Number.isFinite,t.encodeURIComponent=encodeURIComponent,t.decodeURIComponent=decodeURIComponent;for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||cn(i))continue;if(s&&typeof s==="object"&&!Array.isArray(s)){let o=r?.get(s);if(o===void 0)o=xe(s),r?.set(s,o);t[i]=o}else t[i]=s}return t}function xe(e,t=0){if(t>=Je.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((i)=>xe(i,t+1));if(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error)return e;let r={};for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||i==="constructor"||i==="prototype")continue;if(s&&typeof s==="object")r[i]=xe(s,t+1);else r[i]=s}return r}function d(e,t){try{let r=J(t),i=Object.keys(r),s=Object.values(r);return p(e,i)(...s)}catch{return}}function h(e){try{return ea(e),!0}catch{return!1}}var W=new Set;function ln(e,t,r){if(!t.startsWith("__")||!(t in r))return;let i=`${t}\x00${e}`;if(W.has(i))return;if(W.add(i),W.size>500)W.clear();console.warn(`[stx] a condition reads \`${t}\`, which conditions cannot see, so \`${e.trim()}\` is false and nothing it guards is rendered. Names starting with \`__\` are withheld from @if, @elseif and @unless. Derive a plain value in the server script (for example \`const hasRows = ${t}.length > 0\`) and test that instead.`)}function Ml(e,t){try{let r=J(t),i=Object.keys(r),s=Object.values(r),o=!1,c=p(e,i,(f)=>{o=!0,ln(e,f,t)})(...s);return!o&&Boolean(c)}catch{return!1}}function D(e,t){try{let r=d(e,t);if(r&&typeof r==="object"&&!Array.isArray(r))return r;return{}}catch{return{}}}var lt=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),Ke=`stx-compile-probe:${globalThis.crypto.randomUUID()}`,un=0,gn=0;function pn(e,t){let r="__stx_compile_probe";while(e.includes(r))r+="_";let i=Array.from({length:e.length+1});i[e.length]=Ke;for(let s=0;s<16;s++){let o=`c${++un}`,a=`'use strict';if(${r}===${JSON.stringify(Ke)})return ${JSON.stringify(o)};`,c=Function(...e,r,a+t);if(c(...i)===o)return c;gn++}throw Error("[stx] the JavaScript runtime repeatedly returned code compiled from a different source; refusing to evaluate with it.")}var fn=2000,q=new Map;function qe(e,t){let r=`${e.join(",")}\x00${t}`,i=q.get(r);if(i)return i;let s=pn(e,t);if(q.size>=fn)q.clear();return q.set(r,s),s}function Ee(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g,"$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g)||[]}var dn=/^[A-Za-z_$][\w$]*$/;function qr(e){return dn.test(e)&&!lt.has(e)}var Ge=new T(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function p(e,t,r){let i=JSON.stringify([e,t]),s=Ge.get(i);if(!s)s=mn(e,[...t]),s.sourceBytes+=i.length*2,Ge.set(i,s);return hn(yn(s.buildFunc,s.filteredKeys,s.contextKeys,s.validEntries,s.validIndices,r),s.contextKeys,s.dynamicKeys)}function mn(e,t){let{source:r,usesSafeConstructors:i,dynamicKeys:s}=Re(e),o=[];for(let m=0;m<t.length;m++){if(!qr(t[m]))continue;if(t[m]===Y||t[m]==="Object"||ke.has(t[m]))continue;o.push({key:t[m],index:m})}o.sort((m,E)=>m.key<E.key?-1:1);let a=o.map((m)=>m.key),c=o.map((m)=>m.index),f=`
|
|
30
|
+
`)this.line++,this.column=0;else this.column++;this.pos++}}peek(e){return this.source[this.pos+e]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState(e){this.pos=e.pos,this.line=e.line,this.column=e.column}}function _(e,t,r,i=0){let s=0,o=i,a=null,c=0,f=!1;while(o<e.length){let l=e[o];if(a&&f){f=!1,o++;continue}if(a&&l==="\\"){f=!0,o++;continue}if(f=!1,(l==='"'||l==="'"||l==="`")&&!a){a=l,o++;continue}if(l===a&&a!=="`"){a=null,o++;continue}if(a==="`"&&l==="$"&&e[o+1]==="{"){c++,o+=2;continue}if(c>0&&l==="}"){c--,o++;continue}if(l==="`"&&a==="`"&&c===0){a=null,o++;continue}if(a){o++;continue}if(l===t)s++;else if(l===r){if(s--,s===0)return o}o++}return-1}function Bl(e,t){let r=t,i={paren:0,bracket:0,brace:0},s=null,o=0;while(r<e.length){let a=e[r];if((r>0?e[r-1]:"")==="\\"&&s){r++;continue}if((a==='"'||a==="'")&&!s){s=a,r++;continue}if(a===s&&s!=="`"){s=null,r++;continue}if(a==="`"&&!s){s="`",r++;continue}if(a==="`"&&s==="`"&&o===0){s=null,r++;continue}if(s==="`"&&a==="$"&&e[r+1]==="{"){o++,r+=2;continue}if(o>0){if(a==="{")o++;else if(a==="}")o--;r++;continue}if(s){r++;continue}if(i.paren===0&&i.bracket===0&&i.brace===0){if(e.slice(r,r+2)==="}}"||e.slice(r,r+3)==="!!}")break;if(a===","||a===";")break}if(a==="(")i.paren++;else if(a===")"){if(i.paren--,i.paren<0)break}else if(a==="[")i.bracket++;else if(a==="]"){if(i.bracket--,i.bracket<0)break}else if(a==="{")i.brace++;else if(a==="}"){if(i.brace--,i.brace<0)break}r++}return{expression:e.slice(t,r),endPos:r}}var Jt={maxSanitizeDepth:10,allowBracketNotation:!1},Je={...Jt};var Y=/\bnew\s+/,Z="__stx_safe_ctors",Ze=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],ye=[...Ze,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],Ve=ye.map(()=>{return}),Ee=Object.freeze(Object.assign(Object.create(null),{keys:Object.keys,values:Object.values,entries:Object.entries,fromEntries:Object.fromEntries,assign:Object.assign,hasOwn:Object.hasOwn,is:Object.is})),xe=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,Y,/\bdelete\s+/,/\bthis\b/,/\\u(?:\{[\dA-Fa-f]+\}|[\dA-Fa-f]{4})/],Se=new Set([...Ze,"eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",Z]),ke=new Set(["__proto__","constructor","prototype"]);function Qe(e){let t="",r=[],i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o];if(s){s=!1;continue}if(a==="\\"&&i){s=!0;continue}if(i){if(i==="`"&&a==="$"&&o+1<e.length&&e[o+1]==="{"){let c=1;o+=2;while(o<e.length&&c>0){if(e[o]==="{")c++;else if(e[o]==="}")c--;if(c>0)t+=e[o],r.push(o),o++}continue}if(a===i)i=null;continue}if(a==='"'||a==="'"||a==="`"){i=a;continue}t+=a,r.push(o)}return{text:t,map:r}}function it(e){return Qe(e).text}var st=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],ot=(()=>{let e={Date,URL,URLSearchParams},t=Intl;for(let r of st)if(typeof t[r]==="function")e[`Intl_${r}`]=t[r];return Object.freeze(Object.assign(Object.create(null),e))})(),rn=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,We=/(?<![\w$])new(?![\w$])/g,Xe=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${st.join(",")}}() are allowed`;function sn(e){let{text:t,map:r}=Qe(e),i=[];We.lastIndex=0;let s;while((s=We.exec(t))!==null){let a=s.index;if(/(?<!\.)\.\s*$/.test(t.slice(0,a)))continue;let c=rn.exec(t.slice(a)),f=c?.[3],l=!c?null:f?`Intl_${f}`:c[2];if(!c||!l||!(l in ot))throw new v(`matched /${Y.source}/; ${Xe}`,e);let y=a+c[0].length,m=r[a],E=r[y-1]+1;if(e.slice(m,E)!==t.slice(a,y))throw new v(`matched /${Y.source}/; ${Xe}`,e);let S=m+3+c[1].length;i.push({start:S,end:S+c[2].length,key:l})}let o=e;for(let a=i.length-1;a>=0;a--){let c=i[a];o=`${o.slice(0,c.start)}${Z}.${c.key}${o.slice(c.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class v extends Error{rule;expression;constructor(e,t,r){super(r??`Potentially unsafe expression (${e}): ${t}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=t}}function bo(e){try{return Re(e),null}catch(t){return t instanceof v?t.rule:t instanceof Error?t.message:String(t)}}function at(e,t){let r=/[$A-Z_a-z][$\w]*/g,i;while((i=r.exec(e))!==null){let s=i[0],o=e[i.index-1];if(Se.has(s))throw new v(`matched /\\b${s}\\b/; identifier ${s}`,t);if(o==="."&&ke.has(s))throw new v(`matched /.${s}/; property ${s}`,t)}}function ct(e,t=!0){let r=/(?:[$\w)\].]|\?\.)\s*\[([^\]]*)\]/g,i=new Set,s;while((s=r.exec(e))!==null){let o=s.index+s[0].indexOf("["),a=e.slice(0,o);if(/(?:^|[^$\w])(?:let|const|var)\s*$/.test(a))continue;let c=s[1].trim(),f=/^'(?:[^'\\]|\\.)*'$/.test(c),l=/^"(?:[^"\\]|\\.)*"$/.test(c);if(/^\d+$/.test(c))continue;if(f||l){let m=c.slice(1,-1);if(ke.has(m))throw new v(`bracket key ${m}`,e);if(!Je.allowBracketNotation)throw new v("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",e,`Bracket notation with strings not allowed: ${e}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);continue}if(t&&/^[$A-Z_a-z][$\w]*$/.test(c)){i.add(c);continue}throw new v("dynamic bracket notation is not allowed",e)}return[...i]}function Re(e){let t=e.trim(),r=it(t);at(r,t);let i=ct(t);for(let s of xe){if(s===Y)continue;if(s.test(r))throw new v(`matched /${s.source}/`,t)}return{...sn(t),dynamicKeys:i}}function na(e){return Re(e),e.trim()}var wo=Symbol("stx.sanitizeCache"),an=4000,W=new Map;function cn(e){let t=W.get(e);if(t===void 0){if(t=xe.some((r)=>r.test(e)),W.size>=an)W.clear();W.set(e,t)}return t}function Q(e){let t={},r=e[wo];t.Math=Math,t.JSON=JSON,t.Date=Date,t.String=String,t.Number=Number,t.Boolean=Boolean,t.Array=Array,t.Object=Ee,t.parseInt=Number.parseInt,t.parseFloat=Number.parseFloat,t.isNaN=Number.isNaN,t.isFinite=Number.isFinite,t.encodeURIComponent=encodeURIComponent,t.decodeURIComponent=decodeURIComponent;for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||cn(i))continue;if(s&&typeof s==="object"&&!Array.isArray(s)){let o=r?.get(s);if(o===void 0)o=be(s),r?.set(s,o);t[i]=o}else t[i]=s}return t}function be(e,t=0){if(t>=Je.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((i)=>be(i,t+1));if(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error)return e;let r={};for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||i==="constructor"||i==="prototype")continue;if(s&&typeof s==="object")r[i]=be(s,t+1);else r[i]=s}return r}function d(e,t){try{let r=Q(t),i=Object.keys(r),s=Object.values(r);return p(e,i)(...s)}catch{return}}function h(e){try{return na(e),!0}catch{return!1}}var K=new Set;function ln(e,t,r){if(!t.startsWith("__")||!(t in r))return;let i=`${t}\x00${e}`;if(K.has(i))return;if(K.add(i),K.size>500)K.clear();console.warn(`[stx] a condition reads \`${t}\`, which conditions cannot see, so \`${e.trim()}\` is false and nothing it guards is rendered. Names starting with \`__\` are withheld from @if, @elseif and @unless. Derive a plain value in the server script (for example \`const hasRows = ${t}.length > 0\`) and test that instead.`)}function jl(e,t){try{let r=Q(t),i=Object.keys(r),s=Object.values(r),o=!1,c=p(e,i,(f)=>{o=!0,ln(e,f,t)})(...s);return!o&&Boolean(c)}catch{return!1}}function D(e,t){try{let r=d(e,t);if(r&&typeof r==="object"&&!Array.isArray(r))return r;return{}}catch{return{}}}var lt=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),Ke=`stx-compile-probe:${globalThis.crypto.randomUUID()}`,un=0,gn=0;function pn(e,t){let r="__stx_compile_probe";while(e.includes(r))r+="_";let i=Array.from({length:e.length+1});i[e.length]=Ke;for(let s=0;s<16;s++){let o=`c${++un}`,a=`'use strict';if(${r}===${JSON.stringify(Ke)})return ${JSON.stringify(o)};`,c=Function(...e,r,a+t);if(c(...i)===o)return c;gn++}throw Error("[stx] the JavaScript runtime repeatedly returned code compiled from a different source; refusing to evaluate with it.")}var fn=2000,q=new Map;function qe(e,t){let r=`${e.join(",")}\x00${t}`,i=q.get(r);if(i)return i;let s=pn(e,t);if(q.size>=fn)q.clear();return q.set(r,s),s}function Te(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g,"$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g)||[]}var dn=/^[A-Za-z_$][\w$]*$/;function qr(e){return dn.test(e)&&!lt.has(e)}var Ge=new T(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function p(e,t,r){let i=JSON.stringify([e,t]),s=Ge.get(i);if(!s)s=mn(e,[...t]),s.sourceBytes+=i.length*2,Ge.set(i,s);return hn(yn(s.buildFunc,s.filteredKeys,s.contextKeys,s.validEntries,s.validIndices,r),s.contextKeys,s.dynamicKeys)}function mn(e,t){let{source:r,usesSafeConstructors:i,dynamicKeys:s}=Re(e),o=[];for(let m=0;m<t.length;m++){if(!qr(t[m]))continue;if(t[m]===Z||t[m]==="Object"||Se.has(t[m]))continue;o.push({key:t[m],index:m})}o.sort((m,E)=>m.key<E.key?-1:1);let a=o.map((m)=>m.key),c=o.map((m)=>m.index),f=`
|
|
31
31
|
'use strict';
|
|
32
32
|
try {
|
|
33
33
|
return ${r};
|
|
@@ -38,18 +38,18 @@ catch (e) {
|
|
|
38
38
|
}
|
|
39
39
|
throw e;
|
|
40
40
|
}
|
|
41
|
-
`,l=i?(m)=>{let E=qe([
|
|
41
|
+
`,l=i?(m)=>{let E=qe([Z,"Object",...ye,...a,...m],f);return(...S)=>E(ot,Ee,...Ve,...S)}:(m)=>{let E=qe(["Object",...ye,...a,...m],f);return(...S)=>E(Ee,...Ve,...S)},y=l([]);return{sourceBytes:e.length*2+t.reduce((m,E)=>m+E.length*2,0),contextKeys:t,filteredKeys:a,validEntries:o,validIndices:c,dynamicKeys:s,buildFunc:(m)=>m.length===0?y:l(m)}}function hn(e,t,r){if(r.length===0)return e;let i=r.map((s)=>t.indexOf(s));return(...s)=>{for(let o of i){if(o<0)continue;let a=s[o];if(typeof a==="string"&&ke.has(a))return}return e(...s)}}function yn(e,t,r,i,s,o){let a=e([]),c=i.every((l,y)=>l.index===y);if(t.length===r.length&&c)return Ye(a,t,e,void 0,o);return Ye((...l)=>{let y=Array(s.length);for(let m=0;m<s.length;m++)y[m]=l[s[m]];return a(...y)},t,e,(l)=>{a=e(l)},o)}function Ye(e,t,r,i,s){let a=/^(\w+) is not defined$/,c=e,f=[],l=new Set(t);return(...y)=>{for(let m=0;m<=8;m++)try{return c(...y)}catch(E){let S=E instanceof Error?E.message:"",b=a.exec(S);if(!(E instanceof ReferenceError)||!b)return;let w=b[1];if(l.has(w)||lt.has(w)||Se.has(w))return;if(s?.(w),l.add(w),f.push(w),i)i(f);else c=r(f)}return}}function vo(e){let t=e.trim();try{let r=it(t);if(/\b(?:eval|function|import|require|process|globalthis|window|document|fetch|bun|deno|buffer|console|reflect|proxy|prototype|constructor|this)\b/i.test(r))return!1;at(r,t),ct(t);for(let i of xe)if(i.test(r))return!1}catch{return!1}return!0}function sa(e,t){let r=[];t.lastIndex=0;let i;while((i=t.exec(e))!==null){let s=i.index,o=s+i[0].length-1,a=_(e,"(",")",o);if(a===-1){r.push({start:s,end:-1,args:"",call:e.slice(s,Math.min(e.length,s+80))}),t.lastIndex=o+1;continue}r.push({start:s,end:a+1,args:e.slice(o+1,a),call:e.slice(s,a+1)}),t.lastIndex=a+1}return r}function Yt(e,t,r,i){let s="",o=0;for(let a of sa(e,t)){if(s+=e.slice(o,a.start),a.end===-1){s+=i(a.call),o=a.start;continue}s+=r(a.args,a.call),o=a.end}return s+e.slice(o)}function Zt(e){let t=[],r=0,i=null,s="";for(let o=0;o<e.length;o++){let a=e[o];if(i){if(s+=a,a==="\\"&&o+1<e.length){s+=e[++o];continue}if(a===i)i=null;continue}if(a==="'"||a==='"'||a==="`")i=a;else if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;else if(a===","&&r===0){t.push(s.trim()),s="";continue}s+=a}if(s.trim())t.push(s.trim());return t}function bt(e){let t=e.trim(),r=t[0];if(r!=="'"&&r!=='"'&&r!=="`"||t.length<2||t.at(-1)!==r)return null;let i="",s={b:"\b",f:"\f",n:`
|
|
42
42
|
`,r:"\r",t:"\t",v:"\v",0:"\x00"};for(let o=1;o<t.length-1;o++){let a=t[o];if(a==="\\"){if(++o>=t.length-1)return null;let c=t[o];if(/[1-9]/.test(c)||c==="0"&&/\d/.test(t[o+1]??""))return null;if(c===`
|
|
43
43
|
`||c==="\u2028"||c==="\u2029")continue;if(c==="\r"){if(t[o+1]===`
|
|
44
44
|
`)o++;continue}if(c==="x"||c==="u"){let f=c==="u"&&t[o+1]==="{",l=f?t.indexOf("}",o+2):o+(c==="x"?2:4)+1,y=t.slice(o+(f?2:1),l);if(l<0||l>=t.length||!/^[\da-f]+$/i.test(y)||!f&&y.length!==(c==="x"?2:4))return null;let m=Number.parseInt(y,16);if(m>1114111)return null;i+=String.fromCodePoint(m),o=f?l:l-1;continue}i+=Object.hasOwn(s,c)?s[c]:c;continue}if(a===r||r!=="`"&&(a===`
|
|
45
45
|
`||a==="\r"))return null;if(r==="`"&&a==="$"&&t[o+1]==="{")return null;if(r==="`"&&a==="\r"){if(t[o+1]===`
|
|
46
46
|
`)o++;i+=`
|
|
47
|
-
`}else i+=a}return i}var En=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Qt(e,t){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:n.INVALID_DIRECTIVE_SYNTAX};let i=ho(r);if(i)return{ok:!1,message:`the expression is not allowed (${i})`,code:n.UNSAFE_EXPRESSION};let s=J(t),o;try{o=p(r,Object.keys(s))(...Object.values(s))}catch(c){return{ok:!1,message:`the expression could not be evaluated: ${c instanceof Error?c.message:String(c)}`,code:n.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let a=[...new Set(Ee(r))].filter((c)=>!En.has(c)&&!(c in s)&&!(c in globalThis));if(a.length>0)return{ok:!1,message:`${a.map((f)=>`"${f}"`).join(", ")} ${a.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:n.UNDEFINED_VARIABLE};if(o===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:n.EVALUATION_ERROR};return{ok:!0,value:o}}function et(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function wt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function gt(e){if(!e)return"";return ut.isAbsolute(e)?ut.relative(process.cwd(),e)||e:e}function Ce(e){let t=e.replace(/\s+/g," ").trim();return t.length>80?`${t.slice(0,77)}...`:t}function H(e,t,r,i,s=n.EVALUATION_ERROR){let o=i?` in ${gt(i)}`:"";return console.warn(`[stx] ${Ce(t)}${o}: ${r}`),u(e,`${Ce(t)}: ${r}`,s)}function wo(e,t,r){let i=r?` in ${gt(r)}`:"";console.warn(`[stx] ${Ce(e)}${i}: ${t}`)}var en="data-stx-before-runtime";function ra(){return{afterOpen:[],beforeClose:[]}}function bn(e){return e.afterOpen.length>0||e.beforeClose.length>0}function Ll(e,t){if(!bn(t))return e;let r=t.afterOpen.join(""),i=t.beforeClose.join(""),s=O(e),o=r?zn(e):null,a=i&&s!==-1?s:null;if(o===null&&a===null)return e;if(o!==null&&a!==null)return`${e.slice(0,o)}${r}${e.slice(o,a)}${i}${e.slice(a)}`;if(o!==null)return`${e.slice(0,o)}${r}${e.slice(o)}`;return`${e.slice(0,a)}${i}${e.slice(a)}`}var pt=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function zn(e){let t=/<head\b[^>]*>/i.exec(e);if(!t)return null;let r=t.index+t[0].length;pt.lastIndex=r;let i=pt.exec(e);return i?r+i[0].length:r}var Te=/\s*/y,Ae=/\x00STX_HTML_COMMENT_\d+\x00/y;function vt(e){let t=0;while(t<e.length){if(Te.lastIndex=t,Te.exec(e),t=Te.lastIndex,e.startsWith("<!--",t)){let r=e.indexOf("-->",t+4);if(r===-1)return t;t=r+3;continue}if(Ae.lastIndex=t,Ae.test(e)){t=Ae.lastIndex;continue}return t}return t}var _e=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,xn=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function De(e){let t=[],r=0;while(r<e.length){let i=e.indexOf("<",r);if(i===-1)break;if(e.startsWith("<!--",i)){let E=e.indexOf("-->",i+4);if(E===-1)break;r=E+3;continue}_e.lastIndex=i;let s=_e.exec(e);if(!s){r=i+1;continue}let o=_e.lastIndex,a=o,c=null;for(;a<e.length;a++){let E=e[a];if(c){if(E===c)c=null}else if(E==='"'||E==="'")c=E;else if(E===">")break}if(a===e.length)break;let f=s[1]==="/",l=e[a-1]==="/";t.push({start:i,end:a+1,name:s[2],attributes:e.slice(o,l?a-1:a),closing:f,selfClosing:l}),r=a+1;let y=s[2].toLowerCase();if(!f&&y==="plaintext")break;let m=xn.get(y);if(!f&&(y==="script"||y==="style"||m)){let E=m??(y==="script"?ie:se);E.lastIndex=r;let S=E.exec(e);if(!S)break;r=S.index}}return t}var Z=/<script\b[^>]*>/iy,ie=/<\/script\s*>/ig,ee=/<style\b[^>]*>/iy,se=/<\/style\s*>/ig;function ft(e,t,r,i){r.lastIndex=t;let s=r.exec(e);if(!s||s.index!==t)return-1;i.lastIndex=r.lastIndex;let o=i.exec(e);if(!o)return-1;return o.index+o[0].length}function U(e,t){return ft(e,t,Z,ie)}function tn(e,t){return ft(e,t,ee,se)}function tt(e,t){if(!e.startsWith("<!--",t))return-1;let r=e.indexOf("-->",t+4);if(r===-1)return-1;return r+3}function dt(e,t){if(e.startsWith("<!--",t)){let s=tt(e,t);return s===-1?e.length:s}if(Z.lastIndex=t,Z.exec(e)?.index===t){ie.lastIndex=Z.lastIndex;let s=ie.exec(e);return s?s.index+s[0].length:e.length}if(ee.lastIndex=t,ee.exec(e)?.index===t){se.lastIndex=ee.lastIndex;let s=se.exec(e);return s?s.index+s[0].length:e.length}return-1}function g(e,t){let r=[],i=0,s=e.length,o=!1,a=null;while(i<s){let c=e[i];if(o){if(a){if(c===a)a=null}else if(c==='"'||c==="'")a=c;else if(c===">")o=!1;i++;continue}if(c!=="<"){let m=e.indexOf("<",i+1);if(m===-1)break;i=m;continue}let f=t(e,i);if(f>i){r.push({start:i,end:f,token:e.slice(i,f)}),i=f;continue}let l=dt(e,i);if(l>i){i=l;continue}let y=e.charCodeAt(i+1);if(y>=65&&y<=90||y>=97&&y<=122)o=!0;i++}return r}function jl(e){let t=0,r=0,i=0,s=!1,o=null;while(i<e.length){if(s){let m=e[i];if(o){if(m===o)o=null}else if(m==='"'||m==="'")o=m;else if(m===">")s=!1;i++;continue}let a=e.indexOf("<",i),c=a===-1?e.length:a;while(i<c){let m=e[i++];if(m==="{")t++;else if(m==="}")r++;if(t>=2&&r>=2)return!0}if(a===-1)break;let f=dt(e,a);if(f>a){i=f;continue}let l=e.charCodeAt(a+1),y=l===47?e.charCodeAt(a+2):l;if(y>=65&&y<=90||y>=97&&y<=122)s=!0;i=a+1}return!1}function Bl(e,t){while(e.size>=t){let r=e.keys().next();if(r.done)return;e.delete(r.value)}}var Sn=1024,wn=16777216,L=new Map,$e=0;function kn(e,t){L.set(e,t),$e+=e.length+t.output.length;for(let[r,i]of L){if($e<=wn)break;L.delete(r),$e-=r.length+i.output.length}}function we(e,t,r,i){let s=i!==void 0&&e.length>=Sn,o=s?`${i}\x00${e}`:"";if(s){let y=L.get(o);if(y)return L.delete(o),L.set(o,y),{output:y.output,tokens:y.tokens.slice()}}let a=g(e,t);if(a.length===0)return{output:e,tokens:[]};let c=a.map((y)=>y.token),f="",l=0;for(let y=0;y<a.length;y++){let m=a[y];f+=e.slice(l,m.start),f+=r(m.token,y),l=m.end}if(f+=e.slice(l),s)return kn(o,{output:f,tokens:c}),{output:f,tokens:c.slice()};return{output:f,tokens:c}}var vn=1024,Rn=16777216,M=new Map,Ie=0;function Cn(e,t){M.set(e,t),Ie+=e.length+t.output.length;for(let[r,i]of M){if(Ie<=Rn)break;M.delete(r),Ie-=r.length+i.output.length}}function Oe(e,t,r){return{output:t,scripts:r,restore:(i)=>i===t?e:Hn(i,r)}}function ne(e){let t=e.length>=vn;if(t){let s=M.get(e);if(s)return M.delete(e),M.set(e,s),Oe(e,s.output,s.scripts.slice())}let{output:r,tokens:i}=we(e,U,(s,o)=>`\x00STX_SCRIPT_${o}\x00`);if(t)return Cn(e,{output:r,scripts:i}),Oe(e,r,i.slice());return Oe(e,r,i)}function Hn(e,t){if(t.length===0)return e;return e.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(r,i)=>t[+i]??"")}function Q(e){let t=De(e),r=[];for(let i=0;i<t.length;i++){let s=t[i],o=t[i+1];if(s.name.toLowerCase()!=="script"||s.closing||o?.name.toLowerCase()!=="script"||!o.closing)continue;r.push({start:s.start,end:o.end,bodyStart:s.end,bodyEnd:o.start,attrs:s.attributes})}return r}var nn="private, no-store";function nt(e){return e.replace(/&#(\d+);/g,(t,r)=>mt(Number(r),t)).replace(/&#x([0-9a-f]+);/gi,(t,r)=>mt(Number.parseInt(r,16),t)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function mt(e,t){if(!Number.isInteger(e)||e<0||e>1114111)return t;try{return String.fromCodePoint(e)}catch{return t}}function Le(e){return e.headers.get("X-STX-Router")==="true"}function ht(e,t){if(!e)return t;return e.split(",").some((i)=>i.trim().toLowerCase()===t.toLowerCase())?e:`${e}, ${t}`}function X(e){let t=ht(e,"X-STX-Router");for(let r of vo)t=ht(t,r);return{Vary:t}}var vo=["X-STX-Have-Layout","X-STX-Have-Layout-Group"];var oe="data-stx-color-mode-boot",yt="__STX_COLOR_MODE__",Tn=new Set(["light","dark","auto","system"]),An=new Set(["auto","system"]),_n=/^[a-z][\w:-]*$/i,$n=/^[\w-]+$/;function In(e){let t=e.storageKey??"stx-color-mode",r=e.initialMode??"auto",i=e.darkClass===void 0?"dark":e.darkClass,s=e.attribute??null,o=e.autoValue??null,a=e.respectExisting===!0;if(typeof t!=="string"||t.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!Tn.has(r))throw Error(`colorMode.initialMode must be one of light, dark, auto, system \u2014 got ${JSON.stringify(r)}`);if(i!==null&&(typeof i!=="string"||!$n.test(i)))throw Error(`colorMode.darkClass must be a single CSS class name, or null to opt out \u2014 got ${JSON.stringify(i)}`);if(s!==null&&(typeof s!=="string"||!_n.test(s)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(s)}`);if(o!==null&&!An.has(o))throw Error(`colorMode.autoValue must be 'auto' or 'system' \u2014 got ${JSON.stringify(o)}`);if(i===null&&s===null)throw Error("colorMode needs at least one of darkClass or attribute \u2014 with both null nothing would mark the mode on <html>");if(a&&s===null)throw Error("colorMode.respectExisting needs an attribute to read \u2014 the dark class alone cannot say whether a mode was chosen");return{storageKey:t,initialMode:r==="system"?"auto":r,darkClass:i,attribute:s,autoValue:o,respectExisting:a}}function On(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Pe(e={}){let t=In(e),r=On(t),i=`(function(){"use strict";var o=window.${yt};if(o&&typeof o.sync==="function"){o.sync();return}var c=${r};var r=document.documentElement;function read(){var p=c.initialMode,a=c.autoValue;try{var v=localStorage.getItem(c.storageKey);if(v==="light"||v==="dark"){p=v}else if(v==="auto"||v==="system"){p="auto";if(!a)a=v}}catch(e){}return{p:p,a:a}}function sys(){try{return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(e){return"light"}}function stamp(m){if(c.attribute)r.setAttribute(c.attribute,m);if(c.darkClass){if(m==="dark")r.classList.add(c.darkClass);else r.classList.remove(c.darkClass)}}var s=read();var f=null;if(c.respectExisting&&c.attribute){var x=r.getAttribute(c.attribute);if(x==="light"||x==="dark")f=x}var m=f||(s.p==="auto"?sys():s.p);var p=s.p;stamp(m);var g=null;function sync(){var t=read(),n=f||(t.p==="auto"?sys():t.p);var moved=n!==m,chose=t.p!==p;if(moved){r.style.setProperty("transition","none","important");stamp(n);void r.offsetHeight;r.style.removeProperty("transition")}else stamp(n);m=n;p=t.p;if(g){g.mode=n;g.preference=t.p;if(t.a)g.autoValue=t.a}if(moved||chose){try{window.dispatchEvent(new CustomEvent("stx:color-mode",{detail:{mode:n,preference:t.p}}))}catch(e){}}}try{g=window.${yt}={storageKey:c.storageKey,initialMode:c.initialMode,darkClass:c.darkClass,attribute:c.attribute,autoValue:s.a||"auto",respectExisting:c.respectExisting,forced:f,preference:p,mode:m,watching:true,sync:sync}}catch(e){}try{var q=matchMedia("(prefers-color-scheme: dark)");if(q.addEventListener)q.addEventListener("change",sync);else if(q.addListener)q.addListener(sync)}catch(e){}try{addEventListener("pageshow",sync);addEventListener("storage",function(e){if(e.key===null||e.key===c.storageKey)sync()});document.addEventListener("visibilitychange",function(){if(document.visibilityState==="visible")sync()})}catch(e){}}());`;return`<script ${oe}>${i}</script>`}function Xr(e,t={}){if(e.includes(oe))return e;let r=Ne(e);if(r===null)return e;let i=Pe(t);return`${e.slice(0,r)}
|
|
48
|
-
${i}${e.slice(r)}`}var
|
|
49
|
-
${o[0]}${e.slice(r,o.index)}${e.slice(a,s)}${e.slice(s)}`}function
|
|
47
|
+
`}else i+=a}return i}var En=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Qt(e,t){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:n.INVALID_DIRECTIVE_SYNTAX};let i=bo(r);if(i)return{ok:!1,message:`the expression is not allowed (${i})`,code:n.UNSAFE_EXPRESSION};let s=Q(t),o;try{o=p(r,Object.keys(s))(...Object.values(s))}catch(c){return{ok:!1,message:`the expression could not be evaluated: ${c instanceof Error?c.message:String(c)}`,code:n.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let a=[...new Set(Te(r))].filter((c)=>!En.has(c)&&!(c in s)&&!(c in globalThis));if(a.length>0)return{ok:!1,message:`${a.map((f)=>`"${f}"`).join(", ")} ${a.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:n.UNDEFINED_VARIABLE};if(o===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:n.EVALUATION_ERROR};return{ok:!0,value:o}}function et(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function wt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function gt(e){if(!e)return"";return ut.isAbsolute(e)?ut.relative(process.cwd(),e)||e:e}function Ce(e){let t=e.replace(/\s+/g," ").trim();return t.length>80?`${t.slice(0,77)}...`:t}function H(e,t,r,i,s=n.EVALUATION_ERROR){let o=i?` in ${gt(i)}`:"";return console.warn(`[stx] ${Ce(t)}${o}: ${r}`),u(e,`${Ce(t)}: ${r}`,s)}function xo(e,t,r){let i=r?` in ${gt(r)}`:"";console.warn(`[stx] ${Ce(e)}${i}: ${t}`)}var en="data-stx-before-runtime";function oa(){return{afterOpen:[],beforeClose:[]}}function bn(e){return e.afterOpen.length>0||e.beforeClose.length>0}function Fl(e,t){if(!bn(t))return e;let r=t.afterOpen.join(""),i=t.beforeClose.join(""),s=N(e),o=r?zn(e):null,a=i&&s!==-1?s:null;if(o===null&&a===null)return e;if(o!==null&&a!==null)return`${e.slice(0,o)}${r}${e.slice(o,a)}${i}${e.slice(a)}`;if(o!==null)return`${e.slice(0,o)}${r}${e.slice(o)}`;return`${e.slice(0,a)}${i}${e.slice(a)}`}var pt=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function zn(e){let t=/<head\b[^>]*>/i.exec(e);if(!t)return null;let r=t.index+t[0].length;pt.lastIndex=r;let i=pt.exec(e);return i?r+i[0].length:r}var Ae=/\s*/y,_e=/\x00STX_HTML_COMMENT_\d+\x00/y;function vt(e){let t=0;while(t<e.length){if(Ae.lastIndex=t,Ae.exec(e),t=Ae.lastIndex,e.startsWith("<!--",t)){let r=e.indexOf("-->",t+4);if(r===-1)return t;t=r+3;continue}if(_e.lastIndex=t,_e.test(e)){t=_e.lastIndex;continue}return t}return t}var $e=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,xn=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function G(e){let t=[],r=0;while(r<e.length){let i=e.indexOf("<",r);if(i===-1)break;if(e.startsWith("<!--",i)){let E=e.indexOf("-->",i+4);if(E===-1)break;r=E+3;continue}$e.lastIndex=i;let s=$e.exec(e);if(!s){r=i+1;continue}let o=$e.lastIndex,a=o,c=null;for(;a<e.length;a++){let E=e[a];if(c){if(E===c)c=null}else if(E==='"'||E==="'")c=E;else if(E===">")break}if(a===e.length)break;let f=s[1]==="/",l=e[a-1]==="/";t.push({start:i,end:a+1,name:s[2],attributes:e.slice(o,l?a-1:a),closing:f,selfClosing:l}),r=a+1;let y=s[2].toLowerCase();if(!f&&y==="plaintext")break;let m=xn.get(y);if(!f&&(y==="script"||y==="style"||m)){let E=m??(y==="script"?ie:oe);E.lastIndex=r;let S=E.exec(e);if(!S)break;r=S.index}}return t}var ee=/<script\b[^>]*>/iy,ie=/<\/script\s*>/ig,te=/<style\b[^>]*>/iy,oe=/<\/style\s*>/ig;function ft(e,t,r,i){r.lastIndex=t;let s=r.exec(e);if(!s||s.index!==t)return-1;i.lastIndex=r.lastIndex;let o=i.exec(e);if(!o)return-1;return o.index+o[0].length}function U(e,t){return ft(e,t,ee,ie)}function tn(e,t){return ft(e,t,te,oe)}function tt(e,t){if(!e.startsWith("<!--",t))return-1;let r=e.indexOf("-->",t+4);if(r===-1)return-1;return r+3}function dt(e,t){if(e.startsWith("<!--",t)){let s=tt(e,t);return s===-1?e.length:s}if(ee.lastIndex=t,ee.exec(e)?.index===t){ie.lastIndex=ee.lastIndex;let s=ie.exec(e);return s?s.index+s[0].length:e.length}if(te.lastIndex=t,te.exec(e)?.index===t){oe.lastIndex=te.lastIndex;let s=oe.exec(e);return s?s.index+s[0].length:e.length}return-1}function g(e,t){let r=[],i=0,s=e.length,o=!1,a=null;while(i<s){let c=e[i];if(o){if(a){if(c===a)a=null}else if(c==='"'||c==="'")a=c;else if(c===">")o=!1;i++;continue}if(c!=="<"){let m=e.indexOf("<",i+1);if(m===-1)break;i=m;continue}let f=t(e,i);if(f>i){r.push({start:i,end:f,token:e.slice(i,f)}),i=f;continue}let l=dt(e,i);if(l>i){i=l;continue}let y=e.charCodeAt(i+1);if(y>=65&&y<=90||y>=97&&y<=122)o=!0;i++}return r}function zl(e){let t=0,r=0,i=0,s=!1,o=null;while(i<e.length){if(s){let m=e[i];if(o){if(m===o)o=null}else if(m==='"'||m==="'")o=m;else if(m===">")s=!1;i++;continue}let a=e.indexOf("<",i),c=a===-1?e.length:a;while(i<c){let m=e[i++];if(m==="{")t++;else if(m==="}")r++;if(t>=2&&r>=2)return!0}if(a===-1)break;let f=dt(e,a);if(f>a){i=f;continue}let l=e.charCodeAt(a+1),y=l===47?e.charCodeAt(a+2):l;if(y>=65&&y<=90||y>=97&&y<=122)s=!0;i=a+1}return!1}function Hl(e,t){while(e.size>=t){let r=e.keys().next();if(r.done)return;e.delete(r.value)}}var Sn=1024,wn=16777216,L=new Map,Ie=0;function kn(e,t){L.set(e,t),Ie+=e.length+t.output.length;for(let[r,i]of L){if(Ie<=wn)break;L.delete(r),Ie-=r.length+i.output.length}}function ve(e,t,r,i){let s=i!==void 0&&e.length>=Sn,o=s?`${i}\x00${e}`:"";if(s){let y=L.get(o);if(y)return L.delete(o),L.set(o,y),{output:y.output,tokens:y.tokens.slice()}}let a=g(e,t);if(a.length===0)return{output:e,tokens:[]};let c=a.map((y)=>y.token),f="",l=0;for(let y=0;y<a.length;y++){let m=a[y];f+=e.slice(l,m.start),f+=r(m.token,y),l=m.end}if(f+=e.slice(l),s)return kn(o,{output:f,tokens:c}),{output:f,tokens:c.slice()};return{output:f,tokens:c}}var vn=1024,Rn=16777216,M=new Map,Oe=0;function Cn(e,t){M.set(e,t),Oe+=e.length+t.output.length;for(let[r,i]of M){if(Oe<=Rn)break;M.delete(r),Oe-=r.length+i.output.length}}function Ne(e,t,r){return{output:t,scripts:r,restore:(i)=>i===t?e:Hn(i,r)}}function re(e){let t=e.length>=vn;if(t){let s=M.get(e);if(s)return M.delete(e),M.set(e,s),Ne(e,s.output,s.scripts.slice())}let{output:r,tokens:i}=ve(e,U,(s,o)=>`\x00STX_SCRIPT_${o}\x00`);if(t)return Cn(e,{output:r,scripts:i}),Ne(e,r,i.slice());return Ne(e,r,i)}function Hn(e,t){if(t.length===0)return e;return e.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(r,i)=>t[+i]??"")}function V(e){let t=G(e),r=[];for(let i=0;i<t.length;i++){let s=t[i],o=t[i+1];if(s.name.toLowerCase()!=="script"||s.closing||o?.name.toLowerCase()!=="script"||!o.closing)continue;r.push({start:s.start,end:o.end,bodyStart:s.end,bodyEnd:o.start,attrs:s.attributes})}return r}var nn="private, no-store";function nt(e){return e.replace(/&#(\d+);/g,(t,r)=>mt(Number(r),t)).replace(/&#x([0-9a-f]+);/gi,(t,r)=>mt(Number.parseInt(r,16),t)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function mt(e,t){if(!Number.isInteger(e)||e<0||e>1114111)return t;try{return String.fromCodePoint(e)}catch{return t}}function Le(e){return e.headers.get("X-STX-Router")==="true"}function ht(e,t){if(!e)return t;return e.split(",").some((i)=>i.trim().toLowerCase()===t.toLowerCase())?e:`${e}, ${t}`}function J(e){let t=ht(e,"X-STX-Router");for(let r of So)t=ht(t,r);return{Vary:t}}var So=["X-STX-Have-Layout","X-STX-Have-Layout-Group"];var ae="data-stx-color-mode-boot",yt="__STX_COLOR_MODE__",Tn=new Set(["light","dark","auto","system"]),An=new Set(["auto","system"]),_n=/^[a-z][\w:-]*$/i,$n=/^[\w-]+$/;function In(e){let t=e.storageKey??"stx-color-mode",r=e.initialMode??"auto",i=e.darkClass===void 0?"dark":e.darkClass,s=e.attribute??null,o=e.autoValue??null,a=e.respectExisting===!0;if(typeof t!=="string"||t.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!Tn.has(r))throw Error(`colorMode.initialMode must be one of light, dark, auto, system \u2014 got ${JSON.stringify(r)}`);if(i!==null&&(typeof i!=="string"||!$n.test(i)))throw Error(`colorMode.darkClass must be a single CSS class name, or null to opt out \u2014 got ${JSON.stringify(i)}`);if(s!==null&&(typeof s!=="string"||!_n.test(s)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(s)}`);if(o!==null&&!An.has(o))throw Error(`colorMode.autoValue must be 'auto' or 'system' \u2014 got ${JSON.stringify(o)}`);if(i===null&&s===null)throw Error("colorMode needs at least one of darkClass or attribute \u2014 with both null nothing would mark the mode on <html>");if(a&&s===null)throw Error("colorMode.respectExisting needs an attribute to read \u2014 the dark class alone cannot say whether a mode was chosen");return{storageKey:t,initialMode:r==="system"?"auto":r,darkClass:i,attribute:s,autoValue:o,respectExisting:a}}function On(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Pe(e={}){let t=In(e),r=On(t),i=`(function(){"use strict";var o=window.${yt};if(o&&typeof o.sync==="function"){o.sync();return}var c=${r};var r=document.documentElement;function read(){var p=c.initialMode,a=c.autoValue;try{var v=localStorage.getItem(c.storageKey);if(v==="light"||v==="dark"){p=v}else if(v==="auto"||v==="system"){p="auto";if(!a)a=v}}catch(e){}return{p:p,a:a}}function sys(){try{return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(e){return"light"}}function stamp(m){if(c.attribute)r.setAttribute(c.attribute,m);if(c.darkClass){if(m==="dark")r.classList.add(c.darkClass);else r.classList.remove(c.darkClass)}}var s=read();var f=null;if(c.respectExisting&&c.attribute){var x=r.getAttribute(c.attribute);if(x==="light"||x==="dark")f=x}var m=f||(s.p==="auto"?sys():s.p);var p=s.p;stamp(m);var g=null;function sync(){var t=read(),n=f||(t.p==="auto"?sys():t.p);var moved=n!==m,chose=t.p!==p;if(moved){r.style.setProperty("transition","none","important");stamp(n);void r.offsetHeight;r.style.removeProperty("transition")}else stamp(n);m=n;p=t.p;if(g){g.mode=n;g.preference=t.p;if(t.a)g.autoValue=t.a}if(moved||chose){try{window.dispatchEvent(new CustomEvent("stx:color-mode",{detail:{mode:n,preference:t.p}}))}catch(e){}}}try{g=window.${yt}={storageKey:c.storageKey,initialMode:c.initialMode,darkClass:c.darkClass,attribute:c.attribute,autoValue:s.a||"auto",respectExisting:c.respectExisting,forced:f,preference:p,mode:m,watching:true,sync:sync}}catch(e){}try{var q=matchMedia("(prefers-color-scheme: dark)");if(q.addEventListener)q.addEventListener("change",sync);else if(q.addListener)q.addListener(sync)}catch(e){}try{addEventListener("pageshow",sync);addEventListener("storage",function(e){if(e.key===null||e.key===c.storageKey)sync()});document.addEventListener("visibilitychange",function(){if(document.visibilityState==="visible")sync()})}catch(e){}}());`;return`<script ${ae}>${i}</script>`}function Xr(e,t={}){if(e.includes(ae))return e;let r=Me(e);if(r===null)return e;let i=Pe(t);return`${e.slice(0,r)}
|
|
48
|
+
${i}${e.slice(r)}`}var Me=zn,Nn=new RegExp(`<script\\b[^>]*\\b${ae}\\b[^>]*>[\\s\\S]*?<\\/script>`,"i"),Et=/<meta\b[^>]*\bcharset\b[^>]*>/gi,St=/<\/head>/gi;function Ln(e){let t=/<head\b[^>]*>/i.exec(e);if(!t)return e;let r=t.index+t[0].length;St.lastIndex=r;let i=St.exec(e),s=i?i.index:e.length;Et.lastIndex=r;let o=Et.exec(e);if(!o||o.index>=s)return e;if(e.slice(r,o.index).trim()==="")return e;let a=o.index+o[0].length;return`${e.slice(0,r)}
|
|
49
|
+
${o[0]}${e.slice(r,o.index)}${e.slice(a,s)}${e.slice(s)}`}function Ul(e){return Pn(Dn(Ln(e)))}var kt=/<(?:base|meta)\b(?:"[^"]*"|'[^']*'|[^'">])*>/iy,Mn=/^<script\b(?:"[^"]*"|'[^']*'|[^'">])*>/i;function Pn(e){if(!e.includes(`${en}=""`))return e;let t=zn(e),r=N(e);if(t===null||r===-1)return e;let i=e.slice(t,r),s=g(i,U).map((b)=>({...b,attrs:on(Mn.exec(b.token)?.[0]??"")})),o=s.filter(({attrs:b})=>(en in b));if(!o.length)return e;let a=g(i,(b,w)=>{kt.lastIndex=w;let k=kt.exec(b)?.[0];if(!k)return-1;let R=nt(on(k)["http-equiv"]??"").toLowerCase();return/^<base\b/i.test(k)||R==="content-security-policy"?w+k.length:-1}),c=s.find(({attrs:b})=>(ae in b)),f=Math.max(a.at(-1)?.end??0,c?.end??0),l=f;if(o.every((b)=>{if(b.start<l||i.slice(l,b.start).trim())return!1;return l=b.end,!0}))return e;let y=[],m=f;l=0;for(let b of o)if(y.push(i.slice(l,b.start)),l=b.end,b.end<=f)m-=b.end-b.start;y.push(i.slice(l));let E=y.join(""),S=o.map((b)=>b.token).join(`
|
|
50
50
|
`);return e.slice(0,t)+E.slice(0,m)+`
|
|
51
|
-
`+S+E.slice(m)+e.slice(r)}function Dn(e){let t=Nn.exec(e);if(!t)return e;let r=
|
|
52
|
-
${t[0]}${i.slice(s)}`}var jn="[data-stx-component-wrapper]:not([stx-hydrate]){display:contents}",Tt=`<style data-stx-cloak>[x-cloak]{display:none !important}${jn}</style>`,
|
|
51
|
+
`+S+E.slice(m)+e.slice(r)}function Dn(e){let t=Nn.exec(e);if(!t)return e;let r=Me(e);if(r===null)return e;if(t.index<=r||e.slice(r,t.index).trim()==="")return e;let i=e.slice(0,t.index)+e.slice(t.index+t[0].length),s=Me(i);if(s===null)return e;return`${i.slice(0,s)}
|
|
52
|
+
${t[0]}${i.slice(s)}`}var jn="[data-stx-component-wrapper]:not([stx-hydrate]){display:contents}",Tt=`<style data-stx-cloak>[x-cloak]{display:none !important}${jn}</style>`,ce="data-stx-html-attrs",ue="data-stx-html-class",At=/^[A-Za-z_:][\w:.-]*$/;function C(e){return String(e).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Bn(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function xt(e){if(e.name)return`name="${e.name}"`;if(e.property)return`property="${e.property}"`;if(e.charset!=null)return"charset=";if(e["http-equiv"])return`http-equiv="${e["http-equiv"]}"`;return""}function Vn(e){let t=/^\s*<meta\b([^>]*)>/i.exec(e);if(!t)return null;let r={};for(let i of t[1].matchAll(/([\w:-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g))r[i[1].toLowerCase()]=i[2]??i[3]??i[4]??"";return r}function I(e,t){return Object.entries(e).filter(([r])=>!t?.(r)).map(([r,i])=>`${r}="${C(String(i))}"`).join(" ")}function ge(e){let t=String(e.content),r=typeof e.type==="string"?e.type.trim().toLowerCase():"";return/json$|^importmap$/.test(r)?t.replace(/<\//g,"<\\/"):t}function F(e){let{content:t,beforeRuntime:r,...i}=e;if(r!==!0)return i;let s=String(i.type??"").trim().toLowerCase();if(typeof t!=="string"||!t.trim()||i.src||i.async||i.defer||s&&s!=="text/javascript"&&s!=="application/javascript")throw Error("A beforeRuntime head script must be synchronous inline JavaScript.");return delete i.async,delete i.defer,{...i,[en]:""}}function _t(e){let t=I(F(e));return`<script${t?` ${t}`:""}>${ge(e)}</script>`}function Wn(e={},t="en"){let r=[],i=[],s="",o=t;for(let[c,f]of Object.entries(e||{})){if(f==null)continue;let l=c.trim();if(!At.test(l))continue;let y=l.toLowerCase();if(y==="lang"){o=String(f);continue}if(y==="class"){s=String(f).trim();continue}r.push(` ${l}="${C(String(f))}"`),i.push(l)}let a=` lang="${C(o)}"`;if(s)a+=` class="${C(s)}"`;if(a+=r.join(""),s)a+=` ${ue}="${C(s)}"`;if(i.length)a+=` ${ce}="${C(i.join(" "))}"`;return a}function Vl(e={},t={}){let r={...e,...t};if(e.class&&t.class){let i=e.class.split(/\s+/).filter(Boolean);for(let s of t.class.split(/\s+/).filter(Boolean))if(!i.includes(s))i.push(s);r.class=i.join(" ")}return r}function Gr(e,t={}){if(!t||Object.keys(t).length===0)return e;let r=e.match(/<html\b([^>]*)>/i);if(!r)return e;let i={},s=[],o=/([A-Za-z_:][\w:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g,a;while((a=o.exec(r[1]))!==null){let y=a[1];if(!(y in i))s.push(y);i[y]=a[2]??a[3]??a[4]??""}let c=[],f=[];for(let[y,m]of Object.entries(t)){if(m==null)continue;let E=y.trim();if(!At.test(E))continue;let S=E.toLowerCase();if(S==="class"){let b=(i.class||"").split(/\s+/).filter(Boolean);for(let w of String(m).split(/\s+/).filter(Boolean))if(!b.includes(w))b.push(w),c.push(w);if(!("class"in i))s.push("class");i.class=b.join(" ");continue}if(!(E in i))s.push(E);if(i[E]=String(m),S!=="lang")f.push(E)}if(c.length){if(!(ue in i))s.push(ue);i[ue]=c.join(" ")}if(f.length){if(!(ce in i))s.push(ce);i[ce]=f.join(" ")}let l=s.map((y)=>` ${y}="${C(i[y])}"`).join("");return e.replace(r[0],()=>`<html${l}>`)}function Wl(e){if(e.includes("data-stx-cloak"))return null;if(N(e)===-1)return null;return`${Tt}
|
|
53
53
|
`}function Xn(e){let t=[],r=0;while(r<e.length){let o=e.slice(r),a=o.match(/^\s+/);if(a){r+=a[0].length;continue}if(o.startsWith("<!--")){let m=e.indexOf("-->",r);if(m===-1)break;r=m+3;continue}let c=o.match(/^<script\b[^>]*>/i);if(c){let m=e.toLowerCase().indexOf("</script>",r+c[0].length);if(m===-1)break;r=m+9;continue}let f=o.match(/^<link\b[^>]*>/i);if(f){t.push(f[0]),r+=f[0].length;continue}let l=o.match(/^<meta\b[^>]*>/i);if(l){t.push(l[0]),r+=l[0].length;continue}let y=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(y){t.push(y[0]),r+=y[0].length;continue}break}if(t.length===0)return{body:e,hoisted:t};let i="",s=0;while(s<e.length&&s<r){let o=e.slice(s),a=o.match(/^<link\b[^>]*>/i);if(a&&t.includes(a[0])){s+=a[0].length;continue}let c=o.match(/^<meta\b[^>]*>/i);if(c&&t.includes(c[0])){s+=c[0].length;continue}let f=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(f&&t.includes(f[0])){s+=f[0].length;continue}i+=e[s],s++}return i+=e.slice(r),{body:i,hoisted:t}}function Kn(e,t={},r={}){let{title:i="stx App",lang:s="en",meta:o=[],link:a=[],script:c=[],headRaw:f="",htmlAttrs:l={},bodyClass:y="",bodyAttrs:m={}}=t,E=r.title||i,S=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],b=new Set(o.map(xt).filter(Boolean)),{body:w,hoisted:k}=Xn(e),R=new Set(k.flatMap((x)=>{let j=Vn(x);return j?[xt(j)].filter(Boolean):[]})),Lt=[...S.filter((x)=>!b.has(xt(x))),...o].filter((x)=>!R.has(xt(x))).map((x)=>` <meta ${I(x)}>`).join(`
|
|
54
54
|
`),Mt=a.map((x)=>` <link ${I(x)}>`).join(`
|
|
55
55
|
`),Pt=c.map((x)=>{if(x.src)return` <script ${I(F(x))}></script>`;if(x.content)return` ${_t(x)}`;return""}).filter(Boolean).join(`
|
|
@@ -63,8 +63,8 @@ ${Ht.join(`
|
|
|
63
63
|
${Bt.join(`
|
|
64
64
|
`)}
|
|
65
65
|
</body>
|
|
66
|
-
</html>`}var Fe=/\s+/y,He=/<(script|style)\b[^>]*>/iy,qn=/<\/script>/gi,Gn=/<\/style>/gi,Rt=/<!DOCTYPE\b/iy,Ct=/<html[\s>]/iy;function Un(e){let t=0;while(t<e.length){if(Fe.lastIndex=t,Fe.exec(e)){t=Fe.lastIndex;continue}if(e.startsWith("<!--",t)){let s=e.indexOf("-->",t);if(s===-1)return!1;t=s+3;continue}He.lastIndex=t;let i=He.exec(e);if(i){let s=i[1].toLowerCase()==="script"?qn:Gn;s.lastIndex=He.lastIndex;let o=s.exec(e);if(o===null)return!1;t=o.index+o[0].length;continue}if(Rt.lastIndex=t,Rt.test(e))return!0;return Ct.lastIndex=t,Ct.test(e)}return!1}function
|
|
66
|
+
</html>`}var Fe=/\s+/y,He=/<(script|style)\b[^>]*>/iy,qn=/<\/script>/gi,Gn=/<\/style>/gi,Rt=/<!DOCTYPE\b/iy,Ct=/<html[\s>]/iy;function Un(e){let t=0;while(t<e.length){if(Fe.lastIndex=t,Fe.exec(e)){t=Fe.lastIndex;continue}if(e.startsWith("<!--",t)){let s=e.indexOf("-->",t);if(s===-1)return!1;t=s+3;continue}He.lastIndex=t;let i=He.exec(e);if(i){let s=i[1].toLowerCase()==="script"?qn:Gn;s.lastIndex=He.lastIndex;let o=s.exec(e);if(o===null)return!1;t=o.index+o[0].length;continue}if(Rt.lastIndex=t,Rt.test(e))return!0;return Ct.lastIndex=t,Ct.test(e)}return!1}function ia(e){return Un(e)}function ql(e,t={}){let r=N(e);if(r===-1)return e;let{meta:i=[],link:s=[],script:o=[],headRaw:a=""}=t,c=e.slice(0,r),f=[];for(let l of i){let y=xt(l);if(y&&c.includes(y))continue;f.push(` <meta ${I(l)}>`)}for(let l of s){if(l.href&&c.includes(`href="${l.href}"`))continue;f.push(` <link ${I(l)}>`)}for(let l of o)if(l.src){if(c.includes(`src="${l.src}"`))continue;f.push(` <script ${I(F(l))}></script>`)}else if(l.content){if(c.includes(ge(l)))continue;f.push(` ${_t(l)}`)}if(a&&!c.includes(a))f.push(` ${a}`);if(f.length===0)return e;return`${e.slice(0,r)}${f.join(`
|
|
67
67
|
`)}
|
|
68
|
-
${e.slice(r)}`}function Jr(e,t={},r={},i){if(i??
|
|
69
|
-
`)}function
|
|
70
|
-
`,"")),headContent:t.trim()}}function
|
|
68
|
+
${e.slice(r)}`}function Jr(e,t={},r={},i){if(i??ia(e))return e;return Kn(e,t,r)}var Yn=["og:","article:","book:","profile:","fb:","music:","video:"],Jn=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function Yr(e,t){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:n.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:n.INVALID_DIRECTIVE_SYNTAX};let r=Zn(e[0],t);if(typeof r!=="string")return r;let i;if(e.length===2){let o=Qn(e[1],t);if(typeof o!=="string")return o;i=o}else{let o=r.includes(":")?r.slice(r.indexOf(":")+1):r,a=t.openGraph,c=t[o]??(wt(a)?a[o]:void 0);i=c===void 0||c===null||typeof c==="object"?"":String(c)}if(!i)return{kind:"empty"};return{kind:"tag",tag:Yn.some((o)=>r.startsWith(o))?{property:r,content:i}:{name:r,content:i}}}function Zn(e,t){let r=bt(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:n.INVALID_DIRECTIVE_SYNTAX};if(Jn.test(e.trim()))return e.trim();let i=Qt(e,t);if(!i.ok)return{kind:"error",message:`meta name: ${i.message}`,code:i.code};if(typeof i.value!=="string"||!i.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${et(i.value)}`,code:n.TYPE_ERROR};return i.value}function Qn(e,t){let r=bt(e);if(r!==null)return r;let i=Qt(e,t);if(!i.ok)return{kind:"error",message:i.message,code:i.code};let s=i.value;if(s===void 0||s===null||s===!1)return"";if(Array.isArray(s))return s.filter((o)=>o!==void 0&&o!==null&&o!=="").map(String).join(", ");if(typeof s==="object"&&!(s instanceof Date))return{kind:"error",message:`the content must be text, got ${et(s)}`,code:n.TYPE_ERROR};return String(s)}var Zr=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],ko=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],Ot={links:"link",metas:"meta",scripts:"script",styles:"style"},$t=new Set,It=new WeakMap;function Be(e){if($t.has(e))return;$t.add(e),console.warn(e)}function er(e,t){let r=Array.from({length:t.length+1},(i,s)=>s);for(let i=1;i<=e.length;i++){let s=r[0];r[0]=i;for(let o=1;o<=t.length;o++){let a=r[o];r[o]=Math.min(r[o]+1,r[o-1]+1,s+(e[i-1]===t[o-1]?0:1)),s=a}}return r[t.length]}function tr(e,t){let r=e.toLowerCase(),i=t.find((f)=>f.toLowerCase()===r);if(i)return i;let s=Ot[r];if(s&&t.includes(s))return s;let o,a=1/0;for(let f of t){let l=er(r,f.toLowerCase());if(l<a)o=f,a=l}let c=Math.min(e.length,o?.length??0)<=4?1:2;return a<=c?o:void 0}function je(e,t){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=It.get(e);if(r)return r;let{known:i,source:s}=t,o=e;for(let a of Object.keys(e)){if(i.includes(a))continue;let c=Ot[a];if(c&&i.includes(c)&&Array.isArray(e[a])){if(o===e)o={...e};let l=Array.isArray(o[c])?o[c]:[];o[c]=[...l,...e[a]],delete o[a],Be(`[stx] ${s}.${a} is not a head key; reading it as ${s}.${c}. Rename it to \`${c}\`.`);continue}if(/^styles?$/.test(a)&&!i.includes("style")){Be(`[stx] ${s}.${a} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let f=tr(a,i);Be(f?`[stx] ${s}.${a} is not a head key and is ignored. Did you mean \`${f}\`?`:`[stx] ${s}.${a} is not a head key and is ignored. Known keys: ${i.join(", ")}.`)}return It.set(e,o),o}var A={},nr=[],pe={};function aa(){return A}function Wy(){return pe}function qy(){A={},nr.length=0,pe={}}function Kl(e){A=rt(A,je(e,{known:ko,source:"useHead()"}))}function Nt(e,t,r){let i=[...e||[]];for(let s of t||[]){let o=r(s),a=o?i.findIndex((c)=>r(c)===o):-1;if(a<0)i.push(s);else i[a]=s}return i}function rt(e,t){return{title:t.title??e.title,titleTemplate:t.titleTemplate??e.titleTemplate,base:t.base??e.base,meta:Nt(e.meta,t.meta,(r)=>r.name||r.property||(r.httpEquiv?`http:${r.httpEquiv}`:void 0)),link:Nt(e.link,t.link,(r)=>["icon","apple-touch-icon","canonical"].includes(r.rel||"")?[r.rel,r.type,r.media,r.sizes].join(":"):void 0),script:[...e.script||[],...t.script||[]],style:[...e.style||[],...t.style||[]],htmlAttrs:{...e.htmlAttrs,...t.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...t.bodyAttrs}}}function cm(e){Kl(_o(e))}function _o(e){let t=[];if(e.description)t.push({name:"description",content:e.description});if(e.keywords){let f=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;t.push({name:"keywords",content:f})}if(e.author)t.push({name:"author",content:e.author});if(e.robots)t.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,i=e.ogDescription??e.description;if(r)t.push({property:"og:title",content:r});if(i)t.push({property:"og:description",content:i});if(e.ogImage){if(t.push({property:"og:image",content:e.ogImage}),e.ogImageType)t.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)t.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)t.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)t.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)t.push({property:"og:url",content:e.ogUrl});if(e.ogType)t.push({property:"og:type",content:e.ogType});if(e.ogSiteName)t.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)t.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)t.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)t.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)t.push({property:"profile:username",content:e.profileUsername});let s=e.twitterTitle??e.title,o=e.twitterDescription??e.description,a=e.twitterImage??e.ogImage;if(e.twitterCard)t.push({name:"twitter:card",content:e.twitterCard});if(s)t.push({name:"twitter:title",content:s});if(o)t.push({name:"twitter:description",content:o});if(a){t.push({name:"twitter:image",content:a});let f=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(f)t.push({name:"twitter:image:alt",content:f})}if(e.twitterSite)t.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)t.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)t.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)t.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)t.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)t.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let f of e.articleTags)t.push({property:"article:tag",content:f});let c=[];if(e.canonical)c.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:t,link:c}}function Ky(e){if(pe={...pe,...e},e.title||e.description)cm({title:e.title,description:e.description})}function Xy(e){let t=typeof e==="function"?e():e;Kl({title:t})}function Gy(e=A){let t=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);t.push(`<title>${O(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([i,s])=>`${i}="${O(s)}"`).join(" ");t.push(`<base ${r}>`)}for(let r of e.meta||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s==="httpEquiv"?"http-equiv":s}="${O(String(o))}"`).join(" ");t.push(`<meta ${i}>`)}for(let r of e.link||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s}="${O(String(o))}"`).join(" ");t.push(`<link ${i}>`)}for(let r of e.script||[]){let{content:i}=r,s=F({...r}),o=Object.entries(s).filter(([a,c])=>c!==void 0).map(([a,c])=>{if(typeof c==="boolean")return c?a:"";return`${a}="${O(String(c))}"`}).filter(Boolean).join(" ");if(i)t.push(`<script ${o}>${ge(r)}</script>`);else t.push(`<script ${o}></script>`)}for(let r of e.style||[]){let i=r.type?` type="${r.type}"`:"";t.push(`<style${i}>${r.content}</style>`)}return t.join(`
|
|
69
|
+
`)}function Jy(e=A){if(!e.htmlAttrs)return"";return Object.entries(e.htmlAttrs).map(([t,r])=>`${t}="${O(r)}"`).join(" ")}function Yy(e=A){if(!e.bodyAttrs)return"";return Object.entries(e.bodyAttrs).map(([t,r])=>`${t}="${O(r)}"`).join(" ")}function O(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Zy(e=A){if(typeof document>"u")return;if(e.title){let t=e.title;if(e.titleTemplate)t=typeof e.titleTemplate==="function"?e.titleTemplate(t):e.titleTemplate.replace("%s",t);document.title=t}for(let t of e.meta||[]){let r=t.name?`meta[name="${t.name}"]`:t.property?`meta[property="${t.property}"]`:null;if(r){let i=document.querySelector(r);if(!i){if(i=document.createElement("meta"),t.name)i.setAttribute("name",t.name);if(t.property)i.setAttribute("property",t.property);document.head.appendChild(i)}i.setAttribute("content",t.content)}}for(let t of e.link||[]){let r=`link[rel="${t.rel}"]${t.href?`[href="${t.href}"]`:""}`,i=document.querySelector(r);if(!i)i=document.createElement("link"),document.head.appendChild(i);for(let[s,o]of Object.entries(t))if(o!==void 0)i.setAttribute(s,String(o))}if(e.htmlAttrs)for(let[t,r]of Object.entries(e.htmlAttrs))if(t==="class")for(let i of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(i);else document.documentElement.setAttribute(t,r);if(e.bodyAttrs)for(let[t,r]of Object.entries(e.bodyAttrs))document.body.setAttribute(t,r)}function Qy(e){let t="";return{content:e.replace(/@head\s*([\s\S]*?)@endhead/g,(i,s)=>(t+=s.trim()+`
|
|
70
|
+
`,"")),headContent:t.trim()}}function eb(e,t){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,i,s,o)=>{let a=i?s:t[(o||"").trim()]??o,c=t.__stx_runtime_head??{};return t.__stx_runtime_head=rt(c,{title:a}),""})}function tb(e,t,r=""){if(!e.includes("@meta"))return e;return Yt(e,/(?<![\w$@])@meta\s*\(/g,(i,s)=>{let o=Yr(Zt(i),t);if(o.kind==="error")return H("Meta",s,o.message,r,o.code);if(o.kind==="tag"){let a=t.__stx_runtime_head??{};t.__stx_runtime_head=rt(a,{meta:[o.tag]})}return""},(i)=>H("Meta",i,"the call has no closing parenthesis",r,n.INVALID_DIRECTIVE_SYNTAX))}export{bo,na,wo,d,h,jl,D,Te,qr,p,vo,n,le,Kr,ne,u,De,ra,X,Fn,we,_,Bl,sa,Yt,Zt,bt,Qt,et,wt,H,xo,en,oa,Fl,zn,vt,G,U,tn,tt,g,zl,Hl,ve,re,Hn,V,nn,nt,Le,J,So,Xr,Ul,xt,Vl,Gr,Wl,Un,ia,ql,Jr,Yr,Zr,ko,je,aa,Wy,qy,Kl,rt,cm,_o,Ky,Xy,Gy,Jy,Yy,Zy,Qy,eb,tb};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{T}from"./chunk-
|
|
3
|
-
export{Qr,
|
|
2
|
+
import{T}from"./chunk-a78k8fkg.js";import{t,Kn,y}from"./chunk-amnfd29h.js";var M=new T(32,{maxBytes:2097152,sizeOf:(x)=>x.code.length*4}),B=/^[A-Za-z_$][\w$]*$/,O=new Set(["if","for","while","switch","with"]),_=["(","[","{"],D=[")","]","}"],Z=new Set(["const","let","var","return","if","for","while","do","switch","try","throw","export"]);function C(x){let u=t(x),h=[];for(let e of u.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let r=e.index??0;h.push({text:e[0],start:r,end:r+e[0].length})}return{code:u,tokens:h}}function z(x){let u=M.get(x);if(u)return u;let{code:h,tokens:e}=C(x),r=new Map,l=[];for(let o=0;o<e.length;o++){let n=e[o].text;if(["(","[","{"].includes(n))l.push(o);else if([")","]","}"].includes(n)){let i=l.at(-1);if(i!==void 0&&["()","[]","{}"].includes(e[i].text+n))l.pop(),r.set(i,o),r.set(o,i)}}function w(o,n){let i=[],s=o;for(let c=o;c<n;c++){if(["(","[","{"].includes(e[c].text)&&(r.get(c)??n)<n){c=r.get(c);continue}if(e[c].text===",")i.push([s,c]),s=c+1}return i.push([s,n]),i}let k=[];function b(o,n,i,s=!1,c){if(e[o]?.text==="...")o++;if(o>=n)return;let d=e[o].text;if(B.test(d)){if(i.add(d),i===g)k.push({name:d,token:o,functionScoped:s,declarationToken:c});return}if(d!=="{"&&d!=="[")return;let N=r.get(o);if(N===void 0||N>=n)return;for(let[v,m]of w(o+1,N)){let p=v;if(d==="{")for(let E=v;E<m;E++){if(e[E].text===":"){p=E+1;break}if(e[E].text==="=")break;if(["(","[","{"].includes(e[E].text)&&r.has(E))E=r.get(E)}b(p,m,i,s,c)}}function I(o,n){let i=new Set;for(let[s,c]of w(o,n))b(s,c,i);return i}function L(o){let n=o;for(;n<e.length;n++){let i=e[n].text;if(["(","[","{"].includes(i)&&r.has(n)){n=r.get(n);continue}if([",",";",")","]","}"].includes(i))break}return e[Math.max(o,n-1)]?.end??h.length}let g=new Set,A=[];for(let o=0;o<e.length;o++)if(e[o].text==="=>"){let n=o-1,i=n,s;if(e[n]?.text===")"&&r.has(n))i=r.get(n),s=I(i+1,n);else if(e[n]&&B.test(e[n].text))s=new Set([e[n].text]);else continue;let c=o+1,d=e[c]?.text==="{"&&r.has(c)?e[r.get(c)].end:L(c);A.push({start:e[i].start,end:d,bodyStart:e[c]?.start??d,functionBody:!0,names:s})}else if(e[o].text==="("&&r.has(o)){let n=e[o-1]?.text;if(!n||O.has(n)||!B.test(n)&&n!=="*"&&n!=="]")continue;let i=r.get(o),s=i+1;if(e[s]?.text===":"){s++;while(s<e.length&&!["{","=>",";","="].includes(e[s].text))s++}if(e[s]?.text!=="{"||!r.has(s))continue;A.push({start:e[o].start,end:e[r.get(s)].end,bodyStart:e[s].start,functionBody:n!=="catch",names:I(o+1,i)})}function a(o){let n=o;for(;n<e.length;n++){let i=e[n].text;if(_.includes(i)&&r.has(n)){n=r.get(n);continue}if(i===";"||D.includes(i))break;let s=e[n-1];if(n>o&&Z.has(i)&&s.text!==".")break;if(n>o&&/[\n\r]/.test(h.slice(s.end,e[n].start))&&(/^[\w$]+$/.test(s.text)||D.includes(s.text)||['"',"'","`"].includes(s.text))&&B.test(i)&&!["in","of","instanceof"].includes(i))break}return n}let f=[];for(let o=0;o<e.length;o++){if(e[o].text!=="for")continue;let n=e[o+1]?.text==="await"?o+2:o+1;if(e[n]?.text!=="("||!r.has(n))continue;let i=r.get(n),s=i+1,c=e[s]?.text==="{"&&r.has(s)?r.get(s):a(s),d=e[c]?.text===";"||e[c]?.text==="}"?e[c].end:e[Math.max(s,c-1)]?.end??h.length;f.push({headStart:n,headEnd:i,start:e[n].start,end:d})}for(let o=0;o<e.length;o++){let n=e[o].text,i=e[o-1]?.text;if(i==="."||e[o+1]?.text===":")continue;if(i==="as"||i==="<")continue;if(n==="const"||n==="let"||n==="var"){let s=a(o+1),c=o+1,d=!1,N=!1,v=0;for(let m=o+1;m<=s;m++){let p=e[m]?.text;if(m<s&&_.includes(p)&&r.has(m)&&r.get(m)<s){m=r.get(m);continue}if(m<s&&p===":"&&!N)d=!0;else if(m<s&&p==="="&&v===0)d=!1,N=!0;else if(m<s&&d&&p==="<")v++;else if(m<s&&d&&p===">"&&v>0)v--;else if(m===s||p===","&&v===0)b(c,m,g,n==="var",o),c=m+1,d=!1,N=!1}}else if(n==="function"||n==="class"){let s=o+1;if(e[s]?.text==="*")s++;if(e[s]&&B.test(e[s].text)&&e[s].text!=="extends")g.add(e[s].text),k.push({name:e[s].text,token:s,declarationToken:o})}else if(n==="import"){let s=o+1;if(e[s]?.text==="*"&&e[s+1]?.text==="as")s+=2;let c=e[s]?.text;if(c&&B.test(c)&&c!=="type"&&e[s+1]?.text!=="("&&e[s+1]?.text!==".")g.add(c),k.push({name:c,token:s,file:!0});let d=e[s]?.text==="{"?s:e[s+1]?.text===","&&e[s+2]?.text==="{"?s+2:-1;if(d!==-1&&r.has(d)){let N=r.get(d);for(let[v,m]of w(d+1,N)){let p=m-1;while(p>=v&&!B.test(e[p].text))p--;if(p>=v&&e[p].text!=="type")k.push({name:e[p].text,token:p,file:!0})}}}}let S={code:h,scopes:A,loops:f,declarations:g,sites:k,tokens:e,pairs:r};return M.set(x,S),S}function Qr(x){let u=z(x);return{code:u.code,shadows:(h,e)=>u.scopes.some((r)=>e>=r.start&&e<r.end&&r.names.has(h))}}function Co(x){return new Set(z(x).declarations)}function qn(x){let u=z(x),h=Kn(x),{depths:e}=y(h),r=[...h.matchAll(/[A-Za-z_$][\w$]*|\d+(?:[.]\d+)?|[^\s]/g)],l=[];for(let w of u.sites){if(w.file||w.declarationToken===void 0)continue;let k=u.tokens[w.declarationToken];if(e[k.start]!==0)continue;let b=0,I=r.length;while(b<I){let A=b+I>>>1;if(r[A].index<k.start)b=A+1;else I=A}let L=b-1,g=r[L--];if(g?.[0]==="declare")continue;if(k.text==="function"||k.text==="class"){while(g&&["async","export","default","abstract"].includes(g[0]))g=r[L--];if(g&&![";","}"].includes(g[0])){let A=h.slice(g.index+g[0].length,k.start);if(!/[\r\n]/.test(A)||!/^(?:[\w$]+|[)\]])$/.test(g[0])||["return","throw","yield","await","new"].includes(g[0]))continue}}l.push({name:w.name,start:k.start})}return l}function Xl(x){return[...new Set(qn(x).map((u)=>u.name))].sort()}function Be(x,u){let{scopes:h,loops:e,sites:r,tokens:l,pairs:w}=z(x),k=Array.from({length:l.length},()=>-1),b=[];for(let a=0;a<l.length;a++){k[a]=b.length?b[b.length-1]:-1;let f=l[a].text;if(f==="{"&&w.has(a))b.push(a);else if(f==="}"&&b.length&&w.get(a)===b[b.length-1])b.pop()}let I=new Set,L=new Map;for(let a of r){if(!u.has(a.name))continue;I.add(a.token);let f=a.file?-1:k[a.token],S=f===-1?[0,Number.POSITIVE_INFINITY]:[l[f].start,l[w.get(f)].end];if(a.functionScoped){let n=l[a.token].start,i=h.filter((s)=>s.functionBody&&n>=s.bodyStart&&n<s.end).sort((s,c)=>s.end-s.bodyStart-(c.end-c.bodyStart))[0];S=i?[i.bodyStart,i.end]:[0,Number.POSITIVE_INFINITY]}else if(!a.file){let n=e.filter((i)=>a.token>i.headStart&&a.token<i.headEnd).sort((i,s)=>i.headEnd-i.headStart-(s.headEnd-s.headStart))[0];if(n)S=[n.start,n.end]}let o=L.get(a.name);if(o)o.push(S);else L.set(a.name,[S])}let g=new Set;for(let a=0;a<l.length;a++){if(l[a].text!=="import"||l[a-1]?.text===".")continue;let f=a+1;if(l[f]?.text==="type")f++;if(l[f]&&B.test(l[f].text)&&l[f+1]?.text===",")f+=2;if(l[f]?.text==="{"&&w.has(f))for(let S=f+1;S<w.get(f);S++)g.add(S)}let A=new Set;for(let a=0;a<l.length;a++){let f=l[a].text;if(!u.has(f)||A.has(f)||I.has(a)||g.has(a))continue;let S=l[a-1]?.text;if(S==="#"||S==="."&&l[a-2]?.text!=="..")continue;if(l[a+1]?.text===":"&&(S==="{"||S===","))continue;let o=l[a].start;if(L.get(f)?.some(([n,i])=>o>=n&&o<i))continue;if(h.some((n)=>o>=n.start&&o<n.end&&n.names.has(f)))continue;A.add(f)}return A}function Gl(x){let u=z(Kn(x));return u.tokens.some((h,e)=>{if(h.text!=="await")return!1;if(u.tokens[e-1]?.text==="."||u.tokens[e+1]?.text===":")return!1;let r=e+1;if(u.tokens[r]?.text==="("&&u.tokens[(u.pairs.get(r)??-2)+1]?.text==="{")return!1;return!u.scopes.some((l)=>l.functionBody&&l.start<=h.start&&h.start<l.end)})}
|
|
3
|
+
export{Qr,Co,qn,Xl,Be,Gl};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ns,Sg,gi,kg}from"./chunk-3mc9ew9r.js";import"./chunk-2r2tayyd.js";import"./chunk-xnvh4jk2.js";import"./chunk-nkgqhb7s.js";import"./chunk-7767n5k6.js";import"./chunk-w27j0apm.js";import"./chunk-sk8x8nw8.js";import"./chunk-c3nmjx26.js";import"./chunk-ag07tdhn.js";import"./chunk-f8sh6289.js";import"./chunk-t4exh7c9.js";import{Wt}from"./chunk-xdprx6tx.js";import"./chunk-yfe380a4.js";import"./chunk-875wejw1.js";import"./chunk-r7zvrh58.js";import"./chunk-ayrd026n.js";import"./chunk-ra35ptjg.js";import"./chunk-a78k8fkg.js";import"./chunk-4jg8ddfy.js";export{kg as declareBareLoopHead,Wt as parseLoopBinding,Sg as processLoops,gi as processLoopsAsync,Ns as reportDeferredLoopWarnings};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{en,U,g,nt,Le,Un}from"./chunk-r7zvrh58.js";import{B,Kt,Xt,Vr,b,Ll,Yi,ee,M}from"./chunk-xdprx6tx.js";import{yn}from"./chunk-h7z23fpq.js";import{r}from"./chunk-jh1hdq31.js";import{se}from"./chunk-q99y5115.js";import{on,N,c}from"./chunk-ws25jw6x.js";var G=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function W(n){let s=[],t=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,e;while((e=t.exec(n))!==null)s.push({start:e.index,end:e.index+e[0].length});return s}function D(n,s){return s.some((t)=>n>=t.start&&n<t.end)}function Y(n){let s=(n||"").trim();if(!s)return null;if(/[\s>+~,:]/.test(s))return null;let t={},e=s,i=e.match(/^[a-z][\w-]*/i);if(i)t.tag=i[0].toLowerCase(),e=e.slice(i[0].length);while(e.length>0){let o=e.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(o){if(t.attr=o[1],o[3]!==void 0&&o[3]!=="")t.attrValue=o[3];e=e.slice(o[0].length);continue}let l=e.match(/^#([\w-]+)/);if(l){t.id=l[1],e=e.slice(l[0].length);continue}let a=e.match(/^\.([\w-]+)/);if(a){t.className=a[1],e=e.slice(a[0].length);continue}return null}if(!t.tag&&!t.attr&&!t.id&&!t.className)return null;return t}function K(n,s){if(s.attr){if(!(s.attrValue===void 0?new RegExp(`\\b${s.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${s.attr}\\s*=\\s*(["'])\\s*${s.attrValue}\\s*\\1`,"i")).test(n))return!1}if(s.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${s.id}\\s*\\1`,"i").test(n))return!1}if(s.className){let t=n.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!t)return!1;if(!t[2].split(/\s+/).includes(s.className))return!1}return!0}function T(n,s="main"){let t=Y(s);if(!t)return null;let e=/<([a-z][\w-]*)\b([^>]*)>/gi,i=W(n),o;while((o=e.exec(n))!==null){if(D(o.index,i))continue;let l=o[1].toLowerCase(),a=o[2]||"";if(a.trimEnd().endsWith("/")||G.has(l))continue;if(t.tag&&t.tag!==l)continue;if(!K(a,t))continue;let u=o[0],p=o.index+u.length,f=new RegExp(`<(/?)${l}\\b([^>]*)>`,"gi");f.lastIndex=p;let m=1,x;while((x=f.exec(n))!==null){if(D(x.index,i))continue;let S=x[1]==="/";if(!S&&(x[2]||"").trimEnd().endsWith("/"))continue;if(m+=S?-1:1,m===0)return{openTag:u,openIndex:o.index,start:p,end:x.index,tagName:l}}return null}return null}function A(n){return n.replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function F(n){let s=/<head\b[^>]*>([\s\S]*?)<\/head\s*>/i.exec(n)?.[1]??"",t=/<(meta|link)\b(?:[^>"']|"[^"]*"|'[^']*')*>|<title\b[^>]*>[\s\S]*?<\/title\s*>/giy;return g(s,(e,i)=>(t.lastIndex=i,t.exec(e)?t.lastIndex:-1)).map(({token:e})=>e)}function Yn(n){let s=[];for(let t of F(n)){if(/^<title\b/i.test(t)){s.push(`<title>${A(t.replace(/^<title\b[^>]*>|<\/title\s*>$/gi,""))}</title>`);continue}let e=on(t);if(/^<meta\b/i.test(t)){let i=e.property?"property":"name",o=nt(e[i]??"").toLowerCase();if(o==="description"||/^(?:og|twitter):[\w:]+$/.test(o))s.push(`<meta ${i}="${r(o)}" content="${A(e.content??"")}">`)}else{let i=nt(e.rel??"").toLowerCase();if(i==="canonical"||i==="alternate"&&e.hreflang)s.push(`<link rel="${i}" href="${A(e.href??"")}"${i==="alternate"?` hreflang="${A(e.hreflang)}"`:""}>`)}}return`<template data-stx-page-head="1">${s.join("")}</template>
|
|
3
|
+
`}var J=["media","crossorigin","integrity"];function Zn(n){let s=[];for(let t of F(n)){if(!/^<link\b/i.test(t))continue;let e=on(t);if(nt(e.rel??"").trim().toLowerCase()!=="stylesheet")continue;if(!e.href||"data-css"in e||"disabled"in e)continue;let i=J.filter((o)=>(o in e)).map((o)=>` ${o}="${A(e[o])}"`).join("");s.push(`<link rel="stylesheet" href="${A(e.href)}"${i}>`)}return s.length?`<template data-stx-page-css="1">${s.join("")}</template>
|
|
4
|
+
`:""}import P from"path";var X="stx-page-head:",Z=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,_={dev:null,prod:null};function Q(){let n=se()?"dev":"prod",s=_[n];if(s!==null)return s;try{let t=import.meta.require("./chunk-msvphygp.js"),e=n==="dev"&&typeof t.getRouterScriptDev==="function"?t.getRouterScriptDev:t.getRouterScript;_[n]=`<script>${e()}</script>`}catch{_[n]=""}return _[n]}async function Fa(n,s){if(s===!1)return null;if(s&&typeof s==="string"){let e=P.resolve(n,s);if(await Bun.file(e).exists())return e;return null}let t=P.join(n,"app.stx");if(await Bun.file(t).exists())return t;return null}async function Uo(n,s){try{let t=await Bun.file(n).text(),e=t,i=B(t);if(i)e=i.content.trim();let o=yn(t),l=[...o.client.map((d)=>d.fullTag),...o.signals.map((d)=>d.fullTag)],a=[],u=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,p;while((p=u.exec(t))!==null)a.push(p[0]);let f=e;for(let d of o.server)f=f.replace(d.fullTag,"");for(let d of o.client)f=f.replace(d.fullTag,"");f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let m="<!--__STX_PAGE_SLOT__-->";if(f=f.replace(/<slot\s*\/>/gi,m).replace(/<slot\s*>\s*<\/slot>/gi,m),!f.includes(m))return console.warn(`[stx] Shell ${n} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:x,extractVariables:S,defaultConfig:w,loadStxConfig:R}=await import("./chunk-txyze88n.js"),E=await R(),h={__filename:n,__dirname:P.dirname(n)};for(let d of l){let k=d.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(k&&!d.includes("client")&&!d.includes('type="module"'))await S(k[1],h,n)}let y=await x(f,h,n,{...w,...E,...s},new Set),C=y.indexOf(m);if(C===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:y.substring(0,C),afterSlot:y.substring(C+m.length),filePath:n,shellScripts:l,shellStyles:a}}catch(t){return console.error(`[stx] Error processing shell ${n}:`,t),null}}function ms(n,s,t){let e,i="",o=s.match(Z);if(o){s=s.replace(o[0],"");try{let f=Buffer.from(o[1],"base64").toString("utf8"),m=f.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(m)e=m[1].trim();i=f.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let l=t||e||"stx App",a=Q(),u="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
5
|
+
<html lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta charset="UTF-8">
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9
|
+
<title>${l}</title>
|
|
10
|
+
${i?` ${i}
|
|
11
|
+
`:""} ${n.shellStyles.join(`
|
|
12
|
+
`)}
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
${n.beforeSlot}
|
|
16
|
+
<div data-stx-content>${s}</div>
|
|
17
|
+
${n.afterSlot}
|
|
18
|
+
${n.shellScripts.filter((f)=>!f.includes("server")).join(`
|
|
19
|
+
`)}
|
|
20
|
+
${u}
|
|
21
|
+
${a}
|
|
22
|
+
</body>
|
|
23
|
+
</html>`}function it(n,s={}){let t=n.trim();if(!Un(t))return n;let e=[],i=t.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(i){let u=i[1],p=/<style\b[^>]*>[\s\S]*?<\/style>/gi,f;while((f=p.exec(u))!==null)e.push(f[0]);let m=u.match(/<script\b[^>]*data-stx-server-data[^>]*>[\s\S]*?<\/script>/i);if(m)e.push(m[0]);let x=u.match(/<script\b[^>]*data-stx-runtime-config[^>]*>[\s\S]*?<\/script>/i);if(x)e.push(x[0])}if(s.preserveHead&&i){let u=[],p=/<title\b[^>]*>[\s\S]*?<\/title>|<meta\b[^>]*>|<link\b[^>]*>/gi,f;while((f=p.exec(i[1]))!==null){if(/<meta\b[^>]*(?:\bcharset|name="viewport")/i.test(f[0]))continue;u.push(f[0])}if(u.length>0)e.unshift(`<!--${X}${Buffer.from(u.join(`
|
|
24
|
+
`),"utf8").toString("base64")}-->`)}let o=t.match(/<body\b[^>]*>/i),l=c(t);if(o&&l!==-1){let u=o.index+o[0].length,p=t.slice(u,l).trim();if(e.length>0)return e.join(`
|
|
25
|
+
`)+`
|
|
26
|
+
`+p;return p}let a=t;if(a=a.replace(/<!DOCTYPE\b[^>]*>/i,""),a=a.replace(/<html\b[^>]*>/i,""),a=a.replace(/<\/html\s*>/i,""),i)a=a.replace(/<head\b[^>]*>[\s\S]*?<\/head>/i,e.join(`
|
|
27
|
+
`));return a=a.replace(/<body\b[^>]*>/i,""),a=a.replace(/<\/body\s*>/i,""),a.trim()}var L=/^<script\b[^>]*\sdata-stx-(?:owner|instance)(?=[\s=/>])/i;function H(n,s,t,e){if(!L.test(s))return!1;let i=s.slice(0,s.indexOf(">")+1),o=/\sdata-stx-owner="([^"]+)"/i.exec(i)?.[1];if(!o)return!0;let l=`data-stx-scope="${o}"`;for(let a=n.indexOf(l);a!==-1;a=n.indexOf(l,a+l.length))if(a>=t&&a<e)return!1;return!0}function za(n){return Le(n)}function tt(n,s){let t=[],e=new Set;for(let i of g(n,U)){if(i.start>=s.start&&i.start<s.end)continue;let o=i.token.match(/^<script\b((?:"[^"]*"|'[^']*'|[^'">])*)>/i)?.[1]??"",l=new Map;for(let p of o.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))l.set(p[1].toLowerCase(),p[2]??p[3]??p[4]??"");let a=l.get("src")?.trim(),u=l.get("type")?.trim().toLowerCase();if(!a||l.has("server")||u&&!["module","text/javascript","application/javascript"].includes(u))continue;if(l.has(en)||l.has("data-stx-runtime")||l.has("data-stx-router")||/^\/_stx\/(?:runtime|router)(?:\.[a-f0-9]{16})?\.js(?:[?#]|$)/i.test(a))continue;if(H(n,i.token,s.start,s.end)||e.has(i.token))continue;e.add(i.token),t.push(i.token)}return t}function $t(n,s="main"){return!!T(n.trim(),s)}function Fe(n,s="main",t=!1){let e=n.trim(),i=[],o=[],l=e.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(l){let y=l[1],C=/<style\b[^>]*>[\s\S]*?<\/style>/gi,d;while((d=C.exec(y))!==null)i.push(d[0]);let k=/<script\b[^>]*data-stx-(?:route-params|server-data|scoped|component-factories)[^>]*>[\s\S]*?<\/script>/gi;while((d=k.exec(y))!==null){if(L.test(d[0])||d[0].includes("__stx_early_mounts")||/^<script\b[^>]*\bdata-stx-before-runtime(?=[\s=>])/i.test(d[0])||/^<script\b[^>]*\bdata-stx-runtime(?=[\s=>])/i.test(d[0]))continue;o.push(d[0])}}let a=T(e,s);if(!a)return(t?Yn(n)+Zn(n):"")+it(n);let u=tt(e,a),p=new Set(u),{tagName:f,start:m,end:x}=a,S=e.slice(m,x).trim(),w=[],R=e.match(/<body\b[^>]*>/i),E=c(e);if(R&&R.index!==void 0&&E!==-1){let C=[[R.index+R[0].length,a.openIndex],[x+`</${f}>`.length,E]],d=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[k,I]of C){if(k>=I)continue;let z=e.slice(k,I),v;d.lastIndex=0;while((v=d.exec(z))!==null){if(H(e,v[0],m,x))continue;w.push(v[0])}}}let h=[];if(t)h.push(Yn(n)+Zn(n));if(i.length>0)h.push(i.join(`
|
|
28
|
+
`));if(u.length>0)h.push(u.join(`
|
|
29
|
+
`));if(o.length>0)h.push(o.filter((y)=>!p.has(y)).join(`
|
|
30
|
+
`));if(w.length>0)h.push(w.filter((y)=>!p.has(y)).join(`
|
|
31
|
+
`));return h.push(S),h.join(`
|
|
32
|
+
`)}import O from"fs";import V from"path";function Ha(n,s,t){return{version:1,buildTime:new Date().toISOString(),routes:n,assets:s,outputDir:t}}function Ua(n,s){let t=V.join(s,"manifest.json");O.writeFileSync(t,JSON.stringify(n,null,2))}function Va(n){let s=V.join(n,"manifest.json");if(!O.existsSync(s))return null;try{let t=O.readFileSync(s,"utf-8"),e=JSON.parse(t);if(e.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${e.version}`),null;return e}catch(t){return console.warn("[stx] Failed to load manifest:",t),null}}function j(n,s,t={}){let e=`${encodeURIComponent(n)}=${encodeURIComponent(s)}`;if(t.maxAge!==void 0)e+=`; Max-Age=${t.maxAge}`;if(t.expires)e+=`; Expires=${t.expires.toUTCString()}`;if(t.path)e+=`; Path=${t.path}`;if(t.domain)e+=`; Domain=${t.domain}`;if(t.secure)e+="; Secure";if(t.httpOnly)e+="; HttpOnly";if(t.sameSite)e+=`; SameSite=${t.sameSite}`;return e}async function et(n){let s=n.headers.get("content-type")||"",t={},e=(i,o)=>{let l=t[i];if(l===void 0)t[i]=o;else if(Array.isArray(l))l.push(o);else t[i]=[l,o]};if(s.includes("multipart/form-data")){let i=await n.formData();for(let[o,l]of i.entries())if(typeof l==="string")e(o,l);return t}if(s.includes("application/x-www-form-urlencoded")){for(let[i,o]of new URLSearchParams(await n.text()).entries())e(i,o);return t}return t}function Vo(n){if(!n)return!1;let s=n.toUpperCase();return s!=="GET"&&s!=="HEAD"}async function q(n,s={}){let t=s.request,e=s.method??t?.method;if(!t||!Vo(e))return{ran:!1};if(typeof n.action!=="function")return{ran:!1};let i={};try{i=await et(t)}catch{}let o=await n.action({request:t,form:i,params:s.params??{},query:n.query??{},cookies:s.cookies??{}});if(o&&typeof o==="object"){let l=o,a=rt(l.cookies),u=l.redirect;if(typeof u==="string"&&u)return{redirect:u,ran:!0,...a.length>0?{cookies:a}:{}};let{cookies:p,redirect:f,...m}=l;if(Object.assign(n,m),a.length>0)return{ran:!0,cookies:a}}return{ran:!0}}function rt(n){if(!n||typeof n!=="object"||Array.isArray(n))return[];let s=[];for(let[t,e]of Object.entries(n)){if(!t)continue;if(typeof e==="string"){s.push(j(t,e));continue}if(e&&typeof e==="object"){let i=e;if(typeof i.value!=="string")continue;s.push(j(t,i.value,i))}}return s}function Wa(n,s=[],t){let e=new Headers({Location:n,"Cache-Control":"no-store"});for(let i of s)e.append("Set-Cookie",i);for(let[i,o]of Object.entries(t??{}))if(i.toLowerCase()!=="location")e.set(i,o);return new Response(null,{status:303,headers:e})}async function Qn(n,s={}){let{html:t,context:e,redirect:i,cookies:o}=await st(n,s),l=Kt(e),a=Xt(e);if(i)return{html:t,redirect:i,cookies:o,status:l,headers:a};let{extractStreamBoundaries:u}=await import("./chunk-r02asm46.js"),p=u(e),f=n.streamTemplates;if(f&&Object.keys(f).length>0){let{processDirectives:m}=await import("./chunk-tsnzhke9.js"),{defaultConfig:x}=await import("./chunk-0bnv0aaz.js"),S=e.streamBoundaries||{},w={...x,autoShell:!1},R=Object.keys(f).map((h)=>({id:h,render:async()=>{let y=typeof S[h]==="function"?await S[h]():void 0;return m(f[h],{...e,$boundary:y},n.sourceFile,w,new Set)}})),E=new Set(R.map((h)=>h.id));p=[...(p||[]).filter((h)=>!E.has(h.id)),...R]}return{html:t,boundaries:p&&p.length>0?p:void 0,cookies:o,status:l,headers:a}}async function st(n,s){let t={__filename:n.sourceFile,__dirname:n.sourceFile.replace(/[/\\][^/\\]+$/,""),...s};if(!n.hasServerScripts&&!Yi(n.html))return{html:n.html,context:t};for(let l of n.serverScriptContent)try{await b(l,t,n.sourceFile)}catch(a){if(s.__stx_strict_hydration)throw a;console.warn(`[stx] Server script error in ${n.sourceFile}:`,a)}let e=await q(t,{request:s.request,method:s.method,params:s.params??{},cookies:s.cookies??{}}),i=(l)=>{let a=l.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),u=Vr(t);if(!u)return a;let p=N(a);return p<0?u+a:a.slice(0,p)+u+a.slice(p)};if(e.redirect)return{html:n.html,context:t,redirect:e.redirect,cookies:e.cookies};if(!Yi(n.html))return{html:i(n.html),context:t,cookies:e.cookies};let o=new Map;for(let[l,a]of Object.entries(n.placeholders))if(a.expression)try{let u=M(a.expression,t);if(a.type==="raw")o.set(l,u!==void 0&&u!==null?String(u):"");else o.set(l,u!==void 0&&u!==null?ee(String(u)):"")}catch(u){if(s.__stx_strict_hydration)throw u;o.set(l,"")}return{html:i(Ll(n.html,o)),context:t,cookies:e.cookies}}
|
|
33
|
+
export{Yn,Zn,Fa,Uo,ms,it,za,$t,Fe,Ha,Ua,Va,Vo,Wa,Qn};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t}from"./chunk-
|
|
2
|
+
import{t}from"./chunk-amnfd29h.js";function y(e,i,s=240){return e.slice(i,i+s)}var v=[{rule:"route-params",pattern:/\blocation\s*\.\s*pathname\s*\.\s*(?:match|split)\s*\(/g,primitive:"useRoute() / useRouteParams() / useRouteParam(name)",why:"parsing the URL by hand re-implements the router and does not update on SPA navigation"},{rule:"alert",pattern:/(?<![.#\w$])(?:(?:window|globalThis)\s*\.\s*)?alert\s*\(/g,primitive:"stxAlert(message)",why:"themed, focus-trapped and non-blocking \u2014 but `await` it if the code after it "+"depended on the native dialog blocking until dismissal",reject:(e)=>/\b(?:async\s+)?function\s+alert\s*\(/.test(e)||/\b(?:const|let|var)\s+alert\s*=/.test(e)},{rule:"search-params",pattern:/new\s+URLSearchParams\s*\(/g,primitive:"useSearchParams()",why:"reactive, and writes back through the router instead of history.replaceState",reject:(e,i)=>{let s=e.indexOf("(",i);if(s===-1)return!0;let o=e.slice(s+1,e.indexOf(")",s)+1);return!/\b(?:location|search|href|url)\b/i.test(o)}},{rule:"navigate",pattern:/\blocation\s*\.\s*(?:assign|replace)\s*\(|\blocation\s*\.\s*href\s*=/g,primitive:"navigate(path) / goBack()",why:"a full document load throws away every store and the scroll position; navigate() is an SPA transition",reject:(e,i)=>/^[^\n]*?(?:['"`]\s*)?(?:mailto:|tel:|sms:|https?:\/\/|\/\/)/.test(y(e,i,160))},{rule:"fetch",pattern:/new\s+AbortController\s*\(/g,primitive:"useFetch(url) / useAsyncData(key, fn)",why:"cancellation, loading and error state are already wired; hand-rolling them is where the races live"},{rule:"polling",pattern:/setInterval\s*\(/g,primitive:"useEventSource() / useSSE() / useWebSocket() / useChannel()",why:"polling burns requests and lags; the push primitives are delivered",reject:(e,i)=>!/\bfetch\s*\(|\$fetch\b|useFetch\b|\.get\s*\(|axios\b/.test(y(e,i))},{rule:"debounce",pattern:/\bclearTimeout\s*\(/g,primitive:"useDebounce(fn, ms) / useThrottle(fn, ms)",why:"a hand-held timer handle per call site is the usual source of stale-result bugs",requires:(e)=>/setTimeout\s*\(/.test(e)},{rule:"click-outside",pattern:/document\s*\.\s*addEventListener\s*\(\s*['"](?:click|mousedown|pointerdown)['"]/g,primitive:"useClickOutside(ref, fn)",why:"the document-level listener plus the blur race is exactly what this composable exists to remove"},{rule:"focus",pattern:/\.\s*(?:getElementById|querySelector)\s*\([^)]*\)\s*(?:\?\.)?\s*\.?focus\s*\(/g,primitive:"useFocus(ref) with x-ref",why:"a query by id breaks under nested scopes and SPA navigation; a ref does not"},{rule:"clipboard",pattern:/navigator\s*\.\s*(?:clipboard|share)\b/g,primitive:"useClipboard() / useShare()",why:"permission state, the copied flag and the unsupported-browser fallback are already handled"},{rule:"watch",pattern:/\beffect\s*\(\s*\(\s*\)\s*=>\s*\{[^}]*\bvoid\s+\w+\s*\(\s*\)/g,primitive:"watch(source, cb) / watchMultiple([...], cb)",why:"the `void a(); void b()` dance is a manual dependency list; watch takes one directly"}],C=["confirm","tooltip",...v.map((e)=>e.rule)];function g(e,i){let s=1;for(let o=0;o<i;o++)if(e[o]===`
|
|
3
3
|
`)s++;return s}function b(e,i){let s=e.lastIndexOf(`
|
|
4
4
|
`,i)+1,o=e.indexOf(`
|
|
5
5
|
`,i);return e.slice(s,o===-1?e.length:o).trim().slice(0,120)}function S(e,i){let s=e.slice(0,i),o=s.lastIndexOf("function"),l=s.lastIndexOf("=>"),r=Math.max(o,l);if(r===-1)return!1;let n=e.slice(Math.max(0,r-120),r);return/\basync\b[^;{}]*$/.test(n)}function k(e){return/\b(?:async\s+)?function\s+confirm\s*\(/.test(e)||/\b(?:const|let|var)\s+confirm\s*=/.test(e)||/\bimport\s*\{[^}]*\bconfirm\b[^}]*\}/.test(e)}function A(e,i,s){if(k(e))return e;let o=/(^|[^\w$.])(?:(?:window|globalThis)\s*\.\s*)?confirm\s*\(/g,l=m(e),r="",n=0,a;while((a=o.exec(l))!==null){let c=a.index+a[1].length,u=g(e,c),d=b(e,c);if(/stxConfirm\s*\($/.test(e.slice(0,c+8)))continue;let p=S(e,c);if(s.push({file:i,line:u,rule:"confirm",applied:p,snippet:d,reason:p?void 0:"stxConfirm() returns a Promise and native confirm() is synchronous, so this needs `await` inside an async function. Rewriting it here would make the condition always true."}),p)r+=e.slice(n,c)+"await stxConfirm(",n=c+(a[0].length-a[1].length)}return r+e.slice(n)}function E(e,i,s){let o=/(<[a-z][\w-]*\b[^>]*?)\stitle=(["'])(.*?)\2/gis,l=R(e),r="",n=0,a;while((a=o.exec(l))!==null){let[c,u,d,p]=a,h=g(e,a.index),f=b(e,a.index),w=u.match(/^<([A-Za-z][\w-]*)/)?.[1]??"";if(/^[A-Z]/.test(w)){s.push({file:i,line:h,rule:"tooltip",applied:!1,snippet:f,reason:`\`title\` on <${w}> is a component prop, not an HTML attribute \u2014 `+"adding x-tooltip here would put a tooltip on a component and may duplicate text it already renders."});continue}if(/\bx-tooltip[=\s]/.test(u)||p.trim()===""){s.push({file:i,line:h,rule:"tooltip",applied:!1,snippet:f,reason:/\bx-tooltip[=\s]/.test(u)?"already has x-tooltip":"empty title"});continue}s.push({file:i,line:h,rule:"tooltip",applied:!0,snippet:f}),r+=e.slice(n,a.index)+`${u} x-tooltip=${d}${p}${d} title=${d}${p}${d}`,n=a.index+c.length}return r+e.slice(n)}function R(e){return e.replace(/<!--[\s\S]*?-->/g,(i)=>i.replace(/[^\n]/g," ")).replace(/\{\{--[\s\S]*?--\}\}/g,(i)=>i.replace(/[^\n]/g," "))}function F(e){let i=(s)=>s.replace(/[^\n]/g," ");return e.replace(/\/\*[\s\S]*?\*\//g,i).replace(/\/\/[^\n]*/g,i)}function m(e,i=!1){let s=R(e);return(i?F(s):t(s)).replace(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,(l,r)=>/\bclient\b/i.test(r)?l:l.replace(/[^\n]/g," "))}function O(e,i,s,o){let l=m(e),r=m(e,!0);for(let n of v){if(!s.includes(n.rule))continue;if(n.requires&&!n.requires(e))continue;n.pattern.lastIndex=0;let a,c=/['"]/.test(n.pattern.source)?r:l;n.pattern.lastIndex=0;while((a=n.pattern.exec(c))!==null){if(n.reject?.(e,a.index))continue;o.push({file:i,line:g(e,a.index),rule:n.rule,applied:!1,snippet:b(e,a.index),reason:`${n.primitive} \u2014 ${n.why}`})}}}function q(e,i={}){let s=i.rules??C,o=i.file??"<source>",l=[];O(e,o,s,l);let r=e;if(s.includes("confirm"))r=A(r,o,l);if(s.includes("tooltip"))r=E(r,o,l);l.sort((c,u)=>c.line-u.line);let n=new Set,a=l.filter((c)=>{let u=`${c.rule}:${c.line}`;if(n.has(u))return!1;return n.add(u),!0});return{code:r,findings:a}}var x=new Set(["confirm","tooltip"]);function I(e,i){if(e.length===0)return"No hand-rolled equivalents found.";let s=e.filter((n)=>n.applied),o=e.filter((n)=>!n.applied&&x.has(n.rule)),l=e.filter((n)=>!n.applied&&!x.has(n.rule)),r=[];if(s.length>0){r.push(i?`Rewrote ${s.length} site(s):`:`Would rewrite ${s.length} site(s) (pass --fix):`);for(let n of s)r.push(` ${n.file}:${n.line} [${n.rule}] ${n.snippet}`)}if(o.length>0){r.push("",`Needs a human \u2014 ${o.length} site(s):`);for(let n of o)r.push(` ${n.file}:${n.line} [${n.rule}] ${n.snippet}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{aa,Wy,qy,Kl,rt,cm,_o,Ky,Xy,Gy,Jy,Yy,Zy,Qy,eb,tb}from"./chunk-r7zvrh58.js";import"./chunk-a78k8fkg.js";export{Zy as applyHead,Ky as definePageMeta,aa as getHead,Wy as getPageMeta,rt as mergeHeadConfigs,Qy as processHeadDirective,tb as processMetaDirective,eb as processTitleDirective,Yy as renderBodyAttrs,Gy as renderHead,Jy as renderHtmlAttrs,qy as resetHead,_o as seoMetaToHeadConfig,Kl as useHead,Xy as usePageTitle,cm as useSeoMeta,Xy as useTitle};
|