@jxsuite/compiler 4.0.2 → 5.0.0

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/compiler.js CHANGED
@@ -1,4 +1,4 @@
1
- import{createRequire as Hx}from"node:module";var Fx=Object.create;var{getPrototypeOf:Tx,defineProperty:ZE,getOwnPropertyNames:Mx}=Object;var KE=Object.prototype.hasOwnProperty;function Ux(e){return this[e]}var Lx,Ox,vx=(e,t,r)=>{var n=e!=null&&typeof e==="object";if(n){var s=t?Lx??=new WeakMap:Ox??=new WeakMap,A=s.get(e);if(A)return A}r=e!=null?Fx(Tx(e)):{};let o=t||!e||!e.__esModule||!KE.call(e,"default")?ZE(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let i of Mx(e))if(!KE.call(o,i))ZE(o,i,{get:Ux.bind(e,i),enumerable:!0})}if(n)s.set(e,o);return o};var R=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var P=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};var D=Hx(import.meta.url);function Ye(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ve(e){return Ye(e)&&typeof e.$ref==="string"}function _t(e){return Ye(e)&&e.$prototype==="Function"}function Ct(e){return Ye(e)&&Ye(e.$expression)}function Jn(e){return Ct(e)&&Array.isArray(e.parameters)&&e.parameters.length>0}function ir(e){return _t(e)&&Array.isArray(e.body)}function Gs(e){return Ye(e)&&typeof e.$prototype==="string"&&e.$prototype!=="Function"}function Nl(e){return Ye(e)&&e.timing==="server"&&typeof e.$src==="string"&&typeof e.$export==="string"&&!e.$prototype}function zE(e){return Ye(e)&&!e.$prototype&&!e.$expression&&"default"in e}function Zr(e){if(!Ye(e))return!1;for(let t of Object.keys(e))if(!XE.has(t))return!1;return!0}function it(e){return Ye(e)&&e.$prototype==="Array"}function bl(e){if(it(e))return!0;return Array.isArray(e)&&e.some((t)=>it(t))}function ed(e){return Ye(e)&&e.$prototype==="Class"}function ue(e){return typeof e==="string"&&e.includes("${")}function $n(e){return/\breturn\b[^\S\n]*(?![;}\s]|$)/.test(e)}function GZ(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Nr(e){if(!e)return[];return e.map((t)=>typeof t==="string"?t:t.name)}function br(e){if(!Ye(e)||!Ye(e.$expression))return!1;let t=e.$expression;if(t.operator==="?:")return typeof t.value==="string"&&typeof t.initial==="string";if(t.operator==="switch")return Ye(t.cases)&&Object.values(t.cases).every((r)=>typeof r==="string")&&typeof t.default==="string";return!1}function Vs(e){if(typeof e==="string")return[e];if(!br(e))return[];let t=e.$expression;if(t.operator==="?:")return[...new Set([t.value,t.initial])];return[...new Set([...Object.values(t.cases),t.default])]}var XE;var xr=P(()=>{XE=new Set(["type","enum","minimum","maximum","minLength","maxLength","pattern","format","items","properties","required","description","title","$comment"])});function at(e){return e.replaceAll(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}function td(e,t){if(e.startsWith("@--"))return t[e.slice(1)]??e.slice(1);if(e.startsWith("@(")){let r=e.slice(2,-1).trim();return Yx.has(r.toLowerCase())?r:e.slice(1)}return null}function fo(e){return e.startsWith("@position-try")||e.startsWith("@property")||e.startsWith("@font-face")||e.startsWith("@counter-style")}function Eo(e){return e.startsWith("@keyframes")}function rd(e,t){let r=[];for(let n of ho(e))for(let s of ho(t))r.push(Jx(n,s));return r.join(", ")}function Jx(e,t){if(t.startsWith("&"))return t.replaceAll("&",e);if(t.startsWith("[")||t.startsWith(":")||t.startsWith("."))return`${e}${t}`;return`${e} ${t}`}function ho(e){let t=[],r=0,n=null,s=0;for(let o=0;o<e.length;o+=1){let i=e[o];if(n){if(i==="\\")o+=1;else if(i===n)n=null;continue}if(i==='"'||i==="'")n=i;else if(i==="("||i==="[")r+=1;else if(i===")"||i==="]")r=Math.max(0,r-1);else if(i===","&&r===0)t.push(e.slice(s,o)),s=o+1}t.push(e.slice(s));let A=t.map((o)=>o.trim()).filter((o)=>o!=="");return A.length>0?A:[e]}function kr(e){return/^\(\s*prefers-color-scheme\s*:\s*(light|dark)\s*\)$/.exec(e.trim())?.[1]??null}function xl(e,t){if(e===":root"||e==="html")return{auto:`${e}:where(:not([${Wt}]))`,forced:`${e}:where([${Wt}="${t}"])`};return{auto:`:where(:root:not([${Wt}])) ${e}`,forced:`:where(:root[${Wt}="${t}"]) ${e}`}}function Kr(e){return e.startsWith(":")||e.startsWith(".")||e.startsWith("&")||e.startsWith("[")}function kl(e){return e.startsWith("--")?e:at(e)}function ji(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function nd(e,t,r){let n=r.map(([A,o])=>`${A}: ${o}`).join("; "),s=t===null?n:`${t} { ${n} }`;for(let A=e.length-1;A>=0;A-=1)s=`${e[A]} { ${s} }`;return s}function $x(e,t,r){let n=r.map(({selector:A,declarations:o})=>`${A} { ${o.map(([i,a])=>`${i}: ${a}`).join("; ")} }`).join(" "),s=`@keyframes ${t} { ${n} }`;for(let A=e.length-1;A>=0;A-=1)s=`${e[A]} { ${s} }`;return s}function Px(e){let t=Object.keys(e).filter((n)=>Eo(n));if(t.length===0)return e;let r={...e};for(let n of t)delete r[n];return r}function Gx(e){let t=e.startsWith("&")?e.slice(1):e;return t===""||t.startsWith(":")||t.startsWith(".")||t.startsWith("[")}function _s(e,t={}){let{scope:r=null,mediaQueries:n={},transposeValue:s=(E)=>E,transposeSelector:A=(E)=>E,resolveValue:o}=t,i=[],a=(E)=>E!==null&&typeof E==="object"&&!Array.isArray(E)&&!ve(E),c=(E,I)=>{if(a(I))return[I];if(!fo(E)||!Array.isArray(I)||I.length===0)return[];return I.every((C)=>a(C))?I:[]},l=(E,I,C,Q)=>{if(I===void 0||I===null)return null;if(ve(I))return C?o?.(E,I,Q)??null:null;if(typeof I==="object")return null;let w=String(I);if(ue(w))return C?o?.(E,w,Q)??null:null;return s(w)},u=(E,I,C=!0,Q="self")=>{let w=[];for(let[B,S]of Object.entries(E)){if(c(B,S).length>0)continue;if(I&&(B.startsWith("@")||Kr(B)))continue;if(B.startsWith("$"))continue;let p=l(B,S,C,Q);if(p!==null)w.push([kl(B),p])}return w},g=(E,I,C,Q,w)=>{if(C.length===0)return;let B=I;if(B!==null){let p=A(B);if(p===null)return;B=p}let S=nd(E,B,C);i.push({text:S,conditions:[...E],selector:B,declarations:C,target:Q,key:ji(S),...typeof w==="string"&&w!==""?{description:w}:{}})},h=(E,I,C)=>{let Q=E.slice(10).trim();if(Q==="")return;let w=[];for(let[S,p]of Object.entries(I)){if(!a(p))continue;let m=u(p,!0,!1,"unscoped");if(m.length>0)w.push({declarations:m,selector:S.trim()})}if(w.length===0)return;let B=$x(C,Q,w);i.push({blocks:w,conditions:[...C],declarations:[],key:ji(B),selector:null,target:"unscoped",text:B})},f=(E,I,C,Q,w)=>{if(E==="@--")return;if(fo(E)){g([...Q,E],null,u(I,!1,!0,"unscoped"),"unscoped",I.$description);return}if(Eo(E)){h(E,I,Q);return}let B=td(E,n),S=B===null?E:`@media ${B}`,p=B===null?null:kr(B);if(p!==null&&C!==null){let{auto:m,forced:x}=xl(C,p);d(I,m,[...Q,S],w),d(Px(I),x,Q,w);return}d(I,C,[...Q,S],w)};function d(E,I,C,Q){g(C,I,u(E,!0,!0,Q),Q,E.$description);for(let[w,B]of Object.entries(E))for(let S of c(w,B))if(w.startsWith("@"))f(w,S,I,C,Q);else if(I!==null)d(S,rd(I,w),C,Gx(w)?Q:"descendant")}return d(e,r,[],"self"),i}var Yx,Wt="data-color-scheme",Zi="jx-color-scheme";var Ki=P(()=>{xr();Yx=new Set(["all","print","screen","speech"])});function qZ(){return`the Intl helpers ${Tl.join(", ")}`}var ar="en-US",Fl="UTC",sd,Tl,Ad;var od=P(()=>{sd=[{api:"Intl.NumberFormat",params:["value","locale","options"],path:"Intl/formatNumber",summary:"Format a number for a locale — grouping, decimals, currency, percent, units."},{api:"Intl.DateTimeFormat",params:["value","locale","options"],path:"Intl/formatDate",summary:"Format a date or timestamp for a locale. Pass `timeZone` in options."},{api:"Intl.RelativeTimeFormat",params:["value","unit","locale","options"],path:"Intl/formatRelativeTime",summary:'Format a relative time — `-3, "day"` becomes "3 days ago".'},{api:"Intl.ListFormat",params:["values","locale","options"],path:"Intl/formatList",summary:'Join a list the way a locale does — "a, b, and c", not a hand-written comma join.'},{api:"Intl.PluralRules",params:["value","locale","options"],path:"Intl/plural",summary:'Which plural category a number falls in ("one", "few", "other") — many languages have '+"more than two, so a ternary on `n === 1` is wrong outside English."},{api:"Intl.Collator",params:["a","b","locale","options"],path:"Intl/compare",summary:'Compare two strings for sorting. `<` and `sort()` order by UTF-16 code unit, which puts "Zebra" before "apple" and sorts every accented word into the wrong place.'},{api:"Intl.DisplayNames",params:["code","type","locale","options"],path:"Intl/displayName",summary:'The name of a language, region, script or currency in a locale — "de" as "German" or '+'"Deutsch", from CLDR rather than a hand-kept table.'},{api:"Intl.Segmenter",params:["value","granularity","locale"],path:"Intl/segment",summary:"Split text into graphemes, words or sentences (UAX #29). `[...str]` splits code points, so it cuts an emoji with a skin-tone modifier in half."}],Tl=sd.map((e)=>e.path),Ad=Object.fromEntries(sd.map((e)=>[e.path,e.params.indexOf("locale")]))});function Vx(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function Ge(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function zr(e){if(e==="")return[];return e.split("/").map((t)=>Vx(t))}function Xr(e,t){let r=e;for(let n of zr(t))r=r?.[n];return r}function re(e,t){let r=e;for(let n of zr(t))r+=id.test(n)?`.${n}`:`[${JSON.stringify(n)}]`;return r}function Ws(e){return id.test(e)?e:JSON.stringify(e)}function ad(e){let t=e.replaceAll(/[^A-Za-z0-9_$]/g,"_");if(t==="")return"ref";return/^\d/.test(t)?`_${t}`:t}var id;var qs=P(()=>{id=/^[A-Za-z_$][A-Za-z0-9_$]*$/});function Ml(e){let t=e.$map;return t&&typeof t==="object"?t:void 0}function jx(e,t,r){let n=Ad[e];if(n===void 0||n<0||t[n]!=null)return t;let A=r.$page?.locale;if(typeof A!=="string"||A==="")return t;let o=[...t];return o[n]=A,o}function hd(e){return e.startsWith("window#/")&&Wx.has(e.slice(8))}function Fr(e){return ud.has(e)}function Be(e,t){if(!e)return;let r=(e.depth??0)+1;if(r>Zx)return;return{depth:r,path:[...e.path??[],...Array.isArray(t)?t:[t]],report:e.report}}function he(e,t,r,n,s){if(e===null||e===void 0)return e;if(typeof e==="object"&&!Array.isArray(e)&&"operator"in e)return Qt(e,t,r,n,s);if(typeof e==="object"&&!Array.isArray(e)&&"$ref"in e){let A=zi(e.$ref,t,r,n);return s?.report(s.path??[],A),A}if(Array.isArray(e))return e.map((A,o)=>he(A,t,r,n,Be(s,o)));return s?.report(s.path??[],e),e}function Kx(e,t,r,n){let s=(A)=>{if(!e.slice(A.length).includes("/"))return t;return zi(e.slice(0,e.lastIndexOf("/")),t,r,n)};if(e.startsWith("#/state/"))return s("#/state/");if(e.startsWith("parent#/"))return s("parent#/");if(e.startsWith("$map/")||e.startsWith("$args/"))return e.split("/").length>2?zi(e.slice(0,e.lastIndexOf("/")),t,r,n):void 0;return}function zi(e,t,r,n){if(e==="$reduce/acc")return n?.acc;if(e.startsWith("$reduce/"))return n?.acc;if(e.startsWith("$args/")){let s=e.slice(6).split("/"),A=n?.args?.[s[0]];return s.length>1?en(A,s.slice(1).join("/")):A}if(e.startsWith("event#/")){let s=e.slice(7);return en(r,s)}if(e.startsWith("$map/")){let s=e.split("/"),[,A]=s,o,i=Ml(t);if(A==="item")o=n?.item??i?.item??t["$map/item"];else if(A==="index")o=n?.index??i?.index??t["$map/index"];else o=i?.[A]??t[`$map/${A}`];return s.length>2?en(o,s.slice(2).join("/")):o}if(e.startsWith("#/state/"))return Xr(t,e.slice(8));if(e.startsWith("parent#/"))return Xr(t,e.slice(8));if(e.startsWith("window#/"))return en(globalThis.window,e.slice(8));if(e.startsWith("document#/"))return en(globalThis.document,e.slice(10));return Xr(t,e)??null}function zx(e,t,r,n){if(e.startsWith("$map/")){let s=e.split("/"),[,A]=s,o,i=Ml(t);if(A==="item")o=n?.item??i?.item??t["$map/item"];else if(A==="index")o=n?.index??i?.index??t["$map/index"];else o=i?.[A]??t[`$map/${A}`];if(s.length>2){let a=s.slice(2),c=a.pop(),l=a.length>0?en(o,a.join("/")):o;return{key:c,obj:l}}return{key:A==="item"?"$map/item":"$map/index",obj:Ml(t)??t}}if(e.startsWith("#/state/")){let s=e.slice(8);if(s.indexOf("/")===-1)return{key:s,obj:t};let o=zr(s),i=o.pop(),a=t;for(let c of o)a=a[c];return{key:i,obj:a}}return{key:e,obj:t}}function Qt(e,t,r,n,s){let A=Xx(e,t,r,n,s);return s?.report(s.path??[],A),A}function Xx(e,t,r,n,s){let{operator:A,target:o,value:i,initial:a}=e;if(!_x.has(A))throw Error(`$expression: unknown operator "${A}"`);if(Ul.has(A)&&!("value"in e)){let c=he(o,t,r,n,Be(s,"target"));if(A==="!")return!c;if(A==="-")return-c}if(A==="call"){let c=o?.$ref;if(typeof c!=="string")throw TypeError("$expression: call target must be a $ref pointer");let l=(n?.callDepth??0)+1;if(l>cd)throw Error(`$expression: call depth exceeded (${cd})`);let u=Array.isArray(i)?i.map((h,f)=>he(h,t,r,n,Be(s,["value",f]))):[];if(c.startsWith("window#/")){if(!hd(c))throw Error(`$expression: "${c}" is not a blessed pure global`);let h=c.slice(8),f=qx[h];if(f)return f(...jx(h,u,t));let d=en(globalThis.window,h),E=h.lastIndexOf("/"),I=E===-1?globalThis.window:en(globalThis.window,h.slice(0,E));return d.apply(I,u)}let g=zi(c,t,r,n);if(typeof g==="function")return g.apply(Kx(c,t,r,n),u);if(g&&typeof g==="object"&&"$expression"in g){let h=g,f={};for(let[d,E]of(h.parameters??[]).entries()){let I=typeof E==="string"?E:E?.name??"";if(!I)continue;f[I]=u[d]===void 0&&typeof E==="object"&&E!==null&&"default"in E?E.default:u[d]}return Qt(h.$expression,t,r,{args:f,callDepth:l})}throw TypeError(`$expression: call target "${c}" is not callable`)}if(vl.has(A)){if(A==="?:"){let h=he(o,t,r,n,Be(s,"target"));if(s){let f=he(i,t,r,n,Be(s,"value")),d=he(a,t,r,n,Be(s,"initial"));return h?f:d}return h?he(i,t,r,n):he(a,t,r,n)}let c=he(o,t,r,n,Be(s,"target")),l=String(c),u=e.cases??{},g=Object.hasOwn(u,l);if(s){let h;for(let[d,E]of Object.entries(u)){let I=he(E,t,r,n,Be(s,["cases",d]));if(d===l)h=I}let f=he(e.default,t,r,n,Be(s,"default"));return g?h:f}return g?he(u[l],t,r,n):he(e.default,t,r,n)}if(Ll.has(A)){let c=he(o,t,r,n,Be(s,"target")),l=he(i,t,r,n,Be(s,"value"));switch(A){case"+":return c+l;case"-":return c-l;case"*":return c*l;case"/":return c/l;case"%":return c%l;case"===":return c===l;case"!==":return c!==l;case"<":return c<l;case"<=":return c<=l;case">":return c>l;case">=":return c>=l;case"&&":return c&&l;case"||":return c||l;case"??":return c??l;default:break}}if(gd.has(A)){let c=he(i,t,r,n,Be(s,"value")),{obj:l,key:u}=zx(o.$ref,t,r,n);switch(A){case"=":{l[u]=c;break}case"+=":{let g=l[u];l[u]=g+c;break}case"-=":{let g=l[u];l[u]=g-c;break}case"*=":{let g=l[u];l[u]=g*c;break}case"/=":{let g=l[u];l[u]=g/c;break}default:break}return}if(fd.has(A)){let c=he(o,t,r,n,Be(s,"target"));switch(A){case"push":return c.push(he(i,t,r,n,Be(s,"value")));case"unshift":return c.unshift(he(i,t,r,n,Be(s,"value")));case"pop":return c.pop();case"shift":return c.shift();case"splice":{let l=he(i,t,r,n,Be(s,"value"));return c.splice(...l)}default:break}}if(Hl.has(A)){let c=he(o,t,r,n,Be(s,"target")),l=i===void 0?[]:Array.isArray(i)?he(i,t,r,n,Be(s,"value")):[he(i,t,r,n,Be(s,"value"))],u=c?.[A];if(typeof u!=="function")return;return u.apply(c,l)}if(Ol.has(A)){let c=he(o,t,r,n,Be(s,"target"));if(A==="reduce"){let l=he(a,t,r,n,Be(s,"initial"));for(let[u,g]of c.entries())l=Qt(i,t,r,{acc:l,index:u,item:g},u===0?Be(s,"value"):void 0);return l}if(A==="map")return c.map((l,u)=>Qt(i,t,r,{...n,index:u,item:l},u===0?Be(s,"value"):void 0));if(A==="filter")return c.filter((l,u)=>Qt(i,t,r,{...n,index:u,item:l},u===0?Be(s,"value"):void 0))}return}function ye(e,t){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e==="object"&&!Array.isArray(e)&&"operator"in e)return ze(e,t);if(typeof e==="object"&&!Array.isArray(e)&&"$ref"in e)return Yl(e.$ref,t);if(Array.isArray(e))return e.map((r)=>ye(r,t)).join(", ");return JSON.stringify(e)}function ek(e){return`_fx_${e.replaceAll(/[^A-Za-z0-9_$]/g,"_")}`}function Yl(e,t){let r=t.statePrefix??"state",n=t.eventParam??"event";if(e==="$reduce/acc")return"_acc";if(e.startsWith("$reduce/"))return"_acc";if(e.startsWith("$args/"))return re("_args",e.slice(6));if(e.startsWith("event#/"))return re(n,e.slice(7));if(e.startsWith("$map/")){let s=e.split("/"),[,A]=s;if(A==="item")return s.length>2?re("_item",s.slice(2).join("/")):"_item";if(A==="index")return"_index";return`_${A}`}if(e.startsWith("#/state/"))return re(r,e.slice(8));if(e.startsWith("parent#/"))return re(r,e.slice(8));if(e.startsWith("window#/"))return re("window",e.slice(8));if(e.startsWith("document#/"))return re("document",e.slice(10));return re(r,e)}function ld(e,t){if(typeof e==="object"&&e!==null&&"$ref"in e)return Yl(e.$ref,t);return ye(e,t)}function tk(e,t,r){let n=(o)=>t[o]??"undefined",s=`(${r.statePrefix??"state"}?.$page?.locale ?? ${JSON.stringify(ar)})`,A=JSON.stringify(Fl);switch(e){case"Intl/formatNumber":return`new Intl.NumberFormat(${n(1)} ?? ${s}, ${n(2)}).format(${n(0)})`;case"Intl/formatDate":return`new Intl.DateTimeFormat(${n(1)} ?? ${s}, {timeZone: ${A}, ...${n(2)}}).format(new Date(${n(0)}))`;case"Intl/formatRelativeTime":return`new Intl.RelativeTimeFormat(${n(2)} ?? ${s}, ${n(3)}).format(${n(0)}, ${n(1)})`;case"Intl/formatList":return`new Intl.ListFormat(${n(1)} ?? ${s}, ${n(2)}).format(${n(0)})`;case"Intl/plural":return`new Intl.PluralRules(${n(1)} ?? ${s}, ${n(2)}).select(${n(0)})`;case"Intl/compare":return`new Intl.Collator(${n(2)} ?? ${s}, ${n(3)}).compare(${n(0)}, ${n(1)})`;case"Intl/displayName":return`new Intl.DisplayNames(${n(2)} ?? ${s}, {...${n(3)}, type: ${n(1)} ?? 'language'}).of(${n(0)})`;case"Intl/segment":return`[...new Intl.Segmenter(${n(2)} ?? ${s}, {granularity: ${n(1)} ?? 'grapheme'}).segment(${n(0)})].map((p) => p.segment)`;default:return null}}function ze(e,t={}){let{operator:r,target:n,value:s,initial:A}=e;if(Ul.has(r)&&!("value"in e)){let o=ye(n,t);if(r==="!")return`!(${o})`;if(r==="-")return`-(${o})`}if(r==="call"){let o=n?.$ref??"",i=Array.isArray(s)?s.map((a)=>ye(a,t)):[];if(o.startsWith("window#/")){if(!hd(o))throw Error(`$expression: "${o}" is not a blessed pure global`);let a=tk(o.slice(8),i,t);if(a)return a;return`window.${o.slice(8).replaceAll("/",".")}(${i.join(", ")})`}if(o.startsWith("#/state/")){let a=o.slice(8),c=t.formulaParams?.[a];if(c){let l=c.map((u,g)=>`${JSON.stringify(u)}: ${i[g]??"undefined"}`).join(", ");return`${ek(a)}(${t.statePrefix??"state"}, { ${l} })`}}return`${Yl(o,t)}(${i.join(", ")})`}if(vl.has(r)){if(r==="?:"){let c=ye(n,t),l=ye(s,t),u=ye(A,t);return`(${c} ? ${l} : ${u})`}let o=ye(n,t),i=Object.entries(e.cases??{}).map(([c,l])=>`_d === ${JSON.stringify(c)} ? ${ye(l,t)} : `).join(""),a="default"in e?ye(e.default,t):"undefined";return`((_d) => ${i}${a})(String(${o}))`}if(Ll.has(r)){let o=ye(n,t),i=ye(s,t);return`(${o} ${r} ${i})`}if(gd.has(r)){let o=ld(n,t),i=ye(s,t);return`${o} ${r} ${i}`}if(fd.has(r)){let o=ld(n,t);switch(r){case"push":return`${o}.push(${ye(s,t)})`;case"unshift":return`${o}.unshift(${ye(s,t)})`;case"pop":return`${o}.pop()`;case"shift":return`${o}.shift()`;case"splice":{let i=Array.isArray(s)?s.map((a)=>ye(a,t)).join(", "):ye(s,t);return`${o}.splice(${i})`}default:break}}if(Hl.has(r)){let o=ye(n,t),i=s===void 0?"":Array.isArray(s)?s.map((a)=>ye(a,t)).join(", "):ye(s,t);return`(${o})?.${r}?.(${i})`}if(Ol.has(r)){let o=ye(n,t),i=ze(s,t);if(r==="reduce"){let a=ye(A,t);return`${o}.reduce((_acc, _item, _index) => ${i}, ${a})`}if(r==="map")return`${o}.map((_item, _index) => ${i})`;if(r==="filter")return`${o}.filter((_item, _index) => ${i})`}return"undefined"}function en(e,t){return Xr(e,t)}function js(e,t,r,n){return he(e,t,r,n)}function Pn(e,t={}){return ye(e,t)}var ud,Ul,Ll,gd,fd,Ol,vl,Hl,_x,Wx,qx,cd=64,Zx=64;var Io=P(()=>{od();qs();ud=new Set(["=","+=","-=","*=","/=","push","pop","shift","unshift","splice"]),Ul=new Set(["!","-"]),Ll=new Set(["+","-","*","/","%","===","!==","<","<=",">",">=","&&","||","??"]),gd=new Set(["=","+=","-=","*=","/="]),fd=new Set(["push","pop","shift","unshift","splice"]),Ol=new Set(["reduce","map","filter"]),vl=new Set(["?:","switch"]),Hl=new Set(["includes","indexOf","lastIndexOf","join","slice","concat","at","flat","toSorted","toReversed","toSpliced","with","toUpperCase","toLowerCase","trim","trimStart","trimEnd","split","startsWith","endsWith","padStart","padEnd","replaceAll","repeat","charAt","normalize","toLocaleUpperCase","toLocaleLowerCase","toFixed","toPrecision","toLocaleString"]),_x=new Set([...ud,...Ul,...Ll,...Ol,...vl,...Hl,"call"]),Wx=new Set(["isNaN","isFinite","parseFloat","parseInt","encodeURIComponent","decodeURIComponent","structuredClone","Math/abs","Math/ceil","Math/floor","Math/round","Math/trunc","Math/sign","Math/sqrt","Math/cbrt","Math/pow","Math/exp","Math/log","Math/log2","Math/log10","Math/min","Math/max","Math/hypot","Number/isInteger","Number/isFinite","Number/isNaN","Number/parseFloat","Number/parseInt","JSON/parse","JSON/stringify","Object/keys","Object/values","Object/entries","Object/fromEntries","Array/from","Array/isArray","Array/of","String/fromCharCode","String/fromCodePoint",...Tl]),qx={"Intl/compare":(e,t,r,n)=>new Intl.Collator(r??ar,n).compare(e,t),"Intl/displayName":(e,t,r,n)=>new Intl.DisplayNames(r??ar,{...n,type:t??"language"}).of(e),"Intl/formatDate":(e,t,r)=>new Intl.DateTimeFormat(t??ar,{timeZone:Fl,...r}).format(new Date(e)),"Intl/formatList":(e,t,r)=>new Intl.ListFormat(t??ar,r).format(e),"Intl/formatNumber":(e,t,r)=>new Intl.NumberFormat(t??ar,r).format(e),"Intl/formatRelativeTime":(e,t,r,n)=>new Intl.RelativeTimeFormat(r??ar,n).format(e,t),"Intl/plural":(e,t,r)=>new Intl.PluralRules(t??ar,r).select(e),"Intl/segment":(e,t,r)=>[...new Intl.Segmenter(r??ar,{granularity:t??"grapheme"}).segment(e)].map((n)=>n.segment)}});function rk(e){return e.startsWith("npm:")}function tK(e){let t=e;if(rk(t))t=t.slice(4);return t=t.replace(/^\.\//,"").replace(/\.(js|ts|mjs|mts)$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,""),`/assets/${t}.js`}function rK(e){let t=/\.(\w+)$/.exec(e)?.[1]??"",r=e.replace(/\.\w+$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");return t===""?`/assets/${r}`:`/assets/${r}.${t}`}function Ed(e){let t=e.replaceAll("\\","/");return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function dd(e){let t=Ed(e);return t.startsWith("/")?t:`/${t}`}function nk(e,t){return[...e].toSorted((r,n)=>n[t].length-r[t].length)}function nK(e,t){let r=t.split("#")[0].split("?")[0];if(!r.startsWith("/"))return null;let n;try{n=decodeURIComponent(r)}catch{return null}if(/%2e|%2f/i.test(n))return null;for(let s of nk(e,"urlPrefix")){let A=dd(s.urlPrefix);if(!n.startsWith(`${A}/`))continue;let i=n.slice(A.length+1).split("/");if(i.some((a)=>a===""||a==="."||a===".."))return null;return`${Ed(s.dir)}/${i.join("/")}`}return null}function sK(e,t){let r=new Set;for(let n of t){let s=dd(n.urlPrefix),A=new RegExp(`${s.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}/[^${sk}]+`,"g");for(let o of e.matchAll(A)){let i=o[0].split("#")[0].split("?")[0];if(!i.endsWith("/"))r.add(i)}}return[...r].filter(Boolean)}function Ak(e){let t=[],r=0;while(r<e.length){while(r<e.length&&(/\s/.test(e[r])||e[r]===","))r+=1;if(r>=e.length)break;let n=r;while(r<e.length&&!/\s/.test(e[r]))r+=1;let s=e.slice(n,r);if(s.endsWith(",")){t.push({descriptor:"",url:s.replace(/,+$/,"")});continue}while(r<e.length&&/\s/.test(e[r]))r+=1;let A=r;while(r<e.length&&e[r]!==",")r+=1;let o=e.slice(A,r).trim();if(r+=1,s=s.replace(/,+$/,""),s!=="")t.push({descriptor:o,url:s})}return t}function ok(e){return e.map(({url:t,descriptor:r})=>r?`${t} ${r}`:t).join(", ")}function AK(e){if(typeof e!=="string"||e==="")return"";let t;try{({pathname:t}=new URL(e))}catch{return""}let r=t.replace(/\/+$/,"");if(r===""||r==="/")return"";return r.startsWith("/")?r:`/${r}`}function Id(e,t){if(e===""||!t.startsWith("/")||t.startsWith("//"))return t;if(t===e||t.startsWith(`${e}/`))return t;return e+t}function oK(e,t){let r=new URL(t);if(!r.pathname.endsWith("/"))r.pathname+="/";return new URL(e.replace(/^\/+/,""),r).href}var eK="npm:",sk;var Jl=P(()=>{sk=String.raw`"'\s<>()\\`});function Cd(e){if("operator"in e)return"expression";if("if"in e)return"if";if("$switch"in e)return"switch";if("stopPropagation"in e)return"stopPropagation";if("preventDefault"in e)return"preventDefault";return"dispatch"}async function Zs(e,t,r,n={}){let s=n.args?{args:n.args}:void 0;for(let A of e)switch(Cd(A)){case"expression":{let o=Qt(A,t,r,s);if(o&&typeof o.then==="function")await o;break}case"if":{let o=A,i=js(o.if,t,r,s)?o.then:o.else;if(Array.isArray(i))await Zs(i,t,r,n);break}case"switch":{let o=A,i=String(js(o.$switch,t,r,s)),a=o.cases??{},c=Object.hasOwn(a,i)?a[i]:o.default;if(Array.isArray(c))await Zs(c,t,r,n);break}case"dispatch":{let o=A,i=typeof n.target==="function"?n.target():n.target,a=r?.currentTarget??i;if(!a)break;let c={};if("detail"in o)c.detail=js(o.detail,t,r,s);if(o.bubbles!==void 0)c.bubbles=o.bubbles;if(o.composed!==void 0)c.composed=o.composed;a.dispatchEvent(new CustomEvent(o.dispatchEvent,c));break}case"stopPropagation":{r?.stopPropagation();break}case"preventDefault":{r?.preventDefault();break}default:break}}function Tt(e,t={}){let r=t.indent??"",n=[];for(let s of e)switch(Cd(s)){case"expression":{n.push(`${r}${ze(s,t)};`);break}case"if":{let A=s,o=Pn(A.if,t),i={...t,indent:`${r} `};if(n.push(`${r}if (${o}) {`,Tt(A.then??[],i)),A.else)n.push(`${r}} else {`,Tt(A.else,i));n.push(`${r}}`);break}case"switch":{let A=s,o=Pn(A.$switch,t),i={...t,indent:`${r} `};n.push(`${r}switch (String(${o})) {`);for(let[a,c]of Object.entries(A.cases??{}))n.push(`${r} case ${JSON.stringify(a)}: {`,Tt(c,i),`${r} break;`,`${r} }`);if(A.default)n.push(`${r} default: {`,Tt(A.default,i),`${r} }`);n.push(`${r}}`);break}case"dispatch":{let A=s,o=t.eventParam??"event",i=t.dispatchTarget??`(${o} && ${o}.currentTarget)`,a=[];if("detail"in A)a.push(`detail: ${Pn(A.detail,t)}`);if(A.bubbles!==void 0)a.push(`bubbles: ${JSON.stringify(A.bubbles)}`);if(A.composed!==void 0)a.push(`composed: ${JSON.stringify(A.composed)}`);let c=a.length>0?`, { ${a.join(", ")} }`:"";n.push(`${r}${i}?.dispatchEvent(new CustomEvent(${JSON.stringify(A.dispatchEvent)}${c}));`);break}case"stopPropagation":{n.push(`${r}${t.eventParam??"event"}?.stopPropagation();`);break}case"preventDefault":{n.push(`${r}${t.eventParam??"event"}?.preventDefault();`);break}default:break}return n.join(`
1
+ import{createRequire as Hx}from"node:module";var Fx=Object.create;var{getPrototypeOf:Tx,defineProperty:ZE,getOwnPropertyNames:Mx}=Object;var KE=Object.prototype.hasOwnProperty;function Ux(e){return this[e]}var Lx,Ox,vx=(e,t,r)=>{var n=e!=null&&typeof e==="object";if(n){var s=t?Lx??=new WeakMap:Ox??=new WeakMap,A=s.get(e);if(A)return A}r=e!=null?Fx(Tx(e)):{};let o=t||!e||!e.__esModule||!KE.call(e,"default")?ZE(r,"default",{value:e,enumerable:!0}):r;if(e&&typeof e==="object"||typeof e==="function"){for(let i of Mx(e))if(!KE.call(o,i))ZE(o,i,{get:Ux.bind(e,i),enumerable:!0})}if(n)s.set(e,o);return o};var R=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var P=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};var D=Hx(import.meta.url);function Ye(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ve(e){return Ye(e)&&typeof e.$ref==="string"}function _t(e){return Ye(e)&&e.$prototype==="Function"}function Ct(e){return Ye(e)&&Ye(e.$expression)}function Jn(e){return Ct(e)&&Array.isArray(e.parameters)&&e.parameters.length>0}function ir(e){return _t(e)&&Array.isArray(e.body)}function Gs(e){return Ye(e)&&typeof e.$prototype==="string"&&e.$prototype!=="Function"}function Nl(e){return Ye(e)&&e.timing==="server"&&typeof e.$src==="string"&&typeof e.$export==="string"&&!e.$prototype}function zE(e){return Ye(e)&&!e.$prototype&&!e.$expression&&"default"in e}function Zr(e){if(!Ye(e))return!1;for(let t of Object.keys(e))if(!XE.has(t))return!1;return!0}function it(e){return Ye(e)&&e.$prototype==="Array"}function bl(e){if(it(e))return!0;return Array.isArray(e)&&e.some((t)=>it(t))}function ed(e){return Ye(e)&&e.$prototype==="Class"}function ue(e){return typeof e==="string"&&e.includes("${")}function $n(e){return/\breturn\b[^\S\n]*(?![;}\s]|$)/.test(e)}function GZ(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Nr(e){if(!e)return[];return e.map((t)=>typeof t==="string"?t:t.name)}function br(e){if(!Ye(e)||!Ye(e.$expression))return!1;let t=e.$expression;if(t.operator==="?:")return typeof t.value==="string"&&typeof t.initial==="string";if(t.operator==="switch")return Ye(t.cases)&&Object.values(t.cases).every((r)=>typeof r==="string")&&typeof t.default==="string";return!1}function Vs(e){if(typeof e==="string")return[e];if(!br(e))return[];let t=e.$expression;if(t.operator==="?:")return[...new Set([t.value,t.initial])];return[...new Set([...Object.values(t.cases),t.default])]}var XE;var xr=P(()=>{XE=new Set(["type","enum","minimum","maximum","minLength","maxLength","pattern","format","items","properties","required","description","title","$comment"])});function at(e){return e.replaceAll(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}function td(e,t){if(e.startsWith("@--"))return t[e.slice(1)]??e.slice(1);if(e.startsWith("@(")){let r=e.slice(2,-1).trim();return Yx.has(r.toLowerCase())?r:e.slice(1)}return null}function fo(e){return e.startsWith("@position-try")||e.startsWith("@property")||e.startsWith("@font-face")||e.startsWith("@counter-style")}function Eo(e){return e.startsWith("@keyframes")}function rd(e,t){let r=[];for(let n of ho(e))for(let s of ho(t))r.push(Jx(n,s));return r.join(", ")}function Jx(e,t){if(t.startsWith("&"))return t.replaceAll("&",e);if(t.startsWith("[")||t.startsWith(":")||t.startsWith("."))return`${e}${t}`;return`${e} ${t}`}function ho(e){let t=[],r=0,n=null,s=0;for(let o=0;o<e.length;o+=1){let i=e[o];if(n){if(i==="\\")o+=1;else if(i===n)n=null;continue}if(i==='"'||i==="'")n=i;else if(i==="("||i==="[")r+=1;else if(i===")"||i==="]")r=Math.max(0,r-1);else if(i===","&&r===0)t.push(e.slice(s,o)),s=o+1}t.push(e.slice(s));let A=t.map((o)=>o.trim()).filter((o)=>o!=="");return A.length>0?A:[e]}function kr(e){return/^\(\s*prefers-color-scheme\s*:\s*(light|dark)\s*\)$/.exec(e.trim())?.[1]??null}function xl(e,t){if(e===":root"||e==="html")return{auto:`${e}:where(:not([${Wt}]))`,forced:`${e}:where([${Wt}="${t}"])`};return{auto:`:where(:root:not([${Wt}])) ${e}`,forced:`:where(:root[${Wt}="${t}"]) ${e}`}}function Kr(e){return e.startsWith(":")||e.startsWith(".")||e.startsWith("&")||e.startsWith("[")}function kl(e){return e.startsWith("--")?e:at(e)}function ji(e){let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function nd(e,t,r){let n=r.map(([A,o])=>`${A}: ${o}`).join("; "),s=t===null?n:`${t} { ${n} }`;for(let A=e.length-1;A>=0;A-=1)s=`${e[A]} { ${s} }`;return s}function $x(e,t,r){let n=r.map(({selector:A,declarations:o})=>`${A} { ${o.map(([i,a])=>`${i}: ${a}`).join("; ")} }`).join(" "),s=`@keyframes ${t} { ${n} }`;for(let A=e.length-1;A>=0;A-=1)s=`${e[A]} { ${s} }`;return s}function Px(e){let t=Object.keys(e).filter((n)=>Eo(n));if(t.length===0)return e;let r={...e};for(let n of t)delete r[n];return r}function Gx(e){let t=e.startsWith("&")?e.slice(1):e;return t===""||t.startsWith(":")||t.startsWith(".")||t.startsWith("[")}function _s(e,t={}){let{scope:r=null,mediaQueries:n={},transposeValue:s=(E)=>E,transposeSelector:A=(E)=>E,resolveValue:o}=t,i=[],a=(E)=>E!==null&&typeof E==="object"&&!Array.isArray(E)&&!ve(E),c=(E,I)=>{if(a(I))return[I];if(!fo(E)||!Array.isArray(I)||I.length===0)return[];return I.every((C)=>a(C))?I:[]},l=(E,I,C,Q)=>{if(I===void 0||I===null)return null;if(ve(I))return C?o?.(E,I,Q)??null:null;if(typeof I==="object")return null;let w=String(I);if(ue(w))return C?o?.(E,w,Q)??null:null;return s(w)},u=(E,I,C=!0,Q="self")=>{let w=[];for(let[B,S]of Object.entries(E)){if(c(B,S).length>0)continue;if(I&&(B.startsWith("@")||Kr(B)))continue;if(B.startsWith("$"))continue;let p=l(B,S,C,Q);if(p!==null)w.push([kl(B),p])}return w},g=(E,I,C,Q,w)=>{if(C.length===0)return;let B=I;if(B!==null){let p=A(B);if(p===null)return;B=p}let S=nd(E,B,C);i.push({text:S,conditions:[...E],selector:B,declarations:C,target:Q,key:ji(S),...typeof w==="string"&&w!==""?{description:w}:{}})},h=(E,I,C)=>{let Q=E.slice(10).trim();if(Q==="")return;let w=[];for(let[S,p]of Object.entries(I)){if(!a(p))continue;let m=u(p,!0,!1,"unscoped");if(m.length>0)w.push({declarations:m,selector:S.trim()})}if(w.length===0)return;let B=$x(C,Q,w);i.push({blocks:w,conditions:[...C],declarations:[],key:ji(B),selector:null,target:"unscoped",text:B})},f=(E,I,C,Q,w)=>{if(E==="@--")return;if(fo(E)){g([...Q,E],null,u(I,!1,!0,"unscoped"),"unscoped",I.$description);return}if(Eo(E)){h(E,I,Q);return}let B=td(E,n),S=B===null?E:`@media ${B}`,p=B===null?null:kr(B);if(p!==null&&C!==null){let{auto:m,forced:x}=xl(C,p);d(I,m,[...Q,S],w),d(Px(I),x,Q,w);return}d(I,C,[...Q,S],w)};function d(E,I,C,Q){g(C,I,u(E,!0,!0,Q),Q,E.$description);for(let[w,B]of Object.entries(E))for(let S of c(w,B))if(w.startsWith("@"))f(w,S,I,C,Q);else if(I!==null)d(S,rd(I,w),C,Gx(w)?Q:"descendant")}return d(e,r,[],"self"),i}var Yx,Wt="data-color-scheme",Zi="jx-color-scheme";var Ki=P(()=>{xr();Yx=new Set(["all","print","screen","speech"])});function qZ(){return`the Intl helpers ${Tl.join(", ")}`}var ar="en-US",Fl="UTC",sd,Tl,Ad;var od=P(()=>{sd=[{api:"Intl.NumberFormat",params:["value","locale","options"],path:"Intl/formatNumber",summary:"Format a number for a locale — grouping, decimals, currency, percent, units."},{api:"Intl.DateTimeFormat",params:["value","locale","options"],path:"Intl/formatDate",summary:"Format a date or timestamp for a locale. Pass `timeZone` in options."},{api:"Intl.RelativeTimeFormat",params:["value","unit","locale","options"],path:"Intl/formatRelativeTime",summary:'Format a relative time — `-3, "day"` becomes "3 days ago".'},{api:"Intl.ListFormat",params:["values","locale","options"],path:"Intl/formatList",summary:'Join a list the way a locale does — "a, b, and c", not a hand-written comma join.'},{api:"Intl.PluralRules",params:["value","locale","options"],path:"Intl/plural",summary:'Which plural category a number falls in ("one", "few", "other") — many languages have '+"more than two, so a ternary on `n === 1` is wrong outside English."},{api:"Intl.Collator",params:["a","b","locale","options"],path:"Intl/compare",summary:'Compare two strings for sorting. `<` and `sort()` order by UTF-16 code unit, which puts "Zebra" before "apple" and sorts every accented word into the wrong place.'},{api:"Intl.DisplayNames",params:["code","type","locale","options"],path:"Intl/displayName",summary:'The name of a language, region, script or currency in a locale — "de" as "German" or '+'"Deutsch", from CLDR rather than a hand-kept table.'},{api:"Intl.Segmenter",params:["value","granularity","locale"],path:"Intl/segment",summary:"Split text into graphemes, words or sentences (UAX #29). `[...str]` splits code points, so it cuts an emoji with a skin-tone modifier in half."}],Tl=sd.map((e)=>e.path),Ad=Object.fromEntries(sd.map((e)=>[e.path,e.params.indexOf("locale")]))});function Vx(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function Ge(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function zr(e){if(e==="")return[];return e.split("/").map((t)=>Vx(t))}function Xr(e,t){let r=e;for(let n of zr(t))r=r?.[n];return r}function re(e,t){let r=e;for(let n of zr(t))r+=id.test(n)?`.${n}`:`[${JSON.stringify(n)}]`;return r}function Ws(e){return id.test(e)?e:JSON.stringify(e)}function ad(e){let t=e.replaceAll(/[^A-Za-z0-9_$]/g,"_");if(t==="")return"ref";return/^\d/.test(t)?`_${t}`:t}var id;var qs=P(()=>{id=/^[A-Za-z_$][A-Za-z0-9_$]*$/});function Ml(e){let t=e.$map;return t&&typeof t==="object"?t:void 0}function jx(e,t,r){let n=Ad[e];if(n===void 0||n<0||t[n]!=null)return t;let A=r.$page?.locale;if(typeof A!=="string"||A==="")return t;let o=[...t];return o[n]=A,o}function hd(e){return e.startsWith("window#/")&&Wx.has(e.slice(8))}function Fr(e){return ud.has(e)}function Be(e,t){if(!e)return;let r=(e.depth??0)+1;if(r>Zx)return;return{depth:r,path:[...e.path??[],...Array.isArray(t)?t:[t]],report:e.report}}function he(e,t,r,n,s){if(e===null||e===void 0)return e;if(typeof e==="object"&&!Array.isArray(e)&&"operator"in e)return Qt(e,t,r,n,s);if(typeof e==="object"&&!Array.isArray(e)&&"$ref"in e){let A=zi(e.$ref,t,r,n);return s?.report(s.path??[],A),A}if(Array.isArray(e))return e.map((A,o)=>he(A,t,r,n,Be(s,o)));return s?.report(s.path??[],e),e}function Kx(e,t,r,n){let s=(A)=>{if(!e.slice(A.length).includes("/"))return t;return zi(e.slice(0,e.lastIndexOf("/")),t,r,n)};if(e.startsWith("#/state/"))return s("#/state/");if(e.startsWith("parent#/"))return s("parent#/");if(e.startsWith("$map/")||e.startsWith("$args/"))return e.split("/").length>2?zi(e.slice(0,e.lastIndexOf("/")),t,r,n):void 0;return}function zi(e,t,r,n){if(e==="$reduce/acc")return n?.acc;if(e.startsWith("$reduce/"))return n?.acc;if(e.startsWith("$args/")){let s=e.slice(6).split("/"),A=n?.args?.[s[0]];return s.length>1?en(A,s.slice(1).join("/")):A}if(e.startsWith("event#/")){let s=e.slice(7);return en(r,s)}if(e.startsWith("$map/")){let s=e.split("/"),[,A]=s,o,i=Ml(t);if(A==="item")o=n?.item??i?.item??t["$map/item"];else if(A==="index")o=n?.index??i?.index??t["$map/index"];else o=i?.[A]??t[`$map/${A}`];return s.length>2?en(o,s.slice(2).join("/")):o}if(e.startsWith("#/state/"))return Xr(t,e.slice(8));if(e.startsWith("parent#/"))return Xr(t,e.slice(8));if(e.startsWith("window#/"))return en(globalThis.window,e.slice(8));if(e.startsWith("document#/"))return en(globalThis.document,e.slice(10));return Xr(t,e)??null}function zx(e,t,r,n){if(e.startsWith("$map/")){let s=e.split("/"),[,A]=s,o,i=Ml(t);if(A==="item")o=n?.item??i?.item??t["$map/item"];else if(A==="index")o=n?.index??i?.index??t["$map/index"];else o=i?.[A]??t[`$map/${A}`];if(s.length>2){let a=s.slice(2),c=a.pop(),l=a.length>0?en(o,a.join("/")):o;return{key:c,obj:l}}return{key:A==="item"?"$map/item":"$map/index",obj:Ml(t)??t}}if(e.startsWith("#/state/")){let s=e.slice(8);if(s.indexOf("/")===-1)return{key:s,obj:t};let o=zr(s),i=o.pop(),a=t;for(let c of o)a=a[c];return{key:i,obj:a}}return{key:e,obj:t}}function Qt(e,t,r,n,s){let A=Xx(e,t,r,n,s);return s?.report(s.path??[],A),A}function Xx(e,t,r,n,s){let{operator:A,target:o,value:i,initial:a}=e;if(!_x.has(A))throw Error(`$expression: unknown operator "${A}"`);if(Ul.has(A)&&!("value"in e)){let c=he(o,t,r,n,Be(s,"target"));if(A==="!")return!c;if(A==="-")return-c}if(A==="call"){let c=o?.$ref;if(typeof c!=="string")throw TypeError("$expression: call target must be a $ref pointer");let l=(n?.callDepth??0)+1;if(l>cd)throw Error(`$expression: call depth exceeded (${cd})`);let u=Array.isArray(i)?i.map((h,f)=>he(h,t,r,n,Be(s,["value",f]))):[];if(c.startsWith("window#/")){if(!hd(c))throw Error(`$expression: "${c}" is not a blessed pure global`);let h=c.slice(8),f=qx[h];if(f)return f(...jx(h,u,t));let d=en(globalThis.window,h),E=h.lastIndexOf("/"),I=E===-1?globalThis.window:en(globalThis.window,h.slice(0,E));return d.apply(I,u)}let g=zi(c,t,r,n);if(typeof g==="function")return g.apply(Kx(c,t,r,n),u);if(g&&typeof g==="object"&&"$expression"in g){let h=g,f={};for(let[d,E]of(h.parameters??[]).entries()){let I=typeof E==="string"?E:E?.name??"";if(!I)continue;f[I]=u[d]===void 0&&typeof E==="object"&&E!==null&&"default"in E?E.default:u[d]}return Qt(h.$expression,t,r,{args:f,callDepth:l})}throw TypeError(`$expression: call target "${c}" is not callable`)}if(vl.has(A)){if(A==="?:"){let h=he(o,t,r,n,Be(s,"target"));if(s){let f=he(i,t,r,n,Be(s,"value")),d=he(a,t,r,n,Be(s,"initial"));return h?f:d}return h?he(i,t,r,n):he(a,t,r,n)}let c=he(o,t,r,n,Be(s,"target")),l=String(c),u=e.cases??{},g=Object.hasOwn(u,l);if(s){let h;for(let[d,E]of Object.entries(u)){let I=he(E,t,r,n,Be(s,["cases",d]));if(d===l)h=I}let f=he(e.default,t,r,n,Be(s,"default"));return g?h:f}return g?he(u[l],t,r,n):he(e.default,t,r,n)}if(Ll.has(A)){let c=he(o,t,r,n,Be(s,"target")),l=he(i,t,r,n,Be(s,"value"));switch(A){case"+":return c+l;case"-":return c-l;case"*":return c*l;case"/":return c/l;case"%":return c%l;case"===":return c===l;case"!==":return c!==l;case"<":return c<l;case"<=":return c<=l;case">":return c>l;case">=":return c>=l;case"&&":return c&&l;case"||":return c||l;case"??":return c??l;default:break}}if(gd.has(A)){let c=he(i,t,r,n,Be(s,"value")),{obj:l,key:u}=zx(o.$ref,t,r,n);switch(A){case"=":{l[u]=c;break}case"+=":{let g=l[u];l[u]=g+c;break}case"-=":{let g=l[u];l[u]=g-c;break}case"*=":{let g=l[u];l[u]=g*c;break}case"/=":{let g=l[u];l[u]=g/c;break}default:break}return}if(fd.has(A)){let c=he(o,t,r,n,Be(s,"target"));switch(A){case"push":return c.push(he(i,t,r,n,Be(s,"value")));case"unshift":return c.unshift(he(i,t,r,n,Be(s,"value")));case"pop":return c.pop();case"shift":return c.shift();case"splice":{let l=he(i,t,r,n,Be(s,"value"));return c.splice(...l)}default:break}}if(Hl.has(A)){let c=he(o,t,r,n,Be(s,"target")),l=i===void 0?[]:Array.isArray(i)?he(i,t,r,n,Be(s,"value")):[he(i,t,r,n,Be(s,"value"))],u=c?.[A];if(typeof u!=="function")return;return u.apply(c,l)}if(Ol.has(A)){let c=he(o,t,r,n,Be(s,"target"));if(A==="reduce"){let l=he(a,t,r,n,Be(s,"initial"));for(let[u,g]of c.entries())l=Qt(i,t,r,{acc:l,index:u,item:g},u===0?Be(s,"value"):void 0);return l}if(A==="map")return c.map((l,u)=>Qt(i,t,r,{...n,index:u,item:l},u===0?Be(s,"value"):void 0));if(A==="filter")return c.filter((l,u)=>Qt(i,t,r,{...n,index:u,item:l},u===0?Be(s,"value"):void 0))}return}function ye(e,t){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e==="object"&&!Array.isArray(e)&&"operator"in e)return ze(e,t);if(typeof e==="object"&&!Array.isArray(e)&&"$ref"in e)return Yl(e.$ref,t);if(Array.isArray(e))return e.map((r)=>ye(r,t)).join(", ");return JSON.stringify(e)}function ek(e){return`_fx_${e.replaceAll(/[^A-Za-z0-9_$]/g,"_")}`}function Yl(e,t){let r=t.statePrefix??"state",n=t.eventParam??"event";if(e==="$reduce/acc")return"_acc";if(e.startsWith("$reduce/"))return"_acc";if(e.startsWith("$args/"))return re("_args",e.slice(6));if(e.startsWith("event#/"))return re(n,e.slice(7));if(e.startsWith("$map/")){let s=e.split("/"),[,A]=s;if(A==="item")return s.length>2?re("_item",s.slice(2).join("/")):"_item";if(A==="index")return"_index";return`_${A}`}if(e.startsWith("#/state/"))return re(r,e.slice(8));if(e.startsWith("parent#/"))return re(r,e.slice(8));if(e.startsWith("window#/"))return re("window",e.slice(8));if(e.startsWith("document#/"))return re("document",e.slice(10));return re(r,e)}function ld(e,t){if(typeof e==="object"&&e!==null&&"$ref"in e)return Yl(e.$ref,t);return ye(e,t)}function tk(e,t,r){let n=(o)=>t[o]??"undefined",s=`(${r.statePrefix??"state"}?.$page?.locale ?? ${JSON.stringify(ar)})`,A=JSON.stringify(Fl);switch(e){case"Intl/formatNumber":return`new Intl.NumberFormat(${n(1)} ?? ${s}, ${n(2)}).format(${n(0)})`;case"Intl/formatDate":return`new Intl.DateTimeFormat(${n(1)} ?? ${s}, {timeZone: ${A}, ...${n(2)}}).format(new Date(${n(0)}))`;case"Intl/formatRelativeTime":return`new Intl.RelativeTimeFormat(${n(2)} ?? ${s}, ${n(3)}).format(${n(0)}, ${n(1)})`;case"Intl/formatList":return`new Intl.ListFormat(${n(1)} ?? ${s}, ${n(2)}).format(${n(0)})`;case"Intl/plural":return`new Intl.PluralRules(${n(1)} ?? ${s}, ${n(2)}).select(${n(0)})`;case"Intl/compare":return`new Intl.Collator(${n(2)} ?? ${s}, ${n(3)}).compare(${n(0)}, ${n(1)})`;case"Intl/displayName":return`new Intl.DisplayNames(${n(2)} ?? ${s}, {...${n(3)}, type: ${n(1)} ?? 'language'}).of(${n(0)})`;case"Intl/segment":return`[...new Intl.Segmenter(${n(2)} ?? ${s}, {granularity: ${n(1)} ?? 'grapheme'}).segment(${n(0)})].map((p) => p.segment)`;default:return null}}function ze(e,t={}){let{operator:r,target:n,value:s,initial:A}=e;if(Ul.has(r)&&!("value"in e)){let o=ye(n,t);if(r==="!")return`!(${o})`;if(r==="-")return`-(${o})`}if(r==="call"){let o=n?.$ref??"",i=Array.isArray(s)?s.map((a)=>ye(a,t)):[];if(o.startsWith("window#/")){if(!hd(o))throw Error(`$expression: "${o}" is not a blessed pure global`);let a=tk(o.slice(8),i,t);if(a)return a;return`window.${o.slice(8).replaceAll("/",".")}(${i.join(", ")})`}if(o.startsWith("#/state/")){let a=o.slice(8),c=t.formulaParams?.[a];if(c){let l=c.map((u,g)=>`${JSON.stringify(u)}: ${i[g]??"undefined"}`).join(", ");return`${ek(a)}(${t.statePrefix??"state"}, { ${l} })`}}return`${Yl(o,t)}(${i.join(", ")})`}if(vl.has(r)){if(r==="?:"){let c=ye(n,t),l=ye(s,t),u=ye(A,t);return`(${c} ? ${l} : ${u})`}let o=ye(n,t),i=Object.entries(e.cases??{}).map(([c,l])=>`_d === ${JSON.stringify(c)} ? ${ye(l,t)} : `).join(""),a="default"in e?ye(e.default,t):"undefined";return`((_d) => ${i}${a})(String(${o}))`}if(Ll.has(r)){let o=ye(n,t),i=ye(s,t);return`(${o} ${r} ${i})`}if(gd.has(r)){let o=ld(n,t),i=ye(s,t);return`${o} ${r} ${i}`}if(fd.has(r)){let o=ld(n,t);switch(r){case"push":return`${o}.push(${ye(s,t)})`;case"unshift":return`${o}.unshift(${ye(s,t)})`;case"pop":return`${o}.pop()`;case"shift":return`${o}.shift()`;case"splice":{let i=Array.isArray(s)?s.map((a)=>ye(a,t)).join(", "):ye(s,t);return`${o}.splice(${i})`}default:break}}if(Hl.has(r)){let o=ye(n,t),i=s===void 0?"":Array.isArray(s)?s.map((a)=>ye(a,t)).join(", "):ye(s,t);return`(${o})?.${r}?.(${i})`}if(Ol.has(r)){let o=ye(n,t),i=ze(s,t);if(r==="reduce"){let a=ye(A,t);return`${o}.reduce((_acc, _item, _index) => ${i}, ${a})`}if(r==="map")return`${o}.map((_item, _index) => ${i})`;if(r==="filter")return`${o}.filter((_item, _index) => ${i})`}return"undefined"}function en(e,t){return Xr(e,t)}function js(e,t,r,n){return he(e,t,r,n)}function Pn(e,t={}){return ye(e,t)}var ud,Ul,Ll,gd,fd,Ol,vl,Hl,_x,Wx,qx,cd=64,Zx=64;var Io=P(()=>{od();qs();ud=new Set(["=","+=","-=","*=","/=","push","pop","shift","unshift","splice"]),Ul=new Set(["!","-"]),Ll=new Set(["+","-","*","/","%","===","!==","<","<=",">",">=","&&","||","??"]),gd=new Set(["=","+=","-=","*=","/="]),fd=new Set(["push","pop","shift","unshift","splice"]),Ol=new Set(["reduce","map","filter"]),vl=new Set(["?:","switch"]),Hl=new Set(["includes","indexOf","lastIndexOf","join","slice","concat","at","flat","toSorted","toReversed","toSpliced","with","toUpperCase","toLowerCase","trim","trimStart","trimEnd","split","startsWith","endsWith","padStart","padEnd","replaceAll","repeat","charAt","normalize","toLocaleUpperCase","toLocaleLowerCase","toFixed","toPrecision","toLocaleString"]),_x=new Set([...ud,...Ul,...Ll,...Ol,...vl,...Hl,"call"]),Wx=new Set(["isNaN","isFinite","parseFloat","parseInt","encodeURIComponent","decodeURIComponent","structuredClone","Math/abs","Math/ceil","Math/floor","Math/round","Math/trunc","Math/sign","Math/sqrt","Math/cbrt","Math/pow","Math/exp","Math/log","Math/log2","Math/log10","Math/min","Math/max","Math/hypot","Number/isInteger","Number/isFinite","Number/isNaN","Number/parseFloat","Number/parseInt","JSON/parse","JSON/stringify","Object/keys","Object/values","Object/entries","Object/fromEntries","Array/from","Array/isArray","Array/of","String/fromCharCode","String/fromCodePoint",...Tl]),qx={"Intl/compare":(e,t,r,n)=>new Intl.Collator(r??ar,n).compare(e,t),"Intl/displayName":(e,t,r,n)=>new Intl.DisplayNames(r??ar,{...n,type:t??"language"}).of(e),"Intl/formatDate":(e,t,r)=>new Intl.DateTimeFormat(t??ar,{timeZone:Fl,...r}).format(new Date(e)),"Intl/formatList":(e,t,r)=>new Intl.ListFormat(t??ar,r).format(e),"Intl/formatNumber":(e,t,r)=>new Intl.NumberFormat(t??ar,r).format(e),"Intl/formatRelativeTime":(e,t,r,n)=>new Intl.RelativeTimeFormat(r??ar,n).format(e,t),"Intl/plural":(e,t,r)=>new Intl.PluralRules(t??ar,r).select(e),"Intl/segment":(e,t,r)=>[...new Intl.Segmenter(r??ar,{granularity:t??"grapheme"}).segment(e)].map((n)=>n.segment)}});function rk(e){return e.startsWith("npm:")}function tK(e){let t=e;if(rk(t))t=t.slice(4);return t=t.replace(/^\.\//,"").replace(/\.(js|ts|mjs|mts)$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,""),`/assets/${t}.js`}function rK(e){let t=/\.(\w+)$/.exec(e)?.[1]??"",r=e.replace(/\.\w+$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");return t===""?`/assets/${r}`:`/assets/${r}.${t}`}function Ed(e){let t=e.replaceAll("\\","/");return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function dd(e){let t=Ed(e);return t.startsWith("/")?t:`/${t}`}function nk(e,t){return[...e].toSorted((r,n)=>n[t].length-r[t].length)}function nK(e,t){let r=t.split("#")[0].split("?")[0];if(!r.startsWith("/"))return null;let n;try{n=decodeURIComponent(r)}catch{return null}if(/%2e|%2f/i.test(n))return null;for(let s of nk(e,"urlPrefix")){let A=dd(s.urlPrefix);if(!n.startsWith(`${A}/`))continue;let i=n.slice(A.length+1).split("/");if(i.some((c)=>c===""||c==="."||c===".."))return null;let{filter:a}=s;if(a&&!a(i.join("/")))return null;return`${Ed(s.dir)}/${i.join("/")}`}return null}function sK(e,t){let r=new Set;for(let n of t){let s=dd(n.urlPrefix),A=new RegExp(`${s.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}/[^${sk}]+`,"g");for(let o of e.matchAll(A)){let i=o[0].split("#")[0].split("?")[0];if(!i.endsWith("/"))r.add(i)}}return[...r].filter(Boolean)}function Ak(e){let t=[],r=0;while(r<e.length){while(r<e.length&&(/\s/.test(e[r])||e[r]===","))r+=1;if(r>=e.length)break;let n=r;while(r<e.length&&!/\s/.test(e[r]))r+=1;let s=e.slice(n,r);if(s.endsWith(",")){t.push({descriptor:"",url:s.replace(/,+$/,"")});continue}while(r<e.length&&/\s/.test(e[r]))r+=1;let A=r;while(r<e.length&&e[r]!==",")r+=1;let o=e.slice(A,r).trim();if(r+=1,s=s.replace(/,+$/,""),s!=="")t.push({descriptor:o,url:s})}return t}function ok(e){return e.map(({url:t,descriptor:r})=>r?`${t} ${r}`:t).join(", ")}function AK(e){if(typeof e!=="string"||e==="")return"";let t;try{({pathname:t}=new URL(e))}catch{return""}let r=t.replace(/\/+$/,"");if(r===""||r==="/")return"";return r.startsWith("/")?r:`/${r}`}function Id(e,t){if(e===""||!t.startsWith("/")||t.startsWith("//"))return t;if(t===e||t.startsWith(`${e}/`))return t;return e+t}function oK(e,t){let r=new URL(t);if(!r.pathname.endsWith("/"))r.pathname+="/";return new URL(e.replace(/^\/+/,""),r).href}var eK="npm:",sk;var Jl=P(()=>{sk=String.raw`"'\s<>()\\`});function Cd(e){if("operator"in e)return"expression";if("if"in e)return"if";if("$switch"in e)return"switch";if("stopPropagation"in e)return"stopPropagation";if("preventDefault"in e)return"preventDefault";return"dispatch"}async function Zs(e,t,r,n={}){let s=n.args?{args:n.args}:void 0;for(let A of e)switch(Cd(A)){case"expression":{let o=Qt(A,t,r,s);if(o&&typeof o.then==="function")await o;break}case"if":{let o=A,i=js(o.if,t,r,s)?o.then:o.else;if(Array.isArray(i))await Zs(i,t,r,n);break}case"switch":{let o=A,i=String(js(o.$switch,t,r,s)),a=o.cases??{},c=Object.hasOwn(a,i)?a[i]:o.default;if(Array.isArray(c))await Zs(c,t,r,n);break}case"dispatch":{let o=A,i=typeof n.target==="function"?n.target():n.target,a=r?.currentTarget??i;if(!a)break;let c={};if("detail"in o)c.detail=js(o.detail,t,r,s);if(o.bubbles!==void 0)c.bubbles=o.bubbles;if(o.composed!==void 0)c.composed=o.composed;a.dispatchEvent(new CustomEvent(o.dispatchEvent,c));break}case"stopPropagation":{r?.stopPropagation();break}case"preventDefault":{r?.preventDefault();break}default:break}}function Tt(e,t={}){let r=t.indent??"",n=[];for(let s of e)switch(Cd(s)){case"expression":{n.push(`${r}${ze(s,t)};`);break}case"if":{let A=s,o=Pn(A.if,t),i={...t,indent:`${r} `};if(n.push(`${r}if (${o}) {`,Tt(A.then??[],i)),A.else)n.push(`${r}} else {`,Tt(A.else,i));n.push(`${r}}`);break}case"switch":{let A=s,o=Pn(A.$switch,t),i={...t,indent:`${r} `};n.push(`${r}switch (String(${o})) {`);for(let[a,c]of Object.entries(A.cases??{}))n.push(`${r} case ${JSON.stringify(a)}: {`,Tt(c,i),`${r} break;`,`${r} }`);if(A.default)n.push(`${r} default: {`,Tt(A.default,i),`${r} }`);n.push(`${r}}`);break}case"dispatch":{let A=s,o=t.eventParam??"event",i=t.dispatchTarget??`(${o} && ${o}.currentTarget)`,a=[];if("detail"in A)a.push(`detail: ${Pn(A.detail,t)}`);if(A.bubbles!==void 0)a.push(`bubbles: ${JSON.stringify(A.bubbles)}`);if(A.composed!==void 0)a.push(`composed: ${JSON.stringify(A.composed)}`);let c=a.length>0?`, { ${a.join(", ")} }`:"";n.push(`${r}${i}?.dispatchEvent(new CustomEvent(${JSON.stringify(A.dispatchEvent)}${c}));`);break}case"stopPropagation":{n.push(`${r}${t.eventParam??"event"}?.stopPropagation();`);break}case"preventDefault":{n.push(`${r}${t.eventParam??"event"}?.preventDefault();`);break}default:break}return n.join(`
2
2
  `)}var Xi=P(()=>{Io()});function $l(e){if(!e.startsWith("${")||!e.endsWith("}"))return!1;let t=0;for(let r=1;r<e.length;r+=1){let n=e[r];if(n==="{")t+=1;else if(n==="}"){if(t-=1,t===0)return r===e.length-1}}return!1}function Bd(){return[...Qd].toSorted()}function Gn(e,t){let r=e.toLowerCase();if(r.startsWith("aria-")||Qd.has(r))return String(t);return t?"":null}var Tr,Qd;var Co=P(()=>{Ki();Io();qs();xr();Jl();Xi();Ki();Tr=new Set(["$schema","$id","$defs","state","$ref","$props","$elements","$title","$description","$switch","$prototype","$src","$export","$media","$map","timing","default","description","body","parameters","arguments","name","tagName","children","style","attributes","items","map","filter","sort","cases","observedAttributes"]),Qd=new Set(["contenteditable","draggable","spellcheck"])});function pd(e,t,r,n){let s=[],A=(l,u)=>{for(let g of _s(l,{mediaQueries:t,scope:u,transposeValue:r,...n?{resolveValue:(h,f)=>n(h,f,u)}:{}}))s.push(g.text)},o={},i={},a=[],c=[];for(let[l,u]of Object.entries(e)){if(u!==null&&typeof u==="object"&&!Array.isArray(u)){if(l.startsWith("@"))a.push([l,u]);else if(!l.startsWith("--"))c.push([l,u]);continue}if(Kr(l)||l.startsWith("@"))continue;if(l.startsWith("--")||l==="colorScheme"||l==="color-scheme")o[l]=u;else i[l]=u}A(o,":root"),A(i,"body");for(let[l,u]of c)if(l.startsWith("&"))A({[l]:u},":root");else A(u,l);for(let[l,u]of a){if(fo(l)||Eo(l)){A({[l]:u},null);continue}let g={},h={},f=[];for(let[d,E]of Object.entries(u)){if(E!==null&&typeof E==="object"&&!Array.isArray(E)){if(!d.startsWith("@"))f.push([d,E]);continue}if(d.startsWith("--"))g[d]=E;else h[d]=E}A({[l]:g},":root"),A({[l]:h},"body");for(let[d,E]of f)A({[l]:E},d)}if(Object.values(t).some((l)=>kr(l)!==null)&&!("colorScheme"in e))s.push(":root { color-scheme: light dark }",`:root:where([${Wt}="light"]) { color-scheme: light }`,`:root:where([${Wt}="dark"]) { color-scheme: dark }`);return s.join(`
3
3
  `)}var yd=P(()=>{Ki()});function md(e){if(e===!1||e==="open"||e==="closed")return e;return}function ea(e,t){let n=md(e?.$shadow)??md(t?.shadow)??!1;return n===!1?null:n}function Sd(e,t){return t===null?e:":host"}function Qo(e,t){let r=[];for(let[n,s]of(e.parameters??[]).entries()){let A=typeof s==="string"?s:s?.name??"";if(!A)continue;let i=typeof s==="object"&&s!==null&&"default"in s?`_a[${n}] === undefined ? ${JSON.stringify(s.default)} : _a[${n}]`:`_a[${n}]`;r.push(`${JSON.stringify(A)}: ${i}`)}return`(..._a) => { const _args = { ${r.join(", ")} }; return ${t}; }`}function sa(e,t){let r=ql(e,t);return r===e?e:`${r} as ${e}`}function ql(e,t){let r=t?.$export;return typeof r==="string"&&r!==""?r:e}function Aa(e,t,r={}){let{statePrefix:n="state",indent:s="",collect:A}=r,{url:o}=t,i=ue(o),a=t.method??"GET";if(t.manual)return`${s}// ${e}: manual Request — fetch triggered by user action`;let c=[`// ${e}: auto-fetch from ${i?"(dynamic URL)":o}`,A?`${A}.push(effect(() => {`:"effect(() => {"];if(i)c.push(` const url = \`${ak(o,n)}\`;`,' if (!url || url === "undefined" || url.includes("undefined")) return;');else c.push(` const url = ${JSON.stringify(o)};`);let l=[];if(a!=="GET")l.push(`method: ${JSON.stringify(a)}`);if(t.headers)l.push(`headers: ${JSON.stringify(t.headers)}`);if(t.body){let g=typeof t.body==="object"?JSON.stringify(JSON.stringify(t.body)):JSON.stringify(t.body);l.push(`body: ${g}`)}let u=l.length>0?`, { ${l.join(", ")} }`:"";return c.push(` fetch(url${u})`," .then(r => r.ok ? r.json() : Promise.reject(r.statusText))",` .then(d => { ${n}.${e} = d; })`,` .catch(e => { ${n}.${e} = { error: String(e) }; });`,A?"}));":"});"),c.map((g)=>`${s}${g}`).join(`
4
4
  `)}function ak(e,t){if(t==="state")return e;return e.replaceAll(/\$\{([^}]*)\}/g,(r,n)=>`\${${n.replaceAll(/(?<!this\.)\bstate\./g,`${t}.`)}}`)}function aa(e){if(!e||typeof e!=="object")return!1;if(e.state)for(let[t,r]of Object.entries(e.state)){if(t==="$site"||t==="$page")continue;if(r&&typeof r==="object"&&!Array.isArray(r)&&r.timing==="compiler")continue;if(typeof r!=="object"||r===null||Array.isArray(r))return!0;if(r.$prototype)return!0;if("default"in r)return!0;if(Zr(r))continue;return!0}if(e.$switch)return!0;if(it(e)||bl(e.children))return!0;if(Array.isArray(e.children)&&e.children.some((t)=>aa(t)))return!0;for(let[t,r]of Object.entries(e)){if(Tr.has(t))continue;if(r!==null&&typeof r==="object"&&typeof r.$ref==="string")return!0;if(ue(r))return!0}if(e.style&&typeof e.style==="object"){for(let t of Object.values(e.style))if(ue(t))return!0}if(e.attributes&&typeof e.attributes==="object"){for(let t of Object.values(e.attributes))if(ue(t))return!0}return!1}function Dd(e){if(!e||typeof e!=="object")return!1;if(e.$switch)return!0;if(it(e)||bl(e.children))return!0;for(let[t,r]of Object.entries(e)){if(Tr.has(t))continue;if(r!==null&&typeof r==="object"&&typeof r.$ref==="string")return!0;if(ue(r))return!0}if(e.style&&typeof e.style==="object"){for(let t of Object.values(e.style))if(ue(t))return!0}if(e.attributes&&typeof e.attributes==="object"){for(let t of Object.values(e.attributes))if(ue(t))return!0}return!1}function zs(e,t=null,r={},n={}){let s=e?.state?Rd(e.state,t):t??Object.create(null);return{media:n,scope:s,scopeDefs:r}}function _l(e,t){if(typeof e==="string"){for(let s of e.matchAll(ck))t.add(s[1]);for(let s of e.matchAll(lk))t.add(s[1]);return}if(!e||typeof e!=="object")return;if(Array.isArray(e)){for(let s of e)_l(s,t);return}let r=e,n=r.operator;if(typeof n==="string"&&Fr(n)){let s=r.target;if(s&&typeof s.$ref==="string"&&s.$ref.startsWith("#/state/"))t.add(s.$ref.slice(8).split("/")[0])}for(let s of Object.values(r))_l(s,t)}function Rd(e={},t=null){let r=Object.create(t??null),n=t?.[Vl],s=new Set(n instanceof Set?n:[]);Object.defineProperty(r,Vl,{configurable:!0,enumerable:!1,value:s,writable:!0});let A=new Set;for(let c of Object.values(e))if(c&&typeof c==="object"&&(_t(c)||Ct(c)))_l(c.body??c.$expression,A);for(let c of A)if(c in e)s.add(c);for(let[c,l]of Object.entries(e)){if(typeof l!=="object"||l===null||Array.isArray(l)){Mr(r,c,ta(l));continue}let u=l;if("default"in u){Mr(r,c,ta(u.default));continue}if(!u.$prototype&&!("$expression"in u)&&!Zr(u))Mr(r,c,ta(u))}let o=[],i=[];for(let[c,l]of Object.entries(e)){if(typeof l==="string"&&ue(l)){o.push([c,l]);continue}if(!l||typeof l!=="object")continue;if(Ct(l)){let u=l.$expression;if(Jn(l)){let g=l.parameters;Mr(r,c,(...h)=>{let f={};for(let[d,E]of g.entries()){let I=typeof E==="string"?E:E?.name??"";if(!I)continue;f[I]=h[d]===void 0&&typeof E==="object"&&E!==null&&"default"in E?E.default:h[d]}return Qt(u,r,null,{args:f})})}else if(Fr(u.operator))Mr(r,c,(g,h)=>Qt(u,g,h));else Pl(r,c,()=>Qt(u,r,null));continue}if(_t(l)){if(ir(l)){let{body:u}=l;Mr(r,c,(g,h)=>{Zs(u,g??r,h??null)})}else if(typeof l.body==="string"){let u=l.parameters?Nr(l.parameters):l.arguments??[],{body:g}=l,h=u.includes("state")?u:["state",...u],f=Function(...h,g),d=(E,I)=>f(...h.map((C)=>C==="state"?E:I));if($n(g))Pl(r,c,()=>d(r)),i.push([c,g]);else Mr(r,c,d)}else Mr(r,c,()=>{}),s.add(c);continue}if(Gs(l)&&(l.$prototype==="LocalStorage"||l.$prototype==="SessionStorage")){Mr(r,c,ta(l.default??null));continue}if(Gs(l)&&l.$prototype==="Request")s.add(c)}let a=!0;while(a){a=!1;for(let[c,l]of[...i,...o])if(!s.has(c)&&Nd(l,r))s.add(c),a=!0}for(let[c,l]of o)Pl(r,c,()=>jl(l,r));return r}function Mr(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0})}function Pl(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:r})}function me(e,t){if(ct(e))return uk(e.$ref,t);if(ue(e))return jl(e,t);return e}function ct(e){return ve(e)}function uk(e,t){if(typeof e!=="string")return e;if(e.startsWith("$map/")){let r=e.split("/"),n=r[1],s=t.$map?.[n]??t[`$map/${n}`];return r.length>2?Gl(s,r.slice(2).join("/")):s}if(e.startsWith("#/state/"))return Gl(t,e.slice(8));return Gl(t,e)??null}function Nd(e,t){if(!t)return!1;let r=t[Vl];for(let n of e.matchAll(/\bstate\.([A-Za-z_$][\w$]*)\s*(\()?/g)){if(n[2])continue;let s=n[1];if(r instanceof Set&&r.has(s))return!0;let A;try{A=t[s]}catch{continue}if(typeof A==="function")return!0}return!1}function jl(e,t){if(Nd(e,t))return null;let r=["state","$map","$site","$page"],n=[t,t?.$map,t?.$site,t?.$page];try{let s=$l(e)?`return (${e.slice(2,-1)})`:`return \`${e}\``;return Function(...r,s)(...n)}catch{return null}}function Gl(e,t){return Xr(e,t)}function ta(e){if(e===null||typeof e!=="object")return e;return structuredClone(e)}function gk(e,t){if(!e||!t)return"";return Object.entries(e).filter(([r,n])=>!r.startsWith(":")&&!r.startsWith(".")&&!r.startsWith("&")&&!r.startsWith("[")&&!r.startsWith("@")&&n!==null&&typeof n!=="object"&&typeof n==="string"&&ue(n)).map(([r,n])=>{let s=me(n,t);return s==null?null:`${at(r)}: ${s}`}).filter(Boolean).join("; ")}function Vn(e,t,r=""){let n="",s=me(e.id,t),A=me(e.className,t),o=me(e.hidden,t),i=me(e.tabIndex,t),a=me(e.title,t),c=me(e.lang,t),l=me(e.dir,t);if(s)n+=` id="${q(String(s))}"`;if(A)n+=` class="${q(String(A))}"`;if(o)n+=" hidden";if(i!==void 0&&i!==null)n+=` tabindex="${q(String(i))}"`;if(a)n+=` title="${q(String(a))}"`;if(c)n+=` lang="${q(String(c))}"`;if(l)n+=` dir="${q(String(l))}"`;let u=[gk(e.style,t),r].filter(Boolean).join("; ");if(u)n+=` style="${q(u)}"`;if(e.attributes)for(let[g,h]of Object.entries(e.attributes)){let f=me(h,t);if(typeof f==="boolean"){let d=Gn(g,f);if(d!==null)n+=d===""?` ${g}`:` ${g}="${q(d)}"`;continue}if(f!==null&&f!==void 0&&(typeof f==="string"||typeof f==="number"))n+=` ${g}="${q(String(f))}"`}if(e.$static)n+=" data-jx-static";else if(e.$prerendered)n+=" data-jx-prerendered";return n}function Bo(e,t=" "){return e?"":`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jxsuite/compiler",
3
- "version": "4.0.2",
3
+ "version": "5.0.0",
4
4
  "description": "Jx static HTML compiler, island detector, and site builder",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -46,10 +46,10 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@apidevtools/json-schema-ref-parser": "^16.0.3",
49
- "@jxsuite/create": "^1.3.12",
50
- "@jxsuite/runtime": "^4.0.2",
51
- "@jxsuite/schema": "^2.3.0",
52
- "@jxsuite/site": "^2.0.2",
49
+ "@jxsuite/create": "^1.3.13",
50
+ "@jxsuite/runtime": "^4.0.3",
51
+ "@jxsuite/schema": "^3.0.0",
52
+ "@jxsuite/site": "^2.0.3",
53
53
  "@vue/reactivity": "3.5.43",
54
54
  "esbuild": "^0.28.2",
55
55
  "lit-html": "^3.3.3",
@@ -57,8 +57,8 @@
57
57
  },
58
58
  "devDependencies": {
59
59
  "@happy-dom/global-registrator": "^20.14.5",
60
- "@jxsuite/connector": "^0.6.1",
61
- "@jxsuite/parser": "^1.8.2",
60
+ "@jxsuite/connector": "^0.6.2",
61
+ "@jxsuite/parser": "^2.0.0",
62
62
  "@types/mdast": "^4.0.4"
63
63
  }
64
64
  }
@@ -67,6 +67,8 @@ export async function loadAssetMounts(
67
67
  const normalized: AssetMount = {
68
68
  dir: mount.dir,
69
69
  urlPrefix: normalizeAssetPrefix(mount.urlPrefix),
70
+ // What the owner says the mount may serve travels with it (a notes folder's `exclude`).
71
+ ...(typeof mount.filter === "function" && { filter: mount.filter }),
70
72
  };
71
73
  const prior = byPrefix.get(normalized.urlPrefix);
72
74
  if (prior) {
@@ -300,6 +300,28 @@ function entryMtime(pathEntry: Record<string, unknown>): string | null {
300
300
  return typeof mtime === "string" && mtime !== "" ? mtime : null;
301
301
  }
302
302
 
303
+ /**
304
+ * Why a concrete page URL would write outside the output directory, or null when it would not: a
305
+ * `.` or `..` segment, a backslash or a NUL.
306
+ *
307
+ * @param {string} url - The route with its parameters substituted
308
+ * @returns {string | null}
309
+ */
310
+ function traversalIn(url: string): string | null {
311
+ if (url.includes("\0")) {
312
+ return "has a NUL character";
313
+ }
314
+ for (const segment of url.split("/")) {
315
+ if (segment === "." || segment === "..") {
316
+ return 'has a "." or ".." segment';
317
+ }
318
+ if (segment.includes("\\")) {
319
+ return "has a backslash";
320
+ }
321
+ }
322
+ return null;
323
+ }
324
+
303
325
  /**
304
326
  * Expand dynamic routes by resolving $paths from each dynamic page.
305
327
  *
@@ -325,6 +347,11 @@ export async function expandDynamicRoutes(
325
347
  i18n?: ResolvedI18n | null,
326
348
  ) {
327
349
  const expanded: Route[] = [];
350
+ /**
351
+ * Every dynamic page's pattern, so an extension can tell a route no page produces from one a
352
+ * different page does.
353
+ */
354
+ const dynamicPatterns = routes.filter((r) => r.isDynamic).map((r) => r.urlPattern);
328
355
 
329
356
  for (const route of routes) {
330
357
  if (!route.isDynamic) {
@@ -356,6 +383,8 @@ export async function expandDynamicRoutes(
356
383
  // The template's OWN prefix, read before expansion: `/fr/blog/:slug` is a French route
357
384
  // Whatever its entries turn out to be called, and that is what scopes a localized collection.
358
385
  localeOfRoute(route.urlPattern, i18n ?? null),
386
+ route,
387
+ dynamicPatterns,
359
388
  );
360
389
 
361
390
  for (const pathEntry of pathEntries) {
@@ -372,6 +401,17 @@ export async function expandDynamicRoutes(
372
401
  concreteUrl = concreteUrl.replace("*", params[param]);
373
402
  }
374
403
 
404
+ /* A parameter value is data (a frontmatter field, a file name) and becomes part of the path the
405
+ page is written to. One that climbs out of the output directory is not a page. */
406
+ const escapes = traversalIn(concreteUrl);
407
+ if (escapes !== null) {
408
+ console.warn(
409
+ `Warning: $paths for ${route.urlPattern} produced "${concreteUrl}", which ${escapes}; ` +
410
+ `skipping it`,
411
+ );
412
+ continue;
413
+ }
414
+
375
415
  const mtime = entryMtime(pathEntry);
376
416
  expanded.push({
377
417
  ...route,
@@ -400,6 +440,10 @@ export async function expandDynamicRoutes(
400
440
  * @param {Record<string, unknown>} sections - Loaded project sections keyed by section key
401
441
  * @param {ExtensionRegistry} [registry]
402
442
  * @param {ProjectConfig} [projectConfig]
443
+ * @param {string | null} [locale] - The locale the route being expanded belongs to
444
+ * @param {Route} [route] - The dynamic page being expanded; its pattern and parameter names reach
445
+ * an extension's `resolvePaths` so it can produce exactly the parameters this page needs
446
+ * @param {readonly string[]} [patterns] - The pattern of every dynamic page in the project
403
447
  * @returns {Promise<Record<string, unknown>[]>} Array of { paramName: value } objects
404
448
  */
405
449
  async function resolvePathEntries(
@@ -409,6 +453,8 @@ async function resolvePathEntries(
409
453
  registry?: ExtensionRegistry,
410
454
  projectConfig?: ProjectConfig,
411
455
  locale?: string | null,
456
+ route?: Pick<Route, "urlPattern" | "params">,
457
+ patterns?: readonly string[],
412
458
  ): Promise<Record<string, unknown>[]> {
413
459
  // Legacy: array of param objects
414
460
  if (Array.isArray($paths)) {
@@ -456,6 +502,8 @@ async function resolvePathEntries(
456
502
  locale,
457
503
  projectConfig,
458
504
  root: projectRoot,
505
+ ...(route === undefined ? {} : { params: route.params, urlPattern: route.urlPattern }),
506
+ ...(patterns === undefined ? {} : { patterns }),
459
507
  })) as Record<string, unknown>[];
460
508
  }
461
509
 
@@ -1775,6 +1775,33 @@ function isBareSpecifier(s: string) {
1775
1775
  );
1776
1776
  }
1777
1777
 
1778
+ /**
1779
+ * The resolved value of a text template that still contains `${`, as escaped `innerHTML`.
1780
+ *
1781
+ * A template's result is data: an excerpt, a heading, a title. When that data itself holds `${` (a
1782
+ * note that explains template syntax) it is text to show, and left as `textContent` the compile
1783
+ * phase would read it as a template a second time, bind it to an expression that throws or renders
1784
+ * nothing, and the words would be gone. The same entity spelling the `innerHTML` resolution below
1785
+ * uses keeps it text.
1786
+ *
1787
+ * @param {string} resolved
1788
+ * @returns {string}
1789
+ */
1790
+ function inertTextHtml(resolved: string): string {
1791
+ return escapeHtml(resolved).replaceAll("${", "&#36;{");
1792
+ }
1793
+
1794
+ /**
1795
+ * A resolved attribute value with any `${` split by a zero-width space. An entity cannot be written
1796
+ * into an attribute, and a value that kept the sequence would be bound as a template again.
1797
+ *
1798
+ * @param {string} resolved
1799
+ * @returns {string}
1800
+ */
1801
+ function inertAttribute(resolved: string): string {
1802
+ return resolved.replaceAll("${", "$\u200B{");
1803
+ }
1804
+
1778
1805
  /**
1779
1806
  * Deep-clone a map template, resolving template strings and $ref values against the given scope.
1780
1807
  *
@@ -1808,7 +1835,11 @@ function expandMapTemplate(template: JxElement, scope: Record<string, unknown>):
1808
1835
  const attrs = { ...(v as Record<string, JxAttributeValue>) };
1809
1836
  for (const [ak, av] of Object.entries(attrs)) {
1810
1837
  if (isTemplateString(av)) {
1811
- attrs[ak] = (evaluateMapTemplate(av, scope) as JxAttributeValue | undefined) ?? av;
1838
+ const resolved = evaluateMapTemplate(av, scope) as JxAttributeValue | undefined;
1839
+ attrs[ak] =
1840
+ typeof resolved === "string" && resolved.includes("${")
1841
+ ? inertAttribute(resolved)
1842
+ : (resolved ?? av);
1812
1843
  }
1813
1844
  }
1814
1845
  node.attributes = attrs;
@@ -1823,7 +1854,12 @@ function expandMapTemplate(template: JxElement, scope: Record<string, unknown>):
1823
1854
  }
1824
1855
  node.$props = props;
1825
1856
  } else if (typeof v === "string" && isTemplateString(v)) {
1826
- node[k] = evaluateMapTemplate(v, scope) ?? v;
1857
+ const resolved = evaluateMapTemplate(v, scope);
1858
+ if (k === "textContent" && typeof resolved === "string" && resolved.includes("${")) {
1859
+ node.innerHTML = inertTextHtml(resolved);
1860
+ } else {
1861
+ node[k] = resolved ?? v;
1862
+ }
1827
1863
  } else {
1828
1864
  node[k] = v;
1829
1865
  }
@@ -1886,9 +1922,16 @@ function resolveDocTemplates(node: JxElement | string, scope: Record<string, unk
1886
1922
  }
1887
1923
  }
1888
1924
  if (typeof node.textContent === "string" && isTemplateString(node.textContent)) {
1889
- node.textContent =
1890
- (evaluateStaticTemplate(node.textContent, scope) as string | null) ??
1891
- (node.textContent as string | null);
1925
+ const resolved = evaluateStaticTemplate(node.textContent, scope);
1926
+ if (typeof resolved === "string" && resolved.includes("${")) {
1927
+ // The resolved value is data (an excerpt, a heading, a title) that happens to contain `${`, not
1928
+ // A template. Left as `textContent` the compile phase would read it as one again and bind it
1929
+ // To an expression that throws or renders nothing, so it stays text as escaped `innerHTML`.
1930
+ node.innerHTML = inertTextHtml(resolved);
1931
+ delete node.textContent;
1932
+ } else {
1933
+ node.textContent = (resolved as string | null) ?? (node.textContent as string | null);
1934
+ }
1892
1935
  }
1893
1936
  if (node.style && typeof node.style === "object") {
1894
1937
  for (const [k, v] of Object.entries(node.style)) {
@@ -1902,7 +1945,13 @@ function resolveDocTemplates(node: JxElement | string, scope: Record<string, unk
1902
1945
  if (node.attributes && typeof node.attributes === "object") {
1903
1946
  for (const [k, v] of Object.entries(node.attributes)) {
1904
1947
  if (typeof v === "string" && isTemplateString(v)) {
1905
- node.attributes[k] = (evaluateStaticTemplate(v, scope) as JxAttributeValue | null) ?? v;
1948
+ const resolved = evaluateStaticTemplate(v, scope) as JxAttributeValue | null;
1949
+ // A resolved value is data: a `${` left in it must not become a template a second time. An
1950
+ // Entity cannot be written into an attribute, so the sequence is split with a zero-width space.
1951
+ node.attributes[k] =
1952
+ typeof resolved === "string" && resolved.includes("${")
1953
+ ? inertAttribute(resolved)
1954
+ : (resolved ?? v);
1906
1955
  }
1907
1956
  }
1908
1957
  }
@@ -2246,17 +2295,25 @@ function injectComponentScripts(
2246
2295
  .map((href) => `<link rel="modulepreload" href="${href}">`)
2247
2296
  .join("\n ");
2248
2297
 
2249
- const result = intoHead([preloads, styleBlock]);
2298
+ /*
2299
+ * The import map goes in <head>, AHEAD of the hints. The HTML spec rejects an import map that
2300
+ * arrives after a module load or preload has started, and Firefox enforces it: with the map at
2301
+ * the end of <body>, the `modulepreload` links above had already started, so the map was
2302
+ * dropped ("Import maps are not allowed after a module load or preload has started") and every
2303
+ * component module died on `@vue/reactivity` being a bare specifier nothing remapped. That took
2304
+ * down the theme toggle, site search and every interactive component, in Firefox only.
2305
+ *
2306
+ * A map already present (islands, a page template) is already in <head> and is left where it is;
2307
+ * the hints are inserted at `</head>`, behind it.
2308
+ */
2309
+ const hasImportMap = html.includes('<script type="importmap">');
2310
+ const result = intoHead([hasImportMap ? "" : importMap, preloads, styleBlock]);
2250
2311
 
2251
2312
  const moduleScripts = jsTags
2252
2313
  .map((tag: string) => `<script type="module" src="/components/${tag}.js"></script>`)
2253
2314
  .join("\n ");
2254
2315
 
2255
- // Check if an import map already exists (from islands etc.)
2256
- const hasImportMap = result.includes('<script type="importmap">');
2257
- const injection = (hasImportMap ? "" : `${importMap}\n `) + moduleScripts;
2258
-
2259
- return result.replace("</body>", ` ${injection}\n</body>`);
2316
+ return result.replace("</body>", ` ${moduleScripts}\n</body>`);
2260
2317
  }
2261
2318
 
2262
2319
  /**