@jxsuite/compiler 4.0.3 → 5.1.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?"":`
@@ -284,7 +284,7 @@ app.post('${t}/${e}', async (c) => {
284
284
  }
285
285
  })`}var UE=P(()=>{Jl();qb();_n()});function zb(e){let t=[],r=[],n=null,s=0,A=()=>r.at(-1)?.path??"",o=()=>n===null?A():gZ(A(),n),i=()=>{s+=1;let a="";while(s<e.length){let c=e[s];if(c==="\\"){let l=e[s+1]??"";if(l==="u")a+=String.fromCodePoint(Number.parseInt(e.slice(s+2,s+6),16)),s+=6;else a+=lZ[l]??l,s+=2;continue}if(c==='"')return s+=1,a;a+=c,s+=1}return a};while(s<e.length){let a=e[s];if(Kb.has(a)||a===","||a===":"){s+=1;continue}if(a==="{"||a==="["){r.push(a==="{"?{keys:new Set,kind:"object",path:o()}:{kind:"array",path:o()}),n=null,s+=1;continue}if(a==="}"||a==="]"){r.pop(),n=null,s+=1;continue}if(a==='"'){let l=i(),u=r.at(-1);if(u?.kind==="object"&&uZ(e,s)===":"){if(u.keys.has(l))t.push({detail:l,kind:"duplicate-key",path:u.path});u.keys.add(l),n=l}else n=null;continue}if(a==="-"||a>="0"&&a<="9"){let l=s;while(s<e.length&&/[\d+.eE-]/.test(e[s]))s+=1;let u=e.slice(l,s);if(!fZ(u))t.push({detail:u,kind:"unsafe-number",path:o()});n=null;continue}let c=s;while(s<e.length&&/[A-Za-z]/.test(e[s]))s+=1;if(s===c)s+=1;n=null}return t}function uZ(e,t){let r=t;while(r<e.length&&Kb.has(e[r]))r+=1;return e[r]??""}function gZ(e,t){return e===""?t:`${e}.${t}`}function fZ(e){if(/[.eE]/.test(e))return!0;let t=Number(e);if(!Number.isFinite(t))return!1;return String(t)===e.replace(/^\+/,"")}function Xb(e){let t=e.path===""?"the document root":`"${e.path}"`;return e.kind==="duplicate-key"?`duplicate key "${e.detail}" in ${t} — JSON.parse keeps the last one and `+"silently discards the first (RFC 7493 §2.3)":`number ${e.detail} in ${t} cannot be represented exactly and will change when `+"the document is written back (RFC 7493 §2.2)"}var Kb,lZ;var ex=P(()=>{Kb=new Set([" ","\t",`
286
286
  `,"\r"]);lZ={b:"\b",f:"\f",n:`
287
- `,r:"\r",t:"\t"}});function hZ(e){return e instanceof Error?e.message:String(e)}function LE(e){if(typeof e==="string")return tx.test(e)?e.normalize("NFC"):e;if(Array.isArray(e))return e.map((t)=>LE(t));if(Ye(e)){let t={};for(let[r,n]of Object.entries(e))t[tx.test(r)?r.normalize("NFC"):r]=LE(n);return t}return e}function OE(e,t,r){let n;try{n=JSON.parse(e)}catch(A){throw Error(`Failed to parse ${r} at ${t}: ${hZ(A)}`,{cause:A})}if(!Ye(n))throw Error(`Invalid ${r} at ${t}: expected a JSON object`);let s=zb(e);if(s.length>0){let A=s.map((o)=>Xb(o)).join("; ");throw Error(`Invalid ${r} at ${t}: ${A}`)}return LE(n)}function Ql(e,t){return OE(e,t,"Jx document")}function n3(e,t){return OE(e,t,"project config")}function s3(e,t){return OE(e,t,"class definition")}var tx;var vE=P(()=>{xr();ex();tx=/[^\p{ASCII}]/u});function Ax(e){if(typeof e!=="string")return null;let[t,...r]=e.split(";"),n=(t??"").indexOf("/");if(n===-1)return null;let s=(t??"").slice(0,n).trim().toLowerCase(),A=(t??"").slice(n+1).trim().toLowerCase();if(!rx.test(s)||!rx.test(A))return null;let o=A.lastIndexOf("+"),i=o===-1?null:A.slice(o+1),a=o===-1?A:A.slice(0,o);if(i==="")return null;let c=a.indexOf("."),l=c===-1?null:a.slice(0,c),u=l!==null&&EZ.has(l)?l:null,g=u===null?a:a.slice(u.length+1);if(g==="")return null;let h={};for(let f of r){let d=f.indexOf("=");if(d===-1)return null;let E=f.slice(0,d).trim().toLowerCase(),I=f.slice(d+1).trim();if(E==="")return null;if(I.startsWith('"')&&I.endsWith('"')&&I.length>=2)I=I.slice(1,-1);h[E]=I}return{parameters:h,subtype:g,suffix:i,tree:u,type:s}}function ox(e){if(typeof e!=="string"||e.trim()==="")return"expected a media type string";if(!e.includes("/"))return`"${e}" has no "/" — a media type is type/subtype (RFC 6838 §4.2)`;if(Ax(e)===null)return`"${e}" is not a well-formed media type (RFC 6838 §4.2)`;return null}function ix(e){let t=Ax(e);if(t===null)return null;let r=t.tree===null?"":`${t.tree}.`,n=t.suffix===null?"":`+${t.suffix}`;return`${t.type}/${r}${t.subtype}${n}`}var rx,EZ,nx="text/markdown; variant=GFM",sx="application/yaml",o3;var ax=P(()=>{rx=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,EZ=new Set(["vnd","prs","x"]);o3={".markdown":`${nx}; charset=utf-8`,".md":`${nx}; charset=utf-8`,".yaml":`${sx}; charset=utf-8`,".yml":`${sx}; charset=utf-8`}});class Bl{name;classPath;classDef;extensions;mediaType;mediaTypeEssence;documentKinds;exportTarget;remote;studio;project;server;connector;capabilities;#e;#t=null;constructor(e,t,r,n){this.name=e,this.classPath=t,this.classDef=r,this.#e=n;let{format:s}=r;this.extensions=(s?.extensions??[]).map((A)=>A.toLowerCase()),this.mediaType=s?.mediaType??null,this.mediaTypeEssence=ix(this.mediaType),this.documentKinds=s?.documentKinds??[],this.exportTarget=s?.exportTarget===!0,this.remote=s?.remote===!0,this.studio=r.$studio??null,this.project=r.project??null,this.server=r.server??null,this.connector=r.connector??null,this.capabilities=IZ(r)}implementation(){if(!this.#t){let e=this.classDef.$implementation;if(!e)return Promise.reject(Error(`Format class "${this.name}" has no $implementation to import`));this.#t=this.#e.importModule(this.#e.resolvePath(this.classPath,e))}return this.#t}async call(e,...t){let r=this.capabilities[e];if(!r)throw Error(`Format class "${this.name}" does not declare a "${e}" capability`);let n=await this.implementation(),s=this.classDef.title??this.name,A=n[s]??n.default?.[s]??n.default,o=A?.[r.identifier];if(typeof o!=="function")throw TypeError(`Format class "${this.name}": implementation export "${s}" has no static "${r.identifier}" method`);return await o.call(A,...t)}}class pl{#e;constructor(e){this.#e=e;for(let t of e){if(t.mediaType===null)continue;let r=ox(t.mediaType);if(r!==null)throw Error(`Format "${t.name}" declares an invalid mediaType: ${r}`)}for(let t of lx){let r=new Map;for(let n of e){if(!n.capabilities[t])continue;for(let s of n.extensions){let A=r.get(s);if(A)throw Error(`Format conflict: "${A.name}" and "${n.name}" both claim "${s}" with the "${t}" capability`);r.set(s,n)}}}}get entries(){return this.#e}byExtension(e,t){let r=cx(e);return this.#e.find((n)=>n.extensions.includes(r)&&(!t||n.capabilities[t]))}byName(e){return this.#e.find((t)=>t.name===e)}withCapability(e){return this.#e.filter((t)=>t.capabilities[e])}documentExtensions(e){let t=new Set;for(let r of this.#e){if(e&&!r.documentKinds.includes(e))continue;for(let n of r.extensions)t.add(n)}return t.delete(".json"),[...t]}has(e){let t=cx(e);return this.#e.some((r)=>r.extensions.includes(t))}}function IZ(e){let t={},r=e.$defs?.methods??{};for(let[n,s]of Object.entries(r)){let A=s.role;if(!A||!ux.includes(A))continue;let o={identifier:s.identifier??n,timing:s.timing??dZ};if(typeof s.discriminator==="string")o.discriminator=s.discriminator;t[A]=o}return t}function cx(e){let t=e.toLowerCase();return t.startsWith(".")?t:`.${t}`}var lx,ux,dZ;var HE=P(()=>{ax();lx=["parse","serialize","rewrite","discover","load"],ux=[...lx,"projectData","resolvePaths","lower","emit","head","assets","mount","dialect","deploySchema","bindings","testConnection"],dZ=["compiler","server"]});class gx{#e;#t;#r;constructor(e){this.#e=e,this.#t=e.flatMap((s)=>s.classes);let t=new Map;for(let s of e)for(let A of s.classes){let o=t.get(A.name);if(o&&o!==s.specifier)throw Error(`Extension conflict: "${o}" and "${s.specifier}" both provide a class named "${A.name}"`);t.set(A.name,s.specifier)}let r=new Map;for(let s of this.#t){if(!s.project)continue;let A=r.get(s.project.key);if(A)throw Error(`Extension conflict: "${A.name}" and "${s.name}" both claim the project section "${s.project.key}"`);r.set(s.project.key,s)}let n=new Map;for(let s of this.#t){if(!s.server)continue;let{basePath:A}=s.server;if(!A.startsWith("/_jx/"))throw Error(`Extension "${s.name}": server basePath "${A}" must be under /_jx/`);let o=n.get(A);if(o)throw Error(`Extension conflict: "${o.name}" and "${s.name}" both mount "${A}"`);n.set(A,s)}this.#r=new pl(this.#t.filter((s)=>s.extensions.length>0))}get extensions(){return this.#e}get classes(){return this.#t}get formats(){return this.#r}byName(e){return this.#t.find((t)=>t.name===e)}projectContributions(){return this.#t.filter((e)=>e.project!==null)}byProjectKey(e){return this.#t.find((t)=>t.project?.key===e)}byPathsDiscriminator(e){return this.#t.find((t)=>t.capabilities.resolvePaths?.discriminator===e)}emitters(){return this.#t.filter((e)=>e.capabilities.emit!==void 0)}headProviders(){return this.#t.filter((e)=>e.capabilities.head!==void 0)}assetProviders(){return this.#t.filter((e)=>e.capabilities.assets!==void 0)}serverMounts(){return this.#t.filter((e)=>e.server!==null).toSorted((e,t)=>(e.server?.order??100)-(t.server?.order??100)||e.name.localeCompare(t.name))}connectors(){return this.#t.filter((e)=>e.connector!==null)}schemaFragments(e){return this.#e.map((t)=>t.schemas[e]).filter((t)=>typeof t==="string")}}async function fx(e,t,r){let n=[];for(let s of e??[])n.push(await CZ(s,t,r));return new gx(n)}async function CZ(e,t,r){let n;if(e.startsWith("./")||e.startsWith("../")){let i=t.resolvePath(r,e);n=t.resolvePath(`${i}/package.json`,`./${Wi}`)}else try{n=t.resolvePath(r,`${e}/${Wi}`)}catch(i){throw Error(`Extension "${e}" is not resolvable: it must export ${Wi} (is the package installed, and does its exports map include it?): ${YE(i)}`,{cause:i})}let s;try{s=await t.loadJson(n)}catch(i){throw Error(`Extension "${e}": cannot read manifest ${n}: ${YE(i)}`,{cause:i})}if(!s||typeof s!=="object"||typeof s.name!=="string")throw Error(`Extension "${e}": ${Wi} must declare a "name"`);if(!e.startsWith(".")&&s.name!==e)throw Error(`Extension "${e}": manifest name "${s.name}" does not match the specifier`);let A=[];for(let[i,a]of Object.entries(s.classes??{})){let c=t.resolvePath(n,a),l;try{l=await t.loadJson(c)}catch(u){throw Error(`Extension "${e}": cannot read class "${i}" at ${c}: ${YE(u)}`,{cause:u})}A.push(new Bl(i,c,l,t))}let o={};if(s.schemas?.project)o.project=t.resolvePath(n,s.schemas.project);if(s.schemas?.document)o.document=t.resolvePath(n,s.schemas.document);if(s.schemas?.fields)o.fields=t.resolvePath(n,s.schemas.fields);return{specifier:e,manifestPath:n,manifest:s,classes:A,schemas:o}}function YE(e){return e instanceof Error?e.message:String(e)}var Wi="jx-extension.json";var hx=P(()=>{HE();HE()});import{readFileSync as QZ}from"node:fs";import{dirname as BZ,isAbsolute as pZ,resolve as JE,sep as yl}from"node:path";import{pathToFileURL as yZ}from"node:url";import{createRequire as Ex}from"node:module";async function mZ(e){let t=[e],r=`${yl}src${yl}`,n=`${yl}dist${yl}`;if(e.includes(r))t.push(e.replace(r,n));if(e.endsWith(".js"))t.push(`${e.slice(0,-3)}.ts`);let s;for(let A of t)try{return await import(yZ(A).href)}catch(o){s=o}throw s instanceof Error?s:Error(String(s))}function SZ(e){return{importModule:(t)=>mZ(t),loadJson:async(t)=>JSON.parse(QZ(t,"utf8")),resolvePath:(t,r)=>{if(r.startsWith("./")||r.startsWith("../"))return JE(BZ(t),r);if(pZ(r))return r;let n=Ex(JE(e,"package.json"));try{return n.resolve(r)}catch{return Ex(import.meta.url).resolve(r)}}}}async function C3(e,t){return fx(t?.extensions,SZ(e),JE(e,"project.json"))}function ml(e,t){return Error(`No format class registered for "${t}" (${e}). Enable an extension providing this format in project.json "extensions", e.g. "@jxsuite/parser".`)}var $E=P(()=>{hx()});async function Qx(e,t={}){let{resolveElementPath:r,$media:n,formats:s}=t,A=[],o=new Set;async function i(a,c){let l,u;if(typeof a==="string"){let{readFileSync:w}=await import("node:fs"),{resolve:B}=await import("node:path");if(u=c?B(c,a):B(a),o.has(u))return;if(o.add(u),u.endsWith(".json"))l=Ql(w(u,"utf8"),u);else{let{extname:S}=await import("node:path"),p=S(u).toLowerCase(),m=s?.byExtension?.(p,"parse");if(!m){await Promise.resolve().then(() => $E());throw ml(u,p)}l=await m.call("parse",w(u,"utf8"))}}else{if(l=a,u=null,l.tagName&&o.has(l.tagName))return;if(l.tagName)o.add(l.tagName)}let{tagName:g}=l;if(!g||!g.includes("-"))throw Error(`compileElement: tagName "${g}" must contain a hyphen`);let{dirname:h}=await import("node:path"),f=u?h(u):null,d=[];if(Array.isArray(l.$elements))for(let w of l.$elements){let B=ve(w)?w.$ref:w;if(typeof B!=="string")continue;if(f)await i(B,f);let S=r?r(B,f):B.replace(/\.json$/,".js");d.push(S)}let E=ua(g);if(n)l.$media={...n,...l.$media};let{rewriteSrc:I}=t,C=qi(l,E,d,I?(w)=>I(w,f):void 0,ea(l,t.defaults)),Q=u?u.replace(/\.json$/,".js"):`${g}.js`;A.push({content:C,path:Q,tagName:g})}return await i(e,t.basePath??null),{files:A}}async function wZ(e,t={}){let{title:r="Jx App",reactivitySrc:n="https://esm.sh/@vue/reactivity@3.5.13",litHtmlSrc:s="https://esm.sh/lit-html@3.3.0"}=t,A=await Qx(e,t),o=A.files.at(-1);if(!o)throw Error("compileElementPage: no element modules were produced");let{basename:i}=await import("node:path"),a=i(o.path),c=`<!DOCTYPE html>
287
+ `,r:"\r",t:"\t"}});function hZ(e){return e instanceof Error?e.message:String(e)}function LE(e){if(typeof e==="string")return tx.test(e)?e.normalize("NFC"):e;if(Array.isArray(e))return e.map((t)=>LE(t));if(Ye(e)){let t={};for(let[r,n]of Object.entries(e))t[tx.test(r)?r.normalize("NFC"):r]=LE(n);return t}return e}function OE(e,t,r){let n;try{n=JSON.parse(e)}catch(A){throw Error(`Failed to parse ${r} at ${t}: ${hZ(A)}`,{cause:A})}if(!Ye(n))throw Error(`Invalid ${r} at ${t}: expected a JSON object`);let s=zb(e);if(s.length>0){let A=s.map((o)=>Xb(o)).join("; ");throw Error(`Invalid ${r} at ${t}: ${A}`)}return LE(n)}function Ql(e,t){return OE(e,t,"Jx document")}function n3(e,t){return OE(e,t,"project config")}function s3(e,t){return OE(e,t,"class definition")}var tx;var vE=P(()=>{xr();ex();tx=/[^\p{ASCII}]/u});function Ax(e){if(typeof e!=="string")return null;let[t,...r]=e.split(";"),n=(t??"").indexOf("/");if(n===-1)return null;let s=(t??"").slice(0,n).trim().toLowerCase(),A=(t??"").slice(n+1).trim().toLowerCase();if(!rx.test(s)||!rx.test(A))return null;let o=A.lastIndexOf("+"),i=o===-1?null:A.slice(o+1),a=o===-1?A:A.slice(0,o);if(i==="")return null;let c=a.indexOf("."),l=c===-1?null:a.slice(0,c),u=l!==null&&EZ.has(l)?l:null,g=u===null?a:a.slice(u.length+1);if(g==="")return null;let h={};for(let f of r){let d=f.indexOf("=");if(d===-1)return null;let E=f.slice(0,d).trim().toLowerCase(),I=f.slice(d+1).trim();if(E==="")return null;if(I.startsWith('"')&&I.endsWith('"')&&I.length>=2)I=I.slice(1,-1);h[E]=I}return{parameters:h,subtype:g,suffix:i,tree:u,type:s}}function ox(e){if(typeof e!=="string"||e.trim()==="")return"expected a media type string";if(!e.includes("/"))return`"${e}" has no "/" — a media type is type/subtype (RFC 6838 §4.2)`;if(Ax(e)===null)return`"${e}" is not a well-formed media type (RFC 6838 §4.2)`;return null}function ix(e){let t=Ax(e);if(t===null)return null;let r=t.tree===null?"":`${t.tree}.`,n=t.suffix===null?"":`+${t.suffix}`;return`${t.type}/${r}${t.subtype}${n}`}var rx,EZ,nx="text/markdown; variant=GFM",sx="application/yaml",o3;var ax=P(()=>{rx=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,EZ=new Set(["vnd","prs","x"]);o3={".markdown":`${nx}; charset=utf-8`,".md":`${nx}; charset=utf-8`,".yaml":`${sx}; charset=utf-8`,".yml":`${sx}; charset=utf-8`}});class Bl{name;classPath;classDef;extensions;mediaType;mediaTypeEssence;documentKinds;exportTarget;remote;studio;project;server;connector;capabilities;#e;#t=null;constructor(e,t,r,n){this.name=e,this.classPath=t,this.classDef=r,this.#e=n;let{format:s}=r;this.extensions=(s?.extensions??[]).map((A)=>A.toLowerCase()),this.mediaType=s?.mediaType??null,this.mediaTypeEssence=ix(this.mediaType),this.documentKinds=s?.documentKinds??[],this.exportTarget=s?.exportTarget===!0,this.remote=s?.remote===!0,this.studio=r.$studio??null,this.project=r.project??null,this.server=r.server??null,this.connector=r.connector??null,this.capabilities=IZ(r)}implementation(){if(!this.#t){let e=this.classDef.$implementation;if(!e)return Promise.reject(Error(`Format class "${this.name}" has no $implementation to import`));this.#t=this.#e.importModule(this.#e.resolvePath(this.classPath,e))}return this.#t}async call(e,...t){let r=this.capabilities[e];if(!r)throw Error(`Format class "${this.name}" does not declare a "${e}" capability`);let n=await this.implementation(),s=this.classDef.title??this.name,A=n[s]??n.default?.[s]??n.default,o=A?.[r.identifier];if(typeof o!=="function")throw TypeError(`Format class "${this.name}": implementation export "${s}" has no static "${r.identifier}" method`);return await o.call(A,...t)}}class pl{#e;constructor(e){this.#e=e;for(let t of e){if(t.mediaType===null)continue;let r=ox(t.mediaType);if(r!==null)throw Error(`Format "${t.name}" declares an invalid mediaType: ${r}`)}for(let t of lx){let r=new Map;for(let n of e){if(!n.capabilities[t])continue;for(let s of n.extensions){let A=r.get(s);if(A)throw Error(`Format conflict: "${A.name}" and "${n.name}" both claim "${s}" with the "${t}" capability`);r.set(s,n)}}}}get entries(){return this.#e}byExtension(e,t){let r=cx(e);return this.#e.find((n)=>n.extensions.includes(r)&&(!t||n.capabilities[t]))}byName(e){return this.#e.find((t)=>t.name===e)}withCapability(e){return this.#e.filter((t)=>t.capabilities[e])}documentExtensions(e){let t=new Set;for(let r of this.#e){if(e&&!r.documentKinds.includes(e))continue;for(let n of r.extensions)t.add(n)}return t.delete(".json"),[...t]}has(e){let t=cx(e);return this.#e.some((r)=>r.extensions.includes(t))}}function IZ(e){let t={},r=e.$defs?.methods??{};for(let[n,s]of Object.entries(r)){let A=s.role;if(!A||!ux.includes(A))continue;let o={identifier:s.identifier??n,timing:s.timing??dZ};if(typeof s.discriminator==="string")o.discriminator=s.discriminator;t[A]=o}return t}function cx(e){let t=e.toLowerCase();return t.startsWith(".")?t:`.${t}`}var lx,ux,dZ;var HE=P(()=>{ax();lx=["parse","serialize","rewrite","discover","load"],ux=[...lx,"projectData","resolvePaths","lower","emit","head","assets","mount","dialect","deploySchema","bindings","testConnection"],dZ=["compiler","server"]});class gx{#e;#t;#r;constructor(e){this.#e=e,this.#t=e.flatMap((s)=>s.classes);let t=new Map;for(let s of e)for(let A of s.classes){let o=t.get(A.name);if(o&&o!==s.specifier)throw Error(`Extension conflict: "${o}" and "${s.specifier}" both provide a class named "${A.name}"`);t.set(A.name,s.specifier)}let r=new Map;for(let s of this.#t){if(!s.project)continue;let A=r.get(s.project.key);if(A)throw Error(`Extension conflict: "${A.name}" and "${s.name}" both claim the project section "${s.project.key}"`);r.set(s.project.key,s)}let n=new Map;for(let s of this.#t){if(!s.server)continue;let{basePath:A}=s.server;if(!A.startsWith("/_jx/"))throw Error(`Extension "${s.name}": server basePath "${A}" must be under /_jx/`);let o=n.get(A);if(o)throw Error(`Extension conflict: "${o.name}" and "${s.name}" both mount "${A}"`);n.set(A,s)}this.#r=new pl(this.#t.filter((s)=>s.extensions.length>0))}get extensions(){return this.#e}get classes(){return this.#t}get formats(){return this.#r}byName(e){return this.#t.find((t)=>t.name===e)}projectContributions(){return this.#t.filter((e)=>e.project!==null)}byProjectKey(e){return this.#t.find((t)=>t.project?.key===e)}byPathsDiscriminator(e){return this.#t.find((t)=>t.capabilities.resolvePaths?.discriminator===e)}emitters(){return this.#t.filter((e)=>e.capabilities.emit!==void 0)}headProviders(){return this.#t.filter((e)=>e.capabilities.head!==void 0)}assetProviders(){return this.#t.filter((e)=>e.capabilities.assets!==void 0)}serverMounts(){return this.#t.filter((e)=>e.server!==null).toSorted((e,t)=>(e.server?.order??100)-(t.server?.order??100)||e.name.localeCompare(t.name))}connectors(){return this.#t.filter((e)=>e.connector!==null)}schemaFragments(e){return this.#e.map((t)=>t.schemas[e]).filter((t)=>typeof t==="string")}}async function fx(e,t,r){let n=[];for(let s of e??[])n.push(await CZ(s,t,r));return new gx(n)}async function CZ(e,t,r){let n;if(e.startsWith("./")||e.startsWith("../")){let i=t.resolvePath(r,e);n=t.resolvePath(`${i}/package.json`,`./${Wi}`)}else try{n=t.resolvePath(r,`${e}/${Wi}`)}catch(i){throw Error(`Extension "${e}" is not resolvable: it must export ${Wi} (is the package installed, and does its exports map include it?): ${YE(i)}`,{cause:i})}let s;try{s=await t.loadJson(n)}catch(i){throw Error(`Extension "${e}": cannot read manifest ${n}: ${YE(i)}`,{cause:i})}if(!s||typeof s!=="object"||typeof s.name!=="string")throw Error(`Extension "${e}": ${Wi} must declare a "name"`);if(!e.startsWith(".")&&s.name!==e)throw Error(`Extension "${e}": manifest name "${s.name}" does not match the specifier`);let A=[];for(let[i,a]of Object.entries(s.classes??{})){let c=t.resolvePath(n,a),l;try{l=await t.loadJson(c)}catch(u){throw Error(`Extension "${e}": cannot read class "${i}" at ${c}: ${YE(u)}`,{cause:u})}A.push(new Bl(i,c,l,t))}let o={};if(s.schemas?.project)o.project=t.resolvePath(n,s.schemas.project);if(s.schemas?.document)o.document=t.resolvePath(n,s.schemas.document);if(s.schemas?.fields)o.fields=t.resolvePath(n,s.schemas.fields);return{specifier:e,manifestPath:n,manifest:s,classes:A,schemas:o}}function YE(e){return e instanceof Error?e.message:String(e)}var Wi="jx-extension.json";var hx=P(()=>{HE();HE()});import{readFileSync as QZ}from"node:fs";import{dirname as BZ,isAbsolute as pZ,resolve as JE,sep as yl}from"node:path";import{pathToFileURL as yZ}from"node:url";import{createRequire as Ex}from"node:module";async function mZ(e){let t=[e],r=`${yl}src${yl}`,n=`${yl}dist${yl}`;if(e.includes(r)){let A=e.replace(r,n);if(t.push(A),A.endsWith(".ts"))t.push(`${A.slice(0,-3)}.js`)}if(e.endsWith(".js"))t.push(`${e.slice(0,-3)}.ts`);let s;for(let A of t)try{return await import(yZ(A).href)}catch(o){s=o}throw s instanceof Error?s:Error(String(s))}function SZ(e){return{importModule:(t)=>mZ(t),loadJson:async(t)=>JSON.parse(QZ(t,"utf8")),resolvePath:(t,r)=>{if(r.startsWith("./")||r.startsWith("../"))return JE(BZ(t),r);if(pZ(r))return r;let n=Ex(JE(e,"package.json"));try{return n.resolve(r)}catch{return Ex(import.meta.url).resolve(r)}}}}async function C3(e,t){return fx(t?.extensions,SZ(e),JE(e,"project.json"))}function ml(e,t){return Error(`No format class registered for "${t}" (${e}). Enable an extension providing this format in project.json "extensions", e.g. "@jxsuite/parser".`)}var $E=P(()=>{hx()});async function Qx(e,t={}){let{resolveElementPath:r,$media:n,formats:s}=t,A=[],o=new Set;async function i(a,c){let l,u;if(typeof a==="string"){let{readFileSync:w}=await import("node:fs"),{resolve:B}=await import("node:path");if(u=c?B(c,a):B(a),o.has(u))return;if(o.add(u),u.endsWith(".json"))l=Ql(w(u,"utf8"),u);else{let{extname:S}=await import("node:path"),p=S(u).toLowerCase(),m=s?.byExtension?.(p,"parse");if(!m){await Promise.resolve().then(() => $E());throw ml(u,p)}l=await m.call("parse",w(u,"utf8"))}}else{if(l=a,u=null,l.tagName&&o.has(l.tagName))return;if(l.tagName)o.add(l.tagName)}let{tagName:g}=l;if(!g||!g.includes("-"))throw Error(`compileElement: tagName "${g}" must contain a hyphen`);let{dirname:h}=await import("node:path"),f=u?h(u):null,d=[];if(Array.isArray(l.$elements))for(let w of l.$elements){let B=ve(w)?w.$ref:w;if(typeof B!=="string")continue;if(f)await i(B,f);let S=r?r(B,f):B.replace(/\.json$/,".js");d.push(S)}let E=ua(g);if(n)l.$media={...n,...l.$media};let{rewriteSrc:I}=t,C=qi(l,E,d,I?(w)=>I(w,f):void 0,ea(l,t.defaults)),Q=u?u.replace(/\.json$/,".js"):`${g}.js`;A.push({content:C,path:Q,tagName:g})}return await i(e,t.basePath??null),{files:A}}async function wZ(e,t={}){let{title:r="Jx App",reactivitySrc:n="https://esm.sh/@vue/reactivity@3.5.13",litHtmlSrc:s="https://esm.sh/lit-html@3.3.0"}=t,A=await Qx(e,t),o=A.files.at(-1);if(!o)throw Error("compileElementPage: no element modules were produced");let{basename:i}=await import("node:path"),a=i(o.path),c=`<!DOCTYPE html>
288
288
  <html lang="en">
289
289
  <head>
290
290
  <meta charset="utf-8">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jxsuite/compiler",
3
- "version": "4.0.3",
3
+ "version": "5.1.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) {
@@ -22,7 +22,9 @@ export type { FormatRegistry, FormatEntry } from "@jxsuite/schema/format-registr
22
22
  * Import a class $implementation module by absolute path, tolerating source-vs-built layouts. A
23
23
  * `.class.json` typically declares `"$implementation": "./markdown.js"` next to its TypeScript
24
24
  * source: under Bun the sibling `.ts` resolves directly, while under node the built module lives in
25
- * the package's `dist/` directory. Tries, in order: the literal path, src/ → dist/, .js → .ts.
25
+ * the package's `dist/` directory. Tries, in order: the literal path, src/ → dist/, that same file
26
+ * with its `.ts` extension read as `.js` (a descriptor that names its TypeScript source, whose
27
+ * built module is JavaScript), and .js → .ts.
26
28
  *
27
29
  * @param {string} path - Absolute path to the implementation module
28
30
  * @returns {Promise<Record<string, unknown>>}
@@ -32,7 +34,11 @@ export async function importImplementation(path: string): Promise<Record<string,
32
34
  const srcSeg = `${sep}src${sep}`;
33
35
  const distSeg = `${sep}dist${sep}`;
34
36
  if (path.includes(srcSeg)) {
35
- candidates.push(path.replace(srcSeg, distSeg));
37
+ const built = path.replace(srcSeg, distSeg);
38
+ candidates.push(built);
39
+ if (built.endsWith(".ts")) {
40
+ candidates.push(`${built.slice(0, -3)}.js`);
41
+ }
36
42
  }
37
43
  if (path.endsWith(".js")) {
38
44
  candidates.push(`${path.slice(0, -3)}.ts`);
package/src/site/i18n.ts CHANGED
@@ -20,6 +20,8 @@ import {
20
20
  } from "@jxsuite/schema/locale";
21
21
  import type { ResolvedI18n, TextDirection } from "@jxsuite/schema/locale";
22
22
 
23
+ import { servedRoute } from "./static-host.ts";
24
+
23
25
  /*
24
26
  * `resolveI18n` and the two types beside it live in `@jxsuite/schema/locale` rather than here.
25
27
  * Studio needs the same answer and cannot import this package — there is no `./site/i18n` export,
@@ -278,12 +280,15 @@ export function translationSets(
278
280
  * @param {readonly TranslationRoute[]} routes - Concrete routes only
279
281
  * @param {ResolvedI18n | null} i18n
280
282
  * @param {string} siteUrl - Absolute site URL; alternates must be absolute
283
+ * @param {string} [trailingSlash] - `build.trailingSlash`: the alternates name the URL the host
284
+ * serves, so they agree with the canonical link and the sitemap
281
285
  * @returns {Map<string, LocaleAlternate[]>} Keyed by `urlPattern`
282
286
  */
283
287
  export function localeAlternates(
284
288
  routes: readonly TranslationRoute[],
285
289
  i18n: ResolvedI18n | null,
286
290
  siteUrl: string,
291
+ trailingSlash?: string,
287
292
  ): Map<string, LocaleAlternate[]> {
288
293
  const out = new Map<string, LocaleAlternate[]>();
289
294
  if (i18n === null || siteUrl === "") {
@@ -299,13 +304,13 @@ export function localeAlternates(
299
304
  let alternates = built.get(members);
300
305
  if (alternates === undefined) {
301
306
  alternates = members.map((m) => ({
302
- href: siteAbsoluteUrl(m.urlPattern, siteUrl),
307
+ href: siteAbsoluteUrl(servedRoute(m.urlPattern, trailingSlash), siteUrl),
303
308
  hreflang: m.locale,
304
309
  }));
305
310
  const fallback = members.find((m) => m.locale === i18n.defaultLocale);
306
311
  if (fallback !== undefined) {
307
312
  alternates.push({
308
- href: siteAbsoluteUrl(fallback.urlPattern, siteUrl),
313
+ href: siteAbsoluteUrl(servedRoute(fallback.urlPattern, trailingSlash), siteUrl),
309
314
  hreflang: "x-default",
310
315
  });
311
316
  }
@@ -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