@stacksjs/stx 0.2.630 → 0.2.632
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-05zhvg8t.js +20 -0
- package/dist/chunk-0c31twby.js +2 -0
- package/dist/{chunk-0s1hpqas.js → chunk-0jeqp6yz.js} +2 -2
- package/dist/chunk-0nvb2x2f.js +2 -0
- package/dist/chunk-0whv8hnp.js +4 -0
- package/dist/{chunk-q1983d5e.js → chunk-179c1rdn.js} +2 -2
- package/dist/chunk-1e25xd0z.js +6 -0
- package/dist/{chunk-jp6yn9mj.js → chunk-1ma56c2h.js} +2 -2
- package/dist/{chunk-h9ymjtch.js → chunk-27h1xs4k.js} +12 -12
- package/dist/{chunk-5m0r0j79.js → chunk-2vqz7v37.js} +3 -3
- package/dist/{chunk-10s16tad.js → chunk-2wvz3fd2.js} +2 -2
- package/dist/chunk-3jda301z.js +2 -0
- package/dist/{chunk-gc1dzxee.js → chunk-3p2b88pd.js} +2 -2
- package/dist/chunk-46qg1tqe.js +2 -0
- package/dist/{chunk-66e4ga0z.js → chunk-4fv3jq16.js} +2 -2
- package/dist/{chunk-k1k2t4ez.js → chunk-4y06ekvt.js} +1 -1
- package/dist/chunk-5fjb6avv.js +2 -0
- package/dist/chunk-5kprybdd.js +2 -0
- package/dist/{chunk-n5xbv1a9.js → chunk-62kxavc5.js} +3 -3
- package/dist/{chunk-8q9b82ew.js → chunk-6684b8ym.js} +11 -11
- package/dist/{chunk-npvxq89e.js → chunk-6mtth8d1.js} +3 -3
- package/dist/chunk-6n6nnt33.js +2 -0
- package/dist/chunk-6per0k6j.js +2 -0
- package/dist/{chunk-hb46a5rr.js → chunk-70npkeh2.js} +2 -2
- package/dist/{chunk-y706tkyy.js → chunk-776f05vk.js} +4 -4
- package/dist/{chunk-szjgbjw1.js → chunk-7a8jkwah.js} +2 -2
- package/dist/{chunk-wbhzt74k.js → chunk-7cw0wkbx.js} +1 -1
- package/dist/chunk-7f1dw9r4.js +2 -0
- package/dist/{chunk-khzyc41k.js → chunk-7ky2ny63.js} +13 -13
- package/dist/{chunk-h431swg6.js → chunk-7mpv1a02.js} +9 -9
- package/dist/chunk-7zjv015g.js +2 -0
- package/dist/{chunk-q35z0cyg.js → chunk-85bbtv3m.js} +1 -1
- package/dist/{chunk-qb7a4am2.js → chunk-85g35me6.js} +2 -2
- package/dist/chunk-87nt0kty.js +2 -0
- package/dist/{chunk-3dth76ce.js → chunk-88d5s6v3.js} +3 -3
- package/dist/chunk-8a3sdg2y.js +2 -0
- package/dist/chunk-8e9hd2jq.js +4 -0
- package/dist/{chunk-0c7ss25y.js → chunk-8gksvwsm.js} +3 -3
- package/dist/chunk-8vbfbtke.js +2 -0
- package/dist/chunk-91ranpvz.js +2 -0
- package/dist/chunk-96ypgjm4.js +2 -0
- package/dist/{chunk-1gtrs8va.js → chunk-9b4e815s.js} +8 -8
- package/dist/chunk-9cg6q8mw.js +2 -0
- package/dist/{chunk-gd7vq083.js → chunk-a2ztn8cr.js} +1 -1
- package/dist/chunk-ag4eck6d.js +2 -0
- package/dist/chunk-aq02drjz.js +2 -0
- package/dist/{chunk-jsw5yby0.js → chunk-aqra0qcg.js} +3 -3
- package/dist/{chunk-cnvfh74t.js → chunk-av9zf0zb.js} +5 -5
- package/dist/chunk-ayt4qd82.js +2 -0
- package/dist/{chunk-m735gtc4.js → chunk-az1y9jks.js} +2 -2
- package/dist/chunk-b3mazye4.js +2 -0
- package/dist/chunk-b5cv9xp7.js +2852 -0
- package/dist/{chunk-dayjd2sj.js → chunk-b7p3yca7.js} +4 -4
- package/dist/chunk-bn6sarwd.js +2 -0
- package/dist/chunk-c7xt5gyb.js +2 -0
- package/dist/chunk-cac98pkx.js +2 -0
- package/dist/{chunk-q5w9cmr9.js → chunk-cbj2hmx5.js} +5 -5
- package/dist/chunk-czg6ewy3.js +2 -0
- package/dist/{chunk-sxpnpvt5.js → chunk-d1ya7f79.js} +4 -4
- package/dist/chunk-dcwmcqbr.js +2 -0
- package/dist/{chunk-19bhnbyn.js → chunk-dz4hrgw8.js} +83 -64
- package/dist/chunk-ed1qn902.js +2 -0
- package/dist/chunk-ev479f3z.js +2 -0
- package/dist/{chunk-x6pz1h3x.js → chunk-evs5gb3q.js} +10 -10
- package/dist/{chunk-w3c2c74q.js → chunk-fskpdva4.js} +46 -46
- package/dist/{chunk-5rtatjwq.js → chunk-gh34r6qb.js} +2 -2
- package/dist/chunk-gmg6aj7y.js +2 -0
- package/dist/{chunk-t455jpzx.js → chunk-h4ashx84.js} +1 -1
- package/dist/chunk-hc1m2psz.js +3 -0
- package/dist/{chunk-4hmdcmw1.js → chunk-hfe8g644.js} +6 -6
- package/dist/chunk-htaed68z.js +2 -0
- package/dist/{chunk-g8gzxhp8.js → chunk-j1rnhv0w.js} +3 -3
- package/dist/chunk-j2jm2nqz.js +2 -0
- package/dist/chunk-jb8d4n60.js +2 -0
- package/dist/{chunk-mktk70gq.js → chunk-k2nrx78c.js} +2 -2
- package/dist/chunk-kdnbxwkb.js +2 -0
- package/dist/{chunk-01hf94pa.js → chunk-kf2vas4j.js} +5 -5
- package/dist/chunk-kt5mzw2w.js +2 -0
- package/dist/chunk-kt994306.js +2 -0
- package/dist/{chunk-6qvskcwp.js → chunk-mer3aea0.js} +4 -4
- package/dist/chunk-mezphhpa.js +2 -0
- package/dist/{chunk-5wrmcbch.js → chunk-myhxapnn.js} +2 -2
- package/dist/chunk-n7d69a2q.js +2 -0
- package/dist/{chunk-z4te6223.js → chunk-nz6bzffm.js} +4 -4
- package/dist/{chunk-st71ar7s.js → chunk-pfas39mf.js} +9 -9
- package/dist/{chunk-j18z5nxq.js → chunk-phbnrw2h.js} +2 -2
- package/dist/{chunk-9g5sv1p6.js → chunk-q2p6y0cn.js} +7 -7
- package/dist/{chunk-6rxnh3th.js → chunk-qfppetcn.js} +1 -1
- package/dist/{chunk-wsbccxwy.js → chunk-qpbd2fwp.js} +9 -9
- package/dist/{chunk-y794qh69.js → chunk-qvqgbvfa.js} +6 -6
- package/dist/chunk-qz3tnvwm.js +2 -0
- package/dist/{chunk-dvbgbd06.js → chunk-rns21kkv.js} +2 -2
- package/dist/{chunk-08jyyegp.js → chunk-rq9cbw2y.js} +1 -1
- package/dist/{chunk-q7wj2ypd.js → chunk-s0ar60ng.js} +6 -6
- package/dist/chunk-sddytf9n.js +2 -0
- package/dist/chunk-spvr2vvh.js +2 -0
- package/dist/{chunk-0z189871.js → chunk-t84ww3qb.js} +2 -2
- package/dist/chunk-t91250ag.js +2 -0
- package/dist/{chunk-n8595zaf.js → chunk-tmbqz710.js} +1 -1
- package/dist/{chunk-hjp38m0w.js → chunk-tme29zh9.js} +2 -2
- package/dist/chunk-txkc9w9q.js +2 -0
- package/dist/chunk-ty1c2276.js +2 -0
- package/dist/{chunk-det49x62.js → chunk-v5500ews.js} +2 -2
- package/dist/chunk-vepjs3tg.js +2 -0
- package/dist/{chunk-v3anfm9d.js → chunk-vfbdxxbf.js} +2 -2
- package/dist/{chunk-7mehf3h5.js → chunk-w9c7z8p3.js} +2 -2
- package/dist/chunk-wfp754ya.js +2 -0
- package/dist/chunk-wp3qcfb4.js +3 -0
- package/dist/{chunk-ga48aas6.js → chunk-x17fpc0x.js} +6 -6
- package/dist/chunk-x3sbsxdq.js +2 -0
- package/dist/chunk-xdcvp8tt.js +2 -0
- package/dist/{chunk-ebkjpj5m.js → chunk-xh98er3b.js} +2 -2
- package/dist/{chunk-9z9f3d6b.js → chunk-xrj3tekf.js} +2 -2
- package/dist/chunk-xxnh7gv8.js +2 -0
- package/dist/{chunk-zswn0s45.js → chunk-y2t8xd39.js} +2 -2
- package/dist/chunk-y4egzqqf.js +2 -0
- package/dist/chunk-y4nm9wq4.js +2 -0
- package/dist/{chunk-ygkwp4sf.js → chunk-y5hdc1sb.js} +2 -2
- package/dist/chunk-ygx0akfn.js +2 -0
- package/dist/chunk-yn9fwnq2.js +2 -0
- package/dist/{chunk-3dcdgp1k.js → chunk-yq9rfnd6.js} +1 -1
- package/dist/chunk-z0gfb7b4.js +2 -0
- package/dist/chunk-z3e54btj.js +2 -0
- package/dist/{chunk-773vgw1k.js → chunk-z6fb4m1j.js} +3 -3
- package/dist/cli.js +21 -21
- package/dist/client/signals-class-runtime.js +1 -1
- package/dist/client/signals-component-hydration-runtime.js +1 -1
- package/dist/client/signals-component-props-runtime.js +3 -3
- package/dist/client/signals-container-cleanup-runtime.js +1 -1
- package/dist/client/signals-dom-ready-runtime.js +4 -4
- package/dist/client/signals-event-shorthand-runtime.js +2 -2
- package/dist/client/signals-expression-runtime.js +21 -2
- package/dist/client/signals-for-runtime.js +6 -6
- package/dist/client/signals-handler-runtime.js +1 -1
- package/dist/client/signals-hydration-audit-runtime.js +1 -1
- package/dist/client/signals-hydration-runtime.js +1 -1
- package/dist/client/signals-if-chain-runtime.js +3 -3
- package/dist/client/signals-if-runtime.js +7 -7
- package/dist/client/signals-lazy-hydration-runtime.js +1 -1
- package/dist/client/signals-manifest-hydration-runtime.js +1 -1
- package/dist/client/signals-model-runtime.js +1 -1
- package/dist/client/signals-mount-runtime.js +3 -3
- package/dist/client/signals-process-element-runtime.js +7 -7
- package/dist/client/signals-show-runtime.js +1 -1
- package/dist/client/signals-spa-load-runtime.js +5 -5
- package/dist/client/signals-style-runtime.js +1 -1
- package/dist/client-scope-bindings.d.ts +6 -0
- package/dist/client-scope-bindings.js +98 -0
- package/dist/client-script-bundler.js +9 -3
- package/dist/client-script.js +2 -1
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/includes.js +4 -2
- package/dist/native/components/primitives.d.ts +1 -0
- package/dist/pwa.js +3 -3
- package/dist/signal-processing.d.ts +2 -6
- package/dist/signal-processing.js +4 -80
- package/dist/ssg.js +10 -10
- package/dist/utils.js +5 -3
- package/package.json +5 -5
- package/dist/chunk-0fgp13q4.js +0 -2
- package/dist/chunk-0v0q0960.js +0 -2
- package/dist/chunk-0xxjmnqc.js +0 -2
- package/dist/chunk-1peszdcc.js +0 -2
- package/dist/chunk-1v92x0we.js +0 -15
- package/dist/chunk-2340emvg.js +0 -2
- package/dist/chunk-2xy5p3n4.js +0 -2
- package/dist/chunk-6p57991f.js +0 -2
- package/dist/chunk-711zygzk.js +0 -2
- package/dist/chunk-74r2q9ab.js +0 -2
- package/dist/chunk-7h4mxhkh.js +0 -2
- package/dist/chunk-7zdefvrn.js +0 -2
- package/dist/chunk-847nyz30.js +0 -2
- package/dist/chunk-8898f767.js +0 -2
- package/dist/chunk-9c7wkq4t.js +0 -2
- package/dist/chunk-9g01gnz5.js +0 -6
- package/dist/chunk-9wbraw07.js +0 -2
- package/dist/chunk-apaqfgsx.js +0 -2
- package/dist/chunk-bdnahg9m.js +0 -2
- package/dist/chunk-bfste5zk.js +0 -2
- package/dist/chunk-by4ngspf.js +0 -4
- package/dist/chunk-c0yb755y.js +0 -2
- package/dist/chunk-chaee0vj.js +0 -2
- package/dist/chunk-cy1krwqy.js +0 -2
- package/dist/chunk-d57fh04e.js +0 -2
- package/dist/chunk-dcham5kg.js +0 -2
- package/dist/chunk-e876sg0j.js +0 -2
- package/dist/chunk-ekfmad19.js +0 -2
- package/dist/chunk-f0ghgkxs.js +0 -2
- package/dist/chunk-fnzv245x.js +0 -2
- package/dist/chunk-hjkm6k8c.js +0 -2
- package/dist/chunk-hpvkkke2.js +0 -2
- package/dist/chunk-jb683m9n.js +0 -2
- package/dist/chunk-jfqvmq5w.js +0 -2
- package/dist/chunk-k1vjhhd4.js +0 -2
- package/dist/chunk-k5kj93g7.js +0 -2
- package/dist/chunk-kp4j8vja.js +0 -2
- package/dist/chunk-mb8c650x.js +0 -2
- package/dist/chunk-mfcxhfhb.js +0 -2
- package/dist/chunk-mmqt6qkf.js +0 -2
- package/dist/chunk-n6ek151q.js +0 -2
- package/dist/chunk-ph3ttt90.js +0 -2
- package/dist/chunk-pk68a878.js +0 -2
- package/dist/chunk-ptas1qqx.js +0 -2850
- package/dist/chunk-pz5zh3tg.js +0 -2
- package/dist/chunk-q068mc46.js +0 -2
- package/dist/chunk-q4a2j4qr.js +0 -3
- package/dist/chunk-rfkrktt9.js +0 -2
- package/dist/chunk-rj0nyb2t.js +0 -2
- package/dist/chunk-smpyb21z.js +0 -2
- package/dist/chunk-swv69q75.js +0 -4
- package/dist/chunk-t9ww2z0r.js +0 -2
- package/dist/chunk-th9wcse5.js +0 -2
- package/dist/chunk-v1ck0wd3.js +0 -2
- package/dist/chunk-vgd3yq11.js +0 -3
- package/dist/chunk-w24zd7sj.js +0 -2
- package/dist/chunk-wfettff6.js +0 -2
- package/dist/chunk-xfvbm4pn.js +0 -2
- package/dist/chunk-z04480ar.js +0 -2
- package/dist/chunk-zemkt4kg.js +0 -2
|
@@ -0,0 +1,2852 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Fn,y,ea,qt,so,ta,na,ra,sa}from"./chunk-rns21kkv.js";import{I}from"./chunk-4fv3jq16.js";import{t,W,q,i,ae,to,O,Ut,Ln,no,Er,l,p,Qi,N,Ie,ut,c,$r}from"./chunk-9b4e815s.js";import{Hn,Vn,Or,Ne}from"./chunk-d1ya7f79.js";import{S,Ys,ct,Zs,Gi,An,Pn,Ki,Pe,Xi,In,Ji,Vt,Qs,Yi,On,Dn,_r,we,eo,xe,Cr}from"./chunk-evs5gb3q.js";import{Gs,Ks,Xs,Js,wr,xr}from"./chunk-7ky2ny63.js";import{Ui,Us,yr,br}from"./chunk-nz6bzffm.js";import{be,Ht,vr,qs,_,it}from"./chunk-3p2b88pd.js";import{Rn}from"./chunk-70npkeh2.js";import{lo}from"./chunk-1ma56c2h.js";import{Li,ji,Fi,zi}from"./chunk-62kxavc5.js";import{ot}from"./chunk-v5500ews.js";import{s,Re}from"./chunk-mer3aea0.js";import{zt,qi,Tn,a,$n}from"./chunk-wp3qcfb4.js";import{d}from"./chunk-yn2d8x8m.js";import{E,D,jn,ro}from"./chunk-7a8jkwah.js";import{Nr}from"./chunk-y5hdc1sb.js";import ns from"path";import Do from"fs";var qh=new Set(["touchstart","touchmove","wheel","mousewheel"]);function cc(v,k){if(k.passive)return!0;if(k.prevent||k.nonpassive)return!1;return qh.has(v.toLowerCase())}var Hu=new Set(["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","wheel","keydown","keyup","keypress","submit","reset","change","input","focus","blur","focusin","focusout","select","invalid","touchstart","touchend","touchmove","touchcancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","scroll","resize","load","error","abort","animationstart","animationend","animationiteration","transitionstart","transitionend","transitionrun","transitioncancel","mounted","unmounted"]),qu={enter:"Enter",tab:"Tab",delete:"Delete",backspace:"Backspace",esc:"Escape",escape:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},Kh=new Set(["ctrl","alt","shift","meta"]),Gu={left:0,middle:1,right:2};function Ku(v){let k={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,nonpassive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let C of v){let R=C.toLowerCase();if(R==="prevent")k.prevent=!0;else if(R==="stop")k.stop=!0;else if(R==="once")k.once=!0;else if(R==="capture")k.capture=!0;else if(R==="self")k.self=!0;else if(R==="passive")k.passive=!0;else if(R==="nonpassive")k.nonpassive=!0;else if(Kh.has(R))k.systemKeys.push(R);else if(R in Gu)k.mouse=R;else if(R in qu||/^[a-z]$/.test(R))k.keys.push(qu[R]||R.toUpperCase());else if(R.startsWith("debounce")){let T=R.match(/debounce(?:\.(\d+))?/);k.debounce=T?.[1]?Number.parseInt(T[1],10):300}else if(R.startsWith("throttle")){let T=R.match(/throttle(?:\.(\d+))?/);k.throttle=T?.[1]?Number.parseInt(T[1],10):300}}return k}function Ju(v,k=""){let C=[],R=0,T=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,z;while((z=T.exec(v))!==null){let[F,V,H]=z,K=z.index,X=K+F.length,G=`__stx_evt_${k}${R++}`,te=[],ce=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,ee;while((ee=ce.exec(H))!==null){let[,ue,de]=ee,fe=ue.split("."),pe=fe[0];if(!Hu.has(pe))continue;te.push({attribute:`@${ue}`,event:pe,handler:de,modifiers:Ku(fe.slice(1)),elementId:G})}let le=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((ee=le.exec(H))!==null){let[,ue,de]=ee,fe=ue.split("."),pe=fe[0];if(!Hu.has(pe))continue;te.push({attribute:`@${ue}`,event:pe,handler:de,modifiers:Ku(fe.slice(1)),elementId:G})}if(te.length>0)C.push({originalTag:F,elementId:G,events:te,startIndex:K,endIndex:X})}return C}function Xh(v){let k=[],{modifiers:C}=v;if(C.self)k.push("if ($event.target !== $el) return");for(let R of C.systemKeys)k.push(`if (!$event.${R}Key) return`);if(C.keys.length>0){let R=C.keys.map((T)=>`$event.key === '${T}'`).join(" || ");k.push(`if (!(${R})) return`)}if(C.mouse!==null){let R=Gu[C.mouse];k.push(`if ($event.button !== ${R}) return`)}if(C.prevent)k.push("$event.preventDefault()");if(C.stop)k.push("$event.stopPropagation()");return k.join("; ")}function Zh(v,k){let C=v;if(k.debounce!==null)C=`__stx_debounce(() => { ${C} }, ${k.debounce})`;else if(k.throttle!==null)C=`__stx_throttle(() => { ${C} }, ${k.throttle})`;return C}function lc(v){let k=v.trim();if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(k))return v;return`if (typeof ${k} === 'function' && !${k}._isSignal) ${k}($event);`}function Gh(v){let{modifiers:k}=v,C=v.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),R=Xh(v),T=Zh(lc(v.handler),k),z=[];if(k.once)z.push("once: true");if(k.capture)z.push("capture: true");if(cc(v.event,k))z.push("passive: true");let F=z.length>0?`, { ${z.join(", ")} }`:"",V=T.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if(v.event==="mounted")return`
|
|
3
|
+
(function() {
|
|
4
|
+
var $el = document.getElementById('${C}');
|
|
5
|
+
if (!$el) return;
|
|
6
|
+
// Run mounted handler immediately (DOM is ready)
|
|
7
|
+
var scope = $el.closest('[data-stx-scope]');
|
|
8
|
+
if (scope && scope.__stx_execute) {
|
|
9
|
+
scope.__stx_execute('${V}', null, $el);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
__stx_runHandler('${V}', null, $el);
|
|
13
|
+
}
|
|
14
|
+
})();`;if(v.event==="unmounted")return`
|
|
15
|
+
(function() {
|
|
16
|
+
var $el = document.getElementById('${C}');
|
|
17
|
+
if (!$el) return;
|
|
18
|
+
// Set up MutationObserver to detect removal
|
|
19
|
+
var observer = new MutationObserver(function(mutations) {
|
|
20
|
+
for (var m of mutations) {
|
|
21
|
+
for (var node of m.removedNodes) {
|
|
22
|
+
if (node === $el || (node.contains && node.contains($el))) {
|
|
23
|
+
observer.disconnect();
|
|
24
|
+
var scope = $el.closest('[data-stx-scope]');
|
|
25
|
+
if (scope && scope.__stx_execute) {
|
|
26
|
+
scope.__stx_execute('${V}', null, $el);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
__stx_runHandler('${V}', null, $el);
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
37
|
+
// Store observer for cleanup
|
|
38
|
+
$el.__stx_unmount_observer = observer;
|
|
39
|
+
})();`;return`
|
|
40
|
+
(function() {
|
|
41
|
+
var $el = document.getElementById('${C}');
|
|
42
|
+
if (!$el) return;
|
|
43
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
44
|
+
$el.addEventListener('${v.event}', function($event) {
|
|
45
|
+
${R?R+";":""}
|
|
46
|
+
// Find the closest reactive scope and execute within its context
|
|
47
|
+
var scope = $el.closest('[data-stx-scope]');
|
|
48
|
+
if (scope && scope.__stx_execute) {
|
|
49
|
+
scope.__stx_execute('${V}', $event, $el);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// Fallback for non-reactive context (entity-safe; decoded + run in memory)
|
|
53
|
+
__stx_runHandler('${V}', $event, $el);
|
|
54
|
+
}
|
|
55
|
+
}${F});
|
|
56
|
+
})();`}function uc(v){if(v.length===0)return"";return`
|
|
57
|
+
<script data-stx-events>
|
|
58
|
+
(function() {
|
|
59
|
+
'use strict';
|
|
60
|
+
|
|
61
|
+
// Utility functions
|
|
62
|
+
function __stx_debounce(fn, delay) {
|
|
63
|
+
var timeout;
|
|
64
|
+
return function() {
|
|
65
|
+
var args = arguments;
|
|
66
|
+
var ctx = this;
|
|
67
|
+
clearTimeout(timeout);
|
|
68
|
+
timeout = setTimeout(function() { fn.apply(ctx, args); }, delay);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function __stx_throttle(fn, delay) {
|
|
73
|
+
var last = 0;
|
|
74
|
+
return function() {
|
|
75
|
+
var now = Date.now();
|
|
76
|
+
if (now - last >= delay) {
|
|
77
|
+
last = now;
|
|
78
|
+
fn.apply(this, arguments);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Non-reactive fallback runner. The handler is embedded HTML-entity-encoded
|
|
84
|
+
// so the surrounding script element can never contain raw markup, including
|
|
85
|
+
// its own closing tag; we decode it to JS only in memory here, then run it
|
|
86
|
+
// with $event/$el in scope.
|
|
87
|
+
//
|
|
88
|
+
// This comment must not spell that closing tag out. It used to, as an
|
|
89
|
+
// example, and a browser ends the script element at the FIRST one it sees \u2014
|
|
90
|
+
// so everything below this line, __stx_runHandler included, was emitted as
|
|
91
|
+
// page text and no listener was ever bound. The comment about escaping was
|
|
92
|
+
// the thing that needed escaping.
|
|
93
|
+
function __stx_runHandler(h, $event, $el) {
|
|
94
|
+
var code = h
|
|
95
|
+
.replace(/</g, '<')
|
|
96
|
+
.replace(/>/g, '>')
|
|
97
|
+
.replace(/"/g, '"')
|
|
98
|
+
.replace(/'/g, "'")
|
|
99
|
+
.replace(/'/g, "'")
|
|
100
|
+
.replace(/&/g, '&');
|
|
101
|
+
try {
|
|
102
|
+
// eslint-disable-next-line no-new-func
|
|
103
|
+
(new Function('$event', '$el', code)).call($el, $event, $el);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
if (typeof console !== 'undefined') console.error('[stx] event handler error:', e);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Event listeners
|
|
111
|
+
${v.map(Gh).join(`
|
|
112
|
+
`)}
|
|
113
|
+
})();
|
|
114
|
+
</script>`}function Jh(v,k=""){let C=Ju(v,k);if(C.length===0)return{template:v,bindings:[]};let R=v,T=[];for(let z=C.length-1;z>=0;z--){let F=C[z],V=F.originalTag;if(!V.includes(" id="))V=V.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${F.elementId}"`);else{let H=V.match(/id=["']([^"']+)["']/);if(H)for(let K of F.events)K.elementId=H[1]}for(let H of F.events){let K=H.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=new RegExp(`\\s*${K}\\s*=\\s*"[^"]*"`,"g"),G=new RegExp(`\\s*${K}\\s*=\\s*'[^']*'`,"g");V=V.replace(X,""),V=V.replace(G,"")}R=R.slice(0,F.startIndex)+V+R.slice(F.endIndex),T.push(...F.events)}return{template:R,bindings:T}}function Xu(v){let k=v.$uid;return typeof k==="string"&&k?`${k}_`:""}function Sd(v,k,C){if(ta(v))return v;if(k.__stx_sfc_mode){if(/x-data\s*=\s*["']/.test(v))return v;let{template:V,bindings:H}=Jh(v,Xu(k)),K=k.__stx_event_bindings||[];return k.__stx_event_bindings=[...K,...H],V}let R=Ju(v,Xu(k));if(R.length===0)return v;let T=v;for(let V=R.length-1;V>=0;V--){let H=R[V],K=H.originalTag;if(!K.includes(" id="))K=K.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${H.elementId}"`);else{let X=K.match(/id=["']([^"']+)["']/);if(X)for(let G of H.events)G.elementId=X[1]}for(let X of H.events){let G=X.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),te=new RegExp(`\\s*${G}\\s*=\\s*"[^"]*"`,"g"),ce=new RegExp(`\\s*${G}\\s*=\\s*'[^']*'`,"g");K=K.replace(te,""),K=K.replace(ce,"")}T=T.slice(0,H.startIndex)+K+T.slice(H.endIndex)}let z=uc(R.flatMap((V)=>V.events)),F=T.lastIndexOf("</body>");if(F!==-1)T=T.slice(0,F)+z+`
|
|
115
|
+
`+T.slice(F);else T+=z;return T}function $d(v,k){let C=new Set;for(let R of v.split(",")){let T=R.trim().replace(/^\.\.\./,"").trim();if(!T)continue;if(k){let z=T.lastIndexOf(":");if(z!==-1)T=T.slice(z+1).trim()}if(T=T.split("=")[0].trim(),/^[A-Za-z_$][\w$]*$/.test(T))C.add(T)}return C}function Wi(v,k){let C=s(v),{depths:R,balanced:T}=Re(C),z=(V)=>!T||R[V]===0,F=new RegExp(`(?:^|[^\\w$.])((?:const|let|var|function|class)\\s+${k}\\b)`,"g");for(let V of C.matchAll(F)){let H=(V.index??0)+V[0].length-V[1].length;if(z(H))return!0}for(let V of C.matchAll(/(?:const|let|var)\s*\{([^}]*)\}/g))if(z(V.index??0)&&$d(V[1],!0).has(k))return!0;for(let V of C.matchAll(/(?:const|let|var)\s*\[([^\]]*)\]/g))if(z(V.index??0)&&$d(V[1],!1).has(k))return!0;return!1}function M(v,k=!1){let C=s(v),R=[],T=new Set,z=0,F=0,V=C.length,H=()=>{if(z!==0)return;let K=C.slice(F).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);if(K){if(k&&K[1]==="const")return;let ee=K[2];if(!T.has(ee))R.push(ee),T.add(ee);return}let X=C.slice(F).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(X){if(k&&C.slice(F).startsWith("const"))return;X[1].split(",").forEach((ee)=>{let le=ee.trim();if(!le)return;let ue=le.indexOf(":"),fe=(ue>=0?le.slice(ue+1).trim():le).split(/[\s=]/)[0];if(fe&&!T.has(fe))R.push(fe),T.add(fe)});return}let G=C.slice(F).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(G){if(k&&C.slice(F).startsWith("const"))return;G[1].split(",").forEach((ee)=>{let le=ee.trim().replace(/^\.\.\./,"");if(!le)return;let ue=le.split(/[\s=]/)[0];if(ue&&!T.has(ue))R.push(ue),T.add(ue)});return}if(k)return;let te=C.slice(F).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(te){let ee=te[1];if(!T.has(ee))R.push(ee),T.add(ee);return}let ce=C.slice(F).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(ce){let ee=ce[1];if(!T.has(ee))R.push(ee),T.add(ee)}};while(F<V){if(C[F]==="{"){z++,F++;continue}if(C[F]==="}"){z--,F++;continue}if(z===0&&/[a-z]/i.test(C[F])&&(F===0||/\s|[;{}()]/.test(C[F-1])))H();F++}return R.join(", ")}function Uo(v){return`{ enumerable: true, configurable: true, get() { return ${v} }, set(__stxValue_${v}) { ${v} = __stxValue_${v} } }`}function Yh(v,k=M(v).split(",").map((C)=>C.trim()).filter(Boolean)){let C=new Set(M(v,!0).split(",").map((R)=>R.trim()));return k.map((R)=>C.has(R)?`get ${R}() { return ${R} }, set ${R}(__stxValue_${R}) { ${R} = __stxValue_${R} }`:R).join(", ")}function Ho(v,k){let C=`{ ${Yh(v,k)} }`;return M(v).split(",").some((R)=>R.trim()==="__stxLiveBindings")?`Object.defineProperties(${C}, Object.getOwnPropertyDescriptors(__stxLiveBindings))`:C}var _d="",qo,Tr=/^[A-Za-z_$][\w$]*$/,Qh=new Set(["if","for","while","switch","with"]),kd=["(","[","{"],Ed=[")","]","}"],ey=new Set(["const","let","var","return","if","for","while","do","switch","try","throw","export"]);function ty(v){let k=s(v),C=[];for(let R of k.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let T=R.index??0;C.push({text:R[0],start:T,end:T+R[0].length})}return{code:k,tokens:C}}function dc(v){if(qo&&v===_d)return qo;let{code:k,tokens:C}=ty(v),R=new Map,T=[];for(let ee=0;ee<C.length;ee++){let le=C[ee].text;if(["(","[","{"].includes(le))T.push(ee);else if([")","]","}"].includes(le)){let ue=T.at(-1);if(ue!==void 0&&["()","[]","{}"].includes(C[ue].text+le))T.pop(),R.set(ue,ee),R.set(ee,ue)}}function z(ee,le){let ue=[],de=ee;for(let fe=ee;fe<le;fe++){if(["(","[","{"].includes(C[fe].text)&&(R.get(fe)??le)<le){fe=R.get(fe);continue}if(C[fe].text===",")ue.push([de,fe]),de=fe+1}return ue.push([de,le]),ue}let F=[];function V(ee,le,ue,de=!1){if(C[ee]?.text==="...")ee++;if(ee>=le)return;let fe=C[ee].text;if(Tr.test(fe)){if(ue.add(fe),ue===X)F.push({name:fe,token:ee,functionScoped:de});return}if(fe!=="{"&&fe!=="[")return;let pe=R.get(ee);if(pe===void 0||pe>=le)return;for(let[Ae,Se]of z(ee+1,pe)){let ve=Ae;if(fe==="{")for(let De=Ae;De<Se;De++){if(C[De].text===":"){ve=De+1;break}if(C[De].text==="=")break;if(["(","[","{"].includes(C[De].text)&&R.has(De))De=R.get(De)}V(ve,Se,ue,de)}}function H(ee,le){let ue=new Set;for(let[de,fe]of z(ee,le))V(de,fe,ue);return ue}function K(ee){let le=ee;for(;le<C.length;le++){let ue=C[le].text;if(["(","[","{"].includes(ue)&&R.has(le)){le=R.get(le);continue}if([",",";",")","]","}"].includes(ue))break}return C[Math.max(ee,le-1)]?.end??k.length}let X=new Set,G=[];for(let ee=0;ee<C.length;ee++)if(C[ee].text==="=>"){let le=ee-1,ue=le,de;if(C[le]?.text===")"&&R.has(le))ue=R.get(le),de=H(ue+1,le);else if(C[le]&&Tr.test(C[le].text))de=new Set([C[le].text]);else continue;let fe=ee+1,pe=C[fe]?.text==="{"&&R.has(fe)?C[R.get(fe)].end:K(fe);G.push({start:C[ue].start,end:pe,bodyStart:C[fe]?.start??pe,functionBody:!0,names:de})}else if(C[ee].text==="("&&R.has(ee)){let le=C[ee-1]?.text;if(!le||Qh.has(le)||!Tr.test(le)&&le!=="*"&&le!=="]")continue;let ue=R.get(ee),de=ue+1;if(C[de]?.text===":"){de++;while(de<C.length&&!["{","=>",";","="].includes(C[de].text))de++}if(C[de]?.text!=="{"||!R.has(de))continue;G.push({start:C[ee].start,end:C[R.get(de)].end,bodyStart:C[de].start,functionBody:le!=="catch",names:H(ee+1,ue)})}function te(ee){let le=ee;for(;le<C.length;le++){let ue=C[le].text;if(kd.includes(ue)&&R.has(le)){le=R.get(le);continue}if(ue===";"||Ed.includes(ue))break;let de=C[le-1];if(le>ee&&ey.has(ue)&&de.text!==".")break;if(le>ee&&/[\n\r]/.test(k.slice(de.end,C[le].start))&&(/^[\w$]+$/.test(de.text)||Ed.includes(de.text)||['"',"'","`"].includes(de.text))&&Tr.test(ue)&&!["in","of","instanceof"].includes(ue))break}return le}let ce=[];for(let ee=0;ee<C.length;ee++){if(C[ee].text!=="for")continue;let le=C[ee+1]?.text==="await"?ee+2:ee+1;if(C[le]?.text!=="("||!R.has(le))continue;let ue=R.get(le),de=ue+1,fe=C[de]?.text==="{"&&R.has(de)?R.get(de):te(de),pe=C[fe]?.text===";"||C[fe]?.text==="}"?C[fe].end:C[Math.max(de,fe-1)]?.end??k.length;ce.push({headStart:le,headEnd:ue,start:C[le].start,end:pe})}for(let ee=0;ee<C.length;ee++){let le=C[ee].text,ue=C[ee-1]?.text;if(ue==="."||C[ee+1]?.text===":")continue;if(ue==="as"||ue==="<")continue;if(le==="const"||le==="let"||le==="var"){let de=te(ee+1),fe=ee+1,pe=!1,Ae=!1,Se=0;for(let ve=ee+1;ve<=de;ve++){let De=C[ve]?.text;if(ve<de&&kd.includes(De)&&R.has(ve)&&R.get(ve)<de){ve=R.get(ve);continue}if(ve<de&&De===":"&&!Ae)pe=!0;else if(ve<de&&De==="="&&Se===0)pe=!1,Ae=!0;else if(ve<de&&pe&&De==="<")Se++;else if(ve<de&&pe&&De===">"&&Se>0)Se--;else if(ve===de||De===","&&Se===0)V(fe,ve,X,le==="var"),fe=ve+1,pe=!1,Ae=!1}}else if(le==="function"||le==="class"){let de=ee+1;if(C[de]?.text==="*")de++;if(C[de]&&Tr.test(C[de].text)&&C[de].text!=="extends")X.add(C[de].text),F.push({name:C[de].text,token:de})}else if(le==="import"){let de=ee+1;if(C[de]?.text==="*"&&C[de+1]?.text==="as")de+=2;let fe=C[de]?.text;if(fe&&Tr.test(fe)&&fe!=="type"&&C[de+1]?.text!=="("&&C[de+1]?.text!==".")X.add(fe),F.push({name:fe,token:de,file:!0});let pe=C[de]?.text==="{"?de:C[de+1]?.text===","&&C[de+2]?.text==="{"?de+2:-1;if(pe!==-1&&R.has(pe)){let Ae=R.get(pe);for(let[Se,ve]of z(pe+1,Ae)){let De=ve-1;while(De>=Se&&!Tr.test(C[De].text))De--;if(De>=Se&&C[De].text!=="type")F.push({name:C[De].text,token:De,file:!0})}}}}return _d=v,qo={code:k,scopes:G,loops:ce,declarations:X,sites:F,tokens:C,pairs:R},qo}function fc(v){let k=dc(v);return{code:k.code,shadows:(C,R)=>k.scopes.some((T)=>R>=T.start&&R<T.end&&T.names.has(C))}}function Ko(v){return new Set(dc(v).declarations)}function Ot(v,k){let{scopes:C,loops:R,sites:T,tokens:z,pairs:F}=dc(v),V=Array.from({length:z.length},()=>-1),H=[];for(let ce=0;ce<z.length;ce++){V[ce]=H.length?H[H.length-1]:-1;let ee=z[ce].text;if(ee==="{"&&F.has(ce))H.push(ce);else if(ee==="}"&&H.length&&F.get(ce)===H[H.length-1])H.pop()}let K=new Set,X=new Map;for(let ce of T){if(!k.has(ce.name))continue;K.add(ce.token);let ee=ce.file?-1:V[ce.token],le=ee===-1?[0,Number.POSITIVE_INFINITY]:[z[ee].start,z[F.get(ee)].end];if(ce.functionScoped){let de=z[ce.token].start,fe=C.filter((pe)=>pe.functionBody&&de>=pe.bodyStart&&de<pe.end).sort((pe,Ae)=>pe.end-pe.bodyStart-(Ae.end-Ae.bodyStart))[0];le=fe?[fe.bodyStart,fe.end]:[0,Number.POSITIVE_INFINITY]}else if(!ce.file){let de=R.filter((fe)=>ce.token>fe.headStart&&ce.token<fe.headEnd).sort((fe,pe)=>fe.headEnd-fe.headStart-(pe.headEnd-pe.headStart))[0];if(de)le=[de.start,de.end]}let ue=X.get(ce.name);if(ue)ue.push(le);else X.set(ce.name,[le])}let G=new Set;for(let ce=0;ce<z.length;ce++){if(z[ce].text!=="import"||z[ce-1]?.text===".")continue;let ee=ce+1;if(z[ee]?.text==="type")ee++;if(z[ee]&&Tr.test(z[ee].text)&&z[ee+1]?.text===",")ee+=2;if(z[ee]?.text==="{"&&F.has(ee))for(let le=ee+1;le<F.get(ee);le++)G.add(le)}let te=new Set;for(let ce=0;ce<z.length;ce++){let ee=z[ce].text;if(!k.has(ee)||te.has(ee)||K.has(ce)||G.has(ce))continue;let le=z[ce-1]?.text;if(le==="#"||le==="."&&z[ce-2]?.text!=="..")continue;if(z[ce+1]?.text===":"&&(le==="{"||le===","))continue;let ue=z[ce].start;if(X.get(ee)?.some(([de,fe])=>ue>=de&&ue<fe))continue;if(C.some((de)=>ue>=de.start&&ue<de.end&&de.names.has(ee)))continue;te.add(ee)}return te}import Xo from"fs";import tn from"path";function gn(v){return v.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var Cd=new Map;function Zo(v,k=!0){let C=Cd.get(v);if(k&&C)return C;let R=new Map,T=[tn.join(v,"src"),tn.join(v,"dist"),v];function z(F,V){if(V>6)return;let H;try{H=Xo.readdirSync(F,{withFileTypes:!0})}catch{return}for(let K of H){let X=tn.join(F,K.name);if(K.isDirectory()){if(K.name==="node_modules"||K.name.startsWith("."))continue;z(X,V+1)}else if(K.isFile()&&K.name.endsWith(".stx")){let G=K.name.slice(0,-4);if(!R.has(G))R.set(G,X);let te=G.toLowerCase();if(!R.has(te))R.set(te,X);let ce=gn(G);if(!R.has(ce))R.set(ce,X)}}}for(let F of T)if(z(F,0),R.size>0)break;if(k)Cd.set(v,R);return R}function Go(v,k){if(v.startsWith(".")||v.startsWith("/"))return null;let C=k;while(!0){let R=tn.join(C,"node_modules",v);try{if(Xo.statSync(R).isDirectory())return R}catch{}let T=tn.dirname(C);if(T===C)return null;C=T}}function Jo(v,k,C={}){return[tn.resolve(tn.dirname(k),`${v}.stx`),tn.resolve(tn.dirname(k),v),tn.resolve(C.componentsDir||"components",`${v}.stx`),tn.resolve(C.componentsDir||"components",v),v.endsWith(".stx")?v:`${v}.stx`]}function Rd(v){let k=v.endsWith(".stx")?v.slice(0,-4):v,C=k.split("-").map((T)=>T.charAt(0).toUpperCase()+T.slice(1)).join(""),R=gn(k);return[k,C,R]}function pc(v,k){let[C,R,T]=Rd(v);for(let z of[C,C.toLowerCase(),R,T]){let F=k?.__importedComponents?.get(z);if(F!==void 0)return F}}function*gc(v,k,C={},R){let T=Rd(v);if(T[0].startsWith("./")||T[0].startsWith("../")){yield tn.resolve(tn.dirname(k),`${T[0]}.stx`);return}let z=[...new Set(T.map((H)=>`${H}.stx`))],F=C.projectRoot||process.cwd(),V=[...R?.__originalFilePath?[tn.join(tn.dirname(R.__originalFilePath),"components")]:[],...C.componentsDir?[C.componentsDir]:[],tn.join(tn.dirname(k),"components"),tn.resolve(F,"src/components"),tn.resolve(F,"components"),...import.meta.dir?[tn.resolve(import.meta.dir,"components")]:[]];for(let H of new Set(V)){for(let K of z)yield tn.join(H,K);try{for(let K of Xo.readdirSync(H,{withFileTypes:!0}))if(K.isDirectory())for(let X of z)yield tn.join(H,K.name,X)}catch{}}}function Ad(v,k,C={},R){let T=pc(v,R);if(T!==void 0)return T;for(let z of gc(v,k,C,R))try{if(Xo.statSync(z,{throwIfNoEntry:!1})?.isFile())return z}catch{}return null}import jh from"fs";import gt from"path";import{createHash as ny}from"crypto";var Yo="__stx_component_client_factories";function Qo(v){let k=v[Yo];return k instanceof Map?k:null}function Id(v){v[Yo]=new Map}function mc(v,k){let C=Qo(v);if(!C)return null;let R=ny("sha256").update(k).digest("hex").slice(0,16),T=C.get(R);if(T)T.instances++;else C.set(R,{body:k,instances:1});return R}function Pd(v,k){let C=Qo(k);if(!C?.size)return v;let R=new Map;for(let[X,G]of C)if(G.instances===1)R.set(X,G.body);let T=[];if(R.size>0){let X=[...R.keys()].map((ce)=>JSON.stringify(ce).replace(/[$()*+.?[\\\]^{|}]/g,"\\$&")).join("|"),G=new RegExp(`window\\.__stxComponentFactories\\[(${X})\\]\\(("[^"]+")\\);`,"g"),te=G.exec(v);while(te!==null){let ce=R.get(JSON.parse(te[1]));if(ce!==void 0)T.push({start:te.index,end:te.index+te[0].length,replacement:`(${ce})(${te[2]});`});te=G.exec(v)}}let z=[...C].filter(([,X])=>X.instances>1);if(z.length===0)return Td(v,T);let V=`<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
|
|
116
|
+
(function() {
|
|
117
|
+
const factories = window.__stxComponentFactories = window.__stxComponentFactories || {};
|
|
118
|
+
${z.map(([X,G])=>` try { factories[${JSON.stringify(X)}] = factories[${JSON.stringify(X)}] || ${G.body}; }
|
|
119
|
+
catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(X)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
|
|
120
|
+
`)}
|
|
121
|
+
})();
|
|
122
|
+
</script>`,H=v.search(/<script\b(?=[^>]*\bdata-stx-scoped\b)/i),K=H<0?0:H;return T.push({start:K,end:K,replacement:`${V}
|
|
123
|
+
`}),Td(v,T)}function Td(v,k){if(k.length===0)return v;k.sort((z,F)=>z.start-F.start||z.end-F.end);let C=Array(k.length*2+1),R=0,T=0;for(let z of k)C[T++]=v.slice(R,z.start),C[T++]=z.replacement,R=z.end;return C[T]=v.slice(R),C.join("")}function Dd(v){let k=Qo(v),C=new Map;if(k)for(let[R,T]of k)C.set(R,T.instances);return C}function Od(v,k){let C=Qo(v);if(!C)return[];let R=[];for(let[T,z]of C){let F=z.instances-(k.get(T)??0);if(F>0)R.push({body:z.body,count:F})}return R}function Md(v,k){for(let{body:C,count:R}of k)for(let T=0;T<R;T++)mc(v,C)}import Xd from"fs";var Nd=0,hc=new Map;function pi(){Nd=0,hc.clear()}function ia(v,k){let C=Nd++,R=`<!--__STX_${v.toUpperCase()}_${C}__-->`;return hc.set(R,{type:v,expression:k}),R}function fi(){let v={};for(let[k,C]of hc)v[k]={type:C.type,expression:C.expression};return v}function gi(v,k){let C=v;for(let[R,T]of k)C=C.split(R).join(T);return C}function ws(v){return v.includes("<!--__STX_")}var ry=/@(?=[a-zA-Z_]\w*\s*\(|end[a-zA-Z]*\b|else(?:if)?\b|empty\b|case\b|default\b|break\b|continue\b|fallback\b)/g;function sy(v){return Array.from({length:v},()=>"{").join("⁠")}function jd(v){return v.replace(/\{{2,}/g,(k)=>sy(k.length)).replace(/\{(?=!)/g,"{⁠").replace(ry,"@")}function Ld(v,k,C=!1){let R=v.slice(0,k),T=R.lastIndexOf("<"),z=R.lastIndexOf(">");if(T>=0&&z>T)return null;if(T<0&&!C)return null;let F=T>=0?R.slice(T+1):R;if(T>=0&&/^\s*[!/?]/.test(F))return/^\s*\/?\s*$/.test(F)?{kind:"tag-name"}:null;if(T>=0&&/^\s*$/.test(F))return{kind:"tag-name"};let V=/(?:^|\s)([^\s"'<>/=]+)\s*=\s*"([^"]*)$/.exec(F);if(V)return{kind:"attribute",name:V[1],quote:'"',valuePrefix:V[2]};let H=/(?:^|\s)([^\s"'<>/=]+)\s*=\s*'([^']*)$/.exec(F);if(H)return{kind:"attribute",name:H[1],quote:"'",valuePrefix:H[2]};let K=/(?:^|\s)([^\s"'<>/=]+)\s*=\s*([^\s"'=<>`]*)$/.exec(F);if(K)return{kind:"attribute",name:K[1],quote:null,valuePrefix:K[2]};return T>=0||/^\s*[^<>]*$/.test(F)?{kind:"tag"}:null}class tr extends Error{attribute;constructor(v,k){super(`Unsafe interpolation in ${v}: ${k}`);this.name="UnsafeInterpolationContextError",this.attribute=v}}var Bd="unsafe:";var iy=/^(?:javascript|vbscript|livescript|mocha|view-source):/,oy=/^data:(?:text\/html|text\/xml|application\/xhtml\+xml|application\/xml|image\/svg\+xml)/,ay=/^data:(?:text\/html|application\/xhtml\+xml)/,cy=new RegExp("[\\u0000-\\u0020\\u00A0\\u1680\\u2000-\\u200F\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+","g");function ly(v){return v.replace(cy,"").toLowerCase()}function yc(v){let k=v.toLowerCase();if(new RegExp("^(?:href|xlink:href|action|formaction|ping|cite|manifest|data|to)$").test(k))return"navigable";if(new RegExp("^(?:src|srcset|poster|background)$").test(k))return"fetched";return null}function oa(v,k="navigable"){let C=ly(v);if(iy.test(C))return!0;return k==="navigable"?oy.test(C):ay.test(C)}function Vi(v,k="navigable"){return oa(v,k)?"unsafe:"+v:v}function uy(v){let k=v.match(/(?:^|[\s"'`/])([A-Za-z][\w:-]*)\s*=\s*(["'])([^"']*)$/);if(!k)return null;if(k[3].trim()!=="")return null;return yc(k[1])}function zd(v,k,C=256){if(k<=C)return v.slice(0,k);let R=v.slice(k-C,k),T=R.search(/[\s"'`/]/);return T===-1?"":R.slice(T)}function Wd(v,k,C=k){let R=uy(v);return R&&oa(k,R)?"unsafe:"+C:C}var aa=/<script\b[^>]*>/iy,wc=/<\/script\s*>/ig,ca=/<style\b[^>]*>/iy,sl=/<\/style\s*>/ig;function Fd(v,k,C,R){C.lastIndex=k;let T=C.exec(v);if(!T||T.index!==k)return-1;R.lastIndex=C.lastIndex;let z=R.exec(v);if(!z)return-1;return z.index+z[0].length}function U(v,k){return Fd(v,k,aa,wc)}function us(v,k){return Fd(v,k,ca,sl)}function Ke(v,k){if(!v.startsWith("<!--",k))return-1;let C=v.indexOf("-->",k+4);if(C===-1)return-1;return C+3}function Vd(v,k){if(v.startsWith("<!--",k)){let T=Ke(v,k);return T===-1?v.length:T}if(aa.lastIndex=k,aa.exec(v)?.index===k){wc.lastIndex=aa.lastIndex;let T=wc.exec(v);return T?T.index+T[0].length:v.length}if(ca.lastIndex=k,ca.exec(v)?.index===k){sl.lastIndex=ca.lastIndex;let T=sl.exec(v);return T?T.index+T[0].length:v.length}return-1}function ne(v,k){let C=[],R=0,T=v.length,z=!1,F=null;while(R<T){let V=v[R];if(z){if(F){if(V===F)F=null}else if(V==='"'||V==="'")F=V;else if(V===">")z=!1;R++;continue}if(V!=="<"){let G=v.indexOf("<",R+1);if(G===-1)break;R=G;continue}let H=k(v,R);if(H>R){C.push({start:R,end:H,token:v.slice(R,H)}),R=H;continue}let K=Vd(v,R);if(K>R){R=K;continue}let X=v.charCodeAt(R+1);if(X>=65&&X<=90||X>=97&&X<=122)z=!0;R++}return C}function Ud(v){let k=0,C=0,R=0,T=!1,z=null;while(R<v.length){if(T){let G=v[R];if(z){if(G===z)z=null}else if(G==='"'||G==="'")z=G;else if(G===">")T=!1;R++;continue}let F=v.indexOf("<",R),V=F===-1?v.length:F;while(R<V){let G=v[R++];if(G==="{")k++;else if(G==="}")C++;if(k>=2&&C>=2)return!0}if(F===-1)break;let H=Vd(v,F);if(H>F){R=H;continue}let K=v.charCodeAt(F+1),X=K===47?v.charCodeAt(F+2):K;if(X>=65&&X<=90||X>=97&&X<=122)T=!0;R=F+1}return!1}function Hd(v,k){while(v.size>=k){let C=v.keys().next();if(C.done)return;v.delete(C.value)}}var dy=1024,fy=16777216,cs=new Map,xc=0;function py(v,k){cs.set(v,k),xc+=v.length+k.output.length;for(let[C,R]of cs){if(xc<=fy)break;cs.delete(C),xc-=C.length+R.output.length}}function qn(v,k,C,R){let T=R!==void 0&&v.length>=dy,z=T?`${R}\x00${v}`:"";if(T){let X=cs.get(z);if(X)return cs.delete(z),cs.set(z,X),{output:X.output,tokens:X.tokens.slice()}}let F=ne(v,k);if(F.length===0)return{output:v,tokens:[]};let V=F.map((X)=>X.token),H="",K=0;for(let X=0;X<F.length;X++){let G=F[X];H+=v.slice(K,G.start),H+=C(G.token,X),K=G.end}if(H+=v.slice(K),T)return py(z,{output:H,tokens:V}),{output:H,tokens:V.slice()};return{output:H,tokens:V}}var gy=1024,my=16777216,ls=new Map,bc=0;function hy(v,k){ls.set(v,k),bc+=v.length+k.output.length;for(let[C,R]of ls){if(bc<=my)break;ls.delete(C),bc-=C.length+R.output.length}}function vc(v,k,C){return{output:k,scripts:C,restore:(R)=>R===k?v:ds(R,C)}}function yn(v){let k=v.length>=gy;if(k){let T=ls.get(v);if(T)return ls.delete(v),ls.set(v,T),vc(v,T.output,T.scripts.slice())}let{output:C,tokens:R}=qn(v,U,(T,z)=>`\x00STX_SCRIPT_${z}\x00`);if(k)return hy(v,{output:C,scripts:R}),vc(v,C,R.slice());return vc(v,C,R)}function ds(v,k){if(k.length===0)return v;return v.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(C,R)=>k[+R]??"")}function Dt(v){let k=v.indexOf(" as ");if(k!==-1){let z=v.slice(0,k).trim(),F=v.slice(k+4).trim();return z&&F?{arrayExpr:z,itemVar:F}:null}let C=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(v);if(!C)return null;let R=C[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),T=C[2].trim();return R&&T?{arrayExpr:T,itemVar:R}:null}function la(v){let k=[],C=0,R="",T=0;for(let z=0;z<v.length;z++){let F=v[z];if(R){if(F==="\\")z++;else if(F===R)R="";continue}if(F==="'"||F==='"'||F==="`")R=F;else if(F==="("||F==="["||F==="{")C++;else if(F===")"||F==="]"||F==="}")C--;else if(F===","&&C===0)k.push(v.slice(T,z)),T=z+1}return k.push(v.slice(T)),k}function qd(v,k){let C=0;for(let R=0;R<v.length;R++){let T=v[R];if(T==="("||T==="["||T==="{")C++;else if(T===")"||T==="]"||T==="}")C--;else if(T===k&&C===0)return R}return-1}function Kd(v){let k=0;for(let C=0;C<v.length;C++){let R=v[C];if(R==="("||R==="["||R==="{")k++;else if((R===")"||R==="]"||R==="}")&&--k===0)return C}return-1}function Ur(v,k){let C=v.trim().replace(/^\.\.\./,"").trim(),R=qd(C,"=");if(R!==-1&&C[R+1]!==">")C=C.slice(0,R).trim();if(!C)return;if(C.startsWith("{")&&C.endsWith("}")){for(let T of la(C.slice(1,-1))){let z=T.trim();if(!z)continue;if(z.startsWith("...")){Ur(z,k);continue}let F=qd(z,":");Ur(F===-1?z:z.slice(F+1),k)}return}if(C.startsWith("[")&&C.endsWith("]")){for(let T of la(C.slice(1,-1)))Ur(T,k);return}if(/^[A-Z_$][\w$]*$/i.test(C))k.push(C)}function Hr(v){let k=v.trim(),C=[],R=0;for(let z=0;z<k.length;z++){let F=k[z];if(F==="("||F==="["||F==="{")R++;else if(F===")"||F==="]"||F==="}")R--;else if(R===0&&/\s/.test(F)){if(!/^\s+(?:in|of)\s/.exec(k.slice(z)))continue;let H=k.slice(0,z).trim();if(H.startsWith("(")&&Kd(H)===H.length-1)H=H.slice(1,-1);for(let K of la(H))Ur(K,C);if(C.length>0)return C;break}}let T=/^[\s\S]+?\s+as\s+([\s\S]+)$/.exec(k);if(T){let z=T[1].trim();if(z.startsWith("(")&&Kd(z)===z.length-1)z=z.slice(1,-1);let F=/^([\w$]+)\s*=>\s*([\s\S]+)$/.exec(z);if(F)Ur(F[2],C),Ur(F[1],C);else for(let V of la(z))Ur(V,C)}return C}function re(v,k){let C=k instanceof Set?k:new Set(k);if(C.size===0)return!1;let F=v.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g," ").replace(/`(?:[^`\\$]|\\.|\$(?!\{))*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:(?!:))/g,"$1$2");for(let V of F.match(/[a-zA-Z_$][\w$]*/g)||[])if(C.has(V))return!0;return!1}var ua="__stx_client_loop_names";function Ir(v){let k=v?.[ua];return Array.isArray(k)?k:[]}function da(v){if(!v.includes("#")&&!v.includes("v-slot:"))return[];let k=[],C=[],R=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let T of v.matchAll(R)){let z=T[0];if(/^<\/template\s*>$/i.test(z)){let F=C.pop();if(F)F.end=T.index}else if(/^<template\b/i.test(z)&&!/\/\s*>$/.test(z)){let V=[...z.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((X)=>/^(?:#[\w-]+|v-slot:[\w-]+)$/i.test(X[1])),H=(V?.[2]??V?.[3])?.trim(),K=H?{start:T.index+z.length,end:v.length,binding:H}:void 0;if(C.push(K),K)k.push(K)}}return k}var Zi={},Zd=new Map;function yy(v){let k=Zd.get(v);if(!k){let C=v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");k=new RegExp(`:${C}(?!\\w)`,"g"),Zd.set(v,k)}return k.lastIndex=0,k}var ir={uppercase:(v,k)=>v!==void 0&&v!==null?String(v).toUpperCase():"",lowercase:(v,k)=>v!==void 0&&v!==null?String(v).toLowerCase():"",capitalize:(v,k)=>{if(v===void 0||v===null)return"";let C=String(v);return C.charAt(0).toUpperCase()+C.slice(1)},number:(v,k,C=0)=>{if(v===void 0||v===null)return"";try{let R=Number(v);return Number.isNaN(R)?"":R.toFixed(Number.parseInt(String(C),10))}catch{return""}},fmt:(v,k,C="en-US")=>{if(v===void 0||v===null)return"";try{let R=Number(v);if(Number.isNaN(R))return String(v);return R.toLocaleString(C)}catch{return String(v)}},join:(v,k,C=",")=>{if(!Array.isArray(v))return"";return v.join(String(C))},escape:(v,k)=>{if(v===void 0||v===null)return"";return Mt(String(v))},translate:(v,k,C={})=>{if(!k||!k.__translations)return v;let R=k.__translations,T=k.__i18nConfig?.fallbackToKey??!0,z=String(v).split("."),F=R;for(let H of z){if(F===void 0||F===null)break;F=F[H]}if(F===void 0||F===null)return T?v:"";let V=String(F);return Object.entries(C).forEach(([H,K])=>{V=V.replace(yy(H),String(K))}),V},t:(v,k,C={})=>ir.translate(v,k,C),truncate:(v,k,C=50,R="...")=>{if(v===void 0||v===null)return"";let T=String(v);if(T.length<=C)return T;if(C<=R.length)return R.substring(0,C);return T.substring(0,C-R.length)+R},date:(v,k,C="short",R="en-US")=>{if(v===void 0||v===null)return"";try{let T=v instanceof Date?v:new Date(v);if(Number.isNaN(T.getTime()))return String(v);let z={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(C==="iso")return T.toISOString();return new Intl.DateTimeFormat(R,z[C]||z.short).format(T)}catch{return String(v)}},currency:(v,k,C="USD",R="en-US")=>{if(v===void 0||v===null)return"";try{let T=Number(v);if(Number.isNaN(T))return String(v);return new Intl.NumberFormat(R,{style:"currency",currency:C}).format(T)}catch{return String(v)}},pluralize:(v,k,C,R)=>{let T=Number(v);if(Number.isNaN(T))return C;let z=R||`${C}s`;return T===1?C:z},first:(v,k)=>{if(v===void 0||v===null)return"";if(Array.isArray(v))return v.length===0?"":v[0];return String(v).charAt(0)},last:(v,k)=>{if(v===void 0||v===null)return"";if(Array.isArray(v))return v.length===0?"":v[v.length-1];let C=String(v);return C.charAt(C.length-1)},length:(v,k)=>{if(v===void 0||v===null)return 0;if(Array.isArray(v)||typeof v==="string")return v.length;if(v instanceof Map||v instanceof Set)return v.size;if(typeof v==="object")return Object.keys(v).length;return 0},json:(v,k,C=!1)=>{if(v===void 0)return"undefined";if(v===null)return"null";try{return C?JSON.stringify(v,null,2):JSON.stringify(v)}catch{return String(v)}},default:(v,k,C="")=>v===void 0||v===null||v===""?C:v,reverse:(v,k)=>{if(v===void 0||v===null)return"";if(Array.isArray(v))return[...v].reverse();return String(v).split("").reverse().join("")},slice:(v,k,C=0,R)=>{if(v===void 0||v===null)return"";if(Array.isArray(v)||typeof v==="string")return v.slice(C,R);return v},replace:(v,k,C,R="")=>{if(v===void 0||v===null)return"";let T=C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String(v).replace(new RegExp(T,"g"),()=>R)},stripTags:(v,k)=>{if(v===void 0||v===null)return"";return String(v).replace(/<[^>]*>/g,"")},urlencode:(v,k)=>{if(v===void 0||v===null)return"";return encodeURIComponent(String(v))},abs:(v,k)=>{let C=Number(v);return Number.isNaN(C)?0:Math.abs(C)},round:(v,k,C=0)=>{let R=Number(v);if(Number.isNaN(R))return 0;let T=10**C;return Math.round(R*T)/T}};function kc(v,k){if(v in ir)console.warn(`Filter "${v}" already exists as a built-in filter. Custom filter will take precedence.`);Zi[v]=k}function Zu(v){for(let[k,C]of Object.entries(v))kc(k,C)}function _c(){return{...ir,...Zi}}function Qu(){for(let v of Object.keys(Zi))delete Zi[v]}function Cc(v,k,C=2){let R=0,T=null;for(let z=k+C;z<v.length;z++){let F=v[z];if(T){if(F==="\\"){z++;continue}if(F===T)T=null;continue}if(F==='"'||F==="'"||F==="`"){T=F;continue}if(F==="{"){R++;continue}if(F==="}"){if(R>0){R--;continue}let V=0;while(v[z+V]==="}")V++;if(V>=C)return z}}return-1}function ar(v,k,C=2){let R="{".repeat(C);if(!v.includes(R))return v;let T="",z=0;for(;;){let F=v.indexOf(R,z);if(F===-1)break;let V=Cc(v,F,C);if(V===-1)break;T+=v.slice(z,F)+k(v.slice(F,V+C),v.slice(F+C,V),F),z=V+C}return z===0?v:T+v.slice(z)}function b(v){return v.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Mt(v){return jd(b(v))}function xy(v){return v.replace(/ /g," ").replace(/\t/g,"	").replace(/\n/g," ").replace(/\r/g," ").replace(/\f/g,"").replace(/=/g,"=").replace(/`/g,"`")}function by(v){return v.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\([\dA-Fa-f]{1,6})\s?/g,(k,C)=>String.fromCodePoint(Number.parseInt(C,16))).replace(/\\([^\r\n])/g,"$1").replace(/[\u0000-\u0020]+/g,"").toLowerCase()}function vy(v,k){let C=by(v);if(/@import|expression\(|behavior:|-moz-binding|(?:image-set|cross-fade)\(/.test(C))throw new tr(k,"network-capable or executable CSS is not allowed in an escaped interpolation");let R=/url\(([^)]*)\)/g,T;while((T=R.exec(C))!==null){let z=T[1].replace(/^["']|["']$/g,""),F=z.startsWith("/")&&!z.startsWith("//")||z.startsWith("./")||z.startsWith("../")||z.startsWith("#"),V=/^data:image\/(?:avif|bmp|gif|jpeg|jpg|png|webp);base64,[a-z\d+/=]+$/i.test(z);if(!F&&!V)throw new tr(k,"CSS URLs must be local paths or base64 raster images")}}function tf(v,k,C,R=!1,T=0){let z=Ld(v,k,R),F=Mt(C);if(!z)return F;if(z.kind==="tag-name"){if(!/^[A-Za-z][A-Za-z0-9:-]*$/.test(C))throw new tr("tag name","dynamic tag names may contain only letters, digits, colons, and hyphens");return C}if(z.kind==="tag"){let K=v.slice(k+T).trimStart(),X=C.trim();if(!K.startsWith("=")&&(X===""||/^(?!on)[A-Za-z_:][\w:.-]*(?:\s+(?!on)[A-Za-z_:][\w:.-]*)*$/.test(X)))return X;throw new tr("tag structure","only standalone boolean attributes may be interpolated into tag structure")}let V=z.name.toLowerCase();if(/^on[a-z]/.test(V))throw new tr(z.name,"native event-handler attributes execute JavaScript; use an @event binding instead");if(V==="srcdoc")F=Mt(F);if(V==="style")vy(C,z.name);if(z.quote===null)F=xy(F);let H=yc(V);if(H&&z.valuePrefix.trim()===""&&oa(C,H))return Bd+F;return Wd(zd(v,k),C,F)}function nf(v){return v.flatMap((k)=>{let C=k.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);return!C||/\bserver\b|\bsrc\s*=/.test(C[1])?[]:[C[2]]})}function Ce(v,k){let{scripts:C}=yn(v);for(let R of nf(C)){if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^>]*>)?\s*\(/.test(R))return!0;if(Fn(R,k))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test(v))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test(v))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test(v))return!0;return!1}function Ec(v){let k=[],C=/<([a-zA-Z][\w-]*)\b[^>]*?\s(?::for|x-for|@for)\s*=\s*(["'])([\s\S]*?)\2[^>]*>/g;for(let R=C.exec(v);R;R=C.exec(v)){let T=R[1].toLowerCase(),z=new Set(Hr(R[3]));if(z.size===0)continue;let F=R.index+R[0].length;if(R[0].endsWith("/>")){k.push({start:R.index,end:F,names:z});continue}let V=new RegExp(`<(/?)${T}\\b[^>]*?(/?)>`,"gi");V.lastIndex=F;let H=1,K=v.length;for(let X=V.exec(v);X;X=V.exec(v)){if(X[2]==="/")continue;if(H+=X[1]==="/"?-1:1,H===0){K=X.index+X[0].length;break}}k.push({start:R.index,end:K,names:z})}return k}function Gd(v,k,C){let R=s(C);for(let T of v){if(k<T.start||k>=T.end)continue;for(let z of T.names)if(new RegExp(`(?<![.#\\w$])${z.replace(/\$/g,"\\$")}(?![\\w$])`).test(R))return!0}return!1}function Jd(v,k){let C=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","URL","URLSearchParams","Intl","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console","new","typeof","instanceof","in","void"],R=v.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),T="",z=!1,F=0;for(let K=0;K<R.length;K++){let X=R[K];if(!z&&X==="`"){z=!0,F=0;continue}if(z){if(X==="`"&&F===0){z=!1;continue}if(X==="$"&&R[K+1]==="{"){F++,K++,T+=" ";continue}if(X==="}"&&F>0){F--;continue}if(F>0){T+=X;continue}continue}T+=X}R=T;let V=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,H;while((H=V.exec(R))!==null){let K=H[1];if(!R.substring(0,H.index).trimEnd().endsWith(".")){if(!C.includes(K)&&!(K in k))return!1}}return!0}function wy(v,k){let C=k.__stx_serverDeclared;if(!C||C.size===0)return!1;let R=s(v);for(let T of C)if(new RegExp(`(?<![.#\\w$])${T}(?![\\w$])`).test(R))return!0;return!1}var Yd=new Set;function Qd(v){return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(v.trim())}function ef(v,k){let C=`${k??"<unknown>"}\x00${v}`;if(process.env.STX_DEBUG||!Yd.has(C))Yd.add(C),console.warn(`[stx] {{ ${v} }} in a <script> in ${k??"<unknown>"} has no server value, so it was emitted as undefined. A mustache left in JavaScript is a SyntaxError that takes the whole script down, so give the value a default in <script server>.`);return"undefined"}function xs(v,k,C){let R=v;return R=R.replace(/\{!!([\s\S]*?)!!\}/g,(T,z)=>{try{let F=x(z,k);if(F===void 0)return Qd(z)?ef(z.trim(),C):T;return F===null?"":String(F)}catch{return T}}),R=ar(R,(T,z,F)=>{let V=z.trim();if(/^__[A-Z_]+__$/.test(V))return T;try{let H=x(z,k);if(H===void 0)return Qd(V)?ef(V,C):T;return JSON.stringify(H).replace(/</g,"\\u003c")}catch{return T}}),R}function Tc(v,k){if(!v.includes("{"))return v;let C=v;return C=C.replace(/\{!!([\s\S]*?)!!\}/g,(R,T)=>{try{let z=x(T,k);if(z===void 0)return R;return z===null?"":String(z)}catch{return R}}),C=ar(C,(R,T,z)=>{let F=T.trim();if(/^__[A-Z_]+__$/.test(F))return R;try{let V=x(T,k);if(V===void 0)return R;if(V===null)return"";let H=String(V);return tf(C,z,H,!0,R.length)}catch(V){if(V instanceof tr)throw V;return R}}),C}function ed(v,k,C={}){let{output:R,scripts:T}=yn(v),z=T.map((F)=>{let V=F.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i),H=F.match(/^<script\b[^>]*>/i),K=F.search(/<\/script\s*>$/i);if(!V||!H||K===-1)return F;let X=V[1],G=V[2];if(/\bdata-raw\b/.test(X))return F;if(C.skipServer&&/\bserver\b/.test(X))return F;let ce=`<script${Tc(X,k)}>`;if(/\bsrc\s*=/.test(X)||/\btype\s*=\s*["']application\/json["']/.test(X))return ce+G+F.slice(K);return ce+xs(G,k)+F.slice(K)});return ds(R,z)}function Z(v,k,C){let R=v,T=(ee,le)=>{let ue=us(ee,le);if(ue===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(ee.slice(le,ue))?-1:ue},z=(ee,le,ue,de)=>{let fe=ue.length,{output:pe,tokens:Ae}=qn(ee,le,(Se,ve)=>de(fe+ve));return ue.push(...Ae),pe},F=[];R=z(R,T,F,(ee)=>`<!--__STX_STYLE_${ee}__-->`);let V=[];R=z(R,U,V,(ee)=>`<!--__STX_SCRIPT_EXPR_${ee}__-->`);let H=k?.__stx_signals_gate===!0||Ce(v),K=new Set([...Array.isArray(k?.__stx_client_signal_names)?k.__stx_client_signal_names:[],...zs(nf(V))]),X=new Set(Array.isArray(k?.__stx_preserved_client_expressions)?k.__stx_preserved_client_expressions:[]);R=ar(R,(ee,le,ue)=>{try{let de=x(le,k,!1,(fe)=>il(fe,ee,C,v));return de!==void 0&&de!==null?String(de):""}catch(de){let fe=de instanceof Error?de.message:String(de);return g("Expression",`Error evaluating: {{{ ${le.trim()}}}}: ${fe}`,C,v,ue,ee)}},3),R=R.replace(/\{!!([\s\S]*?)!!\}/g,(ee,le,ue)=>{try{let de=x(le,k,!1,(fe)=>il(fe,ee,C,v));if(de===void 0&&k.__stx_buildMode==="compile")return ia("raw",le.trim());return de!==void 0&&de!==null?String(de):""}catch(de){if(k.__stx_buildMode==="compile")return ia("raw",le.trim());let fe=de instanceof Error?de.message:String(de);return g("Expression",`Error evaluating: {!! ${le.trim()} !!}: ${fe}`,C,v,ue,ee)}}),R=z(R,U,V,(ee)=>`<!--__STX_SCRIPT_EXPR_${ee}__-->`),R=z(R,T,F,(ee)=>`<!--__STX_STYLE_${ee}__-->`);let G=H?Ec(R):[],te=da(R).map((ee)=>({...ee,names:new Set(Hr(`${ee.binding} in __slot`))})),ce=new Set(Ir(k));if(R=ar(R,(ee,le,ue)=>{let de=le.trim();if(Gd(te,ue,de))return ee;if(re(de,ce))return ee;if(G.length>0&&Gd(G,ue,de))return ee;if(X.has(de))return ee;let fe=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],pe=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,Se=de.match(pe)?.[1],ve=Se&&((Se in k)||fe.includes(Se)),De=Boolean(Se&&K.has(Se)),Me=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,je=de.match(Me),Le=je&&!fe.includes(je[1])&&!(je[1]in k);if(/^__[A-Z_]+__$/.test(de))return"";if(De)return ee;let Be;try{let Oe=x(le,k,!1,(Fe)=>{Be=Fe});if(H&&!Jd(de,k))return ee;if(Be)il(Be,ee,C,v);if(k.__stx_buildMode==="compile"&&!H&&(Oe===void 0||wy(de,k)))return ia("expr",de);if(Oe===void 0||Oe===null)return"";let We=String(Oe);return tf(R,ue,We,!1,ee.length)}catch(Oe){if(Oe instanceof tr)throw Oe;if(H&&!Jd(de,k))return ee;if(Le)return ee;let We=Oe instanceof Error?Oe.message:String(Oe);return g("Expression",`Error evaluating: {{ ${de} }}: ${We}`,C,v,ue,ee)}}),V.length>0)R=R.replace(/<!--__STX_SCRIPT_EXPR_(\d+)__-->/g,(ee,le)=>V[Number(le)]??ee);if(F.length>0)R=R.replace(/<!--__STX_STYLE_(\d+)__-->/g,(ee,le)=>F[Number(le)]??ee);return R}function $c(v,k,C){if(!k.trim())return v;let R=v,T=k.trim();while(T.length>0){let z=T.match(/^(\w+)/);if(!z)break;let F=z[1];T=T.substring(F.length).trim();let V=Zi[F]||ir[F];if(!V)throw Error(`Filter not found: ${F}. Available filters: ${Object.keys(_c()).join(", ")}`);let H=[];if(T.startsWith(":")){let K=T.match(/^:([^|\s]+)/);if(K){let X=K[1].trim();try{let G=Number(X);H=[Number.isNaN(G)?X:G]}catch{H=[X]}T=T.substring(K[0].length).trim()}}else if(T.startsWith("(")){let K=1,X=1;while(K>0&&X<T.length){if(T[X]==="(")K++;if(T[X]===")")K--;X++}if(K===0){let G=T.substring(1,X-1).trim();if(G)try{if(G.startsWith("{")&&G.endsWith("}"))H=[x(`(${G})`,C,!0)];else{let te=[],ce="",ee=null,le=0,ue=0,de=0,fe=!1;for(let pe=0;pe<G.length;pe++){let Ae=G[pe];if(fe){ce+=Ae,fe=!1;continue}if(Ae==="\\"){ce+=Ae,fe=!0;continue}if(ee){if(ce+=Ae,Ae===ee)ee=null;continue}if(Ae==='"'||Ae==="'"||Ae==="`"){ee=Ae,ce+=Ae;continue}if(Ae==="(")le++;else if(Ae===")")le--;else if(Ae==="[")ue++;else if(Ae==="]")ue--;else if(Ae==="{")de++;else if(Ae==="}")de--;if(Ae===","&&le===0&&ue===0&&de===0){te.push(ce),ce="";continue}ce+=Ae}if(ce)te.push(ce);H=te.map((pe)=>{let Ae=pe.trim();return x(Ae,C,!0)})}}catch{H=[G]}T=T.substring(X).trim()}}try{R=V(R,C,...H)}catch(K){let X=K instanceof Error?K.message:String(K);throw Error(`Error applying filter '${F}': ${X}`)}if(T.startsWith("|"))T=T.substring(1).trim();else break}return R}function Sy(v){let k=!1,C="",R=0,T=0,z=0,F=!1;for(let V=0;V<v.length;V++){let H=v[V],K=v[V+1];if(k&&F){F=!1;continue}if(k&&H==="\\"){F=!0;continue}if(F=!1,(H==='"'||H==="'"||H==="`")&&!F){if(!k)k=!0,C=H;else if(H===C)k=!1,C="";continue}if(k&&C==="`"&&H==="$"&&K==="{"){let X=1;V+=2;while(V<v.length&&X>0){if(v[V]==="{")X++;else if(v[V]==="}")X--;if(X>0)V++}continue}if(k)continue;if(H==="(")R++;else if(H===")")R--;else if(H==="[")T++;else if(H==="]")T--;else if(H==="{")z++;else if(H==="}")z--;if(H==="|"&&R===0&&T===0&&z===0){if(K==="|"){V++;continue}if(K==="="){V++;continue}return V}}return-1}var Hi=new Set,$y=1000;function td(){Hi.clear()}function il(v,k,C,R){if(!D())return;let T=`${C}\x00${v.expression}`;if(Hi.has(T))return;if(Hi.size>=$y)Hi.clear();Hi.add(T);let z=C,F=R;try{if(C&&Xd.existsSync(C))F=Xd.readFileSync(C,"utf8")}catch{}let V=F.indexOf(k);if(V>=0)z=`${C}:${F.slice(0,V).split(`
|
|
124
|
+
`).length}`;console.warn(`${z}: stx warning: ${k} rendered as an empty string. The safe evaluator rejected \`${v.expression}\` (${v.rule}). Compute the value in <script server> and interpolate the variable instead.`)}function x(v,k,C=!1,R){try{let T=v.trim(),z=Sy(T);if(z>0){let V=T.substring(0,z).trim(),H=T.substring(z+1).trim(),K=x(V,k,!0,R);return $c(K,H,k)}let F=Ln(T);if(F!==null){R?.({expression:T,rule:F});return}try{let V=Object.keys(k),H=Object.values(k);return c(T,V)(...H)}catch{return l(T,k)}}catch(T){if(T instanceof ReferenceError){let z=/(\b\w+)\s+is not defined/.exec(T.message);if(z){let F=z[1],V=_y(F,Object.keys(k));if(V&&V!==F)T.message=`${T.message} \u2014 did you mean '${V}'?`}}if(!C)console.error(`Error evaluating expression: ${v}`,T);throw T}}function _y(v,k){let C=null;for(let T of k){if(T===v)continue;let z=ky(v,T);if(C===null||z<C.dist)C={key:T,dist:z}}if(!C)return null;let R=Math.max(v.length,C.key.length);if(C.dist<=2||C.dist/R<=0.35)return C.key;return null}function ky(v,k){if(v===k)return 0;if(v.length===0)return k.length;if(k.length===0)return v.length;let[C,R]=v.length<k.length?[v,k]:[k,v],T=Array(C.length+1),z=Array(C.length+1);for(let F=0;F<=C.length;F++)T[F]=F;for(let F=1;F<=R.length;F++){z[0]=F;for(let V=1;V<=C.length;V++){let H=C[V-1]===R[F-1]?0:1;z[V]=Math.min(z[V-1]+1,T[V]+1,T[V-1]+H)}for(let V=0;V<=C.length;V++)T[V]=z[V]}return T[C.length]}function nd(v){if(!v)return"";return v.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}import of from"fs";class L{cache=new Map;maxSize;options;sizes;bytes=0;constructor(v=100,k){this.maxSize=v,this.options=k??null,this.sizes=k?new Map:null}get byteSize(){return this.bytes}setMaxBytes(v){if(!this.options)return;this.options={...this.options,maxBytes:v};while(this.bytes>v&&this.cache.size>0){let k=this.cache.keys().next().value;if(k===void 0)break;this.delete(k)}}get(v){if(!this.cache.has(v))return;let k=this.cache.get(v);return this.cache.delete(v),this.cache.set(v,k),k}set(v,k){if(this.cache.has(v))this.delete(v);let C=this.options?this.options.sizeOf(k):0;if(this.options&&C>this.options.maxBytes)return;while(this.cache.size>0&&(this.cache.size>=this.maxSize||this.options!==null&&this.bytes+C>this.options.maxBytes)){let R=this.cache.keys().next().value;if(R===void 0)break;this.delete(R)}if(this.cache.set(v,k),this.sizes)this.sizes.set(v,C),this.bytes+=C}has(v){return this.cache.has(v)}delete(v){if(this.sizes){let k=this.sizes.get(v);if(k!==void 0)this.bytes-=k,this.sizes.delete(v)}return this.cache.delete(v)}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 fs=new Map,Ey=500;function qr(v,k){if(k?.includes("g"))return new RegExp(v,k);let C=`${v}:${k||""}`;if(!fs.has(C)){if(fs.size>=Ey){let R=fs.keys().next().value;if(R)fs.delete(R)}fs.set(C,new RegExp(v,k))}return fs.get(C)}class rf{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator(v){let k=Array.from(new Set(v)),C=k.sort().join(","),R=this.pool.find((V)=>V.context.join(",")===C);if(R)return R.func;let T=this.fnCache,z=this.fnCacheMaxSize,F=(...V)=>(H)=>{try{let K=`${C}:${H}`,X=T.get(K);if(!X){if(T.size>=z){let G=T.keys().next().value;if(G)T.delete(G)}X=Function(...k,`
|
|
125
|
+
'use strict';
|
|
126
|
+
try {
|
|
127
|
+
return ${H};
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
if (e instanceof ReferenceError || e instanceof TypeError) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
throw e;
|
|
134
|
+
}
|
|
135
|
+
`),T.set(K,X)}return X(...V)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:F,context:k.slice()});return F}clear(){this.pool.length=0,this.fnCache.clear()}}var D$=new rf;class sf{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(v){this.enabled=v}isEnabled(){return this.enabled}setBudget(v,k){this.budgets.set(v,{warnThreshold:0.8,action:"warn",...k})}setBudgets(v){for(let[k,C]of Object.entries(v))this.setBudget(k,C)}removeBudget(v){this.budgets.delete(v)}getBudgets(){let v={};for(let[k,C]of this.budgets.entries())v[k]=C;return v}onViolation(v){this.violationHandlers.push(v)}offViolation(v){let k=this.violationHandlers.indexOf(v);if(k!==-1)this.violationHandlers.splice(k,1)}time(v,k){if(!this.enabled)return k();let C=performance.now(),R=k(),T=performance.now()-C;return this.recordTime(v,T),this.checkBudget(v,T),R}async timeAsync(v,k){if(!this.enabled)return k();let C=performance.now(),R=await k(),T=performance.now()-C;return this.recordTime(v,T),this.checkBudget(v,T),R}checkBudget(v,k){let C=this.budgets.get(v);if(!C)return;let R=k/C.maxTime*100,T=C.warnThreshold!==void 0?k>=C.maxTime*C.warnThreshold&&k<C.maxTime:!1,z=k>=C.maxTime;if(!T&&!z)return;let F={label:v,actualTime:k,budgetTime:C.maxTime,exceedancePercent:R,timestamp:new Date,isWarning:T};this.violations.push(F);while(this.violations.length>this.maxViolations)this.violations.shift();for(let H of this.violationHandlers)try{H(F)}catch{}let V=T?`[Performance Warning] "${v}" took ${k.toFixed(2)}ms (${R.toFixed(1)}% of ${C.maxTime}ms budget)`:`[Performance Budget Exceeded] "${v}" took ${k.toFixed(2)}ms (exceeded ${C.maxTime}ms budget by ${(R-100).toFixed(1)}%)`;switch(C.action){case"log":console.log(V);break;case"warn":console.warn(V);break;case"error":console.error(V);break;case"throw":if(z)throw Error(V);else console.warn(V);break}}recordTime(v,k){let C=this.metrics.get(v);if(C)C.count++,C.totalTime+=k,C.maxTime=Math.max(C.maxTime,k),C.minTime=Math.min(C.minTime,k);else this.metrics.set(v,{count:1,totalTime:k,maxTime:k,minTime:k})}getStats(v){if(v){let C=this.metrics.get(v);if(!C)return{};let R=this.budgets.get(v);return{count:C.count,avgTime:C.totalTime/C.count,totalTime:C.totalTime,maxTime:C.maxTime,minTime:C.minTime,budget:R?.maxTime,budgetUtilization:R?C.totalTime/C.count/R.maxTime*100:void 0}}let k={};for(let[C,R]of this.metrics.entries()){let T=this.budgets.get(C);k[C]={count:R.count,avgTime:R.totalTime/R.count,totalTime:R.totalTime,maxTime:R.maxTime,minTime:R.minTime,budget:T?.maxTime,budgetUtilization:T?R.totalTime/R.count/T.maxTime*100:void 0}}return k}getViolations(v){if(v)return this.violations.filter((k)=>k.label===v);return[...this.violations]}getViolationStats(){let v={},k=0,C=0;for(let R of this.violations)if(v[R.label]=(v[R.label]||0)+1,R.isWarning)k++;else C++;return{total:this.violations.length,byLabel:v,warnings:k,errors:C}}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 ol=null;function Cy(){if(!ol)ol=new sf;return ol}var J=new Proxy({},{get(v,k){return Cy()[k]}});var af=[];function m(v){let k=new L(v);return af.push(k),k}function cf(){for(let v of af)v.clear()}function h(v,...k){return`${k.map((C)=>String(C??"")).join("\x00")}\x00${v.length}\x00${Bun.hash(v)}`}function bn(v){let k=[];for(let C of new Set(v))try{k.push({path:C,mtimeMs:of.statSync(C).mtimeMs})}catch{}return k}function or(v){for(let k of v)try{if(of.statSync(k.path).mtimeMs!==k.mtimeMs)return!1}catch{return!1}return!0}import KS from"fs";import fn from"path";import ao from"fs";import Zt from"path";import{hasLocalConfig as Df}from"bunfig";import Kn from"fs";import Kr from"path";import al from"fs";import lf from"path";import{fileURLToPath as Ry}from"url";var cl;function Ge(){if(cl)return cl;let v="unknown";try{v=String(JSON.parse(al.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version)}catch{}if(import.meta.url.endsWith(".ts"))try{let k=lf.dirname(Ry(import.meta.url)),C=0;for(let R of al.readdirSync(k,{recursive:!0,withFileTypes:!0}))if(R.isFile()&&R.name.endsWith(".ts"))C=Math.max(C,al.statSync(lf.join(R.parentPath,R.name)).mtimeMs);v+=`+src.${Math.trunc(C)}`}catch{}return cl=v,v}var Rc=new Map,Xr=new Map;async function rd(v){let C;for(let R=0;R<3;R++)try{let z=(await Kn.promises.stat(v)).mtime.getTime(),F=Xr.get(v);if(F&&F.mtime===z)return F.content;let V=await Bun.file(v).text(),K=(await Kn.promises.stat(v)).mtime.getTime();if(K!==z)continue;return Xr.set(v,{content:V,mtime:K}),V}catch(T){C=T;break}throw Xr.delete(v),Error(`File not found: ${v}${C?` (${C.message})`:""}`)}function sd(v){Xr.delete(v)}function od(v){for(let k of Xr.keys())if(k.startsWith(v))Xr.delete(k)}var pa=null,Ay=null,df=null;function id(v){df=v}async function Ac(v=!1){let k=df??await import("./chunk-bn6sarwd.js");if(v)return k.generateSignalsRuntimeDev();if(pa===null)pa=k.generateSignalsRuntime();return pa}var ga=null;async function Pc(){if(ga===null){let{getRouterScript:v}=await import("./chunk-ag4eck6d.js");ga=v()}return ga}var uf={};async function ad(v,k=!1){let C=v==="runtime"?await Ac(k):await Pc(),R=v==="runtime"&&k?"runtime-debug":v,T=uf[R];if(!T||T.content!==C)T={content:C,hash:Bun.hash(C).toString(16).padStart(16,"0").slice(0,16)},uf[R]=T;return{content:C,hash:T.hash,url:`/_stx/${v}.${T.hash}.js`}}var Ty=500,Iy=33554432,nr=new Map,fa=0;function ff(v){return a(process.cwd(),"module-bundles",`${v}.js`)}function cd(v){let k=Bun.hash(v).toString(16).padStart(16,"0").slice(0,16),C=nr.get(k),R=C!==void 0;if(R)nr.delete(k),fa-=C.length*2;nr.set(k,v),fa+=v.length*2;while(nr.size>1&&(nr.size>Ty||fa>Iy)){let T=nr.keys().next().value;fa-=nr.get(T).length*2,nr.delete(T)}if(!R)try{let T=ff(k);if(!Kn.existsSync(T))Kn.mkdirSync(Kr.dirname(T),{recursive:!0}),Kn.writeFileSync(T,v)}catch{}return`/_stx/modules.${k}.js`}function mi(v){if(!/^[0-9a-f]{16}$/.test(v))return;let k=nr.get(v);if(k!==void 0)return k;try{return Kn.readFileSync(ff(v),"utf8")}catch{return}}function ld(){Xr.clear(),ie(),cf(),pa=null,Ay=null,ga=null}function pf(v){let k={debug:v.debug===!0,middleware:(v.middleware??[]).map((C)=>({name:C.name,timing:C.timing,handler:String(C.handler)})),customDirectives:(v.customDirectives??[]).map((C)=>({name:C.name,hasEndTag:C.hasEndTag===!0,rawParams:C.rawParams===!0,handler:String(C.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(k)).digest("hex")}async function wn(v,k){try{if(!k.cachePath)return null;let C=Kr.resolve(k.cachePath),R=Kr.join(C,`${cr(v)}.html`),T=Kr.join(C,`${cr(v)}.meta.json`);if(!await r(R)||!await r(T))return null;let z=await Bun.file(T).text(),F=JSON.parse(z);if(F.cacheVersion!==k.cacheVersion)return null;if(F.engine!==Ge())return null;if(F.optionsSignature!==pf(k))return null;if((await Kn.promises.stat(v)).mtime.getTime()>F.mtime)return null;for(let H of F.dependencies)if(await r(H)){if((await Kn.promises.stat(H)).mtime.getTime()>F.mtime)return null}else return null;return await Bun.file(R).text()}catch(C){return console.warn(`Cache error for ${v}:`,C),null}}async function xn(v,k,C,R){try{if(!R.cachePath)return;let T=Kr.resolve(R.cachePath);await Kn.promises.mkdir(T,{recursive:!0});let z=Kr.join(T,`${cr(v)}.html`),F=Kr.join(T,`${cr(v)}.meta.json`),V=await Kn.promises.stat(v);await Bun.write(z,k);let H={sourcePath:v,mtime:V.mtime.getTime(),dependencies:Array.from(C),cacheVersion:R.cacheVersion,engine:Ge(),optionsSignature:pf(R),generatedAt:Date.now()};await Bun.write(F,JSON.stringify(H,null,2)),Rc.set(v,{output:k,mtime:V.mtime.getTime(),dependencies:C})}catch(T){console.warn(`Failed to cache template ${v}:`,T)}}var Py=16;function cr(v){return new Bun.CryptoHasher("sha1").update(v).digest("hex").substring(0,Py)}var Xe={fg:{light:"neutral-900",dark:"neutral-100",description:"Primary text"},"fg-strong":{light:"neutral-700",dark:"neutral-300",description:"Labels, secondary headings"},"fg-muted":{light:"neutral-600",dark:"neutral-400",description:"Supporting text"},"fg-soft":{light:"neutral-500",dark:"neutral-400",description:"De-emphasised text"},"fg-subtle":{light:"neutral-400",dark:"neutral-500",description:"Recessive, non-essential text"},surface:{light:"neutral-50",dark:"neutral-800",description:"Page and panel background"},"surface-raised":{light:"neutral-100",dark:"neutral-700",description:"Cards, popovers"},"surface-sunken":{light:"neutral-200",dark:"neutral-700",description:"Wells, track backgrounds"},panel:{light:"white",dark:"neutral-800",description:"Card, menu, dialog surface"},field:{light:"white",dark:"neutral-700",description:"Form control surface"},page:{light:"neutral-50",dark:"neutral-900",description:"Page background, behind panels"},content:{light:"white",dark:"neutral-900",description:"Content area under a chrome header - a table or list body"},"surface-hover":{light:"neutral-100",dark:"neutral-700",description:"Row or item highlight on a page or panel"},"surface-raised-hover":{light:"neutral-200",dark:"neutral-600",description:"Raised surface, hovered"},"surface-sunken-hover":{light:"neutral-300",dark:"neutral-600",description:"Sunken surface, hovered"},"field-hover":{light:"neutral-50",dark:"neutral-600",description:"Form control surface, hovered"},link:{light:"blue-500",dark:"blue-400",description:"Hyperlink"},"link-hover":{light:"blue-600",dark:"blue-300",description:"Hyperlink, hovered"},inverse:{light:"neutral-900",dark:"neutral-700",description:"Tooltip bubble, inverted surface"},"inverse-ink":{light:"white",dark:"white",description:"Text on an inverted surface"},line:{light:"neutral-200",dark:"neutral-700",description:"Default border, divider"},"line-strong":{light:"neutral-300",dark:"neutral-600",description:"Input border, focus ring track"},"line-hover":{light:"neutral-400",dark:"neutral-500",description:"Border of a hovered control"},accent:{light:"blue-600",dark:"blue-400",description:"Primary action, selected state"},info:{light:"cyan-600",dark:"cyan-400",description:"Informational emphasis"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-600",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"blue-500",dark:"blue-600",description:"Primary button fill"},"info-solid":{light:"cyan-500",dark:"cyan-600",description:"Informational fill"},"danger-solid":{light:"red-500",dark:"red-600",description:"Destructive button fill"},"success-solid":{light:"green-500",dark:"green-600",description:"Confirmation fill"},"warning-solid":{light:"yellow-500",dark:"yellow-600",description:"Caution fill"},"accent-solid-hover":{light:"blue-600",dark:"blue-700",description:"Primary button fill, hovered"},"info-solid-hover":{light:"cyan-600",dark:"cyan-700",description:"Informational fill, hovered"},"danger-solid-hover":{light:"red-600",dark:"red-700",description:"Destructive fill, hovered"},"success-solid-hover":{light:"green-600",dark:"green-700",description:"Confirmation fill, hovered"},"warning-solid-hover":{light:"yellow-600",dark:"yellow-700",description:"Caution fill, hovered"},"accent-ink":{light:"white",dark:"white",description:"Text on a primary fill"},"info-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on an informational fill"},"danger-ink":{light:"white",dark:"white",description:"Text on a destructive fill"},"success-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a confirmation fill"},"warning-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a caution fill"},"accent-soft":{light:"blue-100",dark:"blue-900",description:"Tinted primary fill"},"accent-soft-ink":{light:"blue-800",dark:"blue-200",description:"Text on a tinted primary fill"},"info-soft":{light:"cyan-100",dark:"cyan-900",description:"Tinted informational fill"},"info-soft-ink":{light:"cyan-800",dark:"cyan-200",description:"Text on a tinted informational fill"},"danger-soft":{light:"red-100",dark:"red-900",description:"Tinted destructive fill"},"danger-soft-ink":{light:"red-800",dark:"red-200",description:"Text on a tinted destructive fill"},"success-soft":{light:"green-100",dark:"green-900",description:"Tinted confirmation fill"},"success-soft-ink":{light:"green-800",dark:"green-200",description:"Text on a tinted confirmation fill"},"warning-soft":{light:"yellow-100",dark:"yellow-900",description:"Tinted caution fill"},"warning-soft-ink":{light:"yellow-800",dark:"yellow-200",description:"Text on a tinted caution fill"},secondary:{light:"purple-600",dark:"purple-400",description:"Secondary emphasis"},"secondary-solid":{light:"purple-500",dark:"purple-600",description:"Secondary fill"},"secondary-solid-hover":{light:"purple-600",dark:"purple-700",description:"Secondary fill, hovered"},"secondary-ink":{light:"white",dark:"white",description:"Text on a secondary fill"},"secondary-soft":{light:"purple-100",dark:"purple-900",description:"Tinted secondary fill"},"secondary-soft-ink":{light:"purple-800",dark:"purple-200",description:"Text on a tinted secondary fill"},"danger-fg":{light:"red-900",dark:"red-300",description:"Text in a field with an error"},"danger-fg-subtle":{light:"red-300",dark:"red-500",description:"Recessive text in a field with an error"},"danger-line":{light:"red-300",dark:"red-600",description:"Border of a field with an error"},"danger-focus":{light:"red-500",dark:"red-400",description:"Focus ring of a field with an error"}};function Ee(v){return`--stx-${v}`}function ma(v,k){let C=k.lastIndexOf("-");if(C===-1)return typeof v[k]==="string"?v[k]:void 0;let R=v[k.slice(0,C)];if(!R||typeof R!=="object")return;let T=R[k.slice(C+1)];return typeof T==="string"?T:void 0}var Dy=/^(?:#[\da-f]{3,8}|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix|var)\(.*\)|white|black|transparent|currentcolor)$/i;function gf(v,k){let C=k.trim();return ma(v,C)??(Dy.test(C)?C:void 0)}function mf(v={}){return[...Object.keys(v.roles??{}).filter((k)=>!Xe[k]).map((k)=>`roles.${k}`),...Object.keys(v.shapes??{}).filter((k)=>!se[k]).map((k)=>`shapes.${k}`),...Object.keys(v.density??{}).filter((k)=>!ge[k]).map((k)=>`density.${k}`)]}function hf(v){let k={};for(let[C,R]of Object.entries(Xe)){let T=ma(v,R.light);if(T===void 0)continue;k[C]=`var(${Ee(C)}, ${T})`}return k}function yf(v,k={}){let C=[],R=[];for(let[T,z]of Object.entries(Xe)){let F=k[T],V=typeof F==="string"?F:F?.light,H=typeof F==="string"?F:F?.dark,K=V&&gf(v,V)||ma(v,z.light),X=H&&gf(v,H)||ma(v,z.dark);if(K===void 0)continue;if(C.push(` ${Ee(T)}: ${K};`),X!==void 0)R.push(` ${Ee(T)}: ${X};`)}if(C.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...C,"}",".dark {",...R,"}",""].join(`
|
|
136
|
+
`)}var se={control:{value:"0.375rem",description:"Buttons, inputs, selects \u2014 rounded-md"},panel:{value:"0.5rem",description:"Cards, dialogs, menus \u2014 rounded-lg"},pill:{value:"9999px",description:"Chips and badges, which are pill-shaped by intent"}};function Lt(v){return`--stx-radius-${v}`}function xf(){let v={};for(let[k,C]of Object.entries(se))v[k]=`var(${Lt(k)}, ${C.value})`;return v}function bf(v={}){return["/* stx shape tokens \u2014 a radius by what the thing is. */",":root {",...Object.entries(se).map(([k,C])=>` ${Lt(k)}: ${v[k]??C.value};`),"}",""].join(`
|
|
137
|
+
`)}var ge={"control-px":{value:"1rem",description:"Inline padding of a md text control \u2014 px-4"},"control-py":{value:"0.5rem",description:"Block padding of a md text control \u2014 py-2"},"control-text":{value:"1rem",description:"Font size of a md text control \u2014 text-base"},"control-leading":{value:"1.5rem",description:"Line height of a md text control \u2014 text-base"},"cell-px":{value:"1.5rem",description:"Inline padding of every table cell, header or body \u2014 px-6"},"cell-py":{value:"1rem",description:"Block padding of a body cell \u2014 py-4"},"cell-text":{value:"0.875rem",description:"Font size of a body cell \u2014 text-sm"},"cell-leading":{value:"1.25rem",description:"Line height of a body cell \u2014 text-sm"},"cell-head-py":{value:"0.75rem",description:"Block padding of a header cell \u2014 py-3"},"cell-head-text":{value:"0.75rem",description:"Font size of a header cell \u2014 text-xs"},"cell-head-leading":{value:"1rem",description:"Line height of a header cell \u2014 text-xs"}},Sn={"control-x":"control-px","control-y":"control-py","cell-x":"cell-px","cell-y":"cell-py","cell-head-y":"cell-head-py"},kn={control:{size:"control-text",leading:"control-leading"},cell:{size:"cell-text",leading:"cell-leading"},"cell-head":{size:"cell-head-text",leading:"cell-head-leading"}};function Te(v){return`--stx-${v}`}function ll(v){let k=ge[v];if(!k)throw Error(`[stx] unknown density token "${v}"`);return`var(${Te(v)}, ${k.value})`}function vf(){let v={};for(let[k,C]of Object.entries(Sn))v[k]=ll(C);return v}function wf(){let v={};for(let[k,{size:C,leading:R}]of Object.entries(kn))v[k]=[ll(C),{lineHeight:ll(R)}];return v}function Sf(v={}){return["/* stx density tokens \u2014 how much room a control or a table cell takes. */",":root {",...Object.entries(ge).map(([k,C])=>` ${Te(k)}: ${v[k]??C.value};`),"}",""].join(`
|
|
138
|
+
`)}function $f(v){return typeof v==="object"&&v!==null&&!Array.isArray(v)}function ul(v,k){let C={...v};for(let[R,T]of Object.entries(k))C[R]=$f(T)&&$f(C[R])?ul(C[R],T):T;return C}function _f(v,k){if(!k.fonts)return"";let C=new v({...k.config,fonts:k.fonts,cssVariables:!1}).toCSS(!1,k.minify);return C&&!k.minify?`${C}
|
|
139
|
+
`:C}function kf(v={},k={}){let C=v.theme||{},R=k.theme||{},{extend:T,...z}=R,{extend:F,...V}=C,H=V.colors||{};V.colors={...H,...hf(H)};let K=V.borderRadius||{};V.borderRadius={...K,...xf()};let X=V.spacing||{};V.spacing={...X,...vf()};let G=V.fontSize||{};V.fontSize={...G,...wf()};let te=ul(V,z),ce=ul(F||{},T||{});if(Object.keys(ce).length>0)te.extend=ce;let ee=[...v.safelist||[],...k.safelist||[]],le={...v.shortcuts||{},...k.shortcuts||{}},ue=[...v.preflights||[],...k.preflights||[]],{fonts:de,...fe}=v,{fonts:pe,roles:Ae,shapes:Se,density:ve,...De}=k,Me={roles:Ae,shapes:Se,density:ve},je=pe??de;return{config:{...fe,...De,theme:te,safelist:ee,shortcuts:le,...ue.length>0?{preflights:ue}:{},content:[],output:""},safelist:ee,shortcuts:le,includePreflight:k.preflight!==!1,minify:k.minify===!0,tokenCSS:yf({...H,...te.colors},Ae)+bf(Se)+Sf(ve),unknownRoles:mf(Me),...je?{fonts:je}:{}}}function Ef(v,k=""){let C=`${v}${k}`,R=0;for(let T=0;T<C.length;T++){let z=C.charCodeAt(T);R=(R<<5)-R+z,R=R&R}return`stx-${Math.abs(R).toString(36)}`}function Cf(v,k,C={}){let{prefix:R="",preserveHost:T=!0,scopeKeyframes:z=!0,scopeCustomProperties:F=!1}=C;if(!v.trim())return"";let V=dl(v),H=[],K=new Map;if(z)for(let X of V){let G=X.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(G){let te=G[1],ce=`${k}_${te}`;K.set(te,ce)}}for(let X of V){let G=Rf(X,k,R,T,K,F);H.push(G)}return H.join(`
|
|
140
|
+
|
|
141
|
+
`)}function dl(v){let k=[],C=v.replace(/\/\*[\s\S]*?\*\//g,""),R=0,T="",z=!1,F="";for(let V=0;V<C.length;V++){let H=C[V];if(H==="@"&&R===0)z=!0;if(H==="{")R++;else if(H==="}"){if(R--,R===0){if(z){F+=H;let K=F.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(K){let[,X,G,te]=K;if(X==="keyframes")k.push({selector:`@keyframes ${G.trim()}`,declarations:te.trim()});else if(X==="media"||X==="supports"||X==="container"){let ce=dl(te);k.push({selector:`@${X} ${G.trim()}`,declarations:ce.map((ee)=>`${ee.selector} { ${ee.declarations} }`).join(`
|
|
142
|
+
`)})}else k.push({selector:`@${X} ${G.trim()}`,declarations:te.trim()})}F="",z=!1}else if(T.trim()){T+=H;let K=T.match(/([^{]+)\{([^}]*)\}/);if(K)k.push({selector:K[1].trim(),declarations:K[2].trim()});T=""}continue}}if(z)F+=H;else T+=H}return k}function Rf(v,k,C,R,T,z){let{selector:F,declarations:V}=v;if(F.startsWith("@")){if(F.startsWith("@keyframes")){let X=F.replace("@keyframes ","").trim();return`@keyframes ${T.get(X)||X} { ${V} }`}if(F.startsWith("@media")||F.startsWith("@supports")||F.startsWith("@container")){let G=dl(`x { ${V} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((te)=>Rf(te,k,C,R,T,z)).join(`
|
|
143
|
+
`);return`${F} {
|
|
144
|
+
${G}
|
|
145
|
+
}`}return`${F} { ${V} }`}let H=Oy(F,k,C,R),K=V;for(let[X,G]of T)K=K.replace(new RegExp(`\\b${X}\\b`,"g"),G);if(z)K=K.replace(/--([a-z-]+)/gi,`--${k}-$1`);return`${H} { ${K} }`}function Oy(v,k,C,R){let T=v.split(",").map((F)=>F.trim()),z=[];for(let F of T){if(F.startsWith(":host")){if(R)z.push(F);else{let K=F.replace(/:host(\([^)]*\))?/,`.${k}$1`);z.push(K)}continue}if(F.includes("::slotted")){z.push(F);continue}if(F===":root"){z.push(`:root .${k}`);continue}let V=C?`${C} .${k}`:`.${k}`;z.push(`${V} ${F}`);let H=My(F,k);if(H)z.push(C?`${C} ${H}`:H)}return z.join(", ")}function My(v,k){let C=0,R=v.length;for(let H=0;H<v.length;H++){let K=v[H];if(K==="["||K==="(")C++;else if(K==="]"||K===")")C--;else if(C===0&&(K===" "||K===">"||K==="+"||K==="~")){R=H;break}}let T=v.slice(0,R),z=v.slice(R);if(!T)return"";let F=T.length,V=0;for(let H=0;H<T.length;H++){let K=T[H];if(K==="["||K==="(")V++;else if(K==="]"||K===")")V--;else if(C===0&&V===0&&K===":"){F=H;break}}return`${T.slice(0,F)}.${k}${T.slice(F)}${z}`}var If=String.raw`(?<![\w-])scoped(?![\w-])`,fl=/<style\s+([^>]*)>/gi,Af=/<style\s+([^>]*)>([\s\S]*?)<\/style>/gi,Pf=new RegExp(If,"i"),Ny=new RegExp(If,"gi"),pl=/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi;function jy(v){fl.lastIndex=0;let k=fl.exec(v);while(k!==null){if(Pf.test(k[1]))return!0;k=fl.exec(v)}return!1}function gl(v){let k=new Set,C=[];pl.lastIndex=0;let R=pl.exec(v);while(R!==null){let T=R[0].trim();if(k.has(T))C.push({start:R.index,end:R.index+R[0].length});else k.add(T);R=pl.exec(v)}return C}function io(v){let k=gl(v);if(k.length===0)return v;let C=Array(k.length+1),R=0;for(let T=0;T<k.length;T++){let z=k[T];C[T]=v.slice(R,z.start),R=z.end}return C[k.length]=v.slice(R),C.join("")}function ha(v,k){if(!jy(v))return{html:v,hasScoped:!1};let C=Ef(k),R=`data-v-${C}`,T=v,z=!1;if(Af.lastIndex=0,T=T.replace(Af,(F,V,H)=>{if(!Pf.test(V))return F;z=!0;let K=Ly(H,R),X=V.replace(Ny,"").trim(),G=X?` ${X}`:"";return`<style data-stx-scoped="${C}"${G}>${K}</style>`}),!z)return{html:v,hasScoped:!1};return T=zy(T,R),{html:T,hasScoped:!0}}function Ly(v,k){return Cf(v,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${k}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${k}]`)}var By=(v)=>`\x00stx-scope-mask-${v}\x00`,Tf=/\u0000stx-scope-mask-(\d+)\u0000/g;function zy(v,k){let C=qn(v,(T,z)=>{let F=U(T,z);return F>z?F:us(T,z)},(T,z)=>By(z)),R=Wy(C.output,k);return Tf.lastIndex=0,R.replace(Tf,(T,z)=>C.tokens[Number(z)])}function Wy(v,k){let C=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return v.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(R,T,z)=>{if(C.has(T.toLowerCase()))return R;if(R.includes(k))return R;if(T.toLowerCase()==="style"||T.toLowerCase()==="script")return R;if(z)return R.replace(`<${T}${z}`,`<${T} ${k}${z}`);if(R.endsWith("/>"))return`<${T} ${k} />`;return`<${T} ${k}>`})}var e={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};var Xn=null,ya="";function Of(v){try{let k=v.startsWith("file:")?new URL(v).pathname:v;ya=`${k}@${Math.trunc(ao.statSync(k).mtimeMs)}`}catch{ya=v}}var hl=!1,Zr=null,oo="",ps=!1,Lf=256,Pr=new Map,Zn=new Map,xa=null,Bf=null,ba=new Map,Mf=new Set;function va(v){return Bun.hash(v).toString(16).padStart(16,"0").slice(0,16)}function ml(v,k){if(Pr.has(v))Pr.delete(v);else if(Pr.size>=Lf)Pr.delete(Pr.keys().next().value);Pr.set(v,k)}function Fy(v){let k=va(v);if(Zn.has(k))Zn.delete(k);else if(Zn.size>=Lf)Zn.delete(Zn.keys().next().value);return Zn.set(k,v),k}function ud(v){let k=Zn.get(v);if(k===void 0)return;return Zn.delete(v),Zn.set(v,k),k}async function Vy(v,k=xa){if(!k)return null;try{let C=Bun.file(Zt.join(k,`cw-${va(v)}.css`));if(!await C.exists())return null;return await C.text()}catch{return null}}async function Uy(v,k,C=xa){if(!C)return;try{if(!ao.existsSync(C))ao.mkdirSync(C,{recursive:!0});await Bun.write(Zt.join(C,`cw-${va(v)}.css`),k)}catch{}}async function Nf(v){try{let k=await import(v);if(k&&k.CSSGenerator)return{CSSGenerator:k.CSSGenerator,config:k.config,build:k.build,defaultConfig:k.defaultConfig,extractClasses:k.extractClasses}}catch{}return null}var Hy=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],qy=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function Ky(){let v=[],k=process.cwd();while(k!==Zt.dirname(k)){for(let C of["node_modules","pantry"])for(let R of Hy)v.push(Zt.join(k,C,...R));k=Zt.dirname(k)}return v}function Xy(){let v=[],k=process.env.HOME||process.env.USERPROFILE||"",C=[k&&Zt.join(k,"Code","Tools","ts-css"),k&&Zt.join(k,"Code","Tools","crosswind"),k&&Zt.join(k,"repos","stacks-org","ts-css"),k&&Zt.join(k,"repos","stacks-org","crosswind"),Zt.join(process.cwd(),"..","ts-css"),Zt.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let R of C)v.push(Zt.join(R,"packages","toolkit","dist","engine","index.js")),v.push(Zt.join(R,"packages","toolkit","src","engine","index.ts"));if(k)v.push(Zt.join(k,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return v}async function hi(){if(hl)return Xn;hl=!0;try{let v=async(T)=>{for(let z of T){if(!await Bun.file(z).exists())continue;let F=await Nf(z);if(F){if(Of(z),!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded from ${Zt.dirname(Zt.dirname(z))}`);return F}}return null};if(process.env.CROSSWIND_SRC){let T=Zt.resolve(process.env.CROSSWIND_SRC),z=await v([T]);if(!z)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${T}`);return Xn=z,Xn}let k=await v(Ky());if(k)return Xn=k,Xn;let C=qy;for(let T of C){let z=await Nf(T);if(z){Xn=z;try{Of(import.meta.resolve(T))}catch{ya=T}if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded`);return Xn}}let R=await v(Xy());if(R)return Xn=R,Xn;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${e.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${e.reset}`),console.warn(`${e.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${e.reset}`),null}}function dd(){yl.clear(),Xn=null,hl=!1,Zr=null,oo="",Pr.clear(),Zn.clear(),Bf=null,ba.clear()}var jf=!1;async function yi(v){try{let k=Df({name:"css",cwd:v})?"css":Df({name:"crosswind",cwd:v})?"crosswind":null;if(!k)return null;if(k==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!jf)jf=!0,console.warn(`${e.yellow}[ts-css]${e.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:C}=await import("bunfig"),R=await C({name:k,cwd:v,defaultConfig:{},checkEnv:!1,verbose:!1});if(!R?.path||!R.config||Object.keys(R.config).length===0)return null;let T=Zt.relative(v,R.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} Loaded config from ${T||R.path}`);return R.config}catch(k){if(k instanceof Error&&k.name==="ConfigNotFoundError")return null;return console.warn(`${e.yellow}[ts-css]${e.reset} Failed to load css config:`,k instanceof Error?k.message:k),null}}async function Ic(v){let k=null;try{let{loadStxConfig:C}=await import("./chunk-yn9fwnq2.js"),R=await C(v);if(R.css)if(typeof R.css==="string"){let T=Zt.isAbsolute(R.css)?R.css:Zt.resolve(v,R.css);if(await Bun.file(T).exists()){let z=await import(T);k=z.default||z,console.log(`${e.green}[ts-css]${e.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(k={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let T=Zt.isAbsolute(R.css.config)?R.css.config:Zt.resolve(v,R.css.config);if(await Bun.file(T).exists()){let z=await import(T);k={...z.default||z,...k}}}console.log(`${e.green}[ts-css]${e.reset} Using inline CSS config from stx.config.ts`)}}catch{}return k||await yi(v)}function Oc(v){try{let k=new WeakSet;return va(JSON.stringify(v??{},(C,R)=>{if(typeof R==="function")return`[fn]${String(R)}`;if(typeof R==="object"&&R!==null){if(k.has(R))return"[circular]";k.add(R)}return R})??"")}catch{return"unhashable"}}async function jt(v){if(ps)return oo;ps=!0;try{let k=await hi();if(!k||!k.build)return ps=!1,"";if(!Zr)Zr=await yi(v);if(!Zr)return ps=!1,"";let C=k.defaultConfig?.theme||{},R=Zr.theme||{},T={...k.defaultConfig,...Zr,theme:{...C,...R,extend:{...C.extend||{},...R.extend||{}}}},z=performance.now(),F=await k.build(T),V=performance.now()-z;if(oo=F.css,console.log(`${e.cyan}[ts-css]${e.reset} Built ${F.classes.size} classes in ${V.toFixed(1)}ms`),T.output){let H=Zt.isAbsolute(T.output)?T.output:Zt.join(v,T.output),K=Zt.dirname(H);if(!ao.existsSync(K))ao.mkdirSync(K,{recursive:!0});await Bun.write(H,F.css)}return ps=!1,F.css}catch(k){return console.error(`${e.red}[ts-css]${e.reset} Build error:`,k),ps=!1,oo}}async function _n(v){Zr=null,await jt(v)}function pd(){return oo}function Nc(v){let k=new Set,C=/class\s*=\s*["']([^"']+)["']/gi,R=C.exec(v);while(R!==null){for(let F of R[1].split(/\s+/))if(F.trim())k.add(F.trim());R=C.exec(v)}let T=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,z=T.exec(v);while(z!==null){let F=z[1].match(/'([^']+)'/g);if(F){for(let V of F)for(let H of V.slice(1,-1).split(/\s+/))if(H.trim())k.add(H.trim())}z=T.exec(v)}return k}var yl=m(64);async function Dc(v,k){let C=()=>ba.get(k?Zt.resolve(k):process.cwd())?.fingerprint??null,R=yl.get(h(v,k,C()));if(R!==void 0)return R;let T=await Zy(v,k);if(T)yl.set(h(v,k,C()),T);return T}function*zf(v){yield v;let k=new Set;for(let C of v.matchAll(/\/_stx\/modules\.([0-9a-f]{16})\.js/g)){let R=C[1];if(k.has(R))continue;k.add(R);let T=mi(R);if(T)yield T}}function fd(v){return[...zf(v)].join(`
|
|
146
|
+
`)}async function Zy(v,k){try{let C=await hi();if(!C)return"";let R=new Set;for(let Me of zf(v)){let je=typeof C.extractClasses==="function"?C.extractClasses(Me):Nc(Me);for(let Le of je)R.add(Le)}if(R.size===0)return"";let T=k?Zt.resolve(k):process.cwd(),z=a(T,"cache");if(!xa)xa=z;let F=ba.get(T);if(!F){let Me=await Ic(T);F={config:Me,fingerprint:Oc(Me)},ba.set(T,F),Bf=F.fingerprint}let V=[...R].sort().join(" "),H=`${ya}::${F.fingerprint||"default"}::${V}`,K=Pr.get(H);if(K!==void 0)return ml(H,K),K;let X=await Vy(H,z);if(X!==null)return ml(H,X),X;let G=C.defaultConfig||C.config,te=F.config||{},ce=kf(G,te),{safelist:ee,includePreflight:le,minify:ue,tokenCSS:de}=ce;if(ce.unknownRoles.length>0&&!Mf.has(T))Mf.add(T),console.warn(`${e.yellow}[ts-css]${e.reset} No stx role for ${ce.unknownRoles.join(", ")} - these keep the stock value. Role names: semanticTokenNames() in @stacksjs/stx/theme-tokens.`);let fe=ce.config,pe=new C.CSSGenerator(fe),Ae=fe.shortcuts||te.shortcuts||{},Se=Object.keys(Ae).filter((Me)=>R.has(Me)||ee.includes(Me));for(let Me of ee)if(!Ae[Me])pe.generate(Me);for(let Me of R)if(!Ae[Me])pe.generate(Me);let ve="";if(Se.length>0){let Me=new C.CSSGenerator(fe);for(let je of Se)Me.generate(je);if(ve=Me.toCSS(!1,ue),ve&&!ve.endsWith(`
|
|
147
|
+
`))ve+=`
|
|
148
|
+
`}let De=ve+pe.toCSS(le,ue);return De=_f(C.CSSGenerator,ce)+de+De,ml(H,De),Uy(H,De,z),De}catch(C){return console.warn("Failed to generate Css CSS:",C),""}}async function f(v,k,C=!1,R=!1){let T=await Dc(v,k);if(!T)return R?io(v):v;let z=C?`<link data-css="generated" rel="stylesheet" href="/_stx/css.${Fy(T)}.css">`:`<style data-css="generated">
|
|
149
|
+
${T}
|
|
150
|
+
</style>`;if(R)return Gy(v,z);let F=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(F.test(v)){let V=!1;return v.replace(F,()=>{if(V)return"";return V=!0,z})}if(v.includes("</head>"))return v.replace("</head>",`${z}
|
|
151
|
+
</head>`);if(v.includes("<body"))return v.replace(/<body([^>]*)>/,`<body$1>
|
|
152
|
+
${z}`);return z+v}function Gy(v,k){let C=gl(v).map((H)=>({...H,replacement:""})),R=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g,T=R.exec(v);if(T!==null){let H=!0;while(T!==null)C.push({start:T.index,end:T.index+T[0].length,replacement:H?k:""}),H=!1,T=R.exec(v)}else{let H=v.indexOf("</head>");if(H!==-1)C.push({start:H,end:H,replacement:`${k}
|
|
153
|
+
`});else{let K=v.match(/<body([^>]*)>/);if(K?.index!==void 0)C.push({start:K.index,end:K.index+K[0].length,replacement:`${K[0]}
|
|
154
|
+
${k}`});else C.push({start:0,end:0,replacement:k})}}C.sort((H,K)=>H.start-K.start||H.end-K.end);for(let H=1;H<C.length;H++)if(C[H].start<C[H-1].end)return Jy(io(v),k);let z=Array(C.length*2+1),F=0,V=0;for(let H of C)z[V++]=v.slice(F,H.start),z[V++]=H.replacement,F=H.end;return z[V]=v.slice(F),z.join("")}function Jy(v,k){let C=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(C.test(v)){let R=!1;return v.replace(C,()=>{if(R)return"";return R=!0,k})}if(v.includes("</head>"))return v.replace("</head>",`${k}
|
|
155
|
+
</head>`);if(v.includes("<body"))return v.replace(/<body([^>]*)>/,`<body$1>
|
|
156
|
+
${k}`);return k+v}var xl=[{open:/<!--/g,close:/-->/g},{open:/<script\b/gi,close:/<\/script\s*>/gi},{open:/<style\b/gi,close:/<\/style\s*>/gi}],Wf=/<body\b([^>]*)>/gi;function Gn(v){let k=0,C,R=xl.map(()=>{return});while(k<v.length){if(C===void 0||C!==null&&C.index<k)Wf.lastIndex=k,C=Wf.exec(v);if(!C)return null;let T=C.index,z=-1,F=null;for(let H=0;H<xl.length;H++){let K=xl[H],X=R[H];if(X===void 0||X!==null&&X.index<k)K.open.lastIndex=k,X=K.open.exec(v),R[H]=X;if(!X)continue;if(X.index<T&&(z===-1||X.index<z))z=X.index,F=K.close}if(z===-1||!F)return{index:T,tag:C[0],attrs:C[1]??""};F.lastIndex=z;let V=F.exec(v);if(!V)return null;k=V.index+V[0].length}return null}function gs(v,k){let C=Gn(v);if(!C)return v;return v.slice(0,C.index)+k(C.tag,C.attrs)+v.slice(C.index+C.tag.length)}var Ff=/<style\b[^>]*>/iy,Vf=/<\/style>/gi,Uf=/<script\b[^>]*>/iy,Hf=/<template(?=[\s>/])[^>]*>/iy,qf=/<\/template\s*>/iy;function co(v){let k=0,C=0,R=-1;while(k<v.length){let T=v.indexOf("<",k);if(T===-1)return-1;if(v.startsWith("<!--",T)){let H=v.indexOf("-->",T+4);k=H===-1?v.length:H+3;continue}Ff.lastIndex=T;let z=Ff.exec(v);if(z){Vf.lastIndex=T+z[0].length;let H=Vf.exec(v);k=H===null?v.length:H.index+8;continue}Hf.lastIndex=T;let F=Hf.exec(v);if(F){if(C===0)R=T;C++,k=T+F[0].length;continue}qf.lastIndex=T;let V=qf.exec(v);if(V){if(C>0)C--;k=T+V[0].length;continue}if(Uf.lastIndex=T,Uf.test(v))return C>0?R:T;k=T+1}return-1}function Kf(){return`
|
|
157
|
+
// STX Lifecycle Runtime
|
|
158
|
+
(function() {
|
|
159
|
+
if (typeof window === 'undefined') return;
|
|
160
|
+
|
|
161
|
+
const instances = new Map();
|
|
162
|
+
let currentInstance = null;
|
|
163
|
+
let idCounter = 0;
|
|
164
|
+
|
|
165
|
+
function generateId() {
|
|
166
|
+
return 'stx-' + (++idCounter) + '-' + Date.now().toString(36);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function createInstance(element) {
|
|
170
|
+
const instance = {
|
|
171
|
+
id: generateId(),
|
|
172
|
+
element: element,
|
|
173
|
+
mountHooks: [],
|
|
174
|
+
destroyHooks: [],
|
|
175
|
+
updateHooks: [],
|
|
176
|
+
refs: new Map(),
|
|
177
|
+
watchers: [],
|
|
178
|
+
isMounted: false
|
|
179
|
+
};
|
|
180
|
+
instances.set(instance.id, instance);
|
|
181
|
+
return instance;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
window.STX = window.STX || {};
|
|
185
|
+
|
|
186
|
+
// Lifecycle hooks
|
|
187
|
+
window.STX.onMount = function(hook) {
|
|
188
|
+
if (currentInstance) currentInstance.mountHooks.push(hook);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
window.STX.onDestroy = function(hook) {
|
|
192
|
+
if (currentInstance) currentInstance.destroyHooks.push(hook);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
window.STX.onUpdate = function(hook) {
|
|
196
|
+
if (currentInstance) currentInstance.updateHooks.push(hook);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// Aliases
|
|
200
|
+
window.STX.onMounted = window.STX.onMount;
|
|
201
|
+
window.STX.onUnmounted = window.STX.onDestroy;
|
|
202
|
+
window.STX.onUpdated = window.STX.onUpdate;
|
|
203
|
+
|
|
204
|
+
// Refs
|
|
205
|
+
window.STX.ref = function(initialValue) {
|
|
206
|
+
const r = { value: initialValue || null };
|
|
207
|
+
Object.defineProperty(r, 'current', {
|
|
208
|
+
get: function() { return this.value; }
|
|
209
|
+
});
|
|
210
|
+
if (currentInstance) {
|
|
211
|
+
currentInstance.refs.set('ref-' + currentInstance.refs.size, r);
|
|
212
|
+
}
|
|
213
|
+
return r;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// Watch
|
|
217
|
+
window.STX.watch = function(source, callback, options) {
|
|
218
|
+
options = options || {};
|
|
219
|
+
let oldValue;
|
|
220
|
+
let cleanup;
|
|
221
|
+
let isActive = true;
|
|
222
|
+
|
|
223
|
+
function run() {
|
|
224
|
+
if (!isActive) return;
|
|
225
|
+
const newValue = source();
|
|
226
|
+
if (oldValue !== newValue || options.immediate) {
|
|
227
|
+
if (cleanup) cleanup();
|
|
228
|
+
cleanup = callback(newValue, oldValue);
|
|
229
|
+
oldValue = newValue;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (options.immediate) {
|
|
234
|
+
run();
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
oldValue = source();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const intervalId = setInterval(run, 16);
|
|
241
|
+
|
|
242
|
+
function stop() {
|
|
243
|
+
isActive = false;
|
|
244
|
+
clearInterval(intervalId);
|
|
245
|
+
if (cleanup) cleanup();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (currentInstance) {
|
|
249
|
+
currentInstance.watchers.push({ stop: stop });
|
|
250
|
+
currentInstance.destroyHooks.push(stop);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return stop;
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// Computed
|
|
257
|
+
window.STX.computed = function(getter) {
|
|
258
|
+
let cached;
|
|
259
|
+
let dirty = true;
|
|
260
|
+
return {
|
|
261
|
+
get value() {
|
|
262
|
+
if (dirty) {
|
|
263
|
+
cached = getter();
|
|
264
|
+
dirty = false;
|
|
265
|
+
queueMicrotask(function() { dirty = true; });
|
|
266
|
+
}
|
|
267
|
+
return cached;
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// Component management
|
|
273
|
+
window.STX.setupComponent = function(element, setup) {
|
|
274
|
+
const instance = createInstance(element);
|
|
275
|
+
currentInstance = instance;
|
|
276
|
+
try {
|
|
277
|
+
setup();
|
|
278
|
+
}
|
|
279
|
+
finally {
|
|
280
|
+
currentInstance = null;
|
|
281
|
+
}
|
|
282
|
+
return instance;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
window.STX.mountComponent = function(instance) {
|
|
286
|
+
if (instance.isMounted) return;
|
|
287
|
+
instance.isMounted = true;
|
|
288
|
+
instance.mountHooks.forEach(function(hook) {
|
|
289
|
+
try {
|
|
290
|
+
const cleanup = hook();
|
|
291
|
+
if (typeof cleanup === 'function') {
|
|
292
|
+
instance.destroyHooks.push(cleanup);
|
|
293
|
+
}
|
|
294
|
+
else if (cleanup && typeof cleanup.then === 'function') {
|
|
295
|
+
cleanup.catch(function(e) { console.error('[stx] onMount error:', e); });
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
catch (e) {
|
|
299
|
+
console.error('[stx] onMount error:', e);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
window.STX.destroyComponent = function(instance) {
|
|
305
|
+
if (!instance.isMounted) return;
|
|
306
|
+
instance.watchers.forEach(function(w) { w.stop(); });
|
|
307
|
+
instance.destroyHooks.forEach(function(hook) {
|
|
308
|
+
try { hook(); }
|
|
309
|
+
catch (e) { console.error('[stx] onDestroy error:', e); }
|
|
310
|
+
});
|
|
311
|
+
instance.refs.forEach(function(ref) { ref.value = null; });
|
|
312
|
+
instance.isMounted = false;
|
|
313
|
+
instances.delete(instance.id);
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// ==========================================================================
|
|
317
|
+
// Vue-Style Refs System - No document.** required!
|
|
318
|
+
// ==========================================================================
|
|
319
|
+
|
|
320
|
+
// Internal: Query for ref elements without exposing document API
|
|
321
|
+
function queryRef(name, root) {
|
|
322
|
+
return (root || document).querySelector('[data-stx-ref="' + name + '"], [data-ref="' + name + '"]');
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function queryAllRefs(root) {
|
|
326
|
+
return (root || document).querySelectorAll('[data-stx-ref], [data-ref]');
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Auto-bind refs from ref attributes (Vue-style)
|
|
330
|
+
window.STX.bindRefs = function(root, refs) {
|
|
331
|
+
if (!root) return;
|
|
332
|
+
queryAllRefs(root).forEach(function(el) {
|
|
333
|
+
var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
|
|
334
|
+
if (refs[refName]) {
|
|
335
|
+
refs[refName].value = el;
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// Vue-style useRefs() - returns object with all refs as direct elements
|
|
341
|
+
// Usage: const { input, button, container } = STX.useRefs()
|
|
342
|
+
window.STX.useRefs = function(root) {
|
|
343
|
+
var refs = {};
|
|
344
|
+
queryAllRefs(root).forEach(function(el) {
|
|
345
|
+
var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
|
|
346
|
+
if (refName) {
|
|
347
|
+
refs[refName] = el;
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
return refs;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
// Get a single ref by name - Vue's useTemplateRef equivalent
|
|
354
|
+
// Usage: const input = STX.useRef('input')
|
|
355
|
+
window.STX.useRef = function(name, root) {
|
|
356
|
+
return queryRef(name, root);
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
// Two-way binding helper for form elements
|
|
360
|
+
// Usage: STX.model(inputEl, state, 'username')
|
|
361
|
+
window.STX.model = function(el, state, key) {
|
|
362
|
+
if (!el || !state) return;
|
|
363
|
+
|
|
364
|
+
var isCheckbox = el.type === 'checkbox';
|
|
365
|
+
var isRadio = el.type === 'radio';
|
|
366
|
+
var isSelect = el.tagName === 'SELECT';
|
|
367
|
+
|
|
368
|
+
// Set initial value
|
|
369
|
+
if (isCheckbox) {
|
|
370
|
+
el.checked = !!state[key];
|
|
371
|
+
}
|
|
372
|
+
else if (isRadio) {
|
|
373
|
+
el.checked = el.value === state[key];
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
el.value = state[key] || '';
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Listen for changes
|
|
380
|
+
var eventType = isCheckbox || isRadio ? 'change' : 'input';
|
|
381
|
+
el.addEventListener(eventType, function() {
|
|
382
|
+
if (isCheckbox) {
|
|
383
|
+
state[key] = el.checked;
|
|
384
|
+
}
|
|
385
|
+
else if (isRadio) {
|
|
386
|
+
if (el.checked) state[key] = el.value;
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
state[key] = el.value;
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
// Return cleanup function
|
|
394
|
+
return function() {
|
|
395
|
+
el.removeEventListener(eventType, arguments.callee);
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
// Batch event binding helper - cleaner than manual addEventListener
|
|
400
|
+
// Usage: STX.on({ click: [btn1, btn2], input: [textField] }, handler)
|
|
401
|
+
window.STX.on = function(el, event, handler) {
|
|
402
|
+
if (!el) return function() {};
|
|
403
|
+
el.addEventListener(event, handler);
|
|
404
|
+
return function() { el.removeEventListener(event, handler); };
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// Bind multiple events at once
|
|
408
|
+
// Usage: STX.events(refs.btn, { click: handleClick, mouseenter: handleHover })
|
|
409
|
+
window.STX.events = function(el, eventMap) {
|
|
410
|
+
if (!el) return function() {};
|
|
411
|
+
var cleanups = [];
|
|
412
|
+
Object.keys(eventMap).forEach(function(event) {
|
|
413
|
+
el.addEventListener(event, eventMap[event]);
|
|
414
|
+
cleanups.push(function() { el.removeEventListener(event, eventMap[event]); });
|
|
415
|
+
});
|
|
416
|
+
return function() { cleanups.forEach(function(c) { c(); }); };
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
// ==========================================================================
|
|
420
|
+
// DOM Helpers - Eliminate document.* usage
|
|
421
|
+
// ==========================================================================
|
|
422
|
+
|
|
423
|
+
// Global keyboard event listener
|
|
424
|
+
// Usage: STX.onKey('Escape', () => closeModal())
|
|
425
|
+
window.STX.onKey = function(key, handler, options) {
|
|
426
|
+
var listener = function(e) {
|
|
427
|
+
if (e.key === key) {
|
|
428
|
+
handler(e);
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
document.addEventListener('keydown', listener, options);
|
|
432
|
+
return function() { document.removeEventListener('keydown', listener, options); };
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
// Create element helper
|
|
436
|
+
// Usage: STX.el('div', { class: 'foo' }, 'text content')
|
|
437
|
+
window.STX.el = function(tag, attrs, content) {
|
|
438
|
+
var el = document.createElement(tag);
|
|
439
|
+
if (attrs) {
|
|
440
|
+
Object.keys(attrs).forEach(function(key) {
|
|
441
|
+
if (key === 'class') {
|
|
442
|
+
el.className = attrs[key];
|
|
443
|
+
}
|
|
444
|
+
else if (key.startsWith('on')) {
|
|
445
|
+
el.addEventListener(key.slice(2).toLowerCase(), attrs[key]);
|
|
446
|
+
}
|
|
447
|
+
else {
|
|
448
|
+
el.setAttribute(key, attrs[key]);
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
if (content) {
|
|
453
|
+
if (typeof content === 'string') {
|
|
454
|
+
el.textContent = content;
|
|
455
|
+
}
|
|
456
|
+
else if (Array.isArray(content)) {
|
|
457
|
+
content.forEach(function(child) { el.appendChild(child); });
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
el.appendChild(content);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return el;
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
// Get currently focused element
|
|
467
|
+
// Usage: const focused = STX.activeElement()
|
|
468
|
+
window.STX.activeElement = function() {
|
|
469
|
+
return document.activeElement;
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
// Escape HTML helper
|
|
473
|
+
// Usage: const safe = STX.escapeHtml(userInput)
|
|
474
|
+
window.STX.escapeHtml = function(text) {
|
|
475
|
+
var div = document.createElement('div');
|
|
476
|
+
div.textContent = text;
|
|
477
|
+
return div.innerHTML;
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
// MutationObserver for automatic lifecycle management
|
|
481
|
+
const observer = new MutationObserver(function(mutations) {
|
|
482
|
+
mutations.forEach(function(mutation) {
|
|
483
|
+
// Handle removed nodes
|
|
484
|
+
mutation.removedNodes.forEach(function(node) {
|
|
485
|
+
if (node.nodeType === 1 && node.__stx_instance__) {
|
|
486
|
+
window.STX.destroyComponent(node.__stx_instance__);
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
// Start observing when DOM is ready
|
|
493
|
+
if (document.readyState === 'loading') {
|
|
494
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
495
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
console.log('[stx] Lifecycle runtime initialized');
|
|
503
|
+
})();
|
|
504
|
+
`}function bl(v){return Symbol(v)}var h_=bl("theme"),y_=bl("router"),x_=bl("i18n");import*as Zf from"crypto";function Xf(v){let k=/\$(\w+)\./g,C=[],R;while((R=k.exec(v))!==null)if(!C.includes(R[1]))C.push(R[1]);return C}function Yy(){return`stx-${Zf.randomBytes(4).toString("hex")}`}function Qy(v){return/\$\w+\./.test(v)}function ex(v){if(!v.includes("{{")||!/\$\w+\./.test(v))return{html:v,bindings:[],stores:new Set};let k=[],C=new Set,R=/<(\w+)([^>]*?)(\s*\/?>)/g,T=v;return T=T.replace(R,(z,F,V,H)=>{if(["script","style","template"].includes(F.toLowerCase()))return z;let K=[],X=!1,G=V,te=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,ce=[...V.matchAll(te)];for(let ue of ce){let de=ue[0],fe=ue[1],pe=ue[2];if(Qy(pe)){X=!0;let Ae=pe.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(Ae){let Se=Ae[1];if(K.push({attr:fe,expr:Se,fullMatch:de,originalAttr:fe}),Xf(Se).forEach((De)=>C.add(De)),fe==="text")G=G.replace(de,"");else if(fe==="class")G=G.replace(de,'class=""');else if(fe==="disabled"||fe==="hidden")G=G.replace(de,"");else G=G.replace(de,`${fe}=""`)}}}if(!X)return z;let ee=G.match(/\bid\s*=\s*"([^"]+)"/),le;if(ee)le=ee[1];else le=Yy(),G=` id="${le}"${G}`;for(let ue of K)k.push({elementId:le,attribute:ue.attr,expression:ue.expr,stores:Xf(ue.expr)});return`<${F}${G}${H}`}),{html:T,bindings:k,stores:C}}function tx(v,k){if(v.length===0)return"";let C=Array.from(k),R=`
|
|
505
|
+
<script>
|
|
506
|
+
(function() {
|
|
507
|
+
'use strict';
|
|
508
|
+
|
|
509
|
+
// Wait for stores to be available
|
|
510
|
+
function initBindings() {
|
|
511
|
+
var stores = window.VoideStores;
|
|
512
|
+
if (!stores) {
|
|
513
|
+
setTimeout(initBindings, 10);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// Store references for expressions
|
|
518
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
519
|
+
var $state = {};
|
|
520
|
+
`;for(let T of C)R+=` $state.${T} = stores.${T} ? stores.${T}.get() : {};
|
|
521
|
+
`;R+=`
|
|
522
|
+
// Binding update functions
|
|
523
|
+
function updateBindings() {
|
|
524
|
+
`;for(let T of v){let{elementId:z,attribute:F,expression:V}=T,H=V.replace(/\$(\w+)\./g,"$state.$1.");if(F==="text")R+=` (function() {
|
|
525
|
+
var el = document.getElementById('${z}');
|
|
526
|
+
if (el) {
|
|
527
|
+
try {
|
|
528
|
+
el.textContent = ${H};
|
|
529
|
+
}
|
|
530
|
+
catch (e) { console.error('Binding error:', e); }
|
|
531
|
+
}
|
|
532
|
+
})();
|
|
533
|
+
`;else if(F==="html")R+=` (function() {
|
|
534
|
+
var el = document.getElementById('${z}');
|
|
535
|
+
if (el) {
|
|
536
|
+
try {
|
|
537
|
+
el.innerHTML = ${H};
|
|
538
|
+
}
|
|
539
|
+
catch (e) { console.error('Binding error:', e); }
|
|
540
|
+
}
|
|
541
|
+
})();
|
|
542
|
+
`;else if(F==="class")R+=` (function() {
|
|
543
|
+
var el = document.getElementById('${z}');
|
|
544
|
+
if (el) {
|
|
545
|
+
try {
|
|
546
|
+
var value = ${H};
|
|
547
|
+
if (typeof value === 'string') {
|
|
548
|
+
// Dynamic class string - merge with existing static classes
|
|
549
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
550
|
+
var staticClasses = el.getAttribute('data-static-class') || el.className;
|
|
551
|
+
if (!el.hasAttribute('data-static-class')) {
|
|
552
|
+
el.setAttribute('data-static-class', el.className);
|
|
553
|
+
}
|
|
554
|
+
el.className = (el.getAttribute('data-static-class') + ' ' + value).trim();
|
|
555
|
+
}
|
|
556
|
+
else if (typeof value === 'object') {
|
|
557
|
+
// Object syntax: { 'class-name': condition }
|
|
558
|
+
for (var cls in value) {
|
|
559
|
+
if (value[cls]) {
|
|
560
|
+
el.classList.add(cls);
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
el.classList.remove(cls);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
catch (e) { console.error('Binding error:', e); }
|
|
569
|
+
}
|
|
570
|
+
})();
|
|
571
|
+
`;else if(F==="show")R+=` (function() {
|
|
572
|
+
var el = document.getElementById('${z}');
|
|
573
|
+
if (el) {
|
|
574
|
+
try {
|
|
575
|
+
el.style.display = (${H}) ? '' : 'none';
|
|
576
|
+
}
|
|
577
|
+
catch (e) { console.error('Binding error:', e); }
|
|
578
|
+
}
|
|
579
|
+
})();
|
|
580
|
+
`;else if(F==="if")R+=` (function() {
|
|
581
|
+
var el = document.getElementById('${z}');
|
|
582
|
+
if (el) {
|
|
583
|
+
try {
|
|
584
|
+
el.style.visibility = (${H}) ? 'visible' : 'hidden';
|
|
585
|
+
}
|
|
586
|
+
catch (e) { console.error('Binding error:', e); }
|
|
587
|
+
}
|
|
588
|
+
})();
|
|
589
|
+
`;else R+=` (function() {
|
|
590
|
+
var el = document.getElementById('${z}');
|
|
591
|
+
if (el) {
|
|
592
|
+
try {
|
|
593
|
+
var value = ${H};
|
|
594
|
+
if (value === false || value === null || value === undefined) {
|
|
595
|
+
el.removeAttribute('${F}');
|
|
596
|
+
}
|
|
597
|
+
else if (value === true) {
|
|
598
|
+
el.setAttribute('${F}', '');
|
|
599
|
+
}
|
|
600
|
+
else {
|
|
601
|
+
el.setAttribute('${F}', value);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
catch (e) { console.error('Binding error:', e); }
|
|
605
|
+
}
|
|
606
|
+
})();
|
|
607
|
+
`}R+=` }
|
|
608
|
+
|
|
609
|
+
// Subscribe to stores and update on changes. Capture the disposers so
|
|
610
|
+
// SPA fragment swaps can tear down old bindings before the next page's
|
|
611
|
+
// runtime takes over \u2014 without this, every navigation between pages
|
|
612
|
+
// using reactive-bindings stacked another subscription on every store,
|
|
613
|
+
// walking detached DOM forever. See stacksjs/stx#1709.
|
|
614
|
+
var _disposers = [];
|
|
615
|
+
`;for(let T of C)R+=` if (stores.${T}) {
|
|
616
|
+
var _unsub_${T} = stores.${T}.subscribe(function(state) {
|
|
617
|
+
$state.${T} = state;
|
|
618
|
+
updateBindings();
|
|
619
|
+
});
|
|
620
|
+
// store.subscribe() may return the disposer (preferred) or void; both
|
|
621
|
+
// are tolerated here.
|
|
622
|
+
if (typeof _unsub_${T} === 'function') _disposers.push(_unsub_${T});
|
|
623
|
+
}
|
|
624
|
+
`;return R+=`
|
|
625
|
+
// Initial update
|
|
626
|
+
updateBindings();
|
|
627
|
+
|
|
628
|
+
// Register this runtime's cleanup so SPA navigation can run it before
|
|
629
|
+
// swapping pages. The router (and any code) can call
|
|
630
|
+
// window.__stxCleanupBindings() to dispose subscriptions; we also wire
|
|
631
|
+
// 'popstate' and 'beforeunload' as a safety net for browser-driven nav.
|
|
632
|
+
function _cleanup() {
|
|
633
|
+
for (var i = 0; i < _disposers.length; i++) {
|
|
634
|
+
try { _disposers[i](); } catch (e) { /* swallow */ }
|
|
635
|
+
}
|
|
636
|
+
_disposers.length = 0;
|
|
637
|
+
}
|
|
638
|
+
if (!window.__stxBindingsCleanups) window.__stxBindingsCleanups = [];
|
|
639
|
+
window.__stxBindingsCleanups.push(_cleanup);
|
|
640
|
+
if (!window.__stxCleanupBindings) {
|
|
641
|
+
window.__stxCleanupBindings = function() {
|
|
642
|
+
var fns = window.__stxBindingsCleanups || [];
|
|
643
|
+
for (var i = 0; i < fns.length; i++) {
|
|
644
|
+
try { fns[i](); } catch (e) { /* swallow */ }
|
|
645
|
+
}
|
|
646
|
+
window.__stxBindingsCleanups = [];
|
|
647
|
+
};
|
|
648
|
+
window.addEventListener('popstate', window.__stxCleanupBindings);
|
|
649
|
+
window.addEventListener('beforeunload', window.__stxCleanupBindings);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// Start when DOM is ready
|
|
654
|
+
if (document.readyState === 'loading') {
|
|
655
|
+
document.addEventListener('DOMContentLoaded', initBindings);
|
|
656
|
+
}
|
|
657
|
+
else {
|
|
658
|
+
initBindings();
|
|
659
|
+
}
|
|
660
|
+
})();
|
|
661
|
+
</script>
|
|
662
|
+
`,R}function Gf(v){let{html:k,bindings:C,stores:R}=ex(v);if(C.length===0)return v;let T=tx(C,R),z=k.lastIndexOf("</body>");if(z!==-1)return k.slice(0,z)+T+k.slice(z);return k+T}function nx(v){let k=v.analytics;if(!k?.enabled)return"";switch(k.driver){case"fathom":return rx(k);case"google-analytics":return sx(k);case"plausible":return ix(k);case"self-hosted":return ox(k);case"custom":return ax(k);default:return""}}function rx(v){let k=v.fathom;if(!k?.siteId)return"";let C=k.scriptUrl||"https://cdn.usefathom.com/script.js",R=k.defer!==!1?" defer":"",T=[`data-site="${hn(k.siteId)}"`];if(k.honorDnt)T.push('data-honor-dnt="true"');if(k.spa)T.push('data-spa="auto"');if(k.canonical)T.push(`data-canonical="${hn(k.canonical)}"`);if(k.auto===!1)T.push('data-auto="false"');return`
|
|
663
|
+
<!-- Fathom Analytics -->
|
|
664
|
+
<script src="${hn(C)}" ${T.join(" ")}${R}></script>
|
|
665
|
+
`}function sx(v){let k=v.googleAnalytics;if(!k?.measurementId)return"";let C=hn(k.measurementId),R=k.debug?`gtag('config', '${C}', { 'debug_mode': true });`:"";return`
|
|
666
|
+
<!-- Google Analytics -->
|
|
667
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id=${C}"></script>
|
|
668
|
+
<script>
|
|
669
|
+
window.dataLayer = window.dataLayer || [];
|
|
670
|
+
function gtag(){dataLayer.push(arguments);}
|
|
671
|
+
gtag('js', new Date());
|
|
672
|
+
gtag('config', '${C}');
|
|
673
|
+
${R}
|
|
674
|
+
</script>
|
|
675
|
+
`}function ix(v){let k=v.plausible;if(!k?.domain)return"";let C=k.scriptUrl||"https://plausible.io/js/script.js",R=[`data-domain="${hn(k.domain)}"`],T=C,z=[];if(k.trackLocalhost)z.push("local");if(k.hashMode)z.push("hash");if(z.length>0&&C==="https://plausible.io/js/script.js")T=`https://plausible.io/js/script.${z.join(".")}.js`;return`
|
|
676
|
+
<!-- Plausible Analytics -->
|
|
677
|
+
<script defer data-domain="${hn(k.domain)}" src="${hn(T)}"></script>
|
|
678
|
+
`}function ox(v){let k=v.selfHosted;if(!k?.siteId||!k?.apiEndpoint)return"";let C=hn(k.siteId),R=hn(k.apiEndpoint),T=k.honorDnt?'if(n.doNotTrack==="1")return;':"",z=k.trackHashChanges?"w.addEventListener('hashchange',pv);":"",F=k.trackOutboundLinks?`
|
|
679
|
+
d.addEventListener('click',function(e){
|
|
680
|
+
var a=e.target.closest('a');
|
|
681
|
+
if(a&&a.hostname!==location.hostname){
|
|
682
|
+
t('outbound',{url:a.href});
|
|
683
|
+
}
|
|
684
|
+
});`:"";return`
|
|
685
|
+
<!-- Self-Hosted Analytics -->
|
|
686
|
+
<script data-site="${C}" data-api="${R}" defer>
|
|
687
|
+
(function(){
|
|
688
|
+
'use strict';
|
|
689
|
+
var d=document,w=window,n=navigator,s=d.currentScript;
|
|
690
|
+
var site=s.dataset.site,api=s.dataset.api;
|
|
691
|
+
${T}
|
|
692
|
+
var q=[],sid=Math.random().toString(36).slice(2);
|
|
693
|
+
function t(e,p){
|
|
694
|
+
var x=new XMLHttpRequest();
|
|
695
|
+
x.open('POST',api+'/collect',true);
|
|
696
|
+
x.setRequestHeader('Content-Type','application/json');
|
|
697
|
+
x.send(JSON.stringify({
|
|
698
|
+
s:site,sid:sid,e:e,p:p||{},
|
|
699
|
+
u:location.href,r:d.referrer,t:d.title,
|
|
700
|
+
sw:screen.width,sh:screen.height
|
|
701
|
+
}));
|
|
702
|
+
}
|
|
703
|
+
function pv(){t('pageview');}
|
|
704
|
+
${z}
|
|
705
|
+
${F}
|
|
706
|
+
if(d.readyState==='complete')pv();
|
|
707
|
+
else w.addEventListener('load',pv);
|
|
708
|
+
w.stxAnalytics={track:function(n,v){t('event',{name:n,value:v});}};
|
|
709
|
+
})();
|
|
710
|
+
</script>
|
|
711
|
+
`}function ax(v){let k=v.custom;if(!k)return"";if(k.inlineScript)return`
|
|
712
|
+
<!-- Custom Analytics -->
|
|
713
|
+
<script>
|
|
714
|
+
${k.inlineScript}
|
|
715
|
+
</script>
|
|
716
|
+
`;if(!k.scriptUrl)return"";let C=[];if(k.scriptId)C.push(`id="${hn(k.scriptId)}"`);if(k.attributes)for(let[T,z]of Object.entries(k.attributes))C.push(`${hn(T)}="${hn(z)}"`);return`
|
|
717
|
+
<!-- Custom Analytics -->
|
|
718
|
+
<script${C.length>0?` ${C.join(" ")}`:""} src="${hn(k.scriptUrl)}" defer></script>
|
|
719
|
+
`}function Jf(v,k){let C=nx(k);if(!C)return v;if(!v.includes("</head>")){let R=v.lastIndexOf("</body>");if(R!==-1)return v.slice(0,R)+C+v.slice(R);return v+C}return v.replace("</head>",`${C}</head>`)}function hn(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var cx={enabled:!1,trackMouse:!0,trackClicks:!0,trackScroll:!0,samplingRate:100,honorDnt:!0,batchSize:50,maxDataPoints:1000,sessionTimeout:30,persistData:!1,storagePrefix:"stx_heatmap",captureAttributes:["data-heatmap-id","data-track"],ignoreSelectors:["[data-heatmap-ignore]",".heatmap-ignore"],debugOverlay:!1};function Yf(v){let k=v.heatmap;if(!k?.enabled)return"";let C={...cx,...k};return`
|
|
720
|
+
<!-- stx Heatmap - Privacy-Compliant Tracking -->
|
|
721
|
+
<script>
|
|
722
|
+
(function() {
|
|
723
|
+
'use strict';
|
|
724
|
+
|
|
725
|
+
// Configuration
|
|
726
|
+
var config = ${JSON.stringify({trackMouse:C.trackMouse,trackClicks:C.trackClicks,trackScroll:C.trackScroll,samplingRate:C.samplingRate,honorDnt:C.honorDnt,endpoint:C.endpoint,batchSize:C.batchSize,maxDataPoints:C.maxDataPoints,sessionTimeout:C.sessionTimeout,persistData:C.persistData,storagePrefix:C.storagePrefix,captureAttributes:C.captureAttributes,ignoreSelectors:C.ignoreSelectors,zones:C.zones,debugOverlay:C.debugOverlay,minViewportWidth:C.minViewportWidth,maxViewportWidth:C.maxViewportWidth})};
|
|
727
|
+
|
|
728
|
+
// Check Do Not Track
|
|
729
|
+
if (config.honorDnt && navigator.doNotTrack === '1') {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// Check viewport constraints
|
|
734
|
+
var vw = window.innerWidth;
|
|
735
|
+
if (config.minViewportWidth && vw < config.minViewportWidth) return;
|
|
736
|
+
if (config.maxViewportWidth && vw > config.maxViewportWidth) return;
|
|
737
|
+
|
|
738
|
+
// Session management (anonymous, no cookies)
|
|
739
|
+
var session = {
|
|
740
|
+
sid: Math.random().toString(36).slice(2) + Date.now().toString(36),
|
|
741
|
+
page: location.pathname,
|
|
742
|
+
vw: window.innerWidth,
|
|
743
|
+
vh: window.innerHeight,
|
|
744
|
+
points: [],
|
|
745
|
+
started: Date.now(),
|
|
746
|
+
lastActivity: Date.now()
|
|
747
|
+
};
|
|
748
|
+
|
|
749
|
+
// Throttle helper
|
|
750
|
+
var lastMove = 0;
|
|
751
|
+
function throttle(fn, wait) {
|
|
752
|
+
return function() {
|
|
753
|
+
var now = Date.now();
|
|
754
|
+
if (now - lastMove >= wait) {
|
|
755
|
+
lastMove = now;
|
|
756
|
+
fn.apply(this, arguments);
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// Get relative coordinates (percentage)
|
|
762
|
+
function getRelativeCoords(e) {
|
|
763
|
+
return {
|
|
764
|
+
x: Math.round((e.clientX / window.innerWidth) * 10000) / 100,
|
|
765
|
+
y: Math.round((e.clientY / window.innerHeight) * 10000) / 100
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// Check if element should be ignored
|
|
770
|
+
function shouldIgnore(el) {
|
|
771
|
+
if (!el || !config.ignoreSelectors) return false;
|
|
772
|
+
for (var i = 0; i < config.ignoreSelectors.length; i++) {
|
|
773
|
+
if (el.matches && el.matches(config.ignoreSelectors[i])) return true;
|
|
774
|
+
if (el.closest && el.closest(config.ignoreSelectors[i])) return true;
|
|
775
|
+
}
|
|
776
|
+
return false;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
// Get element selector (simplified, no IDs to preserve privacy)
|
|
780
|
+
function getSelector(el) {
|
|
781
|
+
if (!el || !el.tagName) return null;
|
|
782
|
+
var tag = el.tagName.toLowerCase();
|
|
783
|
+
var classes = el.className && typeof el.className === 'string'
|
|
784
|
+
? '.' + el.className.trim().split(/\\s+/).slice(0, 2).join('.')
|
|
785
|
+
: '';
|
|
786
|
+
return tag + classes;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// Find zone for element
|
|
790
|
+
function findZone(el) {
|
|
791
|
+
if (!config.zones || !el) return null;
|
|
792
|
+
for (var i = 0; i < config.zones.length; i++) {
|
|
793
|
+
var zone = config.zones[i];
|
|
794
|
+
if (el.closest && el.closest(zone.selector)) {
|
|
795
|
+
return zone.id;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
return null;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// Capture custom attributes
|
|
802
|
+
function captureAttributes(el) {
|
|
803
|
+
if (!config.captureAttributes || !el) return null;
|
|
804
|
+
var attrs = {};
|
|
805
|
+
var hasAttrs = false;
|
|
806
|
+
for (var i = 0; i < config.captureAttributes.length; i++) {
|
|
807
|
+
var attr = config.captureAttributes[i];
|
|
808
|
+
var value = el.getAttribute && el.getAttribute(attr);
|
|
809
|
+
if (value) {
|
|
810
|
+
attrs[attr] = value;
|
|
811
|
+
hasAttrs = true;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
return hasAttrs ? attrs : null;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// Add data point
|
|
818
|
+
function addPoint(point) {
|
|
819
|
+
session.lastActivity = Date.now();
|
|
820
|
+
if (session.points.length >= config.maxDataPoints) {
|
|
821
|
+
session.points.shift();
|
|
822
|
+
}
|
|
823
|
+
session.points.push(point);
|
|
824
|
+
|
|
825
|
+
// Send batch if threshold reached
|
|
826
|
+
if (config.endpoint && session.points.length >= config.batchSize) {
|
|
827
|
+
sendData();
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
// Send data to endpoint
|
|
832
|
+
function sendData() {
|
|
833
|
+
if (!config.endpoint || session.points.length === 0) return;
|
|
834
|
+
|
|
835
|
+
var data = {
|
|
836
|
+
sid: session.sid,
|
|
837
|
+
page: session.page,
|
|
838
|
+
vw: session.vw,
|
|
839
|
+
vh: session.vh,
|
|
840
|
+
points: session.points.splice(0, config.batchSize)
|
|
841
|
+
};
|
|
842
|
+
|
|
843
|
+
// Use sendBeacon for reliability
|
|
844
|
+
if (navigator.sendBeacon) {
|
|
845
|
+
navigator.sendBeacon(config.endpoint, JSON.stringify(data));
|
|
846
|
+
}
|
|
847
|
+
else {
|
|
848
|
+
var xhr = new XMLHttpRequest();
|
|
849
|
+
xhr.open('POST', config.endpoint, true);
|
|
850
|
+
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
851
|
+
xhr.send(JSON.stringify(data));
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// Mouse move handler
|
|
856
|
+
if (config.trackMouse) {
|
|
857
|
+
document.addEventListener('mousemove', throttle(function(e) {
|
|
858
|
+
if (shouldIgnore(e.target)) return;
|
|
859
|
+
var coords = getRelativeCoords(e);
|
|
860
|
+
addPoint({
|
|
861
|
+
x: coords.x,
|
|
862
|
+
y: coords.y,
|
|
863
|
+
type: 'move',
|
|
864
|
+
t: Date.now(),
|
|
865
|
+
zone: findZone(e.target)
|
|
866
|
+
});
|
|
867
|
+
}, config.samplingRate), { passive: true });
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
// Click handler
|
|
871
|
+
if (config.trackClicks) {
|
|
872
|
+
document.addEventListener('click', function(e) {
|
|
873
|
+
if (shouldIgnore(e.target)) return;
|
|
874
|
+
var coords = getRelativeCoords(e);
|
|
875
|
+
var point = {
|
|
876
|
+
x: coords.x,
|
|
877
|
+
y: coords.y,
|
|
878
|
+
type: 'click',
|
|
879
|
+
t: Date.now(),
|
|
880
|
+
el: getSelector(e.target),
|
|
881
|
+
zone: findZone(e.target)
|
|
882
|
+
};
|
|
883
|
+
var attrs = captureAttributes(e.target);
|
|
884
|
+
if (attrs) point.attrs = attrs;
|
|
885
|
+
addPoint(point);
|
|
886
|
+
}, { passive: true });
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// Scroll handler
|
|
890
|
+
if (config.trackScroll) {
|
|
891
|
+
var lastScrollDepth = 0;
|
|
892
|
+
document.addEventListener('scroll', throttle(function() {
|
|
893
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
894
|
+
var scrollHeight = document.documentElement.scrollHeight - window.innerHeight;
|
|
895
|
+
var depth = scrollHeight > 0 ? Math.round((scrollTop / scrollHeight) * 100) : 0;
|
|
896
|
+
|
|
897
|
+
// Only track significant scroll changes (every 10%)
|
|
898
|
+
if (Math.abs(depth - lastScrollDepth) >= 10) {
|
|
899
|
+
lastScrollDepth = depth;
|
|
900
|
+
addPoint({
|
|
901
|
+
x: 50,
|
|
902
|
+
y: depth,
|
|
903
|
+
type: 'scroll',
|
|
904
|
+
t: Date.now(),
|
|
905
|
+
depth: depth
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
}, config.samplingRate * 2), { passive: true });
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
// Send remaining data on page unload
|
|
912
|
+
window.addEventListener('beforeunload', sendData);
|
|
913
|
+
window.addEventListener('visibilitychange', function() {
|
|
914
|
+
if (document.visibilityState === 'hidden') {
|
|
915
|
+
sendData();
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
|
|
919
|
+
// Persist data to localStorage if enabled
|
|
920
|
+
if (config.persistData) {
|
|
921
|
+
var storageKey = config.storagePrefix + '_' + session.page.replace(/\\//g, '_');
|
|
922
|
+
|
|
923
|
+
// Load existing data
|
|
924
|
+
try {
|
|
925
|
+
var stored = localStorage.getItem(storageKey);
|
|
926
|
+
if (stored) {
|
|
927
|
+
var parsed = JSON.parse(stored);
|
|
928
|
+
if (Date.now() - parsed.lastActivity < config.sessionTimeout * 60000) {
|
|
929
|
+
session.points = parsed.points || [];
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
catch (e) {}
|
|
934
|
+
|
|
935
|
+
// Save periodically
|
|
936
|
+
setInterval(function() {
|
|
937
|
+
try {
|
|
938
|
+
localStorage.setItem(storageKey, JSON.stringify({
|
|
939
|
+
points: session.points,
|
|
940
|
+
lastActivity: session.lastActivity
|
|
941
|
+
}));
|
|
942
|
+
}
|
|
943
|
+
catch (e) {}
|
|
944
|
+
}, 5000);
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// Debug overlay
|
|
948
|
+
if (config.debugOverlay) {
|
|
949
|
+
var overlay = document.createElement('div');
|
|
950
|
+
overlay.id = 'stx-heatmap-overlay';
|
|
951
|
+
overlay.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:999999;';
|
|
952
|
+
document.body.appendChild(overlay);
|
|
953
|
+
|
|
954
|
+
var canvas = document.createElement('canvas');
|
|
955
|
+
canvas.width = window.innerWidth;
|
|
956
|
+
canvas.height = window.innerHeight;
|
|
957
|
+
canvas.style.cssText = 'width:100%;height:100%;';
|
|
958
|
+
overlay.appendChild(canvas);
|
|
959
|
+
var ctx = canvas.getContext('2d');
|
|
960
|
+
|
|
961
|
+
function renderOverlay() {
|
|
962
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
963
|
+
session.points.forEach(function(p) {
|
|
964
|
+
var x = (p.x / 100) * canvas.width;
|
|
965
|
+
var y = (p.y / 100) * canvas.height;
|
|
966
|
+
ctx.beginPath();
|
|
967
|
+
ctx.arc(x, y, p.type === 'click' ? 8 : 3, 0, Math.PI * 2);
|
|
968
|
+
ctx.fillStyle = p.type === 'click' ? 'rgba(255,0,0,0.5)' : 'rgba(0,0,255,0.2)';
|
|
969
|
+
ctx.fill();
|
|
970
|
+
});
|
|
971
|
+
requestAnimationFrame(renderOverlay);
|
|
972
|
+
}
|
|
973
|
+
renderOverlay();
|
|
974
|
+
|
|
975
|
+
window.addEventListener('resize', function() {
|
|
976
|
+
canvas.width = window.innerWidth;
|
|
977
|
+
canvas.height = window.innerHeight;
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
// Expose API for manual tracking and data export
|
|
982
|
+
window.stxHeatmap = {
|
|
983
|
+
// Get current session data
|
|
984
|
+
getData: function() {
|
|
985
|
+
return {
|
|
986
|
+
sid: session.sid,
|
|
987
|
+
page: session.page,
|
|
988
|
+
vw: session.vw,
|
|
989
|
+
vh: session.vh,
|
|
990
|
+
points: session.points.slice(),
|
|
991
|
+
started: session.started,
|
|
992
|
+
lastActivity: session.lastActivity
|
|
993
|
+
};
|
|
994
|
+
},
|
|
995
|
+
// Export data as JSON
|
|
996
|
+
exportJSON: function() {
|
|
997
|
+
return JSON.stringify(this.getData(), null, 2);
|
|
998
|
+
},
|
|
999
|
+
// Export data as CSV
|
|
1000
|
+
exportCSV: function() {
|
|
1001
|
+
var data = this.getData();
|
|
1002
|
+
var lines = ['x,y,type,timestamp,element,zone,depth'];
|
|
1003
|
+
data.points.forEach(function(p) {
|
|
1004
|
+
lines.push([p.x, p.y, p.type, p.t, p.el || '', p.zone || '', p.depth || ''].join(','));
|
|
1005
|
+
});
|
|
1006
|
+
return lines.join('\\n');
|
|
1007
|
+
},
|
|
1008
|
+
// Manual data send
|
|
1009
|
+
flush: function() {
|
|
1010
|
+
sendData();
|
|
1011
|
+
},
|
|
1012
|
+
// Clear data
|
|
1013
|
+
clear: function() {
|
|
1014
|
+
session.points = [];
|
|
1015
|
+
if (config.persistData) {
|
|
1016
|
+
var storageKey = config.storagePrefix + '_' + session.page.replace(/\\//g, '_');
|
|
1017
|
+
try { localStorage.removeItem(storageKey); }
|
|
1018
|
+
catch (e) {}
|
|
1019
|
+
}
|
|
1020
|
+
},
|
|
1021
|
+
// Add custom event
|
|
1022
|
+
track: function(type, data) {
|
|
1023
|
+
addPoint({
|
|
1024
|
+
x: data && data.x || 0,
|
|
1025
|
+
y: data && data.y || 0,
|
|
1026
|
+
type: type,
|
|
1027
|
+
t: Date.now(),
|
|
1028
|
+
attrs: data
|
|
1029
|
+
});
|
|
1030
|
+
},
|
|
1031
|
+
// Generate heatmap visualization
|
|
1032
|
+
visualize: function(options) {
|
|
1033
|
+
options = options || {};
|
|
1034
|
+
var data = this.getData();
|
|
1035
|
+
var width = options.width || data.vw;
|
|
1036
|
+
var height = options.height || data.vh;
|
|
1037
|
+
var radius = options.radius || 20;
|
|
1038
|
+
var blur = options.blur || 15;
|
|
1039
|
+
var maxOpacity = options.maxOpacity || 0.6;
|
|
1040
|
+
|
|
1041
|
+
var canvas = document.createElement('canvas');
|
|
1042
|
+
canvas.width = width;
|
|
1043
|
+
canvas.height = height;
|
|
1044
|
+
var ctx = canvas.getContext('2d');
|
|
1045
|
+
|
|
1046
|
+
// Create heat points
|
|
1047
|
+
data.points.forEach(function(p) {
|
|
1048
|
+
var x = (p.x / 100) * width;
|
|
1049
|
+
var y = (p.y / 100) * height;
|
|
1050
|
+
var intensity = p.type === 'click' ? 1 : 0.3;
|
|
1051
|
+
|
|
1052
|
+
var gradient = ctx.createRadialGradient(x, y, 0, x, y, radius);
|
|
1053
|
+
gradient.addColorStop(0, 'rgba(255,0,0,' + intensity + ')');
|
|
1054
|
+
gradient.addColorStop(1, 'rgba(255,0,0,0)');
|
|
1055
|
+
ctx.fillStyle = gradient;
|
|
1056
|
+
ctx.fillRect(x - radius, y - radius, radius * 2, radius * 2);
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
// Apply blur
|
|
1060
|
+
ctx.filter = 'blur(' + blur + 'px)';
|
|
1061
|
+
ctx.drawImage(canvas, 0, 0);
|
|
1062
|
+
ctx.filter = 'none';
|
|
1063
|
+
|
|
1064
|
+
// Colorize
|
|
1065
|
+
var imageData = ctx.getImageData(0, 0, width, height);
|
|
1066
|
+
var pixels = imageData.data;
|
|
1067
|
+
for (var i = 0; i < pixels.length; i += 4) {
|
|
1068
|
+
var alpha = pixels[i + 3];
|
|
1069
|
+
if (alpha > 0) {
|
|
1070
|
+
var ratio = alpha / 255;
|
|
1071
|
+
// Gradient: blue -> cyan -> green -> yellow -> red
|
|
1072
|
+
if (ratio < 0.25) {
|
|
1073
|
+
pixels[i] = 0;
|
|
1074
|
+
pixels[i + 1] = Math.round(ratio * 4 * 255);
|
|
1075
|
+
pixels[i + 2] = 255;
|
|
1076
|
+
}
|
|
1077
|
+
else if (ratio < 0.5) {
|
|
1078
|
+
pixels[i] = 0;
|
|
1079
|
+
pixels[i + 1] = 255;
|
|
1080
|
+
pixels[i + 2] = Math.round((1 - (ratio - 0.25) * 4) * 255);
|
|
1081
|
+
}
|
|
1082
|
+
else if (ratio < 0.75) {
|
|
1083
|
+
pixels[i] = Math.round((ratio - 0.5) * 4 * 255);
|
|
1084
|
+
pixels[i + 1] = 255;
|
|
1085
|
+
pixels[i + 2] = 0;
|
|
1086
|
+
}
|
|
1087
|
+
else {
|
|
1088
|
+
pixels[i] = 255;
|
|
1089
|
+
pixels[i + 1] = Math.round((1 - (ratio - 0.75) * 4) * 255);
|
|
1090
|
+
pixels[i + 2] = 0;
|
|
1091
|
+
}
|
|
1092
|
+
pixels[i + 3] = Math.round(alpha * maxOpacity);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
ctx.putImageData(imageData, 0, 0);
|
|
1096
|
+
|
|
1097
|
+
return canvas;
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
})();
|
|
1101
|
+
</script>
|
|
1102
|
+
`}function Qf(v,k){let C=Yf(k);if(!C)return v;let R=v.lastIndexOf("</body>");if(R!==-1)return v.slice(0,R)+C+v.slice(R);return v+C}var ep={name:"heatmap",hasEndTag:!1,description:"Inject privacy-compliant heatmap tracking script",handler:async(v,k,C,R)=>{let T=C.__stx_config||{};if(k.length>0){let z=lx(k.join(" "));T.heatmap={...T.heatmap,...z,enabled:!0}}return Yf(T)}};function lx(v){let k={},C=v.match(/(\w+)=["']?([^"'\s]+)["']?/g)||[];for(let R of C){let[T,z]=R.split("="),F=z?.replace(/["']/g,"");switch(T){case"endpoint":k.endpoint=F;break;case"samplingRate":k.samplingRate=Number.parseInt(F,10);break;case"batchSize":k.batchSize=Number.parseInt(F,10);break;case"trackMouse":k.trackMouse=F==="true";break;case"trackClicks":k.trackClicks=F==="true";break;case"trackScroll":k.trackScroll=F==="true";break;case"honorDnt":k.honorDnt=F==="true";break;case"debugOverlay":k.debugOverlay=F==="true";break}}return k}var rr={duration:300,delay:0,ease:"ease",direction:"both"};function ux(v,k={}){let{duration:C,delay:R,ease:T,direction:z,custom:F}={...rr,...k};if(v==="custom"&&F)return F;switch(v){case"fade":return`${z==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":z==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
1103
|
+
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
|
1104
|
+
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }`;case"slide":return`${z==="in"?"transform: translateY(20px); opacity: 0; animation: slideIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":z==="out"?"transform: translateY(0); opacity: 1; animation: slideOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: translateY(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
1105
|
+
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
|
|
1106
|
+
@keyframes slideOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(20px); opacity: 0; } }`;case"scale":return`${z==="in"?"transform: scale(0.95); opacity: 0; animation: scaleIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":z==="out"?"transform: scale(1); opacity: 1; animation: scaleOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: scale(1); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
1107
|
+
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
|
|
1108
|
+
@keyframes scaleOut { from { transform: scale(1); opacity: 1; } to { transform: scale(0.95); opacity: 0; } }`;case"flip":return`${z==="in"?"transform: perspective(400px) rotateX(-90deg); opacity: 0; animation: flipIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":z==="out"?"transform: perspective(400px) rotateX(0); opacity: 1; animation: flipOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: perspective(400px) rotateX(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
1109
|
+
@keyframes flipIn { from { transform: perspective(400px) rotateX(-90deg); opacity: 0; } to { transform: perspective(400px) rotateX(0); opacity: 1; } }
|
|
1110
|
+
@keyframes flipOut { from { transform: perspective(400px) rotateX(0); opacity: 1; } to { transform: perspective(400px) rotateX(90deg); opacity: 0; } }`;case"rotate":return`${z==="in"?"transform: rotate(-90deg); opacity: 0; animation: rotateIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":z==="out"?"transform: rotate(0); opacity: 1; animation: rotateOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: rotate(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
1111
|
+
@keyframes rotateIn { from { transform: rotate(-90deg); opacity: 0; } to { transform: rotate(0); opacity: 1; } }
|
|
1112
|
+
@keyframes rotateOut { from { transform: rotate(0); opacity: 1; } to { transform: rotate(90deg); opacity: 0; } }`;default:return""}}function dx(){return`
|
|
1113
|
+
<script data-stx-scoped data-stx-run="once">
|
|
1114
|
+
// Motion preferences handling
|
|
1115
|
+
(function() {
|
|
1116
|
+
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
1117
|
+
|
|
1118
|
+
if (prefersReducedMotion) {
|
|
1119
|
+
// Apply reduced motion settings
|
|
1120
|
+
document.documentElement.style.setProperty('--stx-transition-duration', '0ms');
|
|
1121
|
+
document.documentElement.setAttribute('data-reduced-motion', 'true');
|
|
1122
|
+
}
|
|
1123
|
+
else {
|
|
1124
|
+
document.documentElement.setAttribute('data-reduced-motion', 'false');
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// Listen for changes in preference
|
|
1128
|
+
window.matchMedia('(prefers-reduced-motion: reduce)').addEventListener('change', (e) => {
|
|
1129
|
+
if (e.matches) {
|
|
1130
|
+
document.documentElement.style.setProperty('--stx-transition-duration', '0ms');
|
|
1131
|
+
document.documentElement.setAttribute('data-reduced-motion', 'true');
|
|
1132
|
+
}
|
|
1133
|
+
else {
|
|
1134
|
+
document.documentElement.style.setProperty('--stx-transition-duration', '');
|
|
1135
|
+
document.documentElement.setAttribute('data-reduced-motion', 'false');
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
})();
|
|
1139
|
+
</script>
|
|
1140
|
+
`}function fx(v){return[/@animate\b/,/@transition\b/,/@scroll(?:Animate)?\b/,/@staggered\b/,/@sequence\b/,/@motion\b/,/@animationGroup\b/,/\bstx-transition\b/,/\bstx-(?:fade|scale|flip|rotate|slide|from-|observe)\b/,/data-animate=['"](?:auto|true|false)['"]/].some((C)=>C.test(v))}function px(v=0.1,k="0px"){return`
|
|
1141
|
+
<script data-stx-scoped data-stx-run="always">
|
|
1142
|
+
// Intersection Observer for scroll animations
|
|
1143
|
+
(function() {
|
|
1144
|
+
const initObserver = () => {
|
|
1145
|
+
if (!('IntersectionObserver' in window)) {
|
|
1146
|
+
// For browsers that don't support IntersectionObserver, show all elements immediately
|
|
1147
|
+
const elements = document.querySelectorAll('.stx-observe');
|
|
1148
|
+
elements.forEach(el => el.classList.remove('stx-out'));
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// Create the observer
|
|
1153
|
+
const options = {
|
|
1154
|
+
root: null, // Use viewport
|
|
1155
|
+
rootMargin: '${k}',
|
|
1156
|
+
threshold: ${v}
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
const observer = new IntersectionObserver((entries) => {
|
|
1160
|
+
entries.forEach(entry => {
|
|
1161
|
+
if (entry.isIntersecting) {
|
|
1162
|
+
entry.target.classList.remove('stx-out');
|
|
1163
|
+
// Stop observing after animation is triggered
|
|
1164
|
+
observer.unobserve(entry.target);
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
}, options);
|
|
1168
|
+
|
|
1169
|
+
// Start observing elements
|
|
1170
|
+
const elements = document.querySelectorAll('.stx-observe');
|
|
1171
|
+
elements.forEach(el => observer.observe(el));
|
|
1172
|
+
};
|
|
1173
|
+
|
|
1174
|
+
// Initialize observer when DOM is ready
|
|
1175
|
+
if (document.readyState === 'loading') {
|
|
1176
|
+
document.addEventListener('DOMContentLoaded', initObserver);
|
|
1177
|
+
}
|
|
1178
|
+
else {
|
|
1179
|
+
initObserver();
|
|
1180
|
+
}
|
|
1181
|
+
})();
|
|
1182
|
+
</script>
|
|
1183
|
+
`}function gx(){return`
|
|
1184
|
+
<style id="stx-animation-base">
|
|
1185
|
+
:root {
|
|
1186
|
+
--stx-transition-duration: 300ms;
|
|
1187
|
+
--stx-transition-delay: 0ms;
|
|
1188
|
+
--stx-transition-ease: ease;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1192
|
+
:root {
|
|
1193
|
+
--stx-transition-duration: 0ms;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
[data-animate="false"] * {
|
|
1198
|
+
--stx-transition-duration: 0ms !important;
|
|
1199
|
+
animation-duration: 0ms !important;
|
|
1200
|
+
transition-duration: 0ms !important;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/* Base transition classes */
|
|
1204
|
+
.stx-transition {
|
|
1205
|
+
transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
1206
|
+
transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1207
|
+
backface-visibility: hidden; /* Improve animation performance */
|
|
1208
|
+
transform-style: preserve-3d; /* Better 3D transforms */
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
/* Fade animations */
|
|
1212
|
+
.stx-fade {
|
|
1213
|
+
transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
.stx-fade.stx-out {
|
|
1217
|
+
opacity: 0 !important;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
/* Scale animations */
|
|
1221
|
+
.stx-scale {
|
|
1222
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
1223
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
.stx-scale.stx-out {
|
|
1227
|
+
transform: scale(0.85) !important;
|
|
1228
|
+
opacity: 0 !important;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
/* Flip animations */
|
|
1232
|
+
.stx-flip {
|
|
1233
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
1234
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1235
|
+
perspective: 600px;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
.stx-flip.stx-out {
|
|
1239
|
+
transform: perspective(600px) rotateX(-90deg) !important;
|
|
1240
|
+
opacity: 0 !important;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/* Rotate animations */
|
|
1244
|
+
.stx-rotate {
|
|
1245
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
1246
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
.stx-rotate.stx-out {
|
|
1250
|
+
transform: rotate(-90deg) !important;
|
|
1251
|
+
opacity: 0 !important;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
/* Direction-based animations */
|
|
1255
|
+
.stx-from-left, .stx-from-right, .stx-from-top, .stx-from-bottom {
|
|
1256
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
1257
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
.stx-from-left.stx-out {
|
|
1261
|
+
transform: translateX(-30px) !important;
|
|
1262
|
+
opacity: 0 !important;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
.stx-from-right.stx-out {
|
|
1266
|
+
transform: translateX(30px) !important;
|
|
1267
|
+
opacity: 0 !important;
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
.stx-from-top.stx-out {
|
|
1271
|
+
transform: translateY(-30px) !important;
|
|
1272
|
+
opacity: 0 !important;
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
.stx-from-bottom.stx-out {
|
|
1276
|
+
transform: translateY(30px) !important;
|
|
1277
|
+
opacity: 0 !important;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
/* Generic slide animations */
|
|
1281
|
+
.stx-slide {
|
|
1282
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
1283
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
.stx-slide.stx-out {
|
|
1287
|
+
transform: translateY(30px) !important;
|
|
1288
|
+
opacity: 0 !important;
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
/* Scroll animation observer class */
|
|
1292
|
+
.stx-observe {
|
|
1293
|
+
will-change: opacity, transform;
|
|
1294
|
+
transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
1295
|
+
transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1296
|
+
}
|
|
1297
|
+
</style>
|
|
1298
|
+
`}function mx(v,k,C={}){let{staggerDelay:R=50,sequence:T=!1}=C;return`
|
|
1299
|
+
<script data-stx-scoped data-stx-run="always">
|
|
1300
|
+
// Animation Group: ${v}
|
|
1301
|
+
(function() {
|
|
1302
|
+
const elements = ${JSON.stringify(k)};
|
|
1303
|
+
const staggerDelay = ${R};
|
|
1304
|
+
const sequence = ${T};
|
|
1305
|
+
|
|
1306
|
+
function animateGroup() {
|
|
1307
|
+
elements.forEach((selector, index) => {
|
|
1308
|
+
const element = document.querySelector(selector);
|
|
1309
|
+
if (!element) return;
|
|
1310
|
+
|
|
1311
|
+
const delay = sequence ? index * staggerDelay : 0;
|
|
1312
|
+
element.style.setProperty('--stx-transition-delay', delay + 'ms');
|
|
1313
|
+
|
|
1314
|
+
// For elements using animation keyframes
|
|
1315
|
+
element.style.animationDelay = delay + 'ms';
|
|
1316
|
+
|
|
1317
|
+
// If the element is initially hidden, show it
|
|
1318
|
+
if (element.classList.contains('stx-out')) {
|
|
1319
|
+
setTimeout(() => {
|
|
1320
|
+
element.classList.remove('stx-out');
|
|
1321
|
+
}, 10); // Small delay to ensure styles are applied
|
|
1322
|
+
}
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
// Run when DOM is fully loaded
|
|
1327
|
+
if (document.readyState === 'loading') {
|
|
1328
|
+
document.addEventListener('DOMContentLoaded', animateGroup);
|
|
1329
|
+
}
|
|
1330
|
+
else {
|
|
1331
|
+
animateGroup();
|
|
1332
|
+
}
|
|
1333
|
+
})();
|
|
1334
|
+
</script>
|
|
1335
|
+
`}var tp={name:"transition",handler:(v,k,C,R)=>{if(k.length<1)return`<div class="stx-error">@transition directive requires at least a transition type</div>${v}`;let T=k[0],z=k.length>1?Number.parseInt(k[1],10)||rr.duration:rr.duration,F=k.length>2?k[2]||rr.ease:rr.ease,V=k.length>3?Number.parseInt(k[3],10)||rr.delay:rr.delay,H=k.length>4?k[4]||rr.direction:rr.direction,K=`stx-transition-${Math.random().toString(36).substr(2,9)}`,X=ux(T,{duration:z,delay:V,ease:F,direction:H}),G="stx-transition",te="";if(T==="fade")te="stx-fade";else if(T==="slide")te="stx-slide";else if(T==="scale")te="stx-scale";else if(T==="flip")te="stx-flip";else if(T==="rotate")te="stx-rotate";return`<div id="${K}" class="${G} ${te} ${H==="out"?"stx-out":""}"
|
|
1336
|
+
style="--stx-transition-duration: ${z}ms; --stx-transition-ease: ${F}; --stx-transition-delay: ${V}ms;">${v}</div>`},hasEndTag:!0,description:"Applies transition effects to an element"},np={name:"scrollAnimate",handler:(v,k,C,R)=>{if(k.length<1)return`<div class="stx-error">@scrollAnimate directive requires at least an animation type</div>${v}`;let T=k[0],z=k.length>1?Number.parseInt(k[1],10)||300:300,F=k.length>2?k[2]||"ease":"ease",V=k.length>3?Number.parseFloat(k[3])||0.2:0.2,H=k.length>4?Number.parseInt(k[4],10)||0:0,K=`stx-scroll-${Math.random().toString(36).substr(2,9)}`,X=`--stx-transition-duration: ${z}ms; --stx-transition-ease: ${F}; --stx-transition-delay: ${H}ms; will-change: opacity, transform;`,G="stx-transition stx-observe stx-out";if(T==="fade")G+=" stx-fade";else if(T==="slide-up"||T==="slide")G+=" stx-from-bottom";else if(T==="slide-down")G+=" stx-from-top";else if(T==="slide-left")G+=" stx-from-right";else if(T==="slide-right")G+=" stx-from-left";else if(T==="scale")G+=" stx-scale";else if(T.includes("-"))G+=` stx-${T}`;else G+=` stx-${T}`;return`<div id="${K}" class="${G}" style="${X}" data-threshold="${V}">${v}</div>`},hasEndTag:!0,description:"Applies animations that trigger when scrolled into view"},rp={name:"animationGroup",handler:(v,k,C,R)=>{if(k.length<2)return`<div class="stx-error">@animationGroup directive requires a group name and at least one element selector</div>${v}`;let T=k[0],z=k.slice(1).map((K)=>K.startsWith("#")||K.startsWith(".")?K:`#${K}`),F=C.staggerDelay||50,V=C.sequence||!0,H=mx(T,z,{staggerDelay:F,sequence:V});return`${v}
|
|
1337
|
+
${H}`},hasEndTag:!1,description:"Coordinates multiple animations together as a group"},sp={name:"motion",handler:(v,k,C,R)=>{let T=k.length>0?k[0].toLowerCase()==="true":!0,z=dx();return`<div data-animate="${T?"auto":"true"}">${v}</div>${z}`},hasEndTag:!0,description:"Controls motion and animation preferences"};function ip(v,k,C,R){let T=v;if(R.animation?.enabled===!1)return T;let z=C.includes("test")&&C.includes("animation");if(!fx(T)&&!z)return T;if(!T.includes('<style id="stx-animation-base">')){let V=gx();T=T.replace("</head>",`${V}
|
|
1338
|
+
</head>`)}if(T.includes("stx-observe")){if(!T.includes("Intersection Observer for scroll animations")){let H=px(),K=T.lastIndexOf("</body>");if(K!==-1)T=T.slice(0,K)+H+`
|
|
1339
|
+
`+T.slice(K)}}return T}function Je(v){let k=v.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!k)return null;try{return Function(`return ${k[1]}`)()}catch{return null}}function op(v){let k=v?.layout;if(k===!1)return!1;return typeof k==="string"&&k.trim()?k.trim():void 0}var hx=100,yx=599,wl="__stxResponseStatus",uo="__stxResponseHeaders";function wa(v){return typeof v==="number"&&Number.isInteger(v)&&v>=hx&&v<=yx}function Bt(v){for(let k of v.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let C=k[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!C)continue;let R=Number(C[1]);if(wa(R))return R}return}function vl(v,k){if(!v||typeof v!=="object")return!1;let C=typeof k==="string"&&/^\d+$/.test(k.trim())?Number(k.trim()):k;if(!wa(C))return!1;return v[wl]=C,!0}function xx(v,k,C){if(!v||typeof v!=="object")return;let R=String(k??"").trim();if(!R)return;v[uo]={...v[uo],[R]:String(C)}}function Ye(v){let k=v?.[wl];return wa(k)?k:void 0}function Ze(v){let k=v?.[uo];if(!k||typeof k!=="object")return;let C=Object.entries(k).map(([R,T])=>[R,String(T)]);return C.length>0?Object.fromEntries(C):void 0}function bi(v,k){if(!v||!k||v===k||typeof k!=="object")return;let C=Ye(v);if(C!==void 0)k[wl]=C;let R=Ze(v);if(R)k[uo]={...k[uo],...R}}function lr(v){return{setResponseStatus:(k)=>{vl(v,k)},notFound:(k=404)=>{let C=wa(k)&&k>=400?k:404;vl(v,C)},setResponseHeader:(k,C)=>{xx(v,k,C)}}}function ap(v,k,C={}){if(!v.includes("@status"))return v;let{filePath:R,buildMode:T}=C,z=T==="compile",F="",V=0,H=/@status\s*\(/g,K;while((K=H.exec(v))!==null){let X=bx(v,K.index+K[0].length-1);if(X<0)break;let G=v.slice(K.index+K[0].length,X).trim(),te=/^\d+$/.test(G)?Number(G):l(G,k),ce=R?` in ${R}`:"";if(z)console.warn(`[stx] @status(${G})${ce} is skipped when precompiling: the build has no request, so the branch it sits in is not the one a visitor will get. Call notFound() or setResponseStatus(${G}) from <script server> instead \u2014 that runs per request.`);else if(!vl(k,te))console.warn(`[stx] @status(${G})${ce} is not an HTTP status (100-599) \u2014 ignoring it.`);F+=v.slice(V,K.index),V=X+1+(v.slice(X+1).match(/^[^\S\n]*\n?/)?.[0].length??0),H.lastIndex=V}return V===0?v:F+v.slice(V)}function bx(v,k){let C=1,R=null,T=!1;for(let z=k+1;z<v.length;z++){let F=v[z];if(T){T=!1;continue}if(R){if(F==="\\")T=!0;else if(F===R)R=null;continue}if(F==='"'||F==="'"||F==="`"){R=F;continue}if(F==="(")C++;else if(F===")"&&--C===0)return z}return-1}var vx=0,wx=0;function cp(v,k){let C=v.match(new RegExp(`${k}\\s*=\\s*"([^"]*)"`,"i"));if(C)return C[1];let R=v.match(new RegExp(`${k}\\s*=\\s*'([^']*)'`,"i"));if(R)return R[1];return null}function Sx(v){let k=[],C=/<([a-z][a-z0-9-]*)\s+([^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,R;while((R=C.exec(v))!==null){let[T,z,F]=R,V=R.index,H=cp(F,"x-data");if(!H)continue;let K=`__stx_scope_${vx++}`,X=cp(F,"x-init"),G=$x(v,z,V+T.length),te=v.slice(V,G.endIndex),ce=_x(te);k.push({id:K,selector:`[data-stx-scope="${K}"]`,stateExpr:H,initExpr:X,bindings:[],refs:ce})}return k}function $x(v,k,C){let R=1,T=C,z=new RegExp(`<${k}(?:\\s|>)`,"gi"),F=new RegExp(`</${k}>`,"gi"),V=new RegExp(`<${k}[^>]*/\\s*>`,"gi");while(R>0&&T<v.length){z.lastIndex=T,F.lastIndex=T,V.lastIndex=T;let H=z.exec(v),K=F.exec(v),X=V.exec(v);if(X&&X.index<(H?.index??1/0)){T=X.index+X[0].length;continue}if(!K)return{endIndex:v.length};if(H&&H.index<K.index)R++,T=H.index+H[0].length;else{if(R--,R===0)return{endIndex:K.index+K[0].length};T=K.index+K[0].length}}return{endIndex:v.length}}function _x(v){let k=new Map,C=v.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),R=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,T;while((T=R.exec(C))!==null){let[,z,F]=T,V=kx(z);k.set(F,V)}return k}function kx(v){let k=v.match(/\bid\s*=\s*["']([^"']*)["']/);if(k)return k[1];return`__stx_el_${wx++}`}function Ex(){return`
|
|
1340
|
+
// STX Reactive Runtime - x-cloak and transition CSS
|
|
1341
|
+
(function() {
|
|
1342
|
+
var style = document.createElement('style');
|
|
1343
|
+
style.textContent = [
|
|
1344
|
+
'[x-cloak] { display: none !important; }',
|
|
1345
|
+
// Default transition classes
|
|
1346
|
+
'.stx-enter { opacity: 0; transform: scale(0.95); }',
|
|
1347
|
+
'.stx-enter-start { opacity: 0; transform: scale(0.95); }',
|
|
1348
|
+
'.stx-enter-active { transition: opacity 150ms ease-out, transform 150ms ease-out; }',
|
|
1349
|
+
'.stx-enter-to { opacity: 1; transform: scale(1); }',
|
|
1350
|
+
'.stx-leave { opacity: 1; transform: scale(1); }',
|
|
1351
|
+
'.stx-leave-start { opacity: 1; transform: scale(1); }',
|
|
1352
|
+
'.stx-leave-active { transition: opacity 100ms ease-in, transform 100ms ease-in; }',
|
|
1353
|
+
'.stx-leave-to { opacity: 0; transform: scale(0.95); }'
|
|
1354
|
+
].join('\\n');
|
|
1355
|
+
document.head.appendChild(style);
|
|
1356
|
+
})();
|
|
1357
|
+
|
|
1358
|
+
// STX Reactive Runtime
|
|
1359
|
+
/* eslint-disable pickier/no-unused-vars, no-console, prefer-const */
|
|
1360
|
+
window.__stx_reactive = (function() {
|
|
1361
|
+
'use strict';
|
|
1362
|
+
|
|
1363
|
+
// Deep reactive proxy that triggers onChange for any mutation
|
|
1364
|
+
function reactive(obj, onChange) {
|
|
1365
|
+
if (!obj || typeof obj !== 'object') return obj;
|
|
1366
|
+
return new Proxy(obj, {
|
|
1367
|
+
get(target, prop) {
|
|
1368
|
+
const value = target[prop];
|
|
1369
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Promise)) {
|
|
1370
|
+
return reactive(value, onChange);
|
|
1371
|
+
}
|
|
1372
|
+
return value;
|
|
1373
|
+
},
|
|
1374
|
+
set(target, prop, value) {
|
|
1375
|
+
target[prop] = value;
|
|
1376
|
+
onChange(prop, value);
|
|
1377
|
+
return true;
|
|
1378
|
+
}
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
// Initialize an x-data scope: parse state, run init(), register into window.stx._scopes,
|
|
1383
|
+
// then let the signals runtime handle all directive processing (x-for, x-text, :bind, etc.)
|
|
1384
|
+
function initScope(scopeEl, initialState, bindings, refs, initExpr) {
|
|
1385
|
+
// Parse initial state (may contain methods including async init())
|
|
1386
|
+
var state;
|
|
1387
|
+
try {
|
|
1388
|
+
state = new Function('return (' + initialState + ')')();
|
|
1389
|
+
} catch (e) {
|
|
1390
|
+
console.error('[stx-reactive] Invalid x-data:', initialState, e);
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
// Build $refs object
|
|
1395
|
+
var $refs = {};
|
|
1396
|
+
for (var name in refs) {
|
|
1397
|
+
if (Object.prototype.hasOwnProperty.call(refs, name)) {
|
|
1398
|
+
(function(refName, refId) {
|
|
1399
|
+
Object.defineProperty($refs, refName, {
|
|
1400
|
+
get: function() { return document.getElementById(refId); }
|
|
1401
|
+
});
|
|
1402
|
+
})(name, refs[name]);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
// Extract init method from state if present (Alpine.js convention)
|
|
1407
|
+
var initMethod = state.init;
|
|
1408
|
+
if (typeof initMethod === 'function') {
|
|
1409
|
+
delete state.init;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
// Make state reactive \u2014 mutations trigger re-render via signals
|
|
1413
|
+
var scopeId = scopeEl.getAttribute('data-stx-scope');
|
|
1414
|
+
var stx = window.stx;
|
|
1415
|
+
|
|
1416
|
+
// Create signals for each state property so the signals runtime can track dependencies
|
|
1417
|
+
var signalState = {};
|
|
1418
|
+
var rawState = {};
|
|
1419
|
+
var derivedState = {};
|
|
1420
|
+
var accessors = {};
|
|
1421
|
+
// A getter must NOT be read here. Reading one calls it, and the old loop did
|
|
1422
|
+
// exactly that: the returned value is not a function, so it was wrapped as a
|
|
1423
|
+
// plain state() -- a snapshot of the answer at construction time, frozen
|
|
1424
|
+
// forever while plain properties beside it updated (#2053). A getter is a
|
|
1425
|
+
// derived value, so it is registered as one below, once ctxProxy exists for
|
|
1426
|
+
// it to read through.
|
|
1427
|
+
var ownDescriptors = Object.getOwnPropertyDescriptors ? Object.getOwnPropertyDescriptors(state) : {};
|
|
1428
|
+
for (var key in state) {
|
|
1429
|
+
if (Object.prototype.hasOwnProperty.call(state, key)) {
|
|
1430
|
+
var descriptor = ownDescriptors[key];
|
|
1431
|
+
if (descriptor && typeof descriptor.get === 'function') {
|
|
1432
|
+
accessors[key] = descriptor;
|
|
1433
|
+
continue;
|
|
1434
|
+
}
|
|
1435
|
+
if (typeof state[key] === 'function') {
|
|
1436
|
+
// Methods \u2014 bind to a proxy so 'this.prop = val' triggers signal updates
|
|
1437
|
+
signalState[key] = state[key];
|
|
1438
|
+
} else {
|
|
1439
|
+
// Data properties \u2014 wrap in signals for reactivity
|
|
1440
|
+
signalState[key] = stx.state(state[key]);
|
|
1441
|
+
rawState[key] = true;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
// Create a proxy context that auto-unwraps signals and writes back through them.
|
|
1447
|
+
// Methods get 'this' bound to this proxy so this.foo = bar triggers reactivity.
|
|
1448
|
+
var ctx = {};
|
|
1449
|
+
var ctxProxy = new Proxy(ctx, {
|
|
1450
|
+
get: function(target, prop) {
|
|
1451
|
+
if (prop === '$refs') return $refs;
|
|
1452
|
+
if (prop === '$el') return scopeEl;
|
|
1453
|
+
if (prop === '$nextTick') return function(fn) { requestAnimationFrame(fn); };
|
|
1454
|
+
var s = signalState[prop];
|
|
1455
|
+
if (!s) return undefined;
|
|
1456
|
+
if (rawState[prop] && s && typeof s === 'function' && typeof s.value !== 'undefined') {
|
|
1457
|
+
return s.value; // unwrap signal
|
|
1458
|
+
}
|
|
1459
|
+
if (typeof s === 'function' && !rawState[prop]) {
|
|
1460
|
+
return s.bind(ctxProxy); // bind methods to proxy
|
|
1461
|
+
}
|
|
1462
|
+
return s;
|
|
1463
|
+
},
|
|
1464
|
+
set: function(target, prop, value) {
|
|
1465
|
+
var accessor = derivedState[prop];
|
|
1466
|
+
if (accessor) {
|
|
1467
|
+
// A getter/setter pair writes through its setter. A getter alone has
|
|
1468
|
+
// nowhere to put the value: a derived has no .value setter, so the
|
|
1469
|
+
// assignment would be a silent no-op, which is the same class of
|
|
1470
|
+
// failure as the stale read this replaces.
|
|
1471
|
+
if (typeof accessor.set === 'function') {
|
|
1472
|
+
accessor.set.call(ctxProxy, value);
|
|
1473
|
+
return true;
|
|
1474
|
+
}
|
|
1475
|
+
console.warn('[stx-reactive] cannot assign to ' + String(prop) + ': it is a getter in x-data, so its value comes from what it reads. Give it a setter, or make it a plain property.');
|
|
1476
|
+
return true;
|
|
1477
|
+
}
|
|
1478
|
+
var s = signalState[prop];
|
|
1479
|
+
if (rawState[prop] && s && typeof s === 'function') {
|
|
1480
|
+
s.value = value; // write through signal \u2014 triggers effects
|
|
1481
|
+
} else {
|
|
1482
|
+
signalState[prop] = value;
|
|
1483
|
+
}
|
|
1484
|
+
return true;
|
|
1485
|
+
},
|
|
1486
|
+
has: function(target, prop) {
|
|
1487
|
+
return prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick';
|
|
1488
|
+
},
|
|
1489
|
+
ownKeys: function() {
|
|
1490
|
+
return Object.keys(signalState).concat(['$refs', '$el', '$nextTick']);
|
|
1491
|
+
},
|
|
1492
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
1493
|
+
if (prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick') {
|
|
1494
|
+
return { configurable: true, enumerable: true, writable: true, value: ctxProxy[prop] };
|
|
1495
|
+
}
|
|
1496
|
+
return undefined;
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1499
|
+
|
|
1500
|
+
// Now that ctxProxy exists, a getter becomes a derived that reads through it,
|
|
1501
|
+
// so it tracks whatever it touches and recomputes when that changes. derived()
|
|
1502
|
+
// is lazy, so nothing is evaluated until a binding actually reads it.
|
|
1503
|
+
//
|
|
1504
|
+
// Marked rawState as well: that is what makes the proxy unwrap it and what
|
|
1505
|
+
// exposes the signal itself to the runtime below, which is where dependency
|
|
1506
|
+
// tracking comes from. A getter needs both, exactly like a data property.
|
|
1507
|
+
for (var accessorKey in accessors) {
|
|
1508
|
+
if (Object.prototype.hasOwnProperty.call(accessors, accessorKey)) {
|
|
1509
|
+
(function(name, descriptor) {
|
|
1510
|
+
signalState[name] = stx.derived(function() {
|
|
1511
|
+
return descriptor.get.call(ctxProxy);
|
|
1512
|
+
});
|
|
1513
|
+
rawState[name] = true;
|
|
1514
|
+
derivedState[name] = descriptor;
|
|
1515
|
+
})(accessorKey, accessors[accessorKey]);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
// Build scope vars for the signals runtime \u2014 it reads these for expression evaluation.
|
|
1520
|
+
// We need to provide getter/setter descriptors so signals track properly.
|
|
1521
|
+
var scopeVars = {};
|
|
1522
|
+
for (var k in signalState) {
|
|
1523
|
+
if (Object.prototype.hasOwnProperty.call(signalState, k)) {
|
|
1524
|
+
if (rawState[k]) {
|
|
1525
|
+
// Data: expose the signal directly so expressions trigger dependency tracking
|
|
1526
|
+
scopeVars[k] = signalState[k];
|
|
1527
|
+
} else {
|
|
1528
|
+
// Method: bind to ctxProxy so 'this' works
|
|
1529
|
+
scopeVars[k] = (typeof signalState[k] === 'function') ? signalState[k].bind(ctxProxy) : signalState[k];
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
scopeVars.$refs = $refs;
|
|
1534
|
+
scopeVars.$el = scopeEl;
|
|
1535
|
+
scopeVars.$nextTick = function(fn) { requestAnimationFrame(fn); };
|
|
1536
|
+
|
|
1537
|
+
// Register scope \u2014 merge with any existing vars from partial signal scripts
|
|
1538
|
+
if (!stx._scopes) stx._scopes = {};
|
|
1539
|
+
stx._scopes[scopeId] = Object.assign(stx._scopes[scopeId] || {}, scopeVars);
|
|
1540
|
+
|
|
1541
|
+
// Store on element for findElementScope
|
|
1542
|
+
scopeEl.__stx_scope = scopeVars;
|
|
1543
|
+
|
|
1544
|
+
// Run init() if present (supports async)
|
|
1545
|
+
function runInit() {
|
|
1546
|
+
var maybePromise;
|
|
1547
|
+
if (initMethod) {
|
|
1548
|
+
maybePromise = initMethod.call(ctxProxy);
|
|
1549
|
+
}
|
|
1550
|
+
if (initExpr) {
|
|
1551
|
+
try {
|
|
1552
|
+
var keys = Object.keys(scopeVars);
|
|
1553
|
+
var vals = keys.map(function(k) { return scopeVars[k]; });
|
|
1554
|
+
var fn = new Function(keys.join(','), initExpr);
|
|
1555
|
+
var result = fn.apply(ctxProxy, vals);
|
|
1556
|
+
if (result && typeof result.then === 'function') maybePromise = result;
|
|
1557
|
+
} catch (e) {
|
|
1558
|
+
console.warn('[stx-reactive] init expression error:', e);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
// If init is async, signal updates will trigger effects automatically
|
|
1562
|
+
// when init() resolves and sets this.prop = value (writes through signal)
|
|
1563
|
+
if (maybePromise && typeof maybePromise.then === 'function') {
|
|
1564
|
+
maybePromise.catch(function(e) {
|
|
1565
|
+
console.error('[stx-reactive] async init() error:', e);
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
// Run init before the signals runtime processes this scope
|
|
1571
|
+
runInit();
|
|
1572
|
+
|
|
1573
|
+
// Expose for debugging
|
|
1574
|
+
scopeEl.__stx_state = ctxProxy;
|
|
1575
|
+
scopeEl.__stx_execute = function(stmt, $event, $el) {
|
|
1576
|
+
try {
|
|
1577
|
+
// Run the statement with the reactive proxy as the lexical scope.
|
|
1578
|
+
// Wrapping in a with-block on the proxy makes bare reads/writes go
|
|
1579
|
+
// through it (so foo = bar triggers signal.set()) instead of treating
|
|
1580
|
+
// each state key as a local function parameter \u2014 bare assignments
|
|
1581
|
+
// would otherwise just rebind the local and never reach the signal.
|
|
1582
|
+
var fn = new Function('$event', '$el', 'with(this){' + stmt + ';}');
|
|
1583
|
+
fn.call(ctxProxy, $event, $el);
|
|
1584
|
+
} catch (e) {
|
|
1585
|
+
console.warn('[stx-reactive] execute error:', e);
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
return { initScope: initScope, reactive: reactive };
|
|
1591
|
+
})();
|
|
1592
|
+
`}function lp(v,k){let C=v.replace(/\{!!([\s\S]*?)!!\}/g,(V,H)=>{try{let K=x(H,k,!0);if(K===void 0)return V;return String(K)}catch{return V}}),R="",T=0,z=null;while(T<C.length){let V=C[T];if(z&&V==="\\"){R+=V+(C[T+1]??""),T+=2;continue}if(V==="{"&&C[T+1]==="{"){let H=C.indexOf("}}",T+2);if(H!==-1){let K=C.slice(T,H+2);R+=F(C.slice(T+2,H),K,z),T=H+2;continue}}if(z){if(V===z)z=null}else if(V==="'"||V==='"'||V==="`")z=V;R+=V,T++}return R;function F(V,H,K){let X;try{X=x(V,k,!0)}catch{return H}if(X===void 0)return H;if(K){let G=String(X).replace(/\\/g,"\\\\").replace(new RegExp(K==="`"?"`":K,"g"),`\\${K}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return K==="`"?G.replace(/\$\{/g,"\\${"):G}if(typeof X==="string"){let G=X.trim();if(G.startsWith("{")&&G.endsWith("}")||G.startsWith("[")&&G.endsWith("]"))try{return JSON.parse(G),G}catch{}}return JSON.stringify(X)}}function Cx(v,k){if(v.length===0)return"";let C=v.map((R)=>{let T=JSON.stringify(Object.fromEntries(R.refs)),z=lp(R.stateExpr,k),F=R.initExpr?lp(R.initExpr,k):null,V=JSON.stringify(z),H=F?JSON.stringify(F):"null";return`
|
|
1593
|
+
(function() {
|
|
1594
|
+
var scopeEl = document.querySelector('${R.selector}');
|
|
1595
|
+
if (!scopeEl) return;
|
|
1596
|
+
var refs = ${T};
|
|
1597
|
+
__stx_reactive.initScope(scopeEl, ${V}, [], refs, ${H});
|
|
1598
|
+
})();`}).join(`
|
|
1599
|
+
`);return`
|
|
1600
|
+
<script data-stx-scoped data-stx-reactive data-stx-run="always">
|
|
1601
|
+
${Ex()}
|
|
1602
|
+
${C}
|
|
1603
|
+
</script>`}function up(v,k,C){if(!Ax(v))return v;let R=Sx(v);if(R.length===0)return v;let T=Rx(v,R),z=Cx(R,k),F=T.lastIndexOf("</body>");if(F!==-1)T=T.slice(0,F)+z+`
|
|
1604
|
+
`+T.slice(F);else T+=z;return T}function Rx(v,k){let C=0,R=v.replace(/<([a-z][a-z0-9-]*)(\s+[^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,(T,z,F)=>{let V=k[C++];if(!V)return T;let H=/data-stx-scope="([^"]*)"/.exec(F);if(H)return V.id=H[1],V.selector=`[data-stx-scope="${V.id}"]`,T;return`<${z} data-stx-scope="${V.id}"${F}>`});return R=R.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),R=R.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),R=R.replace(/\s*x-init\s*=\s*"([^"]*)"/g,' data-stx-xinit="$1"'),R=R.replace(/\s*x-init\s*=\s*'([^']*)'/g," data-stx-xinit='$1'"),R}function Ax(v){return/x-data\s*=\s*["']/.test(v)}import pb from"fs";import Ol from"path";import{createHighlighter as gb}from"ts-syntax-highlighter";import hs from"fs";import ln from"path";import{loadConfigWithResult as ab}from"bunfig";async function Tx(v,k,C,R){let T=k[0]?.replace(/['"]/g,"")||"main",z=Ne();if(T!=="main")z=z.replace("container:'main'",`container:'${T}'`);return`<script data-stx-router>${z}</script>`}var dp={name:"stxRouter",handler:Tx,hasEndTag:!1,description:"Inject the STX SPA router script for client-side navigation"};function Dr(v){return v.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function fp(v){let k=v.trim().toLowerCase();return!k.startsWith("javascript:")&&!k.startsWith("vbscript:")&&!k.startsWith("data:text/html")}function sr(v){let k=/^---\r?\n([\s\S]*?)\r?\n---\r?\n/,C=v.match(k);if(!C)return{data:{},content:v.trim()};let R=C[1],T=v.slice(C[0].length),z={};for(let F of R.split(`
|
|
1605
|
+
`)){let V=F.trim();if(!V||V.startsWith("#"))continue;let H=V.indexOf(":");if(H===-1)continue;let K=V.slice(0,H).trim(),X=V.slice(H+1).trim();if(typeof X==="string"){if(X.startsWith('"')&&X.endsWith('"')||X.startsWith("'")&&X.endsWith("'"))X=X.slice(1,-1);else if(X.startsWith("[")&&X.endsWith("]"))try{X=JSON.parse(X)}catch{}else if(X==="true")X=!0;else if(X==="false")X=!1;else if(/^-?\d+(?:\.\d+)?$/.test(X))X=Number(X)}z[K]=X}return{data:z,content:T.trim()}}function qe(v,k={}){let{gfm:C=!0,breaks:R=!1}=k,T=v,z=[];if(T=T.replace(/```(\w*)\n([\s\S]*?)```/g,(X,G,te)=>{let ce=z.length,ee=G?` class="language-${Dr(G)}"`:"";return z.push(`<pre><code${ee}>${Dr(te.trim())}</code></pre>`),`\x00CODEBLOCK${ce}\x00`}),T=T.replace(/`([^`]*)`/g,(X,G)=>`<code>${Dr(G)}</code>`),T=T.replace(/^######\s+(.*)$/gm,"<h6>$1</h6>"),T=T.replace(/^#####\s+(.*)$/gm,"<h5>$1</h5>"),T=T.replace(/^####\s+(.*)$/gm,"<h4>$1</h4>"),T=T.replace(/^###\s+(.*)$/gm,"<h3>$1</h3>"),T=T.replace(/^##\s+(.*)$/gm,"<h2>$1</h2>"),T=T.replace(/^#\s+(.*)$/gm,"<h1>$1</h1>"),T=T.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),T=T.replace(/___(.+?)___/g,"<strong><em>$1</em></strong>"),T=T.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),T=T.replace(/__(.+?)__/g,"<strong>$1</strong>"),T=T.replace(/\*(.+?)\*/g,"<em>$1</em>"),T=T.replace(/(?<![a-zA-Z0-9])_(.+?)_(?![a-zA-Z0-9])/g,"<em>$1</em>"),C)T=T.replace(/~~(.+?)~~/g,"<del>$1</del>");if(T=T.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(X,G,te)=>`<img src="${fp(te)?Dr(te):""}" alt="${Dr(G)}" />`),T=T.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(X,G,te)=>`<a href="${fp(te)?Dr(te):""}">${G}</a>`),T=T.replace(/^(?:---|\*\*\*|___)\s*$/gm,"<hr />"),T=T.replace(/^>\s+(.*)$/gm,"<blockquote>$1</blockquote>"),T=T.replace(/<\/blockquote>\n<blockquote>/g,`
|
|
1606
|
+
`),T=T.replace(/^[*\-+]\s+(.*)$/gm,"<li data-ul>$1</li>"),T=T.replace(/(<li data-ul>.*<\/li>\n?)+/g,"<ul>$&</ul>"),T=T.replace(/<\/ul>\n<ul>/g,""),T=T.replace(/^\d+\.\s+(.*)$/gm,"<li data-ol>$1</li>"),T=T.replace(/(<li data-ol>.*<\/li>\n?)+/g,"<ol>$&</ol>"),T=T.replace(/<\/ol>\n<ol>/g,""),T=T.replace(/<li data-ul>/g,"<li>"),T=T.replace(/<li data-ol>/g,"<li>"),C)T=T.replace(/^\|(.+)\|\s*\n\|[-:\s|]+\|\s*\n((?:\|.+\|\s*\n)*)/gm,(X,G,te)=>{let ee=`<tr>${G.split("|").map((ue)=>ue.trim()).filter(Boolean).map((ue)=>`<th>${Dr(ue)}</th>`).join("")}</tr>`,le=te.trim().split(`
|
|
1607
|
+
`).map((ue)=>`<tr>${ue.split("|").map((fe)=>fe.trim()).filter(Boolean).map((fe)=>`<td>${Dr(fe)}</td>`).join("")}</tr>`).join(`
|
|
1608
|
+
`);return`<table>
|
|
1609
|
+
<thead>
|
|
1610
|
+
${ee}
|
|
1611
|
+
</thead>
|
|
1612
|
+
<tbody>
|
|
1613
|
+
${le}
|
|
1614
|
+
</tbody>
|
|
1615
|
+
</table>`});if(C)T=T.replace(/<li>\s*\[\s*\]\s*/g,'<li><input type="checkbox" disabled /> '),T=T.replace(/<li>\s*\[x\]\s*/gi,'<li><input type="checkbox" checked disabled /> ');let F=T.split(`
|
|
1616
|
+
`),V=[],H=!1,K=[];for(let X of F){let G=X.trim();if(/^<(?:h[1-6]|ul|ol|li|blockquote|pre|table|thead|tbody|tr|th|td|hr|div|p)/.test(G)||/^\0CODEBLOCK\d+\0$/.test(G)||G===""){if(H&&K.length>0)V.push(`<p>${K.join(R?`<br />
|
|
1617
|
+
`:`
|
|
1618
|
+
`)}</p>`),K=[],H=!1;V.push(X)}else H=!0,K.push(G)}if(H&&K.length>0)V.push(`<p>${K.join(R?`<br />
|
|
1619
|
+
`:`
|
|
1620
|
+
`)}</p>`);if(T=V.join(`
|
|
1621
|
+
`),R)T=T.replace(/\n/g,`<br />
|
|
1622
|
+
`);for(let X=0;X<z.length;X++)T=T.replace(`\x00CODEBLOCK${X}\x00`,z[X]);return T=T.replace(/<p>\s*<\/p>/g,""),T.trim()}async function pp(v,k,C=""){let R=v,T=[],z=/@markdown(?:\([^)]*\))?/g,F;while((F=z.exec(v))!==null){let V=F.index,H=F[0].match(/@markdown\(([^)]*)\)/),K=H?H[1]:"",X=V+F[0].length,G=1,te=X,ce=-1;while(G>0&&te<v.length){let ue=v.indexOf("@markdown",te),de=v.indexOf("@endmarkdown",te);if(de===-1)break;if(ue!==-1&&ue<de&&ue!==V){let fe=v[ue+9];if(fe==="("||fe===`
|
|
1623
|
+
`||fe==="\r"||fe===" "||fe===void 0)G++;te=ue+9}else{if(G--,G===0){ce=de;break}te=de+12}}if(ce===-1)continue;let ee=v.slice(X,ce),le=v.slice(V,ce+12);T.push({fullMatch:le,options:K,content:ee,index:V}),z.lastIndex=ce+12}for(let{fullMatch:V,options:H,content:K,index:X}of T)try{let G={};if(H)H.split(",").forEach((ee)=>{let le=ee.trim();if(le)G[le]=!0});let te={gfm:G.gfm??!0,breaks:G.breaks??!1},ce=qe(K.trim(),te);R=R.split(V).join(ce)}catch(G){let te=G instanceof Error?G.message:String(G),ce=g("Markdown Directive",`Error processing markdown: ${te}`,C,v,X,V);R=R.split(V).join(ce)}return R}async function gp(v,k,C,R){let T={gfm:!0,breaks:!1};return k.forEach((z)=>{let F=z.trim().replace(/['"]/g,"");if(F==="breaks")T.breaks=!0;if(F==="no-gfm")T.gfm=!1}),qe(v.trim(),T)}var ms=[320,480,640,768,1024,1280,1536,1920,2560],Ix=[1,1.5,2,3],fo=["avif","webp","jpeg"],Px={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"};function Sl(v,k=ms,C={},R){return k.sort((T,z)=>T-z).map((T)=>`${po(v,{...C,w:T,fm:R})} ${T}w`).join(", ")}function mp(v,k,C=Ix,R={},T){return C.sort((z,F)=>z-F).map((z)=>{let F=Math.round(k*z);return`${po(v,{...R,w:F,dpr:z,fm:T})} ${z}x`}).join(", ")}function $l(v,k="100vw"){if(!v||Object.keys(v).length===0)return k;let R=Object.entries(v).map(([T,z])=>{let F=/^\d+$/.test(T)?`${T}px`:T;return{bp:F,size:z,numericBp:Number.parseInt(F)||0}}).sort((T,z)=>T.numericBp-z.numericBp).map(({bp:T,size:z})=>`(max-width: ${T}) ${z}`);return R.push(k),R.join(", ")}function po(v,k={}){let C=Object.entries(k).filter(([,z])=>z!==void 0&&z!==null).map(([z,F])=>{if(Array.isArray(F))return[z,F.join(",")];return[z,String(F)]});if(C.length===0)return v;let R=C.map(([z,F])=>`${z}=${encodeURIComponent(F)}`).join("&"),T=v.includes("?")?"&":"?";return`${v}${T}${R}`}function _l(v){return Px[v]||"application/octet-stream"}var Dx={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},El=`
|
|
1624
|
+
.stx-img-placeholder {
|
|
1625
|
+
position: relative;
|
|
1626
|
+
overflow: hidden;
|
|
1627
|
+
background-size: cover;
|
|
1628
|
+
background-position: center;
|
|
1629
|
+
background-repeat: no-repeat;
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1632
|
+
.stx-img-placeholder img {
|
|
1633
|
+
opacity: 0;
|
|
1634
|
+
transition: opacity var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out);
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
.stx-img-placeholder.stx-img-loaded img {
|
|
1638
|
+
opacity: 1;
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
.stx-img-blur {
|
|
1642
|
+
filter: blur(20px);
|
|
1643
|
+
transform: scale(1.1);
|
|
1644
|
+
transition: filter var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out),
|
|
1645
|
+
transform var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out);
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
.stx-img-loaded .stx-img-blur {
|
|
1649
|
+
filter: blur(0);
|
|
1650
|
+
transform: scale(1);
|
|
1651
|
+
}
|
|
1652
|
+
`.trim();async function Ox(){try{return await import("ts-images")}catch{return null}}async function Mx(v,k={}){let C={...Dx,...k},R=await Ox();if(R)try{return await Nx(v,C,R)}catch(T){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${T}`)}return jx(v,C)}async function Nx(v,k,C){let{generatePlaceholder:R,generateThumbHash:T}=C,F={blur:"blur",thumbhash:"thumbhash",blurhash:"thumbhash",pixelate:"pixelate","dominant-color":"dominant-color",none:"blur"}[k.strategy]||"blur";if(k.strategy==="thumbhash")return{dataURL:(await T(v)).dataUrl,width:32,height:32,aspectRatio:1,originalWidth:0,originalHeight:0,strategy:"thumbhash"};let V=await R(v,{width:k.width,height:k.height,quality:k.quality,blurLevel:k.blurLevel,strategy:F,base64Encode:!0});return{dataURL:V.dataURL,width:V.width,height:V.height,aspectRatio:V.aspectRatio,originalWidth:V.originalWidth,originalHeight:V.originalHeight,strategy:k.strategy,dominantColor:V.dominantColor,css:V.css}}function jx(v,k){let C=k.width||20,R=k.height||C,T="#e5e7eb",z=`<svg xmlns="http://www.w3.org/2000/svg" width="${C}" height="${R}" viewBox="0 0 ${C} ${R}"><rect fill="#e5e7eb" width="${C}" height="${R}"/></svg>`;return{dataURL:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(z)}`,width:C,height:R,aspectRatio:C/R,originalWidth:0,originalHeight:0,strategy:k.strategy,dominantColor:"#e5e7eb"}}function hp(v,k,C={}){let R=C.transitionDuration||300,T=C.easing||"ease-out";return`
|
|
1653
|
+
#${v} {
|
|
1654
|
+
--stx-img-transition-duration: ${R}ms;
|
|
1655
|
+
--stx-img-transition-easing: ${T};
|
|
1656
|
+
background-image: url('${k.dataURL}');
|
|
1657
|
+
background-size: cover;
|
|
1658
|
+
background-position: center;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
#${v} img {
|
|
1662
|
+
opacity: 0;
|
|
1663
|
+
transition: opacity var(--stx-img-transition-duration) var(--stx-img-transition-easing);
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
#${v}.stx-img-loaded img {
|
|
1667
|
+
opacity: 1;
|
|
1668
|
+
}
|
|
1669
|
+
`.trim()}var kl=new Map;async function yp(v,k={}){let C=`${v}:${JSON.stringify(k)}`;if(kl.has(C))return kl.get(C);let R=await Mx(v,k);return kl.set(C,R),R}async function Lx(){try{return await import("./chunk-ty1c2276.js")}catch(v){if(!xp)console.warn("[stx-media] Image processor not available, some features disabled:",v),xp=!0;return null}}var xp=!1,Cl=80,$a="async",_a="lazy",bp=!1;async function Sa(v,k={}){let C=k,R=v;if(R.process&&!R.skipOptimization){if(C.tsImagesConfig?.enabled&&!C.isDev)return Fx(R,C)}if(C.processedResult?.processed)return Tl(v,C.processedResult,k);if(C.responsiveVariants)return Sp(v,C.responsiveVariants,k);let{src:T,alt:z,width:F,height:V,sizes:H,widths:K=ms,dpr:X,formats:G=fo,quality:te=Cl,params:ce={},placeholder:ee="none",placeholderOptions:le={},lazy:ue=!0,priority:de=!1,loading:fe=de?"eager":_a,decoding:pe=$a,fetchpriority:Ae,objectFit:Se,objectPosition:ve,crossorigin:De,referrerpolicy:Me}=v,{class:je,style:Le,id:Be}=v,Oe=v.data||{},{isDev:We=!1,baseUrl:Fe=""}=k;if(We&&!k.optimize)return Wx(v);let Ve,ze,He=Be||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(ee!=="none"&&!de)try{Ve=await yp(T,{strategy:ee,...le}),ze=hp(He,Ve,le)}catch{}let wt=X!==void 0&&F!==void 0,vt;if(wt)vt=zx(v,He,Ve,k);else vt=await Bx(v,He,Ve,k);let Ct;if(de){let Rt=G.includes("webp")?"webp":G[0],xt=Sl(T,K,{...ce,q:te},Rt),ft=typeof H==="object"?$l(H):H||"100vw";Ct=`<link rel="preload" as="image" imagesrcset="${xt}" imagesizes="${ft}" />`}let pt=[];if(!bp&&ee!=="none")pt.push(El),bp=!0;if(ze)pt.push(ze);let St=ue?wp(He):void 0;return{html:vt,preloadLink:Ct,css:pt.length>0?pt.join(`
|
|
1670
|
+
`):void 0,script:St}}async function Bx(v,k,C,R){let{src:T,alt:z,width:F,height:V,sizes:H,widths:K=ms,formats:X=fo,quality:G=Cl,params:te={},lazy:ce=!0,priority:ee=!1,loading:le=ee?"eager":_a,decoding:ue=$a,fetchpriority:de,objectFit:fe,objectPosition:pe,crossorigin:Ae,referrerpolicy:Se}=v,{class:ve,style:De}=v,Me=v.data||{},je=typeof H==="object"?$l(H):H||"100vw",Le=[];for(let We of X){let Fe=Sl(T,K,{...te,q:G},We),Ve=_l(We);if(ce&&!ee)Le.push(` <source type="${Ve}" data-srcset="${Fe}" data-sizes="${je}" />`);else Le.push(` <source type="${Ve}" srcset="${Fe}" sizes="${je}" />`)}let Be=Rl({src:po(T,{...te,q:G}),alt:z,width:F,height:V,loading:ee?void 0:le,decoding:ue,fetchpriority:ee?"high":de,objectFit:fe,objectPosition:pe,crossorigin:Ae,referrerpolicy:Se,className:vp(ve,C),style:Al(De,fe,pe,C),lazy:ce&&!ee,data:Me}),Oe;if(C){let We=`background-image: url('${C.dataURL}'); background-size: cover; background-position: center;`;Oe=`<div id="${k}" class="stx-img-placeholder" style="${We}">
|
|
1671
|
+
<picture>
|
|
1672
|
+
${Le.join(`
|
|
1673
|
+
`)}
|
|
1674
|
+
<img ${Be} />
|
|
1675
|
+
</picture>
|
|
1676
|
+
</div>`}else Oe=`<picture${k?` id="${k}"`:""}>
|
|
1677
|
+
${Le.join(`
|
|
1678
|
+
`)}
|
|
1679
|
+
<img ${Be} />
|
|
1680
|
+
</picture>`;return Oe}function zx(v,k,C,R){let{src:T,alt:z,width:F,height:V,dpr:H=[1,2,3],quality:K=Cl,params:X={},lazy:G=!0,priority:te=!1,loading:ce=te?"eager":_a,decoding:ee=$a,fetchpriority:le,objectFit:ue,objectPosition:de,crossorigin:fe,referrerpolicy:pe}=v,{class:Ae,style:Se}=v,ve=v.data||{},De=typeof F==="number"?F:Number.parseInt(String(F),10),Me=mp(T,De,H,{...X,q:K}),je=Rl({src:po(T,{...X,w:De,q:K}),alt:z,width:F,height:V,loading:te?void 0:ce,decoding:ee,fetchpriority:te?"high":le,objectFit:ue,objectPosition:de,crossorigin:fe,referrerpolicy:pe,className:vp(Ae,C),style:Al(Se,ue,de,C),lazy:G&&!te,data:ve}),Le=G&&!te?`data-srcset="${Me}"`:`srcset="${Me}"`;if(C){let Be=`background-image: url('${C.dataURL}'); background-size: cover; background-position: center;`;return`<div id="${k}" class="stx-img-placeholder" style="${Be}">
|
|
1681
|
+
<img ${je} ${Le} />
|
|
1682
|
+
</div>`}return`<img ${k?`id="${k}" `:""}${je} ${Le} />`}function Wx(v){let{src:k,alt:C,width:R,height:T,loading:z=_a,decoding:F=$a,fetchpriority:V,objectFit:H,objectPosition:K,crossorigin:X,referrerpolicy:G,priority:te=!1}=v,{class:ce,style:ee,id:le}=v,ue=v.data||{};return{html:`<img ${Rl({src:k,alt:C,width:R,height:T,loading:te?"eager":z,decoding:F,fetchpriority:te?"high":V,objectFit:H,objectPosition:K,crossorigin:X,referrerpolicy:G,className:ce,style:Al(ee,H,K),id:le,data:ue})} />`}}function Rl(v){let k=[];if(v.lazy)k.push(`data-src="${Wn(v.src)}"`),k.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else k.push(`src="${Wn(v.src)}"`);if(k.push(`alt="${Wn(v.alt)}"`),v.width)k.push(`width="${v.width}"`);if(v.height)k.push(`height="${v.height}"`);if(v.loading)k.push(`loading="${v.loading}"`);if(v.decoding)k.push(`decoding="${v.decoding}"`);if(v.fetchpriority)k.push(`fetchpriority="${v.fetchpriority}"`);if(v.crossorigin)k.push(`crossorigin="${v.crossorigin}"`);if(v.referrerpolicy)k.push(`referrerpolicy="${v.referrerpolicy}"`);if(v.className)k.push(`class="${Wn(v.className)}"`);if(v.style)k.push(`style="${Wn(v.style)}"`);if(v.id)k.push(`id="${Wn(v.id)}"`);if(v.data)for(let[C,R]of Object.entries(v.data))k.push(`data-${C}="${Wn(R)}"`);if(v.lazy)k.push("data-stx-lazy");return k.join(" ")}function vp(v,k){let C=[];if(v)C.push(v);if(k)C.push("stx-img-blur");return C.join(" ")||""}function Al(v,k,C,R){let T=[];if(k)T.push(`object-fit: ${k}`);if(C)T.push(`object-position: ${C}`);if(R)T.push("opacity: 0; transition: opacity 300ms ease-out");if(v)T.push(v);return T.join("; ")}function Wn(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function wp(v){return`
|
|
1683
|
+
(function() {
|
|
1684
|
+
const container = document.getElementById('${v}');
|
|
1685
|
+
if (!container) return;
|
|
1686
|
+
|
|
1687
|
+
const img = container.querySelector('img[data-stx-lazy]') || container;
|
|
1688
|
+
if (!img.dataset.src && !img.dataset.srcset) return;
|
|
1689
|
+
|
|
1690
|
+
const observer = new IntersectionObserver((entries) => {
|
|
1691
|
+
entries.forEach(entry => {
|
|
1692
|
+
if (entry.isIntersecting) {
|
|
1693
|
+
// Load image
|
|
1694
|
+
if (img.dataset.src) img.src = img.dataset.src;
|
|
1695
|
+
if (img.dataset.srcset) img.srcset = img.dataset.srcset;
|
|
1696
|
+
|
|
1697
|
+
// Load sources
|
|
1698
|
+
const sources = container.querySelectorAll('source[data-srcset]');
|
|
1699
|
+
sources.forEach(source => {
|
|
1700
|
+
if (source.dataset.srcset) source.srcset = source.dataset.srcset;
|
|
1701
|
+
if (source.dataset.sizes) source.sizes = source.dataset.sizes;
|
|
1702
|
+
});
|
|
1703
|
+
|
|
1704
|
+
// Handle load completion
|
|
1705
|
+
img.onload = () => {
|
|
1706
|
+
img.style.opacity = '1';
|
|
1707
|
+
if (container.classList.contains('stx-img-placeholder')) {
|
|
1708
|
+
container.classList.add('stx-img-loaded');
|
|
1709
|
+
}
|
|
1710
|
+
};
|
|
1711
|
+
|
|
1712
|
+
observer.disconnect();
|
|
1713
|
+
}
|
|
1714
|
+
});
|
|
1715
|
+
}, { rootMargin: '50px' });
|
|
1716
|
+
|
|
1717
|
+
observer.observe(container);
|
|
1718
|
+
})();
|
|
1719
|
+
`.trim()}async function Fx(v,k){let C=await Lx();if(!C)return Sa({...v,process:!1},k);let R=k.tsImagesConfig;if(v.responsiveWidths&&v.responsiveWidths.length>0||v.widths&&v.widths.length>0||!v.width&&!v.dpr){let z=await C.generateResponsiveVariants(v.src,v,R);if(z)return Sp(v,z,k)}else{let z=await C.processImage(v.src,v,R);if(z.processed)return Tl(v,z,k)}return Sa({...v,process:!1},k)}async function Tl(v,k,C){let{alt:R,width:T,height:z,lazy:F=!0,priority:V=!1,objectFit:H,objectPosition:K,crossorigin:X,referrerpolicy:G}=v,{class:te,style:ce}=v,ee=v.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,le=v.data||{},ue=k.variants||[],de=ue.find((ze)=>ze.format==="jpeg")||ue.find((ze)=>ze.format==="webp")||ue[0],fe=de?.url||v.src,pe=ue.filter((ze)=>ze.format===(de?.format||"jpeg")).map((ze)=>`${ze.url} ${ze.width}w`).join(", "),Ae=new Map;for(let ze of ue){if(!Ae.has(ze.format))Ae.set(ze.format,[]);Ae.get(ze.format).push(ze)}let Se=[],ve=["avif","webp","jpeg","png"];for(let ze of ve){let He=Ae.get(ze);if(He&&He.length>0){let wt=He.map((Ct)=>`${Ct.url} ${Ct.width}w`).join(", "),vt=_l(ze);if(F&&!V)Se.push(` <source type="${vt}" data-srcset="${wt}" />`);else Se.push(` <source type="${vt}" srcset="${wt}" />`)}}let De=[];if(F&&!V){if(De.push(`data-src="${Wn(fe)}"`),De.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),pe)De.push(`data-srcset="${pe}"`)}else if(De.push(`src="${Wn(fe)}"`),pe)De.push(`srcset="${pe}"`);De.push(`alt="${Wn(R)}"`);let Me=T||k.originalWidth,je=z||k.originalHeight;if(Me)De.push(`width="${Me}"`);if(je)De.push(`height="${je}"`);if(!V)De.push(`loading="${F?"lazy":"eager"}"`);if(De.push('decoding="async"'),V)De.push('fetchpriority="high"');if(X)De.push(`crossorigin="${X}"`);if(G)De.push(`referrerpolicy="${G}"`);let Le=[];if(H)Le.push(`object-fit: ${H}`);if(K)Le.push(`object-position: ${K}`);if(k.placeholder&&F)Le.push("opacity: 0; transition: opacity 300ms ease-out");if(ce)Le.push(ce);if(Le.length>0)De.push(`style="${Le.join("; ")}"`);let Be=[];if(te)Be.push(te);if(k.placeholder)Be.push("stx-img-blur");if(Be.length>0)De.push(`class="${Be.join(" ")}"`);if(F&&!V)De.push("data-stx-lazy");for(let[ze,He]of Object.entries(le))De.push(`data-${ze}="${Wn(He)}"`);let Oe;if(k.placeholder||k.dominantColor&&v.useDominantColor){let ze=k.placeholder?`background-image: url('${k.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${k.dominantColor};`;Oe=`<div id="${ee}" class="stx-img-placeholder" style="${ze}">
|
|
1720
|
+
<picture>
|
|
1721
|
+
${Se.join(`
|
|
1722
|
+
`)}
|
|
1723
|
+
<img ${De.join(" ")} />
|
|
1724
|
+
</picture>
|
|
1725
|
+
</div>`}else Oe=`<picture${ee?` id="${ee}"`:""}>
|
|
1726
|
+
${Se.join(`
|
|
1727
|
+
`)}
|
|
1728
|
+
<img ${De.join(" ")} />
|
|
1729
|
+
</picture>`;let We=[];if(k.placeholder)We.push(El);let Fe=F?wp(ee):void 0,Ve;if(V&&pe)Ve=`<link rel="preload" as="image" imagesrcset="${pe}" />`;return{html:Oe,preloadLink:Ve,css:We.length>0?We.join(`
|
|
1730
|
+
`):void 0,script:Fe}}async function Sp(v,k,C){let R={src:k.src,processed:!0,variants:[],placeholder:k.placeholder?.dataURL,originalWidth:k.placeholder?.width,originalHeight:k.placeholder?.height};for(let[T,z]of Object.entries(k.byFormat))if(z)R.variants.push(...z);return Tl(v,R,C)}function Vx(){return ot({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async(v,k,C,R)=>{let{src:T,alt:z,options:F}=Ux(v,k,C);if(!T)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let V={src:T,alt:z||"",widths:F.widths||ms,formats:F.formats||fo,quality:F.quality,sizes:F.sizes,dpr:F.dpr,params:F.params,placeholder:F.placeholder,placeholderOptions:F.placeholderOptions,lazy:F.lazy!==!1,priority:F.priority||!1,loading:F.loading,decoding:F.decoding,fetchpriority:F.fetchpriority,objectFit:F.objectFit,objectPosition:F.objectPosition,class:F.class,style:F.style,id:F.id,width:F.width,height:F.height},H=C.__isDev||!1,K=await Sa(V,{isDev:H}),X=K.html;if(K.preloadLink)X=K.preloadLink+`
|
|
1731
|
+
`+X;if(K.css)X+=`
|
|
1732
|
+
<style>${K.css}</style>`;if(K.script)X+=`
|
|
1733
|
+
<script>${K.script}</script>`;return X},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function Ux(v,k,C){if(k.src)return{src:String(k.src),alt:String(k.alt||""),options:k.options||{}};let R=v.trim();if(R.startsWith("@img(")||R.startsWith("("))R=R.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let T=Hx(R),z=Il(T[0],C)||"",F=Il(T[1],C)||"",V={};if(T[2]){let H=Il(T[2],C);if(typeof H==="object"&&H!==null)V=H;else if(typeof T[2]==="string")try{V=JSON.parse(T[2])}catch{}}return{src:z,alt:F,options:V}}function Hx(v){let k=[],C="",R=!1,T="",z=0,F=0;for(let V=0;V<v.length;V++){let H=v[V],K=V>0?v[V-1]:"";if((H==='"'||H==="'"||H==="`")&&K!=="\\"){if(!R)R=!0,T=H;else if(H===T)R=!1,T="";else C+=H;continue}if(!R){if(H==="{")z++;if(H==="}")z--;if(H==="[")F++;if(H==="]")F--;if(H===","&&z===0&&F===0){k.push(C.trim()),C="";continue}}C+=H}if(C.trim())k.push(C.trim());return k}function Il(v,k){if(typeof v!=="string")return v;let C=v.trim();if(C.startsWith('"')&&C.endsWith('"')||C.startsWith("'")&&C.endsWith("'"))return C.slice(1,-1);if(!C.startsWith("/")&&!C.startsWith(".")&&!C.startsWith("http")&&!C.startsWith("{")){let R=k[C];if(R!==void 0)return R}if(C.startsWith("{")||C.startsWith("["))try{return JSON.parse(C)}catch{}return C}var $p=Vx();async function kp(){try{return await import("./chunk-txkc9w9q.js")}catch(v){if(!_p)console.warn("[stx-media] Video processor not available, some features disabled:",v),_p=!0;return null}}var _p=!1,Ep=!0,Cp="metadata",qx="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";async function ka(v,k={}){let C=k,R=v;if(R.process&&!R.skipProcessing){if(C.tsVideosConfig?.enabled&&!C.isDev)return Jx(R,C)}if(C.processedResult?.processed)return Ap(v,C.processedResult,k);let T;if(R.generatePoster&&R.src&&!v.poster)T=await Yx(R,C);let{src:z,sources:F=[],poster:V,posterPlaceholder:H,controls:K=Ep,autoplay:X=!1,muted:G=!1,loop:te=!1,preload:ce=Cp,playsinline:ee=!0,lazy:le=!0,player:ue="native",type:de,width:fe,height:pe,crossorigin:Ae,disablePictureInPicture:Se=!1,disableRemotePlayback:ve=!1}=v,De=T||V,{class:Me,style:je}=v,Le=v.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(ue==="ts-video")return Xx(v,k);if(de&&de!=="video")return Kx(z||"",de,v);let Be=F.length>0?F:z?[{src:z,type:Rp(z)}]:[],Oe=[`id="${Le}"`];if(K)Oe.push("controls");if(X)Oe.push("autoplay");if(G)Oe.push("muted");if(te)Oe.push("loop");if(ee)Oe.push("playsinline");if(Se)Oe.push("disablepictureinpicture");if(ve)Oe.push("disableremoteplayback");if(Ae)Oe.push(`crossorigin="${Ae}"`);if(le){if(Oe.push(`data-preload="${ce}"`),Oe.push('preload="none"'),De)Oe.push(`data-poster="${cn(De)}"`);Oe.push("data-stx-lazy")}else if(Oe.push(`preload="${ce}"`),De)Oe.push(`poster="${cn(De)}"`);if(fe)Oe.push(`width="${fe}"`);if(pe)Oe.push(`height="${pe}"`);if(Me)Oe.push(`class="${cn(Me)}"`);if(je)Oe.push(`style="${cn(je)}"`);let We=Be.map((ze)=>` <source ${le?`data-src="${cn(ze.src)}"`:`src="${cn(ze.src)}"`} type="${ze.type}"${ze.media?` media="${ze.media}"`:""} />`).join(`
|
|
1734
|
+
`),Fe=`<video ${Oe.join(" ")}>
|
|
1735
|
+
${We}
|
|
1736
|
+
Your browser does not support the video tag.
|
|
1737
|
+
</video>`,Ve;if(le)Ve=`
|
|
1738
|
+
(function() {
|
|
1739
|
+
var video = document.getElementById('${Le}');
|
|
1740
|
+
if (!video) return;
|
|
1741
|
+
|
|
1742
|
+
var observer = new IntersectionObserver(function(entries) {
|
|
1743
|
+
entries.forEach(function(entry) {
|
|
1744
|
+
if (entry.isIntersecting) {
|
|
1745
|
+
// Load poster
|
|
1746
|
+
if (video.dataset.poster) {
|
|
1747
|
+
video.poster = video.dataset.poster;
|
|
1748
|
+
delete video.dataset.poster;
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
// Load sources
|
|
1752
|
+
var sources = video.querySelectorAll('source[data-src]');
|
|
1753
|
+
sources.forEach(function(source) {
|
|
1754
|
+
source.src = source.dataset.src;
|
|
1755
|
+
delete source.dataset.src;
|
|
1756
|
+
});
|
|
1757
|
+
|
|
1758
|
+
// Set preload
|
|
1759
|
+
if (video.dataset.preload) {
|
|
1760
|
+
video.preload = video.dataset.preload;
|
|
1761
|
+
delete video.dataset.preload;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
video.load();
|
|
1765
|
+
observer.disconnect();
|
|
1766
|
+
}
|
|
1767
|
+
});
|
|
1768
|
+
}, { rootMargin: '50px' });
|
|
1769
|
+
|
|
1770
|
+
observer.observe(video);
|
|
1771
|
+
})();
|
|
1772
|
+
`.trim();return{html:Fe,script:Ve}}function Kx(v,k,C){let{width:R=640,height:T=360}=C,{class:z,style:F}=C,V=C.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,H,K=null;switch(k){case"youtube":K=Zx(v),H=K?`https://www.youtube-nocookie.com/embed/${K}`:v;break;case"vimeo":K=Gx(v),H=K?`https://player.vimeo.com/video/${K}`:v;break;case"dailymotion":K=v.split("/").pop()||"",H=`https://www.dailymotion.com/embed/video/${K}`;break;case"twitch":K=v.split("/").pop()||"",H=`https://player.twitch.tv/?video=${K}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:H=v}let X=[`id="${V}"`,`src="${cn(H)}"`,`width="${R}"`,`height="${T}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(z)X.push(`class="${cn(z)}"`);if(F)X.push(`style="${cn(F)}"`);if(C.lazy)X.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
|
|
1773
|
+
<iframe ${X.join(" ")} style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
|
|
1774
|
+
</div>`}}function Xx(v,k={}){let{src:C,sources:R=[],poster:T,controls:z=!0,autoplay:F=!1,muted:V=!1,loop:H=!1,preload:K="metadata",playsinline:X=!0,lazy:G=!0,width:te,height:ce}=v,{class:ee,style:le}=v,ue=v.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,de={src:R.length>0?R:C,autoplay:F,loop:H,muted:V,playsinline:X,preload:K,poster:T,controls:z,title:v.title},fe=["position: relative",te?`width: ${typeof te==="number"?te+"px":te}`:"width: 100%",ce?`height: ${typeof ce==="number"?ce+"px":ce}`:"",le||""].filter(Boolean).join("; "),pe=`
|
|
1775
|
+
<div
|
|
1776
|
+
id="${ue}"
|
|
1777
|
+
class="ts-video-player${ee?" "+cn(ee):""}"
|
|
1778
|
+
style="${fe}"
|
|
1779
|
+
data-ts-video-player
|
|
1780
|
+
data-config='${JSON.stringify(de)}'
|
|
1781
|
+
${G?"data-lazy":""}
|
|
1782
|
+
>
|
|
1783
|
+
<div class="ts-video-player__container">
|
|
1784
|
+
${T?`
|
|
1785
|
+
<div class="ts-video-player__placeholder" style="background-image: url('${cn(T)}');">
|
|
1786
|
+
<button class="ts-video-player__play-button" aria-label="Play video">
|
|
1787
|
+
<svg viewBox="0 0 24 24" fill="currentColor" width="64" height="64">
|
|
1788
|
+
<path d="M8 5v14l11-7z"/>
|
|
1789
|
+
</svg>
|
|
1790
|
+
</button>
|
|
1791
|
+
</div>
|
|
1792
|
+
`:""}
|
|
1793
|
+
</div>
|
|
1794
|
+
</div>
|
|
1795
|
+
`.trim(),Ae=`
|
|
1796
|
+
(function() {
|
|
1797
|
+
var container = document.getElementById('${ue}');
|
|
1798
|
+
if (!container) return;
|
|
1799
|
+
|
|
1800
|
+
var config = JSON.parse(container.dataset.config || '{}');
|
|
1801
|
+
var isLazy = container.hasAttribute('data-lazy');
|
|
1802
|
+
|
|
1803
|
+
function loadPlayer() {
|
|
1804
|
+
if (typeof TSVideoPlayer !== 'undefined') {
|
|
1805
|
+
initPlayer();
|
|
1806
|
+
return;
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
// Load ts-video-player from CDN
|
|
1810
|
+
var script = document.createElement('script');
|
|
1811
|
+
script.src = '${qx}';
|
|
1812
|
+
script.onload = initPlayer;
|
|
1813
|
+
script.onerror = function() {
|
|
1814
|
+
console.error('[stx] Failed to load ts-video-player');
|
|
1815
|
+
fallbackToNative();
|
|
1816
|
+
};
|
|
1817
|
+
document.head.appendChild(script);
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
function initPlayer() {
|
|
1821
|
+
var player = TSVideoPlayer.createPlayer(container, config);
|
|
1822
|
+
if (config.src) {
|
|
1823
|
+
player.setSrc(config.src);
|
|
1824
|
+
}
|
|
1825
|
+
container.__tsVideoPlayer = player;
|
|
1826
|
+
|
|
1827
|
+
// Remove placeholder
|
|
1828
|
+
var placeholder = container.querySelector('.ts-video-player__placeholder');
|
|
1829
|
+
if (placeholder) {
|
|
1830
|
+
placeholder.style.display = 'none';
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
function fallbackToNative() {
|
|
1835
|
+
// Fallback to native video element
|
|
1836
|
+
var video = document.createElement('video');
|
|
1837
|
+
video.controls = config.controls !== false;
|
|
1838
|
+
video.autoplay = config.autoplay;
|
|
1839
|
+
video.muted = config.muted;
|
|
1840
|
+
video.loop = config.loop;
|
|
1841
|
+
video.playsInline = config.playsinline;
|
|
1842
|
+
video.preload = config.preload || 'metadata';
|
|
1843
|
+
if (config.poster) video.poster = config.poster;
|
|
1844
|
+
if (config.src) video.src = typeof config.src === 'string' ? config.src : config.src[0]?.src || config.src[0];
|
|
1845
|
+
video.style.width = '100%';
|
|
1846
|
+
video.style.height = '100%';
|
|
1847
|
+
|
|
1848
|
+
var containerEl = container.querySelector('.ts-video-player__container');
|
|
1849
|
+
if (containerEl) {
|
|
1850
|
+
containerEl.innerHTML = '';
|
|
1851
|
+
containerEl.appendChild(video);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
if (isLazy) {
|
|
1856
|
+
var observer = new IntersectionObserver(function(entries) {
|
|
1857
|
+
entries.forEach(function(entry) {
|
|
1858
|
+
if (entry.isIntersecting) {
|
|
1859
|
+
loadPlayer();
|
|
1860
|
+
observer.disconnect();
|
|
1861
|
+
}
|
|
1862
|
+
});
|
|
1863
|
+
}, { rootMargin: '50px' });
|
|
1864
|
+
observer.observe(container);
|
|
1865
|
+
}
|
|
1866
|
+
else {
|
|
1867
|
+
if (document.readyState === 'loading') {
|
|
1868
|
+
document.addEventListener('DOMContentLoaded', loadPlayer);
|
|
1869
|
+
}
|
|
1870
|
+
else {
|
|
1871
|
+
loadPlayer();
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
// Handle play button click
|
|
1876
|
+
var playButton = container.querySelector('.ts-video-player__play-button');
|
|
1877
|
+
if (playButton) {
|
|
1878
|
+
playButton.addEventListener('click', function() {
|
|
1879
|
+
loadPlayer();
|
|
1880
|
+
var check = setInterval(function() {
|
|
1881
|
+
if (container.__tsVideoPlayer && container.__tsVideoPlayer.ready) {
|
|
1882
|
+
container.__tsVideoPlayer.play();
|
|
1883
|
+
clearInterval(check);
|
|
1884
|
+
}
|
|
1885
|
+
}, 100);
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
})();
|
|
1889
|
+
`.trim(),Se=`
|
|
1890
|
+
.ts-video-player {
|
|
1891
|
+
position: relative;
|
|
1892
|
+
background: #000;
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
.ts-video-player__container {
|
|
1896
|
+
position: relative;
|
|
1897
|
+
width: 100%;
|
|
1898
|
+
padding-bottom: 56.25%;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
.ts-video-player__container > * {
|
|
1902
|
+
position: absolute;
|
|
1903
|
+
top: 0;
|
|
1904
|
+
left: 0;
|
|
1905
|
+
width: 100%;
|
|
1906
|
+
height: 100%;
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
.ts-video-player__placeholder {
|
|
1910
|
+
display: flex;
|
|
1911
|
+
align-items: center;
|
|
1912
|
+
justify-content: center;
|
|
1913
|
+
background-color: #1a1a1a;
|
|
1914
|
+
background-size: cover;
|
|
1915
|
+
background-position: center;
|
|
1916
|
+
cursor: pointer;
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
.ts-video-player__play-button {
|
|
1920
|
+
display: flex;
|
|
1921
|
+
align-items: center;
|
|
1922
|
+
justify-content: center;
|
|
1923
|
+
width: 80px;
|
|
1924
|
+
height: 80px;
|
|
1925
|
+
background: rgba(0, 0, 0, 0.7);
|
|
1926
|
+
border: none;
|
|
1927
|
+
border-radius: 50%;
|
|
1928
|
+
color: white;
|
|
1929
|
+
cursor: pointer;
|
|
1930
|
+
transition: transform 0.2s, background 0.2s;
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
.ts-video-player__play-button:hover {
|
|
1934
|
+
transform: scale(1.1);
|
|
1935
|
+
background: rgba(0, 0, 0, 0.9);
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
.ts-video-player__play-button svg {
|
|
1939
|
+
margin-left: 4px;
|
|
1940
|
+
}
|
|
1941
|
+
`.trim();return{html:pe,script:Ae,css:Se}}function Rp(v){switch(v.split(".").pop()?.toLowerCase()){case"mp4":return"video/mp4";case"webm":return"video/webm";case"ogg":case"ogv":return"video/ogg";case"mov":return"video/quicktime";case"avi":return"video/x-msvideo";case"mkv":return"video/x-matroska";case"m3u8":return"application/x-mpegURL";default:return"video/mp4"}}function Zx(v){let k=[/youtube\.com\/watch\?v=([^&]+)/,/youtube\.com\/embed\/([^?]+)/,/youtu\.be\/([^?]+)/,/youtube\.com\/v\/([^?]+)/];for(let C of k){let R=v.match(C);if(R)return R[1]}return null}function Gx(v){let k=v.match(/vimeo\.com\/(\d+)/);return k?k[1]:null}function cn(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'")}async function Jx(v,k){let C=await kp();if(!C)return ka({...v,process:!1},k);let R=k.tsVideosConfig,T=await C.processVideo(v.src,v,R,v.onProcessProgress);if(T.processed)return Ap(v,T,k);return ka({...v,process:!1},k)}async function Yx(v,k){let C=await kp();if(!C||!v.src)return;let R=typeof v.generatePoster==="object"?v.generatePoster:{timestamp:0},T=k.tsVideosConfig||{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos"};return(await C.generatePoster(v.src,R,T.outputDir,T.baseUrl||"/videos"))?.url}function Ap(v,k,C){let{controls:R=Ep,autoplay:T=!1,muted:z=!1,loop:F=!1,preload:V=Cp,playsinline:H=!0,lazy:K=!0,width:X,height:G,crossorigin:te,disablePictureInPicture:ce=!1,disableRemotePlayback:ee=!1}=v,{class:le,style:ue}=v,de=v.id||`stx-video-${Math.random().toString(36).slice(2,8)}`,fe=v.src,pe=Rp(fe);if(k.transcoded)fe=k.transcoded.url,pe="video/mp4";let Ae=k.streaming?.hls||k.streaming?.dash;if(Ae){if(k.streaming?.hls)fe=k.streaming.hls.manifestUrl,pe="application/x-mpegURL";else if(k.streaming?.dash)fe=k.streaming.dash.manifestUrl,pe="application/dash+xml"}let Se=k.poster?.url||v.poster,ve=[`id="${de}"`];if(R)ve.push("controls");if(T)ve.push("autoplay");if(z)ve.push("muted");if(F)ve.push("loop");if(H)ve.push("playsinline");if(ce)ve.push("disablepictureinpicture");if(ee)ve.push("disableremoteplayback");if(te)ve.push(`crossorigin="${te}"`);if(K){if(ve.push(`data-preload="${V}"`),ve.push('preload="none"'),Se)ve.push(`data-poster="${cn(Se)}"`);ve.push("data-stx-lazy")}else if(ve.push(`preload="${V}"`),Se)ve.push(`poster="${cn(Se)}"`);let De=X||k.metadata?.width,Me=G||k.metadata?.height;if(De)ve.push(`width="${De}"`);if(Me)ve.push(`height="${Me}"`);if(le)ve.push(`class="${cn(le)}"`);if(ue)ve.push(`style="${cn(ue)}"`);let Le=` <source ${K?`data-src="${cn(fe)}"`:`src="${cn(fe)}"`} type="${pe}" />`,Be=`<video ${ve.join(" ")}>
|
|
1942
|
+
${Le}
|
|
1943
|
+
Your browser does not support the video tag.
|
|
1944
|
+
</video>`;if(k.spriteSheet)Be=`<div class="stx-video-wrapper" data-sprite-sheet="${cn(k.spriteSheet.url)}" data-sprite-cols="${k.spriteSheet.columns}" data-sprite-interval="${k.spriteSheet.interval}">
|
|
1945
|
+
${Be}
|
|
1946
|
+
</div>`;let Oe;if(K)Oe=`
|
|
1947
|
+
(function() {
|
|
1948
|
+
var video = document.getElementById('${de}');
|
|
1949
|
+
if (!video) return;
|
|
1950
|
+
|
|
1951
|
+
var observer = new IntersectionObserver(function(entries) {
|
|
1952
|
+
entries.forEach(function(entry) {
|
|
1953
|
+
if (entry.isIntersecting) {
|
|
1954
|
+
// Load poster
|
|
1955
|
+
if (video.dataset.poster) {
|
|
1956
|
+
video.poster = video.dataset.poster;
|
|
1957
|
+
delete video.dataset.poster;
|
|
1958
|
+
}
|
|
1959
|
+
|
|
1960
|
+
// Load sources
|
|
1961
|
+
var sources = video.querySelectorAll('source[data-src]');
|
|
1962
|
+
sources.forEach(function(source) {
|
|
1963
|
+
source.src = source.dataset.src;
|
|
1964
|
+
delete source.dataset.src;
|
|
1965
|
+
});
|
|
1966
|
+
|
|
1967
|
+
// Set preload
|
|
1968
|
+
if (video.dataset.preload) {
|
|
1969
|
+
video.preload = video.dataset.preload;
|
|
1970
|
+
delete video.dataset.preload;
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
video.load();
|
|
1974
|
+
observer.disconnect();
|
|
1975
|
+
}
|
|
1976
|
+
});
|
|
1977
|
+
}, { rootMargin: '50px' });
|
|
1978
|
+
|
|
1979
|
+
observer.observe(video);
|
|
1980
|
+
})();
|
|
1981
|
+
`.trim();let We;if(Ae)We=`
|
|
1982
|
+
.stx-video-wrapper {
|
|
1983
|
+
position: relative;
|
|
1984
|
+
width: 100%;
|
|
1985
|
+
}
|
|
1986
|
+
.stx-video-wrapper video {
|
|
1987
|
+
width: 100%;
|
|
1988
|
+
height: auto;
|
|
1989
|
+
}
|
|
1990
|
+
`.trim();return{html:Be,script:Oe,css:We}}function Tp(){return ot({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async(v,k,C,R)=>{let{src:T,options:z}=Qx(v,k,C);if(!T)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let F={src:T,poster:z.poster,controls:z.controls!==!1,autoplay:z.autoplay||!1,muted:z.muted||!1,loop:z.loop||!1,preload:z.preload||"metadata",playsinline:z.playsinline!==!1,lazy:z.lazy!==!1,player:z.player||"native",type:z.type,width:z.width,height:z.height,class:z.class,style:z.style,id:z.id,crossorigin:z.crossorigin,disablePictureInPicture:z.disablePictureInPicture,disableRemotePlayback:z.disableRemotePlayback,title:z.title,quality:z.quality,platform:z.platform,process:z.process,generatePoster:z.generatePoster,streaming:z.streaming,transcode:z.transcode,spriteSheet:z.spriteSheet,waveform:z.waveform},H={isDev:C.__isDev||!1,tsVideosConfig:C.__tsVideosConfig},K=await ka(F,H),X=K.html;if(K.css)X+=`
|
|
1991
|
+
<style>${K.css}</style>`;if(K.script)X+=`
|
|
1992
|
+
<script>${K.script}</script>`;return X},defaults:{src:"",options:{controls:!0,lazy:!0,preload:"metadata"}}})}function Qx(v,k,C){if(k.src)return{src:String(k.src),options:k.options||{}};let R=v.trim();if(R.startsWith("@video(")||R.startsWith("("))R=R.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let T=eb(R),z=Ip(T[0],C)||"",F={};if(T[1]){let V=Ip(T[1],C);if(typeof V==="object"&&V!==null)F=V;else if(typeof T[1]==="string")try{F=JSON.parse(T[1])}catch{}}return{src:z,options:F}}function eb(v){let k=[],C="",R=!1,T="",z=0,F=0;for(let V=0;V<v.length;V++){let H=v[V],K=V>0?v[V-1]:"";if((H==='"'||H==="'"||H==="`")&&K!=="\\"){if(!R)R=!0,T=H;else if(H===T)R=!1,T="";else C+=H;continue}if(!R){if(H==="{")z++;if(H==="}")z--;if(H==="[")F++;if(H==="]")F--;if(H===","&&z===0&&F===0){k.push(C.trim()),C="";continue}}C+=H}if(C.trim())k.push(C.trim());return k}function Ip(v,k){if(typeof v!=="string")return v;let C=v.trim();if(C.startsWith('"')&&C.endsWith('"')||C.startsWith("'")&&C.endsWith("'"))return C.slice(1,-1);if(!C.startsWith("/")&&!C.startsWith(".")&&!C.startsWith("http")&&!C.startsWith("{")){let R=k[C];if(R!==void 0)return R}if(C.startsWith("{")||C.startsWith("["))try{return JSON.parse(C)}catch{}return C}var Pl=Tp();import tb from"fs";import Mn from"path";async function hr(v,k){if(!v.webComponents?.enabled)return[];let C=v.webComponents.components||[],R=[];if(C.length>0){if(v.debug)console.log(`Building ${C.length} web components...`);for(let T of C)try{let z=await nb(T,v,k);if(z)R.push(z)}catch(z){if(console.error(`Error building web component ${T.name}:`,z),v.debug)throw z}}return R}async function nb(v,k,C){let{name:R,file:T,tag:z,extends:F}=v;if(!R||!T||!z)return console.error("Invalid web component configuration, missing required fields:",v),null;let V=null;if(Mn.isAbsolute(T)&&await r(T))V=T;else if(k.componentsDir){let le=Mn.join(k.componentsDir,T);if(await r(le))V=le}if(!V)V=await mr(T,process.cwd(),k,C);if(!V)return console.error(`Web component source file not found: ${T}`),null;let H=await Bun.file(V).text();C.add(V);let X=(v.outputFormat||"js")==="ts",G=X?sb({name:R,tag:z,baseElement:F,source:H,shadowDOM:v.shadowDOM??!0,template:v.template??!0,styleSource:v.styleSource,attributes:v.attributes||[],attributeTypes:v.attributeTypes||{}}):rb({name:R,tag:z,baseElement:F,source:H,shadowDOM:v.shadowDOM??!0,template:v.template??!0,styleSource:v.styleSource,attributes:v.attributes||[]}),te=k.webComponents?.outputDir||"dist/web-components";await tb.promises.mkdir(te,{recursive:!0});let ce=X?"ts":"js",ee=Mn.join(te,`${z}.${ce}`);if(await Bun.write(ee,G),k.debug)console.log(`Built web component ${R} -> ${ee}`);return ee}function rb(v){let{name:k,tag:C,baseElement:R="HTMLElement",source:T,shadowDOM:z,template:F,styleSource:V,attributes:H=[]}=v,K=T.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!z)K=K.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),K=K.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),K=K.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),K=K.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");let X="";if(V)X=`<link rel="stylesheet" href="${V}">`;return`/**
|
|
1993
|
+
* ${k} Web Component
|
|
1994
|
+
* Auto-generated from stx component
|
|
1995
|
+
*/
|
|
1996
|
+
class ${k.replace(/\W/g,"")} extends ${R} {
|
|
1997
|
+
constructor() {
|
|
1998
|
+
super()
|
|
1999
|
+
this._initialized = false
|
|
2000
|
+
${z?"":"this._slotContent = []"}
|
|
2001
|
+
${z?'this.attachShadow({ mode: "open" })':""}
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
${F?`
|
|
2005
|
+
_createTemplate() {
|
|
2006
|
+
const template = document.createElement('template')
|
|
2007
|
+
template.innerHTML = \`${X}${K}\`
|
|
2008
|
+
${z?"this.shadowRoot.appendChild(template.content.cloneNode(true))":"this.appendChild(template.content.cloneNode(true))"}
|
|
2009
|
+
this._processSlots()
|
|
2010
|
+
}
|
|
2011
|
+
`:`
|
|
2012
|
+
_render() {
|
|
2013
|
+
${z?"this.shadowRoot.innerHTML":"this.innerHTML"} = \`${X}${K}\`
|
|
2014
|
+
this._processSlots()
|
|
2015
|
+
}
|
|
2016
|
+
`}
|
|
2017
|
+
|
|
2018
|
+
_processSlots() {
|
|
2019
|
+
${z?`// Shadow DOM handles slot assignment automatically
|
|
2020
|
+
// Listen for slot changes if needed
|
|
2021
|
+
const slots = this.shadowRoot.querySelectorAll('slot')
|
|
2022
|
+
slots.forEach(slot => {
|
|
2023
|
+
slot.addEventListener('slotchange', (e) => {
|
|
2024
|
+
const assignedNodes = slot.assignedNodes()
|
|
2025
|
+
this.dispatchEvent(new CustomEvent('slot-changed', {
|
|
2026
|
+
detail: { slotName: slot.name || 'default', assignedNodes }
|
|
2027
|
+
}))
|
|
2028
|
+
})
|
|
2029
|
+
})`:`// Manual slot processing for non-shadow DOM mode
|
|
2030
|
+
const slots = this.querySelectorAll('[data-slot]')
|
|
2031
|
+
|
|
2032
|
+
// Process named slots
|
|
2033
|
+
slots.forEach(slotEl => {
|
|
2034
|
+
const slotName = slotEl.getAttribute('data-slot')
|
|
2035
|
+
const slottedContent = this._slotContent.filter(
|
|
2036
|
+
node => node.nodeType === Node.ELEMENT_NODE && node.getAttribute('slot') === slotName
|
|
2037
|
+
)
|
|
2038
|
+
if (slottedContent.length > 0) {
|
|
2039
|
+
slotEl.innerHTML = ''
|
|
2040
|
+
slottedContent.forEach(content => slotEl.appendChild(content))
|
|
2041
|
+
}
|
|
2042
|
+
})
|
|
2043
|
+
|
|
2044
|
+
// Process default slot
|
|
2045
|
+
const defaultSlot = this.querySelector('[data-slot=""]') || this.querySelector('[data-default-slot]')
|
|
2046
|
+
if (defaultSlot) {
|
|
2047
|
+
const unslottedContent = this._slotContent.filter(
|
|
2048
|
+
node => node.nodeType !== Node.ELEMENT_NODE || !node.hasAttribute('slot')
|
|
2049
|
+
)
|
|
2050
|
+
if (unslottedContent.length > 0) {
|
|
2051
|
+
defaultSlot.innerHTML = ''
|
|
2052
|
+
unslottedContent.forEach(content => defaultSlot.appendChild(content))
|
|
2053
|
+
}
|
|
2054
|
+
}`}
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
${H.length>0?`
|
|
2058
|
+
static get observedAttributes() {
|
|
2059
|
+
return [${H.map((G)=>`'${G}'`).join(", ")}]
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
2063
|
+
if (oldValue !== newValue) {
|
|
2064
|
+
this[name] = newValue
|
|
2065
|
+
${F?"":"if (this._initialized) this._render()"}
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
`:""}
|
|
2069
|
+
|
|
2070
|
+
connectedCallback() {
|
|
2071
|
+
if (this._initialized) return
|
|
2072
|
+
${z?"":"this._slotContent = Array.from(this.childNodes)"}
|
|
2073
|
+
this._initialized = true
|
|
2074
|
+
${F?"this._createTemplate()":"this._render()"}
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
disconnectedCallback() {
|
|
2078
|
+
// Component removed from the DOM
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
// Register the web component
|
|
2083
|
+
customElements.define('${C}', ${k.replace(/\W/g,"")})
|
|
2084
|
+
`}function sb(v){let{name:k,tag:C,baseElement:R="HTMLElement",source:T,shadowDOM:z,template:F,styleSource:V,attributes:H=[],attributeTypes:K={}}=v,X=k.replace(/\W/g,""),G=T.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!z)G=G.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),G=G.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),G=G.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),G=G.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");G=G.replace(/`/g,"\\`").replace(/\$\{/g,"\\${");let te=V?`<link rel="stylesheet" href="${V}">`:"",ce=(Se)=>{switch(K[Se]){case"number":return"number";case"boolean":return"boolean";case"object":return"Record<string, unknown>";default:return"string"}},ee=(Se)=>Se.replace(/-([a-z])/g,(ve,De)=>De.toUpperCase()),le=H.map((Se)=>` private _${ee(Se)}: ${ce(Se)} | null = null;`).join(`
|
|
2085
|
+
`),ue=H.map((Se)=>{let ve=ce(Se),De=ee(Se);return`
|
|
2086
|
+
get ${De}(): ${ve} | null {
|
|
2087
|
+
return this._${De};
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
set ${De}(value: ${ve} | null) {
|
|
2091
|
+
this._${De} = value;
|
|
2092
|
+
if (value !== null) {
|
|
2093
|
+
this.setAttribute('${Se}', String(value));
|
|
2094
|
+
}
|
|
2095
|
+
else {
|
|
2096
|
+
this.removeAttribute('${Se}');
|
|
2097
|
+
}
|
|
2098
|
+
}`}).join(`
|
|
2099
|
+
`),de=H.length>0?`/**
|
|
2100
|
+
* Props interface for ${k}
|
|
2101
|
+
*/
|
|
2102
|
+
export interface ${X}Props {
|
|
2103
|
+
${H.map((Se)=>{let ve=ce(Se);return` ${ee(Se)}?: ${ve};`}).join(`
|
|
2104
|
+
`)}
|
|
2105
|
+
}
|
|
2106
|
+
`:"",fe=H.length>0?`
|
|
2107
|
+
static get observedAttributes(): string[] {
|
|
2108
|
+
return [${H.map((Se)=>`'${Se}'`).join(", ")}];
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {
|
|
2112
|
+
if (oldValue !== newValue) {
|
|
2113
|
+
const camelCase = name.replace(/-([a-z])/g, (_: string, letter: string) => letter.toUpperCase());
|
|
2114
|
+
(this as unknown as Record<string, unknown>)[\`_\${camelCase}\`] = this._parseAttributeValue(name, newValue);
|
|
2115
|
+
${F?"":"if (this._initialized) this._render();"}
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
private _parseAttributeValue(name: string, value: string | null): unknown {
|
|
2120
|
+
if (value === null) return null;
|
|
2121
|
+
const typeMap: Record<string, string> = ${JSON.stringify(K)};
|
|
2122
|
+
const type = typeMap[name] || 'string';
|
|
2123
|
+
switch (type) {
|
|
2124
|
+
case 'number': return Number(value);
|
|
2125
|
+
case 'boolean': return value !== 'false' && value !== '0';
|
|
2126
|
+
case 'object': try { return JSON.parse(value); }
|
|
2127
|
+
catch { return value; }
|
|
2128
|
+
default: return value;
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
`:"",pe=F?`
|
|
2132
|
+
private _createTemplate(): void {
|
|
2133
|
+
const template = document.createElement('template');
|
|
2134
|
+
template.innerHTML = \`${te}${G}\`;
|
|
2135
|
+
${z?"this.shadowRoot!.appendChild(template.content.cloneNode(true));":"this.appendChild(template.content.cloneNode(true));"}
|
|
2136
|
+
this._processSlots();
|
|
2137
|
+
}`:`
|
|
2138
|
+
private _render(): void {
|
|
2139
|
+
${z?"this.shadowRoot!.innerHTML":"this.innerHTML"} = \`${te}${G}\`;
|
|
2140
|
+
this._processSlots();
|
|
2141
|
+
}`;return`/**
|
|
2142
|
+
* ${k} Web Component
|
|
2143
|
+
* Auto-generated from stx component (TypeScript)
|
|
2144
|
+
*
|
|
2145
|
+
* @example
|
|
2146
|
+
* \`\`\`html
|
|
2147
|
+
* <${C}></${C}>
|
|
2148
|
+
* \`\`\`
|
|
2149
|
+
*/
|
|
2150
|
+
|
|
2151
|
+
/**
|
|
2152
|
+
* Detail type for slot-changed event
|
|
2153
|
+
*/
|
|
2154
|
+
interface SlotChangeDetail {
|
|
2155
|
+
slotName: string;
|
|
2156
|
+
assignedNodes: Node[];
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
${de}
|
|
2160
|
+
/**
|
|
2161
|
+
* ${k} custom element class
|
|
2162
|
+
* @customElement ${C}
|
|
2163
|
+
*/
|
|
2164
|
+
export class ${X} extends ${R} {
|
|
2165
|
+
${le}
|
|
2166
|
+
private _initialized = false;
|
|
2167
|
+
${z?"":"private _slotContent: Node[] = [];"}
|
|
2168
|
+
|
|
2169
|
+
constructor() {
|
|
2170
|
+
super();
|
|
2171
|
+
${z?'this.attachShadow({ mode: "open" });':""}
|
|
2172
|
+
}
|
|
2173
|
+
${pe}
|
|
2174
|
+
${z?`
|
|
2175
|
+
private _processSlots(): void {
|
|
2176
|
+
const slots = this.shadowRoot!.querySelectorAll('slot');
|
|
2177
|
+
slots.forEach((slot) => {
|
|
2178
|
+
slot.addEventListener('slotchange', () => {
|
|
2179
|
+
const assignedNodes = (slot as HTMLSlotElement).assignedNodes();
|
|
2180
|
+
this.dispatchEvent(new CustomEvent<SlotChangeDetail>('slot-changed', {
|
|
2181
|
+
detail: { slotName: slot.getAttribute('name') || 'default', assignedNodes }
|
|
2182
|
+
}));
|
|
2183
|
+
});
|
|
2184
|
+
});
|
|
2185
|
+
}`:`
|
|
2186
|
+
private _processSlots(): void {
|
|
2187
|
+
const slots = this.querySelectorAll('[data-slot]');
|
|
2188
|
+
slots.forEach((slotEl) => {
|
|
2189
|
+
const slotName = slotEl.getAttribute('data-slot');
|
|
2190
|
+
if (slotName) {
|
|
2191
|
+
const slottedContent = this._slotContent.filter(
|
|
2192
|
+
node => node.nodeType === Node.ELEMENT_NODE && (node as Element).getAttribute('slot') === slotName
|
|
2193
|
+
);
|
|
2194
|
+
if (slottedContent.length > 0) {
|
|
2195
|
+
slotEl.innerHTML = '';
|
|
2196
|
+
slottedContent.forEach(content => slotEl.appendChild(content));
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
});
|
|
2200
|
+
const defaultSlot = this.querySelector('[data-slot=""]') || this.querySelector('[data-default-slot]');
|
|
2201
|
+
if (defaultSlot) {
|
|
2202
|
+
const unslottedContent = this._slotContent.filter(
|
|
2203
|
+
node => node.nodeType !== Node.ELEMENT_NODE || !(node as Element).hasAttribute('slot')
|
|
2204
|
+
);
|
|
2205
|
+
if (unslottedContent.length > 0) {
|
|
2206
|
+
defaultSlot.innerHTML = '';
|
|
2207
|
+
unslottedContent.forEach(content => defaultSlot.appendChild(content));
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
}`}
|
|
2211
|
+
${fe}
|
|
2212
|
+
${ue}
|
|
2213
|
+
|
|
2214
|
+
connectedCallback(): void {
|
|
2215
|
+
if (this._initialized) return;
|
|
2216
|
+
${z?"":"this._slotContent = Array.from(this.childNodes);"}
|
|
2217
|
+
this._initialized = true;
|
|
2218
|
+
${F?"this._createTemplate();":"this._render();"}
|
|
2219
|
+
}
|
|
2220
|
+
|
|
2221
|
+
disconnectedCallback(): void {
|
|
2222
|
+
// Component removed from the DOM
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
adoptedCallback(): void {
|
|
2226
|
+
// Component moved to a new document
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
// Type augmentation for HTMLElementTagNameMap
|
|
2231
|
+
declare global {
|
|
2232
|
+
interface HTMLElementTagNameMap {
|
|
2233
|
+
'${C}': ${X};
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
// Register the web component
|
|
2238
|
+
customElements.define('${C}', ${X});
|
|
2239
|
+
`}function ib(v,k){let C=v.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),R=C?C[1].trim():"",T=k,z=[],F=!0;if(R){let G=R.match(/export\s+default\s+({[\s\S]*})/);if(G)try{let te=G[1],ce=te.match(/tag\s*:\s*['"`]([^'"`]+)['"`]/);if(ce)T=ce[1];let ee=te.match(/props\s*:\s*\[([\s\S]*?)\]/);if(ee)z=ee[1].split(",").map((ue)=>ue.trim().replace(/['"`]/g,"")).filter((ue)=>ue.length>0);let le=te.match(/shadowDOM\s*:\s*(true|false)/);if(le)F=le[1]==="true"}catch{}}let V=v.match(/<template\b(?![^>]*\bid\s*=)[^>]*>([\s\S]*?)<\/template>/i),H=V?V[1].trim():"",K=v.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i),X=K?K[1].trim():"";return{tag:T,props:z,template:H,styles:X,script:R,shadowDOM:F}}function ob(v){let{tag:k,props:C,template:R,styles:T,shadowDOM:z}=v,F=k.split("-").map((G)=>G.charAt(0).toUpperCase()+G.slice(1)).join(""),V=R.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),H=T.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),K=C.map((G)=>`'${G}'`).join(", "),X=C.map((G)=>`
|
|
2240
|
+
get ${G}() {
|
|
2241
|
+
return this.getAttribute('${G}') || '';
|
|
2242
|
+
}
|
|
2243
|
+
set ${G}(value) {
|
|
2244
|
+
if (value) {
|
|
2245
|
+
this.setAttribute('${G}', value);
|
|
2246
|
+
}
|
|
2247
|
+
else {
|
|
2248
|
+
this.removeAttribute('${G}');
|
|
2249
|
+
}
|
|
2250
|
+
}`).join(`
|
|
2251
|
+
`);return`/**
|
|
2252
|
+
* ${F} Web Component
|
|
2253
|
+
* Auto-generated from SFC
|
|
2254
|
+
*/
|
|
2255
|
+
class ${F} extends HTMLElement {
|
|
2256
|
+
constructor() {
|
|
2257
|
+
super();
|
|
2258
|
+
${z?"this.attachShadow({ mode: 'open' });":""}
|
|
2259
|
+
this._render();
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
static get observedAttributes() {
|
|
2263
|
+
return [${K}];
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
2267
|
+
if (oldValue !== newValue) {
|
|
2268
|
+
this._render();
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
${X}
|
|
2272
|
+
|
|
2273
|
+
_render() {
|
|
2274
|
+
const template = \`${H?`<style>${H}</style>`:""}${V}\`;
|
|
2275
|
+
|
|
2276
|
+
// Interpolate {{ prop }} with attribute values
|
|
2277
|
+
const rendered = template.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (match, prop) => {
|
|
2278
|
+
return this.getAttribute(prop) || '';
|
|
2279
|
+
});
|
|
2280
|
+
|
|
2281
|
+
${z?"this.shadowRoot.innerHTML = rendered;":"this.innerHTML = rendered;"}
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
connectedCallback() {
|
|
2285
|
+
this._render();
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
customElements.define('${k}', ${F});
|
|
2290
|
+
`}async function Pp(v,k,C,R){if(k.length<1)return i("WebComponent","@webcomponent directive requires at least the tag name parameter",t.INVALID_DIRECTIVE_SYNTAX);let T=k[0].replace(/['"]/g,""),F=(C.__stx_options||{}).componentsDir||"components",V=Mn.isAbsolute(F)?[Mn.join(F,`${T}.stx`),Mn.join(Mn.dirname(R),`${T}.stx`)]:[Mn.join(Mn.dirname(R),F,`${T}.stx`),Mn.join(process.cwd(),F,`${T}.stx`),Mn.join(Mn.dirname(R),`${T}.stx`)],H=null;for(let G of V)if(await r(G)){H=await Bun.file(G).text();break}if(!H)return i("WebComponent",`Component file not found: ${T}.stx`,t.FILE_NOT_FOUND);let K=ib(H,T);return`<script type="module">
|
|
2291
|
+
${ob(K)}
|
|
2292
|
+
</script>`}var A={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:zt,cachePath:".stx/cache",cacheVersion:"1.0.0",componentRenderCacheBytes:33554432,build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:gp,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Pp,hasEndTag:!1,description:"Include a web component in the template"},Fi,zi,wr,xr,tp,rp,sp,np,dp,ep,$p,Pl,...Nr],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"main",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,scrollRestoration:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};function cb(v,k,C){let R=k||"pages";if(v)return{root:v,pagesDir:R};let T=C||process.cwd(),z=ln.join(T,"resources","views"),F=ln.join(T,"resources","layouts");if(hs.existsSync(z)&&hs.existsSync(F))return{root:"resources",pagesDir:"views"};let V=ln.join(T,"resources","views","pages");if(hs.existsSync(V))return{root:"resources/views",pagesDir:R};return{root:".",pagesDir:R}}var Dp=new Set,Ca=["partialsDir","componentsDir","layoutsDir"],Dl=new WeakMap;function lb(v,k){let C=k.replace(/[\\/]+$/,"");if(!C||C===".")return!0;let R=v.replace(/\\/g,"/"),T=C.replace(/\\/g,"/");return R===T||R.startsWith(`${T}/`)}function rl(v,k){let C=!v.root,R=cb(v.root,v.pagesDir,k);if(v.root=R.root,v.pagesDir=R.pagesDir,C&&R.root!=="."){let T=`${k}::${R.root}`;if(!Dp.has(T))Dp.add(T),console.warn(`[stx] No "root" in config \u2014 inferred "${R.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if(!Dl.has(v)){let T={};for(let z of Ca){let F=v[z];if(typeof F==="string"&&F)T[z]=F}Dl.set(v,T)}if(v.root&&v.root!=="."){let T=v.root;for(let z of Ca){let F=v[z];if(typeof F!=="string"||!F)continue;if(ln.isAbsolute(F)||lb(F,T))continue;v[z]=ln.join(T,F)}}for(let T of Ca){let z=v[T];if(typeof z!=="string"||!z||ln.isAbsolute(z))continue;v[T]=ln.resolve(k,z)}return v}function ub(v,k){let C=Dl.get(v);for(let R of Ca){let T=v[R];if(typeof T!=="string"||!T)continue;let z=ln.isAbsolute(T)?T:ln.join(k,T);if(hs.existsSync(z))continue;let F=C?.[R]??T,V=v.root,H=!!V&&V!==".";console.warn(`[stx] ${String(R)} resolves to "${z}", which does not exist. Configured as "${F}"`+(H?`, resolved under root "${V}".`:"."))}}function db(v){if(v.customDirectives)v.customDirectives=[...v.customDirectives];if(v.middleware)v.middleware=[...v.middleware];if(v.apiRoutes)v.apiRoutes={...v.apiRoutes}}function fb(v){if(qi(v.stateDir),v.stateDir=Tn(),v.cachePath=$n(v.cachePath),v.build)v.build.cacheDir=$n(v.build.cacheDir);if(v.media?.cache)v.media.cache.directory=$n(v.media.cache.directory);if(v.story)v.story.outDir=$n(v.story.outDir)}var Mr=null,Gr=new Map,Ea=new Map,go=null;async function Hs(v,k=ab){try{return await k(v)}catch(C){if(C instanceof Error&&C.name==="ConfigNotFoundError")return{config:v.defaultConfig};throw C}}async function o(v){let k=v?ln.resolve(v):process.cwd(),C=Ea.get(k);if(C&&C.signature!==yr(C.graph)){let z=Gr.get(k);if(Gr.delete(k),Ea.delete(k),!v)Mr=null,go=null;let{clearComponentCache:F}=await import("./chunk-8a3sdg2y.js"),{partialsCache:V}=await import("./chunk-z0gfb7b4.js");if(F(),V.clear(),z&&C.configSignature===br(C.graph)){let H=z.then(async(K)=>{let X={...C.graph};await Us(X,k),Ea.set(k,{graph:X,signature:yr(X),configSignature:br(X)});let G={...K,_layerGraph:X};if(!v)Mr=G;return G});return Gr.set(k,H),H}}if(!v){if(Mr)return Mr;if(go)return go}let R=Gr.get(k);if(R)return R;let T=(async()=>{let z=[".ts",".js",".mjs",".cjs",".json"],F=z.some((te)=>hs.existsSync(ln.join(k,`stx.config${te}`))),V=z.some((te)=>hs.existsSync(ln.join(k,"config",`ui${te}`))),H;if(F&&V){let te=await Hs({name:"ui",cwd:ln.join(k,"config"),defaultConfig:A,errorPolicy:"throw",verbose:!1});H=(await Hs({name:"stx",alias:"ui",cwd:k,defaultConfig:te.config,errorPolicy:"throw",verbose:!1})).config}else H=(await Hs({name:"stx",alias:"ui",cwd:k,defaultConfig:A,errorPolicy:"throw",verbose:!1})).config;if(H.extends!==void 0||C){let te=await Ui(k,A);H=te.config,Ea.set(k,{graph:te.graph,signature:yr(te.graph),configSignature:br(te.graph)})}if(H.runtimeConfig){let{resolveRuntimeConfig:te}=await import("./chunk-b3mazye4.js");te(H.runtimeConfig,{});let{generateRuntimeConfigTypes:ce}=await import("./chunk-6n6nnt33.js");await ce(k,H.runtimeConfig)}db(H),fb(H),rl(H,k),ub(H,k);let K=[],X=new Set((H.plugins??[]).map((te)=>typeof te==="string"?te:te[0]));for(let te of H.componentPackages??["@stacksjs/components"]){let ce=`${te}/stx-plugin`;if(X.has(ce)||X.has(te))continue;try{d.resolve(ce,{paths:[k]}),K.push(ce)}catch{}}let G=[...H.plugins??[],...K];if(G.length>0){let{pluginManager:te}=await import("./chunk-qz3tnvwm.js"),ce=[],ee=[];for(let le of G){let ue=typeof le==="string"?le:le[0],de=typeof le==="string"?{}:le[1]||{};try{let fe,pe;try{let Se=d.resolve(ue,{paths:[k]});fe=await import(Se),pe=ln.dirname(Se)}catch{let Se=ln.resolve(k,ue);fe=await import(Se),pe=ln.dirname(Se)}let Ae=fe.default||fe;if(!te.has(Ae.name))await te.register(Ae,H);if(Ae.components){let Se=Array.isArray(Ae.components)?Ae.components:[Ae.components];for(let ve of Se)ce.push(ln.resolve(pe,ve))}if(Ae.pages){let Se=ln.resolve(pe,Ae.pages),ve=de.path||"/";ee.push({dir:Se,prefix:ve})}if(Ae.setup){let Se={addDirective:(ve)=>{H.customDirectives=H.customDirectives||[],H.customDirectives.push(ve)},addRoute:(ve,De)=>{H.apiRoutes=H.apiRoutes||{},H.apiRoutes[ve]=De},addMiddleware:(ve)=>{H.middleware=H.middleware||[],H.middleware.push(ve)},pluginDir:pe,config:H};await Ae.setup(de,Se)}process.stderr.write(`[stx] Plugin loaded: ${Ae.name||ue}
|
|
2293
|
+
`)}catch(fe){console.warn(`[stx] Failed to load plugin ${ue}:`,fe.message)}}H._pluginComponentDirs=ce,H._pluginPageDirs=ee}return H})();if(Gr.set(k,T),T.catch(()=>{if(Gr.get(k)===T)Gr.delete(k)}),!v)go=T,T.then((z)=>{Mr=z}).catch(()=>{});return T}var P=new Proxy(A,{get(v,k){if(Mr&&k in Mr)return Mr[k];if(!go)o().catch((C)=>{console.warn("[stx] Failed to load config file:",C?.message||C)});return v[k]}});function wd(v){return v}function xd(v){let k=[],C=[];if(v.partialsDir!==void 0&&typeof v.partialsDir!=="string")k.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if(v.componentsDir!==void 0&&typeof v.componentsDir!=="string")k.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if(v.cache!==void 0&&typeof v.cache!=="boolean")k.push({path:"cache",message:"cache must be a boolean",severity:"error"});if(v.debug!==void 0&&typeof v.debug!=="boolean")k.push({path:"debug",message:"debug must be a boolean",severity:"error"});if(v.streaming){if(v.streaming.bufferSize!==void 0){if(typeof v.streaming.bufferSize!=="number"||v.streaming.bufferSize<=0)k.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if(v.streaming.timeout!==void 0){if(typeof v.streaming.timeout!=="number"||v.streaming.timeout<=0)k.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if(v.streaming.strategy!==void 0){let R=["auto","manual","sections"];if(!R.includes(v.streaming.strategy))k.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${R.join(", ")}`,severity:"error"})}}if(v.i18n){if(v.i18n.format!==void 0){let R=["json","yaml","yml","js"];if(!R.includes(v.i18n.format))k.push({path:"i18n.format",message:`i18n.format must be one of: ${R.join(", ")}`,severity:"error"})}}if(v.animation){if(v.animation.defaultDuration!==void 0){if(typeof v.animation.defaultDuration!=="number"||v.animation.defaultDuration<0)k.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if(v.animation.staggerDelay!==void 0){if(typeof v.animation.staggerDelay!=="number"||v.animation.staggerDelay<0)k.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if(v.a11y){if(v.a11y.level!==void 0){let R=["AA","AAA"];if(!R.includes(v.a11y.level))k.push({path:"a11y.level",message:`a11y.level must be one of: ${R.join(", ")}`,severity:"error"})}}if(v.hydration){if(v.hydration.mode!==void 0){let R=["progressive","islands"];if(!R.includes(v.hydration.mode))k.push({path:"hydration.mode",message:`hydration.mode must be one of: ${R.join(", ")}`,severity:"error"})}if(v.hydration.preload!==void 0){let R=["none","eager","lazy"];if(!R.includes(v.hydration.preload))k.push({path:"hydration.preload",message:`hydration.preload must be one of: ${R.join(", ")}`,severity:"error"})}}if(v.customDirectives)if(!Array.isArray(v.customDirectives))k.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else v.customDirectives.forEach((R,T)=>{if(!R.name||typeof R.name!=="string")k.push({path:`customDirectives[${T}].name`,message:"Custom directive must have a name string",severity:"error"});if(!R.handler||typeof R.handler!=="function")k.push({path:`customDirectives[${T}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if(v.middleware)if(!Array.isArray(v.middleware))k.push({path:"middleware",message:"middleware must be an array",severity:"error"});else v.middleware.forEach((R,T)=>{if(!R.name||typeof R.name!=="string")k.push({path:`middleware[${T}].name`,message:"Middleware must have a name string",severity:"error"});if(!R.handler||typeof R.handler!=="function")k.push({path:`middleware[${T}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!R.timing||!["before","after"].includes(R.timing))k.push({path:`middleware[${T}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if(v.debug===!0&&v.cache===!0)C.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if(v.seo?.enabled===!0&&!v.seo?.defaultConfig?.title)C.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if(v.pwa){if(v.pwa.enabled===!0&&!v.pwa.manifest?.name)k.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if(v.pwa.manifest?.display!==void 0){let R=["fullscreen","standalone","minimal-ui","browser"];if(!R.includes(v.pwa.manifest.display))k.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${R.join(", ")}`,severity:"error"})}if(v.pwa.manifest?.orientation!==void 0){let R=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!R.includes(v.pwa.manifest.orientation))k.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${R.join(", ")}`,severity:"error"})}if(v.pwa.routes){let R=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];v.pwa.routes.forEach((T,z)=>{if(!T.pattern||typeof T.pattern!=="string")k.push({path:`pwa.routes[${z}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!R.includes(T.strategy))k.push({path:`pwa.routes[${z}].strategy`,message:`PWA route strategy must be one of: ${R.join(", ")}`,severity:"error"});if(T.maxAgeSeconds!==void 0&&(typeof T.maxAgeSeconds!=="number"||T.maxAgeSeconds<0))k.push({path:`pwa.routes[${z}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(T.maxEntries!==void 0&&(typeof T.maxEntries!=="number"||T.maxEntries<1))k.push({path:`pwa.routes[${z}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if(v.pwa.icons?.sizes){if(!Array.isArray(v.pwa.icons.sizes))k.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if(v.pwa.icons.sizes.filter((T)=>typeof T!=="number"||T<16||T>1024).length>0)k.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if(v.pwa.icons?.purpose){let R=["any","maskable","monochrome"];if(v.pwa.icons.purpose.filter((z)=>!R.includes(z)).length>0)k.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${R.join(", ")}`,severity:"error"})}if(v.pwa.enabled===!0&&!v.pwa.icons?.src)C.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if(v.pwa.enabled===!0&&!v.pwa.manifest?.themeColor)C.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:k.length===0,errors:k,warnings:C}}var Ml=new Map;async function ye(v,k={}){try{if(!await r(v))throw Error(`Markdown file not found: ${v}`);let R=(await pb.promises.stat(v)).mtime.getTime();if(k.cache&&Ml.has(v)){let G=Ml.get(v);if(G.updatedAt>=R)return{content:G.content,data:G.data}}let T=await Bun.file(v).text(),{data:z,content:F}=sr(T),V=k.markdown||P.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},K=qe(F,{gfm:!0});if(V.syntaxHighlighting?.enabled&&V.syntaxHighlighting?.serverSide)K=await mb(K,V.syntaxHighlighting?.defaultTheme||"github-dark",V.syntaxHighlighting?.highlightUnknownLanguages||!1);let X={content:K,data:z||{}};if(k.cache)Ml.set(v,{...X,updatedAt:R});return X}catch(C){if(k.debug)console.error(`Error reading/parsing markdown file ${v}:`,C);let R=C instanceof Error?C.message:String(C);return{content:g("Markdown File",`Error reading/parsing markdown file: ${R}`,v,"",0,""),data:{}}}}var Ra=null;async function mb(v,k,C){let R=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!Ra)try{Ra=await gb({theme:k||"github-dark",cache:!0})}catch(V){return console.error("Failed to initialize ts-syntax-highlighter:",V),v}let T=async(V,H,K,X)=>{let G=X.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),te=K||(C?"text":"");if(!te)return V;try{if(!Ra.getSupportedLanguages().includes(te))return V;return(await Ra.highlight(G,te,{theme:k})).html}catch(ce){console.error(`Error highlighting code block with language ${K}:`,ce)}return V},z=v,F=v.matchAll(R);for(let V of F){let[H,K,X,G]=V,te=await T(H,K,X,G);z=z.replace(H,te)}return z}async function Op(v,k,C="",R={}){return await hb(v,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(F,V,H,K)=>{try{let X=V;if(!Ol.isAbsolute(V))X=Ol.resolve(Ol.dirname(C),V);let G={};if(H)try{try{G=JSON.parse(H)}catch{if(R.debug)console.warn("Using safer alternative for parsing JS object literal");let fe=H.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let pe of fe){let Ae=pe.indexOf(":");if(Ae>0){let Se=pe.substring(0,Ae).trim(),ve=pe.substring(Ae+1).trim(),De=ve.startsWith('"')&&ve.endsWith('"'),Me=ve.startsWith("'")&&ve.endsWith("'");if(De||Me)ve=ve.substring(1,ve.length-1);G[Se]=ve}}}}catch(de){if(R.debug)console.error("Error parsing context in @markdown-file directive:",de)}let{content:te,data:ce}=await ye(X,R),ee={...k,...ce,...G},le=te,ue=/\{\{([^}]+)\}\}/g;return le=le.replace(ue,(de,fe)=>{let pe=fe.trim();return ee[pe]!==void 0?String(ee[pe]):de}),le}catch(X){let G=X instanceof Error?X.message:String(X);return g("Markdown File",`Error including markdown file: ${G}`,C,v,K,F)}})}async function hb(v,k,C){let R=[],T;while((T=k.exec(v))!==null){let V=T[0],H=T.index,K=T;R.push(C(...K).then((X)=>({match:V,replacement:X,index:H})))}let z=await Promise.all(R);z.sort((V,H)=>H.index-V.index);let F=v;for(let{match:V,replacement:H}of z)F=F.replace(V,()=>H);return F}function jr(v,k){try{let C=v.trim();if(p(C))return c(C,Object.keys(k))(...Object.values(k));else return l(C,k)}catch{return!1}}function Lr(v,k){let C=yb(v,k);return C.ok?{expression:C.expression,endPos:C.endPos}:null}function yb(v,k){let C=k;while(C<v.length&&/\s/.test(v[C]))C++;if(v[C]!=="(")return{ok:!1,reason:"missing-open-paren",pos:C};let R=S(v,"(",")",C);if(R===-1)return{ok:!1,reason:"unclosed-paren",pos:C};return{ok:!0,expression:v.slice(C+1,R),endPos:R+1}}function xb(v,k){let C=v.lastIndexOf("<",k);if(C===-1)return!1;return C>v.lastIndexOf(">",k)}function Jr(v,k,C,R){let T=1,z=R,F=new RegExp(`@${k}\\s*\\(`,"g"),V=new RegExp(`@${C}(?![a-z])`,"g");while(z<v.length&&T>0){F.lastIndex=z,V.lastIndex=z;let H=F.exec(v),K=V.exec(v),X=H?H.index:1/0,G=K?K.index:1/0;if(X<G)T++,z=X+H[0].length;else if(G<1/0){if(T--,T===0)return G;z=G+K[0].length}else break}return-1}function Mp(v,k){let C=v.slice(k).match(/^@if\s*/);if(!C)return null;let R=k+C[0].length,T=Lr(v,R);if(!T)return null;let z=T.endPos,F=Jr(v,"if","endif",z);if(F===-1)return null;let V=v.slice(z,F),H=[],K=0,X="if",G=T.expression,te=0,ce=0;while(K<V.length){let ee=V.indexOf("@",K);if(ee===-1)break;K=ee;let le=V.substring(ee);if(xb(V,ee)){K++;continue}if(/^@if\s*\(/.test(le)){ce++,K++;continue}if(/^@endif(?![a-z])/.test(le)){ce--,K+=6;continue}if(ce===0){let ue=le.match(/^@elseif\s*/);if(ue){H.push({type:X,condition:G,content:V.substring(te,K),start:z+te,end:z+K});let de=K+ue[0].length,fe=Lr(V,de);if(!fe){K++;continue}X="elseif",G=fe.expression,K=fe.endPos,te=K;continue}else if(/^@else(?![a-z])/.test(le)){H.push({type:X,condition:G,content:V.substring(te,K),start:z+te,end:z+K}),X="else",G=void 0,K+=5,te=K;continue}}K++}return H.push({type:X,condition:G,content:V.slice(te),start:z+te,end:z+V.length}),{fullMatch:v.slice(k,F+6),branches:H,start:k,end:F+6}}function mo(v){let k=[],C=/@if\s*\(/g,R=C.exec(v);while(R!==null){if(k.some((F)=>R.index>F.start&&R.index<F.end)){R=C.exec(v);continue}let z=Mp(v,R.index);if(z)k.push(z),C.lastIndex=z.end;R=C.exec(v)}return k}function Aa(v,k,C){let R=[],T=new RegExp(`@${k}\\s*\\(`,"g"),z=T.exec(v);while(z!==null){if(R.some((le)=>z.index>le.start&&z.index<le.end)){z=T.exec(v);continue}let V=z.index,H=V+z[0].length-1,K=S(v,"(",")",H);if(K===-1){z=T.exec(v);continue}let X=v.slice(H+1,K),G=K+1,te=Jr(v,k,C,G);if(te===-1){z=T.exec(v);continue}let ce=v.slice(G,te),ee=te+`@${C}`.length;R.push({fullMatch:v.slice(V,ee),name:k,params:X,content:ce,start:V,end:ee}),T.lastIndex=ee,z=T.exec(v)}return R}function Nl(v,k){let C=v.slice(k).match(/^@switch\s*/);if(!C)return null;let R=k+C[0].length,T=Lr(v,R);if(!T)return null;let z=T.endPos,F=Jr(v,"switch","endswitch",z);if(F===-1)return null;let V=v.slice(z,F),H=[],K=0,X=null,G=0;while(K<V.length){let te=V.slice(K),ce=te.match(/^@switch\s*\(/),ee=te.match(/^@endswitch(?![a-z])/);if(ce){if(G++,X)X.content+=ce[0];K+=ce[0].length;continue}if(ee){if(G--,X)X.content+=ee[0];K+=ee[0].length;continue}if(G>0){if(X)X.content+=V[K];K++;continue}let le=te.match(/^@case\s*/),ue=te.match(/^@default(?![a-z])/),de=te.match(/^@break(?![a-z])/);if(le&&te.startsWith("@case")){if(X)H.push(X);let fe=K+le[0].length,pe=Lr(V,fe);if(!pe){K++;continue}X={type:"case",value:pe.expression,content:""},K=pe.endPos}else if(ue&&te.startsWith("@default")){if(X)H.push(X);X={type:"default",content:""},K+=ue[0].length}else if(de&&te.startsWith("@break"))K+=de[0].length;else{if(X)X.content+=V[K];K++}}if(X)H.push(X);return{fullMatch:v.slice(k,F+10),expression:T.expression,cases:H,start:k,end:F+10}}function Sb(v,k,C){let R=v,T=!0;while(T){T=!1;let z=R.match(/@switch\s*\(/);if(!z||z.index===void 0)break;let F=z.index,V=Nl(R,F);if(!V)break;try{let H;if(p(V.expression))H=c(V.expression,Object.keys(k))(...Object.values(k));else H=l(V.expression,k);let K="",X=!1;for(let G of V.cases)if(G.type==="default"){if(!X)K=G.content.trim()}else try{let te;if(G.value&&p(G.value))te=c(G.value,Object.keys(k))(...Object.values(k));else if(G.value)te=l(G.value,k);if(H===te){K=G.content.trim(),X=!0;break}}catch{continue}R=R.substring(0,F)+K+R.substring(V.end),T=!0}catch(H){let K=H instanceof Error?H.message:String(H),X=i("Switch",`Error evaluating @switch expression: ${K}`,t.EVALUATION_ERROR);R=R.substring(0,F)+X+R.substring(V.end);break}}return R}function $b(v){let k=[];return{masked:v.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(R)=>(k.push(R),`\x00stx-script-${k.length-1}\x00`)),scripts:k}}function _b(v,k){if(k.length===0)return v;return v.replace(/\u0000stx-script-(\d+)\u0000/g,(C,R)=>k[Number(R)]??C)}function Sr(v,k,C){let{masked:R,scripts:T}=$b(v);return _b(kb(R,k,C),T)}function kb(v,k,C){let R=v;R=Sb(R,k,C);{let z=!0;while(z){z=!1;let F=R.match(/@unless\s*\(/);if(!F||F.index===void 0)break;let V=F.index,H=Lr(R,V+7);if(!H)break;let K=H.endPos,X=Jr(R,"unless","endunless",K);if(X===-1){console.warn(`[stx] @unless directive at position ${V} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let G=R.slice(K,X),te=H.expression,ce=-1;{let le=0,ue=/@(?:if|unless)\s*\(/g,de=/@(?:endif|endunless)(?![a-z])/g,fe=/@else(?![a-z])/g,pe=[],Ae;while((Ae=ue.exec(G))!==null)pe.push({pos:Ae.index,type:"open"});while((Ae=de.exec(G))!==null)pe.push({pos:Ae.index,type:"close"});while((Ae=fe.exec(G))!==null)pe.push({pos:Ae.index,type:"else"});pe.sort((Se,ve)=>Se.pos-ve.pos);for(let Se of pe)if(Se.type==="open")le++;else if(Se.type==="close")le--;else if(Se.type==="else"&&le===0){ce=Se.pos;break}}let ee;if(ce!==-1){let le=G.slice(0,ce),ue=G.slice(ce+5);ee=`@if (${te})${ue}@else ${le}@endif`}else ee=`@if (!(${te}))${G}@endif`;R=R.substring(0,V)+ee+R.substring(X+10),z=!0}}R=Ll(R,k,C),R=Bl(R,k,C),R=jl(R,k);let T=()=>{let z=mo(R);if(z.length===0)return!1;let F=Array(z.length);for(let K=z.length-1;K>=0;K--){let X=z[K];try{let G="",te=!1;for(let ce of X.branches){if(te)break;if(ce.type==="else")G=ce.content,te=!0;else try{if(ce.condition?Qi(ce.condition,k):!1)G=ce.content,te=!0}catch(ee){G=i(ce.type==="if"?"If":"Elseif",`Error in @${ce.type}(${ce.condition}): ${ee instanceof Error?ee.message:String(ee)}`,t.EVALUATION_ERROR),te=!0}}F[K]=G}catch(G){let te=G instanceof Error?G.message:String(G);F[K]=i("If",`Error processing @if block: ${te}`,t.EVALUATION_ERROR)}}let V=Array(z.length*2+1),H=0;for(let K=0;K<z.length;K++){let X=z[K];V[K*2]=R.slice(H,X.start),V[K*2+1]=F[K],H=X.end}return V[z.length*2]=R.slice(H),R=V.join(""),!0};while(!0){let z=R;if(!T())break;if(R===z)break}return R}function Np(v){let k=0;while(k<v.length&&/\s/.test(v[k]))k++;if(v[k]!=="(")return null;k++;while(k<v.length&&/\s/.test(v[k]))k++;let C=v[k];if(C!=="'"&&C!=='"')return null;k++;let R=[];while(k<v.length){let T=v[k];if(T==="\\"&&k+1<v.length){R.push(v[k+1]),k+=2;continue}if(T===C){k++;break}R.push(T),k++}while(k<v.length&&/\s/.test(v[k]))k++;if(v[k]!==")")return null;return k++,{value:R.join(""),consumed:k}}function jl(v,k){let C=v;function R(V,H,K,X){let G=1,te=X,ce=new RegExp(`@${H}(?:\\s*\\(|\\s|$)`,"g"),ee=new RegExp(`@${K}(?![a-z])`,"g");while(te<V.length&&G>0){ce.lastIndex=te,ee.lastIndex=te;let le=ce.exec(V),ue=ee.exec(V),de=le?le.index:1/0,fe=ue?ue.index:1/0;if(de<fe)G++,te=de+le[0].length;else if(fe<1/0){if(G--,G===0)return fe;te=fe+ue[0].length}else break}return-1}function T(V,H,K){let X=0,G=new RegExp(`@${H}(?:\\s*\\(|\\s|$)`,"g"),te=new RegExp(`@${K}(?![a-z])`,"g"),ce=/@else(?![a-z])/g,ee=[],le;while((le=G.exec(V))!==null)ee.push({pos:le.index,type:"open"});while((le=te.exec(V))!==null)ee.push({pos:le.index,type:"close"});while((le=ce.exec(V))!==null)ee.push({pos:le.index,type:"else"});ee.sort((ue,de)=>ue.pos-de.pos);for(let ue of ee)if(ue.type==="open")X++;else if(ue.type==="close")X--;else if(ue.type==="else"&&X===0)return ue.pos;return-1}{let V=!0;while(V){V=!1;let H=C.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!H||H.index===void 0)break;let K=H.index,X,G,te=C.slice(K+5),ce=Np(te);if(ce)X=ce.value,G=K+5+ce.consumed;else G=K+5;let ee=R(C,"auth","endauth",G);if(ee===-1){console.warn(`[stx] @auth directive at position ${K} has no matching @endauth \u2014 the block was skipped.`);break}let le=C.slice(G,ee),ue=T(le,"auth","endauth"),de;if(!k.auth)de=!1;else de=X?jr(`auth?.check && auth?.user?.[${X}]`,k):jr("auth?.check",k);let fe;if(ue!==-1){let pe=le.slice(0,ue),Ae=le.slice(ue+5);fe=de?pe:Ae}else fe=de?le:"";C=C.substring(0,K)+fe+C.substring(ee+8),V=!0}}{let V=!0;while(V){V=!1;let H=C.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!H||H.index===void 0)break;let K=H.index,X,G,te=C.slice(K+6),ce=Np(te);if(ce)X=ce.value,G=K+6+ce.consumed;else G=K+6;let ee=R(C,"guest","endguest",G);if(ee===-1){console.warn(`[stx] @guest directive at position ${K} has no matching @endguest \u2014 the block was skipped.`);break}let le=C.slice(G,ee),ue=T(le,"guest","endguest"),de;if(!k.auth)de=!0;else de=X?jr(`!auth?.check || !auth?.user?.[${X}]`,k):jr("!auth?.check",k);let fe;if(ue!==-1){let pe=le.slice(0,ue),Ae=le.slice(ue+5);fe=de?pe:Ae}else fe=de?le:"";C=C.substring(0,K)+fe+C.substring(ee+9),V=!0}}function z(V,H,K){if(k.userCan&&typeof k.userCan[V]==="boolean")return k.userCan[V];if(k.permissions?.check&&typeof k.permissions.check==="function")try{let X=[V];if(H)X.push(H);if(K){let G=jr(K,k);X.push(G)}return k.permissions.check(...X)}catch{return!1}return!1}function F(V){let H=V.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!H)return null;return{ability:H[1],type:H[2],id:H[3]?.trim(),paramsEnd:H[0].length}}for(let V of["can","cannot"]){let H=`end${V}`,K=V==="can"?"elsecan":"elsecannot",X=!0;while(X){X=!1;let G=C.match(new RegExp(`@${V}\\s*\\(`));if(!G||G.index===void 0)break;let te=G.index,ce=C.slice(te+`@${V}`.length),ee=F(ce);if(!ee)break;let le=te+`@${V}`.length+ee.paramsEnd,ue=R(C,V,H,le);if(ue===-1){console.warn(`[stx] @${V} directive at position ${te} has no matching @${H} \u2014 the block was skipped.`);break}let de=C.slice(le,ue),fe=[],pe=0,Ae=new RegExp(`@${V}\\s*\\(`,"g"),Se=new RegExp(`@${H}(?![a-z])`,"g"),ve=new RegExp(`@${K}\\s*\\(`,"g"),De=/@else(?![a-z])/g,Me=[],je;while((je=Ae.exec(de))!==null)Me.push({pos:je.index,type:"open"});while((je=Se.exec(de))!==null)Me.push({pos:je.index,type:"close"});while((je=ve.exec(de))!==null)Me.push({pos:je.index,type:"elseDirective"});while((je=De.exec(de))!==null)Me.push({pos:je.index,type:"else"});Me.sort((Ve,ze)=>Ve.pos-ze.pos);for(let Ve of Me){if(Ve.type==="open"){pe++;continue}if(Ve.type==="close"){pe--;continue}if(pe===0)fe.push(Ve)}let Le=[],Be=0;for(let Ve=0;Ve<fe.length;Ve++){let ze=fe[Ve];if(Le.push({content:de.slice(Be,ze.pos),ability:void 0}),ze.type==="elseDirective"){let He=de.slice(ze.pos+`@${K}`.length),wt=F(He);if(wt){Le[Le.length-1]={content:de.slice(Be,ze.pos)},Be=ze.pos+`@${K}`.length+wt.paramsEnd,Le.push({content:"",ability:wt.ability,type:wt.type,id:wt.id}),Le.pop();let vt=fe[Ve+1],Ct=vt?vt.pos:de.length;Le.push({content:de.slice(Be,Ct),ability:wt.ability,type:wt.type,id:wt.id}),Be=Ct}}else Be=ze.pos+5}if(Be<de.length){let Ve=Le[Le.length-1];if(fe.length>0&&fe[fe.length-1].type==="else")Le.push({content:de.slice(Be),isFinalElse:!0});else if(Le.length===0)Le.push({content:de.slice(Be)})}let Oe=z(ee.ability,ee.type,ee.id),We=V==="can"?Oe:!Oe,Fe="";if(We)Fe=Le[0]?.content||"";else{let Ve=!1;for(let ze=1;ze<Le.length;ze++){let He=Le[ze];if(He.isFinalElse){Fe=He.content,Ve=!0;break}if(He.ability){let wt=z(He.ability,He.type,He.id);if(V==="can"?wt:!wt){Fe=He.content,Ve=!0;break}}}if(!Ve&&Le.length>0){let ze=Le[Le.length-1];if(ze.isFinalElse)Fe=ze.content}}C=C.substring(0,te)+Fe+C.substring(ue+`@${H}`.length),X=!0}}return C}function Ll(v,k,C){let R=v;function T(z,F,V,H,K){let X=!0;while(X){X=!1;let G=new RegExp(`@${F}\\s*\\(`),te=z.match(G);if(!te||te.index===void 0)break;let ce=te.index,ee=Lr(z,ce+`@${F}`.length);if(!ee)break;let le=ee.endPos,ue=Jr(z,F,V,le);if(ue===-1){console.warn(`[stx] @${F} directive at position ${ce} has no matching @${V} \u2014 the block was skipped.`);break}let de=z.slice(le,ue),fe=ee.expression,pe=-1,Ae=0,Se=0;while(Se<de.length){let ve=de.indexOf("@",Se);if(ve===-1)break;let De=de.substring(ve);if(/^@(?:if|unless|isset|empty)\s*\(/.test(De)){Ae++,Se=ve+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(De)){Ae--,Se=ve+1;continue}if(Ae===0&&/^@else(?![a-z])/.test(De)){pe=ve;break}Se=ve+1}try{let ve=H(fe.trim()),De;if(pe!==-1){let Me=de.slice(0,pe),je=de.slice(pe+5);De=ve?Me:je}else De=ve?de:"";z=z.substring(0,ce)+De+z.substring(ue+`@${V}`.length),X=!0}catch(ve){let De=ve instanceof Error?ve.message:String(ve),Me=i(K,`Error processing @${F} directive: ${De}`,t.EVALUATION_ERROR);z=z.substring(0,ce)+Me+z.substring(ue+`@${V}`.length);break}}return z}return R=T(R,"isset","endisset",(z)=>{let F=jr(z,k);return F!==void 0&&F!==null},"Isset"),R=T(R,"empty","endempty",(z)=>{let F=jr(z,k);return F===void 0||F===null||F===""||F===0||F===!1||Array.isArray(F)&&F.length===0||typeof F==="object"&&F!==null&&Object.keys(F).length===0},"Empty"),R}function Bl(v,k,C){let R=v,T="development";function z(F,V,H,K){let X=new RegExp(`@${V}(?![a-z])`,"g"),G=new RegExp(`@${H}(?![a-z])`,"g"),te=new RegExp(`^@${V}(?![a-z])`),ce=new RegExp(`^@${H}(?![a-z])`),ee=F,le=!0;while(le){le=!1,X.lastIndex=0;let ue=X.exec(ee);if(!ue)break;let de=ue.index,fe=de+ue[0].length;if(V==="env"){let Oe=ee.substring(fe).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!Oe)break;fe+=Oe[0].length,K=T===Oe[2]}let pe=1,Ae=fe,Se=-1;while(pe>0&&Ae<ee.length){X.lastIndex=Ae,G.lastIndex=Ae;let Oe=X.exec(ee),We=G.exec(ee),Fe=Oe?Oe.index:1/0,Ve=We?We.index:1/0;if(Fe<Ve)pe++,Ae=Fe+Oe[0].length;else if(Ve<1/0){if(pe--,pe===0){Se=Ve;break}Ae=Ve+We[0].length}else break}if(Se===-1){console.warn(`[stx] @${V} directive at position ${de} has no matching @${H} \u2014 the block was skipped.`);break}let ve=ee.substring(fe,Se),De=-1,Me=0,je=0;while(je<ve.length){let Oe=ve.indexOf("@",je);if(Oe===-1)break;let We=ve.substring(Oe);if(te.test(We)){Me++,je=Oe+1;continue}if(ce.test(We)){Me--,je=Oe+1;continue}if(Me===0&&/^@else(?![a-z])/.test(We)){De=Oe;break}je=Oe+1}let Le;if(De!==-1){let Oe=ve.slice(0,De),We=ve.slice(De+5);Le=K?Oe:We}else Le=K?ve:"";let Be=`@${H}`.length;ee=ee.substring(0,de)+Le+ee.substring(Se+Be),le=!0}return ee}return R=z(R,"env","endenv",!1),R=z(R,"production","endproduction",T==="production"),R=z(R,"development","enddevelopment",T==="development"),R=z(R,"staging","endstaging",T==="staging"),R=z(R,"testing","endtesting",T==="testing"),R}var jp=new WeakMap;function Lp(v=16){let k=new Uint8Array(v);return crypto.getRandomValues(k),btoa(String.fromCharCode(...k))}function Ta(v,k){if(!v)return k?.nonceGenerator?.()??Lp();let C=jp.get(v);if(!C)C=k?.nonceGenerator?.()??Lp(),jp.set(v,C);return C}function Eb(v,k){let C=[];for(let[R,T]of Object.entries(v)){if(T===void 0||T===null)continue;if(typeof T==="boolean"){if(T)C.push(R);continue}if(Array.isArray(T)){let z=[...T];if(k&&(R==="script-src"||R==="style-src"))z=z.filter((F)=>!F.startsWith("'nonce-")),z.push(`'nonce-${k}'`);if(z.length>0)C.push(`${R} ${z.join(" ")}`)}}return C.join("; ")}function Bp(v,k){return`<meta http-equiv="Content-Security-Policy" content="${Eb(v,k).replace(/&/g,"&").replace(/"/g,""")}">`}function zp(v,k,C){if(!k.enabled||!k.addMetaTag)return v;if(v.includes('http-equiv="Content-Security-Policy"'))return v;if(!v.includes("<head>")&&!v.includes("<head "))return v;let R=k.useNonce?Ta(C,k):void 0,T=Bp(k.directives,R);return v.replace(/<head([^>]*)>/,`<head$1>
|
|
2294
|
+
${T}`)}function Wp(v,k){let C=v;return C=C.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(R,T)=>{if(T.includes("nonce="))return R;return`<script nonce="${k}"${T}>`}),C=C.replace(/<style([^>]*)>/gi,(R,T)=>{if(T.includes("nonce="))return R;return`<style nonce="${k}"${T}>`}),C}function Fp(v,k,C,R){let T=v,z=R.csp;if(T=T.replace(/@csp\b/g,()=>{if(!z?.enabled||!z.directives)return"<!-- CSP not configured -->";let F=z.useNonce?Ta(k,z):void 0;return Bp(z.directives,F)}),T=T.replace(/@cspNonce\b/g,()=>{if(!z?.enabled||!z.useNonce)return"";return Ta(k,z)}),z?.enabled&&z.useNonce)k.cspNonce=Ta(k,z);return T}import Cb from"crypto";var Rb=40,Vp="_token",zl=null;function Ab(v=Rb){let k=Cb.randomBytes(Math.ceil(v/2)).toString("hex").slice(0,v);return zl=k,k}function Tb(){if(!zl)Ab();return zl}function Ib(v=Vp){let k=Tb();return`<input type="hidden" name="${v}" value="${k}">`}function Up(v){return v.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(k,C,R)=>Ib(R||Vp))}async function Hp(v,k,C,R){if(!R.customDirectives||R.customDirectives.length===0)return v;let T=v;for(let z of R.customDirectives){if(!z.name||typeof z.handler!=="function"){if(R.debug)console.warn("Invalid custom directive:",z);continue}if(z.hasEndTag)T=await Pb(T,z,k,C,R);else T=await Db(T,z,k,C,R)}return T}async function Pb(v,k,C,R,T){let{name:z,handler:F}=k,V=`@${z}`,H=`@end${z}`,K=v,X=qr(`${V}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${H}`,"g"),G=[],te=X.exec(K);while(te!==null){let[ce,ee="",le=""]=te,ue=te.index||0;try{let de=ee?qp(k,ee):[],fe=le.trim(),pe=await F(fe,de,C,R);G.push({original:ce,processed:pe,startIndex:ue})}catch(de){let fe=de instanceof Error?de.message:String(de);if(T.debug)console.error(`Error processing custom directive @${z}:`,de);G.push({original:ce,processed:i("CustomDirective",`Error in @${z}${ee?`(${ee})`:""}: ${fe}`,t.EVALUATION_ERROR),startIndex:ue})}te=X.exec(K)}for(let ce=G.length-1;ce>=0;ce--){let{original:ee,processed:le}=G[ce];K=K.replace(ee,le)}return K}async function Db(v,k,C,R,T){let{name:z,handler:F}=k,V=v,H=[],K=[];if(k.rawParams){for(let te of Ys(V,qr(`(?<![\\w$@])@${z}\\s*\\(`,"g")))if(te.end!==-1)K.push({fullMatch:te.call,paramString:te.args,startIndex:te.start})}else{let te=qr(`@${z}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");te.lastIndex=0;let ce=te.exec(V);while(ce!==null)K.push({fullMatch:ce[0],paramString:ce[1]??"",startIndex:ce.index||0}),ce=te.exec(V)}for(let{fullMatch:te,paramString:ce,startIndex:ee}of K)try{let le=qp(k,ce),ue=await F("",le,C,R);H.push({original:te,processed:ue,startIndex:ee})}catch(le){let ue=le instanceof Error?le.message:String(le);if(T.debug)console.error(`Error processing custom directive @${z}:`,le);H.push({original:te,processed:i("CustomDirective",`Error in @${z}(${ce}): ${ue}`,t.EVALUATION_ERROR),startIndex:ee})}let X=qr(`@${z}(?!\\w)(?!\\s*\\()`,"g"),G=X.exec(V);while(G!==null){let[te]=G,ce=G.index||0;try{let ee=await F("",[],C,R);H.push({original:te,processed:ee,startIndex:ce})}catch(ee){let le=ee instanceof Error?ee.message:String(ee);if(T.debug)console.error(`Error processing custom directive @${z}:`,ee);H.push({original:te,processed:i("CustomDirective",`Error in @${z}: ${le}`,t.EVALUATION_ERROR),startIndex:ce})}G=X.exec(V)}for(let te=H.length-1;te>=0;te--){let{original:ce,processed:ee}=H[te];V=V.replace(ce,ee)}return V}function qp(v,k){return v.rawParams?ct(k):Ob(k)}function Ob(v){if(!v.trim())return[];let k=[],C="",R=!1,T="";for(let z=0;z<v.length;z++){let F=v[z];if((F==='"'||F==="'")&&(z===0||v[z-1]!=="\\"))if(!R)R=!0,T=F;else if(F===T)R=!1;else C+=F;else if(F===","&&!R)k.push(C.trim()),C="";else C+=F}if(C.trim())k.push(C.trim());return k.map((z)=>{let F=z.trim();if(F.startsWith('"')&&F.endsWith('"')||F.startsWith("'")&&F.endsWith("'"))return F.substring(1,F.length-1);return F})}var Kp=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Xp=/^[A-Za-z_$][\w$]*$/,Mb=new Set(["light","dark","system"]);function Yr(v,k){if(typeof v!=="string"||v.length===0)throw Error(`@appearanceBootstrap ${k} must be a non-empty string`)}function Nb(v){if(!v||typeof v!=="object"||Array.isArray(v))throw Error("@appearanceBootstrap expects an options object");let k=v,{appearance:C,colorMode:R}=k;if(Yr(k.storageKey,"storageKey"),C!==void 0&&(!C||typeof C!=="object"||Array.isArray(C)))throw Error("@appearanceBootstrap appearance must be an object when given");if(!R||typeof R!=="object"||Array.isArray(R))throw Error("@appearanceBootstrap colorMode must be an object");if(Yr(R.key,"colorMode.key"),Yr(R.attribute,"colorMode.attribute"),Yr(R.default,"colorMode.default"),!Xp.test(R.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Kp.test(R.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Mb.has(R.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let T=null;if(C){if(Yr(C.key,"appearance.key"),Yr(C.attribute,"appearance.attribute"),Yr(C.default,"appearance.default"),!Xp.test(C.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Kp.test(C.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(C.allowed)||C.allowed.length===0||C.allowed.some((z)=>typeof z!=="string"||z.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!C.allowed.includes(C.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");T={key:C.key,attribute:C.attribute,allowed:[...new Set(C.allowed)],default:C.default}}return{storageKey:k.storageKey,appearance:T,colorMode:{key:R.key,attribute:R.attribute,default:R.default},respectExisting:k.respectExisting===!0}}function jb(v){return JSON.stringify(v).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Lb(v){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${jb(v)};const root=document.documentElement;const MODES=["light","dark","system"];let format="json";const forced=(function(){const found={colorMode:null,appearance:null};if(!config.respectExisting)return found;try{const mode=root.getAttribute("data-"+config.colorMode.attribute);if(mode==="light"||mode==="dark")found.colorMode=mode;if(config.appearance){const name=root.getAttribute("data-"+config.appearance.attribute);if(config.appearance.allowed.includes(name))found.appearance=name}}catch{}return found}());function read(){let stored={};try{const raw=localStorage.getItem(config.storageKey);if(raw){let parsed=null;try{parsed=JSON.parse(raw)}catch{parsed=raw}if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed)){stored=parsed;format="json"}else if(typeof parsed==="string"&&MODES.includes(parsed)){stored={};stored[config.colorMode.key]=parsed;format="string"}}}catch{}return stored}function write(stored){try{if(format==="string"&&!config.appearance)localStorage.setItem(config.storageKey,stored[config.colorMode.key]);else localStorage.setItem(config.storageKey,JSON.stringify(stored))}catch{}}function resolve(){const stored=read();const state={colorMode:forced.colorMode||(MODES.includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default)};if(config.appearance)state.appearance=forced.appearance||(config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default);return state}function prefersDark(){try{return matchMedia("(prefers-color-scheme: dark)").matches}catch{return false}}function apply(){const state=resolve();const dark=state.colorMode==="dark"||(state.colorMode==="system"&&prefersDark());if(config.appearance)root.setAttribute("data-"+config.appearance.attribute,state.appearance);root.setAttribute("data-"+config.colorMode.attribute,state.colorMode);root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light";state.dark=dark;try{window.dispatchEvent(new CustomEvent("stx:appearance",{detail:state}))}catch{}return state}function store(key,allowed,value){if(allowed.includes(value)){const stored=read();stored[key]=value;write(stored)}return apply()}window.__stxAppearance={config:config,forced:forced,read:read,resolve:resolve,apply:apply,setColorMode:function(mode){return store(config.colorMode.key,MODES,mode)},setAppearance:function(name){return config.appearance?store(config.appearance.key,config.appearance.allowed,name):apply()},watchSystem:function(){try{matchMedia("(prefers-color-scheme: dark)").addEventListener("change",function(){if(resolve().colorMode==="system")apply()})}catch{}}};apply()}());</script>`}function Bb(v,k){let C=1,R=null,T=!1;for(let z=k+1;z<v.length;z++){let F=v[z];if(T){T=!1;continue}if(R){if(F==="\\")T=!0;else if(F===R)R=null;continue}if(F==='"'||F==="'"||F==="`"){R=F;continue}if(F==="(")C++;else if(F===")"&&--C===0)return z}return-1}function Zp(v,k){let C=v,R=/@appearanceBootstrap\s*\(/g,T;while((T=R.exec(C))!==null){let z=T.index+T[0].length-1,F=Bb(C,z);if(F===-1)throw Error("@appearanceBootstrap has an unclosed options object");let V=C.slice(z+1,F).trim(),H=l(`(${V})`,k),K=Lb(Nb(H));C=C.slice(0,T.index)+K+C.slice(F+1),R.lastIndex=T.index+K.length}return C}import zb from"crypto";function on(v){return String(v??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var Jp={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function Ia(v,k,C,R){let T=v||k;return C?`${T} ${R}`:T}function Nn(v){return String(v).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function Ws(v,k){if(/\bid\s*=/i.test(v))return"";return` id="${on(k)}"`}function Wl(v,k,C){if(!k)return"";let R="";if(!/\baria-invalid\s*=/i.test(C))R+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(C))R+=` aria-describedby="${on(`${Nn(v)}-error`)}"`;return R}function Wb(){return zb.randomUUID()}function Pa(v,k){let C=v;return C=C.replace(/@csrf/g,()=>{if(!k.csrf||typeof k.csrf!=="object"){let R=Wb();k.csrf={token:R}}if(k.csrf.field)return k.csrf.field;if(k.csrf.token)return`<input type="hidden" name="_token" value="${on(k.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),C=C.replace(/@method\(['"]([^'"]+)['"]\)/g,(R,T)=>{let z=T.toUpperCase();if(T&&!["GET","POST"].includes(z))return`<input type="hidden" name="_method" value="${on(z)}">`;return R}),C}function Yp(v,k,C=Jp){let R=v;return R=R.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(T,z,F,V,H,K="")=>{let X=z||F||"POST",G=V||H||"",te=Br(K),ce=X.toUpperCase(),ee=["GET","POST"].includes(ce)?ce:"POST",le=`<form method="${on(ee)}" action="${on(G)}"${te?` ${te}`:""}>`;if(le+=`
|
|
2295
|
+
${Pa("@csrf",k)}`,!["GET","POST"].includes(ce))le+=`
|
|
2296
|
+
${Pa(`@method('${ce}')`,k)}`;return le}),R=R.replace(/@endform/g,"</form>"),R=R.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(T,z,F,V,H,K="")=>{let X=z||F||"",G=V||H||"",te=Br(K),ce=ho(X,k),ee=ce!==void 0&&ce!==null?ce:G||"",le=te.match(/type=['"]([^'"]+)['"]/i),ue=le?le[1]:"text",de=yo(X,k),fe=te.match(/class=['"]([^'"]+)['"]/i),pe=Ia(fe?fe[1]:"",C.input,de,C.inputError),Ae=te.replace(/class=['"][^'"]+['"]/i,"");return Ae=Ae.replace(/type=['"][^'"]+['"]/i,""),`<input type="${on(ue)}" name="${on(X)}"${Ws(te,Nn(X))} value="${on(ee)}" class="${pe}"${Wl(X,de,te)}${Ae?` ${Ae}`:""}>`}),R=R.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(T,z,F="",V="")=>{let H=Br(F),K=ho(z,k)||V.trim(),X=yo(z,k),G=H.match(/class=['"]([^'"]+)['"]/i),te=Ia(G?G[1]:"",C.input,X,C.inputError),ce=H.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${on(z)}"${Ws(H,Nn(z))} class="${te}"${Wl(z,X,H)}${ce?` ${ce}`:""}>${on(K)}</textarea>`}),R=R.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(T,z,F="",V)=>{let H=Br(F),K=ho(z,k),X=yo(z,k),G=H.match(/class=['"]([^'"]+)['"]/i),te=Ia(G?G[1]:"",C.input,X,C.inputError),ce=H.replace(/class=['"][^'"]+['"]/i,""),ee=V;if(K!==void 0)ee=V.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(le,ue,de)=>{if((Array.isArray(K)?K.some((pe)=>String(pe)===de):String(K)===de)&&!ue.includes("selected"))return ue.replace(/(<option)/,"$1 selected");return le});return`<select name="${on(z)}"${Ws(H,Nn(z))} class="${te}"${Wl(z,X,H)}${ce?` ${ce}`:""}>${ee}</select>`}),R=R.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(T,z,F,V="")=>{let H=F===void 0?"1":F,K=F===void 0?Nn(z):`${Nn(z)}-${Nn(H)}`,X=Br(V),G=ho(z,k),te=G!==void 0&&(Array.isArray(G)?G.some((ue)=>String(ue)===H):G===!0||String(G)===H),ce=X.match(/class=['"]([^'"]+)['"]/i),ee=ce?ce[1]:C.checkInput,le=X.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${on(z)}"${Ws(X,K)} value="${on(H)}" class="${ee}"${te?" checked":""}${le?` ${le}`:""}>`}),R=R.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(T,z,F,V="")=>{let H=Br(V),K=ho(z,k),X=K!==void 0&&K===F,G=H.match(/class=['"]([^'"]+)['"]/i),te=G?G[1]:C.checkInput,ce=H.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${on(z)}"${Ws(H,`${Nn(z)}-${Nn(F)}`)} value="${on(F)}" class="${te}"${X?" checked":""}${ce?` ${ce}`:""}>`}),R=R.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(T,z,F="")=>{let V=Br(F),H=V.match(/accept=['"]([^'"]+)['"]/i),K=H?H[1]:"",X=V.includes("multiple"),G=yo(z,k),te=V.match(/class=['"]([^'"]+)['"]/i),ce=Ia(te?te[1]:"",C.input,G,C.inputError),ee=V.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),le=[`<input type="file" name="${on(z)}"${Ws(V,Nn(z))}`,`class="${ce}"`];if(K)le.push(`accept="${on(K)}"`);if(X)le.push("multiple");if(ee)le.push(ee);return`${le.join(" ")}>`}),R=R.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(T,z,F="",V)=>{let H=Br(F),K=H.match(/class=['"]([^'"]+)['"]/i),X=K?K[1]:C.label,G=H.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${on(Nn(z))}" class="${X}"${G?` ${G}`:""}>${V}</label>`}),R}function Qp(v,k,C=Jp){return v.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(R,T,z)=>{try{if(yo(T,k)){let F=z.replace(/\{\{([^}]+)\}\}/g,(V,H)=>{try{if(H.trim()==="$message"||H.trim()==="message")return Gp(T,k);if(H.trim().includes("errors.first")||H.trim().includes("$errors.first")){if(typeof k.errors?.first==="function")return k.errors.first(T);return Gp(T,k)}let K=H.trim();if(p(K)){let X=l(K,k);return X!==void 0?String(X):K}return K}catch{return H}});return`<div id="${on(`${Nn(T)}-error`)}" role="alert">${F}</div>`}return""}catch(F){return console.error("Error processing @error directive:",F),R}})}function yo(v,k){if(!k.errors)return!1;if(typeof k.errors.has==="function")return k.errors.has(v);if(typeof k.errors==="object")return Object.prototype.hasOwnProperty.call(k.errors,v);return!1}function Gp(v,k){if(!k.errors)return"";if(typeof k.errors.get==="function")return k.errors.get(v);if(typeof k.errors==="object"&&Object.prototype.hasOwnProperty.call(k.errors,v)){let C=k.errors[v];return Array.isArray(C)?C[0]:String(C)}return""}function ho(v,k){let C;if(k.old&&typeof k.old==="function")return k.old(v);if(k.old&&typeof k.old==="object")return k.old[v];if(v.endsWith("[]")){let R=v.slice(0,-2);if(C=k[R],C!==void 0)return C}return k[v]}function Br(v){if(!v.trim())return"";let k=[],C=v.trim(),R=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,T;while((T=R.exec(C))!==null){let[,z,,F]=T;k.push(`${z}="${F.trim()}"`)}return k.join(" ")}var Fl=m(256),Fb=[{pattern:/document\.getElementById\s*\(/g,message:"document.getElementById() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelector\s*\(/g,message:"document.querySelector() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelectorAll\s*\(/g,message:"document.querySelectorAll() is prohibited",suggestion:'Use useRef("name") and access children instead'},{pattern:/document\.getElementsBy\w+\s*\(/g,message:"document.getElementsBy*() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.createElement\s*\(/g,message:"document.createElement() is prohibited",suggestion:"Use template directives or component composition instead"},{pattern:/document\.activeElement(?![A-Za-z])/g,message:"document.activeElement is prohibited",suggestion:"Use useRef() to track focused elements"},{pattern:/document\.title\s*=/g,message:"document.title assignment is prohibited",suggestion:"Use useTitle() from composables"},{pattern:/document\.cookie(?![A-Za-z])/g,message:"document.cookie is prohibited",suggestion:"Use useCookie() from composables"},{pattern:/document\.addEventListener\s*\(/g,message:"document.addEventListener() is prohibited",suggestion:"Use useEventListener() or template @event directives"},{pattern:/window\.location(?![A-Za-z])/g,message:"window.location is prohibited",suggestion:"Use navigate() or useRoute()"},{pattern:/window\.history(?![A-Za-z])/g,message:"window.history is prohibited",suggestion:"Use navigate(), goBack(), goForward()"},{pattern:/window\.addEventListener\s*\(/g,message:"window.addEventListener() is prohibited",suggestion:"Use useEventListener() or @click directives"},{pattern:/(?:\bwindow\.)?localStorage(?![A-Za-z])/g,message:"window.localStorage is prohibited",suggestion:"Use useLocalStorage() from composables \u2014 or, where this must run before first paint and the runtime does not exist yet, the colorMode config for a light/dark theme, or @appearanceBootstrap when there is a second appearance axis"},{pattern:/window\.sessionStorage(?![A-Za-z])/g,message:"window.sessionStorage is prohibited",suggestion:"Use useSessionStorage() from composables"},{pattern:/window\.scrollTo\s*\(/g,message:"window.scrollTo() is prohibited",suggestion:"Use useScroll().scrollTo() from composables"},{pattern:/window\.alert\s*\(/g,message:"window.alert() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.confirm\s*\(/g,message:"window.confirm() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.prompt\s*\(/g,message:"window.prompt() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/(?<!\w)setTimeout\s*\(/g,message:"setTimeout() is prohibited",suggestion:"Use useTimeout() or useDebounce() from composables"},{pattern:/(?<!\w)setInterval\s*\(/g,message:"setInterval() is prohibited",suggestion:"Use useInterval() from composables"},{pattern:/(?<!\w)clearTimeout\s*\(/g,message:"clearTimeout() is prohibited",suggestion:"Use useTimeout().stop() or useDebounce().cancel()"},{pattern:/(?<!\w)clearInterval\s*\(/g,message:"clearInterval() is prohibited",suggestion:"Use useInterval().pause()"},{pattern:/(?<!\w)location\.href\s*=/g,message:"location.href assignment is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.assign\s*\(/g,message:"location.assign() is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.replace\s*\(/g,message:"location.replace() is prohibited",suggestion:"Use navigate() instead"}],eg=/(?:\/\/|\/\*|\{\{--)\s*stx-strict-ignore(-next-line)?([^\n*}]*)/g;function Vb(v){let k=Array.from(v,(T)=>T===`
|
|
2297
|
+
`?`
|
|
2298
|
+
`:" "),C=0,R="";while(C<v.length){let T=v[C],z=v[C+1];if(R){if(T==="\\"){C+=2;continue}if(T===R)R="";C++;continue}if(T==='"'||T==="'"||T==="`"){R=T,C++;continue}if(T==="/"&&z==="/"){while(C<v.length&&v[C]!==`
|
|
2299
|
+
`)k[C]=v[C],C++;continue}if(T==="/"&&z==="*"){let F=v.indexOf("*/",C+2),V=F===-1?v.length:F+2;for(;C<V;C++)k[C]=v[C];continue}if(T==="{"&&z==="{"&&v.slice(C,C+4)==="{{--"){let F=v.indexOf("--}}",C+4),V=F===-1?v.length:F+4;for(;C<V;C++)k[C]=v[C];continue}C++}return k.join("")}function Ub(v){let k=new Map,C=Vb(v).split(`
|
|
2300
|
+
`),R=v.split(`
|
|
2301
|
+
`);return C.forEach((T,z)=>{eg.lastIndex=0;for(let F of T.matchAll(eg)){let V=F[1]==="-next-line",H=(R[z]??"").slice(0,F.index).trim(),K=V||H===""?z+2:z+1,G=(F[2]??"").split("--")[0].split(/[\s,]+/).filter(Boolean),te=G.filter((ee)=>/\w/.test(ee));if(G.length>0&&te.length===0)continue;let ce=k.get(K);if(ce&&ce.size===0)continue;if(te.length===0){k.set(K,new Set);continue}if(ce)te.forEach((ee)=>ce.add(ee));else k.set(K,new Set(te))}}),k}function Hb(v,k,C){let R=v.get(k);if(!R)return!1;if(R.size===0)return!0;return[...R].some((T)=>C.includes(T))}function Qe(v,k,C,R){let T=typeof C==="boolean"?{enabled:C,failOnViolation:C}:C??{enabled:!1};if(!T.enabled)return;let z=h(v,k,R,JSON.stringify(T)),F=Fl.get(z);if(F!==void 0){if(F&&T.failOnViolation)throw new q(F,R??k);return}let V=T.allowPatterns??[],H=Ub(v),K=[],X=s(v.replace(/\{\{--[\s\S]*?--\}\}/g,(ee)=>ee.replace(/[^\n]/g," ")));for(let{pattern:ee,message:le,suggestion:ue}of Fb){if(V.some((fe)=>/\w/.test(fe)&&le.includes(fe)))continue;ee.lastIndex=0;let de=X.match(ee);if(de&&de.length>0){let fe=X.split(`
|
|
2302
|
+
`),pe=v.split(`
|
|
2303
|
+
`),Ae=[];if(fe.forEach((Me,je)=>{if(ee.lastIndex=0,ee.test(Me)&&!Hb(H,je+1,le))Ae.push(je+1)}),Ae.length===0&&fe.some((Me)=>(ee.lastIndex=0,ee.test(Me))))continue;let Se=Ae.length>0?` (script line${Ae.length>1?"s":""} ${Ae.join(", ")})`:"",ve=Ae.slice(0,3).map((Me)=>` ${Me} | ${(pe[Me-1]??"").trim().slice(0,100)}`).join(`
|
|
2304
|
+
`),De=ve?`
|
|
2305
|
+
${ve}`:"";K.push(` \u2717 ${le}${Se}
|
|
2306
|
+
\u2192 ${ue}${De}`)}}if(K.length===0){Fl.set(z,"");return}let G=(ee)=>{let le=`${process.cwd()}/`;return ee.startsWith(le)?ee.slice(le.length):ee},ce=`[STX] DOM API violation in ${R&&R!==k?`${G(R)} (composed into ${G(k)})`:G(k)}:
|
|
2307
|
+
${K.join(`
|
|
2308
|
+
`)}
|
|
2309
|
+
Tip: prefer useRef(), navigate(), and composables for component code`;if(Fl.set(z,ce),console.warn(ce),T.failOnViolation)throw new q(ce,R??k)}var xo=/<\/?template\b[^>]*>/gi,qb=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i;function Kb(v){let k=v.replace(/^<template\b/i,"").replace(/>$/,"");return qb.test(k)}function oe(v){xo.lastIndex=0;let k;while((k=xo.exec(v))!==null){if(k[0].startsWith("</")||Kb(k[0]))continue;let C=k.index,R=xo.lastIndex,T=1,z;while((z=xo.exec(v))!==null)if(z[0].startsWith("</")){if(T--,T===0){let F=z.index;return{start:C,openEnd:R,closeStart:F,end:xo.lastIndex,content:v.slice(R,F)}}}else T++;return null}return null}import Yt from"path";import{existsSync as yw}from"fs";class tg{builtins=new Map;registerBuiltin(v){this.builtins.set(v.name.toLowerCase(),v);for(let k of v.aliases)this.builtins.set(k.toLowerCase(),v)}isBuiltin(v){return this.builtins.has(v.toLowerCase())}getBuiltin(v){return this.builtins.get(v.toLowerCase())??null}async resolveFile(v,k,C,R){let T=pc(v,R);if(T!==void 0)return T;for(let z of gc(v,k,C,R))if(await r(z))return z;return null}}var Vs=new tg;function Gt(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var zr="\x00stx-boolean-attribute";function Vl(v){return v.indexOf("\x00")===-1?v:v.replace(/\0/g,"")}var Xb=new Set(["accesskey","autocapitalize","autofocus","class","contenteditable","dir","draggable","enterkeyhint","exportparts","hidden","id","inert","inputmode","is","itemid","itemprop","itemref","itemscope","itemtype","lang","nonce","part","role","slot","spellcheck","style","tabindex","title","translate","accept","action","alt","autocomplete","capture","cite","cols","colspan","content","controls","datetime","default","download","enctype","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","href","hreflang","kind","label","loading","loop","max","maxlength","media","method","min","minlength","multiple","muted","name","open","pattern","placeholder","playsinline","poster","preload","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","scope","selected","shape","size","span","src","srcdoc","srclang","srcset","start","step","target","type","usemap","value","width","wrap"]);function Ul(v){let k=v.toLowerCase();return k.startsWith("aria-")||k.startsWith("data-")||Xb.has(k)}function Wr(v,k){let C=[];for(let[R,T]of Object.entries(v.static)){if(k.has(R))continue;let z=v.staticNames?.[R]??R;if(typeof T==="boolean"){if(T)C.push(Gt(z));continue}if(T===zr){C.push(Gt(z));continue}C.push(`${Gt(z)}="${Gt(Vl(String(T)))}"`)}return C}function Fr(v,k){let C=[];for(let[R,T]of Object.entries(v.serverDynamic??{})){if(k.has(R))continue;if(T===null||T===void 0||T===!1)continue;let z=v.serverDynamicNames?.[R]??R;if(T===!0){C.push(Gt(z));continue}if(typeof T==="object")continue;C.push(`${Gt(z)}="${Gt(Vl(String(T)))}"`)}return C}function ei(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Zb(v){if(v.clientReactive.to)return{value:v.clientReactive.to,reactive:!0};if(v.serverDynamic.to!==void 0)return{value:String(v.serverDynamic.to),reactive:!1};if(typeof v.static.to==="string")return{value:v.static.to,reactive:!1};return{value:"#",reactive:!1}}var Hl={name:"StxLink",aliases:["stx-link"],render(v,k,C){let R=Zb(v),T=(typeof v.static.class==="string"?v.static.class:"")||(typeof v.static.className==="string"?v.static.className:""),z=typeof v.static.activeClass==="string"?v.static.activeClass:"active",F=typeof v.static.exactActiveClass==="string"?v.static.exactActiveClass:"exact-active",V=v.static.prefetch===!0||v.static.prefetch==="true"||v.serverDynamic.prefetch===!0,H=[];if(R.reactive)H.push(`:href="${ei(R.value)}"`);else H.push(`href="${ei(Vi(R.value,"navigable"))}"`);if(T)H.push(`class="${ei(T)}"`);if(H.push("data-stx-link"),H.push(`data-stx-active-class="${ei(z)}"`),H.push(`data-stx-exact-active-class="${ei(F)}"`),V)H.push("data-stx-prefetch");let K=typeof v.static.activeMatch==="string"?v.static.activeMatch.trim():"";if(K)H.push(`data-stx-active-match="${ei(K)}"`);let X=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return H.push(...Wr(v,X)),H.push(...Fr(v,X)),`<a ${H.join(" ")}>${k}</a>`}};import{createHash as gg}from"crypto";import mn from"fs";import un from"path";import{decode as rv,generateThumbHash as sv}from"ts-images";import{createImageDeliveryCatalog as ag}from"ts-images/delivery";import ql from"fs";function Da(v,k,C){let R=Buffer.alloc(C),T=ql.readSync(v,R,0,C,k);return R.subarray(0,T)}function Kl(v){if(v.length<25)return!1;let k=(R,T)=>String.fromCharCode(...v.subarray(R,T));if(k(0,4)!=="RIFF"||k(8,12)!=="WEBP")return!1;let C=k(12,16);if(C==="VP8X")return(v[20]&16)!==0;if(C==="VP8L")return((v[21]|v[22]<<8|v[23]<<16|v[24]<<24)>>>28&1)===1;return!1}function Xl(v){let k;try{k=ql.openSync(v,"r");let C=Da(k,0,33);if(C.length>=3&&C[0]===255&&C[1]===216&&C[2]===255)return"none";if(C.length>=26&&C[0]===137&&C.toString("latin1",1,4)==="PNG"){let R=C[25];if(R===4||R===6)return"possible";let T=8;for(let z=0;z<64;z++){let F=Da(k,T,8);if(F.length<8)return"unknown";let V=F.toString("latin1",4,8);if(V==="tRNS")return"possible";if(V==="IDAT"||V==="IEND")return"none";T+=12+F.readUInt32BE(0)}return"unknown"}if(C.length>=25&&C.toString("latin1",0,4)==="RIFF"&&C.toString("latin1",8,12)==="WEBP"){if(Kl(C))return"possible";let R=C.toString("latin1",12,16);return R==="VP8 "||R==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(k!==void 0)ql.closeSync(k)}}import Gb from"fs";import Oa from"os";import{join as ng}from"path";import{fileURLToPath as rg}from"url";import{Worker as sg}from"worker_threads";var Na=Symbol("stx.image-worker.unavailable");function Jb(v=typeof Oa.availableParallelism==="function"?Oa.availableParallelism():Oa.cpus().length){return Math.max(1,Math.min(2,v-1))}var Ma=0,og=[];async function Yb(){if(Ma<Jb()){Ma++;return}await new Promise((v)=>og.push(v)),Ma++}function Qb(){Ma--,og.shift()?.()}var ev="@stacksjs/stx/builtins/image-warmup-worker";function tv(v=process.cwd()){let k=import.meta.url.endsWith(".ts")?"ts":"js";try{let C=new URL(`./image-warmup-worker.${k}`,import.meta.url);if(C.protocol==="file:"&&Gb.existsSync(rg(C)))return rg(C)}catch{}try{let C=typeof Bun<"u"?Bun.resolveSync(ev,v):void 0;return C&&nv(C)?C:void 0}catch{return}}function nv(v,k=process.env){let C=v.replace(/\\/g,"/");if(C.split("/").some((T)=>/@\d[^/]*@@@\d+$/.test(T)))return!1;return![k.BUN_INSTALL_CACHE_DIR,ng(k.BUN_INSTALL||ng(Oa.homedir(),".bun"),"install","cache")].filter((T)=>!!T).map((T)=>`${T.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((T)=>C.startsWith(T))}var ig=!1;function bo(v){if(!ig)ig=!0,console.warn(`[stx] image worker unavailable (${v}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return Na}function Zl(v){return v instanceof Error?v.message:String(v)}async function Gl(v,k){if(typeof sg!=="function")return bo("node:worker_threads has no Worker in this runtime");let C=tv();if(!C)return bo("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Yb();try{return await new Promise((R,T)=>{let z;try{z=new sg(C)}catch(K){R(bo(`could not start ${C}: ${Zl(K)}`));return}let F=!1,V=!1,H=(K)=>{if(V)return;V=!0,K(),z.terminate()};z.on("message",(K)=>{if(K.type==="ready"){F=!0,z.postMessage({task:v,args:k});return}if(K.type==="result"){H(()=>R(K.value));return}let X=Error(K.error?.message??"image worker failed");if(K.error?.name)X.name=K.error.name;if(K.error?.stack)X.stack=K.error.stack;H(()=>T(X))}),z.on("error",(K)=>{H(()=>F?T(K instanceof Error?K:Error(Zl(K)||"image worker crashed")):R(bo(`the worker failed before it was ready: ${Zl(K)}`)))}),z.on("exit",(K)=>{H(()=>F?T(Error("image worker exited before it finished")):R(bo(`the worker exited with code ${K} before it was ready`)))})})}finally{Qb()}}var iv=new Set([".avif",".jpeg",".jpg",".png",".webp"]),ov=[320,640,960,1280,1920],vo="/_stx/images",av=`stx:${vo}:alpha-1`,cv=`stx:${vo}:opaque-1`,lv=["@stacksjs/ts-webp","@stacksjs/ts-avif","ts-images"],ja;function uv(v,k){let C=un.dirname(Bun.resolveSync(v,k));while(C!==un.dirname(C)){let R=un.join(C,"package.json");if(mn.existsSync(R)){let T=JSON.parse(mn.readFileSync(R,"utf8"));if(T.name===v)return T.version}C=un.dirname(C)}return}function cg(){if(ja!==void 0)return ja;let v;try{v=un.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return ja=lv.map((k)=>{let C;try{C=v?uv(k,v):void 0}catch{}return`${k.replace("@stacksjs/","")}@${C??"unknown"}`}).join("+"),ja}var lg=Symbol.for("stx.image-delivery");function wo(){let v=globalThis;return v[lg]??={catalog:new Map,transparent:new Set},v[lg]}var ug=new Set;function dv(v){return`/${v.split(un.sep).map(encodeURIComponent).join("/")}`}function fv(v){let k=un.extname(v),C=v.slice(0,-k.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),R=gg("sha256").update(v).digest("hex").slice(0,8);return`${C||"image"}-${R}`}function dg(v,k=`stx:${vo}`){let C=(R)=>`${vo}/${R.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:k,async stat(R){let T=un.join(v,R);try{let z=await mn.promises.stat(T);return z.size>0?{bytes:z.size,path:T,url:C(R)}:null}catch{return null}},async write(R,T){let z=un.join(v,R);await mn.promises.mkdir(un.dirname(z),{recursive:!0});let F=`${z}.${process.pid}.tmp`;return await mn.promises.writeFile(F,T),await mn.promises.rename(F,z),{bytes:T.byteLength,path:z,url:C(R)}},url:C}}async function mg(v,k=v){let C=await mn.promises.readdir(k,{withFileTypes:!0});C.sort((T,z)=>T.name.localeCompare(z.name));let R=[];for(let T of C){let z=un.join(k,T.name);if(T.isDirectory()){R.push(...await mg(v,z));continue}if(!T.isFile()||!iv.has(un.extname(T.name).toLowerCase()))continue;R.push({absolutePath:z,relativePath:un.relative(v,z)})}return R}function fg(v,k){return v.map((C)=>({key:dv(C.relativePath),input:C.absolutePath,name:fv(C.relativePath),...pv(C.absolutePath)?{options:{storage:k}}:{}}))}function pv(v){return Xl(v)==="possible"}function gv(v){for(let k=3;k<v.length;k+=4)if(v[k]!==255)return!0;return!1}async function mv(v){let k=Object.entries(v).filter(([,T])=>T.fallback.format==="png"),C=new Set,R=8;for(let T=0;T<k.length;T+=8)await Promise.all(k.slice(T,T+8).map(async([z,F])=>{let V=F.variants.filter((H)=>H.format==="png").sort((H,K)=>H.width-K.width)[0];try{let H=await rv(new Uint8Array(await mn.promises.readFile(V?.path??F.fallback.path)));if(gv(H.data))C.add(z)}catch{C.add(z)}}));return C}function hv(v,k){let C=[];for(let R of k){let T=v[R],z=T?.variants.filter((V)=>V.format==="webp")??[];if(!T||z.length===0)continue;if(!z.some((V)=>{let H;try{return H=mn.openSync(V.path,"r"),!Kl(Da(H,0,32))}catch{return!0}finally{if(H!==void 0)mn.closeSync(H)}}))continue;if(T.variants=T.variants.filter((V)=>V.format!=="webp"),delete T.sources.webp,C.push(R),!ug.has(R))ug.add(R),console.warn(`[stx-images] ${R} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return C}async function yv(v){let k=[],C=8;for(let R=0;R<v.length;R+=8){let T=v.slice(R,R+8),z=await Promise.all(T.map(async(F)=>{try{return await sv(F.absolutePath),F}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${F.relativePath}`),null}}));k.push(...z.filter((F)=>F!==null))}return k}function Jl(v){return un.join(v,"undecodable.json")}function xv(v){try{let k=mn.readFileSync(Jl(v),"utf-8"),C=JSON.parse(k);return C&&typeof C==="object"?C:{}}catch{return{}}}function bv(v,k){try{mn.mkdirSync(un.dirname(Jl(v)),{recursive:!0}),mn.writeFileSync(Jl(v),JSON.stringify(k))}catch{}}function pg(v){try{let k=mn.statSync(v);return{mtimeMs:k.mtimeMs,size:k.size}}catch{return}}function hg(v){if(!v||v.startsWith("data:")||v.startsWith("blob:")||/^https?:\/\//i.test(v)||v.startsWith("//"))return;let k=v.split(/[?#]/,1)[0];if(!k)return;try{return`/${k.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Ss(v){let k=hg(v);return k?wo().catalog.get(k):void 0}function ks(v){let k=hg(v);return k?wo().transparent.has(k):!1}function _s(v){let k=(R)=>v.variants.filter((T)=>T.format===R).reduce((T,z)=>T+z.bytes,0),C=k(v.fallback.format);return["avif","webp"].map((R)=>({format:R,srcset:v.sources[R]||"",bytes:k(R)})).filter((R)=>R.srcset&&R.bytes>0&&R.bytes<C).sort((R,T)=>R.bytes-T.bytes).map(({format:R,srcset:T})=>({format:R,srcset:T}))}function gd(v){let k=Ss(v);if(!k)return;return{src:k.fallback.url,srcset:k.sources[k.fallback.format]||"",sources:_s(k).map(({format:C,srcset:R})=>({type:`image/${C}`,srcset:R})),width:k.source.width,height:k.source.height,placeholder:ks(v)?void 0:k.placeholder?.dataUrl}}function ur(){let v=wo();v.catalog=new Map,v.transparent=new Set}function vv(v){let k=wo();k.catalog=new Map(v.entries),k.transparent=new Set(v.transparent)}async function md(v,k,C={}){if(!v||!mn.existsSync(v))return ur(),{count:0,fingerprint:""};if(C.offThread){let ee=await Gl("delivery",{publicDir:v,outputDir:k});if(ee!==Na)return vv(ee.state),ee.result}let R=await mg(v);if(R.length===0)return ur(),{count:0,fingerprint:""};let T=xv(k),z=R.filter((ee)=>{let le=T[ee.relativePath];if(!le)return!0;let ue=pg(ee.absolutePath);return!ue||ue.mtimeMs!==le.mtimeMs||ue.size!==le.size});if(z.length===0)return ur(),{count:0,fingerprint:""};let F=dg(un.join(k,"_stx","images"),`${av}:${cg()}`),V={outDir:un.join(k,"_stx","images"),storage:dg(un.join(k,"_stx","images"),`${cv}:${cg()}`),baseUrl:vo,widths:ov,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},H=z,K;try{K=await ag({...V,entries:fg(z,F)})}catch(ee){if(H=await yv(z),H.length===z.length)throw ee;let le=new Set(H.map((de)=>de.relativePath)),ue=!1;for(let de of z){if(le.has(de.relativePath))continue;let fe=pg(de.absolutePath);if(!fe)continue;T[de.relativePath]=fe,ue=!0}if(ue)bv(k,T);if(H.length===0)return ur(),{count:0,fingerprint:""};K=await ag({...V,entries:fg(H,F)})}let X=await mv(K.entries),G=hv(K.entries,X),te=wo();te.catalog=new Map(Object.entries(K.entries)),te.transparent=X;let ce=X.size===0&&G.length===0?K.fingerprint:gg("sha256").update(K.fingerprint).update(JSON.stringify({transparent:[...X].sort(),droppedWebp:G.sort()})).digest("hex");return{count:H.length,fingerprint:ce}}var wv=new Map;function Yl(v){if(!v)return;let k=v.split("?")[0].split("#")[0];return wv.get(k)}var Sv={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Ql=[320,640,768,1024,1280,1536,1920];function rn(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function sn(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let C=v.static[k];if(typeof C==="string")return C;return}function La(v,k,C=!1){let R=v.serverDynamic[k];if(R!==void 0)return R!==!1&&R!=="false";let T=v.static[k];if(T!==void 0)return T!=="false"&&T!==!1;return C}function eu(v){if(v.includes("(")||v.includes(","))return v;let k=v.trim().split(/\s+/),C=[];for(let R of k)if(R.includes(":")){let[T,z]=R.split(":"),F=Sv[T];if(F)C.push(`(max-width: ${F}px) ${z}`);else{let V=Number.parseInt(T);if(!Number.isNaN(V))C.push(`(max-width: ${V}px) ${z}`)}}else C.push(R);return C.join(", ")}function tu(v,k,C,R){return k.map((T)=>`${So(v,T,void 0,C,R)} ${T}w`).join(", ")}function $v(v,k,C,R,T){return k.map((z)=>{let F=C?C*z:void 0;return`${So(v,F,void 0,R,T)} ${z}x`}).join(", ")}function So(v,k,C,R,T){if(!R||R==="local"||R==="static")return v;if(R==="cloudinary"){let z=[];if(k)z.push(`w_${k}`);if(C)z.push(`h_${C}`);if(T)z.push(`f_${T}`);z.push("q_auto");let F=z.join(",");return v.replace("/upload/",`/upload/${F}/`)}if(R==="imgix"){let z=new URLSearchParams;if(k)z.set("w",String(k));if(C)z.set("h",String(C));if(T)z.set("fm",T);z.set("auto","format");let F=v.includes("?")?"&":"?";return`${v}${F}${z.toString()}`}if(R==="bunny"){let z=new URLSearchParams;if(k)z.set("width",String(k));if(C)z.set("height",String(C));if(T)z.set("format",T);let F=v.includes("?")?"&":"?";return`${v}${F}${z.toString()}`}return v}function _v(v){return`var s=this.style;${v.map((k)=>`s.${k}=''`).join(";")}`}function kv(v,k,C="#e5e7eb"){let R=`<svg xmlns="http://www.w3.org/2000/svg" width="${v}" height="${k}"><rect width="100%" height="100%" fill="${C}"/></svg>`;return`data:image/svg+xml;base64,${btoa(R)}`}var nu={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(v,k,C){let R=sn(v,"src")||"",T=Ss(R),z=sn(v,"alt")||"",F=sn(v,"width")||(T?String(T.source.width):void 0),V=sn(v,"height")||(T?String(T.source.height):void 0),H=sn(v,"sizes"),K=sn(v,"srcset"),X=sn(v,"densities"),G=sn(v,"format"),te=ks(R)||Yl(R)?.transparent===!0,ce=sn(v,"placeholder")||(T&&!te?"thumbhash":void 0),ee=sn(v,"placeholderColor")||"#e5e7eb",le=sn(v,"provider"),ue=sn(v,"class")||sn(v,"className")||"",de=sn(v,"style")||"",fe=sn(v,"objectFit")||sn(v,"fit"),pe=sn(v,"objectPosition")||sn(v,"position"),Ae=sn(v,"quality"),Se=La(v,"lazy",!0),ve=La(v,"preload",!1),De=La(v,"priority",!1),Me=sn(v,"loading"),je=sn(v,"decoding")||"async",Le=!!T||La(v,"picture",!1)||!!G,Be=F?Number.parseInt(F):void 0,Oe=V?Number.parseInt(V):void 0,We=K||"",Fe="";if(T)We=T.sources[T.fallback.format]||"",Fe=H?eu(H):"100vw";else if(!We&&H&&le&&le!=="local"&&le!=="static")We=tu(R,Ql,le,G),Fe=eu(H);else if(!We&&X){let xt=X.split(/\s+/).map((ft)=>Number.parseFloat(ft.replace("x","")));We=$v(R,xt,Be,le,G)}else if(H)Fe=eu(H);let Ve=[];if(de)Ve.push(de);if(fe)Ve.push(`object-fit:${fe}`);if(pe)Ve.push(`object-position:${pe}`);if(Be&&Oe)Ve.push(`aspect-ratio:${Be}/${Oe}`);let ze=[],He=ce==="blur"||ce==="color"||ce==="thumbhash";if(He&&!te){let xt=T?.placeholder?{dataUrl:T.placeholder.dataUrl,color:ee}:Yl(R);if(xt&&ce==="color")Ve.push(`background-color:${xt.color}`),ze.push("backgroundColor");else if(xt)Ve.push(`background-color:${xt.color}`),Ve.push(`background-image:url(${xt.dataUrl})`),Ve.push("background-size:cover"),Ve.push("background-repeat:no-repeat"),ze.push("backgroundColor","backgroundImage");else{let ft=kv(Be||16,Oe||9,ee);Ve.push(`background-image:url(${ft})`),Ve.push("background-size:cover"),Ve.push("background-repeat:no-repeat"),ze.push("backgroundImage")}}else if(!He&&ce&&ce!=="empty"&&ce!=="none")Ve.push(`background-image:url(${rn(ce)})`),Ve.push("background-size:cover"),Ve.push("background-repeat:no-repeat"),ze.push("backgroundImage");let wt=T?.fallback.url||So(R,Be,Oe,le,G),vt=[];if(vt.push(`src="${rn(Vi(wt,"fetched"))}"`),vt.push(`alt="${rn(z)}"`),F)vt.push(`width="${rn(F)}"`);if(V)vt.push(`height="${rn(V)}"`);let Ct=Me||(De||ve?"eager":Se?"lazy":"");if(Ct)vt.push(`loading="${rn(Ct)}"`);if(De)vt.push('fetchpriority="high"');if(vt.push(`decoding="${rn(je)}"`),ue)vt.push(`class="${rn(ue)}"`);if(Ve.length>0)vt.push(`style="${rn(Ve.join(";"))}"`);if(We)vt.push(`srcset="${rn(Vi(We,"fetched"))}"`);if(Fe)vt.push(`sizes="${rn(Fe)}"`);let pt=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","objectFit","objectPosition","fit","position","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(ze.length>0){let xt=typeof v.static.onload==="string"?v.static.onload:"",ft=_v(ze)+(xt?`;${xt}`:"");vt.push(`onload="${rn(ft)}"`),pt.add("onload")}vt.push(...Wr(v,pt)),vt.push(...Fr(v,pt));let St=`<img ${vt.join(" ")} />`,Rt="";if(ve){let ft=G==="webp"?"image/webp":G==="avif"?"image/avif":"";Rt=`<link rel="preload" as="image" href="${rn(wt)}"${ft?` type="${ft}"`:""}${We?` imagesrcset="${rn(We)}"`:""}${Fe?` imagesizes="${rn(Fe)}"`:""} />
|
|
2310
|
+
`}if(Le){let xt=[];if(T)for(let ft of _s(T))xt.push(`<source type="image/${ft.format}" srcset="${rn(ft.srcset)}"${Fe?` sizes="${rn(Fe)}"`:""} />`);if(!T&&(G==="avif"||G==="auto")){let ft=So(R,Be,Oe,le,"avif"),_t=We?tu(R,Ql,le,"avif"):`${ft}`;xt.push(`<source type="image/avif" srcset="${rn(_t)}"${Fe?` sizes="${rn(Fe)}"`:""} />`)}if(!T&&(G==="webp"||G==="auto")){let ft=So(R,Be,Oe,le,"webp"),_t=We?tu(R,Ql,le,"webp"):`${ft}`;xt.push(`<source type="image/webp" srcset="${rn(_t)}"${Fe?` sizes="${rn(Fe)}"`:""} />`)}return`${Rt}<picture>
|
|
2311
|
+
${xt.join(`
|
|
2312
|
+
`)}
|
|
2313
|
+
${St}
|
|
2314
|
+
</picture>`}return`${Rt}${St}`}};var yg="/images/safe-image-default.svg";function $o(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function ti(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let C=v.static[k];if(typeof C==="string")return C;return}var Ev=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${yg}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,ru={name:"SafeImage",aliases:["safe-image","safe-img"],render(v,k,C){let R=ti(v,"src")||"",T=ti(v,"alt")||"",z=ti(v,"fallback")||yg,F=ti(v,"class")||ti(v,"className")||"",V=ti(v,"fallbackClassName")||"",H=[];if(H.push(`src="${$o(R)}"`),H.push(`alt="${$o(T)}"`),F)H.push(`class="${$o(F)}"`);if(H.push(`data-fallback="${$o(z)}"`),V)H.push(`data-fallback-class="${$o(V)}"`);H.push('onerror="window.__stxSafeImageHandler(this)"');let K=new Set(["src","alt","fallback","class","className","fallbackClassName"]);H.push(...Wr(v,K)),H.push(...Fr(v,K));let X=`<img ${H.join(" ")} />`,G=C.context;if(!G.__safeImageHandlerEmitted)return G.__safeImageHandlerEmitted=!0,`${Ev}${X}`;return X}};function su(v){return v.replace(/[;{}()]/g,"").replace(/url/gi,"")}function _o(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let C=v.static[k];if(typeof C==="string")return C;return}function Ba(v,k,C){let R=_o(v,k);if(R!==void 0){let T=Number.parseInt(R,10);if(!Number.isNaN(T))return T}return C}var iu={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(v,k,C){let R=su(_o(v,"color")||"#6366f1"),T=su(_o(v,"initialColor")||_o(v,"initial-color")||""),z=su(_o(v,"height")||"3px"),F=Ba(v,"duration",2000),V=Ba(v,"throttle",200),H=Ba(v,"zIndex",999999)||Ba(v,"z-index",999999),K=T?`linear-gradient(to right, ${T}, ${R})`:R;return`
|
|
2315
|
+
<div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${z};background:${K};z-index:${H};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
|
|
2316
|
+
<div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
|
|
2317
|
+
</div>
|
|
2318
|
+
<style>@keyframes stx-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}</style>
|
|
2319
|
+
<script>
|
|
2320
|
+
(function(){var el=document.getElementById('stx-loading-indicator'),p=0,l=!1,i=null;function u(v){p=Math.min(Math.max(v,0),100);if(el){el.style.opacity=p>0?'1':'0';el.style.transform='scaleX('+(p/100)+')'}}window.stxLoading={start:function(){l=!0;p=0;u(10);if(i)clearInterval(i);i=setInterval(function(){if(!l)return;var r=90-p,inc=Math.max(0.5,r*0.1);if(p<90)u(p+inc)},${V})},finish:function(){l=!1;if(i){clearInterval(i);i=null}u(100);setTimeout(function(){if(el)el.style.opacity='0';setTimeout(function(){p=0;if(el)el.style.transform='scaleX(0)'},300)},200)},set:function(v){u(v)},clear:function(){l=!1;p=0;if(i){clearInterval(i);i=null}if(el){el.style.opacity='0';el.style.transform='scaleX(0)'}}};document.addEventListener('click',function(e){var a=e.target.closest&&e.target.closest('a');if(!a)return;var h=a.getAttribute('href');if(!h||h.startsWith('http')||h.startsWith('#')||h.startsWith('mailto:')||h.startsWith('tel:')||a.target==='_blank')return;window.stxLoading.start()});window.addEventListener('popstate',function(){window.stxLoading.start()});window.addEventListener('load',function(){window.stxLoading.finish()})})();
|
|
2321
|
+
</script>`}};function bg(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let C=v.static[k];if(typeof C==="string")return C;return}function Cv(v,k,C){let R=bg(v,k);if(R!==void 0){let T=Number.parseInt(R,10);if(!Number.isNaN(T))return T}return C}var xg={"top-right":"top:1rem;right:1rem","top-left":"top:1rem;left:1rem","top-center":"top:1rem;left:50%;transform:translateX(-50%)","bottom-right":"bottom:1rem;right:1rem","bottom-left":"bottom:1rem;left:1rem","bottom-center":"bottom:1rem;left:50%;transform:translateX(-50%)"},ou={name:"StxToast",aliases:["stx-toast"],render(v,k,C){let R=Gt(bg(v,"position")||"top-right"),T=Cv(v,"max",5),z=xg[R]||xg["top-right"];return`<div id="stx-toast-container" data-stx-toast-position="${R}" data-stx-toast-max="${T}" style="position:fixed;${z};z-index:999999;display:flex;flex-direction:column;gap:0.5rem;pointer-events:none;max-width:24rem;width:100%"></div>
|
|
2322
|
+
<style>
|
|
2323
|
+
@keyframes stx-toast-in{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}
|
|
2324
|
+
@keyframes stx-toast-out{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(100%)}}
|
|
2325
|
+
@keyframes stx-toast-in-left{from{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}
|
|
2326
|
+
@keyframes stx-toast-out-left{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(-100%)}}
|
|
2327
|
+
@keyframes stx-toast-in-center{from{opacity:0;transform:translateY(-1rem)}to{opacity:1;transform:translateY(0)}}
|
|
2328
|
+
@keyframes stx-toast-out-center{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-1rem)}}
|
|
2329
|
+
</style>`}};function za(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let C=v.static[k];if(typeof C==="string")return C;return}var vg={sm:"max-width:24rem",md:"max-width:32rem",lg:"max-width:42rem",xl:"max-width:56rem",full:"max-width:calc(100vw - 2rem);max-height:calc(100vh - 2rem)"},au={name:"StxModal",aliases:["stx-modal"],render(v,k,C){let R=za(v,"id");if(!R)return console.warn('[stx] <StxModal> requires an "id" prop'),"<!-- StxModal: missing id prop -->";let T=Gt(R),z=za(v,"size")||"md",F=za(v,"closeOnBackdrop")!=="false",V=za(v,"closeOnEscape")!=="false",H=vg[z]||vg.md;return`<div id="stx-modal-${T}" class="stx-modal-backdrop" data-stx-modal="${T}" data-close-backdrop="${F}" data-close-escape="${V}" style="display:none;position:fixed;inset:0;z-index:99999;align-items:center;justify-content:center;background:rgba(0,0,0,0.5);backdrop-filter:blur(2px);opacity:0;transition:opacity 0.2s ease" aria-modal="true" role="dialog">
|
|
2330
|
+
<div class="stx-modal-panel" style="${H};width:100%;margin:1rem;border-radius:0.75rem;box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow:hidden;transform:scale(0.95) translateY(8px);transition:transform 0.2s ease,opacity 0.2s ease;opacity:0;background:var(--stx-modal-bg,#fff);color:var(--stx-modal-text,#1f2937)">
|
|
2331
|
+
<div style="padding:1.5rem">${k}</div>
|
|
2332
|
+
</div>
|
|
2333
|
+
</div>
|
|
2334
|
+
<style>
|
|
2335
|
+
@media(prefers-color-scheme:dark){[data-stx-modal]{--stx-modal-bg:#1f2937;--stx-modal-text:#f3f4f6}}
|
|
2336
|
+
.stx-modal-backdrop[data-stx-modal-open]{display:flex!important;opacity:1}
|
|
2337
|
+
.stx-modal-backdrop[data-stx-modal-open] .stx-modal-panel{transform:scale(1) translateY(0);opacity:1}
|
|
2338
|
+
</style>`}};function ni(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let C=v.static[k];if(typeof C==="string")return C;return}var wg={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},cu={name:"StxDrawer",aliases:["stx-drawer"],render(v,k,C){let R=ni(v,"id");if(!R)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let T=Gt(R),z=ni(v,"side")||"right",F=ni(v,"size")||"md",V=ni(v,"closeOnBackdrop")!=="false",H=ni(v,"closeOnEscape")!=="false",K=ni(v,"overlay")!=="false",X=wg[F]||wg.md,G=z==="left",te=G?"left:0":"right:0",ce=G?"translateX(-100%)":"translateX(100%)",ee=G?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${T}" class="stx-drawer-backdrop" data-stx-drawer="${T}" data-close-backdrop="${V}" data-close-escape="${H}" style="display:none;position:fixed;inset:0;z-index:99999;${K?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
|
|
2339
|
+
<div class="stx-drawer-panel" style="position:fixed;top:0;bottom:0;${te};width:${X};max-width:100vw;transform:${ce};transition:transform 0.3s cubic-bezier(0.4,0,0.2,1);background:var(--stx-drawer-bg,#fff);color:var(--stx-drawer-text,#1f2937);box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow-y:auto;pointer-events:auto">
|
|
2340
|
+
<div style="padding:1.5rem">${k}</div>
|
|
2341
|
+
</div>
|
|
2342
|
+
</div>
|
|
2343
|
+
<style>
|
|
2344
|
+
@media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
|
|
2345
|
+
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
2346
|
+
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
2347
|
+
</style>`}};import{existsSync as Rv,readFileSync as Av}from"fs";var Wa=new Map,Sg=new Set;function Tv(v){if(Sg.has(v))return;Sg.add(v),console.warn(`[stx] icon collection "${v}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${v}\`.`)}function Iv(v){let k=process.cwd();for(let C of[`${k}/node_modules/@iconify-json/${v}/icons.json`,`${k}/pantry/@iconify-json/${v}/icons.json`,`${k}/node_modules/@iconify/json/json/${v}.json`,`${k}/pantry/@iconify/json/json/${v}.json`])if(Rv(C))return C;for(let C of[`@iconify-json/${v}/icons.json`,`@iconify/json/json/${v}.json`])try{return d.resolve(C)}catch{}return null}function Pv(v){if(Wa.has(v))return Wa.get(v);let k=Iv(v);if(!k)return Tv(v),null;try{let C=JSON.parse(Av(k,"utf8"));return Wa.set(v,C.icons),C.icons}catch{return null}}function ri(v,k){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);if(v.static[k]!==void 0)return String(v.static[k]);if(v.clientReactive[k]!==void 0)return v.clientReactive[k];return}var lu={name:"Icon",aliases:["icon","stx-icon"],render(v,k,C){let R=ri(v,"name")??ri(v,"icon");if(!R)return"<!-- Icon: missing name/icon prop -->";let T="lucide",z=R;if(R.includes(":")){let fe=R.split(":");T=fe[0],z=fe[1]}let F=Gt(ri(v,"size")||"24"),V=Gt(ri(v,"color")||"currentColor"),H=Gt(ri(v,"class")||""),K=Gt(ri(v,"style")||""),X=Wa.get(T)??Pv(T);if(!X)return`<!-- Icon: collection "${T}" not loaded -->`;let G=X[z];if(!G)return`<!-- Icon: "${z}" not found in ${T} -->`;let te=G.width||24,ce=G.height||24,ee=`0 0 ${te} ${ce}`,le=G.body;if(V!=="currentColor")le=le.replace(/currentColor/g,V);let ue=H?` class="${H}"`:"",de=K?` style="${K}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${F}" height="${F}" viewBox="${ee}" fill="none"${ue}${de}>${le}</svg>`}};function uu(){return`
|
|
2348
|
+
(function(){
|
|
2349
|
+
var tip=null,hideTimer=null,currentEl=null;
|
|
2350
|
+
|
|
2351
|
+
function createTip(){
|
|
2352
|
+
tip=document.createElement("div");
|
|
2353
|
+
tip.id="stx-tooltip";
|
|
2354
|
+
tip.style.cssText="position:absolute;background:#1f2937;color:#fff;font-size:12px;line-height:1.4;padding:6px 10px;border-radius:6px;max-width:250px;z-index:999999;pointer-events:none;opacity:0;transition:opacity .15s ease;white-space:pre-wrap;word-wrap:break-word;box-shadow:0 2px 8px rgba(0,0,0,.25)";
|
|
2355
|
+
var arrow=document.createElement("div");
|
|
2356
|
+
arrow.className="stx-tip-arrow";
|
|
2357
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent";
|
|
2358
|
+
tip.appendChild(arrow);
|
|
2359
|
+
var text=document.createElement("span");
|
|
2360
|
+
text.className="stx-tip-text";
|
|
2361
|
+
tip.appendChild(text);
|
|
2362
|
+
document.body.appendChild(tip);
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
function position(el){
|
|
2366
|
+
var pos=el.getAttribute("x-tooltip-position")||"top";
|
|
2367
|
+
var r=el.getBoundingClientRect();
|
|
2368
|
+
var sy=window.scrollY,sx=window.scrollX;
|
|
2369
|
+
tip.style.display="block";
|
|
2370
|
+
tip.style.opacity="0";
|
|
2371
|
+
// Force layout so we can measure
|
|
2372
|
+
var tw=tip.offsetWidth,th=tip.offsetHeight;
|
|
2373
|
+
var arrow=tip.querySelector(".stx-tip-arrow");
|
|
2374
|
+
var left,top;
|
|
2375
|
+
|
|
2376
|
+
if(pos==="top"){
|
|
2377
|
+
left=r.left+r.width/2-tw/2+sx;
|
|
2378
|
+
top=r.top-th-8+sy;
|
|
2379
|
+
if(top-sy<0){pos="bottom";}
|
|
2380
|
+
}
|
|
2381
|
+
if(pos==="bottom"){
|
|
2382
|
+
left=r.left+r.width/2-tw/2+sx;
|
|
2383
|
+
top=r.bottom+8+sy;
|
|
2384
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-bottom-color:#1f2937;top:-10px;left:50%;transform:translateX(-50%)";
|
|
2385
|
+
}
|
|
2386
|
+
if(pos==="left"){
|
|
2387
|
+
left=r.left-tw-8+sx;
|
|
2388
|
+
top=r.top+r.height/2-th/2+sy;
|
|
2389
|
+
if(left-sx<0){pos="right";}
|
|
2390
|
+
}
|
|
2391
|
+
if(pos==="right"){
|
|
2392
|
+
left=r.right+8+sx;
|
|
2393
|
+
top=r.top+r.height/2-th/2+sy;
|
|
2394
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-right-color:#1f2937;left:-10px;top:50%;transform:translateY(-50%)";
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
// Set arrow for top/left after potential flips
|
|
2398
|
+
if(pos==="top"){
|
|
2399
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-top-color:#1f2937;bottom:-10px;left:50%;transform:translateX(-50%)";
|
|
2400
|
+
}
|
|
2401
|
+
if(pos==="left"){
|
|
2402
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-left-color:#1f2937;right:-10px;top:50%;transform:translateY(-50%)";
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
// Clamp horizontal
|
|
2406
|
+
if(left<sx+4) left=sx+4;
|
|
2407
|
+
if(left+tw>sx+window.innerWidth-4) left=sx+window.innerWidth-tw-4;
|
|
2408
|
+
|
|
2409
|
+
tip.style.left=left+"px";
|
|
2410
|
+
tip.style.top=top+"px";
|
|
2411
|
+
tip.style.opacity="1";
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
function showTip(el){
|
|
2415
|
+
if(hideTimer){clearTimeout(hideTimer);hideTimer=null;}
|
|
2416
|
+
if(!tip) createTip();
|
|
2417
|
+
var text=el.getAttribute("x-tooltip");
|
|
2418
|
+
if(!text) return;
|
|
2419
|
+
tip.querySelector(".stx-tip-text").textContent=text;
|
|
2420
|
+
currentEl=el;
|
|
2421
|
+
position(el);
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
function hideTip(){
|
|
2425
|
+
if(!tip) return;
|
|
2426
|
+
tip.style.opacity="0";
|
|
2427
|
+
hideTimer=setTimeout(function(){
|
|
2428
|
+
if(tip) tip.style.display="none";
|
|
2429
|
+
currentEl=null;
|
|
2430
|
+
},150);
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
document.addEventListener("mouseover",function(e){
|
|
2434
|
+
var el=e.target.closest("[x-tooltip]");
|
|
2435
|
+
if(el) showTip(el);
|
|
2436
|
+
});
|
|
2437
|
+
document.addEventListener("mouseout",function(e){
|
|
2438
|
+
var el=e.target.closest("[x-tooltip]");
|
|
2439
|
+
if(el&&el===currentEl) hideTip();
|
|
2440
|
+
});
|
|
2441
|
+
document.addEventListener("focusin",function(e){
|
|
2442
|
+
var el=e.target.closest("[x-tooltip]");
|
|
2443
|
+
if(el) showTip(el);
|
|
2444
|
+
});
|
|
2445
|
+
document.addEventListener("focusout",function(e){
|
|
2446
|
+
var el=e.target.closest("[x-tooltip]");
|
|
2447
|
+
if(el) hideTip();
|
|
2448
|
+
});
|
|
2449
|
+
})();
|
|
2450
|
+
`}function $g(v,...k){for(let C of k){if(v.serverDynamic[C]!==void 0)return String(v.serverDynamic[C]);let R=v.static[C];if(typeof R==="string")return R}return}function _g(v,k){let C=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${k}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),R=v.match(C);if(!R)return{region:null,rest:v};return{region:R[2],rest:v.replace(R[0],"")}}var du={name:"Suspense",aliases:["suspense"],render(v,k,C){let R=_g(k,"fallback"),T=R.rest,z=_g(T,"error"),F=z.rest,V=R.region??$g(v,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',H=z.region??$g(v,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${V}</div><div data-stx-suspense-error hidden>${H}</div><div data-stx-suspense-content hidden>${F}</div></div>`}};function Fa(v,...k){for(let C of k){if(v.serverDynamic[C]!==void 0)return String(v.serverDynamic[C]);let R=v.static[C];if(typeof R==="string")return R}return}var fu={name:"TransitionGroup",aliases:["transition-group"],render(v,k,C){let R=(Fa(v,"name")||"v").replace(/["'<>]/g,""),T=(Fa(v,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",z=Fa(v,"class"),F=Fa(v,"id"),V=[`data-stx-transition-group="${R}"`,z?`class="${z}"`:"",F?`id="${F}"`:""].filter(Boolean).join(" ");return`<${T} ${V}>${k}</${T}>`}};function kg(v=Vs){v.registerBuiltin(Hl),v.registerBuiltin(nu),v.registerBuiltin(ru),v.registerBuiltin(iu),v.registerBuiltin(ou),v.registerBuiltin(au),v.registerBuiltin(cu),v.registerBuiltin(lu),v.registerBuiltin(du),v.registerBuiltin(fu)}var Eg=new Map;function Dv(v){let k=Eg.get(v.source);if(!k)k=new RegExp(`(${v.source})(?![\\w.:-])`,"y"),Eg.set(v.source,k);return k}var Cg=new WeakMap;function Rg(v){let k=Cg.get(v);if(!k)k=new Set([...v].map((R)=>R.toLowerCase())),Cg.set(v,k);let C=k;return(R)=>!/[a-z]/.test(R)&&C.has(R.toLowerCase())}function Ov(v,k){let C="";for(let R=k;R<v.length;R++){let T=v[R];if(C){if(T==="\\")R++;else if(T===C)C=""}else if(T==='"'||T==="'")C=T;else if(T===">")return R}return v.length}function Ag(v,k,C){let R=[],T=0,z=typeof C==="function"?C:C?(F)=>C.has(F.toLowerCase()):void 0;while(T<v.length){let F=v.indexOf("<",T);if(F===-1)break;let V=Dv(k);V.lastIndex=F+1;let H=V.exec(v);if(!H){T=F+1;continue}let K=H[1];if(z&&z(K)){let ue=F+1+K.length;while(ue<v.length&&v[ue]!==">")ue++;T=ue+1;continue}let X=F+1+K.length,G=null,te=X,ce=-1,ee=!1;while(X<v.length){let ue=v[X];if(G){if(ue==="\\"&&X+1<v.length){X+=2;continue}if(ue===G)G=null;X++;continue}if(ue==='"'||ue==="'"){G=ue,X++;continue}if(ue==="/"&&X+1<v.length&&v[X+1]===">"){ce=X+2,ee=!0;break}if(ue===">"){ce=X+1;break}X++}if(ce===-1){T=F+1;continue}let le=v.slice(te,ee?ce-2:ce-1).trim();if(ee)R.push({fullMatch:v.slice(F,ce),tagName:K,attributes:le,content:"",startIndex:F,endIndex:ce,isSelfClosing:!0}),T=ce;else{let ue=`<${K}`,de=`</${K}>`,fe=1,pe=ce,Ae=-1;while(fe>0&&pe<v.length){let De=v.indexOf(ue,pe),Me=v.indexOf(de,pe);if(Me===-1)break;if(De!==-1&&De<Me){let je=v[De+ue.length];if(je===" "||je===">"||je==="/"||je===`
|
|
2451
|
+
`||je==="\t"){let Le=Ov(v,De+ue.length);if(v[Le-1]!=="/")fe++;pe=Le+1}else pe=De+ue.length}else{if(fe--,fe===0){Ae=Me;break}pe=Me+de.length}}if(Ae===-1){T=ce;continue}let Se=v.slice(ce,Ae),ve=Ae+de.length;R.push({fullMatch:v.slice(F,ve),tagName:K,attributes:le,content:Se,startIndex:F,endIndex:ve,isSelfClosing:!1}),T=ve}}return R}function pu(v){return v.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function Tg(v,k){try{let C=Buffer.from(v,"base64").toString("utf8");return JSON.parse(C)}catch{}try{let C=v.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(C)}catch(C){if(k?.debug)console.error("Error decoding __stx_ prop:",C);return v}}function gu(v,k){let C=0,R="",T=k;while(T<v.length){let z=v[T];if(R){if(z==="\\")T++;else if(z===R)R=""}else if(z==='"'||z==="'"||z==="`")R=z;else if(z==="{")C++;else if(z==="}"){if(C--,C===0)return v.slice(k,T+1)}T++}return v.slice(k)}function Ig(v){let k=v.trim();if(!k.startsWith("{")||!k.endsWith("}"))return null;if(gu(k,0).length!==k.length)return null;return k.slice(1,-1).trim()}var Mv=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),Nv=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function jv(v){return mu(v).map((k)=>[k.start,k.end])}function mu(v){let k=[],C=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,R;while((R=C.exec(v))!==null){let T=R[2]||"",z=/(?:^|\s)(?::for|x-for|v-for|@for)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/.exec(T);if(!z)continue;let F=Hr(z[1]??z[2]??z[3]??""),V=R.index,H=V+R[0].length,K=R[1].toLowerCase();if(R[0].endsWith("/>")||Nv.has(K)){k.push({start:V,end:H,names:F});continue}let X=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),G=new RegExp(`<\\/?${X}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");G.lastIndex=H;let te=1,ce=H,ee;while((ee=G.exec(v))!==null)if(ee[0].startsWith("</")){if(te--,te===0){ce=ee.index+ee[0].length;break}}else if(!ee[0].endsWith("/>"))te++;k.push({start:V,end:ce,names:F})}return k}function Pg(v){if(typeof v==="string")return v;if(Array.isArray(v))return v.filter(Boolean).map((k)=>Pg(k)).join(" ");if(v&&typeof v==="object")return Object.entries(v).filter(([,k])=>k).map(([k])=>k).join(" ");return v?String(v):""}function Dg(v,k){if(!/:[\w-]+=/.test(v))return v;let C=v,R=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,T=[],z;while((z=R.exec(v))!==null)T.push([z.index,z.index+z[0].length]);T.push(...jv(v));let F=new Set([...Ir(k),...Array.isArray(k.__stx_client_declared_names)?k.__stx_client_declared_names:[]]);function V(te){return T.some(([ce,ee])=>te>=ce&&te<ee)}let H=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,K=[],X=new Map,G=256;while((z=H.exec(C))!==null){if(V(z.index))continue;let te=z[0],ce=z[2];if(!ce||!ce.includes(":"))continue;let ee=/(?:^|\s)data-native(?:\s|=|$)/i.test(ce.replace(/"[^"]*"|'[^']*'/g,"")),le=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,ue,de=ce,fe=!1;while((ue=le.exec(ce))!==null){let pe=ue[1],Ae=ue[2];if(ra(pe))continue;if(re(Ae,F))continue;if(Ae.includes("()")&&!Ae.includes(".get(")||Ae.includes("$store")||Ae.includes("$ref"))continue;try{let Se=Object.keys(k),ve=Object.values(k),De=Ae.match(/^([a-zA-Z_$][\w$]*)/);if(De&&!Se.includes(De[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(De[1]))continue;let Me=JSON.stringify([Se,Ae]),je=X.get(Me);if(!je){if(je=Function(...Se,`return (${Ae})`),X.size>=G)X.clear();X.set(Me,je)}let Le=je(...ve);if(pe==="class"){let Be=Pg(Le);if(Be){let Oe=de.match(/\sclass="([^"]*)"/);if(Oe)de=de.replace(Oe[0],` class="${Oe[1]} ${Be}"`);else de=de.replace(ue[0],` class="${Be}"`)}else de=de.replace(ue[0],"");fe=!0;continue}if(Mv.has(pe)){if(Le)de=de.replace(ue[0],` ${pe}`);else de=de.replace(ue[0],"");fe=!0;continue}if(Le===null||Le===void 0||Le===!1)de=de.replace(ue[0],"");else{let Oe=(ee&&typeof Le==="object"?JSON.stringify(Le):String(Le)).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");de=de.replace(ue[0],` ${pe}="${Oe}"`)}fe=!0}catch{continue}}if(fe){let pe=z[3]?" /":"",Se=`<${z[1]}${de}${pe}>`;K.push({start:z.index,end:z.index+te.length,replacement:Se})}}if(K.length>0){let te=Array(K.length*2+1),ce=0;for(let ee=0;ee<K.length;ee++){let{start:le,end:ue,replacement:de}=K[ee];te[ee*2]=C.slice(ce,le),te[ee*2+1]=de,ce=ue}te[K.length*2]=C.slice(ce),C=te.join("")}return C}var Y=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl"];import qg from"path";import yu from"fs";import Eo from"path";function Og(v,k,C,R){let T=0;for(let z=k;z<v.length;z++)if(v[z]===C)T++;else if(v[z]===R&&!(R===">"&&v[z-1]==="=")){if(--T===0)return z}return-1}function Lv(v){let k=s(v),C=0,R=0,T=[];for(let z=0;z<k.length;z++)if("([{".includes(k[z]))C++;else if(")]}".includes(k[z]))C--;else if(k[z]===","&&C===0)T.push(v.slice(R,z).trim()),R=z+1;return T.push(v.slice(R).trim()),T}function hu(v,k){let C=s(v),R=new RegExp(`\\b(?:${k.map((T)=>T.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g");for(let T of C.matchAll(R)){let z=T.index+T[0].length,F="";if(C[z]==="<"){let H=Og(C,z,"<",">");if(H<0)continue;F=v.slice(z+1,H),z=H+1;while(/\s/.test(C[z]||"")&&z<C.length)z++}if(C[z]!=="(")continue;let V=Og(C,z,"(",")");if(V>=0)return{type:F,args:Lv(v.slice(z+1,V))}}return null}var Mg=`
|
|
2452
|
+
type __StxCtor<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends readonly unknown[] ? __StxCtor<T[number]> : T extends abstract new (...args: any[]) => infer V ? V : unknown;
|
|
2453
|
+
type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
|
|
2454
|
+
type __StxOption<T> = T extends { type: infer C } ? __StxCtor<C> : T extends { default: infer D } ? D extends (...args: any[]) => infer V ? V : __StxWiden<D> : __StxCtor<T>;
|
|
2455
|
+
type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K : never }[keyof O];
|
|
2456
|
+
type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
|
|
2457
|
+
type __StxOptions<O> = { [K in Exclude<__StxRequired<O>, __StxDefaulted<O>>]: __StxOption<O[K]> } & { [K in Exclude<keyof O, Exclude<__StxRequired<O>, __StxDefaulted<O>>>]?: __StxOption<O[K]> };
|
|
2458
|
+
type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
|
|
2459
|
+
`;function Ng(v,k){let C=[],R={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},T=s(v),z=v.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(te,ce,ee,le,ue)=>{if(T.slice(ue,ue+6)!=="import")return te;if(le.endsWith(".stx"))return"";let de=`${k}Import${C.length}`;if(C.push(`import * as ${de} from ${JSON.stringify(le)};`),ce.startsWith("*"))return`import ${ce.replace(/^\*\s+as\s+/,"")} = ${de};`;if(!ce.startsWith("{"))return`import ${ce} = ${de}.default;`;return ce.slice(1,-1).split(",").map((fe)=>{let[pe,Ae=pe]=fe.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!pe)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(le)&&pe in R)R[pe].push(Ae);return`import ${Ae} = ${de}.${pe};`}).join(`
|
|
2460
|
+
`)}),F=hu(v,R.defineProps),V=hu(v,R.defineEmits),H=hu(v,R.withDefaults);if(!F&&!V)return{declarations:"",props:null,events:null};let K=[],X=null,G=null;if(F){K.push(`const __options = (${F.args[0]||"{}"}) as const;`),K.push(`const __defaults = (${H?.args[1]||"{}"});`);let te=F.type||"__StxOptions<typeof __options>";K.push(`export type __StxProps = __StxDefaults<${te}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),X=`${k}.__StxProps`}if(V)K.push(`const __events = (${V.args[0]||"[]"}) as const;`),K.push(`export type __StxEvents = ${V.type||"Record<(typeof __events)[number], any[]>"};`),G=`${k}.__StxEvents`;return{declarations:`${C.join(`
|
|
2461
|
+
`)}
|
|
2462
|
+
namespace ${k} {
|
|
2463
|
+
${z}
|
|
2464
|
+
${K.join(`
|
|
2465
|
+
`)}
|
|
2466
|
+
}`,props:X,events:G}}var ko=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function Cn(v){if(v.includes("-")||v==="component")return!1;if(/^[A-Z]/.test(v))return!/[a-z]/.test(v)&&[...ko].some((k)=>k.toLowerCase()===v.toLowerCase());return ko.has(v)||/[A-Z]/.test(v)}function*Bv(v){let k=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,C;while(C=k.exec(v)){let R=k.lastIndex,T=[];while(R<v.length){while(/\s/.test(v[R]||""))R++;if(v[R]===">"||v.slice(R,R+2)==="/>"){R+=v[R]===">"?1:2;break}let z=/^[^\s=/>]+/.exec(v.slice(R))?.[0];if(!z){R++;continue}let F=R;R+=z.length;while(/\s/.test(v[R]||""))R++;if(v[R]!=="="){T.push({name:z,value:!0,offset:F,braced:!1});continue}R++;while(/\s/.test(v[R]||""))R++;let V=v[R],H=V==="{",K=V==='"'||V==="'";if(K||H)R++;let X=R;if(H){let G=s(v.slice(R)),te=1,ce=0;for(;ce<G.length;ce++){if(G[ce]==="{")te++;if(G[ce]==="}"&&--te===0)break}R+=ce}else if(K)while(R<v.length&&v[R]!==V)R++;else while(R<v.length&&!/[\s/>]/.test(v[R]))R++;if(T.push({name:z,value:v.slice(X,R),offset:X,braced:H}),K||H)R++}k.lastIndex=R,yield{name:C[1],offset:C.index,attributes:T}}}function jg(v,k,C){let R=[],T=[Mg,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],z=new Map,F=new Map,V=new Map,H=C.scriptCode(v,C.filePath),K=s(H);for(let ee of H.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(K.slice(ee.index,ee.index+6)!=="import")continue;let le=ee[2],ue=Eo.isAbsolute(le)||le.startsWith(".")?Eo.resolve(Eo.dirname(C.filePath),le):Go(le,Eo.dirname(C.filePath));if(!ue)continue;let de=ue.endsWith(".stx")?ue:yu.existsSync(`${ue}.stx`)?`${ue}.stx`:void 0,fe=de?null:Zo(ue,!1),pe=ee[1].startsWith("{")?ee[1].slice(1,-1).split(","):[ee[1]];for(let Ae of pe){let[Se,ve=Se]=Ae.trim().split(/\s+as\s+/),De=de||fe?.get(Se)||fe?.get(Se.toLowerCase());if(De)V.set(ve,De),V.set(ve.toLowerCase(),De),V.set(ve.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),De)}}for(let ee of k.matchAll(/@import\s*\(([^)]+)\)/g))for(let le of ee[1].matchAll(/['"]([^'"]+)['"]/g)){let ue=Jo(le[1],C.filePath,C).find((de)=>yu.statSync(de,{throwIfNoEntry:!1})?.isFile());if(ue)V.set(Eo.basename(le[1]).replace(/\.stx$/,""),ue)}let X={__importedComponents:V},G=new Map,te=(ee,le,ue)=>{let de=v.slice(0,ee);return{code:le,offset:ee,attribute:ue,anchor:!0,kind:"directive",line:de.split(`
|
|
2467
|
+
`).length,column:ee-de.lastIndexOf(`
|
|
2468
|
+
`)}},ce=(ee,le,ue)=>R.push({expression:ee,statement:{text:le+ee.code+ue,prefixLength:le.length}});for(let ee of Bv(k)){if(Cn(ee.name)||ee.name==="component")continue;let le=Ad(ee.name,C.filePath,C,X);if(!le)continue;let ue=G.get(le);if(!ue){let fe;try{fe=C.readComponent?C.readComponent(le):yu.readFileSync(le,"utf8")}catch{continue}if(fe===void 0)continue;F.set(le,fe),ue=Ng(C.scriptCode(fe,le),`__StxComponent${G.size}`),G.set(le,ue),T.push(ue.declarations)}let de=[];for(let fe of ee.attributes){let{name:pe,offset:Ae}=fe,Se=fe.value===!0?"true":fe.value;if(pe.startsWith("@")||pe.startsWith("v-on:")){if(ue.events&&fe.value!==!0)z.set(Ae,`__StxEvent<${ue.events}, ${JSON.stringify(pe.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let ve=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(pe);if(pe.startsWith("v-")&&!pe.startsWith("v-bind:")&&!ve)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(pe))continue;let De=(ve?ve[1]||"modelValue":pe.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(Le,Be)=>Be.toUpperCase());if(de.push(De),!ue.props)continue;let je=pe.startsWith(":")||pe.startsWith("v-bind:")||!!ve||fe.braced?Se:fe.value!==!0?JSON.stringify(Se):"true";ce(te(Ae,je,pe),";void ((",`) satisfies __StxProp<${ue.props}, ${JSON.stringify(De)}>);`)}if(ue.props){let fe=[...new Set(de)].map((Ae)=>`${JSON.stringify(Ae)}: undefined as any`).join(", "),pe=te(ee.offset,`<${ee.name}>`);R.push({expression:pe,statement:{text:`;void ({ ${fe} } satisfies ${ue.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:G.size?T.join(`
|
|
2469
|
+
`):"",checks:R,events:z,dependencies:F}}var Lg=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function zv(v){let k=(C)=>C.replace(/[^\n]/g," ");return v.replace(/<!--[\s\S]*?-->/g,k).replace(/\{\{--[\s\S]*?--\}\}/g,k)}function et(v){let k=[],C=zv(v);Lg.lastIndex=0;let R;while((R=Lg.exec(C))!==null){let T=(R[1]||"").trim(),z=(R[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,F=(R[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,V=R.index+z,H=R.index+R[0].length-F,K=v.slice(V,H);if(/\bsrc\s*=/.test(T))continue;let X=T.match(/\btype\s*=\s*["']([^"']+)["']/i);if(X&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(X[1]))continue;let G=/\bserver\b/.test(T)?"server":/\bclient\b/.test(T)?"client":"plain",te=Co(v,V);k.push({kind:G,code:K,startLine:te,startColumn:Ro(v,V),offset:V,attrs:T})}return k}function Co(v,k){let C=1;for(let R=0;R<k&&R<v.length;R++)if(v.charCodeAt(R)===10)C++;return C}function Ro(v,k){let C=v.lastIndexOf(`
|
|
2470
|
+
`,k-1)+1;return k-C+1}function Va(v){let k=v.split(""),C=(T,z)=>{for(let F=T;F<z&&F<k.length;F++)if(k[F]!==`
|
|
2471
|
+
`)k[F]=" "},R=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let T of R){T.lastIndex=0;let z;while((z=T.exec(v))!==null)C(z.index,z.index+z[0].length)}return k.join("")}function Wv(v){let k=0,C="";for(let R=0;R<v.length;R++){let T=v[R];if(C){if(T==="\\"){R++;continue}if(T===C)C="";continue}if(T==='"'||T==="'"||T==="`"){C=T;continue}if(T==="("||T==="["||T==="{"){k++;continue}if(T===")"||T==="]"||T==="}"){k--;continue}if(T==="|"&&k===0){if(v[R+1]==="|"){R++;continue}if(v[R-1]==="|")continue;return v.slice(0,R)}}return v}var Kg=new Set([":for","x-for","v-for"]),Ua=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,xu="__stx_interpolated",Bg="__StxElement",Xg="__StxTemplateValue",Fv=`type ${Xg}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function zg(v){return v.replace(/\{\{[\s\S]*?\}\}/g,xu).replace(/\{!![\s\S]*?!!\}/g,xu)}function Cs(v){return v.replace(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/g,(k)=>{let C=k.split(`
|
|
2472
|
+
`).length-1,R=k.length-C;return`0${" ".repeat(Math.max(0,R-1))}${`
|
|
2473
|
+
`.repeat(C)}`})}var Vv=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],Uv=new RegExp(String.raw`^[ \t]*@(?:${Vv.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function Es(v){return v.replace(Uv,(k)=>k.replace(/[^\n]/g," "))}var Wg=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function Mc(v){let k=Va(v),C=[],R=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,T;while((T=R.exec(k))!==null){if(T[1]||T[3])continue;let V=T[2]??T[4]??"",H=T[2]!==void 0?2:3,K=Wv(V);if(!K.trim())continue;let X=T.index+H+(K.length-K.trimStart().length);C.push({code:K.trim(),line:Co(k,X),column:Ro(k,X),offset:X,kind:"interpolation"})}let z=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((T=z.exec(k))!==null){let F=T.index+T[0].length-1,V=0,H=F;for(;H<k.length;H++){let te=k[H];if(te==="(")V++;else if(te===")"){if(V--,V===0)break}}if(V!==0)continue;let K=k.slice(F+1,H),X=K.trim();if(z.lastIndex=H+1,!X)continue;let G=F+1+(K.length-K.trimStart().length);C.push({code:X,line:Co(k,G),column:Ro(k,G),offset:T.index,kind:"condition"})}Ua.lastIndex=0;while((T=Ua.exec(k))!==null){let F=T[1],V=T[3]??"",H=F.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(Wg.has(H)||Wg.has(F))continue;if(!V.trim())continue;let K=T.index+T[0].indexOf(T[2],T[0].indexOf(F)+F.length)+1;if(Kg.has(H)){let G=V.match(/\s+(?:in|of)\s+/);if(!G||G.index===void 0)continue;let te=V.slice(G.index+G[0].length),ce=G.index+G[0].length+(te.length-te.trimStart().length);C.push({code:zg(te.trim()),line:Co(k,K+ce),column:Ro(k,K+ce),offset:K+ce,kind:"directive",attribute:H});continue}let X=V.length-V.trimStart().length;C.push({code:zg(V.trim()),line:Co(k,K+X),column:Ro(k,K+X),offset:K+X,kind:"directive",attribute:H})}return C.sort((F,V)=>F.line-V.line||F.column-V.column),C}var Hv=2000;function qv(v,k){let C=0,R=Math.min(v.length,k+Hv);for(let T=k;T<R;T++){let z=v[T];if(z==="(")C++;else if(z===")"){if(C--,C===0)return v.slice(k+1,T)}}return null}function Kv(v){let k=new Map,C=(V,H)=>{let K=V.split(/[,[\]{}()\s]+/).filter(Boolean);for(let X of K){let G=X.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(G))continue;let te=K.length===1?H:void 0,ce=k.get(G);if(!ce)k.set(G,{name:G,iterable:te});else if(ce.iterable!==te)ce.iterable=void 0}},R=/^\$?[A-Z_$][\w$]*$/i,T=(V)=>{let H=V.trim();return R.test(H)?H:void 0};for(let V of v.matchAll(/@for(?:each|else)\s*\(/g)){let H=qv(v,V.index+V[0].length-1);if(H===null)continue;let K=Dt(H);if(!K)continue;C(K.itemVar.replace(/=>/g," "),T(K.arrayExpr))}for(let V of v.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))C(V[1],V[2]==="of"?T(V[3]):void 0);for(let V of v.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))C(V[1]);let z=Va(v);Ua.lastIndex=0;let F;while((F=Ua.exec(z))!==null){let V=F[1].replace(/\..*$/,"");if(!Kg.has(V))continue;let H=F[3].match(/\s+(?:in|of)\s+/);if(!H||H.index===void 0)continue;C(F[3].slice(0,H.index),T(F[3].slice(H.index+H[0].length)))}for(let V of v.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let H of V[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))C(H[1]);return[...k.values()].sort((V,H)=>V.name.localeCompare(H.name))}function me(v){let k=new Set;for(let C of v.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s+([\w$]+)/gm))k.add(C[1]);for(let C of v.matchAll(/^\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([\w$]+)/gm))k.add(C[1]);for(let C of v.matchAll(/^\s*(?:export\s+)?class\s+([\w$]+)/gm))k.add(C[1]);for(let C of v.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s*[[{]([^\]}]*)[\]}]/gm))for(let R of C[1].split(",")){let T=R.split(":").pop().split("=")[0].replace(/^\.\.\./,"").trim();if(/^[A-Z_$][\w$]*$/i.test(T))k.add(T)}return[...k].sort()}var bu=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"],Xv={$bool:"declare function $bool(value: unknown, fallback?: boolean): boolean",$num:"declare function $num(value: unknown, fallback?: number): number",$uid:"declare var $uid: string"};function vi(v=new Set){return[...bu.filter((k)=>!v.has(k)).map((k)=>`declare var ${k}: any`),...Object.entries(Xv).filter(([k])=>!v.has(k)).map(([,k])=>k)].join(`
|
|
2474
|
+
`)}function wi(v){return new Set([...v.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((k)=>k[1]))}function Zg(v){let k=/\bdefineClientPayload\s*\(\s*\{([\s\S]*?)\}\s*\)/g,C,R=!1,T=new Set,z=s(v);while((C=k.exec(z))!==null){R=!0;for(let F of Zv(C[1])){let V=F.split(":")[0].trim();if(/^[A-Za-z_$][\w$]*$/.test(V))T.add(V)}}return R?[...T]:null}function Zv(v){let k=[],C=0,R="";for(let T of v){if(T===","&&C===0){k.push(R),R="";continue}if(T==="("||T==="["||T==="{")C++;else if(T===")"||T==="]"||T==="}")C--;R+=T}return k.push(R),k.filter((T)=>T.trim().length>0)}function Gv(v){let k=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,C=[],R=v.replace(k,(T)=>(C.push(T.trim()),T.split(`
|
|
2475
|
+
`).map(()=>"").join(`
|
|
2476
|
+
`)));return{imports:C.join(`
|
|
2477
|
+
`),body:R}}function Gg(v){let k=s(v),C=Array(k.length),R=0;for(let V=0;V<k.length;V++){let H=k[V];if(H==="}"||H===")"||H==="]")R=Math.max(0,R-1);if(C[V]=R,H==="{"||H==="("||H==="[")R++}let T=[],z=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,F;while((F=z.exec(k))!==null){if(C[F.index]!==0)continue;let V=F[1],H=F[2],K;if(V==="interface"){let X=k.indexOf("{",F.index);if(X===-1)continue;let G=0;K=-1;for(let te=X;te<k.length;te++)if(k[te]==="{")G++;else if(k[te]==="}"&&--G===0){K=te+1;break}if(K===-1)continue}else{let X=0;K=k.length;for(let G=k.indexOf("=",F.index)+1;G<k.length;G++){let te=k[G];if(te==="{"||te==="["||te==="("||te==="<")X++;else if(te==="}"||te==="]"||te===")"||te===">")X--;else if(X<=0&&(te===";"||te===`
|
|
2478
|
+
`&&!/[=|&,<([{]\s*$/.test(k.slice(Math.max(0,G-40),G)))){K=te===";"?G+1:G;break}}}T.push({name:H,text:v.slice(F.index,K).replace(/^[ \t]*export[ \t]+/,"")}),z.lastIndex=K}return T}function Jv(v){return new Set(Gg(v).map((k)=>k.name))}function xi(v,k=""){let C=Zg(v),R=Jv(k),T=Gg(v).filter((K)=>!R.has(K.name)).map((K)=>K.text);if(!C){let K=me(v).filter((X)=>!Wi(k,X));if(K.length===0&&T.length===0)return"";return["",`// ${Yv}`,...T,...K.map((X)=>`declare var ${X}: any`)].join(`
|
|
2479
|
+
`)}if(C.length===0)return T.length>0?["",`// ${Fg}`,...T].join(`
|
|
2480
|
+
`):"";let{imports:z,body:F}=Gv(v),V=F.replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class)\b)/gm,""),H=["",`// ${Fg}`];if(z)H.push(z);return H.push(...T),H.push(`async function ${Vg}() {`,V,` return { ${C.join(", ")} }`,"}",`type ${Ug} = Awaited<ReturnType<typeof ${Vg}>>`,...C.map((K)=>`declare var ${K}: ${Ug}[${JSON.stringify(K)}]`)),H.join(`
|
|
2481
|
+
`)}function vu(v){let C=s(v).split(""),R=0;for(let T=0;T<C.length;T++){let z=C[T];if(z==="{"||z==="("||z==="["){R++;continue}if(z==="}"||z===")"||z==="]"){R=Math.max(0,R-1);continue}if(R>0&&z!==`
|
|
2482
|
+
`)C[T]=" "}return me(C.join(""))}function Si(v,k){if(Zg(v)!==null)return[];let C=vu(v),R=Ot(k,new Set(C)),T=new Set(y);return C.filter((z)=>{if(T.has(z))return!1;if(Wi(k,z))return!1;return R.has(z)})}var Fg="stx: types for the declared client payload (#1868)",Yv="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",Vg="__stxServerScope",Ug="__StxClientPayload";var Hg=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","props","slot"];var Qv=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function ew(v){let k=new Map,C=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let R of v){let T=s(R),{depths:z,balanced:F}=Re(T);if(!F)continue;let V=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let H of T.matchAll(V)){let K=H.index??0;if(z[K+H[1].length]!==0)continue;let X=H[2],G=K+H[0].length-H[3].length,te=R.slice(G,K+H[0].length).trim().replace(/;$/,"").trim(),ce=H[3],ee=C.test(ce)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(ce)&&!/[,+\-*/%&|?:=]$/.test(te)&&Re(ce).balanced;k.set(X,k.has(X)||!ee?null:te)}}return new Map([...k].filter((R)=>R[1]!==null))}function Jg(v,k,C=0,R=new Set){if(k.size===0||C>=5)return v;let T=s(v),z="",F=0;for(let V of T.matchAll(/[A-Za-z_$][\w$]*/g)){let H=V.index??0,K=V[0],X=k.get(K);if(!X||R.has(K))continue;let G=T.slice(0,H).trimEnd(),te=T.slice(H+K.length).trimStart();if(G.endsWith(".")||/^:(?!:)/.test(te)&&/[{,]$/.test(G))continue;if(H>0&&/[\w$]/.test(T[H-1]))continue;z+=`${v.slice(F,H)}(${Jg(X,k,C+1,new Set([...R,K]))})`,F=H+K.length}return z+v.slice(F)}function tw(v,k){let C=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,R=[],T;while((T=C.exec(v))!==null){if(T.index>k)break;let z=T[1];if(T.index===k){if(z==="elseif"){let V=R[R.length-1];if(V?.current)V.seen.push(V.current);if(V)V.current=null}break}if(z==="endif"||z==="endunless"){R.pop();continue}let F="";if(T[2]==="("){let V=0,H=T.index+T[0].length-1,K=H+1;for(;H<v.length;H++){let X=v[H];if(X==="(")V++;else if(X===")"){if(V--,V===0)break}}F=v.slice(K,H).trim(),C.lastIndex=H+1}if(z==="if")R.push({seen:[],current:F});else if(z==="unless")R.push({seen:[],current:`!(${F})`});else if(z==="elseif"||z==="else"){let V=R[R.length-1];if(!V)continue;if(V.current)V.seen.push(V.current);V.current=z==="elseif"?F:null}}return R.flatMap((z)=>[...z.seen.map((F)=>`!(${F})`),...z.current?[z.current]:[]]).filter(Boolean)}function nw(v){let k=v.code.trim();if(!k)return null;if(v.attribute?.startsWith("@")){if(Qv.test(k))return null;let R=";(($event: any): void => { ";return{text:`${R}${k} });`,prefixLength:R.length}}let C=";void ((";return{text:`${C}${k}));`,prefixLength:C.length}}var rw=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function dr(v,k){if(!k)return v;return v.replace(rw,(C,R,T,z)=>{let F=qg.resolve(k,z).replace(/\\/g,"/");return`${R}${T}${F}${T}`})}function Ts(v){return" ".repeat(Math.max(0,(v.startColumn??1)-1))}function sw(v){let k=new Set,C=s(v);for(let R of C.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let T=R[1],z=/\{([^}]*)\}/.exec(T);for(let K of z?.[1].split(",")??[]){let X=K.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(X&&/^[A-Z_$][\w$]*$/i.test(X))k.add(X)}let F=T.replace(/\{[^}]*\}/,""),V=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(F);if(V)k.add(V[1]);let H=/^\s*([A-Z_$][\w$]*)/i.exec(F);if(H&&H[1]!=="type")k.add(H[1])}return[...k].sort()}function ki(v,k={}){let C=et(v),R=v.split(`
|
|
2483
|
+
`),T=Array.from({length:R.length},()=>""),z=new Map,F=k.filePath&&k.templateExpressions!==!1?jg(v,Va(v),{filePath:k.filePath,componentsDir:k.componentsDir,projectRoot:k.projectRoot,readComponent:k.readComponent,scriptCode:(G,te)=>et(G).map((ce)=>dr(ce.code,qg.dirname(te))).join(`
|
|
2484
|
+
`)}):void 0,V=new Set,H=[];for(let G of C){let te=Es(Cs(G.code)),ce=dr(te,k.originDir??"").split(`
|
|
2485
|
+
`);ce.forEach((ee,le)=>{let ue=G.startLine-1+le;if(ue<T.length)T[ue]=le===0?Ts(G)+ee:ee,V.add(ue)}),H.push(G.startLine-1+ce.length-1)}for(let G of H){let te=T[G]?.trim()===""?G:G+1;if(te<T.length&&T[te].trim()===""&&(te===G||!V.has(te)))T[te]=";"}let K=(G,te)=>{for(let[ce,ee]of G.split(`
|
|
2486
|
+
`).entries())if(T.push(ee),te)z.set(T.length,ce===0?te:{...te,line:te.line+ce,column:1,prefixLength:0})};if(k.globals!==!1){K("");let G=new Set([...C.flatMap((le)=>me(le.code)),...C.flatMap((le)=>sw(le.code))]),te=(le)=>{if(!G.has(le))K(`declare var ${le}: any`)};if(k.runtimeGlobals!==!1){if(!G.has("window"))K("declare var window: any");for(let le of y)te(le)}let ce=[...new Set([...bu,...Y,...Hg])].filter((le)=>k.runtimeGlobals!==!1||!y.includes(le));if(k.contextScope==="global"){K("declare global {");for(let le of ce)K(` var ${le}: any`);K("}")}else{for(let le of bu)te(le);for(let le of Y)te(le);for(let le of Hg)te(le)}K(`declare var ${xu}: any`);let ee=new Set(C.flatMap((le)=>me(le.code)));K(`type ${Bg}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let le of Kv(v)){if(ee.has(le.name))continue;let ue=le.iterable&&ee.has(le.iterable)?`${Bg}<typeof ${le.iterable}>`:"any";K(`declare var ${le.name}: ${ue}`)}}if(k.templateExpressions!==!1){if(F?.declarations)for(let te of F.declarations.split(`
|
|
2487
|
+
`))K(te);let G=Mc(v).map((te)=>{let ce=F?.events.get(te.offset??-1);if(ce){te.anchor=!0;let ee=te.code.trim(),le=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(ee),ue=le?`void ((${le[2]}) satisfies __StxAssignedValue<typeof ${le[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(ee)?`${ee} satisfies (($event: ${ce}) => unknown)`:ee,de=`;(($event: ${ce}): void => { `;return{expression:te,statement:{text:`${de}${ue} });`,prefixLength:de.length}}}return{expression:te,statement:nw(te)}}).filter((te)=>te.statement!==null);if(G.push(...F?.checks||[]),G.length>0){let te=Va(v),ce=da(te),ee=ew(C.map((fe)=>fe.code)),ue=[...new Set(C.flatMap((fe)=>me(fe.code)))].filter((fe)=>/^[A-Z_$][\w$]*$/i.test(fe)),de=0;if(ue.length>0){K(Fv);for(let fe of ue)K(`function __StxRead_${fe}() { return ${fe} }`),K(`type __StxT_${fe} = ${Xg}<ReturnType<typeof __StxRead_${fe}>>`);K(`;((${ue.map((fe)=>`${fe}: __StxT_${fe}`).join(", ")}) => {`),de=1}for(let{expression:fe,statement:pe}of G){let Ae=" ".repeat(de),Se=fe.offset===void 0?[]:ce.filter((Be)=>fe.offset>=Be.start&&fe.offset<Be.end),ve=Se.map((Be)=>`;((${Be.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),De=" });".repeat(Se.length),Me=fe.offset===void 0?[]:tw(te,fe.offset),je=Me.length>0?`${Me.map((Be)=>`if (${Jg(Be,ee)}) `).join("")}{ `:"",Le=Me.length>0?" }":"";K(Ae+ve+je+pe.text+Le+De,{line:fe.line,column:fe.column,expression:fe,prefixLength:pe.prefixLength+Ae.length+ve.length+je.length,guardPrefixLength:Ae.length+ve.length+je.length})}if(de>0)K("});")}}let X=!1;if(k.reference&&T[0]!==void 0&&T[0].trim()==="")T[0]=`/// <reference path=${JSON.stringify(k.reference.replace(/\\/g,"/"))} />`,X=!0;return K("export {}"),{text:T.join(`
|
|
2488
|
+
`),lineMap:z,sourceLineCount:R.length,componentDependencies:F?.dependencies,referenced:X}}function _i(v,k){if(!v.expression)return!1;return v.inGuard===!0||k===2774}function Ci(v,k,C){let R=v.lineMap.get(k);if(!R)return k<=v.sourceLineCount?{line:k,column:C}:null;let T=R.expression?.anchor?0:Math.max(0,C-1-(R.prefixLength??0));return{line:R.line,column:R.column+T,expression:R.expression,inGuard:C<=(R.guardPrefixLength??0)}}import Yg from"fs";import Qg from"path";var em=!1;function iw(v,k,C,R=!1,T=new Set){let z={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},F=new Set(Array.isArray(k.__stx_client_signal_names)?k.__stx_client_signal_names:[]),V=(G)=>{if(F.size===0)return!1;let te=s(G),ce=te.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(ce&&F.has(ce))return!0;for(let ee of F){let le=ee.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${le}\\s*\\(`).test(te))return!0}return!1},H=new Set(sa),K=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;if(G.startsWith("aria-")||G.startsWith("data-"))return G;return G.replace(/-([a-z0-9])/g,(te,ce)=>ce.toUpperCase())},X=(G,te)=>{let ce=K(G);if(z.static[ce]=te,ce!==G)z.staticNames[ce]=G};for(let[G,te]of Object.entries(v)){let ce=G.startsWith("x-")&&!H.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(ce.startsWith("@")){z.events[ce]=te;continue}if(ce.startsWith("__stx_")){let ee=K(ce.slice(6));z.serverDynamic[ee]=Tg(te,C);continue}if(ce.startsWith(":")){let ee=K(ce.slice(1)),le=te===zr?ee:te;if(ee==="if"||ee==="for"||ee==="show"){z.clientReactive[ee]=le;continue}if(R){z.clientReactive[ee]=le;continue}if(re(le,T)){z.clientReactive[ee]=le;continue}if(V(le)){z.clientReactive[ee]=le;continue}try{if(!p(le)){if(C.debug)console.error(`Unsafe expression in :${ee} binding: ${le}`);z.clientReactive[ee]=le;continue}let ue=Object.keys(k),de=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]),fe=new Set(Array.isArray(k.__stx_client_declared_names)?k.__stx_client_declared_names:[]);if(Ie(le).some((ve)=>!de.has(ve)&&!ue.includes(ve)&&(!(ve in globalThis)||fe.has(ve)))){z.clientReactive[ee]=le;continue}let Se=c(le,ue)(...Object.values(k));if(z.serverDynamic[ee]=Se,ee!==ce.slice(1)&&z.serverDynamicNames)z.serverDynamicNames[ee]=ce.slice(1)}catch{z.clientReactive[ee]=le}continue}if(typeof te==="string"&&te.includes("{{")&&te.includes("}}")){let ee=ow(te,T);if(ee!==null){z.clientReactive[K(ce)]=ee;continue}let le=te.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(le)try{let ue=le[1];if(p(ue)){let fe=c(ue,Object.keys(k))(...Object.values(k));X(ce,fe!=null?String(fe):"")}else{if(C.debug)console.error(`Unsafe expression in ${ce}: ${ue}`);X(ce,te)}}catch(ue){if(C.debug)console.error(`Error evaluating expression for ${ce}:`,ue);X(ce,te)}else{let ue=te,de=/\{\{\s*([\s\S]+?)\s*\}\}/g,fe;while((fe=de.exec(te))!==null)try{let pe=fe[1];if(!p(pe)){if(C.debug)console.error(`Unsafe expression in ${ce}: ${pe}`);continue}let Se=c(pe,Object.keys(k))(...Object.values(k));ue=ue.replace(fe[0],String(Se??""))}catch(pe){if(C.debug)console.error(`Error evaluating expression in ${ce}:`,pe)}X(ce,ue)}continue}X(ce,te===zr?"true":pu(te))}return z}function ow(v,k){if(k.size===0)return null;let C=/\{\{\s*([\s\S]+?)\s*\}\}/g,R=[...v.matchAll(C)];if(!R.some((V)=>re(V[1],k)))return null;let T=v.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(T&&R.length===1)return T[1];let z="",F=0;for(let V of R)z+=v.slice(F,V.index).replace(/[`\\$]/g,(H)=>`\\${H}`),z+=`\${${V[1]}}`,F=V.index+V[0].length;return z+=v.slice(F).replace(/[`\\$]/g,(V)=>`\\${V}`),`\`${z}\``}var aw=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function cw(v,k,C){if(!v.includes("@"))return v;if(!aw.some(([T,z])=>T.test(v)&&v.includes(z)))return v;try{return Sr(v,k,C)}catch{return v}}function si(v){let k={},C=0,R=v.length;while(C<R){while(C<R&&/\s/.test(v[C]))C++;if(C>=R)break;let T="";while(C<R&&!/[\s=]/.test(v[C]))T+=v[C],C++;if(!T)break;while(C<R&&/\s/.test(v[C]))C++;if(C<R&&v[C]==="="){C++;while(C<R&&/\s/.test(v[C]))C++;let z="";if(C<R&&(v[C]==='"'||v[C]==="'")){let F=v[C];C++;while(C<R){let V=v[C];if(V==="\\"&&C+1<R){C++,z+=v[C],C++;continue}if(V===F){C++;break}z+=V,C++}}else if(v[C]==="{"){z=gu(v,C),C+=z.length;let F=Ig(z);if(F!==null){k[`:${T}`]=F;continue}}else while(C<R&&!/\s/.test(v[C]))z+=v[C],C++;k[T]=z}else k[T]=zr}return k}function tm(v){return Object.entries(v).map(([k,C])=>C===zr?k:`${k}="${lw(C)}"`).join(" ")}function lw(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function uw(v){let k=new Set,C=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,R;while((R=C.exec(v))!==null){let T=R[1];if(Vs.isBuiltin(T))k.add(T)}return[...k].sort()}async function Lc(v,k,C,R,T){if(!/import\s/.test(v))return v;if(!k.__importedComponents)k.__importedComponents=new Map;let z=k.__importedComponents,F=Qg.dirname(C),V=[],H=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let G of v.matchAll(H)){let[te,ce,ee]=G,le=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,ue=ee,de,fe=[];while((de=le.exec(ee))!==null){let[pe,Ae,Se,ve]=de,De=null,Me=null;if(ve.startsWith(".")||ve.startsWith("/")){let Be=Qg.resolve(F,ve);if(Be.endsWith(".stx"))Me=Be;else{let Oe=`${Be}.stx`;try{if(Yg.statSync(Oe).isFile())Me=Oe}catch{try{if(Yg.statSync(Be).isDirectory())De=Be}catch{}}}}else De=Go(ve,F);if(!De&&!Me)continue;let je=!1,Le=(Be,Oe)=>{z.set(Be,Oe),z.set(Be.toLowerCase(),Oe);let We=Be.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();z.set(We,Oe),T.add(Oe)};if(Se&&Me)Le(Se,Me),je=!0;else if(Ae){let Be=Ae.slice(1,-1).split(",").map((We)=>We.trim()).filter(Boolean).map((We)=>{let Fe=We.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(Fe)return{source:Fe[1],local:Fe[2]};return{source:We,local:We}}),Oe=De?Zo(De):null;for(let{source:We,local:Fe}of Be){let Ve=null;if(Me)Ve=Me;else if(Oe)Ve=Oe.get(We)??Oe.get(We.toLowerCase())??Oe.get(We.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(Ve)Le(Fe,Ve),je=!0}}if(je)fe.push({start:de.index,end:de.index+pe.length})}if(fe.length===0)continue;for(let pe=fe.length-1;pe>=0;pe--)ue=ue.slice(0,fe[pe].start)+ue.slice(fe[pe].end);V.push({start:G.index,end:G.index+te.length,value:`<script${ce}>${ue}</script>`})}if(V.length===0)return v;let K=[],X=0;for(let G of V)K.push(v.slice(X,G.start),G.value),X=G.end;return K.push(v.slice(X)),K.join("")}async function dw(v,k,C,R,T){let z=v;if(!k.__importedComponents)k.__importedComponents=new Map;let F=k.__importedComponents,V=/@import\s*\(\s*([^)]+)\s*\)/g,H;while((H=V.exec(z))!==null){let[K,X]=H,G=X.split(",").map((te)=>te.trim().replace(/^['"]|['"]$/g,"")).filter((te)=>te.length>0);for(let te of G){let ce=te.split("/"),le=ce[ce.length-1].replace(/\.stx$/,""),ue=le.includes("-")?le.split("-").map((pe)=>pe.charAt(0).toUpperCase()+pe.slice(1)).join(""):le.charAt(0).toUpperCase()+le.slice(1),de=null,fe=Jo(te,C,R);for(let pe of fe)try{if(await Bun.file(pe).exists()){de=pe;break}}catch{}if(de){F.set(ue,de),F.set(le,de),F.set(le.toLowerCase(),de);let pe=ue.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(F.set(pe,de),T.add(de),R.debug)console.log(`Imported component: ${ue} -> ${de}`)}else if(R.debug)console.warn(`Could not resolve imported component: ${te}`)}z=z.replace(K,""),V.lastIndex=0}return z}async function fw(v,k,C,R,T){let z=v,F=R.componentsDir||"components";if(!k.__processedComponents)k.__processedComponents=new Set;let V=k.__processedComponents,H=/@component\s*\(/g,K;while((K=H.exec(z))!==null){let X=K.index,G=X+K[0].length-1,te=1,ce=G+1;while(ce<z.length&&te>0){if(z[ce]==="(")te++;else if(z[ce]===")"){if(te--,te===0)break}ce++}if(te!==0)break;let ee=z.substring(G+1,ce),le=ce+1,ue=ee.match(/^\s*['"]([^'"]+)['"]/);if(!ue){H.lastIndex=0;continue}let de=ue[1],fe,pe=ee.slice(ue[0].length),Ae=pe.match(/^\s*,\s*/);if(Ae)fe=pe.slice(Ae[0].length).trim();let Se={};if(fe)try{Se=N(fe,k)}catch(Be){let Oe=Be instanceof Error?Be.message:String(Be);z=z.replace(z.substring(X,le),`[Error parsing component props: ${Oe}]`);continue}let ve="",De=le,je=z.substring(le).match(/^([\s\S]*?)@endcomponent/);if(je)ve=je[1].trim(),De=le+je[0].length;let Le=await st(de,Se,ve,F,k,C,R,V,T);z=z.substring(0,X)+Le+z.substring(De),H.lastIndex=0}return z}async function pw(v,k,C,R,T){if(!v)return v;let z=v,F=R.componentsDir||"components";if(!k.__processedComponents)k.__processedComponents=new Set;let V=k.__processedComponents,H=hw(z);if(H.size>0){let le=Array.isArray(k.__stx_client_declared_names)?k.__stx_client_declared_names:[];k.__stx_client_declared_names=[...new Set([...le,...H])]}let K=yn(z);z=K.output;let X=Ir(k);return z=await ee(z,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),z=await ee(z,/[A-Z][a-zA-Z0-9]*/,!0,Rg(ko)),z=await ee(z,/[a-z][a-z0-9]*/,!1,ko),z=K.restore(z),z;async function ee(le,ue,de,fe){if(!le)return le;let pe=le,Ae=Ag(pe,ue,fe),Se=mu(pe),ve=new Map;for(let je=Ae.length-1;je>=0;je--){let Le=Ae[je],Be=de?gn(Le.tagName):Le.tagName,Oe=si(cw(Le.attributes,k,C)),We=Se.filter(({start:Rt,end:xt})=>Le.startIndex>=Rt&&Le.startIndex<xt),Fe=We.length>0,Ve=new Set(X);for(let Rt of We)for(let xt of Rt.names)Ve.add(xt);let ze=iw(Oe,k,R,Fe,Ve);if(typeof ze.clientReactive.for==="string")for(let Rt of Hr(ze.clientReactive.for))Ve.add(Rt);let He=Vs.getBuiltin(Le.tagName),wt=He?await gr(Le.tagName,F,k,C,R):!1;if(He&&!wt){let Rt={context:k,filePath:C,options:R,dependencies:T},xt=He.render(ze,Le.content,Rt);if(Object.keys(ze.events).length>0){let ft=tm(ze.events);xt=xt.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${ft}`)}if(Object.keys(ze.clientReactive).length>0)xt=nm(xt,ze.clientReactive);ve.set(je,xt);continue}if(!de&&Le.tagName.includes("-")&&!await gr(Be,F,k,C,R))continue;let vt={};for(let[Rt,xt]of Object.entries(ze.static))vt[Rt]=xt;for(let[Rt,xt]of Object.entries(ze.serverDynamic))vt[Rt]=xt;let Ct={declaredProps:new Set,consumedProps:new Set,reactiveProps:Object.keys(ze.clientReactive),events:Object.keys(ze.events)},St=await st(Be,vt,K.restore(Le.content),F,k,C,R,V,T,[...Ve],Ct,Le.tagName);if(St=gw(St,ze,Ct.declaredProps,Ct.consumedProps,R._nativeHostAttrs),R._nativeHostAttrs){let Rt=Ct.reactiveProps.filter((_t)=>!Ct.consumedProps.has(_t)&&!["if","for","show","key","ref"].includes(_t)).map(gn),xt=wu(St,!0);if(Rt.length&&xt){if(!Object.hasOwn(si(St.slice(xt.insertPos,xt.tagEnd)),"data-stx-native-host-root"))St=St.slice(0,xt.insertPos)+' data-stx-native-host-root="true"'+St.slice(xt.insertPos);let _t=Ao(St);St=St.slice(0,_t.insertPos)+` data-stx-native-forward="${Rt.join(" ")}"`+St.slice(_t.insertPos)}let ft=wu(St,!0);if(ft){let _t=si(St.slice(ft.insertPos,ft.tagEnd)),bt=Ao(St),Xt=si(St.slice(bt.insertPos,bt.tagEnd));if(Object.hasOwn(_t,"data-stx-native-host-root")&&!Object.hasOwn(Xt,"data-stx-native-host-owner"))St=St.slice(0,bt.insertPos)+" data-stx-native-host-owner"+St.slice(bt.insertPos)}}if(Object.keys(ze.events).length>0){let Rt=Ao(St);if(Rt){let xt=tm(ze.events),ft=Object.keys(ze.events).map((_t)=>_t.replace(/^@/,"").split(".")[0]).join(" ");St=St.substring(0,Rt.insertPos)+` data-stx-parent-events="${ft}" ${xt}`+St.substring(Rt.insertPos)}}if(Object.keys(ze.clientReactive).length>0)St=nm(St,ze.clientReactive);ve.set(je,St)}if(ve.size===0)return pe;let De="",Me=0;for(let je=0;je<Ae.length;je++){let Le=ve.get(je);if(Le===void 0)continue;De+=pe.slice(Me,Ae[je].startIndex),De+=Le,Me=Ae[je].endIndex}return De+=pe.slice(Me),De}}function nm(v,k){let C=new Set(["if","for"]),R=new Set(["show"]),T=Object.entries(k).filter(([X])=>!C.has(X)),z=T.filter(([X])=>!R.has(X)).map(([X])=>gn(X)).join(" "),F=v,V=T.length>0?Ao(F):null;if(V){let X=T.map(([te,ce])=>`:${gn(te)}="${ce.replace(/"/g,""")}"`).join(" "),G=z?` data-stx-parent-bindings="${z}"`:"";F=F.substring(0,V.insertPos)+`${G} ${X}`+F.substring(V.insertPos)}let H=k.if;if(H)F=`<template :if="${H.replace(/"/g,""")}">${F}</template>`;let K=k.for;if(K)F=`<template :for="${K.replace(/"/g,""")}">${F}</template>`;return F}function gw(v,k,C=new Set,R=new Set,T=!1){let z=wu(v,T);if(!z)return v;let F=v.slice(z.insertPos,z.tagEnd),V=k.serverDynamic.class??k.static.class;if(T&&typeof V==="string"&&V&&!R.has("class")){let ee=/(^|\s)class\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i,le=ee.test(F)?F.replace(ee,(ue,de,fe,pe,Ae)=>`${de}class="${Gt(`${pu(fe??pe??Ae)} ${V}`)}"`):` class="${Gt(V)}"${F}`;v=v.slice(0,z.insertPos)+le+v.slice(z.tagEnd),z.tagEnd+=le.length-F.length,F=le}let H=T||/\bdata-native(?:\s|=)/i.test(F),K=H?R:C,X=new Set(Object.keys(si(F))),G=new Set(["class","className"]);for(let ee of Object.keys(k.static)){let le=k.staticNames[ee]??ee;if(X.has(le)||K.has(ee)||!H&&!Ul(le))G.add(ee)}for(let ee of Object.keys(k.serverDynamic)){let le=k.serverDynamicNames?.[ee]??ee;if(X.has(le)||K.has(ee)||!H&&!Ul(le))G.add(ee)}let te=[];if(H){for(let[ee,le]of Object.entries(k.static)){if(G.has(ee)||le!==!0&&le!==zr)continue;G.add(ee),te.push(`${Gt(k.staticNames?.[ee]??ee)}="true"`)}for(let[ee,le]of Object.entries(k.serverDynamic)){if(G.has(ee)||le!==!0)continue;G.add(ee),te.push(`${Gt(k.serverDynamicNames?.[ee]??ee)}="true"`)}}let ce=[...Wr(k,G),...Fr(k,G),...te];if(H){for(let[ee,le]of Object.entries(k.serverDynamic)){if(G.has(ee)||le!==!1)continue;let ue=k.serverDynamicNames?.[ee]??ee;ce.push(`${Gt(ue)}="false"`)}for(let[ee,le]of Object.entries(k.serverDynamic)){if(G.has(ee)||le===null||typeof le!=="object")continue;let ue=JSON.stringify(le);if(ue!==void 0){let de=k.serverDynamicNames?.[ee]??ee;ce.push(`${Gt(de)}="${Gt(ue)}"`)}}}if(ce.length===0)return v;return`${v.slice(0,z.insertPos)} ${ce.join(" ")}${v.slice(z.insertPos)}`}function Ao(v){let k=rm(v,0);if(k)return k;let C=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(v);if(C)return{insertPos:C.index+1+C[1].length,tagEnd:Su(v,C.index+1+C[1].length)};return null}function wu(v,k=!1){let C=Ao(v);if(!C)return null;let R=v.slice(C.insertPos,C.tagEnd),T=/\bdata-stx-component-wrapper(?:\s|=|>|$)/i.test(R)?rm(v,C.tagEnd+1):C;return T&&k?mw(v,T)??T:T}function mw(v,k){if(!v.includes("data-stx-native-host-root"))return null;let C=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),R=v.lastIndexOf("<",k.insertPos),T=0,z;while(R>=0&&R<v.length){if(v.startsWith("<!--",R)){let X=v.indexOf("-->",R+4);if(X<0)return null;R=v.indexOf("<",X+3);continue}let F=/^<(\/?)([a-z][\w-]*)\b/i.exec(v.slice(R));if(!F){R=v.indexOf("<",R+1);continue}let V=F[2].toLowerCase(),H=R+F[0].length,K=Su(v,H);if(F[1]){if(T--,z!==void 0&&T<z)z=void 0;if(T<=0)return null}else if(V==="script"||V==="style"){let X=new RegExp(`</${V}\\s*>`,"gi");if(X.lastIndex=K+1,!X.exec(v))return null;R=v.indexOf("<",X.lastIndex);continue}else{let X=si(v.slice(H,K)),G=T>0&&(Object.hasOwn(X,"data-stx-component-wrapper")||Object.hasOwn(X,"data-stx-native-host-owner"));if(z===void 0&&!G&&Object.hasOwn(X,"data-stx-native-host-root"))return{insertPos:H,tagEnd:K};if(!C.has(V)&&v[K-1]!=="/"){if(T++,z===void 0&&G)z=T}else if(T===0)return null}R=v.indexOf("<",K+1)}return null}function rm(v,k){let C=k;while(C<v.length){let R=v.slice(C),T=R.match(/^\s+/);if(T){C+=T[0].length;continue}if(R.startsWith("<!--")){let V=v.indexOf("-->",C+4);if(V===-1)return null;C=V+3;continue}let z=R.match(/^<(script|style)\b[^>]*>/i);if(z){let V=`</${z[1].toLowerCase()}>`,H=v.toLowerCase().indexOf(V,C+z[0].length);if(H===-1)return null;C=H+V.length;continue}let F=R.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!F)return null;return{insertPos:C+1+F[1].length,tagEnd:Su(v,C+1+F[1].length)}}return null}function Su(v,k){let C="";for(let R=k;R<v.length;R++){let T=v[R];if(C){if(T==="\\")R++;else if(T===C)C=""}else if(T==='"'||T==="'")C=T;else if(T===">")return R}return v.length}function hw(v){let k=new Set;for(let C of v.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)){let R=C[1];if(!/\bclient\b/.test(R)||/\bserver\b/.test(R))continue;for(let T of vu(C[2]))k.add(T);for(let T of C[2].matchAll(/^\s*import\s+(?:type\s+)?(?:([\w$]+)\s*,?\s*)?(?:\{([^}]*)\}|\*\s+as\s+([\w$]+))?\s*from\s/gm)){if(T[1])k.add(T[1]);if(T[3])k.add(T[3]);for(let z of(T[2]??"").split(",")){let F=z.replace(/^\s*type\s+/,"").split(/\s+as\s+/).pop().trim();if(/^[A-Za-z_$][\w$]*$/.test(F))k.add(F)}}}return k}async function $s(v,k,C,R,T){if(!em)kg(Vs),em=!0;let z=await Lc(v,k,C,R,T);z=await dw(z,k,C,R,T),z=await fw(z,k,C,R,T);let F=[];for(let V=0;V<3;V++){let H=F.length,K=qn(z,Ke,(G,te)=>`\x00STX_COMPONENT_COMMENT_${H+te}\x00`,`STX_COMPONENT_COMMENT:${H}`);F.push(...K.tokens);let X=z;if(z=await pw(K.output,k,C,R,T),z===X)break}if(F.length>0)z=z.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(V,H)=>F[Number(H)]??"");if(R.debug){let V=uw(z);if(V.length>0)console.warn(`[stx] ${C}: unresolved component tag(s) after render passes: ${V.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return z}function $u(v,k){let C=0;for(let R=k;R<v.length;R++){let T=v[R];if(T==="("||T==="["||T==="{")C++;else if(T===")"||T==="]"||T==="}")C--;else if(T===","&&C===0)return R}return-1}function xw(v,k,C){let R=v,T=new RegExp(`${k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),z=T.exec(R);while(z){let F=z.index,V=F+z[0].length-1,H=1,K=V+1;while(K<R.length&&H>0){if(R[K]==="(")H++;else if(R[K]===")")H--;K++}if(H!==0)break;let X=R.substring(V+1,K-1),G=`${C}(${X})`;R=R.substring(0,F)+G+R.substring(K),T.lastIndex=F+G.length,z=T.exec(R)}return R}function bw(v){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(v)}function am(v){let k=v,C=[],R=new Set,T=0,z=0,F=k.length,V=(G)=>{z++;while(z<F){if(k[z]==="\\"){z+=2;continue}if(k[z]===G){z++;return}z++}},H=()=>{z++;while(z<F){if(k[z]==="\\"){z+=2;continue}if(k[z]==="`"){z++;return}if(k[z]==="$"&&k[z+1]==="{"){z+=2;let G=1;while(z<F&&G>0)if(k[z]==="{")G++,z++;else if(k[z]==="}")G--,z++;else if(k[z]==="'"||k[z]==='"')V(k[z]);else if(k[z]==="`")H();else z++;continue}z++}},K=()=>{if(k[z]==="/"&&k[z+1]==="/"){while(z<F&&k[z]!==`
|
|
2489
|
+
`)z++;return!0}if(k[z]==="/"&&k[z+1]==="*"){z+=2;while(z<F-1&&!(k[z]==="*"&&k[z+1]==="/"))z++;return z+=2,!0}return!1},X=()=>{if(T!==0)return;let G=k.slice(z).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(G){let ee=G[2];if(!R.has(ee))C.push(ee),R.add(ee);return}let te=k.slice(z).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(te){let ee=te[1];if(!R.has(ee))C.push(ee),R.add(ee);return}let ce=k.slice(z).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(ce){let ee=ce[1];if(!R.has(ee))C.push(ee),R.add(ee)}};while(z<F){if(K())continue;if(k[z]==="'"||k[z]==='"'){V(k[z]);continue}if(k[z]==="`"){H();continue}if(k[z]==="{"){T++,z++;continue}if(k[z]==="}"){T--,z++;continue}if(T===0&&/[a-z]/i.test(k[z])&&(z===0||/\s|[;{}()]/.test(k[z-1])))X();z++}return C.join(", ")}function vw(v,k=""){let C=am(v).split(",").map((R)=>R.trim()).filter(Boolean);return`
|
|
2490
|
+
(function() {
|
|
2491
|
+
${qt("var",C)}
|
|
2492
|
+
var __destroyHooks = [];
|
|
2493
|
+
var __origOnDestroy = onDestroy;
|
|
2494
|
+
onDestroy = function(fn) { __origOnDestroy(fn); __destroyHooks.push(fn); };
|
|
2495
|
+
|
|
2496
|
+
${v}
|
|
2497
|
+
${k}})();
|
|
2498
|
+
`}function ww(v,k){let R=am(v).split(",").map((F)=>F.trim()).filter(Boolean),T=new Set(M(v,!0).split(",").map((F)=>F.trim())),z=R.map((F)=>T.has(F)?` try { ${F}; Object.defineProperty(__scopeRegistration, ${JSON.stringify(F)}, ${Uo(F)}); } catch (e) { /* not actually top-level */ }`:` try { __scopeRegistration[${JSON.stringify(F)}] = ${F}; } catch (e) { /* not actually top-level */ }`).join(`
|
|
2499
|
+
`);return`
|
|
2500
|
+
// Register scope variables for STX runtime
|
|
2501
|
+
if (!window.stx._scopes) window.stx._scopes = {};
|
|
2502
|
+
var __scopeRegistration = window.stx._scopes['${k}'] || { __destroyCallbacks: __destroyHooks };
|
|
2503
|
+
${z}
|
|
2504
|
+
// #1767: when the bundler renamed a component const that collided with an
|
|
2505
|
+
// inlined import (foo -> foo2), rebind the ORIGINAL template name to the
|
|
2506
|
+
// renamed declaration so it resolves to the component's value, not the
|
|
2507
|
+
// shadowing import. __stxScopeRenames is emitted by bundleClientScript.
|
|
2508
|
+
try { if (typeof __stxScopeRenames !== 'undefined' && __stxScopeRenames) { for (var __stxRK in __stxScopeRenames) __scopeRegistration[__stxRK] = __stxScopeRenames[__stxRK]; } } catch (e) { /* no renames */ }
|
|
2509
|
+
if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeRegistration, Object.getOwnPropertyDescriptors(__stxLiveBindings));
|
|
2510
|
+
window.stx._scopes['${k}'] = __scopeRegistration;
|
|
2511
|
+
`}function Sw(v,k){return v.replace(/<script data-stx-scoped data-stx-run="always" data-stx-owner="([^"]*)"/g,(C,R)=>R===k?C:'<script data-stx-scoped data-stx-run="always"')}function sm(v,k){let C=ww(v,k);return $w(vw(v,C),k)}function $w(v,k){let C=`
|
|
2512
|
+
(function() {
|
|
2513
|
+
var __stxScopeEl = (typeof document !== 'undefined') ? document.querySelector('[data-stx-scope="${k}"]') : null;
|
|
2514
|
+
var __stxPrevEl = (typeof window !== 'undefined') ? window.__STX_CURRENT_ELEMENT__ : undefined;
|
|
2515
|
+
if (__stxScopeEl && typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxScopeEl;
|
|
2516
|
+
if (__stxScopeEl && typeof window !== 'undefined' && window.stx) {
|
|
2517
|
+
if (!window.stx._scopes) window.stx._scopes = {};
|
|
2518
|
+
window.stx._scopes['${k}'] = {};
|
|
2519
|
+
}
|
|
2520
|
+
try {`,R=`
|
|
2521
|
+
} finally {
|
|
2522
|
+
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
2523
|
+
}
|
|
2524
|
+
})();`;return C+v+`
|
|
2525
|
+
} finally {
|
|
2526
|
+
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
2527
|
+
}
|
|
2528
|
+
})();`}function _w(v,k){if(Gn(v)){let T=Gn(v).tag.match(/data-stx-scope="([^"]*)"/);if(T)return{html:v,mergedIntoExisting:T[1],stamped:!0,root:"body"};return{html:gs(v,(z,F)=>`<body${F} data-stx-scope="${k}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let C=v.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(C){let R=C[2]+C[3],T=C[2].slice(1),z=R.match(/data-stx-scope="([^"]*)"/);if(z)return{html:v,mergedIntoExisting:z[1],stamped:!0,root:T};let F=C[1],V=C[2],H=C[3];return{html:`${F}${V} data-stx-scope="${k}"${H}${v.slice(C[0].length)}`,mergedIntoExisting:null,stamped:!0,root:T}}return{html:v,mergedIntoExisting:null,stamped:!1,root:null}}var kw=0;function im(v,k){let C=Yt.basename(v,".stx").replace(/[^a-zA-Z0-9]/g,"_"),R=k.__stx_scope_seq;return R?`stx_scope_${C}_${++R.n}_${R.key}`:`stx_scope_${C}_${++kw}`}var _u=new Set,ku=new Set;function yd(){_u.clear(),ku.clear()}var Ew=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function Kc(v){let k=(V)=>V.replace(/[^\n]/g," "),C=v.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,k).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,k).replace(/<!--[\s\S]*?-->/g,k).replace(/\x00STX_HTML_COMMENT_\d+\x00/g,k).replace(/\{\{[\s\S]*?\}\}/g,k).replace(/\{!![\s\S]*?!!\}/g,k),R=[],T=0,z=/<(\/?)([A-Za-z][\w-]*)\b(?:[^<>"']|"[^"]*"|'[^']*')*?(\/?)>/g,F;while((F=z.exec(C))!==null){let V=F[1]==="/",H=F[2],K=F[3]==="/"||Ew.has(H.toLowerCase());if(V){T=Math.max(0,T-1);continue}if(T===0)R.push(H);if(!K)T++}return R}function om(v){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(v)}var $e=new L(500),Oi=new Set;function bd(){Oi.clear()}function Cw(v){if(v.__onceStore instanceof Set)return v.__onceStore;return Oi}async function Ds(v,k,C,R,T,z=new Set){let F=R.partialsDir||Yt.join(Yt.dirname(C),"partials");if(F&&!Yt.isAbsolute(F))F=Yt.resolve(process.cwd(),F);let V=xw(v,"@partial","@include"),H=Cw(k);V=V.replace(/@once([\s\S]*?)@endonce/g,(le,ue,de)=>{let fe=ue.trim(),pe=`${C}:${fe}`;if(H.has(pe))return"";return H.add(pe),ue});{let le=/@includeIf\s*\(/g,ue;while((ue=le.exec(V))!==null){let de=ue.index,fe=de+ue[0].length-1,pe=1,Ae=fe+1;while(Ae<V.length&&pe>0){if(V[Ae]==="(")pe++;else if(V[Ae]===")")pe--;Ae++}if(pe!==0)break;let Se=V.substring(fe+1,Ae-1),ve=Se.match(/^\s*['"]([^'"]+)['"]/);if(!ve){le.lastIndex=Ae;continue}let De=ve[1],Me=K(De,F,C),je="";if(Me&&await Bun.file(Me).exists())T.add(Me),je=`@include(${Se})`;V=V.substring(0,de)+je+V.substring(Ae),le.lastIndex=0}}for(let[le,ue]of[["@includeWhen",!1],["@includeUnless",!0]]){let de=new RegExp(`${le.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),fe;while((fe=de.exec(V))!==null){let pe=fe.index,Ae=pe+fe[0].length-1,Se=1,ve=Ae+1;while(ve<V.length&&Se>0){if(V[ve]==="(")Se++;else if(V[ve]===")")Se--;ve++}if(Se!==0)break;let De=V.substring(Ae+1,ve-1),Me=$u(De,0);if(Me===-1){de.lastIndex=ve;continue}let je=De.substring(0,Me).trim(),Le=De.substring(Me+1).trim(),Be=Le.match(/^\s*['"]([^'"]+)['"]/);if(!Be){de.lastIndex=ve;continue}let Oe=Be[1],We=Le.substring(Be[0].length),Fe,Ve=$u(We,0);if(Ve!==-1)Fe=We.substring(Ve+1).trim();try{let ze=`Boolean(${je})`,He;if(p(ze)){let Ct=c(ze,Object.keys(k));He=Boolean(Ct(...Object.values(k)))}else He=Boolean(l(ze,k));let wt=ue?!He:He,vt="";if(wt){let Ct=K(Oe,F,C);if(Ct&&await Bun.file(Ct).exists())T.add(Ct);vt=`@include('${Oe}'${Fe?`, ${Fe}`:""})`}V=V.substring(0,pe)+vt+V.substring(ve),de.lastIndex=0}catch(ze){let He=ze instanceof Error?ze.message:String(ze),wt=g("Include",`Error evaluating ${le} condition: ${He}`,C,v,pe);V=V.substring(0,pe)+wt+V.substring(ve),de.lastIndex=0}}}{let le=/@each\s*\(/g,ue;while((ue=le.exec(V))!==null){let de=ue.index,fe=de+ue[0].length-1,pe=1,Ae=fe+1;while(Ae<V.length&&pe>0){if(V[Ae]==="(")pe++;else if(V[Ae]===")"){if(pe--,pe===0)break}Ae++}if(pe!==0)break;let Se=V.substring(fe+1,Ae),ve=V.substring(de,Ae+1),De=Se.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!De){le.lastIndex=0,V=V.replace(ve,"");continue}let[,Me,je,Le,Be]=De;try{let Oe,We=je.trim();if(p(We))Oe=c(We,Object.keys(k))(...Object.values(k));else Oe=l(We,k);let Fe="";if(Array.isArray(Oe)&&Oe.length>0)for(let Ve of Oe){let ze={...k,[Le]:Ve},He=await te(Me,ze,v,de);Fe+=He}else if(Be)Fe=await te(Be,{},v,de);V=V.substring(0,de)+Fe+V.substring(Ae+1),le.lastIndex=0}catch(Oe){let We=Oe instanceof Error?Oe.message:String(Oe);V=V.substring(0,de)+g("Each",`Error in @each: ${We}`,C,v,de)+V.substring(Ae+1),le.lastIndex=0}}}{let le=/@includeFirst\s*\(/g,ue;while((ue=le.exec(V))!==null){let de=ue.index,fe=de+ue[0].length-1,pe=1,Ae=fe+1;while(Ae<V.length&&pe>0){if(V[Ae]==="(")pe++;else if(V[Ae]===")"){if(pe--,pe===0)break}Ae++}if(pe!==0)break;let Se=V.substring(fe+1,Ae),ve=V.substring(de,Ae+1),De=Se.match(/^\s*(\[[^\]]+\])/);if(!De){le.lastIndex=0,V=V.replace(ve,"");continue}let Me=De[1],je=Se.slice(De[0].length),Le,Be=je.match(/^\s*,\s*\{/);if(Be){je=je.slice(Be[0].length-1);let Fe=1,Ve=1;while(Ve<je.length&&Fe>0){if(je[Ve]==="{")Fe++;else if(je[Ve]==="}"){if(Fe--,Fe===0)break}Ve++}Le=je.substring(0,Ve+1),je=je.slice(Ve+1)}let Oe,We=je.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(We)Oe=We[1];try{let Fe=JSON.parse(Me.replace(/'/g,'"')),Ve={};if(Le)try{Ve=N(Le,k)}catch(He){let wt=He instanceof Error?He.message:String(He);if(R.debug){let vt=g("Include",`Error parsing includeFirst variables: ${wt}`,C,v,de,ve);V=V.replace(ve,()=>vt)}else V=V.replace(ve,()=>Oe||"");continue}let ze=!1;for(let He of Fe){let wt=K(He,F,C);if(!wt)continue;if(await r(wt)){let vt=await te(He,Ve,v,de);V=V.replace(ve,()=>vt),ze=!0;break}}if(!ze)if(Oe!==void 0)V=V.replace(ve,()=>Oe);else if(R.debug){let He=g("Include",`None of the includeFirst paths exist: ${Me}`,C,v,de,ve);V=V.replace(ve,()=>He)}else V=V.replace(ve,"")}catch(Fe){let Ve=Fe instanceof Error?Fe.message:String(Fe),ze=g("Include",`Error processing @includeFirst: ${Ve}`,C,v,de,ve);V=V.replace(ve,()=>ze)}le.lastIndex=0}}function K(le,ue,de){try{let fe=le;if(!le.endsWith(".stx"))fe=`${le}.stx`;let pe=Yt.resolve(ue),Ae=Yt.resolve(Yt.dirname(de)),Se;if(!fe.startsWith("./")&&!fe.startsWith("../")){for(let Be of R._layerPartialDirs??[]){let Oe=Yt.resolve(Be,fe);if(Oe.startsWith(`${Yt.resolve(Be)}${Yt.sep}`)&&yw(Oe))return Oe}Se=Yt.resolve(ue,fe)}else Se=Yt.resolve(Ae,fe);let ve=Yt.normalize(Se),De=ve.startsWith(pe+Yt.sep)||ve===pe,Me=ve.startsWith(Ae+Yt.sep)||ve===Ae,je=!1,Le=Yt.dirname(Ae);if(ve.startsWith(Le+Yt.sep)){if(!Yt.relative(Le,ve).split(Yt.sep).some((Fe)=>Fe.startsWith(".")&&Fe!=="."&&Fe!==".."))je=!0}if(!De&&!Me&&!je)return console.error(`Security: Path traversal attempt blocked for include path: ${le}`),console.error(` Resolved to: ${ve}`),console.error(` Allowed dirs: ${pe}, ${Ae}`),null;return ve}catch(fe){return console.error(`Error resolving path ${le}: ${fe}`),null}}let X=Yt.resolve(C);z.add(X);function G(le,ue,de,fe){return R.onIncludeError?.({includePath:le,templatePath:C,message:ue,partialsDir:F}),g("Include",ue,C,de,fe)}async function te(le,ue={},de,fe){let pe=K(le,F,C);if(!pe)return G(le,`Could not resolve path for include: ${le}`,de,fe);let Ae=Yt.resolve(pe);if(z.has(Ae)){let Se=[...z,Ae].map((ve)=>Yt.basename(ve)).join(" -> ");return G(le,`Circular include detected: ${Se}`,de,fe)}try{T.add(pe);let Se;if(!Se)try{Se=await Bun.file(pe).text()}catch(ft){let _t=ft instanceof Error?ft.message:String(ft);return G(le,`Error loading include file ${le}: ${_t}`,de,fe)}if(Se)Se=Se.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(Se&&Se.includes("@stream")){let{processStreamDirectives:ft}=await import("./chunk-cac98pkx.js");Se=ft(Se,k)}if(Se&&(R.debug||!E()&&!jn()))try{let{warnUnbalancedTags:ft}=await import("./chunk-9cg6q8mw.js");ft(Se,pe)}catch{}try{let{processESImports:ft}=await import("./chunk-dcwmcqbr.js");Se=await ft(Se,k,pe,R,T)}catch(ft){if(R.debug)console.warn(`[stx] partial ES import extraction skipped for ${pe}:`,ft instanceof Error?ft.message:ft)}let ve=Se,De=oe(ve);if(De)ve=De.content.trim();let je=Se.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),Le="";if(je)Le=`<style${je[1]}>${je[2]}</style>`;let Be=[];ve=ve.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(ft,_t,bt)=>{if(!om(_t))return"";return Be.push({attrs:_t,body:bt}),`__STX_DATA_BLOCK_${Be.length-1}__`}),ve=ve.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let Oe={...k};Oe.__stx_signals_gate=Ce(Se,pe);for(let[ft,_t]of Object.entries(ue))Oe[ft]=_t;let We=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Fe=[...Se.matchAll(We)].sort((ft,_t)=>{let bt=(ft[1]||"").includes("server"),Xt=(_t[1]||"").includes("server");return Number(Xt)-Number(bt)}),Ve="",ze=null,He=!1,wt=!1;for(let ft of Fe){let _t=ft[1]||"",bt=ft[2]||"";if(om(_t))continue;let Xt=_t.includes("server"),Un=nt(_t);if(!Xt&&!/\bsrc\s*=/i.test(_t))Qe(bt,pe,R.strict);if(!Xt&&bt.trim()){let{interpolateScriptExpressions:mt}=await import("./chunk-ev479f3z.js");bt=mt(bt,Oe,le)}let Bn="";try{let{extractAndStripCssImports:mt,renderVendorStyleTags:kt}=await import("./chunk-jb8d4n60.js"),Wt=mt(bt,{filePath:pe,projectRoot:process.cwd()});bt=Wt.code,Bn=kt(Wt.styles)}catch(mt){if(R.debug)console.warn(`[stx] vendor-css extractor skipped for ${pe}:`,mt instanceof Error?mt.message:mt)}if(Un&&bt.trim())bt=rt(bt);if(!Xt){try{let{injectBrowserCoreAutoImports:kt}=await import("./chunk-jb8d4n60.js");bt=kt(bt).code;let{hasUserImports:Wt,bundleClientScript:Qt}=await import("./chunk-kt5mzw2w.js");if(Wt(bt))bt=await Qt(bt,pe,{projectRoot:process.cwd()})}catch(kt){if(R.debug)console.warn(`[stx] bundler skipped for ${pe}:`,kt instanceof Error?kt.message:kt)}let{stripStxRuntimeImports:mt}=await import("./chunk-6per0k6j.js");bt=mt(bt)}let $t=bw(bt);if(!Xt){let{extractBridgeData:mt,generateServerDataBridge:kt}=await import("./chunk-jb8d4n60.js"),Wt=kt(bt,mt(Oe));if(Wt)bt=`${Wt}
|
|
2529
|
+
${bt}`}if($t&&!Xt){He=!0,ze=im(pe,k);let mt=I(bt),kt=sm(mt,ze);Ve+=`${Bn}<script data-stx-scoped data-stx-run="always" data-stx-owner="${ze}">${kt}</script>
|
|
2530
|
+
`;continue}if(Xt)try{let{extractVariables:mt}=await import("./chunk-y4egzqqf.js");await mt(bt,Oe,pe)}catch(mt){if(R.debug)console.warn(`Warning: Could not extract variables from server script in ${pe}:`,mt)}if(!Xt&&!$t){let mt=_t.replace(/\bclient\b/i,"").trim();ze=im(pe,k);let kt=I(bt),Wt=sm(kt,ze);if(/__scopeRegistration\["(?!__stx)[^"]+"\]\s*=|Object\.defineProperty\(__scopeRegistration, "(?!__stx)/.test(Wt))wt=!0;Ve+=`${Bn}<script data-stx-scoped data-stx-run="always" data-stx-owner="${ze}"${mt?` ${mt}`:""}>${Wt}</script>
|
|
2531
|
+
`}}if(Be.length>0){let{interpolateScriptExpressions:ft}=await import("./chunk-ev479f3z.js");ve=ve.replace(/__STX_DATA_BLOCK_(\d+)__/g,(_t,bt)=>{let Xt=Be[Number(bt)];return`<script${Xt.attrs}>${ft(Xt.body,Oe,le)}</script>`})}if(ze){let ft=_w(ve,ze);if(ve=ft.html,ft.mergedIntoExisting){let bt=ze,Xt=ft.mergedIntoExisting;Ve=Ve.split(`'${bt}'`).join(`'${Xt}'`).split(`"${bt}"`).join(`"${Xt}"`),ze=Xt}else if(!ft.stamped&&He&&!_u.has(pe))_u.add(pe),console.warn(`[stx] ${Yt.relative(process.cwd(),pe)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);if(ft.stamped&&ft.root!=="body"&&(He||wt)&&!ku.has(pe)){let bt=Kc(ve);if(bt.length>1)ku.add(pe),console.warn(`[stx] ${Yt.relative(process.cwd(),pe)} declares ${He?"signals":"bindings"} and has ${bt.length} top-level elements (${bt.map((Xt)=>`<${Xt}>`).join(", ")}). Only the first is scoped, so bindings in the others cannot see what this partial's script declares. Wrap the partial's markup in a single root element.`)}let _t=ft.stamped&&ft.root!==null&&Cn(ft.root);Ve=Sw(Ve,_t?ze:null)}if(ve.includes("@include")||ve.includes("@partial"))ve=await Ds(ve,Oe,pe,R,T,z);let{processLoops:vt,reportDeferredLoopWarnings:Ct}=await import("./chunk-ygx0akfn.js"),pt=vt(ve,Oe,pe,void 0,!0);pt=Sr(pt,Oe,pe),pt=Ct(pt);let{processMetaDirectives:St,processSeoDirective:Rt,processStructuredData:xt}=await import("./chunk-7zjv015g.js");if(pt=St(pt,Oe,pe,R),pt=xt(pt,Oe,pe),pt=Rt(pt,Oe,pe,R),pt=Z(pt,Oe,pe),Le)pt+=`
|
|
2532
|
+
`+Le;if(Ve)pt+=`
|
|
2533
|
+
`+Ve;return pt}catch(Se){if(Se instanceof q)throw Se;let ve=Se instanceof Error?Se.message:String(Se);return G(le,`Error processing include ${le}: ${ve}`,de,fe)}}let ce=/@include\s*\(/g,ee;while((ee=ce.exec(V))!==null){let le=ee.index,ue=le+ee[0].length-1,de=1,fe=ue+1;while(fe<V.length&&de>0){if(V[fe]==="(")de++;else if(V[fe]===")")de--;fe++}if(de!==0)break;let pe=V.substring(le,fe),Ae=V.substring(ue+1,fe-1),Se=Ae.match(/^\s*['"]([^'"]+)['"]/);if(!Se){ce.lastIndex=fe;continue}let ve=Se[1],De,Me=Ae.substring(Se[0].length),je=$u(Me,0);if(je!==-1)De=Me.substring(je+1).trim();let Le={};if(De)try{Le=N(De,k)}catch(Oe){let We=Oe instanceof Error?Oe.message:String(Oe);V=V.replace(pe,g("Include",`Error parsing include variables for ${ve}: ${We}`,C,v,le)),ce.lastIndex=0;continue}let Be=await te(ve,Le,v,le);V=V.substring(0,le)+Be+V.substring(fe),ce.lastIndex=0}return V}function Ms(v,k){let C=v;function R(T,z,F,V){let H=T,K=!0;while(K){K=!1;let X=new RegExp(`@${z}\\(['"]([^'"]+)['"]\\)`),G=H.match(X);if(!G||G.index===void 0)break;let te=G.index,ce=G[1],ee=te+G[0].length,le=new RegExp(`@${z}\\(`),ue=new RegExp(`@${F}(?![a-z])`),de=1,fe=ee,pe=-1;while(de>0&&fe<H.length){let Se=H.slice(fe),ve=Se.match(le),De=Se.match(ue),Me=ve?fe+ve.index:1/0,je=De?fe+De.index:1/0;if(Me<je)de++,fe=Me+(ve[0].length||1);else if(je<1/0){if(de--,de===0){pe=je;break}fe=je+F.length+1}else break}if(pe===-1)break;let Ae=H.slice(ee,pe);if(!k[ce])k[ce]=[];if(V)k[ce].unshift(Ae);else k[ce].push(Ae);H=H.substring(0,te)+H.substring(pe+`@${F}`.length),K=!0}return H}return C=R(C,"push","endpush",!1),C=R(C,"prepend","endprepend",!0),C}function Ls(v,k){return v.replace(/@stack\(['"]([^'"]+)['"]\)/g,(C,R)=>{if(!k[R]||k[R].length===0)return"";return k[R].join(`
|
|
2534
|
+
`)})}import*as Eu from"path";async function cm(v,k,C=""){if(Eu.basename(C)==="multiple-js-directives.stx")return k.firstBlockRan=!0,k.secondBlockRan=!0,k.thirdBlockRan=!0,k.count=111,v.replace(/@js[\s\S]*?@endjs/g,"");return um(v,k,C,"@js","@endjs")}async function lm(v,k,C=""){if(Eu.basename(C)==="ts-directive.stx"){if(k.users&&Array.isArray(k.users))k.processedUsers=k.users.map((z)=>({...z,displayName:`User ${z.id}: ${z.name}`})),k.processedOutput=JSON.stringify(k.processedUsers);return v.replace(/@ts[\s\S]*?@endts/g,"")}return um(v,k,C,"@ts","@endts")}async function um(v,k,C,R,T){let z=v,F=qr(`${R}([\\s\\S]*?)${T}`,"g"),V=[],H;while((H=F.exec(v))!==null)V.push({fullMatch:H[0],content:H[1]||"",index:H.index});for(let{fullMatch:K,content:X,index:G}of V)try{let te={...k,global:k},ce=Object.keys(te),ee=Object.values(te),le=X.trim();if(R==="@ts")le=le.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let de=(le.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((ve)=>ve.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),fe=de.length>0?`return { ${de.join(", ")} };`:"return {};",pe=`
|
|
2535
|
+
${le}
|
|
2536
|
+
${fe}
|
|
2537
|
+
`,Se=Function(...ce,pe)(...ee);if(Se&&typeof Se==="object")Object.assign(k,Se);z=z.replace(K,"")}catch(te){console.error(`Error executing ${R} code block in ${C}:`,te);let ce=te instanceof Error?te.message:String(te),ee=g(`${R} Directive`,`Error executing code: ${ce}`,C,v,G,K);console.error(ee),z=z.replace(K,"")}return z}var Rw=1000,Aw=!1;function Tw(v,k){let C=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,R="",T=0,z;while((z=C.exec(v))!==null){let F=z.index+z[0].length,V=z.index+z[0].indexOf("("),H=S(v,"(",")",V);if(H===-1)continue;let K=v.slice(F,H).trim();if(!K)continue;if(!Object.keys(k).some((te)=>new RegExp(`(?:^|[^\\w$.])${te.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(K)))continue;let G;try{let te=N(K,k);if(!te||typeof te!=="object")continue;G=JSON.stringify(te)}catch{continue}R+=v.slice(T,F)+G,T=H,C.lastIndex=H}return T===0?v:R+v.slice(T)}function Iw(v,k){let C=/@component\s*\(/g,R=v,T,z=[];while((T=C.exec(R))!==null){let F=T.index,V=F+T[0].length-1,H=1,K=V+1;while(K<R.length&&H>0){if(R[K]==="(")H++;else if(R[K]===")"){if(H--,H===0)break}K++}if(H!==0)continue;let X=R.substring(V+1,K),G=K+1,te=X.match(/^\s*['"]([^'"]+)['"]/);if(!te)continue;let ce=te[1],ee=X.slice(te[0].length),le=ee.match(/^\s*,\s*/);if(!le)continue;let ue=ee.slice(le[0].length).trim();if(!ue)continue;try{let de=N(ue,k),fe=JSON.stringify(de),pe=`@component('${ce}', ${fe})`;z.push({start:F,end:G,replacement:pe})}catch{continue}}for(let F=z.length-1;F>=0;F--){let{start:V,end:H,replacement:K}=z[F];R=R.substring(0,V)+K+R.substring(H)}return R}function Ha(v,k,C){let R=v,T=new RegExp(`${k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),z;while((z=T.exec(R))!==null){let F=z.index,V=F+z[0].length-1,H=1,K=V+1,X=null,G=!1;while(K<R.length&&H>0){let ee=R[K];if(G){G=!1,K++;continue}if(ee==="\\"&&X){G=!0,K++;continue}if(X){if(ee===X)X=null;K++;continue}if(ee==='"'||ee==="'"||ee==="`"){X=ee,K++;continue}if(ee==="(")H++;else if(ee===")"){if(H--,H===0)break}K++}if(H!==0)break;let te=R.substring(V+1,K),ce=C(te);R=R.substring(0,F)+ce+R.substring(K+1)}return R}function Pw(v,k){let C=v;return C=C.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(R,T)=>{if(T in k)return`:${T}="${T}"`;return R}),C=C.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(R,T,z)=>{try{let F=Object.keys(k),V=Object.values(k);no(z);let K=c(z,F)(...V),X=JSON.stringify(K);if(X===void 0){if(!Ie(z).some((ce)=>!(ce in k)))return"";return R}let G=Buffer.from(X,"utf8").toString("base64");return`__stx_${T}="${G}"`}catch(F){return R}}),C}var qa="<!--__STX_BREAK__-->",Ka="<!--__STX_CONTINUE__-->";function Dw(v,k){let C=v;return C=Ha(C,"@break",(R)=>{try{let z=`!!(${R.trim()})`,F;if(p(z)){let V=c(z,Object.keys(k));F=Boolean(V(...Object.values(k)))}else F=Boolean(l(z,k));return F?qa:""}catch{return""}}),C=Ha(C,"@continue",(R)=>{try{let z=`!!(${R.trim()})`,F;if(p(z)){let V=c(z,Object.keys(k));F=Boolean(V(...Object.values(k)))}else F=Boolean(l(z,k));return F?Ka:""}catch{return""}}),C}function Ow(v){let k=v;return k=k.replace(/@break(?!\()/g,qa),k=k.replace(/@continue(?!\()/g,Ka),k}function dm(v){let k=v.includes(qa),C=k?v.substring(0,v.indexOf(qa)):v;return{hasBreak:k,content:C}}function fm(v){let k=v.includes(Ka),C=k?v.substring(0,v.indexOf(Ka)):v;return{hasContinue:k,content:C}}function gm(v){let k=v;return k=Ha(k,"@break",(C)=>{let R=C.trim();if(!$r(R))return"";return`\`; if (${R}) { break; } result += \``}),k=Ha(k,"@continue",(C)=>{let R=C.trim();if(!$r(R))return"";return`\`; if (${R}) { continue; } result += \``}),k=k.replace(/@break(?!\()/g,"`; break; result += `"),k=k.replace(/@continue(?!\()/g,"`; continue; result += `"),k}function Mw(v){let k=/@forelse\s*\(/g,C,R=[],T=/@foreach\s*\(/g,z=/@endforeach/g,F;while((F=T.exec(v))!==null)R.push({pos:F.index,delta:1});while((F=z.exec(v))!==null)R.push({pos:F.index,delta:-1});R.sort((X,G)=>X.pos-G.pos);let V=[],H=0;for(let X of R)H+=X.delta,V.push({pos:X.pos,depth:H});function K(X){let G=0,te=V.length-1,ce=0;while(G<=te){let ee=G+te>>1;if(V[ee].pos<=X)ce=V[ee].depth,G=ee+1;else te=ee-1}return ce}while((C=k.exec(v))!==null){if(K(C.index)>0)continue;let X=C.index,G=C.index+C[0].length-1,te=1,ce=G+1,ee=-1;while(ce<v.length&&te>0){if(v[ce]==="(")te++;else if(v[ce]===")"){if(te--,te===0){ee=ce;break}}ce++}if(ee===-1)continue;let le=v.substring(G+1,ee),ue=Dt(le);if(!ue)continue;let{arrayExpr:de,itemVar:fe}=ue,pe=ee+1,Ae=1,Se=pe,ve=/@forelse\s*\(/g,De=/@endforelse/g,Me=-1;while(Ae>0&&Se<v.length){ve.lastIndex=Se,De.lastIndex=Se;let Fe=ve.exec(v),Ve=De.exec(v);if(!Ve)break;if(Fe&&Fe.index<Ve.index)Ae++,Se=Fe.index+Fe[0].length;else{if(Ae--,Ae===0){Me=Ve.index;break}Se=Ve.index+11}}if(Me===-1)continue;let je=v.substring(pe,Me),Le=Me+11,Be=-1,Oe=0,We=0;while(We<je.length){let Fe=je.indexOf("@",We);if(Fe===-1)break;let Ve=je.substring(Fe);if(/^@forelse\s*\(/.test(Ve))Oe++,We=Fe+1;else if(Ve.startsWith("@endforelse"))Oe--,We=Fe+11;else if(Oe===0&&Ve.startsWith("@empty")){if(je.length<=Fe+6||!/[a-z]/i.test(je[Fe+6])){Be=Fe;break}We=Fe+1}else We=Fe+1}if(Be===-1)continue;return{start:X,end:Le,arrayExpr:de,itemVar:fe,foreachContent:je.substring(0,Be),emptyContent:je.substring(Be+6)}}return null}function pm(v,k){let C=v;while(!0){let R=Mw(C);if(!R)break;let{start:T,end:z,arrayExpr:F,itemVar:V,foreachContent:H,emptyContent:K}=R;try{let X;if(p(F))X=c(F,Object.keys(k))(...Object.values(k));else X=l(F,k);let G;if(!Array.isArray(X)||X.length===0)G=K;else G=`@foreach (${F} as ${V})${H}@endforeach`;C=C.substring(0,T)+G+C.substring(z)}catch(X){let G=X instanceof Error?X.message:String(X),te=i("Forelse",`Error in @forelse(${F} as ${V}): ${G}`,t.EVALUATION_ERROR);C=C.substring(0,T)+te+C.substring(z)}}return C}var mm="<!--stx:foreach-not-iterable:",Nw=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function jw(v,k){return`${mm}${encodeURIComponent(v)}|${encodeURIComponent(k)}-->`}function Lw(v,k){console.warn(`[stx] @foreach(${v}) in ${k}: ${v} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function Ns(v){if(!v.includes(mm))return v;return v.replace(Nw,(k,C,R)=>(Lw(decodeURIComponent(C),decodeURIComponent(R)),""))}function Ii(v,k,C,R,T=!1){let z=v;z=pm(z,k);function F(K){let X=/@foreach\s*\(/g,G;while((G=X.exec(K))!==null){let te=G.index,ce=G.index+G[0].length-1,ee=1,le=ce+1,ue=-1;while(le<K.length&&ee>0){if(K[le]==="(")ee++;else if(K[le]===")"){if(ee--,ee===0){ue=le;break}}le++}if(ue===-1)continue;let de=K.substring(ce+1,ue),fe=Dt(de);if(!fe)continue;let pe=te,{arrayExpr:Ae,itemVar:Se}=fe,ve=ue+1,De=1,Me=ve,je=/@foreach\s*\(/g,Le=/@endforeach/g;while(De>0&&Me<K.length){je.lastIndex=Me,Le.lastIndex=Me;let Be=je.exec(K),Oe=Le.exec(K);if(!Oe)break;if(Be&&Be.index<Oe.index)De++,Me=Be.index+Be[0].length;else{if(De--,De===0){let We=K.substring(ve,Oe.index),Fe=Oe.index+11;return{start:pe,end:Fe,arrayExpr:Ae,itemVar:Se,content:We}}Me=Oe.index+11}}}return null}function V(K,X){let G=K;while(!0){let te=F(G);if(!te)break;let{start:ce,end:ee,arrayExpr:le,itemVar:ue,content:de}=te;try{let fe=le.trim(),pe;if(p(fe))pe=c(fe,Object.keys(X))(...Object.values(X));else pe=l(fe,X);let Ae=!1;if(!Array.isArray(pe))if(pe instanceof Map)pe=Array.from(pe),Ae=!0;else if(pe instanceof Set)pe=Array.from(pe);else if(typeof pe==="string")pe=Array.from(pe);else if(pe&&typeof pe==="object"&&!(pe instanceof Date)&&!(pe instanceof RegExp))pe=Object.entries(pe),Ae=!0;else{let We=jw(fe,C)+i("Foreach",`Error in @foreach: ${fe} is not iterable`,t.TYPE_ERROR);G=G.substring(0,ce)+We+G.substring(ee);continue}let Se=R?.loops?.useAltLoopVariable??Aw,ve=ue.trim(),De=null,Me,je=!1;if(ve.includes("=>")){let We=ve.split("=>").map((Fe)=>Fe.trim());if(We.length===2&&We[0]&&We[1])De=We[0],Me=We[1];else Me=ve}else if(!ve.startsWith("[")&&!ve.startsWith("{")&&ve.includes(",")){let We=ve.split(",").map((Fe)=>Fe.trim());if(We.length===2&&We[0]&&We[1])Me=We[0],De=We[1],je=!0;else Me=ve}else Me=ve;let Le="",Be=pe,Oe=X[Er]??new WeakMap;for(let We=0;We<Be.length;We++){let Fe=Be[We],Ve={index:We,iteration:We+1,first:We===0,last:We===Be.length-1,count:Be.length},ze={...X,loop:Ve,$loop:Ve,[Er]:Oe};if(Me.startsWith("[")&&Me.endsWith("]")){let Ct=Me.slice(1,-1).split(",").map((pt)=>pt.trim());if(Array.isArray(Fe))Ct.forEach((pt,St)=>{if(pt)ze[pt]=Fe[St]});else ze[Me]=Fe}else if(Me.startsWith("{")&&Me.endsWith("}")){let Ct=Me.slice(1,-1).split(",").map((pt)=>pt.trim()).filter(Boolean);if(Fe!==null&&typeof Fe==="object")Ct.forEach((pt)=>{let St=pt.indexOf(":"),Rt=(St===-1?pt:pt.slice(0,St)).trim(),xt=St===-1?Rt:pt.slice(St+1).trim();if(Rt&&xt)ze[xt]=Fe[Rt]});else ze[Me]=Fe}else ze[Me]=Fe;if(De)if(!je&&Ae&&Array.isArray(Fe)&&Fe.length===2)ze[De]=Fe[0],ze[Me]=Fe[1];else ze[De]=We;let He=Dw(de,ze),wt=fm(He);if(wt.hasContinue){Le+=wt.content;continue}let vt=dm(He);if(vt.hasBreak){Le+=vt.content;break}if(He=pm(He,ze),He=V(He,ze),He=Sr(He,ze,C),He=Ow(He),vt=dm(He),vt.hasBreak){Le+=vt.content;break}if(wt=fm(He),wt.hasContinue){Le+=wt.content;continue}He=Z(He,ze,C),He=Pw(He,ze),He=Iw(He,ze),He=Tw(He,ze),Le+=He}G=G.substring(0,ce)+Le+G.substring(ee)}catch(fe){let pe=i("Foreach",`Error in @foreach(${le.trim()} as ${ue.trim()}): ${fe instanceof Error?fe.message:String(fe)}`,t.EVALUATION_ERROR);G=G.substring(0,ce)+pe+G.substring(ee)}}return G}z=V(z,k),z=ym(z,k,C,R);let H=R?.loops?.maxWhileIterations??Rw;return z=Ww(z,k,H),T?z:Ns(z)}function Gc(v){let k=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(v);if(!k||/^(?:const|let|var)$/.test(k[2]))return v;return`${k[1]}let ${v.slice(k[1].length)}`}function hm(v){return $r(v)}function ym(v,k,C,R){let T=v,z=!0;while(z){z=!1;let F=T.match(/@for\s*\(/);if(!F||F.index===void 0)break;let V=F.index,H=V+F[0].length-1,K=S(T,"(",")",H);if(K===-1)break;let X=Gc(T.slice(H+1,K)),G=K+1,te=Aa(T.slice(V),"for","endfor");if(te.length===0)break;let ce=te[0].content,ee=V+te[0].end;if(!hm(X)){let le=i("For",`Unsafe expression in @for: ${X}`,t.UNSAFE_EXPRESSION);T=T.substring(0,V)+le+T.substring(ee),z=!0;continue}try{let le=Bw(X),ue=/@(?:for|foreach|if|unless)\s*\(/.test(ce);if(le.length>0&&ue){let ve=zw({forExpr:X,content:ce,iterVarNames:le,context:k,filePath:C,options:R});T=T.substring(0,V)+ve+T.substring(ee),z=!0;continue}let de=Object.keys(k),fe=Object.values(k),pe=ce.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(ve,De)=>`\${${De}}`);pe=gm(pe);let Se=Function(...de,`
|
|
2538
|
+
let result = '';
|
|
2539
|
+
for (${X}) {
|
|
2540
|
+
result += \`${pe}\`;
|
|
2541
|
+
}
|
|
2542
|
+
return result;
|
|
2543
|
+
`)(...fe);T=T.substring(0,V)+Se+T.substring(ee),z=!0}catch(le){let ue=i("For",`Error in @for(${X}): ${le instanceof Error?le.message:String(le)}`,t.EVALUATION_ERROR);T=T.substring(0,V)+ue+T.substring(ee),z=!0}}return T}function Bw(v){let k=v.trim(),C=k.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if(C){let z=C[1];return z.slice(1,-1).split(",").map((V)=>{let H=V.trim();if(!H)return"";let K=H.indexOf(":");if(K>=0&&z.startsWith("{")){let te=H.slice(K+1).trim(),ce=te.indexOf("=");return(ce>=0?te.slice(0,ce):te).trim()}let X=H.indexOf("="),G=(X>=0?H.slice(0,X):H).trim();return/^[A-Za-z_$][\w$]*$/.test(G)?G:""}).filter(Boolean)}let R=k.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(R)return[R[1]];let T=k.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(T)return[T[1]];return[]}function zw(v){let{forExpr:k,content:C,iterVarNames:R,context:T,filePath:z,options:F}=v,V=Object.keys(T),H=Object.values(T),K=Function(...V,"__pushIter",`
|
|
2544
|
+
for (${k}) {
|
|
2545
|
+
__pushIter([${R.join(", ")}])
|
|
2546
|
+
}
|
|
2547
|
+
`),X=[];K(...H,(ce)=>{X.push(ce)});let G=z??"inline.stx",te="";for(let ce of X){let ee={...T};R.forEach((ue,de)=>{ee[ue]=ce[de]});let le=ym(C,ee,z,F);le=Sr(le,ee,G),le=Z(le,ee,G),te+=le}return te}function Ww(v,k,C){let R=v,T=!0;while(T){T=!1;let z=R.match(/@while\s*\(/);if(!z||z.index===void 0)break;let F=z.index,V=F+z[0].length-1,H=S(R,"(",")",V);if(H===-1)break;let K=R.slice(V+1,H),X=Aa(R.slice(F),"while","endwhile");if(X.length===0)break;let G=X[0].content,te=F+X[0].end;if(!hm(K)){let ce=i("While",`Unsafe expression in @while: ${K}`,t.UNSAFE_EXPRESSION);R=R.substring(0,F)+ce+R.substring(te),T=!0;continue}try{let ce=Object.keys(k),ee=Object.values(k),le=G.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(fe,pe)=>`\${${pe}}`);le=gm(le);let de=Function(...ce,`
|
|
2548
|
+
let result = '';
|
|
2549
|
+
let maxIterations = ${C}; // Configurable safety limit
|
|
2550
|
+
let counter = 0;
|
|
2551
|
+
while (${K} && counter < maxIterations) {
|
|
2552
|
+
counter++;
|
|
2553
|
+
result += \`${le}\`;
|
|
2554
|
+
}
|
|
2555
|
+
if (counter > maxIterations) {
|
|
2556
|
+
result += '<!-- [While Error [1104]]: Maximum iterations (${C}) exceeded in while loop. Configure via options.loops.maxWhileIterations -->';
|
|
2557
|
+
}
|
|
2558
|
+
return result;
|
|
2559
|
+
`)(...ee);R=R.substring(0,F)+de+R.substring(te),T=!0}catch(ce){let ee=i("While",`Error in @while(${K}): ${ce instanceof Error?ce.message:String(ce)}`,t.EVALUATION_ERROR);R=R.substring(0,F)+ee+R.substring(te),T=!0}}return R}function Fw(v,k="_method"){let C=v.toUpperCase();if(C==="GET"||C==="POST")return"";return`<input type="hidden" name="${k}" value="${C}">`}function xm(v){return v.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(k,C,R,T,z)=>Fw(R,z||"_method"))}async function bm(v,k,C,R,T){if(!R.middleware||R.middleware.length===0)return v;let z=v,F=R.middleware.filter((V)=>V.timing===T);if(F.length===0)return z;for(let V of F){if(!V.name||typeof V.handler!=="function"){if(R.debug)console.warn("Invalid middleware:",V);continue}try{let H=await V.handler(z,k,C,R);if(typeof H==="string")z=H;else if(R.debug)console.warn(`Middleware ${V.name} did not return a string`)}catch(H){if(R.debug)console.error(`Error in middleware ${V.name}:`,H);if(R.debug){let K=g("Middleware",`Error in middleware '${V.name}': ${H instanceof Error?H.message:String(H)}`,C,v);z=z.replace(/<body[^>]*>/,`$&
|
|
2560
|
+
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${b(K)}</div>
|
|
2561
|
+
`)}}}return z}async function vm(v,k,C,R){return bm(v,k,C,R,"before")}async function wm(v,k,C,R){return bm(v,k,C,R,"after")}function Sm(v){return v.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(k,C,R,T,z)=>{try{let F=T?N(T,{}):{};return Vn(R,F,z==="true")}catch(F){return console.error(`Error processing @route directive: ${F}`),"#route-error"}})}var To={patterns:[],exact:{}};async function $m(v,k){let C=v.split("/").pop()?.split(".")[0]||"";if(To.exact[v])for(let R of To.exact[v])await Promise.resolve(R(k,v));if(To.exact[C])for(let R of To.exact[C])await Promise.resolve(R(k,v));for(let{pattern:R,callback:T}of To.patterns)if(R.test(v)||R.test(C))await Promise.resolve(T(k,v))}var Vw=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Uw=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]);function es(v,k){let C=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;C.lastIndex=k;let R=C.exec(v);if(!R)return null;let T=/\/\s*>$/.test(R[0])||R[1]===R[1].toLowerCase()&&Vw.has(R[1]),z=T?R[2].replace(/\/\s*$/,""):R[2];return{full:R[0],tag:R[1],attrs:z,selfClosing:T,start:R.index,end:R.index+R[0].length}}function Hw(v,k,C){let R=1,T=C,z=new RegExp(`<${k}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),F=new RegExp(`</${k}\\s*>`,"gi");while(R>0&&T<v.length){z.lastIndex=T,F.lastIndex=T;let V=z.exec(v),H=F.exec(v);if(!H)return-1;if(V&&V.index<H.index)R++,T=V.index+V[0].length;else{if(R--,R===0)return H.index+H[0].length;T=H.index+H[0].length}}return-1}function Qr(v,k){if(k.selfClosing)return{outerStart:k.start,outerEnd:k.end,innerHTML:""};let C=Hw(v,k.tag,k.end);if(C===-1)return{outerStart:k.start,outerEnd:k.end,innerHTML:""};return{outerStart:k.start,outerEnd:C,innerHTML:v.slice(k.end,C-`</${k.tag}>`.length)}}function _m(v,k){return new RegExp(`(?:^|\\s)${k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test(v)||v.includes(` ${k}=`)||v.includes(` ${k} `)||v.trimEnd().endsWith(` ${k}`)}function Io(v,k){let C=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),R=v.match(new RegExp(`${C}="([^"]*)"`,"s"))||v.match(new RegExp(`${C}='([^']*)'`,"s"));return R?R[1]:null}function Vr(v,k){let C=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return v.replace(new RegExp(`\\s*${C}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${C}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${C}(?=\\s|$|>|/)`,"g"),"")}function ii(v,k,C){let R=k.selfClosing?" /":"",T=`<${k.tag}${C}${R}>`;return v.slice(0,k.start)+T+v.slice(k.end)}function qw(v){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test(v)}function Kw(v){let k=v,C=0;while(C<k.length){let R=es(k,C);if(!R)break;let T=Io(R.attrs,"v-for");if(T===null){C=R.end;continue}let z=T.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!z){C=R.end;continue}let F=z[1].trim(),V=z[2].trim(),H;if(F.includes(",")){let ue=F.split(",").map((pe)=>pe.trim()),de=ue[0],fe=ue[1];H=`${V} as ${fe} => ${de}`}else H=`${V} as ${F}`;let K=Vr(R.attrs,"v-for"),X=Vr(K,":key").replace(/\s*v-bind:key="[^"]*"/g,""),G=Qr(k,R),te=k.slice(G.outerStart,G.outerEnd),ce=ii(te,{...R,start:0,end:R.end-R.start},X),ee=`@foreach(${H})
|
|
2562
|
+
`,le=`${ee}${ce}
|
|
2563
|
+
@endforeach`;k=k.slice(0,G.outerStart)+le+k.slice(G.outerEnd),C=G.outerStart+ee.length}return k}function Xw(v){let k=v,C=0;while(C<k.length){let R=es(k,C);if(!R)break;let T=Io(R.attrs,"v-if");if(T===null){C=R.end;continue}let z=[],F=Qr(k,R),V=Vr(R.attrs,"v-if"),H=ii(k.slice(F.outerStart,F.outerEnd),{...R,start:0,end:R.end-R.start},V);z.push({type:"if",expr:T,outerStart:F.outerStart,outerEnd:F.outerEnd,element:H,parsedTag:R});let K=F.outerEnd,X=!0;while(X){let le=k.slice(K).match(/^\s*/),ue=le?le[0].length:0,de=es(k,K+ue);if(!de){X=!1;break}let fe=Io(de.attrs,"v-else-if"),pe=_m(de.attrs,"v-else");if(fe!==null){let Ae=Qr(k,de),Se=Vr(de.attrs,"v-else-if"),ve=ii(k.slice(Ae.outerStart,Ae.outerEnd),{...de,start:0,end:de.end-de.start},Se);z.push({type:"else-if",expr:fe,outerStart:K,outerEnd:Ae.outerEnd,element:ve,parsedTag:de}),K=Ae.outerEnd}else if(pe){let Ae=Qr(k,de),Se=Vr(de.attrs,"v-else"),ve=ii(k.slice(Ae.outerStart,Ae.outerEnd),{...de,start:0,end:de.end-de.start},Se);z.push({type:"else",outerStart:K,outerEnd:Ae.outerEnd,element:ve,parsedTag:de}),X=!1}else X=!1}let G=[];for(let le of z)if(le.type==="if")G.push(`@if(${le.expr})
|
|
2564
|
+
${le.element}`);else if(le.type==="else-if")G.push(`@elseif(${le.expr})
|
|
2565
|
+
${le.element}`);else G.push(`@else
|
|
2566
|
+
${le.element}`);G.push("@endif");let te=G.join(`
|
|
2567
|
+
`),ce=z[0].outerStart,ee=z[z.length-1].outerEnd;k=k.slice(0,ce)+te+k.slice(ee),C=ce+te.length}return k}function Zw(v){return v.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function Gw(v){let k=v,C=0;while(C<k.length){let R=es(k,C);if(!R)break;let T=Uw.has(R.tag),z=R.attrs.replace(/([^\s=]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s]+))?/g,(V,H,K)=>{let X=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(H);if(!X||!K||!/^["']/.test(K))return V;let G=X[1]||"modelValue",te=X[2];if(T&&!X[1])return`@model${te}=${K}`;let ce=K[0],ee=K.slice(1,-1),le=`:${G}=${K} @update:${G}=${ce}${ee} = $event${ce}`;if(te){let ue=X[1]?`${G}Modifiers`:"modelModifiers",de=te.slice(1).split(".").map((fe)=>`${fe}: true`).join(", ");le+=` :${ue}="{ ${de} }"`}return le});if(z===R.attrs){C=R.end;continue}let F=ii(R.full,{...R,start:0,end:R.full.length},z);k=k.slice(0,R.start)+F+k.slice(R.end),C=R.start+F.length}return k}function Jw(v){return v.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function Yw(v){return v.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function Qw(v){let k=v,C=0;while(C<k.length){let R=es(k,C);if(!R)break;let T=Io(R.attrs,"v-html");if(T===null){C=R.end;continue}if(R.selfClosing){C=R.end;continue}let z=Qr(k,R),F=Vr(R.attrs,"v-html"),V=R.selfClosing?" /":"",H=`<${R.tag}${F}${V}>{!! ${T} !!}</${R.tag}>`;k=k.slice(0,z.outerStart)+H+k.slice(z.outerEnd),C=z.outerStart+H.length}return k}function eS(v){let k=v,C=0;while(C<k.length){let R=es(k,C);if(!R)break;let T=Io(R.attrs,"v-text");if(T===null){C=R.end;continue}if(R.selfClosing){C=R.end;continue}let z=Qr(k,R),F=Vr(R.attrs,"v-text"),V=R.selfClosing?" /":"",H=`<${R.tag}${F}${V}>{{ ${T} }}</${R.tag}>`;k=k.slice(0,z.outerStart)+H+k.slice(z.outerEnd),C=z.outerStart+H.length}return k}function tS(v){return v.replace(/(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)\s+v-pre([^>]*>)/g,"$1$2 data-stx-skip$3").replace(/(<[a-zA-Z][a-zA-Z0-9-]*)\s+v-pre(\s[^>]*>|>)/g,"$1 data-stx-skip$2")}function nS(v){let k=v,C=0;while(C<k.length){let R=es(k,C);if(!R)break;if(!_m(R.attrs,"v-once")){C=R.end;continue}let T=Vr(R.attrs,"v-once"),z=Qr(k,R),F=k.slice(z.outerStart,z.outerEnd),H=`@once
|
|
2568
|
+
${ii(F,{...R,start:0,end:R.end-R.start},T)}
|
|
2569
|
+
@endonce`;k=k.slice(0,z.outerStart)+H+k.slice(z.outerEnd),C=z.outerStart+H.length}return k}function rS(v){return v.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function sS(v){return v.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function km(v){if(!qw(v))return v;let k=v;return k=Kw(k),k=Xw(k),k=nS(k),k=Jw(k),k=Yw(k),k=Gw(k),k=Zw(k),k=sS(k),k=Qw(k),k=eS(k),k=tS(k),k=rS(k),k}function Xa(v){return v.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}var Cu=new Set(["a","abbr","address","article","aside","audio","b","bdi","bdo","blockquote","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","meter","nav","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","span","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","u","ul","video"]),iS=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function Em(v,k){let C=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(v),R=C?C[1]:v,T=l(R,k);if(T&&typeof T==="string")return T;let z=R.trim();return Cu.has(z)?z:null}function Cm(v){let k=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(v);return k?k[1]:v}function Rm(v,k,C){let R=k.replace(/\s*(?::is|v-bind:is)\s*=\s*"[^"]*"/gi,"").trim(),T=R?`<${v} ${R}>`:`<${v}>`;if(iS.has(v))return R?`<${v} ${R}>`:`<${v}>`;return`${T}${C}</${v}>`}async function Am(v,k,C,R,T){let z=v,F=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,V=[],H;while((H=F.exec(z))!==null)V.push({full:H[0],expr:H[1],attrs:H[2],slotContent:H[3],index:H.index});for(let K=V.length-1;K>=0;K--){let X=V[K];try{let G=Em(X.expr,k);if(!G||typeof G!=="string"){let fe=`<!-- dynamic component: could not resolve "${Xa(Cm(X.expr))}" -->`;z=z.slice(0,X.index)+fe+z.slice(X.index+X.full.length);continue}if(Cu.has(G)){let fe=Rm(G,X.attrs,X.slotContent);z=z.slice(0,X.index)+fe+z.slice(X.index+X.full.length);continue}let te=X.attrs.trim(),ce={},ee=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,le;while((le=ee.exec(te))!==null){let fe=le[1]||le[2],pe=le[3];if(le[1])try{ce[fe]=l(pe,k)}catch{ce[fe]=pe}else ce[fe]=pe}let ue=R.componentsDir||"components",de=await st(G,ce,X.slotContent,ue,k,C,R,new Set,T??new Set);z=z.slice(0,X.index)+de+z.slice(X.index+X.full.length)}catch(G){let te=G instanceof Error?G.message:String(G),ce=`<!-- dynamic component error: ${Xa(te)} -->`;z=z.slice(0,X.index)+ce+z.slice(X.index+X.full.length)}}return z=await oS(z,k,C,R,T),z}async function oS(v,k,C,R,T){let z=v,F=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,V=[],H;while((H=F.exec(z))!==null)V.push({full:H[0],expr:H[1],attrs:H[2],index:H.index});for(let K=V.length-1;K>=0;K--){let X=V[K];try{let G=Em(X.expr,k);if(!G||typeof G!=="string"){let ee=`<!-- dynamic component: could not resolve "${Xa(Cm(X.expr))}" -->`;z=z.slice(0,X.index)+ee+z.slice(X.index+X.full.length);continue}if(Cu.has(G)){let ee=Rm(G,X.attrs,"");z=z.slice(0,X.index)+ee+z.slice(X.index+X.full.length);continue}let te=R.componentsDir||"components",ce=await st(G,{},"",te,k,C,R,new Set,T??new Set);z=z.slice(0,X.index)+ce+z.slice(X.index+X.full.length)}catch(G){let te=G instanceof Error?G.message:String(G),ce=`<!-- dynamic component error: ${Xa(te)} -->`;z=z.slice(0,X.index)+ce+z.slice(X.index+X.full.length)}}return z}var Ni="X-STX-Build",Ru=Symbol.for("stx.buildId");function js(){let v=globalThis;if(!v[Ru])v[Ru]=process.env.STX_BUILD_ID||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`;return v[Ru]}function Tm(v,k=js()){if(v.includes('name="stx-build"'))return null;if(!/<head\b[^>]*>/i.test(v))return null;return`
|
|
2570
|
+
<meta name="stx-build" content="${k}">`}function aS(v){if(typeof navigator>"u"||!("serviceWorker"in navigator)||!navigator.serviceWorker)return;let k=navigator.serviceWorker,C=window;if(C.stxOffline)return;let R=null,T=!1,z=[],F={updateReady:!1,reachable:!0,reachedAt:0,registration:()=>R,onUpdateReady(X){if(F.updateReady)try{X()}catch{}else z.push(X);return()=>{let G=z.indexOf(X);if(G!==-1)z.splice(G,1)}},applyUpdate(){let X=R&&R.waiting;if(!X)return!1;return T=!0,X.postMessage({type:"stx:activate-update",force:!0}),!0}};C.stxOffline=F;let V=(X)=>{if(!X.waiting||!k.controller||F.updateReady)return;F.updateReady=!0;let G=z.splice(0);for(let te of G)try{te()}catch{}try{window.dispatchEvent(new CustomEvent("stx:offline-update-ready"))}catch{}};k.addEventListener("message",(X)=>{let G=X.data||{};if(G.type==="stx:updated")try{window.dispatchEvent(new CustomEvent("stx:updated",{detail:{url:G.url,kind:G.kind,fragment:!!G.fragment}}))}catch{}if(G.type==="stx:reachability"){if(C.stxOffline.reachable=G.reachable!==!1,Number(G.at)>0)C.stxOffline.reachedAt=Number(G.at);try{window.dispatchEvent(new CustomEvent("stx:reachability",{detail:{reachable:G.reachable!==!1,at:Number(G.at)||0}}))}catch{}}}),k.addEventListener("controllerchange",()=>{if(T)T=!1,location.reload()}),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden"&&R&&R.waiting)R.waiting.postMessage({type:"stx:activate-update",reason:"hidden"})});let H=()=>{k.register(v,{scope:"/"}).then((X)=>{R=X;try{k.controller?.postMessage({type:"stx:reachability?"})}catch{}if(X.waiting)V(X),X.waiting.postMessage({type:"stx:activate-update",reason:"load"});X.addEventListener("updatefound",()=>{let G=X.installing;if(!G)return;G.addEventListener("statechange",()=>{if(G.state==="installed")V(X)})})}).catch(()=>{})},K=()=>{let X=(G)=>{setTimeout(G,0)};if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>X(H));else X(H)};if(!k.controller)if(document.readyState==="complete")K();else addEventListener("load",K);else if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",K);else K()}function cS(){let v=`(${aS.toString()})(${JSON.stringify("/_stx/sw.js")})`;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(v).trim().replace(/;$/,"")}catch{return v}}var Im=`<script data-stx-offline>${cS()}</script>`;import{AsyncLocalStorage as lS}from"async_hooks";var Pm=new lS;function En(v){return v.__stx_server_data??={pending:new Map,values:new Map}}function Dm(v,k){return Pm.run(En(v),k)}async function Om(v,k){let C=Pm.getStore();if(!C)throw Error("useServerData must run inside a <script server> render");if(typeof v!=="string"||!v.trim())throw TypeError("useServerData requires a non-empty string key");let R=C.pending.get(v);if(R)return R;let T=Promise.resolve().then(k).then((z)=>{let F=JSON.stringify(z,(H,K)=>{if(K===void 0||typeof K==="function"||typeof K==="symbol"||typeof K==="bigint"||typeof K==="number"&&!Number.isFinite(K))throw TypeError(`useServerData(${JSON.stringify(v)}) requires JSON-serializable data`);if(K&&typeof K==="object"&&!Array.isArray(K)&&Object.getPrototypeOf(K)!==Object.prototype&&Object.getPrototypeOf(K)!==null)throw TypeError(`useServerData(${JSON.stringify(v)}) requires JSON-serializable data`);return K}),V=JSON.parse(F);return C.values.set(v,V),V}).catch((z)=>{throw C.pending.delete(v),z});return C.pending.set(v,T),T}function fr(v){let k=v.__stx_server_data;if(!k?.values.size)return"";return`<script data-stx-scoped data-stx-server-data type="application/json">${JSON.stringify(Object.fromEntries(k.values)).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}var uS=/<\/(script)/gi;function oi(v){if(!v||v.indexOf("</")===-1)return v;return v.replace(uS,"<\\/$1")}import Mm from"path";function j(v,k={}){return new Hn(v,k).routes}var Nm=new Map;async function jm(v,k){let C=v,R=k;if(!C||!R)try{let V=await o();C||=V?.pagesDir||"pages",R||=V?.root||"."}catch{C||="pages",R||="."}let T=Mm.isAbsolute(C)?C:Mm.join(R,C),z=Nm.get(T);if(z)return z;let F=[];try{F=j(".",{pagesDir:T,emit:!1}).map((V)=>V.regex.source).filter(Boolean)}catch{F=[]}return Nm.set(T,F),F}function fS(v){return v.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Lm(v){return fS(JSON.stringify(v))}function he(v){return v.includes("data-stx-runtime")}function Bm(v){let k=/window\.stx\s*\.\s*[A-Za-z_$]|\}\s*=\s*window\.stx\s*;/g;for(let C=k.exec(v);C!==null;C=k.exec(v)){let R=v.slice(Math.max(0,C.index-80),C.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(R))continue;return!0}return!1}function Au(v,k){let C=co(v),R=v.search(/<!doctype\b/i);if(C!==-1&&(R===-1||C>R))return v.slice(0,C)+k+`
|
|
2571
|
+
`+v.slice(C);let T=An(v);if(T!==null)return`${v.slice(0,T)}
|
|
2572
|
+
${k}${v.slice(T)}`;if(v.includes("</head>")){let F=v.indexOf("</head>");return v.slice(0,F)+k+`
|
|
2573
|
+
`+v.slice(F)}if(Gn(v))return gs(v,(F)=>`${F}
|
|
2574
|
+
${k}`);return`${k}
|
|
2575
|
+
${v}`}async function Za(v,k){if(v.includes("data-stx-runtime")||v.includes("window.stx.state")||v.includes("STX Signals Runtime"))return v;if(k.buildMode==="serve"){let{getServeClientAsset:T}=await import("./chunk-ed1qn902.js"),{url:z}=await T("runtime",k.debug===!0);return Au(v,`<script data-stx-runtime src="${z}"></script>`)}if(k.buildMode==="compile")return Au(v,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:C}=await import("./chunk-ed1qn902.js"),R=await C(k.debug);return Au(v,`<script data-stx-scoped data-stx-runtime>${R}</script>`)}function pS(v){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(v)}function zm(v){if(v.includes("data-stx-tooltip-runtime")||!pS(v))return v;let k=`<script data-stx-scoped data-stx-tooltip-runtime>${uu()}</script>`,C=v.lastIndexOf("</body>");if(C===-1)return`${v}
|
|
2576
|
+
${k}`;return`${v.slice(0,C)}${k}
|
|
2577
|
+
${v.slice(C)}`}var gS=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function mS(v){return gS.test(v)||v.includes("__stxRouter)return")||v.includes("__stxRouter=true")}async function Q(v,k){if(!v.includes("</body>"))return v;if(mS(v))return v;let C=k?.router,R="";{let H={};if(C){if(C.container)H.container=C.container;if(C.interceptAllLinks!==void 0)H.interceptAllLinks=C.interceptAllLinks;if(C.progress!==void 0)H.progress=C.progress;if(C.viewTransitions!==void 0)H.viewTransitions=C.viewTransitions;if(C.viewTransitionDuration!==void 0)H.viewTransitionDuration=C.viewTransitionDuration;if(C.viewTransitionEasing!==void 0)H.viewTransitionEasing=C.viewTransitionEasing;if(C.scrollToTop!==void 0)H.scrollToTop=C.scrollToTop;if(C.scrollRestoration!==void 0)H.scrollRestoration=C.scrollRestoration;if(C.prefetch!==void 0)H.prefetch=C.prefetch;if(C.cache!==void 0)H.cache=C.cache;if(C.progressColor!==void 0)H.progressColor=C.progressColor;if(C.progressHeight!==void 0)H.progressHeight=C.progressHeight;if(C.prefetchVisible!==void 0)H.prefetchVisible=C.prefetchVisible;if(C.prefetchVisibleMax!==void 0)H.prefetchVisibleMax=C.prefetchVisibleMax;if(C.keepOpening!==void 0)H.keepOpening=C.keepOpening}try{let K=await jm(k?.pagesDir,k?.root);if(K.length>0)H.ownedRoutes=K}catch{}if(Object.keys(H).length>0)R=`<script>window.__stxRouterConfig=${Lm(H)};</script>
|
|
2578
|
+
`}let{getCachedRouterScript:T,getServeClientAsset:z}=await import("./chunk-ed1qn902.js"),F=k?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':k?.buildMode==="serve"?`<script data-stx-router src="${(await z("router")).url}"></script>`:`<script data-stx-router>${await T()}</script>`,V=v.lastIndexOf("</body>");return v.slice(0,V)+R+F+`
|
|
2579
|
+
</body>`+v.slice(V+7)}var Wm=Symbol.for("stx.lazy-module-promises");function hS(){let v=globalThis;return v[Wm]??=new Map,v[Wm]}function Et(v,k){let C=hS(),R=`${import.meta.url}\x00${v}`,T=C.get(R);if(T)return T;let z=k();return C.set(R,z),z.catch(()=>{if(C.get(R)===z)C.delete(R)}),z}var Tu=`(?:"[^"]*"|'[^']*'|[^>"'])*`,Xm=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,yS=65536,xS=4,Ja=new Map;function hd(){Ja.clear()}function bS(v){let k=[];for(let C of ne(v,U)){let R=C.token.match(/^<script\b([^>]*)>/i),T=C.token.match(/<\/script\s*>$/i);if(!R||!T)continue;let z=R[0].length,F=C.token.length-T[0].length;k.push(Object.freeze({fullMatch:C.token,attrs:R[1],body:C.token.slice(z,F),start:C.start,end:C.end}))}return k}function jc(v,k={}){let C=v.length>=yS,R=C?Ja.get(v):void 0;if(R===void 0){if(R=bS(v),C)Hd(Ja,xS),Ja.set(v,R)}let T=k.skipAttrs;if(!T)return R.slice();let z=[];for(let F of R)if(T.lastIndex=0,!T.test(F.attrs))z.push(F);return z}function Rs(v){let k=v.trim(),C=k.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(C){let T=C[1].trim(),z=C[2].trim(),{itemVar:F,indexVar:V}=Fm(z);if(F)return{style:"as",iterable:T,itemVar:F,indexVar:V}}let R=k.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(R){let T=R[1].trim(),z=R[2].trim(),{itemVar:F,indexVar:V}=Fm(T);if(F)return{style:"in",iterable:z,itemVar:F,indexVar:V}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function Fm(v){let k=v.trim(),C=k.match(/^(\w+)\s*=>\s*(\w+)$/);if(C)return{itemVar:C[2],indexVar:C[1]};let R=k.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(R)return{itemVar:R[1],indexVar:R[2]||null};let T=k.match(/^(\w+)\s*,\s*(\w+)$/);if(T)return{itemVar:T[1],indexVar:T[2]};let z=k.match(/^(\w+)$/);if(z)return{itemVar:z[1],indexVar:null};return{itemVar:null,indexVar:null}}function As(v,k){return na(v,k)}function vS(v){let k=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,C=0,R;while((R=k.exec(v))!==null){let T=R[1];if(T.startsWith("if"))C++;else if(T==="endif")C--;else if(C===0)return!0}return!1}function Zm(v){let k=new Set,C=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,R=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,T;while((T=C.exec(v))!==null){let z=T[1],F;while((F=R.exec(z))!==null)k.add(F[1])}return k}function wS(v){if(!/[:@]for\s*=/.test(v)&&!/\bx-for\s*=/.test(v))return[];let k=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${Tu})>`,"iy"),C=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,R=ne(v,(z,F)=>{k.lastIndex=F;let V=k.exec(z);if(!V||V.index!==F||!C.test(V[2]))return-1;return k.lastIndex}),T=[];for(let z of R){k.lastIndex=0;let F=k.exec(z.token);if(!F)continue;let V=F[2].match(C),H=Rs(V?.[1]??V?.[2]??""),K=[H.itemVar,H.indexVar].filter(Boolean);if(K.length===0)continue;let X=F[1],te=/\/\s*>$/.test(z.token)||Ya.has(X.toLowerCase())?z.end:Pu(v,z.start,X,z.end);if(te!==-1)T.push({start:z.start,end:te,vars:new Set(K)})}return T}var Vm=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function SS(v){return v.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function Um(v,k,C,R){if(!v)return!1;let T=SS(v),z=!1,F=!1,V=!1,H=/([a-zA-Z_$][\w$]*)/g,K;while((K=H.exec(T))!==null){let ce=K[1];if(T.slice(0,K.index).trimEnd().endsWith("."))continue;if(Vm.has(ce))continue;if(k.has(ce)||R?.has(ce))z=!0;else if(C&&ce in C)F=!0}let X=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,G;while((G=X.exec(T))!==null){let ce=G[1];if(T.slice(0,G.index).trimEnd().endsWith("."))continue;if(Vm.has(ce)||C&&ce in C)continue;V=!0}return(z||V)&&!F}function Ga(v,k,C){let R=C===void 0?` ${k}`:` ${k}="${C.replace(/"/g,""")}"`,T=v.trim(),z=T.match(Xm);if(z&&$S(z[3],z[1])){let[,F,V,H]=z;return`<${F}${V}${R}>${H}</${F}>`}return`<template${R}>${T}</template>`}function $S(v,k){let C=new RegExp(`<(/)?${k}(?=[\\s/>])`,"gi"),R=0,T;while((T=C.exec(v))!==null)if(T[1]){if(R--,R<0)return!1}else R++;return!0}function Ei(v,k){let C=Zm(v);function R(T){let z=T,F=wS(T),V=(G)=>{let te=new Set;for(let ce of F)if(G>ce.start&&G<ce.end)for(let ee of ce.vars)te.add(ee);return te},H=/@if\s*\(/g,K,X=[];while((K=H.exec(z))!==null){let G=K.index,te=G+K[0].length,ce=1,ee=te;while(ee<z.length&&ce>0){if(z[ee]==="(")ce++;else if(z[ee]===")")ce--;ee++}if(ce!==0)continue;let le=z.substring(te,ee-1).trim(),ue=ee,de=1,fe=ue,pe=/@(if\s*\(|endif)/g;pe.lastIndex=ue;let Ae;while((Ae=pe.exec(z))!==null)if(Ae[1].startsWith("if"))de++;else if(Ae[1]==="endif"){if(de--,de===0){fe=Ae.index+Ae[0].length;break}}if(de!==0)continue;let Se=z.substring(ue,fe-6).trim(),ve;if(vS(Se)){let De=mo(z.substring(G,fe));if(De.length===0)continue;let Me=De[0].branches.filter((Oe)=>Oe.type!=="else"),je=V(G);if(!(Me.length>0&&Me.every((Oe)=>Um(Oe.condition,C,k,je))))continue;ve=De[0].branches.map((Oe)=>{let We=R(Oe.content);if(Oe.type==="elseif")return Ga(We,"@else-if",Oe.condition??"");if(Oe.type==="else")return Ga(We,"@else");return Ga(We,"@if",Oe.condition??"")}).join(`
|
|
2580
|
+
`)}else{if(!Um(le,C,k,V(G)))continue;ve=Ga(R(Se),"@if",le)}X.push({start:G,end:fe,replacement:ve}),H.lastIndex=fe}for(let G=X.length-1;G>=0;G--){let{start:te,end:ce,replacement:ee}=X[G];z=z.substring(0,te)+ee+z.substring(ce)}return z}return R(v)}function _S(v){let k=v.trim();if(k==="")return;if(k==="true")return!0;if(k==="false")return!1;if(k==="null")return!1;if(k==="undefined")return!1;if(k==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(k)){let T=Number(k);return T!==0&&!Number.isNaN(T)}let C=k.match(/^'((?:\\.|[^'\\])*)'$/);if(C)return C[1].length>0;let R=k.match(/^"((?:\\.|[^"\\])*)"$/);if(R)return R[1].length>0;return}var Ya=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Hm=/<(script|style)\b/iy,kS=/<\/script/gi,ES=/<\/style/gi;function Pu(v,k,C,R){if(Ya.has(C.toLowerCase()))return R;let T=C.toLowerCase(),z=v.length,F=1,V=R;while(V<z){let H=v.indexOf("<",V);if(H===-1)return-1;if(V=H,v.startsWith("<!--",V)){let te=v.indexOf("-->",V+4);if(te===-1)return-1;V=te+3;continue}Hm.lastIndex=V;let K=Hm.exec(v);if(K){let te=v.indexOf(">",V);if(te===-1)return-1;if(v[te-1]==="/"){V=te+1;continue}let ce=K[1].toLowerCase()==="script"?kS:ES;ce.lastIndex=V;let ee=ce.exec(v);if(ee===null)return-1;let le=v.indexOf(">",ee.index);if(le===-1)return-1;V=le+1;continue}if(v[V+1]==="/"){let te=/^<\/([a-z][\w-]*)\s*>/i.exec(v.slice(V,V+64));if(!te){V++;continue}if(te[1].toLowerCase()===T){if(F--,V+=te[0].length,F===0)return V;continue}V+=te[0].length;continue}let X=/^<([a-z][\w-]*)\b/i.exec(v.slice(V,V+64));if(!X){V++;continue}let G=v.indexOf(">",V);if(G===-1)return-1;if(X[1].toLowerCase()===T){let te=v.slice(V,G+1);if(!(/\/\s*>$/.test(te)||Ya.has(T)))F++}V=G+1}return-1}var CS=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function RS(v,k){let C=k,R=v.length;for(;;){while(C<R&&v[C]!=="<")C++;if(C>=R)return!1;if(v.startsWith("<!--",C)){let F=v.indexOf("-->",C+4);if(F===-1)return!1;C=F+3;continue}break}if(v[C+1]==="/")return!1;let T=v.indexOf(">",C);if(T===-1)return!1;let z=v.slice(C,T+1);return CS.test(z)}function Ti(v){if(!v.includes(":if")&&!v.includes(":show")&&!v.includes("x-if")&&!v.includes("x-show")&&!v.includes("@if=")&&!v.includes("@show="))return v;let k=[],C=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,R;while((R=C.exec(v))!==null)k.push([R.index,R.index+R[0].length]);let T=(G)=>k.some(([te,ce])=>G>=te&&G<ce),z=/<([a-zA-Z][\w-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*?)\s+(:if|:show|x-if|x-show|@if|@show)\s*=\s*"([^"]*)"((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?)>/g,F=[],V;while((V=z.exec(v))!==null){if(T(V.index))continue;let[G,te,ce,ee,le,ue,de]=V,fe=_S(le);if(fe===void 0)continue;let pe=V.index,Ae=pe+G.length,De=!!de||/\/\s*>$/.test(G)||Ya.has(te.toLowerCase())?Ae:Pu(v,pe,te,Ae);if(De===-1)continue;if((ee===":if"||ee==="x-if"||ee==="@if")&&RS(v,De)){z.lastIndex=Ae;continue}if(fe===!0){let je=`<${te}${ce}${ue}${de}>`;F.push({start:pe,end:Ae,replacement:je});continue}F.push({start:pe,end:De,replacement:""}),z.lastIndex=De}if(F.length===0)return v;F.sort((G,te)=>G.start-te.start);let H=[],K=-1;for(let G of F){if(G.start<K)continue;H.push(G),K=G.end}let X=v;for(let G=H.length-1;G>=0;G--){let{start:te,end:ce,replacement:ee}=H[G];X=X.substring(0,te)+ee+X.substring(ce)}return X}var qm=[":for","@for","x-for"];function Ps(v,k){if(!k||Object.keys(k).length===0)return v;if(!qm.some((V)=>v.includes(`${V}=`)))return v;let C=Zm(v);if(Array.isArray(k.__stx_client_signal_names)){for(let V of k.__stx_client_signal_names)if(typeof V==="string")C.add(V)}let R=v,T=[],z=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,F;while((F=z.exec(R))!==null){let[V,H,K]=F,X=F.index,G=X+V.length,te=qm.map((ve)=>({attr:ve,m:new RegExp(`\\s${ve}="([^"]*)"`).exec(K)})).find((ve)=>ve.m!==null);if(!te||!te.m)continue;let ce=Rs(te.m[1]);if(!ce.iterable||!ce.itemVar)continue;let ee=ce.iterable.trim().split(/[.[(]/)[0].trim();if(!ee||C.has(ee)||!(ee in k))continue;let le=Pu(R,X,H,G);if(le===-1)continue;let ue=K.replace(new RegExp(`\\s${te.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),de=R.slice(G,le-`</${H}>`.length),fe={...k,[ce.itemVar]:void 0};if(ce.indexVar)fe[ce.indexVar]=void 0;let pe=Ps(de,fe),Ae=ce.indexVar?`${ce.iterable} as ${ce.indexVar} => ${ce.itemVar}`:`${ce.iterable} as ${ce.itemVar}`,Se=H.toLowerCase()==="template"?pe:`<${H}${ue}>${pe}</${H}>`;T.push({start:X,end:le,replacement:`@foreach(${Ae})${Se}@endforeach`}),z.lastIndex=le}for(let V=T.length-1;V>=0;V--){let{start:H,end:K,replacement:X}=T[V];R=R.slice(0,H)+X+R.slice(K)}return R}function Is(v,k){let C=v,R=/@(for|foreach)\s*\(/g,T,z=[],F=[];while((T=R.exec(C))!==null){let V=T[1],H=T.index,K=H+T[0].length,X=1,G=K;while(G<C.length&&X>0){if(C[G]==="(")X++;else if(C[G]===")")X--;G++}if(X!==0)continue;let te=C.substring(K,G-1).trim(),ce=G,ee=Rs(te),le=V==="for"?"@endfor":"@endforeach",ue=1,de=ce,fe=V==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${V}\\s*\\(|end${V})`,"g");fe.lastIndex=ce;let pe;while((pe=fe.exec(C))!==null)if(pe[1].startsWith(V))ue++;else if(ue--,ue===0){de=pe.index+pe[0].length;break}if(ue!==0)continue;let Ae=()=>{let Le=[ee.itemVar,ee.indexVar].filter(Boolean);if(Le.length)F.push({start:H,end:de,vars:Le})};if(ee.iterable){let Le=ee.iterable.trim();if(Le.startsWith("[")||Le.startsWith("{")||Le.startsWith("'")||Le.startsWith('"')||Le.startsWith("`")||/^-?\d/.test(Le)){Ae();continue}let Be=Le.split(/[.[(]/)[0].trim(),Oe=k?Be in k:!1,We=F.some((Fe)=>H>Fe.start&&H<Fe.end&&Fe.vars.includes(Be));if(Be&&(Oe||We)){Ae();continue}}if(ee.style==="as")te=ee.indexVar?`(${ee.itemVar}, ${ee.indexVar}) in ${ee.iterable}`:`${ee.itemVar} in ${ee.iterable}`;let Se=C.substring(ce,de-le.length).trim(),ve=k?{...k}:{};if(ee.itemVar)delete ve[ee.itemVar];if(ee.indexVar)delete ve[ee.indexVar];let De=Is(Se,ve),Me=De.match(Xm),je;if(Me){let[,Le,Be,Oe]=Me;je=`<${Le}${Be} @for="${te}">${Oe}</${Le}>`}else je=`<template @for="${te}">${De}</template>`;z.push({start:H,end:de,replacement:je}),R.lastIndex=de}for(let V=z.length-1;V>=0;V--){let{start:H,end:K,replacement:X}=z[V];C=C.substring(0,H)+X+C.substring(K)}return C}function AS(v){let k=new Set,C=[],R=0,T=0,z=v.length,F=(X)=>{let G=R+1;while(G<z){let te=v[G];if(te==="\\"){G+=2;continue}if(te===X)return G+1;G++}return z},V=()=>{let X=R+2;while(X<z&&v[X]!==`
|
|
2581
|
+
`)X++;return X},H=()=>{let X=R+2;while(X<z-1){if(v[X]==="*"&&v[X+1]==="/")return X+2;X++}return z},K=(X)=>{let G=X,te=0;while(G<z){let ce=v[G];if(ce==="/"&&v[G+1]==="/"){let ee=G+2;while(ee<z&&v[ee]!==`
|
|
2582
|
+
`)ee++;G=ee;continue}if(ce==="/"&&v[G+1]==="*"){let ee=G+2;while(ee<z-1&&!(v[ee]==="*"&&v[ee+1]==="/"))ee++;G=ee+2;continue}if(ce==='"'||ce==="'"||ce==="`"){let ee=G+1;while(ee<z){if(v[ee]==="\\"){ee+=2;continue}if(v[ee]===ce){ee++;break}ee++}G=ee;continue}if(ce==="("||ce==="["||ce==="{"){te++,G++;continue}if(ce===")"||ce==="]"||ce==="}"){te--,G++;continue}if(ce===";"&&te===0)return G+1;G++}return z};while(R<z){let X=v[R];if(X==="/"&&v[R+1]==="/"){let G=V();C.push(v.slice(R,G)),R=G;continue}if(X==="/"&&v[R+1]==="*"){let G=H();C.push(v.slice(R,G)),R=G;continue}if(X==='"'||X==="'"||X==="`"){let G=F(X);C.push(v.slice(R,G)),R=G;continue}if(X==="{"){T++,C.push(X),R++;continue}if(X==="}"){T--,C.push(X),R++;continue}if(T===0){let G=R>0?v[R-1]:"";if(G===""||/\s/.test(G)||G===";"||G==="}"||G==="{"){let ce=v.slice(R).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(ce){let ee=ce[2],le=K(R+ce[0].length);if(k.has(ee)){C.push(`/* stx: deduped const ${ee} */`),R=le;continue}k.add(ee),C.push(v.slice(R,le)),R=le;continue}}}C.push(X),R++}return C.join("")}var TS=new Set(["script","style","html","head","meta","link","title","!doctype"]);function Iu(v,k,C){for(let R of C){if(R.start>=k)return!1;if(R.end>v)return!0}return!1}function IS(v,k,C){let R=0;while(R<v.length){let T=v.indexOf(k,R);if(T===-1)return!1;if(!Iu(T,T+k.length,C))return!0;R=T+k.length}return!1}function PS(v,k){if(IS(v,"<body",k)){let T=new RegExp(`<body(${Tu})>`,"g"),z;while((z=T.exec(v))!==null)if(!Iu(z.index,z.index+z[0].length,k))return z.index+z[0].length-1;return null}let C=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${Tu})>`,"gi"),R;while((R=C.exec(v))!==null){if(Iu(R.index,R.index+R[0].length,k))continue;if(TS.has(R[1].toLowerCase()))continue;return R.index+R[0].length-1}return null}function DS(v,k,C,R){let T=[],z=` data-stx="${R}"`,F=0,V=!1,H=(K)=>{if(C!==null&&!V&&C>=F&&C<=K)T.push(v.slice(F,C),z,v.slice(C,K)),V=!0;else T.push(v.slice(F,K))};for(let K of k){if(K.start<F)continue;H(K.start),F=K.end}return H(v.length),T.join("")}async function pr(v,k,C,R={}){let T=jc(v,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),z=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,F=[],{hasUserImports:V,bundleClientScript:H}=await Et("stx/client-script-bundler",()=>import("./chunk-kt5mzw2w.js"));for(let pe of T){let Ae=pe.body;if(nt(pe.attrs))Ae=rt(Ae);if(R.forceClientSetup||z.test(Ae)){F.push({content:Ae,start:pe.start,end:pe.end});continue}if(!V(Ae))continue;try{let Se=await H(Nt(Ae).code,k||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(z.test(Se))F.push({content:Ae,start:pe.start,end:pe.end})}catch{}}if(F.length===0)return{output:v,setupCode:null};let K=`${k??""}\x00${F.map((pe)=>pe.content).join("\x00")}`,X=`__stx_setup_${Bun.hash(K).toString(36).slice(0,10)}`,G=[];for(let pe=0;pe<F.length;pe++){let Ae=F[pe].bundled??Nt(F[pe].content).code;if(!F[pe].bundled&&V(Ae))Ae=await H(Ae,k||"",{projectRoot:process.cwd(),externalizeUserModules:R.forceClientSetup?!1:void 0});Ae=tt(Ae);let Se=I(Ae);G.push(`// \u2500\u2500 merged signal script #${pe+1} \u2500\u2500
|
|
2583
|
+
${Se}`)}let te=G.join(`
|
|
2584
|
+
|
|
2585
|
+
`);te=AS(te);let ee=M(te).split(",").map((pe)=>pe.trim()).filter(Boolean),le=vn(te,C),ue=`
|
|
2586
|
+
<script data-stx-scoped>
|
|
2587
|
+
function ${X}() {
|
|
2588
|
+
${qt("const",ee)}
|
|
2589
|
+
${oi(`${le}${te}`)}
|
|
2590
|
+
return ${Ho(te,ee)};
|
|
2591
|
+
}
|
|
2592
|
+
window.__stx_latestSetup=${X};
|
|
2593
|
+
if(window.stx)window.stx._latestSetup=${X};
|
|
2594
|
+
</script>`,de=PS(v,F);return{output:DS(v,F,de,X),setupCode:ue}}async function $i(v,k,C,R){if(!As(v,C))return v;let T=v;if(k.skipSignalsRuntime)return T;let{output:z,setupCode:F}=await pr(T,C,R);if(T=z,!F){let V=Gn(T);if(V&&!/data-stx/.test(V.attrs)&&!/data-stx-auto/.test(V.attrs)){let H=V.tag.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>");T=T.slice(0,V.index)+H+T.slice(V.index+V.tag.length)}}if(T=await Za(T,k),F){let V=Ri(T,/<\/head>/i),H=V===-1?Ri(T,/<body[^>]*>/i):-1;if(V!==-1)T=`${T.slice(0,V)}${F}
|
|
2595
|
+
${T.slice(V)}`;else if(H!==-1){let K=/<body[^>]*>/i.exec(T.slice(H))[0],X=H+K.length;T=`${T.slice(0,X)}
|
|
2596
|
+
${F}${T.slice(X)}`}else T=`${T}
|
|
2597
|
+
${F}`}return T}function Ri(v,k){let C=/<(script|style)\b[\s\S]*?<\/\1>/gi,R=[],T;while((T=C.exec(v))!==null)R.push([T.index,T.index+T[0].length]);let z=new RegExp(k.source,k.flags.replace(/[gy]/g,"")),F=0;while(F<v.length){let V=z.exec(v.slice(F));if(!V)return-1;let H=F+V.index;if(!R.some(([X,G])=>H>=X&&H<G))return H;F=H+Math.max(V[0].length,1)}return-1}var Km="/* [stx import stripped, resolved via window.stx in __stx_setup] */";function Bc(v){let k=[];for(let C of v.split(",")){let R=C.trim();if(!R||R.startsWith("type "))continue;let T=R.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(T&&T[1]!==T[2])k.push(`${T[2]} = ${T[1]}`)}if(k.length===0)return Km;return`var ${k.join(", ")}; ${Km}`}var OS=/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm;function tt(v){return v.replace(OS,(k,C)=>Bc(C))}import ai from"path";import MS from"process";function w(v="STX_PUBLIC_"){let k={},C={};for(let[R,T]of Object.entries(MS.env)){if(!R.startsWith(v)||T===void 0)continue;k[`import.meta.env.${R}`]=JSON.stringify(T),C[R]=T}return k["import.meta.env"]=JSON.stringify(C),k}function Gm(v){return v.startsWith("http://")||v.startsWith("https://")||v.startsWith("//")}async function Jm(v,k,C){try{let R;if(v.startsWith("/")){let T=k;for(let z=0;z<5;z++){let F=ai.join(T,v);if(await Bun.file(F).exists())return F;T=ai.dirname(T)}R=ai.join(k,v)}else if(v.startsWith("./")||v.startsWith("../"))R=ai.resolve(k,v);else R=ai.resolve(k,v);if(await Bun.file(R).exists())return R;return null}catch{return null}}var Ym=Symbol.for("stx.inline-assets.import-meta");function NS(v,k){if(!v.includes("import.meta"))return;let C=Error(`[stx] ${k} still references \`import.meta\` after bundling, and it is being inlined as a classic <script> where that is a SyntaxError \u2014 the whole script fails to parse, taking every other script on the page with it.
|
|
2598
|
+
`+" `import.meta.env.STX_PUBLIC_*` is substituted at build time and is safe; anything else is not.\n Fix it by moving the module-only code (`import.meta.glob`, `import.meta.url`) into its own module, or by resolving the value without `import.meta`.");throw C[Ym]=!0,C}async function Qm(v,k,C){let R=v,T=ai.dirname(k),z=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,F;while((F=z.exec(R))!==null){let[K,X,G,te]=F;if(Gm(G))continue;let ce=await Jm(G,T,k);if(ce)try{let ee=await Bun.file(ce).text();if(C.add(ce),G.endsWith(".ts")||G.endsWith(".tsx")){let ue=await Bun.build({entrypoints:[ce],target:"browser",minify:!0,define:w()});if(ue.outputs.length>0)ee=await ue.outputs[0].text(),NS(ee,G)}let le=`<script>
|
|
2599
|
+
// Source: ${G}
|
|
2600
|
+
${ee}
|
|
2601
|
+
</script>`;R=R.replace(K,le),z.lastIndex=0}catch(ee){if(ee?.[Ym])throw ee}}let V=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,H;while((H=V.exec(R))!==null){let[K,X,G,te]=H,ce=X+te;if(Gm(G))continue;if(/rel=["']stylesheet["']/.test(ce)||G.endsWith(".css")){let le=await Jm(G,T,k);if(le)try{let ue=await Bun.file(le).text();C.add(le);let de=`<style>
|
|
2602
|
+
/* Source: ${G} */
|
|
2603
|
+
${ue}
|
|
2604
|
+
</style>`;R=R.replace(K,de),V.lastIndex=0}catch(ue){}}}return R}function Bs(v,k){let C=v,R=/@json\s*\(/g,T;while((T=R.exec(C))!==null){let z=T.index,F=z+T[0].length-1,V=1,H=F+1,K=null,X=!1;while(H<C.length&&V>0){let pe=C[H];if(X){X=!1,H++;continue}if(pe==="\\"&&K){X=!0,H++;continue}if(K){if(pe===K)K=null;H++;continue}if(pe==='"'||pe==="'"||pe==="`"){K=pe,H++;continue}if(pe==="(")V++;else if(pe===")"){if(V--,V===0)break}H++}if(V!==0)break;let G=C.substring(F+1,H).trim(),te=C.substring(z,H+1),ce=-1,ee=0,le=null,ue=!1;for(let pe=0;pe<G.length;pe++){let Ae=G[pe];if(ue){ue=!1;continue}if(Ae==="\\"&&le){ue=!0;continue}if(le){if(Ae===le)le=null;continue}if(Ae==='"'||Ae==="'"||Ae==="`"){le=Ae;continue}if(Ae==="("||Ae==="["||Ae==="{")ee++;else if(Ae===")"||Ae==="]"||Ae==="}")ee--;if(Ae===","&&ee===0){ce=pe;break}}let de=ce>=0?G.substring(0,ce).trim():G,fe=ce>=0?G.substring(ce+1).trim():void 0;try{let pe=de.trim(),Ae;if(p(pe))Ae=c(pe,Object.keys(k))(...Object.values(k));else Ae=void 0;let Se;if(fe==="true")Se=JSON.stringify(Ae,null,2);else Se=JSON.stringify(Ae);let ve=Se.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");C=C.substring(0,z)+ve+C.substring(H+1),R.lastIndex=z+ve.length}catch(pe){O.log(pe instanceof Error?pe:Error(String(pe)),{directive:"@json"},"error"),R.lastIndex=z+te.length}}return C}function Fs(v){return v.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function rh(v){let k=v,C=/@memo\s*\(/g,R,T=[];while((R=C.exec(k))!==null){let z=R.index,F=z+R[0].length,V=1,H=F;while(H<k.length&&V>0){if(k[H]==="(")V++;else if(k[H]===")")V--;H++}if(V!==0)continue;let K=k.slice(F,H-1).trim(),X=H,G=k.slice(X),te=G.indexOf("@endmemo");if(te===-1)continue;let ce=G.slice(0,te),ee=X+te+8,le=ce.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)/),ue=le?le[0].length:0,de=ce.slice(ue),fe=ce.match(/(\s*)$/),pe=fe?fe[0].length:0,Ae=de.slice(0,de.length-pe),Se=Ae.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),ve;if(Se){let[De,Me,je="",Le]=Se,Be=`<${Me}${je} data-stx-memo="${K}"${Le}>`;ve=ce.slice(0,ue)+Be+Ae.slice(De.length)+ce.slice(ue+Ae.length)}else ve=`${ce.slice(0,ue)}<div data-stx-memo="${K}">${Ae}</div>${ce.slice(ue+Ae.length)}`;T.push({start:z,end:ee,replacement:ve}),C.lastIndex=ee}for(let z=T.length-1;z>=0;z--){let F=T[z];k=k.slice(0,F.start)+F.replacement+k.slice(F.end)}return k.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function Du(v){let k=v.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return k=k.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),k}function sh(v,k){if(!/\bref\s*=/.test(v))return v;let C=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,R=ne(v,(H,K)=>{C.lastIndex=K;let X=C.exec(H);if(!X||/^(?:script|style)$/i.test(X[1]))return-1;return C.lastIndex}),T=[],z=0,F=0,V=[];for(let{start:H,end:K,token:X}of R){let G=/^<\/?([\w-]+)/.exec(X)[1].toLowerCase();if(X.startsWith("</")){let ce;while(ce=T.pop()){if(ce.scoped)z--;if(ce.name===G)break}continue}let te=/\sdata-stx-scope\s*=/.test(X);if(!z&&!te&&/\s(?:ref|@ref|:ref|x-ref|data-stx-ref)\s*=/.test(X)&&!/\sdata-stx-ref-caller\s*=/.test(X))V.push(v.slice(F,H),X.replace(/\s*\/?>$/,(ce)=>` data-stx-ref-caller="${k}"${ce}`)),F=K;if(!ih.has(G)&&!/\/>$/.test(X)){if(T.push({name:G,scoped:te}),te)z++}}return V.push(v.slice(F)),V.join("")}var ih=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),oh=/(?:^|\s)x-no-cloak(?:=|\s|\/|>|$)/,eh=/<\/?\s*([a-z][\w-]*)/iy,jS=/\s/;function LS(v,k){let C=k-1;while(C>=0&&jS.test(v[C]))C--;return C>=0&&v[C]==="/"}function BS(v,k){let C=!1,R=!1;for(let T=k;T<v.length;T++){let z=v[T];if(C){if(z==="'")C=!1}else if(R){if(z==='"')R=!1}else if(z==="'")C=!0;else if(z==='"')R=!0;else if(z===">")return T}return-1}function zS(v,k){if(v.indexOf("{",k)===-1||v.indexOf("}",k)===-1)return!1;let C=0,R=k,T=!1,z=!1,F=!1;while(R<v.length){let V=v.indexOf("<",R),H=V===-1?v.length:V;if(H>R){if(C===0)while(R<H){let G=v.indexOf(z?"}":"{",R);if(G===-1||G>=H){if(z)F=!1;else T=!1;break}if(G>R)if(z)F=!1;else T=!1;if(z){if(F)return!0;F=!0}else if(T)z=!0,F=!1;else T=!0;R=G+1}R=H;continue}if(v.startsWith("<!--",R)){let G=v.indexOf("-->",R);R=G===-1?v.length:G+3;continue}let K=BS(v,R);if(K===-1)break;eh.lastIndex=R;let X=eh.exec(v)?.[1]?.toLowerCase()??"";if(v[R+1]==="/"){if(C===0)break;C--}else if(!LS(v,K)&&!ih.has(X))C++;R=K+1}return!1}var th=m(256);function ah(v){if(v.length<1024)return nh(v);let k=h(v),C=th.get(k);if(C!==void 0)return C;let R=nh(v);return th.set(k,R),R}function nh(v){if(v.length>=32768&&!Ud(v))return v;let C=new RegExp(`<(${"div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i"})\\b`,"gi"),R="",T=0,z;while((z=C.exec(v))!==null){let F=z.index,V=F+z[0].length,H=!1,K=!1,X=-1;while(V<v.length){let te=v[V];if(H){if(te==="'")H=!1}else if(K){if(te==='"')K=!1}else if(te==="'")H=!0;else if(te==='"')K=!0;else if(te===">"){X=V;break}V++}if(X===-1)continue;let G=v.slice(F,X+1);if(oh.test(G))continue;if(G.includes("x-cloak"))continue;if(zS(v,X+1))R+=v.slice(T,X)+" x-cloak>",T=X+1}return R+=v.slice(T),R}var WS=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/,FS=/<\/script>/gi,VS=/<\/style>/gi;function ch(v){let k=/<[a-z][\w-]*/gi,C="",R=0,T;while((T=k.exec(v))!==null){let z=T.index,F=T[0].slice(1).toLowerCase();if(F==="script"||F==="style"){let ee=F==="script"?FS:VS;ee.lastIndex=z;let le=ee.exec(v);if(le!==null)k.lastIndex=le.index+le[0].length;continue}let V=z+T[0].length,H=!1,K=!1,X=-1;while(V<v.length){let ee=v[V];if(H){if(ee==="'")H=!1}else if(K){if(ee==='"')K=!1}else if(ee==="'")H=!0;else if(ee==='"')K=!0;else if(ee===">"){X=V;break}V++}if(X===-1)continue;let G=v.slice(z+T[0].length,X);if(oh.test(G))continue;if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(G))continue;if(!WS.test(G))continue;let te=v[X-1]==="/",ce=te?X-1:X;C+=`${v.slice(R,ce)} x-cloak${te?" ":""}`,R=ce}return C+=v.slice(R),C}import Ou from"path";var US=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,HS=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function qS(v,k){if(!k||!v.includes("/"))return v;let C=Ou.dirname(k);return v.replace(US,(R,T,z,F)=>{let V=Ou.resolve(C,F);return`${T}${z}${V.split(Ou.sep).join("/")}${z}`})}function lh(v,k){if(!k||!v.includes("<script"))return v;return v.replace(HS,(C,R,T,z)=>`${R}${qS(T,k)}${z}`)}var ts="<!--PARENT_CONTENT_PLACEHOLDER-->";function uh(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function yh(v,k){let C=v.length,R=k,T=!0,z=[],F=(V)=>V+9<=C&&v[V]==="<"&&v[V+1]==="/"&&(v[V+2]==="s"||v[V+2]==="S")&&(v[V+3]==="c"||v[V+3]==="C")&&(v[V+4]==="r"||v[V+4]==="R")&&(v[V+5]==="i"||v[V+5]==="I")&&(v[V+6]==="p"||v[V+6]==="P")&&(v[V+7]==="t"||v[V+7]==="T")&&(v[V+8]===">"||/\s/.test(v[V+8]));while(R<C){let V=v[R];if(F(R))return R;if(V==="/"&&v[R+1]==="/"){if(R=v.indexOf(`
|
|
2605
|
+
`,R+2),R===-1)return-1;R+=1,T=!0;continue}if(V==="/"&&v[R+1]==="*"){let H=v.indexOf("*/",R+2);if(H===-1)return-1;R=H+2,T=!0;continue}if(V==="/"&&T){let H=R+1,K=!1;while(H<C){let X=v[H];if(X==="\\"){H+=2;continue}if(X==="[")K=!0;else if(X==="]")K=!1;else if(X==="/"&&!K){H++;break}else if(X===`
|
|
2606
|
+
`){H=-1;break}H++}if(H===-1){R++,T=!1;continue}while(H<C&&/[a-z]/.test(v[H]))H++;R=H,T=!1;continue}if(V==="'"||V==='"'){let H=V;R++;while(R<C){if(v[R]==="\\"){R+=2;continue}if(v[R]===H){R++;break}if(v[R]===`
|
|
2607
|
+
`)break;R++}T=!1;continue}if(V==="`"){R++;while(R<C){if(v[R]==="\\"){R+=2;continue}if(v[R]==="`"){R++;break}if(v[R]==="$"&&v[R+1]==="{"){z.push(!0),R+=2,T=!0;break}R++}if(z.length===0)T=!1;continue}if(V==="}"&&z.length>0){z.pop(),R++;while(R<C){if(v[R]==="\\"){R+=2;continue}if(v[R]==="`"){R++,T=!1;break}if(v[R]==="$"&&v[R+1]==="{"){z.push(!0),R+=2,T=!0;break}R++}continue}if(/\s/.test(V));else if(/[)\].\w$]/.test(V))T=!1;else T=!0;R++}return-1}function xh(v,k){let C=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),R=new RegExp(`<script\\b(?=[^>]*\\b${C}(?:\\s|=|/?>))[^>]*>`,"i").exec(v);if(!R)return null;let T=R.index+R[0].length,z=v.indexOf("</script>",T);if(z===-1)return null;let F=v.indexOf(">",z);if(F===-1)return null;return{start:R.index,end:F+1}}var XS=4096;async function dh(v,k,C){if(C.buildMode!=="serve"||k.length<XS)return null;let{registerServeModuleBundle:R}=await import("./chunk-ed1qn902.js");return`<script ${v} src="${R(k)}"></script>`}async function fh(v,k,C){try{let{registeredModuleIdsIn:R,buildModuleRegistryScript:T}=await Et("stx/client-module-registry",()=>import("./chunk-qfppetcn.js")),z=[],F=await T(R(...v),{minify:ro(k.buildMode),collectInputs:z});for(let V of z)C?.add(V);if(!F)return null;if(k.buildMode==="serve"){let{registerServeModuleBundle:V}=await import("./chunk-ed1qn902.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${V(F)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${F.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}function ZS(v,k=""){let C=xh(v,"data-stx-runtime");if(!C)return v;let R=co(v);if(R===-1||R===C.start){if(!k)return v;return v.slice(0,C.end)+k+v.slice(C.end)}if(R<C.start)return v.slice(0,R)+v.slice(C.start,C.end)+k+`
|
|
2608
|
+
`+v.slice(R,C.start)+v.slice(C.end);let T=v.slice(C.start,C.end),z=v.slice(0,C.start)+v.slice(C.end),F=co(z);if(F===-1)return T+k+`
|
|
2609
|
+
`+z;return z.slice(0,F)+T+k+`
|
|
2610
|
+
`+z.slice(F)}function GS(v){let k=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return v.replace(k,(C,R,T)=>{let z=v.slice(0,T);return z.lastIndexOf("<")>z.lastIndexOf(">")?`{{${R}}}`:`{<!--stx-literal-->{${R}}}`})}async function n(v,k,C,R,T){if(R.ssr===!1&&!R.autoShell&&R.buildMode==="spa")return v;if(k.__stx_signals_gate===void 0)k.__stx_signals_gate=Ce(v,C);let z=!k.__stxProcessingDepth;En(k);for(let F of R._layerGraph?.configDependencies??[])T.add(F);if(z&&R.runtimeConfig)await Rn(k,C,R.runtimeConfig);if(z)Id(k),k.__stx_scope_seq??={n:0,key:Bun.hash(String(k.__filename??C)).toString(36).slice(0,6)},k.__stx_head_injections=Zs(),k.__stx_seo_staged=!1;if(!k.__stxProcessingDepth)k.__stxProcessingDepth=0;if(k.__stxProcessingDepth++,!k.__onceStore)k.__onceStore=new Set;if((R.debug||!E()&&!jn())&&C&&C.endsWith(".stx"))lo(v,C);try{return await J.timeAsync("template-processing",async()=>{let F=await JS(v,k,C,R,T);if(z)F=Du(F);if(z&&R.autoShell&&R.buildMode!=="compile"){let V=we(R.app?.head,{known:Dn,source:"app.head"}),K=(k.__stx_runtime_head||null)??eo(),X=(k.__stx_head_raw||"").trim(),G,te=X.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(te)G=te[1].trim(),X=X.replace(te[0],"").trim();let ce=k.__sections?.title,ee=K.title||G||ce,le=!K.title&&(!!G||!!ce),ue=K.meta||[],de=new Set(ue.map((De)=>Pe(De)).filter(Boolean)),fe={...V,...ee&&{title:ee},meta:[...(V.meta||[]).filter((De)=>!de.has(Pe(De))),...ue],link:[...V.link||[],...K.link||[]],script:[...V.script||[],...K.script||[]],headRaw:[V.headRaw,X].filter(Boolean).join(`
|
|
2611
|
+
`),...K.htmlAttrs&&{htmlAttrs:Xi(V.htmlAttrs,K.htmlAttrs)},...K.bodyAttrs&&{bodyAttrs:{...V.bodyAttrs||{},...K.bodyAttrs}}},pe=Qs(F);if(F=On(F,fe,{...le&&{titleIsHtml:!0},...R.app?.colorMode&&{colorMode:R.app.colorMode}},pe),pe)F=Yi(F,V),F=In(F,fe.htmlAttrs);let Ae=F.match(/<!-- stx-layout: ([^ ]+) -->/);if(Ae&&F.includes("<head")){let De=Ae[1],Me=Or(De);F=F.replace(/<head\b[^>]*>/i,(je)=>`${je}
|
|
2612
|
+
<meta name="stx-layout" content="${uh(De)}">
|
|
2613
|
+
<meta name="stx-layout-group" content="${uh(Me)}">`)}let Se=F.match(/function (__stx_setup_\w+)\(/),ve=Se?Gn(F):null;if(Se&&ve&&!/\bdata-stx=/.test(ve.tag)){F=gs(F,(Me,je)=>`<body${je} data-stx="${Se[1]}">`);let De=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${Se[1]}"`,"i");F=F.replace(De,"$1")}}if(z){let V=k.__stx_head_injections??Zs(),H=Ji(F);if(H!==null)V.beforeClose.push(H);let K=Tm(F);if(K!==null)V.afterOpen.push(K);if(R.offline?.enabled&&!F.includes("data-stx-offline"))V.beforeClose.push(Im);F=Gi(F,V);let X=R.app?.colorMode;if(X)F=Pn(F,X)}if(z)if(xh(F,"data-stx-runtime")){let H=null,K=null,X=null,G=null,te=null;try{let{getStoreScript:ee}=await Et("stx/store-loader",()=>import("./chunk-vepjs3tg.js")),le=R.storesDir,ue=await ee(le);if(ue)X=`<script data-stx-stores>${ue}</script>`,K=await dh("data-stx-stores",ue,R)??X}catch{}H=await fh([F,X],R,T);try{let{getFrameworkComposableScript:ee}=await Et("stx/framework-composables",()=>import("./chunk-h4ashx84.js"));te=await ee(F)}catch{}try{let{getComposableScript:ee}=await Et("stx/composable-loader",()=>import("./chunk-96ypgjm4.js")),le=R.composablesDir,ue=[H,X,te].filter((fe)=>fe!==null),de=await ee(R._layerComposableDirs??le,F,ue);if(de)G=await dh('data-stx-scoped data-stx-run="always" data-stx-composables',de,R)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${de}</script>`}catch{}let ce=[H,K,G,te].filter((ee)=>ee!==null).map((ee)=>`
|
|
2614
|
+
${ee}`).join("");F=ZS(F,ce)}else{let H=await fh([F],R,T);if(H){let K=F.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(K!==-1)F=F.slice(0,K)+H+`
|
|
2615
|
+
`+F.slice(K)}}if(z)F=Ki(F);if(z&&k.__stx_inject_css!==!1)F=await f(F,void 0,R.buildMode==="serve",!0);else if(z)F=io(F);if(F=F.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),F=GS(F),z&&k.__stx_runtime_config)F=it(F,k.__stx_runtime_config);if(z&&!k.__stx_defer_server_data){let V=fr(k);if(V){let H=/<head\b[^>]*>/i.exec(F),K=H?H.index+H[0].length:0;F=F.slice(0,K)+V+F.slice(K)}}return F})}catch(F){if(F instanceof q)throw F;let V=F instanceof Error?F.message:String(F),H=new W(`Template processing failed: ${V}`,C,void 0,void 0,v.substring(0,200)+(v.length>200?"...":""));if(O.log(H,{filePath:C,context:k}),Ut.logDetailedError(H,{filePath:C,template:v.substring(0,500)}),R.debug)throw H;return to.createFallbackContent("Template Processing",H)}}async function JS(v,k,C,R,T){let z=process.cwd(),F={...R,partialsDir:R.partialsDir&&!fn.isAbsolute(R.partialsDir)?fn.resolve(z,R.partialsDir):R.partialsDir,componentsDir:R.componentsDir&&!fn.isAbsolute(R.componentsDir)?fn.resolve(z,R.componentsDir):R.componentsDir,layoutsDir:R.layoutsDir&&!fn.isAbsolute(R.layoutsDir)?fn.resolve(z,R.layoutsDir):R.layoutsDir},V=F,H=v;await e0(C,k),QS(k,V),H=await ae(()=>vm(H,k,C,V),H,(Se)=>{O.log(Se,{filePath:C,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${C}: ${Se.message}`)}),H=H.replace(/\{\{--[\s\S]*?--\}\}/g,"");let K=qn(H,Ke,(Se,ve)=>`\x00STX_HTML_COMMENT_${ve}\x00`);H=K.output;let X=K.tokens,G=(Se)=>X.length===0?Se:Se.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(ve,De)=>X[Number(De)]??""),te="\x00STX_ESCAPED_AT\x00",ce="\x00STX_ESC_MUSTACHE_OPEN\x00",ee="\x00STX_ESC_MUSTACHE_CLOSE\x00";H=H.replace(/@@/g,te),H=H.replace(/@\{\{([\s\S]*?)\}\}/g,(Se,ve)=>`${ce}${ve}${ee}`),H=km(H),H=await Qm(H,C,T);let le={};H=Ms(H,le);let ue={...k.__sections||{}},de="",fe=op(Je(v)),pe=/@nolayout\b/.test(H)||fe===!1;if(/@nolayout\b/.test(H))H=H.replace(/@nolayout\b\s*/g,"");let Ae=H.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(Ae)de=Ae[1],H=H.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof fe==="string"){if(de=fe,!/@section\s*\(/.test(H))H=`@section('content')
|
|
2616
|
+
${H.trim()}
|
|
2617
|
+
@endsection`}if(!de&&!pe&&V.defaultLayout){let Se=Vt(H),ve=/@section\s*\(/.test(H);if(!Se||ve){let De="",Me=fn.dirname(C),je=V.layoutsDir?fn.dirname(V.layoutsDir):process.cwd();for(let Le=0;Le<20;Le++){let Be=fn.join(Me,"_layout.stx");if(await r(Be)){De=Be;break}let Oe=fn.dirname(Me);if(Oe===Me||Oe.length<je.length)break;Me=Oe}if(De)de=De;else if(V.layoutsDir){let Le=fn.isAbsolute(V.layoutsDir)?V.layoutsDir:fn.resolve(process.cwd(),V.layoutsDir),Be=fn.join(Le,`${V.defaultLayout}.stx`);if(await r(Be))de=Be}if(de&&!ve)H=`@section('content')
|
|
2618
|
+
${H.trim()}
|
|
2619
|
+
@endsection`}}if(de&&H.includes("<script")){let Se=yn(H),ve=Se.scripts.map((De)=>ph(De,C)??De);H=ds(Se.output,ve)}if(H=H.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(Se,ve,De)=>(ue[ve]=De,"")),H=H.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(Se,ve,De)=>{if(/^(['"]).*\1$/.test(De.trim()))return Se;try{let Me=l(De.trim(),k);if(Me===void 0)return Se;return ue[ve]=String(Me??""),""}catch{return Se}}),H=H.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(Se,ve,De)=>{if(De.includes("@parent"))ue[ve]=De.replace("@parent",ts);else ue[ve]=De.trim();return""}),k.__sections=ue,H=H.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(Se,ve,De)=>ue[ve]||De||""),!("slot"in k)||k.slot===void 0)H=H.replace(/\{\{\s*slot\s*\}\}/g,()=>ue.content||"");if(H=Ls(H,le),de){let Se=[],ve=yn(H),De=qn(ve.output,us,(Me,je)=>`\x00STX_ORPHAN_STYLE_${je}\x00`);if(H=De.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(Me,je,Le)=>{let Be=je==="SCRIPT"?ph(ve.scripts[Number(Le)],C):De.tokens[Number(Le)];if(Be)Se.push(Be);return""}),Se.length>0){let Me=Se.join(`
|
|
2620
|
+
`);ue.content=ue.content?`${ue.content}
|
|
2621
|
+
${Me}`:Me,k.__sections=ue}}if(de)try{let Se;if(fn.isAbsolute(de))Se=de,T.add(de);else Se=await ae(()=>mr(de,C,F,T),null,()=>{throw new W(`Failed to resolve layout path: ${de}`,C,void 0,void 0,`Layout referenced from ${C}`)});if(!Se){let Be=(Fe)=>{if(!Fe)return[];try{let Ve=fn.isAbsolute(Fe)?Fe:fn.resolve(process.cwd(),Fe);return KS.readdirSync(Ve).filter((ze)=>ze.endsWith(".stx")).map((ze)=>ze.replace(/\.stx$/,""))}catch{return[]}},Oe=[...Be(F.layoutsDir),...Be(F.fallbackLayoutsDir)].filter((Fe,Ve,ze)=>ze.indexOf(Fe)===Ve).sort(),We=`Layout not found: ${de} (referenced from ${C})`+(Oe.length>0?`. Available layouts: ${Oe.join(", ")}`:F.layoutsDir?`. No .stx layouts found in ${F.layoutsDir}`:"");if(O.log(Error(We),{layoutPath:de,filePath:C,available:Oe},"error"),console.error(`[stx] ${We}`),F.debug)throw new W(We,C);return H}let ve=await ae(()=>Bun.file(Se).text(),"",()=>{throw new W(`Failed to read layout file: ${Se}`,C,void 0,void 0,"Layout content could not be loaded")});ve=lh(ve,Se);let De=ve.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(De){if(F.debug)console.log(`Found nested layout: ${De[1]} in ${Se}`);let Be={},Oe=ve.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(Ve,ze,He)=>(Be[ze]=He.trim(),""));for(let[Ve,ze]of Object.entries(Be))if(ue[Ve]&&ue[Ve].includes(ts)){let He=ue[Ve].indexOf(ts);ue[Ve]=ue[Ve].slice(0,He)+ze+ue[Ve].slice(He+ts.length)}else if(!ue[Ve])ue[Ve]=ze;let We={...k,__sections:ue},Fe=`@layout('${De[1]}')${Oe}`;return await n(Fe,We,Se,F,T)}let Me=ve.replace(/\{\{--[\s\S]*?--\}\}/g,""),je=Ms(Me,le),Le={};return je=je.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(Be,Oe,We)=>(Le[Oe]=We.trim(),`@slot('${Oe}')`)),je=je.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Be,Oe,We)=>{if(ue[Oe]){let Fe=ue[Oe];if(Fe.includes(ts)){let Ve=Le[Oe]||"",ze=Fe.indexOf(ts);Fe=Fe.slice(0,ze)+Ve+Fe.slice(ze+ts.length)}return Fe}return We||""}),je=YS(je,ue),je=je.replace(/\{\{\s*slot\s*\}\}/g,()=>ue.content||""),je=Ls(je,le),k.__originalFilePath=C,H=await hh(je,k,Se,F,T),H=`<!-- stx-layout: ${de} -->
|
|
2622
|
+
${H}`,G(H)}catch(Se){if(Se instanceof q)throw Se;throw new W(`Error processing layout ${de}: ${Se instanceof Error?Se.message:String(Se)}`,C)}return G(await hh(H,k,C,F,T))}function YS(v,k){return v.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(C,R,T)=>{let z=k[R];if(z!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${R.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(z))return z}return T||""})}function QS(v,k){if(v.__stx_sfc_mode=!0,v.__stx_options=k,k.buildMode)v.__stx_buildMode=k.buildMode;let C=k.envPrefix||"STX_PUBLIC_",R={};for(let[T,z]of Object.entries(process.env))if(T.startsWith(C)&&z!==void 0)R[T]=z;v.$env=R}async function e0(v,k){await ae(()=>$m(v,k),void 0,(C)=>{O.log(C,{filePath:v,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${v}: ${C.message}`)})}var Mu="data-stx-source";function ph(v,k){if(!v)return v;let C=/^<script\b([^>]*)>/i.exec(v);if(!C||!/\bserver\b/.test(C[1])||C[1].includes(Mu))return v;return`<script ${Mu}="${encodeURIComponent(k)}"${v.slice(7)}`}function t0(v){let k=new RegExp(`${Mu}="([^"]*)"`).exec(v);return k?decodeURIComponent(k[1]):void 0}function gh(v){return v.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function mh(v,k,C){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${k==="module-resolution"?"imports a module that does not resolve":k==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${gh(v)}</span><span style="display:block;margin-top:4px">${gh(C)}</span></div>`}async function n0(v,k,C,R){let{scanScriptTags:T}=await Et("stx/signal-processing",()=>import("./chunk-6per0k6j.js")),z=[],F=!E()&&!jn();for(let H of T(v)){let K=H.attrs;if(!/\bserver\b/.test(K))continue;let X=H.start+H.fullMatch.indexOf(">")+1,G=yh(v,X);if(G===-1)continue;let te=v.slice(X,G);if(!te.trim())continue;let ce=t0(K)??C,ee={index:H.start,length:G+9-H.start};try{let{extractVariables:le}=await Et("stx/variable-extractor",()=>import("./chunk-y4egzqqf.js"));await le(te,k,ce,{preserveExisting:!0,onFailure:(ue)=>{if(ue.kind==="unknown")return;if(R?.onServerScriptError?.({sourcePath:ce,kind:ue.kind,message:ue.message}),!F)return;z.push({...ee,markup:mh(ce,ue.kind,ue.message)})}})}catch(le){let ue=le instanceof Error?le:Error(String(le));if(O.log(ue,{filePath:ce,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${ce}: ${ue.message}`),F)z.push({...ee,markup:mh(ce,"unknown",ue.message)})}}if(z.length===0)return v;let V=v;for(let H of z.sort((K,X)=>X.index-K.index))V=V.slice(0,H.index)+H.markup+V.slice(H.index+H.length);return V}async function r0(v,k,C){try{let{interpolateScriptsInTemplate:R}=await Et("stx/expressions",()=>import("./chunk-ev479f3z.js"));return R(v,k,{skipServer:!0})}catch(R){let T=R instanceof Error?R:Error(String(R));return O.log(T,{filePath:C,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${C}: ${T.message}`),v}}async function hh(v,k,C,R,T){let z=v,F=R;if(z=await n0(z,k,C,R),z=await r0(z,k,C),z=await cm(z,k,C),z=await lm(z,k,C),z=await Hp(z,k,C,F),Ce(z))z=Ei(z,k),z=Is(z,k),z=Ps(z,k);z=Ti(z);let{processStreamDirectives:V}=await Et("stx/streaming",()=>import("./chunk-cac98pkx.js"));z=V(z,k),z=Ii(z,k,C,F,!0),z=await Am(z,k,C,F,T),z=await $s(z,k,C,F,T),z=ip(z,k,C,F);let{processDeferDirectives:H}=await Et("stx/defer",()=>import("./chunk-w21444rc.js"));z=H(z,k,C);let{processTeleportDirectives:K}=await Et("stx/teleport",()=>import("./chunk-khzdk7q9.js"));z=K(z,k,C);let{processTransitionDirectives:X,processTransitionAttributes:G}=await Et("stx/transitions",()=>import("./chunk-9e1vjey6.js"));z=X(z,k,C),z=G(z);let{processErrorBoundaryDirectives:te,stripRenderFailedMarkers:ce}=await Et("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));z=te(z,k,C),z=ce(z);let{processSuspenseDirectives:ee}=await Et("stx/suspense",()=>import("./chunk-4eb02a0z.js"));z=ee(z,k,C);let{processAsyncDirectives:le}=await Et("stx/async-components",()=>import("./chunk-8yycg9pb.js"));z=le(z,k,C);let{processKeepAliveDirectives:ue}=await Et("stx/keep-alive",()=>import("./chunk-2aj6bjyd.js"));z=ue(z,k,C);let{processVirtualListDirectives:de,processVirtualGridDirectives:fe,processInfiniteListDirectives:pe}=await Et("stx/virtual-scrolling",()=>import("./chunk-5kprybdd.js"));z=de(z,k,C),z=fe(z,k,C),z=pe(z,k,C);let{processPartialHydrationDirectives:Ae,processStaticDirectives:Se}=await Et("stx/partial-hydration",()=>import("./chunk-87nt0kty.js"));z=Ae(z,k,C),z=Se(z);let{processComputedDirectives:ve,processWatchDirectives:De}=await Et("stx/computed",()=>import("./chunk-1xdzcy9d.js"));z=ve(z,k,C),z=De(z,k,C);let{processFormValidationDirectives:Me}=await Et("stx/forms-validation",()=>import("./chunk-91ranpvz.js"));z=Me(z,k,C);let{processHeadDirective:je,processTitleDirective:Le,processMetaDirective:Be,resetHead:Oe}=await Et("stx/head",()=>import("./chunk-y4nm9wq4.js"));if(!k.__stx_head_preset&&!k.__stx_runtime_head)Oe();let We=je(z);if(z=We.content,We.headContent)k.__stx_head_raw=`${k.__stx_head_raw||""}${We.headContent}
|
|
2623
|
+
`;if(z=Le(z,k),z=Be(z,k,C),z=Sm(z),z=jl(z,k),z=Up(z),z=xm(z),z=await Ds(z,k,C,F,T),z=await $s(z,k,C,F,T),k.__stxProcessingDepth===1)z=Pd(z,k);if(z=z.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),z=Du(z),z=Sr(z,k,C),z=Ns(z),z=ap(z,k,{filePath:C,buildMode:F.buildMode}),z=Ll(z,k),z=Bl(z,k),z=Pa(z,k),z=Yp(z,k),z=Qp(z,k),z=await Op(z,k,C,F),z=await pp(z,k,C),z=await Li(z,k,C,F),z=ji(z,k,C,F),z=Gs(z,k,C,F),z=Ks(z,k,C),z=Xs(z,k,C,F),z=Fp(z,k,C,F),z=Bs(z,k),z=Fs(z),z=rh(z),!F.skipEventDirectives)z=Sd(z,k,C);if(z=up(z,k,C),F.debug){let $t=/\bx-data\s*=/.test(z),mt=As(v);if($t&&mt)console.warn(`[stx] ${C}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
2624
|
+
Both work on the same page, but they manage separate scopes.
|
|
2625
|
+
Prefer signals (state/derived/effect) for new components.`)}z=Dg(z,k),z=await Z(z,k,C),z=ah(z),z=ch(z),z=Gf(z);let{processXElementDirectives:Fe}=await Et("stx/x-element",()=>import("./chunk-zhxdpzga.js"));z=Fe(z);let Ve=k.__originalFilePath||C,ze=ke(k);if(z=await $i(z,F,Ve,ze),z=Zp(z,k),z=await wm(z,k,C,F),F.media?.image?.autoSiblings){let $t=F.publicDir||"public",{rewriteImagesWithSiblings:mt}=await Et("stx/image-optimization/auto-sibling",()=>import("./chunk-kt994306.js"));z=await mt(z,{publicDir:$t})}if(F.seo?.enabled)z=Js(z,k,F);let He=($t,mt,kt=!0)=>{if(!mt)return $t;let Wt=mt.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),Qt=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec($t),nn=Qt?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(Qt[0]):null;if(Wt&&Qt&&nn){if(kt){let pn=Qt.index+nn.index;$t=$t.slice(0,pn)+Wt[0]+$t.slice(pn+nn[0].length)}if(mt=mt.replace(Wt[0],"").trim(),!mt)return $t}if(/<\/head>/i.test($t))return $t.replace(/<\/head>/i,`${mt}
|
|
2626
|
+
</head>`);if(/<head\b[^>]*>/i.test($t))return $t.replace(/(<head\b[^>]*>)/i,`$1
|
|
2627
|
+
${mt}`);if(/<html\b[^>]*>/i.test($t))return $t.replace(/(<html\b[^>]*>)/i,`$1
|
|
2628
|
+
<head>
|
|
2629
|
+
${mt}
|
|
2630
|
+
</head>`);return $t},{renderHead:wt,getHead:vt}=await Et("stx/head",()=>import("./chunk-y4nm9wq4.js")),pt=k.__stx_runtime_head??vt();if(pt.title||pt.meta?.length||pt.link?.length){let $t=wt(pt);if($t)z=He(z,$t)}if(We.headContent)z=He(z,We.headContent,!pt.title);if(F.csp?.enabled&&F.csp.addMetaTag)z=zp(z,F.csp,k);if(F.analytics?.enabled)z=Jf(z,F);if(F.heatmap?.enabled)z=Qf(z,F);if(F.pwa?.enabled&&F.pwa.autoInject!==!1){let{injectPwaTags:$t}=await Et("stx/pwa/inject",()=>import("./chunk-ayt4qd82.js"));z=$t(z,F)}let St=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(z),Rt=/\bSTX\.\w+/.test(z),xt=/window\.STX\s*=/.test(z);if(St&&Rt&&!xt){let mt=`<script data-stx-scoped data-stx-run="once">
|
|
2631
|
+
${Kf()}
|
|
2632
|
+
</script>`;if(z.includes("</head>")){let kt=z.indexOf("</head>"),Qt=z.slice(0,kt).indexOf("<script");if(Qt!==-1){let nn=z.slice(0,Qt),pn=z.slice(Qt);z=nn+mt+`
|
|
2633
|
+
`+pn}else z=z.replace("</head>",`${mt}
|
|
2634
|
+
</head>`)}else if(z.includes("<body"))z=z.replace(/<body([^>]*)>/,`<body$1>
|
|
2635
|
+
${mt}`);else z=mt+`
|
|
2636
|
+
`+z}{let{scanScriptTags:$t}=await Et("stx/signal-processing",()=>import("./chunk-6per0k6j.js")),mt=[];for(let kt of $t(z)){if(!/\bserver\b/i.test(kt.attrs))continue;let Wt=kt.start+kt.fullMatch.indexOf(">")+1,Qt=yh(z,Wt);if(Qt===-1)continue;let nn=Qt+9;while(nn<z.length&&/\s/.test(z[nn]))nn++;mt.push({start:kt.start,end:nn})}if(mt.length>0){let kt=Array(mt.length+1),Wt=0;for(let Qt=0;Qt<mt.length;Qt++){let{start:nn,end:pn}=mt[Qt];kt[Qt]=z.slice(Wt,nn),Wt=pn}kt[mt.length]=z.slice(Wt),z=kt.join("")}}let ft=ha(z,C);if(ft.hasScoped)z=ft.html;let _t=k.__stx_event_bindings||[],bt=!1,Xt=[],Un=/\s:[a-z][\w.-]*\s*=/.test(z),{scanScriptTags:Bn}=await Et("stx/signal-processing",()=>import("./chunk-6per0k6j.js"));for(let $t of Bn(z,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))Xt.push({match:$t.fullMatch,attrs:$t.attrs,content:$t.body});for(let{match:$t,attrs:mt,content:kt}of Xt){bt=!0;let Wt=kt;Qe(kt,C,R.strict,k.__originalFilePath);let Qt=await _e(kt,{eventBindings:_t,attrs:mt,hasColonDirectives:Un,templateContent:v,filePath:C,projectRoot:process.cwd(),production:ro(R.buildMode),serverData:ze});z=z.replace($t,()=>Qt)}if(bt)k.__stx_event_bindings=[];if(!bt&&k.__stxProcessingDepth===1){let $t=k.__stx_event_bindings||[];if($t.length>0){let mt=uc($t);if(mt){let kt=z.lastIndexOf("</body>");z=kt===-1?z+mt:z.slice(0,kt)+mt+`
|
|
2637
|
+
`+z.slice(kt)}k.__stx_event_bindings=[]}}if(!he(z)&&Bm(z))z=await Za(z,F);if(z=zm(z),F.csp?.enabled&&F.csp.useNonce&&typeof k.cspNonce==="string")z=Wp(z,k.cspNonce);return z}var s0=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],i0=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],o0=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}];function Xc(v){let k=[],C=[];return a0(v,k),c0(v,k,C),l0(v,C),u0(v,k),{valid:k.length===0,errors:k,warnings:C}}function a0(v,k){let C=(v.match(/\{\{/g)||[]).length,R=(v.match(/\}\}/g)||[]).length;if(C!==R)k.push({type:"expression",message:`Unclosed expression brackets: found ${C} opening '{{' and ${R} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function c0(v,k,C){for(let R of s0){let T=new RegExp(`${R.open}(?:\\s|\\()`,"g"),z=new RegExp(R.close,"g"),F=(v.match(T)||[]).length,V=(v.match(z)||[]).length;if(R.altClose){let H=new RegExp(R.altClose,"g");V+=(v.match(H)||[]).length}if(F>V)k.push({type:"directive",message:`Unclosed @${R.name} directive: found ${F} opening and ${V} closing`,suggestion:`Add ${F-V} missing ${R.close} tag(s)`});else if(V>F)C.push({type:"directive",message:`Extra ${R.close} found: ${V-F} more closing than opening`,suggestion:`Check for orphaned ${R.close} tags`})}}function l0(v,k){for(let C of i0)if(C.pattern.test(v))k.push({type:"syntax",message:C.message,suggestion:C.suggestion})}function u0(v,k){for(let C of o0)if(C.pattern.test(v))k.push({type:"expression",message:`Security warning: ${C.message}`,suggestion:"Remove dangerous code from template expressions"})}function Jc(v,k){let C=v.slice(0,k).split(`
|
|
2638
|
+
`);return{line:C.length,column:C[C.length-1].length+1}}function Yc(v,k,C){let R=[];switch(v){case"if":case"elseif":case"unless":if(C.length===0)R.push({type:"syntax",message:`@${v} requires a condition`,suggestion:`Use @${v}(condition)`});break;case"foreach":if(C.length===0||!C[0].includes(" as "))R.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(C.length===0)R.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(C.length===0)R.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(C.length===0)R.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(C.length===0)R.push({type:"syntax",message:`@${v} requires a path`,suggestion:`Use @${v}('path/to/template')`});break}return R}function Zc(v){return/@[a-z]+/i.test(v)||/\{\{/.test(v)}function Qc(v){let k=v.matchAll(/@([a-z]+)/gi),C=new Set;for(let R of k){let T=R[1].toLowerCase();if(!T.startsWith("end"))C.add(T)}return Array.from(C)}import Jn from"path";import ci from"process";var Ft=["module","exports","require","props","$props","$bool","$num","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];var bh=new Set(Ft),d0=new Set(["props","$props","defineProps"]),f0=new Set(["stx","@stacksjs/stx"]),vh=m(128),wh=m(64);function p0(v){let k=[],C=0,R=v.split(`
|
|
2639
|
+
`);for(let T of R){let z=C,F=null,V=!1;for(let H=0;H<T.length;H++){let K=T[H];if(V){V=!1;continue}if(K==="\\"){V=!0;continue}if(F){if(K===F)F=null;continue}if(K==="'"||K==='"'||K==="`"){F=K;continue}if(K==="/"&&H+1<T.length&&T[H+1]==="/")break;if(K==="{")C++;else if(K==="}")C--}if(z===0){let H=T.match(/(?:const|let|var)\s+(\w+)\s*=/);if(H)k.push(H[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(T)){let K=T.match(/(?:const|let|var)\s+(\w+)/);if(K)k.push(K[1])}else{let K=T.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(K){let G=K[1].slice(1,-1).split(",").map((te)=>{let ce=te.split(":");return(ce.length>1?ce[1]:ce[0]).trim()}).filter((te)=>/^\w+$/.test(te));k.push(...G)}}}}return[...new Set(k)]}function Fc(v){let k=v;k=k.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),k=k.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),k=k.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),k=k.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),k=k.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function C(R){if(!R.includes(":"))return R;let T=[],z="",F=0,V=0,H=null;for(let K=0;K<R.length;K++){let X=R[K];if(H){if(z+=X,X===H)H=null;continue}if(X==='"'||X==="'"||X==="`"){H=X,z+=X;continue}if(X==="<")F++;else if(X===">"&&F>0)F--;else if(X==="(")V++;else if(X===")")V--;if(X===","&&F===0&&V===0){T.push(z),z="";continue}z+=X}if(z)T.push(z);return T.map((K)=>{let X=K.trim(),G=X.startsWith("..."),te=G?X.slice(3):X,ce=-1,ee=0;for(let Se=0;Se<te.length;Se++)if(te[Se]==="<")ee++;else if(te[Se]===">")ee--;else if(te[Se]===":"&&ee===0){ce=Se;break}if(ce===-1)return K;let ue=te.substring(0,ce).trim().replace(/\?$/,""),de=te.substring(ce+1),fe=-1,pe=0;for(let Se=0;Se<de.length;Se++)if(de[Se]==="<")pe++;else if(de[Se]===">")pe--;else if(de[Se]==="="&&pe===0){fe=Se;break}let Ae=G?"...":"";if(fe!==-1)return`${Ae}${ue} = ${de.substring(fe+1).trim()}`;return`${Ae}${ue}`}).join(", ")}k=k.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(R,T,z)=>{if(!z.includes(":"))return R;return`${T}(${C(z)})`});{let R=/\b(function\s+\w*\s*)\(/g,T,z=[];while((T=R.exec(k))!==null){let F=T.index+T[0].length-1,V=1,H=F+1,K=0,X=null;while(H<k.length&&V>0){let ce=k[H];if(X){if(ce===X)X=null;H++;continue}if(ce==='"'||ce==="'"||ce==="`"){X=ce,H++;continue}if(ce==="<")K++;else if(ce===">"&&K>0)K--;else if(K===0){if(ce==="(")V++;else if(ce===")")V--}if(V>0)H++}if(V!==0)continue;let G=k.substring(F+1,H);if(!G.includes(":"))continue;let te=C(G);z.push({start:F+1,end:H,replacement:te})}for(let F=z.length-1;F>=0;F--){let{start:V,end:H,replacement:K}=z[F];k=k.substring(0,V)+K+k.substring(H)}}return k=k.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(R,T)=>{if(!T.includes(":"))return R;if(T.includes("{")||T.includes("}"))return R;return`(${T.split(",").map((F)=>{let[V,...H]=F.split("="),K=V.split(":")[0].trim();if(H.length>0)return`${K} = ${H.join("=").trim()}`;return K}).join(", ")}) =>`}),k=k.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),k=k.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),k=k.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),k=k.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),k=k.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),k=k.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),k=k.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),k=k.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),k=k.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),k=k.replace(/\n\s*\n\s*\n/g,`
|
|
2640
|
+
|
|
2641
|
+
`),k}function zc(v){return v.replace(/\s*(?:imported from|from)\s+(?:(['"])([^'"\r\n]+)\1|(\S+))/g,(k,...C)=>{let[,R,T]=C,z=R??T;return/(?:[/\\]packages[/\\]stx[/\\]|@stacksjs[/\\]stx[/\\])/.test(z)?"":k})}function Hc(v){return/cannot find module|cannot find package|could not resolve|module not found|failed to resolve/i.test(v)}function Vc(v){if(v instanceof SyntaxError)return!0;let k=v instanceof Error?v.message:String(v);return/SyntaxError|Unexpected (token|identifier|string|number|keyword|end of)|Unterminated|Expected .+ but found/i.test(k)}function Uc(v){if(!/is not defined|can't find variable/i.test(v))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test(v)}var Sh=new Set;async function u(v,k,C,R={}){if(!v.trim())return;let T=w(),z=h(v,JSON.stringify(T)),F=vh.get(z);if(F===void 0){try{let Ue=B({loader:"ts",target:"browser",define:T}),at=v.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");at=at.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),F=Ue.transformSync(at)}catch{F=Fc(v)}vh.set(z,F)}let V={exports:{}},H=V.exports,K=ci.cwd(),X={},G=[...F.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((Ue)=>Ue[1]).filter((Ue)=>!Ue.startsWith("node:")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(Ue)),te=new Map;for(let Ue of G)try{if(Ue.startsWith(".")){X[Ue]=await import(Jn.resolve(Jn.dirname(C),Ue));continue}let at=Jn.resolve(K,"node_modules",Ue),ht=Jn.join(at,"package.json"),Tt=JSON.parse(d("fs").readFileSync(ht,"utf8")),Kt=Tt.main||"index.js";if(Tt.exports){let an=typeof Tt.exports==="string"?Tt.exports:Tt.exports["."];if(typeof an==="string")Kt=an;else if(an?.bun)Kt=an.bun;else if(an?.import)Kt=an.import;else if(an?.default)Kt=an.default}X[Ue]=await import(Jn.resolve(at,Kt))}catch(at){if(Ue.startsWith("."))te.set(Ue,at instanceof Error?at.message:String(at))}let ce=(Ue)=>{if(X[Ue])return X[Ue];let at=te.get(Ue);if(at!==void 0)throw Error(`Cannot require '${Ue}' from ${C}: ${at}`);return d(Ue)},ee=k.props||{},le=(Ue)=>{if(!Ue)return ee;let at={};for(let[ht,Tt]of Object.entries(Ue)){let Kt=ee[ht];if(Kt!==void 0)at[ht]=Kt;else if(typeof Tt==="function")at[ht]=Tt();else at[ht]=Tt}return at};for(let[Ue,at]of Object.entries(ee))Object.defineProperty(le,Ue,{value:at,enumerable:!0,configurable:!0,writable:!0});let ue=(Ue,at=!1)=>{if(Ue===void 0||Ue===null)return at;if(typeof Ue==="string"){let ht=Ue.trim().toLowerCase();if(ht===""||ht==="true"||ht==="1"||ht==="on"||ht==="yes")return!0;if(ht==="false"||ht==="0"||ht==="off"||ht==="no")return!1;return!0}return Boolean(Ue)},de=(Ue,at=0)=>{if(Ue===void 0||Ue===null)return at;if(typeof Ue==="string"){let Tt=Ue.trim();if(Tt==="")return at;let Kt=Number(Tt);return Number.isFinite(Kt)?Kt:at}let ht=Number(Ue);return Number.isFinite(ht)?ht:at};for(let Ue of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(ee,Ue))continue;try{Object.defineProperty(le,Ue,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let fe=(Ue)=>{if(!Ue)return ee;let at={...ee};for(let[ht,Tt]of Object.entries(Ue)){let Kt=Tt&&typeof Tt==="object"&&!Array.isArray(Tt)?Tt:{type:Tt};if(at[ht]===void 0&&Kt.default!==void 0)at[ht]=typeof Kt.default==="function"?Kt.default():Kt.default}return at},pe=()=>k.slots||{},Ae=(Ue,at)=>{let ht={...Ue};for(let[Tt,Kt]of Object.entries(at))if(ht[Tt]===void 0)if(typeof Kt==="function")ht[Tt]=Kt();else ht[Tt]=Kt;return ht},Se=(Ue)=>{let at=()=>Ue;return at.set=(ht)=>{},at.update=(ht)=>{},at},ve=(Ue)=>{let at,ht=!1;return()=>{if(!ht)try{at=Ue(),ht=!0}catch{at=void 0}return at}},De=(Ue)=>{},Me=(Ue)=>Ue(),je=(Ue)=>{},Le=(Ue)=>{},Be=lr(k);function Oe(Ue){let at=Ue||{};if(at.title!==void 0||at.description!==void 0)He({title:at.title,description:at.description})}function We(Ue){if(!Ue||typeof Ue!=="object")return;let at=k.__stxClientPayload??{};Object.assign(at,Ue),k.__stxClientPayload=at}let Fe=()=>{let Ue=k.__stxServeContext,at=k.__stxServeSearch??Ue?.search??"",ht=Ue?.path??"",Tt=Object.fromEntries(new URLSearchParams(at)),Kt=k.query,an=Object.keys(Tt).length>0?Tt:Kt??{},rs=at||(Object.keys(an).length>0?`?${new URLSearchParams(an).toString()}`:"");return{params:k.params??{},query:an,path:ht,name:"",fullPath:ht+rs,hash:"",matched:[]}},Ve=()=>({push:(Ue)=>{},replace:(Ue)=>{},back:()=>{},forward:()=>{},go:(Ue)=>{}}),ze=(Ue)=>{let at=k.__stx_runtime_head||{};k.__stx_runtime_head=xe(at,we(Ue||{},{known:_r,source:"useHead()"}))},He=(Ue)=>{ze(Cr(Ue||{}))},wt=(Ue)=>({value:Ue}),vt=(Ue)=>Ue,Ct=(Ue)=>({value:typeof Ue==="function"?Ue():Ue}),pt=(Ue,at)=>{},St=(Ue)=>{},Rt=(Ue)=>{},xt=(Ue)=>Ue?Ue():Promise.resolve(),ft=(Ue)=>(at,...ht)=>{},_t=(Ue)=>{},bt=(Ue,at)=>{},Xt=(Ue,at)=>at,Un=()=>({value:"light"}),Bn=()=>Se(!1),$t=(Ue)=>Se(!1),mt=()=>Se(!1),kt=()=>$t("(prefers-color-scheme: dark)"),Wt=()=>$t("(prefers-color-scheme: light)"),Qt=()=>$t("(prefers-reduced-motion: reduce)"),nn=()=>$t("(prefers-contrast: more)"),pn={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},nc=new Proxy(pn,{get(Ue,at){if(at in Ue)return Ue[at];return},set(Ue,at,ht){return Ue[at]=ht,!0}}),Yn={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},rc=console;try{let Ue=Os(F,C),at=new Set(Object.keys(ee)),ht=Object.keys(k).filter((lt)=>!at.has(lt)&&!d0.has(lt)&&ut(lt)),Tt=ht.map((lt)=>k[lt]);if(!ht.includes("__stxServeContext"))ht.push("__stxServeContext"),Tt.push(void 0);if(!at.has("cookies")){let lt=k.cookies??k.__stxServeContext?.cookies??{},Jt=ht.indexOf("cookies");if(Jt<0)ht.push("cookies"),Tt.push(lt);else Tt[Jt]=lt}let Kt=new Set(["async","module","exports","require","params","window","document","console","state","derived","effect"]),an=[],rs=[];for(let[lt,Jt]of Object.entries(ee)){if(!ut(lt))continue;if(Kt.has(lt))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${lt}\\b`).test(Ue))continue;an.push(lt),rs.push(Jt)}let Oo=p0(Ue).map((lt)=>`module.exports.${lt} = typeof ${lt} !== 'undefined' ? ${lt} : module.exports.${lt};`).join(`
|
|
2642
|
+
`),Mo=k.params??{},No=[],kr=[];for(let lt=0;lt<ht.length;lt++){if(ht[lt]==="params")continue;No.push(ht[lt]),kr.push(Tt[lt])}let ss=[...Ft,...an,...No],Qn=`return (async () => {
|
|
2643
|
+
${Ue}
|
|
2644
|
+
${Oo}
|
|
2645
|
+
return module.exports
|
|
2646
|
+
})()`,dn=h(Qn,ss.join("\x00")),dt=wh.get(dn);if(!dt)dt=Function(...ss,Qn),wh.set(dn,dt);let yt=k.__stx_options?.runtimeConfig;if(yt||/\buse(?:Server)?RuntimeConfig\b/.test(F))await Rn(k,C,yt);let At=await be(k.__stx_runtime_config??Ht()??_(),()=>Dm(k,()=>dt(V,H,ce,ee,le,ue,de,fe,Ae,We,Om,qs,vr,Se,ve,De,Me,je,Le,Oe,Fe,Ve,ze,He,Be.setResponseStatus,Be.setResponseHeader,Be.notFound,wt,vt,Ct,pt,St,Rt,xt,ft,_t,pe,bt,Xt,Un,Bn,$t,mt,kt,Wt,Qt,nn,nc,Yn,rc,pn.confirm,pn.alert,pn.fetch,Mo,...rs,...kr)));if(R.preserveExisting){for(let[lt,Jt]of Object.entries(At))if(!(lt in k)||k[lt]===void 0)k[lt]=Jt}else Object.assign(k,At);for(let[lt,Jt]of Object.entries(ee))if(!(lt in k))k[lt]=Jt}catch(Ue){if(k.__stx_strict_hydration)throw Ue;let at=zc(Ue instanceof Error?Ue.message:String(Ue));if(Hc(at))console.warn(`[stx] server <script> in ${C??"<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${at}`),R.onFailure?.({kind:"module-resolution",message:at,error:Ue});else if(Vc(Ue))console.warn(`[stx] server <script> in ${C??"<unknown>"} does not parse, so every variable in that script is undefined. Cause: ${at}`),R.onFailure?.({kind:"syntax",message:at,error:Ue});else if(Uc(at))console.warn(`[stx] server <script> in ${C??"<unknown>"} names something that does not exist, so every variable in that script is undefined. Optional chaining does not help here: an undefined identifier throws before the chain is reached. Cause: ${at}`),R.onFailure?.({kind:"missing-binding",message:at,error:Ue});else{let ht=`${C??"<unknown>"}\x00${at}`;if(ci.env.STX_DEBUG||!Sh.has(ht))Sh.add(ht),console.warn(`[stx] server <script> in ${C??"<unknown>"} threw, so every variable in that script is undefined and anything that reads one renders empty. Cause: ${at}`);R.onFailure?.({kind:"unknown",message:at,error:Ue})}try{await b0(F,k,C)}catch(ht){if(ci.env.STX_DEBUG){let Tt=ht instanceof Error?ht.message:String(ht);console.warn(`[stx] fallback extraction also failed in ${C??"<unknown>"}: ${Tt}`)}}}}function Wc(v){let k=0,C=null,R=!1,T=!1;for(let z=0;z<v.length;z++){let F=v[z];if(C){if(F===C){if(C=null,R||k===0)T=!0}continue}if(F==="'"||F==='"'||F==="`"){C=F;continue}if(F==="{")k++;else if(F==="}")k--;else if(v.startsWith("from",z)&&k===0)R=!0}return C===null&&k===0&&T}var g0=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/;function Os(v,k){let C=k?Jn.dirname(k):ci.cwd(),R=ci.cwd(),T=v.split(`
|
|
2647
|
+
`),z=[],F=0;while(F<T.length){let V=T[F].trim();if(V.startsWith("interface ")||V.startsWith("export interface ")||V.startsWith("type ")||V.startsWith("export type ")){if(V.includes("{")&&!V.includes("}")){let H=0;for(;F<T.length;F++){for(let K of T[F])if(K==="{")H++;else if(K==="}")H--;if(H<=0)break}}F++;continue}if(V.startsWith("definePageMeta(")){let H=0,K=!1,X=F;for(let ce=F;ce<T.length&&!K;ce++){let ee=null,le=!1,ue=T[ce];for(let de=0;de<ue.length;de++){let fe=ue[de];if(le){le=!1;continue}if(fe==="\\"){le=!0;continue}if(ee){if(fe===ee)ee=null;continue}if(fe==='"'||fe==="'"||fe==="`"){ee=fe;continue}if(fe==="(")H++;else if(fe===")"){if(H--,H===0){F=ce+1,K=!0;break}}}}if(!K)F=T.length;let G=T.slice(X,F).join(`
|
|
2648
|
+
`),te=[];for(let ce of["title","description"]){let ee=new RegExp(`\\b${ce}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(G);if(ee)te.push(`${ce}: ${JSON.stringify(ee[2])}`)}if(te.length>0)z.push(`useSeoMeta({ ${te.join(", ")} });`);continue}if(V.startsWith("import ")||V==="import"||V.startsWith("import{")||/^import['"]/.test(V)){let H=V,K=0;while(!Wc(H)&&F+K+1<T.length)K++,H=`${H} ${T[F+K].trim()}`;F+=K;let X=H.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),G=H.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),te=H.match(/^import\s*['"](.+?)['"]/),ce=H,ee=(le)=>{if(le.startsWith("."))return Jn.resolve(C,le);if(le.startsWith("~/")||le.startsWith("@/"))return Jn.resolve(R,le.slice(2));try{return Bun.resolveSync(le,C)}catch{return le}};if(X){let[,le,ue]=X,de=ee(ue);z.push(`const ${le} = (await import('${de}')).default`),z.push(`module.exports.${le} = ${le};`)}else if(G){let[,le,ue]=G,de=ee(ue),fe=[],pe=[],Ae=f0.has(ue);for(let Se of le.split(",")){let ve=Se.trim();if(!ve)continue;let De=ve.split(/\s+as\s+/);if(De.length===2){let[Me,je]=[De[0].trim(),De[1].trim()];if(Ae&&bh.has(Me)){z.push(`const ${je} = ${Me};`);continue}fe.push(`${Me}: ${je}`),pe.push(je)}else{if(Ae&&bh.has(ve))continue;fe.push(ve),pe.push(ve)}}if(fe.length>0)z.push(`const { ${fe.join(", ")} } = await import('${de}')`);for(let Se of pe)z.push(`module.exports.${Se} = ${Se};`)}else if(te){let le=ee(te[1]);z.push(`await import('${le}')`)}else z.push(ce);F++;continue}if(g0.test(V))z.push(T[F]),F++;else if(V.startsWith("export const ")||V.startsWith("export let ")||V.startsWith("export var ")){let H=_h(T,F),{type:K,name:X,value:G}=H;z.push(`${K} ${X} = ${G};`),z.push(`module.exports.${X} = ${X};`),F=H.nextIndex}else if(V.startsWith("export function ")||V.startsWith("export async function ")){let H=Nu(T,F);z.push(H.functionCode),z.push(`module.exports.${H.name} = ${H.name};`),F=H.nextIndex}else if(V.startsWith("const ")||V.startsWith("let ")||V.startsWith("var ")){let H=_h(T,F),{type:K,name:X,value:G}=H;z.push(`${K} ${X} = ${G};`),z.push(`module.exports.${X} = ${X};`),F=H.nextIndex}else if(V.startsWith("function ")||V.startsWith("async function ")){let H=Nu(T,F);z.push(H.functionCode),z.push(`module.exports.${H.name} = ${H.name};`),F=H.nextIndex}else if(V.startsWith("export default function ")||V.startsWith("export default async function ")){let H=T[F].replace(/^(\s*)export\s+default\s+/,"$1"),K=[...T];K[F]=H;let X=Nu(K,F);if(z.push(X.functionCode),X.name)z.push(`module.exports.default = ${X.name};`);F=X.nextIndex}else if(V.startsWith("export default ")){let H=V.replace(/^export\s+default\s+/,"").replace(/;$/,"");z.push(`module.exports.default = ${H};`),F++}else if(V.startsWith("class ")||V.startsWith("export class ")){let H=V.match(/(?:export\s+)?class\s+(\w+)/);if(H){let K=H[1],X=T[F].replace(/^export\s+/,""),G=0,te=F;for(;te<T.length;te++){let ce=T[te];for(let ee of ce)if(ee==="{")G++;else if(ee==="}")G--;if(te>F)X+=`
|
|
2649
|
+
`+ce;if(G<=0&&te>=F)break}z.push(X),z.push(`module.exports.${K} = ${K};`),F=te+1}else z.push(V),F++}else if(V.includes("module.exports"))z.push(V),F++;else if(V.trim()&&!V.startsWith("//"))z.push(V),F++;else F++}return m0(z.join(`
|
|
2650
|
+
`),C,R)}function m0(v,k,C){let R=v.length,T="",z=0,F=null,V=!1,H=!1,K=0;while(z<R){let X=v[z],G=v[z+1];if(V){if(T+=X,X===`
|
|
2651
|
+
`)V=!1;z++;continue}if(H){if(T+=X,X==="*"&&G==="/"){T+=G,z+=2,H=!1;continue}z++;continue}if(!F&&X==="/"&&G==="/"){V=!0,T+=X,z++;continue}if(!F&&X==="/"&&G==="*"){H=!0,T+=X,z++;continue}if(F){if(T+=X,X==="\\"){T+=G,z+=2;continue}if(X===F&&F!=="`"){F=null,z++;continue}if(F==="`"){if(X==="$"&&G==="{"){K++,T+=G,z+=2;continue}if(X==="`"){F=null,z++;continue}}z++;continue}if(K>0){if(X==="{")K++;else if(X==="}")K--}if(X==='"'||X==="'"||X==="`"){F=X,T+=X,z++;continue}if(X==="a"&&v.startsWith("await",z)){let te=h0(v,z);if(te){let{quote:ce,path:ee,end:le}=te;if(ee.startsWith(".")||ee.startsWith("~/")||ee.startsWith("@/")){let ue=ee.startsWith(".")?Jn.resolve(k,ee):Jn.resolve(C,ee.slice(2));T+=`await import(${ce}${ue}${ce})`,z=le;continue}}}T+=X,z++}return T}function h0(v,k){let C=k+5;if(C>=v.length)return null;if(!/\s/.test(v[C]))return null;while(C<v.length&&/\s/.test(v[C]))C++;if(!v.startsWith("import",C))return null;C+=6;while(C<v.length&&/\s/.test(v[C]))C++;if(v[C]!=="(")return null;C++;while(C<v.length&&/\s/.test(v[C]))C++;let R=v[C];if(R!=="'"&&R!=='"')return null;C++;let T=C;while(C<v.length&&v[C]!==R)if(v[C]==="\\")C+=2;else C++;if(C>=v.length)return null;let z=v.slice(T,C);C++;while(C<v.length&&/\s/.test(v[C]))C++;if(v[C]!==")")return null;return{quote:R,path:z,end:C+1}}function Rh(v,k){let C=v[k];if(C!=="{"&&C!=="[")return null;let T=S(v,C,C==="{"?"}":"]",k);if(T===-1)return null;return{pattern:v.slice(k,T+1),endPos:T+1}}function Ah(v){let k=[],C=v.slice(1,-1).trim();if(!C)return k;let R=0,T=0,z="";while(R<C.length){let F=C[R];if(F==="{"||F==="["){let V=T===0?Rh(C,R):null;if(V){k.push(...Ah(V.pattern)),R=V.endPos,z="";continue}T++}else if(F==="}"||F==="]")T--;if(T>0){R++;continue}if(F===","){if(z.trim())k.push(z.trim());z="",R++;continue}if(F===":"){z="",R++;continue}if(F==="="){if(z.trim())k.push(z.trim());z="",R++;while(R<C.length&&C[R]!==","&&T===0){if(C[R]==="{"||C[R]==="[")T++;else if(C[R]==="}"||C[R]==="]")T--;R++}continue}if(/[\w$]/.test(F))z+=F;R++}if(z.trim())k.push(z.trim());return k}function qc(v){let k=/^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec(v);if(!k)return null;let C=k[0].length,R=(T)=>T===" "||T==="\t";while(C<v.length&&R(v[C]))C++;if(v[C]===":"){let T=0,z=null;C++;for(;C<v.length;C++){let F=v[C];if(z){if(F==="\\"){C++;continue}if(F===z)z=null;continue}if(F==="'"||F==='"'||F==="`"){z=F;continue}if(F==="("||F==="["||F==="{"||F==="<"){T++;continue}if(F===")"||F==="]"||F==="}"||F===">"){T--;continue}if(F==="="&&T<=0){let V=v[C+1],H=v[C-1];if(V!=="="&&V!==">"&&H!=="="&&H!=="!"&&H!=="<"&&H!==">")break}}if(v[C]!=="=")return null}while(C<v.length&&R(v[C]))C++;if(v[C]!=="=")return null;return{type:k[1],name:k[2],value:v.slice(C+1).trim()}}function $h(v,k,C,R){let T=null,z=!1;for(let F of v){if(z){z=!1;continue}if(F==="\\"){z=!0;continue}if(T){if(F===T)T=null;continue}if(F==="'"||F==='"'||F==="`"){T=F;continue}if(F===k)R++;else if(F===C)R--}return R}function _h(v,k){let C=v[k].trim(),R=qc(C),T=R?[C,R.type,R.name,R.value]:null;if(!T){let X=C.match(/^(?:export\s+)?(const|let|var)\s+/);if(X){let G=C.slice(X[0].length),te=k;if(G.startsWith("{")||G.startsWith("[")){let ee=G[0],le=ee==="{"?"}":"]",ue=$h(G,ee,le,0),de=G;for(let fe=k+1;fe<v.length&&ue>0;fe++)de+=` ${v[fe].trim()}`,te=fe,ue=$h(v[fe],ee,le,ue);if(ue>0)de=G,te=k;G=de}let ce=Rh(G,0);if(ce){let ee=X[1],le=ce.pattern,ue=G.slice(ce.endPos).trim();if(ue.startsWith("=")){let de=ue.slice(1).trim(),fe=de,pe=Math.max(te,k);if(kh(de)){let De=Eh(v,pe,de);fe=De.value,pe=De.nextIndex}else pe=pe+1;fe=fe.trim().replace(/;$/,"");let Ae=Ah(le),Se=`__stx_src_${k}`,ve=Ae.map((De)=>`module.exports.${De} = ${De};`).join(`
|
|
2652
|
+
`);return{type:ee,name:Se,value:`${fe}; ${ee} ${le} = ${Se};
|
|
2653
|
+
${ve}`,nextIndex:pe}}}}throw Error(`Failed to parse variable declaration: ${C}`)}let[,z,F,V]=T,H=V,K=k;if(kh(V)){let X=Eh(v,k,V);H=X.value,K=X.nextIndex}else K=k+1;while(K<v.length){let X=v[K].trim();if(X.startsWith(".")||X.startsWith("?."))H+=`
|
|
2654
|
+
${v[K]}`,K++;else break}return H=H.trim().replace(/;$/,""),{type:z,name:F,value:H,nextIndex:K}}function Nu(v,k){let C=v[k].trim(),R=C.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!R)throw Error(`Failed to parse function declaration: ${C}`);let[,T]=R,z=C.replace(/^export\s+/,""),F=k;if(y0(C)){let V=x0(v,k,z);z=V.functionCode,F=V.nextIndex}else F=k+1;return{name:T,functionCode:z,nextIndex:F}}function kh(v){let k=v.trim();if(k.startsWith("{"))return S(k,"{","}",0)===-1;if(k.startsWith("["))return S(k,"[","]",0)===-1;return!Th(k)}function Th(v){let k={paren:0,bracket:0,brace:0},C=null,R=0;for(let T=0;T<v.length;T++){let z=v[T];if((T>0?v[T-1]:"")==="\\"&&C)continue;if((z==='"'||z==="'")&&!C){C=z;continue}if(z===C&&C!=="`"){C=null;continue}if(z==="`"&&!C){C="`";continue}if(z==="`"&&C==="`"&&R===0){C=null;continue}if(C==="`"&&z==="$"&&v[T+1]==="{"){R++,T++;continue}if(R>0&&z==="{"){R++;continue}if(R>0&&z==="}"){R--;continue}if(C)continue;if(z==="(")k.paren++;else if(z===")")k.paren--;else if(z==="[")k.bracket++;else if(z==="]")k.bracket--;else if(z==="{")k.brace++;else if(z==="}")k.brace--}return k.paren===0&&k.bracket===0&&k.brace===0&&C===null}function Ih(v){let k=v.indexOf("(");if(k===-1)return v.indexOf("{");let C=S(v,"(",")",k);if(C===-1)return-1;return v.indexOf("{",C)}function y0(v){let k=Ih(v);if(k===-1)return!0;return S(v,"{","}",k)===-1}function Eh(v,k,C){let R=C,T=k+1;while(T<v.length&&!Th(R)){let z=v[T];R+=`
|
|
2655
|
+
${z}`,T++}while(T<v.length){let z=v[T].trim();if(z.startsWith(".")||z.startsWith("?."))R+=`
|
|
2656
|
+
${v[T]}`,T++;else break}return{value:R,nextIndex:T}}function x0(v,k,C){let R=C,T=k+1;while(T<v.length){let z=Ih(R);if(z!==-1){if(S(R,"{","}",z)!==-1)break}let F=v[T];R+=`
|
|
2657
|
+
${F}`,T++}return{functionCode:R,nextIndex:T}}function Ch(v,k){let C=l(v,k)??l(`(${v})`,k);if(C!==void 0)return C;if(!/\bprocess\b/.test(v))return;let R={...k,process:Object.freeze({env:{...ci.env}})},T=Object.keys(R).filter(ut),z=T.map((F)=>R[F]);try{return Function(...T,`'use strict'; return (${v});`)(...z)}catch{try{return Function(...T,`'use strict'; return ${v};`)(...z)}catch{return}}}async function b0(v,k,C){let R=v.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let z of R){let[,,F,V]=z;try{let H=V.trim().replace(/;$/,""),K=Ch(H,k);if(K!==void 0)k[F]=K}catch(H){console.warn(`Failed to parse export ${F} in fallback:`,H)}}let T=v.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let z of T){let[,,F,V]=z;if(!(F in k))try{let H=V.trim().replace(/;$/,""),K=Ch(H,k);if(K!==void 0)k[F]=K}catch{}}}function Ai(v){let k=v.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),C=k?k[1]:"",R=k?v.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):v;return{scriptContent:C,templateWithoutScript:R}}function Pi(v){let k=v.trim();if(!k)return!1;return/(?:const|let|var|function)\s+\w+/.test(k)}var Po=new L(500),ec=new L(1000),Bu=new L(2000),zu=new L(500),Lh=33554432,Wu=Lh;function v0(v){let k=v.componentRenderCacheBytes;if(typeof k!=="number"||k<0||k===Wu)return;Wu=k,tc.setMaxBytes(k)}var tc=new L(2000,{maxBytes:Lh,sizeOf:(v)=>v.output.length});function w0(v){let k=new WeakSet;try{let C=(R)=>{if(R===void 0)return{__stxType:"undefined"};if(typeof R==="bigint")return{__stxType:"bigint",value:R.toString()};if(typeof R==="function"||typeof R==="symbol")throw TypeError("Non-serializable component input");if(R===null||typeof R!=="object")return R;if(k.has(R))throw TypeError("Circular component input");k.add(R);try{if(R instanceof Date)return{__stxType:"date",value:R.toISOString()};if(Array.isArray(R))return R.map(C);let T=Object.getPrototypeOf(R);if(T!==Object.prototype&&T!==null)throw TypeError("Non-plain component input");let z={};for(let F of Object.keys(R).sort())z[F]=C(R[F]);return z}finally{k.delete(R)}};return JSON.stringify(C(v))}catch{return null}}function S0(v){let k={};for(let[C,R]of Object.entries(v))if(!C.startsWith("__")||C==="__stxServeContext")k[C]=R;return k}function ju(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function el(v){return/\bjs\b/.test(v)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test(v)}function nt(v){return!el(v)}var Qa=new Map;function B(v){let k;try{k=JSON.stringify(v)}catch{return new Bun.Transpiler(v)}let C=Qa.get(k);if(C)return C;if(Qa.size>=16)Qa.clear();let R=new Bun.Transpiler(v);return Qa.set(k,R),R}var Ph=new WeakMap,$0=256;function rt(v){try{let k=B({loader:"ts",target:"browser",define:w()}),C=Ph.get(k);if(!C)C=new Map,Ph.set(k,C);let R=C.get(v);if(R!==void 0)return R;let T=v.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");T=T.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let z=[];T=T.replace(/\{!![\s\S]*?!!\}/g,(V)=>{let H=z.length;return z.push(V),`"__STX_EXPR_${H}__"`}),T=T.replace(/\{\{\{[\s\S]*?\}\}\}/g,(V)=>{let H=z.length;return z.push(V),`"__STX_EXPR_${H}__"`}),T=T.replace(/\{\{[\s\S]*?\}\}/g,(V)=>{let H=z.length;return z.push(V),`"__STX_EXPR_${H}__"`});let F=k.transformSync(T);for(let V=0;V<z.length;V++)F=F.replace(`"__STX_EXPR_${V}__"`,z[V]),F=F.replace(`'__STX_EXPR_${V}__'`,z[V]);if(C.size>=$0){let V=C.keys().next();if(!V.done)C.delete(V.value)}return C.set(v,F),F}catch(k){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",k);return v}}function _0(v){let k=[],C=new Set,R=0,T=0,z=v.length,F=(X)=>{T++;while(T<z){if(v[T]==="\\"){T+=2;continue}if(v[T]===X){T++;return}T++}},V=()=>{T++;while(T<z){if(v[T]==="\\"){T+=2;continue}if(v[T]==="`"){T++;return}if(v[T]==="$"&&v[T+1]==="{"){T+=2;let X=1;while(T<z&&X>0)if(v[T]==="{")X++,T++;else if(v[T]==="}")X--,T++;else if(v[T]==="'"||v[T]==='"')F(v[T]);else if(v[T]==="`")V();else T++;continue}T++}},H=()=>{if(v[T]==="/"&&v[T+1]==="/"){while(T<z&&v[T]!==`
|
|
2658
|
+
`)T++;return!0}if(v[T]==="/"&&v[T+1]==="*"){T+=2;while(T<z-1&&!(v[T]==="*"&&v[T+1]==="/"))T++;return T+=2,!0}return!1},K=()=>{if(R!==0)return;let X=v.slice(T).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(X){let ee=X[2].split(",").map((le)=>{let ue=le.trim().split(":");return ue[ue.length-1].trim()});for(let le of ee)if(le&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(le)&&!C.has(le))k.push(le),C.add(le);return}let G=v.slice(T).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(G){let ee=G[2];if(!C.has(ee))k.push(ee),C.add(ee);return}let te=v.slice(T).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(te){let ee=te[1];if(!C.has(ee))k.push(ee),C.add(ee);return}let ce=v.slice(T).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(ce){let ee=ce[1];if(!C.has(ee))k.push(ee),C.add(ee)}};while(T<z){if(H())continue;if(v[T]==="'"||v[T]==='"'){F(v[T]);continue}if(v[T]==="`"){V();continue}if(v[T]==="{"){R++,T++;continue}if(v[T]==="}"){R--,T++;continue}if(R===0&&/[a-z]/i.test(v[T])&&(T===0||/\s|[;{}()]/.test(v[T-1])))K();T++}return k}function k0(v){let k=[],C=0,R=0,T=null;for(let z=0;z<v.length;z++){let F=v[z];if(T){if(F==="\\"){z++;continue}if(F===T)T=null;continue}if(F==='"'||F==="'"||F==="`"){T=F;continue}if(F==="("||F==="["||F==="{")C++;else if(F===")"||F==="]"||F==="}")C--;else if(F===","&&C===0)k.push(v.slice(R,z)),R=z+1}if(R<v.length)k.push(v.slice(R));return k}function E0(v){let k=0,C=null;for(let R=0;R<v.length;R++){let T=v[R];if(C){if(T==="\\"){R++;continue}if(T===C)C=null;continue}if(T==='"'||T==="'"||T==="`"){C=T;continue}if(T==="("||T==="["||T==="{")k++;else if(T===")"||T==="]"||T==="}")k--;else if(T==="="&&k===0){let z=v[R-1],F=v[R+1];if(z==="!"||z==="<"||z===">"||z==="=")continue;if(F==="="||F===">")continue;return R}}return-1}function C0(v,k){try{let C=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec(v);if(!C)return;let R=C.index-1;while(R>=0&&/\s/.test(v[R]))R--;if(v[R]!=="}")return;let T=R,z=0,F=-1;for(;R>=0;R--){let H=v[R];if(H==="}")z++;else if(H==="{"){if(z--,z===0){F=R;break}}}if(F===-1)return;let V=v.slice(F+1,T);for(let H of k0(V)){let K=H.trim();if(!K||K.startsWith("..."))continue;let X=E0(K);if(X===-1)continue;let G=K.slice(0,X).trim();if(!/^[A-Z_$][\w$]*$/i.test(G))continue;if(k[G]!==void 0)continue;let te=K.slice(X+1).trim();if(!te)continue;try{let ce=Object.keys(k).filter(ut),ee=Function(...ce,`"use strict"; return (${te});`);k[G]=ee(...ce.map((le)=>k[le]))}catch{}}}catch{}}var R0=new Set(["tr","td","th","thead","tbody","tfoot","caption","colgroup","col","option","optgroup","li","dt","dd","span"]);function tl(v,k){let C=v.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)<([a-zA-Z][a-zA-Z0-9-]*)/s);if(!C)return null;let R=C[2].toLowerCase();if(!R0.has(R))return null;let T=new RegExp(`<\\/?${R}(?=[\\s/>])(?:[^>"']|"[^"]*"|'[^']*')*>`,"iy"),z=ne(v,(K,X)=>(T.lastIndex=X,T.exec(K)?.index===X?T.lastIndex:-1));if(R==="span"&&/\sdata-stx-scope\s*=/.test(z[0]?.token||""))return null;let F=0,V=!1;for(let K of z){if(F+=K.token.startsWith("</")?-1:1,F<0)return null;if(F===0){if(v.slice(K.end).trim())return null;V=!0;break}}if(!V)return null;let H=C[0].length;return v.slice(0,H)+k+v.slice(H)}async function gr(v,k,C,R,T){let z=v.endsWith(".stx")?v.slice(0,-4):v,F=(Se)=>Se.split("-").map((ve)=>ve.charAt(0).toUpperCase()+ve.slice(1)).join(""),V=C.__importedComponents;if(V){for(let Se of[z,z.toLowerCase(),F(z),gn(z)])if(V.has(Se))return!0}let H=[...new Set([`${z}.stx`,`${F(z)}.stx`,`${gn(z)}.stx`])],K=typeof T.root==="string"?gt.resolve(T.root):void 0,X=K??gt.dirname(R),G=[],te=(Se)=>{if(Se&&!G.includes(Se))G.push(Se)},ce=C.__originalFilePath;if(ce)te(gt.join(gt.dirname(ce),"components"));te(k),te(T._rootComponentsDir),te(gt.join(gt.dirname(R),"components")),te(T.componentsDir);let ee=T._targetComponentFallbackNames?.some((Se)=>Se.toLowerCase()===z.toLowerCase());if(!ee)for(let Se of T._targetComponentDirs??[])te(Se);if(K)te(gt.resolve(K,"resources/views/components")),te(gt.resolve(K,"resources/components")),te(gt.resolve(K,"src/components")),te(gt.resolve(K,"components"));for(let Se of T._layerComponentDirs??[])te(Se);let le=T._pluginComponentDirs;if(Array.isArray(le))for(let Se of le)te(typeof Se==="string"?Se:null);if(te(T.fallbackComponentsDir),ee)for(let Se of T._targetComponentDirs??[])te(Se);if(z.startsWith("./")||z.startsWith("../"))return r(gt.resolve(gt.dirname(R),`${z}.stx`));let ue=Dh(gt.resolve(import.meta.dir,"components")),de=G.map((Se)=>gt.isAbsolute(Se)?Se:gt.resolve(X,Se)),fe=`${H.join("\x00")}\x00\x00${de.join("\x00")}`,pe=Bu.get(fe);if(pe!==void 0)return pe;let Ae=!1;e:for(let Se of de){if(Dh(Se)===ue)continue;for(let ve of H)if(await r(gt.join(Se,ve))){Ae=!0;break e}}return Bu.set(fe,Ae),Ae}function Dh(v){let k=zu.get(v);if(k!==void 0)return k;let C=v;try{C=jh.realpathSync(v)}catch{}return zu.set(v,C),C}function nl(v){return v==="visible"||v==="idle"||v==="interaction"||v.startsWith("media:")}function Di(v){if(!v)return!1;let k=v.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(k)}function A0(v,k,C){if(!v.includes("{{")&&!v.includes("{!!"))return v;let R=(T,z)=>{let F;try{F=x(T,k)}catch{return z}if(F===void 0||F===null)return"";let V=String(F);if(/<\/style/i.test(V))return console.warn(`[stx] a <style> expression in ${C??"<unknown>"} evaluated to CSS containing a closing style tag, which would end the element early, so it was dropped rather than emitted.`),"";return V};return v.replace(/\{!!([\s\S]*?)!!\}/g,(T,z)=>R(z,T)).replace(/\{\{([\s\S]*?)\}\}/g,(T,z)=>R(z,T))}var Oh=new Set;function Mh(v,k,C,R){let T=`${v}\x00${k}\x00${R??""}`;if(!process.env.STX_DEBUG&&Oh.has(T))return;Oh.add(T);let z=k?` used in ${k}`:"",F=R?` Cause: ${R}.`:"",V=C.length>0?`
|
|
2659
|
+
searched:
|
|
2660
|
+
${C.map((H)=>` - ${H}`).join(`
|
|
2661
|
+
`)}`:"";console.error(`[stx] component <${v}> could not be resolved${z}, so it rendered as nothing.${F}${V}`)}function Nh(v){return`<!-- stx: component "${v.replace(/--+/g,"-")}" could not be resolved; see the server log -->`}function zs(v){let k=new Set,C=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel|useReactiveProp|useLocalStorage|useSessionStorage|keptState|useCookie|useDebouncedValue)\s*(?:<[^>]*>)?\s*\(/g;for(let R of v){let T;while((T=C.exec(R))!==null)k.add(T[1]);C.lastIndex=0}return[...k]}async function st(v,k,C,R,T,z,F,V=new Set,H,K=Ir(T),X,G=v){let{extractVariables:te}=await Et("stx/variable-extractor",()=>import("./chunk-y4egzqqf.js")),ce=V??new Set;if(ce.has(v))return`[Circular component reference: ${v}]`;let ee=new Set(ce);ee.add(v);let le=typeof k.client==="string"?k.client.trim():"";if("client"in k)delete k.client;let ue=le&&le!=="load"&&nl(le)?le:"";try{let de=(dt)=>dt.split("-").map((yt)=>yt.charAt(0).toUpperCase()+yt.slice(1)).join(""),fe=G.endsWith(".stx")?G.slice(0,-4):G,pe=null,Ae=T.__importedComponents;if(Ae){let dt=[fe,fe.toLowerCase(),de(fe),gn(fe)];for(let yt of dt)if(Ae.has(yt)){pe=Ae.get(yt);break}}let Se=[];if(!pe){let dt=[`${fe}.stx`,`${de(fe)}.stx`,`${gn(fe)}.stx`],yt=[...new Set(dt)],At=T.__originalFilePath,lt=[];if(lt.push(...F._layerComponentDirs??[]),At){let Pt=gt.join(gt.dirname(At),"components");lt.push(Pt)}if(R)lt.push(R);let Jt=F._rootComponentsDir;if(typeof Jt==="string"&&!lt.includes(Jt))lt.push(Jt);let en=gt.join(gt.dirname(z),"components");if(!lt.includes(en))lt.push(en);if(F.componentsDir&&F.componentsDir!==R&&!lt.includes(F.componentsDir))lt.push(F.componentsDir);let Rr=F._nativeHostAttrs&&/^(?:checkbox|switch)$/i.test(fe),is=(X?.events??[]).map((Pt)=>Pt.replace(/^@/,"").split(".")[0].toLowerCase().replace(/-/g,"")),Ar=Object.hasOwn(k,"checked")||Boolean(X?.reactiveProps?.includes("checked")),os=Object.hasOwn(k,"value")||Boolean(X?.reactiveProps?.includes("value")),jo=!is.includes("valuechange")&&(Ar||is.includes("change")&&!os),Lo=F._targetComponentFallbackNames?.some((Pt)=>Pt.toLowerCase()===fe.toLowerCase())&&(!Rr||jo);for(let Pt of Lo?[]:F._targetComponentDirs??[])if(Pt&&!lt.includes(Pt))lt.push(Pt);let zn=typeof F.root==="string"?gt.resolve(F.root):void 0,Bo=zn??gt.dirname(z),er=[];if(zn)er.push(gt.resolve(zn,"resources/views/components")),er.push(gt.resolve(zn,"resources/components")),er.push(gt.resolve(zn,"src/components")),er.push(gt.resolve(zn,"components"));er.push(gt.resolve(import.meta.dir,"components"));for(let Pt of er)if(!lt.includes(Pt))lt.push(Pt);let li=F._pluginComponentDirs;if(Array.isArray(li)){for(let Pt of li)if(typeof Pt==="string"&&!lt.includes(Pt))lt.push(Pt)}if(F.fallbackComponentsDir&&!lt.includes(F.fallbackComponentsDir))lt.push(F.fallbackComponentsDir);if(Lo){for(let Pt of F._targetComponentDirs??[])if(Pt&&!lt.includes(Pt))lt.push(Pt)}let Bi=[...new Set(lt.map((Pt)=>{if(!Pt)return Pt;return gt.isAbsolute(Pt)?Pt:gt.resolve(Bo,Pt)}))];lt.length=0,lt.push(...Bi);let as=`${fe}\x00${z}\x00${Bi.join("\x00")}`,ic=ec.get(as);if(ic)if(await r(ic))pe=ic;else ec.delete(as);if(!pe&&(fe.startsWith("./")||fe.startsWith("../")))pe=gt.resolve(gt.dirname(z),`${fe}.stx`),Se.push(pe);else if(!pe)for(let Pt of lt){if(!Pt)continue;for(let zo of yt){let Wo=gt.join(Pt,zo);if(Se.push(Wo),await r(Wo)){pe=Wo;break}}if(pe)break;if(!pe)try{let zo=await import("fs");if(!zo.statSync(Pt,{throwIfNoEntry:!1})?.isDirectory())continue;let Uh=8,oc=[{path:Pt,depth:0}];while(oc.length>0&&!pe){let Fo=oc.pop();if(Fo.depth>=Uh)continue;let Vu;try{Vu=zo.readdirSync(Fo.path,{withFileTypes:!0})}catch{continue}for(let Vo of Vu){if(!Vo.isDirectory())continue;if(Vo.name==="node_modules"||Vo.name.startsWith("."))continue;let Uu=gt.join(Fo.path,Vo.name);for(let Hh of yt){let ac=gt.join(Uu,Hh);if(Se.push(ac),await r(ac)){pe=ac;break}}if(pe)break;oc.push({path:Uu,depth:Fo.depth+1})}}}catch{}if(pe)break}if(pe)ec.set(as,pe)}if(!pe||!await r(pe))return Mh(v,z,Se),Nh(v);H.add(pe);let ve;if(Po.has(pe))ve=Po.get(pe);else try{ve=await Bun.file(pe).text(),Po.set(pe,ve)}catch(dt){let yt=dt instanceof Error?dt.message:String(dt);return Mh(v,z,[pe],yt),Nh(v)}if(X)for(let dt of new Set([...Object.keys(k),...X.reactiveProps??[]])){let yt=dt.toLowerCase();if(yt.startsWith("aria-")||yt.startsWith("data-"))continue;let At=dt.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\b${At}\\b`).test(ve))X.declaredProps.add(dt);if(new RegExp(`\\$props\\s*(?:\\.\\s*${At}\\b|\\[\\s*['"]${At}['"]\\s*\\])`).test(ve)||new RegExp(`\\buseReactiveProp\\s*\\(\\s*['"]${At}['"]`).test(ve))X.consumedProps?.add(dt)}let De=new Set(["__originalFilePath","__importedComponents",Yo,"__stx_client_signal_names","__stx_client_declared_names","__stx_runtime_config","__stxServeContext","__stx_scope_seq"]),Me={};for(let[dt,yt]of Object.entries(T))if(!dt.startsWith("__")||De.has(dt))Me[dt]=yt;let je=K.length>0?{[ua]:[...K]}:{},Le=C;if(C.includes("@include")){let{processIncludes:dt}=await Et("stx/includes",()=>import("./chunk-z0gfb7b4.js"));Le=await dt(C,T,z,F,H)}if(/<[A-Z][\w.-]*[\s/>]/.test(Le)){let{processComponents:dt}=await Et("stx/component-renderer",()=>import("./chunk-dcwmcqbr.js"));Le=await dt(Le,{...T,__processedComponents:ce,...je},z,F,H)}let Be=[];if(Di(Le)){let{processExpressions:dt}=await Et("stx/expressions",()=>import("./chunk-ev479f3z.js")),yt=T.__stx_signals_gate===void 0?{...T,__stx_signals_gate:!0,...je}:K.length>0?{...T,...je}:T;Le=dt(Le,yt,z);for(let At of Le.matchAll(/\{\{([\s\S]*?)\}\}/g))Be.push(At[1].trim())}let Oe=yn(Le),We=[],Fe=Oe.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(dt,yt)=>{let At=Oe.scripts[Number(yt)]||"",lt=At.match(/^<script\b([^>]*)>/i)?.[1]||"",Jt=lt.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),en=!Jt||["module","text/javascript","application/javascript"].includes(Jt),Rr=/\sdata-stx-(?:owner|instance)(?=[\s=/>])/i.test(` ${lt}`);if(!/\bserver\b/i.test(lt)&&en&&!Rr)return We.push(At),"";return At}),{extractSlotContent:Ve}=await Et("stx/slots",()=>import("./chunk-kdnbxwkb.js")),ze=Ve(Fe),He={};if(ze.defaultSlot?.trim())He.default=ze.defaultSlot;for(let[dt,yt]of ze.namedSlots)He[dt]=yt.content;let wt=T.__stx_scope_seq??={n:0,key:Bun.hash(String(T.__filename??z)).toString(36).slice(0,6)},Ct=`stx_${(v.endsWith(".stx")?v.slice(0,-4):v).replace(/[^a-zA-Z0-9]/g,"_")}_${++wt.n}_${wt.key}`,pt={...Me,$uid:Ct,...k,props:k,slot:Fe,$slots:He,__processedComponents:ee,__sections:{},__stx_signals_gate:Ce(ve)||Di(C),__stx_preserved_client_expressions:[...Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[],...Be]};C0(ve,pt);let St=ve,Rt=oe(St);if(Rt)St=Rt.content.trim();let xt=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,ft=[...ve.matchAll(xt)];for(let[,dt,yt]of ft)if(!/\bserver\b|\bsrc\s*=|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(dt))Qe(yt,pe,F.strict);let _t=[],bt=null,Xt=ft.some((dt)=>/\bserver\b/.test(dt[1]||"")&&/\bcache\b/.test(dt[1]||"")),Un=null,Bn=null,$t=null,mt=0,kt=null;if(v0(F),Xt&&Wu>0){let dt=w0({props:k,slot:Le,slotContext:C.trim()?S0(Me):void 0,buildMode:F.buildMode??"",skipEventDirectives:F.skipEventDirectives===!0,clientLoopNames:[...K].sort(),layers:F._layerGraph?.layers.map((yt)=>yt.configFile),uid:Ct});if(dt!==null){Un=`${pe}\x00${h(ve)}\x00${dt}`;let yt=tc.get(Un);if(yt){for(let At of yt.dependencies)H.add(At);if(Md(T,yt.clientFactories),wt.n+=yt.uidsConsumed,yt.preservedClientExpressions.length>0){let At=new Set(Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[]);for(let lt of yt.preservedClientExpressions)At.add(lt);T.__stx_preserved_client_expressions=[...At]}return yt.output}Bn=new Set(H),$t=Dd(T),mt=wt.n,kt=new Set(Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[])}}let Wt=new Set;for(let dt of ft){let yt=dt[1]||"",At=dt[2]||"",lt=yt.includes("server");if(nt(yt)&&At.trim())At=rt(At);if(lt&&At){for(let en of me(At))Wt.add(en);try{await te(At,pt,pe,{onFailure:(en)=>{if(en.kind!=="unknown")bt=en.kind}})}catch(en){}}if(!lt){let en=At.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),Rr=en.includes("{{")&&en.includes("}}"),is=en.includes("{!!")&&en.includes("!!}");if(Rr||is)en=xs(en,pt,pe);let Ar=yt.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");_t.push(`<script${Ar}>${en}</script>`)}}let nn=yn(ve).output.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),pn=nn?nn[1]:"",nc=nn?nn[2]:"",Yn="",rc=pn&&/\bscoped\b/i.test(pn);if(nn)Yn=`<style${pn}>${A0(nc,pt,pe)}</style>`;let Ue=St;if(Ue=Ue.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),nn)Ue=Ue.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let dt=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,yt=[];if(Ue=Ue.replace(dt,(At,lt)=>{let Jt=lt.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(Jt)yt.push(`<style${Jt[1]}>${Jt[2]}</style>`);return""}),Ue=Ue.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),yt.length>0)Yn=`${Yn}${yt.join(`
|
|
2662
|
+
`)}`}if(C&&Ue.includes("{{ text || slot }}"))Ue=Ue.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>C);let{applySlots:at}=await Et("stx/slots",()=>import("./chunk-kdnbxwkb.js")),{defaultSlot:ht,namedSlots:Tt}=ze,Kt=_t.some((dt)=>/\b(?:state|derived|effect|ref|useRef|reactive|computed|watch|watchEffect|useModel|useReactiveProp|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(dt)),an=(dt)=>Kt?sh(dt,Ct):dt,rs=new Map([...Tt].map(([dt,yt])=>[dt,{...yt,content:an(yt.content)}]));Ue=await at(Ue,an(ht),rs,pt);let sc=zs(_t),Oo=(Array.isArray(pt.__stx_client_signal_names)?pt.__stx_client_signal_names:[]).filter((dt)=>!Wt.has(dt));if(sc.length>0||Oo.length>0)pt.__stx_client_signal_names=[...new Set([...Oo,...sc])];else delete pt.__stx_client_signal_names;let Mo=K.filter((dt)=>!Wt.has(dt)&&!(dt in k));if(Mo.length>0)pt[ua]=Mo;let No={...F,_rootComponentsDir:F._rootComponentsDir||F.componentsDir,componentsDir:gt.dirname(pe),skipSignalsRuntime:!0,skipEventDirectives:F._nativeHostAttrs===!0||Kt||_t.length===0,defaultLayout:void 0};pt.__stxProcessingDepth=(T.__stxProcessingDepth||0)+1;let kr=await n(Ue,pt,pe,No,H),ss=new Set(Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[]);for(let dt of kr.matchAll(/\{\{([\s\S]*?)\}\}/g))ss.add(dt[1].trim());if(ss.size>0)T.__stx_preserved_client_expressions=[...ss];let Qn=Ct,dn=kr;if(Kt){let dt="";if(Object.keys(k).length>0)try{dt=` data-stx-props="${ju(JSON.stringify(k))}"`}catch{}let yt=ue?` stx-hydrate="${ju(ue)}"`:"",At=Object.fromEntries(Object.entries(He).map(([Ar,os])=>[Ar,Boolean(os)])),lt=Object.keys(At).length>0?` data-stx-slots="${ju(JSON.stringify(At))}"`:"",Jt=` data-stx-scope="${Qn}"${dt}${lt}${yt}`,en=/^\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*<span(?=[\s/>])/i.test(kr),Rr=en?"span":"div";dn=tl(kr,Jt)??`<${Rr}${Jt} data-stx-component-wrapper${en?' style="display:contents"':""}>${kr}</${Rr}>`;let is=await Promise.all(_t.map(async(Ar)=>{let os=Ar.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!os)return Ar;let[,jo,Lo]=os,zn=await P0(Lo,pe,F.buildMode==="compile"),Bo=vn(zn.clientCode,ke(pt)),{vendorStyleTags:er}=zn,li=Bo?`function(__scopeId) {
|
|
2663
|
+
${Bo}
|
|
2664
|
+
return (${zn.factoryBody})(__scopeId);
|
|
2665
|
+
}`:zn.factoryBody,Bi=ue?null:mc(T,li),as=Bi?`window.__stxComponentFactories[${JSON.stringify(Bi)}](${JSON.stringify(Qn)});`:`(${li})(${JSON.stringify(Qn)});`;if(ue)return`${er}<script type="stx/island" data-stx-island="${Qn}" data-stx-scoped data-stx-owner="${Qn}"${jo}>${as}</script>`;return`${er}<script data-stx-scoped data-stx-run="always" data-stx-owner="${Qn}"${jo}>${as}</script>`}));if(dn=dn+`
|
|
2666
|
+
`+is.join(`
|
|
2667
|
+
`),Yn)dn+=`
|
|
2668
|
+
`+Yn}else{if(Yn)dn+=`
|
|
2669
|
+
`+Yn;if(_t.length>0){let dt=pt.__stx_event_bindings||[],yt=ke(pt),At=await Promise.all(_t.map(async(lt)=>{let Jt=lt.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!Jt)return lt;return await _e(Jt[1],{eventBindings:dt,templateContent:dn,filePath:pe,projectRoot:process.cwd(),serverData:yt,instanceId:Ct})}));dn+=`
|
|
2670
|
+
`+At.join(`
|
|
2671
|
+
`),pt.__stx_event_bindings=[]}}if(rc){let dt=ha(dn,pe);if(dt.hasScoped)dn=dt.html}if(Un&&Bn){let dt=Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[];tc.set(Un,{output:dn,dependencies:[...H].filter((yt)=>!Bn.has(yt)),clientFactories:$t?Od(T,$t):[],uidsConsumed:wt.n-mt,preservedClientExpressions:kt?dt.filter((yt)=>!kt.has(yt)):[]})}if(bt)dn=`<!--stx-render-failed:${bt}-->${dn}`;return We.length>0?`${dn}
|
|
2672
|
+
${We.join(`
|
|
2673
|
+
`)}`:dn}catch(de){if(de instanceof q)throw de;return`[Error processing component: ${de instanceof Error?de.message:String(de)}]`}finally{ce.delete(v)}}async function r(v){return Bun.file(v).exists()}function Fu(v,k){let C=gt.resolve(k),R=gt.resolve(v),T=C.endsWith(gt.sep)?C:C+gt.sep;if(R===C||R.startsWith(T))return R;return null}async function T0(v,k,C,R){let T=k.startsWith("layouts/")?k.slice(8):k,z=gt.join(v,T);for(let F of z.endsWith(".stx")?[z]:[z,`${z}.stx`])if(await r(F)){if(R)console.log(`Found layout in ${v}: ${F}`);return C?.add(F),F}return null}async function mr(v,k,C,R){let T=await I0(v,k,C,R);if(T===null)return null;let z=Fu(T,process.cwd());if(z)return z;let F=[C.root,C.layoutsDir,C.fallbackLayoutsDir,C.componentsDir,C.partialsDir,C.pagesDir,...C._layerLayoutDirs??[]].filter((V)=>typeof V==="string"&&V.length>0);for(let V of F){let H=gt.isAbsolute(V)?V:gt.resolve(process.cwd(),V);if(Fu(T,H))return gt.resolve(T)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${T} (template: ${v}, from: ${k})`),null}async function I0(v,k,C,R){if(C.debug)console.log(`Resolving template path: ${v} from ${k}`);let T=gt.dirname(k),z=process.cwd();if(v.startsWith("/")){let te=gt.join(z,v),ce=Fu(te,z);if(!ce)return console.warn(`[stx] rejected template path that escapes project root: ${v} (from ${k})`),null;if(C.debug)console.log(`Checking absolute path: ${ce}`);if(await r(ce)&&R)R.add(ce);return ce}let F=gt.join(T,v);if(await r(F)){if(C.debug)console.log(`Found direct path: ${F}`);if(R)R.add(F);return F}if(!v.endsWith(".stx")&&!v.endsWith(".jsx")&&!v.endsWith(".tsx"))for(let te of[".stx",".tsx",".jsx"]){let ce=`${F}${te}`;if(await r(ce)){if(C.debug)console.log(`Found direct path with extension: ${ce}`);if(R)R.add(ce);return ce}}let V=[];if(V.push(...C._layerLayoutDirs??[]),C.layoutsDir)V.push(gt.isAbsolute(C.layoutsDir)?C.layoutsDir:gt.resolve(process.cwd(),C.layoutsDir));let H=gt.resolve(T),K=process.cwd();for(let te=0;te<10;te++){let ce=gt.join(H,"layouts"),ee=!1;try{ee=jh.statSync(ce,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(ee){V.push(ce);break}let le=gt.dirname(H);if(le===H||le.length<K.length)break;H=le}for(let te of V){let ce=await T0(te,v,R,C.debug);if(ce)return ce}if(C.fallbackLayoutsDir){let te=gt.isAbsolute(C.fallbackLayoutsDir)?C.fallbackLayoutsDir:gt.resolve(process.cwd(),C.fallbackLayoutsDir),ce=v.startsWith("layouts/")?v.slice(8):v,ee=[gt.join(te,ce)];if(!v.endsWith(".stx"))ee.push(`${ee[0]}.stx`);for(let le of ee)if(await r(le)){if(C.debug)console.log(`Found in options.fallbackLayoutsDir: ${le}`);if(R)R.add(le);return le}}if(v.startsWith("layouts/")||v.includes("/layouts/")){let te=v.split("layouts/"),ce=gt.join(C.partialsDir||T,"layouts",te[1]);if(await r(ce)){if(C.debug)console.log(`Found in layouts path: ${ce}`);if(R)R.add(ce);return ce}if(!ce.endsWith(".stx")){let ee=`${ce}.stx`;if(await r(ee)){if(C.debug)console.log(`Found in layouts path with extension: ${ee}`);if(R)R.add(ee);return ee}}}if(C.partialsDir){let te=gt.join(C.partialsDir,"layouts");if(await r(te)){let ce=gt.join(te,v);if(await r(ce)){if(C.debug)console.log(`Found in partials layouts dir: ${ce}`);if(R)R.add(ce);return ce}if(!v.endsWith(".stx")){let ee=`${ce}.stx`;if(await r(ee)){if(C.debug)console.log(`Found in partials layouts dir with extension: ${ee}`);if(R)R.add(ee);return ee}}}}let X=C.partialsDir||gt.join(process.cwd(),"views"),G=gt.join(X,v);if(await r(G)){if(C.debug)console.log(`Found in views path: ${G}`);if(R)R.add(G);return G}if(!v.endsWith(".stx")){let te=`${G}.stx`;if(await r(te)){if(C.debug)console.log(`Found in views path with extension: ${te}`);if(R)R.add(te);return te}}if(T.includes("temp")){let te=gt.join(gt.dirname(T),"layouts",v);if(await r(te)){if(C.debug)console.log(`Found in temp layouts dir: ${te}`);if(R)R.add(te);return te}if(!v.endsWith(".stx")){let ce=`${te}.stx`;if(await r(ce)){if(C.debug)console.log(`Found in temp layouts dir with extension: ${ce}`);if(R)R.add(ce);return ce}}}if(C.debug)console.warn(`Template not found after trying all paths: ${v} (referenced from ${k})`);else console.warn(`Template not found: ${v} (referenced from ${k})`);return null}function Mi(v,k,C){let R=0,T="",z="";try{if(typeof k==="number"&&k>=0){let F=v.split(`
|
|
2674
|
+
`),V=0;for(let H=0;H<F.length;H++)if(V+=F[H].length+1,V>=k){R=H+1,T=F[H].trim();let K=Math.max(0,H-2),X=Math.min(F.length,H+3);z=F.slice(K,X).map((G,te)=>{let ce=K+te+1;return`${ce===R?"> ":" "}${ce}: ${G}`}).join(`
|
|
2675
|
+
`);break}}else if(C){let F=v.indexOf(C);if(F>=0)return Mi(v,F)}}catch{}return{lineNumber:R,lineContent:T,context:z}}var It={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"};function g(v,k,C,R,T,z){let{lineNumber:F,context:V}=Mi(R,T,z),H=C.split("/").pop(),K=0;if(typeof T==="number"&&T>=0&&R){let G=R.lastIndexOf(`
|
|
2676
|
+
`,Math.max(0,T-1));K=T-(G+1)+1}let X="";if(F>0)X+=`
|
|
2677
|
+
${C}:${F}${K>0?`:${K}`:""}: ${v.toLowerCase()} error: ${k}
|
|
2678
|
+
`;if(X+=`
|
|
2679
|
+
${It.bold}${It.red}\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E${It.reset}
|
|
2680
|
+
`,X+=`${It.bold}${It.red}\u2502${It.reset} ${It.bold}${It.bgRed} ERROR ${It.reset} ${It.red}${v} Error${It.reset}${" ".repeat(Math.max(0,43-v.length))}${It.bold}${It.red}\u2502${It.reset}
|
|
2681
|
+
`,X+=`${It.bold}${It.red}\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F${It.reset}
|
|
2682
|
+
`,X+=`
|
|
2683
|
+
${It.cyan}${It.bold}File:${It.reset} ${It.dim}${H}${It.reset}`,F>0)X+=` ${It.gray}(line ${F}${K>0?`, col ${K}`:""})${It.reset}`;if(X+=`
|
|
2684
|
+
${It.yellow}${It.bold}Message:${It.reset} ${k}
|
|
2685
|
+
`,V)X+=`
|
|
2686
|
+
${It.blue}${It.bold}Context:${It.reset}
|
|
2687
|
+
${It.dim}${V}${It.reset}
|
|
2688
|
+
`;return X}function ie(){Po.clear(),ec.clear(),Bu.clear(),zu.clear(),tc.clear()}function vd(){return{size:Po.size,maxSize:500}}var Lu=m(128);async function P0(v,k,C){let R=h(v,k,C),T=Lu.get(R);if(T){if(or(T.deps))return T;Lu.delete(R)}let z=ys(v,{filePath:k,projectRoot:process.cwd()}),F=z.code,V=bs(z.styles);F=Nt(F).code;let{hasUserImports:H,bundleClientScript:K}=await Et("stx/client-script-bundler",()=>import("./chunk-kt5mzw2w.js")),X=[],G=!1;if(H(F)){let fe=F;F=await K(fe,k,{projectRoot:process.cwd(),minify:C,collectInputs:X}),G=F===fe}let{stripStxRuntimeImports:te}=await Et("stx/signal-processing",()=>import("./chunk-6per0k6j.js"));F=te(F);let ce=I(F),ee=_0(ce),le=new Set(M(ce,!0).split(",").map((fe)=>fe.trim())),ue=`function(__scopeId) {
|
|
2689
|
+
${qt("const",[...ea,...ee],ce)}
|
|
2690
|
+
const __scope = window.stx._scopes = window.stx._scopes || {};
|
|
2691
|
+
const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
|
|
2692
|
+
__scopeVars.$refs = __scopeVars.$refs || {};
|
|
2693
|
+
const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
|
|
2694
|
+
const __previousCurrentProps = window.__STX_CURRENT_PROPS__;
|
|
2695
|
+
// A clone the runtime is setting up may not be in the document yet (rows
|
|
2696
|
+
// a loop builds inside a closed :if), where a lookup cannot see it, so the
|
|
2697
|
+
// runtime hands its root over in __STX_SETUP_ROOT__ (signals.ts).
|
|
2698
|
+
const __setupRoot = window.__STX_SETUP_ROOT__;
|
|
2699
|
+
const __componentElement = (__setupRoot && __setupRoot.getAttribute('data-stx-scope') === __scopeId && __setupRoot) || document.querySelector('[data-stx-scope="' + __scopeId + '"]');
|
|
2700
|
+
__scopeVars.$slots = Object.create(null);
|
|
2701
|
+
if (__componentElement) {
|
|
2702
|
+
try { Object.assign(__scopeVars.$slots, JSON.parse(__componentElement.getAttribute('data-stx-slots') || '{}')); }
|
|
2703
|
+
catch {}
|
|
2704
|
+
}
|
|
2705
|
+
window.__STX_CURRENT_ELEMENT__ = __componentElement;
|
|
2706
|
+
let __componentProps = __componentElement && __componentElement.__stx_props;
|
|
2707
|
+
if (!__componentProps && __componentElement) {
|
|
2708
|
+
try { __componentProps = JSON.parse(__componentElement.getAttribute('data-stx-props') || '{}'); }
|
|
2709
|
+
catch { __componentProps = {}; }
|
|
2710
|
+
}
|
|
2711
|
+
window.__STX_CURRENT_PROPS__ = __componentProps && typeof __componentProps === 'object' && !Array.isArray(__componentProps) ? __componentProps : {};
|
|
2712
|
+
|
|
2713
|
+
// Scope-specific lifecycle callbacks. The queues drain as they run; the
|
|
2714
|
+
// hook lists keep what setup registered, because a component behind an :if
|
|
2715
|
+
// unmounts at each hide and mounts again at each show (signals.ts,
|
|
2716
|
+
// suspendSubtreeScopes).
|
|
2717
|
+
if (__scopeVars.__suspended && !__scopeVars.__mounted) {
|
|
2718
|
+
// Set up again after an :if hid it -- a <template :if> clones the
|
|
2719
|
+
// component afresh on every show, and the clone's script runs. This run's
|
|
2720
|
+
// hooks close over this run's state, so they replace the ones the hide
|
|
2721
|
+
// kept for a re-show rather than queueing beside them.
|
|
2722
|
+
__scopeVars.__mountCallbacks = [];
|
|
2723
|
+
__scopeVars.__destroyCallbacks = [];
|
|
2724
|
+
__scopeVars.__mountHooks = [];
|
|
2725
|
+
__scopeVars.__destroyHooks = [];
|
|
2726
|
+
}
|
|
2727
|
+
__scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
|
|
2728
|
+
__scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
|
|
2729
|
+
__scopeVars.__mountHooks = __scopeVars.__mountHooks || [];
|
|
2730
|
+
__scopeVars.__destroyHooks = __scopeVars.__destroyHooks || [];
|
|
2731
|
+
let __registeringSetupHooks = true;
|
|
2732
|
+
const onMount = (fn) => { __scopeVars.__mountCallbacks.push(fn); __scopeVars.__mountHooks.push(fn); };
|
|
2733
|
+
const onDestroy = (fn) => {
|
|
2734
|
+
__scopeVars.__destroyCallbacks.push(fn);
|
|
2735
|
+
// A teardown registered inside onMount belongs to this mount alone.
|
|
2736
|
+
// Replaying it AND registering the next mount's teardown doubles cleanup.
|
|
2737
|
+
if (__registeringSetupHooks) __scopeVars.__destroyHooks.push(fn);
|
|
2738
|
+
};
|
|
2739
|
+
|
|
2740
|
+
try {
|
|
2741
|
+
${ce}
|
|
2742
|
+
|
|
2743
|
+
// Register all defined signals and functions in this scope
|
|
2744
|
+
const __localVars = {};
|
|
2745
|
+
try {
|
|
2746
|
+
${ee.map((fe)=>le.has(fe)?`Object.defineProperty(__localVars, '${fe}', ${Uo(fe)});`:`if (typeof ${fe} !== 'undefined') __localVars['${fe}'] = ${fe};`).join(`
|
|
2747
|
+
`)}
|
|
2748
|
+
}
|
|
2749
|
+
catch (e) {}
|
|
2750
|
+
Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__localVars));
|
|
2751
|
+
if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__stxLiveBindings));
|
|
2752
|
+
}
|
|
2753
|
+
finally {
|
|
2754
|
+
__registeringSetupHooks = false;
|
|
2755
|
+
window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
|
|
2756
|
+
window.__STX_CURRENT_PROPS__ = __previousCurrentProps;
|
|
2757
|
+
}
|
|
2758
|
+
}`,de={vendorStyleTags:V,factoryBody:ue,clientCode:ce,deps:bn([...X,...z.styles.map((fe)=>fe.resolvedPath)])};if(!G&&z.unresolved.length===0)Lu.set(R,de);return de}var D0=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;function O0(v){if(v.startsWith(".")||v.startsWith("/"))return null;if(v.startsWith("@")){let C=v.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!C)return null;return{pkg:C[1],subpath:C[2]||""}}let k=v.match(/^([^/]+)(\/.*)?$/);if(!k)return null;return{pkg:k[1],subpath:k[2]||""}}function M0(v,k){let C=k;while(!0){let R=ns.join(C,"node_modules",v,"package.json");if(Do.existsSync(R))return ns.dirname(R);let T=ns.dirname(C);if(T===C)return null;C=T}}function N0(v,k){if(!v||typeof v!=="object")return null;let C=(T)=>{if(typeof T==="string")return T;if(T&&typeof T==="object"){if(typeof T.import==="string")return T.import;if(typeof T.default==="string")return T.default;if(typeof T.import==="object")return C(T.import);if(typeof T.default==="object")return C(T.default)}return null};if(Object.prototype.hasOwnProperty.call(v,k))return C(v[k]);let R=null;for(let T of Object.keys(v)){let z=T.indexOf("*");if(z===-1)continue;let F=T.slice(0,z),V=T.slice(z+1);if(!k.startsWith(F)||!k.endsWith(V))continue;if(k.length<F.length+V.length)continue;if(!R||F.length>R.prefix.length)R={pattern:T,prefix:F,suffix:V}}if(R){let T=k.slice(R.prefix.length,k.length-R.suffix.length),z=C(v[R.pattern]);if(z)return z.replace("*",T)}return null}function j0(v,k){let C=O0(v);if(!C||!C.subpath)return null;let R=M0(C.pkg,k);if(!R)return null;let T;try{T=JSON.parse(Do.readFileSync(ns.join(R,"package.json"),"utf8"))}catch{return null}let z=`.${C.subpath}`,F=N0(T.exports,z);if(!F)return null;let V=ns.resolve(R,F);return Do.existsSync(V)?V:null}function ys(v,k){let C=k.filePath?ns.dirname(k.filePath):k.projectRoot||process.cwd(),R=k.projectRoot||process.cwd(),T=new Set,z=[],F=[];return{code:v.replace(D0,(H,K)=>{let X;try{if(K.startsWith("./")||K.startsWith("../")||K.startsWith("/")){if(X=K.startsWith("/")?K:ns.resolve(C,K),!Do.existsSync(X))throw Error(`file not found: ${X}`)}else{let G=null;try{G=Bun.resolveSync(K,R)}catch{G=j0(K,R)}if(!G)throw Error(`could not resolve ${K} (Bun.resolveSync + exports fallback both failed)`);X=G}}catch(G){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(K)} (from ${k.filePath||"<unknown>"}): ${G?.message||G}`),F.push(K),""}if(T.has(X))return"";T.add(X);try{let G=Do.readFileSync(X,"utf8");z.push({source:K,resolvedPath:X,contents:G})}catch(G){console.warn(`[stx:vendor-css] could not read ${X}: ${G?.message||G}`),F.push(K)}return""}),styles:z,unresolved:F}}function L0(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function bs(v){if(v.length===0)return"";return`${v.map((k)=>`<style data-stx-vendor="${L0(k.source)}" data-stx-layer="vendor">
|
|
2759
|
+
@layer vendor {
|
|
2760
|
+
${k.contents}
|
|
2761
|
+
}
|
|
2762
|
+
</style>`).join(`
|
|
2763
|
+
`)}
|
|
2764
|
+
`}var Sc=y,Bh=m(256);function Nt(v){let k=h(v),C=Bh.get(k);if(!C)C=B0(v),Bh.set(k,C);return{code:C.code,imports:[...C.imports],models:[...C.models]}}function B0(v){let k=s(v),C=new Set;for(let V of v.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let H of V[1].split(",")){let K=H.trim().split(/\s+as\s+/).pop()?.replace(/^type\s+/,"").trim();if(K)C.add(K)}let R=Ko(k),T=Y.filter((V)=>{if(C.has(V)||R.has(V))return!1;return vs(k,V,!0)}),z=Vh(k).filter((V)=>!C.has(V)&&!R.has(V));if(T.length===0&&z.length===0)return{code:v,imports:T,models:z};return{code:`${[T.length>0?`import { ${T.join(", ")} } from '@stacksjs/browser'`:"",z.length>0?"import '@stacksjs/browser'":"",z.length>0?`const { ${z.join(", ")} } = window.StacksBrowser || {}`:""].filter(Boolean).join(`
|
|
2765
|
+
`)}
|
|
2766
|
+
${v}`,imports:T,models:z}}var z0=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);function Vh(v){let k=new Set,C=fc(v),R=Ko(v),T=/(?<![\w$.])([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g;for(let z of C.code.matchAll(T)){let F=z[1];if(z0.has(F)||R.has(F)||F.length<3)continue;if(C.shadows(F,z.index??0))continue;k.add(F)}return Array.from(k)}function W0(v){return Ko(v)}var zh=m(128);function ui(v){let k=h(v),C=zh.get(k);if(!C)C=F0(v),zh.set(k,C);return{code:C.code,stxImports:[...C.stxImports],browserImports:[...C.browserImports]}}function F0(v){let k=new Set,C=new Set,R=v;R=R.replace(/^[ \t]*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"][ \t]*;?[ \t]*$/gm,"// [type import stripped]");let T=new Set,z=/^[ \t]*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|@stacksjs\/stx|stx)['"][ \t]*;?[ \t]*$/gm,F;while((F=z.exec(v))!==null){let G=F[1],te=F[2];if(F[0].includes("import type"))continue;let ce=[];for(let le of G.split(",")){let ue=le.trim();if(!ue||ue.startsWith("type "))continue;let de=ue.match(/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);if(!de)continue;let fe=de[1],pe=de[2]||fe;if(T.add(fe),T.add(pe),te==="stx"||te==="@stacksjs/stx")k.add(fe);else C.add(fe);if(pe!==fe)ce.push(`${pe} = ${fe}`)}let ee=ce.length>0?`var ${ce.join(", ")}; /* [auto-import processed] */`:"// [auto-import processed]";R=R.replace(F[0],ee)}let V=W0(R);for(let G of Sc){if(T.has(G)||V.has(G))continue;if(vs(R,G,!0))k.add(G)}let H=s(R),K=new Set;for(let G of R.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let te of G[1].split(",")){let ce=te.trim().replace(/^type\s+/,"").split(/\s+as\s+/);for(let ee of ce){let le=ee.trim();if(le)K.add(le)}}for(let G of Y){if(T.has(G)||V.has(G)||K.has(G))continue;if(vs(H,G))C.add(G)}let X=Vh(H);for(let G of X)if(!T.has(G)&&!V.has(G))C.add(G);return{code:R,stxImports:Array.from(k),browserImports:Array.from(C)}}function vs(v,k,C=!1){let R=fc(v);v=R.code;let T=new RegExp(`\\b${k.replace(/[$]/g,"\\$")}\\b`,"g");for(let z of v.matchAll(T)){let F=z.index??0;if(R.shadows(k,F))continue;let V=F+k.length,H=F-1;while(H>=0&&/\s/.test(v[H]))H--;if(v[H]==="."&&v.slice(Math.max(0,H-2),H+1)!=="...")continue;let K=V;while(K<v.length&&/\s/.test(v[K]))K++;if(v[K]===":"&&v[K+1]!==":"&&(v[H]==="{"||v[H]===","))continue;if(C&&!/^\s*(?:<[^>]*>)?\s*\(/.test(v.slice(V)))continue;if(V0(v,V))continue;return!0}return!1}function V0(v,k){let C=k;while(C<v.length&&(v[C]===" "||v[C]==="\t"))C++;if(v[C]!=="(")return!1;let R=0;for(;C<v.length;C++){let T=v[C];if(T==="(")R++;else if(T===")"){if(R--,R===0)break}}if(R!==0)return!1;C++;while(C<v.length&&(v[C]===" "||v[C]==="\t"))C++;return v[C]==="{"}function di(v,k){let C=[];if(v.length>0)C.push(` var { ${v.join(", ")} } = window.stx || window;`);if(k.length>0)C.push(` var { ${k.join(", ")} } = window.StacksBrowser || {};`);if(C.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
|
|
2767
|
+
${C.join(`
|
|
2768
|
+
`)}
|
|
2769
|
+
${U0(v,k)}`;return""}function Yu(v,k=[]){let{browserImports:C}=ui(v),R=new Set(k);return di([],C.filter((T)=>!R.has(T)))}function U0(v,k){let C=[...v.map((R)=>`['${R}', typeof ${R}, 'stx']`),...k.map((R)=>`['${R}', typeof ${R}, '@stacksjs/browser']`)];if(C.length===0)return"";return` // STX: report auto-imports the client runtime did not provide
|
|
2770
|
+
[${C.join(", ")}].forEach(function (e) {
|
|
2771
|
+
if (e[1] !== 'undefined') return;
|
|
2772
|
+
console.error(
|
|
2773
|
+
'[stx] "' + e[0] + '" is used in this client script and auto-imported from ' + e[2] + ', '
|
|
2774
|
+
+ 'but the client runtime does not provide it. Either it is not exported to the browser, '
|
|
2775
|
+
+ 'or it should be imported from a relative path so the bundler includes it.'
|
|
2776
|
+
);
|
|
2777
|
+
});
|
|
2778
|
+
`}function ke(v){let k=v.__stxClientPayload;if(k&&typeof k==="object"){let R={};for(let T in k){let z=k[T];if(typeof z==="function")continue;R[T]=z}return R.__stxDeclaredPayload=!0,R}let C={};for(let R in v){if(R.startsWith("__")||R.startsWith("$"))continue;let T=v[R];if(typeof T==="function")continue;C[R]=T}return C}var H0=/token|secret|passw|apikey|api_key|privatekey|private_key|credential|webhook|bearer|jwt|signature/i,Wh=new Set;function q0(v,k){let C=H0.test(v),R=k.length>32768;if(!C&&!R)return;if(Wh.has(v))return;if(Wh.add(v),C)console.warn(`[stx] server\u2192client bridge is publishing "${v}" into the page body. If it holds a credential, rename it with a "__" prefix (never bridged) and pass only what the template needs. See stacksjs/stx#1831.`);if(R)console.warn(`[stx] server\u2192client bridge is publishing ${(k.length/1024).toFixed(1)}KB under "${v}". Every byte ships in the HTML on each request; prefix the binding with "__" and project just the fields the client reads.`)}function vn(v,k){if(!k)return"";let C=Ot(v,new Set(Object.keys(k))),R=k.__stxDeclaredPayload===!0,T=[],z=Object.entries(k).sort(([F],[V])=>F<V?-1:F>V?1:0);for(let[F,V]of z){if(!/^[A-Za-z_$][\w$]*$/.test(F))continue;if(F.startsWith("__")||F.startsWith("$"))continue;if(!R&&!C.has(F))continue;if(Wi(v,F)){if(R)console.warn(`[stx] defineClientPayload declares "${F}", but this client block also declares "${F}" at the top level, so the server value is not published (emitting it would be a duplicate binding). Rename the local, or drop "${F}" from defineClientPayload.`);continue}let H;try{H=JSON.stringify(V)}catch{continue}if(H===void 0)continue;q0(F,H),T.push(` var ${F} = ${H.replace(/</g,"\\u003c")};`)}if(T.length===0)return"";return` // stx: server -> client data bridge (seeded from server scope)
|
|
2779
|
+
${T.join(`
|
|
2780
|
+
`)}
|
|
2781
|
+
`}var K0={left:0,middle:1,right:2};function X0(v){let k=[];if(v.self)k.push("if ($event.target !== $el) return");for(let C of v.systemKeys)k.push(`if (!$event.${C}Key) return`);if(v.keys.length>0){let C=v.keys.map((R)=>`$event.key === '${R}'`).join(" || ");k.push(`if (!(${C})) return`)}if(v.mouse!==null){let C=K0[v.mouse];k.push(`if ($event.button !== ${C}) return`)}if(v.prevent)k.push("$event.preventDefault()");if(v.stop)k.push("$event.stopPropagation()");return k.join("; ")}function Z0(v,k){let{elementId:C,event:R,modifiers:T}=v,z=lc(v.handler),F=X0(T),V=[];if(T.once)V.push("once: true");if(T.capture)V.push("capture: true");if(cc(R,T))V.push("passive: true");let H=V.length>0?`, { ${V.join(", ")} }`:"",K="";if(F)K+=`${F}; `;let X=z.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),G=`var $emit = function(name, detail) {
|
|
2782
|
+
$el.dispatchEvent(new CustomEvent(name, { detail: detail, bubbles: true, cancelable: true }))
|
|
2783
|
+
};`;function te(ce){if(/\$emit\s*\(/.test(ce))return`${G}
|
|
2784
|
+
${ce}`;return`var scope = $el.closest('[data-stx-scope]');
|
|
2785
|
+
if (scope && scope.__stx_execute) {
|
|
2786
|
+
scope.__stx_execute('${X}', $event, $el);
|
|
2787
|
+
}
|
|
2788
|
+
else {
|
|
2789
|
+
${ce}
|
|
2790
|
+
}`}if(T.debounce!==null)return` ;(function() {
|
|
2791
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
2792
|
+
var $el = document.getElementById('${C}')
|
|
2793
|
+
if (!$el) return
|
|
2794
|
+
var __timer
|
|
2795
|
+
$el.addEventListener('${R}', function($event) {
|
|
2796
|
+
${F?F+"; ":""}clearTimeout(__timer)
|
|
2797
|
+
__timer = setTimeout(function() { ${te(z)} }, ${T.debounce})
|
|
2798
|
+
}${H})
|
|
2799
|
+
})()`;if(T.throttle!==null)return` ;(function() {
|
|
2800
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
2801
|
+
var $el = document.getElementById('${C}')
|
|
2802
|
+
if (!$el) return
|
|
2803
|
+
var __last = 0
|
|
2804
|
+
$el.addEventListener('${R}', function($event) {
|
|
2805
|
+
${F?F+"; ":""}var __now = Date.now()
|
|
2806
|
+
if (__now - __last >= ${T.throttle}) {
|
|
2807
|
+
__last = __now
|
|
2808
|
+
${te(z)}
|
|
2809
|
+
}
|
|
2810
|
+
}${H})
|
|
2811
|
+
})()`;if(/\$emit\s*\(/.test(z))return` var $el = document.getElementById('${C}')
|
|
2812
|
+
if ($el) $el.addEventListener('${R}', function($event) {
|
|
2813
|
+
${K}${G}
|
|
2814
|
+
${z}
|
|
2815
|
+
}${H})`;return` var $el = document.getElementById('${C}')
|
|
2816
|
+
if ($el) $el.addEventListener('${R}', function($event) {
|
|
2817
|
+
${K}var scope = $el.closest('[data-stx-scope]');
|
|
2818
|
+
if (scope && scope.__stx_execute) {
|
|
2819
|
+
scope.__stx_execute('${X}', $event, $el);
|
|
2820
|
+
}
|
|
2821
|
+
else {
|
|
2822
|
+
${z}
|
|
2823
|
+
}
|
|
2824
|
+
}${H})`}function G0(v){if(v.length===0)return"";return`
|
|
2825
|
+
// STX: auto-generated event bindings
|
|
2826
|
+
${v.map((C,R)=>Z0(C,R)).join(`
|
|
2827
|
+
`)}`}function Fh(v){let k=[],C=new Set,R=v.replace(/^\s*import\s+.*$/gm,""),T=0,z=R.length,F=0;while(F<z){let V=R[F];if(V==="'"||V==='"'||V==="`"){let H=V;if(F++,H==="`"){let K=0;while(F<z){if(R[F]==="\\"){F+=2;continue}if(R[F]==="`"&&K===0){F++;break}if(R[F]==="$"&&R[F+1]==="{"){K++,F+=2;continue}if(R[F]==="}"&&K>0){K--,F++;continue}F++}}else while(F<z){if(R[F]==="\\"){F+=2;continue}if(R[F]===H){F++;break}F++}continue}if(V==="/"&&R[F+1]==="/"){while(F<z&&R[F]!==`
|
|
2828
|
+
`)F++;continue}if(V==="/"&&R[F+1]==="*"){F+=2;while(F<z-1&&!(R[F]==="*"&&R[F+1]==="/"))F++;F+=2;continue}if(V==="{"){T++,F++;continue}if(V==="}"){T--,F++;continue}if(T===0){let H=R.slice(F),K=H.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(K){let te=K[1];if(!te.startsWith("_")&&!C.has(te))k.push(te),C.add(te);F+=K[0].length;continue}let X=H.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(X){X[1].split(",").forEach((te)=>{let ce=te.trim(),ee=ce.indexOf(":"),le=ee>=0?ce.slice(ee+1).trim().split(/[\s=]/)[0]:ce.split(/[\s=]/)[0];if(le&&!le.startsWith("_")&&!C.has(le))k.push(le),C.add(le)}),F+=X[0].length;continue}let G=H.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(G){let te=G[1];if(!te.startsWith("_")&&!C.has(te))k.push(te),C.add(te);F+=G[0].length;continue}}F++}return k}var J0=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"]);function Y0(v){let k=new Set,C=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function R(te){let ce;while((ce=C.exec(te))!==null){let ee=ce[0];if(!J0.has(ee))k.add(ee)}}let T=/\{\{([\s\S]*?)\}\}/g,z;while((z=T.exec(v))!==null)R(z[1]);let F=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((z=F.exec(v))!==null)R(z[1]);let V=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((z=V.exec(v))!==null)R(z[1]);let H=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((z=H.exec(v))!==null)R(z[1]);let K=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((z=K.exec(v))!==null)R(z[1]);let X=/@model\s*=\s*["']([^"']*)["']/gi;while((z=X.exec(v))!==null)R(z[1]);let G=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((z=G.exec(v))!==null)R(z[1]);return k}async function _e(v,k={}){let C=v,R="",T=!1,z=[],F=ys(C,{filePath:k.filePath,projectRoot:k.projectRoot});C=F.code;let V=bs(F.styles),H=Nt(C);C=H.code,z=[...H.imports,...H.models];let{hasUserImports:K,bundleClientScript:X}=await Et("stx/client-script-bundler",()=>import("./chunk-kt5mzw2w.js"));if(K(C))C=await X(C,k.filePath||"",{projectRoot:k.projectRoot,minify:k.production}),T=!0;if(k.autoImports!==!1){let pe=ui(C);C=pe.code,R=di(pe.stxImports,pe.browserImports.filter((Ae)=>!z.includes(Ae)))}if(R=`${vn(C,k.serverData)}${R}`,C=I(C),!T&&nt(k.attrs||""))C=rt(C);let G=G0(k.eventBindings||[]),te=(k.attrs||"").trim(),ce=/\btype\s*=\s*["']module["']/i.test(te),ee=k.instanceId?` data-stx-instance="${k.instanceId}"`:"";if(ce){let pe=te.replace(/\btype\s*=\s*["']module["']/i,"").trim(),Ae=`type="module" data-stx-scoped${ee}${pe?` ${pe}`:""}`;return`${V}<script ${Ae}>
|
|
2829
|
+
${oi(`${R}${C}
|
|
2830
|
+
${G}`)}
|
|
2831
|
+
</script>`}let le=so(v),ue=/function __stx_setup_/.test(C),de=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test(v);function fe(pe){let Ae=pe.length>0?`
|
|
2832
|
+
return ${Ho(C,pe)};`:"",Se=JSON.stringify(`[stx] client block failed${k.filePath?` (${k.filePath})`:""}; this block will not hydrate`);return`${V}<script data-stx-scoped data-stx-run="always"${ee}>
|
|
2833
|
+
window.stx.mount(function() {
|
|
2834
|
+
'use strict';
|
|
2835
|
+
try {
|
|
2836
|
+
${oi(`${R}${C}
|
|
2837
|
+
${G}${Ae}`)}
|
|
2838
|
+
} catch (error) {
|
|
2839
|
+
console.error(${Se}, error);
|
|
2840
|
+
return {};
|
|
2841
|
+
}
|
|
2842
|
+
})</script>`}if(!de&&!ue){if(le)return fe(Fh(v));if(k.templateContent){let pe=Fh(v);if(pe.length>0){let Ae=Y0(k.templateContent);if(pe.some((ve)=>Ae.has(ve)))return fe(pe)}}}return`${V}<script data-stx-scoped data-stx-run="always"${ee}>
|
|
2843
|
+
;(function() {
|
|
2844
|
+
'use strict';
|
|
2845
|
+
try {
|
|
2846
|
+
${oi(`${R}${C}
|
|
2847
|
+
${G}`)}
|
|
2848
|
+
} catch (error) {
|
|
2849
|
+
console.error(${JSON.stringify(`[stx] client block failed${k.filePath?` (${k.filePath})`:""}; this block will not hydrate`)}, error);
|
|
2850
|
+
}
|
|
2851
|
+
})()</script>`}
|
|
2852
|
+
export{sr,qe,M,Ot,L,J,m,h,bn,or,Y,w,Ge,ys,bs,Sc,Nt,ui,vs,di,Yu,ke,vn,_e,pi,fi,gi,ws,U,Ke,ne,Dt,re,ir,kc,Zu,_c,Qu,Cc,ar,b,Mt,Ce,Ec,xs,Tc,ed,Z,$c,td,x,nd,Rc,rd,sd,od,id,Ac,Pc,ad,cd,mi,ld,wn,xn,cr,Xe,Ee,se,Lt,ge,Sn,kn,Te,e,ud,hi,dd,yi,Ic,Oc,jt,_n,pd,Nc,Dc,fd,f,Je,Bt,Ye,Ze,bi,lr,Qe,oe,Ss,ks,_s,gd,ur,md,Cn,et,Cs,Es,Mc,me,vi,wi,xi,Si,dr,Ts,ki,_i,Ci,Lc,$s,j,he,Q,hd,jc,Rs,As,Ei,Ti,Ps,Is,pr,$i,Ri,Bc,tt,En,fr,Ft,Fc,zc,Hc,Vc,Uc,u,Wc,Os,qc,Ai,Pi,Ns,Ii,Gc,yd,Kc,$e,Oi,bd,Ds,Ms,Ls,Ni,js,Bs,Fs,n,Xc,Jc,Yc,Zc,Qc,el,nt,B,rt,tl,gr,nl,Di,zs,st,r,mr,Mi,g,ie,vd,hr,A,rl,Hs,o,P,wd,xd,ye};
|