@stacksjs/stx 0.2.855 → 0.2.858
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-0ts3p84y.js +2 -0
- package/dist/{chunk-zme05d1n.js → chunk-0vptj943.js} +2 -2
- package/dist/{chunk-0dmpc70r.js → chunk-0z2gqttt.js} +16 -16
- package/dist/{chunk-1qybwj8k.js → chunk-1347hwt5.js} +15 -15
- package/dist/chunk-139mxsyc.js +2 -0
- package/dist/chunk-1barsha6.js +2 -0
- package/dist/chunk-1fnx7ze9.js +2 -0
- package/dist/chunk-1g06wfs9.js +2 -0
- package/dist/{chunk-w032x0zm.js → chunk-1nankvf6.js} +2 -2
- package/dist/chunk-1nasq00e.js +2 -0
- package/dist/{chunk-csgfws3j.js → chunk-1z2am28h.js} +2 -2
- package/dist/chunk-2102tvxh.js +2 -0
- package/dist/{chunk-yzvp90yk.js → chunk-252enthj.js} +2 -2
- package/dist/{chunk-2j2qzv8g.js → chunk-27zp4q77.js} +2 -2
- package/dist/{chunk-77kanny8.js → chunk-2bks42z4.js} +9 -9
- package/dist/chunk-39cwa35j.js +2 -0
- package/dist/{chunk-fj5jw2jd.js → chunk-3b7q7d7j.js} +6 -6
- package/dist/{chunk-9z7fnv33.js → chunk-3evwxrpx.js} +1 -1
- package/dist/chunk-3rcegvgg.js +2 -0
- package/dist/chunk-3wvq28hz.js +2 -0
- package/dist/{chunk-68pvvd7v.js → chunk-3zjyhhg4.js} +3 -3
- package/dist/{chunk-mhjxx64x.js → chunk-4ezfen91.js} +25 -25
- package/dist/{chunk-a2fngjfx.js → chunk-4h9kkkh7.js} +1 -1
- package/dist/{chunk-gxqtbbz0.js → chunk-5xy1z71a.js} +5 -5
- package/dist/{chunk-63rvsnt2.js → chunk-69zj9q02.js} +3 -3
- package/dist/chunk-6d74qdc6.js +2 -0
- package/dist/chunk-6m4v1tsq.js +2 -0
- package/dist/{chunk-9hvfmqs1.js → chunk-6qbha6fb.js} +9 -9
- package/dist/{chunk-q0jmc3m4.js → chunk-71s4hpkj.js} +9 -9
- package/dist/chunk-75e4wzzs.js +3 -0
- package/dist/{chunk-11y3106w.js → chunk-78amng8s.js} +5 -5
- package/dist/chunk-7ambc4f7.js +2 -0
- package/dist/{chunk-ngnvyqk3.js → chunk-7fgfzaah.js} +2 -2
- package/dist/{chunk-4wrddn8m.js → chunk-8623gte8.js} +9 -9
- package/dist/{chunk-mpmnbvy4.js → chunk-8cpqcn19.js} +5 -5
- package/dist/chunk-8nmc3rh7.js +2 -0
- package/dist/chunk-8pn7ah12.js +2 -0
- package/dist/chunk-8zwwmnpb.js +2 -0
- package/dist/chunk-98bgx3ws.js +2 -0
- package/dist/{chunk-car6nhfe.js → chunk-9n8t7v78.js} +2 -2
- package/dist/chunk-a4v8z93r.js +2 -0
- package/dist/chunk-a58w524e.js +2 -0
- package/dist/chunk-a6v6x2pg.js +2 -0
- package/dist/{chunk-krtkxnz6.js → chunk-admnvsmx.js} +2 -2
- package/dist/{chunk-hgy98n76.js → chunk-afrqm7w5.js} +4 -4
- package/dist/{chunk-t3a3wbjk.js → chunk-az9b4bj4.js} +2 -2
- package/dist/chunk-b62mr2kz.js +2 -0
- package/dist/chunk-b7vxb2y6.js +2 -0
- package/dist/chunk-bb20hnqd.js +2 -0
- package/dist/chunk-bc3sknxf.js +2 -0
- package/dist/{chunk-fphnst8a.js → chunk-bef0wr53.js} +5 -5
- package/dist/{chunk-cy60hmv2.js → chunk-bhzh7mj1.js} +1 -1
- package/dist/{chunk-jn6mdfrs.js → chunk-bxn4b0wm.js} +2 -2
- package/dist/{chunk-yscys65t.js → chunk-c7eew8qs.js} +1 -1
- package/dist/chunk-cbrbrkp1.js +2 -0
- package/dist/{chunk-fba71th7.js → chunk-cqkr291c.js} +7 -7
- package/dist/{chunk-mmdqdkbd.js → chunk-d6am6en8.js} +1 -1
- package/dist/chunk-d8djpp7f.js +2 -0
- package/dist/chunk-dk6t4h48.js +2 -0
- package/dist/chunk-dkbm7117.js +2 -0
- package/dist/chunk-e44bse67.js +2 -0
- package/dist/{chunk-kvafq9gy.js → chunk-e763qsg0.js} +2 -2
- package/dist/{chunk-pm241ehv.js → chunk-e7thwrt5.js} +2 -2
- package/dist/{chunk-wzv7k91a.js → chunk-e8we717q.js} +2 -2
- package/dist/{chunk-q0ycypnt.js → chunk-eazccp6e.js} +2 -2
- package/dist/{chunk-zqb294v2.js → chunk-egwtv5hp.js} +3 -3
- package/dist/chunk-ewnfgczq.js +2 -0
- package/dist/chunk-f1v5hvbt.js +2 -0
- package/dist/{chunk-anva219c.js → chunk-f1vvhbmw.js} +2 -2
- package/dist/{chunk-pwem4sed.js → chunk-fbnykfnv.js} +4 -4
- package/dist/{chunk-0vg0j7xa.js → chunk-fd7e162p.js} +3 -3
- package/dist/{chunk-fhrvxfq9.js → chunk-ff3j7jnf.js} +2 -2
- package/dist/{chunk-j2wcawmf.js → chunk-fw50vydb.js} +2 -2
- package/dist/{chunk-te82sjhy.js → chunk-fxk1psd8.js} +31 -31
- package/dist/chunk-g6epqcb3.js +2 -0
- package/dist/{chunk-9n3584wt.js → chunk-g8d24rfk.js} +2 -2
- package/dist/{chunk-ya6f7mt5.js → chunk-gjbnzn7k.js} +4 -4
- package/dist/chunk-gmvypdm8.js +2 -0
- package/dist/{chunk-4dfz7cdr.js → chunk-gz0j98dy.js} +5 -5
- package/dist/{chunk-csksn1kg.js → chunk-hjh5wt5f.js} +2 -2
- package/dist/chunk-hmgry6dn.js +2 -0
- package/dist/{chunk-s37af6rd.js → chunk-jafn7f7f.js} +2 -2
- package/dist/chunk-jbv1srnh.js +2 -0
- package/dist/{chunk-mv48q1p4.js → chunk-jdqmk5sv.js} +75 -75
- package/dist/{chunk-d4gy4yz0.js → chunk-jgvwzt1t.js} +2 -2
- package/dist/chunk-jhm1228j.js +4 -0
- package/dist/{chunk-k0arm18k.js → chunk-jtag68hg.js} +2 -2
- package/dist/chunk-jwtp4csj.js +20 -0
- package/dist/{chunk-9r999ees.js → chunk-jwwsxym6.js} +2 -2
- package/dist/chunk-jzynkjfc.js +2 -0
- package/dist/{chunk-n77xrpv9.js → chunk-k19ba3jz.js} +2 -2
- package/dist/chunk-k1qajhpx.js +2 -0
- package/dist/{chunk-tm8a2b69.js → chunk-kedgfk9z.js} +4 -4
- package/dist/{chunk-f9thwm8c.js → chunk-kq3h2rjq.js} +9 -9
- package/dist/chunk-ksxbfyef.js +3 -0
- package/dist/chunk-m28j4ym7.js +2 -0
- package/dist/{chunk-4nhbbcr9.js → chunk-m2rm2gxv.js} +5 -5
- package/dist/{chunk-v8p8t3t4.js → chunk-me16tftr.js} +1 -1
- package/dist/{chunk-bkefg64w.js → chunk-mh45hcsa.js} +5 -5
- package/dist/{chunk-279n7sde.js → chunk-mxazxwc4.js} +4 -4
- package/dist/chunk-mzembfxk.js +2 -0
- package/dist/{chunk-hpwtjb4a.js → chunk-mzes9ds7.js} +2 -2
- package/dist/{chunk-ynd2nfvs.js → chunk-mzg1wq86.js} +27 -27
- package/dist/chunk-ngzjwp2e.js +2 -0
- package/dist/chunk-nj9n0en9.js +2 -0
- package/dist/{chunk-w835crjw.js → chunk-nv5xhfwz.js} +2 -2
- package/dist/chunk-nyasqjnt.js +2 -0
- package/dist/{chunk-vw73gsxx.js → chunk-pa8xkctc.js} +7 -7
- package/dist/{chunk-ybq56wam.js → chunk-pb09xy77.js} +2 -2
- package/dist/chunk-pn0rmd8d.js +2 -0
- package/dist/chunk-pvx1hrqq.js +2 -0
- package/dist/chunk-q78dsejp.js +2 -0
- package/dist/chunk-q87hkwfg.js +3 -0
- package/dist/{chunk-fzkyk5j4.js → chunk-q93jcdgj.js} +8 -8
- package/dist/chunk-qe6631me.js +2 -0
- package/dist/{chunk-e8zpzt9s.js → chunk-qv52et0d.js} +1 -1
- package/dist/{chunk-4cd94cd5.js → chunk-qvwzaxdd.js} +5 -5
- package/dist/chunk-qw1f97s7.js +2 -0
- package/dist/chunk-rcn0yyh2.js +2 -0
- package/dist/{chunk-xfb7fdeq.js → chunk-rq9pqd4s.js} +10 -10
- package/dist/{chunk-7hp50cpd.js → chunk-s322kcw7.js} +6 -6
- package/dist/chunk-shy2hkvj.js +2 -0
- package/dist/{chunk-w7p34cr3.js → chunk-smve11g0.js} +1 -1
- package/dist/{chunk-7kc9xwht.js → chunk-snmq7yn4.js} +4 -4
- package/dist/{chunk-v4bqmzj9.js → chunk-sny8rqe8.js} +2 -2
- package/dist/chunk-t9h3e3bp.js +2 -0
- package/dist/{chunk-ctb1bj28.js → chunk-tjer45j7.js} +3 -3
- package/dist/{chunk-qxk9grjm.js → chunk-tk67pqaf.js} +3 -3
- package/dist/{chunk-h1f3dpvq.js → chunk-tpw435g0.js} +2 -2
- package/dist/chunk-ts9bvjzh.js +2 -0
- package/dist/chunk-tzvgjrp4.js +2 -0
- package/dist/{chunk-7tteg9bn.js → chunk-v8b1wz1b.js} +1 -1
- package/dist/{chunk-ma4ftg5p.js → chunk-va1hj69e.js} +5 -5
- package/dist/{chunk-r69en2jg.js → chunk-w7s3afam.js} +1 -1
- package/dist/chunk-w9aa8xte.js +2 -0
- package/dist/{chunk-zswtgwxg.js → chunk-wd4z5w4d.js} +1 -1
- package/dist/chunk-wegkgjmf.js +2 -0
- package/dist/chunk-wn065q3f.js +2 -0
- package/dist/{chunk-fbpqkrvb.js → chunk-wskdnfh9.js} +6 -6
- package/dist/{chunk-jr346anv.js → chunk-xhvw0t0f.js} +2 -2
- package/dist/{chunk-xn2gyhes.js → chunk-xz1csyq9.js} +10 -10
- package/dist/chunk-y2dtqrrz.js +2 -0
- package/dist/{chunk-2rxr5cj6.js → chunk-y67r0d0c.js} +9 -9
- package/dist/chunk-yss7n9db.js +2 -0
- package/dist/chunk-z6p0yxwd.js +2 -0
- package/dist/{chunk-5erremft.js → chunk-z703xzhy.js} +2 -2
- package/dist/chunk-zcpwc47w.js +2 -0
- package/dist/{chunk-33ph9zb2.js → chunk-zn9dp7yn.js} +5 -5
- package/dist/chunk-zsmrq1w3.js +2 -0
- package/dist/cli.js +18 -18
- package/dist/client-script-bundler.d.ts +21 -0
- package/dist/client-script-bundler.js +14 -0
- package/dist/component-client-factories.js +6 -5
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +8 -8
- package/dist/utils.js +3 -2
- package/package.json +5 -5
- package/dist/chunk-05f4tjsq.js +0 -2
- package/dist/chunk-0xwmweqm.js +0 -2
- package/dist/chunk-161ksm7f.js +0 -2
- package/dist/chunk-1p968nww.js +0 -2
- package/dist/chunk-2y20dvab.js +0 -2
- package/dist/chunk-33yeb861.js +0 -2
- package/dist/chunk-3pm6d9zj.js +0 -2
- package/dist/chunk-3wt0nh3p.js +0 -2
- package/dist/chunk-463zkecq.js +0 -2
- package/dist/chunk-5758n8sm.js +0 -2
- package/dist/chunk-5dykcrnv.js +0 -2
- package/dist/chunk-5ppe8d51.js +0 -2
- package/dist/chunk-5xcxc9f8.js +0 -2
- package/dist/chunk-6bm19d4k.js +0 -2
- package/dist/chunk-6w3gv9d6.js +0 -2
- package/dist/chunk-81z64a84.js +0 -2
- package/dist/chunk-8gsd2n0j.js +0 -2
- package/dist/chunk-8kqqxqyp.js +0 -2
- package/dist/chunk-8qe34jb8.js +0 -3
- package/dist/chunk-bk0arddt.js +0 -2
- package/dist/chunk-bz4bskx3.js +0 -2
- package/dist/chunk-c557w9e6.js +0 -2
- package/dist/chunk-cfmjtyzm.js +0 -2
- package/dist/chunk-ck9zengd.js +0 -2
- package/dist/chunk-cwt26rvt.js +0 -3
- package/dist/chunk-dbag44ta.js +0 -2
- package/dist/chunk-dee5mtdv.js +0 -2
- package/dist/chunk-dfcnaaym.js +0 -2
- package/dist/chunk-dm10y06z.js +0 -2
- package/dist/chunk-dw9vnhc4.js +0 -2
- package/dist/chunk-eegs2at0.js +0 -2
- package/dist/chunk-ehp792dy.js +0 -3
- package/dist/chunk-enxnw50k.js +0 -2
- package/dist/chunk-f858fazq.js +0 -2
- package/dist/chunk-fsg958xx.js +0 -2
- package/dist/chunk-ggthncvg.js +0 -2
- package/dist/chunk-gn1dmfdv.js +0 -2
- package/dist/chunk-gsn5vvw4.js +0 -2
- package/dist/chunk-hfcagm39.js +0 -2
- package/dist/chunk-hfe2byfx.js +0 -2
- package/dist/chunk-hmys6w75.js +0 -2
- package/dist/chunk-hqtj4ngq.js +0 -2
- package/dist/chunk-j3s5y2k5.js +0 -2
- package/dist/chunk-kez50h8a.js +0 -2
- package/dist/chunk-kfq4mwem.js +0 -2
- package/dist/chunk-knd3m4t4.js +0 -2
- package/dist/chunk-m3kc2a3v.js +0 -2
- package/dist/chunk-mjp2sp74.js +0 -2
- package/dist/chunk-mx79sfyr.js +0 -2
- package/dist/chunk-n6w82yf2.js +0 -2
- package/dist/chunk-ns5epsng.js +0 -2
- package/dist/chunk-p91288ce.js +0 -2
- package/dist/chunk-pesgcwrj.js +0 -20
- package/dist/chunk-pw6n7a9k.js +0 -2
- package/dist/chunk-q1z8edtn.js +0 -2
- package/dist/chunk-qccpfn5x.js +0 -2
- package/dist/chunk-syww37qd.js +0 -2
- package/dist/chunk-vbsr76qe.js +0 -2
- package/dist/chunk-vgaqznwt.js +0 -2
- package/dist/chunk-vw9h1x2m.js +0 -2
- package/dist/chunk-w165qe5q.js +0 -2
- package/dist/chunk-wz54wsm7.js +0 -2
- package/dist/chunk-x2vybq9n.js +0 -2
- package/dist/chunk-x4077p94.js +0 -2
- package/dist/chunk-z0qfspzg.js +0 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ni,my,hy,bl,We,Ig,to,yy,by,wy,vy,xy,Sy,ky,_y,Cy}from"./chunk-0z2gqttt.js";export{Sy as applyHead,yy as definePageMeta,Ni as getHead,my as getPageMeta,We as mergeHeadConfigs,ky as processHeadDirective,Cy as processMetaDirective,_y as processTitleDirective,xy as renderBodyAttrs,wy as renderHead,vy as renderHtmlAttrs,hy as resetHead,to as seoMetaToHeadConfig,bl as useHead,by as usePageTitle,Ig as useSeoMeta,by as useTitle};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{a}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{a}from"./chunk-1347hwt5.js";import{xo}from"./chunk-12r22pf0.js";import p from"path";async function om(t={}){let l=performance.now(),s=t.root||process.cwd(),e=await a(s),o=t.ssr?.routeRules??e.routeRules??{};if(xo(o),!e.ssr&&Object.keys(o).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let u,n;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");u=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-a58w524e.js");n=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let d=Math.round(performance.now()-l);return{mode:r,ssg:u,ssr:n,duration:d}}
|
|
3
|
+
export{om};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{G}from"./chunk-ym5qgw03.js";import
|
|
2
|
+
import{G}from"./chunk-ym5qgw03.js";import Ve from"path";var t={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 Q(e){for(let[n,r]of Object.entries(t))if(r===e)return n;return}import yt from"path";var bt={showRelativePaths:!1,enableAutoRecovery:G(),logRecoveryWarnings:!0},te={...bt};function F(){return{...te}}function j(e){if(!te.showRelativePaths||!e)return e;let n=te.baseDir||process.cwd();try{let r=yt.relative(n,e);return r.startsWith("..")?e:r}catch{return e}}class N extends Error{code;filePath;line;column;context;numericCode;constructor(e,n,r,i,s,o,a){super(e);this.code=n;this.filePath=r;this.line=i;this.column=s;this.context=o;if(this.name="StxError",this.numericCode=a||t.EVALUATION_ERROR,this.filePath)this.filePath=j(this.filePath)}}class ee extends N{constructor(e,n,r,i,s,o){super(e,"stx_RUNTIME_ERROR",n,r,i,s,o||t.EVALUATION_ERROR);this.name="StxRuntimeError"}}class Ar extends N{constructor(e,n,r,i,s,o){super(e,"stx_FILE_ERROR",n,r,i,s,o||t.FILE_NOT_FOUND);this.name="StxFileError"}}class K extends N{isFatal=!0;constructor(e,n,r,i,s,o){super(e,"stx_VALIDATION_ERROR",n,r,i,s,o||t.DOM_API_VIOLATION);this.name="StxValidationError"}}function ve(e){let{type:n,message:r,code:i,filePath:s,line:o,column:a,template:c,offset:p,snippet:g,suggestion:h,format:m="text"}=e,y=o,E=a;if(!y&&c&&p!==void 0){let Z=kt(c,p);y=Z.line,E=Z.column}let v=s?j(s):void 0,w=i?Q(i):void 0,T={type:n,code:i,codeName:w,message:r,filePath:v,line:y,column:E,snippet:g,suggestion:h,timestamp:new Date().toISOString()},A;switch(m){case"html":A=xt(T);break;case"json":A=JSON.stringify(T,null,2);break;case"console":A=wt(T,c,p);break;case"text":default:A=Et(T,c,p);break}return{formatted:A,data:T}}function Et(e,n,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}`),n&&e.line){let o=vt(n,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(`
|
|
6
|
-
Suggestion: ${e.suggestion}`);return i.join(" ")}function xt(e){let n=e.code?` [${e.code}]`:"",r=e.filePath?` in ${e.filePath}${e.line?`:${e.line}`:""}`:"",i=`<!-- [${e.type} Error${n}]${r}: ${
|
|
6
|
+
Suggestion: ${e.suggestion}`);return i.join(" ")}function xt(e){let n=e.code?` [${e.code}]`:"",r=e.filePath?` in ${e.filePath}${e.line?`:${e.line}`:""}`:"",i=`<!-- [${e.type} Error${n}]${r}: ${we(e.message)}`;if(e.suggestion)i+=` | Suggestion: ${we(e.suggestion)}`;return i+=" -->",i}function wt(e,n,r){let g=[],h=e.code?` [${e.codeName||e.code}]`:"";if(g.push(`\x1B[1m${"\x1B[31m"}\u2501\u2501\u2501 ${e.type} Error${h} \u2501\u2501\u2501${"\x1B[0m"}`),e.filePath){let m=`\x1B[36m${e.filePath}\x1B[0m`;if(e.line){if(m+=`\x1B[90m:${e.line}\x1B[0m`,e.column)m+=`\x1B[90m:${e.column}\x1B[0m`}g.push(`
|
|
7
7
|
\x1B[90mat\x1B[0m ${m}`)}if(g.push(`
|
|
8
8
|
|
|
9
9
|
${e.message}`),n&&e.line){let m=St(n,e.line,2);if(m)g.push(`
|
|
@@ -16,8 +16,8 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
16
16
|
`),s=Math.max(0,n-r-1),o=Math.min(i.length-1,n+r-1),a=[];for(let c=s;c<=o;c++){let p=(c+1).toString().padStart(4),g=c===n-1?">":" ";a.push(`${g}${p} | ${i[c]}`)}return a.join(`
|
|
17
17
|
`)}function St(e,n,r){let i=e.split(`
|
|
18
18
|
`),s=Math.max(0,n-r-1),o=Math.min(i.length-1,n+r-1),a="\x1B[90m",c="\x1B[31m",p="\x1B[0m",g=[];for(let h=s;h<=o;h++){let m=(h+1).toString().padStart(4),y=h===n-1,E=y?"\x1B[31m>\x1B[0m":" ",v=y?`\x1B[31m${i[h]}\x1B[0m`:`\x1B[90m${i[h]}\x1B[0m`;g.push(`${E}\x1B[90m${m}\x1B[0m | ${v}`)}return g.join(`
|
|
19
|
-
`)}function
|
|
20
|
-
`);return{line:i.length,column:i[i.length-1].length}}function l(e,n,r){return
|
|
19
|
+
`)}function we(e){return e.replace(/--/g,"- -").replace(/>/g,">")}function kt(e,n){let i=e.substring(0,n).split(`
|
|
20
|
+
`);return{line:i.length,column:i[i.length-1].length}}function l(e,n,r){return ve({type:e,message:n,code:r,format:"html"}).formatted}async function Ce(e,n,r){try{return await e()}catch(i){if(r&&i instanceof Error)r(i);return n}}var Ai={isEnabled(){return F().enableAutoRecovery},fixCommonSyntaxErrors(e){let n=F();if(!n.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 p=(r.match(new RegExp(`@${c}\\b`,"g"))||[]).length,g=(r.match(new RegExp(`@end${c}\\b`,"g"))||[]).length;if(p>g){let h=p-g;for(let m=0;m<h;m++)r+=`
|
|
21
21
|
@end${c}`;i.push(`Added ${h} missing @end${c}`)}}if(i.length>0&&n.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,n){if(G())return`<!-- ${e} failed: ${n.message} -->`;return"<!-- stx rendering error -->"}};class ne{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,n,r="error"){let i={timestamp:new Date,error:e,context:n,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 n=[`[${e.timestamp.toISOString()}] [${(e.level||"error").toUpperCase()}] ${e.error.constructor.name}: ${e.error.message}`];if(e.error.stack)n.push(` Stack: ${e.error.stack.split(`
|
|
22
22
|
`).slice(1).join(`
|
|
23
23
|
`)}`);if(e.context)n.push(` Context: ${JSON.stringify(e.context)}`);return n.join(`
|
|
@@ -25,7 +25,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
25
25
|
`;n.appendFileSync(this.logFilePath,s,"utf-8")}catch(n){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",n)}})}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(n){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",n)}}getRecentErrors(e=10){return this.errors.slice(-e)}getErrorsByType(e){return this.errors.filter((n)=>n.error.constructor.name===e)}getErrorsByLevel(e){return this.errors.filter((n)=>n.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={},n={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";n[s]=(n[s]||0)+1}return{total:this.errors.length,byType:e,byLevel:n}}async exportToFile(e,n="json"){let r=await import("fs"),i=await import("path"),s=i.dirname(e);if(!r.existsSync(s))r.mkdirSync(s,{recursive:!0});if(n==="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
27
|
`),"utf-8")}}async flush(){await this.writeQueue}}var z=new ne,En={isDevelopment(){return G()},logDetailedError(e,n){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",e.message),console.error("Stack:",e.stack),n)console.error("Context:",n);console.error("========================")},createErrorReport(e,n){let r=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${e.message}`,`Type: ${e.constructor.name}`,`Stack: ${e.stack}`];if(n)r.push(`Context: ${JSON.stringify(n,null,2)}`);return r.push("========================"),r.join(`
|
|
28
|
-
`)}};function x(e,n,r,i=0){let s=0,o=i,a=null,c=0,p=!1;while(o<e.length){let g=e[o];if(a&&p){p=!1,o++;continue}if(a&&g==="\\"){p=!0,o++;continue}if(p=!1,(g==='"'||g==="'"||g==="`")&&!a){a=g,o++;continue}if(g===a&&a!=="`"){a=null,o++;continue}if(a==="`"&&g==="$"&&e[o+1]==="{"){c++,o+=2;continue}if(c>0&&g==="}"){c--,o++;continue}if(g==="`"&&a==="`"&&c===0){a=null,o++;continue}if(a){o++;continue}if(g===n)s++;else if(g===r){if(s--,s===0)return o}o++}return-1}function
|
|
28
|
+
`)}};function x(e,n,r,i=0){let s=0,o=i,a=null,c=0,p=!1;while(o<e.length){let g=e[o];if(a&&p){p=!1,o++;continue}if(a&&g==="\\"){p=!0,o++;continue}if(p=!1,(g==='"'||g==="'"||g==="`")&&!a){a=g,o++;continue}if(g===a&&a!=="`"){a=null,o++;continue}if(a==="`"&&g==="$"&&e[o+1]==="{"){c++,o+=2;continue}if(c>0&&g==="}"){c--,o++;continue}if(g==="`"&&a==="`"&&c===0){a=null,o++;continue}if(a){o++;continue}if(g===n)s++;else if(g===r){if(s--,s===0)return o}o++}return-1}function pl(e,n){let r=n,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(n,r),endPos:r}}class R{cache=new Map;maxSize;options;sizes;bytes=0;constructor(e=100,n){this.maxSize=e,this.options=n??null,this.sizes=n?new Map:null}get byteSize(){return this.bytes}setMaxBytes(e){if(!this.options)return;this.options={...this.options,maxBytes:e};while(this.bytes>e&&this.cache.size>0){let n=this.cache.keys().next().value;if(n===void 0)break;this.delete(n)}}get(e){if(!this.cache.has(e))return;let n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}set(e,n){if(this.cache.has(e))this.delete(e);let r=this.options?this.options.sizeOf(n):0;if(this.options&&r>this.options.maxBytes)return;while(this.cache.size>0&&(this.cache.size>=this.maxSize||this.options!==null&&this.bytes+r>this.options.maxBytes)){let i=this.cache.keys().next().value;if(i===void 0)break;this.delete(i)}if(this.cache.set(e,n),this.sizes)this.sizes.set(e,r),this.bytes+=r}has(e){return this.cache.has(e)}delete(e){if(this.sizes){let n=this.sizes.get(e);if(n!==void 0)this.bytes-=n,this.sizes.delete(e)}return this.cache.delete(e)}clear(){this.cache.clear(),this.sizes?.clear(),this.bytes=0}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}var M=new Map,Tt=500;function Ft(e,n){if(n?.includes("g"))return new RegExp(e,n);let r=`${e}:${n||""}`;if(!M.has(r)){if(M.size>=Tt){let i=M.keys().next().value;if(i)M.delete(i)}M.set(r,new RegExp(e,n))}return M.get(r)}class ke{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator(e){let n=Array.from(new Set(e)),r=n.sort().join(","),i=this.pool.find((c)=>c.context.join(",")===r);if(i)return i.func;let s=this.fnCache,o=this.fnCacheMaxSize,a=(...c)=>(p)=>{try{let g=`${r}:${p}`,h=s.get(g);if(!h){if(s.size>=o){let m=s.keys().next().value;if(m)s.delete(m)}h=Function(...n,`
|
|
29
29
|
'use strict';
|
|
30
30
|
try {
|
|
31
31
|
return ${p};
|
|
@@ -36,7 +36,7 @@ catch (e) {
|
|
|
36
36
|
}
|
|
37
37
|
throw e;
|
|
38
38
|
}
|
|
39
|
-
`),s.set(g,h)}return h(...c)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:a,context:n.slice()});return a}clear(){this.pool.length=0,this.fnCache.clear()}}var or=new Se;class ke{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(e){this.enabled=e}isEnabled(){return this.enabled}setBudget(e,n){this.budgets.set(e,{warnThreshold:0.8,action:"warn",...n})}setBudgets(e){for(let[n,r]of Object.entries(e))this.setBudget(n,r)}removeBudget(e){this.budgets.delete(e)}getBudgets(){let e={};for(let[n,r]of this.budgets.entries())e[n]=r;return e}onViolation(e){this.violationHandlers.push(e)}offViolation(e){let n=this.violationHandlers.indexOf(e);if(n!==-1)this.violationHandlers.splice(n,1)}time(e,n){if(!this.enabled)return n();let r=performance.now(),i=n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),i}async timeAsync(e,n){if(!this.enabled)return n();let r=performance.now(),i=await n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),i}checkBudget(e,n){let r=this.budgets.get(e);if(!r)return;let i=n/r.maxTime*100,s=r.warnThreshold!==void 0?n>=r.maxTime*r.warnThreshold&&n<r.maxTime:!1,o=n>=r.maxTime;if(!s&&!o)return;let a={label:e,actualTime:n,budgetTime:r.maxTime,exceedancePercent:i,timestamp:new Date,isWarning:s};this.violations.push(a);while(this.violations.length>this.maxViolations)this.violations.shift();for(let p of this.violationHandlers)try{p(a)}catch{}let c=s?`[Performance Warning] "${e}" took ${n.toFixed(2)}ms (${i.toFixed(1)}% of ${r.maxTime}ms budget)`:`[Performance Budget Exceeded] "${e}" took ${n.toFixed(2)}ms (exceeded ${r.maxTime}ms budget by ${(i-100).toFixed(1)}%)`;switch(r.action){case"log":console.log(c);break;case"warn":console.warn(c);break;case"error":console.error(c);break;case"throw":if(o)throw Error(c);else console.warn(c);break}}recordTime(e,n){let r=this.metrics.get(e);if(r)r.count++,r.totalTime+=n,r.maxTime=Math.max(r.maxTime,n),r.minTime=Math.min(r.minTime,n);else this.metrics.set(e,{count:1,totalTime:n,maxTime:n,minTime:n})}getStats(e){if(e){let r=this.metrics.get(e);if(!r)return{};let i=this.budgets.get(e);return{count:r.count,avgTime:r.totalTime/r.count,totalTime:r.totalTime,maxTime:r.maxTime,minTime:r.minTime,budget:i?.maxTime,budgetUtilization:i?r.totalTime/r.count/i.maxTime*100:void 0}}let n={};for(let[r,i]of this.metrics.entries()){let s=this.budgets.get(r);n[r]={count:i.count,avgTime:i.totalTime/i.count,totalTime:i.totalTime,maxTime:i.maxTime,minTime:i.minTime,budget:s?.maxTime,budgetUtilization:s?i.totalTime/i.count/s.maxTime*100:void 0}}return n}getViolations(e){if(e)return this.violations.filter((n)=>n.label===e);return[...this.violations]}getViolationStats(){let e={},n=0,r=0;for(let i of this.violations)if(e[i.label]=(e[i.label]||0)+1,i.isWarning)n++;else r++;return{total:this.violations.length,byLabel:e,warnings:n,errors:r}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var re=null;function Rt(){if(!re)re=new ke;return re}var ce=new Proxy({},{get(e,n){return Rt()[n]}});var ve=0;async function _(){if(performance.now()-ve<16)return;await new Promise((e)=>setTimeout(e,0)),ve=performance.now()}var $t={maxSanitizeDepth:10,allowBracketNotation:!1},Le={...$t};var U=/\bnew\s+/,V="__stx_safe_ctors",Me=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],ie=[...Me,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],Te=ie.map(()=>{return}),se=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})),ae=[/\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*\(/,U,/\bdelete\s+/,/\bthis\b/,/\\u(?:\{[\dA-Fa-f]+\}|[\dA-Fa-f]{4})/],le=new Set([...Me,"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",V]),ue=new Set(["__proto__","constructor","prototype"]);function Ne(e){let n="",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)n+=e[o],r.push(o),o++}continue}if(a===i)i=null;continue}if(a==='"'||a==="'"||a==="`"){i=a;continue}n+=a,r.push(o)}return{text:n,map:r}}function De(e){return Ne(e).text}var Fe=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],ze=(()=>{let e={Date,URL,URLSearchParams},n=Intl;for(let r of Fe)if(typeof n[r]==="function")e[`Intl_${r}`]=n[r];return Object.freeze(Object.assign(Object.create(null),e))})(),Ct=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,Re=/(?<![\w$])new(?![\w$])/g,$e=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Fe.join(",")}}() are allowed`;function At(e){let{text:n,map:r}=Ne(e),i=[];Re.lastIndex=0;let s;while((s=Re.exec(n))!==null){let a=s.index;if(/(?<!\.)\.\s*$/.test(n.slice(0,a)))continue;let c=Ct.exec(n.slice(a)),p=c?.[3],g=!c?null:p?`Intl_${p}`:c[2];if(!c||!g||!(g in ze))throw new S(`matched /${U.source}/; ${$e}`,e);let h=a+c[0].length,m=r[a],y=r[h-1]+1;if(e.slice(m,y)!==n.slice(a,h))throw new S(`matched /${U.source}/; ${$e}`,e);let E=m+3+c[1].length;i.push({start:E,end:E+c[2].length,key:g})}let o=e;for(let a=i.length-1;a>=0;a--){let c=i[a];o=`${o.slice(0,c.start)}${V}.${c.key}${o.slice(c.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class S extends Error{rule;expression;constructor(e,n,r){super(r??`Potentially unsafe expression (${e}): ${n}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=n}}function Js(e){try{return ge(e),null}catch(n){return n instanceof S?n.rule:n instanceof Error?n.message:String(n)}}function je(e,n){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(le.has(s))throw new S(`matched /\\b${s}\\b/; identifier ${s}`,n);if(o==="."&&ue.has(s))throw new S(`matched /.${s}/; property ${s}`,n)}}function Be(e,n=!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(),p=/^'(?:[^'\\]|\\.)*'$/.test(c),g=/^"(?:[^"\\]|\\.)*"$/.test(c);if(/^\d+$/.test(c))continue;if(p||g){let m=c.slice(1,-1);if(ue.has(m))throw new S(`bracket key ${m}`,e);if(!Le.allowBracketNotation)throw new S("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(n&&/^[$A-Z_a-z][$\w]*$/.test(c)){i.add(c);continue}throw new S("dynamic bracket notation is not allowed",e)}return[...i]}function ge(e){let n=e.trim(),r=De(n);je(r,n);let i=Be(n);for(let s of ae){if(s===U)continue;if(s.test(r))throw new S(`matched /${s.source}/`,n)}return{...At(n),dynamicKeys:i}}function Ri(e){return ge(e),e.trim()}var Ys=Symbol("stx.sanitizeCache"),_t=4000,B=new Map;function Ot(e){let n=B.get(e);if(n===void 0){if(n=ae.some((r)=>r.test(e)),B.size>=_t)B.clear();B.set(e,n)}return n}function W(e){let n={},r=e[Ys];n.Math=Math,n.JSON=JSON,n.Date=Date,n.String=String,n.Number=Number,n.Boolean=Boolean,n.Array=Array,n.Object=se,n.parseInt=Number.parseInt,n.parseFloat=Number.parseFloat,n.isNaN=Number.isNaN,n.isFinite=Number.isFinite,n.encodeURIComponent=encodeURIComponent,n.decodeURIComponent=decodeURIComponent;for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||Ot(i))continue;if(s&&typeof s==="object"&&!Array.isArray(s)){let o=r?.get(s);if(o===void 0)o=oe(s),r?.set(s,o);n[i]=o}else n[i]=s}return n}function oe(e,n=0){if(n>=Le.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((i)=>oe(i,n+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]=oe(s,n+1);else r[i]=s}return r}function u(e,n){try{let r=W(n),i=Object.keys(r),s=Object.values(r);return d(e,i)(...s)}catch{return}}function f(e){try{return Ri(e),!0}catch{return!1}}function ul(e,n){try{let r=W(n),i=Object.keys(r),s=Object.values(r),o=!1,c=d(e,i,()=>{o=!0})(...s);return!o&&Boolean(c)}catch{return!1}}function P(e,n){try{let r=u(e,n);if(r&&typeof r==="object"&&!Array.isArray(r))return r;return{}}catch{return{}}}var He=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"]),Ae=`stx-compile-probe:${globalThis.crypto.randomUUID()}`,It=0,Pt=0;function Lt(e,n){let r="__stx_compile_probe";while(e.includes(r))r+="_";let i=Array.from({length:e.length+1});i[e.length]=Ae;for(let s=0;s<16;s++){let o=`c${++It}`,a=`'use strict';if(${r}===${JSON.stringify(Ae)})return ${JSON.stringify(o)};`,c=Function(...e,r,a+n);if(c(...i)===o)return c;Pt++}throw Error("[stx] the JavaScript runtime repeatedly returned code compiled from a different source; refusing to evaluate with it.")}var Mt=2000,H=new Map;function Oe(e,n){let r=`${e.join(",")}\x00${n}`,i=H.get(r);if(i)return i;let s=Lt(e,n);if(H.size>=Mt)H.clear();return H.set(r,s),s}function it(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 Nt=/^[A-Za-z_$][\w$]*$/;function Ft(e){return Nt.test(e)&&!He.has(e)}var Ie=new R(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function d(e,n,r){let i=JSON.stringify([e,n]),s=Ie.get(i);if(!s)s=Dt(e,[...n]),s.sourceBytes+=i.length*2,Ie.set(i,s);return jt(Ut(s.buildFunc,s.filteredKeys,s.contextKeys,s.validEntries,s.validIndices,r),s.contextKeys,s.dynamicKeys)}function Dt(e,n){let{source:r,usesSafeConstructors:i,dynamicKeys:s}=ge(e),o=[];for(let m=0;m<n.length;m++){if(!Ft(n[m]))continue;if(n[m]===V||n[m]==="Object"||le.has(n[m]))continue;o.push({key:n[m],index:m})}o.sort((m,y)=>m.key<y.key?-1:1);let a=o.map((m)=>m.key),c=o.map((m)=>m.index),p=`
|
|
39
|
+
`),s.set(g,h)}return h(...c)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:a,context:n.slice()});return a}clear(){this.pool.length=0,this.fnCache.clear()}}var or=new ke;class Te{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(e){this.enabled=e}isEnabled(){return this.enabled}setBudget(e,n){this.budgets.set(e,{warnThreshold:0.8,action:"warn",...n})}setBudgets(e){for(let[n,r]of Object.entries(e))this.setBudget(n,r)}removeBudget(e){this.budgets.delete(e)}getBudgets(){let e={};for(let[n,r]of this.budgets.entries())e[n]=r;return e}onViolation(e){this.violationHandlers.push(e)}offViolation(e){let n=this.violationHandlers.indexOf(e);if(n!==-1)this.violationHandlers.splice(n,1)}time(e,n){if(!this.enabled)return n();let r=performance.now(),i=n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),i}async timeAsync(e,n){if(!this.enabled)return n();let r=performance.now(),i=await n(),s=performance.now()-r;return this.recordTime(e,s),this.checkBudget(e,s),i}checkBudget(e,n){let r=this.budgets.get(e);if(!r)return;let i=n/r.maxTime*100,s=r.warnThreshold!==void 0?n>=r.maxTime*r.warnThreshold&&n<r.maxTime:!1,o=n>=r.maxTime;if(!s&&!o)return;let a={label:e,actualTime:n,budgetTime:r.maxTime,exceedancePercent:i,timestamp:new Date,isWarning:s};this.violations.push(a);while(this.violations.length>this.maxViolations)this.violations.shift();for(let p of this.violationHandlers)try{p(a)}catch{}let c=s?`[Performance Warning] "${e}" took ${n.toFixed(2)}ms (${i.toFixed(1)}% of ${r.maxTime}ms budget)`:`[Performance Budget Exceeded] "${e}" took ${n.toFixed(2)}ms (exceeded ${r.maxTime}ms budget by ${(i-100).toFixed(1)}%)`;switch(r.action){case"log":console.log(c);break;case"warn":console.warn(c);break;case"error":console.error(c);break;case"throw":if(o)throw Error(c);else console.warn(c);break}}recordTime(e,n){let r=this.metrics.get(e);if(r)r.count++,r.totalTime+=n,r.maxTime=Math.max(r.maxTime,n),r.minTime=Math.min(r.minTime,n);else this.metrics.set(e,{count:1,totalTime:n,maxTime:n,minTime:n})}getStats(e){if(e){let r=this.metrics.get(e);if(!r)return{};let i=this.budgets.get(e);return{count:r.count,avgTime:r.totalTime/r.count,totalTime:r.totalTime,maxTime:r.maxTime,minTime:r.minTime,budget:i?.maxTime,budgetUtilization:i?r.totalTime/r.count/i.maxTime*100:void 0}}let n={};for(let[r,i]of this.metrics.entries()){let s=this.budgets.get(r);n[r]={count:i.count,avgTime:i.totalTime/i.count,totalTime:i.totalTime,maxTime:i.maxTime,minTime:i.minTime,budget:s?.maxTime,budgetUtilization:s?i.totalTime/i.count/s.maxTime*100:void 0}}return n}getViolations(e){if(e)return this.violations.filter((n)=>n.label===e);return[...this.violations]}getViolationStats(){let e={},n=0,r=0;for(let i of this.violations)if(e[i.label]=(e[i.label]||0)+1,i.isWarning)n++;else r++;return{total:this.violations.length,byLabel:e,warnings:n,errors:r}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var re=null;function Rt(){if(!re)re=new Te;return re}var le=new Proxy({},{get(e,n){return Rt()[n]}});var Se=0;async function _(){if(performance.now()-Se<16)return;await new Promise((e)=>setTimeout(e,0)),Se=performance.now()}var $t={maxSanitizeDepth:10,allowBracketNotation:!1},Le={...$t};var U=/\bnew\s+/,V="__stx_safe_ctors",Me=["Bun","Deno","Buffer","fetch","atob","btoa","console","Response","Request","Headers","WebAssembly","structuredClone","queueMicrotask","crypto","performance","navigator","Worker","WebSocket","BroadcastChannel","EventSource","XMLHttpRequest","localStorage","sessionStorage"],ie=[...Me,"Function","setTimeout","setInterval","setImmediate","process","require","exports","module","window","document","global","globalThis","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry"],Re=ie.map(()=>{return}),se=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})),ae=[/\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*\(/,U,/\bdelete\s+/,/\bthis\b/,/\\u(?:\{[\dA-Fa-f]+\}|[\dA-Fa-f]{4})/],ce=new Set([...Me,"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",V]),ue=new Set(["__proto__","constructor","prototype"]);function Ne(e){let n="",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)n+=e[o],r.push(o),o++}continue}if(a===i)i=null;continue}if(a==='"'||a==="'"||a==="`"){i=a;continue}n+=a,r.push(o)}return{text:n,map:r}}function De(e){return Ne(e).text}var Fe=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],ze=(()=>{let e={Date,URL,URLSearchParams},n=Intl;for(let r of Fe)if(typeof n[r]==="function")e[`Intl_${r}`]=n[r];return Object.freeze(Object.assign(Object.create(null),e))})(),Ct=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,$e=/(?<![\w$])new(?![\w$])/g,Ae=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Fe.join(",")}}() are allowed`;function At(e){let{text:n,map:r}=Ne(e),i=[];$e.lastIndex=0;let s;while((s=$e.exec(n))!==null){let a=s.index;if(/(?<!\.)\.\s*$/.test(n.slice(0,a)))continue;let c=Ct.exec(n.slice(a)),p=c?.[3],g=!c?null:p?`Intl_${p}`:c[2];if(!c||!g||!(g in ze))throw new S(`matched /${U.source}/; ${Ae}`,e);let h=a+c[0].length,m=r[a],y=r[h-1]+1;if(e.slice(m,y)!==n.slice(a,h))throw new S(`matched /${U.source}/; ${Ae}`,e);let E=m+3+c[1].length;i.push({start:E,end:E+c[2].length,key:g})}let o=e;for(let a=i.length-1;a>=0;a--){let c=i[a];o=`${o.slice(0,c.start)}${V}.${c.key}${o.slice(c.end)}`}return{source:o,usesSafeConstructors:i.length>0}}class S extends Error{rule;expression;constructor(e,n,r){super(r??`Potentially unsafe expression (${e}): ${n}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=n}}function Js(e){try{return ge(e),null}catch(n){return n instanceof S?n.rule:n instanceof Error?n.message:String(n)}}function je(e,n){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(ce.has(s))throw new S(`matched /\\b${s}\\b/; identifier ${s}`,n);if(o==="."&&ue.has(s))throw new S(`matched /.${s}/; property ${s}`,n)}}function Be(e,n=!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(),p=/^'(?:[^'\\]|\\.)*'$/.test(c),g=/^"(?:[^"\\]|\\.)*"$/.test(c);if(/^\d+$/.test(c))continue;if(p||g){let m=c.slice(1,-1);if(ue.has(m))throw new S(`bracket key ${m}`,e);if(!Le.allowBracketNotation)throw new S("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(n&&/^[$A-Z_a-z][$\w]*$/.test(c)){i.add(c);continue}throw new S("dynamic bracket notation is not allowed",e)}return[...i]}function ge(e){let n=e.trim(),r=De(n);je(r,n);let i=Be(n);for(let s of ae){if(s===U)continue;if(s.test(r))throw new S(`matched /${s.source}/`,n)}return{...At(n),dynamicKeys:i}}function Ri(e){return ge(e),e.trim()}var Ys=Symbol("stx.sanitizeCache"),_t=4000,B=new Map;function Ot(e){let n=B.get(e);if(n===void 0){if(n=ae.some((r)=>r.test(e)),B.size>=_t)B.clear();B.set(e,n)}return n}function W(e){let n={},r=e[Ys];n.Math=Math,n.JSON=JSON,n.Date=Date,n.String=String,n.Number=Number,n.Boolean=Boolean,n.Array=Array,n.Object=se,n.parseInt=Number.parseInt,n.parseFloat=Number.parseFloat,n.isNaN=Number.isNaN,n.isFinite=Number.isFinite,n.encodeURIComponent=encodeURIComponent,n.decodeURIComponent=decodeURIComponent;for(let[i,s]of Object.entries(e)){if(i.startsWith("__")||Ot(i))continue;if(s&&typeof s==="object"&&!Array.isArray(s)){let o=r?.get(s);if(o===void 0)o=oe(s),r?.set(s,o);n[i]=o}else n[i]=s}return n}function oe(e,n=0){if(n>=Le.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((i)=>oe(i,n+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]=oe(s,n+1);else r[i]=s}return r}function u(e,n){try{let r=W(n),i=Object.keys(r),s=Object.values(r);return d(e,i)(...s)}catch{return}}function f(e){try{return Ri(e),!0}catch{return!1}}function dl(e,n){try{let r=W(n),i=Object.keys(r),s=Object.values(r),o=!1,c=d(e,i,()=>{o=!0})(...s);return!o&&Boolean(c)}catch{return!1}}function P(e,n){try{let r=u(e,n);if(r&&typeof r==="object"&&!Array.isArray(r))return r;return{}}catch{return{}}}var He=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"]),_e=`stx-compile-probe:${globalThis.crypto.randomUUID()}`,It=0,Pt=0;function Lt(e,n){let r="__stx_compile_probe";while(e.includes(r))r+="_";let i=Array.from({length:e.length+1});i[e.length]=_e;for(let s=0;s<16;s++){let o=`c${++It}`,a=`'use strict';if(${r}===${JSON.stringify(_e)})return ${JSON.stringify(o)};`,c=Function(...e,r,a+n);if(c(...i)===o)return c;Pt++}throw Error("[stx] the JavaScript runtime repeatedly returned code compiled from a different source; refusing to evaluate with it.")}var Mt=2000,H=new Map;function Oe(e,n){let r=`${e.join(",")}\x00${n}`,i=H.get(r);if(i)return i;let s=Lt(e,n);if(H.size>=Mt)H.clear();return H.set(r,s),s}function at(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 Nt=/^[A-Za-z_$][\w$]*$/;function zt(e){return Nt.test(e)&&!He.has(e)}var Ie=new R(2000,{maxBytes:2097152,sizeOf:(e)=>e.sourceBytes});function d(e,n,r){let i=JSON.stringify([e,n]),s=Ie.get(i);if(!s)s=Dt(e,[...n]),s.sourceBytes+=i.length*2,Ie.set(i,s);return jt(Bt(s.buildFunc,s.filteredKeys,s.contextKeys,s.validEntries,s.validIndices,r),s.contextKeys,s.dynamicKeys)}function Dt(e,n){let{source:r,usesSafeConstructors:i,dynamicKeys:s}=ge(e),o=[];for(let m=0;m<n.length;m++){if(!zt(n[m]))continue;if(n[m]===V||n[m]==="Object"||ce.has(n[m]))continue;o.push({key:n[m],index:m})}o.sort((m,y)=>m.key<y.key?-1:1);let a=o.map((m)=>m.key),c=o.map((m)=>m.index),p=`
|
|
40
40
|
'use strict';
|
|
41
41
|
try {
|
|
42
42
|
return ${r};
|
|
@@ -47,15 +47,15 @@ catch (e) {
|
|
|
47
47
|
}
|
|
48
48
|
throw e;
|
|
49
49
|
}
|
|
50
|
-
`,g=i?(m)=>{let y=Oe([V,"Object",...ie,...a,...m],p);return(...E)=>y(ze,se,...
|
|
51
|
-
`:a==="t"?"\t":a;continue}if(o===r)return null;if(r==="`"&&o==="$"&&n[s+1]==="{")return null;i+=o}return i}var Wt=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function
|
|
50
|
+
`,g=i?(m)=>{let y=Oe([V,"Object",...ie,...a,...m],p);return(...E)=>y(ze,se,...Re,...E)}:(m)=>{let y=Oe(["Object",...ie,...a,...m],p);return(...E)=>y(se,...Re,...E)},h=g([]);return{sourceBytes:e.length*2+n.reduce((m,y)=>m+y.length*2,0),contextKeys:n,filteredKeys:a,validEntries:o,validIndices:c,dynamicKeys:s,buildFunc:(m)=>m.length===0?h:g(m)}}function jt(e,n,r){if(r.length===0)return e;let i=r.map((s)=>n.indexOf(s));return(...s)=>{for(let o of i){if(o<0)continue;let a=s[o];if(typeof a==="string"&&ue.has(a))return}return e(...s)}}function Bt(e,n,r,i,s,o){let a=e([]),c=i.every((g,h)=>g.index===h);if(n.length===r.length&&c)return Pe(a,n,e,void 0,o);return Pe((...g)=>{let h=Array(s.length);for(let m=0;m<s.length;m++)h[m]=g[s[m]];return a(...h)},n,e,(g)=>{a=e(g)},o)}function Pe(e,n,r,i,s){let a=/^(\w+) is not defined$/,c=e,p=[],g=new Set(n);return(...h)=>{for(let m=0;m<=8;m++)try{return c(...h)}catch(y){let E=y instanceof Error?y.message:"",v=a.exec(E);if(!(y instanceof ReferenceError)||!v)return;let w=v[1];if(g.has(w)||He.has(w)||ce.has(w))return;if(s?.(w),g.add(w),p.push(w),i)i(p);else c=r(p)}return}}function Zs(e){let n=e.trim();try{let r=De(n);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;je(r,n),Be(n);for(let i of ae)if(i.test(r))return!1}catch{return!1}return!0}function Pi(e,n){let r=[];n.lastIndex=0;let i;while((i=n.exec(e))!==null){let s=i.index,o=s+i[0].length-1,a=x(e,"(",")",o);if(a===-1){r.push({start:s,end:-1,args:"",call:e.slice(s,Math.min(e.length,s+80))}),n.lastIndex=o+1;continue}r.push({start:s,end:a+1,args:e.slice(o+1,a),call:e.slice(s,a+1)}),n.lastIndex=a+1}return r}function Ht(e,n,r,i){let s="",o=0;for(let a of Pi(e,n)){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 Vt(e){let n=[],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){n.push(s.trim()),s="";continue}s+=a}if(s.trim())n.push(s.trim());return n}function de(e){let n=e.trim(),r=n[0];if(r!=="'"&&r!=='"'&&r!=="`"||n.length<2||n.at(-1)!==r)return null;let i="";for(let s=1;s<n.length-1;s++){let o=n[s];if(o==="\\"&&s+1<n.length-1){let a=n[++s];i+=a==="n"?`
|
|
51
|
+
`:a==="t"?"\t":a;continue}if(o===r)return null;if(r==="`"&&o==="$"&&n[s+1]==="{")return null;i+=o}return i}var Wt=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Ut(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let i=Js(r);if(i)return{ok:!1,message:`the expression is not allowed (${i})`,code:t.UNSAFE_EXPRESSION};let s=W(n),o;try{o=d(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:t.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let a=[...new Set(at(r))].filter((c)=>!Wt.has(c)&&!(c in s)&&!(c in globalThis));if(a.length>0)return{ok:!1,message:`${a.map((p)=>`"${p}"`).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:t.UNDEFINED_VARIABLE};if(o===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:t.EVALUATION_ERROR};return{ok:!0,value:o}}function Ue(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 ct(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Ke(e){if(!e)return"";return Ve.isAbsolute(e)?Ve.relative(process.cwd(),e)||e:e}function pe(e){let n=e.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}function D(e,n,r,i,s=t.EVALUATION_ERROR){let o=i?` in ${Ke(i)}`:"";return console.warn(`[stx] ${pe(n)}${o}: ${r}`),l(e,`${pe(n)}: ${r}`,s)}function Qs(e,n,r){let i=r?` in ${Ke(r)}`:"";console.warn(`[stx] ${pe(e)}${i}: ${n}`)}function Ii(){return{afterOpen:[],beforeClose:[]}}function Kt(e){return e.afterOpen.length>0||e.beforeClose.length>0}function fl(e,n){if(!Kt(n))return e;let r=n.afterOpen.join(""),i=n.beforeClose.join(""),s=e.lastIndexOf("</head>"),o=r?Pr(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 Xe=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function Pr(e){let n=/<head\b[^>]*>/i.exec(e);if(!n)return null;let r=n.index+n[0].length;Xe.lastIndex=r;let i=Xe.exec(e);return i?r+i[0].length:r}var me="data-stx-color-mode-boot",qe="__STX_COLOR_MODE__",Xt=new Set(["light","dark","auto","system"]),qt=new Set(["auto","system"]),Gt=/^[a-z][\w:-]*$/i,Yt=/^[\w-]+$/;function Jt(e){let n=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 n!=="string"||n.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!Xt.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"||!Yt.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"||!Gt.test(s)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(s)}`);if(o!==null&&!qt.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:n,initialMode:r==="system"?"auto":r,darkClass:i,attribute:s,autoValue:o,respectExisting:a}}function Zt(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function he(e={}){let n=Jt(e),r=Zt(n),i=`(function(){"use strict";var o=window.${qe};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.${qe}={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 ${me}>${i}</script>`}function Ir(e,n={}){if(e.includes(me))return e;let r=fe(e);if(r===null)return e;let i=he(n);return`${e.slice(0,r)}
|
|
52
52
|
${i}${e.slice(r)}`}var fe=Pr,Qt=new RegExp(`<script\\b[^>]*\\b${me}\\b[^>]*>[\\s\\S]*?<\\/script>`,"i"),Ge=/<meta\b[^>]*\bcharset\b[^>]*>/gi,Ye=/<\/head>/gi;function en(e){let n=/<head\b[^>]*>/i.exec(e);if(!n)return e;let r=n.index+n[0].length;Ye.lastIndex=r;let i=Ye.exec(e),s=i?i.index:e.length;Ge.lastIndex=r;let o=Ge.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)}
|
|
53
|
-
${o[0]}${e.slice(r,o.index)}${e.slice(a,s)}${e.slice(s)}`}function
|
|
54
|
-
${n[0]}${i.slice(s)}`}var nn="[data-stx-component-wrapper]:not([stx-hydrate]){display:contents}",Qe=`<style data-stx-cloak>[x-cloak]{display:none !important}${nn}</style>`,X="data-stx-html-attrs",q="data-stx-html-class",et=/^[A-Za-z_:][\w:.-]*$/;function k(e){return String(e).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function rn(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function
|
|
55
|
-
`}function an(e){let n=[],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 p=o.match(/^<link\b[^>]*>/i);if(p){n.push(p[0]),r+=p[0].length;continue}let g=o.match(/^<meta\b[^>]*>/i);if(g){n.push(g[0]),r+=g[0].length;continue}let h=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(h){n.push(h[0]),r+=h[0].length;continue}break}if(n.length===0)return{body:e,hoisted:n};let i="",s=0;while(s<e.length&&s<r){let o=e.slice(s),a=o.match(/^<link\b[^>]*>/i);if(a&&n.includes(a[0])){s+=a[0].length;continue}let c=o.match(/^<meta\b[^>]*>/i);if(c&&n.includes(c[0])){s+=c[0].length;continue}let p=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(p&&n.includes(p[0])){s+=p[0].length;continue}i+=e[s],s++}return i+=e.slice(r),{body:i,hoisted:n}}function cn(e,n={},r={}){let{title:i="stx App",lang:s="en",meta:o=[],link:a=[],script:c=[],headRaw:p="",htmlAttrs:g={},bodyClass:h="",bodyAttrs:m={}}=n,y=r.title||i,E=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],v=new Set(o.map(
|
|
53
|
+
${o[0]}${e.slice(r,o.index)}${e.slice(a,s)}${e.slice(s)}`}function gl(e){return tn(en(e))}function tn(e){let n=Qt.exec(e);if(!n)return e;let r=fe(e);if(r===null)return e;if(n.index<=r||e.slice(r,n.index).trim()==="")return e;let i=e.slice(0,n.index)+e.slice(n.index+n[0].length),s=fe(i);if(s===null)return e;return`${i.slice(0,s)}
|
|
54
|
+
${n[0]}${i.slice(s)}`}var nn="[data-stx-component-wrapper]:not([stx-hydrate]){display:contents}",Qe=`<style data-stx-cloak>[x-cloak]{display:none !important}${nn}</style>`,X="data-stx-html-attrs",q="data-stx-html-class",et=/^[A-Za-z_:][\w:.-]*$/;function k(e){return String(e).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function rn(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function lt(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 sn(e){let n=/^\s*<meta\b([^>]*)>/i.exec(e);if(!n)return null;let r={};for(let i of n[1].matchAll(/([\w:-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g))r[i[1].toLowerCase()]=i[2]??i[3]??i[4]??"";return r}function O(e,n){return Object.entries(e).filter(([r])=>!n?.(r)).map(([r,i])=>`${r}="${k(String(i))}"`).join(" ")}function Y(e){let n=String(e.content),r=typeof e.type==="string"?e.type.trim().toLowerCase():"";return/json$|^importmap$/.test(r)?n.replace(/<\//g,"<\\/"):n}function tt(e){let n=O(e,(r)=>r==="content");return`<script${n?` ${n}`:""}>${Y(e)}</script>`}function on(e={},n="en"){let r=[],i=[],s="",o=n;for(let[c,p]of Object.entries(e||{})){if(p==null)continue;let g=c.trim();if(!et.test(g))continue;let h=g.toLowerCase();if(h==="lang"){o=String(p);continue}if(h==="class"){s=String(p).trim();continue}r.push(` ${g}="${k(String(p))}"`),i.push(g)}let a=` lang="${k(o)}"`;if(s)a+=` class="${k(s)}"`;if(a+=r.join(""),s)a+=` ${q}="${k(s)}"`;if(i.length)a+=` ${X}="${k(i.join(" "))}"`;return a}function ml(e={},n={}){let r={...e,...n};if(e.class&&n.class){let i=e.class.split(/\s+/).filter(Boolean);for(let s of n.class.split(/\s+/).filter(Boolean))if(!i.includes(s))i.push(s);r.class=i.join(" ")}return r}function Or(e,n={}){if(!n||Object.keys(n).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 h=a[1];if(!(h in i))s.push(h);i[h]=a[2]??a[3]??a[4]??""}let c=[],p=[];for(let[h,m]of Object.entries(n)){if(m==null)continue;let y=h.trim();if(!et.test(y))continue;let E=y.toLowerCase();if(E==="class"){let v=(i.class||"").split(/\s+/).filter(Boolean);for(let w of String(m).split(/\s+/).filter(Boolean))if(!v.includes(w))v.push(w),c.push(w);if(!("class"in i))s.push("class");i.class=v.join(" ");continue}if(!(y in i))s.push(y);if(i[y]=String(m),E!=="lang")p.push(y)}if(c.length){if(!(q in i))s.push(q);i[q]=c.join(" ")}if(p.length){if(!(X in i))s.push(X);i[X]=p.join(" ")}let g=s.map((h)=>` ${h}="${k(i[h])}"`).join("");return e.replace(r[0],()=>`<html${g}>`)}function hl(e){if(e.includes("data-stx-cloak"))return null;if(e.lastIndexOf("</head>")===-1)return null;return`${Qe}
|
|
55
|
+
`}function an(e){let n=[],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 p=o.match(/^<link\b[^>]*>/i);if(p){n.push(p[0]),r+=p[0].length;continue}let g=o.match(/^<meta\b[^>]*>/i);if(g){n.push(g[0]),r+=g[0].length;continue}let h=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(h){n.push(h[0]),r+=h[0].length;continue}break}if(n.length===0)return{body:e,hoisted:n};let i="",s=0;while(s<e.length&&s<r){let o=e.slice(s),a=o.match(/^<link\b[^>]*>/i);if(a&&n.includes(a[0])){s+=a[0].length;continue}let c=o.match(/^<meta\b[^>]*>/i);if(c&&n.includes(c[0])){s+=c[0].length;continue}let p=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(p&&n.includes(p[0])){s+=p[0].length;continue}i+=e[s],s++}return i+=e.slice(r),{body:i,hoisted:n}}function cn(e,n={},r={}){let{title:i="stx App",lang:s="en",meta:o=[],link:a=[],script:c=[],headRaw:p="",htmlAttrs:g={},bodyClass:h="",bodyAttrs:m={}}=n,y=r.title||i,E=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],v=new Set(o.map(lt).filter(Boolean)),{body:w,hoisted:T}=an(e),A=new Set(T.flatMap((b)=>{let L=sn(b);return L?[lt(L)].filter(Boolean):[]})),ot=[...E.filter((b)=>!v.has(lt(b))),...o].filter((b)=>!A.has(lt(b))).map((b)=>` <meta ${O(b)}>`).join(`
|
|
56
56
|
`),ut=a.map((b)=>` <link ${O(b)}>`).join(`
|
|
57
57
|
`),gt=c.map((b)=>{if(b.src)return` <script ${O(b,(L)=>L==="content")}></script>`;if(b.content)return` ${tt(b)}`;return""}).filter(Boolean).join(`
|
|
58
|
-
`),pt=on(g,s),dt=Object.entries(m).map(([b,L])=>` ${b}="${k(String(L))}"`).join(""),ft=h?` class="${k(h)}"`:"",mt=[
|
|
58
|
+
`),pt=on(g,s),dt=Object.entries(m).map(([b,L])=>` ${b}="${k(String(L))}"`).join(""),ft=h?` class="${k(h)}"`:"",mt=[ot,r.colorMode?` ${he(r.colorMode)}`:"",` <title>${r.titleIsHtml?y:rn(y)}</title>`,` ${Qe}`,ut,gt,p?` ${p}`:"",...(r.styles||[]).map((b)=>` ${b}`),...T.map((b)=>` ${b}`),...(r.headScripts||[]).map((b)=>` ${b}`),r.headStack||""].filter(Boolean),ht=[w,...(r.bodyScripts||[]).map((b)=>b),r.bodyStack||""].filter(Boolean);return`<!DOCTYPE html>
|
|
59
59
|
<html${pt}>
|
|
60
60
|
<head>
|
|
61
61
|
${mt.join(`
|
|
@@ -65,8 +65,8 @@ ${mt.join(`
|
|
|
65
65
|
${ht.join(`
|
|
66
66
|
`)}
|
|
67
67
|
</body>
|
|
68
|
-
</html>`}var ye=/\s+/y,be=/<(script|style)\b[^>]*>/iy,ln=/<\/script>/gi,un=/<\/style>/gi,Je=/<!DOCTYPE\b/iy,Ze=/<html[\s>]/iy;function Tn(e){let n=0;while(n<e.length){if(ye.lastIndex=n,ye.exec(e)){n=ye.lastIndex;continue}if(e.startsWith("<!--",n)){let s=e.indexOf("-->",n);if(s===-1)return!1;n=s+3;continue}be.lastIndex=n;let i=be.exec(e);if(i){let s=i[1].toLowerCase()==="script"?ln:un;s.lastIndex=be.lastIndex;let o=s.exec(e);if(o===null)return!1;n=o.index+o[0].length;continue}if(Je.lastIndex=n,Je.test(e))return!0;return Ze.lastIndex=n,Ze.test(e)}return!1}function Oi(e){return Tn(e)}function
|
|
68
|
+
</html>`}var ye=/\s+/y,be=/<(script|style)\b[^>]*>/iy,ln=/<\/script>/gi,un=/<\/style>/gi,Je=/<!DOCTYPE\b/iy,Ze=/<html[\s>]/iy;function Tn(e){let n=0;while(n<e.length){if(ye.lastIndex=n,ye.exec(e)){n=ye.lastIndex;continue}if(e.startsWith("<!--",n)){let s=e.indexOf("-->",n);if(s===-1)return!1;n=s+3;continue}be.lastIndex=n;let i=be.exec(e);if(i){let s=i[1].toLowerCase()==="script"?ln:un;s.lastIndex=be.lastIndex;let o=s.exec(e);if(o===null)return!1;n=o.index+o[0].length;continue}if(Je.lastIndex=n,Je.test(e))return!0;return Ze.lastIndex=n,Ze.test(e)}return!1}function Oi(e){return Tn(e)}function yl(e,n={}){let r=e.lastIndexOf("</head>");if(r===-1)return e;let{meta:i=[],link:s=[],script:o=[],headRaw:a=""}=n,c=e.slice(0,r),p=[];for(let g of i){let h=lt(g);if(h&&c.includes(h))continue;p.push(` <meta ${O(g)}>`)}for(let g of s){if(g.href&&c.includes(`href="${g.href}"`))continue;p.push(` <link ${O(g)}>`)}for(let g of o)if(g.src){if(c.includes(`src="${g.src}"`))continue;p.push(` <script ${O(g,(h)=>h==="content")}></script>`)}else if(g.content){if(c.includes(Y(g)))continue;p.push(` ${tt(g)}`)}if(a&&!c.includes(a))p.push(` ${a}`);if(p.length===0)return e;return`${e.slice(0,r)}${p.join(`
|
|
69
69
|
`)}
|
|
70
|
-
${e.slice(r)}`}function Nr(e,n={},r={},i){if(i??Oi(e))return e;return cn(e,n,r)}var gn=["og:","article:","book:","profile:","fb:","music:","video:"],pn=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function Mr(e,n){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:t.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:t.INVALID_DIRECTIVE_SYNTAX};let r=dn(e[0],n);if(typeof r!=="string")return r;let i;if(e.length===2){let o=fn(e[1],n);if(typeof o!=="string")return o;i=o}else{let o=r.includes(":")?r.slice(r.indexOf(":")+1):r,a=n.openGraph,c=n[o]??(
|
|
71
|
-
`)}function
|
|
72
|
-
`,"")),headContent:n.trim()}}function
|
|
70
|
+
${e.slice(r)}`}function Nr(e,n={},r={},i){if(i??Oi(e))return e;return cn(e,n,r)}var gn=["og:","article:","book:","profile:","fb:","music:","video:"],pn=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function Mr(e,n){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:t.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:t.INVALID_DIRECTIVE_SYNTAX};let r=dn(e[0],n);if(typeof r!=="string")return r;let i;if(e.length===2){let o=fn(e[1],n);if(typeof o!=="string")return o;i=o}else{let o=r.includes(":")?r.slice(r.indexOf(":")+1):r,a=n.openGraph,c=n[o]??(ct(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:gn.some((o)=>r.startsWith(o))?{property:r,content:i}:{name:r,content:i}}}function dn(e,n){let r=de(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:t.INVALID_DIRECTIVE_SYNTAX};if(pn.test(e.trim()))return e.trim();let i=Ut(e,n);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 ${Ue(i.value)}`,code:t.TYPE_ERROR};return i.value}function fn(e,n){let r=de(e);if(r!==null)return r;let i=Ut(e,n);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 ${Ue(s)}`,code:t.TYPE_ERROR};return String(s)}var Dr=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],eo=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],it={links:"link",metas:"meta",scripts:"script",styles:"style"},nt=new Set,rt=new WeakMap;function xe(e){if(nt.has(e))return;nt.add(e),console.warn(e)}function mn(e,n){let r=Array.from({length:n.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<=n.length;o++){let a=r[o];r[o]=Math.min(r[o]+1,r[o-1]+1,s+(e[i-1]===n[o-1]?0:1)),s=a}}return r[n.length]}function hn(e,n){let r=e.toLowerCase(),i=n.find((p)=>p.toLowerCase()===r);if(i)return i;let s=it[r];if(s&&n.includes(s))return s;let o,a=1/0;for(let p of n){let g=mn(r,p.toLowerCase());if(g<a)o=p,a=g}let c=Math.min(e.length,o?.length??0)<=4?1:2;return a<=c?o:void 0}function Ee(e,n){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=rt.get(e);if(r)return r;let{known:i,source:s}=n,o=e;for(let a of Object.keys(e)){if(i.includes(a))continue;let c=it[a];if(c&&i.includes(c)&&Array.isArray(e[a])){if(o===e)o={...e};let g=Array.isArray(o[c])?o[c]:[];o[c]=[...g,...e[a]],delete o[a],xe(`[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")){xe(`[stx] ${s}.${a} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let p=hn(a,i);xe(p?`[stx] ${s}.${a} is not a head key and is ignored. Did you mean \`${p}\`?`:`[stx] ${s}.${a} is not a head key and is ignored. Known keys: ${i.join(", ")}.`)}return rt.set(e,o),o}var C={},yn=[],J={};function Ni(){return C}function my(){return J}function hy(){C={},yn.length=0,J={}}function bl(e){C=We(C,Ee(e,{known:eo,source:"useHead()"}))}function st(e,n,r){let i=[...e||[]];for(let s of n||[]){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 We(e,n){return{title:n.title??e.title,titleTemplate:n.titleTemplate??e.titleTemplate,base:n.base??e.base,meta:st(e.meta,n.meta,(r)=>r.name||r.property||(r.httpEquiv?`http:${r.httpEquiv}`:void 0)),link:st(e.link,n.link,(r)=>["icon","apple-touch-icon","canonical"].includes(r.rel||"")?[r.rel,r.type,r.media,r.sizes].join(":"):void 0),script:[...e.script||[],...n.script||[]],style:[...e.style||[],...n.style||[]],htmlAttrs:{...e.htmlAttrs,...n.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...n.bodyAttrs}}}function Ig(e){bl(to(e))}function to(e){let n=[];if(e.description)n.push({name:"description",content:e.description});if(e.keywords){let p=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;n.push({name:"keywords",content:p})}if(e.author)n.push({name:"author",content:e.author});if(e.robots)n.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,i=e.ogDescription??e.description;if(r)n.push({property:"og:title",content:r});if(i)n.push({property:"og:description",content:i});if(e.ogImage){if(n.push({property:"og:image",content:e.ogImage}),e.ogImageType)n.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)n.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)n.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)n.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)n.push({property:"og:url",content:e.ogUrl});if(e.ogType)n.push({property:"og:type",content:e.ogType});if(e.ogSiteName)n.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)n.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)n.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)n.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)n.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)n.push({name:"twitter:card",content:e.twitterCard});if(s)n.push({name:"twitter:title",content:s});if(o)n.push({name:"twitter:description",content:o});if(a){n.push({name:"twitter:image",content:a});let p=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(p)n.push({name:"twitter:image:alt",content:p})}if(e.twitterSite)n.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)n.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)n.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)n.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)n.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)n.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let p of e.articleTags)n.push({property:"article:tag",content:p});let c=[];if(e.canonical)c.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:n,link:c}}function yy(e){if(J={...J,...e},e.title||e.description)Ig({title:e.title,description:e.description})}function by(e){let n=typeof e==="function"?e():e;bl({title:n})}function wy(e=C){let n=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);n.push(`<title>${I(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([i,s])=>`${i}="${I(s)}"`).join(" ");n.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}="${I(String(o))}"`).join(" ");n.push(`<meta ${i}>`)}for(let r of e.link||[]){let i=Object.entries(r).filter(([s,o])=>o!==void 0).map(([s,o])=>`${s}="${I(String(o))}"`).join(" ");n.push(`<link ${i}>`)}for(let r of e.script||[]){let{content:i,...s}=r,o=Object.entries(s).filter(([a,c])=>c!==void 0).map(([a,c])=>{if(typeof c==="boolean")return c?a:"";return`${a}="${I(String(c))}"`}).filter(Boolean).join(" ");if(i)n.push(`<script ${o}>${Y(r)}</script>`);else n.push(`<script ${o}></script>`)}for(let r of e.style||[]){let i=r.type?` type="${r.type}"`:"";n.push(`<style${i}>${r.content}</style>`)}return n.join(`
|
|
71
|
+
`)}function vy(e=C){if(!e.htmlAttrs)return"";return Object.entries(e.htmlAttrs).map(([n,r])=>`${n}="${I(r)}"`).join(" ")}function xy(e=C){if(!e.bodyAttrs)return"";return Object.entries(e.bodyAttrs).map(([n,r])=>`${n}="${I(r)}"`).join(" ")}function I(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Sy(e=C){if(typeof document>"u")return;if(e.title){let n=e.title;if(e.titleTemplate)n=typeof e.titleTemplate==="function"?e.titleTemplate(n):e.titleTemplate.replace("%s",n);document.title=n}for(let n of e.meta||[]){let r=n.name?`meta[name="${n.name}"]`:n.property?`meta[property="${n.property}"]`:null;if(r){let i=document.querySelector(r);if(!i){if(i=document.createElement("meta"),n.name)i.setAttribute("name",n.name);if(n.property)i.setAttribute("property",n.property);document.head.appendChild(i)}i.setAttribute("content",n.content)}}for(let n of e.link||[]){let r=`link[rel="${n.rel}"]${n.href?`[href="${n.href}"]`:""}`,i=document.querySelector(r);if(!i)i=document.createElement("link"),document.head.appendChild(i);for(let[s,o]of Object.entries(n))if(o!==void 0)i.setAttribute(s,String(o))}if(e.htmlAttrs)for(let[n,r]of Object.entries(e.htmlAttrs))if(n==="class")for(let i of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(i);else document.documentElement.setAttribute(n,r);if(e.bodyAttrs)for(let[n,r]of Object.entries(e.bodyAttrs))document.body.setAttribute(n,r)}function ky(e){let n="";return{content:e.replace(/@head\s*([\s\S]*?)@endhead/g,(i,s)=>(n+=s.trim()+`
|
|
72
|
+
`,"")),headContent:n.trim()}}function _y(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,i,s,o)=>{let a=i?s:n[(o||"").trim()]??o,c=n.__stx_runtime_head??{};return n.__stx_runtime_head=We(c,{title:a}),""})}function Cy(e,n,r=""){if(!e.includes("@meta"))return e;return Ht(e,/(?<![\w$@])@meta\s*\(/g,(i,s)=>{let o=Mr(Vt(i),n);if(o.kind==="error")return D("Meta",s,o.message,r,o.code);if(o.kind==="tag"){let a=n.__stx_runtime_head??{};n.__stx_runtime_head=We(a,{meta:[o.tag]})}return""},(i)=>D("Meta",i,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{R,Ft,le,_,Js,Ri,Ys,u,f,dl,P,at,zt,d,Zs,t,ee,Ar,K,l,Ce,Ai,z,En,x,pl,Pi,Ht,Vt,Ut,Ue,ct,D,Qs,Ii,fl,Pr,Ir,gl,lt,ml,Or,hl,Tn,Oi,yl,Nr,Mr,Dr,eo,Ee,Ni,my,hy,bl,We,Ig,to,yy,by,wy,vy,xy,Sy,ky,_y,Cy};
|