@stacksjs/stx 0.2.195 → 0.2.197
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-0ae6chzd.js +4 -0
- package/dist/chunk-0w0mrtme.js +2 -0
- package/dist/chunk-0y46fbkx.js +3 -0
- package/dist/chunk-118a77bs.js +4471 -0
- package/dist/chunk-12nvcvtn.js +3 -0
- package/dist/chunk-14ynv5ah.js +2 -0
- package/dist/chunk-1e25ksp6.js +3 -0
- package/dist/chunk-1mhc4g86.js +43 -0
- package/dist/chunk-1thssz8x.js +2 -0
- package/dist/chunk-1yk07x7b.js +2 -0
- package/dist/chunk-2zkj69dg.js +13 -0
- package/dist/chunk-338316c2.js +2 -0
- package/dist/chunk-3952ykhb.js +1655 -0
- package/dist/chunk-3es366z4.js +3 -0
- package/dist/chunk-3m49eb4v.js +2 -0
- package/dist/chunk-3nmpfsw5.js +2 -0
- package/dist/chunk-3vy1q9da.js +2 -0
- package/dist/chunk-4a4h28pp.js +3022 -0
- package/dist/chunk-4pf61rcb.js +2 -0
- package/dist/chunk-5anpcnde.js +2 -0
- package/dist/chunk-5mkkre22.js +505 -0
- package/dist/chunk-5n0dt838.js +2 -0
- package/dist/chunk-5s2y052b.js +2 -0
- package/dist/chunk-5v64c8tr.js +2 -0
- package/dist/chunk-5xd7vge2.js +2 -0
- package/dist/chunk-6bxcjdp4.js +2 -0
- package/dist/chunk-6msvxnbr.js +2 -0
- package/dist/chunk-7kger0se.js +1280 -0
- package/dist/chunk-7ry55nms.js +3 -0
- package/dist/chunk-7s0wfa4e.js +24 -0
- package/dist/chunk-7w4c5w2b.js +2 -0
- package/dist/chunk-8src5smc.js +15 -0
- package/dist/chunk-937effkz.js +2 -0
- package/dist/chunk-9b82d4g5.js +3 -0
- package/dist/chunk-9xh78snm.js +3 -0
- package/dist/chunk-a2899x2t.js +2 -0
- package/dist/chunk-abpw3b39.js +2 -0
- package/dist/chunk-avwj12at.js +194 -0
- package/dist/chunk-b6jhznkh.js +71 -0
- package/dist/chunk-bpa2jeyw.js +3 -0
- package/dist/chunk-cbc56wpd.js +3 -0
- package/dist/chunk-dhpy0h9y.js +2 -0
- package/dist/chunk-dtmwr674.js +302 -0
- package/dist/chunk-dxfcyj8t.js +2 -0
- package/dist/chunk-e0460y7f.js +29 -0
- package/dist/chunk-ede7zpjf.js +2 -0
- package/dist/chunk-ehfzp7xe.js +2 -0
- package/dist/chunk-fd77g6t6.js +2 -0
- package/dist/chunk-fnkxbnka.js +30 -0
- package/dist/chunk-fvjh7rx0.js +84 -0
- package/dist/chunk-g19skgmw.js +18 -0
- package/dist/chunk-gcnrdgrq.js +3 -0
- package/dist/chunk-h2wpnxrh.js +8 -0
- package/dist/chunk-hb83d0qc.js +2 -0
- package/dist/chunk-hncp9gz6.js +8 -0
- package/dist/chunk-ht51fz7w.js +4 -0
- package/dist/chunk-hyrjade7.js +321 -0
- package/dist/chunk-hyyzp99b.js +2 -0
- package/dist/chunk-jpbk42j7.js +2 -0
- package/dist/chunk-jr5tp4ks.js +2 -0
- package/dist/chunk-k03b9z9e.js +898 -0
- package/dist/chunk-kjr22neh.js +3 -0
- package/dist/chunk-mjt5e2jy.js +2 -0
- package/dist/chunk-mkm91b6w.js +2 -0
- package/dist/chunk-mtr2f82n.js +2 -0
- package/dist/chunk-n8zpm7xb.js +397 -0
- package/dist/chunk-ndnc7k2n.js +22 -0
- package/dist/chunk-nenge2m2.js +2 -0
- package/dist/chunk-nngpktr2.js +2 -0
- package/dist/chunk-nsjyn31z.js +2 -0
- package/dist/chunk-nye9brje.js +147 -0
- package/dist/chunk-p5kp35dy.js +2 -0
- package/dist/chunk-pw0rzgpv.js +3 -0
- package/dist/chunk-q020t182.js +2 -0
- package/dist/chunk-q4gp9egt.js +4 -0
- package/dist/chunk-q8szpd6w.js +3 -0
- package/dist/chunk-q9n5swx7.js +3 -0
- package/dist/chunk-qpcwahse.js +2 -0
- package/dist/chunk-qz75kx6n.js +231 -0
- package/dist/chunk-r41nsgym.js +116 -0
- package/dist/chunk-r4qnvxhv.js +18 -0
- package/dist/chunk-r6p4ws0a.js +3809 -0
- package/dist/chunk-rdf7d42n.js +2 -0
- package/dist/chunk-rs2fa3g1.js +2 -0
- package/dist/chunk-ryjpp51z.js +499 -0
- package/dist/chunk-s018d32j.js +30 -0
- package/dist/chunk-spn8e3b3.js +2 -0
- package/dist/chunk-sry9atvv.js +2 -0
- package/dist/chunk-st5qggks.js +3 -0
- package/dist/chunk-tywvd1zc.js +11 -0
- package/dist/chunk-v3ryxw4v.js +2 -0
- package/dist/chunk-va9k88da.js +2 -0
- package/dist/chunk-vgk5v31k.js +216 -0
- package/dist/chunk-vj320kyr.js +2 -0
- package/dist/chunk-vr3qtsj4.js +2 -0
- package/dist/chunk-w0ng9e1m.js +341 -0
- package/dist/chunk-w29sv5jf.js +2 -0
- package/dist/chunk-whq99ytc.js +7987 -0
- package/dist/chunk-wnaddtv3.js +288 -0
- package/dist/chunk-wtengj6h.js +2 -0
- package/dist/chunk-x0ks1fer.js +1194 -0
- package/dist/chunk-x0zh76yv.js +4 -0
- package/dist/chunk-x13f5bbe.js +358 -0
- package/dist/chunk-xfp10a23.js +2 -0
- package/dist/chunk-xp3fp266.js +11 -0
- package/dist/chunk-xz019t7t.js +2 -0
- package/dist/chunk-y35rktea.js +12 -0
- package/dist/chunk-y4hkqsgw.js +4 -0
- package/dist/chunk-yab6d6kb.js +28 -0
- package/dist/chunk-yckd6ks5.js +3 -0
- package/dist/chunk-ycn1vnv2.js +5 -0
- package/dist/chunk-yf3bmmkk.js +8 -0
- package/dist/chunk-ygr11tgz.js +3 -0
- package/dist/chunk-ymccpdg6.js +351 -0
- package/dist/chunk-yr2wc2pa.js +3 -0
- package/dist/chunk-yv340gxj.js +2 -0
- package/dist/chunk-z2sp0k8d.js +3 -0
- package/dist/chunk-z5cm0bwn.js +11 -0
- package/dist/chunk-zda3hvde.js +14 -0
- package/dist/chunk-zgvga8rc.js +5 -0
- package/dist/chunk-zqbw8zqq.js +3 -0
- package/dist/cli.js +108 -27481
- package/dist/craft-entry.js +9 -5
- package/dist/craft.js +7 -18503
- package/dist/database.js +2 -2
- package/dist/pwa.js +8 -16603
- package/dist/ssg.js +52 -15512
- package/dist/visual-testing.js +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,3809 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Tr as v9,bs as U6,cs as W6}from"./chunk-8src5smc.js";import{hs as p0}from"./chunk-xp3fp266.js";import{ms as d5}from"./chunk-nye9brje.js";import{Gs as x9}from"./chunk-tywvd1zc.js";import{Hs as K6,Js as z6,Ks as H6,Ms as j5}from"./chunk-cbc56wpd.js";import{Ns as g9,Rs as o5,Ts as i9}from"./chunk-x0zh76yv.js";import{ct as h9}from"./chunk-0ae6chzd.js";import{dt as Q8,et as $8,ft as l1,gt as G8,ht as E4,it as n2,jt as K2,kt as N9}from"./chunk-kjr22neh.js";import{Dt as f3,Ut as f9,Wt as dQ,Xt as h$,Zt as U5,tt as c3,wt as P2}from"./chunk-3952ykhb.js";import{cu as B6}from"./chunk-dtmwr674.js";import{hu as h}from"./chunk-pw0rzgpv.js";import b1 from"path";import I5 from"fs";var T4=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"]),I4={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"},H8=new Set(["ctrl","alt","shift","meta"]),b4={left:0,middle:1,right:2};function k4($){let Z={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let X of $){let Y=X.toLowerCase();if(Y==="prevent")Z.prevent=!0;else if(Y==="stop")Z.stop=!0;else if(Y==="once")Z.once=!0;else if(Y==="capture")Z.capture=!0;else if(Y==="self")Z.self=!0;else if(Y==="passive")Z.passive=!0;else if(H8.has(Y))Z.systemKeys.push(Y);else if(Y in b4)Z.mouse=Y;else if(Y in I4||/^[a-z]$/.test(Y))Z.keys.push(I4[Y]||Y.toUpperCase());else if(Y.startsWith("debounce")){let J=Y.match(/debounce(?:\.(\d+))?/);Z.debounce=J?.[1]?Number.parseInt(J[1],10):300}else if(Y.startsWith("throttle")){let J=Y.match(/throttle(?:\.(\d+))?/);Z.throttle=J?.[1]?Number.parseInt(J[1],10):300}}return Z}function y4($){let Z=[],X=0,Y=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,J;while((J=Y.exec($))!==null){let[Q,G,q]=J,U=J.index,W=U+Q.length,K=`__stx_evt_${X++}`,z=[],H=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,B;while((B=H.exec(q))!==null){let[,_,V]=B,O=_.split("."),F=O[0];if(!T4.has(F))continue;z.push({attribute:`@${_}`,event:F,handler:V,modifiers:k4(O.slice(1)),elementId:K})}let j=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((B=j.exec(q))!==null){let[,_,V]=B,O=_.split("."),F=O[0];if(!T4.has(F))continue;z.push({attribute:`@${_}`,event:F,handler:V,modifiers:k4(O.slice(1)),elementId:K})}if(z.length>0)Z.push({originalTag:Q,elementId:K,events:z,startIndex:U,endIndex:W})}return Z}function B8($){let Z=[],{modifiers:X}=$;if(X.self)Z.push("if ($event.target !== $el) return");for(let Y of X.systemKeys)Z.push(`if (!$event.${Y}Key) return`);if(X.keys.length>0){let Y=X.keys.map((J)=>`$event.key === '${J}'`).join(" || ");Z.push(`if (!(${Y})) return`)}if(X.mouse!==null){let Y=b4[X.mouse];Z.push(`if ($event.button !== ${Y}) return`)}if(X.prevent)Z.push("$event.preventDefault()");if(X.stop)Z.push("$event.stopPropagation()");return Z.join("; ")}function j8($,Z){let X=$;if(Z.debounce!==null)X=`__stx_debounce(() => { ${X} }, ${Z.debounce})`;else if(Z.throttle!==null)X=`__stx_throttle(() => { ${X} }, ${Z.throttle})`;return X}function I$($){let Z=$.trim();if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(Z))return $;return`if (typeof ${Z} === 'function' && !${Z}._isSignal) ${Z}($event);`}function _8($){let{modifiers:Z}=$,X=$.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),Y=B8($),J=j8(I$($.handler),Z),Q=[];if(Z.once)Q.push("once: true");if(Z.capture)Q.push("capture: true");if(Z.passive)Q.push("passive: true");let G=Q.length>0?`, { ${Q.join(", ")} }`:"",q=J.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if($.event==="mounted")return`
|
|
3
|
+
(function() {
|
|
4
|
+
var $el = document.getElementById('${X}');
|
|
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('${q}', null, $el);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
__stx_runHandler('${q}', null, $el);
|
|
13
|
+
}
|
|
14
|
+
})();`;if($.event==="unmounted")return`
|
|
15
|
+
(function() {
|
|
16
|
+
var $el = document.getElementById('${X}');
|
|
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('${q}', null, $el);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
__stx_runHandler('${q}', 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('${X}');
|
|
42
|
+
if (!$el) return;
|
|
43
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
44
|
+
$el.addEventListener('${$.event}', function($event) {
|
|
45
|
+
${Y?Y+";":""}
|
|
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('${q}', $event, $el);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// Fallback for non-reactive context (entity-safe; decoded + run in memory)
|
|
53
|
+
__stx_runHandler('${q}', $event, $el);
|
|
54
|
+
}
|
|
55
|
+
}${G});
|
|
56
|
+
})();`}function k$($){if($.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
|
+
${$.map(_8).join(`
|
|
112
|
+
`)}
|
|
113
|
+
})();
|
|
114
|
+
</script>`}function O8($){let Z=y4($);if(Z.length===0)return{template:$,bindings:[]};let X=$,Y=[];for(let J=Z.length-1;J>=0;J--){let Q=Z[J],G=Q.originalTag;if(!G.includes(" id="))G=G.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${Q.elementId}"`);else{let q=G.match(/id=["']([^"']+)["']/);if(q)for(let U of Q.events)U.elementId=q[1]}for(let q of Q.events){let U=q.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),W=new RegExp(`\\s*${U}\\s*=\\s*"[^"]*"`,"g"),K=new RegExp(`\\s*${U}\\s*=\\s*'[^']*'`,"g");G=G.replace(W,""),G=G.replace(K,"")}X=X.slice(0,Q.startIndex)+G+X.slice(Q.endIndex),Y.push(...Q.events)}return{template:X,bindings:Y}}function S4($,Z,X){if(E4($))return $;if(Z.__stx_sfc_mode){if(/x-data\s*=\s*["']/.test($))return $;let{template:q,bindings:U}=O8($),W=Z.__stx_event_bindings||[];return Z.__stx_event_bindings=[...W,...U],q}let Y=y4($);if(Y.length===0)return $;let J=$;for(let q=Y.length-1;q>=0;q--){let U=Y[q],W=U.originalTag;if(!W.includes(" id="))W=W.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${U.elementId}"`);else{let K=W.match(/id=["']([^"']+)["']/);if(K)for(let z of U.events)z.elementId=K[1]}for(let K of U.events){let z=K.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),H=new RegExp(`\\s*${z}\\s*=\\s*"[^"]*"`,"g"),B=new RegExp(`\\s*${z}\\s*=\\s*'[^']*'`,"g");W=W.replace(H,""),W=W.replace(B,"")}J=J.slice(0,U.startIndex)+W+J.slice(U.endIndex)}let Q=k$(Y.flatMap((q)=>q.events)),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
|
|
115
|
+
`+J.slice(G);else J+=Q;return J}function Gq($){return/@[a-z]+(?:\.[a-z]+)*\s*=\s*["'][^"']*["']/i.test($)}function o0($){let Z=/import\s*\{([^}]+)\}\s*from\s*['"](@stores|stx\/stores)['"]\s*;?\n?/g;$=$.replace(Z,(Y,J)=>{return`const { ${J.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__STX_STORES__
|
|
116
|
+
`});let X=/import\s*\{([^}]+)\}\s*from\s*['"]@composables['"]\s*;?\n?/g;return $=$.replace(X,(Y,J)=>{return`const { ${J.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__composables
|
|
117
|
+
`}),$}function Uq($){return $.replace(/^import\s+[^'"]*?from\s*['"][^'"]+['"]\s*;?[ \t]*$/gm,"").replace(/^import\s+['"][^'"]+['"]\s*;?[ \t]*$/gm,"")}import TG from"fs";import g from"path";import{createHash as V8}from"crypto";var y5="__stx_component_client_factories";function C4($){let Z=$[y5];return Z instanceof Map?Z:null}function P4($){$[y5]=new Map}function v4($,Z){let X=C4($);if(!X)return null;let Y=V8("sha256").update(Z).digest("hex").slice(0,16),J=X.get(Y);if(J)J.instances++;else X.set(Y,{body:Z,instances:1});return Y}function f4($,Z){let X=C4(Z);if(!X?.size)return $;let Y=$;for(let[U,W]of X){if(W.instances!==1)continue;let K=new RegExp(`window\\.__stxComponentFactories\\[${JSON.stringify(U)}\\]\\(("[^"]+")\\);`,"g");Y=Y.replace(K,(z,H)=>`(${W.body})(${H});`)}let J=[...X].filter(([,U])=>U.instances>1);if(J.length===0)return Y;let G=`<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
|
|
118
|
+
(function() {
|
|
119
|
+
const factories = window.__stxComponentFactories = window.__stxComponentFactories || {};
|
|
120
|
+
${J.map(([U,W])=>` try { factories[${JSON.stringify(U)}] = factories[${JSON.stringify(U)}] || ${W.body}; }
|
|
121
|
+
catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(U)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
|
|
122
|
+
`)}
|
|
123
|
+
})();
|
|
124
|
+
</script>`,q=Y.search(/<script\b(?=[^>]*\bdata-stx-scoped\b)/i);if(q<0)return`${G}
|
|
125
|
+
${Y}`;return`${Y.slice(0,q)}${G}
|
|
126
|
+
${Y.slice(q)}`}var F8={maxSanitizeDepth:10,allowBracketNotation:!1},g4={...F8};var h4=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,/\bnew\s+/,/\bdelete\s+/,/\bthis\b/],L8=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this"]),u4=new Set(["__proto__","constructor","prototype"]),w8=/[\w)\]]\s*\[\s*['"]/;function R8($){let Z="",X=null,Y=!1;for(let J=0;J<$.length;J++){let Q=$[J];if(Y){Y=!1;continue}if(Q==="\\"&&X){Y=!0;continue}if(X){if(X==="`"&&Q==="$"&&J+1<$.length&&$[J+1]==="{"){let G=1;J+=2;while(J<$.length&&G>0){if($[J]==="{")G++;else if($[J]==="}")G--;if(G>0)Z+=$[J],J++}continue}if(Q===X)X=null;continue}if(Q==='"'||Q==="'"||Q==="`"){X=Q;continue}Z+=Q}return Z}function D8($,Z){let X=/[$A-Z_a-z][$\w]*/g,Y;while((Y=X.exec($))!==null){let J=Y[0],Q=$[Y.index-1];if(L8.has(J))throw Error(`Potentially unsafe expression (matched /\\b${J}\\b/; identifier ${J}): ${Z}`);if(Q==="."&&u4.has(J))throw Error(`Potentially unsafe expression (matched /.${J}/; property ${J}): ${Z}`)}}function N8($){let Z=/\[\s*(['"])(.*?)\1\s*\]/g,X;while((X=Z.exec($))!==null){let Y=X[2];if(!u4.has(Y))continue;let J=$.slice(0,X.index).match(/\S(?=\s*$)/)?.[0],Q=$.slice(X.index+X[0].length).match(/^\s*(\S)/)?.[1];if(!((J==="{"||J===",")&&Q===":"))throw Error(`Potentially unsafe expression (bracket key ${X[2]}): ${$}`)}}function S5($){let Z=$.trim(),X=R8(Z);D8(X,Z),N8(Z);for(let Y of h4)if(Y.test(X))throw Error(`Potentially unsafe expression (matched /${Y.source}/): ${Z}`);if(!g4.allowBracketNotation&&w8.test(Z))throw Error(`Bracket notation with strings not allowed: ${Z}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);return Z}function A8($){let Z={};Z.Math=Math,Z.JSON=JSON,Z.Date=Date,Z.String=String,Z.Number=Number,Z.Boolean=Boolean,Z.Array=Array,Z.parseInt=Number.parseInt,Z.parseFloat=Number.parseFloat,Z.isNaN=Number.isNaN,Z.isFinite=Number.isFinite,Z.encodeURIComponent=encodeURIComponent,Z.decodeURIComponent=decodeURIComponent;for(let[X,Y]of Object.entries($)){if(X.startsWith("__")||h4.some((J)=>J.test(X)))continue;if(Y&&typeof Y==="object"&&!Array.isArray(Y))Z[X]=E$(Y);else Z[X]=Y}return Z}function E$($,Z=0){if(Z>=g4.maxSanitizeDepth)return"[Object too deep]";if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Y)=>E$(Y,Z+1));if($ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Error)return $;let X={};for(let[Y,J]of Object.entries($)){if(Y.startsWith("__")||Y==="constructor"||Y==="prototype")continue;if(J&&typeof J==="object")X[Y]=E$(J,Z+1);else X[Y]=J}return X}function X0($,Z){try{let X=A8(Z),Y=Object.keys(X),J=Object.values(X);return G0($,Y)(...J)}catch{return}}function Q0($){try{return S5($),!0}catch{return!1}}function _0($,Z){try{let X=X0($,Z);if(X&&typeof X==="object"&&!Array.isArray(X))return X;return{}}catch{return{}}}var d4=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]);function G0($,Z){let X=S5($),Y=/^[A-Za-z_$][\w$]*$/,J=[],Q=[];for(let W=0;W<Z.length;W++){let K=Z[W];if(!Y.test(K))continue;if(d4.has(K))continue;J.push(W),Q.push(K)}let G=(W)=>Function(...Q,...W,`
|
|
127
|
+
'use strict';
|
|
128
|
+
try {
|
|
129
|
+
return ${X};
|
|
130
|
+
}
|
|
131
|
+
catch (e) {
|
|
132
|
+
if (e instanceof TypeError) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
throw e;
|
|
136
|
+
}
|
|
137
|
+
`),q=G([]);if(Q.length===Z.length)return x4(q,Q,G);return x4((...W)=>{let K=Array(J.length);for(let z=0;z<J.length;z++)K[z]=W[J[z]];return q(...K)},Q,G,(W)=>{q=G(W)})}function x4($,Z,X,Y){let Q=/^(\w+) is not defined$/,G=$,q=[],U=new Set(Z);return(...W)=>{for(let K=0;K<=8;K++)try{return G(...W)}catch(z){let H=z instanceof Error?z.message:"",B=Q.exec(H);if(!(z instanceof ReferenceError)||!B)return;let j=B[1];if(U.has(j)||d4.has(j))return;U.add(j),q.push(j),G=X(q),Y?.(q)}return}}function C5($){let Z=$.trim(),X=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let Y of X)if(Y.test(Z))return!1;return!0}var m4=0,P5=new Map;function Bq(){m4=0,P5.clear()}function v5($,Z){let X=m4++,Y=`<!--__STX_${$.toUpperCase()}_${X}__-->`;return P5.set(Y,{type:$,expression:Z}),Y}function jq(){let $={};for(let[Z,X]of P5)$[Z]={type:X.type,expression:X.expression};return $}function _q($){let Z={},X=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,Y;while((Y=X.exec($))!==null){let J=Y[0],Q=Y[1].toLowerCase(),G=P5.get(J);Z[J]={type:Q,expression:G?.expression||""}}return Z}function Oq($,Z){let X=$;for(let[Y,J]of Z)X=X.split(Y).join(J);return X}function Vq($){return $.includes("<!--__STX_")}var l4=/<script\b[^>]*>/iy,c4=/<\/script\s*>/ig,p4=/<style\b[^>]*>/iy,i4=/<\/style\s*>/ig;function n4($,Z,X,Y){X.lastIndex=Z;let J=X.exec($);if(!J||J.index!==Z)return-1;Y.lastIndex=X.lastIndex;let Q=Y.exec($);if(!Q)return-1;return Q.index+Q[0].length}function Y1($,Z){return n4($,Z,l4,c4)}function S1($,Z){return n4($,Z,p4,i4)}function Q5($,Z){if(!$.startsWith("<!--",Z))return-1;let X=$.indexOf("-->",Z+4);if(X===-1)return-1;return X+3}function M8($,Z){if($.startsWith("<!--",Z)){let X=Q5($,Z);return X===-1?$.length:X}for(let[X,Y]of[[l4,c4],[p4,i4]]){X.lastIndex=Z;let J=X.exec($);if(!J||J.index!==Z)continue;Y.lastIndex=X.lastIndex;let Q=Y.exec($);return Q?Q.index+Q[0].length:$.length}return-1}function f5($,Z){let X=[],Y=0,J=$.length,Q=!1,G=null;while(Y<J){let q=$[Y];if(Q){if(G){if(q===G)G=null}else if(q==='"'||q==="'")G=q;else if(q===">")Q=!1;Y++;continue}if(q!=="<"){Y++;continue}let U=Z($,Y);if(U>Y){X.push({start:Y,end:U,token:$.slice(Y,U)}),Y=U;continue}let W=M8($,Y);if(W>Y){Y=W;continue}if(/^<\/?[a-zA-Z]/.test($.slice(Y,Y+2)))Q=!0;Y++}return X}function l0($,Z,X){let Y=f5($,Z);if(Y.length===0)return{output:$,tokens:[]};let J=Y.map((q)=>q.token),Q="",G=0;for(let q=0;q<Y.length;q++){let U=Y[q];Q+=$.slice(G,U.start),Q+=X(U.token,q),G=U.end}return Q+=$.slice(G),{output:Q,tokens:J}}function c0($){let{output:Z,tokens:X}=l0($,Y1,(Y,J)=>`\x00STX_SCRIPT_${J}\x00`);return{output:Z,scripts:X}}function C1($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(X,Y)=>Z[+Y]??"")}var G5={},s4=new Map;function T8($){let Z=s4.get($);if(!Z){let X=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${X}(?!\\w)`,"g"),s4.set($,Z)}return Z.lastIndex=0,Z}var x5={uppercase:($,Z)=>{return $!==void 0&&$!==null?String($).toUpperCase():""},lowercase:($,Z)=>{return $!==void 0&&$!==null?String($).toLowerCase():""},capitalize:($,Z)=>{if($===void 0||$===null)return"";let X=String($);return X.charAt(0).toUpperCase()+X.slice(1)},number:($,Z,X=0)=>{if($===void 0||$===null)return"";try{let Y=Number($);return Number.isNaN(Y)?"":Y.toFixed(Number.parseInt(String(X),10))}catch{return""}},fmt:($,Z,X="en-US")=>{if($===void 0||$===null)return"";try{let Y=Number($);if(Number.isNaN(Y))return String($);return Y.toLocaleString(X)}catch{return String($)}},join:($,Z,X=",")=>{if(!Array.isArray($))return"";return $.join(String(X))},escape:($,Z)=>{if($===void 0||$===null)return"";return r4(String($))},translate:($,Z,X={})=>{if(!Z||!Z.__translations)return $;let Y=Z.__translations,J=Z.__i18nConfig?.fallbackToKey??!0,Q=String($).split("."),G=Y;for(let U of Q){if(G===void 0||G===null)break;G=G[U]}if(G===void 0||G===null)return J?$:"";let q=String(G);return Object.entries(X).forEach(([U,W])=>{q=q.replace(T8(U),String(W))}),q},t:($,Z,X={})=>{return x5.translate($,Z,X)},truncate:($,Z,X=50,Y="...")=>{if($===void 0||$===null)return"";let J=String($);if(J.length<=X)return J;if(X<=Y.length)return Y.substring(0,X);return J.substring(0,X-Y.length)+Y},date:($,Z,X="short",Y="en-US")=>{if($===void 0||$===null)return"";try{let J=$ instanceof Date?$:new Date($);if(Number.isNaN(J.getTime()))return String($);let Q={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(X==="iso")return J.toISOString();return new Intl.DateTimeFormat(Y,Q[X]||Q.short).format(J)}catch{return String($)}},currency:($,Z,X="USD",Y="en-US")=>{if($===void 0||$===null)return"";try{let J=Number($);if(Number.isNaN(J))return String($);return new Intl.NumberFormat(Y,{style:"currency",currency:X}).format(J)}catch{return String($)}},pluralize:($,Z,X,Y)=>{let J=Number($);if(Number.isNaN(J))return X;let Q=Y||`${X}s`;return J===1?X:Q},first:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[0];return String($).charAt(0)},last:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[$.length-1];let X=String($);return X.charAt(X.length-1)},length:($,Z)=>{if($===void 0||$===null)return 0;if(Array.isArray($)||typeof $==="string")return $.length;if($ instanceof Map||$ instanceof Set)return $.size;if(typeof $==="object")return Object.keys($).length;return 0},json:($,Z,X=!1)=>{if($===void 0)return"undefined";if($===null)return"null";try{return X?JSON.stringify($,null,2):JSON.stringify($)}catch{return String($)}},default:($,Z,X="")=>{return $===void 0||$===null||$===""?X:$},reverse:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return[...$].reverse();return String($).split("").reverse().join("")},slice:($,Z,X=0,Y)=>{if($===void 0||$===null)return"";if(Array.isArray($)||typeof $==="string")return $.slice(X,Y);return $},replace:($,Z,X,Y="")=>{if($===void 0||$===null)return"";let J=X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String($).replace(new RegExp(J,"g"),()=>Y)},stripTags:($,Z)=>{if($===void 0||$===null)return"";return String($).replace(/<[^>]*>/g,"")},urlencode:($,Z)=>{if($===void 0||$===null)return"";return encodeURIComponent(String($))},abs:($,Z)=>{let X=Number($);return Number.isNaN(X)?0:Math.abs(X)},round:($,Z,X=0)=>{let Y=Number($);if(Number.isNaN(Y))return 0;let J=10**X;return Math.round(Y*J)/J}};function I8($,Z){if($ in x5)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);G5[$]=Z}function Mq($){for(let[Z,X]of Object.entries($))I8(Z,X)}function k8(){return{...x5,...G5}}function Tq(){for(let $ of Object.keys(G5))delete G5[$]}function b$($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r4($){return b$($).replace(/\{{2,}/g,(Z)=>E8(Z.length)).replace(/\{(?=!)/g,`{${a4}`)}var a4="⁠";function E8($){return Array.from({length:$},()=>"{").join(a4)}function J1($){let{scripts:Z}=c0($);for(let X of Z){let Y=X.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);if(!Y||/\bserver\b|\bsrc\s*=/.test(Y[1]))continue;let J=Y[2];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(J))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test($))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test($))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test($))return!0;return!1}function o4($,Z){let X=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console"],Y=$.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),J="",Q=!1,G=0;for(let W=0;W<Y.length;W++){let K=Y[W];if(!Q&&K==="`"){Q=!0,G=0;continue}if(Q){if(K==="`"&&G===0){Q=!1;continue}if(K==="$"&&Y[W+1]==="{"){G++,W++,J+=" ";continue}if(K==="}"&&G>0){G--;continue}if(G>0){J+=K;continue}continue}J+=K}Y=J;let q=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,U;while((U=q.exec(Y))!==null){let W=U[1];if(!Y.substring(0,U.index).trimEnd().endsWith(".")){if(!X.includes(W)&&!(W in Z))return!1}}return!0}function b8($,Z){let X=Z.__stx_serverDeclared;if(!X||X.size===0)return!1;let Y=p0($);for(let J of X)if(new RegExp(`(?<![.#\\w$])${J}(?![\\w$])`).test(Y))return!0;return!1}function y$($,Z){let X=$;return X=X.replace(/\{!!([\s\S]*?)!!\}/g,(Y,J)=>{try{let Q=b0(J,Z);if(Q===void 0)return Y;return Q===null?"":String(Q)}catch{return Y}}),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(Y,J)=>{let Q=J.trim();if(/^__[A-Z_]+__$/.test(Q))return Y;try{let G=b0(J,Z);if(G===void 0)return Y;return JSON.stringify(G).replace(/</g,"\\u003c")}catch{return Y}}),X}function y8($,Z){if(!$.includes("{"))return $;let X=$;return X=X.replace(/\{!!([\s\S]*?)!!\}/g,(Y,J)=>{try{let Q=b0(J,Z);if(Q===void 0)return Y;return Q===null?"":String(Q)}catch{return Y}}),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(Y,J)=>{let Q=J.trim();if(/^__[A-Z_]+__$/.test(Q))return Y;try{let G=b0(J,Z);if(G===void 0)return Y;if(G===null)return"";return String(G).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}catch{return Y}}),X}function Iq($,Z,X={}){let{output:Y,scripts:J}=c0($),Q=J.map((G)=>{let q=G.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i),U=G.match(/^<script\b[^>]*>/i),W=G.search(/<\/script\s*>$/i);if(!q||!U||W===-1)return G;let K=q[1],z=q[2];if(/\bdata-raw\b/.test(K))return G;if(X.skipServer&&/\bserver\b/.test(K))return G;let B=`<script${y8(K,Z)}>`;if(/\bsrc\s*=/.test(K)||/\btype\s*=\s*["']application\/json["']/.test(K))return B+z+G.slice(W);return B+y$(z,Z)+G.slice(W)});return C1(Y,Q)}function _1($,Z,X){let Y=$,J=(z,H)=>{let B=S1(z,H);if(B===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(z.slice(H,B))?-1:B},Q=(z,H,B,j)=>{let _=B.length,{output:V,tokens:O}=l0(z,H,(F,L)=>j(_+L));return B.push(...O),V},G=[];Y=Q(Y,J,G,(z)=>`<!--__STX_STYLE_${z}__-->`);let q=[];Y=Q(Y,Y1,q,(z)=>`<!--__STX_SCRIPT_EXPR_${z}__-->`);let U=Z?.__stx_signals_gate===!0||J1($),W=new Set(Array.isArray(Z?.__stx_client_signal_names)?Z.__stx_client_signal_names:[]),K=new Set(Array.isArray(Z?.__stx_preserved_client_expressions)?Z.__stx_preserved_client_expressions:[]);Y=Y.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(z,H,B)=>{try{let j=b0(H,Z);return j!==void 0&&j!==null?String(j):""}catch(j){let _=j instanceof Error?j.message:String(j);return W0("Expression",`Error evaluating: {{{ ${H.trim()}}}}: ${_}`,X,$,B,z)}}),Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(z,H,B)=>{try{let j=b0(H,Z);if(j===void 0&&Z.__stx_buildMode==="compile")return v5("raw",H.trim());return j!==void 0&&j!==null?String(j):""}catch(j){if(Z.__stx_buildMode==="compile")return v5("raw",H.trim());let _=j instanceof Error?j.message:String(j);return W0("Expression",`Error evaluating: {!! ${H.trim()} !!}: ${_}`,X,$,B,z)}}),Y=Q(Y,Y1,q,(z)=>`<!--__STX_SCRIPT_EXPR_${z}__-->`),Y=Q(Y,J,G,(z)=>`<!--__STX_STYLE_${z}__-->`),Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(z,H,B)=>{let j=H.trim();if(K.has(j))return z;let _=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],V=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,F=j.match(V)?.[1],L=F&&((F in Z)||_.includes(F)),w=Boolean(F&&W.has(F)),R=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,D=j.match(R),N=D&&!_.includes(D[1])&&!(D[1]in Z);if(/^__[A-Z_]+__$/.test(j))return"";try{let T=b0(H,Z);if(w)return z;if(U&&!o4(j,Z))return z;if(Z.__stx_buildMode==="compile"&&!U&&(T===void 0||b8(j,Z)))return v5("expr",j);return T!==void 0&&T!==null?r4(String(T)):""}catch(T){if(w)return z;if(U&&!o4(j,Z))return z;if(N)return z;let A=T instanceof Error?T.message:String(T);return W0("Expression",`Error evaluating: {{ ${j} }}: ${A}`,X,$,B,z)}});for(let z=0;z<q.length;z++)Y=Y.replace(`<!--__STX_SCRIPT_EXPR_${z}__-->`,()=>q[z]);for(let z=0;z<G.length;z++)Y=Y.replace(`<!--__STX_STYLE_${z}__-->`,()=>G[z]);return Y}function S8($,Z,X){if(!Z.trim())return $;let Y=$,J=Z.trim();while(J.length>0){let Q=J.match(/^(\w+)/);if(!Q)break;let G=Q[1];J=J.substring(G.length).trim();let q=G5[G]||x5[G];if(!q)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(k8()).join(", ")}`);let U=[];if(J.startsWith(":")){let W=J.match(/^:([^|\s]+)/);if(W){let K=W[1].trim();try{let z=Number(K);U=[Number.isNaN(z)?K:z]}catch{U=[K]}J=J.substring(W[0].length).trim()}}else if(J.startsWith("(")){let W=1,K=1;while(W>0&&K<J.length){if(J[K]==="(")W++;if(J[K]===")")W--;K++}if(W===0){let z=J.substring(1,K-1).trim();if(z)try{if(z.startsWith("{")&&z.endsWith("}"))U=[b0(`(${z})`,X,!0)];else{let H=[],B="",j=null,_=0,V=0,O=0,F=!1;for(let L=0;L<z.length;L++){let w=z[L];if(F){B+=w,F=!1;continue}if(w==="\\"){B+=w,F=!0;continue}if(j){if(B+=w,w===j)j=null;continue}if(w==='"'||w==="'"||w==="`"){j=w,B+=w;continue}if(w==="(")_++;else if(w===")")_--;else if(w==="[")V++;else if(w==="]")V--;else if(w==="{")O++;else if(w==="}")O--;if(w===","&&_===0&&V===0&&O===0){H.push(B),B="";continue}B+=w}if(B)H.push(B);U=H.map((L)=>{let w=L.trim();return b0(w,X,!0)})}}catch{U=[z]}J=J.substring(K).trim()}}try{Y=q(Y,X,...U)}catch(W){let K=W instanceof Error?W.message:String(W);throw Error(`Error applying filter '${G}': ${K}`)}if(J.startsWith("|"))J=J.substring(1).trim();else break}return Y}function C8($){let Z=!1,X="",Y=0,J=0,Q=0,G=!1;for(let q=0;q<$.length;q++){let U=$[q],W=$[q+1];if(Z&&G){G=!1;continue}if(Z&&U==="\\"){G=!0;continue}if(G=!1,(U==='"'||U==="'"||U==="`")&&!G){if(!Z)Z=!0,X=U;else if(U===X)Z=!1,X="";continue}if(Z&&X==="`"&&U==="$"&&W==="{"){let K=1;q+=2;while(q<$.length&&K>0){if($[q]==="{")K++;else if($[q]==="}")K--;if(K>0)q++}continue}if(Z)continue;if(U==="(")Y++;else if(U===")")Y--;else if(U==="[")J++;else if(U==="]")J--;else if(U==="{")Q++;else if(U==="}")Q--;if(U==="|"&&Y===0&&J===0&&Q===0){if(W==="|"){q++;continue}if(W==="="){q++;continue}return q}}return-1}function b0($,Z,X=!1){try{let Y=$.trim(),J=C8(Y);if(J>0){let Q=Y.substring(0,J).trim(),G=Y.substring(J+1).trim(),q=b0(Q,Z,!0);return S8(q,G,Z)}if(!Q0(Y)){if(!X)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${Y}`);return X0(Y,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return G0(Y,Q)(...G)}catch{return X0(Y,Z)}}catch(Y){if(Y instanceof ReferenceError){let J=/(\b\w+)\s+is not defined/.exec(Y.message);if(J){let Q=J[1],G=P8(Q,Object.keys(Z));if(G&&G!==Q)Y.message=`${Y.message} \u2014 did you mean '${G}'?`}}if(!X)console.error(`Error evaluating expression: ${$}`,Y);throw Y}}function P8($,Z){let X=null;for(let J of Z){if(J===$)continue;let Q=v8($,J);if(X===null||Q<X.dist)X={key:J,dist:Q}}if(!X)return null;let Y=Math.max($.length,X.key.length);if(X.dist<=2||X.dist/Y<=0.35)return X.key;return null}function v8($,Z){if($===Z)return 0;if($.length===0)return Z.length;if(Z.length===0)return $.length;let[X,Y]=$.length<Z.length?[$,Z]:[Z,$],J=Array(X.length+1),Q=Array(X.length+1);for(let G=0;G<=X.length;G++)J[G]=G;for(let G=1;G<=Y.length;G++){Q[0]=G;for(let q=1;q<=X.length;q++){let U=X[q-1]===Y[G-1]?0:1;Q[q]=Math.min(Q[q-1]+1,J[q]+1,J[q-1]+U)}for(let q=0;q<=X.length;q++)J[q]=Q[q]}return J[X.length]}function kq($){if(!$)return"";return $.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}class O1{cache=new Map;maxSize;constructor($=100){this.maxSize=$}get($){if(!this.cache.has($))return;let Z=this.cache.get($);return this.cache.delete($),this.cache.set($,Z),Z}set($,Z){if(this.cache.has($))this.cache.delete($);else if(this.cache.size>=this.maxSize){let X=this.cache.keys().next().value;if(X!==void 0)this.cache.delete(X)}this.cache.set($,Z)}has($){return this.cache.has($)}delete($){return this.cache.delete($)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}var P1=new Map,f8=500;function v1($,Z){if(Z?.includes("g"))return new RegExp($,Z);let X=`${$}:${Z||""}`;if(!P1.has(X)){if(P1.size>=f8){let Y=P1.keys().next().value;if(Y)P1.delete(Y)}P1.set(X,new RegExp($,Z))}return P1.get(X)}class t4{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator($){let Z=Array.from(new Set($)),X=Z.sort().join(","),Y=this.pool.find((q)=>q.context.join(",")===X);if(Y)return Y.func;let J=this.fnCache,Q=this.fnCacheMaxSize,G=(...q)=>{return(U)=>{try{let W=`${X}:${U}`,K=J.get(W);if(!K){if(J.size>=Q){let z=J.keys().next().value;if(z)J.delete(z)}K=Function(...Z,`
|
|
138
|
+
'use strict';
|
|
139
|
+
try {
|
|
140
|
+
return ${U};
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
if (e instanceof ReferenceError || e instanceof TypeError) {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
throw e;
|
|
147
|
+
}
|
|
148
|
+
`),J.set(W,K)}return K(...q)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:G,context:Z.slice()});return G}clear(){this.pool.length=0,this.fnCache.clear()}}var bq=new t4;class e4{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,Z){this.budgets.set($,{warnThreshold:0.8,action:"warn",...Z})}setBudgets($){for(let[Z,X]of Object.entries($))this.setBudget(Z,X)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[Z,X]of this.budgets.entries())$[Z]=X;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let Z=this.violationHandlers.indexOf($);if(Z!==-1)this.violationHandlers.splice(Z,1)}time($,Z){if(!this.enabled)return Z();let X=performance.now(),Y=Z(),J=performance.now()-X;return this.recordTime($,J),this.checkBudget($,J),Y}async timeAsync($,Z){if(!this.enabled)return Z();let X=performance.now(),Y=await Z(),J=performance.now()-X;return this.recordTime($,J),this.checkBudget($,J),Y}checkBudget($,Z){let X=this.budgets.get($);if(!X)return;let Y=Z/X.maxTime*100,J=X.warnThreshold!==void 0?Z>=X.maxTime*X.warnThreshold&&Z<X.maxTime:!1,Q=Z>=X.maxTime;if(!J&&!Q)return;let G={label:$,actualTime:Z,budgetTime:X.maxTime,exceedancePercent:Y,timestamp:new Date,isWarning:J};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let U of this.violationHandlers)try{U(G)}catch{}let q=J?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${Y.toFixed(1)}% of ${X.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${X.maxTime}ms budget by ${(Y-100).toFixed(1)}%)`;switch(X.action){case"log":console.log(q);break;case"warn":console.warn(q);break;case"error":console.error(q);break;case"throw":if(Q)throw Error(q);else console.warn(q);break}}recordTime($,Z){let X=this.metrics.get($);if(X)X.count++,X.totalTime+=Z,X.maxTime=Math.max(X.maxTime,Z),X.minTime=Math.min(X.minTime,Z);else this.metrics.set($,{count:1,totalTime:Z,maxTime:Z,minTime:Z})}getStats($){if($){let X=this.metrics.get($);if(!X)return{};let Y=this.budgets.get($);return{count:X.count,avgTime:X.totalTime/X.count,totalTime:X.totalTime,maxTime:X.maxTime,minTime:X.minTime,budget:Y?.maxTime,budgetUtilization:Y?X.totalTime/X.count/Y.maxTime*100:void 0}}let Z={};for(let[X,Y]of this.metrics.entries()){let J=this.budgets.get(X);Z[X]={count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:J?.maxTime,budgetUtilization:J?Y.totalTime/Y.count/J.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,X=0;for(let Y of this.violations)if($[Y.label]=($[Y.label]||0)+1,Y.isWarning)Z++;else X++;return{total:this.violations.length,byLabel:$,warnings:Z,errors:X}}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 S$=null;function x8(){if(!S$)S$=new e4;return S$}var $7=new Proxy({},{get($,Z){return x8()[Z]}});import mQ from"fs";import R0 from"path";var C$=[{open:/<!--/g,close:/-->/g},{open:/<script\b/gi,close:/<\/script\s*>/gi},{open:/<style\b/gi,close:/<\/style\s*>/gi}],Z7=/<body\b([^>]*)>/gi;function q5($){let Z=0,X,Y=C$.map(()=>{return});while(Z<$.length){if(X===void 0||X!==null&&X.index<Z)Z7.lastIndex=Z,X=Z7.exec($);if(!X)return null;let J=X.index,Q=-1,G=null;for(let U=0;U<C$.length;U++){let W=C$[U],K=Y[U];if(K===void 0||K!==null&&K.index<Z)W.open.lastIndex=Z,K=W.open.exec($),Y[U]=K;if(!K)continue;if(K.index<J&&(Q===-1||K.index<Q))Q=K.index,G=W.close}if(Q===-1||!G)return{index:J,tag:X[0],attrs:X[1]??""};G.lastIndex=Q;let q=G.exec($);if(!q)return null;Z=q.index+q[0].length}return null}function g5($,Z){let X=q5($);if(!X)return $;return $.slice(0,X.index)+Z(X.tag,X.attrs)+$.slice(X.index+X.tag.length)}var X7=null;function g8($){if(!X7)return console.warn(`[stx] ${$} must be called within a component setup.`),null;return X7}function Cq($){let Z=g8("onUpdate");if(Z)Z.updateHooks.push($)}function Y7(){return`
|
|
149
|
+
// STX Lifecycle Runtime
|
|
150
|
+
(function() {
|
|
151
|
+
if (typeof window === 'undefined') return;
|
|
152
|
+
|
|
153
|
+
const instances = new Map();
|
|
154
|
+
let currentInstance = null;
|
|
155
|
+
let idCounter = 0;
|
|
156
|
+
|
|
157
|
+
function generateId() {
|
|
158
|
+
return 'stx-' + (++idCounter) + '-' + Date.now().toString(36);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function createInstance(element) {
|
|
162
|
+
const instance = {
|
|
163
|
+
id: generateId(),
|
|
164
|
+
element: element,
|
|
165
|
+
mountHooks: [],
|
|
166
|
+
destroyHooks: [],
|
|
167
|
+
updateHooks: [],
|
|
168
|
+
refs: new Map(),
|
|
169
|
+
watchers: [],
|
|
170
|
+
isMounted: false
|
|
171
|
+
};
|
|
172
|
+
instances.set(instance.id, instance);
|
|
173
|
+
return instance;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
window.STX = window.STX || {};
|
|
177
|
+
|
|
178
|
+
// Lifecycle hooks
|
|
179
|
+
window.STX.onMount = function(hook) {
|
|
180
|
+
if (currentInstance) currentInstance.mountHooks.push(hook);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
window.STX.onDestroy = function(hook) {
|
|
184
|
+
if (currentInstance) currentInstance.destroyHooks.push(hook);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
window.STX.onUpdate = function(hook) {
|
|
188
|
+
if (currentInstance) currentInstance.updateHooks.push(hook);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// Aliases
|
|
192
|
+
window.STX.onMounted = window.STX.onMount;
|
|
193
|
+
window.STX.onUnmounted = window.STX.onDestroy;
|
|
194
|
+
window.STX.onUpdated = window.STX.onUpdate;
|
|
195
|
+
|
|
196
|
+
// Refs
|
|
197
|
+
window.STX.ref = function(initialValue) {
|
|
198
|
+
const r = { value: initialValue || null };
|
|
199
|
+
Object.defineProperty(r, 'current', {
|
|
200
|
+
get: function() { return this.value; }
|
|
201
|
+
});
|
|
202
|
+
if (currentInstance) {
|
|
203
|
+
currentInstance.refs.set('ref-' + currentInstance.refs.size, r);
|
|
204
|
+
}
|
|
205
|
+
return r;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// Watch
|
|
209
|
+
window.STX.watch = function(source, callback, options) {
|
|
210
|
+
options = options || {};
|
|
211
|
+
let oldValue;
|
|
212
|
+
let cleanup;
|
|
213
|
+
let isActive = true;
|
|
214
|
+
|
|
215
|
+
function run() {
|
|
216
|
+
if (!isActive) return;
|
|
217
|
+
const newValue = source();
|
|
218
|
+
if (oldValue !== newValue || options.immediate) {
|
|
219
|
+
if (cleanup) cleanup();
|
|
220
|
+
cleanup = callback(newValue, oldValue);
|
|
221
|
+
oldValue = newValue;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (options.immediate) {
|
|
226
|
+
run();
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
oldValue = source();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const intervalId = setInterval(run, 16);
|
|
233
|
+
|
|
234
|
+
function stop() {
|
|
235
|
+
isActive = false;
|
|
236
|
+
clearInterval(intervalId);
|
|
237
|
+
if (cleanup) cleanup();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (currentInstance) {
|
|
241
|
+
currentInstance.watchers.push({ stop: stop });
|
|
242
|
+
currentInstance.destroyHooks.push(stop);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return stop;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// Computed
|
|
249
|
+
window.STX.computed = function(getter) {
|
|
250
|
+
let cached;
|
|
251
|
+
let dirty = true;
|
|
252
|
+
return {
|
|
253
|
+
get value() {
|
|
254
|
+
if (dirty) {
|
|
255
|
+
cached = getter();
|
|
256
|
+
dirty = false;
|
|
257
|
+
queueMicrotask(function() { dirty = true; });
|
|
258
|
+
}
|
|
259
|
+
return cached;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
// Component management
|
|
265
|
+
window.STX.setupComponent = function(element, setup) {
|
|
266
|
+
const instance = createInstance(element);
|
|
267
|
+
currentInstance = instance;
|
|
268
|
+
try {
|
|
269
|
+
setup();
|
|
270
|
+
}
|
|
271
|
+
finally {
|
|
272
|
+
currentInstance = null;
|
|
273
|
+
}
|
|
274
|
+
return instance;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
window.STX.mountComponent = function(instance) {
|
|
278
|
+
if (instance.isMounted) return;
|
|
279
|
+
instance.isMounted = true;
|
|
280
|
+
instance.mountHooks.forEach(function(hook) {
|
|
281
|
+
try {
|
|
282
|
+
const cleanup = hook();
|
|
283
|
+
if (typeof cleanup === 'function') {
|
|
284
|
+
instance.destroyHooks.push(cleanup);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
catch (e) {
|
|
288
|
+
console.error('[stx] onMount error:', e);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
window.STX.destroyComponent = function(instance) {
|
|
294
|
+
if (!instance.isMounted) return;
|
|
295
|
+
instance.watchers.forEach(function(w) { w.stop(); });
|
|
296
|
+
instance.destroyHooks.forEach(function(hook) {
|
|
297
|
+
try { hook(); }
|
|
298
|
+
catch (e) { console.error('[stx] onDestroy error:', e); }
|
|
299
|
+
});
|
|
300
|
+
instance.refs.forEach(function(ref) { ref.value = null; });
|
|
301
|
+
instance.isMounted = false;
|
|
302
|
+
instances.delete(instance.id);
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
// ==========================================================================
|
|
306
|
+
// Vue-Style Refs System - No document.** required!
|
|
307
|
+
// ==========================================================================
|
|
308
|
+
|
|
309
|
+
// Internal: Query for ref elements without exposing document API
|
|
310
|
+
function queryRef(name, root) {
|
|
311
|
+
return (root || document).querySelector('[data-stx-ref="' + name + '"], [data-ref="' + name + '"]');
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function queryAllRefs(root) {
|
|
315
|
+
return (root || document).querySelectorAll('[data-stx-ref], [data-ref]');
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Auto-bind refs from ref attributes (Vue-style)
|
|
319
|
+
window.STX.bindRefs = function(root, refs) {
|
|
320
|
+
if (!root) return;
|
|
321
|
+
queryAllRefs(root).forEach(function(el) {
|
|
322
|
+
var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
|
|
323
|
+
if (refs[refName]) {
|
|
324
|
+
refs[refName].value = el;
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
// Vue-style useRefs() - returns object with all refs as direct elements
|
|
330
|
+
// Usage: const { input, button, container } = STX.useRefs()
|
|
331
|
+
window.STX.useRefs = function(root) {
|
|
332
|
+
var refs = {};
|
|
333
|
+
queryAllRefs(root).forEach(function(el) {
|
|
334
|
+
var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
|
|
335
|
+
if (refName) {
|
|
336
|
+
refs[refName] = el;
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
return refs;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
// Get a single ref by name - Vue's useTemplateRef equivalent
|
|
343
|
+
// Usage: const input = STX.useRef('input')
|
|
344
|
+
window.STX.useRef = function(name, root) {
|
|
345
|
+
return queryRef(name, root);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
// Two-way binding helper for form elements
|
|
349
|
+
// Usage: STX.model(inputEl, state, 'username')
|
|
350
|
+
window.STX.model = function(el, state, key) {
|
|
351
|
+
if (!el || !state) return;
|
|
352
|
+
|
|
353
|
+
var isCheckbox = el.type === 'checkbox';
|
|
354
|
+
var isRadio = el.type === 'radio';
|
|
355
|
+
var isSelect = el.tagName === 'SELECT';
|
|
356
|
+
|
|
357
|
+
// Set initial value
|
|
358
|
+
if (isCheckbox) {
|
|
359
|
+
el.checked = !!state[key];
|
|
360
|
+
}
|
|
361
|
+
else if (isRadio) {
|
|
362
|
+
el.checked = el.value === state[key];
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
el.value = state[key] || '';
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// Listen for changes
|
|
369
|
+
var eventType = isCheckbox || isRadio ? 'change' : 'input';
|
|
370
|
+
el.addEventListener(eventType, function() {
|
|
371
|
+
if (isCheckbox) {
|
|
372
|
+
state[key] = el.checked;
|
|
373
|
+
}
|
|
374
|
+
else if (isRadio) {
|
|
375
|
+
if (el.checked) state[key] = el.value;
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
state[key] = el.value;
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// Return cleanup function
|
|
383
|
+
return function() {
|
|
384
|
+
el.removeEventListener(eventType, arguments.callee);
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
// Batch event binding helper - cleaner than manual addEventListener
|
|
389
|
+
// Usage: STX.on({ click: [btn1, btn2], input: [textField] }, handler)
|
|
390
|
+
window.STX.on = function(el, event, handler) {
|
|
391
|
+
if (!el) return function() {};
|
|
392
|
+
el.addEventListener(event, handler);
|
|
393
|
+
return function() { el.removeEventListener(event, handler); };
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
// Bind multiple events at once
|
|
397
|
+
// Usage: STX.events(refs.btn, { click: handleClick, mouseenter: handleHover })
|
|
398
|
+
window.STX.events = function(el, eventMap) {
|
|
399
|
+
if (!el) return function() {};
|
|
400
|
+
var cleanups = [];
|
|
401
|
+
Object.keys(eventMap).forEach(function(event) {
|
|
402
|
+
el.addEventListener(event, eventMap[event]);
|
|
403
|
+
cleanups.push(function() { el.removeEventListener(event, eventMap[event]); });
|
|
404
|
+
});
|
|
405
|
+
return function() { cleanups.forEach(function(c) { c(); }); };
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
// ==========================================================================
|
|
409
|
+
// DOM Helpers - Eliminate document.* usage
|
|
410
|
+
// ==========================================================================
|
|
411
|
+
|
|
412
|
+
// Global keyboard event listener
|
|
413
|
+
// Usage: STX.onKey('Escape', () => closeModal())
|
|
414
|
+
window.STX.onKey = function(key, handler, options) {
|
|
415
|
+
var listener = function(e) {
|
|
416
|
+
if (e.key === key) {
|
|
417
|
+
handler(e);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
document.addEventListener('keydown', listener, options);
|
|
421
|
+
return function() { document.removeEventListener('keydown', listener, options); };
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
// Create element helper
|
|
425
|
+
// Usage: STX.el('div', { class: 'foo' }, 'text content')
|
|
426
|
+
window.STX.el = function(tag, attrs, content) {
|
|
427
|
+
var el = document.createElement(tag);
|
|
428
|
+
if (attrs) {
|
|
429
|
+
Object.keys(attrs).forEach(function(key) {
|
|
430
|
+
if (key === 'class') {
|
|
431
|
+
el.className = attrs[key];
|
|
432
|
+
}
|
|
433
|
+
else if (key.startsWith('on')) {
|
|
434
|
+
el.addEventListener(key.slice(2).toLowerCase(), attrs[key]);
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
el.setAttribute(key, attrs[key]);
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
if (content) {
|
|
442
|
+
if (typeof content === 'string') {
|
|
443
|
+
el.textContent = content;
|
|
444
|
+
}
|
|
445
|
+
else if (Array.isArray(content)) {
|
|
446
|
+
content.forEach(function(child) { el.appendChild(child); });
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
el.appendChild(content);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return el;
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
// Get currently focused element
|
|
456
|
+
// Usage: const focused = STX.activeElement()
|
|
457
|
+
window.STX.activeElement = function() {
|
|
458
|
+
return document.activeElement;
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
// Escape HTML helper
|
|
462
|
+
// Usage: const safe = STX.escapeHtml(userInput)
|
|
463
|
+
window.STX.escapeHtml = function(text) {
|
|
464
|
+
var div = document.createElement('div');
|
|
465
|
+
div.textContent = text;
|
|
466
|
+
return div.innerHTML;
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
// MutationObserver for automatic lifecycle management
|
|
470
|
+
const observer = new MutationObserver(function(mutations) {
|
|
471
|
+
mutations.forEach(function(mutation) {
|
|
472
|
+
// Handle removed nodes
|
|
473
|
+
mutation.removedNodes.forEach(function(node) {
|
|
474
|
+
if (node.nodeType === 1 && node.__stx_instance__) {
|
|
475
|
+
window.STX.destroyComponent(node.__stx_instance__);
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// Start observing when DOM is ready
|
|
482
|
+
if (document.readyState === 'loading') {
|
|
483
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
484
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
console.log('[stx] Lifecycle runtime initialized');
|
|
492
|
+
})();
|
|
493
|
+
`}function P$($){return Symbol($)}var Pq=P$("theme"),vq=P$("router"),fq=P$("i18n");import*as Q7 from"crypto";function J7($){let Z=/\$(\w+)\./g,X=[],Y;while((Y=Z.exec($))!==null)if(!X.includes(Y[1]))X.push(Y[1]);return X}function h8(){return`stx-${Q7.randomBytes(4).toString("hex")}`}function u8($){return/\$\w+\./.test($)}function d8($){let Z=[],X=new Set,Y=/<(\w+)([^>]*?)(\s*\/?>)/g,J=$;return J=J.replace(Y,(Q,G,q,U)=>{if(["script","style","template"].includes(G.toLowerCase()))return Q;let W=[],K=!1,z=q,H=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,B=[...q.matchAll(H)];for(let V of B){let O=V[0],F=V[1],L=V[2];if(u8(L)){K=!0;let w=L.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(w){let R=w[1];if(W.push({attr:F,expr:R,fullMatch:O,originalAttr:F}),J7(R).forEach((N)=>X.add(N)),F==="text")z=z.replace(O,"");else if(F==="class")z=z.replace(O,'class=""');else if(F==="disabled"||F==="hidden")z=z.replace(O,"");else z=z.replace(O,`${F}=""`)}}}if(!K)return Q;let j=z.match(/\bid\s*=\s*"([^"]+)"/),_;if(j)_=j[1];else _=h8(),z=` id="${_}"${z}`;for(let V of W)Z.push({elementId:_,attribute:V.attr,expression:V.expr,stores:J7(V.expr)});return`<${G}${z}${U}`}),{html:J,bindings:Z,stores:X}}function m8($,Z){if($.length===0)return"";let X=Array.from(Z),Y=`
|
|
494
|
+
<script>
|
|
495
|
+
(function() {
|
|
496
|
+
'use strict';
|
|
497
|
+
|
|
498
|
+
// Wait for stores to be available
|
|
499
|
+
function initBindings() {
|
|
500
|
+
var stores = window.VoideStores;
|
|
501
|
+
if (!stores) {
|
|
502
|
+
setTimeout(initBindings, 10);
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// Store references for expressions
|
|
507
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
508
|
+
var $state = {};
|
|
509
|
+
`;for(let J of X)Y+=` $state.${J} = stores.${J} ? stores.${J}.get() : {};
|
|
510
|
+
`;Y+=`
|
|
511
|
+
// Binding update functions
|
|
512
|
+
function updateBindings() {
|
|
513
|
+
`;for(let J of $){let{elementId:Q,attribute:G,expression:q}=J,U=q.replace(/\$(\w+)\./g,"$state.$1.");if(G==="text")Y+=` (function() {
|
|
514
|
+
var el = document.getElementById('${Q}');
|
|
515
|
+
if (el) {
|
|
516
|
+
try {
|
|
517
|
+
el.textContent = ${U};
|
|
518
|
+
}
|
|
519
|
+
catch (e) { console.error('Binding error:', e); }
|
|
520
|
+
}
|
|
521
|
+
})();
|
|
522
|
+
`;else if(G==="html")Y+=` (function() {
|
|
523
|
+
var el = document.getElementById('${Q}');
|
|
524
|
+
if (el) {
|
|
525
|
+
try {
|
|
526
|
+
el.innerHTML = ${U};
|
|
527
|
+
}
|
|
528
|
+
catch (e) { console.error('Binding error:', e); }
|
|
529
|
+
}
|
|
530
|
+
})();
|
|
531
|
+
`;else if(G==="class")Y+=` (function() {
|
|
532
|
+
var el = document.getElementById('${Q}');
|
|
533
|
+
if (el) {
|
|
534
|
+
try {
|
|
535
|
+
var value = ${U};
|
|
536
|
+
if (typeof value === 'string') {
|
|
537
|
+
// Dynamic class string - merge with existing static classes
|
|
538
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
539
|
+
var staticClasses = el.getAttribute('data-static-class') || el.className;
|
|
540
|
+
if (!el.hasAttribute('data-static-class')) {
|
|
541
|
+
el.setAttribute('data-static-class', el.className);
|
|
542
|
+
}
|
|
543
|
+
el.className = (el.getAttribute('data-static-class') + ' ' + value).trim();
|
|
544
|
+
}
|
|
545
|
+
else if (typeof value === 'object') {
|
|
546
|
+
// Object syntax: { 'class-name': condition }
|
|
547
|
+
for (var cls in value) {
|
|
548
|
+
if (value[cls]) {
|
|
549
|
+
el.classList.add(cls);
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
el.classList.remove(cls);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
catch (e) { console.error('Binding error:', e); }
|
|
558
|
+
}
|
|
559
|
+
})();
|
|
560
|
+
`;else if(G==="show")Y+=` (function() {
|
|
561
|
+
var el = document.getElementById('${Q}');
|
|
562
|
+
if (el) {
|
|
563
|
+
try {
|
|
564
|
+
el.style.display = (${U}) ? '' : 'none';
|
|
565
|
+
}
|
|
566
|
+
catch (e) { console.error('Binding error:', e); }
|
|
567
|
+
}
|
|
568
|
+
})();
|
|
569
|
+
`;else if(G==="if")Y+=` (function() {
|
|
570
|
+
var el = document.getElementById('${Q}');
|
|
571
|
+
if (el) {
|
|
572
|
+
try {
|
|
573
|
+
el.style.visibility = (${U}) ? 'visible' : 'hidden';
|
|
574
|
+
}
|
|
575
|
+
catch (e) { console.error('Binding error:', e); }
|
|
576
|
+
}
|
|
577
|
+
})();
|
|
578
|
+
`;else Y+=` (function() {
|
|
579
|
+
var el = document.getElementById('${Q}');
|
|
580
|
+
if (el) {
|
|
581
|
+
try {
|
|
582
|
+
var value = ${U};
|
|
583
|
+
if (value === false || value === null || value === undefined) {
|
|
584
|
+
el.removeAttribute('${G}');
|
|
585
|
+
}
|
|
586
|
+
else if (value === true) {
|
|
587
|
+
el.setAttribute('${G}', '');
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
el.setAttribute('${G}', value);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
catch (e) { console.error('Binding error:', e); }
|
|
594
|
+
}
|
|
595
|
+
})();
|
|
596
|
+
`}Y+=` }
|
|
597
|
+
|
|
598
|
+
// Subscribe to stores and update on changes. Capture the disposers so
|
|
599
|
+
// SPA fragment swaps can tear down old bindings before the next page's
|
|
600
|
+
// runtime takes over \u2014 without this, every navigation between pages
|
|
601
|
+
// using reactive-bindings stacked another subscription on every store,
|
|
602
|
+
// walking detached DOM forever. See stacksjs/stx#1709.
|
|
603
|
+
var _disposers = [];
|
|
604
|
+
`;for(let J of X)Y+=` if (stores.${J}) {
|
|
605
|
+
var _unsub_${J} = stores.${J}.subscribe(function(state) {
|
|
606
|
+
$state.${J} = state;
|
|
607
|
+
updateBindings();
|
|
608
|
+
});
|
|
609
|
+
// store.subscribe() may return the disposer (preferred) or void; both
|
|
610
|
+
// are tolerated here.
|
|
611
|
+
if (typeof _unsub_${J} === 'function') _disposers.push(_unsub_${J});
|
|
612
|
+
}
|
|
613
|
+
`;return Y+=`
|
|
614
|
+
// Initial update
|
|
615
|
+
updateBindings();
|
|
616
|
+
|
|
617
|
+
// Register this runtime's cleanup so SPA navigation can run it before
|
|
618
|
+
// swapping pages. The router (and any code) can call
|
|
619
|
+
// window.__stxCleanupBindings() to dispose subscriptions; we also wire
|
|
620
|
+
// 'popstate' and 'beforeunload' as a safety net for browser-driven nav.
|
|
621
|
+
function _cleanup() {
|
|
622
|
+
for (var i = 0; i < _disposers.length; i++) {
|
|
623
|
+
try { _disposers[i](); } catch (e) { /* swallow */ }
|
|
624
|
+
}
|
|
625
|
+
_disposers.length = 0;
|
|
626
|
+
}
|
|
627
|
+
if (!window.__stxBindingsCleanups) window.__stxBindingsCleanups = [];
|
|
628
|
+
window.__stxBindingsCleanups.push(_cleanup);
|
|
629
|
+
if (!window.__stxCleanupBindings) {
|
|
630
|
+
window.__stxCleanupBindings = function() {
|
|
631
|
+
var fns = window.__stxBindingsCleanups || [];
|
|
632
|
+
for (var i = 0; i < fns.length; i++) {
|
|
633
|
+
try { fns[i](); } catch (e) { /* swallow */ }
|
|
634
|
+
}
|
|
635
|
+
window.__stxBindingsCleanups = [];
|
|
636
|
+
};
|
|
637
|
+
window.addEventListener('popstate', window.__stxCleanupBindings);
|
|
638
|
+
window.addEventListener('beforeunload', window.__stxCleanupBindings);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
// Start when DOM is ready
|
|
643
|
+
if (document.readyState === 'loading') {
|
|
644
|
+
document.addEventListener('DOMContentLoaded', initBindings);
|
|
645
|
+
}
|
|
646
|
+
else {
|
|
647
|
+
initBindings();
|
|
648
|
+
}
|
|
649
|
+
})();
|
|
650
|
+
</script>
|
|
651
|
+
`,Y}function G7($){let{html:Z,bindings:X,stores:Y}=d8($);if(X.length===0)return $;let J=m8(X,Y),Q=Z.lastIndexOf("</body>");if(Q!==-1)return Z.slice(0,Q)+J+Z.slice(Q);return Z+J}function q7($){let Z=$.analytics;if(!Z?.enabled)return"";switch(Z.driver){case"fathom":return l8(Z);case"google-analytics":return c8(Z);case"plausible":return p8(Z);case"self-hosted":return i8(Z);case"custom":return n8(Z);default:return""}}function l8($){let Z=$.fathom;if(!Z?.siteId)return"";let X=Z.scriptUrl||"https://cdn.usefathom.com/script.js",Y=Z.defer!==!1?" defer":"",J=[`data-site="${y0(Z.siteId)}"`];if(Z.honorDnt)J.push('data-honor-dnt="true"');if(Z.spa)J.push('data-spa="auto"');if(Z.canonical)J.push(`data-canonical="${y0(Z.canonical)}"`);if(Z.auto===!1)J.push('data-auto="false"');return`
|
|
652
|
+
<!-- Fathom Analytics -->
|
|
653
|
+
<script src="${y0(X)}" ${J.join(" ")}${Y}></script>
|
|
654
|
+
`}function c8($){let Z=$.googleAnalytics;if(!Z?.measurementId)return"";let X=y0(Z.measurementId),Y=Z.debug?`gtag('config', '${X}', { 'debug_mode': true });`:"";return`
|
|
655
|
+
<!-- Google Analytics -->
|
|
656
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id=${X}"></script>
|
|
657
|
+
<script>
|
|
658
|
+
window.dataLayer = window.dataLayer || [];
|
|
659
|
+
function gtag(){dataLayer.push(arguments);}
|
|
660
|
+
gtag('js', new Date());
|
|
661
|
+
gtag('config', '${X}');
|
|
662
|
+
${Y}
|
|
663
|
+
</script>
|
|
664
|
+
`}function p8($){let Z=$.plausible;if(!Z?.domain)return"";let X=Z.scriptUrl||"https://plausible.io/js/script.js",Y=[`data-domain="${y0(Z.domain)}"`],J=X,Q=[];if(Z.trackLocalhost)Q.push("local");if(Z.hashMode)Q.push("hash");if(Q.length>0&&X==="https://plausible.io/js/script.js")J=`https://plausible.io/js/script.${Q.join(".")}.js`;return`
|
|
665
|
+
<!-- Plausible Analytics -->
|
|
666
|
+
<script defer data-domain="${y0(Z.domain)}" src="${y0(J)}"></script>
|
|
667
|
+
`}function i8($){let Z=$.selfHosted;if(!Z?.siteId||!Z?.apiEndpoint)return"";let X=y0(Z.siteId),Y=y0(Z.apiEndpoint),J=Z.honorDnt?'if(n.doNotTrack==="1")return;':"",Q=Z.trackHashChanges?"w.addEventListener('hashchange',pv);":"",G=Z.trackOutboundLinks?`
|
|
668
|
+
d.addEventListener('click',function(e){
|
|
669
|
+
var a=e.target.closest('a');
|
|
670
|
+
if(a&&a.hostname!==location.hostname){
|
|
671
|
+
t('outbound',{url:a.href});
|
|
672
|
+
}
|
|
673
|
+
});`:"";return`
|
|
674
|
+
<!-- Self-Hosted Analytics -->
|
|
675
|
+
<script data-site="${X}" data-api="${Y}" defer>
|
|
676
|
+
(function(){
|
|
677
|
+
'use strict';
|
|
678
|
+
var d=document,w=window,n=navigator,s=d.currentScript;
|
|
679
|
+
var site=s.dataset.site,api=s.dataset.api;
|
|
680
|
+
${J}
|
|
681
|
+
var q=[],sid=Math.random().toString(36).slice(2);
|
|
682
|
+
function t(e,p){
|
|
683
|
+
var x=new XMLHttpRequest();
|
|
684
|
+
x.open('POST',api+'/collect',true);
|
|
685
|
+
x.setRequestHeader('Content-Type','application/json');
|
|
686
|
+
x.send(JSON.stringify({
|
|
687
|
+
s:site,sid:sid,e:e,p:p||{},
|
|
688
|
+
u:location.href,r:d.referrer,t:d.title,
|
|
689
|
+
sw:screen.width,sh:screen.height
|
|
690
|
+
}));
|
|
691
|
+
}
|
|
692
|
+
function pv(){t('pageview');}
|
|
693
|
+
${Q}
|
|
694
|
+
${G}
|
|
695
|
+
if(d.readyState==='complete')pv();
|
|
696
|
+
else w.addEventListener('load',pv);
|
|
697
|
+
w.stxAnalytics={track:function(n,v){t('event',{name:n,value:v});}};
|
|
698
|
+
})();
|
|
699
|
+
</script>
|
|
700
|
+
`}function n8($){let Z=$.custom;if(!Z)return"";if(Z.inlineScript)return`
|
|
701
|
+
<!-- Custom Analytics -->
|
|
702
|
+
<script>
|
|
703
|
+
${Z.inlineScript}
|
|
704
|
+
</script>
|
|
705
|
+
`;if(!Z.scriptUrl)return"";let X=[];if(Z.scriptId)X.push(`id="${y0(Z.scriptId)}"`);if(Z.attributes)for(let[J,Q]of Object.entries(Z.attributes))X.push(`${y0(J)}="${y0(Q)}"`);return`
|
|
706
|
+
<!-- Custom Analytics -->
|
|
707
|
+
<script${X.length>0?` ${X.join(" ")}`:""} src="${y0(Z.scriptUrl)}" defer></script>
|
|
708
|
+
`}function U7($,Z){let X=q7(Z);if(!X)return $;if(!$.includes("</head>")){let Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+X+$.slice(Y);return $+X}return $.replace("</head>",`${X}</head>`)}function y0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var hq={name:"analytics",hasEndTag:!1,handler:async($,Z,X,Y)=>{let J=X.__stx_config||{};return q7(J)}};var s8={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 W7($){let Z=$.heatmap;if(!Z?.enabled)return"";let X={...s8,...Z};return`
|
|
709
|
+
<!-- stx Heatmap - Privacy-Compliant Tracking -->
|
|
710
|
+
<script>
|
|
711
|
+
(function() {
|
|
712
|
+
'use strict';
|
|
713
|
+
|
|
714
|
+
// Configuration
|
|
715
|
+
var config = ${JSON.stringify({trackMouse:X.trackMouse,trackClicks:X.trackClicks,trackScroll:X.trackScroll,samplingRate:X.samplingRate,honorDnt:X.honorDnt,endpoint:X.endpoint,batchSize:X.batchSize,maxDataPoints:X.maxDataPoints,sessionTimeout:X.sessionTimeout,persistData:X.persistData,storagePrefix:X.storagePrefix,captureAttributes:X.captureAttributes,ignoreSelectors:X.ignoreSelectors,zones:X.zones,debugOverlay:X.debugOverlay,minViewportWidth:X.minViewportWidth,maxViewportWidth:X.maxViewportWidth})};
|
|
716
|
+
|
|
717
|
+
// Check Do Not Track
|
|
718
|
+
if (config.honorDnt && navigator.doNotTrack === '1') {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// Check viewport constraints
|
|
723
|
+
var vw = window.innerWidth;
|
|
724
|
+
if (config.minViewportWidth && vw < config.minViewportWidth) return;
|
|
725
|
+
if (config.maxViewportWidth && vw > config.maxViewportWidth) return;
|
|
726
|
+
|
|
727
|
+
// Session management (anonymous, no cookies)
|
|
728
|
+
var session = {
|
|
729
|
+
sid: Math.random().toString(36).slice(2) + Date.now().toString(36),
|
|
730
|
+
page: location.pathname,
|
|
731
|
+
vw: window.innerWidth,
|
|
732
|
+
vh: window.innerHeight,
|
|
733
|
+
points: [],
|
|
734
|
+
started: Date.now(),
|
|
735
|
+
lastActivity: Date.now()
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
// Throttle helper
|
|
739
|
+
var lastMove = 0;
|
|
740
|
+
function throttle(fn, wait) {
|
|
741
|
+
return function() {
|
|
742
|
+
var now = Date.now();
|
|
743
|
+
if (now - lastMove >= wait) {
|
|
744
|
+
lastMove = now;
|
|
745
|
+
fn.apply(this, arguments);
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// Get relative coordinates (percentage)
|
|
751
|
+
function getRelativeCoords(e) {
|
|
752
|
+
return {
|
|
753
|
+
x: Math.round((e.clientX / window.innerWidth) * 10000) / 100,
|
|
754
|
+
y: Math.round((e.clientY / window.innerHeight) * 10000) / 100
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
// Check if element should be ignored
|
|
759
|
+
function shouldIgnore(el) {
|
|
760
|
+
if (!el || !config.ignoreSelectors) return false;
|
|
761
|
+
for (var i = 0; i < config.ignoreSelectors.length; i++) {
|
|
762
|
+
if (el.matches && el.matches(config.ignoreSelectors[i])) return true;
|
|
763
|
+
if (el.closest && el.closest(config.ignoreSelectors[i])) return true;
|
|
764
|
+
}
|
|
765
|
+
return false;
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// Get element selector (simplified, no IDs to preserve privacy)
|
|
769
|
+
function getSelector(el) {
|
|
770
|
+
if (!el || !el.tagName) return null;
|
|
771
|
+
var tag = el.tagName.toLowerCase();
|
|
772
|
+
var classes = el.className && typeof el.className === 'string'
|
|
773
|
+
? '.' + el.className.trim().split(/\\s+/).slice(0, 2).join('.')
|
|
774
|
+
: '';
|
|
775
|
+
return tag + classes;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// Find zone for element
|
|
779
|
+
function findZone(el) {
|
|
780
|
+
if (!config.zones || !el) return null;
|
|
781
|
+
for (var i = 0; i < config.zones.length; i++) {
|
|
782
|
+
var zone = config.zones[i];
|
|
783
|
+
if (el.closest && el.closest(zone.selector)) {
|
|
784
|
+
return zone.id;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
return null;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// Capture custom attributes
|
|
791
|
+
function captureAttributes(el) {
|
|
792
|
+
if (!config.captureAttributes || !el) return null;
|
|
793
|
+
var attrs = {};
|
|
794
|
+
var hasAttrs = false;
|
|
795
|
+
for (var i = 0; i < config.captureAttributes.length; i++) {
|
|
796
|
+
var attr = config.captureAttributes[i];
|
|
797
|
+
var value = el.getAttribute && el.getAttribute(attr);
|
|
798
|
+
if (value) {
|
|
799
|
+
attrs[attr] = value;
|
|
800
|
+
hasAttrs = true;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
return hasAttrs ? attrs : null;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// Add data point
|
|
807
|
+
function addPoint(point) {
|
|
808
|
+
session.lastActivity = Date.now();
|
|
809
|
+
if (session.points.length >= config.maxDataPoints) {
|
|
810
|
+
session.points.shift();
|
|
811
|
+
}
|
|
812
|
+
session.points.push(point);
|
|
813
|
+
|
|
814
|
+
// Send batch if threshold reached
|
|
815
|
+
if (config.endpoint && session.points.length >= config.batchSize) {
|
|
816
|
+
sendData();
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// Send data to endpoint
|
|
821
|
+
function sendData() {
|
|
822
|
+
if (!config.endpoint || session.points.length === 0) return;
|
|
823
|
+
|
|
824
|
+
var data = {
|
|
825
|
+
sid: session.sid,
|
|
826
|
+
page: session.page,
|
|
827
|
+
vw: session.vw,
|
|
828
|
+
vh: session.vh,
|
|
829
|
+
points: session.points.splice(0, config.batchSize)
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
// Use sendBeacon for reliability
|
|
833
|
+
if (navigator.sendBeacon) {
|
|
834
|
+
navigator.sendBeacon(config.endpoint, JSON.stringify(data));
|
|
835
|
+
}
|
|
836
|
+
else {
|
|
837
|
+
var xhr = new XMLHttpRequest();
|
|
838
|
+
xhr.open('POST', config.endpoint, true);
|
|
839
|
+
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
840
|
+
xhr.send(JSON.stringify(data));
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// Mouse move handler
|
|
845
|
+
if (config.trackMouse) {
|
|
846
|
+
document.addEventListener('mousemove', throttle(function(e) {
|
|
847
|
+
if (shouldIgnore(e.target)) return;
|
|
848
|
+
var coords = getRelativeCoords(e);
|
|
849
|
+
addPoint({
|
|
850
|
+
x: coords.x,
|
|
851
|
+
y: coords.y,
|
|
852
|
+
type: 'move',
|
|
853
|
+
t: Date.now(),
|
|
854
|
+
zone: findZone(e.target)
|
|
855
|
+
});
|
|
856
|
+
}, config.samplingRate), { passive: true });
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// Click handler
|
|
860
|
+
if (config.trackClicks) {
|
|
861
|
+
document.addEventListener('click', function(e) {
|
|
862
|
+
if (shouldIgnore(e.target)) return;
|
|
863
|
+
var coords = getRelativeCoords(e);
|
|
864
|
+
var point = {
|
|
865
|
+
x: coords.x,
|
|
866
|
+
y: coords.y,
|
|
867
|
+
type: 'click',
|
|
868
|
+
t: Date.now(),
|
|
869
|
+
el: getSelector(e.target),
|
|
870
|
+
zone: findZone(e.target)
|
|
871
|
+
};
|
|
872
|
+
var attrs = captureAttributes(e.target);
|
|
873
|
+
if (attrs) point.attrs = attrs;
|
|
874
|
+
addPoint(point);
|
|
875
|
+
}, { passive: true });
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
// Scroll handler
|
|
879
|
+
if (config.trackScroll) {
|
|
880
|
+
var lastScrollDepth = 0;
|
|
881
|
+
document.addEventListener('scroll', throttle(function() {
|
|
882
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
883
|
+
var scrollHeight = document.documentElement.scrollHeight - window.innerHeight;
|
|
884
|
+
var depth = scrollHeight > 0 ? Math.round((scrollTop / scrollHeight) * 100) : 0;
|
|
885
|
+
|
|
886
|
+
// Only track significant scroll changes (every 10%)
|
|
887
|
+
if (Math.abs(depth - lastScrollDepth) >= 10) {
|
|
888
|
+
lastScrollDepth = depth;
|
|
889
|
+
addPoint({
|
|
890
|
+
x: 50,
|
|
891
|
+
y: depth,
|
|
892
|
+
type: 'scroll',
|
|
893
|
+
t: Date.now(),
|
|
894
|
+
depth: depth
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
}, config.samplingRate * 2), { passive: true });
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// Send remaining data on page unload
|
|
901
|
+
window.addEventListener('beforeunload', sendData);
|
|
902
|
+
window.addEventListener('visibilitychange', function() {
|
|
903
|
+
if (document.visibilityState === 'hidden') {
|
|
904
|
+
sendData();
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
// Persist data to localStorage if enabled
|
|
909
|
+
if (config.persistData) {
|
|
910
|
+
var storageKey = config.storagePrefix + '_' + session.page.replace(/\\//g, '_');
|
|
911
|
+
|
|
912
|
+
// Load existing data
|
|
913
|
+
try {
|
|
914
|
+
var stored = localStorage.getItem(storageKey);
|
|
915
|
+
if (stored) {
|
|
916
|
+
var parsed = JSON.parse(stored);
|
|
917
|
+
if (Date.now() - parsed.lastActivity < config.sessionTimeout * 60000) {
|
|
918
|
+
session.points = parsed.points || [];
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
catch (e) {}
|
|
923
|
+
|
|
924
|
+
// Save periodically
|
|
925
|
+
setInterval(function() {
|
|
926
|
+
try {
|
|
927
|
+
localStorage.setItem(storageKey, JSON.stringify({
|
|
928
|
+
points: session.points,
|
|
929
|
+
lastActivity: session.lastActivity
|
|
930
|
+
}));
|
|
931
|
+
}
|
|
932
|
+
catch (e) {}
|
|
933
|
+
}, 5000);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// Debug overlay
|
|
937
|
+
if (config.debugOverlay) {
|
|
938
|
+
var overlay = document.createElement('div');
|
|
939
|
+
overlay.id = 'stx-heatmap-overlay';
|
|
940
|
+
overlay.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:999999;';
|
|
941
|
+
document.body.appendChild(overlay);
|
|
942
|
+
|
|
943
|
+
var canvas = document.createElement('canvas');
|
|
944
|
+
canvas.width = window.innerWidth;
|
|
945
|
+
canvas.height = window.innerHeight;
|
|
946
|
+
canvas.style.cssText = 'width:100%;height:100%;';
|
|
947
|
+
overlay.appendChild(canvas);
|
|
948
|
+
var ctx = canvas.getContext('2d');
|
|
949
|
+
|
|
950
|
+
function renderOverlay() {
|
|
951
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
952
|
+
session.points.forEach(function(p) {
|
|
953
|
+
var x = (p.x / 100) * canvas.width;
|
|
954
|
+
var y = (p.y / 100) * canvas.height;
|
|
955
|
+
ctx.beginPath();
|
|
956
|
+
ctx.arc(x, y, p.type === 'click' ? 8 : 3, 0, Math.PI * 2);
|
|
957
|
+
ctx.fillStyle = p.type === 'click' ? 'rgba(255,0,0,0.5)' : 'rgba(0,0,255,0.2)';
|
|
958
|
+
ctx.fill();
|
|
959
|
+
});
|
|
960
|
+
requestAnimationFrame(renderOverlay);
|
|
961
|
+
}
|
|
962
|
+
renderOverlay();
|
|
963
|
+
|
|
964
|
+
window.addEventListener('resize', function() {
|
|
965
|
+
canvas.width = window.innerWidth;
|
|
966
|
+
canvas.height = window.innerHeight;
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
// Expose API for manual tracking and data export
|
|
971
|
+
window.stxHeatmap = {
|
|
972
|
+
// Get current session data
|
|
973
|
+
getData: function() {
|
|
974
|
+
return {
|
|
975
|
+
sid: session.sid,
|
|
976
|
+
page: session.page,
|
|
977
|
+
vw: session.vw,
|
|
978
|
+
vh: session.vh,
|
|
979
|
+
points: session.points.slice(),
|
|
980
|
+
started: session.started,
|
|
981
|
+
lastActivity: session.lastActivity
|
|
982
|
+
};
|
|
983
|
+
},
|
|
984
|
+
// Export data as JSON
|
|
985
|
+
exportJSON: function() {
|
|
986
|
+
return JSON.stringify(this.getData(), null, 2);
|
|
987
|
+
},
|
|
988
|
+
// Export data as CSV
|
|
989
|
+
exportCSV: function() {
|
|
990
|
+
var data = this.getData();
|
|
991
|
+
var lines = ['x,y,type,timestamp,element,zone,depth'];
|
|
992
|
+
data.points.forEach(function(p) {
|
|
993
|
+
lines.push([p.x, p.y, p.type, p.t, p.el || '', p.zone || '', p.depth || ''].join(','));
|
|
994
|
+
});
|
|
995
|
+
return lines.join('\\n');
|
|
996
|
+
},
|
|
997
|
+
// Manual data send
|
|
998
|
+
flush: function() {
|
|
999
|
+
sendData();
|
|
1000
|
+
},
|
|
1001
|
+
// Clear data
|
|
1002
|
+
clear: function() {
|
|
1003
|
+
session.points = [];
|
|
1004
|
+
if (config.persistData) {
|
|
1005
|
+
var storageKey = config.storagePrefix + '_' + session.page.replace(/\\//g, '_');
|
|
1006
|
+
try { localStorage.removeItem(storageKey); }
|
|
1007
|
+
catch (e) {}
|
|
1008
|
+
}
|
|
1009
|
+
},
|
|
1010
|
+
// Add custom event
|
|
1011
|
+
track: function(type, data) {
|
|
1012
|
+
addPoint({
|
|
1013
|
+
x: data && data.x || 0,
|
|
1014
|
+
y: data && data.y || 0,
|
|
1015
|
+
type: type,
|
|
1016
|
+
t: Date.now(),
|
|
1017
|
+
attrs: data
|
|
1018
|
+
});
|
|
1019
|
+
},
|
|
1020
|
+
// Generate heatmap visualization
|
|
1021
|
+
visualize: function(options) {
|
|
1022
|
+
options = options || {};
|
|
1023
|
+
var data = this.getData();
|
|
1024
|
+
var width = options.width || data.vw;
|
|
1025
|
+
var height = options.height || data.vh;
|
|
1026
|
+
var radius = options.radius || 20;
|
|
1027
|
+
var blur = options.blur || 15;
|
|
1028
|
+
var maxOpacity = options.maxOpacity || 0.6;
|
|
1029
|
+
|
|
1030
|
+
var canvas = document.createElement('canvas');
|
|
1031
|
+
canvas.width = width;
|
|
1032
|
+
canvas.height = height;
|
|
1033
|
+
var ctx = canvas.getContext('2d');
|
|
1034
|
+
|
|
1035
|
+
// Create heat points
|
|
1036
|
+
data.points.forEach(function(p) {
|
|
1037
|
+
var x = (p.x / 100) * width;
|
|
1038
|
+
var y = (p.y / 100) * height;
|
|
1039
|
+
var intensity = p.type === 'click' ? 1 : 0.3;
|
|
1040
|
+
|
|
1041
|
+
var gradient = ctx.createRadialGradient(x, y, 0, x, y, radius);
|
|
1042
|
+
gradient.addColorStop(0, 'rgba(255,0,0,' + intensity + ')');
|
|
1043
|
+
gradient.addColorStop(1, 'rgba(255,0,0,0)');
|
|
1044
|
+
ctx.fillStyle = gradient;
|
|
1045
|
+
ctx.fillRect(x - radius, y - radius, radius * 2, radius * 2);
|
|
1046
|
+
});
|
|
1047
|
+
|
|
1048
|
+
// Apply blur
|
|
1049
|
+
ctx.filter = 'blur(' + blur + 'px)';
|
|
1050
|
+
ctx.drawImage(canvas, 0, 0);
|
|
1051
|
+
ctx.filter = 'none';
|
|
1052
|
+
|
|
1053
|
+
// Colorize
|
|
1054
|
+
var imageData = ctx.getImageData(0, 0, width, height);
|
|
1055
|
+
var pixels = imageData.data;
|
|
1056
|
+
for (var i = 0; i < pixels.length; i += 4) {
|
|
1057
|
+
var alpha = pixels[i + 3];
|
|
1058
|
+
if (alpha > 0) {
|
|
1059
|
+
var ratio = alpha / 255;
|
|
1060
|
+
// Gradient: blue -> cyan -> green -> yellow -> red
|
|
1061
|
+
if (ratio < 0.25) {
|
|
1062
|
+
pixels[i] = 0;
|
|
1063
|
+
pixels[i + 1] = Math.round(ratio * 4 * 255);
|
|
1064
|
+
pixels[i + 2] = 255;
|
|
1065
|
+
}
|
|
1066
|
+
else if (ratio < 0.5) {
|
|
1067
|
+
pixels[i] = 0;
|
|
1068
|
+
pixels[i + 1] = 255;
|
|
1069
|
+
pixels[i + 2] = Math.round((1 - (ratio - 0.25) * 4) * 255);
|
|
1070
|
+
}
|
|
1071
|
+
else if (ratio < 0.75) {
|
|
1072
|
+
pixels[i] = Math.round((ratio - 0.5) * 4 * 255);
|
|
1073
|
+
pixels[i + 1] = 255;
|
|
1074
|
+
pixels[i + 2] = 0;
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
pixels[i] = 255;
|
|
1078
|
+
pixels[i + 1] = Math.round((1 - (ratio - 0.75) * 4) * 255);
|
|
1079
|
+
pixels[i + 2] = 0;
|
|
1080
|
+
}
|
|
1081
|
+
pixels[i + 3] = Math.round(alpha * maxOpacity);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
ctx.putImageData(imageData, 0, 0);
|
|
1085
|
+
|
|
1086
|
+
return canvas;
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
})();
|
|
1090
|
+
</script>
|
|
1091
|
+
`}function K7($,Z){let X=W7(Z);if(!X)return $;let Y=$.lastIndexOf("</body>");if(Y!==-1)return $.slice(0,Y)+X+$.slice(Y);return $+X}var z7={name:"heatmap",hasEndTag:!1,description:"Inject privacy-compliant heatmap tracking script",handler:async($,Z,X,Y)=>{let J=X.__stx_config||{};if(Z.length>0){let Q=o8(Z.join(" "));J.heatmap={...J.heatmap,...Q,enabled:!0}}return W7(J)}};function o8($){let Z={},X=$.match(/(\w+)=["']?([^"'\s]+)["']?/g)||[];for(let Y of X){let[J,Q]=Y.split("="),G=Q?.replace(/["']/g,"");switch(J){case"endpoint":Z.endpoint=G;break;case"samplingRate":Z.samplingRate=Number.parseInt(G,10);break;case"batchSize":Z.batchSize=Number.parseInt(G,10);break;case"trackMouse":Z.trackMouse=G==="true";break;case"trackClicks":Z.trackClicks=G==="true";break;case"trackScroll":Z.trackScroll=G==="true";break;case"honorDnt":Z.honorDnt=G==="true";break;case"debugOverlay":Z.debugOverlay=G==="true";break}}return Z}class H7{sessions=new Map;addSession($){let Z=this.sessions.get($.sid);if(Z)Z.points.push(...$.points),Z.lastActivity=Math.max(Z.lastActivity,$.lastActivity);else this.sessions.set($.sid,$)}getPageData($){let Z=[];for(let X of this.sessions.values())if(X.page===$)Z.push(...X.points);return Z}getClickData($){return this.getPageData($).filter((Z)=>Z.type==="click")}getMovementData($){return this.getPageData($).filter((Z)=>Z.type==="move")}getScrollData($){let Z=this.getPageData($).filter((Y)=>Y.type==="scroll"),X=new Map;for(let Y of Z)if(Y.depth!==void 0)X.set(Y.depth,(X.get(Y.depth)||0)+1);return Array.from(X.entries()).map(([Y,J])=>({depth:Y,count:J})).sort((Y,J)=>Y.depth-J.depth)}getZoneStats($){let Z=new Map,X=this.getPageData($);for(let Y of X)if(Y.zone){let J=Z.get(Y.zone)||{clicks:0,hovers:0};if(Y.type==="click")J.clicks++;else if(Y.type==="move")J.hovers++;Z.set(Y.zone,J)}return Z}generateGridData($,Z=20){let X=this.getPageData($),Y=[];for(let Q=0;Q<Z;Q++){Y[Q]=[];for(let G=0;G<Z;G++)Y[Q][G]=0}for(let Q of X){let G=Math.min(Math.floor(Q.x/100*Z),Z-1),q=Math.min(Math.floor(Q.y/100*Z),Z-1);Y[q][G]+=Q.type==="click"?3:1}let J=0;for(let Q of Y)for(let G of Q)J=Math.max(J,G);return Y.map((Q,G)=>Q.map((q,U)=>({x:U,y:G,intensity:J>0?q/J:0})))}exportJSON(){return JSON.stringify({sessions:Array.from(this.sessions.values()),exportedAt:new Date().toISOString()},null,2)}clear(){this.sessions.clear()}get sessionCount(){return this.sessions.size}get totalPoints(){let $=0;for(let Z of this.sessions.values())$+=Z.points.length;return $}}function dq(){return new H7}var r8;((G)=>{G.Fade="fade";G.Slide="slide";G.Scale="scale";G.Flip="flip";G.Rotate="rotate";G.Custom="custom"})(r8||={});var a8;((Y)=>{Y.In="in";Y.Out="out";Y.Both="both"})(a8||={});var t8;((G)=>{G.Linear="linear";G.Ease="ease";G.EaseIn="ease-in";G.EaseOut="ease-out";G.EaseInOut="ease-in-out";G.Spring="spring"})(t8||={});var r0={duration:300,delay:0,ease:"ease",direction:"both"};function e8($,Z={}){let{duration:X,delay:Y,ease:J,direction:Q,custom:G}={...r0,...Z};if($==="custom"&&G)return G;switch($){case"fade":return`${Q==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":Q==="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);"}
|
|
1092
|
+
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
|
1093
|
+
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }`;case"slide":return`${Q==="in"?"transform: translateY(20px); opacity: 0; animation: slideIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":Q==="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);"}
|
|
1094
|
+
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
|
|
1095
|
+
@keyframes slideOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(20px); opacity: 0; } }`;case"scale":return`${Q==="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;":Q==="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);"}
|
|
1096
|
+
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
|
|
1097
|
+
@keyframes scaleOut { from { transform: scale(1); opacity: 1; } to { transform: scale(0.95); opacity: 0; } }`;case"flip":return`${Q==="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;":Q==="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);"}
|
|
1098
|
+
@keyframes flipIn { from { transform: perspective(400px) rotateX(-90deg); opacity: 0; } to { transform: perspective(400px) rotateX(0); opacity: 1; } }
|
|
1099
|
+
@keyframes flipOut { from { transform: perspective(400px) rotateX(0); opacity: 1; } to { transform: perspective(400px) rotateX(90deg); opacity: 0; } }`;case"rotate":return`${Q==="in"?"transform: rotate(-90deg); opacity: 0; animation: rotateIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":Q==="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);"}
|
|
1100
|
+
@keyframes rotateIn { from { transform: rotate(-90deg); opacity: 0; } to { transform: rotate(0); opacity: 1; } }
|
|
1101
|
+
@keyframes rotateOut { from { transform: rotate(0); opacity: 1; } to { transform: rotate(90deg); opacity: 0; } }`;default:return""}}function $Z(){return`
|
|
1102
|
+
<script data-stx-scoped data-stx-run="once">
|
|
1103
|
+
// Motion preferences handling
|
|
1104
|
+
(function() {
|
|
1105
|
+
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
1106
|
+
|
|
1107
|
+
if (prefersReducedMotion) {
|
|
1108
|
+
// Apply reduced motion settings
|
|
1109
|
+
document.documentElement.style.setProperty('--stx-transition-duration', '0ms');
|
|
1110
|
+
document.documentElement.setAttribute('data-reduced-motion', 'true');
|
|
1111
|
+
}
|
|
1112
|
+
else {
|
|
1113
|
+
document.documentElement.setAttribute('data-reduced-motion', 'false');
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
// Listen for changes in preference
|
|
1117
|
+
window.matchMedia('(prefers-reduced-motion: reduce)').addEventListener('change', (e) => {
|
|
1118
|
+
if (e.matches) {
|
|
1119
|
+
document.documentElement.style.setProperty('--stx-transition-duration', '0ms');
|
|
1120
|
+
document.documentElement.setAttribute('data-reduced-motion', 'true');
|
|
1121
|
+
}
|
|
1122
|
+
else {
|
|
1123
|
+
document.documentElement.style.setProperty('--stx-transition-duration', '');
|
|
1124
|
+
document.documentElement.setAttribute('data-reduced-motion', 'false');
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
})();
|
|
1128
|
+
</script>
|
|
1129
|
+
`}function ZZ($){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((X)=>X.test($))}function XZ($=0.1,Z="0px"){return`
|
|
1130
|
+
<script data-stx-scoped data-stx-run="always">
|
|
1131
|
+
// Intersection Observer for scroll animations
|
|
1132
|
+
(function() {
|
|
1133
|
+
const initObserver = () => {
|
|
1134
|
+
if (!('IntersectionObserver' in window)) {
|
|
1135
|
+
// For browsers that don't support IntersectionObserver, show all elements immediately
|
|
1136
|
+
const elements = document.querySelectorAll('.stx-observe');
|
|
1137
|
+
elements.forEach(el => el.classList.remove('stx-out'));
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
// Create the observer
|
|
1142
|
+
const options = {
|
|
1143
|
+
root: null, // Use viewport
|
|
1144
|
+
rootMargin: '${Z}',
|
|
1145
|
+
threshold: ${$}
|
|
1146
|
+
};
|
|
1147
|
+
|
|
1148
|
+
const observer = new IntersectionObserver((entries) => {
|
|
1149
|
+
entries.forEach(entry => {
|
|
1150
|
+
if (entry.isIntersecting) {
|
|
1151
|
+
entry.target.classList.remove('stx-out');
|
|
1152
|
+
// Stop observing after animation is triggered
|
|
1153
|
+
observer.unobserve(entry.target);
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1156
|
+
}, options);
|
|
1157
|
+
|
|
1158
|
+
// Start observing elements
|
|
1159
|
+
const elements = document.querySelectorAll('.stx-observe');
|
|
1160
|
+
elements.forEach(el => observer.observe(el));
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
// Initialize observer when DOM is ready
|
|
1164
|
+
if (document.readyState === 'loading') {
|
|
1165
|
+
document.addEventListener('DOMContentLoaded', initObserver);
|
|
1166
|
+
}
|
|
1167
|
+
else {
|
|
1168
|
+
initObserver();
|
|
1169
|
+
}
|
|
1170
|
+
})();
|
|
1171
|
+
</script>
|
|
1172
|
+
`}function YZ(){return`
|
|
1173
|
+
<style id="stx-animation-base">
|
|
1174
|
+
:root {
|
|
1175
|
+
--stx-transition-duration: 300ms;
|
|
1176
|
+
--stx-transition-delay: 0ms;
|
|
1177
|
+
--stx-transition-ease: ease;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1181
|
+
:root {
|
|
1182
|
+
--stx-transition-duration: 0ms;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
[data-animate="false"] * {
|
|
1187
|
+
--stx-transition-duration: 0ms !important;
|
|
1188
|
+
animation-duration: 0ms !important;
|
|
1189
|
+
transition-duration: 0ms !important;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
/* Base transition classes */
|
|
1193
|
+
.stx-transition {
|
|
1194
|
+
transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
1195
|
+
transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1196
|
+
backface-visibility: hidden; /* Improve animation performance */
|
|
1197
|
+
transform-style: preserve-3d; /* Better 3D transforms */
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
/* Fade animations */
|
|
1201
|
+
.stx-fade {
|
|
1202
|
+
transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
.stx-fade.stx-out {
|
|
1206
|
+
opacity: 0 !important;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/* Scale animations */
|
|
1210
|
+
.stx-scale {
|
|
1211
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
1212
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
.stx-scale.stx-out {
|
|
1216
|
+
transform: scale(0.85) !important;
|
|
1217
|
+
opacity: 0 !important;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
/* Flip animations */
|
|
1221
|
+
.stx-flip {
|
|
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
|
+
perspective: 600px;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
.stx-flip.stx-out {
|
|
1228
|
+
transform: perspective(600px) rotateX(-90deg) !important;
|
|
1229
|
+
opacity: 0 !important;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
/* Rotate animations */
|
|
1233
|
+
.stx-rotate {
|
|
1234
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
1235
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
.stx-rotate.stx-out {
|
|
1239
|
+
transform: rotate(-90deg) !important;
|
|
1240
|
+
opacity: 0 !important;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/* Direction-based animations */
|
|
1244
|
+
.stx-from-left, .stx-from-right, .stx-from-top, .stx-from-bottom {
|
|
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-from-left.stx-out {
|
|
1250
|
+
transform: translateX(-30px) !important;
|
|
1251
|
+
opacity: 0 !important;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
.stx-from-right.stx-out {
|
|
1255
|
+
transform: translateX(30px) !important;
|
|
1256
|
+
opacity: 0 !important;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
.stx-from-top.stx-out {
|
|
1260
|
+
transform: translateY(-30px) !important;
|
|
1261
|
+
opacity: 0 !important;
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
.stx-from-bottom.stx-out {
|
|
1265
|
+
transform: translateY(30px) !important;
|
|
1266
|
+
opacity: 0 !important;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
/* Generic slide animations */
|
|
1270
|
+
.stx-slide {
|
|
1271
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
1272
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
.stx-slide.stx-out {
|
|
1276
|
+
transform: translateY(30px) !important;
|
|
1277
|
+
opacity: 0 !important;
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
/* Scroll animation observer class */
|
|
1281
|
+
.stx-observe {
|
|
1282
|
+
will-change: opacity, transform;
|
|
1283
|
+
transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
1284
|
+
transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
1285
|
+
}
|
|
1286
|
+
</style>
|
|
1287
|
+
`}function JZ($,Z,X={}){let{staggerDelay:Y=50,sequence:J=!1}=X;return`
|
|
1288
|
+
<script data-stx-scoped data-stx-run="always">
|
|
1289
|
+
// Animation Group: ${$}
|
|
1290
|
+
(function() {
|
|
1291
|
+
const elements = ${JSON.stringify(Z)};
|
|
1292
|
+
const staggerDelay = ${Y};
|
|
1293
|
+
const sequence = ${J};
|
|
1294
|
+
|
|
1295
|
+
function animateGroup() {
|
|
1296
|
+
elements.forEach((selector, index) => {
|
|
1297
|
+
const element = document.querySelector(selector);
|
|
1298
|
+
if (!element) return;
|
|
1299
|
+
|
|
1300
|
+
const delay = sequence ? index * staggerDelay : 0;
|
|
1301
|
+
element.style.setProperty('--stx-transition-delay', delay + 'ms');
|
|
1302
|
+
|
|
1303
|
+
// For elements using animation keyframes
|
|
1304
|
+
element.style.animationDelay = delay + 'ms';
|
|
1305
|
+
|
|
1306
|
+
// If the element is initially hidden, show it
|
|
1307
|
+
if (element.classList.contains('stx-out')) {
|
|
1308
|
+
setTimeout(() => {
|
|
1309
|
+
element.classList.remove('stx-out');
|
|
1310
|
+
}, 10); // Small delay to ensure styles are applied
|
|
1311
|
+
}
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
// Run when DOM is fully loaded
|
|
1316
|
+
if (document.readyState === 'loading') {
|
|
1317
|
+
document.addEventListener('DOMContentLoaded', animateGroup);
|
|
1318
|
+
}
|
|
1319
|
+
else {
|
|
1320
|
+
animateGroup();
|
|
1321
|
+
}
|
|
1322
|
+
})();
|
|
1323
|
+
</script>
|
|
1324
|
+
`}var v$={name:"transition",handler:($,Z,X,Y)=>{if(Z.length<1)return`<div class="stx-error">@transition directive requires at least a transition type</div>${$}`;let J=Z[0],Q=Z.length>1?Number.parseInt(Z[1],10)||r0.duration:r0.duration,G=Z.length>2?Z[2]||r0.ease:r0.ease,q=Z.length>3?Number.parseInt(Z[3],10)||r0.delay:r0.delay,U=Z.length>4?Z[4]||r0.direction:r0.direction,W=`stx-transition-${Math.random().toString(36).substr(2,9)}`,K=e8(J,{duration:Q,delay:q,ease:G,direction:U}),z="stx-transition",H="";if(J==="fade")H="stx-fade";else if(J==="slide")H="stx-slide";else if(J==="scale")H="stx-scale";else if(J==="flip")H="stx-flip";else if(J==="rotate")H="stx-rotate";return`<div id="${W}" class="${z} ${H} ${U==="out"?"stx-out":""}"
|
|
1325
|
+
style="--stx-transition-duration: ${Q}ms; --stx-transition-ease: ${G}; --stx-transition-delay: ${q}ms;">${$}</div>`},hasEndTag:!0,description:"Applies transition effects to an element"},f$={name:"scrollAnimate",handler:($,Z,X,Y)=>{if(Z.length<1)return`<div class="stx-error">@scrollAnimate directive requires at least an animation type</div>${$}`;let J=Z[0],Q=Z.length>1?Number.parseInt(Z[1],10)||300:300,G=Z.length>2?Z[2]||"ease":"ease",q=Z.length>3?Number.parseFloat(Z[3])||0.2:0.2,U=Z.length>4?Number.parseInt(Z[4],10)||0:0,W=`stx-scroll-${Math.random().toString(36).substr(2,9)}`,K=`--stx-transition-duration: ${Q}ms; --stx-transition-ease: ${G}; --stx-transition-delay: ${U}ms; will-change: opacity, transform;`,z="stx-transition stx-observe stx-out";if(J==="fade")z+=" stx-fade";else if(J==="slide-up"||J==="slide")z+=" stx-from-bottom";else if(J==="slide-down")z+=" stx-from-top";else if(J==="slide-left")z+=" stx-from-right";else if(J==="slide-right")z+=" stx-from-left";else if(J==="scale")z+=" stx-scale";else if(J.includes("-"))z+=` stx-${J}`;else z+=` stx-${J}`;return`<div id="${W}" class="${z}" style="${K}" data-threshold="${q}">${$}</div>`},hasEndTag:!0,description:"Applies animations that trigger when scrolled into view"},x$={name:"animationGroup",handler:($,Z,X,Y)=>{if(Z.length<2)return`<div class="stx-error">@animationGroup directive requires a group name and at least one element selector</div>${$}`;let J=Z[0],Q=Z.slice(1).map((W)=>W.startsWith("#")||W.startsWith(".")?W:`#${W}`),G=X.staggerDelay||50,q=X.sequence||!0,U=JZ(J,Q,{staggerDelay:G,sequence:q});return`${$}
|
|
1326
|
+
${U}`},hasEndTag:!1,description:"Coordinates multiple animations together as a group"},g$={name:"motion",handler:($,Z,X,Y)=>{let J=Z.length>0?Z[0].toLowerCase()==="true":!0,Q=$Z();return`<div data-animate="${J?"auto":"true"}">${$}</div>${Q}`},hasEndTag:!0,description:"Controls motion and animation preferences"};function j7($,Z,X,Y){let J=$;if(Y.animation?.enabled===!1)return J;let Q=X.includes("test")&&X.includes("animation");if(!ZZ(J)&&!Q)return J;if(!J.includes('<style id="stx-animation-base">')){let q=YZ();J=J.replace("</head>",`${q}
|
|
1327
|
+
</head>`)}if(J.includes("stx-observe")){if(!J.includes("Intersection Observer for scroll animations")){let U=XZ(),W=J.lastIndexOf("</body>");if(W!==-1)J=J.slice(0,W)+U+`
|
|
1328
|
+
`+J.slice(W)}}return J}var B7={default:{stiffness:100,damping:10,mass:1},gentle:{stiffness:120,damping:14,mass:1},wobbly:{stiffness:180,damping:12,mass:1},stiff:{stiffness:210,damping:20,mass:1},slow:{stiffness:280,damping:60,mass:1},molasses:{stiffness:280,damping:120,mass:1}};function QZ($,Z){let X=Z.map((Y)=>{let J=Y.offset!==void 0?`${Y.offset*100}%`:"from",Q=Object.entries(Y.properties).map(([G,q])=>`${G}: ${q}`).join("; ");return`${J} { ${Q} }`}).join(`
|
|
1329
|
+
`);return`@keyframes ${$} {
|
|
1330
|
+
${X}
|
|
1331
|
+
}`}var GZ={name:"keyframe",hasEndTag:!0,handler:($,Z,X,Y)=>{if(Z.length<1)return`<div class="stx-error">@keyframe requires an animation name</div>${$}`;let J=Z[0].replace(/['"`]/g,""),Q=Z[1]?Number.parseInt(Z[1],10):1000,G=Z[2]?.replace(/['"`]/g,"")||"ease",q=Z[3]||"1",U=Z[4]?.replace(/['"`]/g,"")||"normal",W=Z[5]?.replace(/['"`]/g,"")||"forwards",K=`stx-keyframe-${Math.random().toString(36).slice(2,9)}`,z=`
|
|
1332
|
+
animation-name: ${J};
|
|
1333
|
+
animation-duration: ${Q}ms;
|
|
1334
|
+
animation-timing-function: ${G};
|
|
1335
|
+
animation-iteration-count: ${q};
|
|
1336
|
+
animation-direction: ${U};
|
|
1337
|
+
animation-fill-mode: ${W};
|
|
1338
|
+
`.trim().replace(/\s+/g," ");return`<div id="${K}" style="${z}">${$}</div>`},description:"Applies a keyframe animation to an element"};function qZ($,Z,X,Y,J){return`
|
|
1339
|
+
<script data-stx-scoped data-stx-run="always">
|
|
1340
|
+
(function() {
|
|
1341
|
+
const container = document.getElementById('${$}');
|
|
1342
|
+
if (!container) return;
|
|
1343
|
+
|
|
1344
|
+
const children = container.querySelectorAll('${Z}');
|
|
1345
|
+
children.forEach((child, index) => {
|
|
1346
|
+
const delay = ${X} + (index * ${Y});
|
|
1347
|
+
child.style.setProperty('--stx-stagger-delay', delay + 'ms');
|
|
1348
|
+
child.style.animationDelay = delay + 'ms';
|
|
1349
|
+
child.classList.add('${J}');
|
|
1350
|
+
});
|
|
1351
|
+
})();
|
|
1352
|
+
</script>`}var UZ={name:"stagger",hasEndTag:!0,handler:($,Z,X,Y)=>{let J=Z[0]?.replace(/['"`]/g,"")||"> *",Q=Z[1]?Number.parseInt(Z[1],10):100,G=Z[2]?Number.parseInt(Z[2],10):0,q=Z[3]?.replace(/['"`]/g,"")||"fade",U=`stx-stagger-${Math.random().toString(36).slice(2,9)}`,W="stx-stagger-item";if(q==="fade")W+=" stx-fade";else if(q==="slide")W+=" stx-from-bottom";else if(q==="scale")W+=" stx-scale";let K=qZ(U,J,G,Q,W);return`${`
|
|
1353
|
+
<style>
|
|
1354
|
+
#${U} .stx-stagger-item {
|
|
1355
|
+
opacity: 0;
|
|
1356
|
+
animation: staggerIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-stagger-delay, 0ms) forwards;
|
|
1357
|
+
}
|
|
1358
|
+
@keyframes staggerIn {
|
|
1359
|
+
from { opacity: 0; transform: translateY(10px); }
|
|
1360
|
+
to { opacity: 1; transform: translateY(0); }
|
|
1361
|
+
}
|
|
1362
|
+
</style>`}<div id="${U}" class="stx-stagger-container">${$}</div>${K}`},description:"Applies staggered animations to child elements"};function WZ($){let{stiffness:Z,damping:X}=$,Y=X/(2*Math.sqrt(Z));if(Y<0.5)return"cubic-bezier(0.175, 0.885, 0.32, 1.275)";else if(Y<1)return"cubic-bezier(0.34, 1.56, 0.64, 1)";else return"cubic-bezier(0.25, 0.1, 0.25, 1)"}var KZ={name:"spring",hasEndTag:!0,handler:($,Z,X,Y)=>{let J=Z[0]?.replace(/['"`]/g,"")||"default",Q;if(B7[J])Q=B7[J];else Q={stiffness:Number.parseInt(J,10)||100,damping:Z[1]?Number.parseInt(Z[1],10):10,mass:Z[2]?Number.parseFloat(Z[2]):1};let G=Z[3]?Number.parseInt(Z[3],10):500,q=`stx-spring-${Math.random().toString(36).slice(2,9)}`,U=WZ(Q),W=`
|
|
1363
|
+
transition: all ${G}ms ${U};
|
|
1364
|
+
--stx-spring-stiffness: ${Q.stiffness};
|
|
1365
|
+
--stx-spring-damping: ${Q.damping};
|
|
1366
|
+
--stx-spring-mass: ${Q.mass};
|
|
1367
|
+
`.trim().replace(/\s+/g," ");return`<div id="${q}" class="stx-spring" style="${W}">${$}</div>`},description:"Applies spring physics animations to an element"};function lq($){let Z=`stx-timeline-${Math.random().toString(36).slice(2,9)}`;return`
|
|
1368
|
+
<script data-stx-scoped data-stx-run="always">
|
|
1369
|
+
(function() {
|
|
1370
|
+
const timeline = ${JSON.stringify($)};
|
|
1371
|
+
|
|
1372
|
+
function runTimeline() {
|
|
1373
|
+
timeline.forEach((entry, index) => {
|
|
1374
|
+
const element = document.querySelector(entry.selector);
|
|
1375
|
+
if (!element) return;
|
|
1376
|
+
|
|
1377
|
+
const keyframes = entry.keyframes.map(kf => {
|
|
1378
|
+
const frame = { ...kf.properties };
|
|
1379
|
+
if (kf.offset !== undefined) frame.offset = kf.offset;
|
|
1380
|
+
if (kf.easing) frame.easing = kf.easing;
|
|
1381
|
+
return frame;
|
|
1382
|
+
});
|
|
1383
|
+
|
|
1384
|
+
const options = {
|
|
1385
|
+
duration: entry.options.duration || 1000,
|
|
1386
|
+
delay: entry.options.delay || 0,
|
|
1387
|
+
easing: entry.options.easing || 'ease',
|
|
1388
|
+
iterations: entry.options.iterations || 1,
|
|
1389
|
+
direction: entry.options.direction || 'normal',
|
|
1390
|
+
fill: entry.options.fill || 'forwards'
|
|
1391
|
+
};
|
|
1392
|
+
|
|
1393
|
+
element.animate(keyframes, options);
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
if (document.readyState === 'loading') {
|
|
1398
|
+
document.addEventListener('DOMContentLoaded', runTimeline);
|
|
1399
|
+
}
|
|
1400
|
+
else {
|
|
1401
|
+
runTimeline();
|
|
1402
|
+
}
|
|
1403
|
+
})();
|
|
1404
|
+
</script>`}function cq($,Z,X){let Y=QZ($,Z),J=`
|
|
1405
|
+
.${$}-animation {
|
|
1406
|
+
animation-name: ${$};
|
|
1407
|
+
animation-duration: ${X.duration}ms;
|
|
1408
|
+
animation-timing-function: ${X.easing||"ease"};
|
|
1409
|
+
animation-delay: ${X.delay||0}ms;
|
|
1410
|
+
animation-iteration-count: ${X.iterations==="infinite"?"infinite":X.iterations||1};
|
|
1411
|
+
animation-direction: ${X.direction||"normal"};
|
|
1412
|
+
animation-fill-mode: ${X.fill||"forwards"};
|
|
1413
|
+
}`;return`${Y}
|
|
1414
|
+
${J}`}function pq($){let Z=$.trim().split(/\s+/),X={duration:300};for(let Y=0;Y<Z.length;Y++){let J=Z[Y];if(/^\d+(?:ms|s)?$/.test(J)){let Q=Number.parseInt(J,10);if(Y===0)X.duration=J.endsWith("s")&&!J.endsWith("ms")?Q*1000:Q;else X.delay=J.endsWith("s")&&!J.endsWith("ms")?Q*1000:Q}else if(J==="infinite"||/^\d+$/.test(J))X.iterations=J==="infinite"?"infinite":Number.parseInt(J,10);else if(["normal","reverse","alternate","alternate-reverse"].includes(J))X.direction=J;else if(["none","forwards","backwards","both"].includes(J))X.fill=J;else X.easing=J}return X}function iq(){return`
|
|
1415
|
+
<script data-stx-scoped data-stx-run="once">
|
|
1416
|
+
window.__stxAnimation = {
|
|
1417
|
+
// Registry of animations
|
|
1418
|
+
animations: new Map(),
|
|
1419
|
+
|
|
1420
|
+
// Register a reusable animation
|
|
1421
|
+
register(name, keyframes, options) {
|
|
1422
|
+
this.animations.set(name, { keyframes, options });
|
|
1423
|
+
},
|
|
1424
|
+
|
|
1425
|
+
// Run an animation on an element
|
|
1426
|
+
animate(element, nameOrKeyframes, options = {}) {
|
|
1427
|
+
if (typeof element === 'string') {
|
|
1428
|
+
element = document.querySelector(element);
|
|
1429
|
+
}
|
|
1430
|
+
if (!element) return null;
|
|
1431
|
+
|
|
1432
|
+
let keyframes, defaultOptions;
|
|
1433
|
+
|
|
1434
|
+
if (typeof nameOrKeyframes === 'string' && this.animations.has(nameOrKeyframes)) {
|
|
1435
|
+
const registered = this.animations.get(nameOrKeyframes);
|
|
1436
|
+
keyframes = registered.keyframes;
|
|
1437
|
+
defaultOptions = registered.options;
|
|
1438
|
+
}
|
|
1439
|
+
else {
|
|
1440
|
+
keyframes = nameOrKeyframes;
|
|
1441
|
+
defaultOptions = {};
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
const finalOptions = { ...defaultOptions, ...options };
|
|
1445
|
+
return element.animate(keyframes, finalOptions);
|
|
1446
|
+
},
|
|
1447
|
+
|
|
1448
|
+
// Animate multiple elements with stagger
|
|
1449
|
+
stagger(elements, keyframes, options = {}, staggerDelay = 100) {
|
|
1450
|
+
if (typeof elements === 'string') {
|
|
1451
|
+
elements = document.querySelectorAll(elements);
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
const animations = [];
|
|
1455
|
+
Array.from(elements).forEach((el, index) => {
|
|
1456
|
+
const elementOptions = {
|
|
1457
|
+
...options,
|
|
1458
|
+
delay: (options.delay || 0) + (index * staggerDelay)
|
|
1459
|
+
};
|
|
1460
|
+
animations.push(this.animate(el, keyframes, elementOptions));
|
|
1461
|
+
});
|
|
1462
|
+
|
|
1463
|
+
return animations;
|
|
1464
|
+
},
|
|
1465
|
+
|
|
1466
|
+
// Chain animations sequentially
|
|
1467
|
+
async sequence(steps) {
|
|
1468
|
+
for (const step of steps) {
|
|
1469
|
+
const animation = this.animate(step.element, step.keyframes, step.options);
|
|
1470
|
+
if (animation) {
|
|
1471
|
+
await animation.finished;
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
},
|
|
1475
|
+
|
|
1476
|
+
// Run animations in parallel
|
|
1477
|
+
parallel(steps) {
|
|
1478
|
+
return Promise.all(
|
|
1479
|
+
steps.map(step => {
|
|
1480
|
+
const animation = this.animate(step.element, step.keyframes, step.options);
|
|
1481
|
+
return animation ? animation.finished : Promise.resolve();
|
|
1482
|
+
})
|
|
1483
|
+
);
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
</script>`}function nq($){let Z=$.customDirectives||[];return Z.push(v$),Z.push(x$),Z.push(g$),Z.push(f$),Z.push(GZ),Z.push(UZ),Z.push(KZ),{...$,customDirectives:Z}}function _7($){let Z=$.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!Z)return null;try{return Function(`return ${Z[1]}`)()}catch{return null}}function O7($){let Z=$?.layout;if(Z===!1)return!1;return typeof Z==="string"&&Z.trim()?Z.trim():void 0}var zZ=0,HZ=0;function V7($,Z){let X=$.match(new RegExp(`${Z}\\s*=\\s*"([^"]*)"`,"i"));if(X)return X[1];let Y=$.match(new RegExp(`${Z}\\s*=\\s*'([^']*)'`,"i"));if(Y)return Y[1];return null}function BZ($){let Z=[],X=/<([a-z][a-z0-9-]*)\s+([^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,Y;while((Y=X.exec($))!==null){let[J,Q,G]=Y,q=Y.index,U=V7(G,"x-data");if(!U)continue;let W=`__stx_scope_${zZ++}`,K=V7(G,"x-init"),z=jZ($,Q,q+J.length),H=$.slice(q,z.endIndex),B=_Z(H);Z.push({id:W,selector:`[data-stx-scope="${W}"]`,stateExpr:U,initExpr:K,bindings:[],refs:B})}return Z}function jZ($,Z,X){let Y=1,J=X,Q=new RegExp(`<${Z}(?:\\s|>)`,"gi"),G=new RegExp(`</${Z}>`,"gi"),q=new RegExp(`<${Z}[^>]*/\\s*>`,"gi");while(Y>0&&J<$.length){Q.lastIndex=J,G.lastIndex=J,q.lastIndex=J;let U=Q.exec($),W=G.exec($),K=q.exec($);if(K&&K.index<(U?.index??1/0)){J=K.index+K[0].length;continue}if(!W)return{endIndex:$.length};if(U&&U.index<W.index)Y++,J=U.index+U[0].length;else{if(Y--,Y===0)return{endIndex:W.index+W[0].length};J=W.index+W[0].length}}return{endIndex:$.length}}function _Z($){let Z=new Map,X=$.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),Y=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,J;while((J=Y.exec(X))!==null){let[,Q,G]=J,q=OZ(Q);Z.set(G,q)}return Z}function OZ($){let Z=$.match(/\bid\s*=\s*["']([^"']*)["']/);if(Z)return Z[1];return`__stx_el_${HZ++}`}function VZ(){return`
|
|
1487
|
+
// STX Reactive Runtime - x-cloak and transition CSS
|
|
1488
|
+
(function() {
|
|
1489
|
+
var style = document.createElement('style');
|
|
1490
|
+
style.textContent = [
|
|
1491
|
+
'[x-cloak] { display: none !important; }',
|
|
1492
|
+
// Default transition classes
|
|
1493
|
+
'.stx-enter { opacity: 0; transform: scale(0.95); }',
|
|
1494
|
+
'.stx-enter-start { opacity: 0; transform: scale(0.95); }',
|
|
1495
|
+
'.stx-enter-active { transition: opacity 150ms ease-out, transform 150ms ease-out; }',
|
|
1496
|
+
'.stx-enter-to { opacity: 1; transform: scale(1); }',
|
|
1497
|
+
'.stx-leave { opacity: 1; transform: scale(1); }',
|
|
1498
|
+
'.stx-leave-start { opacity: 1; transform: scale(1); }',
|
|
1499
|
+
'.stx-leave-active { transition: opacity 100ms ease-in, transform 100ms ease-in; }',
|
|
1500
|
+
'.stx-leave-to { opacity: 0; transform: scale(0.95); }'
|
|
1501
|
+
].join('\\n');
|
|
1502
|
+
document.head.appendChild(style);
|
|
1503
|
+
})();
|
|
1504
|
+
|
|
1505
|
+
// STX Reactive Runtime
|
|
1506
|
+
/* eslint-disable pickier/no-unused-vars, no-console, prefer-const */
|
|
1507
|
+
window.__stx_reactive = (function() {
|
|
1508
|
+
'use strict';
|
|
1509
|
+
|
|
1510
|
+
// Deep reactive proxy that triggers onChange for any mutation
|
|
1511
|
+
function reactive(obj, onChange) {
|
|
1512
|
+
if (!obj || typeof obj !== 'object') return obj;
|
|
1513
|
+
return new Proxy(obj, {
|
|
1514
|
+
get(target, prop) {
|
|
1515
|
+
const value = target[prop];
|
|
1516
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Promise)) {
|
|
1517
|
+
return reactive(value, onChange);
|
|
1518
|
+
}
|
|
1519
|
+
return value;
|
|
1520
|
+
},
|
|
1521
|
+
set(target, prop, value) {
|
|
1522
|
+
target[prop] = value;
|
|
1523
|
+
onChange(prop, value);
|
|
1524
|
+
return true;
|
|
1525
|
+
}
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
// Initialize an x-data scope: parse state, run init(), register into window.stx._scopes,
|
|
1530
|
+
// then let the signals runtime handle all directive processing (x-for, x-text, :bind, etc.)
|
|
1531
|
+
function initScope(scopeEl, initialState, bindings, refs, initExpr) {
|
|
1532
|
+
// Parse initial state (may contain methods including async init())
|
|
1533
|
+
var state;
|
|
1534
|
+
try {
|
|
1535
|
+
state = new Function('return (' + initialState + ')')();
|
|
1536
|
+
} catch (e) {
|
|
1537
|
+
console.error('[stx-reactive] Invalid x-data:', initialState, e);
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
// Build $refs object
|
|
1542
|
+
var $refs = {};
|
|
1543
|
+
for (var name in refs) {
|
|
1544
|
+
if (Object.prototype.hasOwnProperty.call(refs, name)) {
|
|
1545
|
+
(function(refName, refId) {
|
|
1546
|
+
Object.defineProperty($refs, refName, {
|
|
1547
|
+
get: function() { return document.getElementById(refId); }
|
|
1548
|
+
});
|
|
1549
|
+
})(name, refs[name]);
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
// Extract init method from state if present (Alpine.js convention)
|
|
1554
|
+
var initMethod = state.init;
|
|
1555
|
+
if (typeof initMethod === 'function') {
|
|
1556
|
+
delete state.init;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
// Make state reactive \u2014 mutations trigger re-render via signals
|
|
1560
|
+
var scopeId = scopeEl.getAttribute('data-stx-scope');
|
|
1561
|
+
var stx = window.stx;
|
|
1562
|
+
|
|
1563
|
+
// Create signals for each state property so the signals runtime can track dependencies
|
|
1564
|
+
var signalState = {};
|
|
1565
|
+
var rawState = {};
|
|
1566
|
+
for (var key in state) {
|
|
1567
|
+
if (Object.prototype.hasOwnProperty.call(state, key)) {
|
|
1568
|
+
if (typeof state[key] === 'function') {
|
|
1569
|
+
// Methods \u2014 bind to a proxy so 'this.prop = val' triggers signal updates
|
|
1570
|
+
signalState[key] = state[key];
|
|
1571
|
+
} else {
|
|
1572
|
+
// Data properties \u2014 wrap in signals for reactivity
|
|
1573
|
+
signalState[key] = stx.state(state[key]);
|
|
1574
|
+
rawState[key] = true;
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
|
|
1579
|
+
// Create a proxy context that auto-unwraps signals and writes back through them.
|
|
1580
|
+
// Methods get 'this' bound to this proxy so this.foo = bar triggers reactivity.
|
|
1581
|
+
var ctx = {};
|
|
1582
|
+
var ctxProxy = new Proxy(ctx, {
|
|
1583
|
+
get: function(target, prop) {
|
|
1584
|
+
if (prop === '$refs') return $refs;
|
|
1585
|
+
if (prop === '$el') return scopeEl;
|
|
1586
|
+
if (prop === '$nextTick') return function(fn) { requestAnimationFrame(fn); };
|
|
1587
|
+
var s = signalState[prop];
|
|
1588
|
+
if (!s) return undefined;
|
|
1589
|
+
if (rawState[prop] && s && typeof s === 'function' && typeof s.value !== 'undefined') {
|
|
1590
|
+
return s.value; // unwrap signal
|
|
1591
|
+
}
|
|
1592
|
+
if (typeof s === 'function' && !rawState[prop]) {
|
|
1593
|
+
return s.bind(ctxProxy); // bind methods to proxy
|
|
1594
|
+
}
|
|
1595
|
+
return s;
|
|
1596
|
+
},
|
|
1597
|
+
set: function(target, prop, value) {
|
|
1598
|
+
var s = signalState[prop];
|
|
1599
|
+
if (rawState[prop] && s && typeof s === 'function') {
|
|
1600
|
+
s.value = value; // write through signal \u2014 triggers effects
|
|
1601
|
+
} else {
|
|
1602
|
+
signalState[prop] = value;
|
|
1603
|
+
}
|
|
1604
|
+
return true;
|
|
1605
|
+
},
|
|
1606
|
+
has: function(target, prop) {
|
|
1607
|
+
return prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick';
|
|
1608
|
+
},
|
|
1609
|
+
ownKeys: function() {
|
|
1610
|
+
return Object.keys(signalState).concat(['$refs', '$el', '$nextTick']);
|
|
1611
|
+
},
|
|
1612
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
1613
|
+
if (prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick') {
|
|
1614
|
+
return { configurable: true, enumerable: true, writable: true, value: ctxProxy[prop] };
|
|
1615
|
+
}
|
|
1616
|
+
return undefined;
|
|
1617
|
+
}
|
|
1618
|
+
});
|
|
1619
|
+
|
|
1620
|
+
// Build scope vars for the signals runtime \u2014 it reads these for expression evaluation.
|
|
1621
|
+
// We need to provide getter/setter descriptors so signals track properly.
|
|
1622
|
+
var scopeVars = {};
|
|
1623
|
+
for (var k in signalState) {
|
|
1624
|
+
if (Object.prototype.hasOwnProperty.call(signalState, k)) {
|
|
1625
|
+
if (rawState[k]) {
|
|
1626
|
+
// Data: expose the signal directly so expressions trigger dependency tracking
|
|
1627
|
+
scopeVars[k] = signalState[k];
|
|
1628
|
+
} else {
|
|
1629
|
+
// Method: bind to ctxProxy so 'this' works
|
|
1630
|
+
scopeVars[k] = (typeof signalState[k] === 'function') ? signalState[k].bind(ctxProxy) : signalState[k];
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
scopeVars.$refs = $refs;
|
|
1635
|
+
scopeVars.$el = scopeEl;
|
|
1636
|
+
scopeVars.$nextTick = function(fn) { requestAnimationFrame(fn); };
|
|
1637
|
+
|
|
1638
|
+
// Register scope \u2014 merge with any existing vars from partial signal scripts
|
|
1639
|
+
if (!stx._scopes) stx._scopes = {};
|
|
1640
|
+
stx._scopes[scopeId] = Object.assign(stx._scopes[scopeId] || {}, scopeVars);
|
|
1641
|
+
|
|
1642
|
+
// Store on element for findElementScope
|
|
1643
|
+
scopeEl.__stx_scope = scopeVars;
|
|
1644
|
+
|
|
1645
|
+
// Run init() if present (supports async)
|
|
1646
|
+
function runInit() {
|
|
1647
|
+
var maybePromise;
|
|
1648
|
+
if (initMethod) {
|
|
1649
|
+
maybePromise = initMethod.call(ctxProxy);
|
|
1650
|
+
}
|
|
1651
|
+
if (initExpr) {
|
|
1652
|
+
try {
|
|
1653
|
+
var keys = Object.keys(scopeVars);
|
|
1654
|
+
var vals = keys.map(function(k) { return scopeVars[k]; });
|
|
1655
|
+
var fn = new Function(keys.join(','), initExpr);
|
|
1656
|
+
var result = fn.apply(ctxProxy, vals);
|
|
1657
|
+
if (result && typeof result.then === 'function') maybePromise = result;
|
|
1658
|
+
} catch (e) {
|
|
1659
|
+
console.warn('[stx-reactive] init expression error:', e);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
// If init is async, signal updates will trigger effects automatically
|
|
1663
|
+
// when init() resolves and sets this.prop = value (writes through signal)
|
|
1664
|
+
if (maybePromise && typeof maybePromise.then === 'function') {
|
|
1665
|
+
maybePromise.catch(function(e) {
|
|
1666
|
+
console.error('[stx-reactive] async init() error:', e);
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1671
|
+
// Run init before the signals runtime processes this scope
|
|
1672
|
+
runInit();
|
|
1673
|
+
|
|
1674
|
+
// Expose for debugging
|
|
1675
|
+
scopeEl.__stx_state = ctxProxy;
|
|
1676
|
+
scopeEl.__stx_execute = function(stmt, $event, $el) {
|
|
1677
|
+
try {
|
|
1678
|
+
// Run the statement with the reactive proxy as the lexical scope.
|
|
1679
|
+
// Wrapping in a with-block on the proxy makes bare reads/writes go
|
|
1680
|
+
// through it (so foo = bar triggers signal.set()) instead of treating
|
|
1681
|
+
// each state key as a local function parameter \u2014 bare assignments
|
|
1682
|
+
// would otherwise just rebind the local and never reach the signal.
|
|
1683
|
+
var fn = new Function('$event', '$el', 'with(this){' + stmt + ';}');
|
|
1684
|
+
fn.call(ctxProxy, $event, $el);
|
|
1685
|
+
} catch (e) {
|
|
1686
|
+
console.warn('[stx-reactive] execute error:', e);
|
|
1687
|
+
}
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
return { initScope: initScope, reactive: reactive };
|
|
1692
|
+
})();
|
|
1693
|
+
`}function F7($,Z){let X=$.replace(/\{!!([\s\S]*?)!!\}/g,(q,U)=>{try{let W=b0(U,Z,!0);if(W===void 0)return q;return String(W)}catch{return q}}),Y="",J=0,Q=null;while(J<X.length){let q=X[J];if(Q&&q==="\\"){Y+=q+(X[J+1]??""),J+=2;continue}if(q==="{"&&X[J+1]==="{"){let U=X.indexOf("}}",J+2);if(U!==-1){let W=X.slice(J,U+2);Y+=G(X.slice(J+2,U),W,Q),J=U+2;continue}}if(Q){if(q===Q)Q=null}else if(q==="'"||q==='"'||q==="`")Q=q;Y+=q,J++}return Y;function G(q,U,W){let K;try{K=b0(q,Z,!0)}catch{return U}if(K===void 0)return U;if(W){let z=String(K).replace(/\\/g,"\\\\").replace(new RegExp(W==="`"?"`":W,"g"),`\\${W}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return W==="`"?z.replace(/\$\{/g,"\\${"):z}if(typeof K==="string"){let z=K.trim();if(z.startsWith("{")&&z.endsWith("}")||z.startsWith("[")&&z.endsWith("]"))try{return JSON.parse(z),z}catch{}}return JSON.stringify(K)}}function FZ($,Z){if($.length===0)return"";let X=$.map((Y)=>{let J=JSON.stringify(Object.fromEntries(Y.refs)),Q=F7(Y.stateExpr,Z),G=Y.initExpr?F7(Y.initExpr,Z):null,q=JSON.stringify(Q),U=G?JSON.stringify(G):"null";return`
|
|
1694
|
+
(function() {
|
|
1695
|
+
var scopeEl = document.querySelector('${Y.selector}');
|
|
1696
|
+
if (!scopeEl) return;
|
|
1697
|
+
var refs = ${J};
|
|
1698
|
+
__stx_reactive.initScope(scopeEl, ${q}, [], refs, ${U});
|
|
1699
|
+
})();`}).join(`
|
|
1700
|
+
`);return`
|
|
1701
|
+
<script data-stx-scoped data-stx-reactive data-stx-run="always">
|
|
1702
|
+
${VZ()}
|
|
1703
|
+
${X}
|
|
1704
|
+
</script>`}function L7($,Z,X){if(!wZ($))return $;let Y=BZ($);if(Y.length===0)return $;let J=LZ($,Y),Q=FZ(Y,Z),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
|
|
1705
|
+
`+J.slice(G);else J+=Q;return J}function LZ($,Z){let X=0,Y=$.replace(/<([a-z][a-z0-9-]*)(\s+[^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,(J,Q,G)=>{let q=Z[X++];if(!q)return J;let U=/data-stx-scope="([^"]*)"/.exec(G);if(U)return q.id=U[1],q.selector=`[data-stx-scope="${q.id}"]`,J;return`<${Q} data-stx-scope="${q.id}"${G}>`});return Y=Y.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),Y=Y.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),Y=Y.replace(/\s*x-init\s*=\s*"([^"]*)"/g,' data-stx-xinit="$1"'),Y=Y.replace(/\s*x-init\s*=\s*'([^']*)'/g," data-stx-xinit='$1'"),Y}function wZ($){return/x-data\s*=\s*["']/.test($)}import yX from"fs";import W3 from"path";import{createHighlighter as SX}from"ts-syntax-highlighter";import a5 from"fs";import S0 from"path";import{loadConfigWithResult as MX}from"bunfig";U5();async function RZ($,Z,X,Y){let J=Z[0]?.replace(/['"]/g,"")||"main",Q=h$();if(J!=="main")Q=Q.replace("container:'main'",`container:'${J}'`);return`<script data-stx-router>${Q}</script>`}var w7={name:"stxRouter",handler:RZ,hasEndTag:!1,description:"Inject the STX SPA router script for client-side navigation"};function Q1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function R7($){let Z=$.trim().toLowerCase();return!Z.startsWith("javascript:")&&!Z.startsWith("vbscript:")&&!Z.startsWith("data:text/html")}function D7($){let Z=/^---\r?\n([\s\S]*?)\r?\n---\r?\n/,X=$.match(Z);if(!X)return{data:{},content:$.trim()};let Y=X[1],J=$.slice(X[0].length),Q={};for(let G of Y.split(`
|
|
1706
|
+
`)){let q=G.trim();if(!q||q.startsWith("#"))continue;let U=q.indexOf(":");if(U===-1)continue;let W=q.slice(0,U).trim(),K=q.slice(U+1).trim();if(typeof K==="string"){if(K.startsWith('"')&&K.endsWith('"')||K.startsWith("'")&&K.endsWith("'"))K=K.slice(1,-1);else if(K.startsWith("[")&&K.endsWith("]"))try{K=JSON.parse(K)}catch{}else if(K==="true")K=!0;else if(K==="false")K=!1;else if(/^-?\d+(?:\.\d+)?$/.test(K))K=Number(K)}Q[W]=K}return{data:Q,content:J.trim()}}function W5($,Z={}){let{gfm:X=!0,breaks:Y=!1}=Z,J=$,Q=[];if(J=J.replace(/```(\w*)\n([\s\S]*?)```/g,(K,z,H)=>{let B=Q.length,j=z?` class="language-${Q1(z)}"`:"";return Q.push(`<pre><code${j}>${Q1(H.trim())}</code></pre>`),`\x00CODEBLOCK${B}\x00`}),J=J.replace(/`([^`]*)`/g,(K,z)=>`<code>${Q1(z)}</code>`),J=J.replace(/^######\s+(.*)$/gm,"<h6>$1</h6>"),J=J.replace(/^#####\s+(.*)$/gm,"<h5>$1</h5>"),J=J.replace(/^####\s+(.*)$/gm,"<h4>$1</h4>"),J=J.replace(/^###\s+(.*)$/gm,"<h3>$1</h3>"),J=J.replace(/^##\s+(.*)$/gm,"<h2>$1</h2>"),J=J.replace(/^#\s+(.*)$/gm,"<h1>$1</h1>"),J=J.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),J=J.replace(/___(.+?)___/g,"<strong><em>$1</em></strong>"),J=J.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),J=J.replace(/__(.+?)__/g,"<strong>$1</strong>"),J=J.replace(/\*(.+?)\*/g,"<em>$1</em>"),J=J.replace(/(?<![a-zA-Z0-9])_(.+?)_(?![a-zA-Z0-9])/g,"<em>$1</em>"),X)J=J.replace(/~~(.+?)~~/g,"<del>$1</del>");if(J=J.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(K,z,H)=>{return`<img src="${R7(H)?Q1(H):""}" alt="${Q1(z)}" />`}),J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(K,z,H)=>{return`<a href="${R7(H)?Q1(H):""}">${z}</a>`}),J=J.replace(/^(?:---|\*\*\*|___)\s*$/gm,"<hr />"),J=J.replace(/^>\s+(.*)$/gm,"<blockquote>$1</blockquote>"),J=J.replace(/<\/blockquote>\n<blockquote>/g,`
|
|
1707
|
+
`),J=J.replace(/^[*\-+]\s+(.*)$/gm,"<li data-ul>$1</li>"),J=J.replace(/(<li data-ul>.*<\/li>\n?)+/g,"<ul>$&</ul>"),J=J.replace(/<\/ul>\n<ul>/g,""),J=J.replace(/^\d+\.\s+(.*)$/gm,"<li data-ol>$1</li>"),J=J.replace(/(<li data-ol>.*<\/li>\n?)+/g,"<ol>$&</ol>"),J=J.replace(/<\/ol>\n<ol>/g,""),J=J.replace(/<li data-ul>/g,"<li>"),J=J.replace(/<li data-ol>/g,"<li>"),X)J=J.replace(/^\|(.+)\|\s*\n\|[-:\s|]+\|\s*\n((?:\|.+\|\s*\n)*)/gm,(K,z,H)=>{let j=`<tr>${z.split("|").map((V)=>V.trim()).filter(Boolean).map((V)=>`<th>${Q1(V)}</th>`).join("")}</tr>`,_=H.trim().split(`
|
|
1708
|
+
`).map((V)=>{return`<tr>${V.split("|").map((F)=>F.trim()).filter(Boolean).map((F)=>`<td>${Q1(F)}</td>`).join("")}</tr>`}).join(`
|
|
1709
|
+
`);return`<table>
|
|
1710
|
+
<thead>
|
|
1711
|
+
${j}
|
|
1712
|
+
</thead>
|
|
1713
|
+
<tbody>
|
|
1714
|
+
${_}
|
|
1715
|
+
</tbody>
|
|
1716
|
+
</table>`});if(X)J=J.replace(/<li>\s*\[\s*\]\s*/g,'<li><input type="checkbox" disabled /> '),J=J.replace(/<li>\s*\[x\]\s*/gi,'<li><input type="checkbox" checked disabled /> ');let G=J.split(`
|
|
1717
|
+
`),q=[],U=!1,W=[];for(let K of G){let z=K.trim();if(/^<(?:h[1-6]|ul|ol|li|blockquote|pre|table|thead|tbody|tr|th|td|hr|div|p)/.test(z)||/^\0CODEBLOCK\d+\0$/.test(z)||z===""){if(U&&W.length>0)q.push(`<p>${W.join(Y?`<br />
|
|
1718
|
+
`:`
|
|
1719
|
+
`)}</p>`),W=[],U=!1;q.push(K)}else U=!0,W.push(z)}if(U&&W.length>0)q.push(`<p>${W.join(Y?`<br />
|
|
1720
|
+
`:`
|
|
1721
|
+
`)}</p>`);if(J=q.join(`
|
|
1722
|
+
`),Y)J=J.replace(/\n/g,`<br />
|
|
1723
|
+
`);for(let K=0;K<Q.length;K++)J=J.replace(`\x00CODEBLOCK${K}\x00`,Q[K]);return J=J.replace(/<p>\s*<\/p>/g,""),J.trim()}async function N7($,Z,X=""){let Y=$,J=[],Q=/@markdown(?:\([^)]*\))?/g,G;while((G=Q.exec($))!==null){let q=G.index,U=G[0].match(/@markdown\(([^)]*)\)/),W=U?U[1]:"",K=q+G[0].length,z=1,H=K,B=-1;while(z>0&&H<$.length){let V=$.indexOf("@markdown",H),O=$.indexOf("@endmarkdown",H);if(O===-1)break;if(V!==-1&&V<O&&V!==q){let F=$[V+9];if(F==="("||F===`
|
|
1724
|
+
`||F==="\r"||F===" "||F===void 0)z++;H=V+9}else{if(z--,z===0){B=O;break}H=O+12}}if(B===-1)continue;let j=$.slice(K,B),_=$.slice(q,B+12);J.push({fullMatch:_,options:W,content:j,index:q}),Q.lastIndex=B+12}for(let{fullMatch:q,options:U,content:W,index:K}of J)try{let z={};if(U)U.split(",").forEach((j)=>{let _=j.trim();if(_)z[_]=!0});let H={gfm:z.gfm??!0,breaks:z.breaks??!1},B=W5(W.trim(),H);Y=Y.split(q).join(B)}catch(z){let H=z instanceof Error?z.message:String(z),B=W0("Markdown Directive",`Error processing markdown: ${H}`,X,$,K,q);Y=Y.split(q).join(B)}return Y}async function A7($,Z,X,Y){let J={gfm:!0,breaks:!1};return Z.forEach((Q)=>{let G=Q.trim().replace(/['"]/g,"");if(G==="breaks")J.breaks=!0;if(G==="no-gfm")J.gfm=!1}),W5($.trim(),J)}var V1=[320,480,640,768,1024,1280,1536,1920,2560],M7=[1,1.5,2,3],f1=["avif","webp","jpeg"],T7={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"},DZ={avif:"avif",webp:"webp",jpeg:"jpg",png:"png",gif:"gif"};function K5($,Z=V1,X={},Y){return Z.sort((J,Q)=>J-Q).map((J)=>{return`${G1($,{...X,w:J,fm:Y})} ${J}w`}).join(", ")}function qU($,Z=320,X=2560,Y=0.08,J={},Q){let G=NZ(Z,X,Y);return K5($,G,J,Q)}function NZ($,Z,X=0.08){let Y=[],J=$;while(J<Z)Y.push(Math.round(J)),J*=1+X*2;if(Y[Y.length-1]!==Z)Y.push(Z);return Y}function u$($,Z,X=M7,Y={},J){return X.sort((Q,G)=>Q-G).map((Q)=>{let G=Math.round(Z*Q);return`${G1($,{...Y,w:G,dpr:Q,fm:J})} ${Q}x`}).join(", ")}function UU($,Z,X=M7,Y=80,J={},Q){let G={1:Y,1.5:Math.round(Y*0.9),2:Math.round(Y*0.8),3:Math.round(Y*0.7),4:Math.round(Y*0.6),5:Math.round(Y*0.5)};return X.sort((q,U)=>q-U).map((q)=>{let U=Math.round(Z*q),W=G[q]||Math.round(Y*Math.max(0.5,1-q*0.1));return`${G1($,{...J,w:U,q:W,dpr:q,fm:Q})} ${q}x`}).join(", ")}function d$($,Z="100vw"){if(!$||Object.keys($).length===0)return Z;let Y=Object.entries($).map(([J,Q])=>{let G=/^\d+$/.test(J)?`${J}px`:J;return{bp:G,size:Q,numericBp:Number.parseInt(G)||0}}).sort((J,Q)=>J.numericBp-Q.numericBp).map(({bp:J,size:Q})=>`(max-width: ${J}) ${Q}`);return Y.push(Z),Y.join(", ")}function WU($,Z="100vw"){if(!$||$.length===0)return Z;let Y=[...$].sort((J,Q)=>(J.maxWidth||0)-(Q.maxWidth||0)).filter((J)=>J.maxWidth).map((J)=>`(max-width: ${J.maxWidth}px) ${J.imageWidth}`);return Y.push(Z),Y.join(", ")}var KU={fullWidth:"100vw",halfDesktop:"(max-width: 768px) 100vw, 50vw",thirdDesktop:"(max-width: 768px) 100vw, 33.33vw",quarterDesktop:"(max-width: 480px) 100vw, (max-width: 768px) 50vw, 25vw",contentWidth:"(max-width: 768px) 100vw, (max-width: 1200px) 80vw, 960px"};function G1($,Z={}){let X=Object.entries(Z).filter(([,Q])=>Q!==void 0&&Q!==null).map(([Q,G])=>{if(Array.isArray(G))return[Q,G.join(",")];return[Q,String(G)]});if(X.length===0)return $;let Y=X.map(([Q,G])=>`${Q}=${encodeURIComponent(G)}`).join("&"),J=$.includes("?")?"&":"?";return`${$}${J}${Y}`}function zU($){let[Z,X]=$.split("?"),Y={};if(X)new URLSearchParams(X).forEach((Q,G)=>{if(/^\d+$/.test(Q))Y[G]=Number.parseInt(Q,10);else if(/^\d+\.\d+$/.test(Q))Y[G]=Number.parseFloat(Q);else if(Q==="true")Y[G]=!0;else if(Q==="false")Y[G]=!1;else Y[G]=Q});return{src:Z,params:Y}}function HU($){let{src:Z,widths:X,dprValues:Y,fixedWidth:J,formats:Q=f1,baseUrl:G="",params:q={}}=$,U=[];for(let W of Q){let K,z;if(J!==void 0&&Y)K=u$(Z,J,Y,q,W),z=Y.map((H)=>({path:"",url:G1(Z,{...q,w:Math.round(J*H),fm:W}),width:Math.round(J*H),height:0,format:W,size:0,dpr:H}));else{let H=X||V1;K=K5(Z,H,q,W),z=H.map((B)=>({path:"",url:G1(Z,{...q,w:B,fm:W}),width:B,height:0,format:W,size:0}))}U.push({srcset:K,format:W,mimeType:T7[W],variants:z})}return U}function BU($,Z="100vw"){return $.map(({srcset:X,mimeType:Y})=>`<source type="${Y}" srcset="${X}" sizes="${Z}" />`).join(`
|
|
1725
|
+
`)}function jU($,Z){if($.length===0)return;let X=[...$].sort((J,Q)=>J.width-Q.width),Y=X.find((J)=>J.width>=Z);if(Y)return Y;return X[X.length-1]}function m$($){return T7[$]||"application/octet-stream"}function _U($){return DZ[$]||$}function OU($){switch($.split(".").pop()?.toLowerCase()){case"jpg":case"jpeg":return"jpeg";case"png":return"png";case"webp":return"webp";case"avif":return"avif";case"gif":return"gif";default:return}}var AZ={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},l$=`
|
|
1726
|
+
.stx-img-placeholder {
|
|
1727
|
+
position: relative;
|
|
1728
|
+
overflow: hidden;
|
|
1729
|
+
background-size: cover;
|
|
1730
|
+
background-position: center;
|
|
1731
|
+
background-repeat: no-repeat;
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
.stx-img-placeholder img {
|
|
1735
|
+
opacity: 0;
|
|
1736
|
+
transition: opacity var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out);
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
.stx-img-placeholder.stx-img-loaded img {
|
|
1740
|
+
opacity: 1;
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
.stx-img-blur {
|
|
1744
|
+
filter: blur(20px);
|
|
1745
|
+
transform: scale(1.1);
|
|
1746
|
+
transition: filter var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out),
|
|
1747
|
+
transform var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out);
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
.stx-img-loaded .stx-img-blur {
|
|
1751
|
+
filter: blur(0);
|
|
1752
|
+
transform: scale(1);
|
|
1753
|
+
}
|
|
1754
|
+
`.trim();async function c$(){try{return await import("ts-images")}catch{return null}}async function I7($,Z={}){let X={...AZ,...Z},Y=await c$();if(Y)try{return await MZ($,X,Y)}catch(J){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${J}`)}return k7($,X)}async function MZ($,Z,X){let{generatePlaceholder:Y,generateThumbHash:J}=X,G={blur:"blur",thumbhash:"thumbhash",blurhash:"thumbhash",pixelate:"pixelate","dominant-color":"dominant-color",none:"blur"}[Z.strategy]||"blur";if(Z.strategy==="thumbhash")return{dataURL:(await J($)).dataUrl,width:32,height:32,aspectRatio:1,originalWidth:0,originalHeight:0,strategy:"thumbhash"};let q=await Y($,{width:Z.width,height:Z.height,quality:Z.quality,blurLevel:Z.blurLevel,strategy:G,base64Encode:!0});return{dataURL:q.dataURL,width:q.width,height:q.height,aspectRatio:q.aspectRatio,originalWidth:q.originalWidth,originalHeight:q.originalHeight,strategy:Z.strategy,dominantColor:q.dominantColor,css:q.css}}function k7($,Z){let X=Z.width||20,Y=Z.height||X,J="#e5e7eb",Q=`<svg xmlns="http://www.w3.org/2000/svg" width="${X}" height="${Y}" viewBox="0 0 ${X} ${Y}"><rect fill="#e5e7eb" width="${X}" height="${Y}"/></svg>`;return{dataURL:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(Q)}`,width:X,height:Y,aspectRatio:X/Y,originalWidth:0,originalHeight:0,strategy:Z.strategy,dominantColor:"#e5e7eb"}}async function FU($){let Z=await c$();if(Z)try{return(await Z.generateThumbHash($)).dataUrl}catch{}return(await k7($,{strategy:"thumbhash",width:32,height:32})).dataURL}function LU($){let Z=$[0]|$[1]<<8|$[2]<<16,X=(Z&63)/63,Y=(Z>>6&63)/31.5-1,J=(Z>>12&63)/31.5-1,Q=(Z>>18&31)/31,G=Z>>23!==0,q=$[3]|$[4]<<8,U=(q>>3&63)/63,W=(q>>9&63)/63,K=q>>15!==0,z=Math.max(3,K?G?5:7:G?5:7),H=Math.max(3,K?G?5:7:G?5:7),B=32,j=32,_=Math.max(0,Math.min(255,Math.round((X+Y)*255))),V=Math.max(0,Math.min(255,Math.round(X*255))),O=Math.max(0,Math.min(255,Math.round((X-Y)*255))),F=`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">
|
|
1755
|
+
<rect fill="rgb(${_},${V},${O})" width="32" height="32"/>
|
|
1756
|
+
</svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(F)}`}async function wU($,Z=20,X=50){return I7($,{strategy:"blur",width:Z,quality:X,blurLevel:40})}async function RU($){let Z=await c$();if(Z)try{return(await Z.generatePlaceholder($,{strategy:"dominant-color"})).dominantColor||"#e5e7eb"}catch{}return"#e5e7eb"}function DU($,Z=1,X=1){let Y=`<svg xmlns="http://www.w3.org/2000/svg" width="${Z}" height="${X}"><rect fill="${$}" width="${Z}" height="${X}"/></svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(Y)}`}function E7($,Z,X={}){let Y=X.transitionDuration||300,J=X.easing||"ease-out";return`
|
|
1757
|
+
#${$} {
|
|
1758
|
+
--stx-img-transition-duration: ${Y}ms;
|
|
1759
|
+
--stx-img-transition-easing: ${J};
|
|
1760
|
+
background-image: url('${Z.dataURL}');
|
|
1761
|
+
background-size: cover;
|
|
1762
|
+
background-position: center;
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
#${$} img {
|
|
1766
|
+
opacity: 0;
|
|
1767
|
+
transition: opacity var(--stx-img-transition-duration) var(--stx-img-transition-easing);
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
#${$}.stx-img-loaded img {
|
|
1771
|
+
opacity: 1;
|
|
1772
|
+
}
|
|
1773
|
+
`.trim()}function NU($){return`background-image: url('${$.dataURL}'); background-size: cover; background-position: center;`}var x1=new Map;async function b7($,Z={}){let X=`${$}:${JSON.stringify(Z)}`;if(x1.has(X))return x1.get(X);let Y=await I7($,Z);return x1.set(X,Y),Y}function AU(){x1.clear()}function MU(){return{size:x1.size,keys:Array.from(x1.keys())}}async function TZ(){try{return await import("./chunk-5n0dt838.js")}catch($){if(!y7)console.warn("[stx-media] Image processor not available, some features disabled:",$),y7=!0;return null}}var y7=!1,p$=80,h5="async",u5="lazy",S7=!1;async function z5($,Z={}){let X=Z,Y=$;if(Y.process&&!Y.skipOptimization){if(X.tsImagesConfig?.enabled&&!X.isDev)return yZ(Y,X)}if(X.processedResult?.processed)return s$($,X.processedResult,Z);if(X.responsiveVariants)return v7($,X.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:q,sizes:U,widths:W=V1,dpr:K,formats:z=f1,quality:H=p$,params:B={},placeholder:j="none",placeholderOptions:_={},lazy:V=!0,priority:O=!1,loading:F=O?"eager":u5,decoding:L=h5,fetchpriority:w,objectFit:R,objectPosition:D,crossorigin:N,referrerpolicy:T}=$,A=$.class,M=$.style,k=$.id,I=$.data||{},{isDev:y=!1,baseUrl:E=""}=Z;if(y&&!Z.optimize)return EZ($);let b,C,x=k||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!O)try{b=await b7(J,{strategy:j,..._}),C=E7(x,b,_)}catch{}let f=K!==void 0&&G!==void 0,n;if(f)n=kZ($,x,b,Z);else n=await IZ($,x,b,Z);let m;if(O){let M0=z.includes("webp")?"webp":z[0],g0=K5(J,W,{...B,q:H},M0),t=typeof U==="object"?d$(U):U||"100vw";m=`<link rel="preload" as="image" imagesrcset="${g0}" imagesizes="${t}" />`}let V0=[];if(!S7&&j!=="none")V0.push(l$),S7=!0;if(C)V0.push(C);let A0=V?P7(x):void 0;return{html:n,preloadLink:m,css:V0.length>0?V0.join(`
|
|
1774
|
+
`):void 0,script:A0}}async function IZ($,Z,X,Y){let{src:J,alt:Q,width:G,height:q,sizes:U,widths:W=V1,formats:K=f1,quality:z=p$,params:H={},lazy:B=!0,priority:j=!1,loading:_=j?"eager":u5,decoding:V=h5,fetchpriority:O,objectFit:F,objectPosition:L,crossorigin:w,referrerpolicy:R}=$,D=$.class,N=$.style,T=$.data||{},A=typeof U==="object"?d$(U):U||"100vw",M=[];for(let y of K){let E=K5(J,W,{...H,q:z},y),b=m$(y);if(B&&!j)M.push(` <source type="${b}" data-srcset="${E}" data-sizes="${A}" />`);else M.push(` <source type="${b}" srcset="${E}" sizes="${A}" />`)}let k=i$({src:G1(J,{...H,q:z}),alt:Q,width:G,height:q,loading:j?void 0:_,decoding:V,fetchpriority:j?"high":O,objectFit:F,objectPosition:L,crossorigin:w,referrerpolicy:R,className:C7(D,X),style:n$(N,F,L,X),lazy:B&&!j,data:T}),I;if(X){let y=`background-image: url('${X.dataURL}'); background-size: cover; background-position: center;`;I=`<div id="${Z}" class="stx-img-placeholder" style="${y}">
|
|
1775
|
+
<picture>
|
|
1776
|
+
${M.join(`
|
|
1777
|
+
`)}
|
|
1778
|
+
<img ${k} />
|
|
1779
|
+
</picture>
|
|
1780
|
+
</div>`}else I=`<picture${Z?` id="${Z}"`:""}>
|
|
1781
|
+
${M.join(`
|
|
1782
|
+
`)}
|
|
1783
|
+
<img ${k} />
|
|
1784
|
+
</picture>`;return I}function kZ($,Z,X,Y){let{src:J,alt:Q,width:G,height:q,dpr:U=[1,2,3],quality:W=p$,params:K={},lazy:z=!0,priority:H=!1,loading:B=H?"eager":u5,decoding:j=h5,fetchpriority:_,objectFit:V,objectPosition:O,crossorigin:F,referrerpolicy:L}=$,w=$.class,R=$.style,D=$.data||{},N=typeof G==="number"?G:Number.parseInt(String(G),10),T=u$(J,N,U,{...K,q:W}),A=i$({src:G1(J,{...K,w:N,q:W}),alt:Q,width:G,height:q,loading:H?void 0:B,decoding:j,fetchpriority:H?"high":_,objectFit:V,objectPosition:O,crossorigin:F,referrerpolicy:L,className:C7(w,X),style:n$(R,V,O,X),lazy:z&&!H,data:D}),M=z&&!H?`data-srcset="${T}"`:`srcset="${T}"`;if(X){let k=`background-image: url('${X.dataURL}'); background-size: cover; background-position: center;`;return`<div id="${Z}" class="stx-img-placeholder" style="${k}">
|
|
1785
|
+
<img ${A} ${M} />
|
|
1786
|
+
</div>`}return`<img ${Z?`id="${Z}" `:""}${A} ${M} />`}function EZ($){let{src:Z,alt:X,width:Y,height:J,loading:Q=u5,decoding:G=h5,fetchpriority:q,objectFit:U,objectPosition:W,crossorigin:K,referrerpolicy:z,priority:H=!1}=$,B=$.class,j=$.style,_=$.id,V=$.data||{};return{html:`<img ${i$({src:Z,alt:X,width:Y,height:J,loading:H?"eager":Q,decoding:G,fetchpriority:H?"high":q,objectFit:U,objectPosition:W,crossorigin:K,referrerpolicy:z,className:B,style:n$(j,U,W),id:_,data:V})} />`}}function i$($){let Z=[];if($.lazy)Z.push(`data-src="${h0($.src)}"`),Z.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else Z.push(`src="${h0($.src)}"`);if(Z.push(`alt="${h0($.alt)}"`),$.width)Z.push(`width="${$.width}"`);if($.height)Z.push(`height="${$.height}"`);if($.loading)Z.push(`loading="${$.loading}"`);if($.decoding)Z.push(`decoding="${$.decoding}"`);if($.fetchpriority)Z.push(`fetchpriority="${$.fetchpriority}"`);if($.crossorigin)Z.push(`crossorigin="${$.crossorigin}"`);if($.referrerpolicy)Z.push(`referrerpolicy="${$.referrerpolicy}"`);if($.className)Z.push(`class="${h0($.className)}"`);if($.style)Z.push(`style="${h0($.style)}"`);if($.id)Z.push(`id="${h0($.id)}"`);if($.data)for(let[X,Y]of Object.entries($.data))Z.push(`data-${X}="${h0(Y)}"`);if($.lazy)Z.push("data-stx-lazy");return Z.join(" ")}function C7($,Z){let X=[];if($)X.push($);if(Z)X.push("stx-img-blur");return X.join(" ")||""}function n$($,Z,X,Y){let J=[];if(Z)J.push(`object-fit: ${Z}`);if(X)J.push(`object-position: ${X}`);if(Y)J.push("opacity: 0; transition: opacity 300ms ease-out");if($)J.push($);return J.join("; ")}function h0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function P7($){return`
|
|
1787
|
+
(function() {
|
|
1788
|
+
const container = document.getElementById('${$}');
|
|
1789
|
+
if (!container) return;
|
|
1790
|
+
|
|
1791
|
+
const img = container.querySelector('img[data-stx-lazy]') || container;
|
|
1792
|
+
if (!img.dataset.src && !img.dataset.srcset) return;
|
|
1793
|
+
|
|
1794
|
+
const observer = new IntersectionObserver((entries) => {
|
|
1795
|
+
entries.forEach(entry => {
|
|
1796
|
+
if (entry.isIntersecting) {
|
|
1797
|
+
// Load image
|
|
1798
|
+
if (img.dataset.src) img.src = img.dataset.src;
|
|
1799
|
+
if (img.dataset.srcset) img.srcset = img.dataset.srcset;
|
|
1800
|
+
|
|
1801
|
+
// Load sources
|
|
1802
|
+
const sources = container.querySelectorAll('source[data-srcset]');
|
|
1803
|
+
sources.forEach(source => {
|
|
1804
|
+
if (source.dataset.srcset) source.srcset = source.dataset.srcset;
|
|
1805
|
+
if (source.dataset.sizes) source.sizes = source.dataset.sizes;
|
|
1806
|
+
});
|
|
1807
|
+
|
|
1808
|
+
// Handle load completion
|
|
1809
|
+
img.onload = () => {
|
|
1810
|
+
img.style.opacity = '1';
|
|
1811
|
+
if (container.classList.contains('stx-img-placeholder')) {
|
|
1812
|
+
container.classList.add('stx-img-loaded');
|
|
1813
|
+
}
|
|
1814
|
+
};
|
|
1815
|
+
|
|
1816
|
+
observer.disconnect();
|
|
1817
|
+
}
|
|
1818
|
+
});
|
|
1819
|
+
}, { rootMargin: '50px' });
|
|
1820
|
+
|
|
1821
|
+
observer.observe(container);
|
|
1822
|
+
})();
|
|
1823
|
+
`.trim()}function bZ($){let Z=$.match(/<Img\s+([^>]*?)\/?>/);if(!Z)return null;let X=Z[1],Y={},J=/(:?)(\w+)(?:=(?:"([^"]*)"|'([^']*)'|\{([^}]+)\}))?/g,Q;while((Q=J.exec(X))!==null){let[,G,q,U,W,K]=Q,z=U??W??K??!0;if(G===":"&&typeof z==="string")try{Y[q]=JSON.parse(z)}catch{Y[q]=z}else switch(q){case"src":Y.src=String(z);break;case"alt":Y.alt=String(z);break;case"width":Y.width=Number(z)||z;break;case"height":Y.height=Number(z)||z;break;case"sizes":Y.sizes=String(z);break;case"quality":Y.quality=Number(z);break;case"placeholder":Y.placeholder=z;break;case"lazy":Y.lazy=z===!0||z==="true";break;case"priority":Y.priority=z===!0||z==="true";break;case"class":Y.class=String(z);break;case"style":Y.style=String(z);break;case"id":Y.id=String(z);break;case"loading":Y.loading=z;break;case"decoding":Y.decoding=z;break;case"fetchpriority":Y.fetchpriority=z;break;case"objectFit":Y.objectFit=z;break;case"objectPosition":Y.objectPosition=String(z);break;case"crossorigin":Y.crossorigin=z;break}}if(!Y.src||!Y.alt)return null;return Y}async function EU($,Z={}){let X=/<Img\s+[^>]*?\/?>/g,Y=[],J=[],Q=[],G=$,q=[],U;while((U=X.exec($))!==null)q.push({match:U[0],index:U.index});for(let W=q.length-1;W>=0;W--){let{match:K}=q[W],z=bZ(K);if(z){let H=await z5(z,Z);if(G=G.replace(K,H.html),H.preloadLink)Y.push(H.preloadLink);if(H.css)J.push(H.css);if(H.script)Q.push(H.script)}}return{html:G,preloadLinks:Y,styles:J,scripts:Q}}async function yZ($,Z){let X=await TZ();if(!X)return z5({...$,process:!1},Z);let Y=Z.tsImagesConfig;if($.responsiveWidths&&$.responsiveWidths.length>0||$.widths&&$.widths.length>0||!$.width&&!$.dpr){let Q=await X.generateResponsiveVariants($.src,$,Y);if(Q)return v7($,Q,Z)}else{let Q=await X.processImage($.src,$,Y);if(Q.processed)return s$($,Q,Z)}return z5({...$,process:!1},Z)}async function s$($,Z,X){let{alt:Y,width:J,height:Q,lazy:G=!0,priority:q=!1,objectFit:U,objectPosition:W,crossorigin:K,referrerpolicy:z}=$,H=$.class,B=$.style,j=$.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,_=$.data||{},V=Z.variants||[],O=V.find((C)=>C.format==="jpeg")||V.find((C)=>C.format==="webp")||V[0],F=O?.url||$.src,L=V.filter((C)=>C.format===(O?.format||"jpeg")).map((C)=>`${C.url} ${C.width}w`).join(", "),w=new Map;for(let C of V){if(!w.has(C.format))w.set(C.format,[]);w.get(C.format).push(C)}let R=[],D=["avif","webp","jpeg","png"];for(let C of D){let x=w.get(C);if(x&&x.length>0){let f=x.map((m)=>`${m.url} ${m.width}w`).join(", "),n=m$(C);if(G&&!q)R.push(` <source type="${n}" data-srcset="${f}" />`);else R.push(` <source type="${n}" srcset="${f}" />`)}}let N=[];if(G&&!q){if(N.push(`data-src="${h0(F)}"`),N.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),L)N.push(`data-srcset="${L}"`)}else if(N.push(`src="${h0(F)}"`),L)N.push(`srcset="${L}"`);N.push(`alt="${h0(Y)}"`);let T=J||Z.originalWidth,A=Q||Z.originalHeight;if(T)N.push(`width="${T}"`);if(A)N.push(`height="${A}"`);if(!q)N.push(`loading="${G?"lazy":"eager"}"`);if(N.push('decoding="async"'),q)N.push('fetchpriority="high"');if(K)N.push(`crossorigin="${K}"`);if(z)N.push(`referrerpolicy="${z}"`);let M=[];if(U)M.push(`object-fit: ${U}`);if(W)M.push(`object-position: ${W}`);if(Z.placeholder&&G)M.push("opacity: 0; transition: opacity 300ms ease-out");if(B)M.push(B);if(M.length>0)N.push(`style="${M.join("; ")}"`);let k=[];if(H)k.push(H);if(Z.placeholder)k.push("stx-img-blur");if(k.length>0)N.push(`class="${k.join(" ")}"`);if(G&&!q)N.push("data-stx-lazy");for(let[C,x]of Object.entries(_))N.push(`data-${C}="${h0(x)}"`);let I;if(Z.placeholder||Z.dominantColor&&$.useDominantColor){let C=Z.placeholder?`background-image: url('${Z.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${Z.dominantColor};`;I=`<div id="${j}" class="stx-img-placeholder" style="${C}">
|
|
1824
|
+
<picture>
|
|
1825
|
+
${R.join(`
|
|
1826
|
+
`)}
|
|
1827
|
+
<img ${N.join(" ")} />
|
|
1828
|
+
</picture>
|
|
1829
|
+
</div>`}else I=`<picture${j?` id="${j}"`:""}>
|
|
1830
|
+
${R.join(`
|
|
1831
|
+
`)}
|
|
1832
|
+
<img ${N.join(" ")} />
|
|
1833
|
+
</picture>`;let y=[];if(Z.placeholder)y.push(l$);let E=G?P7(j):void 0,b;if(q&&L)b=`<link rel="preload" as="image" imagesrcset="${L}" />`;return{html:I,preloadLink:b,css:y.length>0?y.join(`
|
|
1834
|
+
`):void 0,script:E}}async function v7($,Z,X){let Y={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[J,Q]of Object.entries(Z.byFormat))if(Q)Y.variants.push(...Q);return s$($,Y,X)}function SZ(){return d5({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,X,Y)=>{let{src:J,alt:Q,options:G}=CZ($,Z,X);if(!J)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let q={src:J,alt:Q||"",widths:G.widths||V1,formats:G.formats||f1,quality:G.quality,sizes:G.sizes,dpr:G.dpr,params:G.params,placeholder:G.placeholder,placeholderOptions:G.placeholderOptions,lazy:G.lazy!==!1,priority:G.priority||!1,loading:G.loading,decoding:G.decoding,fetchpriority:G.fetchpriority,objectFit:G.objectFit,objectPosition:G.objectPosition,class:G.class,style:G.style,id:G.id,width:G.width,height:G.height},U=X.__isDev||!1,W=await z5(q,{isDev:U}),K=W.html;if(W.preloadLink)K=W.preloadLink+`
|
|
1835
|
+
`+K;if(W.css)K+=`
|
|
1836
|
+
<style>${W.css}</style>`;if(W.script)K+=`
|
|
1837
|
+
<script>${W.script}</script>`;return K},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function CZ($,Z,X){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let Y=$.trim();if(Y.startsWith("@img(")||Y.startsWith("("))Y=Y.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let J=PZ(Y),Q=o$(J[0],X)||"",G=o$(J[1],X)||"",q={};if(J[2]){let U=o$(J[2],X);if(typeof U==="object"&&U!==null)q=U;else if(typeof J[2]==="string")try{q=JSON.parse(J[2])}catch{}}return{src:Q,alt:G,options:q}}function PZ($){let Z=[],X="",Y=!1,J="",Q=0,G=0;for(let q=0;q<$.length;q++){let U=$[q],W=q>0?$[q-1]:"";if((U==='"'||U==="'"||U==="`")&&W!=="\\"){if(!Y)Y=!0,J=U;else if(U===J)Y=!1,J="";else X+=U;continue}if(!Y){if(U==="{")Q++;if(U==="}")Q--;if(U==="[")G++;if(U==="]")G--;if(U===","&&Q===0&&G===0){Z.push(X.trim()),X="";continue}}X+=U}if(X.trim())Z.push(X.trim());return Z}function o$($,Z){if(typeof $!=="string")return $;let X=$.trim();if(X.startsWith('"')&&X.endsWith('"')||X.startsWith("'")&&X.endsWith("'"))return X.slice(1,-1);if(!X.startsWith("/")&&!X.startsWith(".")&&!X.startsWith("http")&&!X.startsWith("{")){let Y=Z[X];if(Y!==void 0)return Y}if(X.startsWith("{")||X.startsWith("["))try{return JSON.parse(X)}catch{}return X}var f7=SZ();async function g7(){try{return await import("./chunk-nsjyn31z.js")}catch($){if(!x7)console.warn("[stx-media] Video processor not available, some features disabled:",$),x7=!0;return null}}var x7=!1,h7=!0,u7="metadata",vZ="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";async function m5($,Z={}){let X=Z,Y=$;if(Y.process&&!Y.skipProcessing){if(X.tsVideosConfig?.enabled&&!X.isDev)return uZ(Y,X)}if(X.processedResult?.processed)return m7($,X.processedResult,Z);let J;if(Y.generatePoster&&Y.src&&!$.poster)J=await dZ(Y,X);let{src:Q,sources:G=[],poster:q,posterPlaceholder:U,controls:W=h7,autoplay:K=!1,muted:z=!1,loop:H=!1,preload:B=u7,playsinline:j=!0,lazy:_=!0,player:V="native",type:O,width:F,height:L,crossorigin:w,disablePictureInPicture:R=!1,disableRemotePlayback:D=!1}=$,N=J||q,T=$.class,A=$.style,M=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(V==="ts-video")return xZ($,Z);if(O&&O!=="video")return fZ(Q||"",O,$);let k=G.length>0?G:Q?[{src:Q,type:d7(Q)}]:[],I=[`id="${M}"`];if(W)I.push("controls");if(K)I.push("autoplay");if(z)I.push("muted");if(H)I.push("loop");if(j)I.push("playsinline");if(R)I.push("disablepictureinpicture");if(D)I.push("disableremoteplayback");if(w)I.push(`crossorigin="${w}"`);if(_){if(I.push(`data-preload="${B}"`),I.push('preload="none"'),N)I.push(`data-poster="${O0(N)}"`);I.push("data-stx-lazy")}else if(I.push(`preload="${B}"`),N)I.push(`poster="${O0(N)}"`);if(F)I.push(`width="${F}"`);if(L)I.push(`height="${L}"`);if(T)I.push(`class="${O0(T)}"`);if(A)I.push(`style="${O0(A)}"`);let y=k.map((C)=>{return` <source ${_?`data-src="${O0(C.src)}"`:`src="${O0(C.src)}"`} type="${C.type}"${C.media?` media="${C.media}"`:""} />`}).join(`
|
|
1838
|
+
`),E=`<video ${I.join(" ")}>
|
|
1839
|
+
${y}
|
|
1840
|
+
Your browser does not support the video tag.
|
|
1841
|
+
</video>`,b;if(_)b=`
|
|
1842
|
+
(function() {
|
|
1843
|
+
var video = document.getElementById('${M}');
|
|
1844
|
+
if (!video) return;
|
|
1845
|
+
|
|
1846
|
+
var observer = new IntersectionObserver(function(entries) {
|
|
1847
|
+
entries.forEach(function(entry) {
|
|
1848
|
+
if (entry.isIntersecting) {
|
|
1849
|
+
// Load poster
|
|
1850
|
+
if (video.dataset.poster) {
|
|
1851
|
+
video.poster = video.dataset.poster;
|
|
1852
|
+
delete video.dataset.poster;
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
// Load sources
|
|
1856
|
+
var sources = video.querySelectorAll('source[data-src]');
|
|
1857
|
+
sources.forEach(function(source) {
|
|
1858
|
+
source.src = source.dataset.src;
|
|
1859
|
+
delete source.dataset.src;
|
|
1860
|
+
});
|
|
1861
|
+
|
|
1862
|
+
// Set preload
|
|
1863
|
+
if (video.dataset.preload) {
|
|
1864
|
+
video.preload = video.dataset.preload;
|
|
1865
|
+
delete video.dataset.preload;
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
video.load();
|
|
1869
|
+
observer.disconnect();
|
|
1870
|
+
}
|
|
1871
|
+
});
|
|
1872
|
+
}, { rootMargin: '50px' });
|
|
1873
|
+
|
|
1874
|
+
observer.observe(video);
|
|
1875
|
+
})();
|
|
1876
|
+
`.trim();return{html:E,script:b}}function fZ($,Z,X){let{width:Y=640,height:J=360}=X,Q=X.class,G=X.style,q=X.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,U,W=null;switch(Z){case"youtube":W=gZ($),U=W?`https://www.youtube-nocookie.com/embed/${W}`:$;break;case"vimeo":W=hZ($),U=W?`https://player.vimeo.com/video/${W}`:$;break;case"dailymotion":W=$.split("/").pop()||"",U=`https://www.dailymotion.com/embed/video/${W}`;break;case"twitch":W=$.split("/").pop()||"",U=`https://player.twitch.tv/?video=${W}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:U=$}let K=[`id="${q}"`,`src="${O0(U)}"`,`width="${Y}"`,`height="${J}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(Q)K.push(`class="${O0(Q)}"`);if(G)K.push(`style="${O0(G)}"`);if(X.lazy)K.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
|
|
1877
|
+
<iframe ${K.join(" ")} style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
|
|
1878
|
+
</div>`}}function xZ($,Z={}){let{src:X,sources:Y=[],poster:J,controls:Q=!0,autoplay:G=!1,muted:q=!1,loop:U=!1,preload:W="metadata",playsinline:K=!0,lazy:z=!0,width:H,height:B}=$,j=$.class,_=$.style,V=$.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,O={src:Y.length>0?Y:X,autoplay:G,loop:U,muted:q,playsinline:K,preload:W,poster:J,controls:Q,title:$.title},F=["position: relative",H?`width: ${typeof H==="number"?H+"px":H}`:"width: 100%",B?`height: ${typeof B==="number"?B+"px":B}`:"",_||""].filter(Boolean).join("; "),L=`
|
|
1879
|
+
<div
|
|
1880
|
+
id="${V}"
|
|
1881
|
+
class="ts-video-player${j?" "+O0(j):""}"
|
|
1882
|
+
style="${F}"
|
|
1883
|
+
data-ts-video-player
|
|
1884
|
+
data-config='${JSON.stringify(O)}'
|
|
1885
|
+
${z?"data-lazy":""}
|
|
1886
|
+
>
|
|
1887
|
+
<div class="ts-video-player__container">
|
|
1888
|
+
${J?`
|
|
1889
|
+
<div class="ts-video-player__placeholder" style="background-image: url('${O0(J)}');">
|
|
1890
|
+
<button class="ts-video-player__play-button" aria-label="Play video">
|
|
1891
|
+
<svg viewBox="0 0 24 24" fill="currentColor" width="64" height="64">
|
|
1892
|
+
<path d="M8 5v14l11-7z"/>
|
|
1893
|
+
</svg>
|
|
1894
|
+
</button>
|
|
1895
|
+
</div>
|
|
1896
|
+
`:""}
|
|
1897
|
+
</div>
|
|
1898
|
+
</div>
|
|
1899
|
+
`.trim(),w=`
|
|
1900
|
+
(function() {
|
|
1901
|
+
var container = document.getElementById('${V}');
|
|
1902
|
+
if (!container) return;
|
|
1903
|
+
|
|
1904
|
+
var config = JSON.parse(container.dataset.config || '{}');
|
|
1905
|
+
var isLazy = container.hasAttribute('data-lazy');
|
|
1906
|
+
|
|
1907
|
+
function loadPlayer() {
|
|
1908
|
+
if (typeof TSVideoPlayer !== 'undefined') {
|
|
1909
|
+
initPlayer();
|
|
1910
|
+
return;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
// Load ts-video-player from CDN
|
|
1914
|
+
var script = document.createElement('script');
|
|
1915
|
+
script.src = '${vZ}';
|
|
1916
|
+
script.onload = initPlayer;
|
|
1917
|
+
script.onerror = function() {
|
|
1918
|
+
console.error('[stx] Failed to load ts-video-player');
|
|
1919
|
+
fallbackToNative();
|
|
1920
|
+
};
|
|
1921
|
+
document.head.appendChild(script);
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
function initPlayer() {
|
|
1925
|
+
var player = TSVideoPlayer.createPlayer(container, config);
|
|
1926
|
+
if (config.src) {
|
|
1927
|
+
player.setSrc(config.src);
|
|
1928
|
+
}
|
|
1929
|
+
container.__tsVideoPlayer = player;
|
|
1930
|
+
|
|
1931
|
+
// Remove placeholder
|
|
1932
|
+
var placeholder = container.querySelector('.ts-video-player__placeholder');
|
|
1933
|
+
if (placeholder) {
|
|
1934
|
+
placeholder.style.display = 'none';
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
function fallbackToNative() {
|
|
1939
|
+
// Fallback to native video element
|
|
1940
|
+
var video = document.createElement('video');
|
|
1941
|
+
video.controls = config.controls !== false;
|
|
1942
|
+
video.autoplay = config.autoplay;
|
|
1943
|
+
video.muted = config.muted;
|
|
1944
|
+
video.loop = config.loop;
|
|
1945
|
+
video.playsInline = config.playsinline;
|
|
1946
|
+
video.preload = config.preload || 'metadata';
|
|
1947
|
+
if (config.poster) video.poster = config.poster;
|
|
1948
|
+
if (config.src) video.src = typeof config.src === 'string' ? config.src : config.src[0]?.src || config.src[0];
|
|
1949
|
+
video.style.width = '100%';
|
|
1950
|
+
video.style.height = '100%';
|
|
1951
|
+
|
|
1952
|
+
var containerEl = container.querySelector('.ts-video-player__container');
|
|
1953
|
+
if (containerEl) {
|
|
1954
|
+
containerEl.innerHTML = '';
|
|
1955
|
+
containerEl.appendChild(video);
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
if (isLazy) {
|
|
1960
|
+
var observer = new IntersectionObserver(function(entries) {
|
|
1961
|
+
entries.forEach(function(entry) {
|
|
1962
|
+
if (entry.isIntersecting) {
|
|
1963
|
+
loadPlayer();
|
|
1964
|
+
observer.disconnect();
|
|
1965
|
+
}
|
|
1966
|
+
});
|
|
1967
|
+
}, { rootMargin: '50px' });
|
|
1968
|
+
observer.observe(container);
|
|
1969
|
+
}
|
|
1970
|
+
else {
|
|
1971
|
+
if (document.readyState === 'loading') {
|
|
1972
|
+
document.addEventListener('DOMContentLoaded', loadPlayer);
|
|
1973
|
+
}
|
|
1974
|
+
else {
|
|
1975
|
+
loadPlayer();
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
// Handle play button click
|
|
1980
|
+
var playButton = container.querySelector('.ts-video-player__play-button');
|
|
1981
|
+
if (playButton) {
|
|
1982
|
+
playButton.addEventListener('click', function() {
|
|
1983
|
+
loadPlayer();
|
|
1984
|
+
var check = setInterval(function() {
|
|
1985
|
+
if (container.__tsVideoPlayer && container.__tsVideoPlayer.ready) {
|
|
1986
|
+
container.__tsVideoPlayer.play();
|
|
1987
|
+
clearInterval(check);
|
|
1988
|
+
}
|
|
1989
|
+
}, 100);
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
})();
|
|
1993
|
+
`.trim(),R=`
|
|
1994
|
+
.ts-video-player {
|
|
1995
|
+
position: relative;
|
|
1996
|
+
background: #000;
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
.ts-video-player__container {
|
|
2000
|
+
position: relative;
|
|
2001
|
+
width: 100%;
|
|
2002
|
+
padding-bottom: 56.25%;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
.ts-video-player__container > * {
|
|
2006
|
+
position: absolute;
|
|
2007
|
+
top: 0;
|
|
2008
|
+
left: 0;
|
|
2009
|
+
width: 100%;
|
|
2010
|
+
height: 100%;
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
.ts-video-player__placeholder {
|
|
2014
|
+
display: flex;
|
|
2015
|
+
align-items: center;
|
|
2016
|
+
justify-content: center;
|
|
2017
|
+
background-color: #1a1a1a;
|
|
2018
|
+
background-size: cover;
|
|
2019
|
+
background-position: center;
|
|
2020
|
+
cursor: pointer;
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
.ts-video-player__play-button {
|
|
2024
|
+
display: flex;
|
|
2025
|
+
align-items: center;
|
|
2026
|
+
justify-content: center;
|
|
2027
|
+
width: 80px;
|
|
2028
|
+
height: 80px;
|
|
2029
|
+
background: rgba(0, 0, 0, 0.7);
|
|
2030
|
+
border: none;
|
|
2031
|
+
border-radius: 50%;
|
|
2032
|
+
color: white;
|
|
2033
|
+
cursor: pointer;
|
|
2034
|
+
transition: transform 0.2s, background 0.2s;
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
.ts-video-player__play-button:hover {
|
|
2038
|
+
transform: scale(1.1);
|
|
2039
|
+
background: rgba(0, 0, 0, 0.9);
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
.ts-video-player__play-button svg {
|
|
2043
|
+
margin-left: 4px;
|
|
2044
|
+
}
|
|
2045
|
+
`.trim();return{html:L,script:w,css:R}}function d7($){switch($.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 gZ($){let Z=[/youtube\.com\/watch\?v=([^&]+)/,/youtube\.com\/embed\/([^?]+)/,/youtu\.be\/([^?]+)/,/youtube\.com\/v\/([^?]+)/];for(let X of Z){let Y=$.match(X);if(Y)return Y[1]}return null}function hZ($){let Z=$.match(/vimeo\.com\/(\d+)/);return Z?Z[1]:null}function O0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'")}function vU($,Z,X){if(Z.src)return{src:String(Z.src),...Z};let Y=$.trim();if(Y.startsWith("@video(")||Y.startsWith("("))Y=Y.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let J=Y.indexOf(",");if(J===-1)return{src:Y.replace(/^['"]|['"]$/g,"")};let Q=Y.slice(0,J).trim().replace(/^['"]|['"]$/g,""),G=Y.slice(J+1).trim();try{let q=JSON.parse(G);return{src:Q,...q}}catch{return{src:Q}}}async function uZ($,Z){let X=await g7();if(!X)return m5({...$,process:!1},Z);let Y=Z.tsVideosConfig,J=await X.processVideo($.src,$,Y,$.onProcessProgress);if(J.processed)return m7($,J,Z);return m5({...$,process:!1},Z)}async function dZ($,Z){let X=await g7();if(!X||!$.src)return;let Y=typeof $.generatePoster==="object"?$.generatePoster:{timestamp:0},J=Z.tsVideosConfig||{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos"};return(await X.generatePoster($.src,Y,J.outputDir,J.baseUrl||"/videos"))?.url}function m7($,Z,X){let{controls:Y=h7,autoplay:J=!1,muted:Q=!1,loop:G=!1,preload:q=u7,playsinline:U=!0,lazy:W=!0,width:K,height:z,crossorigin:H,disablePictureInPicture:B=!1,disableRemotePlayback:j=!1}=$,_=$.class,V=$.style,O=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`,F=$.src,L=d7(F);if(Z.transcoded)F=Z.transcoded.url,L="video/mp4";let w=Z.streaming?.hls||Z.streaming?.dash;if(w){if(Z.streaming?.hls)F=Z.streaming.hls.manifestUrl,L="application/x-mpegURL";else if(Z.streaming?.dash)F=Z.streaming.dash.manifestUrl,L="application/dash+xml"}let R=Z.poster?.url||$.poster,D=[`id="${O}"`];if(Y)D.push("controls");if(J)D.push("autoplay");if(Q)D.push("muted");if(G)D.push("loop");if(U)D.push("playsinline");if(B)D.push("disablepictureinpicture");if(j)D.push("disableremoteplayback");if(H)D.push(`crossorigin="${H}"`);if(W){if(D.push(`data-preload="${q}"`),D.push('preload="none"'),R)D.push(`data-poster="${O0(R)}"`);D.push("data-stx-lazy")}else if(D.push(`preload="${q}"`),R)D.push(`poster="${O0(R)}"`);let N=K||Z.metadata?.width,T=z||Z.metadata?.height;if(N)D.push(`width="${N}"`);if(T)D.push(`height="${T}"`);if(_)D.push(`class="${O0(_)}"`);if(V)D.push(`style="${O0(V)}"`);let M=` <source ${W?`data-src="${O0(F)}"`:`src="${O0(F)}"`} type="${L}" />`,k=`<video ${D.join(" ")}>
|
|
2046
|
+
${M}
|
|
2047
|
+
Your browser does not support the video tag.
|
|
2048
|
+
</video>`;if(Z.spriteSheet)k=`<div class="stx-video-wrapper" data-sprite-sheet="${O0(Z.spriteSheet.url)}" data-sprite-cols="${Z.spriteSheet.columns}" data-sprite-interval="${Z.spriteSheet.interval}">
|
|
2049
|
+
${k}
|
|
2050
|
+
</div>`;let I;if(W)I=`
|
|
2051
|
+
(function() {
|
|
2052
|
+
var video = document.getElementById('${O}');
|
|
2053
|
+
if (!video) return;
|
|
2054
|
+
|
|
2055
|
+
var observer = new IntersectionObserver(function(entries) {
|
|
2056
|
+
entries.forEach(function(entry) {
|
|
2057
|
+
if (entry.isIntersecting) {
|
|
2058
|
+
// Load poster
|
|
2059
|
+
if (video.dataset.poster) {
|
|
2060
|
+
video.poster = video.dataset.poster;
|
|
2061
|
+
delete video.dataset.poster;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
// Load sources
|
|
2065
|
+
var sources = video.querySelectorAll('source[data-src]');
|
|
2066
|
+
sources.forEach(function(source) {
|
|
2067
|
+
source.src = source.dataset.src;
|
|
2068
|
+
delete source.dataset.src;
|
|
2069
|
+
});
|
|
2070
|
+
|
|
2071
|
+
// Set preload
|
|
2072
|
+
if (video.dataset.preload) {
|
|
2073
|
+
video.preload = video.dataset.preload;
|
|
2074
|
+
delete video.dataset.preload;
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
video.load();
|
|
2078
|
+
observer.disconnect();
|
|
2079
|
+
}
|
|
2080
|
+
});
|
|
2081
|
+
}, { rootMargin: '50px' });
|
|
2082
|
+
|
|
2083
|
+
observer.observe(video);
|
|
2084
|
+
})();
|
|
2085
|
+
`.trim();let y;if(w)y=`
|
|
2086
|
+
.stx-video-wrapper {
|
|
2087
|
+
position: relative;
|
|
2088
|
+
width: 100%;
|
|
2089
|
+
}
|
|
2090
|
+
.stx-video-wrapper video {
|
|
2091
|
+
width: 100%;
|
|
2092
|
+
height: auto;
|
|
2093
|
+
}
|
|
2094
|
+
`.trim();return{html:k,script:I,css:y}}function l7(){return d5({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async($,Z,X,Y)=>{let{src:J,options:Q}=mZ($,Z,X);if(!J)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let G={src:J,poster:Q.poster,controls:Q.controls!==!1,autoplay:Q.autoplay||!1,muted:Q.muted||!1,loop:Q.loop||!1,preload:Q.preload||"metadata",playsinline:Q.playsinline!==!1,lazy:Q.lazy!==!1,player:Q.player||"native",type:Q.type,width:Q.width,height:Q.height,class:Q.class,style:Q.style,id:Q.id,crossorigin:Q.crossorigin,disablePictureInPicture:Q.disablePictureInPicture,disableRemotePlayback:Q.disableRemotePlayback,title:Q.title,quality:Q.quality,platform:Q.platform,process:Q.process,generatePoster:Q.generatePoster,streaming:Q.streaming,transcode:Q.transcode,spriteSheet:Q.spriteSheet,waveform:Q.waveform},U={isDev:X.__isDev||!1,tsVideosConfig:X.__tsVideosConfig},W=await m5(G,U),K=W.html;if(W.css)K+=`
|
|
2095
|
+
<style>${W.css}</style>`;if(W.script)K+=`
|
|
2096
|
+
<script>${W.script}</script>`;return K},defaults:{src:"",options:{controls:!0,lazy:!0,preload:"metadata"}}})}function mZ($,Z,X){if(Z.src)return{src:String(Z.src),options:Z.options||{}};let Y=$.trim();if(Y.startsWith("@video(")||Y.startsWith("("))Y=Y.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let J=lZ(Y),Q=c7(J[0],X)||"",G={};if(J[1]){let q=c7(J[1],X);if(typeof q==="object"&&q!==null)G=q;else if(typeof J[1]==="string")try{G=JSON.parse(J[1])}catch{}}return{src:Q,options:G}}function lZ($){let Z=[],X="",Y=!1,J="",Q=0,G=0;for(let q=0;q<$.length;q++){let U=$[q],W=q>0?$[q-1]:"";if((U==='"'||U==="'"||U==="`")&&W!=="\\"){if(!Y)Y=!0,J=U;else if(U===J)Y=!1,J="";else X+=U;continue}if(!Y){if(U==="{")Q++;if(U==="}")Q--;if(U==="[")G++;if(U==="]")G--;if(U===","&&Q===0&&G===0){Z.push(X.trim()),X="";continue}}X+=U}if(X.trim())Z.push(X.trim());return Z}function c7($,Z){if(typeof $!=="string")return $;let X=$.trim();if(X.startsWith('"')&&X.endsWith('"')||X.startsWith("'")&&X.endsWith("'"))return X.slice(1,-1);if(!X.startsWith("/")&&!X.startsWith(".")&&!X.startsWith("http")&&!X.startsWith("{")){let Y=Z[X];if(Y!==void 0)return Y}if(X.startsWith("{")||X.startsWith("["))try{return JSON.parse(X)}catch{}return X}var r$=l7();var cZ={1001:{message:"Unclosed directive: {{directive}}",help:"Make sure to close the directive with the appropriate end tag"},1002:{message:"Unclosed expression at position {{position}}",help:"Check for missing closing braces }}"},1003:{message:"Invalid directive syntax: {{directive}}",help:"Review the directive documentation for correct syntax"},1004:{message:"Malformed expression: {{expression}}",help:"Check for syntax errors in your expression"},1005:{message:"Unexpected token: {{token}}",help:"Remove or fix the unexpected token"},1101:{message:"Undefined variable: {{variable}}",help:"Make sure the variable is defined in the template context"},1102:{message:"Type error: {{details}}",help:"Check that you are using the correct types"},1103:{message:"Evaluation error: {{details}}",help:"Review the expression for errors"},1104:{message:"Infinite loop detected in {{location}}",help:"Check your loop conditions"},1105:{message:"Circular reference detected: {{path}}",help:"Remove the circular dependency"},1201:{message:"Unsafe expression blocked: {{expression}}",help:"This expression contains potentially dangerous code"},1202:{message:"Path traversal attempt blocked: {{path}}",help:"Use only relative paths within allowed directories"},1203:{message:"Potential XSS attempt blocked",help:"Sanitize user input before rendering"},1204:{message:"Code injection attempt blocked: {{code}}",help:"Avoid executing dynamic code"},1205:{message:"Prohibited DOM API usage: {{api}}",help:"Use STX.useRefs(), STX.useRef(), STX.el() and other STX helpers instead of direct DOM manipulation"},1301:{message:"File not found: {{path}}",help:"Check that the file exists and the path is correct"},1302:{message:"Error reading file: {{path}}",help:"Check file permissions and encoding"},1303:{message:"Invalid file path: {{path}}",help:"Use a valid file path"},1304:{message:"Permission denied: {{path}}",help:"Check file permissions"},1401:{message:"Invalid configuration: {{details}}",help:"Review your stx.config.ts file"},1402:{message:"Missing required configuration: {{key}}",help:"Add the required configuration option"},1403:{message:"Deprecated configuration: {{key}}",help:"Update to the new configuration format"},1501:{message:"Component not found: {{name}}",help:"Check that the component exists in your components directory"},1502:{message:"Invalid props for component {{name}}: {{details}}",help:"Check the component prop requirements"},1503:{message:"Error rendering component {{name}}: {{details}}",help:"Check the component template for errors"},1601:{message:"Filter not found: {{filter}}",help:"Register the filter or check the filter name"},1602:{message:"Invalid arguments for filter {{filter}}: {{details}}",help:"Check the filter documentation for correct arguments"},1603:{message:"Expression evaluation timed out",help:"Simplify the expression or increase the timeout"}},l5={},p7="en";function pZ($){p7=$}function iZ(){return p7}function nZ($){l5={...l5,...$}}function sZ(){l5={}}function i7($,Z={}){let X=l5[$]||cZ[$]||{message:`Unknown error (code: ${$})`},Y=X.message,J=X.help;for(let[Q,G]of Object.entries(Z)){let q=`{{${Q}}}`;if(Y=Y.replace(new RegExp(q,"g"),G),J)J=J.replace(new RegExp(q,"g"),G)}return{message:Y,help:J}}function oZ($,Z={}){let{message:X,help:Y}=i7($,Z);return Y?`${X}
|
|
2097
|
+
Help: ${Y}`:X}var l={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603};function a$($){for(let[Z,X]of Object.entries(l))if(X===$)return Z;return}import rZ from"path";function H5(){return!1}function B5(){return!H5()||process.env.STX_DEBUG==="true"}function c5(){return!1}var n7={showRelativePaths:!1,enableAutoRecovery:B5(),logRecoveryWarnings:!0},g1={...n7};function aZ($){g1={...g1,...$}}function p5(){return{...g1}}function tZ(){g1={...n7}}function i5($){if(!g1.showRelativePaths||!$)return $;let Z=g1.baseDir||process.cwd();try{let X=rZ.relative(Z,$);return X.startsWith("..")?$:X}catch{return $}}class F1 extends Error{code;filePath;line;column;context;numericCode;constructor($,Z,X,Y,J,Q,G){super($);this.code=Z;this.filePath=X;this.line=Y;this.column=J;this.context=Q;if(this.name="StxError",this.numericCode=G||l.EVALUATION_ERROR,this.filePath)this.filePath=i5(this.filePath)}}class s7 extends F1{constructor($,Z,X,Y,J,Q){super($,"stx_SYNTAX_ERROR",Z,X,Y,J,Q||l.INVALID_DIRECTIVE_SYNTAX);this.name="StxSyntaxError"}}class L1 extends F1{constructor($,Z,X,Y,J,Q){super($,"stx_RUNTIME_ERROR",Z,X,Y,J,Q||l.EVALUATION_ERROR);this.name="StxRuntimeError"}}class o7 extends F1{constructor($,Z,X,Y,J,Q){super($,"stx_SECURITY_ERROR",Z,X,Y,J,Q||l.UNSAFE_EXPRESSION);this.name="StxSecurityError"}}class r7 extends F1{constructor($,Z,X,Y,J,Q){super($,"stx_FILE_ERROR",Z,X,Y,J,Q||l.FILE_NOT_FOUND);this.name="StxFileError"}}class n5 extends F1{isFatal=!0;constructor($,Z,X,Y,J,Q){super($,"stx_VALIDATION_ERROR",Z,X,Y,J,Q||l.DOM_API_VIOLATION);this.name="StxValidationError"}}function t$($){let{type:Z,message:X,code:Y,filePath:J,line:Q,column:G,template:q,offset:U,snippet:W,suggestion:K,format:z="text"}=$,H=Q,B=G;if(!H&&q&&U!==void 0){let F=t7(q,U);H=F.line,B=F.column}let j=J?i5(J):void 0,_=Y?a$(Y):void 0,V={type:Z,code:Y,codeName:_,message:X,filePath:j,line:H,column:B,snippet:W,suggestion:K,timestamp:new Date().toISOString()},O;switch(z){case"html":O=$X(V);break;case"json":O=JSON.stringify(V,null,2);break;case"console":O=ZX(V,q,U);break;case"text":default:O=eZ(V,q,U);break}return{formatted:O,data:V}}function eZ($,Z,X){let Y=[],J=$.code?` [${$.codeName||$.code}]`:"";if(Y.push(`[${$.type} Error${J}]`),$.filePath){let Q=$.filePath;if($.line){if(Q+=`:${$.line}`,$.column)Q+=`:${$.column}`}Y.push(`at ${Q}`)}if(Y.push(`
|
|
2098
|
+
${$.message}`),Z&&$.line){let Q=XX(Z,$.line,2);if(Q)Y.push(`
|
|
2099
|
+
${Q}`)}if($.snippet)Y.push(`
|
|
2100
|
+
Snippet: ${$.snippet}`);if($.suggestion)Y.push(`
|
|
2101
|
+
Suggestion: ${$.suggestion}`);return Y.join(" ")}function $X($){let Z=$.code?` [${$.code}]`:"",X=$.filePath?` in ${$.filePath}${$.line?`:${$.line}`:""}`:"",Y=`<!-- [${$.type} Error${Z}]${X}: ${a7($.message)}`;if($.suggestion)Y+=` | Suggestion: ${a7($.suggestion)}`;return Y+=" -->",Y}function ZX($,Z,X){let W=[],K=$.code?` [${$.codeName||$.code}]`:"";if(W.push(`\x1B[1m${"\x1B[31m"}\u2501\u2501\u2501 ${$.type} Error${K} \u2501\u2501\u2501${"\x1B[0m"}`),$.filePath){let z=`\x1B[36m${$.filePath}\x1B[0m`;if($.line){if(z+=`\x1B[90m:${$.line}\x1B[0m`,$.column)z+=`\x1B[90m:${$.column}\x1B[0m`}W.push(`
|
|
2102
|
+
\x1B[90mat\x1B[0m ${z}`)}if(W.push(`
|
|
2103
|
+
|
|
2104
|
+
${$.message}`),Z&&$.line){let z=YX(Z,$.line,2);if(z)W.push(`
|
|
2105
|
+
|
|
2106
|
+
\x1B[90mContext:\x1B[0m
|
|
2107
|
+
${z}`)}if($.suggestion)W.push(`
|
|
2108
|
+
|
|
2109
|
+
\x1B[33mSuggestion:\x1B[0m ${$.suggestion}`);return W.push(`
|
|
2110
|
+
${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501${"\x1B[0m"}`),W.join("")}function XX($,Z,X){let Y=$.split(`
|
|
2111
|
+
`),J=Math.max(0,Z-X-1),Q=Math.min(Y.length-1,Z+X-1),G=[];for(let q=J;q<=Q;q++){let U=(q+1).toString().padStart(4),W=q===Z-1?">":" ";G.push(`${W}${U} | ${Y[q]}`)}return G.join(`
|
|
2112
|
+
`)}function YX($,Z,X){let Y=$.split(`
|
|
2113
|
+
`),J=Math.max(0,Z-X-1),Q=Math.min(Y.length-1,Z+X-1),G="\x1B[90m",q="\x1B[31m",U="\x1B[0m",W=[];for(let K=J;K<=Q;K++){let z=(K+1).toString().padStart(4),H=K===Z-1,B=H?"\x1B[31m>\x1B[0m":" ",j=H?`\x1B[31m${Y[K]}\x1B[0m`:`\x1B[90m${Y[K]}\x1B[0m`;W.push(`${B}\x1B[90m${z}\x1B[0m | ${j}`)}return W.join(`
|
|
2114
|
+
`)}function a7($){return $.replace(/--/g,"- -").replace(/>/g,">")}function t7($,Z){let Y=$.substring(0,Z).split(`
|
|
2115
|
+
`);return{line:Y.length,column:Y[Y.length-1].length}}function $0($,Z,X){return t$({type:$,message:Z,code:X,format:"html"}).formatted}function JX($,Z,X,Y,J){return t$({type:$,message:Z,code:J,filePath:X,line:Y,format:"console"}).formatted}function QX($,Z,X){let Y=X.template.split(`
|
|
2116
|
+
`),J=t7(X.template,X.offset),Q=`[${$} Error at line ${J.line} in ${X.filePath}]: ${Z}
|
|
2117
|
+
|
|
2118
|
+
`,G=Math.max(0,J.line-3),q=Math.min(Y.length-1,J.line+2);Q+=`Context:
|
|
2119
|
+
`;for(let U=G;U<=q;U++){let W=U+1,K=Y[U]||"",z=U===J.line-1?">":" ";Q+=`${z} ${W.toString().padStart(3)}: ${K}
|
|
2120
|
+
`}if(J.line-1<Y.length){let U=" ".repeat(J.column+5);Q+=`${U}^
|
|
2121
|
+
`}return Q}function GX($,Z,X){try{return $()}catch(Y){if(X&&Y instanceof Error)X(Y);return Z}}async function h1($,Z,X){try{return await $()}catch(Y){if(X&&Y instanceof Error)X(Y);return Z}}var e$={isEnabled(){return p5().enableAutoRecovery},fixCommonSyntaxErrors($){let Z=p5();if(!Z.enableAutoRecovery)return{fixed:$,fixes:[]};let X=$,Y=[],J=(X.match(/\{\{/g)||[]).length,Q=(X.match(/\}\}/g)||[]).length;if(J>Q){let q=J-Q;X+="}}".repeat(q),Y.push(`Added ${q} missing closing braces '}}'`)}let G=["if","foreach","for","switch","section"];for(let q of G){let U=(X.match(new RegExp(`@${q}\\b`,"g"))||[]).length,W=(X.match(new RegExp(`@end${q}\\b`,"g"))||[]).length;if(U>W){let K=U-W;for(let z=0;z<K;z++)X+=`
|
|
2122
|
+
@end${q}`;Y.push(`Added ${K} missing @end${q}`)}}if(Y.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),Y.forEach((q)=>console.warn(` - ${q}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:X,fixes:Y}},createFallbackContent($,Z){if(B5())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};class $3{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor($={}){this.maxErrors=$.maxErrors??1000,this.enableFileLogging=$.enableFileLogging??!1,this.logFilePath=$.logFilePath??".stx/errors.log",this.logFormat=$.logFormat??"json",this.maxFileSize=$.maxFileSize??10485760,this.maxLogFiles=$.maxLogFiles??5,this.minLevel=$.minLevel??"all"}configure($){if($.maxErrors!==void 0)this.maxErrors=$.maxErrors;if($.enableFileLogging!==void 0)this.enableFileLogging=$.enableFileLogging;if($.logFilePath!==void 0)this.logFilePath=$.logFilePath;if($.logFormat!==void 0)this.logFormat=$.logFormat;if($.maxFileSize!==void 0)this.maxFileSize=$.maxFileSize;if($.maxLogFiles!==void 0)this.maxLogFiles=$.maxLogFiles;if($.minLevel!==void 0)this.minLevel=$.minLevel}log($,Z,X="error"){let Y={timestamp:new Date,error:$,context:Z,level:X};if(this.errors.push(Y),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(X))this.writeToFile(Y)}shouldLog($){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return $==="error"||$==="warning";if(this.minLevel==="error")return $==="error";return!0}formatEntry($){if(this.logFormat==="json")return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level||"error",type:$.error.constructor.name,message:$.error.message,stack:$.error.stack,context:$.context});let Z=[`[${$.timestamp.toISOString()}] [${($.level||"error").toUpperCase()}] ${$.error.constructor.name}: ${$.error.message}`];if($.error.stack)Z.push(` Stack: ${$.error.stack.split(`
|
|
2123
|
+
`).slice(1).join(`
|
|
2124
|
+
`)}`);if($.context)Z.push(` Context: ${JSON.stringify($.context)}`);return Z.join(`
|
|
2125
|
+
`)}writeToFile($){this.writeQueue=this.writeQueue.then(async()=>{try{let Z=await import("fs"),Y=(await import("path")).dirname(this.logFilePath);if(!Z.existsSync(Y))Z.mkdirSync(Y,{recursive:!0});await this.rotateIfNeeded(Z);let J=`${this.formatEntry($)}
|
|
2126
|
+
`;Z.appendFileSync(this.logFilePath,J,"utf-8")}catch(Z){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",Z)}})}async rotateIfNeeded($){try{if(!$.existsSync(this.logFilePath))return;if($.statSync(this.logFilePath).size<this.maxFileSize)return;for(let X=this.maxLogFiles-1;X>=1;X--){let Y=`${this.logFilePath}.${X}`,J=`${this.logFilePath}.${X+1}`;if($.existsSync(Y))if(X>=this.maxLogFiles-1)$.unlinkSync(Y);else $.renameSync(Y,J)}if(this.maxLogFiles<=1)$.writeFileSync(this.logFilePath,"");else $.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(Z){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",Z)}}getRecentErrors($=10){return this.errors.slice(-$)}getErrorsByType($){return this.errors.filter((Z)=>Z.error.constructor.name===$)}getErrorsByLevel($){return this.errors.filter((Z)=>Z.level===$)}clear(){this.errors.length=0}async clearLogFile(){try{let $=await import("fs");if($.existsSync(this.logFilePath))$.writeFileSync(this.logFilePath,"","utf-8")}catch($){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",$)}}getStats(){let $={},Z={error:0,warning:0,info:0};for(let X of this.errors){let Y=X.error.constructor.name;$[Y]=($[Y]||0)+1;let J=X.level||"error";Z[J]=(Z[J]||0)+1}return{total:this.errors.length,byType:$,byLevel:Z}}async exportToFile($,Z="json"){let X=await import("fs"),J=(await import("path")).dirname($);if(!X.existsSync(J))X.mkdirSync(J,{recursive:!0});if(Z==="json"){let Q=this.errors.map((G)=>({timestamp:G.timestamp.toISOString(),level:G.level||"error",type:G.error.constructor.name,message:G.error.message,stack:G.error.stack,context:G.context}));X.writeFileSync($,JSON.stringify(Q,null,2),"utf-8")}else{let Q=this.errors.map((G)=>this.formatEntry(G));X.writeFileSync($,Q.join(`
|
|
2127
|
+
|
|
2128
|
+
`),"utf-8")}}async flush(){await this.writeQueue}}var u0=new $3,Z3={isDevelopment(){return B5()},logDetailedError($,Z){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",$.message),console.error("Stack:",$.stack),Z)console.error("Context:",Z);console.error("========================")},createErrorReport($,Z){let X=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(Z)X.push(`Context: ${JSON.stringify(Z,null,2)}`);return X.push("========================"),X.join(`
|
|
2129
|
+
`)}};import X3 from"path";var Y3={isValidFilePath($,Z){let X=$.replace(/\\/g,"/");if(X.includes("\x00"))return!1;if(X.includes("../")||X.includes("..\\")||X===".."||X.startsWith("../")||X.endsWith("/..")||X.includes("/..\\")||X.includes("\\../"))return!1;if(/^[a-z][a-z0-9+.-]*:/i.test(X))return!1;if(X.startsWith("/")){if(["/etc/","/root/","/var/","/usr/","/bin/","/sbin/","/proc/","/sys/","/dev/","/boot/","/home/","/private/","/Library/","/System/"].some((Q)=>X===Q.slice(0,-1)||X.startsWith(Q)))return!1}if(/^[a-z]:/i.test(X)){if(["Windows/","Windows\\","System32/","System32\\","Program Files/","Program Files\\"].some((Q)=>X.includes(Q)))return!1}if(Z){let J=X3.resolve(Z,$),Q=X3.resolve(Z);if(!J.startsWith(Q+X3.sep)&&J!==Q)return!1}return!0},isValidVariableName($){return/^[a-z_$]\w*$/i.test($)},isValidDirectiveName($){return/^[a-z][\w-]*$/i.test($)},isSafeContent($){return![/<script[^>]*>[\s\S]*?<\/script>/i,/javascript:/i,/data:text\/html/i,/vbscript:/i,/on\w+\s*=/i].some((X)=>X.test($))}};function qX($){let Z={"&":"&","<":"<",">":">",'"':""","'":"'"};return $.replace(/[&<>"']/g,(X)=>Z[X]||X)}function s5($,Z={}){let{allowHtml:X=!1,maxLength:Y=1e4,allowSpecialChars:J=!0,customSanitizer:Q}=Z,G=[],q=$,U=!1;if(Q){let K=Q(q);if(K!==q)q=K,U=!0}if(q.includes("\x00"))q=q.replace(/\0/g,""),U=!0,G.push("Null bytes removed from parameter");if(q.length>Y)q=q.substring(0,Y),U=!0,G.push(`Parameter truncated to ${Y} characters`);if(!X&&/<[^>]+>/.test(q))q=qX(q),U=!0,G.push("HTML content was escaped");let W=[{pattern:/javascript:/gi,replacement:"",name:"javascript: URI"},{pattern:/vbscript:/gi,replacement:"",name:"vbscript: URI"},{pattern:/data:text\/html/gi,replacement:"",name:"data:text/html URI"}];for(let{pattern:K,replacement:z,name:H}of W)if(K.test(q))q=q.replace(K,z),U=!0,G.push(`Removed ${H} from parameter`);if(!J){let K=q;if(q=q.split("").filter((z)=>{let H=z.charCodeAt(0);return H>=32&&H!==127}).join(""),q!==K)U=!0,G.push("Control characters removed")}return{value:q,modified:U,warnings:G}}function UX($,Z){let X=$.replace(/\0/g,"");X=X.replace(/\\/g,"/"),X=X.replace(/^[a-z][a-z0-9+.-]*:/i,"");while(X.includes("../")||X.includes("./"))X=X.replace(/\.\.\//g,"").replace(/\.\//g,"");if(!Y3.isValidFilePath(X,Z))return null;return X}function WX($){let Z=[],X=$.trim(),Y=X!==$,J=[{pattern:/\beval\s*\(/gi,name:"eval()"},{pattern:/\bFunction\s*\(/gi,name:"Function()"},{pattern:/\bsetTimeout\s*\(/gi,name:"setTimeout()"},{pattern:/\bsetInterval\s*\(/gi,name:"setInterval()"},{pattern:/\bimport\s*\(/gi,name:"dynamic import()"},{pattern:/\brequire\s*\(/gi,name:"require()"},{pattern:/\b__proto__\b/gi,name:"__proto__"},{pattern:/\bconstructor\b/gi,name:"constructor"},{pattern:/\bprototype\b/gi,name:"prototype"}];for(let{pattern:Q,name:G}of J)if(Q.test(X))Z.push(`Potentially dangerous pattern detected: ${G}`);if(X.includes("\x00"))X=X.replace(/\0/g,""),Y=!0,Z.push("Null bytes removed from expression");return{value:X,modified:Y,warnings:Z}}function KX($,Z={}){return $.map((X)=>s5(X,Z))}function e7($){let Z={};for(let[X,Y]of Object.entries($)){if(!Y3.isValidVariableName(X))continue;if(typeof Y==="string"){let J=s5(Y);Z[X]=J.value}else if(Array.isArray(Y))Z[X]=Y.map((J)=>typeof J==="string"?s5(J).value:J);else if(typeof Y==="object"&&Y!==null)Z[X]=e7(Y);else Z[X]=Y}return Z}function Z6($,Z,X,Y){let J=$;J=J.replace(/@meta\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(q,U,W)=>{if(!W&&U.includes(":")){let K=U.split(":"),z=U,H=K.length>1?K[1]:"";if(H&&Z[H])W=Z[H];else if(z.startsWith("og:")&&Z.openGraph&&Z.openGraph[K[1]])W=Z.openGraph[K[1]];else W="";return W?`<meta property="${c(z)}" content="${c(W)}">`:""}return W?`<meta name="${c(U)}" content="${c(W)}">`:""});let Q=/@metaTag\s*\(/g,G;while((G=Q.exec(J))!==null){let q=G.index,U=q+G[0].length-1,W=1,K=U+1;while(K<J.length&&W>0){if(J[K]==="(")W++;else if(J[K]===")"){if(W--,W===0)break}K++}if(W!==0)break;let z=J.substring(U+1,K).trim(),H=K+1,B=(()=>{try{let j=_0(z,Z);if(!j)return"";let _="<meta";if(j.name)_+=` name="${c(String(j.name))}"`;if(j.property)_+=` property="${c(String(j.property))}"`;if(j.httpEquiv)_+=` http-equiv="${c(String(j.httpEquiv))}"`;if(j.content)_+=` content="${c(String(j.content))}"`;return _+=">",_}catch(j){let _=j instanceof Error?j.message:String(j);return $0("MetaTag",_,l.EVALUATION_ERROR)}})();J=J.substring(0,q)+B+J.substring(H),Q.lastIndex=0}return J}function X6($,Z,X){let Y=$,J=/@structuredData\s*\(/g,Q;while((Q=J.exec(Y))!==null){let G=Q.index,q=G+Q[0].length-1,U=1,W=q+1;while(W<Y.length&&U>0){if(Y[W]==="(")U++;else if(Y[W]===")"){if(U--,U===0)break}W++}if(U!==0)break;let K=Y.substring(q+1,W).trim(),z=W+1,H=(()=>{try{let B=_0(K,Z);if(!B)return"";if(!B["@context"])B["@context"]="https://schema.org";return`<script type="application/ld+json">${JSON.stringify(B).replace(/<\//g,"<\\/")}</script>`}catch(B){let j=B instanceof Error?B.message:String(B);return $0("StructuredData",j,l.EVALUATION_ERROR)}})();Y=Y.substring(0,G)+H+Y.substring(z),J.lastIndex=0}return Y}function Y6($,Z,X,Y){let J=$,Q=/@seo\s*\(\s*\{/g,G;while((G=Q.exec(J))!==null){let q=J.indexOf("{",G.index+4),U=1,W=q+1,K=null,z=!1;while(W<J.length&&U>0){let O=J[W];if(z){z=!1,W++;continue}if(O==="\\"&&K){z=!0,W++;continue}if(K){if(O===K)K=null;W++;continue}if(O==='"'||O==="'"||O==="`"){K=O,W++;continue}if(O==="{")U++;else if(O==="}")U--;W++}if(U!==0)break;let H=J.substring(W).match(/^\s*\)/);if(!H)break;let B=W+H[0].length,j=J.substring(q,W),_=J.substring(G.index,B),V=((O)=>{try{let F=_0(O,Z);if(!F)return"";let L="";if(F.title)L+=`<title>${c(F.title)}</title>
|
|
2130
|
+
`,L+=`<meta name="title" content="${c(F.title)}">
|
|
2131
|
+
`;if(F.description)L+=`<meta name="description" content="${c(F.description)}">
|
|
2132
|
+
`;if(F.keywords){let w=Array.isArray(F.keywords)?F.keywords.join(", "):F.keywords;L+=`<meta name="keywords" content="${c(w)}">
|
|
2133
|
+
`}if(F.robots)L+=`<meta name="robots" content="${c(F.robots)}">
|
|
2134
|
+
`;if(F.canonical)L+=`<link rel="canonical" href="${c(F.canonical)}">
|
|
2135
|
+
`;if(F.openGraph){let w=F.openGraph;if(L+=`<meta property="og:type" content="${c(w.type||"website")}">
|
|
2136
|
+
`,w.title||F.title){let R=w.title||F.title||"";L+=`<meta property="og:title" content="${c(R)}">
|
|
2137
|
+
`}if(w.description||F.description){let R=w.description||F.description||"";L+=`<meta property="og:description" content="${c(R)}">
|
|
2138
|
+
`}if(w.url||F.canonical){let R=w.url||F.canonical||"";L+=`<meta property="og:url" content="${c(R)}">
|
|
2139
|
+
`}if(w.image){if(L+=`<meta property="og:image" content="${c(w.image)}">
|
|
2140
|
+
`,w.imageAlt)L+=`<meta property="og:image:alt" content="${c(w.imageAlt)}">
|
|
2141
|
+
`;if(w.imageWidth)L+=`<meta property="og:image:width" content="${c(String(w.imageWidth))}">
|
|
2142
|
+
`;if(w.imageHeight)L+=`<meta property="og:image:height" content="${c(String(w.imageHeight))}">
|
|
2143
|
+
`}if(w.siteName)L+=`<meta property="og:site_name" content="${c(w.siteName)}">
|
|
2144
|
+
`}if(F.twitter){let w=F.twitter;if(L+=`<meta name="twitter:card" content="${c(w.card||"summary_large_image")}">
|
|
2145
|
+
`,w.title||F.title){let R=w.title||F.title||"";L+=`<meta name="twitter:title" content="${c(R)}">
|
|
2146
|
+
`}if(w.description||F.description){let R=w.description||F.description||"";L+=`<meta name="twitter:description" content="${c(R)}">
|
|
2147
|
+
`}if(w.image||F.openGraph&&F.openGraph.image){let R=w.image||(F.openGraph?F.openGraph.image:"")||"";L+=`<meta name="twitter:image" content="${c(R)}">
|
|
2148
|
+
`}if(w.site)L+=`<meta name="twitter:site" content="${c(w.site)}">
|
|
2149
|
+
`;if(w.creator)L+=`<meta name="twitter:creator" content="${c(w.creator)}">
|
|
2150
|
+
`}if(F.structuredData){let w=JSON.stringify(F.structuredData).replace(/<\//g,"<\\/");L+=`<script type="application/ld+json">${w}</script>
|
|
2151
|
+
`}return L.trim()}catch(F){let L=F instanceof Error?F.message:String(F);return $0("SEO",`Error processing @seo directive: ${L}`,l.EVALUATION_ERROR)}})(j);J=J.substring(0,G.index)+V+J.substring(B),Q.lastIndex=G.index+V.length}return J}function J6($,Z,X){if(X.seo?.enabled===!1)return $;if($.includes("<!-- stx SEO Tags -->")||X.skipDefaultSeoTags===!0)return $;let Y=Z.__stx_runtime_head;if(!!(Y?.title||Y?.meta?.some((z)=>z.property==="og:title"||z.name==="og:title"||z.name==="twitter:title"||z.name==="description")))return $;if(/<meta\s+(?:[^>]*\s)?property=["']og:title["']/i.test($)||/<meta\s+(?:[^>]*\s)?name=["']og:title["']/i.test($)||/<meta\s+(?:[^>]*\s)?name=["']twitter:title["']/i.test($))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let Q=$.includes("<title>")||$.includes("</title>"),G="";if(Z.title)G=Z.title;else if(Z.meta&&Z.meta.title)G=Z.meta.title;else if(X.seo?.defaultConfig?.title)G=X.seo.defaultConfig.title;else G=X.defaultTitle||"stx Project";let q="";if(Z.description)q=Z.description;else if(Z.meta&&Z.meta.description)q=Z.meta.description;else if(X.seo?.defaultConfig?.description)q=X.seo.defaultConfig.description;else q=X.defaultDescription||"A website built with stx templating engine";let U="";if(Z.image)U=Z.image;else if(Z.meta&&Z.meta.image)U=Z.meta.image;else if(Z.openGraph&&Z.openGraph.image)U=Z.openGraph.image;else if(X.seo?.defaultImage)U=X.seo.defaultImage;else if(X.defaultImage)U=X.defaultImage;let W=`
|
|
2152
|
+
<!-- stx SEO Tags -->
|
|
2153
|
+
<meta name="title" content="${c(G)}">
|
|
2154
|
+
<meta name="description" content="${c(q)}">
|
|
2155
|
+
<meta property="og:title" content="${c(G)}">
|
|
2156
|
+
<meta property="og:description" content="${c(q)}">
|
|
2157
|
+
<meta property="og:type" content="website">
|
|
2158
|
+
<meta name="twitter:card" content="summary_large_image">
|
|
2159
|
+
<meta name="twitter:title" content="${c(G)}">
|
|
2160
|
+
<meta name="twitter:description" content="${c(q)}">
|
|
2161
|
+
`;if(U)W+=`
|
|
2162
|
+
<meta property="og:image" content="${c(U)}">
|
|
2163
|
+
<meta name="twitter:image" content="${c(U)}">
|
|
2164
|
+
`;let K=$;if(!Q)K=K.replace(/<head[^>]*>/,`$&
|
|
2165
|
+
<title>${c(G)}</title>`);return K.replace(/<head[^>]*>/,`$&
|
|
2166
|
+
${W}
|
|
2167
|
+
`)}function c($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var zX=["og:","article:","book:","profile:","fb:","music:","video:"];function $6($){let Z=$.trim(),X=Z[0];if((X==="'"||X==='"'||X==="`")&&Z.length>1&&Z.at(-1)===X)return{value:Z.slice(1,-1),quoted:!0};return{value:Z,quoted:!1}}var J3={name:"meta",handler:($,Z,X,Y)=>{if(Z.length<1)return $0("Meta","meta directive requires at least the meta name",l.INVALID_DIRECTIVE_SYNTAX);let J=$6(Z[0]).value,Q;if(Z.length>1){let U=$6(Z[1]);Q=U.quoted?U.value:String(X?.[U.value]??U.value)}else{let U=J.includes(":")?J.slice(J.indexOf(":")+1):J,W=X?.openGraph;Q=String(X?.[U]??W?.[U]??"")}if(!Q)return"";let q=zX.some((U)=>J.startsWith(U))?{property:J,content:Q}:{name:J,content:Q};if(X)X.__stx_runtime_head=o5(X.__stx_runtime_head??{},{meta:[q]});return""},hasEndTag:!1},Q3={name:"structuredData",handler:($,Z,X,Y)=>{if($.trim()==="")return $0("StructuredData","structuredData directive requires JSON-LD content",l.INVALID_DIRECTIVE_SYNTAX);try{let J=JSON.parse($);if(!J["@context"])J["@context"]="https://schema.org";if(!J["@type"])return $0("StructuredData","structuredData requires @type property",l.INVALID_DIRECTIVE_SYNTAX);return`<script type="application/ld+json">${JSON.stringify(J)}</script>`}catch(J){let Q=J instanceof Error?J.message:String(J);return $0("StructuredData",Q,l.EVALUATION_ERROR)}},hasEndTag:!0};function HW(){return[J3,Q3]}function BW($,Z){let X=Z.replace(/\/$/,""),Y=new Date().toISOString().split("T")[0];return`<?xml version="1.0" encoding="UTF-8"?>
|
|
2168
|
+
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
2169
|
+
${$.map((Q)=>{let G=Q.startsWith("http")?Q:`${X}${Q.startsWith("/")?"":"/"}${Q}`;return` <sitemap>
|
|
2170
|
+
<loc>${BX(G)}</loc>
|
|
2171
|
+
<lastmod>${Y}</lastmod>
|
|
2172
|
+
</sitemap>`}).join(`
|
|
2173
|
+
`)}
|
|
2174
|
+
</sitemapindex>`}async function jW($,Z){let{extensions:X=[".stx",".html",".htm"],ignore:Y=["_*",".*","node_modules","components","partials","layouts"]}=Z,J=[],Q=X.length===1?`*${X[0]}`:`*{${X.join(",")}}`,G=new Bun.Glob(`**/${Q}`);for await(let q of G.scan($)){if(Y.some((H)=>{if(H.startsWith("*"))return q.includes(H.slice(1));return q.startsWith(H)||q.includes(`/${H}`)}))continue;let W=q.replace(/\\/g,"/").replace(/index\.(stx|html|htm)$/,"").replace(/\.(stx|html|htm)$/,"");if(!W.startsWith("/"))W=`/${W}`;if(W!=="/"&&W.endsWith("/"))W=W.slice(0,-1);let K=`${$}/${q}`,z;try{let H=await Bun.file(K).stat();if(H)z=new Date(H.mtime).toISOString().split("T")[0]}catch{}J.push({loc:W||"/",lastmod:z,priority:W==="/"?1:0.5})}return J.sort((q,U)=>q.loc.localeCompare(U.loc)),J}function HX($){let Z=[];for(let X of $.rules){if(Z.push(`User-agent: ${X.userAgent}`),X.allow)for(let Y of X.allow)Z.push(`Allow: ${Y}`);if(X.disallow)for(let Y of X.disallow)Z.push(`Disallow: ${Y}`);if(X.crawlDelay!==void 0)Z.push(`Crawl-delay: ${X.crawlDelay}`);Z.push("")}if($.sitemap){let X=Array.isArray($.sitemap)?$.sitemap:[$.sitemap];for(let Y of X)Z.push(`Sitemap: ${Y}`)}if($.host)Z.push(`Host: ${$.host}`);return Z.join(`
|
|
2175
|
+
`).trim()}function _W($){return HX({rules:[{userAgent:"*",allow:["/"]}],sitemap:$})}function BX($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}import jX from"fs";import q1 from"path";async function RW($,Z){if(!$.webComponents?.enabled)return[];let X=$.webComponents.components||[],Y=[];if(X.length>0){if($.debug)console.log(`Building ${X.length} web components...`);for(let J of X)try{let Q=await _X(J,$,Z);if(Q)Y.push(Q)}catch(Q){if(console.error(`Error building web component ${J.name}:`,Q),$.debug)throw Q}}return Y}async function _X($,Z,X){let{name:Y,file:J,tag:Q,extends:G}=$;if(!Y||!J||!Q)return console.error("Invalid web component configuration, missing required fields:",$),null;let q=null;if(q1.isAbsolute(J)&&await r(J))q=J;else if(Z.componentsDir){let _=q1.join(Z.componentsDir,J);if(await r(_))q=_}if(!q)q=await r5(J,process.cwd(),Z,X);if(!q)return console.error(`Web component source file not found: ${J}`),null;let U=await Bun.file(q).text();X.add(q);let K=($.outputFormat||"js")==="ts",z=K?VX({name:Y,tag:Q,baseElement:G,source:U,shadowDOM:$.shadowDOM??!0,template:$.template??!0,styleSource:$.styleSource,attributes:$.attributes||[],attributeTypes:$.attributeTypes||{}}):OX({name:Y,tag:Q,baseElement:G,source:U,shadowDOM:$.shadowDOM??!0,template:$.template??!0,styleSource:$.styleSource,attributes:$.attributes||[]}),H=Z.webComponents?.outputDir||"dist/web-components";await jX.promises.mkdir(H,{recursive:!0});let B=K?"ts":"js",j=q1.join(H,`${Q}.${B}`);if(await Bun.write(j,z),Z.debug)console.log(`Built web component ${Y} -> ${j}`);return j}function OX($){let{name:Z,tag:X,baseElement:Y="HTMLElement",source:J,shadowDOM:Q,template:G,styleSource:q,attributes:U=[]}=$,W=J.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!Q)W=W.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),W=W.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),W=W.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),W=W.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");let K="";if(q)K=`<link rel="stylesheet" href="${q}">`;return`/**
|
|
2176
|
+
* ${Z} Web Component
|
|
2177
|
+
* Auto-generated from stx component
|
|
2178
|
+
*/
|
|
2179
|
+
class ${Z.replace(/\W/g,"")} extends ${Y} {
|
|
2180
|
+
constructor() {
|
|
2181
|
+
super()
|
|
2182
|
+
this._initialized = false
|
|
2183
|
+
${Q?"":"this._slotContent = []"}
|
|
2184
|
+
${Q?'this.attachShadow({ mode: "open" })':""}
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
${G?`
|
|
2188
|
+
_createTemplate() {
|
|
2189
|
+
const template = document.createElement('template')
|
|
2190
|
+
template.innerHTML = \`${K}${W}\`
|
|
2191
|
+
${Q?"this.shadowRoot.appendChild(template.content.cloneNode(true))":"this.appendChild(template.content.cloneNode(true))"}
|
|
2192
|
+
this._processSlots()
|
|
2193
|
+
}
|
|
2194
|
+
`:`
|
|
2195
|
+
_render() {
|
|
2196
|
+
${Q?"this.shadowRoot.innerHTML":"this.innerHTML"} = \`${K}${W}\`
|
|
2197
|
+
this._processSlots()
|
|
2198
|
+
}
|
|
2199
|
+
`}
|
|
2200
|
+
|
|
2201
|
+
_processSlots() {
|
|
2202
|
+
${Q?`// Shadow DOM handles slot assignment automatically
|
|
2203
|
+
// Listen for slot changes if needed
|
|
2204
|
+
const slots = this.shadowRoot.querySelectorAll('slot')
|
|
2205
|
+
slots.forEach(slot => {
|
|
2206
|
+
slot.addEventListener('slotchange', (e) => {
|
|
2207
|
+
const assignedNodes = slot.assignedNodes()
|
|
2208
|
+
this.dispatchEvent(new CustomEvent('slot-changed', {
|
|
2209
|
+
detail: { slotName: slot.name || 'default', assignedNodes }
|
|
2210
|
+
}))
|
|
2211
|
+
})
|
|
2212
|
+
})`:`// Manual slot processing for non-shadow DOM mode
|
|
2213
|
+
const slots = this.querySelectorAll('[data-slot]')
|
|
2214
|
+
|
|
2215
|
+
// Process named slots
|
|
2216
|
+
slots.forEach(slotEl => {
|
|
2217
|
+
const slotName = slotEl.getAttribute('data-slot')
|
|
2218
|
+
const slottedContent = this._slotContent.filter(
|
|
2219
|
+
node => node.nodeType === Node.ELEMENT_NODE && node.getAttribute('slot') === slotName
|
|
2220
|
+
)
|
|
2221
|
+
if (slottedContent.length > 0) {
|
|
2222
|
+
slotEl.innerHTML = ''
|
|
2223
|
+
slottedContent.forEach(content => slotEl.appendChild(content))
|
|
2224
|
+
}
|
|
2225
|
+
})
|
|
2226
|
+
|
|
2227
|
+
// Process default slot
|
|
2228
|
+
const defaultSlot = this.querySelector('[data-slot=""]') || this.querySelector('[data-default-slot]')
|
|
2229
|
+
if (defaultSlot) {
|
|
2230
|
+
const unslottedContent = this._slotContent.filter(
|
|
2231
|
+
node => node.nodeType !== Node.ELEMENT_NODE || !node.hasAttribute('slot')
|
|
2232
|
+
)
|
|
2233
|
+
if (unslottedContent.length > 0) {
|
|
2234
|
+
defaultSlot.innerHTML = ''
|
|
2235
|
+
unslottedContent.forEach(content => defaultSlot.appendChild(content))
|
|
2236
|
+
}
|
|
2237
|
+
}`}
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
${U.length>0?`
|
|
2241
|
+
static get observedAttributes() {
|
|
2242
|
+
return [${U.map((z)=>`'${z}'`).join(", ")}]
|
|
2243
|
+
}
|
|
2244
|
+
|
|
2245
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
2246
|
+
if (oldValue !== newValue) {
|
|
2247
|
+
this[name] = newValue
|
|
2248
|
+
${G?"":"if (this._initialized) this._render()"}
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
`:""}
|
|
2252
|
+
|
|
2253
|
+
connectedCallback() {
|
|
2254
|
+
if (this._initialized) return
|
|
2255
|
+
${Q?"":"this._slotContent = Array.from(this.childNodes)"}
|
|
2256
|
+
this._initialized = true
|
|
2257
|
+
${G?"this._createTemplate()":"this._render()"}
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
disconnectedCallback() {
|
|
2261
|
+
// Component removed from the DOM
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
// Register the web component
|
|
2266
|
+
customElements.define('${X}', ${Z.replace(/\W/g,"")})
|
|
2267
|
+
`}function VX($){let{name:Z,tag:X,baseElement:Y="HTMLElement",source:J,shadowDOM:Q,template:G,styleSource:q,attributes:U=[],attributeTypes:W={}}=$,K=Z.replace(/\W/g,""),z=J.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!Q)z=z.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),z=z.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),z=z.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),z=z.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");z=z.replace(/`/g,"\\`").replace(/\$\{/g,"\\${");let H=q?`<link rel="stylesheet" href="${q}">`:"",B=(R)=>{switch(W[R]){case"number":return"number";case"boolean":return"boolean";case"object":return"Record<string, unknown>";default:return"string"}},j=(R)=>R.replace(/-([a-z])/g,(D,N)=>N.toUpperCase()),_=U.map((R)=>` private _${j(R)}: ${B(R)} | null = null;`).join(`
|
|
2268
|
+
`),V=U.map((R)=>{let D=B(R),N=j(R);return`
|
|
2269
|
+
get ${N}(): ${D} | null {
|
|
2270
|
+
return this._${N};
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
set ${N}(value: ${D} | null) {
|
|
2274
|
+
this._${N} = value;
|
|
2275
|
+
if (value !== null) {
|
|
2276
|
+
this.setAttribute('${R}', String(value));
|
|
2277
|
+
}
|
|
2278
|
+
else {
|
|
2279
|
+
this.removeAttribute('${R}');
|
|
2280
|
+
}
|
|
2281
|
+
}`}).join(`
|
|
2282
|
+
`),O=U.length>0?`/**
|
|
2283
|
+
* Props interface for ${Z}
|
|
2284
|
+
*/
|
|
2285
|
+
export interface ${K}Props {
|
|
2286
|
+
${U.map((R)=>{let D=B(R);return` ${j(R)}?: ${D};`}).join(`
|
|
2287
|
+
`)}
|
|
2288
|
+
}
|
|
2289
|
+
`:"",F=U.length>0?`
|
|
2290
|
+
static get observedAttributes(): string[] {
|
|
2291
|
+
return [${U.map((R)=>`'${R}'`).join(", ")}];
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {
|
|
2295
|
+
if (oldValue !== newValue) {
|
|
2296
|
+
const camelCase = name.replace(/-([a-z])/g, (_: string, letter: string) => letter.toUpperCase());
|
|
2297
|
+
(this as unknown as Record<string, unknown>)[\`_\${camelCase}\`] = this._parseAttributeValue(name, newValue);
|
|
2298
|
+
${G?"":"if (this._initialized) this._render();"}
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
|
|
2302
|
+
private _parseAttributeValue(name: string, value: string | null): unknown {
|
|
2303
|
+
if (value === null) return null;
|
|
2304
|
+
const typeMap: Record<string, string> = ${JSON.stringify(W)};
|
|
2305
|
+
const type = typeMap[name] || 'string';
|
|
2306
|
+
switch (type) {
|
|
2307
|
+
case 'number': return Number(value);
|
|
2308
|
+
case 'boolean': return value !== 'false' && value !== '0';
|
|
2309
|
+
case 'object': try { return JSON.parse(value); }
|
|
2310
|
+
catch { return value; }
|
|
2311
|
+
default: return value;
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
`:"",L=G?`
|
|
2315
|
+
private _createTemplate(): void {
|
|
2316
|
+
const template = document.createElement('template');
|
|
2317
|
+
template.innerHTML = \`${H}${z}\`;
|
|
2318
|
+
${Q?"this.shadowRoot!.appendChild(template.content.cloneNode(true));":"this.appendChild(template.content.cloneNode(true));"}
|
|
2319
|
+
this._processSlots();
|
|
2320
|
+
}`:`
|
|
2321
|
+
private _render(): void {
|
|
2322
|
+
${Q?"this.shadowRoot!.innerHTML":"this.innerHTML"} = \`${H}${z}\`;
|
|
2323
|
+
this._processSlots();
|
|
2324
|
+
}`;return`/**
|
|
2325
|
+
* ${Z} Web Component
|
|
2326
|
+
* Auto-generated from stx component (TypeScript)
|
|
2327
|
+
*
|
|
2328
|
+
* @example
|
|
2329
|
+
* \`\`\`html
|
|
2330
|
+
* <${X}></${X}>
|
|
2331
|
+
* \`\`\`
|
|
2332
|
+
*/
|
|
2333
|
+
|
|
2334
|
+
/**
|
|
2335
|
+
* Detail type for slot-changed event
|
|
2336
|
+
*/
|
|
2337
|
+
interface SlotChangeDetail {
|
|
2338
|
+
slotName: string;
|
|
2339
|
+
assignedNodes: Node[];
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
${O}
|
|
2343
|
+
/**
|
|
2344
|
+
* ${Z} custom element class
|
|
2345
|
+
* @customElement ${X}
|
|
2346
|
+
*/
|
|
2347
|
+
export class ${K} extends ${Y} {
|
|
2348
|
+
${_}
|
|
2349
|
+
private _initialized = false;
|
|
2350
|
+
${Q?"":"private _slotContent: Node[] = [];"}
|
|
2351
|
+
|
|
2352
|
+
constructor() {
|
|
2353
|
+
super();
|
|
2354
|
+
${Q?'this.attachShadow({ mode: "open" });':""}
|
|
2355
|
+
}
|
|
2356
|
+
${L}
|
|
2357
|
+
${Q?`
|
|
2358
|
+
private _processSlots(): void {
|
|
2359
|
+
const slots = this.shadowRoot!.querySelectorAll('slot');
|
|
2360
|
+
slots.forEach((slot) => {
|
|
2361
|
+
slot.addEventListener('slotchange', () => {
|
|
2362
|
+
const assignedNodes = (slot as HTMLSlotElement).assignedNodes();
|
|
2363
|
+
this.dispatchEvent(new CustomEvent<SlotChangeDetail>('slot-changed', {
|
|
2364
|
+
detail: { slotName: slot.getAttribute('name') || 'default', assignedNodes }
|
|
2365
|
+
}));
|
|
2366
|
+
});
|
|
2367
|
+
});
|
|
2368
|
+
}`:`
|
|
2369
|
+
private _processSlots(): void {
|
|
2370
|
+
const slots = this.querySelectorAll('[data-slot]');
|
|
2371
|
+
slots.forEach((slotEl) => {
|
|
2372
|
+
const slotName = slotEl.getAttribute('data-slot');
|
|
2373
|
+
if (slotName) {
|
|
2374
|
+
const slottedContent = this._slotContent.filter(
|
|
2375
|
+
node => node.nodeType === Node.ELEMENT_NODE && (node as Element).getAttribute('slot') === slotName
|
|
2376
|
+
);
|
|
2377
|
+
if (slottedContent.length > 0) {
|
|
2378
|
+
slotEl.innerHTML = '';
|
|
2379
|
+
slottedContent.forEach(content => slotEl.appendChild(content));
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
});
|
|
2383
|
+
const defaultSlot = this.querySelector('[data-slot=""]') || this.querySelector('[data-default-slot]');
|
|
2384
|
+
if (defaultSlot) {
|
|
2385
|
+
const unslottedContent = this._slotContent.filter(
|
|
2386
|
+
node => node.nodeType !== Node.ELEMENT_NODE || !(node as Element).hasAttribute('slot')
|
|
2387
|
+
);
|
|
2388
|
+
if (unslottedContent.length > 0) {
|
|
2389
|
+
defaultSlot.innerHTML = '';
|
|
2390
|
+
unslottedContent.forEach(content => defaultSlot.appendChild(content));
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
}`}
|
|
2394
|
+
${F}
|
|
2395
|
+
${V}
|
|
2396
|
+
|
|
2397
|
+
connectedCallback(): void {
|
|
2398
|
+
if (this._initialized) return;
|
|
2399
|
+
${Q?"":"this._slotContent = Array.from(this.childNodes);"}
|
|
2400
|
+
this._initialized = true;
|
|
2401
|
+
${G?"this._createTemplate();":"this._render();"}
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
disconnectedCallback(): void {
|
|
2405
|
+
// Component removed from the DOM
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
adoptedCallback(): void {
|
|
2409
|
+
// Component moved to a new document
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
// Type augmentation for HTMLElementTagNameMap
|
|
2414
|
+
declare global {
|
|
2415
|
+
interface HTMLElementTagNameMap {
|
|
2416
|
+
'${X}': ${K};
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
// Register the web component
|
|
2421
|
+
customElements.define('${X}', ${K});
|
|
2422
|
+
`}var G3={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0};function q3($){let Z=$.split("").reduce((X,Y)=>(X<<5)-X+Y.charCodeAt(0)|0,0);return Math.abs(Z).toString(36).slice(0,8)}function FX($,Z,X={}){let Y={...G3,...X},J=q3(Z);switch(Y.strategy){case"shadow":return $;case"prefix":return wX($,Y.prefix||Z,Y.preserveOriginal);case"attribute":return LX($,J,Y.attributeName||"data-v",Y.preserveOriginal);case"bem":return RX($,Z,Y.preserveOriginal);default:return $}}function LX($,Z,X,Y){let J=`[${X}-${Z}]`;return $.replace(/([.#]?[\w-]+|\*)\s*(\{|,)/g,(Q,G,q)=>{if(G.startsWith("@"))return Q;if(/^(?::root|:host|html|body)$/i.test(G))return Q;return`${Y?`${G}${J}`:`${G}${J}`}${q}`})}function wX($,Z,X){return $.replace(/\.([a-z_][\w-]*)/gi,(Y,J)=>{if(J.startsWith(Z))return Y;let Q=`${Z}__${J}`;return X?`.${Q}`:`.${Q}`})}function RX($,Z,X){let Y=Z.replace(/[^a-z0-9]/gi,"-");return $.replace(/\.([a-z_][\w-]*)/gi,(J,Q)=>{if(Q.includes("__")||Q.includes("--")){if(!Q.startsWith(Y))return`.${Y}__${Q}`;return J}let G=`${Y}__${Q}`;return X?`.${G}`:`.${G}`})}function DX($,Z,X={}){let Y={...G3,...X};if(Y.strategy==="shadow")return $;if(Y.strategy==="attribute"){let J=q3(Z),G=`${Y.attributeName||"data-v"}-${J}`;return $.replace(/<([a-z][a-z0-9-]*)([^>]*)>/gi,(q,U,W)=>{if(/^(?:script|style|!--)$/i.test(U))return q;let K=W.trimEnd().endsWith("/"),z=K?W.slice(0,-1):W;return`<${U}${z} ${G}${K?"/":""}>`})}if(Y.strategy==="prefix"||Y.strategy==="bem"){let J=Y.strategy==="bem"?Z.replace(/[^a-z0-9]/gi,"-"):Y.prefix||Z;return $.replace(/\bclass\s*=\s*["']([^"']+)["']/gi,(Q,G)=>{return`class="${G.split(/\s+/).map((U)=>{if(!U)return U;if(U.startsWith(J))return U;return`${J}__${U}`}).join(" ")}"`})}return $}function DW($,Z={}){let X={...G3,...Z},Y=q3($);return`${X.attributeName||"data-v"}-${Y}`}function NW($,Z,X={}){let Y="",J=$.replace(/<style([^>]*)>([\s\S]*?)<\/style>/gi,(G,q,U)=>{if(/\bscoped\b/i.test(q)||X.strategy!=="shadow")Y+=`${FX(U,Z,X)}
|
|
2423
|
+
`;else Y+=`${U}
|
|
2424
|
+
`;return""});return{html:DX(J,Z,X),css:Y.trim()}}function u1($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function AW($){let{name:Z,tag:X,baseElement:Y="HTMLElement",template:J,styles:Q="",shadowDOM:G=!0,properties:q={},lifecycle:U={},events:W={},methods:K={},state:z={}}=$,H=Z.replace(/\W/g,""),B=Object.keys(q),j=B.filter((T)=>q[T].attribute!==!1).map((T)=>q[T].attribute||u1(T)),_=B.map((T)=>{let A=q[T],M=A.default!==void 0?JSON.stringify(A.default):A.type==="string"?'""':A.type==="number"?"0":A.type==="boolean"?"false":A.type==="array"?"[]":"{}";return` this._${T} = ${M};`}).join(`
|
|
2425
|
+
`),V=B.map((T)=>{let A=q[T],M=A.attribute!==!1?A.attribute||u1(T):null,k=A.reflect&&M?`
|
|
2426
|
+
if (value !== null && value !== undefined) {
|
|
2427
|
+
${A.type==="boolean"?`if (value) { this.setAttribute('${M}', ''); }
|
|
2428
|
+
else { this.removeAttribute('${M}'); }`:`this.setAttribute('${M}', ${A.type==="object"||A.type==="array"?"JSON.stringify(value)":"String(value)"});`}
|
|
2429
|
+
}
|
|
2430
|
+
else {
|
|
2431
|
+
this.removeAttribute('${M}');
|
|
2432
|
+
}`:"",I=A.observer?`this.${A.observer}(value, oldValue);`:"",y=A.render!==!1?"this._scheduleRender();":"";return`
|
|
2433
|
+
get ${T}() {
|
|
2434
|
+
return this._${T};
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
set ${T}(value) {
|
|
2438
|
+
const oldValue = this._${T};
|
|
2439
|
+
if (oldValue === value) return;
|
|
2440
|
+
this._${T} = value;${k}
|
|
2441
|
+
${I}
|
|
2442
|
+
${y}
|
|
2443
|
+
this.dispatchEvent(new CustomEvent('${T}-changed', {
|
|
2444
|
+
detail: { value, oldValue },
|
|
2445
|
+
bubbles: true
|
|
2446
|
+
}));
|
|
2447
|
+
}`}).join(`
|
|
2448
|
+
`),O=j.length>0?`
|
|
2449
|
+
static get observedAttributes() {
|
|
2450
|
+
return [${j.map((T)=>`'${T}'`).join(", ")}];
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
2454
|
+
if (oldValue === newValue) return;
|
|
2455
|
+
const propName = this._attrToProp[name];
|
|
2456
|
+
if (propName) {
|
|
2457
|
+
const propDef = this._propertyDefs[propName];
|
|
2458
|
+
this[propName] = this._deserializeAttribute(newValue, propDef.type);
|
|
2459
|
+
}
|
|
2460
|
+
${U.attributeChanged||""}
|
|
2461
|
+
}`:"",F=Object.entries(W).map(([T,A])=>{return`this._root.addEventListener('${T}', (e) => { ${A} });`}).join(`
|
|
2462
|
+
`),L=Object.entries(K).map(([T,A])=>{return`
|
|
2463
|
+
${T}() {
|
|
2464
|
+
${A}
|
|
2465
|
+
}`}).join(`
|
|
2466
|
+
`),w=JSON.stringify(Object.fromEntries(B.map((T)=>[T,q[T]]))),R=JSON.stringify(Object.fromEntries(B.filter((T)=>q[T].attribute!==!1).map((T)=>[q[T].attribute||u1(T),T]))),D=J.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),N=Q.replace(/\\/g,"\\\\").replace(/`/g,"\\`");return`/**
|
|
2467
|
+
* ${Z} - Reactive Web Component
|
|
2468
|
+
* Auto-generated with reactive properties and lifecycle management
|
|
2469
|
+
*
|
|
2470
|
+
* @customElement ${X}
|
|
2471
|
+
*/
|
|
2472
|
+
class ${H} extends ${Y} {
|
|
2473
|
+
// Property definitions
|
|
2474
|
+
_propertyDefs = ${w};
|
|
2475
|
+
_attrToProp = ${R};
|
|
2476
|
+
|
|
2477
|
+
// Internal state
|
|
2478
|
+
_state = ${JSON.stringify(z)};
|
|
2479
|
+
_renderPending = false;
|
|
2480
|
+
_isConnected = false;
|
|
2481
|
+
|
|
2482
|
+
constructor() {
|
|
2483
|
+
super();
|
|
2484
|
+
${G?'this.attachShadow({ mode: "open" });':""}
|
|
2485
|
+
this._root = ${G?"this.shadowRoot":"this"};
|
|
2486
|
+
|
|
2487
|
+
// Initialize properties with defaults
|
|
2488
|
+
${_}
|
|
2489
|
+
|
|
2490
|
+
// Initial render
|
|
2491
|
+
this._render();
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
// =========================================================================
|
|
2495
|
+
// Reactive Properties
|
|
2496
|
+
// =========================================================================
|
|
2497
|
+
${V}
|
|
2498
|
+
|
|
2499
|
+
// =========================================================================
|
|
2500
|
+
// State Management
|
|
2501
|
+
// =========================================================================
|
|
2502
|
+
|
|
2503
|
+
/**
|
|
2504
|
+
* Get current internal state
|
|
2505
|
+
*/
|
|
2506
|
+
get state() {
|
|
2507
|
+
return { ...this._state };
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
/**
|
|
2511
|
+
* Update internal state and trigger re-render
|
|
2512
|
+
* @param {Object} updates - State updates to merge
|
|
2513
|
+
*/
|
|
2514
|
+
setState(updates) {
|
|
2515
|
+
const oldState = { ...this._state };
|
|
2516
|
+
this._state = { ...this._state, ...updates };
|
|
2517
|
+
this._scheduleRender();
|
|
2518
|
+
this.dispatchEvent(new CustomEvent('state-changed', {
|
|
2519
|
+
detail: { state: this._state, oldState },
|
|
2520
|
+
bubbles: true
|
|
2521
|
+
}));
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
// =========================================================================
|
|
2525
|
+
// Rendering
|
|
2526
|
+
// =========================================================================
|
|
2527
|
+
|
|
2528
|
+
/**
|
|
2529
|
+
* Schedule a render on the next animation frame (batched)
|
|
2530
|
+
*/
|
|
2531
|
+
_scheduleRender() {
|
|
2532
|
+
if (this._renderPending) return;
|
|
2533
|
+
this._renderPending = true;
|
|
2534
|
+
requestAnimationFrame(() => {
|
|
2535
|
+
this._renderPending = false;
|
|
2536
|
+
this._render();
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2540
|
+
/**
|
|
2541
|
+
* Render the component template
|
|
2542
|
+
*/
|
|
2543
|
+
_render() {
|
|
2544
|
+
const template = \`${N?`<style>${N}</style>`:""}${D}\`;
|
|
2545
|
+
|
|
2546
|
+
// Interpolate template with property values
|
|
2547
|
+
const rendered = template.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (match, propName) => {
|
|
2548
|
+
if (propName in this) {
|
|
2549
|
+
const value = this[propName];
|
|
2550
|
+
if (value === null || value === undefined) return '';
|
|
2551
|
+
if (typeof value === 'object') return JSON.stringify(value);
|
|
2552
|
+
return String(value);
|
|
2553
|
+
}
|
|
2554
|
+
if (propName in this._state) {
|
|
2555
|
+
const value = this._state[propName];
|
|
2556
|
+
if (value === null || value === undefined) return '';
|
|
2557
|
+
if (typeof value === 'object') return JSON.stringify(value);
|
|
2558
|
+
return String(value);
|
|
2559
|
+
}
|
|
2560
|
+
return match;
|
|
2561
|
+
});
|
|
2562
|
+
|
|
2563
|
+
this._root.innerHTML = rendered;
|
|
2564
|
+
this._bindEvents();
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
/**
|
|
2568
|
+
* Bind event handlers after render
|
|
2569
|
+
*/
|
|
2570
|
+
_bindEvents() {
|
|
2571
|
+
${F}
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
// =========================================================================
|
|
2575
|
+
// Attribute Handling
|
|
2576
|
+
// =========================================================================
|
|
2577
|
+
|
|
2578
|
+
/**
|
|
2579
|
+
* Deserialize attribute value to property type
|
|
2580
|
+
*/
|
|
2581
|
+
_deserializeAttribute(value, type) {
|
|
2582
|
+
if (value === null) return null;
|
|
2583
|
+
switch (type) {
|
|
2584
|
+
case 'number': return Number(value);
|
|
2585
|
+
case 'boolean': return value !== null && value !== 'false' && value !== '0';
|
|
2586
|
+
case 'object':
|
|
2587
|
+
case 'array':
|
|
2588
|
+
try { return JSON.parse(value); }
|
|
2589
|
+
catch { return type === 'array' ? [] : {}; }
|
|
2590
|
+
default: return value;
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
${O}
|
|
2595
|
+
|
|
2596
|
+
// =========================================================================
|
|
2597
|
+
// Lifecycle
|
|
2598
|
+
// =========================================================================
|
|
2599
|
+
|
|
2600
|
+
connectedCallback() {
|
|
2601
|
+
this._isConnected = true;
|
|
2602
|
+
${U.connected||"// Component connected to DOM"}
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
disconnectedCallback() {
|
|
2606
|
+
this._isConnected = false;
|
|
2607
|
+
${U.disconnected||"// Component disconnected from DOM"}
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
adoptedCallback() {
|
|
2611
|
+
${U.adopted||"// Component moved to new document"}
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
// =========================================================================
|
|
2615
|
+
// Custom Methods
|
|
2616
|
+
// =========================================================================
|
|
2617
|
+
${L}
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
// Register the custom element
|
|
2621
|
+
customElements.define('${X}', ${H});
|
|
2622
|
+
|
|
2623
|
+
// Export for module usage
|
|
2624
|
+
export { ${H} };
|
|
2625
|
+
export default ${H};
|
|
2626
|
+
`}function MW($){let{name:Z,tag:X,baseElement:Y="HTMLElement",template:J,styles:Q="",shadowDOM:G=!0,properties:q={},lifecycle:U={},events:W={},methods:K={},state:z={}}=$,H=Z.replace(/\W/g,""),B=Object.keys(q),j=B.filter((A)=>q[A].attribute!==!1).map((A)=>q[A].attribute||u1(A)),_=(A)=>{switch(A){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":return"Record<string, unknown>";case"array":return"unknown[]";default:return"unknown"}},V=B.length>0?`
|
|
2627
|
+
/**
|
|
2628
|
+
* Props interface for ${Z}
|
|
2629
|
+
*/
|
|
2630
|
+
export interface ${H}Props {
|
|
2631
|
+
${B.map((A)=>` ${A}?: ${_(q[A].type)};`).join(`
|
|
2632
|
+
`)}
|
|
2633
|
+
}
|
|
2634
|
+
`:"",O=Object.keys(z).length>0?`
|
|
2635
|
+
/**
|
|
2636
|
+
* State interface for ${Z}
|
|
2637
|
+
*/
|
|
2638
|
+
export interface ${H}State {
|
|
2639
|
+
${Object.entries(z).map(([A,M])=>` ${A}: ${typeof M};`).join(`
|
|
2640
|
+
`)}
|
|
2641
|
+
}
|
|
2642
|
+
`:`
|
|
2643
|
+
export interface ${H}State {
|
|
2644
|
+
[key: string]: unknown;
|
|
2645
|
+
}
|
|
2646
|
+
`,F=B.map((A)=>{let M=q[A],k=_(M.type);return` private _${A}: ${k};`}).join(`
|
|
2647
|
+
`),L=B.map((A)=>{let M=q[A],k=_(M.type),I=M.attribute!==!1?M.attribute||u1(A):null,y=M.default!==void 0?JSON.stringify(M.default):M.type==="string"?'""':M.type==="number"?"0":M.type==="boolean"?"false":M.type==="array"?"[]":"{}",E=M.reflect&&I?`
|
|
2648
|
+
if (value !== null && value !== undefined) {
|
|
2649
|
+
${M.type==="boolean"?`if (value) { this.setAttribute('${I}', ''); }
|
|
2650
|
+
else { this.removeAttribute('${I}'); }`:`this.setAttribute('${I}', ${M.type==="object"||M.type==="array"?"JSON.stringify(value)":"String(value)"});`}
|
|
2651
|
+
}
|
|
2652
|
+
else {
|
|
2653
|
+
this.removeAttribute('${I}');
|
|
2654
|
+
}`:"",b=M.observer?`this.${M.observer}(value, oldValue);`:"",C=M.render!==!1?"this._scheduleRender();":"";return`
|
|
2655
|
+
get ${A}(): ${k} {
|
|
2656
|
+
return this._${A};
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
set ${A}(value: ${k}) {
|
|
2660
|
+
const oldValue = this._${A};
|
|
2661
|
+
if (oldValue === value) return;
|
|
2662
|
+
this._${A} = value;${E}
|
|
2663
|
+
${b}
|
|
2664
|
+
${C}
|
|
2665
|
+
this.dispatchEvent(new CustomEvent('${A}-changed', {
|
|
2666
|
+
detail: { value, oldValue },
|
|
2667
|
+
bubbles: true
|
|
2668
|
+
}));
|
|
2669
|
+
}
|
|
2670
|
+
|
|
2671
|
+
// Property default: ${y}`}).join(`
|
|
2672
|
+
`),w=j.length>0?`
|
|
2673
|
+
static get observedAttributes(): string[] {
|
|
2674
|
+
return [${j.map((A)=>`'${A}'`).join(", ")}];
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {
|
|
2678
|
+
if (oldValue === newValue) return;
|
|
2679
|
+
const propName = this._attrToProp[name];
|
|
2680
|
+
if (propName) {
|
|
2681
|
+
const propDef = this._propertyDefs[propName];
|
|
2682
|
+
(this as unknown as Record<string, unknown>)[propName] = this._deserializeAttribute(newValue, propDef.type);
|
|
2683
|
+
}
|
|
2684
|
+
${U.attributeChanged||""}
|
|
2685
|
+
}`:"",R=Object.entries(W).map(([A,M])=>{return`this._root.addEventListener('${A}', (e: Event) => { ${M} });`}).join(`
|
|
2686
|
+
`),D=Object.entries(K).map(([A,M])=>{return`
|
|
2687
|
+
${A}(): void {
|
|
2688
|
+
${M}
|
|
2689
|
+
}`}).join(`
|
|
2690
|
+
`),N=J.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),T=Q.replace(/\\/g,"\\\\").replace(/`/g,"\\`");return`/**
|
|
2691
|
+
* ${Z} - Reactive Web Component (TypeScript)
|
|
2692
|
+
* Auto-generated with reactive properties and lifecycle management
|
|
2693
|
+
*
|
|
2694
|
+
* @customElement ${X}
|
|
2695
|
+
*/
|
|
2696
|
+
|
|
2697
|
+
${V}
|
|
2698
|
+
${O}
|
|
2699
|
+
|
|
2700
|
+
/**
|
|
2701
|
+
* Property definition type
|
|
2702
|
+
*/
|
|
2703
|
+
interface PropertyDefinition {
|
|
2704
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
2705
|
+
default?: unknown;
|
|
2706
|
+
reflect?: boolean;
|
|
2707
|
+
attribute?: string | false;
|
|
2708
|
+
observer?: string;
|
|
2709
|
+
render?: boolean;
|
|
2710
|
+
}
|
|
2711
|
+
|
|
2712
|
+
/**
|
|
2713
|
+
* ${Z} custom element
|
|
2714
|
+
*/
|
|
2715
|
+
export class ${H} extends ${Y} {
|
|
2716
|
+
// Property definitions
|
|
2717
|
+
private _propertyDefs: Record<string, PropertyDefinition> = ${JSON.stringify(q)};
|
|
2718
|
+
private _attrToProp: Record<string, string> = ${JSON.stringify(Object.fromEntries(B.filter((A)=>q[A].attribute!==!1).map((A)=>[q[A].attribute||u1(A),A])))};
|
|
2719
|
+
|
|
2720
|
+
// Internal state
|
|
2721
|
+
private _state: ${H}State = ${JSON.stringify(z)};
|
|
2722
|
+
private _renderPending = false;
|
|
2723
|
+
private _isConnected = false;
|
|
2724
|
+
private _root: ShadowRoot | HTMLElement;
|
|
2725
|
+
|
|
2726
|
+
// Property backing fields
|
|
2727
|
+
${F}
|
|
2728
|
+
|
|
2729
|
+
constructor() {
|
|
2730
|
+
super();
|
|
2731
|
+
${G?'this.attachShadow({ mode: "open" });':""}
|
|
2732
|
+
this._root = ${G?"this.shadowRoot!":"this"};
|
|
2733
|
+
|
|
2734
|
+
// Initialize properties with defaults
|
|
2735
|
+
${B.map((A)=>{let M=q[A],k=M.default!==void 0?JSON.stringify(M.default):M.type==="string"?'""':M.type==="number"?"0":M.type==="boolean"?"false":M.type==="array"?"[]":"{}";return` this._${A} = ${k};`}).join(`
|
|
2736
|
+
`)}
|
|
2737
|
+
|
|
2738
|
+
// Initial render
|
|
2739
|
+
this._render();
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2742
|
+
// =========================================================================
|
|
2743
|
+
// Reactive Properties
|
|
2744
|
+
// =========================================================================
|
|
2745
|
+
${L}
|
|
2746
|
+
|
|
2747
|
+
// =========================================================================
|
|
2748
|
+
// State Management
|
|
2749
|
+
// =========================================================================
|
|
2750
|
+
|
|
2751
|
+
/**
|
|
2752
|
+
* Get current internal state
|
|
2753
|
+
*/
|
|
2754
|
+
get state(): ${H}State {
|
|
2755
|
+
return { ...this._state };
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
/**
|
|
2759
|
+
* Update internal state and trigger re-render
|
|
2760
|
+
*/
|
|
2761
|
+
setState(updates: Partial<${H}State>): void {
|
|
2762
|
+
const oldState = { ...this._state };
|
|
2763
|
+
this._state = { ...this._state, ...updates };
|
|
2764
|
+
this._scheduleRender();
|
|
2765
|
+
this.dispatchEvent(new CustomEvent('state-changed', {
|
|
2766
|
+
detail: { state: this._state, oldState },
|
|
2767
|
+
bubbles: true
|
|
2768
|
+
}));
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
// =========================================================================
|
|
2772
|
+
// Rendering
|
|
2773
|
+
// =========================================================================
|
|
2774
|
+
|
|
2775
|
+
/**
|
|
2776
|
+
* Schedule a render on the next animation frame (batched)
|
|
2777
|
+
*/
|
|
2778
|
+
private _scheduleRender(): void {
|
|
2779
|
+
if (this._renderPending) return;
|
|
2780
|
+
this._renderPending = true;
|
|
2781
|
+
requestAnimationFrame(() => {
|
|
2782
|
+
this._renderPending = false;
|
|
2783
|
+
this._render();
|
|
2784
|
+
});
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
/**
|
|
2788
|
+
* Render the component template
|
|
2789
|
+
*/
|
|
2790
|
+
private _render(): void {
|
|
2791
|
+
const template = \`${T?`<style>${T}</style>`:""}${N}\`;
|
|
2792
|
+
|
|
2793
|
+
// Interpolate template with property values
|
|
2794
|
+
const rendered = template.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (match, propName) => {
|
|
2795
|
+
if (propName in this) {
|
|
2796
|
+
const value = (this as unknown as Record<string, unknown>)[propName];
|
|
2797
|
+
if (value === null || value === undefined) return '';
|
|
2798
|
+
if (typeof value === 'object') return JSON.stringify(value);
|
|
2799
|
+
return String(value);
|
|
2800
|
+
}
|
|
2801
|
+
if (propName in this._state) {
|
|
2802
|
+
const value = this._state[propName as keyof ${H}State];
|
|
2803
|
+
if (value === null || value === undefined) return '';
|
|
2804
|
+
if (typeof value === 'object') return JSON.stringify(value);
|
|
2805
|
+
return String(value);
|
|
2806
|
+
}
|
|
2807
|
+
return match;
|
|
2808
|
+
});
|
|
2809
|
+
|
|
2810
|
+
this._root.innerHTML = rendered;
|
|
2811
|
+
this._bindEvents();
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
/**
|
|
2815
|
+
* Bind event handlers after render
|
|
2816
|
+
*/
|
|
2817
|
+
private _bindEvents(): void {
|
|
2818
|
+
${R}
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
// =========================================================================
|
|
2822
|
+
// Attribute Handling
|
|
2823
|
+
// =========================================================================
|
|
2824
|
+
|
|
2825
|
+
/**
|
|
2826
|
+
* Deserialize attribute value to property type
|
|
2827
|
+
*/
|
|
2828
|
+
private _deserializeAttribute(value: string | null, type: string): unknown {
|
|
2829
|
+
if (value === null) return null;
|
|
2830
|
+
switch (type) {
|
|
2831
|
+
case 'number': return Number(value);
|
|
2832
|
+
case 'boolean': return value !== null && value !== 'false' && value !== '0';
|
|
2833
|
+
case 'object':
|
|
2834
|
+
case 'array':
|
|
2835
|
+
try { return JSON.parse(value); }
|
|
2836
|
+
catch { return type === 'array' ? [] : {}; }
|
|
2837
|
+
default: return value;
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
|
|
2841
|
+
${w}
|
|
2842
|
+
|
|
2843
|
+
// =========================================================================
|
|
2844
|
+
// Lifecycle
|
|
2845
|
+
// =========================================================================
|
|
2846
|
+
|
|
2847
|
+
connectedCallback(): void {
|
|
2848
|
+
this._isConnected = true;
|
|
2849
|
+
${U.connected||"// Component connected to DOM"}
|
|
2850
|
+
}
|
|
2851
|
+
|
|
2852
|
+
disconnectedCallback(): void {
|
|
2853
|
+
this._isConnected = false;
|
|
2854
|
+
${U.disconnected||"// Component disconnected from DOM"}
|
|
2855
|
+
}
|
|
2856
|
+
|
|
2857
|
+
adoptedCallback(): void {
|
|
2858
|
+
${U.adopted||"// Component moved to new document"}
|
|
2859
|
+
}
|
|
2860
|
+
|
|
2861
|
+
// =========================================================================
|
|
2862
|
+
// Custom Methods
|
|
2863
|
+
// =========================================================================
|
|
2864
|
+
${D}
|
|
2865
|
+
}
|
|
2866
|
+
|
|
2867
|
+
// Type augmentation for HTMLElementTagNameMap
|
|
2868
|
+
declare global {
|
|
2869
|
+
interface HTMLElementTagNameMap {
|
|
2870
|
+
'${X}': ${H};
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
|
|
2874
|
+
// Register the custom element
|
|
2875
|
+
customElements.define('${X}', ${H});
|
|
2876
|
+
|
|
2877
|
+
export default ${H};
|
|
2878
|
+
`}function TW(){return`/**
|
|
2879
|
+
* ReactiveElement Mixin
|
|
2880
|
+
* Adds reactive properties and lifecycle management to web components
|
|
2881
|
+
*/
|
|
2882
|
+
const ReactiveElement = (Base) => class extends Base {
|
|
2883
|
+
static get observedAttributes() {
|
|
2884
|
+
const props = this.properties || {};
|
|
2885
|
+
return Object.keys(props)
|
|
2886
|
+
.filter(prop => props[prop].attribute !== false)
|
|
2887
|
+
.map(prop => props[prop].attribute || prop.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase());
|
|
2888
|
+
}
|
|
2889
|
+
|
|
2890
|
+
constructor() {
|
|
2891
|
+
super();
|
|
2892
|
+
this._state = {};
|
|
2893
|
+
this._renderPending = false;
|
|
2894
|
+
this._propertyValues = new Map();
|
|
2895
|
+
this._initializeProperties();
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
_initializeProperties() {
|
|
2899
|
+
const props = this.constructor.properties || {};
|
|
2900
|
+
for (const [name, def] of Object.entries(props)) {
|
|
2901
|
+
// Set default value
|
|
2902
|
+
if (def.default !== undefined) {
|
|
2903
|
+
this._propertyValues.set(name, def.default);
|
|
2904
|
+
}
|
|
2905
|
+
|
|
2906
|
+
// Define getter/setter
|
|
2907
|
+
Object.defineProperty(this, name, {
|
|
2908
|
+
get: () => this._propertyValues.get(name),
|
|
2909
|
+
set: (value) => {
|
|
2910
|
+
const oldValue = this._propertyValues.get(name);
|
|
2911
|
+
if (oldValue === value) return;
|
|
2912
|
+
this._propertyValues.set(name, value);
|
|
2913
|
+
|
|
2914
|
+
// Reflect to attribute
|
|
2915
|
+
if (def.reflect) {
|
|
2916
|
+
const attrName = def.attribute || name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
2917
|
+
if (def.type === 'boolean') {
|
|
2918
|
+
value ? this.setAttribute(attrName, '') : this.removeAttribute(attrName);
|
|
2919
|
+
}
|
|
2920
|
+
else {
|
|
2921
|
+
this.setAttribute(attrName, def.type === 'object' ? JSON.stringify(value) : String(value));
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
|
|
2925
|
+
// Call observer
|
|
2926
|
+
if (def.observer && typeof this[def.observer] === 'function') {
|
|
2927
|
+
this[def.observer](value, oldValue);
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2930
|
+
// Schedule render
|
|
2931
|
+
if (def.render !== false) {
|
|
2932
|
+
this._scheduleRender();
|
|
2933
|
+
}
|
|
2934
|
+
|
|
2935
|
+
// Dispatch event
|
|
2936
|
+
this.dispatchEvent(new CustomEvent(\`\${name}-changed\`, {
|
|
2937
|
+
detail: { value, oldValue },
|
|
2938
|
+
bubbles: true
|
|
2939
|
+
}));
|
|
2940
|
+
},
|
|
2941
|
+
enumerable: true,
|
|
2942
|
+
configurable: true
|
|
2943
|
+
});
|
|
2944
|
+
}
|
|
2945
|
+
}
|
|
2946
|
+
|
|
2947
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
2948
|
+
if (oldValue === newValue) return;
|
|
2949
|
+
const props = this.constructor.properties || {};
|
|
2950
|
+
const propName = Object.keys(props).find(p =>
|
|
2951
|
+
(props[p].attribute || p.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()) === name
|
|
2952
|
+
);
|
|
2953
|
+
if (propName) {
|
|
2954
|
+
const def = props[propName];
|
|
2955
|
+
this[propName] = this._deserialize(newValue, def.type);
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
_deserialize(value, type) {
|
|
2960
|
+
if (value === null) return null;
|
|
2961
|
+
switch (type) {
|
|
2962
|
+
case 'number': return Number(value);
|
|
2963
|
+
case 'boolean': return value !== null && value !== 'false';
|
|
2964
|
+
case 'object':
|
|
2965
|
+
case 'array':
|
|
2966
|
+
try { return JSON.parse(value); }
|
|
2967
|
+
catch { return type === 'array' ? [] : {}; }
|
|
2968
|
+
default: return value;
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
|
|
2972
|
+
get state() {
|
|
2973
|
+
return { ...this._state };
|
|
2974
|
+
}
|
|
2975
|
+
|
|
2976
|
+
setState(updates) {
|
|
2977
|
+
const oldState = { ...this._state };
|
|
2978
|
+
this._state = { ...this._state, ...updates };
|
|
2979
|
+
this._scheduleRender();
|
|
2980
|
+
this.dispatchEvent(new CustomEvent('state-changed', {
|
|
2981
|
+
detail: { state: this._state, oldState },
|
|
2982
|
+
bubbles: true
|
|
2983
|
+
}));
|
|
2984
|
+
}
|
|
2985
|
+
|
|
2986
|
+
_scheduleRender() {
|
|
2987
|
+
if (this._renderPending) return;
|
|
2988
|
+
this._renderPending = true;
|
|
2989
|
+
requestAnimationFrame(() => {
|
|
2990
|
+
this._renderPending = false;
|
|
2991
|
+
if (typeof this.render === 'function') {
|
|
2992
|
+
this.render();
|
|
2993
|
+
}
|
|
2994
|
+
});
|
|
2995
|
+
}
|
|
2996
|
+
};
|
|
2997
|
+
|
|
2998
|
+
export { ReactiveElement };
|
|
2999
|
+
export default ReactiveElement;
|
|
3000
|
+
`}function IW(){return`/**
|
|
3001
|
+
* stx Reactive Web Components Runtime
|
|
3002
|
+
* Provides base classes and utilities for reactive web components
|
|
3003
|
+
*/
|
|
3004
|
+
(function(global) {
|
|
3005
|
+
'use strict';
|
|
3006
|
+
|
|
3007
|
+
/**
|
|
3008
|
+
* Base class for reactive web components
|
|
3009
|
+
*/
|
|
3010
|
+
class StxElement extends HTMLElement {
|
|
3011
|
+
static get observedAttributes() {
|
|
3012
|
+
const props = this.properties || {};
|
|
3013
|
+
return Object.keys(props)
|
|
3014
|
+
.filter(prop => props[prop].attribute !== false)
|
|
3015
|
+
.map(prop => props[prop].attribute || toKebabCase(prop));
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
constructor() {
|
|
3019
|
+
super();
|
|
3020
|
+
this._state = {};
|
|
3021
|
+
this._renderPending = false;
|
|
3022
|
+
this._props = new Map();
|
|
3023
|
+
this._setupShadowDOM();
|
|
3024
|
+
this._initProperties();
|
|
3025
|
+
}
|
|
3026
|
+
|
|
3027
|
+
_setupShadowDOM() {
|
|
3028
|
+
if (this.constructor.useShadowDOM !== false) {
|
|
3029
|
+
this.attachShadow({ mode: 'open' });
|
|
3030
|
+
this._root = this.shadowRoot;
|
|
3031
|
+
}
|
|
3032
|
+
else {
|
|
3033
|
+
this._root = this;
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
|
|
3037
|
+
_initProperties() {
|
|
3038
|
+
const props = this.constructor.properties || {};
|
|
3039
|
+
for (const [name, def] of Object.entries(props)) {
|
|
3040
|
+
let value = def.default;
|
|
3041
|
+
this._props.set(name, value);
|
|
3042
|
+
|
|
3043
|
+
Object.defineProperty(this, name, {
|
|
3044
|
+
get: () => this._props.get(name),
|
|
3045
|
+
set: (newValue) => this._setProperty(name, newValue, def),
|
|
3046
|
+
enumerable: true
|
|
3047
|
+
});
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
_setProperty(name, value, def) {
|
|
3052
|
+
const oldValue = this._props.get(name);
|
|
3053
|
+
if (oldValue === value) return;
|
|
3054
|
+
|
|
3055
|
+
this._props.set(name, value);
|
|
3056
|
+
|
|
3057
|
+
if (def.reflect && def.attribute !== false) {
|
|
3058
|
+
this._reflectToAttribute(name, value, def);
|
|
3059
|
+
}
|
|
3060
|
+
|
|
3061
|
+
if (def.observer && this[def.observer]) {
|
|
3062
|
+
this[def.observer](value, oldValue);
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3065
|
+
if (def.render !== false) {
|
|
3066
|
+
this.requestUpdate();
|
|
3067
|
+
}
|
|
3068
|
+
|
|
3069
|
+
this.dispatchEvent(new CustomEvent(name + '-changed', {
|
|
3070
|
+
detail: { value, oldValue },
|
|
3071
|
+
bubbles: true,
|
|
3072
|
+
composed: true
|
|
3073
|
+
}));
|
|
3074
|
+
}
|
|
3075
|
+
|
|
3076
|
+
_reflectToAttribute(name, value, def) {
|
|
3077
|
+
const attrName = def.attribute || toKebabCase(name);
|
|
3078
|
+
if (value == null || (def.type === 'boolean' && !value)) {
|
|
3079
|
+
this.removeAttribute(attrName);
|
|
3080
|
+
}
|
|
3081
|
+
else if (def.type === 'boolean') {
|
|
3082
|
+
this.setAttribute(attrName, '');
|
|
3083
|
+
}
|
|
3084
|
+
else if (def.type === 'object' || def.type === 'array') {
|
|
3085
|
+
this.setAttribute(attrName, JSON.stringify(value));
|
|
3086
|
+
}
|
|
3087
|
+
else {
|
|
3088
|
+
this.setAttribute(attrName, String(value));
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
3093
|
+
if (oldValue === newValue) return;
|
|
3094
|
+
const props = this.constructor.properties || {};
|
|
3095
|
+
const propName = Object.keys(props).find(p => {
|
|
3096
|
+
const def = props[p];
|
|
3097
|
+
return (def.attribute || toKebabCase(p)) === name;
|
|
3098
|
+
});
|
|
3099
|
+
|
|
3100
|
+
if (propName) {
|
|
3101
|
+
const def = props[propName];
|
|
3102
|
+
this[propName] = deserialize(newValue, def.type);
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
|
|
3106
|
+
get state() {
|
|
3107
|
+
return { ...this._state };
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
setState(updates) {
|
|
3111
|
+
const oldState = { ...this._state };
|
|
3112
|
+
Object.assign(this._state, updates);
|
|
3113
|
+
this.requestUpdate();
|
|
3114
|
+
this.dispatchEvent(new CustomEvent('state-changed', {
|
|
3115
|
+
detail: { state: this._state, oldState },
|
|
3116
|
+
bubbles: true
|
|
3117
|
+
}));
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
requestUpdate() {
|
|
3121
|
+
if (this._renderPending) return;
|
|
3122
|
+
this._renderPending = true;
|
|
3123
|
+
requestAnimationFrame(() => {
|
|
3124
|
+
this._renderPending = false;
|
|
3125
|
+
this.update();
|
|
3126
|
+
});
|
|
3127
|
+
}
|
|
3128
|
+
|
|
3129
|
+
update() {
|
|
3130
|
+
if (this.render) {
|
|
3131
|
+
const content = this.render();
|
|
3132
|
+
if (typeof content === 'string') {
|
|
3133
|
+
this._root.innerHTML = content;
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
connectedCallback() {
|
|
3139
|
+
this.update();
|
|
3140
|
+
if (this.connected) this.connected();
|
|
3141
|
+
}
|
|
3142
|
+
|
|
3143
|
+
disconnectedCallback() {
|
|
3144
|
+
if (this.disconnected) this.disconnected();
|
|
3145
|
+
}
|
|
3146
|
+
|
|
3147
|
+
adoptedCallback() {
|
|
3148
|
+
if (this.adopted) this.adopted();
|
|
3149
|
+
}
|
|
3150
|
+
|
|
3151
|
+
// Template helper
|
|
3152
|
+
html(strings, ...values) {
|
|
3153
|
+
return strings.reduce((result, str, i) => {
|
|
3154
|
+
let value = values[i] || '';
|
|
3155
|
+
if (Array.isArray(value)) value = value.join('');
|
|
3156
|
+
if (typeof value === 'object') value = JSON.stringify(value);
|
|
3157
|
+
return result + str + value;
|
|
3158
|
+
}, '');
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3162
|
+
// Utility functions
|
|
3163
|
+
function toKebabCase(str) {
|
|
3164
|
+
return str.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
3165
|
+
}
|
|
3166
|
+
|
|
3167
|
+
function deserialize(value, type) {
|
|
3168
|
+
if (value === null) return null;
|
|
3169
|
+
switch (type) {
|
|
3170
|
+
case 'number': return Number(value);
|
|
3171
|
+
case 'boolean': return value !== null && value !== 'false' && value !== '0';
|
|
3172
|
+
case 'object':
|
|
3173
|
+
case 'array':
|
|
3174
|
+
try { return JSON.parse(value); }
|
|
3175
|
+
catch { return type === 'array' ? [] : {}; }
|
|
3176
|
+
default: return value;
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
|
|
3180
|
+
// Export to global
|
|
3181
|
+
global.StxElement = StxElement;
|
|
3182
|
+
global.stxComponents = global.stxComponents || {};
|
|
3183
|
+
|
|
3184
|
+
// Helper to define components
|
|
3185
|
+
global.defineStxComponent = function(tag, config) {
|
|
3186
|
+
const { properties, template, styles, methods, ...options } = config;
|
|
3187
|
+
|
|
3188
|
+
class Component extends StxElement {
|
|
3189
|
+
static get properties() { return properties || {}; }
|
|
3190
|
+
static get useShadowDOM() { return options.shadowDOM !== false; }
|
|
3191
|
+
|
|
3192
|
+
render() {
|
|
3193
|
+
let html = template || '';
|
|
3194
|
+
// Simple interpolation
|
|
3195
|
+
html = html.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (match, key) => {
|
|
3196
|
+
if (key in this) return this[key] ?? '';
|
|
3197
|
+
if (key in this._state) return this._state[key] ?? '';
|
|
3198
|
+
return match;
|
|
3199
|
+
});
|
|
3200
|
+
return (styles ? '<style>' + styles + '</style>' : '') + html;
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
|
|
3204
|
+
// Add methods
|
|
3205
|
+
if (methods) {
|
|
3206
|
+
for (const [name, fn] of Object.entries(methods)) {
|
|
3207
|
+
Component.prototype[name] = fn;
|
|
3208
|
+
}
|
|
3209
|
+
}
|
|
3210
|
+
|
|
3211
|
+
customElements.define(tag, Component);
|
|
3212
|
+
global.stxComponents[tag] = Component;
|
|
3213
|
+
return Component;
|
|
3214
|
+
};
|
|
3215
|
+
|
|
3216
|
+
})(typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : this);
|
|
3217
|
+
`}function NX($,Z){let X=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Y=X?X[1].trim():"",J=Z,Q=[],G=!0;if(Y){let z=Y.match(/export\s+default\s+({[\s\S]*})/);if(z)try{let H=z[1],B=H.match(/tag\s*:\s*['"`]([^'"`]+)['"`]/);if(B)J=B[1];let j=H.match(/props\s*:\s*\[([\s\S]*?)\]/);if(j)Q=j[1].split(",").map((V)=>V.trim().replace(/['"`]/g,"")).filter((V)=>V.length>0);let _=H.match(/shadowDOM\s*:\s*(true|false)/);if(_)G=_[1]==="true"}catch{}}let q=$.match(/<template\b(?![^>]*\bid\s*=)[^>]*>([\s\S]*?)<\/template>/i),U=q?q[1].trim():"",W=$.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i),K=W?W[1].trim():"";return{tag:J,props:Q,template:U,styles:K,script:Y,shadowDOM:G}}function AX($){let{tag:Z,props:X,template:Y,styles:J,shadowDOM:Q}=$,G=Z.split("-").map((z)=>z.charAt(0).toUpperCase()+z.slice(1)).join(""),q=Y.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),U=J.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),W=X.map((z)=>`'${z}'`).join(", "),K=X.map((z)=>`
|
|
3218
|
+
get ${z}() {
|
|
3219
|
+
return this.getAttribute('${z}') || '';
|
|
3220
|
+
}
|
|
3221
|
+
set ${z}(value) {
|
|
3222
|
+
if (value) {
|
|
3223
|
+
this.setAttribute('${z}', value);
|
|
3224
|
+
}
|
|
3225
|
+
else {
|
|
3226
|
+
this.removeAttribute('${z}');
|
|
3227
|
+
}
|
|
3228
|
+
}`).join(`
|
|
3229
|
+
`);return`/**
|
|
3230
|
+
* ${G} Web Component
|
|
3231
|
+
* Auto-generated from SFC
|
|
3232
|
+
*/
|
|
3233
|
+
class ${G} extends HTMLElement {
|
|
3234
|
+
constructor() {
|
|
3235
|
+
super();
|
|
3236
|
+
${Q?"this.attachShadow({ mode: 'open' });":""}
|
|
3237
|
+
this._render();
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
static get observedAttributes() {
|
|
3241
|
+
return [${W}];
|
|
3242
|
+
}
|
|
3243
|
+
|
|
3244
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
3245
|
+
if (oldValue !== newValue) {
|
|
3246
|
+
this._render();
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
${K}
|
|
3250
|
+
|
|
3251
|
+
_render() {
|
|
3252
|
+
const template = \`${U?`<style>${U}</style>`:""}${q}\`;
|
|
3253
|
+
|
|
3254
|
+
// Interpolate {{ prop }} with attribute values
|
|
3255
|
+
const rendered = template.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (match, prop) => {
|
|
3256
|
+
return this.getAttribute(prop) || '';
|
|
3257
|
+
});
|
|
3258
|
+
|
|
3259
|
+
${Q?"this.shadowRoot.innerHTML = rendered;":"this.innerHTML = rendered;"}
|
|
3260
|
+
}
|
|
3261
|
+
|
|
3262
|
+
connectedCallback() {
|
|
3263
|
+
this._render();
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3266
|
+
|
|
3267
|
+
customElements.define('${Z}', ${G});
|
|
3268
|
+
`}async function Q6($,Z,X,Y){if(Z.length<1)return $0("WebComponent","@webcomponent directive requires at least the tag name parameter",l.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),G=(X.__stx_options||{}).componentsDir||"components",q=[q1.join(q1.dirname(Y),G,`${J}.stx`),q1.join(process.cwd(),G,`${J}.stx`),q1.join(q1.dirname(Y),`${J}.stx`)],U=null;for(let z of q)if(await r(z)){U=await Bun.file(z).text();break}if(!U)return $0("WebComponent",`Component file not found: ${J}.stx`,l.FILE_NOT_FOUND);let W=NX(U,J);return`<script type="module">
|
|
3269
|
+
${AX(W)}
|
|
3270
|
+
</script>`}var j6={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:K6,cachePath:".stx/cache",cacheVersion:"1.0.0",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:A7,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Q6,hasEndTag:!1,description:"Include a web component in the template"},U6,W6,J3,Q3,v$,x$,g$,f$,w7,z7,f7,r$,...B6],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,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 TX($,Z,X){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let J=X||process.cwd(),Q=S0.join(J,"resources","views"),G=S0.join(J,"resources","layouts");if(a5.existsSync(Q)&&a5.existsSync(G))return{root:"resources",pagesDir:"views"};let q=S0.join(J,"resources","views","pages");if(a5.existsSync(q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}var G6=new Set;function IX($,Z){let X=Z.replace(/[\\/]+$/,"");if(!X||X===".")return!0;let Y=$.replace(/\\/g,"/"),J=X.replace(/\\/g,"/");return Y===J||Y.startsWith(`${J}/`)}function kX($,Z){let X=!$.root,Y=TX($.root,$.pagesDir,Z);if($.root=Y.root,$.pagesDir=Y.pagesDir,X&&Y.root!=="."){let J=`${Z}::${Y.root}`;if(!G6.has(J))G6.add(J),console.warn(`[stx] No "root" in config \u2014 inferred "${Y.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if($.root&&$.root!=="."){let J=$.root;for(let Q of["partialsDir","componentsDir","layoutsDir"]){let G=$[Q];if(typeof G!=="string"||!G)continue;if(S0.isAbsolute(G)||IX(G,J))continue;$[Q]=S0.join(J,G)}}return $}function EX($,Z){let X=["componentsDir","layoutsDir","partialsDir"];for(let Y of X){let J=$[Y];if(typeof J!=="string"||!J)continue;let Q=S0.isAbsolute(J)?J:S0.join(Z,J);if(a5.existsSync(Q))continue;let G=$.root,q=!!G&&G!==".";console.warn(`[stx] ${String(Y)} resolves to "${Q}", which does not exist. Configured as "${J}"`+(q?`, resolved under root "${G}".`:"."))}}function bX($){if(z6($.stateDir),$.stateDir=H6(),$.cachePath=j5($.cachePath),$.build)$.build.cacheDir=j5($.build.cacheDir);if($.media?.cache)$.media.cache.directory=j5($.media.cache.directory);if($.story)$.story.outDir=j5($.story.outDir)}var d1=null,q6=new Map,t5=null;async function U3($){if(!$){if(d1)return d1;if(t5)return t5}let Z=$?S0.resolve($):process.cwd(),X=q6.get(Z);if(X)return X;let Y=(async()=>{let Q=(await MX({name:"stx",alias:"ui",cwd:Z,defaultConfig:j6,verbose:!1})).config;if(bX(Q),kX(Q,Z),EX(Q,Z),Q.plugins&&Q.plugins.length>0){let{pluginManager:G}=await import("./chunk-xfp10a23.js"),q=[],U=[];for(let W of Q.plugins){let K=typeof W==="string"?W:W[0],z=typeof W==="string"?{}:W[1]||{};try{let H,B;try{H=await import(K),B=S0.dirname(h.resolve(K))}catch{let _=S0.resolve(process.cwd(),K);H=await import(_),B=S0.dirname(_)}let j=H.default||H;if(G.register(j,Q),j.components){let _=Array.isArray(j.components)?j.components:[j.components];for(let V of _)q.push(S0.resolve(B,V))}if(j.pages){let _=S0.resolve(B,j.pages),V=z.path||"/";U.push({dir:_,prefix:V})}if(j.setup){let _={addDirective:(V)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(V)},addRoute:(V,O)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[V]=O},addMiddleware:(V)=>{Q.middleware=Q.middleware||[],Q.middleware.push(V)},pluginDir:B,config:Q};await j.setup(z,_)}console.log(`[stx] Plugin loaded: ${j.name||K}`)}catch(H){console.warn(`[stx] Failed to load plugin ${K}:`,H.message)}}Q._pluginComponentDirs=q,Q._pluginPageDirs=U}return Q})();if(q6.set(Z,Y),!$)t5=Y,Y.then((J)=>{d1=J}).catch(()=>{});return Y}var _6=new Proxy(j6,{get($,Z){if(d1&&Z in d1)return d1[Z];if(!t5)U3().catch((X)=>{console.warn("[stx] Failed to load config file:",X?.message||X)});return $[Z]}});function lW($){return $}function cW($){let Z=[],X=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let Y=["auto","manual","sections"];if(!Y.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${Y.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let Y=["json","yaml","yml","js"];if(!Y.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${Y.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let Y=["AA","AAA"];if(!Y.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${Y.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let Y=["progressive","islands"];if(!Y.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${Y.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let Y=["none","eager","lazy"];if(!Y.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${Y.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((Y,J)=>{if(!Y.name||typeof Y.name!=="string")Z.push({path:`customDirectives[${J}].name`,message:"Custom directive must have a name string",severity:"error"});if(!Y.handler||typeof Y.handler!=="function")Z.push({path:`customDirectives[${J}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((Y,J)=>{if(!Y.name||typeof Y.name!=="string")Z.push({path:`middleware[${J}].name`,message:"Middleware must have a name string",severity:"error"});if(!Y.handler||typeof Y.handler!=="function")Z.push({path:`middleware[${J}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!Y.timing||!["before","after"].includes(Y.timing))Z.push({path:`middleware[${J}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)X.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)X.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let Y=["fullscreen","standalone","minimal-ui","browser"];if(!Y.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${Y.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let Y=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!Y.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${Y.join(", ")}`,severity:"error"})}if($.pwa.routes){let Y=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((J,Q)=>{if(!J.pattern||typeof J.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!Y.includes(J.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${Y.join(", ")}`,severity:"error"});if(J.maxAgeSeconds!==void 0&&(typeof J.maxAgeSeconds!=="number"||J.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(J.maxEntries!==void 0&&(typeof J.maxEntries!=="number"||J.maxEntries<1))Z.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((J)=>typeof J!=="number"||J<16||J>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let Y=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!Y.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${Y.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)X.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)X.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:X}}var K3=new Map;async function CX($,Z={}){try{if(!await r($))throw Error(`Markdown file not found: ${$}`);let Y=(await yX.promises.stat($)).mtime.getTime();if(Z.cache&&K3.has($)){let z=K3.get($);if(z.updatedAt>=Y)return{content:z.content,data:z.data}}let J=await Bun.file($).text(),{data:Q,content:G}=D7(J),q=Z.markdown||_6.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},W=W5(G,{gfm:!0});if(q.syntaxHighlighting?.enabled&&q.syntaxHighlighting?.serverSide)W=await PX(W,q.syntaxHighlighting?.defaultTheme||"github-dark",q.syntaxHighlighting?.highlightUnknownLanguages||!1);let K={content:W,data:Q||{}};if(Z.cache)K3.set($,{...K,updatedAt:Y});return K}catch(X){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,X);let Y=X instanceof Error?X.message:String(X);return{content:W0("Markdown File",`Error reading/parsing markdown file: ${Y}`,$,"",0,""),data:{}}}}var e5=null;async function PX($,Z,X){let Y=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!e5)try{e5=await SX({theme:Z||"github-dark",cache:!0})}catch(q){return console.error("Failed to initialize ts-syntax-highlighter:",q),$}let J=async(q,U,W,K)=>{let z=K.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),H=W||(X?"text":"");if(!H)return q;try{if(!e5.getSupportedLanguages().includes(H))return q;return(await e5.highlight(z,H,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${W}:`,B)}return q},Q=$,G=$.matchAll(Y);for(let q of G){let[U,W,K,z]=q,H=await J(U,W,K,z);Q=Q.replace(U,H)}return Q}async function O6($,Z,X="",Y={}){return await vX($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,q,U,W)=>{try{let K=q;if(!W3.isAbsolute(q))K=W3.resolve(W3.dirname(X),q);let z={};if(U)try{try{z=JSON.parse(U)}catch{if(Y.debug)console.warn("Using safer alternative for parsing JS object literal");let F=U.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let L of F){let w=L.indexOf(":");if(w>0){let R=L.substring(0,w).trim(),D=L.substring(w+1).trim(),N=D.startsWith('"')&&D.endsWith('"'),T=D.startsWith("'")&&D.endsWith("'");if(N||T)D=D.substring(1,D.length-1);z[R]=D}}}}catch(O){if(Y.debug)console.error("Error parsing context in @markdown-file directive:",O)}let{content:H,data:B}=await CX(K,Y),j={...Z,...B,...z},_=H,V=/\{\{([^}]+)\}\}/g;return _=_.replace(V,(O,F)=>{let L=F.trim();return j[L]!==void 0?String(j[L]):O}),_}catch(K){let z=K instanceof Error?K.message:String(K);return W0("Markdown File",`Error including markdown file: ${z}`,X,$,W,G)}})}async function vX($,Z,X){let Y=[],J;while((J=Z.exec($))!==null){let q=J[0],U=J.index,W=J;Y.push(X(...W).then((K)=>({match:q,replacement:K,index:U})))}let Q=await Promise.all(Y);Q.sort((q,U)=>U.index-q.index);let G=$;for(let{match:q,replacement:U}of Q)G=G.replace(q,()=>U);return G}function U1($,Z){try{let X=$.trim();if(Q0(X))return G0(X,Object.keys(Z))(...Object.values(Z));else return X0(X,Z)}catch{return!1}}class $${source;pos=0;line=1;column=0;tokens=[];constructor($){this.source=$}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let $=this.nextToken();if($)this.tokens.push($)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let $=this.pos,Z=this.line,X=this.column,Y=this.source[this.pos];if(/\s/.test(Y))return this.readWhitespace($,Z,X);if(Y==="/"&&this.peek(1)==="/")return this.readLineComment($,Z,X);if(Y==="/"&&this.peek(1)==="*")return this.readBlockComment($,Z,X);if(Y==='"'||Y==="'")return this.readString(Y,$,Z,X);if(Y==="`")return this.readTemplateString($,Z,X);if(/\d/.test(Y)||Y==="."&&/\d/.test(this.peek(1)||""))return this.readNumber($,Z,X);if(/[a-z_$]/i.test(Y))return this.readIdentifier($,Z,X);if(Y==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:$,end:this.pos,line:Z,column:X};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:$,end:this.pos,line:Z,column:X};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:$,end:this.pos,line:Z,column:X}}if(Y==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:$,end:this.pos,line:Z,column:X};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:$,end:this.pos,line:Z,column:X}}if(Y==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:$,end:this.pos,line:Z,column:X};if(Y==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective($,Z,X);let J=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let Q of J)if(this.source.slice(this.pos,this.pos+Q.length)===Q)return this.advance(Q.length),{type:"OPERATOR",value:Q,start:$,end:this.pos,line:Z,column:X};if(/[+\-*/%<>=!&|^~?:]/.test(Y))return this.advance(),{type:"OPERATOR",value:Y,start:$,end:this.pos,line:Z,column:X};if(/[()[\]{},;.]/.test(Y))return this.advance(),{type:"PUNCTUATION",value:Y,start:$,end:this.pos,line:Z,column:X};return this.advance(),{type:"PUNCTUATION",value:Y,start:$,end:this.pos,line:Z,column:X}}readWhitespace($,Z,X){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:X}}readLineComment($,Z,X){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
|
|
3271
|
+
`)this.advance();return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:X}}readBlockComment($,Z,X){this.advance(2);while(this.pos<this.source.length-1){if(this.source[this.pos]==="*"&&this.source[this.pos+1]==="/"){this.advance(2);break}this.advance()}return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:X}}readString($,Z,X,Y){this.advance();while(this.pos<this.source.length){let J=this.source[this.pos];if(J==="\\"){this.advance(2);continue}if(J===$){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(Z,this.pos),start:Z,end:this.pos,line:X,column:Y}}readTemplateString($,Z,X){this.advance();let Y=0,J=256;while(this.pos<this.source.length){let Q=this.source[this.pos];if(Q==="\\"){this.advance(2);continue}if(Q==="$"&&this.peek(1)==="{"){if(Y>=J){this.pos=this.source.length;break}this.advance(2),Y++;continue}if(Q==="{"&&Y>0){Y++,this.advance();continue}if(Q==="}"&&Y>0){Y--,this.advance();continue}if(Q==="`"&&Y===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:X}}readNumber($,Z,X){if(this.source[this.pos]==="0"){let Y=this.peek(1)?.toLowerCase();if(Y==="x"||Y==="o"||Y==="b"){this.advance(2);while(this.pos<this.source.length&&/[\da-f_]/i.test(this.source[this.pos]))this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:X}}}while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance();if(this.source[this.pos]==="."&&/\d/.test(this.peek(1)||"")){this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(/e/i.test(this.source[this.pos]||"")){if(this.advance(),/[+-]/.test(this.source[this.pos]||""))this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(this.source[this.pos]==="n")this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:X}}readIdentifier($,Z,X){while(this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]))this.advance();return{type:"IDENTIFIER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:X}}readDirective($,Z,X){this.advance();while(this.pos<this.source.length&&/[a-z]/i.test(this.source[this.pos]))this.advance();return{type:"DIRECTIVE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:X}}advance($=1){for(let Z=0;Z<$&&this.pos<this.source.length;Z++){if(this.source[this.pos]===`
|
|
3272
|
+
`)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function H0($,Z,X,Y=0){let J=0,Q=Y,G=null,q=0,U=!1;while(Q<$.length){let W=$[Q];if(G&&U){U=!1,Q++;continue}if(G&&W==="\\"){U=!0,Q++;continue}if(U=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,Q++;continue}if(W===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&W==="$"&&$[Q+1]==="{"){q++,Q+=2;continue}if(q>0&&W==="}"){q--,Q++;continue}if(W==="`"&&G==="`"&&q===0){G=null,Q++;continue}if(G){Q++;continue}if(W===Z)J++;else if(W===X){if(J--,J===0)return Q}Q++}return-1}function V6($,Z){let X=Z,Y={paren:0,bracket:0,brace:0},J=null,Q=0;while(X<$.length){let G=$[X];if((X>0?$[X-1]:"")==="\\"&&J){X++;continue}if((G==='"'||G==="'")&&!J){J=G,X++;continue}if(G===J&&J!=="`"){J=null,X++;continue}if(G==="`"&&!J){J="`",X++;continue}if(G==="`"&&J==="`"&&Q===0){J=null,X++;continue}if(J==="`"&&G==="$"&&$[X+1]==="{"){Q++,X+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;X++;continue}if(J){X++;continue}if(Y.paren===0&&Y.bracket===0&&Y.brace===0){if($.slice(X,X+2)==="}}"||$.slice(X,X+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")Y.paren++;else if(G===")"){if(Y.paren--,Y.paren<0)break}else if(G==="[")Y.bracket++;else if(G==="]"){if(Y.bracket--,Y.bracket<0)break}else if(G==="{")Y.brace++;else if(G==="}"){if(Y.brace--,Y.brace<0)break}X++}return{expression:$.slice(Z,X),endPos:X}}function z3($){let Z=[],X="",Y={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let q=$[G];if((G>0?$[G-1]:"")==="\\"&&J){X+=q;continue}if((q==='"'||q==="'")&&!J){J=q,X+=q;continue}if(q===J&&J!=="`"){J=null,X+=q;continue}if(q==="`"&&!J){J="`",X+=q;continue}if(q==="`"&&J==="`"&&Q===0){J=null,X+=q;continue}if(J==="`"&&q==="$"&&$[G+1]==="{"){Q++,X+=q+$[G+1],G++;continue}if(Q>0&&q==="{"){Q++,X+=q;continue}if(Q>0&&q==="}"){Q--,X+=q;continue}if(J){X+=q;continue}if(q==="(")Y.paren++;else if(q===")")Y.paren--;else if(q==="[")Y.bracket++;else if(q==="]")Y.bracket--;else if(q==="{")Y.brace++;else if(q==="}")Y.brace--;if(q==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&Y.paren===0&&Y.bracket===0&&Y.brace===0){Z.push(X.trim()),X="";continue}if(q==="|"&&$[G-1]==="\\"&&!J){X=X.slice(0,-1)+q;continue}X+=q}if(X.trim())Z.push(X.trim());return Z}function W1($,Z){let X=fX($,Z);return X.ok?{expression:X.expression,endPos:X.endPos}:null}function fX($,Z){let X=Z;while(X<$.length&&/\s/.test($[X]))X++;if($[X]!=="(")return{ok:!1,reason:"missing-open-paren",pos:X};let Y=H0($,"(",")",X);if(Y===-1)return{ok:!1,reason:"unclosed-paren",pos:X};return{ok:!0,expression:$.slice(X+1,Y),endPos:Y+1}}function xX($,Z){let X=$.lastIndexOf("<",Z);if(X===-1)return!1;return X>$.lastIndexOf(">",Z)}function w1($,Z,X,Y){let J=1,Q=Y,G=new RegExp(`@${Z}\\s*\\(`,"g"),q=new RegExp(`@${X}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,q.lastIndex=Q;let U=G.exec($),W=q.exec($),K=U?U.index:1/0,z=W?W.index:1/0;if(K<z)J++,Q=K+U[0].length;else if(z<1/0){if(J--,J===0)return z;Q=z+W[0].length}else break}return-1}function F6($,Z){let X=$.slice(Z).match(/^@if\s*/);if(!X)return null;let Y=Z+X[0].length,J=W1($,Y);if(!J)return null;let Q=J.endPos,G=w1($,"if","endif",Q);if(G===-1)return null;let q=$.slice(Q,G),U=[],W=0,K="if",z=J.expression,H=0,B=0;while(W<q.length){let j=q.indexOf("@",W);if(j===-1)break;W=j;let _=q.substring(j);if(xX(q,j)){W++;continue}if(/^@if\s*\(/.test(_)){B++,W++;continue}if(/^@endif(?![a-z])/.test(_)){B--,W+=6;continue}if(B===0){let V=_.match(/^@elseif\s*/);if(V){U.push({type:K,condition:z,content:q.substring(H,W),start:Q+H,end:Q+W});let O=W+V[0].length,F=W1(q,O);if(!F){W++;continue}K="elseif",z=F.expression,W=F.endPos,H=W;continue}else if(/^@else(?![a-z])/.test(_)){U.push({type:K,condition:z,content:q.substring(H,W),start:Q+H,end:Q+W}),K="else",z=void 0,W+=5,H=W;continue}}W++}return U.push({type:K,condition:z,content:q.slice(H),start:Q+H,end:Q+q.length}),{fullMatch:$.slice(Z,G+6),branches:U,start:Z,end:G+6}}function _5($){let Z=[],X=/@if\s*\(/g,Y=X.exec($);while(Y!==null){if(Z.some((G)=>Y.index>G.start&&Y.index<G.end)){Y=X.exec($);continue}let Q=F6($,Y.index);if(Q)Z.push(Q),X.lastIndex=Q.end;Y=X.exec($)}return Z}function Z$($,Z,X){let Y=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(Y.some((_)=>Q.index>_.start&&Q.index<_.end)){Q=J.exec($);continue}let q=Q.index,U=q+Q[0].length-1,W=H0($,"(",")",U);if(W===-1){Q=J.exec($);continue}let K=$.slice(U+1,W),z=W+1,H=w1($,Z,X,z);if(H===-1){Q=J.exec($);continue}let B=$.slice(z,H),j=H+`@${X}`.length;Y.push({fullMatch:$.slice(q,j),name:Z,params:K,content:B,start:q,end:j}),J.lastIndex=j,Q=J.exec($)}return Y}function H3($,Z){let X=$.slice(Z).match(/^@switch\s*/);if(!X)return null;let Y=Z+X[0].length,J=W1($,Y);if(!J)return null;let Q=J.endPos,G=w1($,"switch","endswitch",Q);if(G===-1)return null;let q=$.slice(Q,G),U=[],W=0,K=null,z=0;while(W<q.length){let H=q.slice(W),B=H.match(/^@switch\s*\(/),j=H.match(/^@endswitch(?![a-z])/);if(B){if(z++,K)K.content+=B[0];W+=B[0].length;continue}if(j){if(z--,K)K.content+=j[0];W+=j[0].length;continue}if(z>0){if(K)K.content+=q[W];W++;continue}let _=H.match(/^@case\s*/),V=H.match(/^@default(?![a-z])/),O=H.match(/^@break(?![a-z])/);if(_&&H.startsWith("@case")){if(K)U.push(K);let F=W+_[0].length,L=W1(q,F);if(!L){W++;continue}K={type:"case",value:L.expression,content:""},W=L.endPos}else if(V&&H.startsWith("@default")){if(K)U.push(K);K={type:"default",content:""},W+=V[0].length}else if(O&&H.startsWith("@break"))W+=O[0].length;else{if(K)K.content+=q[W];W++}}if(K)U.push(K);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:U,start:Z,end:G+10}}function gX($){let Z=[],X=0;while(X<$.length){let Y=$.indexOf("{{",X),J=$.indexOf("{!!",X),Q=!1,G;if(Y===-1&&J===-1)break;else if(Y===-1)G=J,Q=!0;else if(J===-1)G=Y,Q=!1;else if(J<Y)G=J,Q=!0;else G=Y,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let q=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",U=Q?q==="{{{"?"}}}":"!!}":"}}",W=G+q.length,K=hX($,W,U);if(K===-1){X=G+1;continue}let z=$.slice(W,K).trim(),H=K+U.length;Z.push({fullMatch:$.slice(G,H),expression:z,start:G,end:H,isRaw:Q}),X=H}return Z}function hX($,Z,X){let Y=Z,J=null,Q={paren:0,bracket:0,brace:0},G=0;while(Y<$.length){let q=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&J){Y++;continue}if((q==='"'||q==="'")&&!J){J=q,Y++;continue}if(q===J&&J!=="`"){J=null,Y++;continue}if(q==="`"&&!J){J="`",Y++;continue}if(q==="`"&&J==="`"&&G===0){J=null,Y++;continue}if(J==="`"&&q==="$"&&$[Y+1]==="{"){G++,Y+=2;continue}if(G>0){if(q==="{")G++;else if(q==="}")G--;Y++;continue}if(J){Y++;continue}if(q==="(")Q.paren++;else if(q===")")Q.paren--;else if(q==="[")Q.bracket++;else if(q==="]")Q.bracket--;else if(q==="{")Q.brace++;else if(q==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(Y,Y+X.length)===X)return Y}Y++}return-1}function uX($){let Z=z3($);if(Z.length===0)return{baseExpression:"",filters:[]};let X=Z[0],Y=[];for(let J=1;J<Z.length;J++){let Q=dX(Z[J]);if(Q)Y.push(Q)}return{baseExpression:X,filters:Y}}function dX($){let Z=$.trim();if(!Z)return null;let X=Z.indexOf("(");if(X===-1)return{name:Z,args:[]};let Y=Z.slice(0,X).trim(),J=X+1,Q=H0(Z,"(",")",X);if(Q===-1)return{name:Y,args:[]};let G=Z.slice(J,Q),q=R6(G);return{name:Y,args:q}}function R6($){let Z=[],X="",Y={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let q=$[G];if((G>0?$[G-1]:"")==="\\"&&J){X+=q;continue}if((q==='"'||q==="'")&&!J){J=q,X+=q;continue}if(q===J&&J!=="`"){J=null,X+=q;continue}if(q==="`"&&!J){J="`",X+=q;continue}if(q==="`"&&J==="`"&&Q===0){J=null,X+=q;continue}if(J==="`"&&q==="$"&&$[G+1]==="{"){Q++,X+="${",G++;continue}if(Q>0&&q==="{"){Q++,X+=q;continue}if(Q>0&&q==="}"){Q--,X+=q;continue}if(J){X+=q;continue}if(q==="(")Y.paren++;else if(q===")")Y.paren--;else if(q==="[")Y.bracket++;else if(q==="]")Y.bracket--;else if(q==="{")Y.brace++;else if(q==="}")Y.brace--;if(q===","&&Y.paren===0&&Y.bracket===0&&Y.brace===0){Z.push(X.trim()),X="";continue}X+=q}if(X.trim())Z.push(X.trim());return Z}function mX($,Z){let X=Z;while(X<$.length&&/\s/.test($[X]))X++;if($[X]!=="(")return null;let Y=H0($,"(",")",X);if(Y===-1)return null;return{params:$.slice(X+1,Y),endPos:Y+1}}function lX($){let Z=[],Y=new $$($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<Y.length){let Q=Y[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=Y.length)break}let q=Y[J];if(q.type==="IDENTIFIER"&&(q.value==="const"||q.value==="let"||q.value==="var")){let U=q.value;if(J++,J>=Y.length)break;let W=Y[J];if(W.type==="IDENTIFIER"){let K=W.value;if(J++,J<Y.length&&Y[J].type==="OPERATOR"&&Y[J].value==="="){J++;let z=J<Y.length?Y[J].start:$.length,H=L6(Y,J,$);J=H.nextIndex,Z.push({type:"variable",name:K,value:$.slice(z,H.endPos),exported:G,start:q.start,end:H.endPos})}}else if(W.type==="PUNCTUATION"&&(W.value==="{"||W.value==="[")){let K=W.start,z=W.value==="{"?"}":"]",H=H0($,W.value,z,K);if(H!==-1){let B=$.slice(K,H+1);if(J=w6(Y,H+1),J<Y.length&&Y[J].type==="OPERATOR"&&Y[J].value==="="){J++;let j=J<Y.length?Y[J].start:$.length,_=L6(Y,J,$);J=_.nextIndex;let V=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:V,value:`${$.slice(j,_.endPos)}; ${U} ${B} = ${V}`,exported:G,start:q.start,end:_.endPos})}}}}else if(q.type==="IDENTIFIER"&&q.value==="function"){let U=G?Y[J-1].start:q.start;if(J++,J>=Y.length)break;let W=Y[J];if(W.type==="IDENTIFIER"){let K=W.value;J++;let z=-1;while(J<Y.length){if(Y[J].type==="PUNCTUATION"&&Y[J].value==="{"){z=Y[J].start;break}J++}if(z!==-1){let H=H0($,"{","}",z);if(H!==-1)Z.push({type:"function",name:K,value:$.slice(U,H+1).replace(/^export\s+/,""),exported:G,start:U,end:H+1}),J=w6(Y,H+1)}}}else J++}return Z}function L6($,Z,X){let Y=Z,J={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:X.length;while(Y<$.length){let G=$[Y];if(G.type==="PUNCTUATION"){if(G.value==="(")J.paren++;else if(G.value===")")J.paren--;else if(G.value==="[")J.bracket++;else if(G.value==="]")J.bracket--;else if(G.value==="{")J.brace++;else if(G.value==="}")J.brace--;if(G.value===";"&&J.paren===0&&J.bracket===0&&J.brace===0){Q=G.start,Y++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(J.paren===0&&J.bracket===0&&J.brace===0){Q=$[Y-1]?.end??G.start;break}}Q=G.end,Y++}return{nextIndex:Y,endPos:Q}}function w6($,Z){for(let X=0;X<$.length;X++)if($[X].start>=Z)return X;return $.length}function cX($,Z,X){let Y=$,J=!0;while(J){J=!1;let Q=Y.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,q=H3(Y,G);if(!q)break;try{let U;if(Q0(q.expression))U=G0(q.expression,Object.keys(Z))(...Object.values(Z));else U=X0(q.expression,Z);let W="",K=!1;for(let z of q.cases)if(z.type==="default"){if(!K)W=z.content.trim()}else try{let H;if(z.value&&Q0(z.value))H=G0(z.value,Object.keys(Z))(...Object.values(Z));else if(z.value)H=X0(z.value,Z);if(U===H){W=z.content.trim(),K=!0;break}}catch{continue}Y=Y.substring(0,G)+W+Y.substring(q.end),J=!0}catch(U){let W=U instanceof Error?U.message:String(U),K=$0("Switch",`Error evaluating @switch expression: ${W}`,l.EVALUATION_ERROR);Y=Y.substring(0,G)+K+Y.substring(q.end);break}}return Y}function pX($){let Z=[];return{masked:$.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(Y)=>{return Z.push(Y),`\x00stx-script-${Z.length-1}\x00`}),scripts:Z}}function iX($,Z){if(Z.length===0)return $;return $.replace(/\u0000stx-script-(\d+)\u0000/g,(X,Y)=>Z[Number(Y)]??X)}function a0($,Z,X){let{masked:Y,scripts:J}=pX($);return iX(nX(Y,Z,X),J)}function nX($,Z,X){let Y=$;Y=cX(Y,Z,X);{let Q=!0;while(Q){Q=!1;let G=Y.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let q=G.index,U=W1(Y,q+7);if(!U)break;let W=U.endPos,K=w1(Y,"unless","endunless",W);if(K===-1){console.warn(`[stx] @unless directive at position ${q} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let z=Y.slice(W,K),H=U.expression,B=-1;{let _=0,V=/@(?:if|unless)\s*\(/g,O=/@(?:endif|endunless)(?![a-z])/g,F=/@else(?![a-z])/g,L=[],w;while((w=V.exec(z))!==null)L.push({pos:w.index,type:"open"});while((w=O.exec(z))!==null)L.push({pos:w.index,type:"close"});while((w=F.exec(z))!==null)L.push({pos:w.index,type:"else"});L.sort((R,D)=>R.pos-D.pos);for(let R of L)if(R.type==="open")_++;else if(R.type==="close")_--;else if(R.type==="else"&&_===0){B=R.pos;break}}let j;if(B!==-1){let _=z.slice(0,B),V=z.slice(B+5);j=`@if (${H})${V}@else ${_}@endif`}else j=`@if (!(${H}))${z}@endif`;Y=Y.substring(0,q)+j+Y.substring(K+10),Q=!0}}Y=j3(Y,Z,X),Y=_3(Y,Z,X),Y=B3(Y,Z);let J=()=>{let Q=_5(Y);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let q=Q[G];try{let U="",W=!1;for(let K of q.branches){if(W)break;if(K.type==="else")U=K.content,W=!0;else try{let z;if(K.condition&&Q0(K.condition))z=G0(K.condition,Object.keys(Z))(...Object.values(Z));else if(K.condition)z=X0(K.condition,Z);if(z)U=K.content,W=!0}catch(z){U=$0(K.type==="if"?"If":"Elseif",`Error in @${K.type}(${K.condition}): ${z instanceof Error?z.message:String(z)}`,l.EVALUATION_ERROR),W=!0}}Y=Y.substring(0,q.start)+U+Y.substring(q.end)}catch(U){let W=U instanceof Error?U.message:String(U),K=$0("If",`Error processing @if block: ${W}`,l.EVALUATION_ERROR);Y=Y.substring(0,q.start)+K+Y.substring(q.end)}}return!0};while(!0){let Q=Y;if(!J())break;if(Y===Q)break}return Y}function D6($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let X=$[Z];if(X!=="'"&&X!=='"')return null;Z++;let Y=[];while(Z<$.length){let J=$[Z];if(J==="\\"&&Z+1<$.length){Y.push($[Z+1]),Z+=2;continue}if(J===X){Z++;break}Y.push(J),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:Y.join(""),consumed:Z}}function B3($,Z){let X=$;function Y(q,U,W,K){let z=1,H=K,B=new RegExp(`@${U}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(H<q.length&&z>0){B.lastIndex=H,j.lastIndex=H;let _=B.exec(q),V=j.exec(q),O=_?_.index:1/0,F=V?V.index:1/0;if(O<F)z++,H=O+_[0].length;else if(F<1/0){if(z--,z===0)return F;H=F+V[0].length}else break}return-1}function J(q,U,W){let K=0,z=new RegExp(`@${U}(?:\\s*\\(|\\s|$)`,"g"),H=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],_;while((_=z.exec(q))!==null)j.push({pos:_.index,type:"open"});while((_=H.exec(q))!==null)j.push({pos:_.index,type:"close"});while((_=B.exec(q))!==null)j.push({pos:_.index,type:"else"});j.sort((V,O)=>V.pos-O.pos);for(let V of j)if(V.type==="open")K++;else if(V.type==="close")K--;else if(V.type==="else"&&K===0)return V.pos;return-1}{let q=!0;while(q){q=!1;let U=X.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!U||U.index===void 0)break;let W=U.index,K,z,H=X.slice(W+5),B=D6(H);if(B)K=B.value,z=W+5+B.consumed;else z=W+5;let j=Y(X,"auth","endauth",z);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let _=X.slice(z,j),V=J(_,"auth","endauth"),O;if(!Z.auth)O=!1;else O=K?U1(`auth?.check && auth?.user?.[${K}]`,Z):U1("auth?.check",Z);let F;if(V!==-1){let L=_.slice(0,V),w=_.slice(V+5);F=O?L:w}else F=O?_:"";X=X.substring(0,W)+F+X.substring(j+8),q=!0}}{let q=!0;while(q){q=!1;let U=X.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!U||U.index===void 0)break;let W=U.index,K,z,H=X.slice(W+6),B=D6(H);if(B)K=B.value,z=W+6+B.consumed;else z=W+6;let j=Y(X,"guest","endguest",z);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let _=X.slice(z,j),V=J(_,"guest","endguest"),O;if(!Z.auth)O=!0;else O=K?U1(`!auth?.check || !auth?.user?.[${K}]`,Z):U1("!auth?.check",Z);let F;if(V!==-1){let L=_.slice(0,V),w=_.slice(V+5);F=O?L:w}else F=O?_:"";X=X.substring(0,W)+F+X.substring(j+9),q=!0}}function Q(q,U,W){if(Z.userCan&&typeof Z.userCan[q]==="boolean")return Z.userCan[q];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let K=[q];if(U)K.push(U);if(W){let z=U1(W,Z);K.push(z)}return Z.permissions.check(...K)}catch{return!1}return!1}function G(q){let U=q.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!U)return null;return{ability:U[1],type:U[2],id:U[3]?.trim(),paramsEnd:U[0].length}}for(let q of["can","cannot"]){let U=`end${q}`,W=q==="can"?"elsecan":"elsecannot",K=!0;while(K){K=!1;let z=X.match(new RegExp(`@${q}\\s*\\(`));if(!z||z.index===void 0)break;let H=z.index,B=X.slice(H+`@${q}`.length),j=G(B);if(!j)break;let _=H+`@${q}`.length+j.paramsEnd,V=Y(X,q,U,_);if(V===-1){console.warn(`[stx] @${q} directive at position ${H} has no matching @${U} \u2014 the block was skipped.`);break}let O=X.slice(_,V),F=[],L=0,w=new RegExp(`@${q}\\s*\\(`,"g"),R=new RegExp(`@${U}(?![a-z])`,"g"),D=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],A;while((A=w.exec(O))!==null)T.push({pos:A.index,type:"open"});while((A=R.exec(O))!==null)T.push({pos:A.index,type:"close"});while((A=D.exec(O))!==null)T.push({pos:A.index,type:"elseDirective"});while((A=N.exec(O))!==null)T.push({pos:A.index,type:"else"});T.sort((b,C)=>b.pos-C.pos);for(let b of T){if(b.type==="open"){L++;continue}if(b.type==="close"){L--;continue}if(L===0)F.push(b)}let M=[],k=0;for(let b=0;b<F.length;b++){let C=F[b];if(M.push({content:O.slice(k,C.pos),ability:void 0}),C.type==="elseDirective"){let x=O.slice(C.pos+`@${W}`.length),f=G(x);if(f){M[M.length-1]={content:O.slice(k,C.pos)},k=C.pos+`@${W}`.length+f.paramsEnd,M.push({content:"",ability:f.ability,type:f.type,id:f.id}),M.pop();let n=F[b+1],m=n?n.pos:O.length;M.push({content:O.slice(k,m),ability:f.ability,type:f.type,id:f.id}),k=m}}else k=C.pos+5}if(k<O.length){let b=M[M.length-1];if(F.length>0&&F[F.length-1].type==="else")M.push({content:O.slice(k),isFinalElse:!0});else if(M.length===0)M.push({content:O.slice(k)})}let I=Q(j.ability,j.type,j.id),y=q==="can"?I:!I,E="";if(y)E=M[0]?.content||"";else{let b=!1;for(let C=1;C<M.length;C++){let x=M[C];if(x.isFinalElse){E=x.content,b=!0;break}if(x.ability){let f=Q(x.ability,x.type,x.id);if(q==="can"?f:!f){E=x.content,b=!0;break}}}if(!b&&M.length>0){let C=M[M.length-1];if(C.isFinalElse)E=C.content}}X=X.substring(0,H)+E+X.substring(V+`@${U}`.length),K=!0}}return X}function j3($,Z,X){let Y=$;function J(Q,G,q,U,W){let K=!0;while(K){K=!1;let z=new RegExp(`@${G}\\s*\\(`),H=Q.match(z);if(!H||H.index===void 0)break;let B=H.index,j=W1(Q,B+`@${G}`.length);if(!j)break;let _=j.endPos,V=w1(Q,G,q,_);if(V===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${q} \u2014 the block was skipped.`);break}let O=Q.slice(_,V),F=j.expression,L=-1,w=0,R=0;while(R<O.length){let D=O.indexOf("@",R);if(D===-1)break;let N=O.substring(D);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){w++,R=D+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){w--,R=D+1;continue}if(w===0&&/^@else(?![a-z])/.test(N)){L=D;break}R=D+1}try{let D=U(F.trim()),N;if(L!==-1){let T=O.slice(0,L),A=O.slice(L+5);N=D?T:A}else N=D?O:"";Q=Q.substring(0,B)+N+Q.substring(V+`@${q}`.length),K=!0}catch(D){let N=D instanceof Error?D.message:String(D),T=$0(W,`Error processing @${G} directive: ${N}`,l.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(V+`@${q}`.length);break}}return Q}return Y=J(Y,"isset","endisset",(Q)=>{let G=U1(Q,Z);return G!==void 0&&G!==null},"Isset"),Y=J(Y,"empty","endempty",(Q)=>{let G=U1(Q,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),Y}function _3($,Z,X){let Y=$,J="development";function Q(G,q,U,W){let K=new RegExp(`@${q}(?![a-z])`,"g"),z=new RegExp(`@${U}(?![a-z])`,"g"),H=new RegExp(`^@${q}(?![a-z])`),B=new RegExp(`^@${U}(?![a-z])`),j=G,_=!0;while(_){_=!1,K.lastIndex=0;let V=K.exec(j);if(!V)break;let O=V.index,F=O+V[0].length;if(q==="env"){let I=j.substring(F).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!I)break;F+=I[0].length,W=J===I[2]}let L=1,w=F,R=-1;while(L>0&&w<j.length){K.lastIndex=w,z.lastIndex=w;let I=K.exec(j),y=z.exec(j),E=I?I.index:1/0,b=y?y.index:1/0;if(E<b)L++,w=E+I[0].length;else if(b<1/0){if(L--,L===0){R=b;break}w=b+y[0].length}else break}if(R===-1){console.warn(`[stx] @${q} directive at position ${O} has no matching @${U} \u2014 the block was skipped.`);break}let D=j.substring(F,R),N=-1,T=0,A=0;while(A<D.length){let I=D.indexOf("@",A);if(I===-1)break;let y=D.substring(I);if(H.test(y)){T++,A=I+1;continue}if(B.test(y)){T--,A=I+1;continue}if(T===0&&/^@else(?![a-z])/.test(y)){N=I;break}A=I+1}let M;if(N!==-1){let I=D.slice(0,N),y=D.slice(N+5);M=W?I:y}else M=W?D:"";let k=`@${U}`.length;j=j.substring(0,O)+M+j.substring(R+k),_=!0}return j}return Y=Q(Y,"env","endenv",!1),Y=Q(Y,"production","endproduction",J==="production"),Y=Q(Y,"development","enddevelopment",J==="development"),Y=Q(Y,"staging","endstaging",J==="staging"),Y=Q(Y,"testing","endtesting",J==="testing"),Y}var O3=new WeakMap;function N6($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function R1($,Z){if(!$)return Z?.nonceGenerator?.()??N6();let X=O3.get($);if(!X)X=Z?.nonceGenerator?.()??N6(),O3.set($,X);return X}function VK($){O3.delete($)}function A6($,Z){let X=[];for(let[Y,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)X.push(Y);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(Y==="script-src"||Y==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)X.push(`${Y} ${Q.join(" ")}`)}}return X.join("; ")}function F3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${A6($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}var sX={"default-src":["'self'"],"script-src":["'self'","'strict-dynamic'"],"style-src":["'self'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'none'"],"base-uri":["'self'"],"form-action":["'self'"],"frame-ancestors":["'self'"],"upgrade-insecure-requests":!0},V3={"default-src":["'self'"],"script-src":["'self'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'","https:"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"upgrade-insecure-requests":!0},oX={"default-src":["'self'"],"script-src":["'self'","'unsafe-inline'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:","http:"],"font-src":["'self'","https:","http:","data:"],"connect-src":["'self'","https:","http:","ws:","wss:"],"media-src":["'self'","https:","http:"],"object-src":["'none'"],"frame-src":["'self'","https:"],"base-uri":["'self'"]},rX={"default-src":["'none'"],"frame-ancestors":["'none'"]};function FK($){return{enabled:!0,directives:{strict:sX,moderate:V3,relaxed:oX,api:rX}[$]||V3,useNonce:$==="strict",addMetaTag:!0}}function LK($,Z){let X={...$};for(let[Y,J]of Object.entries(Z)){let Q=Y,G=X[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")X[Q]=G||J;else if(Array.isArray(J)){let q=Array.isArray(G)?G:[],U=[...new Set([...q,...J])];X[Q]=U}}return X}function M6($,Z,X){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let Y=Z.useNonce?R1(X,Z):void 0,J=F3(Z.directives,Y);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3273
|
+
${J}`)}function T6($,Z){let X=$;return X=X.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(Y,J)=>{if(J.includes("nonce="))return Y;return`<script nonce="${Z}"${J}>`}),X=X.replace(/<style([^>]*)>/gi,(Y,J)=>{if(J.includes("nonce="))return Y;return`<style nonce="${Z}"${J}>`}),X}function I6($,Z,X,Y){let J=$,Q=Y.csp;if(J=J.replace(/@csp\b/g,()=>{if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?R1(Z,Q):void 0;return F3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return R1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=R1(Z,Q);return J}var aX={name:"csp",handler:($,Z,X,Y)=>{let Q=X.__stx_options?.csp;if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?R1(X,Q):void 0;return F3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},tX={name:"cspNonce",handler:($,Z,X,Y)=>{let Q=X.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return R1(X,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};function wK(){return[aX,tX]}function RK($){let Z=[];if($["script-src"]?.includes("'unsafe-inline'"))Z.push("CSP: Using unsafe-inline in script-src significantly reduces XSS protection");if($["script-src"]?.includes("'unsafe-eval'"))Z.push("CSP: Using unsafe-eval in script-src allows eval() and related functions");if(!$["default-src"])Z.push("CSP: No default-src specified. Recommend adding default-src as a fallback");if($["default-src"]?.includes("*"))Z.push("CSP: Using * in default-src provides minimal protection");if(!$["object-src"]&&!$["default-src"]?.includes("'none'"))Z.push("CSP: Consider adding object-src: none to block plugins");if(!$["base-uri"])Z.push("CSP: Consider adding base-uri to prevent base tag injection attacks");for(let[X,Y]of Object.entries($))if(Array.isArray(Y)&&Y.includes("http:"))Z.push(`CSP: Using http: in ${X} allows insecure resources`);return Z}function eX($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function DK($,Z){if(!$.enabled)return{};let X=$.useNonce?R1(Z,$):void 0,Y=A6($.directives,X);return{[eX($.reportOnly)]:Y}}var NK={enabled:!1,reportOnly:!1,directives:V3,useNonce:!1,addMetaTag:!0};import $Y from"crypto";var ZY=40,k6="_token",L3=null;function XY($=ZY){let Z=$Y.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return L3=Z,Z}function YY(){if(!L3)XY();return L3}function JY($=k6){let Z=YY();return`<input type="hidden" name="${$}" value="${Z}">`}function E6($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,X,Y)=>{return JY(Y||k6)})}async function b6($,Z,X,Y){if(!Y.customDirectives||Y.customDirectives.length===0)return $;let J=$;for(let Q of Y.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(Y.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)J=await QY(J,Q,Z,X,Y);else J=await GY(J,Q,Z,X,Y)}return J}async function QY($,Z,X,Y,J){let{name:Q,handler:G}=Z,q=`@${Q}`,U=`@end${Q}`,W=$,K=v1(`${q}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${U}`,"g"),z=[],H=K.exec(W);while(H!==null){let[B,j="",_=""]=H,V=H.index||0;try{let O=j?y6(j):[],F=_.trim(),L=await G(F,O,X,Y);z.push({original:B,processed:L,startIndex:V})}catch(O){let F=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);z.push({original:B,processed:$0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${F}`,l.EVALUATION_ERROR),startIndex:V})}H=K.exec(W)}for(let B=z.length-1;B>=0;B--){let{original:j,processed:_}=z[B];W=W.replace(j,_)}return W}async function GY($,Z,X,Y,J){let{name:Q,handler:G}=Z,q=$,U=v1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),W=[],K=U.exec(q);while(K!==null){let[B,j=""]=K,_=K.index||0;try{let V=y6(j),O=await G("",V,X,Y);W.push({original:B,processed:O,startIndex:_})}catch(V){let O=V instanceof Error?V.message:String(V);if(J.debug)console.error(`Error processing custom directive @${Q}:`,V);W.push({original:B,processed:$0("CustomDirective",`Error in @${Q}(${j}): ${O}`,l.EVALUATION_ERROR),startIndex:_})}K=U.exec(q)}let z=v1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),H=z.exec(q);while(H!==null){let[B]=H,j=H.index||0;try{let _=await G("",[],X,Y);W.push({original:B,processed:_,startIndex:j})}catch(_){let V=_ instanceof Error?_.message:String(_);if(J.debug)console.error(`Error processing custom directive @${Q}:`,_);W.push({original:B,processed:$0("CustomDirective",`Error in @${Q}: ${V}`,l.EVALUATION_ERROR),startIndex:j})}H=z.exec(q)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:_}=W[B];q=q.replace(j,_)}return q}function y6($){if(!$.trim())return[];let Z=[],X="",Y=!1,J="";for(let Q=0;Q<$.length;Q++){let G=$[Q];if((G==='"'||G==="'")&&(Q===0||$[Q-1]!=="\\"))if(!Y)Y=!0,J=G;else if(G===J)Y=!1;else X+=G;else if(G===","&&!Y)Z.push(X.trim()),X="";else X+=G}if(X.trim())Z.push(X.trim());return Z.map((Q)=>{let G=Q.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var S6=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,C6=/^[A-Za-z_$][\w$]*$/,qY=new Set(["light","dark","system"]);function D1($,Z){if(typeof $!=="string"||$.length===0)throw Error(`@appearanceBootstrap ${Z} must be a non-empty string`)}function UY($){if(!$||typeof $!=="object"||Array.isArray($))throw Error("@appearanceBootstrap expects an options object");let Z=$,X=Z.appearance,Y=Z.colorMode;if(D1(Z.storageKey,"storageKey"),!X||typeof X!=="object"||Array.isArray(X))throw Error("@appearanceBootstrap appearance must be an object");if(!Y||typeof Y!=="object"||Array.isArray(Y))throw Error("@appearanceBootstrap colorMode must be an object");if(D1(X.key,"appearance.key"),D1(X.attribute,"appearance.attribute"),D1(X.default,"appearance.default"),D1(Y.key,"colorMode.key"),D1(Y.attribute,"colorMode.attribute"),D1(Y.default,"colorMode.default"),!C6.test(X.key)||!C6.test(Y.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!S6.test(X.attribute)||!S6.test(Y.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(X.allowed)||X.allowed.length===0||X.allowed.some((J)=>typeof J!=="string"||J.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!X.allowed.includes(X.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");if(!qY.has(Y.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");return{storageKey:Z.storageKey,appearance:{key:X.key,attribute:X.attribute,allowed:[...new Set(X.allowed)],default:X.default},colorMode:{key:Y.key,attribute:Y.attribute,default:Y.default}}}function WY($){return JSON.stringify($).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function KY($){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${WY($)};const root=document.documentElement;let stored={};try{const raw=localStorage.getItem(config.storageKey);const parsed=raw?JSON.parse(raw):{};if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed))stored=parsed}catch{}const selectedAppearance=config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default;const selectedMode=["light","dark","system"].includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default;root.setAttribute("data-"+config.appearance.attribute,selectedAppearance);root.setAttribute("data-"+config.colorMode.attribute,selectedMode);let dark=selectedMode==="dark";if(selectedMode==="system"){try{dark=matchMedia("(prefers-color-scheme: dark)").matches}catch{dark=false}}root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light"}());</script>`}function zY($,Z){let X=1,Y=null,J=!1;for(let Q=Z+1;Q<$.length;Q++){let G=$[Q];if(J){J=!1;continue}if(Y){if(G==="\\")J=!0;else if(G===Y)Y=null;continue}if(G==='"'||G==="'"||G==="`"){Y=G;continue}if(G==="(")X++;else if(G===")"&&--X===0)return Q}return-1}function P6($,Z){let X=$,Y=/@appearanceBootstrap\s*\(/g,J;while((J=Y.exec(X))!==null){let Q=J.index+J[0].length-1,G=zY(X,Q);if(G===-1)throw Error("@appearanceBootstrap has an unclosed options object");let q=X.slice(Q+1,G).trim(),U=X0(`(${q})`,Z),W=KY(UY(U));X=X.slice(0,J.index)+W+X.slice(G+1),Y.lastIndex=J.index+W.length}return X}import HY from"crypto";function B0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var R3={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function BY($){return{...R3,...$.forms?.classes}}function X$($,Z,X,Y){let J=$||Z;return X?`${J} ${Y}`:J}function f0($){return String($).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function m1($,Z){if(/\bid\s*=/i.test($))return"";return` id="${B0(Z)}"`}function w3($,Z,X){if(!Z)return"";let Y="";if(!/\baria-invalid\s*=/i.test(X))Y+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(X))Y+=` aria-describedby="${B0(`${f0($)}-error`)}"`;return Y}function jY(){return HY.randomUUID()}function PK($,Z,X,Y){let J=BY(Y),Q=$;return Q=OY(Q,Z),Q=F5(Q,Z),Q=D3(Q,Z,J),Q=N3(Q,Z,J),Q}function F5($,Z){let X=$;return X=X.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let Y=jY();Z.csrf={token:Y}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${B0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),X=X.replace(/@method\(['"]([^'"]+)['"]\)/g,(Y,J)=>{let Q=J.toUpperCase();if(J&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${B0(Q)}">`;return Y}),X}function D3($,Z,X=R3){let Y=$;return Y=Y.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,q,U,W="")=>{let K=Q||G||"POST",z=q||U||"",H=K1(W),B=K.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",_=`<form method="${B0(j)}" action="${B0(z)}"${H?` ${H}`:""}>`;if(_+=`
|
|
3274
|
+
${F5("@csrf",Z)}`,!["GET","POST"].includes(B))_+=`
|
|
3275
|
+
${F5(`@method('${B}')`,Z)}`;return _}),Y=Y.replace(/@endform/g,"</form>"),Y=Y.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(J,Q,G,q,U,W="")=>{let K=Q||G||"",z=q||U||"",H=K1(W),B=O5(K,Z),j=B!==void 0&&B!==null?B:z||"",_=H.match(/type=['"]([^'"]+)['"]/i),V=_?_[1]:"text",O=V5(K,Z),F=H.match(/class=['"]([^'"]+)['"]/i),L=X$(F?F[1]:"",X.input,O,X.inputError),w=H.replace(/class=['"][^'"]+['"]/i,"");return w=w.replace(/type=['"][^'"]+['"]/i,""),`<input type="${B0(V)}" name="${B0(K)}"${m1(H,f0(K))} value="${B0(j)}" class="${L}"${w3(K,O,H)}${w?` ${w}`:""}>`}),Y=Y.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(J,Q,G="",q="")=>{let U=K1(G),W=O5(Q,Z)||q.trim(),K=V5(Q,Z),z=U.match(/class=['"]([^'"]+)['"]/i),H=X$(z?z[1]:"",X.input,K,X.inputError),B=U.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${B0(Q)}"${m1(U,f0(Q))} class="${H}"${w3(Q,K,U)}${B?` ${B}`:""}>${B0(W)}</textarea>`}),Y=Y.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(J,Q,G="",q)=>{let U=K1(G),W=O5(Q,Z),K=V5(Q,Z),z=U.match(/class=['"]([^'"]+)['"]/i),H=X$(z?z[1]:"",X.input,K,X.inputError),B=U.replace(/class=['"][^'"]+['"]/i,""),j=q;if(W!==void 0)j=q.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(_,V,O)=>{if((Array.isArray(W)?W.some((L)=>String(L)===O):String(W)===O)&&!V.includes("selected"))return V.replace(/(<option)/,"$1 selected");return _});return`<select name="${B0(Q)}"${m1(U,f0(Q))} class="${H}"${w3(Q,K,U)}${B?` ${B}`:""}>${j}</select>`}),Y=Y.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G,q="")=>{let U=G===void 0?"1":G,W=G===void 0?f0(Q):`${f0(Q)}-${f0(U)}`,K=K1(q),z=O5(Q,Z),H=z!==void 0&&(Array.isArray(z)?z.some((V)=>String(V)===U):z===!0||String(z)===U),B=K.match(/class=['"]([^'"]+)['"]/i),j=B?B[1]:X.checkInput,_=K.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${B0(Q)}"${m1(K,W)} value="${B0(U)}" class="${j}"${H?" checked":""}${_?` ${_}`:""}>`}),Y=Y.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G,q="")=>{let U=K1(q),W=O5(Q,Z),K=W!==void 0&&W===G,z=U.match(/class=['"]([^'"]+)['"]/i),H=z?z[1]:X.checkInput,B=U.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${B0(Q)}"${m1(U,`${f0(Q)}-${f0(G)}`)} value="${B0(G)}" class="${H}"${K?" checked":""}${B?` ${B}`:""}>`}),Y=Y.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="")=>{let q=K1(G),U=q.match(/accept=['"]([^'"]+)['"]/i),W=U?U[1]:"",K=q.includes("multiple"),z=V5(Q,Z),H=q.match(/class=['"]([^'"]+)['"]/i),B=X$(H?H[1]:"",X.input,z,X.inputError),j=q.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),_=[`<input type="file" name="${B0(Q)}"${m1(q,f0(Q))}`,`class="${B}"`];if(W)_.push(`accept="${B0(W)}"`);if(K)_.push("multiple");if(j)_.push(j);return`${_.join(" ")}>`}),Y=Y.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(J,Q,G="",q)=>{let U=K1(G),W=U.match(/class=['"]([^'"]+)['"]/i),K=W?W[1]:X.label,z=U.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${B0(f0(Q))}" class="${K}"${z?` ${z}`:""}>${q}</label>`}),Y}function N3($,Z,X=R3){return $.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(Y,J,Q)=>{try{if(V5(J,Z)){let G=Q.replace(/\{\{([^}]+)\}\}/g,(q,U)=>{try{if(U.trim()==="$message"||U.trim()==="message")return v6(J,Z);if(U.trim().includes("errors.first")||U.trim().includes("$errors.first")){if(typeof Z.errors?.first==="function")return Z.errors.first(J);return v6(J,Z)}let W=U.trim();if(Q0(W)){let K=X0(W,Z);return K!==void 0?String(K):W}return W}catch{return U}});return`<div id="${B0(`${f0(J)}-error`)}" role="alert">${G}</div>`}return""}catch(G){return console.error("Error processing @error directive:",G),Y}})}function V5($,Z){if(!Z.errors)return!1;if(typeof Z.errors.has==="function")return Z.errors.has($);if(typeof Z.errors==="object")return Object.prototype.hasOwnProperty.call(Z.errors,$);return!1}function v6($,Z){if(!Z.errors)return"";if(typeof Z.errors.get==="function")return Z.errors.get($);if(typeof Z.errors==="object"&&Object.prototype.hasOwnProperty.call(Z.errors,$)){let X=Z.errors[$];return Array.isArray(X)?X[0]:String(X)}return""}function O5($,Z){let X;if(Z.old&&typeof Z.old==="function")return Z.old($);if(Z.old&&typeof Z.old==="object")return Z.old[$];if($.endsWith("[]")){let Y=$.slice(0,-2);if(X=Z[Y],X!==void 0)return X}return Z[$]}function K1($){if(!$.trim())return"";let Z=[],X=$.trim(),Y=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,J;while((J=Y.exec(X))!==null){let[,Q,,G]=J;Z.push(`${Q}="${G.trim()}"`)}return Z.join(" ")}var f6={required:($,Z,X)=>{if($===void 0||$===null||$===""||Array.isArray($)&&$.length===0)return`The ${X} field is required.`;return null},email:($,Z,X)=>{if(!$)return null;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String($)))return`The ${X} field must be a valid email address.`;return null},min:($,Z,X)=>{if(!$)return null;let Y=Number(Z[0]);if(typeof $==="string"&&$.length<Y)return`The ${X} field must be at least ${Y} characters.`;if(typeof $==="number"&&$<Y)return`The ${X} field must be at least ${Y}.`;if(Array.isArray($)&&$.length<Y)return`The ${X} field must have at least ${Y} items.`;return null},max:($,Z,X)=>{if(!$)return null;let Y=Number(Z[0]);if(typeof $==="string"&&$.length>Y)return`The ${X} field must not exceed ${Y} characters.`;if(typeof $==="number"&&$>Y)return`The ${X} field must not exceed ${Y}.`;if(Array.isArray($)&&$.length>Y)return`The ${X} field must not have more than ${Y} items.`;return null},confirmed:($,Z,X)=>{if(Z[0]!==void 0&&$!==Z[0])return`The ${X} confirmation does not match.`;return null},numeric:($,Z,X)=>{if(!$)return null;if(Number.isNaN(Number($)))return`The ${X} field must be a number.`;return null},integer:($,Z,X)=>{if(!$)return null;if(!Number.isInteger(Number($)))return`The ${X} field must be an integer.`;return null},alpha:($,Z,X)=>{if(!$)return null;if(!/^[a-z]+$/i.test(String($)))return`The ${X} field must only contain letters.`;return null},alphanumeric:($,Z,X)=>{if(!$)return null;if(!/^[a-z0-9]+$/i.test(String($)))return`The ${X} field must only contain letters and numbers.`;return null},url:($,Z,X)=>{if(!$)return null;try{return new URL(String($))?null:null}catch{return`The ${X} field must be a valid URL.`}},regex:($,Z,X)=>{if(!$)return null;try{if(!new RegExp(Z[0]).test(String($)))return`The ${X} field format is invalid.`;return null}catch{return`The ${X} field has an invalid validation pattern.`}},in:($,Z,X)=>{if(!$)return null;if(!Z.includes(String($)))return`The ${X} field must be one of: ${Z.join(", ")}.`;return null},notIn:($,Z,X)=>{if(!$)return null;if(Z.includes(String($)))return`The ${X} field must not be: ${Z.join(", ")}.`;return null},date:($,Z,X)=>{if(!$)return null;let Y=new Date($);if(Number.isNaN(Y.getTime()))return`The ${X} field must be a valid date.`;return null},before:($,Z,X)=>{if(!$)return null;let Y=new Date($),J=new Date(Z[0]);if(Y>=J)return`The ${X} field must be before ${Z[0]}.`;return null},after:($,Z,X)=>{if(!$)return null;let Y=new Date($),J=new Date(Z[0]);if(Y<=J)return`The ${X} field must be after ${Z[0]}.`;return null}};function vK($,Z){f6[$]=Z}function A3($){let[Z,...X]=$.split(":"),Y=X.length>0?X.join(":").split(","):[];return{name:Z.trim(),params:Y}}function _Y($,Z,X,Y={}){let J=[],Q=X.split("|").map((G)=>G.trim()).filter(Boolean);for(let G of Q){let q=A3(G),U=f6[q.name];if(!U){console.warn(`Unknown validation rule: ${q.name}`);continue}if(q.name==="confirmed"){let K=`${$}_confirmation`;q.params=[Y[K]]}let W=U(Z,q.params||[],$);if(W)J.push(q.message||W)}return{field:$,valid:J.length===0,errors:J}}function fK($,Z){let X={};for(let[Y,J]of Object.entries(Z)){let Q=_Y(Y,$[Y],J,$);if(!Q.valid)X[Y]=Q.errors}return X}function OY($,Z){return $.replace(/@validate\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]*)\})?\s*\)/g,(X,Y,J,Q)=>{let G=J.split("|").map((U)=>U.trim()),q=[];for(let U of G){let W=A3(U);switch(W.name){case"required":q.push("required");break;case"email":q.push('type="email"');break;case"url":q.push('type="url"');break;case"numeric":case"integer":if(q.push('type="number"'),W.name==="integer")q.push('step="1"');break;case"min":if(W.params?.[0])q.push(`minlength="${W.params[0]}"`);break;case"max":if(W.params?.[0])q.push(`maxlength="${W.params[0]}"`);break;case"regex":if(W.params?.[0])q.push(`pattern="${W.params[0]}"`);break}}return`<!-- @validate:${Y}:${J} -->${q.length>0?`<!-- attrs:${q.join(" ")} -->`:""}`})}var x6={required:{name:"required",validate:($)=>{if($===null||$===void 0||$==="")return"This field is required";if(Array.isArray($)&&$.length===0)return"This field is required";return!0},toHtml5:()=>["required"],message:"This field is required"},email:{name:"email",validate:($)=>{if(!$)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String($))||"Please enter a valid email address"},toHtml5:()=>['type="email"'],message:"Please enter a valid email address"},url:{name:"url",validate:($)=>{if(!$)return!0;try{return new URL(String($)).protocol.startsWith("http")||"Please enter a valid URL"}catch{return"Please enter a valid URL"}},toHtml5:()=>['type="url"'],message:"Please enter a valid URL"},numeric:{name:"numeric",validate:($)=>{if(!$)return!0;return!Number.isNaN(Number($))||"Please enter a number"},toHtml5:()=>['type="number"'],message:"Please enter a number"},integer:{name:"integer",validate:($)=>{if(!$)return!0;let Z=Number($);return Number.isInteger(Z)||"Please enter a whole number"},toHtml5:()=>['type="number"','step="1"'],message:"Please enter a whole number"},alpha:{name:"alpha",validate:($)=>{if(!$)return!0;return/^[a-z]+$/i.test(String($))||"Please enter only letters"},toHtml5:()=>['pattern="[a-zA-Z]+"'],message:"Please enter only letters"},alphanumeric:{name:"alphanumeric",validate:($)=>{if(!$)return!0;return/^[a-z0-9]+$/i.test(String($))||"Please enter only letters and numbers"},toHtml5:()=>['pattern="[a-zA-Z0-9]+"'],message:"Please enter only letters and numbers"},min:{name:"min",validate:($,Z)=>{if(!$)return!0;let X=Number(Z[0]);if(typeof $==="string")return $.length>=X||`Must be at least ${X} characters`;if(typeof $==="number")return $>=X||`Must be at least ${X}`;if(Array.isArray($))return $.length>=X||`Must have at least ${X} items`;return!0},toHtml5:($)=>[`minlength="${$[0]}"`,`min="${$[0]}"`],message:"Must be at least {{param}} characters"},max:{name:"max",validate:($,Z)=>{if(!$)return!0;let X=Number(Z[0]);if(typeof $==="string")return $.length<=X||`Must be no more than ${X} characters`;if(typeof $==="number")return $<=X||`Must be no more than ${X}`;if(Array.isArray($))return $.length<=X||`Must have no more than ${X} items`;return!0},toHtml5:($)=>[`maxlength="${$[0]}"`,`max="${$[0]}"`],message:"Must be no more than {{param}} characters"},between:{name:"between",validate:($,Z)=>{if(!$)return!0;let[X,Y]=Z.map(Number);if(typeof $==="string")return $.length>=X&&$.length<=Y||`Must be between ${X} and ${Y} characters`;if(typeof $==="number")return $>=X&&$<=Y||`Must be between ${X} and ${Y}`;return!0},toHtml5:($)=>[`minlength="${$[0]}"`,`maxlength="${$[1]}"`],message:"Must be between {{min}} and {{max}}"},confirmed:{name:"confirmed",validate:($,Z,X)=>{let Y=Object.keys(X);for(let J of Y)if(J.endsWith("_confirmation")&&X[J]===$)return!0;return"Confirmation does not match"},message:"Confirmation does not match"},in:{name:"in",validate:($,Z)=>{if(!$)return!0;return Z.includes(String($))||`Must be one of: ${Z.join(", ")}`},message:"Must be one of: {{values}}"},notIn:{name:"notIn",validate:($,Z)=>{if(!$)return!0;return!Z.includes(String($))||`Must not be: ${Z.join(", ")}`},message:"Must not be: {{values}}"},regex:{name:"regex",validate:($,Z)=>{if(!$)return!0;try{return new RegExp(Z[0]).test(String($))||"Invalid format"}catch{return"Invalid format"}},toHtml5:($)=>[`pattern="${$[0]}"`],message:"Invalid format"},date:{name:"date",validate:($)=>{if(!$)return!0;let Z=new Date(String($));return!Number.isNaN(Z.getTime())||"Please enter a valid date"},toHtml5:()=>['type="date"'],message:"Please enter a valid date"},before:{name:"before",validate:($,Z)=>{if(!$)return!0;let X=new Date(String($)),Y=new Date(Z[0]);return X<Y||`Must be before ${Z[0]}`},toHtml5:($)=>[`max="${$[0]}"`],message:"Must be before {{date}}"},after:{name:"after",validate:($,Z)=>{if(!$)return!0;let X=new Date(String($)),Y=new Date(Z[0]);return X>Y||`Must be after ${Z[0]}`},toHtml5:($)=>[`min="${$[0]}"`],message:"Must be after {{date}}"},size:{name:"size",validate:($,Z)=>{if(!$)return!0;let X=Number(Z[0]);if(typeof $==="string")return $.length===X||`Must be exactly ${X} characters`;if(Array.isArray($))return $.length===X||`Must have exactly ${X} items`;return!0},message:"Must be exactly {{size}}"},phone:{name:"phone",validate:($)=>{if(!$)return!0;return/^\+?\(?\d{1,4}\)?[-\s./\d]*$/.test(String($))||"Please enter a valid phone number"},toHtml5:()=>['type="tel"','pattern="\\+?\\(?\\d{1,4}\\)?[-\\s./\\d]*"'],message:"Please enter a valid phone number"}};function xK($){x6[$.name]=$}function VY($,Z,X={}){let Y=[],J=Z.split("|").map((Q)=>Q.trim());for(let Q of J){let G=A3(Q),q=x6[G.name];if(!q){console.warn(`Unknown validation rule: ${G.name}`);continue}let U=q.validate($,G.params||[],X);if(U!==!0)Y.push(U)}return{valid:Y.length===0,errors:Y}}function gK($,Z){let X={},Y=!0;for(let[J,Q]of Object.entries(Z)){let G=VY($[J],Q,$);if(!G.valid)Y=!1,X[J]=G.errors}return{valid:Y,errors:X}}function hK($,Z){let X=JSON.stringify(Z);return`
|
|
3276
|
+
<script>
|
|
3277
|
+
(function() {
|
|
3278
|
+
const form = document.getElementById('${$}');
|
|
3279
|
+
if (!form) return;
|
|
3280
|
+
|
|
3281
|
+
const rules = ${X};
|
|
3282
|
+
const validators = {
|
|
3283
|
+
required: (v) => v !== null && v !== undefined && v !== '' ? true : 'This field is required',
|
|
3284
|
+
email: (v) => !v || /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(v) ? true : 'Please enter a valid email',
|
|
3285
|
+
url: (v) => { if (!v) return true; try { new URL(v); return true; }
|
|
3286
|
+
catch { return 'Please enter a valid URL'; } },
|
|
3287
|
+
numeric: (v) => !v || !isNaN(Number(v)) ? true : 'Please enter a number',
|
|
3288
|
+
integer: (v) => !v || Number.isInteger(Number(v)) ? true : 'Please enter a whole number',
|
|
3289
|
+
min: (v, p) => !v || (typeof v === 'string' ? v.length >= p : v >= p) ? true : 'Too short/small',
|
|
3290
|
+
max: (v, p) => !v || (typeof v === 'string' ? v.length <= p : v <= p) ? true : 'Too long/large',
|
|
3291
|
+
regex: (v, p) => !v || new RegExp(p).test(v) ? true : 'Invalid format',
|
|
3292
|
+
};
|
|
3293
|
+
|
|
3294
|
+
form.addEventListener('submit', function(e) {
|
|
3295
|
+
let valid = true;
|
|
3296
|
+
const errors = {};
|
|
3297
|
+
|
|
3298
|
+
for (const [field, fieldRules] of Object.entries(rules)) {
|
|
3299
|
+
const input = form.querySelector('[name="' + field + '"]');
|
|
3300
|
+
if (!input) continue;
|
|
3301
|
+
|
|
3302
|
+
const value = input.value;
|
|
3303
|
+
const ruleList = fieldRules.split('|');
|
|
3304
|
+
|
|
3305
|
+
for (const rule of ruleList) {
|
|
3306
|
+
const [name, param] = rule.split(':');
|
|
3307
|
+
const validator = validators[name];
|
|
3308
|
+
if (validator) {
|
|
3309
|
+
const result = validator(value, param);
|
|
3310
|
+
if (result !== true) {
|
|
3311
|
+
valid = false;
|
|
3312
|
+
errors[field] = errors[field] || [];
|
|
3313
|
+
errors[field].push(result);
|
|
3314
|
+
input.classList.add('is-invalid');
|
|
3315
|
+
break;
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
}
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3321
|
+
if (!valid) {
|
|
3322
|
+
e.preventDefault();
|
|
3323
|
+
console.log('Validation errors:', errors);
|
|
3324
|
+
}
|
|
3325
|
+
});
|
|
3326
|
+
})();
|
|
3327
|
+
</script>`.trim()}import T3 from"path";var L5;async function FY(){if(L5!==void 0)return L5;try{L5=(await import("@stacksjs/ts-i18n")).loadLocale??null}catch{L5=null}return L5}var E3={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},I0={},d0={},t0={};function cK($){if($)delete I0[$];else for(let Z of Object.keys(I0))delete I0[Z]}function pK(){let $=Object.entries(I0).map(([Z,X])=>({locale:Z,loadedAt:new Date(X.loadedAt),keyCount:h6(X.translations)}));return{size:Object.keys(I0).length,locales:Object.keys(I0),entries:$}}function h6($,Z=0){for(let X of Object.values($))if(Z++,X&&typeof X==="object"&&!Array.isArray(X))Z=h6(X,Z);return Z}function LY($,Z=0){if(Z<=0)return!1;return Date.now()-$.loadedAt>Z}function iK($){if(I0[$])return"loaded";return t0[$]||"idle"}function nK($){return t0[$]==="loading"}function sK($){return!!I0[$]}async function wY($,Z){let{locales:X,parallel:Y=!0,priority:J={},onLocaleLoaded:Q,onComplete:G,onError:q}=$,U=Y?X:[...X].sort((W,K)=>(J[K]||0)-(J[W]||0));if(Y){let W=U.map(async(K)=>{try{await Y$(K,Z),Q?.(K)}catch(z){q?.(K,z instanceof Error?z:Error(String(z)))}});await Promise.all(W)}else for(let W of U)try{await Y$(W,Z),Q?.(W)}catch(K){q?.(W,K instanceof Error?K:Error(String(K)))}G?.()}function oK($,Z){queueMicrotask(()=>{wY($,Z).catch((X)=>{if(Z.debug)console.error("Background preload error:",X)})})}async function Y$($,Z){if({...E3,...Z.i18n}.cache&&I0[$]){let J=I0[$],Q=Z.i18n?.cacheMaxAge??0;if(!LY(J,Q))return J.translations}if(d0[$]?.state==="loading")return d0[$].promise;t0[$]="loading";let Y=I3($,Z).then((J)=>{return t0[$]="loaded",delete d0[$],J}).catch((J)=>{throw t0[$]="error",d0[$]={promise:Y,state:"error",error:J instanceof Error?J:Error(String(J))},J});return d0[$]={promise:Y,state:"loading"},Y}function RY($){return I0[$]?.translations}async function rK($,Z){let X=RY($);if(X)return X;return Y$($,Z)}async function aK($,Z){if(I0[$])return I0[$].translations;if(d0[$]){if(Z)return Promise.race([d0[$].promise,new Promise((X,Y)=>setTimeout(()=>Y(Error(`Timeout waiting for locale: ${$}`)),Z))]);return d0[$].promise}throw Error(`Locale "${$}" is not loading. Call loadTranslationLazy first.`)}function tK(){return Object.entries(t0).filter(([$,Z])=>Z==="loading").map(([$])=>$)}function eK($){if($)delete d0[$],delete t0[$];else{for(let Z of Object.keys(d0))delete d0[Z];for(let Z of Object.keys(t0))delete t0[Z]}}async function I3($,Z){let X={...E3,...Z.i18n},Y=T3.isAbsolute(X.translationsDir)?X.translationsDir:T3.resolve(Z.root||process.cwd(),X.translationsDir);try{let J=await FY(),Q=J?await J($,{translationsDir:Y,defaultLocale:X.defaultLocale,sources:TY(X.format)}):await DY($,X,Y);if(Q===void 0){if($!==X.defaultLocale)return I3(X.defaultLocale,Z);return{}}let G=Q;if(X.cache)I0[$]={translations:G,loadedAt:Date.now(),locale:$};return G}catch(J){if(Z.debug)console.error(`Error loading translation file for locale "${$}":`,J);if($!==X.defaultLocale)return I3(X.defaultLocale,Z);return{}}}async function DY($,Z,X){let Y=T3.join(X,`${$}${NY(Z.format)}`);try{let J=await import(Y);return J.default||J}catch(J){try{let Q=await Bun.file(Y).text();if(Z.format==="yaml"||Z.format==="yml")return AY(Q);if(Z.format==="json")return JSON.parse(Q);throw J}catch{return}}}function NY($){switch($){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function AY($){let Z={},X=$.split(`
|
|
3328
|
+
`),Y=[{obj:Z,indent:-1}];for(let J of X){let Q=J.replace(/#.*$/,"").trimEnd();if(!Q.trim())continue;let G=Q.search(/\S/);if(G===-1)continue;while(Y.length>1&&Y[Y.length-1].indent>=G)Y.pop();let q=Y[Y.length-1].obj,U=Q.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(U){let[,,W,K]=U,z=W.trim(),H=K.trim();if(H==="")q[z]={},Y.push({obj:q[z],indent:G});else q[z]=MY(H)}}return Z}function MY($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);let Z=$.toLowerCase();if(Z==="true"||Z==="yes")return!0;if(Z==="false"||Z==="no")return!1;if(Z==="null"||Z==="~")return null;let X=Number($);if(!Number.isNaN(X)&&$!=="")return X;return $}function TY($){switch($){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function IY($,Z){return Y$($,Z)}function kY($,Z){for(let X of $){let Y=X.trim(),J=Y.match(/^\{(\d+)\}\s*(.*)$/);if(J){let G=Number.parseInt(J[1],10);if(Z===G)return J[2];continue}let Q=Y.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(Q){let G=Number.parseInt(Q[1],10),q=Q[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(Q[2],10);if(Z>=G&&Z<=q)return Q[3];continue}}if($.length===2)return Z===1?$[0].trim():$[1].trim();if(Z<$.length)return $[Z].trim();return $[$.length-1].trim()}function EY($,Z={}){return u6($,Z)}function u6($,Z){let X="",Y=0;while(Y<$.length)if($[Y]==="{"){let J=bY($,Y);if(J===-1){X+=$[Y],Y++;continue}let Q=$.slice(Y+1,J);X+=yY(Q,Z),Y=J+1}else if($[Y]==="'"&&Y+1<$.length)if($[Y+1]==="'")X+="'",Y+=2;else if($[Y+1]==="{"||$[Y+1]==="}")X+=$[Y+1],Y+=2;else X+=$[Y],Y++;else X+=$[Y],Y++;return X}function bY($,Z){let X=0;for(let Y=Z;Y<$.length;Y++)if($[Y]==="{")X++;else if($[Y]==="}"){if(X--,X===0)return Y}return-1}function yY($,Z){let X=SY($);if(X.length===0)return`{${$}}`;let Y=X[0].trim(),J=Z[Y];if(X.length===1)return J!==void 0?String(J):`{${Y}}`;switch(X[1].trim().toLowerCase()){case"plural":return CY(J,X.slice(2).join(","),Z);case"select":return vY(J,X.slice(2).join(","));case"selectordinal":return fY(J,X.slice(2).join(","));case"number":return gY(J,X[2]?.trim());case"date":return hY(J,X[2]?.trim());case"time":return uY(J,X[2]?.trim());default:return J!==void 0?String(J):`{${$}}`}}function SY($){let Z=[],X="",Y=0;for(let J=0;J<$.length;J++){let Q=$[J];if(Q==="{")Y++,X+=Q;else if(Q==="}")Y--,X+=Q;else if(Q===","&&Y===0)Z.push(X),X="";else X+=Q}if(X)Z.push(X);return Z}function CY($,Z,X){let Y=Number($)||0,J=b3(Z),Q=`=${Y}`;if(J[Q])return M3(J[Q],Y,X);let G=PY(Y);if(J[G])return M3(J[G],Y,X);if(J.other)return M3(J.other,Y,X);return String(Y)}function M3($,Z,X){let Y=$.replace(/#/g,String(Z));return u6(Y,X)}function PY($){let Z=Math.abs($),X=Math.floor(Z),Y=String($).includes(".")?String($).split(".")[1].length:0;if(X===1&&Y===0)return"one";return"other"}function vY($,Z){let X=String($||""),Y=b3(Z);if(Y[X])return Y[X];return Y.other||String($)}function fY($,Z){let X=Number($)||0,Y=b3(Z),J=xY(X);if(Y[J])return Y[J].replace(/#/g,String(X));if(Y.other)return Y.other.replace(/#/g,String(X));return String(X)}function xY($){let Z=Math.abs($),X=Z%10,Y=Z%100;if(X===1&&Y!==11)return"one";if(X===2&&Y!==12)return"two";if(X===3&&Y!==13)return"few";return"other"}function b3($){let Z={},X=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,Y=X.exec($);while(Y!==null)Z[Y[1]]=Y[2],Y=X.exec($);return Z}function gY($,Z){let X=Number($);if(Number.isNaN(X))return String($);switch(Z){case"integer":return Math.floor(X).toLocaleString();case"percent":return`${(X*100).toFixed(0)}%`;case"currency":return X.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return X.toLocaleString()}}function hY($,Z){let X=$ instanceof Date?$:new Date(String($));if(Number.isNaN(X.getTime()))return String($);let Y={};switch(Z){case"short":Y.dateStyle="short";break;case"medium":Y.dateStyle="medium";break;case"long":Y.dateStyle="long";break;case"full":Y.dateStyle="full";break;default:Y.dateStyle="medium"}return X.toLocaleDateString(void 0,Y)}function uY($,Z){let X=$ instanceof Date?$:new Date(String($));if(Number.isNaN(X.getTime()))return String($);let Y={};switch(Z){case"short":Y.timeStyle="short";break;case"medium":Y.timeStyle="medium";break;case"long":Y.timeStyle="long";break;case"full":Y.timeStyle="full";break;default:Y.timeStyle="short"}return X.toLocaleTimeString(void 0,Y)}function dY($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function k3($,Z,X=!0,Y={}){let J=$.split("."),Q=Z;for(let q of J){if(Q===void 0||Q===null)break;Q=Q[q]}if(Q===void 0||Q===null)return X?$:"";let G=String(Q);if(dY(G))return EY(G,Y);if(G.includes("|")&&"count"in Y){let q=Number(Y.count),U=G.split("|");G=kY(U,q)}for(let[q,U]of Object.entries(Y)){let W=q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");G=G.replace(new RegExp(`:${W}`,"g"),String(U))}return G}async function d6($,Z,X,Y){let J=$,Q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...E3,...Y.i18n},q=await IY(G.locale,Y);Z.__translations=q,Z.__locale=G.locale,Z.__i18nConfig=G,J=await g6(J,Q,async(K,z,H,B,j)=>{try{let _={};if(H)try{let O=[()=>JSON.parse(H),()=>{let F=`{"data":${H}}`,L=JSON.parse(F);return typeof L.data==="object"?L.data:{}},()=>{return _0(H,Z)}];for(let F of O)try{if(_=F(),Object.keys(_).length>0)break}catch{}}catch(O){if(Y.debug)console.error("Error parsing parameters for @translate directive:",O)}return k3(z,q,G.fallbackToKey,_)||B.trim()}catch(_){if(Y.debug)console.error("Error processing @translate directive:",_);return $0("Translate",`Error in @translate('${z}'): ${_ instanceof Error?_.message:String(_)}`,l.EVALUATION_ERROR)}});let U=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(Y.debug){console.warn(`Processing translations in template. Sections: ${J.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let K=[...J.matchAll(U)];console.warn(`Found ${K.length} @translate matches`),K.forEach((z,H)=>console.warn(`Match ${H}: ${z[0]}, Key: ${z[1]}, Params: ${z[2]||"none"}`))}return J=await g6(J,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(K,z,H,B)=>{try{let j={};if(H)try{let _=[()=>JSON.parse(H),()=>{let V=`{"data":${H}}`,O=JSON.parse(V);return typeof O.data==="object"?O.data:{}},()=>{return _0(H,Z)}];for(let V of _)try{if(j=V(),Object.keys(j).length>0)break}catch{}}catch(_){if(Y.debug)console.error("Error parsing parameters for @translate directive:",_)}return k3(z,q,G.fallbackToKey,j)}catch(j){if(Y.debug)console.error("Error processing @translate directive:",j);return $0("Translate",`Error in @translate('${z}'): ${j instanceof Error?j.message:String(j)}`,l.EVALUATION_ERROR)}}),J}async function g6($,Z,X){let Y=[];return $.replace(Z,(Q,...G)=>{let q=X(Q,...G).then((U)=>({match:Q,replacement:U}));return Y.push(q),Q}),(await Promise.all(Y)).reduce((Q,{match:G,replacement:q})=>Q.replace(G,q),$)}function $z($,Z=!0){return(X,Y={})=>{return k3(X,$,Z,Y)}}var w5=/<\/?template\b[^>]*>/gi,mY=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i;function lY($){let Z=$.replace(/^<template\b/i,"").replace(/>$/,"");return mY.test(Z)}function J$($){w5.lastIndex=0;let Z;while((Z=w5.exec($))!==null){if(Z[0].startsWith("</")||lY(Z[0]))continue;let X=Z.index,Y=w5.lastIndex,J=1,Q;while((Q=w5.exec($))!==null)if(Q[0].startsWith("</")){if(J--,J===0){let G=Q.index;return{start:X,openEnd:Y,closeStart:G,end:w5.lastIndex,content:$.slice(Y,G)}}}else J++;return null}return null}import U0 from"path";function y3($,Z){let X=0;for(let Y=Z;Y<$.length;Y++){let J=$[Y];if(J==="("||J==="["||J==="{")X++;else if(J===")"||J==="]"||J==="}")X--;else if(J===","&&X===0)return Y}return-1}function cY($,Z,X){let Y=$,J=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),Q=J.exec(Y);while(Q){let G=Q.index,q=G+Q[0].length-1,U=1,W=q+1;while(W<Y.length&&U>0){if(Y[W]==="(")U++;else if(Y[W]===")")U--;W++}if(U!==0)break;let K=Y.substring(q+1,W-1),z=`${X}(${K})`;Y=Y.substring(0,G)+z+Y.substring(W),J.lastIndex=G+z.length,Q=J.exec(Y)}return Y}function pY($){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test($)}function l6($){let Z=$,X=[],Y=new Set,J=0,Q=0,G=Z.length,q=(z)=>{Q++;while(Q<G){if(Z[Q]==="\\"){Q+=2;continue}if(Z[Q]===z){Q++;return}Q++}},U=()=>{Q++;while(Q<G){if(Z[Q]==="\\"){Q+=2;continue}if(Z[Q]==="`"){Q++;return}if(Z[Q]==="$"&&Z[Q+1]==="{"){Q+=2;let z=1;while(Q<G&&z>0)if(Z[Q]==="{")z++,Q++;else if(Z[Q]==="}")z--,Q++;else if(Z[Q]==="'"||Z[Q]==='"')q(Z[Q]);else if(Z[Q]==="`")U();else Q++;continue}Q++}},W=()=>{if(Z[Q]==="/"&&Z[Q+1]==="/"){while(Q<G&&Z[Q]!==`
|
|
3329
|
+
`)Q++;return!0}if(Z[Q]==="/"&&Z[Q+1]==="*"){Q+=2;while(Q<G-1&&!(Z[Q]==="*"&&Z[Q+1]==="/"))Q++;return Q+=2,!0}return!1},K=()=>{if(J!==0)return;let z=Z.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(z){let j=z[2];if(!Y.has(j))X.push(j),Y.add(j);return}let H=Z.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(H){let j=H[1];if(!Y.has(j))X.push(j),Y.add(j);return}let B=Z.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))X.push(j),Y.add(j)}};while(Q<G){if(W())continue;if(Z[Q]==="'"||Z[Q]==='"'){q(Z[Q]);continue}if(Z[Q]==="`"){U();continue}if(Z[Q]==="{"){J++,Q++;continue}if(Z[Q]==="}"){J--,Q++;continue}if(J===0&&/[a-z]/i.test(Z[Q])&&(Q===0||/\s|[;{}()]/.test(Z[Q-1])))K();Q++}return X.join(", ")}function c6($,Z=""){let X=l6($).split(",").map((Y)=>Y.trim()).filter(Boolean);return`
|
|
3330
|
+
(function() {
|
|
3331
|
+
${l1("var",X)}
|
|
3332
|
+
var __destroyHooks = [];
|
|
3333
|
+
var __origOnDestroy = onDestroy;
|
|
3334
|
+
onDestroy = function(fn) { __origOnDestroy(fn); __destroyHooks.push(fn); };
|
|
3335
|
+
|
|
3336
|
+
${$}
|
|
3337
|
+
${Z}})();
|
|
3338
|
+
`}function p6($,Z){return`
|
|
3339
|
+
// Register scope variables for STX runtime
|
|
3340
|
+
if (!window.stx._scopes) window.stx._scopes = {};
|
|
3341
|
+
var __scopeRegistration = { __destroyCallbacks: __destroyHooks };
|
|
3342
|
+
${l6($).split(",").map((Q)=>Q.trim()).filter(Boolean).map((Q)=>` try { __scopeRegistration[${JSON.stringify(Q)}] = ${Q}; } catch (e) { /* not actually top-level */ }`).join(`
|
|
3343
|
+
`)}
|
|
3344
|
+
// #1767: when the bundler renamed a component const that collided with an
|
|
3345
|
+
// inlined import (foo -> foo2), rebind the ORIGINAL template name to the
|
|
3346
|
+
// renamed declaration so it resolves to the component's value, not the
|
|
3347
|
+
// shadowing import. __stxScopeRenames is emitted by bundleClientScript.
|
|
3348
|
+
try { if (typeof __stxScopeRenames !== 'undefined' && __stxScopeRenames) { for (var __stxRK in __stxScopeRenames) __scopeRegistration[__stxRK] = __stxScopeRenames[__stxRK]; } } catch (e) { /* no renames */ }
|
|
3349
|
+
window.stx._scopes['${Z}'] = __scopeRegistration;
|
|
3350
|
+
`}function iY($,Z){let X=p6($,Z),Y=`
|
|
3351
|
+
(function() {
|
|
3352
|
+
var __stxScopeEl = (typeof document !== 'undefined') ? document.querySelector('[data-stx-scope="${Z}"]') : null;
|
|
3353
|
+
var __stxPrevEl = (typeof window !== 'undefined') ? window.__STX_CURRENT_ELEMENT__ : undefined;
|
|
3354
|
+
if (__stxScopeEl && typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxScopeEl;
|
|
3355
|
+
try {`,J=`
|
|
3356
|
+
} finally {
|
|
3357
|
+
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
3358
|
+
}
|
|
3359
|
+
})();`;return Y+c6($,X)+`
|
|
3360
|
+
} finally {
|
|
3361
|
+
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
3362
|
+
}
|
|
3363
|
+
})();`}function nY($,Z){let X=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(X){let J=(X[2]+X[3]).match(/data-stx-scope="([^"]*)"/);if(J)return{html:$,mergedIntoExisting:J[1]};let Q=X[1],G=X[2],q=X[3];return{html:`${Q}${G} data-stx-scope="${Z}"${q}${$.slice(X[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}var m6=0,Bz=new O1(500),i6=new Set;function jz(){i6.clear()}function sY($){if($.__onceStore instanceof Set)return $.__onceStore;return i6}async function S3($,Z,X,Y,J,Q=new Set){let G=Y.partialsDir||U0.join(U0.dirname(X),"partials");if(G&&!U0.isAbsolute(G))G=U0.resolve(process.cwd(),G);let q=cY($,"@partial","@include"),U=sY(Z);q=q.replace(/@once([\s\S]*?)@endonce/g,(_,V,O)=>{let F=V.trim(),L=`${X}:${F}`;if(U.has(L))return"";return U.add(L),V});{let _=/@includeIf\s*\(/g,V;while((V=_.exec(q))!==null){let O=V.index,F=O+V[0].length-1,L=1,w=F+1;while(w<q.length&&L>0){if(q[w]==="(")L++;else if(q[w]===")")L--;w++}if(L!==0)break;let R=q.substring(F+1,w-1),D=R.match(/^\s*['"]([^'"]+)['"]/);if(!D){_.lastIndex=w;continue}let N=D[1],T=W(N,G,X),A="";if(T&&await Bun.file(T).exists())J.add(T),A=`@include(${R})`;q=q.substring(0,O)+A+q.substring(w),_.lastIndex=0}}for(let[_,V]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=O.exec(q))!==null){let L=F.index,w=L+F[0].length-1,R=1,D=w+1;while(D<q.length&&R>0){if(q[D]==="(")R++;else if(q[D]===")")R--;D++}if(R!==0)break;let N=q.substring(w+1,D-1),T=y3(N,0);if(T===-1){O.lastIndex=D;continue}let A=N.substring(0,T).trim(),M=N.substring(T+1).trim(),k=M.match(/^\s*['"]([^'"]+)['"]/);if(!k){O.lastIndex=D;continue}let I=k[1],y=M.substring(k[0].length),E,b=y3(y,0);if(b!==-1)E=y.substring(b+1).trim();try{let C=`Boolean(${A})`,x;if(Q0(C)){let m=G0(C,Object.keys(Z));x=Boolean(m(...Object.values(Z)))}else x=Boolean(X0(C,Z));let f=V?!x:x,n="";if(f){let m=W(I,G,X);if(m&&await Bun.file(m).exists())J.add(m);n=`@include('${I}'${E?`, ${E}`:""})`}q=q.substring(0,L)+n+q.substring(D),O.lastIndex=0}catch(C){let x=C instanceof Error?C.message:String(C),f=W0("Include",`Error evaluating ${_} condition: ${x}`,X,$,L);q=q.substring(0,L)+f+q.substring(D),O.lastIndex=0}}}{let _=/@each\s*\(/g,V;while((V=_.exec(q))!==null){let O=V.index,F=O+V[0].length-1,L=1,w=F+1;while(w<q.length&&L>0){if(q[w]==="(")L++;else if(q[w]===")"){if(L--,L===0)break}w++}if(L!==0)break;let R=q.substring(F+1,w),D=q.substring(O,w+1),N=R.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!N){_.lastIndex=0,q=q.replace(D,"");continue}let[,T,A,M,k]=N;try{let I,y=A.trim();if(Q0(y))I=G0(y,Object.keys(Z))(...Object.values(Z));else I=X0(y,Z);let E="";if(Array.isArray(I)&&I.length>0)for(let b of I){let C={...Z,[M]:b},x=await H(T,C,$,O);E+=x}else if(k)E=await H(k,{},$,O);q=q.substring(0,O)+E+q.substring(w+1),_.lastIndex=0}catch(I){let y=I instanceof Error?I.message:String(I);q=q.substring(0,O)+W0("Each",`Error in @each: ${y}`,X,$,O)+q.substring(w+1),_.lastIndex=0}}}{let _=/@includeFirst\s*\(/g,V;while((V=_.exec(q))!==null){let O=V.index,F=O+V[0].length-1,L=1,w=F+1;while(w<q.length&&L>0){if(q[w]==="(")L++;else if(q[w]===")"){if(L--,L===0)break}w++}if(L!==0)break;let R=q.substring(F+1,w),D=q.substring(O,w+1),N=R.match(/^\s*(\[[^\]]+\])/);if(!N){_.lastIndex=0,q=q.replace(D,"");continue}let T=N[1],A=R.slice(N[0].length),M,k=A.match(/^\s*,\s*\{/);if(k){A=A.slice(k[0].length-1);let E=1,b=1;while(b<A.length&&E>0){if(A[b]==="{")E++;else if(A[b]==="}"){if(E--,E===0)break}b++}M=A.substring(0,b+1),A=A.slice(b+1)}let I,y=A.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(y)I=y[1];try{let E=JSON.parse(T.replace(/'/g,'"')),b={};if(M)try{b=_0(M,Z)}catch(x){let f=x instanceof Error?x.message:String(x);if(Y.debug){let n=W0("Include",`Error parsing includeFirst variables: ${f}`,X,$,O,D);q=q.replace(D,()=>n)}else q=q.replace(D,()=>I||"");continue}let C=!1;for(let x of E){let f=W(x,G,X);if(!f)continue;if(await r(f)){let n=await H(x,b,$,O);q=q.replace(D,()=>n),C=!0;break}}if(!C)if(I!==void 0)q=q.replace(D,()=>I);else if(Y.debug){let x=W0("Include",`None of the includeFirst paths exist: ${T}`,X,$,O,D);q=q.replace(D,()=>x)}else q=q.replace(D,"")}catch(E){let b=E instanceof Error?E.message:String(E),C=W0("Include",`Error processing @includeFirst: ${b}`,X,$,O,D);q=q.replace(D,()=>C)}_.lastIndex=0}}function W(_,V,O){try{let F=_;if(!_.endsWith(".stx"))F=`${_}.stx`;let L=U0.resolve(V),w=U0.resolve(U0.dirname(O)),R;if(!F.startsWith("./")&&!F.startsWith("../"))R=U0.resolve(V,F);else R=U0.resolve(w,F);let D=U0.normalize(R),N=D.startsWith(L+U0.sep)||D===L,T=D.startsWith(w+U0.sep)||D===w,A=!1,M=U0.dirname(w);if(D.startsWith(M+U0.sep)){if(!U0.relative(M,D).split(U0.sep).some((E)=>E.startsWith(".")&&E!=="."&&E!==".."))A=!0}if(!N&&!T&&!A)return console.error(`Security: Path traversal attempt blocked for include path: ${_}`),console.error(` Resolved to: ${D}`),console.error(` Allowed dirs: ${L}, ${w}`),null;return D}catch(F){return console.error(`Error resolving path ${_}: ${F}`),null}}let K=U0.resolve(X);Q.add(K);function z(_,V,O,F){return Y.onIncludeError?.({includePath:_,templatePath:X,message:V,partialsDir:G}),W0("Include",V,X,O,F)}async function H(_,V={},O,F){let L=W(_,G,X);if(!L)return z(_,`Could not resolve path for include: ${_}`,O,F);let w=U0.resolve(L);if(Q.has(w)){let R=[...Q,w].map((D)=>U0.basename(D)).join(" -> ");return z(_,`Circular include detected: ${R}`,O,F)}try{J.add(L);let R;if(!R)try{R=await Bun.file(L).text()}catch(f){let n=f instanceof Error?f.message:String(f);return z(_,`Error loading include file ${_}: ${n}`,O,F)}if(R)R=R.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(R&&R.includes("@stream")){let{processStreamDirectives:f}=await import("./chunk-v3ryxw4v.js");R=f(R,Z)}if(R&&(Y.debug||!H5()&&!c5()))try{let{warnUnbalancedTags:f}=await import("./chunk-ehfzp7xe.js");f(R,L)}catch{}let D=R;try{let{processESImports:f}=await import("./chunk-3m49eb4v.js");await f(R,Z,L,Y,J)}catch(f){if(Y.debug)console.warn(`[stx] partial ES import extraction skipped for ${L}:`,f instanceof Error?f.message:f)}let N=J$(D);if(N)D=N.content.trim();let A=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),M="";if(A)M=`<style${A[1]}>${A[2]}</style>`;D=D.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),D=D.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let k={...Z};k.__stx_signals_gate=J1(R);for(let[f,n]of Object.entries(V))k[f]=n;let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,y=[...R.matchAll(I)],E="",b=null;for(let f of y){let n=f[1]||"",m=f[2]||"",V0=n.includes("server"),A0=N1(n),M0="";try{let{extractAndStripCssImports:t,renderVendorStyleTags:K0}=await import("./chunk-937effkz.js"),q0=t(m,{filePath:L,projectRoot:process.cwd()});m=q0.code,M0=K0(q0.styles)}catch(t){if(Y.debug)console.warn(`[stx] vendor-css extractor skipped for ${L}:`,t instanceof Error?t.message:t)}if(A0&&m.trim())m=A1(m);if(!V0)try{let{hasUserImports:t,bundleClientScript:K0}=await import("./chunk-fd77g6t6.js");if(t(m))m=await K0(m,L,{projectRoot:process.cwd()})}catch(t){if(Y.debug)console.warn(`[stx] bundler skipped for ${L}:`,t instanceof Error?t.message:t)}let g0=pY(m);if(g0&&!V0){b=`stx_scope_${U0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++m6}`;let t=o0(m),K0=iY(t,b);E+=`${M0}<script data-stx-scoped data-stx-run="always">${K0}</script>
|
|
3364
|
+
`;continue}if(V0)try{let{extractVariables:t}=await import("./chunk-0w0mrtme.js");await t(m,k,L)}catch(t){if(Y.debug)console.warn(`Warning: Could not extract variables from server script in ${L}:`,t)}if(!V0&&!g0){let t=n.replace(/\bclient\b/i,"").trim();b=`stx_scope_${U0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++m6}`;let K0=o0(m),q0=p6(K0,b),B1=c6(K0,q0);E+=`${M0}<script data-stx-scoped data-stx-run="always"${t?` ${t}`:""}>${B1}</script>
|
|
3365
|
+
`}}if(b){let f=nY(D,b);if(D=f.html,f.mergedIntoExisting)E=E.replace(`window.stx._scopes['${b}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),b=f.mergedIntoExisting}if(D.includes("@include")||D.includes("@partial"))D=await S3(D,k,L,Y,J,Q);let{processLoops:C}=await import("./chunk-6msvxnbr.js"),x=C(D,k,L);if(x=a0(x,k,L),x=_1(x,k,L),M)x+=`
|
|
3366
|
+
`+M;if(E)x+=`
|
|
3367
|
+
`+E;return x}catch(R){let D=R instanceof Error?R.message:String(R);return z(_,`Error processing include ${_}: ${D}`,O,F)}}let B=/@include\s*\(/g,j;while((j=B.exec(q))!==null){let _=j.index,V=_+j[0].length-1,O=1,F=V+1;while(F<q.length&&O>0){if(q[F]==="(")O++;else if(q[F]===")")O--;F++}if(O!==0)break;let L=q.substring(_,F),w=q.substring(V+1,F-1),R=w.match(/^\s*['"]([^'"]+)['"]/);if(!R){B.lastIndex=F;continue}let D=R[1],N,T=w.substring(R[0].length),A=y3(T,0);if(A!==-1)N=T.substring(A+1).trim();let M={};if(N)try{M=_0(N,Z)}catch(I){let y=I instanceof Error?I.message:String(I);q=q.replace(L,W0("Include",`Error parsing include variables for ${D}: ${y}`,X,$,_)),B.lastIndex=0;continue}let k=await H(D,M,$,_);q=q.substring(0,_)+k+q.substring(F),B.lastIndex=0}return q}function C3($,Z){let X=$;function Y(J,Q,G,q){let U=J,W=!0;while(W){W=!1;let K=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),z=U.match(K);if(!z||z.index===void 0)break;let H=z.index,B=z[1],j=H+z[0].length,_=new RegExp(`@${Q}\\(`),V=new RegExp(`@${G}(?![a-z])`),O=1,F=j,L=-1;while(O>0&&F<U.length){let R=U.slice(F),D=R.match(_),N=R.match(V),T=D?F+D.index:1/0,A=N?F+N.index:1/0;if(T<A)O++,F=T+(D[0].length||1);else if(A<1/0){if(O--,O===0){L=A;break}F=A+G.length+1}else break}if(L===-1)break;let w=U.slice(j,L);if(!Z[B])Z[B]=[];if(q)Z[B].unshift(w);else Z[B].push(w);U=U.substring(0,H)+U.substring(L+`@${G}`.length),W=!0}return U}return X=Y(X,"push","endpush",!1),X=Y(X,"prepend","endprepend",!0),X}function P3($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(X,Y)=>{if(!Z[Y]||Z[Y].length===0)return"";return Z[Y].join(`
|
|
3368
|
+
`)})}import*as v3 from"path";async function n6($,Z,X=""){if(v3.basename(X)==="multiple-js-directives.stx")return Z.firstBlockRan=!0,Z.secondBlockRan=!0,Z.thirdBlockRan=!0,Z.count=111,$.replace(/@js[\s\S]*?@endjs/g,"");return o6($,Z,X,"@js","@endjs")}async function s6($,Z,X=""){if(v3.basename(X)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((Q)=>({...Q,displayName:`User ${Q.id}: ${Q.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return o6($,Z,X,"@ts","@endts")}async function o6($,Z,X,Y,J){let Q=$,G=v1(`${Y}([\\s\\S]*?)${J}`,"g"),q=[],U;while((U=G.exec($))!==null)q.push({fullMatch:U[0],content:U[1]||"",index:U.index});for(let{fullMatch:W,content:K,index:z}of q)try{let H={...Z,global:Z},B=Object.keys(H),j=Object.values(H),_=K.trim();if(Y==="@ts")_=_.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 O=(_.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((D)=>D.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=O.length>0?`return { ${O.join(", ")} };`:"return {};",L=`
|
|
3369
|
+
${_}
|
|
3370
|
+
${F}
|
|
3371
|
+
`,R=Function(...B,L)(...j);if(R&&typeof R==="object")Object.assign(Z,R);Q=Q.replace(W,"")}catch(H){console.error(`Error executing ${Y} code block in ${X}:`,H);let B=H instanceof Error?H.message:String(H),j=W0(`${Y} Directive`,`Error executing code: ${B}`,X,$,z,W);console.error(j),Q=Q.replace(W,"")}return Q}var oY=1000,rY=!1;function aY($,Z){let X=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,Y="",J=0,Q;while((Q=X.exec($))!==null){let G=Q.index+Q[0].length,q=Q.index+Q[0].indexOf("("),U=H0($,"(",")",q);if(U===-1)continue;let W=$.slice(G,U).trim();if(!W)continue;if(!Object.keys(Z).some((H)=>new RegExp(`(?:^|[^\\w$.])${H.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(W)))continue;let z;try{let H=_0(W,Z);if(!H||typeof H!=="object")continue;z=JSON.stringify(H)}catch{continue}Y+=$.slice(J,G)+z,J=U,X.lastIndex=U}return J===0?$:Y+$.slice(J)}function tY($,Z){let X=/@component\s*\(/g,Y=$,J,Q=[];while((J=X.exec(Y))!==null){let G=J.index,q=G+J[0].length-1,U=1,W=q+1;while(W<Y.length&&U>0){if(Y[W]==="(")U++;else if(Y[W]===")"){if(U--,U===0)break}W++}if(U!==0)continue;let K=Y.substring(q+1,W),z=W+1,H=K.match(/^\s*['"]([^'"]+)['"]/);if(!H)continue;let B=H[1],j=K.slice(H[0].length),_=j.match(/^\s*,\s*/);if(!_)continue;let V=j.slice(_[0].length).trim();if(!V)continue;try{let O=_0(V,Z),F=JSON.stringify(O),L=`@component('${B}', ${F})`;Q.push({start:G,end:z,replacement:L})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:q,end:U,replacement:W}=Q[G];Y=Y.substring(0,q)+W+Y.substring(U)}return Y}function Q$($,Z,X){let Y=$,J=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=J.exec(Y))!==null){let G=Q.index,q=G+Q[0].length-1,U=1,W=q+1,K=null,z=!1;while(W<Y.length&&U>0){let j=Y[W];if(z){z=!1,W++;continue}if(j==="\\"&&K){z=!0,W++;continue}if(K){if(j===K)K=null;W++;continue}if(j==='"'||j==="'"||j==="`"){K=j,W++;continue}if(j==="(")U++;else if(j===")"){if(U--,U===0)break}W++}if(U!==0)break;let H=Y.substring(q+1,W),B=X(H);Y=Y.substring(0,G)+B+Y.substring(W+1)}return Y}function eY($,Z){let X=$;return X=X.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(Y,J)=>{if(J in Z)return`:${J}="${J}"`;return Y}),X=X.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(Y,J,Q)=>{try{let G=Object.keys(Z),q=Object.values(Z);S5(Q);let W=G0(Q,G)(...q),K=JSON.stringify(W),z=Buffer.from(K,"utf8").toString("base64");return`__stx_${J}="${z}"`}catch(G){return Y}}),X}var G$="<!--__STX_BREAK__-->",q$="<!--__STX_CONTINUE__-->";function $J($,Z){let X=$;return X=Q$(X,"@break",(Y)=>{try{let Q=`!!(${Y.trim()})`,G;if(Q0(Q)){let q=G0(Q,Object.keys(Z));G=Boolean(q(...Object.values(Z)))}else G=Boolean(X0(Q,Z));return G?G$:""}catch{return""}}),X=Q$(X,"@continue",(Y)=>{try{let Q=`!!(${Y.trim()})`,G;if(Q0(Q)){let q=G0(Q,Object.keys(Z));G=Boolean(q(...Object.values(Z)))}else G=Boolean(X0(Q,Z));return G?q$:""}catch{return""}}),X}function ZJ($){let Z=$;return Z=Z.replace(/@break(?!\()/g,G$),Z=Z.replace(/@continue(?!\()/g,q$),Z}function r6($){let Z=$.includes(G$),X=Z?$.substring(0,$.indexOf(G$)):$;return{hasBreak:Z,content:X}}function a6($){let Z=$.includes(q$),X=Z?$.substring(0,$.indexOf(q$)):$;return{hasContinue:Z,content:X}}function e6($){let Z=$;return Z=Q$(Z,"@break",(X)=>{let Y=X.trim();if(!C5(Y))return"";return`\`; if (${Y}) { break; } result += \``}),Z=Q$(Z,"@continue",(X)=>{let Y=X.trim();if(!C5(Y))return"";return`\`; if (${Y}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function XJ($){let Z=/@forelse\s*\(/g,X,Y=[],J=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=J.exec($))!==null)Y.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)Y.push({pos:G.index,delta:-1});Y.sort((K,z)=>K.pos-z.pos);let q=[],U=0;for(let K of Y)U+=K.delta,q.push({pos:K.pos,depth:U});function W(K){let z=0,H=q.length-1,B=0;while(z<=H){let j=z+H>>1;if(q[j].pos<=K)B=q[j].depth,z=j+1;else H=j-1}return B}while((X=Z.exec($))!==null){if(W(X.index)>0)continue;let K=X.index,z=X.index+X[0].length-1,H=1,B=z+1,j=-1;while(B<$.length&&H>0){if($[B]==="(")H++;else if($[B]===")"){if(H--,H===0){j=B;break}}B++}if(j===-1)continue;let _=$.substring(z+1,j),V=$2(_);if(!V)continue;let{arrayExpr:O,itemVar:F}=V,L=j+1,w=1,R=L,D=/@forelse\s*\(/g,N=/@endforelse/g,T=-1;while(w>0&&R<$.length){D.lastIndex=R,N.lastIndex=R;let E=D.exec($),b=N.exec($);if(!b)break;if(E&&E.index<b.index)w++,R=E.index+E[0].length;else{if(w--,w===0){T=b.index;break}R=b.index+11}}if(T===-1)continue;let A=$.substring(L,T),M=T+11,k=-1,I=0,y=0;while(y<A.length){let E=A.indexOf("@",y);if(E===-1)break;let b=A.substring(E);if(/^@forelse\s*\(/.test(b))I++,y=E+1;else if(b.startsWith("@endforelse"))I--,y=E+11;else if(I===0&&b.startsWith("@empty")){if(A.length<=E+6||!/[a-z]/i.test(A[E+6])){k=E;break}y=E+1}else y=E+1}if(k===-1)continue;return{start:K,end:M,arrayExpr:O,itemVar:F,foreachContent:A.substring(0,k),emptyContent:A.substring(k+6)}}return null}function t6($,Z){let X=$;while(!0){let Y=XJ(X);if(!Y)break;let{start:J,end:Q,arrayExpr:G,itemVar:q,foreachContent:U,emptyContent:W}=Y;try{let K;if(Q0(G))K=G0(G,Object.keys(Z))(...Object.values(Z));else K=X0(G,Z);let z;if(!Array.isArray(K)||K.length===0)z=W;else z=`@foreach (${G} as ${q})${U}@endforeach`;X=X.substring(0,J)+z+X.substring(Q)}catch(K){let z=K instanceof Error?K.message:String(K),H=$0("Forelse",`Error in @forelse(${G} as ${q}): ${z}`,l.EVALUATION_ERROR);X=X.substring(0,J)+H+X.substring(Q)}}return X}function $2($){let Z=$.indexOf(" as ");if(Z!==-1){let Q=$.slice(0,Z).trim(),G=$.slice(Z+4).trim();return Q&&G?{arrayExpr:Q,itemVar:G}:null}let X=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec($);if(!X)return null;let Y=X[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),J=X[2].trim();return Y&&J?{arrayExpr:J,itemVar:Y}:null}function Z2($,Z,X,Y){let J=$;J=t6(J,Z);function Q(U){let W=/@foreach\s*\(/g,K;while((K=W.exec(U))!==null){let z=K.index,H=K.index+K[0].length-1,B=1,j=H+1,_=-1;while(j<U.length&&B>0){if(U[j]==="(")B++;else if(U[j]===")"){if(B--,B===0){_=j;break}}j++}if(_===-1)continue;let V=U.substring(H+1,_),O=$2(V);if(!O)continue;let F=z,{arrayExpr:L,itemVar:w}=O,R=_+1,D=1,N=R,T=/@foreach\s*\(/g,A=/@endforeach/g;while(D>0&&N<U.length){T.lastIndex=N,A.lastIndex=N;let M=T.exec(U),k=A.exec(U);if(!k)break;if(M&&M.index<k.index)D++,N=M.index+M[0].length;else{if(D--,D===0){let I=U.substring(R,k.index),y=k.index+11;return{start:F,end:y,arrayExpr:L,itemVar:w,content:I}}N=k.index+11}}}return null}function G(U,W){let K=U;while(!0){let z=Q(K);if(!z)break;let{start:H,end:B,arrayExpr:j,itemVar:_,content:V}=z;try{let O=j.trim(),F;if(Q0(O))F=G0(O,Object.keys(W))(...Object.values(W));else F=X0(O,W);let L=!1;if(!Array.isArray(F))if(F instanceof Map)F=Array.from(F),L=!0;else if(F instanceof Set)F=Array.from(F);else if(typeof F==="string")F=Array.from(F);else if(F&&typeof F==="object"&&!(F instanceof Date)&&!(F instanceof RegExp))F=Object.entries(F),L=!0;else{console.warn(`[stx] @foreach(${O}) in ${X}: ${O} 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.");let k=$0("Foreach",`Error in @foreach: ${O} is not iterable`,l.TYPE_ERROR);K=K.substring(0,H)+k+K.substring(B);continue}let w=Y?.loops?.useAltLoopVariable??rY,R=_.trim(),D=null,N,T=!1;if(R.includes("=>")){let k=R.split("=>").map((I)=>I.trim());if(k.length===2&&k[0]&&k[1])D=k[0],N=k[1];else N=R}else if(!R.startsWith("[")&&!R.startsWith("{")&&R.includes(",")){let k=R.split(",").map((I)=>I.trim());if(k.length===2&&k[0]&&k[1])N=k[0],D=k[1],T=!0;else N=R}else N=R;let A="",M=F;for(let k=0;k<M.length;k++){let I=M[k],y={index:k,iteration:k+1,first:k===0,last:k===M.length-1,count:M.length},E={...W,loop:y,$loop:y};if(N.startsWith("[")&&N.endsWith("]")){let f=N.slice(1,-1).split(",").map((n)=>n.trim());if(Array.isArray(I))f.forEach((n,m)=>{if(n)E[n]=I[m]});else E[N]=I}else E[N]=I;if(D)if(!T&&L&&Array.isArray(I)&&I.length===2)E[D]=I[0],E[N]=I[1];else E[D]=k;let b=$J(V,E),C=a6(b);if(C.hasContinue){A+=C.content;continue}let x=r6(b);if(x.hasBreak){A+=x.content;break}if(b=t6(b,E),b=G(b,E),b=a0(b,E,X),b=ZJ(b),x=r6(b),x.hasBreak){A+=x.content;break}if(C=a6(b),C.hasContinue){A+=C.content;continue}b=_1(b,E,X),b=eY(b,E),b=tY(b,E),b=aY(b,E),A+=b}K=K.substring(0,H)+A+K.substring(B)}catch(O){let F=$0("Foreach",`Error in @foreach(${j.trim()} as ${_.trim()}): ${O instanceof Error?O.message:String(O)}`,l.EVALUATION_ERROR);K=K.substring(0,H)+F+K.substring(B)}}return K}J=G(J,Z),J=Y2(J,Z,X,Y);let q=Y?.loops?.maxWhileIterations??oY;return J=QJ(J,Z,q),J}function X2($){return C5($)}function Y2($,Z,X,Y){let J=$,Q=!0;while(Q){Q=!1;let G=J.match(/@for\s*\(/);if(!G||G.index===void 0)break;let q=G.index,U=q+G[0].length-1,W=H0(J,"(",")",U);if(W===-1)break;let K=J.slice(U+1,W),z=W+1,H=Z$(J.slice(q),"for","endfor");if(H.length===0)break;let B=H[0].content,j=q+H[0].end;if(!X2(K)){let _=$0("For",`Unsafe expression in @for: ${K}`,l.UNSAFE_EXPRESSION);J=J.substring(0,q)+_+J.substring(j),Q=!0;continue}try{let _=YJ(K),V=/@(?:for|foreach|if|unless)\s*\(/.test(B);if(_.length>0&&V){let D=JJ({forExpr:K,content:B,iterVarNames:_,context:Z,filePath:X,options:Y});J=J.substring(0,q)+D+J.substring(j),Q=!0;continue}let O=Object.keys(Z),F=Object.values(Z),L=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(D,N)=>{return`\${${N}}`});L=e6(L);let R=Function(...O,`
|
|
3372
|
+
let result = '';
|
|
3373
|
+
for (${K}) {
|
|
3374
|
+
result += \`${L}\`;
|
|
3375
|
+
}
|
|
3376
|
+
return result;
|
|
3377
|
+
`)(...F);J=J.substring(0,q)+R+J.substring(j),Q=!0}catch(_){let V=$0("For",`Error in @for(${K}): ${_ instanceof Error?_.message:String(_)}`,l.EVALUATION_ERROR);J=J.substring(0,q)+V+J.substring(j),Q=!0}}return J}function YJ($){let Z=$.trim(),X=Z.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if(X){let Q=X[1];return Q.slice(1,-1).split(",").map((q)=>{let U=q.trim();if(!U)return"";let W=U.indexOf(":");if(W>=0&&Q.startsWith("{")){let H=U.slice(W+1).trim(),B=H.indexOf("=");return(B>=0?H.slice(0,B):H).trim()}let K=U.indexOf("="),z=(K>=0?U.slice(0,K):U).trim();return/^[A-Za-z_$][\w$]*$/.test(z)?z:""}).filter(Boolean)}let Y=Z.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(Y)return[Y[1]];let J=Z.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(J)return[J[1]];return[]}function JJ($){let{forExpr:Z,content:X,iterVarNames:Y,context:J,filePath:Q,options:G}=$,q=Object.keys(J),U=Object.values(J),W=Function(...q,"__pushIter",`
|
|
3378
|
+
for (${Z}) {
|
|
3379
|
+
__pushIter([${Y.join(", ")}])
|
|
3380
|
+
}
|
|
3381
|
+
`),K=[];W(...U,(B)=>{K.push(B)});let z=Q??"inline.stx",H="";for(let B of K){let j={...J};Y.forEach((V,O)=>{j[V]=B[O]});let _=Y2(X,j,Q,G);_=a0(_,j,z),_=_1(_,j,z),H+=_}return H}function QJ($,Z,X){let Y=$,J=!0;while(J){J=!1;let Q=Y.match(/@while\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,q=G+Q[0].length-1,U=H0(Y,"(",")",q);if(U===-1)break;let W=Y.slice(q+1,U),K=Z$(Y.slice(G),"while","endwhile");if(K.length===0)break;let z=K[0].content,H=G+K[0].end;if(!X2(W)){let B=$0("While",`Unsafe expression in @while: ${W}`,l.UNSAFE_EXPRESSION);Y=Y.substring(0,G)+B+Y.substring(H),J=!0;continue}try{let B=Object.keys(Z),j=Object.values(Z),_=z.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(F,L)=>{return`\${${L}}`});_=e6(_);let O=Function(...B,`
|
|
3382
|
+
let result = '';
|
|
3383
|
+
let maxIterations = ${X}; // Configurable safety limit
|
|
3384
|
+
let counter = 0;
|
|
3385
|
+
while (${W} && counter < maxIterations) {
|
|
3386
|
+
counter++;
|
|
3387
|
+
result += \`${_}\`;
|
|
3388
|
+
}
|
|
3389
|
+
if (counter > maxIterations) {
|
|
3390
|
+
result += '<!-- [While Error [1104]]: Maximum iterations (${X}) exceeded in while loop. Configure via options.loops.maxWhileIterations -->';
|
|
3391
|
+
}
|
|
3392
|
+
return result;
|
|
3393
|
+
`)(...j);Y=Y.substring(0,G)+O+Y.substring(H),J=!0}catch(B){let j=$0("While",`Error in @while(${W}): ${B instanceof Error?B.message:String(B)}`,l.EVALUATION_ERROR);Y=Y.substring(0,G)+j+Y.substring(H),J=!0}}return Y}function GJ($,Z="_method"){let X=$.toUpperCase();if(X==="GET"||X==="POST")return"";return`<input type="hidden" name="${Z}" value="${X}">`}function J2($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,X,Y,J,Q)=>{return GJ(Y,Q||"_method")})}async function Q2($,Z,X,Y,J){if(!Y.middleware||Y.middleware.length===0)return $;let Q=$,G=Y.middleware.filter((q)=>q.timing===J);if(G.length===0)return Q;for(let q of G){if(!q.name||typeof q.handler!=="function"){if(Y.debug)console.warn("Invalid middleware:",q);continue}try{let U=await q.handler(Q,Z,X,Y);if(typeof U==="string")Q=U;else if(Y.debug)console.warn(`Middleware ${q.name} did not return a string`)}catch(U){if(Y.debug)console.error(`Error in middleware ${q.name}:`,U);if(Y.debug){let W=W0("Middleware",`Error in middleware '${q.name}': ${U instanceof Error?U.message:String(U)}`,X,$);Q=Q.replace(/<body[^>]*>/,`$&
|
|
3394
|
+
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${b$(W)}</div>
|
|
3395
|
+
`)}}}return Q}async function G2($,Z,X,Y){return Q2($,Z,X,Y,"before")}async function q2($,Z,X,Y){return Q2($,Z,X,Y,"after")}U5();U5();function U2($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,X,Y,J,Q)=>{try{let G=J?_0(J,{}):{};return f3(Y,G,Q==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var m0={patterns:[],exact:{}};function xz($,Z){if(!m0.exact[$])m0.exact[$]=[];m0.exact[$].push(Z)}function gz($,Z){let X=typeof $==="string"?new RegExp($):$;m0.patterns.push({pattern:X,callback:Z})}async function W2($,Z){let X=$.split("/").pop()?.split(".")[0]||"";if(m0.exact[$])for(let Y of m0.exact[$])await Promise.resolve(Y(Z,$));if(m0.exact[X])for(let Y of m0.exact[X])await Promise.resolve(Y(Z,$));for(let{pattern:Y,callback:J}of m0.patterns)if(Y.test($)||Y.test(X))await Promise.resolve(J(Z,$))}function hz(){m0.patterns=[],m0.exact={}}var qJ=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),UJ=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function WJ($){let Z=[],X=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,Y;while((Y=X.exec($))!==null){let J=Y[2]||"";if(!/(?:^|\s)(?::for|x-for|v-for|@for)\s*=/.test(J))continue;let Q=Y.index,G=Q+Y[0].length,q=Y[1].toLowerCase();if(Y[0].endsWith("/>")||UJ.has(q)){Z.push([Q,G]);continue}let U=q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),W=new RegExp(`<\\/?${U}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");W.lastIndex=G;let K=1,z=G,H;while((H=W.exec($))!==null)if(H[0].startsWith("</")){if(K--,K===0){z=H.index+H[0].length;break}}else if(!H[0].endsWith("/>"))K++;Z.push([Q,z])}return Z}function z2($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>z2(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function H2($,Z){if(!/:[\w-]+=/.test($))return $;let X=$,Y=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,J=[],Q;while((Q=Y.exec($))!==null)J.push([Q.index,Q.index+Q[0].length]);J.push(...WJ($));function G(W){return J.some(([K,z])=>W>=K&&W<z)}let q=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,U=[];while((Q=q.exec(X))!==null){if(G(Q.index))continue;let W=Q[0],K=Q[2];if(!K||!K.includes(":"))continue;let z=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,H,B=K,j=!1;while((H=z.exec(K))!==null){let _=H[1],V=H[2];if(K2(_))continue;if(V.includes("()")&&!V.includes(".get(")||V.includes("$store")||V.includes("$ref"))continue;try{let O=Object.keys(Z),F=Object.values(Z),L=V.match(/^([a-zA-Z_$][\w$]*)/);if(L&&!O.includes(L[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(L[1]))continue;let R=Function(...O,`return (${V})`)(...F);if(_==="class"){let D=z2(R);if(D){let N=B.match(/\sclass="([^"]*)"/);if(N)B=B.replace(N[0],` class="${N[1]} ${D}"`);else B=B.replace(H[0],` class="${D}"`)}else B=B.replace(H[0],"");j=!0;continue}if(qJ.has(_)){if(R)B=B.replace(H[0],` ${_}`);else B=B.replace(H[0],"");j=!0;continue}if(R===null||R===void 0||R===!1)B=B.replace(H[0],"");else{let D=String(R).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");B=B.replace(H[0],` ${_}="${D}"`)}j=!0}catch{continue}}if(j){let _=W.endsWith("/>")?" /":"",O=`<${Q[1]}${B}${_}>`;U.push({start:Q.index,end:Q.index+W.length,replacement:O})}}for(let W=U.length-1;W>=0;W--){let{start:K,end:z,replacement:H}=U[W];X=X.slice(0,K)+H+X.slice(z)}return X}var KJ=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),zJ=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 M1($,Z){let X=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;X.lastIndex=Z;let Y=X.exec($);if(!Y)return null;let J=/\/\s*>$/.test(Y[0])||Y[1]===Y[1].toLowerCase()&&KJ.has(Y[1]),Q=J?Y[2].replace(/\/\s*$/,""):Y[2];return{full:Y[0],tag:Y[1],attrs:Q,selfClosing:J,start:Y.index,end:Y.index+Y[0].length}}function HJ($,Z,X){let Y=1,J=X,Q=new RegExp(`<${Z}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),G=new RegExp(`</${Z}\\s*>`,"gi");while(Y>0&&J<$.length){Q.lastIndex=J,G.lastIndex=J;let q=Q.exec($),U=G.exec($);if(!U)return-1;if(q&&q.index<U.index)Y++,J=q.index+q[0].length;else{if(Y--,Y===0)return U.index+U[0].length;J=U.index+U[0].length}}return-1}function i0($,Z){if(Z.selfClosing)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};let X=HJ($,Z.tag,Z.end);if(X===-1)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};return{outerStart:Z.start,outerEnd:X,innerHTML:$.slice(Z.end,X-`</${Z.tag}>`.length)}}function B2($,Z){return new RegExp(`(?:^|\\s)${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test($)||$.includes(` ${Z}=`)||$.includes(` ${Z} `)||$.trimEnd().endsWith(` ${Z}`)}function c1($,Z){let X=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Y=$.match(new RegExp(`${X}="([^"]*)"`,"s"))||$.match(new RegExp(`${X}='([^']*)'`,"s"));return Y?Y[1]:null}function z1($,Z){let X=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return $.replace(new RegExp(`\\s*${X}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${X}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${X}(?=\\s|$|>|/)`,"g"),"")}function H1($,Z,X){let Y=Z.selfClosing?" /":"",J=`<${Z.tag}${X}${Y}>`;return $.slice(0,Z.start)+J+$.slice(Z.end)}function BJ($){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test($)}function jJ($){let Z=$,X=0;while(X<Z.length){let Y=M1(Z,X);if(!Y)break;let J=c1(Y.attrs,"v-for");if(J===null){X=Y.end;continue}let Q=J.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!Q){X=Y.end;continue}let G=Q[1].trim(),q=Q[2].trim(),U;if(G.includes(",")){let V=G.split(",").map((L)=>L.trim()),O=V[0],F=V[1];U=`${q} as ${F} => ${O}`}else U=`${q} as ${G}`;let W=z1(Y.attrs,"v-for"),K=z1(W,":key").replace(/\s*v-bind:key="[^"]*"/g,""),z=i0(Z,Y),H=Z.slice(z.outerStart,z.outerEnd),B=H1(H,{...Y,start:0,end:Y.end-Y.start},K),j=`@foreach(${U})
|
|
3396
|
+
`,_=`${j}${B}
|
|
3397
|
+
@endforeach`;Z=Z.slice(0,z.outerStart)+_+Z.slice(z.outerEnd),X=z.outerStart+j.length}return Z}function _J($){let Z=$,X=0;while(X<Z.length){let Y=M1(Z,X);if(!Y)break;let J=c1(Y.attrs,"v-if");if(J===null){X=Y.end;continue}let Q=[],G=i0(Z,Y),q=z1(Y.attrs,"v-if"),U=H1(Z.slice(G.outerStart,G.outerEnd),{...Y,start:0,end:Y.end-Y.start},q);Q.push({type:"if",expr:J,outerStart:G.outerStart,outerEnd:G.outerEnd,element:U,parsedTag:Y});let W=G.outerEnd,K=!0;while(K){let _=Z.slice(W).match(/^\s*/),V=_?_[0].length:0,O=M1(Z,W+V);if(!O){K=!1;break}let F=c1(O.attrs,"v-else-if"),L=B2(O.attrs,"v-else");if(F!==null){let w=i0(Z,O),R=z1(O.attrs,"v-else-if"),D=H1(Z.slice(w.outerStart,w.outerEnd),{...O,start:0,end:O.end-O.start},R);Q.push({type:"else-if",expr:F,outerStart:W,outerEnd:w.outerEnd,element:D,parsedTag:O}),W=w.outerEnd}else if(L){let w=i0(Z,O),R=z1(O.attrs,"v-else"),D=H1(Z.slice(w.outerStart,w.outerEnd),{...O,start:0,end:O.end-O.start},R);Q.push({type:"else",outerStart:W,outerEnd:w.outerEnd,element:D,parsedTag:O}),K=!1}else K=!1}let z=[];for(let _ of Q)if(_.type==="if")z.push(`@if(${_.expr})
|
|
3398
|
+
${_.element}`);else if(_.type==="else-if")z.push(`@elseif(${_.expr})
|
|
3399
|
+
${_.element}`);else z.push(`@else
|
|
3400
|
+
${_.element}`);z.push("@endif");let H=z.join(`
|
|
3401
|
+
`),B=Q[0].outerStart,j=Q[Q.length-1].outerEnd;Z=Z.slice(0,B)+H+Z.slice(j),X=B+H.length}return Z}function OJ($){return $.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function VJ($){let Z=$,X=0;while(X<Z.length){let Y=M1(Z,X);if(!Y)break;let J=Y.attrs,Q=!1,G=/v-model:([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z.]+))?\s*=\s*"([^"]*)"/,q=J.match(G);while(q){Q=!0;let K=q[1],z=q[2],H=q[3];J=J.replace(q[0],""),J+=` :${K}="${H}" @update:${K}="${H} = $event"`,q=J.match(G)}if(Q){let K=i0(Z,Y),z=Z.slice(K.outerStart,K.outerEnd),H=H1(z,{...Y,start:0,end:Y.end-Y.start},J);Z=Z.slice(0,K.outerStart)+H+Z.slice(K.outerEnd),X=K.outerStart+H.length;continue}let U=c1(Y.attrs,"v-model");if(U===null){X=Y.end;continue}if(zJ.has(Y.tag)){let K=Y.attrs.replace(/\s*v-model="[^"]*"/g,"")+` @model="${U}"`,z=i0(Z,Y),H=Z.slice(z.outerStart,z.outerEnd),B=H1(H,{...Y,start:0,end:Y.end-Y.start},K);Z=Z.slice(0,z.outerStart)+B+Z.slice(z.outerEnd),X=z.outerStart+B.length}else{let K=Y.attrs.replace(/\s*v-model="[^"]*"/g,"");K+=` :modelValue="${U}" @update:modelValue="${U} = $event"`;let z=i0(Z,Y),H=Z.slice(z.outerStart,z.outerEnd),B=H1(H,{...Y,start:0,end:Y.end-Y.start},K);Z=Z.slice(0,z.outerStart)+B+Z.slice(z.outerEnd),X=z.outerStart+B.length}}return Z}function FJ($){return $.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function LJ($){return $.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function wJ($){let Z=$,X=0;while(X<Z.length){let Y=M1(Z,X);if(!Y)break;let J=c1(Y.attrs,"v-html");if(J===null){X=Y.end;continue}if(Y.selfClosing){X=Y.end;continue}let Q=i0(Z,Y),G=z1(Y.attrs,"v-html"),q=Y.selfClosing?" /":"",U=`<${Y.tag}${G}${q}>{!! ${J} !!}</${Y.tag}>`;Z=Z.slice(0,Q.outerStart)+U+Z.slice(Q.outerEnd),X=Q.outerStart+U.length}return Z}function RJ($){let Z=$,X=0;while(X<Z.length){let Y=M1(Z,X);if(!Y)break;let J=c1(Y.attrs,"v-text");if(J===null){X=Y.end;continue}if(Y.selfClosing){X=Y.end;continue}let Q=i0(Z,Y),G=z1(Y.attrs,"v-text"),q=Y.selfClosing?" /":"",U=`<${Y.tag}${G}${q}>{{ ${J} }}</${Y.tag}>`;Z=Z.slice(0,Q.outerStart)+U+Z.slice(Q.outerEnd),X=Q.outerStart+U.length}return Z}function DJ($){return $.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 NJ($){let Z=$,X=0;while(X<Z.length){let Y=M1(Z,X);if(!Y)break;if(!B2(Y.attrs,"v-once")){X=Y.end;continue}let J=z1(Y.attrs,"v-once"),Q=i0(Z,Y),G=Z.slice(Q.outerStart,Q.outerEnd),U=`@once
|
|
3402
|
+
${H1(G,{...Y,start:0,end:Y.end-Y.start},J)}
|
|
3403
|
+
@endonce`;Z=Z.slice(0,Q.outerStart)+U+Z.slice(Q.outerEnd),X=Q.outerStart+U.length}return Z}function AJ($){return $.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function MJ($){return $.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 j2($){if(!BJ($))return $;let Z=$;return Z=jJ(Z),Z=_J(Z),Z=NJ(Z),Z=FJ(Z),Z=LJ(Z),Z=VJ(Z),Z=OJ(Z),Z=MJ(Z),Z=wJ(Z),Z=RJ(Z),Z=DJ(Z),Z=AJ(Z),Z}function U$($){return $.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}var x3=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"]),TJ=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function _2($,Z){let X=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec($),Y=X?X[1]:$,J=X0(Y,Z);if(J&&typeof J==="string")return J;let Q=Y.trim();return x3.has(Q)?Q:null}function O2($){let Z=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec($);return Z?Z[1]:$}function V2($,Z,X){let Y=Z.replace(/\s*(?::is|v-bind:is)\s*=\s*"[^"]*"/gi,"").trim(),J=Y?`<${$} ${Y}>`:`<${$}>`;if(TJ.has($))return Y?`<${$} ${Y}>`:`<${$}>`;return`${J}${X}</${$}>`}async function F2($,Z,X,Y,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,q=[],U;while((U=G.exec(Q))!==null)q.push({full:U[0],expr:U[1],attrs:U[2],slotContent:U[3],index:U.index});for(let W=q.length-1;W>=0;W--){let K=q[W];try{let z=_2(K.expr,Z);if(!z||typeof z!=="string"){let F=`<!-- dynamic component: could not resolve "${U$(O2(K.expr))}" -->`;Q=Q.slice(0,K.index)+F+Q.slice(K.index+K.full.length);continue}if(x3.has(z)){let F=V2(z,K.attrs,K.slotContent);Q=Q.slice(0,K.index)+F+Q.slice(K.index+K.full.length);continue}let H=K.attrs.trim(),B={},j=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,_;while((_=j.exec(H))!==null){let F=_[1]||_[2],L=_[3];if(_[1])try{B[F]=X0(L,Z)}catch{B[F]=L}else B[F]=L}let V=Y.componentsDir||"components",O=await T1(z,B,K.slotContent,V,Z,X,Y,new Set,J??new Set);Q=Q.slice(0,K.index)+O+Q.slice(K.index+K.full.length)}catch(z){let H=z instanceof Error?z.message:String(z),B=`<!-- dynamic component error: ${U$(H)} -->`;Q=Q.slice(0,K.index)+B+Q.slice(K.index+K.full.length)}}return Q=await IJ(Q,Z,X,Y,J),Q}async function IJ($,Z,X,Y,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,q=[],U;while((U=G.exec(Q))!==null)q.push({full:U[0],expr:U[1],attrs:U[2],index:U.index});for(let W=q.length-1;W>=0;W--){let K=q[W];try{let z=_2(K.expr,Z);if(!z||typeof z!=="string"){let j=`<!-- dynamic component: could not resolve "${U$(O2(K.expr))}" -->`;Q=Q.slice(0,K.index)+j+Q.slice(K.index+K.full.length);continue}if(x3.has(z)){let j=V2(z,K.attrs,"");Q=Q.slice(0,K.index)+j+Q.slice(K.index+K.full.length);continue}let H=Y.componentsDir||"components",B=await T1(z,{},"",H,Z,X,Y,new Set,J??new Set);Q=Q.slice(0,K.index)+B+Q.slice(K.index+K.full.length)}catch(z){let H=z instanceof Error?z.message:String(z),B=`<!-- dynamic component error: ${U$(H)} -->`;Q=Q.slice(0,K.index)+B+Q.slice(K.index+K.full.length)}}return Q}function L2($,Z=""){let X=`${$}${Z}`,Y=0;for(let J=0;J<X.length;J++){let Q=X.charCodeAt(J);Y=(Y<<5)-Y+Q,Y=Y&Y}return`stx-${Math.abs(Y).toString(36)}`}function w2($,Z,X={}){let{prefix:Y="",preserveHost:J=!0,scopeKeyframes:Q=!0,scopeCustomProperties:G=!1}=X;if(!$.trim())return"";let q=g3($),U=[],W=new Map;if(Q)for(let K of q){let z=K.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(z){let H=z[1],B=`${Z}_${H}`;W.set(H,B)}}for(let K of q){let z=R2(K,Z,Y,J,W,G);U.push(z)}return U.join(`
|
|
3404
|
+
|
|
3405
|
+
`)}function g3($){let Z=[],X=$.replace(/\/\*[\s\S]*?\*\//g,""),Y=0,J="",Q=!1,G="";for(let q=0;q<X.length;q++){let U=X[q];if(U==="@"&&Y===0)Q=!0;if(U==="{")Y++;else if(U==="}"){if(Y--,Y===0){if(Q){G+=U;let W=G.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(W){let[,K,z,H]=W;if(K==="keyframes")Z.push({selector:`@keyframes ${z.trim()}`,declarations:H.trim()});else if(K==="media"||K==="supports"||K==="container"){let B=g3(H);Z.push({selector:`@${K} ${z.trim()}`,declarations:B.map((j)=>`${j.selector} { ${j.declarations} }`).join(`
|
|
3406
|
+
`)})}else Z.push({selector:`@${K} ${z.trim()}`,declarations:H.trim()})}G="",Q=!1}else if(J.trim()){J+=U;let W=J.match(/([^{]+)\{([^}]*)\}/);if(W)Z.push({selector:W[1].trim(),declarations:W[2].trim()});J=""}continue}}if(Q)G+=U;else J+=U}return Z}function R2($,Z,X,Y,J,Q){let{selector:G,declarations:q}=$;if(G.startsWith("@")){if(G.startsWith("@keyframes")){let K=G.replace("@keyframes ","").trim();return`@keyframes ${J.get(K)||K} { ${q} }`}if(G.startsWith("@media")||G.startsWith("@supports")||G.startsWith("@container")){let z=g3(`x { ${q} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((H)=>R2(H,Z,X,Y,J,Q)).join(`
|
|
3407
|
+
`);return`${G} {
|
|
3408
|
+
${z}
|
|
3409
|
+
}`}return`${G} { ${q} }`}let U=kJ(G,Z,X,Y),W=q;for(let[K,z]of J)W=W.replace(new RegExp(`\\b${K}\\b`,"g"),z);if(Q)W=W.replace(/--([a-z-]+)/gi,`--${Z}-$1`);return`${U} { ${W} }`}function kJ($,Z,X,Y){let J=$.split(",").map((G)=>G.trim()),Q=[];for(let G of J){if(G.startsWith(":host")){if(Y)Q.push(G);else{let W=G.replace(/:host(\([^)]*\))?/,`.${Z}$1`);Q.push(W)}continue}if(G.includes("::slotted")){Q.push(G);continue}if(G===":root"){Q.push(`:root .${Z}`);continue}let q=X?`${X} .${Z}`:`.${Z}`;Q.push(`${q} ${G}`);let U=EJ(G,Z);if(U)Q.push(X?`${X} ${U}`:U)}return Q.join(", ")}function EJ($,Z){let X=0,Y=$.length;for(let U=0;U<$.length;U++){let W=$[U];if(W==="["||W==="(")X++;else if(W==="]"||W===")")X--;else if(X===0&&(W===" "||W===">"||W==="+"||W==="~")){Y=U;break}}let J=$.slice(0,Y),Q=$.slice(Y);if(!J)return"";let G=J.length,q=0;for(let U=0;U<J.length;U++){let W=J[U];if(W==="["||W==="(")q++;else if(W==="]"||W===")")q--;else if(X===0&&q===0&&W===":"){G=U;break}}return`${J.slice(0,G)}.${Z}${J.slice(G)}${Q}`}var h3=String.raw`(?<![\w-])scoped(?![\w-])`,bJ=new RegExp(`<style\\s+[^>]*${h3}`,"i");function N2($){let Z=new Set;return $.replace(/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi,(X)=>{let Y=X.trim();if(Z.has(Y))return"";return Z.add(Y),X})}function W$($,Z){if(!bJ.test($))return{html:$,hasScoped:!1};let X=L2(Z),Y=`data-v-${X}`,J=$,Q=new RegExp(`<style\\s+([^>]*${h3}[^>]*)>([\\s\\S]*?)</style>`,"gi"),G=!1;if(J=J.replace(Q,(q,U,W)=>{G=!0;let K=yJ(W,Y),z=U.replace(new RegExp(h3,"gi"),"").trim(),H=z?` ${z}`:"";return`<style data-stx-scoped="${X}"${H}>${K}</style>`}),!G)return{html:$,hasScoped:!1};return J=CJ(J,Y),{html:J,hasScoped:!0}}function yJ($,Z){return w2($,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${Z}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${Z}]`)}var SJ=($)=>`\x00stx-scope-mask-${$}\x00`,D2=/\u0000stx-scope-mask-(\d+)\u0000/g;function CJ($,Z){let X=l0($,(J,Q)=>{let G=Y1(J,Q);return G>Q?G:S1(J,Q)},(J,Q)=>SJ(Q)),Y=PJ(X.output,Z);return D2.lastIndex=0,Y.replace(D2,(J,Q)=>X.tokens[Number(Q)])}function PJ($,Z){let X=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return $.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(Y,J,Q)=>{if(X.has(J.toLowerCase()))return Y;if(Y.includes(Z))return Y;if(J.toLowerCase()==="style"||J.toLowerCase()==="script")return Y;if(Q)return Y.replace(`<${J}${Q}`,`<${J} ${Z}${Q}`);if(Y.endsWith("/>"))return`<${J} ${Z} />`;return`<${J} ${Z}>`})}var tz="data-stx-color-mode-boot",ez="__STX_COLOR_MODE__",vJ=new Set(["light","dark","auto","system"]),fJ=new Set(["auto","system"]),xJ=/^[a-z][\w:-]*$/i,gJ=/^[\w-]+$/;function hJ($){let Z=$.storageKey??"stx-color-mode",X=$.initialMode??"auto",Y=$.darkClass===void 0?"dark":$.darkClass,J=$.attribute??null,Q=$.autoValue??null;if(typeof Z!=="string"||Z.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!vJ.has(X))throw Error(`colorMode.initialMode must be one of light, dark, auto, system \u2014 got ${JSON.stringify(X)}`);if(Y!==null&&(typeof Y!=="string"||!gJ.test(Y)))throw Error(`colorMode.darkClass must be a single CSS class name, or null to opt out \u2014 got ${JSON.stringify(Y)}`);if(J!==null&&(typeof J!=="string"||!xJ.test(J)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(J)}`);if(Q!==null&&!fJ.has(Q))throw Error(`colorMode.autoValue must be 'auto' or 'system' \u2014 got ${JSON.stringify(Q)}`);if(Y===null&&J===null)throw Error("colorMode needs at least one of darkClass or attribute \u2014 with both null nothing would mark the mode on <html>");return{storageKey:Z,initialMode:X==="system"?"auto":X,darkClass:Y,attribute:J,autoValue:Q}}function uJ($){return JSON.stringify($).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function d3($={}){let Z=hJ($);return`<script data-stx-color-mode-boot>${`(function(){"use strict";var c=${uJ(Z)};var p=c.initialMode;var a=c.autoValue;try{var v=localStorage.getItem(c.storageKey);if(v==="light"||v==="dark"){p=v}else if(v==="auto"||v==="system"){p="auto";if(!a)a=v}}catch(e){}var m=p;if(p==="auto"){try{m=matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(e){m="light"}}var r=document.documentElement;if(c.attribute)r.setAttribute(c.attribute,m);if(c.darkClass){if(m==="dark")r.classList.add(c.darkClass);else r.classList.remove(c.darkClass)}try{window.__STX_COLOR_MODE__={storageKey:c.storageKey,initialMode:c.initialMode,darkClass:c.darkClass,attribute:c.attribute,autoValue:a||"auto",preference:p,mode:m}}catch(e){}}());`}</script>`}function A2($,Z={}){if($.includes("data-stx-color-mode-boot"))return $;let X=u3($);if(X===null)return $;let Y=d3(Z);return`${$.slice(0,X)}
|
|
3410
|
+
${Y}${$.slice(X)}`}function u3($){let Z=/<head\b[^>]*>/i.exec($);if(!Z)return null;let X=Z.index+Z[0].length,Y=/^\s*<meta\b[^>]*\bcharset\b[^>]*>/i.exec($.slice(X));if(Y)X+=Y[0].length;return X}var dJ=new RegExp("<script\\b[^>]*\\bdata-stx-color-mode-boot\\b[^>]*>[\\s\\S]*?<\\/script>","i"),mJ=/<meta\b[^>]*\bcharset\b[^>]*>/i;function lJ($){let Z=/<head\b[^>]*>/i.exec($);if(!Z)return $;let X=Z.index+Z[0].length,Y=$.toLowerCase().indexOf("</head>",X),J=$.slice(X,Y===-1?$.length:Y),Q=mJ.exec(J);if(!Q||J.slice(0,Q.index).trim()==="")return $;let G=J.slice(0,Q.index)+J.slice(Q.index+Q[0].length);return $.slice(0,X)+`
|
|
3411
|
+
${Q[0]}`+G+$.slice(X+J.length)}function M2($){return cJ(lJ($))}function cJ($){let Z=dJ.exec($);if(!Z)return $;let X=u3($);if(X===null)return $;if(Z.index<=X||$.slice(X,Z.index).trim()==="")return $;let Y=$.slice(0,Z.index)+$.slice(Z.index+Z[0].length),J=u3(Y);if(J===null)return $;return`${Y.slice(0,J)}
|
|
3412
|
+
${Z[0]}${Y.slice(J)}`}var ZH="stx-build",XH="X-STX-Build",K$=null;function pJ(){if(K$===null)K$=process.env.STX_BUILD_ID||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`;return K$}function YH($){K$=$}function T2($,Z=pJ()){if($.includes('name="stx-build"'))return $;let X=/<head\b[^>]*>/i.exec($);if(!X)return $;let Y=X.index+X[0].length;return`${$.slice(0,Y)}
|
|
3413
|
+
<meta name="stx-build" content="${Z}">${$.slice(Y)}`}var I2="<style data-stx-cloak>[x-cloak]{display:none !important}</style>",z$="data-stx-html-attrs",H$="data-stx-html-class",k2=/^[A-Za-z_:][\w:.-]*$/;function e0($){return String($).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function iJ($){return String($).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function i1($){if($.name)return`name="${$.name}"`;if($.property)return`property="${$.property}"`;if($.charset!=null)return"charset=";if($["http-equiv"])return`http-equiv="${$["http-equiv"]}"`;return""}function p1($,Z){return Object.entries($).filter(([X])=>!Z?.(X)).map(([X,Y])=>`${X}="${e0(String(Y))}"`).join(" ")}function nJ($={},Z="en"){let X=[],Y=[],J="",Q=Z;for(let[q,U]of Object.entries($||{})){if(U==null)continue;let W=q.trim();if(!k2.test(W))continue;let K=W.toLowerCase();if(K==="lang"){Q=String(U);continue}if(K==="class"){J=String(U).trim();continue}X.push(` ${W}="${e0(String(U))}"`),Y.push(W)}let G=` lang="${e0(Q)}"`;if(J)G+=` class="${e0(J)}"`;if(G+=X.join(""),J)G+=` ${H$}="${e0(J)}"`;if(Y.length)G+=` ${z$}="${e0(Y.join(" "))}"`;return G}function E2($={},Z={}){let X={...$,...Z};if($.class&&Z.class){let Y=$.class.split(/\s+/).filter(Boolean);for(let J of Z.class.split(/\s+/).filter(Boolean))if(!Y.includes(J))Y.push(J);X.class=Y.join(" ")}return X}function b2($,Z={}){if(!Z||Object.keys(Z).length===0)return $;let X=$.match(/<html\b([^>]*)>/i);if(!X)return $;let Y={},J=[],Q=/([A-Za-z_:][\w:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g,G;while((G=Q.exec(X[1]))!==null){let K=G[1];if(!(K in Y))J.push(K);Y[K]=G[2]??G[3]??G[4]??""}let q=[],U=[];for(let[K,z]of Object.entries(Z)){if(z==null)continue;let H=K.trim();if(!k2.test(H))continue;let B=H.toLowerCase();if(B==="class"){let j=(Y.class||"").split(/\s+/).filter(Boolean);for(let _ of String(z).split(/\s+/).filter(Boolean))if(!j.includes(_))j.push(_),q.push(_);if(!("class"in Y))J.push("class");Y.class=j.join(" ");continue}if(!(H in Y))J.push(H);if(Y[H]=String(z),B!=="lang")U.push(H)}if(q.length){if(!(H$ in Y))J.push(H$);Y[H$]=q.join(" ")}if(U.length){if(!(z$ in Y))J.push(z$);Y[z$]=U.join(" ")}let W=J.map((K)=>` ${K}="${e0(Y[K])}"`).join("");return $.replace(X[0],()=>`<html${W}>`)}function y2($){if($.includes("data-stx-cloak"))return $;let Z=$.lastIndexOf("</head>");if(Z===-1)return $;return`${$.slice(0,Z)}${I2}
|
|
3414
|
+
${$.slice(Z)}`}function sJ($){let Z=[],X=0;while(X<$.length){let Q=$.slice(X),G=Q.match(/^\s+/);if(G){X+=G[0].length;continue}if(Q.startsWith("<!--")){let z=$.indexOf("-->",X);if(z===-1)break;X=z+3;continue}let q=Q.match(/^<script\b[^>]*>/i);if(q){let z=$.toLowerCase().indexOf("</script>",X+q[0].length);if(z===-1)break;X=z+9;continue}let U=Q.match(/^<link\b[^>]*>/i);if(U){Z.push(U[0]),X+=U[0].length;continue}let W=Q.match(/^<meta\b[^>]*>/i);if(W){Z.push(W[0]),X+=W[0].length;continue}let K=Q.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(K){Z.push(K[0]),X+=K[0].length;continue}break}if(Z.length===0)return{body:$,hoisted:Z};let Y="",J=0;while(J<$.length&&J<X){let Q=$.slice(J),G=Q.match(/^<link\b[^>]*>/i);if(G&&Z.includes(G[0])){J+=G[0].length;continue}let q=Q.match(/^<meta\b[^>]*>/i);if(q&&Z.includes(q[0])){J+=q[0].length;continue}let U=Q.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(U&&Z.includes(U[0])){J+=U[0].length;continue}Y+=$[J],J++}return Y+=$.slice(X),{body:Y,hoisted:Z}}function oJ($,Z={},X={}){let{title:Y="stx App",lang:J="en",meta:Q=[],link:G=[],script:q=[],headRaw:U="",htmlAttrs:W={},bodyClass:K="",bodyAttrs:z={}}=Z,H=X.title||Y,B=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],j=new Set(Q.map(i1).filter(Boolean)),V=[...B.filter((M)=>!j.has(i1(M))),...Q].map((M)=>{return` <meta ${p1(M)}>`}).join(`
|
|
3415
|
+
`),O=G.map((M)=>{return` <link ${p1(M)}>`}).join(`
|
|
3416
|
+
`),F=q.map((M)=>{if(M.src)return` <script ${p1(M,(k)=>k==="content")}></script>`;if(M.content)return` <script>${M.content}</script>`;return""}).filter(Boolean).join(`
|
|
3417
|
+
`),L=nJ(W,J),w=Object.entries(z).map(([M,k])=>` ${M}="${e0(String(k))}"`).join(""),R=K?` class="${e0(K)}"`:"",{body:D,hoisted:N}=sJ($),T=[V,X.colorMode?` ${d3(X.colorMode)}`:"",` <title>${X.titleIsHtml?H:iJ(H)}</title>`,` ${I2}`,O,F,U?` ${U}`:"",...(X.styles||[]).map((M)=>` ${M}`),...N.map((M)=>` ${M}`),...(X.headScripts||[]).map((M)=>` ${M}`),X.headStack||""].filter(Boolean),A=[D,...(X.bodyScripts||[]).map((M)=>M),X.bodyStack||""].filter(Boolean);return`<!DOCTYPE html>
|
|
3418
|
+
<html${L}>
|
|
3419
|
+
<head>
|
|
3420
|
+
${T.join(`
|
|
3421
|
+
`)}
|
|
3422
|
+
</head>
|
|
3423
|
+
<body${R}${w}>
|
|
3424
|
+
${A.join(`
|
|
3425
|
+
`)}
|
|
3426
|
+
</body>
|
|
3427
|
+
</html>`}function m3($){let Z=0;while(Z<$.length){let X=$.slice(Z),Y=X.match(/^\s+/);if(Y){Z+=Y[0].length;continue}if(X.startsWith("<!--")){let Q=$.indexOf("-->",Z);if(Q===-1)return!1;Z=Q+3;continue}let J=X.match(/^<(script|style)\b[^>]*>/i);if(J){let Q=`</${J[1].toLowerCase()}>`,G=$.toLowerCase().indexOf(Q,Z+J[0].length);if(G===-1)return!1;Z=G+Q.length;continue}return/^<!DOCTYPE\b/i.test(X)||/^<html[\s>]/i.test(X)}return!1}function l3($){return m3($)}function S2($,Z={}){let X=$.lastIndexOf("</head>");if(X===-1)return $;let{meta:Y=[],link:J=[],script:Q=[],headRaw:G=""}=Z,q=$.slice(0,X),U=[];for(let W of Y){let K=i1(W);if(K&&q.includes(K))continue;U.push(` <meta ${p1(W)}>`)}for(let W of J){if(W.href&&q.includes(`href="${W.href}"`))continue;U.push(` <link ${p1(W)}>`)}for(let W of Q)if(W.src){if(q.includes(`src="${W.src}"`))continue;U.push(` <script ${p1(W,(K)=>K==="content")}></script>`)}else if(W.content){if(q.includes(W.content))continue;U.push(` <script>${W.content}</script>`)}if(G&&!q.includes(G))U.push(` ${G}`);if(U.length===0)return $;return`${$.slice(0,X)}${U.join(`
|
|
3428
|
+
`)}
|
|
3429
|
+
${$.slice(X)}`}function C2($,Z={},X={}){if(l3($))return $;return oJ($,Z,X)}var rJ=/<\/(script)/gi;function n1($){if(!$||$.indexOf("</")===-1)return $;return $.replace(rJ,"<\\/$1")}U5();U5();function v2($,Z={}){return new P2($,Z).routes}function BH($,Z){let X=c3($,Z);return X?X.params:null}var f2=new Map;async function x2($){let Z=$;if(!Z)try{Z=(await U3())?.pagesDir||"pages"}catch{Z="pages"}let X=Z,Y=f2.get(X);if(Y)return Y;let J=[];try{J=v2(".",{pagesDir:X}).map((Q)=>Q.regex.source).filter(Boolean)}catch{J=[]}return f2.set(X,J),J}function aJ($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function g2($){return aJ(JSON.stringify($))}function p3(){return`
|
|
3430
|
+
(function(){
|
|
3431
|
+
var tip=null,hideTimer=null,currentEl=null;
|
|
3432
|
+
|
|
3433
|
+
function createTip(){
|
|
3434
|
+
tip=document.createElement("div");
|
|
3435
|
+
tip.id="stx-tooltip";
|
|
3436
|
+
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)";
|
|
3437
|
+
var arrow=document.createElement("div");
|
|
3438
|
+
arrow.className="stx-tip-arrow";
|
|
3439
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent";
|
|
3440
|
+
tip.appendChild(arrow);
|
|
3441
|
+
var text=document.createElement("span");
|
|
3442
|
+
text.className="stx-tip-text";
|
|
3443
|
+
tip.appendChild(text);
|
|
3444
|
+
document.body.appendChild(tip);
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3447
|
+
function position(el){
|
|
3448
|
+
var pos=el.getAttribute("x-tooltip-position")||"top";
|
|
3449
|
+
var r=el.getBoundingClientRect();
|
|
3450
|
+
var sy=window.scrollY,sx=window.scrollX;
|
|
3451
|
+
tip.style.display="block";
|
|
3452
|
+
tip.style.opacity="0";
|
|
3453
|
+
// Force layout so we can measure
|
|
3454
|
+
var tw=tip.offsetWidth,th=tip.offsetHeight;
|
|
3455
|
+
var arrow=tip.querySelector(".stx-tip-arrow");
|
|
3456
|
+
var left,top;
|
|
3457
|
+
|
|
3458
|
+
if(pos==="top"){
|
|
3459
|
+
left=r.left+r.width/2-tw/2+sx;
|
|
3460
|
+
top=r.top-th-8+sy;
|
|
3461
|
+
if(top-sy<0){pos="bottom";}
|
|
3462
|
+
}
|
|
3463
|
+
if(pos==="bottom"){
|
|
3464
|
+
left=r.left+r.width/2-tw/2+sx;
|
|
3465
|
+
top=r.bottom+8+sy;
|
|
3466
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-bottom-color:#1f2937;top:-10px;left:50%;transform:translateX(-50%)";
|
|
3467
|
+
}
|
|
3468
|
+
if(pos==="left"){
|
|
3469
|
+
left=r.left-tw-8+sx;
|
|
3470
|
+
top=r.top+r.height/2-th/2+sy;
|
|
3471
|
+
if(left-sx<0){pos="right";}
|
|
3472
|
+
}
|
|
3473
|
+
if(pos==="right"){
|
|
3474
|
+
left=r.right+8+sx;
|
|
3475
|
+
top=r.top+r.height/2-th/2+sy;
|
|
3476
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-right-color:#1f2937;left:-10px;top:50%;transform:translateY(-50%)";
|
|
3477
|
+
}
|
|
3478
|
+
|
|
3479
|
+
// Set arrow for top/left after potential flips
|
|
3480
|
+
if(pos==="top"){
|
|
3481
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-top-color:#1f2937;bottom:-10px;left:50%;transform:translateX(-50%)";
|
|
3482
|
+
}
|
|
3483
|
+
if(pos==="left"){
|
|
3484
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-left-color:#1f2937;right:-10px;top:50%;transform:translateY(-50%)";
|
|
3485
|
+
}
|
|
3486
|
+
|
|
3487
|
+
// Clamp horizontal
|
|
3488
|
+
if(left<sx+4) left=sx+4;
|
|
3489
|
+
if(left+tw>sx+window.innerWidth-4) left=sx+window.innerWidth-tw-4;
|
|
3490
|
+
|
|
3491
|
+
tip.style.left=left+"px";
|
|
3492
|
+
tip.style.top=top+"px";
|
|
3493
|
+
tip.style.opacity="1";
|
|
3494
|
+
}
|
|
3495
|
+
|
|
3496
|
+
function showTip(el){
|
|
3497
|
+
if(hideTimer){clearTimeout(hideTimer);hideTimer=null;}
|
|
3498
|
+
if(!tip) createTip();
|
|
3499
|
+
var text=el.getAttribute("x-tooltip");
|
|
3500
|
+
if(!text) return;
|
|
3501
|
+
tip.querySelector(".stx-tip-text").textContent=text;
|
|
3502
|
+
currentEl=el;
|
|
3503
|
+
position(el);
|
|
3504
|
+
}
|
|
3505
|
+
|
|
3506
|
+
function hideTip(){
|
|
3507
|
+
if(!tip) return;
|
|
3508
|
+
tip.style.opacity="0";
|
|
3509
|
+
hideTimer=setTimeout(function(){
|
|
3510
|
+
if(tip) tip.style.display="none";
|
|
3511
|
+
currentEl=null;
|
|
3512
|
+
},150);
|
|
3513
|
+
}
|
|
3514
|
+
|
|
3515
|
+
document.addEventListener("mouseover",function(e){
|
|
3516
|
+
var el=e.target.closest("[x-tooltip]");
|
|
3517
|
+
if(el) showTip(el);
|
|
3518
|
+
});
|
|
3519
|
+
document.addEventListener("mouseout",function(e){
|
|
3520
|
+
var el=e.target.closest("[x-tooltip]");
|
|
3521
|
+
if(el&&el===currentEl) hideTip();
|
|
3522
|
+
});
|
|
3523
|
+
document.addEventListener("focusin",function(e){
|
|
3524
|
+
var el=e.target.closest("[x-tooltip]");
|
|
3525
|
+
if(el) showTip(el);
|
|
3526
|
+
});
|
|
3527
|
+
document.addEventListener("focusout",function(e){
|
|
3528
|
+
var el=e.target.closest("[x-tooltip]");
|
|
3529
|
+
if(el) hideTip();
|
|
3530
|
+
});
|
|
3531
|
+
})();
|
|
3532
|
+
`}function h2($){return $.includes("data-stx-runtime")}function u2($){let Z=/window\.stx\s*\.\s*[A-Za-z_$]|\}\s*=\s*window\.stx\s*;/g;for(let X=Z.exec($);X!==null;X=Z.exec($)){let Y=$.slice(Math.max(0,X.index-80),X.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(Y))continue;return!0}return!1}function i3($,Z){let X=$.indexOf("<script"),Y=$.search(/<!doctype\b/i);if(X!==-1&&(Y===-1||X>Y))return $.slice(0,X)+Z+`
|
|
3533
|
+
`+$.slice(X);let J=/<head\b[^>]*>/i.exec($);if(J){let G=J.index+J[0].length;return`${$.slice(0,G)}
|
|
3534
|
+
${Z}${$.slice(G)}`}if($.includes("</head>")){let G=$.indexOf("</head>");return $.slice(0,G)+Z+`
|
|
3535
|
+
`+$.slice(G)}if(q5($))return g5($,(G)=>`${G}
|
|
3536
|
+
${Z}`);return`${Z}
|
|
3537
|
+
${$}`}async function B$($,Z){if($.includes("data-stx-runtime")||$.includes("window.stx.state")||$.includes("STX Signals Runtime"))return $;if(Z.buildMode==="serve")return i3($,'<script data-stx-runtime src="/_stx/runtime.js"></script>');if(Z.buildMode==="compile")return i3($,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:X}=await import("./chunk-5xd7vge2.js"),Y=await X(Z.debug);return i3($,`<script data-stx-scoped data-stx-runtime>${Y}</script>`)}function tJ($){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test($)}function d2($){if($.includes("data-stx-tooltip-runtime")||!tJ($))return $;let Z=`<script data-stx-scoped data-stx-tooltip-runtime>${p3()}</script>`,X=$.lastIndexOf("</body>");if(X===-1)return`${$}
|
|
3538
|
+
${Z}`;return`${$.slice(0,X)}${Z}
|
|
3539
|
+
${$.slice(X)}`}async function eJ($,Z){if(!$.includes("</body>"))return $;if($.includes("data-stx-router")||$.includes("__stxRouter)return")||$.includes("__stxRouter=true"))return $;let X=Z?.router,Y="";{let q={};if(X){if(X.container)q.container=X.container;if(X.interceptAllLinks!==void 0)q.interceptAllLinks=X.interceptAllLinks;if(X.progress!==void 0)q.progress=X.progress;if(X.viewTransitions!==void 0)q.viewTransitions=X.viewTransitions;if(X.viewTransitionDuration!==void 0)q.viewTransitionDuration=X.viewTransitionDuration;if(X.viewTransitionEasing!==void 0)q.viewTransitionEasing=X.viewTransitionEasing;if(X.scrollToTop!==void 0)q.scrollToTop=X.scrollToTop;if(X.prefetch!==void 0)q.prefetch=X.prefetch;if(X.cache!==void 0)q.cache=X.cache;if(X.progressColor!==void 0)q.progressColor=X.progressColor;if(X.progressHeight!==void 0)q.progressHeight=X.progressHeight}try{let U=await x2(Z?.pagesDir);if(U.length>0)q.ownedRoutes=U}catch{}if(Object.keys(q).length>0)Y=`<script>window.__stxRouterConfig=${g2(q)};</script>
|
|
3540
|
+
`}let{getCachedRouterScript:J}=await import("./chunk-5xd7vge2.js"),Q=Z?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':Z?.buildMode==="serve"?'<script data-stx-router src="/_stx/router.js"></script>':`<script data-stx-router>${await J()}</script>`,G=$.lastIndexOf("</body>");return $.slice(0,G)+Y+Q+`
|
|
3541
|
+
</body>`+$.slice(G+7)}var m2=Symbol.for("stx.lazy-module-promises");function $Q(){let $=globalThis;return $[m2]??=new Map,$[m2]}function a($,Z){let X=$Q(),Y=`${import.meta.url}\x00${$}`,J=X.get(Y);if(J)return J;let Q=Z();return X.set(Y,Q),Q.catch(()=>{if(X.get(Y)===Q)X.delete(Y)}),Q}var ZQ=0,s3=`(?:"[^"]*"|'[^']*'|[^>"'])*`,s2=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s;function XQ($,Z={}){let X=[];for(let Y of f5($,Y1)){let J=Y.token.match(/^<script\b([^>]*)>/i),Q=Y.token.match(/<\/script\s*>$/i);if(!J||!Q)continue;let G=J[1];if(Z.skipAttrs){if(Z.skipAttrs.lastIndex=0,Z.skipAttrs.test(G))continue}let q=J[0].length,U=Y.token.length-Q[0].length;X.push({fullMatch:Y.token,attrs:G,body:Y.token.slice(q,U),start:Y.start,end:Y.end})}return X}function o2($){let Z=$.trim(),X=Z.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(X){let J=X[1].trim(),Q=X[2].trim(),{itemVar:G,indexVar:q}=l2(Q);if(G)return{style:"as",iterable:J,itemVar:G,indexVar:q}}let Y=Z.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(Y){let J=Y[1].trim(),Q=Y[2].trim(),{itemVar:G,indexVar:q}=l2(J);if(G)return{style:"in",iterable:Q,itemVar:G,indexVar:q}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function l2($){let Z=$.trim(),X=Z.match(/^(\w+)\s*=>\s*(\w+)$/);if(X)return{itemVar:X[2],indexVar:X[1]};let Y=Z.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(Y)return{itemVar:Y[1],indexVar:Y[2]||null};let J=Z.match(/^(\w+)\s*,\s*(\w+)$/);if(J)return{itemVar:J[1],indexVar:J[2]};let Q=Z.match(/^(\w+)$/);if(Q)return{itemVar:Q[1],indexVar:null};return{itemVar:null,indexVar:null}}function r3($){return n2($)}function YQ($){let Z=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,X=0,Y;while((Y=Z.exec($))!==null){let J=Y[1];if(J.startsWith("if"))X++;else if(J==="endif")X--;else if(X===0)return!0}return!1}function JQ($){let Z=new Set,X=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,Y=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal)\s*(?:<[^>]*>)?\s*\(/g,J;while((J=X.exec($))!==null){let Q=J[1],G;while((G=Y.exec(Q))!==null)Z.add(G[1])}return Z}function QQ($){if(!/[:@]for\s*=/.test($)&&!/\bx-for\s*=/.test($))return[];let Z=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${s3})>`,"iy"),X=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,Y=f5($,(Q,G)=>{Z.lastIndex=G;let q=Z.exec(Q);if(!q||q.index!==G||!X.test(q[2]))return-1;return Z.lastIndex}),J=[];for(let Q of Y){Z.lastIndex=0;let G=Z.exec(Q.token);if(!G)continue;let q=G[2].match(X),U=o2(q?.[1]??q?.[2]??""),W=[U.itemVar,U.indexVar].filter(Boolean);if(W.length===0)continue;let K=G[1],H=/\/\s*>$/.test(Q.token)||_$.has(K.toLowerCase())?Q.end:a2($,Q.start,K,Q.end);if(H!==-1)J.push({start:Q.start,end:H,vars:new Set(W)})}return J}var c2=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 GQ($){return $.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function p2($,Z,X,Y){if(!$)return!1;let J=GQ($),Q=!1,G=!1,q=!1,U=/([a-zA-Z_$][\w$]*)/g,W;while((W=U.exec(J))!==null){let B=W[1];if(J.slice(0,W.index).trimEnd().endsWith("."))continue;if(c2.has(B))continue;if(Z.has(B)||Y?.has(B))Q=!0;else if(X&&B in X)G=!0}let K=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,z;while((z=K.exec(J))!==null){let B=z[1];if(J.slice(0,z.index).trimEnd().endsWith("."))continue;if(c2.has(B)||X&&B in X)continue;q=!0}return(Q||q)&&!G}function j$($,Z,X){let Y=X===void 0?` ${Z}`:` ${Z}="${X.replace(/"/g,""")}"`,J=$.trim(),Q=J.match(s2);if(Q&&qQ(Q[3],Q[1])){let[,G,q,U]=Q;return`<${G}${q}${Y}>${U}</${G}>`}return`<template${Y}>${J}</template>`}function qQ($,Z){let X=new RegExp(`<(/)?${Z}(?=[\\s/>])`,"gi"),Y=0,J;while((J=X.exec($))!==null)if(J[1]){if(Y--,Y<0)return!1}else Y++;return!0}function r2($,Z){let X=JQ($);function Y(J){let Q=J,G=QQ(J),q=(z)=>{let H=new Set;for(let B of G)if(z>B.start&&z<B.end)for(let j of B.vars)H.add(j);return H},U=/@if\s*\(/g,W,K=[];while((W=U.exec(Q))!==null){let z=W.index,H=z+W[0].length,B=1,j=H;while(j<Q.length&&B>0){if(Q[j]==="(")B++;else if(Q[j]===")")B--;j++}if(B!==0)continue;let _=Q.substring(H,j-1).trim(),V=j,O=1,F=V,L=/@(if\s*\(|endif)/g;L.lastIndex=V;let w;while((w=L.exec(Q))!==null)if(w[1].startsWith("if"))O++;else if(w[1]==="endif"){if(O--,O===0){F=w.index+w[0].length;break}}if(O!==0)continue;let R=Q.substring(V,F-6).trim(),D;if(YQ(R)){let N=_5(Q.substring(z,F));if(N.length===0)continue;let T=N[0].branches.filter((I)=>I.type!=="else"),A=q(z);if(!(T.length>0&&T.every((I)=>p2(I.condition,X,Z,A))))continue;D=N[0].branches.map((I)=>{let y=Y(I.content);if(I.type==="elseif")return j$(y,"@else-if",I.condition??"");if(I.type==="else")return j$(y,"@else");return j$(y,"@if",I.condition??"")}).join(`
|
|
3542
|
+
`)}else{if(!p2(_,X,Z,q(z)))continue;D=j$(Y(R),"@if",_)}K.push({start:z,end:F,replacement:D}),U.lastIndex=F}for(let z=K.length-1;z>=0;z--){let{start:H,end:B,replacement:j}=K[z];Q=Q.substring(0,H)+j+Q.substring(B)}return Q}return Y($)}function UQ($){let Z=$.trim();if(Z==="")return;if(Z==="true")return!0;if(Z==="false")return!1;if(Z==="null")return!1;if(Z==="undefined")return!1;if(Z==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(Z)){let J=Number(Z);return J!==0&&!Number.isNaN(J)}let X=Z.match(/^'((?:\\.|[^'\\])*)'$/);if(X)return X[1].length>0;let Y=Z.match(/^"((?:\\.|[^"\\])*)"$/);if(Y)return Y[1].length>0;return}var _$=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function a2($,Z,X,Y){if(_$.has(X.toLowerCase()))return Y;let J=X.toLowerCase(),Q=$.toLowerCase(),G=$.length,q=1,U=Y;while(U<G){let W=$.indexOf("<",U);if(W===-1)return-1;if(U=W,$.startsWith("<!--",U)){let B=$.indexOf("-->",U+4);if(B===-1)return-1;U=B+3;continue}let K=/^<(script|style)\b/i.exec($.slice(U,U+8));if(K){let B=$.indexOf(">",U);if(B===-1)return-1;if($[B-1]==="/"){U=B+1;continue}let j=Q.indexOf(`</${K[1].toLowerCase()}`,U);if(j===-1)return-1;let _=$.indexOf(">",j);if(_===-1)return-1;U=_+1;continue}if($[U+1]==="/"){let B=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(U,U+64));if(!B){U++;continue}if(B[1].toLowerCase()===J){if(q--,U+=B[0].length,q===0)return U;continue}U+=B[0].length;continue}let z=/^<([a-z][\w-]*)\b/i.exec($.slice(U,U+64));if(!z){U++;continue}let H=$.indexOf(">",U);if(H===-1)return-1;if(z[1].toLowerCase()===J){let B=$.slice(U,H+1);if(!(/\/\s*>$/.test(B)||_$.has(J)))q++}U=H+1}return-1}var WQ=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function KQ($,Z){let X=Z,Y=$.length;for(;;){while(X<Y&&$[X]!=="<")X++;if(X>=Y)return!1;if($.startsWith("<!--",X)){let G=$.indexOf("-->",X+4);if(G===-1)return!1;X=G+3;continue}break}if($[X+1]==="/")return!1;let J=$.indexOf(">",X);if(J===-1)return!1;let Q=$.slice(X,J+1);return WQ.test(Q)}function t2($){if(!$.includes(":if")&&!$.includes(":show")&&!$.includes("x-if")&&!$.includes("x-show")&&!$.includes("@if=")&&!$.includes("@show="))return $;let Z=[],X=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,Y;while((Y=X.exec($))!==null)Z.push([Y.index,Y.index+Y[0].length]);let J=(z)=>Z.some(([H,B])=>z>=H&&z<B),Q=/<([a-zA-Z][\w-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*?)\s+(:if|:show|x-if|x-show|@if|@show)\s*=\s*"([^"]*)"((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?)>/g,G=[],q;while((q=Q.exec($))!==null){if(J(q.index))continue;let[z,H,B,j,_,V,O]=q,F=UQ(_);if(F===void 0)continue;let L=q.index,w=L+z.length,N=!!O||/\/\s*>$/.test(z)||_$.has(H.toLowerCase())?w:a2($,L,H,w);if(N===-1)continue;if((j===":if"||j==="x-if"||j==="@if")&&KQ($,N)){Q.lastIndex=w;continue}if(F===!0){let A=`<${H}${B}${V}${O}>`;G.push({start:L,end:w,replacement:A});continue}G.push({start:L,end:N,replacement:""}),Q.lastIndex=N}if(G.length===0)return $;G.sort((z,H)=>z.start-H.start);let U=[],W=-1;for(let z of G){if(z.start<W)continue;U.push(z),W=z.end}let K=$;for(let z=U.length-1;z>=0;z--){let{start:H,end:B,replacement:j}=U[z];K=K.substring(0,H)+j+K.substring(B)}return K}function e2($,Z){let X=$,Y=/@(for|foreach)\s*\(/g,J,Q=[],G=[];while((J=Y.exec(X))!==null){let q=J[1],U=J.index,W=U+J[0].length,K=1,z=W;while(z<X.length&&K>0){if(X[z]==="(")K++;else if(X[z]===")")K--;z++}if(K!==0)continue;let H=X.substring(W,z-1).trim(),B=z,j=o2(H),_=q==="for"?"@endfor":"@endforeach",V=1,O=B,F=q==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${q}\\s*\\(|end${q})`,"g");F.lastIndex=B;let L;while((L=F.exec(X))!==null)if(L[1].startsWith(q))V++;else if(V--,V===0){O=L.index+L[0].length;break}if(V!==0)continue;let w=()=>{let T=[j.itemVar,j.indexVar].filter(Boolean);if(T.length)G.push({start:U,end:O,vars:T})};if(j.iterable){let T=j.iterable.trim();if(T.startsWith("[")||T.startsWith("{")||T.startsWith("'")||T.startsWith('"')||T.startsWith("`")||/^-?\d/.test(T)){w();continue}let A=T.split(/[.[(]/)[0].trim(),M=Z?A in Z:!1,k=G.some((I)=>U>I.start&&U<I.end&&I.vars.includes(A));if(A&&(M||k)){w();continue}}if(j.style==="as")H=j.indexVar?`(${j.itemVar}, ${j.indexVar}) in ${j.iterable}`:`${j.itemVar} in ${j.iterable}`;let R=X.substring(B,O-_.length).trim(),D=R.match(s2),N;if(D){let[,T,A,M]=D;N=`<${T}${A} @for="${H}">${M}</${T}>`}else N=`<template @for="${H}">${R}</template>`;Q.push({start:U,end:O,replacement:N})}for(let q=Q.length-1;q>=0;q--){let{start:U,end:W,replacement:K}=Q[q];X=X.substring(0,U)+K+X.substring(W)}return X}function zQ($){let Z=new Set,X=[],Y=0,J=0,Q=$.length,G=(K)=>{let z=Y+1;while(z<Q){let H=$[z];if(H==="\\"){z+=2;continue}if(H===K)return z+1;z++}return Q},q=()=>{let K=Y+2;while(K<Q&&$[K]!==`
|
|
3543
|
+
`)K++;return K},U=()=>{let K=Y+2;while(K<Q-1){if($[K]==="*"&&$[K+1]==="/")return K+2;K++}return Q},W=(K)=>{let z=K,H=0;while(z<Q){let B=$[z];if(B==="/"&&$[z+1]==="/"){let j=z+2;while(j<Q&&$[j]!==`
|
|
3544
|
+
`)j++;z=j;continue}if(B==="/"&&$[z+1]==="*"){let j=z+2;while(j<Q-1&&!($[j]==="*"&&$[j+1]==="/"))j++;z=j+2;continue}if(B==='"'||B==="'"||B==="`"){let j=z+1;while(j<Q){if($[j]==="\\"){j+=2;continue}if($[j]===B){j++;break}j++}z=j;continue}if(B==="("||B==="["||B==="{"){H++,z++;continue}if(B===")"||B==="]"||B==="}"){H--,z++;continue}if(B===";"&&H===0)return z+1;z++}return Q};while(Y<Q){let K=$[Y];if(K==="/"&&$[Y+1]==="/"){let z=q();X.push($.slice(Y,z)),Y=z;continue}if(K==="/"&&$[Y+1]==="*"){let z=U();X.push($.slice(Y,z)),Y=z;continue}if(K==='"'||K==="'"||K==="`"){let z=G(K);X.push($.slice(Y,z)),Y=z;continue}if(K==="{"){J++,X.push(K),Y++;continue}if(K==="}"){J--,X.push(K),Y++;continue}if(J===0){let z=Y>0?$[Y-1]:"";if(z===""||/\s/.test(z)||z===";"||z==="}"||z==="{"){let B=$.slice(Y).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(B){let j=B[2],_=W(Y+B[0].length);if(Z.has(j)){X.push(`/* stx: deduped const ${j} */`),Y=_;continue}Z.add(j),X.push($.slice(Y,_)),Y=_;continue}}}X.push(K),Y++}return X.join("")}async function HQ($,Z,X){let Y=XQ($,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),J=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|useCookie|useId|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*\(/,Q=[];for(let V of Y){let O=V.body;if(N1(V.attrs))O=A1(O);if(J.test(O))Q.push({fullMatch:V.fullMatch,attrs:V.attrs,content:O})}if(Q.length===0)return{output:$,setupCode:null};let G=`__stx_setup_${Date.now()}_${ZQ++}`,{hasUserImports:q,bundleClientScript:U}=await a("stx/client-script-bundler",()=>import("./chunk-fd77g6t6.js")),W=[];for(let V=0;V<Q.length;V++){let O=Q[V].content;if(O=R5(O).code,q(O))O=await U(O,Z||"",{projectRoot:process.cwd()});O=O.replace(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm,(L,w)=>jQ(w));let F=o0(O);W.push(`// \u2500\u2500 merged signal script #${V+1} \u2500\u2500
|
|
3545
|
+
${F}`)}let K=W.join(`
|
|
3546
|
+
|
|
3547
|
+
`);K=zQ(K);let z=BQ(K),H=z.split(",").map((V)=>V.trim()).filter(Boolean),B=o3(K,X),j=`
|
|
3548
|
+
<script data-stx-scoped>
|
|
3549
|
+
function ${G}() {
|
|
3550
|
+
${l1("const",H)}
|
|
3551
|
+
${n1(`${B}${K}`)}
|
|
3552
|
+
return { ${z} };
|
|
3553
|
+
}
|
|
3554
|
+
window.__stx_latestSetup=${G};
|
|
3555
|
+
if(window.stx)window.stx._latestSetup=${G};
|
|
3556
|
+
</script>`,_=$;for(let V of Q)_=_.split(V.fullMatch).join("");if(_.includes("<body"))_=_.replace(new RegExp(`<body(${s3})>`),`<body$1 data-stx="${G}">`);else{let V=["script","style","html","head","meta","link","title","!doctype"],O=!1;_=_.replace(new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${s3})>`,"gi"),(F,L,w)=>{if(O||V.includes(L.toLowerCase()))return F;return O=!0,`<${L}${w} data-stx="${G}">`})}return{output:_,setupCode:j}}function BQ($){let Z=$,X=[],Y=new Set,J=0,Q=0,G=Z.length,q="",U=()=>{Q++;let j=!1;while(Q<G){let _=Z[Q];if(_==="\\"){Q+=2;continue}if(_==="["&&!j){j=!0,Q++;continue}if(_==="]"&&j){j=!1,Q++;continue}if(_==="/"&&!j){Q++;while(Q<G&&/[gimsuyd]/.test(Z[Q]))Q++;return}if(_===`
|
|
3557
|
+
`)return;Q++}},W=()=>{if(!q)return!0;if(/[\w)\]]/.test(q))return!1;return!0},K=(j)=>{Q++;while(Q<G){if(Z[Q]==="\\"){Q+=2;continue}if(Z[Q]===j){Q++;return}Q++}},z=()=>{Q++;while(Q<G){if(Z[Q]==="\\"){Q+=2;continue}if(Z[Q]==="`"){Q++;return}if(Z[Q]==="$"&&Z[Q+1]==="{"){Q+=2;let j=1;while(Q<G&&j>0)if(Z[Q]==="{")j++,Q++;else if(Z[Q]==="}")j--,Q++;else if(Z[Q]==="'"||Z[Q]==='"')K(Z[Q]);else if(Z[Q]==="`")z();else Q++;continue}Q++}},H=()=>{if(Z[Q]==="/"&&Z[Q+1]==="/"){while(Q<G&&Z[Q]!==`
|
|
3558
|
+
`)Q++;return!0}if(Z[Q]==="/"&&Z[Q+1]==="*"){Q+=2;while(Q<G-1&&!(Z[Q]==="*"&&Z[Q+1]==="/"))Q++;return Q+=2,!0}return!1},B=()=>{if(J!==0)return;let j=Z.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);if(j){let L=j[2];if(!Y.has(L))X.push(L),Y.add(L);return}let _=Z.slice(Q).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(_){_[1].split(",").forEach((L)=>{let w=L.trim();if(!w)return;let R=w.indexOf(":"),N=(R>=0?w.slice(R+1).trim():w).split(/[\s=]/)[0];if(N&&!Y.has(N))X.push(N),Y.add(N)});return}let V=Z.slice(Q).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(V){V[1].split(",").forEach((L)=>{let w=L.trim().replace(/^\.\.\./,"");if(!w)return;let R=w.split(/[\s=]/)[0];if(R&&!Y.has(R))X.push(R),Y.add(R)});return}let O=Z.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(O){let L=O[1];if(!Y.has(L))X.push(L),Y.add(L);return}let F=Z.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(F){let L=F[1];if(!Y.has(L))X.push(L),Y.add(L)}};while(Q<G){if(H())continue;if(Z[Q]==="'"||Z[Q]==='"'){K(Z[Q]),q=Z[Q-1];continue}if(Z[Q]==="`"){z(),q="`";continue}if(Z[Q]==="/"&&Z[Q+1]!=="/"&&Z[Q+1]!=="*"&&W()){U(),q="/";continue}if(Z[Q]==="{"){J++,q="{",Q++;continue}if(Z[Q]==="}"){J--,q="}",Q++;continue}if(J===0&&/[a-z]/i.test(Z[Q])&&(Q===0||/\s|[;{}()]/.test(Z[Q-1])))B();if(!/\s/.test(Z[Q]))q=Z[Q];Q++}return X.join(", ")}async function $9($,Z,X,Y){if(!r3($))return $;let J=$;if(Z.skipSignalsRuntime)return J;let{output:Q,setupCode:G}=await HQ(J,X,Y);if(J=Q,J=await B$(J,Z),G){let K=n3(J,/<\/head>/i),z=K===-1?n3(J,/<body[^>]*>/i):-1;if(K!==-1)J=`${J.slice(0,K)}${G}
|
|
3559
|
+
${J.slice(K)}`;else if(z!==-1){let H=/<body[^>]*>/i.exec(J.slice(z))[0],B=z+H.length;J=`${J.slice(0,B)}
|
|
3560
|
+
${G}${J.slice(B)}`}else J=`${J}
|
|
3561
|
+
${G}`}let U=J.replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<style\b[\s\S]*?<\/style>/gi,"").match(/<body([^>]*)>/i),W=U&&/data-stx/.test(U[1]);if(!G&&!W&&U&&!/data-stx-auto/.test(U[1])){let K=/<body[^>]*>/i,z=n3(J,K);if(z!==-1){let H=J.slice(0,z),B=J.slice(z).replace(K,(j)=>j.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>"));J=H+B}}return J}function n3($,Z){let X=/<(script|style)\b[\s\S]*?<\/\1>/gi,Y=[],J;while((J=X.exec($))!==null)Y.push([J.index,J.index+J[0].length]);let Q=new RegExp(Z.source,Z.flags.replace(/[gy]/g,"")),G=0;while(G<$.length){let q=Q.exec($.slice(G));if(!q)return-1;let U=G+q.index;if(!Y.some(([K,z])=>U>=K&&U<z))return U;G=U+Math.max(q[0].length,1)}return-1}var i2="/* [stx import stripped, resolved via window.stx in __stx_setup] */";function jQ($){let Z=[];for(let X of $.split(",")){let Y=X.trim();if(!Y||Y.startsWith("type "))continue;let J=Y.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(J&&J[1]!==J[2])Z.push(`${J[2]} = ${J[1]}`)}if(Z.length===0)return i2;return`var ${Z.join(", ")}; ${i2}`}import x0 from"path";import a3 from"fs";function Z9($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function X9($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class Y9{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,X,Y){let J=$.endsWith(".stx")?$.slice(0,-4):$,Q=Y?.__importedComponents;if(Q){let B=[J,J.toLowerCase(),Z9(J),X9(J)];for(let j of B)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${Z9(J)}.stx`,`${X9(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let B=x0.resolve(x0.dirname(Z),`${J}.stx`);if(await r(B))return B;return null}let q=[],U=X.componentsDir||"",W=Y?.__originalFilePath;if(W)q.push(x0.join(x0.dirname(W),"components"));if(U)q.push(U);let K=x0.join(x0.dirname(Z),"components");if(!q.includes(K))q.push(K);let z=process.cwd(),H=[x0.resolve(z,"src/components"),x0.resolve(z,"components"),x0.resolve(import.meta.dir,"components")];for(let B of H)if(!q.includes(B))q.push(B);for(let B of q){if(!B)continue;for(let j of G){let _=x0.join(B,j);if(await r(_))return _}try{if(!a3.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let _=a3.readdirSync(B,{withFileTypes:!0});for(let V of _)if(V.isDirectory()){let O=x0.join(B,V.name);for(let F of G){let L=x0.join(O,F);if(await r(L))return L}}}catch{}}return null}}var k0=new Y9;function j0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var I1="\x00stx-boolean-attribute";function t3($){return $.indexOf("\x00")===-1?$:$.replace(/\0/g,"")}function s1($,Z){let X=[];for(let[Y,J]of Object.entries($.static)){if(Z.has(Y))continue;let Q=$.staticNames?.[Y]??Y;if(typeof J==="boolean"){if(J)X.push(j0(Q));continue}if(J===I1){X.push(j0(Q));continue}X.push(`${j0(Q)}="${j0(t3(String(J)))}"`)}return X}function o1($,Z){let X=[];for(let[Y,J]of Object.entries($.serverDynamic??{})){if(Z.has(Y))continue;if(J===null||J===void 0||J===!1)continue;let Q=$.serverDynamicNames?.[Y]??Y;if(J===!0){X.push(j0(Q));continue}if(typeof J==="object")continue;X.push(`${j0(Q)}="${j0(t3(String(J)))}"`)}return X}function D5($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function _Q($){if($.clientReactive.to)return{value:$.clientReactive.to,reactive:!0};if($.serverDynamic.to!==void 0)return{value:String($.serverDynamic.to),reactive:!1};if(typeof $.static.to==="string")return{value:$.static.to,reactive:!1};return{value:"#",reactive:!1}}var e3={name:"StxLink",aliases:["stx-link"],render($,Z,X){let Y=_Q($),J=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),Q=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",q=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,U=[];if(Y.reactive)U.push(`:href="${D5(Y.value)}"`);else U.push(`href="${D5(Y.value)}"`);if(J)U.push(`class="${D5(J)}"`);if(U.push("data-stx-link"),U.push(`data-stx-active-class="${D5(Q)}"`),U.push(`data-stx-exact-active-class="${D5(G)}"`),q)U.push("data-stx-prefetch");let W=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);return U.push(...s1($,W)),U.push(...o1($,W)),`<a ${U.join(" ")}>${Z}</a>`}};var OQ={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},$4=[320,640,768,1024,1280,1536,1920];function w0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function N0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let X=$.static[Z];if(typeof X==="string")return X;return}function Z4($,Z,X=!1){let Y=$.serverDynamic[Z];if(Y!==void 0)return Y!==!1&&Y!=="false";let J=$.static[Z];if(J!==void 0)return J!=="false"&&J!==!1;return X}function J9($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),X=[];for(let Y of Z)if(Y.includes(":")){let[J,Q]=Y.split(":"),G=OQ[J];if(G)X.push(`(max-width: ${G}px) ${Q}`);else{let q=Number.parseInt(J);if(!Number.isNaN(q))X.push(`(max-width: ${q}px) ${Q}`)}}else X.push(Y);return X.join(", ")}function X4($,Z,X,Y){return Z.map((J)=>`${N5($,J,void 0,X,Y)} ${J}w`).join(", ")}function VQ($,Z,X,Y,J){return Z.map((Q)=>{let G=X?X*Q:void 0;return`${N5($,G,void 0,Y,J)} ${Q}x`}).join(", ")}function N5($,Z,X,Y,J){if(!Y||Y==="local"||Y==="static")return $;if(Y==="cloudinary"){let Q=[];if(Z)Q.push(`w_${Z}`);if(X)Q.push(`h_${X}`);if(J)Q.push(`f_${J}`);Q.push("q_auto");let G=Q.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(Y==="imgix"){let Q=new URLSearchParams;if(Z)Q.set("w",String(Z));if(X)Q.set("h",String(X));if(J)Q.set("fm",J);Q.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}if(Y==="bunny"){let Q=new URLSearchParams;if(Z)Q.set("width",String(Z));if(X)Q.set("height",String(X));if(J)Q.set("format",J);let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}return $}function FQ($,Z,X="#e5e7eb"){let Y=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${Z}"><rect width="100%" height="100%" fill="${X}"/></svg>`;return`data:image/svg+xml;base64,${btoa(Y)}`}var Y4={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,X){let Y=N0($,"src")||"",J=N0($,"alt")||"",Q=N0($,"width"),G=N0($,"height"),q=N0($,"sizes"),U=N0($,"srcset"),W=N0($,"densities"),K=N0($,"format"),z=N0($,"placeholder"),H=N0($,"placeholderColor")||"#e5e7eb",B=N0($,"provider"),j=N0($,"class")||N0($,"className")||"",_=N0($,"style")||"",V=N0($,"quality"),O=Z4($,"lazy",!0),F=Z4($,"preload",!1),L=Z4($,"picture",!1)||!!K,w=Q?Number.parseInt(Q):void 0,R=G?Number.parseInt(G):void 0,D=U||"",N="";if(!D&&q)D=X4(Y,$4,B,K),N=J9(q);else if(!D&&W){let E=W.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));D=VQ(Y,E,w,B,K)}else if(q)N=J9(q);let T=[];if(_)T.push(_);if(w&&R)T.push(`aspect-ratio:${w}/${R}`);if(z==="blur"||z==="color"||z==="thumbhash"){let E=FQ(w||16,R||9,H);T.push(`background-image:url(${E})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(z&&z!=="empty"&&z!=="none")T.push(`background-image:url(${w0(z)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let A=N5(Y,w,R,B,K),M=[];if(M.push(`src="${w0(A)}"`),M.push(`alt="${w0(J)}"`),Q)M.push(`width="${w0(Q)}"`);if(G)M.push(`height="${w0(G)}"`);if(O)M.push('loading="lazy"');if(M.push('decoding="async"'),j)M.push(`class="${w0(j)}"`);if(T.length>0)M.push(`style="${w0(T.join(";"))}"`);if(D)M.push(`srcset="${w0(D)}"`);if(N)M.push(`sizes="${w0(N)}"`);let k=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);M.push(...s1($,k)),M.push(...o1($,k));let I=`<img ${M.join(" ")} />`,y="";if(F){let b=K==="webp"?"image/webp":K==="avif"?"image/avif":"";y=`<link rel="preload" as="image" href="${w0(A)}"${b?` type="${b}"`:""}${D?` imagesrcset="${w0(D)}"`:""}${N?` imagesizes="${w0(N)}"`:""} />
|
|
3562
|
+
`}if(L){let E=[];if(K==="avif"||K==="auto"){let b=N5(Y,w,R,B,"avif"),C=D?X4(Y,$4,B,"avif"):`${b}`;E.push(`<source type="image/avif" srcset="${w0(C)}"${N?` sizes="${w0(N)}"`:""} />`)}if(K==="webp"||K==="auto"){let b=N5(Y,w,R,B,"webp"),C=D?X4(Y,$4,B,"webp"):`${b}`;E.push(`<source type="image/webp" srcset="${w0(C)}"${N?` sizes="${w0(N)}"`:""} />`)}return`${y}<picture>
|
|
3563
|
+
${E.join(`
|
|
3564
|
+
`)}
|
|
3565
|
+
${I}
|
|
3566
|
+
</picture>`}return`${y}${I}`}};var Q9="/images/safe-image-default.svg";function A5($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function r1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let X=$.static[Z];if(typeof X==="string")return X;return}var LQ=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${Q9}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,J4={name:"SafeImage",aliases:["safe-image","safe-img"],render($,Z,X){let Y=r1($,"src")||"",J=r1($,"alt")||"",Q=r1($,"fallback")||Q9,G=r1($,"class")||r1($,"className")||"",q=r1($,"fallbackClassName")||"",U=[];if(U.push(`src="${A5(Y)}"`),U.push(`alt="${A5(J)}"`),G)U.push(`class="${A5(G)}"`);if(U.push(`data-fallback="${A5(Q)}"`),q)U.push(`data-fallback-class="${A5(q)}"`);U.push('onerror="window.__stxSafeImageHandler(this)"');let W=new Set(["src","alt","fallback","class","className","fallbackClassName"]);U.push(...s1($,W)),U.push(...o1($,W));let K=`<img ${U.join(" ")} />`,z=X.context;if(!z.__safeImageHandlerEmitted)return z.__safeImageHandlerEmitted=!0,`${LQ}${K}`;return K}};function Q4($){return $.replace(/[;{}()]/g,"").replace(/url/gi,"")}function M5($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let X=$.static[Z];if(typeof X==="string")return X;return}function O$($,Z,X){let Y=M5($,Z);if(Y!==void 0){let J=Number.parseInt(Y,10);if(!Number.isNaN(J))return J}return X}var G4={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render($,Z,X){let Y=Q4(M5($,"color")||"#6366f1"),J=Q4(M5($,"initialColor")||M5($,"initial-color")||""),Q=Q4(M5($,"height")||"3px"),G=O$($,"duration",2000),q=O$($,"throttle",200),U=O$($,"zIndex",999999)||O$($,"z-index",999999),W=J?`linear-gradient(to right, ${J}, ${Y})`:Y;return`
|
|
3567
|
+
<div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${Q};background:${W};z-index:${U};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
|
|
3568
|
+
<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>
|
|
3569
|
+
</div>
|
|
3570
|
+
<style>@keyframes stx-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}</style>
|
|
3571
|
+
<script>
|
|
3572
|
+
(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)},${q})},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()})})();
|
|
3573
|
+
</script>`}};function q9($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let X=$.static[Z];if(typeof X==="string")return X;return}function wQ($,Z,X){let Y=q9($,Z);if(Y!==void 0){let J=Number.parseInt(Y,10);if(!Number.isNaN(J))return J}return X}var G9={"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%)"},q4={name:"StxToast",aliases:["stx-toast"],render($,Z,X){let Y=j0(q9($,"position")||"top-right"),J=wQ($,"max",5),Q=G9[Y]||G9["top-right"];return`<div id="stx-toast-container" data-stx-toast-position="${Y}" data-stx-toast-max="${J}" style="position:fixed;${Q};z-index:999999;display:flex;flex-direction:column;gap:0.5rem;pointer-events:none;max-width:24rem;width:100%"></div>
|
|
3574
|
+
<style>
|
|
3575
|
+
@keyframes stx-toast-in{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}
|
|
3576
|
+
@keyframes stx-toast-out{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(100%)}}
|
|
3577
|
+
@keyframes stx-toast-in-left{from{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}
|
|
3578
|
+
@keyframes stx-toast-out-left{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(-100%)}}
|
|
3579
|
+
@keyframes stx-toast-in-center{from{opacity:0;transform:translateY(-1rem)}to{opacity:1;transform:translateY(0)}}
|
|
3580
|
+
@keyframes stx-toast-out-center{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-1rem)}}
|
|
3581
|
+
</style>`}};function V$($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let X=$.static[Z];if(typeof X==="string")return X;return}var U9={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)"},U4={name:"StxModal",aliases:["stx-modal"],render($,Z,X){let Y=V$($,"id");if(!Y)return console.warn('[stx] <StxModal> requires an "id" prop'),"<!-- StxModal: missing id prop -->";let J=j0(Y),Q=V$($,"size")||"md",G=V$($,"closeOnBackdrop")!=="false",q=V$($,"closeOnEscape")!=="false",U=U9[Q]||U9.md;return`<div id="stx-modal-${J}" class="stx-modal-backdrop" data-stx-modal="${J}" data-close-backdrop="${G}" data-close-escape="${q}" 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">
|
|
3582
|
+
<div class="stx-modal-panel" style="${U};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)">
|
|
3583
|
+
<div style="padding:1.5rem">${Z}</div>
|
|
3584
|
+
</div>
|
|
3585
|
+
</div>
|
|
3586
|
+
<style>
|
|
3587
|
+
@media(prefers-color-scheme:dark){[data-stx-modal]{--stx-modal-bg:#1f2937;--stx-modal-text:#f3f4f6}}
|
|
3588
|
+
.stx-modal-backdrop[data-stx-modal-open]{display:flex!important;opacity:1}
|
|
3589
|
+
.stx-modal-backdrop[data-stx-modal-open] .stx-modal-panel{transform:scale(1) translateY(0);opacity:1}
|
|
3590
|
+
</style>`}};function a1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let X=$.static[Z];if(typeof X==="string")return X;return}var W9={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},W4={name:"StxDrawer",aliases:["stx-drawer"],render($,Z,X){let Y=a1($,"id");if(!Y)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let J=j0(Y),Q=a1($,"side")||"right",G=a1($,"size")||"md",q=a1($,"closeOnBackdrop")!=="false",U=a1($,"closeOnEscape")!=="false",W=a1($,"overlay")!=="false",K=W9[G]||W9.md,z=Q==="left",H=z?"left:0":"right:0",B=z?"translateX(-100%)":"translateX(100%)",j=z?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${J}" class="stx-drawer-backdrop" data-stx-drawer="${J}" data-close-backdrop="${q}" data-close-escape="${U}" style="display:none;position:fixed;inset:0;z-index:99999;${W?"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">
|
|
3591
|
+
<div class="stx-drawer-panel" style="position:fixed;top:0;bottom:0;${H};width:${K};max-width:100vw;transform:${B};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">
|
|
3592
|
+
<div style="padding:1.5rem">${Z}</div>
|
|
3593
|
+
</div>
|
|
3594
|
+
</div>
|
|
3595
|
+
<style>
|
|
3596
|
+
@media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
|
|
3597
|
+
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
3598
|
+
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
3599
|
+
</style>`}};import{existsSync as RQ,readFileSync as DQ}from"fs";var k1=new Map,K9=new Set;function z9($){if(K9.has($))return;K9.add($),console.warn(`[stx] icon collection "${$}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${$}\`.`)}function H9($){let Z=process.cwd();for(let X of[`${Z}/node_modules/@iconify-json/${$}/icons.json`,`${Z}/pantry/@iconify-json/${$}/icons.json`,`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(RQ(X))return X;for(let X of[`@iconify-json/${$}/icons.json`,`@iconify/json/json/${$}.json`])try{return h.resolve(X)}catch{}return null}function NQ($){if(k1.has($))return k1.get($);let Z=H9($);if(!Z)return z9($),null;try{let X=JSON.parse(DQ(Z,"utf8"));return k1.set($,X.icons),X.icons}catch{return null}}async function AQ($,Z=!1){if(k1.has($))return k1.get($);let X=H9($);if(!X){if(!Z)z9($);return null}try{let Y=await Bun.file(X).json();return k1.set($,Y.icons),Y.icons}catch{return null}}function t1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);if($.static[Z]!==void 0)return String($.static[Z]);if($.clientReactive[Z]!==void 0)return $.clientReactive[Z];return}var K4={name:"Icon",aliases:["icon","stx-icon"],render($,Z,X){let Y=t1($,"name")??t1($,"icon");if(!Y)return"<!-- Icon: missing name/icon prop -->";let J="lucide",Q=Y;if(Y.includes(":")){let F=Y.split(":");J=F[0],Q=F[1]}let G=j0(t1($,"size")||"24"),q=j0(t1($,"color")||"currentColor"),U=j0(t1($,"class")||""),W=j0(t1($,"style")||""),K=k1.get(J)??NQ(J);if(!K)return`<!-- Icon: collection "${J}" not loaded -->`;let z=K[Q];if(!z)return`<!-- Icon: "${Q}" not found in ${J} -->`;let H=z.width||24,B=z.height||24,j=`0 0 ${H} ${B}`,_=z.body;if(q!=="currentColor")_=_.replace(/currentColor/g,q);let V=U?` class="${U}"`:"",O=W?` style="${W}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${V}${O}>${_}</svg>`}};async function MQ($="lucide",Z={}){await AQ($,Z.speculative??!0)}function B9($,...Z){for(let X of Z){if($.serverDynamic[X]!==void 0)return String($.serverDynamic[X]);let Y=$.static[X];if(typeof Y==="string")return Y}return}function j9($,Z){let X=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${Z}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),Y=$.match(X);if(!Y)return{region:null,rest:$};return{region:Y[2],rest:$.replace(Y[0],"")}}var z4={name:"Suspense",aliases:["suspense"],render($,Z,X){let Y=j9(Z,"fallback"),J=Y.rest,Q=j9(J,"error"),G=Q.rest,q=Y.region??B9($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',U=Q.region??B9($,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${q}</div><div data-stx-suspense-error hidden>${U}</div><div data-stx-suspense-content hidden>${G}</div></div>`}};function F$($,...Z){for(let X of Z){if($.serverDynamic[X]!==void 0)return String($.serverDynamic[X]);let Y=$.static[X];if(typeof Y==="string")return Y}return}var H4={name:"TransitionGroup",aliases:["transition-group"],render($,Z,X){let Y=(F$($,"name")||"v").replace(/["'<>]/g,""),J=(F$($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",Q=F$($,"class"),G=F$($,"id"),q=[`data-stx-transition-group="${Y}"`,Q?`class="${Q}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${J} ${q}>${Z}</${J}>`}};function _9(){k0.registerBuiltin(e3),k0.registerBuiltin(Y4),k0.registerBuiltin(J4),k0.registerBuiltin(G4),k0.registerBuiltin(q4),k0.registerBuiltin(U4),k0.registerBuiltin(W4),k0.registerBuiltin(K4),k0.registerBuiltin(z4),k0.registerBuiltin(H4)}function L$($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function O9($,Z,X){let Y=[],J=0;while(J<$.length){let Q=$.indexOf("<",J);if(Q===-1)break;let q=$.slice(Q+1).match(new RegExp(`^(${Z.source})(?![\\w.:-])`));if(!q){J=Q+1;continue}let U=q[1];if(X&&X.has(U.toLowerCase())){let _=Q+1+U.length;while(_<$.length&&$[_]!==">")_++;J=_+1;continue}let W=Q+1+U.length,K=null,z=W,H=-1,B=!1;while(W<$.length){let _=$[W];if(K){if(_==="\\"&&W+1<$.length){W+=2;continue}if(_===K)K=null;W++;continue}if(_==='"'||_==="'"){K=_,W++;continue}if(_==="/"&&W+1<$.length&&$[W+1]===">"){H=W+2,B=!0;break}if(_===">"){H=W+1;break}W++}if(H===-1){J=Q+1;continue}let j=$.slice(z,B?H-2:H-1).trim();if(B)Y.push({fullMatch:$.slice(Q,H),tagName:U,attributes:j,content:"",startIndex:Q,endIndex:H,isSelfClosing:!0}),J=H;else{let _=`<${U}`,V=`</${U}>`,O=1,F=H,L=-1;while(O>0&&F<$.length){let D=$.indexOf(_,F),N=$.indexOf(V,F);if(N===-1)break;if(D!==-1&&D<N){let T=$[D+_.length];if(T===" "||T===">"||T==="/"||T===`
|
|
3600
|
+
`||T==="\t")O++;F=D+_.length}else{if(O--,O===0){L=N;break}F=N+V.length}}if(L===-1){J=H;continue}let w=$.slice(H,L),R=L+V.length;Y.push({fullMatch:$.slice(Q,R),tagName:U,attributes:j,content:w,startIndex:Q,endIndex:R,isSelfClosing:!1}),J=R}}return Y}function V9($){return $.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function F9($,Z){try{let X=Buffer.from($,"base64").toString("utf8");return JSON.parse(X)}catch{}try{let X=$.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(X)}catch(X){if(Z?.debug)console.error("Error decoding __stx_ prop:",X);return $}}import R$ from"fs";import C0 from"path";var L9=!1,TQ=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 IQ($,Z,X){let Y={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},J=new Set(Array.isArray(Z.__stx_client_signal_names)?Z.__stx_client_signal_names:[]),Q=(W)=>{if(J.size===0)return!1;let K=p0(W),z=K.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(z&&J.has(z))return!0;for(let H of J){let B=H.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${B}\\s*\\(`).test(K))return!0}return!1},G=new Set(N9),q=(W)=>{if(!W.includes("-")||W.startsWith("@")||W.startsWith(":")||W.startsWith("x-")||W.startsWith("__"))return W;if(W.startsWith("aria-")||W.startsWith("data-"))return W;return W.replace(/-([a-z0-9])/g,(K,z)=>z.toUpperCase())},U=(W,K)=>{let z=q(W);if(Y.static[z]=K,z!==W)Y.staticNames[z]=W};for(let[W,K]of Object.entries($)){let z=W.startsWith("x-")&&!G.has(W)&&!W.startsWith("x-bind:")&&!W.startsWith("x-on:")?`:${W.slice(2)}`:W;if(z.startsWith("@")){Y.events[z]=K;continue}if(z.startsWith("__stx_")){let H=q(z.slice(6));Y.serverDynamic[H]=F9(K,X);continue}if(z.startsWith(":")){let H=q(z.slice(1)),B=K===I1?H:K;if(H==="if"||H==="for"||H==="show"){Y.clientReactive[H]=B;continue}if(Q(B)){Y.clientReactive[H]=B;continue}try{if(!Q0(B)){if(X.debug)console.error(`Unsafe expression in :${H} binding: ${B}`);Y.clientReactive[H]=B;continue}let j=Object.keys(Z),V=G0(B,j)(...Object.values(Z));if(V===void 0){let O=B.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],F=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(O.some((w)=>!F.has(w)&&!j.includes(w))){Y.clientReactive[H]=B;continue}}if(Y.serverDynamic[H]=V,H!==z.slice(1)&&Y.serverDynamicNames)Y.serverDynamicNames[H]=z.slice(1)}catch{Y.clientReactive[H]=B}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let H=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(H)try{let B=H[1];if(Q0(B)){let _=G0(B,Object.keys(Z))(...Object.values(Z));U(z,_!=null?String(_):"")}else{if(X.debug)console.error(`Unsafe expression in ${z}: ${B}`);U(z,K)}}catch(B){if(X.debug)console.error(`Error evaluating expression for ${z}:`,B);U(z,K)}else{let B=K,j=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=j.exec(K))!==null)try{let V=_[1];if(!Q0(V)){if(X.debug)console.error(`Unsafe expression in ${z}: ${V}`);continue}let F=G0(V,Object.keys(Z))(...Object.values(Z));B=B.replace(_[0],String(F??""))}catch(V){if(X.debug)console.error(`Error evaluating expression in ${z}:`,V)}U(z,B)}continue}U(z,K===I1?"true":V9(K))}return Y}var kQ=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function EQ($,Z,X){if(!$.includes("@"))return $;if(!kQ.some(([J,Q])=>J.test($)&&$.includes(Q)))return $;try{return a0($,Z,X)}catch{return $}}function bQ($){let Z={},X=0,Y=$.length;while(X<Y){while(X<Y&&/\s/.test($[X]))X++;if(X>=Y)break;let J="";while(X<Y&&!/[\s=]/.test($[X]))J+=$[X],X++;if(!J)break;while(X<Y&&/\s/.test($[X]))X++;if(X<Y&&$[X]==="="){X++;while(X<Y&&/\s/.test($[X]))X++;let Q="";if(X<Y&&($[X]==='"'||$[X]==="'")){let G=$[X];X++;while(X<Y){let q=$[X];if(q==="\\"&&X+1<Y){X++,Q+=$[X],X++;continue}if(q===G){X++;break}Q+=q,X++}}else while(X<Y&&!/\s/.test($[X]))Q+=$[X],X++;Z[J]=Q}else Z[J]=I1}return Z}function w9($){return Object.entries($).map(([Z,X])=>X===I1?Z:`${Z}="${yQ(X)}"`).join(" ")}function yQ($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function SQ($){let Z=new Set,X=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,Y;while((Y=X.exec($))!==null){let J=Y[1];if(k0.isBuiltin(J))Z.add(J)}return[...Z].sort()}var R9=new Map;function CQ($){let Z=R9.get($);if(Z)return Z;let X=new Map,Y=[C0.join($,"src"),C0.join($,"dist"),$];function J(Q,G){if(G>6)return;let q;try{q=R$.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let U of q){let W=C0.join(Q,U.name);if(U.isDirectory()){if(U.name==="node_modules"||U.name.startsWith("."))continue;J(W,G+1)}else if(U.isFile()&&U.name.endsWith(".stx")){let K=U.name.slice(0,-4);if(!X.has(K))X.set(K,W);let z=K.toLowerCase();if(!X.has(z))X.set(z,W);let H=K.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!X.has(H))X.set(H,W)}}}for(let Q of Y)if(J(Q,0),X.size>0)break;return R9.set($,X),X}function PQ($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let X=Z;while(!0){let Y=C0.join(X,"node_modules",$);try{if(R$.statSync(Y).isDirectory())return Y}catch{}let J=C0.dirname(X);if(J===X)return null;X=J}}async function vQ($,Z,X,Y,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=C0.dirname(X),q=$,U=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return q=q.replace(U,(W,K,z)=>{let H=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=z,j,_=[];while((j=H.exec(z))!==null){let[V,O,F,L]=j,w=null,R=null;if(L.startsWith(".")||L.startsWith("/")){let T=C0.resolve(G,L);if(T.endsWith(".stx"))R=T;else{let A=`${T}.stx`;try{if(R$.statSync(A).isFile())R=A}catch{try{if(R$.statSync(T).isDirectory())w=T}catch{}}}}else w=PQ(L,G);if(!w&&!R)continue;let D=!1,N=(T,A)=>{Q.set(T,A),Q.set(T.toLowerCase(),A);let M=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(M,A),J.add(A)};if(F&&R)N(F,R),D=!0;else if(O){let T=O.slice(1,-1).split(",").map((M)=>M.trim()).filter(Boolean).map((M)=>{let k=M.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(k)return{source:k[1],local:k[2]};return{source:M,local:M}}),A=w?CQ(w):null;for(let{source:M,local:k}of T){let I=null;if(R)I=R;else if(A)I=A.get(M)??A.get(M.toLowerCase())??A.get(M.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(I)N(k,I),D=!0}}if(D)_.push({start:j.index,end:j.index+V.length})}if(_.length===0)return W;for(let V=_.length-1;V>=0;V--)B=B.slice(0,_[V].start)+B.slice(_[V].end);return`<script${K}>${B}</script>`}),q}async function fQ($,Z,X,Y,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,q=/@import\s*\(\s*([^)]+)\s*\)/g,U;while((U=q.exec(Q))!==null){let[W,K]=U,z=K.split(",").map((H)=>H.trim().replace(/^['"]|['"]$/g,"")).filter((H)=>H.length>0);for(let H of z){let B=H.split("/"),_=B[B.length-1].replace(/\.stx$/,""),V=_.includes("-")?_.split("-").map((L)=>L.charAt(0).toUpperCase()+L.slice(1)).join(""):_.charAt(0).toUpperCase()+_.slice(1),O=null,F=[C0.resolve(C0.dirname(X),`${H}.stx`),C0.resolve(C0.dirname(X),H),C0.resolve(Y.componentsDir||"components",`${H}.stx`),C0.resolve(Y.componentsDir||"components",H),H.endsWith(".stx")?H:`${H}.stx`];for(let L of F)try{if(await Bun.file(L).exists()){O=L;break}}catch{}if(O){G.set(V,O),G.set(_,O),G.set(_.toLowerCase(),O);let L=V.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(L,O),J.add(O),Y.debug)console.log(`Imported component: ${V} -> ${O}`)}else if(Y.debug)console.warn(`Could not resolve imported component: ${H}`)}Q=Q.replace(W,""),q.lastIndex=0}return Q}async function xQ($,Z,X,Y,J){let Q=$,G=Y.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let q=Z.__processedComponents,U=/@component\s*\(/g,W;while((W=U.exec(Q))!==null){let K=W.index,z=K+W[0].length-1,H=1,B=z+1;while(B<Q.length&&H>0){if(Q[B]==="(")H++;else if(Q[B]===")"){if(H--,H===0)break}B++}if(H!==0)break;let j=Q.substring(z+1,B),_=B+1,V=j.match(/^\s*['"]([^'"]+)['"]/);if(!V){U.lastIndex=0;continue}let O=V[1],F,L=j.slice(V[0].length),w=L.match(/^\s*,\s*/);if(w)F=L.slice(w[0].length).trim();let R={};if(F)try{R=_0(F,Z)}catch(k){let I=k instanceof Error?k.message:String(k);Q=Q.replace(Q.substring(K,_),`[Error parsing component props: ${I}]`);continue}let D="",N=_,A=Q.substring(_).match(/^([\s\S]*?)@endcomponent/);if(A)D=A[1].trim(),N=_+A[0].length;let M=await T1(O,R,D,G,Z,X,Y,q,J);Q=Q.substring(0,K)+M+Q.substring(N),U.lastIndex=0}return Q}async function gQ($,Z,X,Y,J){if(!$)return $;let Q=$,G=Y.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let q=Z.__processedComponents,U=c0(Q);return Q=U.output,Q=await H(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await H(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await H(Q,/[a-z][a-z0-9]*/,!1,TQ),Q=C1(Q,U.scripts),Q;async function H(B,j,_,V){if(!B)return B;let O=B,F=O9(O,j,V);for(let L=F.length-1;L>=0;L--){let w=F[L],R=_?L$(w.tagName):w.tagName,D=bQ(EQ(w.attributes,Z,X)),N=IQ(D,Z,Y),T=k0.getBuiltin(w.tagName),A=T?await w$(R,G,Z,X,Y):!1;if(T&&!A){let y={context:Z,filePath:X,options:Y,dependencies:J},E=T.render(N,w.content,y);if(Object.keys(N.clientReactive).length>0)E=D9(E,N.clientReactive);if(Object.keys(N.events).length>0){let b=w9(N.events);E=E.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}O=O.substring(0,w.startIndex)+E+O.substring(w.endIndex);continue}if(!_&&w.tagName.includes("-")&&!await w$(R,G,Z,X,Y))continue;let M={};for(let[y,E]of Object.entries(N.static))M[y]=E;for(let[y,E]of Object.entries(N.serverDynamic))M[y]=E;let I=await T1(R,M,C1(w.content,U.scripts),G,Z,X,Y,q,J);if(Object.keys(N.clientReactive).length>0)I=D9(I,N.clientReactive);if(Object.keys(N.events).length>0){let y=A9(I);if(y){let E=w9(N.events),b=Object.keys(N.events).map((C)=>C.replace(/^@/,"").split(".")[0]).join(" ");I=I.substring(0,y.insertPos)+` data-stx-parent-events="${b}" ${E}`+I.substring(y.insertPos)}}O=O.substring(0,w.startIndex)+I+O.substring(w.endIndex)}return O}}function D9($,Z){let X=new Set(["if","for"]),Y=new Set(["show"]),J=Object.entries(Z).filter(([K])=>!X.has(K)),Q=J.filter(([K])=>!Y.has(K)).map(([K])=>L$(K)).join(" "),G=$,q=J.length>0?A9(G):null;if(q){let K=J.map(([H,B])=>`:${L$(H)}="${B.replace(/"/g,""")}"`).join(" "),z=Q?` data-stx-parent-bindings="${Q}"`:"";G=G.substring(0,q.insertPos)+`${z} ${K}`+G.substring(q.insertPos)}let U=Z.if;if(U)G=`<template :if="${U.replace(/"/g,""")}">${G}</template>`;let W=Z.for;if(W)G=`<template :for="${W.replace(/"/g,""")}">${G}</template>`;return G}function A9($){let Z=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec($);if(Z)return{insertPos:Z.index+1+Z[1].length};let X=0;while(X<$.length){let Y=$.slice(X),J=Y.match(/^\s+/);if(J){X+=J[0].length;continue}if(Y.startsWith("<!--")){let q=$.indexOf("-->",X+4);if(q===-1)return null;X=q+3;continue}let Q=Y.match(/^<(script|style)\b[^>]*>/i);if(Q){let q=`</${Q[1].toLowerCase()}>`,U=$.toLowerCase().indexOf(q,X+Q[0].length);if(U===-1)return null;X=U+q.length;continue}let G=Y.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!G)return null;return{insertPos:X+1+G[1].length}}return null}async function B4($,Z,X,Y,J){if(!L9)_9(),L9=!0;let Q=await vQ($,Z,X,Y,J);Q=await fQ(Q,Z,X,Y,J),Q=await xQ(Q,Z,X,Y,J);let G=[];for(let q=0;q<3;q++){let U=l0(Q,Q5,(K,z)=>`\x00STX_COMPONENT_COMMENT_${G.length+z}\x00`);G.push(...U.tokens);let W=Q;if(Q=await gQ(U.output,Z,X,Y,J),Q===W)break}if(G.length>0)Q=Q.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(q,U)=>G[Number(U)]??"");if(Y.debug){let q=SQ(Q);if(q.length>0)console.warn(`[stx] ${X}: unresolved component tag(s) after render passes: ${q.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}import $5 from"path";import M9 from"process";function e1($="STX_PUBLIC_"){let Z={},X={};for(let[Y,J]of Object.entries(M9.env)){if(!Y.startsWith($)||J===void 0)continue;Z[`import.meta.env.${Y}`]=JSON.stringify(J),X[Y]=J}return Z["import.meta.env"]=JSON.stringify(X),Z}function $j($="STX_PUBLIC_"){let Z={};for(let[X,Y]of Object.entries(M9.env))if(X.startsWith($)&&Y!==void 0)Z[X]=Y;return Z}function T9($){return $.startsWith("http://")||$.startsWith("https://")||$.startsWith("//")}async function I9($,Z,X){try{let Y;if($.startsWith("/")){let J=Z;for(let Q=0;Q<5;Q++){let G=$5.join(J,$);if(await Bun.file(G).exists())return G;J=$5.dirname(J)}Y=$5.join(Z,$)}else if($.startsWith("./")||$.startsWith("../"))Y=$5.resolve(Z,$);else Y=$5.resolve(Z,$);if(await Bun.file(Y).exists())return Y;return null}catch{return null}}async function k9($,Z,X){let Y=$,J=$5.dirname(Z),Q=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,G;while((G=Q.exec(Y))!==null){let[W,K,z,H]=G;if(T9(z))continue;let B=await I9(z,J,Z);if(B)try{let j=await Bun.file(B).text();if(X.add(B),z.endsWith(".ts")||z.endsWith(".tsx")){let V=await Bun.build({entrypoints:[B],target:"browser",minify:!1,define:e1()});if(V.outputs.length>0)j=await V.outputs[0].text()}let _=`<script>
|
|
3601
|
+
// Source: ${z}
|
|
3602
|
+
${j}
|
|
3603
|
+
</script>`;Y=Y.replace(W,_),Q.lastIndex=0}catch(j){}}let q=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,U;while((U=q.exec(Y))!==null){let[W,K,z,H]=U,B=K+H;if(T9(z))continue;if(/rel=["']stylesheet["']/.test(B)||z.endsWith(".css")){let _=await I9(z,J,Z);if(_)try{let V=await Bun.file(_).text();X.add(_);let O=`<style>
|
|
3604
|
+
/* Source: ${z} */
|
|
3605
|
+
${V}
|
|
3606
|
+
</style>`;Y=Y.replace(W,O),q.lastIndex=0}catch(V){}}}return Y}function j4($,Z){let X=$,Y=/@json\s*\(/g,J;while((J=Y.exec(X))!==null){let Q=J.index,G=Q+J[0].length-1,q=1,U=G+1,W=null,K=!1;while(U<X.length&&q>0){let L=X[U];if(K){K=!1,U++;continue}if(L==="\\"&&W){K=!0,U++;continue}if(W){if(L===W)W=null;U++;continue}if(L==='"'||L==="'"||L==="`"){W=L,U++;continue}if(L==="(")q++;else if(L===")"){if(q--,q===0)break}U++}if(q!==0)break;let z=X.substring(G+1,U).trim(),H=X.substring(Q,U+1),B=-1,j=0,_=null,V=!1;for(let L=0;L<z.length;L++){let w=z[L];if(V){V=!1;continue}if(w==="\\"&&_){V=!0;continue}if(_){if(w===_)_=null;continue}if(w==='"'||w==="'"||w==="`"){_=w;continue}if(w==="("||w==="["||w==="{")j++;else if(w===")"||w==="]"||w==="}")j--;if(w===","&&j===0){B=L;break}}let O=B>=0?z.substring(0,B).trim():z,F=B>=0?z.substring(B+1).trim():void 0;try{let L=O.trim(),w;if(Q0(L))w=G0(L,Object.keys(Z))(...Object.values(Z));else w=void 0;let R;if(F==="true")R=JSON.stringify(w,null,2);else R=JSON.stringify(w);let D=R.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");X=X.substring(0,Q)+D+X.substring(U+1),Y.lastIndex=Q+D.length}catch(L){u0.log(L instanceof Error?L:Error(String(L)),{directive:"@json"},"error"),Y.lastIndex=Q+H.length}}return X}function _4($){return $.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function E9($){let Z=$,X=/@memo\s*\(/g,Y,J=[];while((Y=X.exec(Z))!==null){let Q=Y.index,G=Q+Y[0].length,q=1,U=G;while(U<Z.length&&q>0){if(Z[U]==="(")q++;else if(Z[U]===")")q--;U++}if(q!==0)continue;let W=Z.slice(G,U-1).trim(),K=U,z=Z.slice(K),H=z.indexOf("@endmemo");if(H===-1)continue;let B=z.slice(0,H),j=K+H+8,_=B.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)/),V=_?_[0].length:0,O=B.slice(V),F=B.match(/(\s*)$/),L=F?F[0].length:0,w=O.slice(0,O.length-L),R=w.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),D;if(R){let[N,T,A="",M]=R,k=`<${T}${A} data-stx-memo="${W}"${M}>`;D=B.slice(0,V)+k+w.slice(N.length)+B.slice(V+w.length)}else D=`${B.slice(0,V)}<div data-stx-memo="${W}">${w}</div>${B.slice(V+w.length)}`;J.push({start:Q,end:j,replacement:D}),X.lastIndex=j}for(let Q=J.length-1;Q>=0;Q--){let G=J[Q];Z=Z.slice(0,G.start)+G.replacement+Z.slice(G.end)}return Z.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function O4($){let Z=$.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return Z=Z.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),Z}function b9($){let X=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"),Y="",J=0,Q;while((Q=X.exec($))!==null){let G=Q.index,q=G+Q[0].length,U=!1,W=!1,K=-1;while(q<$.length){let _=$[q];if(U){if(_==="'")U=!1}else if(W){if(_==='"')W=!1}else if(_==="'")U=!0;else if(_==='"')W=!0;else if(_===">"){K=q;break}q++}if(K===-1)continue;if($.slice(G,K+1).includes("x-cloak"))continue;let H=$.slice(K+1),B=H.indexOf("</"),j=B>=0?H.slice(0,B):H.slice(0,200);if(/\{\{[\s\S]*?\}\}/.test(j))Y+=$.slice(J,K)+" x-cloak>",J=K+1}return Y+=$.slice(J),Y}var hQ=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/;function y9($){let Z=/<[a-z][\w-]*/gi,X="",Y=0,J;while((J=Z.exec($))!==null){let Q=J.index,G=J[0].slice(1).toLowerCase();if(G==="script"||G==="style"){let j=`</${G}>`,_=$.toLowerCase().indexOf(j,Q);if(_!==-1)Z.lastIndex=_+j.length;continue}let q=Q+J[0].length,U=!1,W=!1,K=-1;while(q<$.length){let j=$[q];if(U){if(j==="'")U=!1}else if(W){if(j==='"')W=!1}else if(j==="'")U=!0;else if(j==='"')W=!0;else if(j===">"){K=q;break}q++}if(K===-1)continue;let z=$.slice(Q+J[0].length,K);if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(z))continue;if(!hQ.test(z))continue;let H=$[K-1]==="/",B=H?K-1:K;X+=`${$.slice(Y,B)} x-cloak${H?" ":""}`,Y=B}return X+=$.slice(Y),X}var uQ=[{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 @appearanceBootstrap if this must run before first paint, where the runtime does not exist yet"},{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"}];function V4($,Z,X,Y){let J=typeof X==="boolean"?{enabled:X,failOnViolation:X}:X??{enabled:!1},Q=J.allowPatterns??[],G=[],q=p0($.replace(/\{\{--[\s\S]*?--\}\}/g,(U)=>U.replace(/[^\n]/g," ")));for(let{pattern:U,message:W,suggestion:K}of uQ){if(Q.some((H)=>/\w/.test(H)&&W.includes(H)))continue;U.lastIndex=0;let z=q.match(U);if(z&&z.length>0){let H=q.split(`
|
|
3607
|
+
`),B=$.split(`
|
|
3608
|
+
`),j=[];H.forEach((F,L)=>{if(U.lastIndex=0,U.test(F))j.push(L+1)});let _=j.length>0?` (script line${j.length>1?"s":""} ${j.join(", ")})`:"",V=j.slice(0,3).map((F)=>` ${F} | ${(B[F-1]??"").trim().slice(0,100)}`).join(`
|
|
3609
|
+
`),O=V?`
|
|
3610
|
+
${V}`:"";G.push(` \u2717 ${W}${_}
|
|
3611
|
+
\u2192 ${K}${O}`)}}if(G.length>0&&J.enabled){let U=(z)=>{let H=`${process.cwd()}/`;return z.startsWith(H)?z.slice(H.length):z},K=`[STX] DOM API violation in ${Y&&Y!==Z?`${U(Y)} (composed into ${U(Z)})`:U(Z)}:
|
|
3612
|
+
${G.join(`
|
|
3613
|
+
`)}
|
|
3614
|
+
Tip: prefer useRef(), navigate(), and composables for component code`;if(J.failOnViolation)throw Error(K);else console.warn(K)}}dQ();var E1="<!--PARENT_CONTENT_PLACEHOLDER-->";function S9($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function lQ($,Z){let X=$.length,Y=Z,J=!0,Q=[],G=(q)=>q+9<=X&&$[q]==="<"&&$[q+1]==="/"&&($[q+2]==="s"||$[q+2]==="S")&&($[q+3]==="c"||$[q+3]==="C")&&($[q+4]==="r"||$[q+4]==="R")&&($[q+5]==="i"||$[q+5]==="I")&&($[q+6]==="p"||$[q+6]==="P")&&($[q+7]==="t"||$[q+7]==="T")&&($[q+8]===">"||/\s/.test($[q+8]));while(Y<X){let q=$[Y];if(G(Y))return Y;if(q==="/"&&$[Y+1]==="/"){if(Y=$.indexOf(`
|
|
3615
|
+
`,Y+2),Y===-1)return-1;Y+=1,J=!0;continue}if(q==="/"&&$[Y+1]==="*"){let U=$.indexOf("*/",Y+2);if(U===-1)return-1;Y=U+2,J=!0;continue}if(q==="/"&&J){let U=Y+1,W=!1;while(U<X){let K=$[U];if(K==="\\"){U+=2;continue}if(K==="[")W=!0;else if(K==="]")W=!1;else if(K==="/"&&!W){U++;break}else if(K===`
|
|
3616
|
+
`){U=-1;break}U++}if(U===-1){Y++,J=!1;continue}while(U<X&&/[a-z]/.test($[U]))U++;Y=U,J=!1;continue}if(q==="'"||q==='"'){let U=q;Y++;while(Y<X){if($[Y]==="\\"){Y+=2;continue}if($[Y]===U){Y++;break}if($[Y]===`
|
|
3617
|
+
`)break;Y++}J=!1;continue}if(q==="`"){Y++;while(Y<X){if($[Y]==="\\"){Y+=2;continue}if($[Y]==="`"){Y++;break}if($[Y]==="$"&&$[Y+1]==="{"){Q.push(!0),Y+=2,J=!0;break}Y++}if(Q.length===0)J=!1;continue}if(q==="}"&&Q.length>0){Q.pop(),Y++;while(Y<X){if($[Y]==="\\"){Y+=2;continue}if($[Y]==="`"){Y++,J=!1;break}if($[Y]==="$"&&$[Y+1]==="{"){Q.push(!0),Y+=2,J=!0;break}Y++}continue}if(/\s/.test(q));else if(/[)\].\w$]/.test(q))J=!1;else J=!0;Y++}return-1}function Z5($,Z){let X=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Y=new RegExp(`<script\\b(?=[^>]*\\b${X}(?:\\s|=|/?>))[^>]*>`,"i").exec($);if(!Y)return null;let J=Y.index+Y[0].length,Q=$.indexOf("</script>",J);if(Q===-1)return null;let G=$.indexOf(">",Q);if(G===-1)return null;return{start:Y.index,end:G+1}}function C9($){let Z=0;while(Z<$.length){let X=$.indexOf("<",Z);if(X===-1)return-1;if($.startsWith("<!--",X)){let Q=$.indexOf("-->",X+4);Z=Q===-1?$.length:Q+3;continue}let Y=$.slice(X),J=/^<style\b[^>]*>/i.exec(Y);if(J){let Q=$.toLowerCase().indexOf("</style>",X+J[0].length);Z=Q===-1?$.length:Q+8;continue}if(/^<script\b[^>]*>/i.test(Y))return X;Z=X+1}return-1}function cQ($){let Z=Z5($,"data-stx-runtime");if(!Z)return $;let X=C9($);if(X===-1||X===Z.start)return $;let Y=$.slice(Z.start,Z.end),J=$.slice(0,Z.start)+$.slice(Z.end),Q=C9(J);if(Q===-1)return Y+`
|
|
3618
|
+
`+J;return J.slice(0,Q)+Y+`
|
|
3619
|
+
`+J.slice(Q)}async function F4($,Z,X,Y,J){if(Y.ssr===!1&&!Y.autoShell&&Y.buildMode==="spa")return $;if(Z.__stx_signals_gate===void 0)Z.__stx_signals_gate=J1($);let Q=!Z.__stxProcessingDepth;if(Q)P4(Z);if(!Z.__stxProcessingDepth)Z.__stxProcessingDepth=0;if(Z.__stxProcessingDepth++,!Z.__onceStore)Z.__onceStore=new Set;if((Y.debug||!H5()&&!c5())&&X&&X.endsWith(".stx"))h9($,X);try{return await $7.timeAsync("template-processing",async()=>{let G=await pQ($,Z,X,Y,J);if(Q)G=O4(G);if(Q&&Y.autoShell&&Y.buildMode!=="compile"){let q=Y.app?.head||{},W=(Z.__stx_runtime_head||null)??g9(),K=(Z.__stx_head_raw||"").trim(),z,H=K.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(H)z=H[1].trim(),K=K.replace(H[0],"").trim();let B=Z.__sections?.title,j=W.title||z||B,_=!W.title&&(!!z||!!B),V=W.meta||[],O=new Set(V.map((N)=>i1(N)).filter(Boolean)),F={...q,...j&&{title:j},meta:[...(q.meta||[]).filter((N)=>!O.has(i1(N))),...V],link:[...q.link||[],...W.link||[]],script:[...q.script||[],...W.script||[]],headRaw:[q.headRaw,K].filter(Boolean).join(`
|
|
3620
|
+
`),...W.htmlAttrs&&{htmlAttrs:E2(q.htmlAttrs,W.htmlAttrs)},...W.bodyAttrs&&{bodyAttrs:{...q.bodyAttrs||{},...W.bodyAttrs}}},L=l3(G);if(G=C2(G,F,{..._&&{titleIsHtml:!0},...Y.app?.colorMode&&{colorMode:Y.app.colorMode}}),L)G=S2(G,q),G=b2(G,F.htmlAttrs);let w=G.match(/<!-- stx-layout: ([^ ]+) -->/);if(w&&G.includes("<head")){let N=w[1],T=f9(N);G=G.replace(/<head\b[^>]*>/i,(A)=>`${A}
|
|
3621
|
+
<meta name="stx-layout" content="${S9(N)}">
|
|
3622
|
+
<meta name="stx-layout-group" content="${S9(T)}">`)}let R=G.match(/function (__stx_setup_\d+_\d+)\(/),D=R?q5(G):null;if(R&&D&&!/\bdata-stx=/.test(D.tag)){G=g5(G,(T,A)=>`<body${A} data-stx="${R[1]}">`);let N=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${R[1]}"`,"i");G=G.replace(N,"$1")}}if(Q){G=y2(G);let q=Y.app?.colorMode;if(q)G=A2(G,q);G=T2(G),G=cQ(G)}if(Q)try{let{getStoreScript:q}=await a("stx/store-loader",()=>import("./chunk-rdf7d42n.js")),U=Y.storesDir,W=await q(U);if(W){let K=`<script data-stx-stores>${W}</script>`,z=Z5(G,"data-stx-runtime");if(z)G=G.slice(0,z.end)+`
|
|
3623
|
+
`+K+G.slice(z.end)}}catch{}if(Q)try{let{getFrameworkComposableScript:q}=await a("stx/framework-composables",()=>import("./chunk-y35rktea.js")),U=await q(G);if(U){let W=Z5(G,"data-stx-stores")||Z5(G,"data-stx-runtime");if(W)G=G.slice(0,W.end)+`
|
|
3624
|
+
`+U+G.slice(W.end)}}catch{}if(Q)try{let{getComposableScript:q}=await a("stx/composable-loader",()=>import("./chunk-dxfcyj8t.js")),U=Y.composablesDir,W=await q(U,G);if(W){let K=`<script data-stx-composables>${W}</script>`,z=Z5(G,"data-stx-stores")||Z5(G,"data-stx-runtime");if(z)G=G.slice(0,z.end)+`
|
|
3625
|
+
`+K+G.slice(z.end)}}catch{}if(Q)G=M2(G);if(Q&&Z.__stx_inject_css!==!1)G=await x9(G,void 0,Y.buildMode==="serve");if(Q)G=N2(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof n5)throw G;let q=G instanceof Error?G.message:String(G),U=new L1(`Template processing failed: ${q}`,X,void 0,void 0,$.substring(0,200)+($.length>200?"...":""));if(u0.log(U,{filePath:X,context:Z}),Z3.logDetailedError(U,{filePath:X,template:$.substring(0,500)}),Y.debug)throw U;return e$.createFallbackContent("Template Processing",U)}}async function pQ($,Z,X,Y,J){let Q=process.cwd(),G={...Y,partialsDir:Y.partialsDir&&!R0.isAbsolute(Y.partialsDir)?R0.resolve(Q,Y.partialsDir):Y.partialsDir,componentsDir:Y.componentsDir&&!R0.isAbsolute(Y.componentsDir)?R0.resolve(Q,Y.componentsDir):Y.componentsDir,layoutsDir:Y.layoutsDir&&!R0.isAbsolute(Y.layoutsDir)?R0.resolve(Q,Y.layoutsDir):Y.layoutsDir},q=G,U=$;await sQ(X,Z),nQ(Z,q),U=await h1(()=>G2(U,Z,X,q),U,(L)=>{u0.log(L,{filePath:X,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${X}: ${L.message}`)}),U=U.replace(/\{\{--[\s\S]*?--\}\}/g,"");let W=l0(U,Q5,(L,w)=>`\x00STX_HTML_COMMENT_${w}\x00`);U=W.output;let K=W.tokens,z=(L)=>K.length===0?L:L.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(w,R)=>K[Number(R)]??""),H="\x00STX_ESCAPED_AT\x00";U=U.replace(/@@/g,H),U=U.replace(/@\{\{([\s\S]*?)\}\}/g,(L,w)=>{return`{{ ${w} }}`}),U=j2(U),U=await k9(U,X,J);let B={};U=C3(U,B);let j={...Z.__sections||{}},_="",V=O7(_7($)),O=/@nolayout\b/.test(U)||V===!1;if(/@nolayout\b/.test(U))U=U.replace(/@nolayout\b\s*/g,"");let F=U.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(F)_=F[1],U=U.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof V==="string"){if(_=V,!/@section\s*\(/.test(U))U=`@section('content')
|
|
3626
|
+
${U.trim()}
|
|
3627
|
+
@endsection`}if(!_&&!O&&q.defaultLayout){let L=m3(U),w=/@section\s*\(/.test(U);if(!L||w){let R="",D=R0.dirname(X),N=q.layoutsDir?R0.dirname(q.layoutsDir):process.cwd();for(let T=0;T<20;T++){let A=R0.join(D,"_layout.stx");if(await r(A)){R=A;break}let M=R0.dirname(D);if(M===D||M.length<N.length)break;D=M}if(R)_=R;else if(q.layoutsDir){let T=R0.isAbsolute(q.layoutsDir)?q.layoutsDir:R0.resolve(process.cwd(),q.layoutsDir),A=R0.join(T,`${q.defaultLayout}.stx`);if(await r(A))_=A}if(_&&!w)U=`@section('content')
|
|
3628
|
+
${U.trim()}
|
|
3629
|
+
@endsection`}}if(U=U.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(L,w,R)=>{return j[w]=R,""}),U=U.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(L,w,R)=>{if(/^(['"]).*\1$/.test(R.trim()))return L;try{let D=X0(R.trim(),Z);if(D===void 0)return L;return j[w]=String(D??""),""}catch{return L}}),U=U.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(L,w,R)=>{if(R.includes("@parent"))j[w]=R.replace("@parent",E1);else j[w]=R.trim();return""}),Z.__sections=j,U=U.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(L,w,R)=>{return j[w]||R||""}),!("slot"in Z)||Z.slot===void 0)U=U.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""});if(U=P3(U,B),_){let L=[],w=c0(U),R=l0(w.output,S1,(D,N)=>`\x00STX_ORPHAN_STYLE_${N}\x00`);if(U=R.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(D,N,T)=>{let A=N==="SCRIPT"?w.scripts[Number(T)]:R.tokens[Number(T)];if(A)L.push(A);return""}),L.length>0){let D=L.join(`
|
|
3630
|
+
`);j.content=j.content?`${j.content}
|
|
3631
|
+
${D}`:D,Z.__sections=j}}if(_)try{let L;if(R0.isAbsolute(_))L=_,J.add(_);else L=await h1(()=>r5(_,X,G,J),null,()=>{throw new L1(`Failed to resolve layout path: ${_}`,X,void 0,void 0,`Layout referenced from ${X}`)});if(!L){let A=(I)=>{if(!I)return[];try{let y=R0.isAbsolute(I)?I:R0.resolve(process.cwd(),I);return mQ.readdirSync(y).filter((E)=>E.endsWith(".stx")).map((E)=>E.replace(/\.stx$/,""))}catch{return[]}},M=[...A(G.layoutsDir),...A(G.fallbackLayoutsDir)].filter((I,y,E)=>E.indexOf(I)===y).sort(),k=`Layout not found: ${_} (referenced from ${X})`+(M.length>0?`. Available layouts: ${M.join(", ")}`:G.layoutsDir?`. No .stx layouts found in ${G.layoutsDir}`:"");if(u0.log(Error(k),{layoutPath:_,filePath:X,available:M},"error"),console.error(`[stx] ${k}`),G.debug)throw new L1(k,X);return U}let w=await h1(()=>Bun.file(L).text(),"",()=>{throw new L1(`Failed to read layout file: ${L}`,X,void 0,void 0,"Layout content could not be loaded")}),R=w.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(R){if(G.debug)console.log(`Found nested layout: ${R[1]} in ${L}`);let A={},M=w.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(y,E,b)=>{return A[E]=b.trim(),""});for(let[y,E]of Object.entries(A))if(j[y]&&j[y].includes(E1)){let b=j[y].indexOf(E1);j[y]=j[y].slice(0,b)+E+j[y].slice(b+E1.length)}else if(!j[y])j[y]=E;let k={...Z,__sections:j},I=`@layout('${R[1]}')${M}`;return await F4(I,k,L,G,J)}let D=w.replace(/\{\{--[\s\S]*?--\}\}/g,""),N=C3(D,B),T={};return N=N.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(A,M,k)=>{return T[M]=k.trim(),`@slot('${M}')`}),N=N.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(A,M,k)=>{if(j[M]){let I=j[M];if(I.includes(E1)){let y=T[M]||"",E=I.indexOf(E1);I=I.slice(0,E)+y+I.slice(E+E1.length)}return I}return k||""}),N=iQ(N,j),N=N.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""}),N=P3(N,B),Z.__originalFilePath=X,U=await P9(N,Z,L,G,J),U=`<!-- stx-layout: ${_} -->
|
|
3632
|
+
${U}`,z(U)}catch(L){return u0.log(L instanceof Error?L:Error(String(L)),{layoutPath:_,filePath:X},"error"),`[Error processing layout: ${L instanceof Error?L.message:String(L)}]`}return z(await P9(U,Z,X,G,J))}function iQ($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(X,Y,J)=>{let Q=Z[Y];if(Q!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(Q))return Q}return J||""})}function nQ($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let X=Z.envPrefix||"STX_PUBLIC_",Y={};for(let[J,Q]of Object.entries(process.env))if(J.startsWith(X)&&Q!==void 0)Y[J]=Q;$.$env=Y}async function sQ($,Z){await h1(()=>W2($,Z),void 0,(X)=>{u0.log(X,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${X.message}`)})}async function oQ($,Z,X){let Y=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,J;while((J=Y.exec($))!==null){let Q=J[1],G=J[2];if(!/\bserver\b/.test(Q)||!G.trim())continue;try{let{extractVariables:U}=await a("stx/variable-extractor",()=>import("./chunk-0w0mrtme.js"));await U(G,Z,X,{preserveExisting:!0})}catch(U){let W=U instanceof Error?U:Error(String(U));u0.log(W,{filePath:X,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${X}: ${W.message}`)}}}async function rQ($,Z,X){try{let{interpolateScriptsInTemplate:Y}=await a("stx/expressions",()=>import("./chunk-yv340gxj.js"));return Y($,Z,{skipServer:!0})}catch(Y){let J=Y instanceof Error?Y:Error(String(Y));return u0.log(J,{filePath:X,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${X}: ${J.message}`),$}}async function P9($,Z,X,Y,J){let Q=$,G=Y;if(await oQ(Q,Z,X),Q=await rQ(Q,Z,X),Q=await n6(Q,Z,X),Q=await s6(Q,Z,X),Q=await b6(Q,Z,X,G),J1(Q))Q=r2(Q,Z),Q=e2(Q,Z);Q=t2(Q);let{processStreamDirectives:q}=await a("stx/streaming",()=>import("./chunk-v3ryxw4v.js"));Q=q(Q,Z),Q=Z2(Q,Z,X,G),Q=await F2(Q,Z,X,G,J),Q=await B4(Q,Z,X,G,J),Q=j7(Q,Z,X,G);let{processDeferDirectives:U}=await a("stx/defer",()=>import("./chunk-3vy1q9da.js"));Q=U(Q,Z,X);let{processTeleportDirectives:W}=await a("stx/teleport",()=>import("./chunk-rs2fa3g1.js"));Q=W(Q,Z,X);let{processTransitionDirectives:K,processTransitionAttributes:z}=await a("stx/transitions",()=>import("./chunk-7w4c5w2b.js"));Q=K(Q,Z,X),Q=z(Q);let{processErrorBoundaryDirectives:H}=await a("stx/error-boundaries",()=>import("./chunk-qz75kx6n.js"));Q=H(Q,Z,X);let{processSuspenseDirectives:B}=await a("stx/suspense",()=>import("./chunk-jr5tp4ks.js"));Q=B(Q,Z,X);let{processAsyncDirectives:j}=await a("stx/async-components",()=>import("./chunk-va9k88da.js"));Q=j(Q,Z,X);let{processKeepAliveDirectives:_}=await a("stx/keep-alive",()=>import("./chunk-dhpy0h9y.js"));Q=_(Q,Z,X);let{processVirtualListDirectives:V,processVirtualGridDirectives:O,processInfiniteListDirectives:F}=await a("stx/virtual-scrolling",()=>import("./chunk-4pf61rcb.js"));Q=V(Q,Z,X),Q=O(Q,Z,X),Q=F(Q,Z,X);let{processPartialHydrationDirectives:L,processStaticDirectives:w}=await a("stx/partial-hydration",()=>import("./chunk-wtengj6h.js"));Q=L(Q,Z,X),Q=w(Q);let{processComputedDirectives:R,processWatchDirectives:D}=await a("stx/computed",()=>import("./chunk-zda3hvde.js"));Q=R(Q,Z,X),Q=D(Q,Z,X);let{processFormValidationDirectives:N}=await a("stx/forms-validation",()=>import("./chunk-5s2y052b.js"));Q=N(Q,Z,X);let{processHeadDirective:T,processTitleDirective:A,processMetaDirective:M,resetHead:k}=await a("stx/head",()=>import("./chunk-jpbk42j7.js"));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)k();let I=T(Q);if(Q=I.content,I.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${I.headContent}
|
|
3633
|
+
`;if(Q=A(Q,Z),Q=M(Q,Z),Q=U2(Q),Q=B3(Q,Z),Q=E6(Q),Q=J2(Q),Q=await S3(Q,Z,X,G,J),Q=await B4(Q,Z,X,G,J),Z.__stxProcessingDepth===1)Q=f4(Q,Z);if(Q=Q.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),Q=O4(Q),Q=a0(Q,Z,X),Q=j3(Q,Z),Q=_3(Q,Z),Q=F5(Q,Z),Q=D3(Q,Z),Q=N3(Q,Z),Q=await O6(Q,Z,X,G),Q=await N7(Q,Z,X),Q=await d6(Q,Z,X,G),Q=v9(Q,Z,X,G),Q=Z6(Q,Z,X,G),Q=X6(Q,Z,X),Q=Y6(Q,Z,X,G),Q=I6(Q,Z,X,G),Q=j4(Q,Z),Q=_4(Q),Q=E9(Q),!G.skipEventDirectives)Q=S4(Q,Z,X);if(Q=L7(Q,Z,X),G.debug){let p=/\bx-data\s*=/.test(Q),e=r3($);if(p&&e)console.warn(`[stx] ${X}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
3634
|
+
Both work on the same page, but they manage separate scopes.
|
|
3635
|
+
Prefer signals (state/derived/effect) for new components.`)}Q=H2(Q,Z),Q=await _1(Q,Z,X),Q=b9(Q),Q=y9(Q),Q=G7(Q);let{processXElementDirectives:y}=await a("stx/x-element",()=>import("./chunk-wnaddtv3.js"));Q=y(Q);let E=Z.__originalFilePath||X,b=D$(Z);if(Q=await $9(Q,G,E,b),Q=P6(Q,Z),Q=await q2(Q,Z,X,G),G.media?.image?.autoSiblings){let p=G.publicDir||"public",{rewriteImagesWithSiblings:e}=await a("stx/image-optimization/auto-sibling",()=>import("./chunk-6bxcjdp4.js"));Q=await e(Q,{publicDir:p})}if(G.seo?.enabled)Q=J6(Q,Z,G);let C=(p,e,J0=!0)=>{if(!e)return p;let T0=e.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),F0=p.match(/<title\b[^>]*>[\s\S]*?<\/title>/i);if(T0&&F0){if(J0)p=p.replace(F0[0],T0[0]);if(e=e.replace(T0[0],"").trim(),!e)return p}if(/<\/head>/i.test(p))return p.replace(/<\/head>/i,`${e}
|
|
3636
|
+
</head>`);if(/<head\b[^>]*>/i.test(p))return p.replace(/(<head\b[^>]*>)/i,`$1
|
|
3637
|
+
${e}`);if(/<html\b[^>]*>/i.test(p))return p.replace(/(<html\b[^>]*>)/i,`$1
|
|
3638
|
+
<head>
|
|
3639
|
+
${e}
|
|
3640
|
+
</head>`);return p},{renderHead:x,getHead:f}=await a("stx/head",()=>import("./chunk-jpbk42j7.js")),m=Z.__stx_runtime_head??f();if(m.title||m.meta?.length||m.link?.length){let p=x(m);if(p)Q=C(Q,p)}if(I.headContent)Q=C(Q,I.headContent,!m.title);if(G.csp?.enabled&&G.csp.addMetaTag)Q=M6(Q,G.csp,Z);if(G.analytics?.enabled)Q=U7(Q,G);if(G.heatmap?.enabled)Q=K7(Q,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:p}=await a("stx/pwa/inject",()=>import("./chunk-mtr2f82n.js"));Q=p(Q,G)}let V0=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(Q),A0=/\bSTX\.\w+/.test(Q),M0=/window\.STX\s*=/.test(Q);if(V0&&A0&&!M0){let e=`<script data-stx-scoped data-stx-run="once">
|
|
3641
|
+
${Y7()}
|
|
3642
|
+
</script>`;if(Q.includes("</head>")){let J0=Q.indexOf("</head>"),F0=Q.slice(0,J0).indexOf("<script");if(F0!==-1){let P0=Q.slice(0,F0),S=Q.slice(F0);Q=P0+e+`
|
|
3643
|
+
`+S}else Q=Q.replace("</head>",`${e}
|
|
3644
|
+
</head>`)}else if(Q.includes("<body"))Q=Q.replace(/<body([^>]*)>/,`<body$1>
|
|
3645
|
+
${e}`);else Q=e+`
|
|
3646
|
+
`+Q}{let{scanScriptTags:p}=await a("stx/signal-processing",()=>import("./chunk-w29sv5jf.js")),e=[];for(let J0 of p(Q)){if(!/\bserver\b/i.test(J0.attrs))continue;let T0=J0.start+J0.fullMatch.indexOf(">")+1,F0=lQ(Q,T0);if(F0===-1)continue;let P0=F0+9;while(P0<Q.length&&/\s/.test(Q[P0]))P0++;e.push({start:J0.start,end:P0})}for(let J0=e.length-1;J0>=0;J0--){let{start:T0,end:F0}=e[J0];Q=Q.substring(0,T0)+Q.substring(F0)}}let g0=W$(Q,X);if(g0.hasScoped)Q=g0.html;let t=Z.__stx_event_bindings||[],K0=!1,q0=[],B1=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:Y5}=await a("stx/signal-processing",()=>import("./chunk-w29sv5jf.js"));for(let p of Y5(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))q0.push({match:p.fullMatch,attrs:p.attrs,content:p.body});for(let{match:p,attrs:e,content:J0}of q0){K0=!0;let T0=J0;V4(J0,X,Y.strict,Z.__originalFilePath);let F0=await N$(J0,{eventBindings:t,attrs:e,hasColonDirectives:B1,templateContent:$,filePath:X,projectRoot:process.cwd(),production:Y.buildMode==="compile",serverData:b});Q=Q.replace(p,()=>F0)}if(K0)Z.__stx_event_bindings=[];if(!K0&&Z.__stxProcessingDepth===1){let p=Z.__stx_event_bindings||[];if(p.length>0){let e=k$(p);if(e){let J0=Q.lastIndexOf("</body>");Q=J0===-1?Q+e:Q.slice(0,J0)+e+`
|
|
3647
|
+
`+Q.slice(J0)}Z.__stx_event_bindings=[]}}if(!h2(Q)&&u2(Q))Q=await B$(Q,G);if(Q=d2(Q),G.csp?.enabled&&G.csp.useNonce&&typeof Z.cspNonce==="string")Q=T6(Q,Z.cspNonce);return Q}var aQ=[{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"}],tQ=[{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')"}],eQ=[{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 $G($){let Z=[],X=[];return ZG($,Z),XG($,Z,X),YG($,X),JG($,Z),{valid:Z.length===0,errors:Z,warnings:X}}function ZG($,Z){let X=($.match(/\{\{/g)||[]).length,Y=($.match(/\}\}/g)||[]).length;if(X!==Y)Z.push({type:"expression",message:`Unclosed expression brackets: found ${X} opening '{{' and ${Y} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function XG($,Z,X){for(let Y of aQ){let J=new RegExp(`${Y.open}(?:\\s|\\()`,"g"),Q=new RegExp(Y.close,"g"),G=($.match(J)||[]).length,q=($.match(Q)||[]).length;if(Y.altClose){let U=new RegExp(Y.altClose,"g");q+=($.match(U)||[]).length}if(G>q)Z.push({type:"directive",message:`Unclosed @${Y.name} directive: found ${G} opening and ${q} closing`,suggestion:`Add ${G-q} missing ${Y.close} tag(s)`});else if(q>G)X.push({type:"directive",message:`Extra ${Y.close} found: ${q-G} more closing than opening`,suggestion:`Check for orphaned ${Y.close} tags`})}}function YG($,Z){for(let X of tQ)if(X.pattern.test($))Z.push({type:"syntax",message:X.message,suggestion:X.suggestion})}function JG($,Z){for(let X of eQ)if(X.pattern.test($))Z.push({type:"expression",message:`Security warning: ${X.message}`,suggestion:"Remove dangerous code from template expressions"})}function QG($,Z){let X=$.slice(0,Z).split(`
|
|
3648
|
+
`);return{line:X.length,column:X[X.length-1].length+1}}function GG($,Z,X){let Y=[];switch($){case"if":case"elseif":case"unless":if(X.length===0)Y.push({type:"syntax",message:`@${$} requires a condition`,suggestion:`Use @${$}(condition)`});break;case"foreach":if(X.length===0||!X[0].includes(" as "))Y.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(X.length===0)Y.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(X.length===0)Y.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(X.length===0)Y.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(X.length===0)Y.push({type:"syntax",message:`@${$} requires a path`,suggestion:`Use @${$}('path/to/template')`});break}return Y}function qG($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function UG($){let Z=$.matchAll(/@([a-z]+)/gi),X=new Set;for(let Y of Z){let J=Y[1].toLowerCase();if(!J.startsWith("end"))X.add(J)}return Array.from(X)}import n0 from"path";import X5 from"process";var n9=["module","exports","require","props","$props","defineProps","withDefaults","defineClientPayload","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","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"],u9=new Set(n9),WG=new Set(["props","$props","defineProps"]),KG=new Set(["stx","@stacksjs/stx"]);function zG($){let Z=[],X=0,Y=$.split(`
|
|
3649
|
+
`);for(let J of Y){let Q=X,G=null,q=!1;for(let U=0;U<J.length;U++){let W=J[U];if(q){q=!1;continue}if(W==="\\"){q=!0;continue}if(G){if(W===G)G=null;continue}if(W==="'"||W==='"'||W==="`"){G=W;continue}if(W==="/"&&U+1<J.length&&J[U+1]==="/")break;if(W==="{")X++;else if(W==="}")X--}if(Q===0){let U=J.match(/(?:const|let|var)\s+(\w+)\s*=/);if(U)Z.push(U[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(J)){let W=J.match(/(?:const|let|var)\s+(\w+)/);if(W)Z.push(W[1])}else{let W=J.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(W){let z=W[1].slice(1,-1).split(",").map((H)=>{let B=H.split(":");return(B.length>1?B[1]:B[0]).trim()}).filter((H)=>/^\w+$/.test(H));Z.push(...z)}}}}return[...new Set(Z)]}function HG($){let Z=$;Z=Z.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),Z=Z.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),Z=Z.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function X(Y){if(!Y.includes(":"))return Y;let J=[],Q="",G=0,q=0,U=null;for(let W=0;W<Y.length;W++){let K=Y[W];if(U){if(Q+=K,K===U)U=null;continue}if(K==='"'||K==="'"||K==="`"){U=K,Q+=K;continue}if(K==="<")G++;else if(K===">"&&G>0)G--;else if(K==="(")q++;else if(K===")")q--;if(K===","&&G===0&&q===0){J.push(Q),Q="";continue}Q+=K}if(Q)J.push(Q);return J.map((W)=>{let K=W.trim(),z=K.startsWith("..."),H=z?K.slice(3):K,B=-1,j=0;for(let R=0;R<H.length;R++)if(H[R]==="<")j++;else if(H[R]===">")j--;else if(H[R]===":"&&j===0){B=R;break}if(B===-1)return W;let V=H.substring(0,B).trim().replace(/\?$/,""),O=H.substring(B+1),F=-1,L=0;for(let R=0;R<O.length;R++)if(O[R]==="<")L++;else if(O[R]===">")L--;else if(O[R]==="="&&L===0){F=R;break}let w=z?"...":"";if(F!==-1)return`${w}${V} = ${O.substring(F+1).trim()}`;return`${w}${V}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(Y,J,Q)=>{if(!Q.includes(":"))return Y;return`${J}(${X(Q)})`});{let Y=/\b(function\s+\w*\s*)\(/g,J,Q=[];while((J=Y.exec(Z))!==null){let G=J.index+J[0].length-1,q=1,U=G+1,W=0,K=null;while(U<Z.length&&q>0){let B=Z[U];if(K){if(B===K)K=null;U++;continue}if(B==='"'||B==="'"||B==="`"){K=B,U++;continue}if(B==="<")W++;else if(B===">"&&W>0)W--;else if(W===0){if(B==="(")q++;else if(B===")")q--}if(q>0)U++}if(q!==0)continue;let z=Z.substring(G+1,U);if(!z.includes(":"))continue;let H=X(z);Q.push({start:G+1,end:U,replacement:H})}for(let G=Q.length-1;G>=0;G--){let{start:q,end:U,replacement:W}=Q[G];Z=Z.substring(0,q)+W+Z.substring(U)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(Y,J)=>{if(!J.includes(":"))return Y;if(J.includes("{")||J.includes("}"))return Y;return`(${J.split(",").map((G)=>{let[q,...U]=G.split("="),W=q.split(":")[0].trim();if(U.length>0)return`${W} = ${U.join("=").trim()}`;return W}).join(", ")}) =>`}),Z=Z.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"),Z=Z.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),Z=Z.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),Z=Z.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),Z=Z.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),Z=Z.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),Z=Z.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),Z=Z.replace(/\n\s*\n\s*\n/g,`
|
|
3650
|
+
|
|
3651
|
+
`),Z}function BG($){return/cannot find module|could not resolve|module not found|failed to resolve/i.test($)}function jG($){if(!/is not defined|can't find variable/i.test($))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test($)}async function _G($,Z,X,Y={}){if(!$.trim())return;let J;try{let S=w4({loader:"ts",target:"browser",define:e1()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),J=S.transformSync(v)}catch{J=HG($)}let Q={exports:{}},G=Q.exports,q=X5.cwd(),U={},W=[...J.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((S)=>S[1]).filter((S)=>!S.startsWith("node:")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(S)),K=new Map;for(let S of W)try{if(S.startsWith(".")){U[S]=await import(n0.resolve(n0.dirname(X),S));continue}let v=n0.resolve(q,"node_modules",S),d=n0.join(v,"package.json"),P=JSON.parse(h("fs").readFileSync(d,"utf8")),u=P.main||"index.js";if(P.exports){let s=typeof P.exports==="string"?P.exports:P.exports["."];if(typeof s==="string")u=s;else if(s?.bun)u=s.bun;else if(s?.import)u=s.import;else if(s?.default)u=s.default}U[S]=await import(n0.resolve(v,u))}catch(v){if(S.startsWith("."))K.set(S,v instanceof Error?v.message:String(v))}let z=(S)=>{if(U[S])return U[S];let v=K.get(S);if(v!==void 0)throw Error(`Cannot require '${S}' from ${X}: ${v}`);return h(S)},H=Z.props||{},B=(S)=>{if(!S)return H;let v={};for(let[d,P]of Object.entries(S)){let u=H[d];if(u!==void 0)v[d]=u;else if(typeof P==="function")v[d]=P();else v[d]=P}return v};for(let[S,v]of Object.entries(H))Object.defineProperty(B,S,{value:v,enumerable:!0,configurable:!0,writable:!0});for(let S of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(H,S))continue;try{Object.defineProperty(B,S,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let j=(S)=>{if(!S)return H;let v={...H};for(let[d,P]of Object.entries(S)){let u=P&&typeof P==="object"&&!Array.isArray(P)?P:{type:P};if(v[d]===void 0&&u.default!==void 0)v[d]=typeof u.default==="function"?u.default():u.default}return v},_=()=>Z.slots||{},V=(S,v)=>{let d={...S};for(let[P,u]of Object.entries(v))if(d[P]===void 0)if(typeof u==="function")d[P]=u();else d[P]=u;return d},O=(S)=>{let v=()=>S;return v.set=(d)=>{},v.update=(d)=>{},v},F=(S)=>{let v,d=!1;return()=>{if(!d)try{v=S(),d=!0}catch{v=void 0}return v}},L=(S)=>{},w=(S)=>S(),R=(S)=>{},D=(S)=>{};function N(S){let v=S||{};if(v.title!==void 0||v.description!==void 0)I({title:v.title,description:v.description})}function T(S){if(!S||typeof S!=="object")return;let v=Z.__stxClientPayload??{};Object.assign(v,S),Z.__stxClientPayload=v}let A=()=>{let S=Z.__stxServeContext,v=Z.__stxServeSearch??S?.search??"",d=S?.path??"",P=Object.fromEntries(new URLSearchParams(v)),u=Z.query,s=Object.keys(P).length>0?P:u??{},o=v||(Object.keys(s).length>0?`?${new URLSearchParams(s).toString()}`:"");return{params:Z.params??{},query:s,path:d,name:"",fullPath:d+o,hash:"",matched:[]}},M=()=>({push:(S)=>{},replace:(S)=>{},back:()=>{},forward:()=>{},go:(S)=>{}}),k=(S)=>{let v=Z.__stx_runtime_head||{};Z.__stx_runtime_head=o5(v,S||{})},I=(S)=>{k(i9(S||{}))},y=(S)=>({value:S}),E=(S)=>S,b=(S)=>({value:typeof S==="function"?S():S}),C=(S,v)=>{},x=(S)=>{},f=(S)=>{},n=(S)=>S?S():Promise.resolve(),m=(S)=>(v,...d)=>{},V0=(S)=>{},A0=(S,v)=>{},M0=(S,v)=>v,g0=()=>({value:"light"}),t=()=>O(!1),K0=(S)=>O(!1),q0=()=>O(!1),B1=()=>K0("(prefers-color-scheme: dark)"),Y5=()=>K0("(prefers-color-scheme: light)"),p=()=>K0("(prefers-reduced-motion: reduce)"),e=()=>K0("(prefers-contrast: more)"),J0={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:{}},T0=new Proxy(J0,{get(S,v){if(v in S)return S[v];return},set(S,v,d){return S[v]=d,!0}}),F0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},P0=console;try{let S=s9(J,X),v=new Set(Object.keys(H)),d=(i)=>/^[a-z_$][\w$]*$/i.test(i),P=Object.keys(Z).filter((i)=>!v.has(i)&&!WG.has(i)&&d(i)),u=P.map((i)=>Z[i]);if(!P.includes("__stxServeContext"))P.push("__stxServeContext"),u.push(void 0);let s=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),o=[],z0=[];for(let[i,Y0]of Object.entries(H)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(i))continue;if(s.has(i))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${i}\\b`).test(S))continue;o.push(i),z0.push(Y0)}let $1=zG(S).map((i)=>`module.exports.${i} = typeof ${i} !== 'undefined' ? ${i} : module.exports.${i};`).join(`
|
|
3652
|
+
`),E0=Z.params??{},D0=[],v0=[];for(let i=0;i<P.length;i++){if(P[i]==="params")continue;D0.push(P[i]),v0.push(u[i])}let Z1=await Function(...n9,...o,...D0,`return (async () => {
|
|
3653
|
+
${S}
|
|
3654
|
+
${$1}
|
|
3655
|
+
return module.exports
|
|
3656
|
+
})()`)(Q,G,z,H,B,j,V,T,O,F,L,w,R,D,N,A,M,k,I,y,E,b,C,x,f,n,m,V0,_,A0,M0,g0,t,K0,q0,B1,Y5,p,e,T0,F0,P0,J0.confirm,J0.alert,J0.fetch,E0,...z0,...v0);if(Y.preserveExisting){for(let[i,Y0]of Object.entries(Z1))if(!(i in Z)||Z[i]===void 0)Z[i]=Y0}else Object.assign(Z,Z1);for(let[i,Y0]of Object.entries(H))if(!(i in Z))Z[i]=Y0}catch(S){let v=S instanceof Error?S.message:String(S);if(BG(v))console.warn(`[stx] server <script> in ${X??"<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${v}`);else if(jG(v))console.warn(`[stx] server <script> in ${X??"<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: ${v}`);else if(X5.env.STX_DEBUG)console.warn(`[stx] server <script> did not execute in ${X??"<unknown>"} \u2014 falling back to static extraction. Cause: ${v}`);try{await NG(J,Z,X)}catch(d){if(X5.env.STX_DEBUG){let P=d instanceof Error?d.message:String(d);console.warn(`[stx] fallback extraction also failed in ${X??"<unknown>"}: ${P}`)}}}}function OG($){let Z=0,X=null,Y=!1,J=!1;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(X){if(G===X){if(X=null,Y||Z===0)J=!0}continue}if(G==="'"||G==='"'||G==="`"){X=G;continue}if(G==="{")Z++;else if(G==="}")Z--;else if($.startsWith("from",Q)&&Z===0)Y=!0}return X===null&&Z===0&&J}var VG=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/;function s9($,Z){let X=Z?n0.dirname(Z):X5.cwd(),Y=X5.cwd(),J=$.split(`
|
|
3657
|
+
`),Q=[],G=0;while(G<J.length){let q=J[G].trim();if(q.startsWith("interface ")||q.startsWith("export interface ")||q.startsWith("type ")||q.startsWith("export type ")){if(q.includes("{")&&!q.includes("}")){let U=0;for(;G<J.length;G++){for(let W of J[G])if(W==="{")U++;else if(W==="}")U--;if(U<=0)break}}G++;continue}if(q.startsWith("definePageMeta(")){let U=0,W=!1,K=G;for(let B=G;B<J.length&&!W;B++){let j=null,_=!1,V=J[B];for(let O=0;O<V.length;O++){let F=V[O];if(_){_=!1;continue}if(F==="\\"){_=!0;continue}if(j){if(F===j)j=null;continue}if(F==='"'||F==="'"||F==="`"){j=F;continue}if(F==="(")U++;else if(F===")"){if(U--,U===0){G=B+1,W=!0;break}}}}if(!W)G=J.length;let z=J.slice(K,G).join(`
|
|
3658
|
+
`),H=[];for(let B of["title","description"]){let j=new RegExp(`\\b${B}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(z);if(j)H.push(`${B}: ${JSON.stringify(j[2])}`)}if(H.length>0)Q.push(`useSeoMeta({ ${H.join(", ")} });`);continue}if(q.startsWith("import ")||q==="import"||q.startsWith("import{")){let U=q,W=0;while(!OG(U)&&G+W+1<J.length)W++,U=`${U} ${J[G+W].trim()}`;G+=W;let K=U.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),z=U.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),H=U.match(/^import\s+['"](.+?)['"]/),B=U,j=(_)=>{if(_.startsWith("."))return n0.resolve(X,_);if(_.startsWith("~/")||_.startsWith("@/"))return n0.resolve(Y,_.slice(2));return _};if(K){let[,_,V]=K,O=j(V);Q.push(`const ${_} = (await import('${O}')).default`),Q.push(`module.exports.${_} = ${_};`)}else if(z){let[,_,V]=z,O=j(V),F=[],L=[],w=KG.has(V);for(let R of _.split(",")){let D=R.trim();if(!D)continue;let N=D.split(/\s+as\s+/);if(N.length===2){let[T,A]=[N[0].trim(),N[1].trim()];if(w&&u9.has(T)){Q.push(`const ${A} = ${T};`);continue}F.push(`${T}: ${A}`),L.push(A)}else{if(w&&u9.has(D))continue;F.push(D),L.push(D)}}if(F.length>0)Q.push(`const { ${F.join(", ")} } = await import('${O}')`);for(let R of L)Q.push(`module.exports.${R} = ${R};`)}else if(H){let _=j(H[1]);Q.push(`await import('${_}')`)}else Q.push(B);G++;continue}if(VG.test(q))Q.push(J[G]),G++;else if(q.startsWith("export const ")||q.startsWith("export let ")||q.startsWith("export var ")){let U=m9(J,G),{type:W,name:K,value:z}=U;Q.push(`${W} ${K} = ${z};`),Q.push(`module.exports.${K} = ${K};`),G=U.nextIndex}else if(q.startsWith("export function ")||q.startsWith("export async function ")){let U=L4(J,G);Q.push(U.functionCode),Q.push(`module.exports.${U.name} = ${U.name};`),G=U.nextIndex}else if(q.startsWith("const ")||q.startsWith("let ")||q.startsWith("var ")){let U=m9(J,G),{type:W,name:K,value:z}=U;Q.push(`${W} ${K} = ${z};`),Q.push(`module.exports.${K} = ${K};`),G=U.nextIndex}else if(q.startsWith("function ")||q.startsWith("async function ")){let U=L4(J,G);Q.push(U.functionCode),Q.push(`module.exports.${U.name} = ${U.name};`),G=U.nextIndex}else if(q.startsWith("export default function ")||q.startsWith("export default async function ")){let U=J[G].replace(/^(\s*)export\s+default\s+/,"$1"),W=[...J];W[G]=U;let K=L4(W,G);if(Q.push(K.functionCode),K.name)Q.push(`module.exports.default = ${K.name};`);G=K.nextIndex}else if(q.startsWith("export default ")){let U=q.replace(/^export\s+default\s+/,"").replace(/;$/,"");Q.push(`module.exports.default = ${U};`),G++}else if(q.startsWith("class ")||q.startsWith("export class ")){let U=q.match(/(?:export\s+)?class\s+(\w+)/);if(U){let W=U[1],K=J[G].replace(/^export\s+/,""),z=0,H=G;for(;H<J.length;H++){let B=J[H];for(let j of B)if(j==="{")z++;else if(j==="}")z--;if(H>G)K+=`
|
|
3659
|
+
`+B;if(z<=0&&H>=G)break}Q.push(K),Q.push(`module.exports.${W} = ${W};`),G=H+1}else Q.push(q),G++}else if(q.includes("module.exports"))Q.push(q),G++;else if(q.trim()&&!q.startsWith("//"))Q.push(q),G++;else G++}return FG(Q.join(`
|
|
3660
|
+
`),X,Y)}function FG($,Z,X){let Y=$.length,J="",Q=0,G=null,q=!1,U=!1,W=0;while(Q<Y){let K=$[Q],z=$[Q+1];if(q){if(J+=K,K===`
|
|
3661
|
+
`)q=!1;Q++;continue}if(U){if(J+=K,K==="*"&&z==="/"){J+=z,Q+=2,U=!1;continue}Q++;continue}if(!G&&K==="/"&&z==="/"){q=!0,J+=K,Q++;continue}if(!G&&K==="/"&&z==="*"){U=!0,J+=K,Q++;continue}if(G){if(J+=K,K==="\\"){J+=z,Q+=2;continue}if(K===G&&G!=="`"){G=null,Q++;continue}if(G==="`"){if(K==="$"&&z==="{"){W++,J+=z,Q+=2;continue}if(K==="`"){G=null,Q++;continue}}Q++;continue}if(W>0){if(K==="{")W++;else if(K==="}")W--}if(K==='"'||K==="'"||K==="`"){G=K,J+=K,Q++;continue}if(K==="a"&&$.startsWith("await",Q)){let H=LG($,Q);if(H){let{quote:B,path:j,end:_}=H;if(j.startsWith(".")||j.startsWith("~/")||j.startsWith("@/")){let V=j.startsWith(".")?n0.resolve(Z,j):n0.resolve(X,j.slice(2));J+=`await import(${B}${V}${B})`,Q=_;continue}}}J+=K,Q++}return J}function LG($,Z){let X=Z+5;if(X>=$.length)return null;if(!/\s/.test($[X]))return null;while(X<$.length&&/\s/.test($[X]))X++;if(!$.startsWith("import",X))return null;X+=6;while(X<$.length&&/\s/.test($[X]))X++;if($[X]!=="(")return null;X++;while(X<$.length&&/\s/.test($[X]))X++;let Y=$[X];if(Y!=="'"&&Y!=='"')return null;X++;let J=X;while(X<$.length&&$[X]!==Y)if($[X]==="\\")X+=2;else X++;if(X>=$.length)return null;let Q=$.slice(J,X);X++;while(X<$.length&&/\s/.test($[X]))X++;if($[X]!==")")return null;return{quote:Y,path:Q,end:X+1}}function o9($,Z){let X=$[Z];if(X!=="{"&&X!=="[")return null;let J=H0($,X,X==="{"?"}":"]",Z);if(J===-1)return null;return{pattern:$.slice(Z,J+1),endPos:J+1}}function r9($){let Z=[],X=$.slice(1,-1).trim();if(!X)return Z;let Y=0,J=0,Q="";while(Y<X.length){let G=X[Y];if(G==="{"||G==="["){let q=J===0?o9(X,Y):null;if(q){Z.push(...r9(q.pattern)),Y=q.endPos,Q="";continue}J++}else if(G==="}"||G==="]")J--;if(J>0){Y++;continue}if(G===","){if(Q.trim())Z.push(Q.trim());Q="",Y++;continue}if(G===":"){Q="",Y++;continue}if(G==="="){if(Q.trim())Z.push(Q.trim());Q="",Y++;while(Y<X.length&&X[Y]!==","&&J===0){if(X[Y]==="{"||X[Y]==="[")J++;else if(X[Y]==="}"||X[Y]==="]")J--;Y++}continue}if(/[\w$]/.test(G))Q+=G;Y++}if(Q.trim())Z.push(Q.trim());return Z}function wG($){let Z=/^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec($);if(!Z)return null;let X=Z[0].length,Y=(J)=>J===" "||J==="\t";while(X<$.length&&Y($[X]))X++;if($[X]===":"){let J=0,Q=null;X++;for(;X<$.length;X++){let G=$[X];if(Q){if(G==="\\"){X++;continue}if(G===Q)Q=null;continue}if(G==="'"||G==='"'||G==="`"){Q=G;continue}if(G==="("||G==="["||G==="{"||G==="<"){J++;continue}if(G===")"||G==="]"||G==="}"||G===">"){J--;continue}if(G==="="&&J<=0){let q=$[X+1],U=$[X-1];if(q!=="="&&q!==">"&&U!=="="&&U!=="!"&&U!=="<"&&U!==">")break}}if($[X]!=="=")return null}while(X<$.length&&Y($[X]))X++;if($[X]!=="=")return null;return{type:Z[1],name:Z[2],value:$.slice(X+1).trim()}}function d9($,Z,X,Y){let J=null,Q=!1;for(let G of $){if(Q){Q=!1;continue}if(G==="\\"){Q=!0;continue}if(J){if(G===J)J=null;continue}if(G==="'"||G==='"'||G==="`"){J=G;continue}if(G===Z)Y++;else if(G===X)Y--}return Y}function m9($,Z){let X=$[Z].trim(),Y=wG(X),J=Y?[X,Y.type,Y.name,Y.value]:null;if(!J){let K=X.match(/^(?:export\s+)?(const|let|var)\s+/);if(K){let z=X.slice(K[0].length),H=Z;if(z.startsWith("{")||z.startsWith("[")){let j=z[0],_=j==="{"?"}":"]",V=d9(z,j,_,0),O=z;for(let F=Z+1;F<$.length&&V>0;F++)O+=` ${$[F].trim()}`,H=F,V=d9($[F],j,_,V);if(V>0)O=z,H=Z;z=O}let B=o9(z,0);if(B){let j=K[1],_=B.pattern,V=z.slice(B.endPos).trim();if(V.startsWith("=")){let O=V.slice(1).trim(),F=O,L=Math.max(H,Z);if(l9(O)){let N=c9($,L,O);F=N.value,L=N.nextIndex}else L=L+1;F=F.trim().replace(/;$/,"");let w=r9(_),R=`__stx_src_${Z}`,D=w.map((N)=>`module.exports.${N} = ${N};`).join(`
|
|
3662
|
+
`);return{type:j,name:R,value:`${F}; ${j} ${_} = ${R};
|
|
3663
|
+
${D}`,nextIndex:L}}}}throw Error(`Failed to parse variable declaration: ${X}`)}let[,Q,G,q]=J,U=q,W=Z;if(l9(q)){let K=c9($,Z,q);U=K.value,W=K.nextIndex}else W=Z+1;while(W<$.length){let K=$[W].trim();if(K.startsWith(".")||K.startsWith("?."))U+=`
|
|
3664
|
+
${$[W]}`,W++;else break}return U=U.trim().replace(/;$/,""),{type:Q,name:G,value:U,nextIndex:W}}function L4($,Z){let X=$[Z].trim(),Y=X.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!Y)throw Error(`Failed to parse function declaration: ${X}`);let[,J]=Y,Q=X.replace(/^export\s+/,""),G=Z;if(RG(X)){let q=DG($,Z,Q);Q=q.functionCode,G=q.nextIndex}else G=Z+1;return{name:J,functionCode:Q,nextIndex:G}}function l9($){let Z=$.trim();if(Z.startsWith("{"))return H0(Z,"{","}",0)===-1;if(Z.startsWith("["))return H0(Z,"[","]",0)===-1;return!a9(Z)}function a9($){let Z={paren:0,bracket:0,brace:0},X=null,Y=0;for(let J=0;J<$.length;J++){let Q=$[J];if((J>0?$[J-1]:"")==="\\"&&X)continue;if((Q==='"'||Q==="'")&&!X){X=Q;continue}if(Q===X&&X!=="`"){X=null;continue}if(Q==="`"&&!X){X="`";continue}if(Q==="`"&&X==="`"&&Y===0){X=null;continue}if(X==="`"&&Q==="$"&&$[J+1]==="{"){Y++,J++;continue}if(Y>0&&Q==="{"){Y++;continue}if(Y>0&&Q==="}"){Y--;continue}if(X)continue;if(Q==="(")Z.paren++;else if(Q===")")Z.paren--;else if(Q==="[")Z.bracket++;else if(Q==="]")Z.bracket--;else if(Q==="{")Z.brace++;else if(Q==="}")Z.brace--}return Z.paren===0&&Z.bracket===0&&Z.brace===0&&X===null}function t9($){let Z=$.indexOf("(");if(Z===-1)return $.indexOf("{");let X=H0($,"(",")",Z);if(X===-1)return-1;return $.indexOf("{",X)}function RG($){let Z=t9($);if(Z===-1)return!0;return H0($,"{","}",Z)===-1}function c9($,Z,X){let Y=X,J=Z+1;while(J<$.length&&!a9(Y)){let Q=$[J];Y+=`
|
|
3665
|
+
${Q}`,J++}while(J<$.length){let Q=$[J].trim();if(Q.startsWith(".")||Q.startsWith("?."))Y+=`
|
|
3666
|
+
${$[J]}`,J++;else break}return{value:Y,nextIndex:J}}function DG($,Z,X){let Y=X,J=Z+1;while(J<$.length){let Q=t9(Y);if(Q!==-1){if(H0(Y,"{","}",Q)!==-1)break}let G=$[J];Y+=`
|
|
3667
|
+
${G}`,J++}return{functionCode:Y,nextIndex:J}}function p9($,Z){let X=X0($,Z)??X0(`(${$})`,Z);if(X!==void 0)return X;if(!/\bprocess\b/.test($))return;let Y={...Z,process:Object.freeze({env:{...X5.env}})};try{return Function(...Object.keys(Y),`'use strict'; return (${$});`)(...Object.values(Y))}catch{try{return Function(...Object.keys(Y),`'use strict'; return ${$};`)(...Object.values(Y))}catch{return}}}async function NG($,Z,X){let Y=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of Y){let[,,G,q]=Q;try{let U=q.trim().replace(/;$/,""),W=p9(U,Z);if(W!==void 0)Z[G]=W}catch(U){console.warn(`Failed to parse export ${G} in fallback:`,U)}}let J=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of J){let[,,G,q]=Q;if(!(G in Z))try{let U=q.trim().replace(/;$/,""),W=p9(U,Z);if(W!==void 0)Z[G]=W}catch{}}}function AG($){let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),X=Z?Z[1]:"",Y=Z?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:X,templateWithoutScript:Y}}function MG($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var T5=new O1(500),M$=new O1(1000),R4=new O1(2000),IG=0;function kG($){let Z=new WeakSet;try{let X=(Y)=>{if(Y===void 0)return{__stxType:"undefined"};if(typeof Y==="bigint")return{__stxType:"bigint",value:Y.toString()};if(typeof Y==="function"||typeof Y==="symbol")throw TypeError("Non-serializable component input");if(Y===null||typeof Y!=="object")return Y;if(Z.has(Y))throw TypeError("Circular component input");if(Z.add(Y),Y instanceof Date)return{__stxType:"date",value:Y.toISOString()};if(Array.isArray(Y))return Y.map(X);let J={};for(let Q of Object.keys(Y).sort())J[Q]=X(Y[Q]);return J};return JSON.stringify(X($))}catch{return null}}function e9($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function EG($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function N1($){return!EG($)}var A$=new Map;function w4($){let Z;try{Z=JSON.stringify($)}catch{return new Bun.Transpiler($)}let X=A$.get(Z);if(X)return X;if(A$.size>=16)A$.clear();let Y=new Bun.Transpiler($);return A$.set(Z,Y),Y}function A1($){try{let Z=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Z=Z.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let X=[];Z=Z.replace(/\{!![\s\S]*?!!\}/g,(Q)=>{let G=X.length;return X.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Q)=>{let G=X.length;return X.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(Q)=>{let G=X.length;return X.push(Q),`"__STX_EXPR_${G}__"`});let J=w4({loader:"ts",target:"browser",define:e1()}).transformSync(Z);for(let Q=0;Q<X.length;Q++)J=J.replace(`"__STX_EXPR_${Q}__"`,X[Q]),J=J.replace(`'__STX_EXPR_${Q}__'`,X[Q]);return J}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function bG($){let Z=[],X=new Set,Y=0,J=0,Q=$.length,G=(K)=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]===K){J++;return}J++}},q=()=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]==="`"){J++;return}if($[J]==="$"&&$[J+1]==="{"){J+=2;let K=1;while(J<Q&&K>0)if($[J]==="{")K++,J++;else if($[J]==="}")K--,J++;else if($[J]==="'"||$[J]==='"')G($[J]);else if($[J]==="`")q();else J++;continue}J++}},U=()=>{if($[J]==="/"&&$[J+1]==="/"){while(J<Q&&$[J]!==`
|
|
3668
|
+
`)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},W=()=>{if(Y!==0)return;let K=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(K){let j=K[2].split(",").map((_)=>{let V=_.trim().split(":");return V[V.length-1].trim()});for(let _ of j)if(_&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(_)&&!X.has(_))Z.push(_),X.add(_);return}let z=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(z){let j=z[2];if(!X.has(j))Z.push(j),X.add(j);return}let H=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(H){let j=H[1];if(!X.has(j))Z.push(j),X.add(j);return}let B=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!X.has(j))Z.push(j),X.add(j)}};while(J<Q){if(U())continue;if($[J]==="'"||$[J]==='"'){G($[J]);continue}if($[J]==="`"){q();continue}if($[J]==="{"){Y++,J++;continue}if($[J]==="}"){Y--,J++;continue}if(Y===0&&/[a-z]/i.test($[J])&&(J===0||/\s|[;{}()]/.test($[J-1])))W();J++}return Z}function yG($){let Z=[],X=0,Y=0,J=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(J){if(G==="\\"){Q++;continue}if(G===J)J=null;continue}if(G==='"'||G==="'"||G==="`"){J=G;continue}if(G==="("||G==="["||G==="{")X++;else if(G===")"||G==="]"||G==="}")X--;else if(G===","&&X===0)Z.push($.slice(Y,Q)),Y=Q+1}if(Y<$.length)Z.push($.slice(Y));return Z}function SG($){let Z=0,X=null;for(let Y=0;Y<$.length;Y++){let J=$[Y];if(X){if(J==="\\"){Y++;continue}if(J===X)X=null;continue}if(J==='"'||J==="'"||J==="`"){X=J;continue}if(J==="("||J==="["||J==="{")Z++;else if(J===")"||J==="]"||J==="}")Z--;else if(J==="="&&Z===0){let Q=$[Y-1],G=$[Y+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return Y}}return-1}function CG($,Z){try{let X=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!X)return;let Y=X.index-1;while(Y>=0&&/\s/.test($[Y]))Y--;if($[Y]!=="}")return;let J=Y,Q=0,G=-1;for(;Y>=0;Y--){let U=$[Y];if(U==="}")Q++;else if(U==="{"){if(Q--,Q===0){G=Y;break}}}if(G===-1)return;let q=$.slice(G+1,J);for(let U of yG(q)){let W=U.trim();if(!W||W.startsWith("..."))continue;let K=SG(W);if(K===-1)continue;let z=W.slice(0,K).trim();if(!/^[A-Z_$][\w$]*$/i.test(z))continue;if(Z[z]!==void 0)continue;let H=W.slice(K+1).trim();if(!H)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${H});`);Z[z]=j(...B.map((_)=>Z[_]))}catch{}}}catch{}}async function w$($,Z,X,Y,J){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(V)=>V.split("-").map((O)=>O.charAt(0).toUpperCase()+O.slice(1)).join(""),q=(V)=>V.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),U=X.__importedComponents;if(U){for(let V of[Q,Q.toLowerCase(),G(Q),q(Q)])if(U.has(V))return!0}let W=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${q(Q)}.stx`])],K=typeof J.root==="string"?g.resolve(J.root):void 0,z=K??g.dirname(Y),H=[],B=(V)=>{if(V&&!H.includes(V))H.push(V)},j=X.__originalFilePath;if(j)B(g.join(g.dirname(j),"components"));B(Z),B(J._rootComponentsDir),B(g.join(g.dirname(Y),"components")),B(J.componentsDir);let _=J._pluginComponentDirs;if(Array.isArray(_))for(let V of _)B(typeof V==="string"?V:null);if(K)B(g.resolve(K,"resources/views/components")),B(g.resolve(K,"resources/components")),B(g.resolve(K,"src/components")),B(g.resolve(K,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return r(g.resolve(g.dirname(Y),`${Q}.stx`));for(let V of H){let O=g.isAbsolute(V)?V:g.resolve(z,V);for(let F of W)if(await r(g.join(O,F)))return!0}return!1}function PG($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}function vG($){if(!$)return!1;let Z=$.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(Z)}function fG($){let Z=new Set,X=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useReactiveProp|useLocalStorage|useSessionStorage|useCookie|useDebouncedValue)\s*(?:<[^>]*>)?\s*\(/g;for(let Y of $){let J;while((J=X.exec(Y))!==null)Z.add(J[1]);X.lastIndex=0}return[...Z]}async function T1($,Z,X,Y,J,Q,G,q=new Set,U){let{extractVariables:W}=await a("stx/variable-extractor",()=>import("./chunk-0w0mrtme.js")),K=q??new Set;if(K.has($))return`[Circular component reference: ${$}]`;let z=new Set(K);z.add($);let H=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let B=H&&H!=="load"&&PG(H)?H:"";try{let j=(P)=>P.split("-").map((u)=>u.charAt(0).toUpperCase()+u.slice(1)).join(""),_=(P)=>P.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),V=$.endsWith(".stx")?$.slice(0,-4):$,O=null,F=J.__importedComponents;if(F){let P=[V,V.toLowerCase(),j(V),_(V)];for(let u of P)if(F.has(u)){O=F.get(u);break}}let L=[];if(!O){let P=[`${V}.stx`,`${j(V)}.stx`,`${_(V)}.stx`],u=[...new Set(P)],s=J.__originalFilePath,o=[];if(s){let Y0=g.join(g.dirname(s),"components");o.push(Y0)}if(Y)o.push(Y);let z0=G._rootComponentsDir;if(typeof z0==="string"&&!o.includes(z0))o.push(z0);let L0=g.join(g.dirname(Q),"components");if(!o.includes(L0))o.push(L0);if(G.componentsDir&&G.componentsDir!==Y&&!o.includes(G.componentsDir))o.push(G.componentsDir);let $1=G._pluginComponentDirs;if(Array.isArray($1)){for(let Y0 of $1)if(typeof Y0==="string"&&!o.includes(Y0))o.push(Y0)}let E0=typeof G.root==="string"?g.resolve(G.root):void 0,D0=E0??g.dirname(Q),v0=[];if(E0)v0.push(g.resolve(E0,"resources/views/components")),v0.push(g.resolve(E0,"resources/components")),v0.push(g.resolve(E0,"src/components")),v0.push(g.resolve(E0,"components"));v0.push(g.resolve(import.meta.dir,"components"));for(let Y0 of v0)if(!o.includes(Y0))o.push(Y0);let J5=[...new Set(o.map((Y0)=>{if(!Y0)return Y0;return g.isAbsolute(Y0)?Y0:g.resolve(D0,Y0)}))];o.length=0,o.push(...J5);let Z1=`${V}\x00${Q}\x00${J5.join("\x00")}`,i=M$.get(Z1);if(i)if(await r(i))O=i;else M$.delete(Z1);if(!O&&(V.startsWith("./")||V.startsWith("../")))O=g.resolve(g.dirname(Q),`${V}.stx`),L.push(O);else if(!O)for(let Y0 of o){if(!Y0)continue;for(let X1 of u){let j1=g.join(Y0,X1);if(L.push(j1),await r(j1)){O=j1;break}}if(O)break;if(!O)try{let X1=await import("fs");if(!X1.statSync(Y0,{throwIfNoEntry:!1})?.isDirectory())continue;let k5=8,y1=[{path:Y0,depth:0}];while(y1.length>0&&!O){let s0=y1.pop();if(s0.depth>=k5)continue;let E5;try{E5=X1.readdirSync(s0.path,{withFileTypes:!0})}catch{continue}for(let b5 of E5){if(!b5.isDirectory())continue;if(b5.name==="node_modules"||b5.name.startsWith("."))continue;let M4=g.join(s0.path,b5.name);for(let z8 of u){let T$=g.join(M4,z8);if(L.push(T$),await r(T$)){O=T$;break}}if(O)break;y1.push({path:M4,depth:s0.depth+1})}}}catch{}if(O)break}if(O)M$.set(Z1,O)}if(!O||!await r(O)){let P=L.length>0?`
|
|
3669
|
+
Searched paths:
|
|
3670
|
+
${L.map((u)=>` - ${u}`).join(`
|
|
3671
|
+
`)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${P}`}U.add(O);let w;if(T5.has(O))w=T5.get(O);else try{w=await Bun.file(O).text(),T5.set(O,w)}catch(P){return`[Error loading component: ${P instanceof Error?P.message:String(P)}]`}let R=new Set(["__originalFilePath","__importedComponents",y5,"__stx_client_signal_names","__stxServeContext"]),D={};for(let[P,u]of Object.entries(J))if(!P.startsWith("__")||R.has(P))D[P]=u;let N=c0(X),T=[],A=N.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(P,u)=>{let s=N.scripts[Number(u)]||"",o=s.match(/^<script\b([^>]*)>/i)?.[1]||"",z0=o.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),L0=!z0||["module","text/javascript","application/javascript"].includes(z0);if(!/\bserver\b/i.test(o)&&L0)return T.push(s),"";return s}),{extractSlotContent:M}=await a("stx/slots",()=>import("./chunk-14ynv5ah.js")),k=M(A),I={};if(k.defaultSlot?.trim())I.default=k.defaultSlot;for(let[P,u]of k.namedSlots)I[P]=u.content;let y={...D,...Z,props:Z,slot:A,$slots:I,__processedComponents:z,__sections:{},__stx_signals_gate:J1(w)||vG(X)};CG(w,y);let E=w,b=J$(E);if(b)E=b.content.trim();let C=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,x=[...w.matchAll(C)],f=[],n=x.some((P)=>/\bserver\b/.test(P[1]||"")&&/\bcache\b/.test(P[1]||""))&&x.every((P)=>/\bserver\b/.test(P[1]||"")),m=null,V0=null;if(n){let P=kG({props:Z,slot:X,buildMode:G.buildMode??"",skipEventDirectives:G.skipEventDirectives===!0});if(P!==null){m=`${O}\x00${P}`;let u=R4.get(m);if(u){for(let s of u.dependencies)U.add(s);return u.output}V0=new Set(U)}}for(let P of x){let u=P[1]||"",s=P[2]||"",o=u.includes("server");if(N1(u)&&s.trim())s=A1(s);if(o&&s)try{await W(s,y,O)}catch(L0){}if(!o){let L0=s.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),$1=L0.includes("{{")&&L0.includes("}}"),E0=L0.includes("{!!")&&L0.includes("!!}");if($1||E0)L0=y$(L0,y);let D0=u.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");f.push(`<script${D0}>${L0}</script>`)}}let A0=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),M0=A0?A0[1]:"",g0=A0?A0[2]:"",t="",K0=M0&&/\bscoped\b/i.test(M0);if(A0)t=`<style${M0}>${g0}</style>`;let q0=E;if(q0=q0.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),A0)q0=q0.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let P=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,u=[];if(q0=q0.replace(P,(s,o)=>{let z0=o.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(z0)u.push(`<style${z0[1]}>${z0[2]}</style>`);return""}),q0=q0.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),u.length>0)t=`${t}${u.join(`
|
|
3672
|
+
`)}`}if(X&&q0.includes("{{ text || slot }}"))q0=q0.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>X);let{applySlots:B1}=await a("stx/slots",()=>import("./chunk-14ynv5ah.js")),{defaultSlot:Y5,namedSlots:p}=k;q0=await B1(q0,Y5,p,y);let e=f.some((P)=>/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useReactiveProp|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(P)),J0=fG(f),T0=Array.isArray(y.__stx_client_signal_names)?y.__stx_client_signal_names:[];if(J0.length>0||T0.length>0)y.__stx_client_signal_names=[...new Set([...T0,...J0])];let F0={...G,_rootComponentsDir:G._rootComponentsDir||G.componentsDir,componentsDir:g.dirname(O),skipSignalsRuntime:!0,skipEventDirectives:e||f.length===0,defaultLayout:void 0};y.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let P0=await F4(q0,y,O,F0,U),S=new Set(Array.isArray(J.__stx_preserved_client_expressions)?J.__stx_preserved_client_expressions:[]);for(let P of P0.matchAll(/\{\{([\s\S]*?)\}\}/g))S.add(P[1].trim());if(S.size>0)J.__stx_preserved_client_expressions=[...S];let v=`stx_${V.replace(/[^a-zA-Z0-9]/g,"_")}_${++IG}_${Math.random().toString(36).slice(2,8)}`,d=P0;if(e){let P="";if(Object.keys(Z).length>0)try{P=` data-stx-props="${e9(JSON.stringify(Z))}"`}catch{}let u=B?` stx-hydrate="${e9(B)}"`:"";d=`<div data-stx-scope="${v}"${P}${u}>${P0}</div>`;let s=await Promise.all(f.map(async(o)=>{let z0=o.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!z0)return o;let[,L0,$1]=z0,E0=N4($1,{filePath:O,projectRoot:process.cwd()}),D0=E0.code,v0=A4(E0.styles);D0=R5(D0).code;let{hasUserImports:J5,bundleClientScript:Z1}=await a("stx/client-script-bundler",()=>import("./chunk-fd77g6t6.js"));if(J5(D0))D0=await Z1(D0,O,{projectRoot:process.cwd(),minify:G.buildMode==="compile"});let{rewriteStxImportSpecifiers:i}=await a("stx/signal-processing",()=>import("./chunk-w29sv5jf.js"));D0=D0.replace(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm,(s0,E5)=>i(E5));let Y0=o0(D0),X1=bG(Y0),j1=`function(__scopeId) {
|
|
3673
|
+
${l1("const",[...$8,...X1],Y0)}
|
|
3674
|
+
const __scope = window.stx._scopes = window.stx._scopes || {};
|
|
3675
|
+
const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
|
|
3676
|
+
__scopeVars.$refs = __scopeVars.$refs || {};
|
|
3677
|
+
const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
|
|
3678
|
+
window.__STX_CURRENT_ELEMENT__ = document.querySelector('[data-stx-scope="' + __scopeId + '"]');
|
|
3679
|
+
|
|
3680
|
+
// Scope-specific lifecycle callbacks
|
|
3681
|
+
__scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
|
|
3682
|
+
__scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
|
|
3683
|
+
const onMount = (fn) => __scopeVars.__mountCallbacks.push(fn);
|
|
3684
|
+
const onDestroy = (fn) => __scopeVars.__destroyCallbacks.push(fn);
|
|
3685
|
+
|
|
3686
|
+
try {
|
|
3687
|
+
${Y0}
|
|
3688
|
+
|
|
3689
|
+
// Register all defined signals and functions in this scope
|
|
3690
|
+
const __localVars = {};
|
|
3691
|
+
try {
|
|
3692
|
+
${X1.map((s0)=>`if (typeof ${s0} !== 'undefined') __localVars['${s0}'] = ${s0};`).join(`
|
|
3693
|
+
`)}
|
|
3694
|
+
}
|
|
3695
|
+
catch (e) {}
|
|
3696
|
+
Object.assign(__scopeVars, __localVars);
|
|
3697
|
+
}
|
|
3698
|
+
finally {
|
|
3699
|
+
window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
|
|
3700
|
+
}
|
|
3701
|
+
}`,k5=B?null:v4(J,j1),y1=k5?`window.__stxComponentFactories[${JSON.stringify(k5)}](${JSON.stringify(v)});`:`(${j1})(${JSON.stringify(v)});`;if(B)return`${v0}<script type="stx/island" data-stx-island="${v}" data-stx-scoped${L0}>${y1}</script>`;return`${v0}<script data-stx-scoped data-stx-run="always"${L0}>${y1}</script>`}));if(d=d+`
|
|
3702
|
+
`+s.join(`
|
|
3703
|
+
`),t)d+=`
|
|
3704
|
+
`+t}else{if(t)d+=`
|
|
3705
|
+
`+t;if(f.length>0){let P=y.__stx_event_bindings||[],u=D$(y),s=await Promise.all(f.map(async(o)=>{let z0=o.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!z0)return o;return await N$(z0[1],{eventBindings:P,templateContent:d,filePath:O,projectRoot:process.cwd(),serverData:u})}));d+=`
|
|
3706
|
+
`+s.join(`
|
|
3707
|
+
`),y.__stx_event_bindings=[]}}if(K0){let P=W$(d,O);if(P.hasScoped)d=P.html}if(m&&V0)R4.set(m,{output:d,dependencies:[...U].filter((P)=>!V0.has(P))});return T.length>0?`${d}
|
|
3708
|
+
${T.join(`
|
|
3709
|
+
`)}`:d}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{K.delete($)}}async function r($){return Bun.file($).exists()}function D4($,Z){let X=g.resolve(Z),Y=g.resolve($),J=X.endsWith(g.sep)?X:X+g.sep;if(Y===X||Y.startsWith(J))return Y;return null}async function xG($,Z,X,Y){let J=Z.startsWith("layouts/")?Z.slice(8):Z,Q=g.join($,J);for(let G of Q.endsWith(".stx")?[Q]:[Q,`${Q}.stx`])if(await r(G)){if(Y)console.log(`Found layout in ${$}: ${G}`);return X?.add(G),G}return null}async function r5($,Z,X,Y){let J=await gG($,Z,X,Y);if(J===null)return null;let Q=D4(J,process.cwd());if(Q)return Q;let G=[X.root,X.layoutsDir,X.fallbackLayoutsDir,X.componentsDir,X.partialsDir,X.pagesDir].filter((q)=>typeof q==="string"&&q.length>0);for(let q of G){let U=g.isAbsolute(q)?q:g.resolve(process.cwd(),q);if(D4(J,U))return g.resolve(J)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${$}, from: ${Z})`),null}async function gG($,Z,X,Y){if(X.debug)console.log(`Resolving template path: ${$} from ${Z}`);let J=g.dirname(Z),Q=process.cwd();if($.startsWith("/")){let H=g.join(Q,$),B=D4(H,Q);if(!B)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(X.debug)console.log(`Checking absolute path: ${B}`);if(await r(B)&&Y)Y.add(B);return B}let G=g.join(J,$);if(await r(G)){if(X.debug)console.log(`Found direct path: ${G}`);if(Y)Y.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let H of[".stx",".tsx",".jsx"]){let B=`${G}${H}`;if(await r(B)){if(X.debug)console.log(`Found direct path with extension: ${B}`);if(Y)Y.add(B);return B}}let q=[];if(X.layoutsDir)q.push(g.isAbsolute(X.layoutsDir)?X.layoutsDir:g.resolve(process.cwd(),X.layoutsDir));let U=g.resolve(J),W=process.cwd();for(let H=0;H<10;H++){let B=g.join(U,"layouts"),j=!1;try{j=TG.statSync(B,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){q.push(B);break}let _=g.dirname(U);if(_===U||_.length<W.length)break;U=_}for(let H of q){let B=await xG(H,$,Y,X.debug);if(B)return B}if(X.fallbackLayoutsDir){let H=g.isAbsolute(X.fallbackLayoutsDir)?X.fallbackLayoutsDir:g.resolve(process.cwd(),X.fallbackLayoutsDir),B=$.startsWith("layouts/")?$.slice(8):$,j=[g.join(H,B)];if(!$.endsWith(".stx"))j.push(`${j[0]}.stx`);for(let _ of j)if(await r(_)){if(X.debug)console.log(`Found in options.fallbackLayoutsDir: ${_}`);if(Y)Y.add(_);return _}}if($.startsWith("layouts/")||$.includes("/layouts/")){let H=$.split("layouts/"),B=g.join(X.partialsDir||J,"layouts",H[1]);if(await r(B)){if(X.debug)console.log(`Found in layouts path: ${B}`);if(Y)Y.add(B);return B}if(!B.endsWith(".stx")){let j=`${B}.stx`;if(await r(j)){if(X.debug)console.log(`Found in layouts path with extension: ${j}`);if(Y)Y.add(j);return j}}}if(X.partialsDir){let H=g.join(X.partialsDir,"layouts");if(await r(H)){let B=g.join(H,$);if(await r(B)){if(X.debug)console.log(`Found in partials layouts dir: ${B}`);if(Y)Y.add(B);return B}if(!$.endsWith(".stx")){let j=`${B}.stx`;if(await r(j)){if(X.debug)console.log(`Found in partials layouts dir with extension: ${j}`);if(Y)Y.add(j);return j}}}}let K=X.partialsDir||g.join(process.cwd(),"views"),z=g.join(K,$);if(await r(z)){if(X.debug)console.log(`Found in views path: ${z}`);if(Y)Y.add(z);return z}if(!$.endsWith(".stx")){let H=`${z}.stx`;if(await r(H)){if(X.debug)console.log(`Found in views path with extension: ${H}`);if(Y)Y.add(H);return H}}if(J.includes("temp")){let H=g.join(g.dirname(J),"layouts",$);if(await r(H)){if(X.debug)console.log(`Found in temp layouts dir: ${H}`);if(Y)Y.add(H);return H}if(!$.endsWith(".stx")){let B=`${H}.stx`;if(await r(B)){if(X.debug)console.log(`Found in temp layouts dir with extension: ${B}`);if(Y)Y.add(B);return B}}}if(X.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function Z8($,Z,X){let Y=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
|
|
3710
|
+
`),q=0;for(let U=0;U<G.length;U++)if(q+=G[U].length+1,q>=Z){Y=U+1,J=G[U].trim();let W=Math.max(0,U-2),K=Math.min(G.length,U+3);Q=G.slice(W,K).map((z,H)=>{let B=W+H+1;return`${B===Y?"> ":" "}${B}: ${z}`}).join(`
|
|
3711
|
+
`);break}}else if(X){let G=$.indexOf(X);if(G>=0)return Z8($,G)}}catch{}return{lineNumber:Y,lineContent:J,context:Q}}var Z0={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 W0($,Z,X,Y,J,Q){let{lineNumber:G,context:q}=Z8(Y,J,Q),U=X.split("/").pop(),W=0;if(typeof J==="number"&&J>=0&&Y){let z=Y.lastIndexOf(`
|
|
3712
|
+
`,Math.max(0,J-1));W=J-(z+1)+1}let K="";if(G>0)K+=`
|
|
3713
|
+
${X}:${G}${W>0?`:${W}`:""}: ${$.toLowerCase()} error: ${Z}
|
|
3714
|
+
`;if(K+=`
|
|
3715
|
+
${Z0.bold}${Z0.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${Z0.reset}
|
|
3716
|
+
`,K+=`${Z0.bold}${Z0.red}\u2502${Z0.reset} ${Z0.bold}${Z0.bgRed} ERROR ${Z0.reset} ${Z0.red}${$} Error${Z0.reset}${" ".repeat(Math.max(0,43-$.length))}${Z0.bold}${Z0.red}\u2502${Z0.reset}
|
|
3717
|
+
`,K+=`${Z0.bold}${Z0.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${Z0.reset}
|
|
3718
|
+
`,K+=`
|
|
3719
|
+
${Z0.cyan}${Z0.bold}File:${Z0.reset} ${Z0.dim}${U}${Z0.reset}`,G>0)K+=` ${Z0.gray}(line ${G}${W>0?`, col ${W}`:""})${Z0.reset}`;if(K+=`
|
|
3720
|
+
${Z0.yellow}${Z0.bold}Message:${Z0.reset} ${Z}
|
|
3721
|
+
`,q)K+=`
|
|
3722
|
+
${Z0.blue}${Z0.bold}Context:${Z0.reset}
|
|
3723
|
+
${Z0.dim}${q}${Z0.reset}
|
|
3724
|
+
`;return K}function d_(){T5.clear(),M$.clear(),R4.clear()}function m_(){return{size:T5.size,maxSize:500}}var hG=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;function uG($){if($.startsWith(".")||$.startsWith("/"))return null;if($.startsWith("@")){let X=$.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!X)return null;return{pkg:X[1],subpath:X[2]||""}}let Z=$.match(/^([^/]+)(\/.*)?$/);if(!Z)return null;return{pkg:Z[1],subpath:Z[2]||""}}function dG($,Z){let X=Z;while(!0){let Y=b1.join(X,"node_modules",$,"package.json");if(I5.existsSync(Y))return b1.dirname(Y);let J=b1.dirname(X);if(J===X)return null;X=J}}function mG($,Z){if(!$||typeof $!=="object")return null;let X=(J)=>{if(typeof J==="string")return J;if(J&&typeof J==="object"){if(typeof J.import==="string")return J.import;if(typeof J.default==="string")return J.default;if(typeof J.import==="object")return X(J.import);if(typeof J.default==="object")return X(J.default)}return null};if(Object.prototype.hasOwnProperty.call($,Z))return X($[Z]);let Y=null;for(let J of Object.keys($)){let Q=J.indexOf("*");if(Q===-1)continue;let G=J.slice(0,Q),q=J.slice(Q+1);if(!Z.startsWith(G)||!Z.endsWith(q))continue;if(Z.length<G.length+q.length)continue;if(!Y||G.length>Y.prefix.length)Y={pattern:J,prefix:G,suffix:q}}if(Y){let J=Z.slice(Y.prefix.length,Z.length-Y.suffix.length),Q=X($[Y.pattern]);if(Q)return Q.replace("*",J)}return null}function lG($,Z){let X=uG($);if(!X||!X.subpath)return null;let Y=dG(X.pkg,Z);if(!Y)return null;let J;try{J=JSON.parse(I5.readFileSync(b1.join(Y,"package.json"),"utf8"))}catch{return null}let Q=`.${X.subpath}`,G=mG(J.exports,Q);if(!G)return null;let q=b1.resolve(Y,G);return I5.existsSync(q)?q:null}function N4($,Z){let X=Z.filePath?b1.dirname(Z.filePath):Z.projectRoot||process.cwd(),Y=Z.projectRoot||process.cwd(),J=new Set,Q=[];return{code:$.replace(hG,(q,U)=>{let W;try{if(U.startsWith("./")||U.startsWith("../")||U.startsWith("/")){if(W=U.startsWith("/")?U:b1.resolve(X,U),!I5.existsSync(W))throw Error(`file not found: ${W}`)}else{let K=null;try{K=Bun.resolveSync(U,Y)}catch{K=lG(U,Y)}if(!K)throw Error(`could not resolve ${U} (Bun.resolveSync + exports fallback both failed)`);W=K}}catch(K){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(U)} (from ${Z.filePath||"<unknown>"}): ${K?.message||K}`),""}if(J.has(W))return"";J.add(W);try{let K=I5.readFileSync(W,"utf8");Q.push({source:U,resolvedPath:W,contents:K})}catch(K){console.warn(`[stx:vendor-css] could not read ${W}: ${K?.message||K}`)}return""}),styles:Q}}function cG($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function A4($){if($.length===0)return"";return`${$.map((Z)=>{return`<style data-stx-vendor="${cG(Z.source)}" data-stx-layer="vendor">
|
|
3725
|
+
@layer vendor {
|
|
3726
|
+
${Z.contents}
|
|
3727
|
+
}
|
|
3728
|
+
</style>`}).join(`
|
|
3729
|
+
`)}
|
|
3730
|
+
`}var pG=Q8,q8=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useDocumentVisibility","useIntervalFn","useTimeoutFn"];function R5($){let Z=p0($),X=new Set;for(let q of $.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let U of q[1].split(",")){let W=U.trim().split(/\s+as\s+/).pop()?.replace(/^type\s+/,"").trim();if(W)X.add(W)}let Y=new Set;for(let q of Z.matchAll(/\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g))Y.add(q[1]);for(let q of Z.matchAll(/\b(?:const|let|var)\s*\{([^}]*)\}/g))for(let U of q[1].split(",")){let W=U.trim().split(/[:=]/).pop()?.trim();if(W)Y.add(W)}let J=q8.filter((q)=>{if(X.has(q)||Y.has(q))return!1;return new RegExp(`\\b${q}\\s*\\(`).test(Z)}),Q=U8(Z).filter((q)=>!X.has(q)&&!Y.has(q));if(J.length===0&&Q.length===0)return{code:$,imports:J,models:Q};return{code:`${[J.length>0?`import { ${J.join(", ")} } from '@stacksjs/browser'`:"",Q.length>0?"import '@stacksjs/browser'":"",Q.length>0?`const { ${Q.join(", ")} } = window.StacksBrowser || {}`:""].filter(Boolean).join(`
|
|
3731
|
+
`)}
|
|
3732
|
+
${$}`,imports:J,models:Q}}var iG=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 U8($){let Z=new Set,X=/\b([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g,Y;while((Y=X.exec($))!==null)if(!iG.has(Y[1]))Z.add(Y[1]);return Array.from(Z)}function nG($){let Z=new Set;for(let X of $.matchAll(/\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g))Z.add(X[1]);for(let X of $.matchAll(/\b(?:const|let|var)\s*\{([^}]*)\}/g))for(let Y of X[1].split(",")){let J=Y.trim().split(/[:=]/).pop()?.trim();if(J&&/^[A-Za-z_$][\w$]*$/.test(J))Z.add(J)}return Z}function W8($){let Z=new Set,X=new Set,Y=$;Y=Y.replace(/^\s*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm,"// [type import stripped]");let J=new Set,Q=/^\s*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|@stacksjs\/stx|stx)['"]\s*;?\s*$/gm,G;while((G=Q.exec($))!==null){let W=G[1],K=G[2];if(G[0].includes("import type"))continue;let z=[];for(let B of W.split(",")){let j=B.trim();if(!j||j.startsWith("type "))continue;let _=j.match(/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);if(!_)continue;let V=_[1],O=_[2]||V;if(J.add(V),J.add(O),K==="stx"||K==="@stacksjs/stx")Z.add(V);else X.add(V);if(O!==V)z.push(`${O} = ${V}`)}let H=z.length>0?`var ${z.join(", ")}; /* [auto-import processed] */`:"// [auto-import processed]";Y=Y.replace(G[0],H)}let q=nG(Y);for(let W of pG){if(J.has(W)||q.has(W))continue;if(new RegExp(`\\b${W}\\s*(?:<[^>]*>)?\\s*\\(`,"g").test(Y))Z.add(W)}for(let W of q8){if(J.has(W)||q.has(W))continue;if(new RegExp(`\\b${W}\\b`,"g").test(Y))X.add(W)}let U=U8(Y);for(let W of U)if(!J.has(W)&&!q.has(W))X.add(W);return{code:Y,stxImports:Array.from(Z),browserImports:Array.from(X)}}function K8($,Z){let X=[];if($.length>0)X.push(` var { ${$.join(", ")} } = window.stx || window;`);if(Z.length>0)X.push(` var { ${Z.join(", ")} } = window.StacksBrowser || {};`);if(X.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
|
|
3733
|
+
${X.join(`
|
|
3734
|
+
`)}
|
|
3735
|
+
${sG($,Z)}`;return""}function YO($,Z=[]){let{browserImports:X}=W8($),Y=new Set(Z);return K8([],X.filter((J)=>!Y.has(J)))}function sG($,Z){let X=[...$.map((Y)=>`['${Y}', typeof ${Y}, 'stx']`),...Z.map((Y)=>`['${Y}', typeof ${Y}, '@stacksjs/browser']`)];if(X.length===0)return"";return` // STX: report auto-imports the client runtime did not provide
|
|
3736
|
+
[${X.join(", ")}].forEach(function (e) {
|
|
3737
|
+
if (e[1] !== 'undefined') return;
|
|
3738
|
+
console.error(
|
|
3739
|
+
'[stx] "' + e[0] + '" is used in this client script and auto-imported from ' + e[2] + ', '
|
|
3740
|
+
+ 'but the client runtime does not provide it. Either it is not exported to the browser, '
|
|
3741
|
+
+ 'or it should be imported from a relative path so the bundler includes it.'
|
|
3742
|
+
);
|
|
3743
|
+
});
|
|
3744
|
+
`}function D$($){let Z=$.__stxClientPayload;if(Z&&typeof Z==="object"){let Y={};for(let J in Z){let Q=Z[J];if(typeof Q==="function")continue;Y[J]=Q}return Y.__stxDeclaredPayload=!0,Y}let X={};for(let Y in $){if(Y.startsWith("__")||Y.startsWith("$"))continue;let J=$[Y];if(typeof J==="function")continue;X[Y]=J}return X}function X8($,Z){let X=new Set;for(let Y of $.split(",")){let J=Y.trim().replace(/^\.\.\./,"").trim();if(!J)continue;if(Z){let Q=J.lastIndexOf(":");if(Q!==-1)J=J.slice(Q+1).trim()}if(J=J.split("=")[0].trim(),/^[A-Za-z_$][\w$]*$/.test(J))X.add(J)}return X}function oG($,Z){if(new RegExp(`(?:const|let|var|function|class)\\s+${Z}\\b`).test($))return!0;for(let X of $.matchAll(/(?:const|let|var)\s*\{([^}]*)\}/g))if(X8(X[1],!0).has(Z))return!0;for(let X of $.matchAll(/(?:const|let|var)\s*\[([^\]]*)\]/g))if(X8(X[1],!1).has(Z))return!0;return!1}function rG($,Z){return new RegExp(`(?<![.#\\w$])${Z}(?![\\w$])`).test($)}var aG=/token|secret|passw|apikey|api_key|privatekey|private_key|credential|webhook|bearer|jwt|signature/i,Y8=new Set;function tG($,Z){let X=aG.test($),Y=Z.length>32768;if(!X&&!Y)return;if(Y8.has($))return;if(Y8.add($),X)console.warn(`[stx] server\u2192client bridge is publishing "${$}" 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(Y)console.warn(`[stx] server\u2192client bridge is publishing ${(Z.length/1024).toFixed(1)}KB under "${$}". Every byte ships in the HTML on each request; prefix the binding with "__" and project just the fields the client reads.`)}function o3($,Z){if(!Z)return"";let X=p0($),Y=Z.__stxDeclaredPayload===!0,J=[];for(let[Q,G]of Object.entries(Z)){if(!/^[A-Za-z_$][\w$]*$/.test(Q))continue;if(Q.startsWith("__")||Q.startsWith("$"))continue;if(!Y&&!rG(X,Q))continue;if(oG($,Q))continue;let q;try{q=JSON.stringify(G)}catch{continue}if(q===void 0)continue;tG(Q,q),J.push(` var ${Q} = ${q.replace(/</g,"\\u003c")};`)}if(J.length===0)return"";return` // stx: server -> client data bridge (seeded from server scope)
|
|
3745
|
+
${J.join(`
|
|
3746
|
+
`)}
|
|
3747
|
+
`}var eG={left:0,middle:1,right:2};function $q($){let Z=[];if($.self)Z.push("if ($event.target !== $el) return");for(let X of $.systemKeys)Z.push(`if (!$event.${X}Key) return`);if($.keys.length>0){let X=$.keys.map((Y)=>`$event.key === '${Y}'`).join(" || ");Z.push(`if (!(${X})) return`)}if($.mouse!==null){let X=eG[$.mouse];Z.push(`if ($event.button !== ${X}) return`)}if($.prevent)Z.push("$event.preventDefault()");if($.stop)Z.push("$event.stopPropagation()");return Z.join("; ")}function Zq($,Z){let{elementId:X,event:Y,modifiers:J}=$,Q=I$($.handler),G=$q(J),q=[];if(J.once)q.push("once: true");if(J.capture)q.push("capture: true");if(J.passive)q.push("passive: true");let U=q.length>0?`, { ${q.join(", ")} }`:"",W="";if(G)W+=`${G}; `;let K=Q.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),z=`var $emit = function(name, detail) {
|
|
3748
|
+
$el.dispatchEvent(new CustomEvent(name, { detail: detail, bubbles: true, cancelable: true }))
|
|
3749
|
+
};`;function H(B){if(/\$emit\s*\(/.test(B))return`${z}
|
|
3750
|
+
${B}`;return`var scope = $el.closest('[data-stx-scope]');
|
|
3751
|
+
if (scope && scope.__stx_execute) {
|
|
3752
|
+
scope.__stx_execute('${K}', $event, $el);
|
|
3753
|
+
}
|
|
3754
|
+
else {
|
|
3755
|
+
${B}
|
|
3756
|
+
}`}if(J.debounce!==null)return` ;(function() {
|
|
3757
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
3758
|
+
var $el = document.getElementById('${X}')
|
|
3759
|
+
if (!$el) return
|
|
3760
|
+
var __timer
|
|
3761
|
+
$el.addEventListener('${Y}', function($event) {
|
|
3762
|
+
${G?G+"; ":""}clearTimeout(__timer)
|
|
3763
|
+
__timer = setTimeout(function() { ${H(Q)} }, ${J.debounce})
|
|
3764
|
+
}${U})
|
|
3765
|
+
})()`;if(J.throttle!==null)return` ;(function() {
|
|
3766
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
3767
|
+
var $el = document.getElementById('${X}')
|
|
3768
|
+
if (!$el) return
|
|
3769
|
+
var __last = 0
|
|
3770
|
+
$el.addEventListener('${Y}', function($event) {
|
|
3771
|
+
${G?G+"; ":""}var __now = Date.now()
|
|
3772
|
+
if (__now - __last >= ${J.throttle}) {
|
|
3773
|
+
__last = __now
|
|
3774
|
+
${H(Q)}
|
|
3775
|
+
}
|
|
3776
|
+
}${U})
|
|
3777
|
+
})()`;if(/\$emit\s*\(/.test(Q))return` var $el = document.getElementById('${X}')
|
|
3778
|
+
if ($el) $el.addEventListener('${Y}', function($event) {
|
|
3779
|
+
${W}${z}
|
|
3780
|
+
${Q}
|
|
3781
|
+
}${U})`;return` var $el = document.getElementById('${X}')
|
|
3782
|
+
if ($el) $el.addEventListener('${Y}', function($event) {
|
|
3783
|
+
${W}var scope = $el.closest('[data-stx-scope]');
|
|
3784
|
+
if (scope && scope.__stx_execute) {
|
|
3785
|
+
scope.__stx_execute('${K}', $event, $el);
|
|
3786
|
+
}
|
|
3787
|
+
else {
|
|
3788
|
+
${Q}
|
|
3789
|
+
}
|
|
3790
|
+
}${U})`}function Xq($){if($.length===0)return"";return`
|
|
3791
|
+
// STX: auto-generated event bindings
|
|
3792
|
+
${$.map((X,Y)=>Zq(X,Y)).join(`
|
|
3793
|
+
`)}`}function J8($){let Z=[],X=new Set,Y=$.replace(/^\s*import\s+.*$/gm,""),J=0,Q=Y.length,G=0;while(G<Q){let q=Y[G];if(q==="'"||q==='"'||q==="`"){let U=q;if(G++,U==="`"){let W=0;while(G<Q){if(Y[G]==="\\"){G+=2;continue}if(Y[G]==="`"&&W===0){G++;break}if(Y[G]==="$"&&Y[G+1]==="{"){W++,G+=2;continue}if(Y[G]==="}"&&W>0){W--,G++;continue}G++}}else while(G<Q){if(Y[G]==="\\"){G+=2;continue}if(Y[G]===U){G++;break}G++}continue}if(q==="/"&&Y[G+1]==="/"){while(G<Q&&Y[G]!==`
|
|
3794
|
+
`)G++;continue}if(q==="/"&&Y[G+1]==="*"){G+=2;while(G<Q-1&&!(Y[G]==="*"&&Y[G+1]==="/"))G++;G+=2;continue}if(q==="{"){J++,G++;continue}if(q==="}"){J--,G++;continue}if(J===0){let U=Y.slice(G),W=U.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(W){let H=W[1];if(!H.startsWith("_")&&!X.has(H))Z.push(H),X.add(H);G+=W[0].length;continue}let K=U.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(K){K[1].split(",").forEach((H)=>{let B=H.trim(),j=B.indexOf(":"),_=j>=0?B.slice(j+1).trim().split(/[\s=]/)[0]:B.split(/[\s=]/)[0];if(_&&!_.startsWith("_")&&!X.has(_))Z.push(_),X.add(_)}),G+=K[0].length;continue}let z=U.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(z){let H=z[1];if(!H.startsWith("_")&&!X.has(H))Z.push(H),X.add(H);G+=z[0].length;continue}}G++}return Z}var Yq=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 Jq($){let Z=new Set,X=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function Y(H){let B;while((B=X.exec(H))!==null){let j=B[0];if(!Yq.has(j))Z.add(j)}}let J=/\{\{([\s\S]*?)\}\}/g,Q;while((Q=J.exec($))!==null)Y(Q[1]);let G=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((Q=G.exec($))!==null)Y(Q[1]);let q=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((Q=q.exec($))!==null)Y(Q[1]);let U=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((Q=U.exec($))!==null)Y(Q[1]);let W=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((Q=W.exec($))!==null)Y(Q[1]);let K=/@model\s*=\s*["']([^"']*)["']/gi;while((Q=K.exec($))!==null)Y(Q[1]);let z=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((Q=z.exec($))!==null)Y(Q[1]);return Z}async function N$($,Z={}){let X=$,Y="",J=!1,Q=[],G=N4(X,{filePath:Z.filePath,projectRoot:Z.projectRoot});X=G.code;let q=A4(G.styles),U=R5(X);X=U.code,Q=[...U.imports,...U.models];let{hasUserImports:W,bundleClientScript:K}=await a("stx/client-script-bundler",()=>import("./chunk-fd77g6t6.js"));if(W(X))X=await K(X,Z.filePath||"",{projectRoot:Z.projectRoot,minify:Z.production}),J=!0;if(Z.autoImports!==!1){let F=W8(X);X=F.code,Y=K8(F.stxImports,F.browserImports.filter((L)=>!Q.includes(L)))}if(Y=`${o3(X,Z.serverData)}${Y}`,X=o0(X),!J&&N1(Z.attrs||""))X=A1(X);let z=Xq(Z.eventBindings||[]),H=(Z.attrs||"").trim();if(/\btype\s*=\s*["']module["']/i.test(H)){let F=H.replace(/\btype\s*=\s*["']module["']/i,"").trim(),L=`type="module" data-stx-scoped${F?` ${F}`:""}`;return`${q}<script ${L}>
|
|
3795
|
+
${n1(`${Y}${X}
|
|
3796
|
+
${z}`)}
|
|
3797
|
+
</script>`}let j=G8($),_=/function __stx_setup_/.test(X),V=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test($);function O(F){let L=F.length>0?`
|
|
3798
|
+
return { ${F.join(", ")} };`:"";return`${q}<script data-stx-scoped data-stx-run="always">
|
|
3799
|
+
window.stx.mount(function() {
|
|
3800
|
+
'use strict';
|
|
3801
|
+
${n1(`${Y}${X}
|
|
3802
|
+
${z}${L}`)}
|
|
3803
|
+
})</script>`}if(!V&&!_){if(j)return O(J8($));if(Z.templateContent){let F=J8($);if(F.length>0){let L=Jq(Z.templateContent);if(F.some((R)=>L.has(R)))return O(F)}}}return`${q}<script data-stx-scoped data-stx-run="always">
|
|
3804
|
+
;(function() {
|
|
3805
|
+
'use strict';
|
|
3806
|
+
${n1(`${Y}${X}
|
|
3807
|
+
${z}`)}
|
|
3808
|
+
})()</script>`}
|
|
3809
|
+
export{r8 as dl,a8 as el,t8 as fl,r0 as gl,v$ as hl,f$ as il,x$ as jl,g$ as kl,j7 as ll,B7 as ml,GZ as nl,UZ as ol,KZ as pl,lq as ql,cq as rl,pq as sl,iq as tl,nq as ul,s8 as vl,W7 as wl,K7 as xl,z7 as yl,H7 as zl,dq as Al,D7 as Bl,W5 as Cl,I$ as Dl,k$ as El,O8 as Fl,S4 as Gl,Gq as Hl,o0 as Il,Uq as Jl,e1 as Kl,$j as Ll,N4 as Ml,A4 as Nl,pG as Ol,R5 as Pl,K8 as Ql,YO as Rl,D$ as Sl,o3 as Tl,N$ as Ul,Q0 as Vl,_0 as Wl,G0 as Xl,Bq as Yl,v5 as Zl,jq as _l,_q as $l,Oq as am,Vq as bm,Y1 as cm,Q5 as dm,x5 as em,I8 as fm,Mq as gm,k8 as hm,Tq as im,b$ as jm,r4 as km,J1 as lm,y$ as mm,y8 as nm,Iq as om,_1 as pm,S8 as qm,b0 as rm,kq as sm,$7 as tm,Cq as um,d8 as vm,m8 as wm,G7 as xm,q7 as ym,U7 as zm,hq as Am,_7 as Bm,U1 as Cm,pZ as Dm,iZ as Em,nZ as Fm,sZ as Gm,i7 as Hm,oZ as Im,l as Jm,a$ as Km,H5 as Lm,B5 as Mm,c5 as Nm,aZ as Om,p5 as Pm,tZ as Qm,i5 as Rm,F1 as Sm,s7 as Tm,L1 as Um,o7 as Vm,r7 as Wm,n5 as Xm,t$ as Ym,$0 as Zm,JX as _m,QX as $m,GX as an,h1 as bn,e$ as cn,$3 as dn,u0 as en,Z3 as fn,Y3 as gn,s5 as hn,UX as in,WX as jn,KX as kn,e7 as ln,$$ as mn,H0 as nn,V6 as on,z3 as pn,W1 as qn,w1 as rn,F6 as sn,_5 as tn,Z$ as un,H3 as vn,gX as wn,uX as xn,R6 as yn,mX as zn,lX as An,N6 as Bn,R1 as Cn,VK as Dn,A6 as En,F3 as Fn,sX as Gn,V3 as Hn,oX as In,rX as Jn,FK as Kn,LK as Ln,M6 as Mn,T6 as Nn,I6 as On,aX as Pn,tX as Qn,wK as Rn,RK as Sn,eX as Tn,DK as Un,NK as Vn,b6 as Wn,P6 as Xn,R3 as Yn,PK as Zn,F5 as _n,D3 as $n,N3 as ao,vK as bo,_Y as co,fK as do,OY as eo,x6 as fo,xK as go,VY as ho,gK as io,hK as jo,E3 as ko,cK as lo,pK as mo,iK as no,nK as oo,sK as po,wY as qo,oK as ro,Y$ as so,RY as to,rK as uo,aK as vo,tK as wo,eK as xo,IY as yo,EY as zo,dY as Ao,k3 as Bo,d6 as Co,$z as Do,J$ as Eo,MQ as Fo,vQ as Go,B4 as Ho,n9 as Io,HG as Jo,BG as Ko,jG as Lo,_G as Mo,OG as No,s9 as Oo,wG as Po,AG as Qo,MG as Ro,$2 as So,Z2 as To,Bz as Uo,i6 as Vo,jz as Wo,S3 as Xo,C3 as Yo,P3 as Zo,Q2 as _o,G2 as $o,q2 as ap,Z6 as bp,X6 as cp,Y6 as dp,J6 as ep,J3 as fp,Q3 as gp,HW as hp,BW as ip,jW as jp,HX as kp,_W as lp,xz as mp,gz as np,W2 as op,hz as pp,H2 as qp,BJ as rp,j2 as sp,F2 as tp,N2 as up,W$ as vp,tz as wp,ez as xp,d3 as yp,A2 as zp,M2 as Ap,cJ as Bp,ZH as Cp,XH as Dp,pJ as Ep,YH as Fp,T2 as Gp,I2 as Hp,z$ as Ip,H$ as Jp,i1 as Kp,nJ as Lp,E2 as Mp,b2 as Np,y2 as Op,sJ as Pp,oJ as Qp,m3 as Rp,l3 as Sp,S2 as Tp,C2 as Up,v2 as Vp,BH as Wp,h2 as Xp,eJ as Yp,XQ as Zp,o2 as _p,r3 as $p,r2 as aq,t2 as bq,e2 as cq,HQ as dq,BQ as eq,$9 as fq,n3 as gq,jQ as hq,j4 as iq,_4 as jq,V4 as kq,F4 as lq,$G as mq,QG as nq,GG as oq,qG as pq,UG as qq,EG as rq,N1 as sq,w4 as tq,A1 as uq,w$ as vq,PG as wq,vG as xq,fG as yq,T1 as zq,r as Aq,r5 as Bq,Z8 as Cq,W0 as Dq,d_ as Eq,m_ as Fq,N7 as Gq,A7 as Hq,V1 as Iq,M7 as Jq,f1 as Kq,T7 as Lq,K5 as Mq,qU as Nq,NZ as Oq,u$ as Pq,UU as Qq,d$ as Rq,WU as Sq,KU as Tq,G1 as Uq,zU as Vq,HU as Wq,BU as Xq,jU as Yq,_U as Zq,OU as _q,AZ as $q,l$ as ar,I7 as br,FU as cr,LU as dr,wU as er,RU as fr,DU as gr,E7 as hr,NU as ir,b7 as jr,AU as kr,MU as lr,z5 as mr,bZ as nr,EU as or,SZ as pr,f7 as qr,m5 as rr,vU as sr,l7 as tr,r$ as ur,RW as vr,q3 as wr,FX as xr,DX as yr,DW as zr,NW as Ar,AW as Br,MW as Cr,TW as Dr,IW as Er,NX as Fr,AX as Gr,Q6 as Hr,j6 as Ir,kX as Jr,U3 as Kr,_6 as Lr,lW as Mr,cW as Nr,K3 as Or,CX as Pr,O6 as Qr};
|