@jxsuite/compiler 8.2.0 → 8.3.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,34 +1,78 @@
1
- import{createRequire as cs}from"node:module";var rs=Object.create;var{getPrototypeOf:ss,defineProperty:wn,getOwnPropertyNames:os}=Object;var Cn=Object.prototype.hasOwnProperty;function is(e){return this[e]}var as,ls,Vo=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var s=t?as??=new WeakMap:ls??=new WeakMap,o=s.get(e);if(o)return o}n=e!=null?rs(ss(e)):{};let i=t||!e||!e.__esModule||!Cn.call(e,"default")?wn(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let u of os(e))if(!Cn.call(i,u))wn(i,u,{get:is.bind(e,u),enumerable:!0})}if(r)s.set(e,i);return i};var Ho=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var I=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(r){n=[r]}if(n)throw n[0];return t};var Uo=cs(import.meta.url);function J(e){return typeof e==="string"}function ee(e){return typeof e==="number"}function K(e){return typeof e==="boolean"}function te(e){return typeof e==="function"}function C(e){return typeof e==="object"&&e!==null}function L(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function P(e){return L(e)&&typeof e.$ref==="string"}function G(e){return L(e)&&e.$prototype==="Function"}function X(e){return L(e)&&L(e.$expression)}function Ee(e){return X(e)&&Array.isArray(e.parameters)&&e.parameters.length>0}function xe(e){return G(e)&&Array.isArray(e.body)}function ye(e){return L(e)&&typeof e.$prototype==="string"&&e.$prototype!=="Function"}function le(e){return L(e)&&e.timing==="server"&&typeof e.$src==="string"&&typeof e.$export==="string"&&!e.$prototype}function vn(e){return L(e)&&!e.$prototype&&!e.$expression&&"default"in e}function $e(e){if(!L(e))return!1;for(let t of Object.keys(e))if(!On.has(t))return!1;return!0}function V(e){return L(e)&&e.$prototype==="Array"}function Pt(e){return(Array.isArray(e)?e:[e]).some((n)=>V(n))}function An(e){return L(e)&&e.$prototype==="Class"}function Fe(e){return L(e)}function N(e){return typeof e==="string"&&e.includes("${")}function we(e){return/\breturn\b[^\S\n]*(?![;}\s]|$)/.test(e)}function us(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ce(e){if(!e)return[];return e.map((t)=>J(t)?t:t.name)}function ps(e){return typeof e==="string"}function oe(e){if(typeof e!=="object"||e===null||Array.isArray(e)||!L(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 L(t.cases)&&Object.values(t.cases).every((n)=>J(n))&&typeof t.default==="string";return!1}function Oe(e){if(ps(e))return[e];if(!oe(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 On;var H=I(()=>{On=new Set(["type","enum","minimum","maximum","minLength","maxLength","pattern","format","items","properties","required","description","title","$comment"])});function z(e){return e.replaceAll(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}function jn(e,t){if(e.startsWith("@--"))return t[e.slice(1)]??e.slice(1);if(e.startsWith("@(")){let n=e.slice(2,-1).trim();return fs.has(n.toLowerCase())?n:e.slice(1)}return null}function We(e){return e.startsWith("@position-try")||e.startsWith("@property")||e.startsWith("@font-face")||e.startsWith("@counter-style")}function He(e){return e.startsWith("@keyframes")}function Rn(e,t){let n=[];for(let r of Ve(e))for(let s of Ve(t))n.push(ms(r,s));return n.join(", ")}function ms(e,t){let n=tt(t,e);if(n!==null)return n;if(t.startsWith("[")||t.startsWith(":")||t.startsWith("."))return`${e}${t}`;return`${e} ${t}`}function Tt(e){let t=[],n=null,r=0;for(let s=0;s<e.length;s+=1){let o=e[s];if(n){if(o==="\\")s+=1;else if(o===n)n=null;continue}if(o==="\\")s+=1;else if(o==='"'||o==="'")n=o;else if(o==="[")r+=1;else if(o==="]")r=Math.max(0,r-1);else if(o==="&"&&r===0)t.push(s)}return t}function tt(e,t){return Tt(e).length>0?ds(e,t):null}function ds(e,t){let n="",r=0;for(let s of Tt(e))n+=e.slice(r,s)+t,r=s+1;return n+e.slice(r)}function Ve(e){let t=[],n=0,r=null,s=0;for(let i=0;i<e.length;i+=1){let u=e[i];if(r){if(u==="\\")i+=1;else if(u===r)r=null;continue}if(u==='"'||u==="'")r=u;else if(u==="("||u==="[")n+=1;else if(u===")"||u==="]")n=Math.max(0,n-1);else if(u===","&&n===0)t.push(e.slice(s,i)),s=i+1}t.push(e.slice(s));let o=t.flatMap((i)=>{let u=i.trim();return u===""?[]:[u]});return o.length>0?o:[e]}function ue(e){let t=/^\(\s*prefers-color-scheme\s*:\s*(light|dark)\s*\)$/.exec(e.trim())?.[1];return t==="light"||t==="dark"?t:null}function kt(e,t){if(e===":root"||e==="html")return{auto:`${e}:where(:not([${se}]))`,forced:`${e}:where([${se}="${t}"])`};return{auto:`:where(:root:not([${se}])) ${e}`,forced:`:where(:root[${se}="${t}"]) ${e}`}}function Se(e){return e.startsWith(":")||e.startsWith(".")||e.startsWith("&")||e.startsWith("[")}function _t(e){return e.startsWith("--")?e:z(e)}function et(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Nn(e,t,n){let r=n.map(([o,i])=>`${o}: ${i}`).join("; "),s=t===null?r:`${t} { ${r} }`;for(let o=e.length-1;o>=0;o-=1)s=`${e[o]} { ${s} }`;return s}function gs(e,t,n){let r=n.map(({selector:o,declarations:i})=>`${o} { ${i.map(([u,a])=>`${u}: ${a}`).join("; ")} }`).join(" "),s=`@keyframes ${t} { ${r} }`;for(let o=e.length-1;o>=0;o-=1)s=`${e[o]} { ${s} }`;return s}function hs(e){let t=Object.keys(e).filter((r)=>He(r));if(t.length===0)return e;let n={...e};for(let r of t)delete n[r];return n}function xs(e){let n=Tt(e).at(-1),r=n===void 0?e:e.slice(n+1);return r===""||r.startsWith(":")||r.startsWith(".")||r.startsWith("[")}function Ae(e,t={}){let{scope:n=null,mediaQueries:r={},transposeValue:s=(m)=>m,transposeSelector:o=(m)=>m,resolveValue:i}=t,u=[],a=(m)=>m!==null&&typeof m==="object"&&!Array.isArray(m)&&!P(m),c=(m,y)=>{if(a(y))return[y];if(!We(m)||!Array.isArray(y)||y.length===0)return[];return y.every((w)=>a(w))?y:[]},l=(m,y,w,O)=>{if(y===void 0||y===null)return null;if(P(y))return w?i?.(m,y,O)??null:null;if(C(y))return null;let v=String(y);if(N(v))return w?i?.(m,v,O)??null:null;return s(v)},p=(m,y,w=!0,O="self")=>{let v=[];for(let[A,k]of Object.entries(m)){if(c(A,k).length>0)continue;if(y&&(A.startsWith("@")||Se(A)))continue;if(A.startsWith("$"))continue;let S=l(A,k,w,O);if(S!==null)v.push([_t(A),S])}return v},g=(m,y,w,O,v)=>{if(w.length===0)return;let A=y;if(A!==null){let h=o(A);if(h===null)return;A=h}let k=Nn(m,A,w),S={text:k,conditions:[...m],selector:A,declarations:w,target:O,key:et(k)};if(J(v)&&v!=="")S.description=v;u.push(S)},d=(m,y,w)=>{let O=m.slice(10).trim();if(O==="")return;let v=[];for(let[k,S]of Object.entries(y)){if(!a(S))continue;let h=p(S,!0,!1,"unscoped");if(h.length>0)v.push({declarations:h,selector:k.trim()})}if(v.length===0)return;let A=gs(w,O,v);u.push({blocks:v,conditions:[...w],declarations:[],key:et(A),selector:null,target:"unscoped",text:A})},x=(m,y,w,O,v)=>{if(m==="@--")return;if(We(m)){g([...O,m],null,p(y,!1,!0,"unscoped"),"unscoped",y.$description);return}if(He(m)){d(m,y,O);return}let A=jn(m,r),k=A===null?m:`@media ${A}`,S=A===null?null:ue(A);if(S!==null&&w!==null){let{auto:h,forced:b}=kt(w,S);f(y,h,[...O,k],v),f(hs(y),b,O,v);return}f(y,w,[...O,k],v)};function f(m,y,w,O){g(w,y,p(m,!0,!0,O),O,m.$description);for(let[v,A]of Object.entries(m))for(let k of c(v,A))if(v.startsWith("@"))x(v,k,y,w,O);else if(y!==null)f(k,Rn(y,v),w,xs(v)?O:"descendant")}return f(e,n,[],"self"),u}var fs,se="data-color-scheme",nt="jx-color-scheme";var Be=I(()=>{H();fs=new Set(["all","print","screen","speech"])});function Go(){return`the Intl helpers ${Mt.join(", ")}`}var ie="en-US",Dt="UTC",Pn,Mt,Tn;var kn=I(()=>{Pn=[{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."}],Mt=Pn.map((e)=>e.path),Tn=Object.fromEntries(Pn.map((e)=>[e.path,e.params.indexOf("locale")]))});function ys(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function B(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function pe(e){if(e==="")return[];return e.split("/").map((t)=>ys(t))}function U(e,t){let n=e;for(let r of pe(t))n=n?.[r];return n}function R(e,t){let n=e;for(let r of pe(t))n+=It.test(r)?`.${r}`:`[${JSON.stringify(r)}]`;return n}function _n(e,t){let n=e;for(let[r,s]of pe(t).entries()){let o=r===0?"":"?.";n+=It.test(s)?`${r===0?".":o}${s}`:`${o}[${JSON.stringify(s)}]`}return n}function fe(e){return It.test(e)?e:JSON.stringify(e)}function Dn(e){let t=e.replaceAll(/[^A-Za-z0-9_$]/g,"_");if(t==="")return"ref";return/^\d/.test(t)?`_${t}`:t}var It;var je=I(()=>{It=/^[A-Za-z_$][A-Za-z0-9_$]*$/});function Lt(e){let t=e.$map;return C(t)?t:void 0}function Fn(e){return C(e)&&!Array.isArray(e)&&"operator"in e}function Ue(e){return C(e)&&!Array.isArray(e)&&"$ref"in e}function Js(e,t,n){let r=Tn[e];if(r===void 0||r<0||t[r]!=null)return t;let s=U(n.$page,"locale");if(!J(s)||s==="")return t;let o=[...t];return o[r]=s,o}function Bn(e){return e.startsWith("window#/")&&Ss.has(e.slice(8))}function me(e){return Wn.has(e)}function D(e,t){if(!e)return;let n=(e.depth??0)+1;if(n>Es)return;return{depth:n,path:[...e.path??[],...Array.isArray(t)?t:[t]],report:e.report}}function _(e,t,n,r,s){if(e===null||e===void 0)return e;if(Fn(e))return Z(e,t,n,r,s);if(Ue(e)){let o=rt(e.$ref,t,n,r);return s?.report(s.path??[],o),o}if(Array.isArray(e))return Un(e,t,n,r,s);return s?.report(s.path??[],e),e}function Un(e,t,n,r,s){return e.map((o,i)=>_(o,t,n,r,D(s,i)))}function ws(e,t,n,r){let s=(o)=>{if(!e.slice(o.length).includes("/"))return t;return rt(e.slice(0,e.lastIndexOf("/")),t,n,r)};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?rt(e.slice(0,e.lastIndexOf("/")),t,n,r):void 0;return}function rt(e,t,n,r){if(e==="$reduce/acc")return r?.acc;if(e.startsWith("$reduce/"))return r?.acc;if(e.startsWith("$args/")){let s=e.slice(6).split("/"),o=r?.args?.[s[0]];return s.length>1?U(o,s.slice(1).join("/")):o}if(e.startsWith("event#/")){let s=e.slice(7);return U(n,s)}if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s,i,u=Lt(t);if(o==="item")i=r?.item??u?.item??t["$map/item"];else if(o==="index")i=r?.index??u?.index??t["$map/index"];else i=u?.[o]??t[`$map/${o}`];return s.length>2?U(i,s.slice(2).join("/")):i}if(e.startsWith("#/state/"))return U(t,e.slice(8));if(e.startsWith("parent#/"))return U(t,e.slice(8));if(e.startsWith("window#/"))return U(globalThis.window,e.slice(8));if(e.startsWith("document#/"))return U(globalThis.document,e.slice(10));return U(t,e)??null}function Cs(e,t,n,r){if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s,i,u=Lt(t);if(o==="item")i=r?.item??u?.item??t["$map/item"];else if(o==="index")i=r?.index??u?.index??t["$map/index"];else i=u?.[o]??t[`$map/${o}`];if(s.length>2){let a=s.slice(2),c=a.pop(),l=a.length>0?U(i,a.join("/")):i;return{key:c,obj:l}}return{key:o==="item"?"$map/item":"$map/index",obj:Lt(t)??t}}if(e.startsWith("#/state/")){let s=e.slice(8);if(s.indexOf("/")===-1)return{key:s,obj:t};let i=pe(s),u=i.pop(),a=t;for(let c of i)a=a[c];return{key:u,obj:a}}return{key:e,obj:t}}function Z(e,t,n,r,s){let o=vs(e,t,n,r,s);return s?.report(s.path??[],o),o}function In(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n;case"%":return t%n;case"<":return t<n;case"<=":return t<=n;case">":return t>n;default:return t>=n}}function vs(e,t,n,r,s){let{operator:o,target:i,value:u,initial:a}=e;if(!$s.has(o))throw Error(`$expression: unknown operator "${o}"`);if(Ft.has(o)&&!("value"in e)){let c=_(i,t,n,r,D(s,"target"));if(o==="!")return!c;if(o==="-")return-c}if(o==="call"){let c=Ue(i)?i.$ref:void 0;if(!J(c))throw TypeError("$expression: call target must be a $ref pointer");let l=(r?.callDepth??0)+1;if(l>Mn)throw Error(`$expression: call depth exceeded (${Mn})`);let p=Array.isArray(u)?u.map((d,x)=>_(d,t,n,r,D(s,["value",x]))):[];if(c.startsWith("window#/")){if(!Bn(c))throw Error(`$expression: "${c}" is not a blessed pure global`);let d=c.slice(8),x=bs.get(d);if(x)return x(...Js(d,p,t));let f=U(globalThis.window,d),m=d.lastIndexOf("/"),y=m===-1?globalThis.window:U(globalThis.window,d.slice(0,m));return f.apply(y,p)}let g=rt(c,t,n,r);if(te(g))return g.apply(ws(c,t,n,r),p);if(C(g)&&"$expression"in g){let d=g,x={};for(let[f,m]of(d.parameters??[]).entries()){let y=J(m)?m:m?.name??"";if(!y)continue;x[y]=p[f]===void 0&&C(m)&&"default"in m?m.default:p[f]}return Z(d.$expression,t,n,{args:x,callDepth:l})}throw TypeError(`$expression: call target "${c}" is not callable`)}if(Ht.has(o)){if(o==="?:"){let d=_(i,t,n,r,D(s,"target"));if(s){let x=_(u,t,n,r,D(s,"value")),f=_(a,t,n,r,D(s,"initial"));return d?x:f}return d?_(u,t,n,r):_(a,t,n,r)}let c=_(i,t,n,r,D(s,"target")),l=String(c),p=e.cases??{},g=Object.hasOwn(p,l);if(s){let d;for(let[f,m]of Object.entries(p)){let y=_(m,t,n,r,D(s,["cases",f]));if(f===l)d=y}let x=_(e.default,t,n,r,D(s,"default"));return g?d:x}return g?_(p[l],t,n,r):_(e.default,t,n,r)}if(Wt.has(o)){let c=_(i,t,n,r,D(s,"target")),l=_(u,t,n,r,D(s,"value"));switch(o){case"===":return c===l;case"!==":return c!==l;case"&&":return c&&l;case"||":return c||l;case"??":return c??l;default:return In(o,c,l)}}if(Vn.has(o)){let c=_(u,t,n,r,D(s,"value")),{obj:l,key:p}=Cs(i.$ref,t,n,r);l[p]=o==="="?c:In(o.slice(0,-1),l[p],c);return}if(Hn.has(o)){let c=_(i,t,n,r,D(s,"target"));switch(o){case"push":return c.push(_(u,t,n,r,D(s,"value")));case"unshift":return c.unshift(_(u,t,n,r,D(s,"value")));case"pop":return c.pop();case"shift":return c.shift();case"splice":{let l=_(u,t,n,r,D(s,"value"));return c.splice(...l)}default:break}}if(Bt.has(o)){let c=_(i,t,n,r,D(s,"target")),l=u===void 0?[]:Array.isArray(u)?Un(u,t,n,r,D(s,"value")):[_(u,t,n,r,D(s,"value"))],p=U(c,o);if(!te(p))return;return p.apply(c,l)}if(Vt.has(o)){let c=_(i,t,n,r,D(s,"target")),l=u;if(o==="reduce"){let p=_(a,t,n,r,D(s,"initial"));for(let[g,d]of c.entries())p=Z(l,t,n,{acc:p,index:g,item:d},g===0?D(s,"value"):void 0);return p}if(o==="map")return c.map((p,g)=>Z(l,t,n,{...r,index:g,item:p},g===0?D(s,"value"):void 0));if(o==="filter")return c.filter((p,g)=>Z(l,t,n,{...r,index:g,item:p},g===0?D(s,"value"):void 0))}return}function M(e,t){if(e===null)return"null";if(e===void 0)return"undefined";if(Fn(e))return q(e,t);if(Ue(e))return Ut(e.$ref,t);if(Array.isArray(e))return e.map((n)=>M(n,t)).join(", ");return JSON.stringify(e)}function Os(e){return`_fx_${e.replaceAll(/[^A-Za-z0-9_$]/g,"_")}`}function Ut(e,t){let n=t.statePrefix??"state",r=t.eventParam??"event";if(e==="$reduce/acc")return"_acc";if(e.startsWith("$reduce/"))return"_acc";if(e.startsWith("$args/"))return R("_args",e.slice(6));if(e.startsWith("event#/"))return R(r,e.slice(7));if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s;if(o==="item")return s.length>2?R("_item",s.slice(2).join("/")):"_item";if(o==="index")return"_index";return`_${o}`}if(e.startsWith("#/state/"))return R(n,e.slice(8));if(e.startsWith("parent#/"))return R(n,e.slice(8));if(e.startsWith("window#/"))return R("window",e.slice(8));if(e.startsWith("document#/"))return R("document",e.slice(10));return R(n,e)}function Ln(e,t){if(Ue(e))return Ut(e.$ref,t);return M(e,t)}function As(e,t,n){let r=(i)=>t[i]??"undefined",s=`(${n.statePrefix??"state"}?.$page?.locale ?? ${JSON.stringify(ie)})`,o=JSON.stringify(Dt);switch(e){case"Intl/formatNumber":return`new Intl.NumberFormat(${r(1)} ?? ${s}, ${r(2)}).format(${r(0)})`;case"Intl/formatDate":return`new Intl.DateTimeFormat(${r(1)} ?? ${s}, {timeZone: ${o}, ...${r(2)}}).format(new Date(${r(0)}))`;case"Intl/formatRelativeTime":return`new Intl.RelativeTimeFormat(${r(2)} ?? ${s}, ${r(3)}).format(${r(0)}, ${r(1)})`;case"Intl/formatList":return`new Intl.ListFormat(${r(1)} ?? ${s}, ${r(2)}).format(${r(0)})`;case"Intl/plural":return`new Intl.PluralRules(${r(1)} ?? ${s}, ${r(2)}).select(${r(0)})`;case"Intl/compare":return`new Intl.Collator(${r(2)} ?? ${s}, ${r(3)}).compare(${r(0)}, ${r(1)})`;case"Intl/displayName":return`new Intl.DisplayNames(${r(2)} ?? ${s}, {...${r(3)}, type: ${r(1)} ?? 'language'}).of(${r(0)})`;case"Intl/segment":return`[...new Intl.Segmenter(${r(2)} ?? ${s}, {granularity: ${r(1)} ?? 'grapheme'}).segment(${r(0)})].map((p) => p.segment)`;default:return null}}function q(e,t={}){let{operator:n,target:r,value:s,initial:o}=e;if(Ft.has(n)&&!("value"in e)){let i=M(r,t);if(n==="!")return`!(${i})`;if(n==="-")return`-(${i})`}if(n==="call"){let i=(Ue(r)?r.$ref:void 0)??"",u=Array.isArray(s)?s.map((a)=>M(a,t)):[];if(i.startsWith("window#/")){if(!Bn(i))throw Error(`$expression: "${i}" is not a blessed pure global`);let a=As(i.slice(8),u,t);if(a)return a;return`window.${i.slice(8).replaceAll("/",".")}(${u.join(", ")})`}if(i.startsWith("#/state/")){let a=i.slice(8),c=t.formulaParams?.[a];if(c){let l=c.map((p,g)=>`${JSON.stringify(p)}: ${u[g]??"undefined"}`).join(", ");return`${Os(a)}(${t.statePrefix??"state"}, { ${l} })`}}return`${Ut(i,t)}(${u.join(", ")})`}if(Ht.has(n)){if(n==="?:"){let c=M(r,t),l=M(s,t),p=M(o,t);return`(${c} ? ${l} : ${p})`}let i=M(r,t),u=Object.entries(e.cases??{}).map(([c,l])=>`_d === ${JSON.stringify(c)} ? ${M(l,t)} : `).join(""),a="default"in e?M(e.default,t):"undefined";return`((_d) => ${u}${a})(String(${i}))`}if(Wt.has(n)){let i=M(r,t),u=M(s,t);return`(${i} ${n} ${u})`}if(Vn.has(n)){let i=Ln(r,t),u=M(s,t);return`${i} ${n} ${u}`}if(Hn.has(n)){let i=Ln(r,t);switch(n){case"push":return`${i}.push(${M(s,t)})`;case"unshift":return`${i}.unshift(${M(s,t)})`;case"pop":return`${i}.pop()`;case"shift":return`${i}.shift()`;case"splice":{let u=Array.isArray(s)?s.map((a)=>M(a,t)).join(", "):M(s,t);return`${i}.splice(${u})`}default:break}}if(Bt.has(n)){let i=M(r,t),u=s===void 0?"":Array.isArray(s)?s.map((a)=>M(a,t)).join(", "):M(s,t);return`(${i})?.${n}?.(${u})`}if(Vt.has(n)){let i=M(r,t),u=q(s,t);if(n==="reduce"){let a=M(o,t);return`${i}.reduce((_acc, _item, _index) => ${u}, ${a})`}if(n==="map")return`${i}.map((_item, _index) => ${u})`;if(n==="filter")return`${i}.filter((_item, _index) => ${u})`}return"undefined"}function Re(e,t,n,r){return _(e,t,n,r)}function de(e,t={}){return M(e,t)}var Wn,Ft,Wt,Vn,Hn,Vt,Ht,Bt,$s,Ss,bs,Mn=64,Es=64;var qe=I(()=>{kn();H();je();Wn=new Set(["=","+=","-=","*=","/=","push","pop","shift","unshift","splice"]),Ft=new Set(["!","-"]),Wt=new Set(["+","-","*","/","%","===","!==","<","<=",">",">=","&&","||","??"]),Vn=new Set(["=","+=","-=","*=","/="]),Hn=new Set(["push","pop","shift","unshift","splice"]),Vt=new Set(["reduce","map","filter"]),Ht=new Set(["?:","switch"]),Bt=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"]),$s=new Set([...Wn,...Ft,...Wt,...Vt,...Ht,...Bt,"call"]),Ss=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",...Mt]),bs=new Map([["Intl/compare",(e,t,n,r)=>new Intl.Collator(n??ie,r).compare(e,t)],["Intl/displayName",(e,t,n,r)=>new Intl.DisplayNames(n??ie,{...r,type:t??"language"}).of(e)],["Intl/formatDate",(e,t,n)=>new Intl.DateTimeFormat(t??ie,{timeZone:Dt,...n}).format(new Date(e))],["Intl/formatList",(e,t,n)=>new Intl.ListFormat(t??ie,n).format(e)],["Intl/formatNumber",(e,t,n)=>new Intl.NumberFormat(t??ie,n).format(e)],["Intl/formatRelativeTime",(e,t,n,r)=>new Intl.RelativeTimeFormat(n??ie,r).format(e,t)],["Intl/plural",(e,t,n)=>new Intl.PluralRules(t??ie,n).select(e)],["Intl/segment",(e,t,n)=>[...new Intl.Segmenter(n??ie,{granularity:t??"grapheme"}).segment(e)].map((r)=>r.segment)]])});function js(e){return e.startsWith(qn)}function si(e){let t=e;if(js(t))t=t.slice(qn.length);return t=t.replace(/^\.\//,"").replace(/\.(js|ts|mjs|mts)$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,""),`${qt}${t}.js`}function oi(e){let t=/\.(\w+)$/.exec(e)?.[1]??"",n=e.replace(/\.\w+$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");return t===""?`${qt}${n}`:`${qt}${n}.${t}`}function Kn(e){let t=e.replaceAll("\\","/");return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function zn(e){let t=Kn(e);return t.startsWith("/")?t:`/${t}`}function Rs(e,t){return[...e].toSorted((n,r)=>r[t].length-n[t].length)}function ii(e,t){let n=t.split("#")[0].split("?")[0];if(!n.startsWith("/"))return null;let r;try{r=decodeURIComponent(n)}catch{return null}if(/%2e|%2f/i.test(r))return null;for(let s of Rs(e,"urlPrefix")){let o=zn(s.urlPrefix);if(!r.startsWith(`${o}/`))continue;let u=r.slice(o.length+1).split("/");if(u.some((c)=>c===""||c==="."||c===".."))return null;let{filter:a}=s;if(a&&!a(u.join("/")))return null;return`${Kn(s.dir)}/${u.join("/")}`}return null}function ai(e,t){let n=new Set;for(let r of t){let s=zn(r.urlPrefix),o=new RegExp(`${s.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}/[^${Ns}]+`,"g");for(let i of e.matchAll(o)){let u=i[0].split("#")[0].split("?")[0];if(!u.endsWith("/"))n.add(u)}}return[...n].filter(Boolean)}function Ps(e){let t=[],n=0;while(n<e.length){while(n<e.length&&(/\s/.test(e[n])||e[n]===","))n+=1;if(n>=e.length)break;let r=n;while(n<e.length&&!/\s/.test(e[n]))n+=1;let s=e.slice(r,n);if(s.endsWith(",")){t.push({descriptor:"",url:s.replace(/,+$/,"")});continue}while(n<e.length&&/\s/.test(e[n]))n+=1;let o=n;while(n<e.length&&e[n]!==",")n+=1;let i=e.slice(o,n).trim();if(n+=1,s=s.replace(/,+$/,""),s!=="")t.push({descriptor:i,url:s})}return t}function Ts(e){return e.map(({url:t,descriptor:n})=>n?`${t} ${n}`:t).join(", ")}function li(e){if(!J(e)||e==="")return"";let t;try{({pathname:t}=new URL(e))}catch{return""}let n=t.replace(/\/+$/,"");if(n===""||n==="/")return"";return n.startsWith("/")?n:`/${n}`}function Yn(e,t){if(e===""||!t.startsWith("/")||t.startsWith("//"))return t;if(t===e||t.startsWith(`${e}/`))return t;return e+t}function ci(e,t){let n=new URL(t);if(!n.pathname.endsWith("/"))n.pathname+="/";return new URL(e.replace(/^\/+/,""),n).href}var qn="npm:",qt="/assets/",Ns;var Kt=I(()=>{H();Ns=String.raw`"'\s<>()\\`});function Gn(e){if("operator"in e)return{kind:"expression",node:e};if("if"in e)return{kind:"if",node:e};if("$switch"in e)return{kind:"switch",node:e};if("stopPropagation"in e)return{kind:"stopPropagation"};if("preventDefault"in e)return{kind:"preventDefault"};return{kind:"dispatch",node:e}}function ks(e){return(C(e)||te(e))&&"then"in e&&te(e.then)}async function Ne(e,t,n,r={}){let s=r.args?{args:r.args}:void 0;for(let o of e){let i=Gn(o);switch(i.kind){case"expression":{let u=Z(i.node,t,n,s);if(ks(u))await u;break}case"if":{let u=i.node,a=Re(u.if,t,n,s)?u.then:u.else;if(Array.isArray(a))await Ne(a,t,n,r);break}case"switch":{let u=i.node,a=String(Re(u.$switch,t,n,s)),c=u.cases??{},l=Object.hasOwn(c,a)?c[a]:u.default;if(Array.isArray(l))await Ne(l,t,n,r);break}case"dispatch":{let u=i.node,a=te(r.target)?r.target():r.target,c=n?.currentTarget??a;if(!c)break;let l={};if("detail"in u)l.detail=Re(u.detail,t,n,s);if(u.bubbles!==void 0)l.bubbles=u.bubbles;if(u.composed!==void 0)l.composed=u.composed;c.dispatchEvent(new CustomEvent(u.dispatchEvent,l));break}case"stopPropagation":{n?.stopPropagation();break}case"preventDefault":{n?.preventDefault();break}default:break}}}function ne(e,t={}){let n=t.indent??"",r=[];for(let s of e){let o=Gn(s);switch(o.kind){case"expression":{r.push(`${n}${q(o.node,t)};`);break}case"if":{let i=o.node,u=de(i.if,t),a={...t,indent:`${n} `};if(r.push(`${n}if (${u}) {`,ne(i.then??[],a)),i.else)r.push(`${n}} else {`,ne(i.else,a));r.push(`${n}}`);break}case"switch":{let i=o.node,u=de(i.$switch,t),a={...t,indent:`${n} `};r.push(`${n}switch (String(${u})) {`);for(let[c,l]of Object.entries(i.cases??{}))r.push(`${n} case ${JSON.stringify(c)}: {`,ne(l,a),`${n} break;`,`${n} }`);if(i.default)r.push(`${n} default: {`,ne(i.default,a),`${n} }`);r.push(`${n}}`);break}case"dispatch":{let i=o.node,u=t.eventParam??"event",a=t.dispatchTarget??`(${u} && ${u}.currentTarget)`,c=[];if("detail"in i)c.push(`detail: ${de(i.detail,t)}`);if(i.bubbles!==void 0)c.push(`bubbles: ${JSON.stringify(i.bubbles)}`);if(i.composed!==void 0)c.push(`composed: ${JSON.stringify(i.composed)}`);let l=c.length>0?`, { ${c.join(", ")} }`:"";r.push(`${n}${a}?.dispatchEvent(new CustomEvent(${JSON.stringify(i.dispatchEvent)}${l}));`);break}case"stopPropagation":{r.push(`${n}${t.eventParam??"event"}?.stopPropagation();`);break}case"preventDefault":{r.push(`${n}${t.eventParam??"event"}?.preventDefault();`);break}default:break}}return r.join(`
2
- `)}var st=I(()=>{H();qe()});function ot(e){if(!e.startsWith("${")||!e.endsWith("}"))return!1;let t=0;for(let n=1;n<e.length;n+=1){let r=e[n];if(r==="{")t+=1;else if(r==="}"){if(t-=1,t===0)return n===e.length-1}}return!1}function Zn(){return[...Xn].toSorted()}function Ce(e,t){let n=e.toLowerCase();if(n.startsWith("aria-")||Xn.has(n))return String(t);return t?"":null}var ge,Xn,zt=32,it,at="jx-slot",Yt="data-jx-slots",Gt="jx.slot.group",vi;var ze=I(()=>{Be();qe();je();H();Kt();st();Be();ge=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"]),Xn=new Set(["contenteditable","draggable","spellcheck"]);it=/^[\t\n\f\r ]+$/u,vi=(()=>{let e=Symbol.for(Gt),t=globalThis;return t[e]??=new WeakMap,t[e]})()});function Qn(e,t,n,r,s=Ds){let o=[],i=(p,g)=>{let d={mediaQueries:t,scope:g,transposeValue:n};if(r)d.resolveValue=(x,f)=>r(x,f,g);for(let x of Ae(p,d))o.push(x.text)},u={},a={},c=[],l=[];for(let[p,g]of Object.entries(e)){if(C(g)&&!Array.isArray(g)){if(p.startsWith("@"))c.push([p,g]);else if(!p.startsWith("--"))l.push([p,g]);continue}if(Se(p)||p.startsWith("@"))continue;if(p.startsWith("--")||p==="colorScheme"||p==="color-scheme")u[p]=g;else a[p]=g}i(u,s.root),i(a,s.body);for(let[p,g]of l)if(p.startsWith("&"))i({[p]:g},s.root);else i(g,p);for(let[p,g]of c){if(We(p)||He(p)){i({[p]:g},null);continue}let d={},x={},f=[];for(let[m,y]of Object.entries(g)){if(C(y)&&!Array.isArray(y)){if(!m.startsWith("@"))f.push([m,y]);continue}if(m.startsWith("--"))d[m]=y;else x[m]=y}i({[p]:d},s.root),i({[p]:x},s.body);for(let[m,y]of f)i({[p]:y},m)}if(Object.values(t).some((p)=>ue(p)!==null)&&!("colorScheme"in e))o.push(`${s.root} { color-scheme: light dark }`,`${s.root}:where([${se}="light"]) { color-scheme: light }`,`${s.root}:where([${se}="dark"]) { color-scheme: dark }`);return o.join(`
3
- `)}var Ds;var er=I(()=>{Be();H();Ds={body:"body",root:":root"}});function tr(e){return e===!1||e==="open"||e==="closed"}function lt(e,t){let n=e?.$shadow;if(tr(n))return n===!1?null:n;let r=t?.shadow;return tr(r)&&r!==!1?r:null}function nr(e,t){return t===null?e:":host"}function Ge(e,t){let n=[];for(let[r,s]of(e.parameters??[]).entries()){let o=rr(s);if(!o)continue;let i=sr(s)?`_a[${r}] === undefined ? ${JSON.stringify(s.default)} : _a[${r}]`:`_a[${r}]`;n.push(`${JSON.stringify(o)}: ${i}`)}return`(..._a) => { const _args = { ${n.join(", ")} }; return ${t}; }`}function rr(e){return J(e)?e:e?.name??""}function sr(e){return C(e)&&"default"in e}function ft(e,t){let n=nn(e,t);return n===e?e:`${n} as ${e}`}function nn(e,t){let n=t?.$export;return J(n)&&n!==""?n:e}function mt(e,t,n={}){let{statePrefix:r="state",indent:s="",collect:o}=n,{url:i}=t,u=N(i),a=t.method??"GET";if(t.manual)return`${s}// ${e}: manual Request — fetch triggered by user action`;let c=[`// ${e}: auto-fetch from ${u?"(dynamic URL)":i}`,o?`${o}.push(effect(() => {`:"effect(() => {"];if(u)c.push(` const url = \`${Is(i,r)}\`;`,' if (!url || url === "undefined" || url.includes("undefined")) return;');else c.push(` const url = ${JSON.stringify(i)};`);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=C(t.body)?JSON.stringify(JSON.stringify(t.body)):JSON.stringify(t.body);l.push(`body: ${g}`)}let p=l.length>0?`, { ${l.join(", ")} }`:"";return c.push(` fetch(url${p})`," .then(r => r.ok ? r.json() : Promise.reject(r.statusText))",` .then(d => { ${r}.${e} = d; })`,` .catch(e => { ${r}.${e} = { error: String(e) }; });`,o?"}));":"});"),c.map((g)=>`${s}${g}`).join(`
4
- `)}function dt(e,t,n={}){let{statePrefix:r="state",indent:s="",collect:o,serverBaseUrl:i="/_jx/server"}=n,u=JSON.stringify(`${i}/${t.$export}`),a=Object.entries(t.arguments??{}),c=a.map(([f,m])=>{if(!P(m))return`${fe(f)}: ${JSON.stringify(m)}`;if(Ms.some((y)=>m.$ref.startsWith(y)))throw Error(`Server function "${e}": argument "${f}" references "${m.$ref}", which a state entry cannot read. Use a #/state/, parent#/, window#/ or document#/ reference.`);return`${fe(f)}: ${de({$ref:m.$ref},{statePrefix:r})}`}),l=a.some(([,f])=>P(f)),p=`${pr}(${u}, ${c.length>0?`{ ${c.join(", ")} }`:"{}"})`,g=R(r,B(e)),d=`console.error(${JSON.stringify(`Jx server function ${t.$export}:`)}, e)`;return(l?[`// ${e}: server function ${t.$export}, called again when an argument changes`,"{"," let _jxSeq = 0;",o?` ${o}.push(effect(() => {`:" effect(() => {"," const _seq = ++_jxSeq;",` ${p}`,` .then((d) => { if (_seq === _jxSeq) ${g} = d; })`,` .catch((e) => { if (_seq === _jxSeq) ${d}; });`,o?" }));":" });","}"]:[`// ${e}: server function ${t.$export}, called once`,p,` .then((d) => { ${g} = d; })`,` .catch((e) => { ${d}; });`]).map((f)=>`${s}${f}`).join(`
5
- `)}function Is(e,t){if(t==="state")return e;return e.replaceAll(/\$\{([^}]*)\}/g,(n,r)=>`\${${r.replaceAll(/(?<!this\.)\bstate\./g,`${t}.`)}}`)}function xt(e){if(!C(e))return!1;if(e.state)for(let[t,n]of Object.entries(e.state)){if(t==="$site"||t==="$page")continue;if(!C(n)||Array.isArray(n))return!0;if(n.timing==="compiler")continue;if(n.$prototype)return!0;if("default"in n)return!0;if($e(n))continue;return!0}if(e.$switch)return!0;if(V(e)||Pt(e.children))return!0;if(Array.isArray(e.children)&&e.children.some((t)=>xt(t)))return!0;for(let[t,n]of Object.entries(e)){if(ge.has(t))continue;if(P(n))return!0;if(N(n))return!0}if(C(e.style)){for(let t of Object.values(e.style))if(N(t))return!0}if(C(e.attributes)){for(let t of Object.values(e.attributes))if(N(t))return!0}return!1}function ir(e){if(!C(e))return!1;if(e.$switch)return!0;if(V(e)||Pt(e.children))return!0;for(let[t,n]of Object.entries(e)){if(ge.has(t))continue;if(P(n))return!0;if(N(n))return!0}if(C(e.style)){for(let t of Object.values(e.style))if(N(t))return!0}if(C(e.attributes)){for(let t of Object.values(e.attributes))if(N(t))return!0}return!1}function ke(e,t=null,n={},r={}){let s=e?.state?en(e.state,t):t??ar();return{media:r,scope:s,scopeDefs:n}}function ar(e=null){return Object.create(e)}function lr(e){return e[or]}function Qt(e,t){if(J(e)){for(let o of e.matchAll(Ls))t.add(o[1]);for(let o of e.matchAll(Fs))t.add(o[1]);return}if(Array.isArray(e)){for(let o of e)Qt(o,t);return}if(!C(e))return;let n=e,{operator:r,target:s}=n;if(J(r)&&me(r)&&P(s)&&s.$ref.startsWith("#/state/"))t.add(s.$ref.slice(8).split("/")[0]);for(let o of Object.values(n))Qt(o,t)}function en(e={},t=null){let n=ar(t),r=t?lr(t):void 0,s=new Set(r);Object.defineProperty(n,or,{configurable:!0,enumerable:!1,value:s,writable:!0});let o=new Set;for(let c of Object.values(e))if(G(c)||X(c))Qt(c.body??c.$expression,o);for(let c of o)if(c in e)s.add(c);for(let[c,l]of Object.entries(e)){if(!C(l)||Array.isArray(l)){he(n,c,ct(l));continue}if("default"in l){he(n,c,ct(l.default));continue}if(le(l)){s.add(c);continue}if(!l.$prototype&&!("$expression"in l)&&!$e(l))he(n,c,ct(l))}let i=[],u=[];for(let[c,l]of Object.entries(e)){if(N(l)){i.push([c,l]);continue}if(!C(l))continue;if(X(l)){let p=l.$expression;if(Ee(l)){let g=l.parameters;he(n,c,(...d)=>{let x={};for(let[f,m]of g.entries()){let y=rr(m);if(!y)continue;x[y]=d[f]===void 0&&sr(m)?m.default:d[f]}return Z(p,n,null,{args:x})})}else if(me(p.operator))he(n,c,(g,d)=>Z(p,g,d));else Xt(n,c,()=>Z(p,n,null));continue}if(G(l)){if(xe(l)){let{body:p}=l;he(n,c,(g,d)=>{Ne(p,g??n,d??null)})}else if(J(l.body)){let p=l.parameters?ce(l.parameters):l.arguments??[],{body:g}=l,d=p.includes("state")?p:["state",...p],x=Function(...d,g),f=(m,y)=>x(...d.map((w)=>w==="state"?m:y));if(we(g))Xt(n,c,()=>f(n)),u.push([c,g]);else he(n,c,f)}else he(n,c,()=>{}),s.add(c);continue}if(ye(l)&&(l.$prototype==="LocalStorage"||l.$prototype==="SessionStorage")){he(n,c,ct(l.default??null));continue}if(ye(l)&&l.$prototype==="Request")s.add(c)}let a=!0;while(a){a=!1;for(let[c,l]of[...u,...i])if(!s.has(c)&&cr(l,n))s.add(c),a=!0}for(let[c,l]of i)Xt(n,c,()=>rn(l,n));return n}function he(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}function Xt(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:n})}function T(e,t){if(P(e))return Ws(e.$ref,t);if(N(e))return rn(e,t);return e}function Y(e){return P(e)}function Ws(e,t){if(!J(e))return e;if(e.startsWith("$map/")){let n=e.split("/"),r=n[1],o=t.$map?.[r]??t[`$map/${r}`];return n.length>2?Zt(o,n.slice(2).join("/")):o}if(e.startsWith("#/state/"))return Zt(t,e.slice(8));return Zt(t,e)??null}function cr(e,t){if(!t)return!1;let n=lr(t);for(let r of e.matchAll(/\bstate\.([A-Za-z_$][\w$]*)\s*(\()?/g)){if(r[2])continue;let s=r[1];if(n?.has(s))return!0;let o;try{o=t[s]}catch{continue}if(te(o))return!0}return!1}function yt(e){return ot(e)?`(${e.slice(2,-1)})`:`\`${e}\``}function rn(e,t){if(cr(e,t))return null;let n=["state","$map","$site","$page"],r=[t,t?.$map,t?.$site,t?.$page];try{let s=ot(e)?`return (${e.slice(2,-1)})`:`return \`${e}\``;return Function(...n,s)(...r)}catch{return null}}function Zt(e,t){return U(e,t)}function ct(e){if(!C(e))return e;return structuredClone(e)}function Vs(e,t){if(!e||!t)return"";return Object.entries(e).filter(([n,r])=>!n.startsWith(":")&&!n.startsWith(".")&&!n.startsWith("&")&&!n.startsWith("[")&&!n.startsWith("@")&&N(r)).map(([n,r])=>{let s=T(r,t);return s==null?null:`${z(n)}: ${s}`}).filter(Boolean).join("; ")}function ve(e,t,n=""){let r="",s=T(e.id,t),o=T(e.className,t),i=T(e.hidden,t),u=T(e.tabIndex,t),a=T(e.title,t),c=T(e.lang,t),l=T(e.dir,t);if(s)r+=` id="${j(String(s))}"`;if(o)r+=` class="${j(String(o))}"`;if(i)r+=" hidden";if(u!==void 0&&u!==null)r+=` tabindex="${j(String(u))}"`;if(a)r+=` title="${j(String(a))}"`;if(c)r+=` lang="${j(String(c))}"`;if(l)r+=` dir="${j(String(l))}"`;let p=[Vs(e.style,t),n].filter(Boolean).join("; ");if(p)r+=` style="${j(p)}"`;if(e.attributes)for(let[g,d]of Object.entries(e.attributes)){let x=T(d,t);if(K(x)){let f=Ce(g,x);if(f!==null)r+=f===""?` ${g}`:` ${g}="${j(f)}"`;continue}if(J(x)||ee(x))r+=` ${g}="${j(String(x))}"`}if(e.$static)r+=" data-jx-static";else if(e.$prerendered)r+=" data-jx-prerendered";return r}function Xe(e,t=" "){return e?"":`
6
- ${t}`}function $t(){let e=JSON.stringify(nt),t=JSON.stringify(se);return`(function(){try{var s=localStorage.getItem(${e});if(s==="light"||s==="dark"){document.documentElement.setAttribute(${t},s)}}catch(e){}})()`}function ut(e,t,n,r){for(let s of Ae(t,{mediaQueries:r,resolveValue:(o,i)=>ur(o,i,n),scope:n}))e.push(s.text)}function ur(e,t,n){let r=J(t)?t:t.$ref;return Hs.push({property:e,selector:n,source:r}),null}function St(){return`const __jxEnumAttrs = new Set(${JSON.stringify(Zn())});
7
- function ${_e}(n, v) {
1
+ import{createRequire as al}from"node:module";var tl=Object.create;var{getPrototypeOf:nl,defineProperty:mo,getOwnPropertyNames:rl}=Object;var go=Object.prototype.hasOwnProperty;function sl(e){return this[e]}var ol,il,Uu=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var s=t?ol??=new WeakMap:il??=new WeakMap,o=s.get(e);if(o)return o}n=e!=null?tl(nl(e)):{};let i=t||!e||!e.__esModule||!go.call(e,"default")?mo(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let c of rl(e))if(!go.call(i,c))mo(i,c,{get:sl.bind(e,c),enumerable:!0})}if(r)s.set(e,i);return i};var qu=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var v=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(r){n=[r]}if(n)throw n[0];return t};var Ku=al(import.meta.url);function b(e){return typeof e==="string"}function se(e){return typeof e==="number"}function pe(e){return typeof e==="boolean"}function ye(e){return typeof e==="function"}function A(e){return typeof e==="object"&&e!==null}function D(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function H(e){return D(e)&&typeof e.$ref==="string"}function $e(e){return D(e)&&e.$prototype==="Function"}function Se(e){return D(e)&&D(e.$expression)}function gt(e){return Se(e)&&Array.isArray(e.parameters)&&e.parameters.length>0}function nt(e){return $e(e)&&Array.isArray(e.body)}function rt(e){return D(e)&&typeof e.$prototype==="string"&&e.$prototype!=="Function"}function He(e){return D(e)&&e.timing==="server"&&typeof e.$src==="string"&&typeof e.$export==="string"&&!e.$prototype}function ho(e){return D(e)&&!e.$prototype&&!e.$expression&&"default"in e}function st(e){if(!D(e))return!1;for(let t of Object.keys(e))if(!xo.has(t))return!1;return!0}function ne(e){return D(e)&&e.$prototype==="Array"}function Wr(e){return(Array.isArray(e)?e:[e]).some((n)=>ne(n))}function yo(e){return D(e)&&e.$prototype==="Class"}function rn(e){return D(e)}function L(e){return typeof e==="string"&&e.includes("${")}function ht(e){return/\breturn\b[^\S\n]*(?![;}\s]|$)/.test(e)}function ll(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Be(e){if(!e)return[];return e.map((t)=>b(t)?t:t.name)}function cl(e){return typeof e==="string"}function Ie(e){if(typeof e!=="object"||e===null||Array.isArray(e)||!D(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 D(t.cases)&&Object.values(t.cases).every((n)=>b(n))&&typeof t.default==="string";return!1}function vt(e){if(cl(e))return[e];if(!Ie(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 xo;var K=v(()=>{xo=new Set(["type","enum","minimum","maximum","minLength","maxLength","pattern","format","items","properties","required","description","title","$comment"])});function de(e){return e.replaceAll(/[A-Z]/g,(t)=>`-${t.toLowerCase()}`)}function $o(e,t){if(e.startsWith("@--"))return t[e.slice(1)]??e.slice(1);if(e.startsWith("@(")){let n=e.slice(2,-1).trim();return ul.has(n.toLowerCase())?n:e.slice(1)}return null}function sn(e){return e.startsWith("@position-try")||e.startsWith("@property")||e.startsWith("@font-face")||e.startsWith("@counter-style")}function an(e){return e.startsWith("@keyframes")}function So(e,t){let n=[];for(let r of on(e))for(let s of on(t))n.push(fl(r,s));return n.join(", ")}function fl(e,t){let n=kn(t,e);if(n!==null)return n;if(t.startsWith("[")||t.startsWith(":")||t.startsWith("."))return`${e}${t}`;return`${e} ${t}`}function Vr(e){let t=[],n=null,r=0;for(let s=0;s<e.length;s+=1){let o=e[s];if(n){if(o==="\\")s+=1;else if(o===n)n=null;continue}if(o==="\\")s+=1;else if(o==='"'||o==="'")n=o;else if(o==="[")r+=1;else if(o==="]")r=Math.max(0,r-1);else if(o==="&"&&r===0)t.push(s)}return t}function kn(e,t){return Vr(e).length>0?pl(e,t):null}function pl(e,t){let n="",r=0;for(let s of Vr(e))n+=e.slice(r,s)+t,r=s+1;return n+e.slice(r)}function on(e){let t=[],n=0,r=null,s=0;for(let i=0;i<e.length;i+=1){let c=e[i];if(r){if(c==="\\")i+=1;else if(c===r)r=null;continue}if(c==='"'||c==="'")r=c;else if(c==="("||c==="[")n+=1;else if(c===")"||c==="]")n=Math.max(0,n-1);else if(c===","&&n===0)t.push(e.slice(s,i)),s=i+1}t.push(e.slice(s));let o=t.flatMap((i)=>{let c=i.trim();return c===""?[]:[c]});return o.length>0?o:[e]}function Ue(e){let t=/^\(\s*prefers-color-scheme\s*:\s*(light|dark)\s*\)$/.exec(e.trim())?.[1];return t==="light"||t==="dark"?t:null}function Hr(e,t){if(e===":root"||e==="html")return{auto:`${e}:where(:not([${Te}]))`,forced:`${e}:where([${Te}="${t}"])`};return{auto:`:where(:root:not([${Te}])) ${e}`,forced:`:where(:root[${Te}="${t}"]) ${e}`}}function ot(e){return e.startsWith(":")||e.startsWith(".")||e.startsWith("&")||e.startsWith("[")}function Br(e){return e.startsWith("--")?e:de(e)}function _n(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function bo(e,t,n){let r=n.map(([o,i])=>`${o}: ${i}`).join("; "),s=t===null?r:`${t} { ${r} }`;for(let o=e.length-1;o>=0;o-=1)s=`${e[o]} { ${s} }`;return s}function dl(e,t,n){let r=n.map(({selector:o,declarations:i})=>`${o} { ${i.map(([c,a])=>`${c}: ${a}`).join("; ")} }`).join(" "),s=`@keyframes ${t} { ${r} }`;for(let o=e.length-1;o>=0;o-=1)s=`${e[o]} { ${s} }`;return s}function ml(e){let t=Object.keys(e).filter((r)=>an(r));if(t.length===0)return e;let n={...e};for(let r of t)delete n[r];return n}function gl(e){let n=Vr(e).at(-1),r=n===void 0?e:e.slice(n+1);return r===""||r.startsWith(":")||r.startsWith(".")||r.startsWith("[")}function Tt(e,t={}){let{scope:n=null,mediaQueries:r={},transposeValue:s=(m)=>m,transposeSelector:o=(m)=>m,resolveValue:i}=t,c=[],a=(m)=>m!==null&&typeof m==="object"&&!Array.isArray(m)&&!H(m),l=(m,x)=>{if(a(x))return[x];if(!sn(m)||!Array.isArray(x)||x.length===0)return[];return x.every((E)=>a(E))?x:[]},u=(m,x,E,O)=>{if(x===void 0||x===null)return null;if(H(x))return E?i?.(m,x,O)??null:null;if(A(x))return null;let J=String(x);if(L(J))return E?i?.(m,J,O)??null:null;return s(J)},f=(m,x,E=!0,O="self")=>{let J=[];for(let[C,q]of Object.entries(m)){if(l(C,q).length>0)continue;if(x&&(C.startsWith("@")||ot(C)))continue;if(C.startsWith("$"))continue;let S=u(C,q,E,O);if(S!==null)J.push([Br(C),S])}return J},p=(m,x,E,O,J)=>{if(E.length===0)return;let C=x;if(C!==null){let y=o(C);if(y===null)return;C=y}let q=bo(m,C,E),S={text:q,conditions:[...m],selector:C,declarations:E,target:O,key:_n(q)};if(b(J)&&J!=="")S.description=J;c.push(S)},d=(m,x,E)=>{let O=m.slice(10).trim();if(O==="")return;let J=[];for(let[q,S]of Object.entries(x)){if(!a(S))continue;let y=f(S,!0,!1,"unscoped");if(y.length>0)J.push({declarations:y,selector:q.trim()})}if(J.length===0)return;let C=dl(E,O,J);c.push({blocks:J,conditions:[...E],declarations:[],key:_n(C),selector:null,target:"unscoped",text:C})},h=(m,x,E,O,J)=>{if(m==="@--")return;if(sn(m)){p([...O,m],null,f(x,!1,!0,"unscoped"),"unscoped",x.$description);return}if(an(m)){d(m,x,O);return}let C=$o(m,r),q=C===null?m:`@media ${C}`,S=C===null?null:Ue(C);if(S!==null&&E!==null){let{auto:y,forced:w}=Hr(E,S);g(x,y,[...O,q],J),g(ml(x),w,O,J);return}g(x,E,[...O,q],J)};function g(m,x,E,O){p(E,x,f(m,!0,!0,O),O,m.$description);for(let[J,C]of Object.entries(m))for(let q of l(J,C))if(J.startsWith("@"))h(J,q,x,E,O);else if(x!==null)g(q,So(x,J),E,gl(J)?O:"descendant")}return g(e,n,[],"self"),c}var ul,Te="data-color-scheme",Pn="jx-color-scheme";var ln=v(()=>{K();ul=new Set(["all","print","screen","speech"])});function Qu(){return`the Intl helpers ${qr.join(", ")}`}var De="en-US",Ur="UTC",wo,qr,Eo;var Jo=v(()=>{wo=[{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."}],qr=wo.map((e)=>e.path),Eo=Object.fromEntries(wo.map((e)=>[e.path,e.params.indexOf("locale")]))});function hl(e){return e.replaceAll("~1","/").replaceAll("~0","~")}function re(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function qe(e){if(e==="")return[];return e.split("/").map((t)=>hl(t))}function oe(e,t){let n=e;for(let r of qe(t))n=n?.[r];return n}function P(e,t){let n=e;for(let r of qe(t))n+=zr.test(r)?`.${r}`:`[${JSON.stringify(r)}]`;return n}function No(e,t){let n=e;for(let[r,s]of qe(t).entries()){let o=r===0?"":"?.";n+=zr.test(s)?`${r===0?".":o}${s}`:`${o}[${JSON.stringify(s)}]`}return n}function ze(e){return zr.test(e)?e:JSON.stringify(e)}function Ao(e){let t=e.replaceAll(/[^A-Za-z0-9_$]/g,"_");if(t==="")return"ref";return/^\d/.test(t)?`_${t}`:t}var zr;var jt=v(()=>{zr=/^[A-Za-z_$][A-Za-z0-9_$]*$/});function Kr(e){let t=e.$map;return A(t)?t:void 0}function To(e){return A(e)&&!Array.isArray(e)&&"operator"in e}function cn(e){return A(e)&&!Array.isArray(e)&&"$ref"in e}function Sl(e,t,n){let r=Eo[e];if(r===void 0||r<0||t[r]!=null)return t;let s=oe(n.$page,"locale");if(!b(s)||s==="")return t;let o=[...t];return o[r]=s,o}function ko(e){return e.startsWith("window#/")&&yl.has(e.slice(8))}function Ke(e){return jo.has(e)}function G(e,t){if(!e)return;let n=(e.depth??0)+1;if(n>bl)return;return{depth:n,path:[...e.path??[],...Array.isArray(t)?t:[t]],report:e.report}}function z(e,t,n,r,s){if(e===null||e===void 0)return e;if(To(e))return be(e,t,n,r,s);if(cn(e)){let o=In(e.$ref,t,n,r);return s?.report(s.path??[],o),o}if(Array.isArray(e))return Po(e,t,n,r,s);return s?.report(s.path??[],e),e}function Po(e,t,n,r,s){return e.map((o,i)=>z(o,t,n,r,G(s,i)))}function wl(e,t,n,r){let s=(o)=>{if(!e.slice(o.length).includes("/"))return t;return In(e.slice(0,e.lastIndexOf("/")),t,n,r)};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?In(e.slice(0,e.lastIndexOf("/")),t,n,r):void 0;return}function In(e,t,n,r){if(e==="$reduce/acc")return r?.acc;if(e.startsWith("$reduce/"))return r?.acc;if(e.startsWith("$args/")){let s=e.slice(6).split("/"),o=r?.args?.[s[0]];return s.length>1?oe(o,s.slice(1).join("/")):o}if(e.startsWith("event#/")){let s=e.slice(7);return oe(n,s)}if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s,i,c=Kr(t);if(o==="item")i=r?.item??c?.item??t["$map/item"];else if(o==="index")i=r?.index??c?.index??t["$map/index"];else i=c?.[o]??t[`$map/${o}`];return s.length>2?oe(i,s.slice(2).join("/")):i}if(e.startsWith("#/state/"))return oe(t,e.slice(8));if(e.startsWith("parent#/"))return oe(t,e.slice(8));if(e.startsWith("window#/"))return oe(globalThis.window,e.slice(8));if(e.startsWith("document#/"))return oe(globalThis.document,e.slice(10));return oe(t,e)??null}function El(e,t,n,r){if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s,i,c=Kr(t);if(o==="item")i=r?.item??c?.item??t["$map/item"];else if(o==="index")i=r?.index??c?.index??t["$map/index"];else i=c?.[o]??t[`$map/${o}`];if(s.length>2){let a=s.slice(2),l=a.pop(),u=a.length>0?oe(i,a.join("/")):i;return{key:l,obj:u}}return{key:o==="item"?"$map/item":"$map/index",obj:Kr(t)??t}}if(e.startsWith("#/state/")){let s=e.slice(8);if(s.indexOf("/")===-1)return{key:s,obj:t};let i=qe(s),c=i.pop(),a=t;for(let l of i)a=a[l];return{key:c,obj:a}}return{key:e,obj:t}}function be(e,t,n,r,s){let o=Jl(e,t,n,r,s);return s?.report(s.path??[],o),o}function Co(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n;case"%":return t%n;case"<":return t<n;case"<=":return t<=n;case">":return t>n;default:return t>=n}}function Jl(e,t,n,r,s){let{operator:o,target:i,value:c,initial:a}=e;if(!xl.has(o))throw Error(`$expression: unknown operator "${o}"`);if(Gr.has(o)&&!("value"in e)){let l=z(i,t,n,r,G(s,"target"));if(o==="!")return!l;if(o==="-")return-l}if(o==="call"){let l=cn(i)?i.$ref:void 0;if(!b(l))throw TypeError("$expression: call target must be a $ref pointer");let u=(r?.callDepth??0)+1;if(u>Oo)throw Error(`$expression: call depth exceeded (${Oo})`);let f=Array.isArray(c)?c.map((d,h)=>z(d,t,n,r,G(s,["value",h]))):[];if(l.startsWith("window#/")){if(!ko(l))throw Error(`$expression: "${l}" is not a blessed pure global`);let d=l.slice(8),h=$l.get(d);if(h)return h(...Sl(d,f,t));let g=oe(globalThis.window,d),m=d.lastIndexOf("/"),x=m===-1?globalThis.window:oe(globalThis.window,d.slice(0,m));return g.apply(x,f)}let p=In(l,t,n,r);if(ye(p))return p.apply(wl(l,t,n,r),f);if(A(p)&&"$expression"in p){let d=p,h={};for(let[g,m]of(d.parameters??[]).entries()){let x=b(m)?m:m?.name??"";if(!x)continue;h[x]=f[g]===void 0&&A(m)&&"default"in m?m.default:f[g]}return be(d.$expression,t,n,{args:h,callDepth:u})}throw TypeError(`$expression: call target "${l}" is not callable`)}if(Zr.has(o)){if(o==="?:"){let d=z(i,t,n,r,G(s,"target"));if(s){let h=z(c,t,n,r,G(s,"value")),g=z(a,t,n,r,G(s,"initial"));return d?h:g}return d?z(c,t,n,r):z(a,t,n,r)}let l=z(i,t,n,r,G(s,"target")),u=String(l),f=e.cases??{},p=Object.hasOwn(f,u);if(s){let d;for(let[g,m]of Object.entries(f)){let x=z(m,t,n,r,G(s,["cases",g]));if(g===u)d=x}let h=z(e.default,t,n,r,G(s,"default"));return p?d:h}return p?z(f[u],t,n,r):z(e.default,t,n,r)}if(Yr.has(o)){let l=z(i,t,n,r,G(s,"target")),u=z(c,t,n,r,G(s,"value"));switch(o){case"===":return l===u;case"!==":return l!==u;case"&&":return l&&u;case"||":return l||u;case"??":return l??u;default:return Co(o,l,u)}}if(Ro.has(o)){let l=z(c,t,n,r,G(s,"value")),{obj:u,key:f}=El(i.$ref,t,n,r);u[f]=o==="="?l:Co(o.slice(0,-1),u[f],l);return}if(_o.has(o)){let l=z(i,t,n,r,G(s,"target"));switch(o){case"push":return l.push(z(c,t,n,r,G(s,"value")));case"unshift":return l.unshift(z(c,t,n,r,G(s,"value")));case"pop":return l.pop();case"shift":return l.shift();case"splice":{let u=z(c,t,n,r,G(s,"value"));return l.splice(...u)}default:break}}if(Qr.has(o)){let l=z(i,t,n,r,G(s,"target")),u=c===void 0?[]:Array.isArray(c)?Po(c,t,n,r,G(s,"value")):[z(c,t,n,r,G(s,"value"))],f=oe(l,o);if(!ye(f))return;return f.apply(l,u)}if(Xr.has(o)){let l=z(i,t,n,r,G(s,"target")),u=c;if(o==="reduce"){let f=z(a,t,n,r,G(s,"initial"));for(let[p,d]of l.entries())f=be(u,t,n,{acc:f,index:p,item:d},p===0?G(s,"value"):void 0);return f}if(o==="map")return l.map((f,p)=>be(u,t,n,{...r,index:p,item:f},p===0?G(s,"value"):void 0));if(o==="filter")return l.filter((f,p)=>be(u,t,n,{...r,index:p,item:f},p===0?G(s,"value"):void 0))}return}function Y(e,t){if(e===null)return"null";if(e===void 0)return"undefined";if(To(e))return le(e,t);if(cn(e))return es(e.$ref,t);if(Array.isArray(e))return e.map((n)=>Y(n,t)).join(", ");return JSON.stringify(e)}function Nl(e){return`_fx_${e.replaceAll(/[^A-Za-z0-9_$]/g,"_")}`}function es(e,t){let n=t.statePrefix??"state",r=t.eventParam??"event";if(e==="$reduce/acc")return"_acc";if(e.startsWith("$reduce/"))return"_acc";if(e.startsWith("$args/"))return P("_args",e.slice(6));if(e.startsWith("event#/"))return P(r,e.slice(7));if(e.startsWith("$map/")){let s=e.split("/"),[,o]=s;if(o==="item")return s.length>2?P("_item",s.slice(2).join("/")):"_item";if(o==="index")return"_index";return`_${o}`}if(e.startsWith("#/state/"))return P(n,e.slice(8));if(e.startsWith("parent#/"))return P(n,e.slice(8));if(e.startsWith("window#/"))return P("window",e.slice(8));if(e.startsWith("document#/"))return P("document",e.slice(10));return P(n,e)}function vo(e,t){if(cn(e))return es(e.$ref,t);return Y(e,t)}function Al(e,t,n){let r=(i)=>t[i]??"undefined",s=`(${n.statePrefix??"state"}?.$page?.locale ?? ${JSON.stringify(De)})`,o=JSON.stringify(Ur);switch(e){case"Intl/formatNumber":return`new Intl.NumberFormat(${r(1)} ?? ${s}, ${r(2)}).format(${r(0)})`;case"Intl/formatDate":return`new Intl.DateTimeFormat(${r(1)} ?? ${s}, {timeZone: ${o}, ...${r(2)}}).format(new Date(${r(0)}))`;case"Intl/formatRelativeTime":return`new Intl.RelativeTimeFormat(${r(2)} ?? ${s}, ${r(3)}).format(${r(0)}, ${r(1)})`;case"Intl/formatList":return`new Intl.ListFormat(${r(1)} ?? ${s}, ${r(2)}).format(${r(0)})`;case"Intl/plural":return`new Intl.PluralRules(${r(1)} ?? ${s}, ${r(2)}).select(${r(0)})`;case"Intl/compare":return`new Intl.Collator(${r(2)} ?? ${s}, ${r(3)}).compare(${r(0)}, ${r(1)})`;case"Intl/displayName":return`new Intl.DisplayNames(${r(2)} ?? ${s}, {...${r(3)}, type: ${r(1)} ?? 'language'}).of(${r(0)})`;case"Intl/segment":return`[...new Intl.Segmenter(${r(2)} ?? ${s}, {granularity: ${r(1)} ?? 'grapheme'}).segment(${r(0)})].map((p) => p.segment)`;default:return null}}function le(e,t={}){let{operator:n,target:r,value:s,initial:o}=e;if(Gr.has(n)&&!("value"in e)){let i=Y(r,t);if(n==="!")return`!(${i})`;if(n==="-")return`-(${i})`}if(n==="call"){let i=(cn(r)?r.$ref:void 0)??"",c=Array.isArray(s)?s.map((a)=>Y(a,t)):[];if(i.startsWith("window#/")){if(!ko(i))throw Error(`$expression: "${i}" is not a blessed pure global`);let a=Al(i.slice(8),c,t);if(a)return a;return`window.${i.slice(8).replaceAll("/",".")}(${c.join(", ")})`}if(i.startsWith("#/state/")){let a=i.slice(8),l=t.formulaParams?.[a];if(l){let u=l.map((f,p)=>`${JSON.stringify(f)}: ${c[p]??"undefined"}`).join(", ");return`${Nl(a)}(${t.statePrefix??"state"}, { ${u} })`}}return`${es(i,t)}(${c.join(", ")})`}if(Zr.has(n)){if(n==="?:"){let l=Y(r,t),u=Y(s,t),f=Y(o,t);return`(${l} ? ${u} : ${f})`}let i=Y(r,t),c=Object.entries(e.cases??{}).map(([l,u])=>`_d === ${JSON.stringify(l)} ? ${Y(u,t)} : `).join(""),a="default"in e?Y(e.default,t):"undefined";return`((_d) => ${c}${a})(String(${i}))`}if(Yr.has(n)){let i=Y(r,t),c=Y(s,t);return`(${i} ${n} ${c})`}if(Ro.has(n)){let i=vo(r,t),c=Y(s,t);return`${i} ${n} ${c}`}if(_o.has(n)){let i=vo(r,t);switch(n){case"push":return`${i}.push(${Y(s,t)})`;case"unshift":return`${i}.unshift(${Y(s,t)})`;case"pop":return`${i}.pop()`;case"shift":return`${i}.shift()`;case"splice":{let c=Array.isArray(s)?s.map((a)=>Y(a,t)).join(", "):Y(s,t);return`${i}.splice(${c})`}default:break}}if(Qr.has(n)){let i=Y(r,t),c=s===void 0?"":Array.isArray(s)?s.map((a)=>Y(a,t)).join(", "):Y(s,t);return`(${i})?.${n}?.(${c})`}if(Xr.has(n)){let i=Y(r,t),c=le(s,t);if(n==="reduce"){let a=Y(o,t);return`${i}.reduce((_acc, _item, _index) => ${c}, ${a})`}if(n==="map")return`${i}.map((_item, _index) => ${c})`;if(n==="filter")return`${i}.filter((_item, _index) => ${c})`}return"undefined"}function Rt(e,t,n,r){return z(e,t,n,r)}function Ge(e,t={}){return Y(e,t)}var jo,Gr,Yr,Ro,_o,Xr,Zr,Qr,xl,yl,$l,Oo=64,bl=64;var un=v(()=>{Jo();K();jt();jo=new Set(["=","+=","-=","*=","/=","push","pop","shift","unshift","splice"]),Gr=new Set(["!","-"]),Yr=new Set(["+","-","*","/","%","===","!==","<","<=",">",">=","&&","||","??"]),Ro=new Set(["=","+=","-=","*=","/="]),_o=new Set(["push","pop","shift","unshift","splice"]),Xr=new Set(["reduce","map","filter"]),Zr=new Set(["?:","switch"]),Qr=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"]),xl=new Set([...jo,...Gr,...Yr,...Xr,...Zr,...Qr,"call"]),yl=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",...qr]),$l=new Map([["Intl/compare",(e,t,n,r)=>new Intl.Collator(n??De,r).compare(e,t)],["Intl/displayName",(e,t,n,r)=>new Intl.DisplayNames(n??De,{...r,type:t??"language"}).of(e)],["Intl/formatDate",(e,t,n)=>new Intl.DateTimeFormat(t??De,{timeZone:Ur,...n}).format(new Date(e))],["Intl/formatList",(e,t,n)=>new Intl.ListFormat(t??De,n).format(e)],["Intl/formatNumber",(e,t,n)=>new Intl.NumberFormat(t??De,n).format(e)],["Intl/formatRelativeTime",(e,t,n,r)=>new Intl.RelativeTimeFormat(n??De,r).format(e,t)],["Intl/plural",(e,t,n)=>new Intl.PluralRules(t??De,n).select(e)],["Intl/segment",(e,t,n)=>[...new Intl.Segmenter(n??De,{granularity:t??"grapheme"}).segment(e)].map((r)=>r.segment)]])});function Ol(e){return e.startsWith(Io)}function lf(e){let t=e;if(Ol(t))t=t.slice(Io.length);return t=t.replace(/^\.\//,"").replace(/\.(js|ts|mjs|mts)$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,""),`${ts}${t}.js`}function cf(e){let t=/\.(\w+)$/.exec(e)?.[1]??"",n=e.replace(/\.\w+$/,"").replaceAll("@","").replaceAll(/[/\\]+/g,"-").replaceAll(/[^\w.-]/g,"-").replaceAll(/-+/g,"-").replaceAll(/^-|-$/g,"");return t===""?`${ts}${n}`:`${ts}${n}.${t}`}function Do(e){let t=e.replaceAll("\\","/");return t.length>1&&t.endsWith("/")?t.slice(0,-1):t}function Mo(e){let t=Do(e);return t.startsWith("/")?t:`/${t}`}function Cl(e,t){return[...e].toSorted((n,r)=>r[t].length-n[t].length)}function uf(e,t){let n=t.split("#")[0].split("?")[0];if(!n.startsWith("/"))return null;let r;try{r=decodeURIComponent(n)}catch{return null}if(/%2e|%2f/i.test(r))return null;for(let s of Cl(e,"urlPrefix")){let o=Mo(s.urlPrefix);if(!r.startsWith(`${o}/`))continue;let c=r.slice(o.length+1).split("/");if(c.some((l)=>l===""||l==="."||l===".."))return null;let{filter:a}=s;if(a&&!a(c.join("/")))return null;return`${Do(s.dir)}/${c.join("/")}`}return null}function ff(e,t){let n=new Set;for(let r of t){let s=Mo(r.urlPrefix),o=new RegExp(`${s.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}/[^${vl}]+`,"g");for(let i of e.matchAll(o)){let c=i[0].split("#")[0].split("?")[0];if(!c.endsWith("/"))n.add(c)}}return[...n].filter(Boolean)}function Tl(e){let t=[],n=0;while(n<e.length){while(n<e.length&&(/\s/.test(e[n])||e[n]===","))n+=1;if(n>=e.length)break;let r=n;while(n<e.length&&!/\s/.test(e[n]))n+=1;let s=e.slice(r,n);if(s.endsWith(",")){t.push({descriptor:"",url:s.replace(/,+$/,"")});continue}while(n<e.length&&/\s/.test(e[n]))n+=1;let o=n;while(n<e.length&&e[n]!==",")n+=1;let i=e.slice(o,n).trim();if(n+=1,s=s.replace(/,+$/,""),s!=="")t.push({descriptor:i,url:s})}return t}function jl(e){return e.map(({url:t,descriptor:n})=>n?`${t} ${n}`:t).join(", ")}function pf(e){if(!b(e)||e==="")return"";let t;try{({pathname:t}=new URL(e))}catch{return""}let n=t.replace(/\/+$/,"");if(n===""||n==="/")return"";return n.startsWith("/")?n:`/${n}`}function Lo(e,t){if(e===""||!t.startsWith("/")||t.startsWith("//"))return t;if(t===e||t.startsWith(`${e}/`))return t;return e+t}function df(e,t){let n=new URL(t);if(!n.pathname.endsWith("/"))n.pathname+="/";return new URL(e.replace(/^\/+/,""),n).href}var Io="npm:",ts="/assets/",vl;var ns=v(()=>{K();vl=String.raw`"'\s<>()\\`});function Fo(e){if("operator"in e)return{kind:"expression",node:e};if("if"in e)return{kind:"if",node:e};if("$switch"in e)return{kind:"switch",node:e};if("stopPropagation"in e)return{kind:"stopPropagation"};if("preventDefault"in e)return{kind:"preventDefault"};return{kind:"dispatch",node:e}}function Rl(e){return(A(e)||ye(e))&&"then"in e&&ye(e.then)}async function _t(e,t,n,r={}){let s=r.args?{args:r.args}:void 0;for(let o of e){let i=Fo(o);switch(i.kind){case"expression":{let c=be(i.node,t,n,s);if(Rl(c))await c;break}case"if":{let c=i.node,a=Rt(c.if,t,n,s)?c.then:c.else;if(Array.isArray(a))await _t(a,t,n,r);break}case"switch":{let c=i.node,a=String(Rt(c.$switch,t,n,s)),l=c.cases??{},u=Object.hasOwn(l,a)?l[a]:c.default;if(Array.isArray(u))await _t(u,t,n,r);break}case"dispatch":{let c=i.node,a=ye(r.target)?r.target():r.target,l=n?.currentTarget??a;if(!l)break;let u={};if("detail"in c)u.detail=Rt(c.detail,t,n,s);if(c.bubbles!==void 0)u.bubbles=c.bubbles;if(c.composed!==void 0)u.composed=c.composed;l.dispatchEvent(new CustomEvent(c.dispatchEvent,u));break}case"stopPropagation":{n?.stopPropagation();break}case"preventDefault":{n?.preventDefault();break}default:break}}}function Ne(e,t={}){let n=t.indent??"",r=[];for(let s of e){let o=Fo(s);switch(o.kind){case"expression":{r.push(`${n}${le(o.node,t)};`);break}case"if":{let i=o.node,c=Ge(i.if,t),a={...t,indent:`${n} `};if(r.push(`${n}if (${c}) {`,Ne(i.then??[],a)),i.else)r.push(`${n}} else {`,Ne(i.else,a));r.push(`${n}}`);break}case"switch":{let i=o.node,c=Ge(i.$switch,t),a={...t,indent:`${n} `};r.push(`${n}switch (String(${c})) {`);for(let[l,u]of Object.entries(i.cases??{}))r.push(`${n} case ${JSON.stringify(l)}: {`,Ne(u,a),`${n} break;`,`${n} }`);if(i.default)r.push(`${n} default: {`,Ne(i.default,a),`${n} }`);r.push(`${n}}`);break}case"dispatch":{let i=o.node,c=t.eventParam??"event",a=t.dispatchTarget??`(${c} && ${c}.currentTarget)`,l=[];if("detail"in i)l.push(`detail: ${Ge(i.detail,t)}`);if(i.bubbles!==void 0)l.push(`bubbles: ${JSON.stringify(i.bubbles)}`);if(i.composed!==void 0)l.push(`composed: ${JSON.stringify(i.composed)}`);let u=l.length>0?`, { ${l.join(", ")} }`:"";r.push(`${n}${a}?.dispatchEvent(new CustomEvent(${JSON.stringify(i.dispatchEvent)}${u}));`);break}case"stopPropagation":{r.push(`${n}${t.eventParam??"event"}?.stopPropagation();`);break}case"preventDefault":{r.push(`${n}${t.eventParam??"event"}?.preventDefault();`);break}default:break}}return r.join(`
2
+ `)}var Dn=v(()=>{K();un()});function Mn(e){if(!e.startsWith("${")||!e.endsWith("}"))return!1;let t=0;for(let n=1;n<e.length;n+=1){let r=e[n];if(r==="{")t+=1;else if(r==="}"){if(t-=1,t===0)return n===e.length-1}}return!1}function Vo(){return[...Wo].toSorted()}function xt(e,t){let n=e.toLowerCase();if(n.startsWith("aria-")||Wo.has(n))return String(t);return t?"":null}var Ye,Wo,rs=32,Ln,Fn="jx-slot",ss="data-jx-slots",os="jx.slot.group",Tf;var fn=v(()=>{ln();un();jt();K();ns();Dn();ln();Ye=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"]),Wo=new Set(["contenteditable","draggable","spellcheck"]);Ln=/^[\t\n\f\r ]+$/u,Tf=(()=>{let e=Symbol.for(os),t=globalThis;return t[e]??=new WeakMap,t[e]})()});function Ho(e,t,n,r,s=kl){let o=[],i=(f,p)=>{let d={mediaQueries:t,scope:p,transposeValue:n};if(r)d.resolveValue=(h,g)=>r(h,g,p);for(let h of Tt(f,d))o.push(h.text)},c={},a={},l=[],u=[];for(let[f,p]of Object.entries(e)){if(A(p)&&!Array.isArray(p)){if(f.startsWith("@"))l.push([f,p]);else if(!f.startsWith("--"))u.push([f,p]);continue}if(ot(f)||f.startsWith("@"))continue;if(f.startsWith("--")||f==="colorScheme"||f==="color-scheme")c[f]=p;else a[f]=p}i(c,s.root),i(a,s.body);for(let[f,p]of u)if(f.startsWith("&"))i({[f]:p},s.root);else i(p,f);for(let[f,p]of l){if(sn(f)||an(f)){i({[f]:p},null);continue}let d={},h={},g=[];for(let[m,x]of Object.entries(p)){if(A(x)&&!Array.isArray(x)){if(!m.startsWith("@"))g.push([m,x]);continue}if(m.startsWith("--"))d[m]=x;else h[m]=x}i({[f]:d},s.root),i({[f]:h},s.body);for(let[m,x]of g)i({[f]:x},m)}if(Object.values(t).some((f)=>Ue(f)!==null)&&!("colorScheme"in e))o.push(`${s.root} { color-scheme: light dark }`,`${s.root}:where([${Te}="light"]) { color-scheme: light }`,`${s.root}:where([${Te}="dark"]) { color-scheme: dark }`);return o.join(`
3
+ `)}var kl;var Bo=v(()=>{ln();K();kl={body:"body",root:":root"}});function Uo(e){return e===!1||e==="open"||e==="closed"}function Wn(e,t){let n=e?.$shadow;if(Uo(n))return n===!1?null:n;let r=t?.shadow;return Uo(r)&&r!==!1?r:null}function qo(e,t){return t===null?e:":host"}function dn(e,t){let n=[];for(let[r,s]of(e.parameters??[]).entries()){let o=zo(s);if(!o)continue;let i=Ko(s)?`_a[${r}] === undefined ? ${JSON.stringify(s.default)} : _a[${r}]`:`_a[${r}]`;n.push(`${JSON.stringify(o)}: ${i}`)}return`(..._a) => { const _args = { ${n.join(", ")} }; return ${t}; }`}function zo(e){return b(e)?e:e?.name??""}function Ko(e){return A(e)&&"default"in e}function Un(e,t){let n=fs(e,t);return n===e?e:`${n} as ${e}`}function fs(e,t){let n=t?.$export;return b(n)&&n!==""?n:e}function qn(e,t,n={}){let{statePrefix:r="state",indent:s="",collect:o}=n,{url:i}=t,c=L(i),a=t.method??"GET";if(t.manual)return`${s}// ${e}: manual Request — fetch triggered by user action`;let l=[`// ${e}: auto-fetch from ${c?"(dynamic URL)":i}`,o?`${o}.push(effect(() => {`:"effect(() => {"];if(c)l.push(` const url = \`${Il(i,r)}\`;`,' if (!url || url === "undefined" || url.includes("undefined")) return;');else l.push(` const url = ${JSON.stringify(i)};`);let u=[];if(a!=="GET")u.push(`method: ${JSON.stringify(a)}`);if(t.headers)u.push(`headers: ${JSON.stringify(t.headers)}`);if(t.body){let p=A(t.body)?JSON.stringify(JSON.stringify(t.body)):JSON.stringify(t.body);u.push(`body: ${p}`)}let f=u.length>0?`, { ${u.join(", ")} }`:"";return l.push(` fetch(url${f})`," .then(r => r.ok ? r.json() : Promise.reject(r.statusText))",` .then(d => { ${r}.${e} = d; })`,` .catch(e => { ${r}.${e} = { error: String(e) }; });`,o?"}));":"});"),l.map((p)=>`${s}${p}`).join(`
4
+ `)}function zn(e,t,n={}){let{statePrefix:r="state",indent:s="",collect:o,serverBaseUrl:i="/_jx/server"}=n,c=JSON.stringify(`${i}/${t.$export}`),a=Object.entries(t.arguments??{}),l=a.map(([g,m])=>{if(!H(m))return`${ze(g)}: ${JSON.stringify(m)}`;if(Pl.some((x)=>m.$ref.startsWith(x)))throw Error(`Server function "${e}": argument "${g}" references "${m.$ref}", which a state entry cannot read. Use a #/state/, parent#/, window#/ or document#/ reference.`);return`${ze(g)}: ${Ge({$ref:m.$ref},{statePrefix:r})}`}),u=a.some(([,g])=>H(g)),f=`${ti}(${c}, ${l.length>0?`{ ${l.join(", ")} }`:"{}"})`,p=P(r,re(e)),d=`console.error(${JSON.stringify(`Jx server function ${t.$export}:`)}, e)`;return(u?[`// ${e}: server function ${t.$export}, called again when an argument changes`,"{"," let _jxSeq = 0;",o?` ${o}.push(effect(() => {`:" effect(() => {"," const _seq = ++_jxSeq;",` ${f}`,` .then((d) => { if (_seq === _jxSeq) ${p} = d; })`,` .catch((e) => { if (_seq === _jxSeq) ${d}; });`,o?" }));":" });","}"]:[`// ${e}: server function ${t.$export}, called once`,f,` .then((d) => { ${p} = d; })`,` .catch((e) => { ${d}; });`]).map((g)=>`${s}${g}`).join(`
5
+ `)}function Il(e,t){if(t==="state")return e;return e.replaceAll(/\$\{([^}]*)\}/g,(n,r)=>`\${${r.replaceAll(/(?<!this\.)\bstate\./g,`${t}.`)}}`)}function Yn(e){if(!A(e))return!1;if(e.state)for(let[t,n]of Object.entries(e.state)){if(t==="$site"||t==="$page")continue;if(!A(n)||Array.isArray(n))return!0;if(n.timing==="compiler")continue;if(n.$prototype)return!0;if("default"in n)return!0;if(st(n))continue;return!0}if(e.$switch)return!0;if(ne(e)||Wr(e.children))return!0;if(Array.isArray(e.children)&&e.children.some((t)=>Yn(t)))return!0;for(let[t,n]of Object.entries(e)){if(Ye.has(t))continue;if(H(n))return!0;if(L(n))return!0}if(A(e.style)){for(let t of Object.values(e.style))if(L(t))return!0}if(A(e.attributes)){for(let t of Object.values(e.attributes))if(L(t))return!0}return!1}function Yo(e){if(!A(e))return!1;if(e.$switch)return!0;if(ne(e)||Wr(e.children))return!0;for(let[t,n]of Object.entries(e)){if(Ye.has(t))continue;if(H(n))return!0;if(L(n))return!0}if(A(e.style)){for(let t of Object.values(e.style))if(L(t))return!0}if(A(e.attributes)){for(let t of Object.values(e.attributes))if(L(t))return!0}return!1}function It(e,t=null,n={},r={}){let s=e?.state?cs(e.state,t):t??Xo();return{media:r,scope:s,scopeDefs:n}}function Xo(e=null){return Object.create(e)}function Zo(e){return e[Go]}function ls(e,t){if(b(e)){for(let o of e.matchAll(Dl))t.add(o[1]);for(let o of e.matchAll(Ml))t.add(o[1]);return}if(Array.isArray(e)){for(let o of e)ls(o,t);return}if(!A(e))return;let n=e,{operator:r,target:s}=n;if(b(r)&&Ke(r)&&H(s)&&s.$ref.startsWith("#/state/"))t.add(s.$ref.slice(8).split("/")[0]);for(let o of Object.values(n))ls(o,t)}function cs(e={},t=null){let n=Xo(t),r=t?Zo(t):void 0,s=new Set(r);Object.defineProperty(n,Go,{configurable:!0,enumerable:!1,value:s,writable:!0});let o=new Set;for(let l of Object.values(e))if($e(l)||Se(l))ls(l.body??l.$expression,o);for(let l of o)if(l in e)s.add(l);for(let[l,u]of Object.entries(e)){if(!A(u)||Array.isArray(u)){Xe(n,l,Vn(u));continue}if("default"in u){Xe(n,l,Vn(u.default));continue}if(He(u)){s.add(l);continue}if(!u.$prototype&&!("$expression"in u)&&!st(u))Xe(n,l,Vn(u))}let i=[],c=[];for(let[l,u]of Object.entries(e)){if(L(u)){i.push([l,u]);continue}if(!A(u))continue;if(Se(u)){let f=u.$expression;if(gt(u)){let p=u.parameters;Xe(n,l,(...d)=>{let h={};for(let[g,m]of p.entries()){let x=zo(m);if(!x)continue;h[x]=d[g]===void 0&&Ko(m)?m.default:d[g]}return be(f,n,null,{args:h})})}else if(Ke(f.operator))Xe(n,l,(p,d)=>be(f,p,d));else is(n,l,()=>be(f,n,null));continue}if($e(u)){if(nt(u)){let{body:f}=u;Xe(n,l,(p,d)=>{_t(f,p??n,d??null)})}else if(b(u.body)){let f=u.parameters?Be(u.parameters):u.arguments??[],{body:p}=u,d=f.includes("state")?f:["state",...f],h=Function(...d,p),g=(m,x)=>h(...d.map((E)=>E==="state"?m:x));if(ht(p))is(n,l,()=>g(n)),c.push([l,p]);else Xe(n,l,g)}else Xe(n,l,()=>{}),s.add(l);continue}if(rt(u)&&(u.$prototype==="LocalStorage"||u.$prototype==="SessionStorage")){Xe(n,l,Vn(u.default??null));continue}if(rt(u)&&u.$prototype==="Request")s.add(l)}let a=!0;while(a){a=!1;for(let[l,u]of[...c,...i])if(!s.has(l)&&Qo(u,n))s.add(l),a=!0}for(let[l,u]of i)is(n,l,()=>ps(u,n));return n}function Xe(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0})}function is(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:n})}function B(e,t){if(H(e))return Ll(e.$ref,t);if(L(e))return ps(e,t);return e}function me(e){return H(e)}function Ll(e,t){if(!b(e))return e;if(e.startsWith("$map/")){let n=e.split("/"),r=n[1],o=t.$map?.[r]??t[`$map/${r}`];return n.length>2?as(o,n.slice(2).join("/")):o}if(e.startsWith("#/state/"))return as(t,e.slice(8));return as(t,e)??null}function Qo(e,t){if(!t)return!1;let n=Zo(t);for(let r of e.matchAll(/\bstate\.([A-Za-z_$][\w$]*)\s*(\()?/g)){if(r[2])continue;let s=r[1];if(n?.has(s))return!0;let o;try{o=t[s]}catch{continue}if(ye(o))return!0}return!1}function Xn(e){return Mn(e)?`(${e.slice(2,-1)})`:`\`${e}\``}function ps(e,t){if(Qo(e,t))return null;let n=["state","$map","$site","$page"],r=[t,t?.$map,t?.$site,t?.$page];try{let s=Mn(e)?`return (${e.slice(2,-1)})`:`return \`${e}\``;return Function(...n,s)(...r)}catch{return null}}function as(e,t){return oe(e,t)}function Vn(e){if(!A(e))return e;return structuredClone(e)}function Fl(e,t){if(!e||!t)return"";return Object.entries(e).filter(([n,r])=>!n.startsWith(":")&&!n.startsWith(".")&&!n.startsWith("&")&&!n.startsWith("[")&&!n.startsWith("@")&&L(r)).map(([n,r])=>{let s=B(r,t);return s==null?null:`${de(n)}: ${s}`}).filter(Boolean).join("; ")}function yt(e,t,n=""){let r="",s=B(e.id,t),o=B(e.className,t),i=B(e.hidden,t),c=B(e.tabIndex,t),a=B(e.title,t),l=B(e.lang,t),u=B(e.dir,t);if(s)r+=` id="${_(String(s))}"`;if(o)r+=` class="${_(String(o))}"`;if(i)r+=" hidden";if(c!==void 0&&c!==null)r+=` tabindex="${_(String(c))}"`;if(a)r+=` title="${_(String(a))}"`;if(l)r+=` lang="${_(String(l))}"`;if(u)r+=` dir="${_(String(u))}"`;let f=[Fl(e.style,t),n].filter(Boolean).join("; ");if(f)r+=` style="${_(f)}"`;if(e.attributes)for(let[p,d]of Object.entries(e.attributes)){let h=B(d,t);if(pe(h)){let g=xt(p,h);if(g!==null)r+=g===""?` ${p}`:` ${p}="${_(g)}"`;continue}if(b(h)||se(h))r+=` ${p}="${_(String(h))}"`}if(e.$static)r+=" data-jx-static";else if(e.$prerendered)r+=" data-jx-prerendered";return r}function mn(e,t=" "){return e?"":`
6
+ ${t}`}function Zn(){let e=JSON.stringify(Pn),t=JSON.stringify(Te);return`(function(){try{var s=localStorage.getItem(${e});if(s==="light"||s==="dark"){document.documentElement.setAttribute(${t},s)}}catch(e){}})()`}function Hn(e,t,n,r){for(let s of Tt(t,{mediaQueries:r,resolveValue:(o,i)=>ei(o,i,n),scope:n}))e.push(s.text)}function ei(e,t,n){let r=b(t)?t:t.$ref;return Wl.push({property:e,selector:n,source:r}),null}function Qn(){return`const __jxEnumAttrs = new Set(${JSON.stringify(Vo())});
7
+ function ${Dt}(n, v) {
8
8
  if (typeof v !== 'boolean') return v;
9
9
  const l = n.toLowerCase();
10
10
  if (l.startsWith('aria-') || __jxEnumAttrs.has(l)) return String(v);
11
11
  return v ? '' : null;
12
- }`}function bt(){return[`async function ${pr}(url, args) {`," const r = await fetch(url, {"," method: 'POST',"," headers: { 'Content-Type': 'application/json' },"," body: JSON.stringify(args),"," });"," const text = await r.text();"," let body = null;"," if (text !== '') {"," try { body = JSON.parse(text); } catch (e) { if (r.ok) throw e; }"," }"," if (!r.ok) throw new Error((body && body.error) || text || r.statusText);"," return body;","}"].join(`
13
- `)}function fr(){let e=`new RegExp(${JSON.stringify(it.source)}, ${JSON.stringify(it.flags)})`,t=`Symbol.for(${JSON.stringify(Gt)})`,n=JSON.stringify(Yt),r=JSON.stringify(at);return[`const __jxSlotWs = ${e};`,`const __jxSlotRec = globalThis[${t}] || (globalThis[${t}] = new WeakMap());`,`function ${sn}(host) {`,` const id = host.getAttribute(${n});`," if (id === null) return Array.from(host.childNodes);",` host.removeAttribute(${n});`,` const open = ${r} + ' ' + id + ' ';`,` const close = '/' + ${r} + ' ' + id;`," const openers = [];"," const w = host.ownerDocument.createTreeWalker(host, 128);"," for (let n = w.nextNode(); n; n = w.nextNode()) if (n.data.startsWith(open)) openers.push(n);"," const out = [];"," for (const o of openers) {"," const name = decodeURIComponent(o.data.slice(open.length));"," for (let n = o.nextSibling; n; n = n.nextSibling) {"," if (n.nodeType === 8 && n.data === close) break;"," __jxSlotRec.set(n, name);"," out.push(n);"," }"," }"," return out;","}",`function ${on}(host, captured) {`," const slots = Array.from(host.querySelectorAll('slot'));"," if (slots.length === 0) return;"," const groups = new Map();"," for (const n of captured) {"," if (n.nodeType === 3 && __jxSlotWs.test(n.data)) continue;"," const r = __jxSlotRec.get(n);"," __jxSlotRec.delete(n);"," const name = r !== undefined ? r : n.nodeType === 1 ? n.getAttribute('slot') || '' : '';"," let g = groups.get(name);"," if (!g) { g = []; groups.set(name, g); }"," g.push(n);"," }"," const taken = new Set();"," for (const slot of slots) {"," const name = slot.getAttribute('name') || '';"," let g = [];"," if (!taken.has(name)) { taken.add(name); g = groups.get(name) || []; }"," const content = g.some((n) => n.nodeType === 1 || (n.nodeType === 3 && n.data !== ''));"," const placed = content ? g : g.concat(Array.from(slot.childNodes));"," const p = slot.parentElement;"," if (p && p !== host && p.localName.includes('-')) {"," const r = __jxSlotRec.get(slot);"," const f = r !== undefined ? r : slot.getAttribute('slot') || '';"," for (const n of placed) __jxSlotRec.set(n, f);"," }"," slot.replaceWith(...placed);"," }","}"].join(`
14
- `)}function Pe(e){for(let t of an(e)){if(V(t)){if(t.map&&Pe([t.map]))return!0;continue}if(!Fe(t))continue;if(t.tagName==="slot")return!0;let n=Object.values(t.cases??{}).filter((r)=>Fe(r)&&!Y(r));if(Pe(n)||Pe(t.children))return!0}return!1}function an(e){if(V(e))return[e];if(!Array.isArray(e))return[];return e}function Me(e,t={},n=null){let r=[],s=Qn(C(n)?n:{},t,(i)=>i,ur);if(s!=="")r.push(s);if(Te(e,r,t,"",{n:0}),r.length===0)return"";return`<style>
15
- ${Bs(r.join(`
12
+ }`}function er(){return[`async function ${ti}(url, args) {`," const r = await fetch(url, {"," method: 'POST',"," headers: { 'Content-Type': 'application/json' },"," body: JSON.stringify(args),"," });"," const text = await r.text();"," let body = null;"," if (text !== '') {"," try { body = JSON.parse(text); } catch (e) { if (r.ok) throw e; }"," }"," if (!r.ok) throw new Error((body && body.error) || text || r.statusText);"," return body;","}"].join(`
13
+ `)}function ni(){let e=`new RegExp(${JSON.stringify(Ln.source)}, ${JSON.stringify(Ln.flags)})`,t=`Symbol.for(${JSON.stringify(os)})`,n=JSON.stringify(ss),r=JSON.stringify(Fn);return[`const __jxSlotWs = ${e};`,`const __jxSlotRec = globalThis[${t}] || (globalThis[${t}] = new WeakMap());`,`function ${ds}(host) {`,` const id = host.getAttribute(${n});`," if (id === null) return Array.from(host.childNodes);",` host.removeAttribute(${n});`,` const open = ${r} + ' ' + id + ' ';`,` const close = '/' + ${r} + ' ' + id;`," const openers = [];"," const w = host.ownerDocument.createTreeWalker(host, 128);"," for (let n = w.nextNode(); n; n = w.nextNode()) if (n.data.startsWith(open)) openers.push(n);"," const out = [];"," for (const o of openers) {"," const name = decodeURIComponent(o.data.slice(open.length));"," for (let n = o.nextSibling; n; n = n.nextSibling) {"," if (n.nodeType === 8 && n.data === close) break;"," __jxSlotRec.set(n, name);"," out.push(n);"," }"," }"," return out;","}",`function ${ms}(host, captured) {`," const slots = Array.from(host.querySelectorAll('slot'));"," if (slots.length === 0) return;"," const groups = new Map();"," for (const n of captured) {"," if (n.nodeType === 3 && __jxSlotWs.test(n.data)) continue;"," const r = __jxSlotRec.get(n);"," __jxSlotRec.delete(n);"," const name = r !== undefined ? r : n.nodeType === 1 ? n.getAttribute('slot') || '' : '';"," let g = groups.get(name);"," if (!g) { g = []; groups.set(name, g); }"," g.push(n);"," }"," const taken = new Set();"," for (const slot of slots) {"," const name = slot.getAttribute('name') || '';"," let g = [];"," if (!taken.has(name)) { taken.add(name); g = groups.get(name) || []; }"," const content = g.some((n) => n.nodeType === 1 || (n.nodeType === 3 && n.data !== ''));"," const placed = content ? g : g.concat(Array.from(slot.childNodes));"," const p = slot.parentElement;"," if (p && p !== host && p.localName.includes('-')) {"," const r = __jxSlotRec.get(slot);"," const f = r !== undefined ? r : slot.getAttribute('slot') || '';"," for (const n of placed) __jxSlotRec.set(n, f);"," }"," slot.replaceWith(...placed);"," }","}"].join(`
14
+ `)}function kt(e){for(let t of gs(e)){if(ne(t)){if(t.map&&kt([t.map]))return!0;continue}if(!rn(t))continue;if(t.tagName==="slot")return!0;let n=Object.values(t.cases??{}).filter((r)=>rn(r)&&!me(r));if(kt(n)||kt(t.children))return!0}return!1}function gs(e){if(ne(e))return[e];if(!Array.isArray(e))return[];return e}function Lt(e,t={},n=null){let r=[],s=Ho(A(n)?n:{},t,(i)=>i,ei);if(s!=="")r.push(s);if(Pt(e,r,t,"",{n:0}),r.length===0)return"";return`<style>
15
+ ${Vl(r.join(`
16
16
  `))}
17
- </style>`}function Bs(e){return e.replaceAll(/<\/(?=style)/gi,String.raw`<\/`)}function Te(e,t,n,r="",s,o="jx"){let i=s??{n:0};if(!C(e))return;if(e.style&&!e.id&&!e.className)e.className=`${o}-${i.n}`,i.n+=1;let u=Oe(e.tagName).join(", ")||"*",a=e.id?`#${e.id}`:e.className?`.${e.className.split(" ")[0]}`:u;if(e.style)ut(t,e.style,a,n);if(Array.isArray(e.children))for(let c of e.children)Te(c,t,n,a,i,o);if(C(e.cases))for(let c of Object.values(e.cases))Te(c,t,n,a,i,o)}function j(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function Jt(e){return e.split("-").map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}function Vi(e){let t=[];return mr(e,t),t}function mr(e,t){if(!C(e))return;if(e.state){for(let[n,r]of Object.entries(e.state))if(le(r))t.push({exportName:r.$export,key:n,src:r.$src})}if(Array.isArray(e.children))for(let n of e.children)mr(n,t)}function cn(e,t){if(J(e))return e;let n=Oe(e);if(n.length===0)return"div";if(!oe(e))return n[0];let r=e.$expression,s=r.target;if(r.operator==="?:")return T(s,t)?r.value:r.initial;let o=T(s,t);return r.cases[String(o)]??r.default}function Us(e){if(!e?.slotIds)return null;return e.slotIds.n+=1,e.slotIds.n}function qs(e,t,n,r=null){let s=new Map;for(let o of an(e)){let i="",u=!0,a;if(J(o)||ee(o)||K(o)){if(a=n(o),it.test(a))continue;u=a!==""}else if(V(o))a="";else if(!Fe(o))a=n(o),u=a!=="";else{let l=T(o.attributes?.slot,t),p=J(o.slot)?T(o.slot,t):null;if(J(l)&&l!=="")i=l,a=n(o);else if(J(p)&&p!==""){i=p;let{slot:g,...d}=o;a=n({...d,attributes:{...d.attributes,slot:p}})}else a=n(o)}let c=s.get(i);if(c)c.html=c.html===""?a:`${c.html}
18
- ${a}`,c.content||=u;else s.set(i,{content:u,html:a})}return{groups:s,id:r,taken:new Set}}function dr(e,t,n){for(let r of an(e)){if(V(r)||!Fe(r))continue;if(r.tagName==="slot"){let s=T(r.attributes?.name,t);n.taken.add(J(s)?s:"")}dr(r.children,t,n)}}function Ks(e){let t=null,n={};for(let[r,s]of Object.entries(e??{}))if(r.startsWith("props.")&&r.length>6)t??={},t[r.slice(6)]=s;else n[r]=s;return{lifted:t,rest:n}}function gr(e,t){if(!t)return en(e.state??{},null);let n={...e.state};for(let[r,s]of Object.entries(t)){let o=n[r];n[r]=C(o)&&!Array.isArray(o)&&"default"in o?{...o,default:s}:s}return en(n,null)}function zs(e,t){return Object.fromEntries(Object.entries(e??{}).flatMap(([n,r])=>{if(!N(r))return[];let s=T(r,t);return s==null?[]:[[n,s]]}))}function Ye(e,t,n,r){if(e.textContent!==void 0){let s=T(e.textContent,t);return s!=null?j(String(s)):""}if(e.innerHTML){let s=T(e.innerHTML,t);return s!=null?String(s):e.innerHTML}if(Array.isArray(e.children))return e.children.map((s)=>pt(s,t,n,r)).join(`
19
- `);return""}function pt(e,t,n=null,r=null){if(J(e)){if(N(e)&&t){let u=rn(e,t);return u!=null?j(String(u)):j(e)}return j(e)}if(ee(e)||K(e))return j(String(e));if(Array.isArray(e))return e.map((u)=>pt(u,t,n,r)).join(`
20
- `);if(!C(e))return"";if(e.$prototype==="Array")return"";if(e.$switch){let u=e.tagName??"div",a=ve(e,t),c=T(e.$switch,t),l=c==null?void 0:e.cases?.[String(c)],p=l!==void 0&&!Y(l)?pt(l,t,n,r):"";return`<${u}${a}>${p}</${u}>`}let s=cn(e.tagName,t);if(s==="slot"&&n){let u=T(e.attributes?.name,t),a=J(u)?u:"",c;if(!n.taken.has(a))n.taken.add(a),c=n.groups.get(a);let l=c?.html??"";if(l!==""&&n.id!==null)l=`<!--${at} ${n.id} ${encodeURIComponent(a)}-->${l}<!--/${at} ${n.id}-->`;if(c?.content)return dr(e.children,t,n),l;let p=Ye(e,t,n,r);return l===""?p:p===""?l:`${l}
21
- ${p}`}let o=r?.componentDefs.get(s);if(o&&r)return Ys(e,o,t,n,r);let i=ve(e,t);if(ln.has(s))return`<${s}${i}>`;return`<${s}${i}>${Ye(e,t,n,r)}</${s}>`}function Ys(e,t,n,r,s){let o=t.tagName,{lifted:i,rest:u}=Ks(e.attributes),a={...i,...e.$props},c={};for(let[h,b]of Object.entries(a))c[h]=T(b,n)??b;let l=Object.keys(c).length>0,p=s.path??[],g={key:JSON.stringify(c),tag:o},d=[...p.map((h)=>h.tag),o].join(" → ");if(p.some((h)=>h.tag===g.tag&&h.key===g.key))throw Error(`Component <${o}> renders itself: ${d}. A component cannot appear inside its own `+"definition with the same props — the expansion would never end.");if(p.length>=zt)throw Error(`Component nesting exceeds ${zt} levels: ${d}. A component that renders itself with changing props needs a case that stops.`);let x={...s,path:[...p,g]},{children:f}=e,m=(h)=>pt(h,n,r,s),y=lt(t,s.defaults),w=Gs(t),O=gr(t,l?c:null),v,A=null;if(y){let h=Array.isArray(f)?f.map((b)=>m(b)).join(`
22
- `):"";v=`<template shadowrootmode="${y}"><link rel="stylesheet" href="/components/${o}.css">${Ye(t,O,null,x)}</template>${h}`}else{A=!w&&Pe(t.children)?Us(s):null;let h=qs(f,n,m,A);v=Ye(t,O,h,x)}let k=Object.entries(zs(t.style,O)).map(([h,b])=>`${z(h)}: ${b}`).join("; "),S={...e};if(delete S.$props,delete S.children,S.attributes=!w&&l?{...u,"data-jx-props":JSON.stringify(c)}:u,A!==null)S.attributes={...S.attributes,[Yt]:String(A)};if(w)S.$static=!0;else S.$prerendered=!0;return`<${o}${ve(S,n,k)}>${v}</${o}>`}function Hi(e,t=null,n=null,r=null){return Ye(e,gr(e,t),n,r)}function Gs(e){return tn(e)}function tn(e){if(!C(e))return!0;if(Array.isArray(e))return e.every((t)=>tn(t));if(e.$prototype)return!1;if(e.$ref)return!1;if(e.state)for(let t of Object.values(e.state)){if(!C(t)||Array.isArray(t))continue;if(t.$prototype)return!1;if(t.$ref)return!1}for(let t of Object.keys(e))if(t.startsWith("on")&&t!=="observedAttributes")return!1;if(Array.isArray(e.children))return e.children.every((t)=>tn(t));if(V(e.children))return!1;return!0}function Zs(e,t){return Ve(e).map((n)=>Qs(n,t)).join(", ")}function Qs(e,t){let n=tt(e,t);if(n!==null)return n;if(e.startsWith(":host")){let r=/^:host\((.*)\)$/.exec(e)?.[1];if(t===":host")return e;return r===void 0?t:`${t}${r}`}if(t===":host"&&Xs.test(e))return e;return`${t}${e}`}function Bi(e,t,n=null,r={},s=null){let o=[],i=nr(e,s);if(C(t)){let u={},a=[];for(let[c,l]of Object.entries(t))if(P(l))u[c]=l;else if(C(l)&&!Array.isArray(l))a.push([c,l]);else if(!c.startsWith("@")&&!Se(c))u[c]=l;ut(o,u,i,r);for(let[c,l]of a)if(c.startsWith("@"))ut(o,{[c]:l},i,r);else if(Se(c))ut(o,l,Zs(c,i),r)}if(n&&Array.isArray(n.children)){let u={n:0};for(let a of n.children)Te(a,o,r,"",u,e)}return o.length>0?`${o.join(`
17
+ </style>`}function Vl(e){return e.replaceAll(/<\/(?=style)/gi,String.raw`<\/`)}function Pt(e,t,n,r="",s,o="jx"){let i=s??{n:0};if(!A(e))return;if(e.style&&!e.id&&!e.className)e.className=`${o}-${i.n}`,i.n+=1;let c=vt(e.tagName).join(", ")||"*",a=e.id?`#${e.id}`:e.className?`.${e.className.split(" ")[0]}`:c;if(e.style)Hn(t,e.style,a,n);if(Array.isArray(e.children))for(let l of e.children)Pt(l,t,n,a,i,o);if(A(e.cases))for(let l of Object.values(e.cases))Pt(l,t,n,a,i,o)}function _(e){return String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;")}function tr(e){return e.split("-").map((t)=>t.charAt(0).toUpperCase()+t.slice(1)).join("")}function qf(e){let t=[];return ri(e,t),t}function ri(e,t){if(!A(e))return;if(e.state){for(let[n,r]of Object.entries(e.state))if(He(r))t.push({exportName:r.$export,key:n,src:r.$src})}if(Array.isArray(e.children))for(let n of e.children)ri(n,t)}function xs(e,t){if(b(e))return e;let n=vt(e);if(n.length===0)return"div";if(!Ie(e))return n[0];let r=e.$expression,s=r.target;if(r.operator==="?:")return B(s,t)?r.value:r.initial;let o=B(s,t);return r.cases[String(o)]??r.default}function Hl(e){if(!e?.slotIds)return null;return e.slotIds.n+=1,e.slotIds.n}function Bl(e,t,n,r=null){let s=new Map;for(let o of gs(e)){let i="",c=!0,a;if(b(o)||se(o)||pe(o)){if(a=n(o),Ln.test(a))continue;c=a!==""}else if(ne(o))a="";else if(!rn(o))a=n(o),c=a!=="";else{let u=B(o.attributes?.slot,t),f=b(o.slot)?B(o.slot,t):null;if(b(u)&&u!=="")i=u,a=n(o);else if(b(f)&&f!==""){i=f;let{slot:p,...d}=o;a=n({...d,attributes:{...d.attributes,slot:f}})}else a=n(o)}let l=s.get(i);if(l)l.html=l.html===""?a:`${l.html}
18
+ ${a}`,l.content||=c;else s.set(i,{content:c,html:a})}return{groups:s,id:r,taken:new Set}}function si(e,t,n){for(let r of gs(e)){if(ne(r)||!rn(r))continue;if(r.tagName==="slot"){let s=B(r.attributes?.name,t);n.taken.add(b(s)?s:"")}si(r.children,t,n)}}function Ul(e){let t=null,n={};for(let[r,s]of Object.entries(e??{}))if(r.startsWith("props.")&&r.length>6)t??={},t[r.slice(6)]=s;else n[r]=s;return{lifted:t,rest:n}}function oi(e,t){if(!t)return cs(e.state??{},null);let n={...e.state};for(let[r,s]of Object.entries(t)){let o=n[r];n[r]=A(o)&&!Array.isArray(o)&&"default"in o?{...o,default:s}:s}return cs(n,null)}function ql(e,t){return Object.fromEntries(Object.entries(e??{}).flatMap(([n,r])=>{if(!L(r))return[];let s=B(r,t);return s==null?[]:[[n,s]]}))}function pn(e,t,n,r){if(e.textContent!==void 0){let s=B(e.textContent,t);return s!=null?_(String(s)):""}if(e.innerHTML){let s=B(e.innerHTML,t);return s!=null?String(s):e.innerHTML}if(Array.isArray(e.children))return e.children.map((s)=>Bn(s,t,n,r)).join(`
19
+ `);return""}function Bn(e,t,n=null,r=null){if(b(e)){if(L(e)&&t){let c=ps(e,t);return c!=null?_(String(c)):_(e)}return _(e)}if(se(e)||pe(e))return _(String(e));if(Array.isArray(e))return e.map((c)=>Bn(c,t,n,r)).join(`
20
+ `);if(!A(e))return"";if(e.$prototype==="Array")return"";if(e.$switch){let c=e.tagName??"div",a=yt(e,t),l=B(e.$switch,t),u=l==null?void 0:e.cases?.[String(l)],f=u!==void 0&&!me(u)?Bn(u,t,n,r):"";return`<${c}${a}>${f}</${c}>`}let s=xs(e.tagName,t);if(s==="slot"&&n){let c=B(e.attributes?.name,t),a=b(c)?c:"",l;if(!n.taken.has(a))n.taken.add(a),l=n.groups.get(a);let u=l?.html??"";if(u!==""&&n.id!==null)u=`<!--${Fn} ${n.id} ${encodeURIComponent(a)}-->${u}<!--/${Fn} ${n.id}-->`;if(l?.content)return si(e.children,t,n),u;let f=pn(e,t,n,r);return u===""?f:f===""?u:`${u}
21
+ ${f}`}let o=r?.componentDefs.get(s);if(o&&r)return zl(e,o,t,n,r);let i=yt(e,t);if(hs.has(s))return`<${s}${i}>`;return`<${s}${i}>${pn(e,t,n,r)}</${s}>`}function zl(e,t,n,r,s){let o=t.tagName,{lifted:i,rest:c}=Ul(e.attributes),a={...i,...e.$props},l={};for(let[y,w]of Object.entries(a))l[y]=B(w,n)??w;let u=Object.keys(l).length>0,f=s.path??[],p={key:JSON.stringify(l),tag:o},d=[...f.map((y)=>y.tag),o].join(" → ");if(f.some((y)=>y.tag===p.tag&&y.key===p.key))throw Error(`Component <${o}> renders itself: ${d}. A component cannot appear inside its own `+"definition with the same props — the expansion would never end.");if(f.length>=rs)throw Error(`Component nesting exceeds ${rs} levels: ${d}. A component that renders itself with changing props needs a case that stops.`);let h={...s,path:[...f,p]},{children:g}=e,m=(y)=>Bn(y,n,r,s),x=Wn(t,s.defaults),E=Kl(t),O=oi(t,u?l:null),J,C=null;if(x){let y=Array.isArray(g)?g.map((w)=>m(w)).join(`
22
+ `):"";J=`<template shadowrootmode="${x}"><link rel="stylesheet" href="/components/${o}.css">${pn(t,O,null,h)}</template>${y}`}else{C=!E&&kt(t.children)?Hl(s):null;let y=Bl(g,n,m,C);J=pn(t,O,y,h)}let q=Object.entries(ql(t.style,O)).map(([y,w])=>`${de(y)}: ${w}`).join("; "),S={...e};if(delete S.$props,delete S.children,S.attributes=!E&&u?{...c,"data-jx-props":JSON.stringify(l)}:c,C!==null)S.attributes={...S.attributes,[ss]:String(C)};if(E)S.$static=!0;else S.$prerendered=!0;return`<${o}${yt(S,n,q)}>${J}</${o}>`}function zf(e,t=null,n=null,r=null){return pn(e,oi(e,t),n,r)}function Kl(e){return us(e)}function us(e){if(!A(e))return!0;if(Array.isArray(e))return e.every((t)=>us(t));if(e.$prototype)return!1;if(e.$ref)return!1;if(e.state)for(let t of Object.values(e.state)){if(!A(t)||Array.isArray(t))continue;if(t.$prototype)return!1;if(t.$ref)return!1}for(let t of Object.keys(e))if(t.startsWith("on")&&t!=="observedAttributes")return!1;if(Array.isArray(e.children))return e.children.every((t)=>us(t));if(ne(e.children))return!1;return!0}function Yl(e,t){return on(e).map((n)=>Xl(n,t)).join(", ")}function Xl(e,t){let n=kn(e,t);if(n!==null)return n;if(e.startsWith(":host")){let r=/^:host\((.*)\)$/.exec(e)?.[1];if(t===":host")return e;return r===void 0?t:`${t}${r}`}if(t===":host"&&Gl.test(e))return e;return`${t}${e}`}function Kf(e,t,n=null,r={},s=null){let o=[],i=qo(e,s);if(A(t)){let c={},a=[];for(let[l,u]of Object.entries(t))if(H(u))c[l]=u;else if(A(u)&&!Array.isArray(u))a.push([l,u]);else if(!l.startsWith("@")&&!ot(l))c[l]=u;Hn(o,c,i,r);for(let[l,u]of a)if(l.startsWith("@"))Hn(o,{[l]:u},i,r);else if(ot(l))Hn(o,u,Yl(l,i),r)}if(n&&Array.isArray(n.children)){let c={n:0};for(let a of n.children)Pt(a,o,r,"",c,e)}return o.length>0?`${o.join(`
23
23
  `)}
24
- `:""}var Ms,or,gt="https://esm.sh/@vue/reactivity@3.5.40",ht="https://esm.sh/lit-html@3.3.0",Ls,Fs,be,Hs,_e="__jxAttrText",pr="__jxServerCall",sn="__jxCaptureSlotted",on="__jxDistributeSlots",De="<!---->",ln,Xs;var Ie=I(()=>{ze();Be();qe();st();er();H();je();ze();qe();st();H();Ms=["$map/","event#/","$args/","$reduce/"];or=Symbol("jx.runtimeOnlyStateKeys");Ls=/\bstate\.([A-Za-z_$][\w$]*)\s*(?:\+\+|--|(?:\*\*|\|\||&&|\?\?|<<|>>>|>>|[-+*/%&|^])?=(?!=))/g,Fs=/\bstate\.([A-Za-z_$][\w$]*)\s*\.\s*(?:push|pop|shift|unshift|splice|sort|reverse|fill|copyWithin)\s*\(/g;be=new Set(["pre","textarea","listing","plaintext","xmp"]);Hs=[];ln=new Set(["input","br","hr","img","meta","link","area","col","source"]);Xs=/^(?:::slotted\(|::part\()/});function xr(e){let t=[],n=[],r=null,s=0,o=()=>n.at(-1)?.path??"",i=()=>r===null?o():no(o(),r),u=()=>{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+=eo.get(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(hr.has(a)||a===","||a===":"){s+=1;continue}if(a==="{"||a==="["){n.push(a==="{"?{keys:new Set,kind:"object",path:i()}:{kind:"array",path:i()}),r=null,s+=1;continue}if(a==="}"||a==="]"){n.pop(),r=null,s+=1;continue}if(a==='"'){let l=u(),p=n.at(-1);if(p?.kind==="object"&&to(e,s)===":"){if(p.keys.has(l))t.push({detail:l,kind:"duplicate-key",path:p.path});p.keys.add(l),r=l}else r=null;continue}if(a==="-"||a>="0"&&a<="9"){let l=s;while(s<e.length&&/[\d+.eE-]/.test(e[s]))s+=1;let p=e.slice(l,s);if(!ro(p))t.push({detail:p,kind:"unsafe-number",path:i()});r=null;continue}let c=s;while(s<e.length&&/[A-Za-z]/.test(e[s]))s+=1;if(s===c)s+=1;r=null}return t}function to(e,t){let n=t;while(n<e.length&&hr.has(e[n]))n+=1;return e[n]??""}function no(e,t){return e===""?t:`${e}.${t}`}function ro(e){if(/[.eE]/.test(e))return!0;let t=Number(e);if(!Number.isFinite(t))return!1;return String(t)===e.replace(/^\+/,"")}function yr(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 hr,eo;var $r=I(()=>{hr=new Set([" ","\t",`
25
- `,"\r"]);eo=new Map([["b","\b"],["f","\f"],["n",`
26
- `],["r","\r"],["t","\t"]])});function so(e){return e instanceof Error?e.message:String(e)}function br(e){if(J(e))return Sr.test(e)?e.normalize("NFC"):e;if(Array.isArray(e))return e.map((t)=>br(t));if(L(e))return Jr(e);return e}function Jr(e){let t={};for(let[n,r]of Object.entries(e))t[Sr.test(n)?n.normalize("NFC"):n]=br(r);return t}function un(e,t,n){let r;try{r=JSON.parse(e)}catch(o){throw Error(`Failed to parse ${n} at ${t}: ${so(o)}`,{cause:o})}if(!L(r))throw Error(`Invalid ${n} at ${t}: expected a JSON object`);let s=xr(e);if(s.length>0){let o=s.map((i)=>yr(i)).join("; ");throw Error(`Invalid ${n} at ${t}: ${o}`)}return Jr(r)}function Et(e,t){return un(e,t,"Jx document")}function Qi(e,t){return un(e,t,"project config")}function ea(e,t){return un(e,t,"class definition")}var Sr;var pn=I(()=>{H();$r();Sr=/[^\p{ASCII}]/u});function vr(e){if(!J(e))return null;let[t,...n]=e.split(";"),r=(t??"").indexOf("/");if(r===-1)return null;let s=(t??"").slice(0,r).trim().toLowerCase(),o=(t??"").slice(r+1).trim().toLowerCase();if(!Er.test(s)||!Er.test(o))return null;let i=o.lastIndexOf("+"),u=i===-1?null:o.slice(i+1),a=i===-1?o:o.slice(0,i);if(u==="")return null;let c=a.indexOf("."),l=c===-1?null:a.slice(0,c),p=l!==null&&oo.has(l)?l:null,g=p===null?a:a.slice(p.length+1);if(g==="")return null;let d={};for(let x of n){let f=x.indexOf("=");if(f===-1)return null;let m=x.slice(0,f).trim().toLowerCase(),y=x.slice(f+1).trim();if(m==="")return null;if(y.startsWith('"')&&y.endsWith('"')&&y.length>=2)y=y.slice(1,-1);d[m]=y}return{parameters:d,subtype:g,suffix:u,tree:p,type:s}}function Or(e){if(!J(e)||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(vr(e)===null)return`"${e}" is not a well-formed media type (RFC 6838 §4.2)`;return null}function Ar(e){let t=vr(e);if(t===null)return null;let n=t.tree===null?"":`${t.tree}.`,r=t.suffix===null?"":`+${t.suffix}`;return`${t.type}/${n}${t.subtype}${r}`}var Er,oo,wr="text/markdown; variant=GFM",Cr="application/yaml",ra;var jr=I(()=>{H();Er=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,oo=new Set(["vnd","prs","x"]);ra={".markdown":`${wr}; charset=utf-8`,".md":`${wr}; charset=utf-8`,".yaml":`${Cr}; charset=utf-8`,".yml":`${Cr}; charset=utf-8`}});function Tr(e){if(e===null)throw TypeError("A class descriptor cannot be null");return L(e)?e:{}}class wt{name;classPath;classDef;extensions;mediaType;mediaTypeEssence;documentKinds;exportTarget;remote;studio;project;server;connector;capabilities;#t;#e=null;constructor(e,t,n,r){this.name=e,this.classPath=t,this.classDef=n,this.#t=r;let{format:s}=n;this.extensions=(s?.extensions??[]).map((o)=>o.toLowerCase()),this.mediaType=s?.mediaType??null,this.mediaTypeEssence=Ar(this.mediaType),this.documentKinds=s?.documentKinds??[],this.exportTarget=s?.exportTarget===!0,this.remote=s?.remote===!0,this.studio=n.$studio??null,this.project=n.project??null,this.server=n.server??null,this.connector=n.connector??null,this.capabilities=ao(n)}implementation(){if(!this.#e){let e=this.classDef.$implementation;if(!e)return Promise.reject(Error(`Format class "${this.name}" has no $implementation to import`));this.#e=this.#t.importModule(this.#t.resolvePath(this.classPath,e))}return this.#e}async implementationExport(){return this.#n(await this.implementation())}#n(e){let t=this.classDef.title??this.name;return e[t]??e.default?.[t]??e.default}async call(e,...t){let n=this.capabilities[e];if(!n)throw Error(`Format class "${this.name}" does not declare a "${e}" capability`);let r=this.#n(await this.implementation()),s=r?.[n.identifier];if(!te(s)){let i=this.classDef.title??this.name;throw TypeError(`Format class "${this.name}": implementation export "${i}" has no static "${n.identifier}" method`)}return await s.call(r,...t)}async parseDocument(e,t){return await this.call("parse",e,t)}}class Ct{#t;constructor(e){this.#t=e;for(let t of e){if(t.mediaType===null)continue;let n=Or(t.mediaType);if(n!==null)throw Error(`Format "${t.name}" declares an invalid mediaType: ${n}`)}for(let t of Nr){let n=new Map;for(let r of e){if(!r.capabilities[t])continue;for(let s of r.extensions){let o=n.get(s);if(o)throw Error(`Format conflict: "${o.name}" and "${r.name}" both claim "${s}" with the "${t}" capability`);n.set(s,r)}}}}get entries(){return this.#t}byExtension(e,t){let n=Rr(e);return this.#t.find((r)=>r.extensions.includes(n)&&(!t||r.capabilities[t]))}byName(e){return this.#t.find((t)=>t.name===e)}withCapability(e){return this.#t.filter((t)=>t.capabilities[e])}documentExtensions(e){let t=new Set;for(let n of this.#t){if(e&&!n.documentKinds.includes(e))continue;for(let r of n.extensions)t.add(r)}return t.delete(".json"),[...t]}has(e){let t=Rr(e);return this.#t.some((n)=>n.extensions.includes(t))}}function ao(e){let t={},n=e.$defs?.methods??{};for(let[r,s]of Object.entries(n)){let{role:o}=s;if(!co(o))continue;let i={identifier:s.identifier??r,timing:s.timing??io};if(J(s.discriminator))i.discriminator=s.discriminator;t[o]=i}return t}function co(e){return e!==void 0&&lo.has(e)}function Rr(e){let t=e.toLowerCase();return t.startsWith(".")?t:`.${t}`}var Nr,Pr,io,lo;var fn=I(()=>{H();jr();Nr=["parse","serialize","rewrite","discover","load"],Pr=[...Nr,"projectData","resolvePaths","lower","emit","head","assets","mount","dialect","deploySchema","bindings","testConnection"];io=["compiler","server"];lo=new Set(Pr)});class kr{#t;#e;#n;constructor(e){this.#t=e,this.#e=e.flatMap((s)=>s.classes);let t=new Map;for(let s of e)for(let o of s.classes){let i=t.get(o.name);if(i&&i!==s.specifier)throw Error(`Extension conflict: "${i}" and "${s.specifier}" both provide a class named "${o.name}"`);t.set(o.name,s.specifier)}let n=new Map;for(let s of this.#e){if(!s.project)continue;let o=n.get(s.project.key);if(o)throw Error(`Extension conflict: "${o.name}" and "${s.name}" both claim the project section "${s.project.key}"`);n.set(s.project.key,s)}let r=new Map;for(let s of this.#e){if(!s.server)continue;let{basePath:o}=s.server;if(!o.startsWith("/_jx/"))throw Error(`Extension "${s.name}": server basePath "${o}" must be under /_jx/`);let i=r.get(o);if(i)throw Error(`Extension conflict: "${i.name}" and "${s.name}" both mount "${o}"`);r.set(o,s)}this.#n=new Ct(this.#e.filter((s)=>s.extensions.length>0))}get extensions(){return this.#t}get classes(){return this.#e}get formats(){return this.#n}byName(e){return this.#e.find((t)=>t.name===e)}projectContributions(){return this.#e.filter((e)=>e.project!==null)}byProjectKey(e){return this.#e.find((t)=>t.project?.key===e)}byPathsDiscriminator(e){return this.#e.find((t)=>t.capabilities.resolvePaths?.discriminator===e)}emitters(){return this.#e.filter((e)=>e.capabilities.emit!==void 0)}headProviders(){return this.#e.filter((e)=>e.capabilities.head!==void 0)}assetProviders(){return this.#e.filter((e)=>e.capabilities.assets!==void 0)}serverMounts(){return this.#e.filter((e)=>e.server!==null).toSorted((e,t)=>(e.server?.order??100)-(t.server?.order??100)||e.name.localeCompare(t.name))}connectors(){return this.#e.filter((e)=>e.connector!==null)}schemaFragments(e){return this.#t.map((t)=>t.schemas[e]).filter((t)=>typeof t==="string")}}async function _r(e,t,n){let r=[];for(let s of e??[])r.push(await uo(s,t,n));return new kr(r)}async function uo(e,t,n){let r;if(e.startsWith("./")||e.startsWith("../")){let a=t.resolvePath(n,e);r=t.resolvePath(`${a}/package.json`,`./${Ze}`)}else try{r=t.resolvePath(n,`${e}/${Ze}`)}catch(a){throw Error(`Extension "${e}" is not resolvable: it must export ${Ze} (is the package installed, and does its exports map include it?): ${mn(a)}`,{cause:a})}let s;try{s=await t.loadJson(r)}catch(a){throw Error(`Extension "${e}": cannot read manifest ${r}: ${mn(a)}`,{cause:a})}if(!L(s)||!J(s.name))throw Error(`Extension "${e}": ${Ze} must declare a "name"`);let o=s;if(!e.startsWith(".")&&o.name!==e)throw Error(`Extension "${e}": manifest name "${o.name}" does not match the specifier`);let i=[];for(let[a,c]of Object.entries(o.classes??{})){let l=t.resolvePath(r,c),p;try{p=await t.loadJson(l)}catch(g){throw Error(`Extension "${e}": cannot read class "${a}" at ${l}: ${mn(g)}`,{cause:g})}i.push(new wt(a,l,Tr(p),t))}let u={};if(o.schemas?.project)u.project=t.resolvePath(r,o.schemas.project);if(o.schemas?.document)u.document=t.resolvePath(r,o.schemas.document);if(o.schemas?.fields)u.fields=t.resolvePath(r,o.schemas.fields);return{specifier:e,manifestPath:r,manifest:o,classes:i,schemas:u}}function mn(e){return e instanceof Error?e.message:String(e)}var Ze="jx-extension.json";var Dr=I(()=>{fn();H();fn()});import{readFileSync as po}from"node:fs";import{dirname as fo,isAbsolute as mo,resolve as dn,sep as vt}from"node:path";import{pathToFileURL as go}from"node:url";import{createRequire as ho}from"node:module";async function xo(e){let t=[e],n=`${vt}src${vt}`,r=`${vt}dist${vt}`;if(e.includes(n)){let o=e.replace(n,r);if(t.push(o),o.endsWith(".ts"))t.push(`${o.slice(0,-3)}.js`)}if(e.endsWith(".js"))t.push(`${e.slice(0,-3)}.ts`);let s;for(let o of t)try{return await import(go(o).href)}catch(i){s=i}throw s instanceof Error?s:Error(String(s))}function yo(e,t){return ho(dn(e,"package.json")).resolve(t)}function $o(e){return{importModule:(t)=>xo(t),loadJson:async(t)=>JSON.parse(po(t,"utf8")),resolvePath:(t,n)=>{if(n.startsWith("./")||n.startsWith("../"))return dn(fo(t),n);if(mo(n))return n;return yo(e,n)}}}async function ya(e,t){return _r(t?.extensions,$o(e),dn(e,"project.json"))}function Ot(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 gn=I(()=>{Dr();H()});async function Fr(e,t={}){let{resolveElementPath:n,$media:r,formats:s}=t,o=[],i=new Set;async function u(a,c){let l,p;if(J(a)){let{readFileSync:v}=await import("node:fs"),{resolve:A}=await import("node:path");if(p=c?A(c,a):A(a),i.has(p))return;if(i.add(p),p.endsWith(".json"))l=Et(v(p,"utf8"),p);else{let{extname:k}=await import("node:path"),S=k(p).toLowerCase(),h=s?.byExtension(S,"parse");if(!h){await Promise.resolve().then(() => gn());throw Ot(p,S)}l=await h.parseDocument(v(p,"utf8"))}}else{if(l=a,p=null,l.tagName&&i.has(l.tagName))return;if(l.tagName)i.add(l.tagName)}let{tagName:g}=l;if(!g||!g.includes("-"))throw Error(`compileElement: tagName "${g}" must contain a hyphen`);let{dirname:d}=await import("node:path"),x=p?d(p):null,f=[];if(Array.isArray(l.$elements))for(let v of l.$elements){let A=P(v)?v.$ref:v;if(!J(A))continue;if(x)await u(A,x);let k=n?n(A,x):A.replace(/\.json$/,".js");f.push(k)}let m=Jt(g);if(r)l.$media={...r,...l.$media};let{rewriteSrc:y}=t,w=Qe(l,m,f,y?(v)=>y(v,x):void 0,lt(l,t.defaults),t.serverBaseUrl),O=p?p.replace(/\.json$/,".js"):`${g}.js`;o.push({content:w,path:O,tagName:g})}return await u(e,t.basePath??null),{files:o}}async function So(e,t={}){let{title:n="Jx App",reactivitySrc:r="https://esm.sh/@vue/reactivity@3.5.13",litHtmlSrc:s="https://esm.sh/lit-html@3.3.0"}=t,o=await Fr(e,t),i=o.files.at(-1);if(!i)throw Error("compileElementPage: no element modules were produced");let{basename:u}=await import("node:path"),a=u(i.path),c=`<!DOCTYPE html>
24
+ `:""}var Pl,Go,Kn="https://esm.sh/@vue/reactivity@3.5.40",Gn="https://esm.sh/lit-html@3.3.0",Dl,Ml,it,Wl,Dt="__jxAttrText",ti="__jxServerCall",ds="__jxCaptureSlotted",ms="__jxDistributeSlots",Mt="<!---->",hs,Gl;var Ft=v(()=>{fn();ln();un();Dn();Bo();K();jt();fn();un();Dn();K();Pl=["$map/","event#/","$args/","$reduce/"];Go=Symbol("jx.runtimeOnlyStateKeys");Dl=/\bstate\.([A-Za-z_$][\w$]*)\s*(?:\+\+|--|(?:\*\*|\|\||&&|\?\?|<<|>>>|>>|[-+*/%&|^])?=(?!=))/g,Ml=/\bstate\.([A-Za-z_$][\w$]*)\s*\.\s*(?:push|pop|shift|unshift|splice|sort|reverse|fill|copyWithin)\s*\(/g;it=new Set(["pre","textarea","listing","plaintext","xmp"]);Wl=[];hs=new Set(["input","br","hr","img","meta","link","area","col","source"]);Gl=/^(?:::slotted\(|::part\()/});class ii{index;text;constructor(e){this.text=e,this.index=e.codePointAt(0)===65279?1:0}get done(){return this.index>=this.text.length}startsWith(e){return this.text.startsWith(e,this.index)}skipLine(){let e=this.text.indexOf(`
25
+ `,this.index);this.index=e===-1?this.text.length:e}skipBlock(){let e=1;this.index+=2;while(!this.done&&e>0)if(this.startsWith("/*"))e+=1,this.index+=2;else if(this.startsWith("*/"))e-=1,this.index+=2;else this.index+=1}skipTrivia(){for(;;){while(!this.done&&/[\s;]/u.test(this.text.charAt(this.index)))this.index+=1;if(this.startsWith("//"))this.skipLine();else if(this.startsWith("/*"))this.skipBlock();else if(this.startsWith("/-"))this.index+=2,this.skipNode();else return}}skipString(){let e=0,t=this.index;while(this.text.charAt(t)==="#")e+=1,t+=1;let n=this.text.startsWith('"""',t),r=n?'"""':'"',s=r+"#".repeat(e);t+=r.length;while(t<this.text.length)if(e===0&&this.text.charAt(t)==="\\")t+=2;else if(this.text.startsWith(s,t))return this.index=t+s.length,!0;else if(!n&&this.text.charAt(t)===`
26
+ `)return!1;else t+=1;return!1}skipNode(){let e=0;while(!this.done){let t=this.text.charAt(this.index);if(t==='"'||t==="#"&&/^#+"/u.test(this.text.slice(this.index,this.index+16))){if(!this.skipString())return!1}else if(this.startsWith("//"))this.skipLine();else if(this.startsWith("/*"))this.skipBlock();else if(t==="{")e+=1,this.index+=1;else if(t==="}"){if(e===0)return!1;e-=1,this.index+=1}else if((t===`
27
+ `||t===";")&&e===0)return this.index+=1,!0;else this.index+=1}return e===0}}function ys(e){if(Zl.test(e))return"unreadable";let t=new ii(e);for(;;){if(t.skipTrivia(),t.done)return"document";if(t.startsWith("(")){let n=e.indexOf(")",t.index);if(n===-1)return"unreadable";t.index=n+1}else{let[n]=Ql.exec(e.slice(t.index,t.index+256))??[];if(!n)return t.startsWith('"')||t.startsWith("#")?"document":"unreadable";if(!n.startsWith("$"))return n==="project"?"project":"document";if(t.index+=n.length,!t.skipNode())return"unreadable"}}}var Zl,Ql;var $s=v(()=>{Zl=/\0/u,Ql=/^[^\s\\/(){};[\]"#=]+/u});function li(e){let t=[],n=[],r=null,s=0,o=()=>n.at(-1)?.path??"",i=()=>r===null?o():nc(o(),r),c=()=>{s+=1;let a="";while(s<e.length){let l=e[s];if(l==="\\"){let u=e[s+1]??"";if(u==="u")a+=String.fromCodePoint(Number.parseInt(e.slice(s+2,s+6),16)),s+=6;else a+=ec.get(u)??u,s+=2;continue}if(l==='"')return s+=1,a;a+=l,s+=1}return a};while(s<e.length){let a=e[s];if(ai.has(a)||a===","||a===":"){s+=1;continue}if(a==="{"||a==="["){n.push(a==="{"?{keys:new Set,kind:"object",path:i()}:{kind:"array",path:i()}),r=null,s+=1;continue}if(a==="}"||a==="]"){n.pop(),r=null,s+=1;continue}if(a==='"'){let u=c(),f=n.at(-1);if(f?.kind==="object"&&tc(e,s)===":"){if(f.keys.has(u))t.push({detail:u,kind:"duplicate-key",path:f.path});f.keys.add(u),r=u}else r=null;continue}if(a==="-"||a>="0"&&a<="9"){let u=s;while(s<e.length&&/[\d+.eE-]/.test(e[s]))s+=1;let f=e.slice(u,s);if(!rc(f))t.push({detail:f,kind:"unsafe-number",path:i()});r=null;continue}let l=s;while(s<e.length&&/[A-Za-z]/.test(e[s]))s+=1;if(s===l)s+=1;r=null}return t}function tc(e,t){let n=t;while(n<e.length&&ai.has(e[n]))n+=1;return e[n]??""}function nc(e,t){return e===""?t:`${e}.${t}`}function rc(e){if(/[.eE]/.test(e))return!0;let t=Number(e);if(!Number.isFinite(t))return!1;return String(t)===e.replace(/^\+/,"")}function ci(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 ai,ec;var ui=v(()=>{ai=new Set([" ","\t",`
28
+ `,"\r"]);ec=new Map([["b","\b"],["f","\f"],["n",`
29
+ `],["r","\r"],["t","\t"]])});function sc(e){return e instanceof Error?e.message:String(e)}function pi(e){if(b(e))return fi.test(e)?e.normalize("NFC"):e;if(Array.isArray(e))return e.map((t)=>pi(t));if(D(e))return nr(e);return e}function nr(e){let t={};for(let[n,r]of Object.entries(e))t[fi.test(n)?n.normalize("NFC"):n]=pi(r);return t}function Ss(e,t,n){let r;try{r=JSON.parse(e)}catch(o){throw Error(`Failed to parse ${n} at ${t}: ${sc(o)}`,{cause:o})}if(!D(r))throw Error(`Invalid ${n} at ${t}: expected a JSON object`);let s=li(e);if(s.length>0){let o=s.map((i)=>ci(i)).join("; ");throw Error(`Invalid ${n} at ${t}: ${o}`)}return nr(r)}function di(e,t){return Ss(e,t,"Jx document")}function oc(e,t){return Ss(e,t,"project config")}function sp(e,t){return Ss(e,t,"class definition")}var fi;var rr=v(()=>{K();ui();fi=/[^\p{ASCII}]/u});function xn(e){switch(e){case 9:case 32:case 160:case 5760:case 8192:case 8193:case 8194:case 8195:case 8196:case 8197:case 8198:case 8199:case 8200:case 8201:case 8202:case 8239:case 8287:case 12288:return!0}return!1}function ut(e){return e===13||e===10||e===133||e===11||e===12||e===8232||e===8233||!1}function mr(e){return e<8||e>=14&&e<=25||e===127||e>=55296&&e<=57343||e>1114111||e===8206||e===8207||e>=8234&&e<=8238||e>=8294&&e<=8297||e===65279}function U(e){return!isNaN(e)&&!xn(e)&&!ut(e)&&e!==61&&e!==92&&e!==47&&e!==40&&e!==41&&e!==123&&e!==125&&e!==59&&e!==91&&e!==93&&e!==34&&e!==35&&!0}function mi(e){return e>=65&&e<91||e>=97&&e<123||!1}function bs(e){return e>=48&&e<64||e>=65&&e<71||e>=97&&e<103||!1}function ws(e){return bs(e)||e===95}function Qe(e){return e>=48&&e<58}function wt(e){return Qe(e)||e===95}function Es(e){return e>=48&&e<56}function gi(e){return Es(e)||e===95}function Js(e){return e===48||e===49}function hi(e){return Js(e)||e===95}function xi(e){return e===45||e===43}var at=1,Wt=2,$t=3,sr=4,or=5,gn=6,ir=7,ar=8,hn=9,lt=10,ie=11,Vt=12,Ht=13,lr=14,Ze=15,cr=16,ur=17,St=18,ct=19,fr=20,pr=21,dr=22,Bt=23,bt=24,Me=28;function*ac(e){for(let t of(ic??=new Intl.Segmenter("en")).segment(e))yield t.segment}function lc(e){return e[Symbol.iterator]()}function yi(e,{flags:t,graphemeLocations:n=!1}){let r=n?ac(e):lc(e),s=r.next();return{text:e,graphemeLocations:n,line:1,column:1,offset:0,length:e.length,iterator:r,currentIter:s,current:s.done?NaN:s.value.codePointAt(0),start:{line:1,column:1,offset:0},errorsInToken:null,flags:t}}function*$i(e){if(k(e,65279))e.column=1,yield T(e,Wt);if(mr(e.current))throw Le(e,`Invalid character \\u${e.current.toString(16)}`)}function Z(e){e.offset+=e.currentIter.value.length,e.column++;let t=e.currentIter=e.iterator.next(),n=e.current=t.done?NaN:t.value.codePointAt(0);if(mr(n))if(n>=55296&&n<=57343||n>1114111)yn(e,`Invalid character \\u${n.toString(16)}`);else yn(e,`Invalid character \\u${n.toString(16)}, this character is not allowed but can be included in strings as \\u{${n.toString(16)}}`);return n}function je(e,t){if(t(e.current)){let n=e.current;return Z(e),n}}function k(e,t){if(e.current===t)return Z(e),t}function Ut(e){if(!ut(e.current))return!1;if(!e.graphemeLocations&&e.current===13&&e.text.codePointAt(e.offset+1)===10)e.iterator.next(),e.offset++;return Z(e),e.column=1,e.line++,!0}function Ns(e,t){while(e.current===t)Z(e)}function F(e,t){while(t(e.current))Z(e)}function T(e,t,n){let{line:r,column:s,offset:o}=e,i={line:r,column:s,offset:o},c=e.start;e.start=i;let a=e.errorsInToken;e.errorsInToken=null;let l={type:t,text:e.text.slice(c.offset,i.offset),start:c,end:i,errors:a};if(n){if(!l.errors)l.errors=[];l.errors.push(new I(n,{token:l}))}return l}function Le(e,t){if(t instanceof I)return t;let{line:n,column:r,offset:s}=e,o={line:n,column:r,offset:s},i;if(s<e.length)if(ut(e.current))i={line:n+1,column:1,offset:s+1};else i={line:n,column:r+1,offset:s+1};return new I(`${t}`,{start:o,end:i})}function yn(e,t){(e.errorsInToken??=[]).push(Le(e,t))}var ic;var Si=v(()=>{Et()});function Jt(e){return(t)=>(Z(t),T(t,e))}function $n(e){return F(e,xn),T(e,St)}function Nt(e){return Ut(e),T(e,ct)}function cc(e){Z(e);let t=!1,n=!1;if(k(e,34)){if(!k(e,34))return T(e,hn);if(n=!0,e.current===34)throw Le(e,"Multiline strings must start with exactly three quotes");while(!t&&e.offset<e.length)if(k(e,34)){if(k(e,34)&&k(e,34))t=!0}else k(e,92),Ut(e)||Z(e)}else while(!t&&e.offset<e.length)if(k(e,34))t=!0;else k(e,92),Ut(e)||Z(e);if(!t)throw Le(e,"Unexpected EOF inside string");return T(e,n?Bt:hn)}function bi(e){if(Z(e),e.current===35||e.current===34){let t=1;while(k(e,35))t++;if(!k(e,34))throw Le(e,`Expected a quote after ${"#".repeat(t)}`);let n=!1;if(k(e,34))if(k(e,34)){if(e.current===34)throw Le(e,"Multiline strings must start with exactly three quotes");n=!0}else{let r=0;while(k(e,35))r++;if(r===t)return T(e,lt)}while(!0){if(e.offset>=e.length)throw Le(e,"Unexpected EOF while parsing raw string");if(k(e,34)){if(n){if(!k(e,34)||!k(e,34))continue}let r=0;while(r<t&&k(e,35))r++;if(r===t)return T(e,n?bt:lt)}else Ut(e)||Z(e)}}else{let t;if(e.current<255){let n=j[e.current];t=n(e)}else if(xn(e.current))t=$n(e);else if(ut(e.current))t=Nt(e);else t=Os(e);if(t.type!==ie)(t.errors??=[]).push(new I("Expected a valid identifier",{token:t}));return t.type=Ht,t}}function uc(e){if(Z(e),je(e,Qe))return F(e,U),T(e,ie,"Invalid identifier, identifiers that start with a sign and a dot must be quoted if the next character is a digit to prevent confusion with decimal numbers");return F(e,U),T(e,ie)}function fc(e){if(Z(e),k(e,45))return T(e,$t);else if(k(e,47)){while(e.offset<e.length&&!ut(e.current))Z(e);return T(e,pr)}else if(k(e,42)){let t=1;while(e.offset<e.length)if(k(e,42)){if(k(e,47)){if(t--,t===0)return T(e,dr)}}else if(k(e,47)){if(k(e,42))t++}else Ut(e)||Z(e);throw Le(e,"Unexpected EOF in multiline comment")}else hr(e)}function wi(e){return Z(e),pc(e)}function pc(e){if(Qe(e.current))return Re(e);else if(k(e,46)){if(je(e,Qe))return F(e,U),T(e,ie,"Invalid identifier or number, surround with quotes to make it an identifier or add a zero between the sign and the decimal point");return F(e,U),T(e,ie)}else return F(e,U),T(e,ie)}function As(e,t,n,r){return(s)=>{let o=Z(s);if(je(s,n))return F(s,r),T(s,t);else if(!s.flags.experimentalSuffixedNumbers){if(k(s,95)){if(F(s,r),!U(s.current))return T(s,t,`Invalid ${e} number, the first character after 0${String.fromCodePoint(o)} cannot be an underscore`)}return F(s,U),T(s,ie,`Invalid ${e} number`)}else if(k(s,95)){if(Ns(s,95),n(s.current)){if(F(s,r),!U(s.current))return T(s,t,`Invalid ${e} number, the first character after 0${String.fromCodePoint(o)} cannot be an underscore`)}return F(s,U),T(s,ie,"Invalid number with suffix, a suffix cannot start with a letter followed by an underscore")}else if(Qe(s.current))return T(s,ie,"Invalid number with suffix, a suffix cannot start with a letter followed by a number");else return F(s,U),T(s,Me)}}function Re(e){if(k(e,48)){let t=gr[e.current];if(t)return t(e)}if(F(e,wt),k(e,46)){if(!je(e,Qe))if(e.current===95)yn(e,"Invalid decimal number, the part after the decimal point mustn't start on an underscore");else yn(e,"Invalid decimal number, a decimal point must be followed by a digit");F(e,wt)}if(k(e,101)||k(e,69))if(je(e,xi),je(e,Qe)){if(F(e,wt),U(e.current))return F(e,U),T(e,ie,"Invalid number with suffix, a number with an exponent cannot have a suffix");return T(e,Ze)}else if(!e.flags.experimentalSuffixedNumbers)if(e.current===95)return F(e,wt),T(e,Ze,"Invalid decimal number, the number after the exponent mustn't start on an underscore");else return F(e,U),T(e,Ze,"Invalid decimal number, missing a number after the exponent");else if(k(e,95)){if(Ns(e,95),Qe(e.current)){if(F(e,wt),!U(e.current))return T(e,Ze,"Invalid decimal number, the number after the exponent mustn't start on an underscore")}return F(e,U),T(e,ie,"Invalid number with suffix, a suffix cannot start with a letter followed by an underscore")}else return F(e,U),T(e,Me);else if(e.flags.experimentalSuffixedNumbers)if(e.current===88||e.current===120){Z(e);let t=null;if(je(e,ws))t="Invalid number with suffix, a suffix cannot start with an x followed by a hexidecimal number";return F(e,U),T(e,Me,t)}else if(je(e,mi)){let t=null;if(je(e,wt))t="Invalid number with suffix, a suffix cannot start with a letter followed by a digit";return F(e,U),T(e,Me,t)}else if(k(e,44))return F(e,U),T(e,Me,"Invalid number with suffix, a suffix cannot start with a comma");else if(k(e,46))return F(e,U),T(e,Me,"Invalid number with suffix, a suffix cannot start with a dot");else if(je(e,U))return F(e,U),T(e,Me);else return T(e,Ze);else return T(e,Ze)}function dc(e){if(Z(e),e.current!=35)return F(e,U),T(e,ie);let t=bi(e);t.start.offset--,t.start.column--;let n;switch(t.type){case lt:case bt:n='Invalid raw string, the correct syntax is #" "#, not r#" "#';break;default:n="Invalid token, did you forget a whitespace after this r?"}return(t.errors??=[]).push(new I(n,{token:t})),t}function Os(e){return Z(e),F(e,U),T(e,ie)}function hr(e){throw Le(e,`Unexpected character ${JSON.stringify(String.fromCodePoint(e.current))}, did you forget to quote an identifier?`)}function*Sn(e,t){let n=yi(e,t);yield*$i(n);while(!n.currentIter.done){if(n.current<255){let r=j[n.current];yield r(n);continue}if(xn(n.current)){yield $n(n);continue}if(ut(n.current)){yield Nt(n);continue}yield Os(n)}yield T(n,at)}var gr,j;var Ei=v(()=>{Et();Si();gr=Array(256).fill(null);gr[98]=As("binary",ur,Js,hi);gr[111]=As("octal",cr,Es,gi);gr[120]=As("hexadecimal",lr,bs,ws);j=Array(255);j.fill(Os);for(let e=0;e<32;e++)j[e]=hr;j[9]=$n;j[10]=Nt;j[11]=Nt;j[12]=Nt;j[13]=Nt;j[32]=$n;j[34]=cc;j[35]=bi;j[40]=Jt(sr);j[41]=Jt(gn);j[43]=wi;j[45]=wi;j[46]=uc;j[47]=fc;j[48]=Re;j[49]=Re;j[50]=Re;j[51]=Re;j[52]=Re;j[53]=Re;j[54]=Re;j[55]=Re;j[56]=Re;j[57]=Re;j[59]=Jt(ar);j[61]=Jt(Vt);j[91]=hr;j[92]=Jt(fr);j[93]=hr;j[114]=dc;j[123]=Jt(or);j[125]=Jt(ir);j[133]=Nt;j[160]=$n});var qt=v(()=>{Ei()});var I;var Et=v(()=>{qt();I=class I extends Error{name="InvalidKdlError";start;end;token;errors;constructor(e,{token:t,start:n=t?.start,end:r=t?.end,errors:s,...o}={}){if(t?.type===at)e=`${e} at end of input`;else if(n)e=`${e} at ${n.line}:${n.column}`;super(e,o);this.token=t,this.start=n,this.end=r,this.errors=s}*flat(){if(this.errors==null){yield this;return}for(let e of this.errors)yield*e.flat()}}});function zt(e){return Ji.get(e)}function Ni(e,{start:t},{end:n}){Ji.set(e,{start:t,end:n})}var Ji;var Cs=v(()=>{Ji=new WeakMap});function Ai({experimentalSuffixedNumbers:e=!1}={}){return{experimentalSuffixedNumbers:e}}class _e{type="identifier";static type="identifier";representation;constructor(e){this.name=e}getName(){return this.name}setName(e){if(e!==this.name)this.name=e,this.representation=void 0}clone(){let e=new _e(this.name);return e.representation=this.representation,e}}class Fe{type="tag";static type="tag";representation;leading;trailing;suffix;constructor(e){this.name,Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!1,value:e})}getName(){return this.name}setName(e){if(e!==this.name)this.name=e,this.representation=void 0}clone(){let e=new Fe(this.name);return e.representation=this.representation,e.leading=this.leading,e.trailing=this.trailing,e.suffix=this.suffix,e}}class ke{type="value";static type="value";representation;tag=null;betweenTagAndValue;constructor(e){this.value=e}clone(){let e=new ke(this.value);return e.tag=this.tag?.clone()??null,e.betweenTagAndValue=this.betweenTagAndValue,e.representation=this.representation,e}getValue(){return this.value}setValue(e){if(e!==this.value)this.value=e,this.representation=void 0}getTag(){return this.tag?this.tag.name:null}setTag(e){if(e==null)this.tag=null;else if(this.tag!=null)this.tag.setName(e);else this.tag=new Fe(e)}}var vs=()=>{};class we{static createArgument(e){return new we(new ke(e),null)}static createProperty(e,t){return new we(new ke(t),new _e(e))}type="entry";static type="entry";name;value;leading;trailing;equals;constructor(e,t){this.value=e,this.name=t}clone(){let e=new we(this.value.clone(),this.name?.clone()??null);return e.leading=this.leading,e.trailing=this.trailing,e.equals=this.equals,e}getTag(){return this.value.getTag()}setTag(e){this.value.setTag(e)}getName(){return this.name?this.name.name:null}setName(e){this.name=e!=null?new _e(e):null}getValue(){return this.value.value}setValue(e){this.value=new ke(e)}isArgument(){return this.name==null}isProperty(){return this.name!=null}}var Ts=v(()=>{vs()});function*Kt(e){for(let t=e.length-1;t>=0;t--)yield e[t]}function js(e){return e.children??(e.children=new ft)}class Gt{static create(e){return new Gt(new _e(e))}type="node";static type="node";name;tag=null;entries;children;leading;trailing;beforeChildren;betweenTagAndName;constructor(e,t=[],n=null){this.name=e,this.entries=t,this.children=n}clone({shallow:e=!1}={}){let t=new Gt(this.name.clone(),e?[]:this.entries.map((n)=>n.clone()),this.children?.clone({shallow:e}));if(this.tag)t.tag=this.tag.clone();return t.leading=this.leading,t.betweenTagAndName=this.betweenTagAndName,t.beforeChildren=this.beforeChildren,t.trailing=this.trailing,t}getTag(){return this.tag?this.tag.name:null}setTag(e){this.tag=e!=null?new Fe(e):null}getName(){return this.name.name}setName(e){this.name.setName(e)}hasArguments(){return this.entries.some((e)=>e.isArgument())}getArguments(){return this.getArgumentEntries().map((e)=>e.getValue())}getArgumentEntries(){return this.entries.filter((e)=>e.isArgument())}hasArgument(e){return this.getArgumentEntry(e)!=null}getArgument(e){return this.getArgumentEntry(e)?.getValue()}getArgumentEntry(e){for(let t of this.entries){if(!t.isArgument())continue;if(e===0)return t;e--}}addArgument(e,t,n){let r=we.createArgument(e);if(r.value.setTag(t),n!=null)for(let[s,o]of this.entries.entries()){if(!o.isArgument())continue;if(n===0){this.entries.splice(s,0,o);return}n--}this.entries.push(r)}removeArgument(e){for(let[t,n]of this.entries.entries()){if(!n.isArgument())continue;if(e===0){this.entries.splice(t,1);return}e--}}hasProperties(){return this.entries.some((e)=>e.isProperty())}getProperties(){return new Map(this.getPropertyEntries().map((e)=>[e.getName(),e.getValue()]))}getPropertyEntries(){return this.entries.filter((e)=>e.isProperty())}getPropertyEntryMap(){return new Map(this.getPropertyEntries().map((e)=>[e.getName(),e]))}hasProperty(e){return this.getPropertyEntry(e)!=null}getProperty(e){return this.getPropertyEntry(e)?.getValue()}getPropertyEntry(e){for(let t of Kt(this.entries))if(t.getName()===e)return t;return}setProperty(e,t,n){for(let s of Kt(this.entries))if(s.getName()===e){s.setValue(t),s.value.setTag(n);return}let r=we.createProperty(e,t);r.value.setTag(n),this.entries.push(r)}deleteProperty(e){this.entries=this.entries.filter((t)=>t.getName()!==e)}hasChildren(){return this.children!=null&&!this.children.isEmpty()}appendNode(e){js(this).appendNode(e)}insertNodeBefore(e,t){js(this).insertNodeBefore(e,t)}insertNodeAfter(e,t){js(this).insertNodeAfter(e,t)}removeNode(e){if(this.children==null)throw Error("Node to remove is not in document");this.children.removeNode(e)}replaceNode(e,t){if(this.children==null)throw Error("Node to remove is not in document");this.children.replaceNode(e,t)}findNodesByName(e){return this.children!=null?this.children.findNodesByName(e):[]}findNodeByName(e){return this.children?.findNodeByName(e)}findParameterizedNode(e,t){return this.children?.findParameterizedNode(e,t)}removeNodesByName(e){this.children?.removeNodesByName(e)}}var Oi=v(()=>{Rs();Ts()});function*Yt(e){if(e instanceof ft)yield*e.nodes;else yield e}class ft{type="document";static type="document";nodes;trailing;constructor(e=[]){this.nodes=e}clone({shallow:e}={}){let t=new ft(e?[]:this.nodes.map((n)=>n.clone()));return t.trailing=this.trailing,t}appendNode(e){this.nodes.push(...Yt(e))}insertNodeBefore(e,t){if(t==null){this.nodes.push(...Yt(e));return}let n=this.nodes.indexOf(t);if(n===-1)throw Error("Reference node is not in document");this.nodes.splice(n,0,...Yt(e))}insertNodeAfter(e,t){if(t==null){this.nodes.unshift(...Yt(e));return}let n=this.nodes.indexOf(t);if(n===-1)throw Error("Reference node is not in document");this.nodes.splice(n+1,0,...Yt(e))}removeNode(e){let t=this.nodes.indexOf(e);if(t===-1)throw Error("Node to remove is not in document");this.nodes.splice(t,1)}replaceNode(e,t){let n=this.nodes.indexOf(e);if(n===-1)throw Error("Node to replace is not in document");this.nodes.splice(n,1,...Yt(t))}findNodesByName(e){return this.nodes.filter((t)=>t.name.name===e)}findNodeByName(e){for(let t of Kt(this.nodes))if(t.name.name===e)return t;return}findParameterizedNode(e,t){for(let n of Kt(this.nodes)){if(n.name.name!==e)continue;let r=n.getArguments();if(r.length!==1||t!==void 0&&r[0]!==t)continue;return n}return}removeNodesByName(e){this.nodes=this.nodes.filter((t)=>t.name.name!==e)}isEmpty(){return this.nodes.length===0}}var Rs=()=>{};var Ci=v(()=>{Rs();Ts();Oi();vs()});function vi(e,t,n){let r;while(r=gc.exec(t)){let s=bn(n,t,r.index);e.push(new I("Raw strings with single quotes cannot contain any unescaped newlines, use triple-quotes for multiline strings",{token:n,start:s,end:{offset:s.offset+r[0].length,line:s.line+1,column:1}}))}return t}function Ti(e,t,n){if(!Xt.test(t))return e.push(new I("Raw strings with three quotes must be multiline strings",{token:n})),t;if(!Xt.test(t[0]))return e.push(new I("Multi-line strings must start with a newline",{token:n})),t;let r=yc.exec(t)?.[1];if(r==null)return e.push(new I("The final line in a multiline string may only contain whitespace",{token:n})),t;return t.replace(Sc,(s,o,i,c,a)=>{if(!c)return`
30
+ `;if(!i.startsWith(r)){let l=bn(n,t,a+o.length);return e.push(new I("Every non-blank line of a multi-line string must start with the offset defined by the last line of the string",{token:n,start:l,end:{offset:l.offset+r.length,line:l.line,column:l.column+r.length}})),`
31
+ `}return`
32
+ `+i.slice(r.length)+c}).slice(1,-1)}function ji(e,t,n){let r;while(r=xc.exec(t)){let s=bn(n,t,r.indices[1][0]);e.push(new I("Strings with single quotes cannot contain any unescaped newlines, use triple-quotes for multiline strings",{token:n,start:s,end:{offset:s.offset+r[1].length,line:s.line+1,column:1}}))}return t.replace(wc,(s,o,i,c,a)=>_i(e,t,n,s,o,i,c,a))}function Ri(e,t,n){if(!hc.test(t))return e.push(new I("Strings with three quotes must be multiline strings",{token:n})),t;if(!Xt.test(t[0]))return e.push(new I("Multi-line strings must start with a newline",{token:n})),t;let r=$c.exec(t)?.[1];if(r==null){let s=bc.exec(t),o=s?bn(n,t,s.index):void 0,i="The final line in a multiline string may only contain whitespace";if(s?.[0][0]==="\\")i+=" after removing escaped whitespace";return e.push(new I(i,{token:n,start:o,end:o&&{offset:o.offset,line:o.line,column:o.column+1}})),t}return t.replace(Ec,(s,o,i,c,a,l,u)=>{if(!o)return _i(e,t,n,s,c,a,l,u);let f=t[u+o.length+(i?i.length:0)];if(Xt.test(f))return`
33
+ `;if(!i.startsWith(r)){let p=bn(n,t,u+o.length);return e.push(new I("Every non-blank line of a multi-line string must start with the offset defined by the last line of the string",{token:n,start:p,end:{offset:p.offset+r.length,line:p.line,column:p.column+r.length}})),`
34
+ `}return`
35
+ `+i.slice(r.length)}).slice(1,-1)}function _i(e,t,n,r,s,o,i,c){if(i)return"";if(o){let a=n.text.startsWith('"""'),l=t.slice(0,c).split(Xt),u={offset:n.start.offset+(a?3:1)+c,line:n.start.line+(l.length-1),column:l.length===1?n.start.column+(a?3:1)+c:l.at(-1).length},f={offset:u.offset+r.length,line:u.line,column:u.column+r.length};if(!o.startsWith("{"))e.push(new I(String.raw`Invalid unicode escape "\u${o}", did you forget to use {}? "\u{${o}}"`,{token:n,start:u,end:f}));else e.push(new I(String.raw`Invalid unicode escape "\u${o.endsWith("}")?o:`${o}...`}"`,{token:n,start:u,end:f}));return""}else if(s){let a=parseInt(s,16);if(a>=55296&&a<=57343)e.push(new I(String.raw`Invalid unicode escape "\u{${s}}, only scalar values can be added using an escape`,{token:n}));return String.fromCodePoint(a)}else{let a=mc.get(r);if(a==null)return e.push(new I(r.length<2?"Invalid whitespace escape at the end of a string":`Invalid escape "${r}"`,{token:n})),"";return a}}function bn(e,t,n){let r=1;switch(e.type){case Bt:r=3;break;case lt:r=e.text.indexOf('"')+1;break;case bt:r=e.text.indexOf('"')+3;break}let s=t.slice(0,n).split(Xt);return{offset:e.start.offset+r+n,line:e.start.line+(s.length-1),column:s.length===1?e.start.column+r+n:1+s[s.length-1].length}}var qp,mc,Xt,gc,hc,xc,yc,$c,Sc,bc,wc,Ec;var ki=v(()=>{Et();qt();qp=new Map([...Array.from({length:32},(e,t)=>[t,`\\u{${t.toString(16).padStart(2,"0")}}`]),[127,"\\u{7f}"],[8206,"\\u{200e}"],[8207,"\\u{200f}"],[8234,"\\u{202a}"],[8235,"\\u{202b}"],[8236,"\\u{202c}"],[8237,"\\u{202d}"],[8238,"\\u{202e}"],[8294,"\\u{2066}"],[8295,"\\u{2067}"],[8296,"\\u{2068}"],[8297,"\\u{2069}"],[65279,"\\u{feff}"],[34,"\\\""],[92,"\\\\"],[10,"\\n"],[11,"\\u{0b}"],[12,"\\f"],[13,"\\r"],[133,"\\u{85}"],[8232,"\\u{2028}"],[8233,"\\u{2029}"],[8,"\\b"],[9,"\\t"]]),mc=new Map([["\\n",`
36
+ `],["\\r","\r"],["\\t","\t"],["\\\\","\\"],["\\\"",'"'],["\\b","\b"],["\\f","\f"],["\\s"," "]]),Xt=/\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029]/,gc=/\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029]/g,hc=/(?:^|[^\\\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029])(?:\\\\)*[\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029]*(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])/s,xc=/(?:^|[^\\\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029])(?:\\\\)*[\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\x0A\x0B\x0C\x0D\x85\u2028\u2029]*(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])/dgs;yc=/[\x0A\x0B\x0C\x0D\x85\u2028\u2029]([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)$/,$c=/(?:^|[^\\\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000])(?:\\\\)*[\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*[\x0A\x0B\x0C\x0D\x85\u2028\u2029]([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)(?:\\[\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)*$/,Sc=/(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)([^\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]?)/g,bc=/([^\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000])[\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*$/;wc=/\\(?:$|u\{(0[0-9a-fA-F]{0,5}|10[0-9a-fA-F]{4}|[1-9a-fA-F][0-9a-fA-F]{0,4})\}|u(\{[^}]{1,6}\}?|[0-9a-fA-F]{1,5}|10[0-9a-fA-F]{4})|([\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]+)|.)/g;Ec=/(\x0D\x0A|[\x0A\x0B\x0C\x0D\x85\u2028\u2029])([\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]*)|\\(?:$|u\{(0[0-9a-fA-F]{0,5}|10[0-9a-fA-F]{4}|[1-9a-fA-F][0-9a-fA-F]{0,4})\}|u(\{[^}]{1,6}\}?|[0-9a-fA-F]{1,5}|10[0-9a-fA-F]{4})|([\x0A\x0B\x0C\x0D\x85\u2028\u2029\uFEFF\u0009\u0020\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]+)|.)/g});function et(e){if(!e.current.done)e.lastToken=e.current.value;e.current=e.tokens.next();let t=!e.current.done&&e.current.value.errors;if(t)e.errors.push(...t)}function W(e,t){if(!e.current.done&&e.current.value.type===t){let n=e.current.value;return et(e),n}}function R(e,t){let n="current"in e?e.current.value??e.lastToken:e;return new I(t,{token:n})}function ge(e,t,n,r=n){if(e.storeLocations)Ni(t,n,r)}function ae(e="",t="",n=""){return e+t+n||void 0}function $r(e,t,{storeLocations:n=!1,flags:r}){let s={type:-1,text:"",start:{offset:0,line:1,column:1},end:{offset:0,line:1,column:1},errors:null},o={text:e,tokens:t[Symbol.iterator](),current:{done:!1,value:s},storeLocations:n,lastToken:s,errors:[],flags:r};return et(o),o}function ks(e,t){if(!t&&!e.current.done&&e.current.value.type!==at)t=R(e,`Unexpected token ${JSON.stringify(e.current.value.text)}, did you forget to quote an identifier?`);let n=e.errors??[];if(t!=null)if(t instanceof I)if(t.errors)n.push(...t.errors);else n.push(t);else n.push(new I(`An unexpected error occurred, ${String(t)}, this is likely a bug in the KDL parser`,{cause:t}));if(n.length)if(n.length===1)throw n[0];else throw new I("Encountered multiple errors",{errors:n})}function xr(e){switch(e){case"#null":return null;case"#true":return!0;case"#false":return!1;case"#inf":return 1/0;case"#-inf":return-1/0;case"#nan":return NaN}}function Pi(e){return e==="inf"||e==="-inf"||e==="nan"||e==="true"||e==="false"||e==="null"||!1}function Ps(e){let{value:t}=e.current,n,r,s,o,i,c=!1;if(t?.text[0]==="-"||t?.text[0]==="+")i=t.text[0];switch(t?.type){case Me:{if(!e.flags.experimentalSuffixedNumbers)throw new I("Unreachable code: got a suffixed number from the tokenizer but the suffixed number flag is not set",{token:t});let u=i?t.text.slice(1):t.text,f=u.search(/[^0-9._]/);if(r=(i??"")+u.slice(0,f),n=Number.parseFloat(r.replaceAll("_","")),o=s=u.slice(f),Pi(s))e.errors.push(R(e,`Invalid suffix ${s}, values that look like keywords cannot be used as suffix`))}break;case ur:c=!0,n=(i==="-"?-1:1)*Number.parseInt(t.text.slice(i?3:2).replaceAll("_",""),2);break;case cr:c=!0,n=(i==="-"?-1:1)*Number.parseInt(t.text.slice(i?3:2).replaceAll("_",""),8);break;case Ze:c=!0,n=Number.parseFloat(t.text.replaceAll("_",""));break;case lr:c=!0,n=(i==="-"?-1:1)*Number.parseInt(t.text.slice(i?3:2).replaceAll("_",""),16);break;case Ht:if(n=xr(t.text),n===void 0)if(n=null,xr(t.text.toLowerCase())!==void 0)e.errors.push(R(e,`Invalid keyword ${t.text}, keywords are case sensitive, write ${t.text.toLowerCase()} instead`));else switch(t.text.toLowerCase()){case"#nul":case"#nill":e.errors.push(R(e,`Invalid keyword ${t.text}, did you mean #null?`));break;case"#fals":case"#fasle":e.errors.push(R(e,`Invalid keyword ${t.text}, did you mean #false?`));break;case"#ture":case"#treu":e.errors.push(R(e,`Invalid keyword ${t.text}, did you mean #true?`));break;case"#ifn":e.errors.push(R(e,`Invalid keyword ${t.text}, did you mean #inf?`));break;case"#-ifn":e.errors.push(R(e,`Invalid keyword ${t.text}, did you mean #-inf?`));break;default:e.errors.push(R(e,`Invalid keyword ${t.text}, surround it with quotes to use a string`))}break;default:return}et(e);let a=e.flags.experimentalSuffixedNumbers&&W(e,Ht);if(a)if(c){if(o=a.text,xr(o)!==void 0)e.errors.push(R(a,`Invalid number suffix ${o}, did you forget a space between the number and the keyword?`));s=o.slice(1)}else if(s)e.errors.push(R(a,"Unexpected hashed suffix, a number can only have one suffix"));else if(typeof n==="number")e.errors.push(R(a,"Unexpected hashed suffix, you cannot place suffixes on number keywords"));else e.errors.push(R(a,"Unexpected hashed suffix, you can only place suffixes on numbers"));let l=new ke(n);if(l.representation=r??t.text,ge(e,l,t),s){let u=new Fe(s);u.representation=o,u.suffix=!0,ge(e,u,e.lastToken),l.tag=u}return l}function wn(e){if(e.current.done)return;let{value:t}=e.current,n;switch(t.type){case ie:if(et(e),Pi(t.text))e.errors.push(R(e,`Invalid keyword "${t.text}", add a leading # to use the keyword or surround with quotes to make it a string`));n=[t.text,t.text,t];break;case hn:et(e),n=[ji(e.errors,t.text.slice(1,-1),t),t.text,t];break;case Bt:et(e),n=[Ri(e.errors,t.text.slice(3,-3),t),t.text,t];break;case lt:{et(e);let r=t.text,s=r.indexOf('"');n=[vi(e.errors,r.slice(s+1,-(s+1)),t),r,t];break}case bt:{et(e);let r=t.text,s=r.indexOf('"');n=[Ti(e.errors,r.slice(s+3,-(s+3)),t),r,t];break}default:return}if(W(e,Ht))e.errors.push(R(e.lastToken,xr(e.lastToken.text)===void 0?"Unexpected hashed suffix on a string, you can only place suffixes on numbers":"Unexpected keyword, did you forget to add whitespace?"));return n}function Is(e){let t=wn(e);if(!t)return;let n=new _e(t[0]);return n.representation=t[1],ge(e,n,t[2],e.lastToken),n}function yr(e){let t=Ps(e);if(t)return t;let n=wn(e);if(!n)return;let r=new ke(n[0]);return r.representation=n[1],ge(e,r,n[2],e.lastToken),r}function En(e){let t=W(e,pr);if(!t)return;let{value:n}=e.current;return et(e),t.text+(n?.text??"")}function Sr(e){return W(e,dr)?.text}function Ds(e){return W(e,St)??Sr(e)}function br(e){let t=W(e,fr);if(!t)return;while(Ds(e));if(!En(e)&&!W(e,ct)&&!W(e,at))e.errors.push(R(e,`Expected newline or single-line comment after backslash but got ${e.current.value?.text??"EOF"}`));return e.text.slice(t.start.offset,e.lastToken.end.offset)}function pt(e){let t=e.lastToken.end;while(W(e,ct)?.text??En(e)??Ds(e)??br(e));if(e.lastToken.end===t)return;return e.text.slice(t.offset,e.lastToken.end.offset)}function ee(e){let t=e.lastToken.end;while(Ds(e)??br(e));if(e.lastToken.end===t)return;return e.text.slice(t.offset,e.lastToken.end.offset)}function _s(e){let t=W(e,sr);if(!t)return;let n=ee(e),r=wn(e);if(!r&&e.current.value){let c=e.current.value;if(pt(e))e.errors.push(R(c,"This type of whitespace is not allowed inside a tag"));r=wn(e)}if(!r){if(Ps(e))e.errors.push(R(e,"Invalid tag, did you forget to quote a string?")),r=["error","error"]}if(!r)throw R(e,"Invalid tag, did you forget to quote a string?");let s=ee(e),o=W(e,gn);if(!o&&e.current.value){let c=e.current.value;if(pt(e))e.errors.push(R(c,"This type of whitespace is not allowed inside a tag"));o=W(e,gn)}if(!o)throw R(e,"Invalid tag, did you forget to quote a string?");let i=new Fe(r[0]);return i.representation=r[1],i.leading=n,i.trailing=s,ge(e,i,t,e.lastToken),i}function wr(e){return En(e)??W(e,ct)?.text??W(e,ar)?.text??W(e,at)?.text}function Ms(e){if(!W(e,or))return;let t=Li(e);if(!W(e,ir))throw R(e,"Invalid node children");return t}function Zt(e){let t=e.current.value;{let f=_s(e);if(f){let p=ee(e),d=yr(e);if(!d)throw R(e,"Invalid argument");if(d.tag)e.errors.push(R(e.lastToken,"A number suffix cannot be combined with a regular tag"));d.tag=f,d.betweenTagAndValue=p;let h=new we(d,null);ge(e,d,t,e.lastToken),ge(e,h,t,e.lastToken);let g=ee(e);if(W(e,Vt))e.errors.push(R(e.lastToken,typeof d.value==="string"?"Unexpected equals sign, properties are name=(tag)value not (tag)name=value":"Unexpected equals sign")),g=ae(g,ee(e))||" ";return[h,g]}}{let f=Ps(e);if(f){let p=new we(f,null);ge(e,p,t,e.lastToken);let d=ee(e);if(W(e,Vt))e.errors.push(R(e.lastToken,"Unexpected equals sign, did you forget to quote the property name?")),d=ae(d,ee(e))||" ";return[p,d]}}let n=wn(e);if(!n)return;let r=ee(e),s=W(e,Vt);if(!s){let f=new ke(n[0]);f.representation=n[1],ge(e,f,n[2]);let p=new we(f,null);return ge(e,p,t,e.lastToken),[p,r]}let o=new _e(n[0]);o.representation=n[1],ge(e,o,n[2]);let i=ee(e),c=_s(e),a=c&&ee(e),l=yr(e);if(!l)throw R(e,"Expected a value");if(c){if(l.tag)e.errors.push(R(e.lastToken,"A number suffix cannot be combined with a regular tag"));l.tag=c,l.betweenTagAndValue=a}let u=new we(l,o);return ge(e,u,t,e.lastToken),u.equals=ae(r,s.text,i),[u,void 0]}function Ii(e){let t=ee(e)??"",n;while(n=At(e)){let i=e.lastToken.end,c=Zt(e);if(!c)throw R(e,"Expected a property or argument");if(!(c[1]??ee(e)))throw R(e,"Expected space after slashdashed property or argument");t=t+n+e.text.slice(i.offset,e.lastToken.end.offset)}let r=Zt(e);if(!r)return;let s=r[1]??ee(e)??"";while(n=At(e)){let i=e.lastToken.end,c=Zt(e);if(!c)throw R(e,"Expected a property or argument");if(!(c[1]??ee(e)))break;s=s+n+e.text.slice(i.offset,e.lastToken.end.offset)}let o=r[0];return o.leading=t,o.trailing=s,o}function At(e){let t=W(e,$t)?.text;if(!t)return;return ae(t,pt(e))}function Er(e){let t=e.current.value,n=_s(e),r=n&&ee(e),s=Is(e);if(!s)if(n)throw R(e,"Couldn't find node name");else return;let o=ee(e),i=o!=null,c=At(e),a=[];while(i||c){let p=e.lastToken.end,d=Zt(e);if(!d)break;if(c)i=(d[1]||ee(e))!=null,o=ae(o,c,e.text.slice(p.offset,e.lastToken.end.offset)),c=At(e);else{let h=d[0];h.leading=o,a.push(h),o=d[1]||ee(e),i=o!=null,c=At(e)}}let l,u;while(!0){c??=At(e);let p=e.lastToken.end,d=Ms(e);if(!d){if(c)throw R(e,"Unexpected slashdash");break}if(c)o=ae(o,c,e.text.slice(p.offset,e.lastToken.end.offset)),c=void 0;else{if(l)e.errors.push(R(e,"A node can only have one children block"));l=d,u=o??"",o=void 0}o=ae(o,ee(e))}let f=new Gt(s,a,l);return f.tag=n??null,f.betweenTagAndName=r,f.beforeChildren=u,f.trailing=o??"",ge(e,f,t,e.lastToken),f}function Di(e){let t=pt(e),n=Er(e);if(!n)return;let r=ae(wr(e),pt(e));return n.leading=ae(t,n.leading),n.trailing=ae(n.trailing,r),n}function Mi(e){let t=W(e,Wt)?.text,n=Li(e);if(!t)return n;if(n.nodes[0])n.nodes[0].leading=ae(t,n.nodes[0].leading);else n.trailing=ae(t,n.trailing);return n}function Li(e){let t=e.current.value,n=[],r=!0,s=pt(e);while(r){let i=e.lastToken.end,c=At(e),a=Er(e);if(!a){if(c)throw R(e,"Unexpected slashdash");break}let l=ee(e),u=wr(e);if(c)s=ae(s,e.text.slice(i.offset,e.lastToken.end.offset),pt(e));else a.trailing=ae(a.trailing,l,u)??"",n.push(a),a.leading=s??"",s=pt(e);r=u!=null}let o=new ft(n);return ge(e,o,t,e.lastToken),o.trailing=s??"",o}var Ls=v(()=>{Et();Cs();Ci();ki();qt()});function Fi(e,t){let n=[],r;while(r=t(e))n.push(r);return n.length>0?n:void 0}function Jc(e){{let t=W(e,Wt);if(t)return{type:"bom",text:t.text}}{let t=W(e,ct);if(t)return{type:"newline",text:t.text}}{let t=W(e,St);if(t)return{type:"space",text:t.text}}{let t=En(e);if(t)return{type:"singleline",text:t}}{let t=Sr(e);if(t)return{type:"multiline",text:t}}return}function Jr(e){{let t=br(e);if(t)return{type:"line-escape",text:t}}{let t=W(e,St);if(t)return{type:"space",text:t.text}}{let t=Sr(e);if(t)return{type:"multiline",text:t}}return}function Wi(e){let t=[];while(!0){{let n=Jc(e);if(n){t.push(n);continue}}if(W(e,$t)?.text){let r,s=Fi(e,Jr)??[],o=Er(e);if(!o)throw R(e,"Invalid slashdash, expected a commented node");o.trailing=ae(o.trailing,Fi(e,Jr)?.map((i)=>i.text).join(""),wr(e)),t.push({type:"slashdash",preface:s,value:o});continue}break}return t}function Nc(e){let t=W(e,$t);if(t==null)return;let n,r=[];while(n=Jr(e))r.push(n);let s,o,i="";if(o=Zt(e)){if(s=o[0],o[1])i=o[1]}else if(o=Ms(e))s=o;else throw R(t,"Couldn't find argument, property, or children that were commented by slashdash");return[{type:"slashdash",preface:r,value:s},i]}function Fs(e){let t=[];while(!0){let n=Jr(e);if(!n)break;let r=!0;t.push(n);while(r){let s=Nc(e);if(!s)break;if(t.push(s[0]),s[1][0])t.push(...Fs($r(s[1][0],Sn(s[1][0],{flags:e.flags}),{flags:e.flags})));r=!!s[1][0]}}return t}var Vi=v(()=>{qt();Ls()});function dt(e,{as:t="document",flags:n,...r}={}){let s=Ac[t];if(s==null)throw TypeError(`Invalid "as" target passed: ${JSON.stringify(t)}`);if(typeof e!=="string"){if(typeof TextDecoder!=="function")throw TypeError("Uint8Array input is only supported on platforms that include TextDecoder");e=new TextDecoder("utf-8",{fatal:!0}).decode(e)}let o=Ai(n),i=Sn(e,{...r,flags:o}),c=$r(e,i,{...r,flags:o}),a;try{a=s(c)}catch(l){ks(c,l)}if(ks(c),!a)throw new I(`Expected ${/^[aeiouy]/.exec(t)?"an":"a"} ${t}`);return a}var Ac;var Hi=v(()=>{Et();qt();Ls();Vi();Ac={value:yr,identifier:Is,node:Di,entry:Ii,document:Mi,"whitespace in document":Wi,"whitespace in node":Fs}});var Nr=v(()=>{Et();Cs();Hi()});function Qt(e,t){let n=e.slice(0,t),r=n.split(`
37
+ `).length;return{column:t-n.lastIndexOf(`
38
+ `),line:r,offset:t}}var he;var Jn=v(()=>{he=class he extends Error{column;line;offset;reason;constructor(e,t=null){super(t?`${e} (line ${t.line}, column ${t.column})`:e);this.name="JxnError",this.column=t?.column??null,this.line=t?.line??null,this.offset=t?.offset??null,this.reason=e}inFile(e){let t=this.line!==null&&this.column!==null&&this.offset!==null?{column:this.column,line:this.line,offset:this.offset}:null;return new he(`${e}: ${this.reason}`,t)}}});var Bi;var Ui=v(()=>{Bi=new Set(["onabort","onactivate","onaddsourcebuffer","onaddtrack","onadvertisementreceived","onafterprint","onanimationcancel","onanimationend","onanimationiteration","onanimationstart","onappinstalled","onaudioend","onaudioprocess","onaudiostart","onauxclick","onavailabilitychanged","onbackgroundfetchabort","onbackgroundfetchclick","onbackgroundfetchfail","onbackgroundfetchsuccess","onbeforeinput","onbeforeinstallprompt","onbeforematch","onbeforeprint","onbeforetoggle","onbeforexrselect","onbegin","onblocked","onblur","onboundary","onbufferedamountlow","onbufferedchange","oncancel","oncanmakepayment","oncanplay","oncanplaythrough","oncaptureaction","oncapturedmousechange","oncapturehandlechange","onchange","oncharacterboundsupdate","oncharacteristicvaluechanged","onchargingchange","onchargingtimechange","onclick","onclose","onclosing","oncommand","oncomplete","oncompositionend","oncompositionstart","onconfigurationchange","onconnect","onconnecting","onconnectionavailable","onconnectionstatechange","oncontentdelete","oncontextlost","oncontextmenu","oncontextoverflow","oncontextrestored","oncontrollerchange","oncookiechange","oncopy","oncuechange","oncurrententrychange","oncurrentscreenchange","oncut","ondataavailable","ondatachannel","ondblclick","ondequeue","ondevicechange","ondevicemotion","ondeviceorientation","ondeviceorientationabsolute","ondischargingtimechange","ondisconnect","ondispose","ondownloadprogress","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onencrypted","onend","onended","onendstreaming","onenter","onenterpictureinpicture","onerror","onexit","onfencedtreeclick","onfetch","onfinish","onfocus","onformdata","onframeratechange","onfreeze","onfullscreenchange","onfullscreenerror","ongamepadconnected","ongamepaddisconnected","ongatheringstatechange","ongattserverdisconnected","ongeometrychange","ongotpointercapture","onhashchange","onicecandidate","onicecandidateerror","oniceconnectionstatechange","onicegatheringstatechange","oninput","oninputreport","oninputsourceschange","oninstall","oninstallresult","oninvalid","onisolationchange","onkeydown","onkeyframerequest","onkeypress","onkeystatuseschange","onkeyup","onlanguagechange","onlayoutchange","onleavepictureinpicture","onlevelchange","onload","onloadeddata","onloadedmetadata","onloadend","onloading","onloadingdone","onloadingerror","onloadstart","onlocation","onlostpointercapture","onmanagedconfigurationchange","onmark","onmessage","onmessageerror","onmidimessage","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmute","onnavigate","onnavigateerror","onnavigatesuccess","onnegotiationneeded","onnomatch","onnotificationclick","onnotificationclose","onoffline","ononline","onopen","onorientationchange","onpagehide","onpagereveal","onpageshow","onpageswap","onpaste","onpause","onpayerdetailchange","onpaymentmethodchange","onpaymentrequest","onperiodicsync","onplay","onplaying","onpointercancel","onpointerdown","onpointerenter","onpointerleave","onpointerlockchange","onpointerlockerror","onpointermove","onpointerout","onpointerover","onpointerrawupdate","onpointerup","onpopstate","onportalactivate","onprerenderingchange","onprioritychange","onprocessorerror","onprogress","onpromptaction","onpromptdismiss","onpush","onpushsubscriptionchange","onquotaoverflow","onratechange","onreading","onreadingerror","onreadystatechange","onredraw","onreflectionchange","onrejectionhandled","onrelease","onremove","onremovesourcebuffer","onremovetrack","onrepeat","onreset","onresize","onresourcetimingbufferfull","onresult","onresume","onrtctransform","onscreenschange","onscroll","onscrollend","onsecuritypolicyviolation","onseeked","onseeking","onselect","onselectedcandidatepairchange","onselectend","onselectionchange","onselectstart","onserviceadded","onservicechanged","onserviceremoved","onshippingaddresschange","onshippingoptionchange","onshow","onsignalingstatechange","onsinkchange","onslotchange","onsnapchanged","onsnapchanging","onsoundend","onsoundstart","onsourceclose","onsourceended","onsourceopen","onspeechend","onspeechstart","onsqueeze","onsqueezeend","onsqueezestart","onstalled","onstart","onstartstreaming","onstatechange","onstop","onstorage","onstream","onsubmit","onsuccess","onsuspend","onsync","onterminate","ontextformatupdate","ontextupdate","ontimeout","ontimeupdate","ontoggle","ontonechange","ontoolactivated","ontoolcancel","ontoolchange","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ontrack","ontransitioncancel","ontransitionend","ontransitionrun","ontransitionstart","onuncapturederror","onunhandledrejection","onunload","onunmute","onupdate","onupdateend","onupdatefound","onupdatestart","onupgradeneeded","onvalidationstatuschange","onversionchange","onvisibilitychange","onvoiceschanged","onvolumechange","onwaiting","onwaitingforkey","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel","onzoomlevelchange"])});function M(e,t,n,r,s){let o=t.normalize("NFC");if(o==="__proto__")throw V(r,s,'"__proto__" cannot be a key: it would not be data');if(Object.hasOwn(e,o))throw V(r,s,`"${o}" is written twice, and one of them would be lost`);e[o]=n}function V(e,t,n){let r=qi(t)?.start;return new he(n,r===void 0?null:Qt(e.text,r))}function qi(e){let t=zt(e);return t?{end:t.end.offset,start:t.start.offset}:null}function xe(e,t,n){let r=e.spans?qi(n):null;if(r)e.spans?.set(t,r)}function Pe(e){return e.replaceAll("~","~0").replaceAll("/","~1")}function Or(e,t){let n=t.getTag();if(n!==null&&!Cc.has(n))throw V(e,t,`(${n}) is not an annotation Jx Notation has`);if(n==="ref")throw V(e,t,"(ref) annotates a value, and this is a name");return n}function en(e,t){let n=t.getTag(),r=t.getValue();if(n!==null&&n!=="ref")throw V(e,t,`(${n}) cannot annotate a value here; only (ref) can`);if(se(r)){if(!Number.isFinite(r))throw V(e,t,"JSON has no way to hold #inf or #nan");if(Number.isInteger(r)&&!Number.isSafeInteger(r))throw V(e,t,"This number is too large to survive being read as JSON")}if(n==="ref"){if(!b(r))throw V(e,t,"(ref) needs a string");return{$ref:r}}return r}function Ot(e,t){return t.entries.filter((n)=>!n.name).map((n)=>en(e,n))}function Ct(e){return e.entries.filter((t)=>t.name)}function Ae(e){return e.children?.nodes??[]}function Nn(e){return e.getName()??""}function Tc(e,t,n){let r={$prototype:"Function"},s=Ot(e,t),o=Ae(t);for(let i of Ct(t))M(r,Nn(i),en(e,i),e,i);if(o.length>0){if(s.length>0)M(r,"parameters",s,e,t);M(r,"body",Ws(e,o,`${n}/body`),e,t)}else if(s.length>0){let i=s.at(-1)??null,c=s.slice(0,-1);if(c.length>0)M(r,"parameters",c,e,t);M(r,"body",i,e,t)}return xe(e,n,t),r}function Ws(e,t,n){return t.map((r,s)=>{if(r.getName()!=="-")throw V(e,r,`A list holds only "-" items, and this is "${r.getName()}"`);return We(e,r,`${n}/${s}`)})}function We(e,t,n){let r=Or(e,t);if(xe(e,n,t),r==="fn")return Tc(e,t,n);let s=Ot(e,t),o=Ct(t),i=Ae(t);if(r==="array"){if(o.length>0)throw V(e,t,"(array) holds items, and these are named");return[...s,...Ws(e,i,n)]}if(r!=="object"){if(s.length>1){if(o.length>0||i.length>0)throw V(e,t,"A list of values cannot also have names or a block");return s}if(s.length===1){if(o.length>0||i.length>0)throw V(e,t,"A value cannot also have names or a block");return s[0]??null}if(i.length>0&&o.length===0&&i.every((a)=>a.getName()==="-"))return Ws(e,i,n)}else if(s.length>0)throw V(e,t,"(object) holds names, and this is a value");let c={};for(let a of o){let l=Nn(a);M(c,l,en(e,a),e,a),xe(e,`${n}/${Pe(l)}`,a)}for(let a of i){let l=a.getName();M(c,l,We(e,a,`${n}/${Pe(l)}`),e,a)}return c}function zi(e,t,n){let r={};if(xe(e,n,t),Ot(e,t).length>0)throw V(e,t,"A style block holds declarations, and this is a value");for(let s of Ct(t)){let o=Nn(s);M(r,o,en(e,s),e,s),xe(e,`${n}/${Pe(o)}`,s)}for(let s of Ae(t)){let o=s.getName(),i=`${n}/${Pe(o)}`,c=Ae(s);if(s.getTag()==="array"||c.length>0&&c.every((l)=>l.getName()==="-")){M(r,o,We(e,s,i),e,s);continue}let a=Ot(e,s);if(a.length>1)throw V(e,s,`"${o}" has more than one value. A selector with a space in it needs quotes`);if(a.length===1){if(Ct(s).length>0||Ae(s).length>0)throw V(e,s,`"${o}" has a value and names. A selector with a space in it needs quotes`);M(r,o,a[0]??null,e,s),xe(e,i,s)}else M(r,o,zi(e,s,i),e,s)}return r}function Ar(e,t,n){let r=Ae(t);if(r.length!==1||!r[0])throw V(e,t,`"${t.getName()}" holds one element`);return Gi(e,r[0],n)}function Ki(e,t,n){let r={$prototype:"Array"};if(xe(e,n,t),Ot(e,t).length>0)throw V(e,t,"$array holds names and one element, and this is a value");for(let s of Ct(t)){let o=Nn(s);M(r,o.startsWith(".")?o.slice(1):o,en(e,s),e,s)}if(Ae(t).length>0)M(r,"map",Ar(e,t,`${n}/map`),e,t);return r}function Gi(e,t,n){let r=t.getName();if(r==="-"){let s=Ot(e,t);if(s.length!==1||Ct(t).length>0||Ae(t).length>0)throw V(e,t,'"-" is one piece of text or one (ref)');return xe(e,n,t),s[0]??null}if(r==="$array")return Ki(e,t,n);return Vs(e,t,n)}function jc(e,t,n,r){let s=Or(e,n);if(t==="map")return Ar(e,n,r);if(t==="cases"){let o={};for(let i of Ae(n)){let c=i.getName();M(o,c,Ar(e,i,`${r}/${Pe(c)}`),e,i)}return o}if(t==="children"&&s!=="array"&&Ae(n).length>0)return Ar(e,n,r);return We(e,n,r)}function Vs(e,t,n){let r={},s=t.getName(),o=Or(e,t);if(xe(e,n,t),o!==null)throw V(e,t,`(${o}) cannot annotate an element`);let i=Ot(e,t);if(s==="$element"){let[a,l,...u]=i;if(u.length>0)throw V(e,t,"$element takes at most a tag and a text value");if(a!==void 0)M(r,"tagName",a,e,t);if(l!==void 0)M(r,"textContent",l,e,t)}else{if(s.startsWith("$"))throw V(e,t,`"${s}" is not a kind of element`);if(M(r,"tagName",s,e,t),i.length>1)throw V(e,t,"An element has one text value. A list of them needs a block");if(i[0]!==void 0)M(r,"textContent",i[0],e,t),xe(e,`${n}/textContent`,t)}Rc(e,t,r,n);let c=[];for(let a of Ae(t))_c(e,a,r,c,n);if(c.length>0)M(r,"children",c,e,t);return r}function Yi(e){let{attributes:t}=e;if(D(t))return t;let n={};return e.attributes=n,n}function Rc(e,t,n,r){for(let s of Ct(t)){let o=Nn(s),i=s.getTag();if(i==="fn")throw V(e,s,"A function has a block form: (fn)name, on a line of its own");let c=en(e,s);if(o.startsWith(".")||o.startsWith("$")){let a=o.startsWith(".")?o.slice(1):o;M(n,a,c,e,s),xe(e,`${r}/${Pe(a)}`,s)}else if(o.startsWith("on")&&i==="ref")M(n,o,c,e,s),xe(e,`${r}/${Pe(o)}`,s);else if(o.startsWith("on")&&Bi.has(o))throw V(e,s,`${o} needs (ref)"pointer", or a function on a line of its own: (fn)${o} "…"`);else M(Yi(n),o,c,e,s),xe(e,`${r}/attributes/${Pe(o)}`,s)}}function _c(e,t,n,r,s){let o=t.getName(),i=Or(e,t),c=(a)=>`${s}/${Pe(a)}`;if(i==="fn"||i==="on"){if(!o.startsWith("on"))throw V(e,t,`(${i}) in an element marks a handler, and "${o}" is not one`);M(n,o,We(e,t,c(o)),e,t)}else if(o==="script")throw V(e,t,'"script" is reserved. A <script> element is $element "script"');else if(o==="state")M(n,"state",We(e,t,c("state")),e,t);else if(o==="style")M(n,"style",zi(e,t,c("style")),e,t);else if(o==="attributes"){let a=We(e,t,c("attributes"));if(D(a))for(let[l,u]of Object.entries(a))M(Yi(n),l,u,e,t);else M(n,"attributes",a,e,t)}else if(o.startsWith(".")){let a=o.slice(1);M(n,a,jc(e,a,t,c(a)),e,t)}else if(o.startsWith("$")&&o!=="$array"&&o!=="$element")M(n,o,We(e,t,c(o)),e,t);else{if(vc.has(o))throw V(e,t,`"${o}" is reserved here`);r.push(Gi(e,t,`${s}/children/${r.length}`))}}function kc(e,t){return Ae(t).map((n,r)=>{let s=`/$head/${r}`;return n.getName()==="-"?We(e,n,s):Vs(e,n,s)})}function Pc(e){let t=Oc.exec(e);if(t)throw new he(`A raw control character (U+${t[0].codePointAt(0)?.toString(16).toUpperCase().padStart(4,"0")}) cannot be in a Jx Notation file. Escape it, as \\u{1b}`,Qt(e,t.index));try{return dt(e,{storeLocations:!0})}catch(n){let s=(n instanceof I?n.errors?.[0]??n:null)?.start,o=n instanceof Error?n.message:String(n);throw new he(o.split(`
39
+ `)[0]??o,s?Qt(e,s.offset):null)}}function Xi(e){if(ys(e.text)==="project")throw new he('This is a project file: its first node is "project". A document has an element there, and a <project> element is $element "project"');let n=Pc(e.text),r={},s=null;for(let o of n.nodes){let i=o.getName();if(i==="$head"&&o.getTag()===null)M(r,i,kc(e,o),e,o);else if(i.startsWith("$")&&i!=="$array"&&i!=="$element")M(r,i,We(e,o,`/${Pe(i)}`),e,o),xe(e,`/${Pe(i)}`,o);else if(s)throw V(e,o,"A document has one root element, and this is a second");else s=o}if(s){let o=s.getName()==="$array"?Ki(e,s,""):Vs(e,s,"");for(let[i,c]of Object.entries(o))M(r,i,c,e,s)}return nr(r)}function An(e,t){try{return Xi({spans:null,text:e})}catch(n){throw t!==void 0&&n instanceof he?n.inFile(t):n}}function Hs(e){let t=new Map;return{document:Xi({spans:t,text:e}),spans:t}}var Oc,Cc,vc;var Cr=v(()=>{Nr();K();rr();$s();Jn();Ui();Oc=/(?![\t\n\v\f\r])\p{Cc}/u,Cc=new Set(["array","fn","object","on","ref"]),vc=new Set(["attributes","script","state","style"])});function Bs(e){return e.toLowerCase().endsWith(".jxn")}function On(e){return e.endsWith(".json")||Bs(e)}function Cn(e,t){return Bs(t)?An(e,t):di(e,t)}var Zi=v(()=>{rr();Cr()});function Dc(e){let t={comments:0,escapes:[]},n=0;while(n<e.length)if(e.startsWith("//",n)){t.comments+=1;let r=e.indexOf(`
40
+ `,n);n=r===-1?e.length:r}else if(e.startsWith("/*",n)){t.comments+=1;let r=e.indexOf("*/",n+2);n=r===-1?e.length:r+2}else if(e.startsWith("/-",n))t.comments+=1,n+=2;else if(e.charAt(n)==="#"&&/^#+"/u.test(e.slice(n,n+16))){let[r=""]=/^#+/u.exec(e.slice(n))??[],s=n+r.length,o=e.startsWith('"""',s)?'"""':'"',i=e.indexOf(o+r,s+o.length);n=i===-1?e.length:i+o.length+r.length}else if(e.charAt(n)==='"'){let r=e.startsWith('"""',n)?'"""':'"';n+=r.length;while(n<e.length&&!e.startsWith(r,n))if(e.charAt(n)==="\\")t.escapes.push(n),n+=2;else n+=1;n+=r.length}else n+=1;return t}function Mc(e){return Dc(e).escapes.flatMap((t)=>{let n=Ic.get(e.charAt(t+1));return n?[{...Qt(e,t),message:n}]:[]})}var Ic;var Qi=v(()=>{Jn();Ic=new Map([["b",String.raw`\b in a quoted string is a backspace, not a word boundary. Use a raw string, like #"…"#, if this is a pattern.`],["s",String.raw`\s in a quoted string is a space, not whitespace. Use a raw string, like #"…"#, if this is a pattern.`]])});function tn(e,t=!1){if(Array.isArray(e))return`[${e.map((s)=>tn(s,t)).join(",")}]`;if(!D(e))return e===void 0?"null":JSON.stringify(e);return`{${(t?Object.keys(e):Object.keys(e).toSorted()).map((s)=>`${JSON.stringify(s)}:${tn(e[s],t||s==="style")}`).join(",")}}`}function Lc(e,t){let n=e;for(let r of t.split("/").slice(1)){let s=r.replaceAll("~1","/").replaceAll("~0","~");if(Array.isArray(n))n=n[Number(s)];else n=D(n)?n[s]:void 0}return n}function Fc({spans:e}){let t=new Map;for(let[n,r]of e){let s=t.get(r.start);if(s===void 0||n.length<s.length)t.set(r.start,n)}return t}function ea(e,t){let n=Fc(e),r=new Map;for(let[s,o]of n)r.set(s,tn(Lc(e.document,o)));return{meanings:r,pointers:n,text:t}}function tt(e){let t=zt(e);return{end:t?.end.offset??0,start:t?.start.offset??0}}function Tr(e,t){let{end:n,start:r}=tt(e);return t.slice(r,n).trimEnd()}function vr(e,t){let{end:n,start:r}=tt(e);return`${e.leading??" "}${t.slice(r,n).trimEnd()}`}function Ks(e){return e.children?.nodes??[]}function Us(e){let t=e.entries.map((o)=>`${o.getName()??""}=(${o.getTag()??""})${JSON.stringify(o.getValue())}`),n=t.filter((o)=>!o.startsWith("=")).toSorted(),r=t.filter((o)=>o.startsWith("=")),s=Ks(e).map((o)=>Us(o));return`(${e.getTag()??""})${e.getName()} ${[...n,...r].join(" ")} {${s.join(";")}}`}function qs(e,t,n){if(Us(t)===Us(n))return!0;let r=e.previous.meanings.get(tt(t).start);return r!==void 0&&r===e.next.meanings.get(tt(n).start)}function ta(e){let n=e.entries.filter((r)=>["$id","key"].includes(r.getName()??"")).map((r)=>JSON.stringify(r.getValue()));return`(${e.getTag()??""})${e.getName()} ${n.join(" ")}`}function na(e,t,n){let r=e.length+1,s=t.length+1,o=new Int32Array(r*s);for(let l=e.length-1;l>=0;l-=1)for(let u=t.length-1;u>=0;u-=1){let f=e[l],p=t[u];o[l*s+u]=f!==void 0&&p!==void 0&&n(f,p)?(o[(l+1)*s+u+1]??0)+1:Math.max(o[(l+1)*s+u]??0,o[l*s+u+1]??0)}let i=[],c=0,a=0;while(c<e.length&&a<t.length){let l=e[c],u=t[a];if(l!==void 0&&u!==void 0&&n(l,u))i.push([c,a]),c+=1,a+=1;else if((o[(c+1)*s+a]??0)>=(o[c*s+a+1]??0))c+=1;else a+=1}return i}function Wc(e,t,n){let r=new Map,s=new Set,o=(l,u)=>{let f=t[l];if(f)r.set(u,f),s.add(l)},i=na(t,n,(l,u)=>qs(e,l,u)),c=0,a=0;for(let[l,u]of[...i,[t.length,n.length]]){let f=na(t.slice(c,l),n.slice(a,u),(p,d)=>ta(p)===ta(d));for(let[p,d]of f)o(c+p,a+d);if(l<t.length)o(l,u);c=l+1,a=u+1}for(let[l,u]of n.entries())if(!r.has(l)){let f=t.findIndex((p,d)=>!s.has(d)&&qs(e,p,u));if(f!==-1)o(f,l)}return r}function Gs(e){let t=e.leading??"";return t.slice(t.lastIndexOf(`
41
+ `)+1)}function Vc(e,t,n){return e.split(`
42
+ `).map((r,s)=>s>0&&r.startsWith(t)?n+r.slice(t.length):r).join(`
43
+ `)}function Hc(e,t,n){let r=[...n],s=(i)=>{let c=i.getName(),a=r.findIndex((l)=>l.getName()===c);return a===-1?void 0:r.splice(a,1)[0]},o="";for(let i of t.entries){let c=s(i);if(c){let a=c.getTag()===i.getTag()&&c.getValue()===i.getValue();o+=a?vr(i,e.previous.text):`${i.leading??" "}${vr(c,e.next.text).trimStart()}`}}for(let i of r)o+=` ${vr(i,e.next.text).trimStart()}`;return o}function Bc(e,t,n){let r=new Map;for(let o of Ks(t)){let i=e.previous.pointers.get(tt(o).start);if(i!==void 0)r.set(i,o)}let s=new Map;for(let o of n.entries){let i=e.next.pointers.get(tt(o).start),c=i===void 0?void 0:r.get(i);if(c&&o.getName()!==null)s.set(c,o)}return s}function Uc(e,t,n){let{text:r}=e.previous,s=vr(n,e.next.text).trimStart().slice(`${n.getName()}=`.length),[o]=t.entries;if(o?.getName()===null&&t.entries.length===1&&!t.children){if(o.getValue()===n.getValue()&&o.getTag()===n.getTag())return Tr(t,r);return`${zs(t,r)}${o.leading??" "}${s}`}return`${zs(t,r)} ${s}`}function zs(e,t){let{start:n}=tt(e),[r]=e.entries;if(r)return t.slice(n,tt(r).start-(r.leading??"").length);let s=e.children&&zt(e.children);if(s)return t.slice(n,s.start.offset-1).trimEnd();return Tr(e,t)}function qc(e,t,n,r){let s=Bc(e,t,n),o=new Set(s.values()),i=n.entries.filter((d)=>!o.has(d)),c=`${zs(t,e.previous.text)}${Hc(e,t,i)}`,a=Ks(n);if(a.length===0&&s.size===0)return c;let l=a[0]?Gs(a[0]):`${r} `,u=t.children,f=t.beforeChildren===""?" ":t.beforeChildren??" ";if(u&&u.nodes.length>0&&Kc(u,e.previous.text,t)){let d=`${r}${zc(u,r)}`;return`${c}${f}{${sa(e,u,a,d,l,s)}}`}let p=a.map((d)=>ra(e,d,l,`${r} `));return`${c}${f}{
44
+ ${p.join("")}${r}}`}function zc(e,t){let[n]=e.nodes,r=n?Gs(n):"";return r.startsWith(t)?r.slice(t.length):" "}function Kc(e,t,n){let{end:r,start:s}=tt(n),[o]=e.nodes;return o!==void 0&&(o.leading??"").includes(`
45
+ `)&&t.slice(s,r).includes(`
46
+ `)}function ra(e,t,n,r){return`${r}${Vc(Tr(t,e.next.text),n,r)}
47
+ `}function sa(e,t,n,r,s,o){let i=t.nodes.filter((m)=>!o.has(m)),c=Wc(e,i,n),a=t.nodes[0]?.leading??"",l=a.indexOf(`
48
+ `),u=l===-1?"":a.slice(0,l+1),f=u,p=-1,d=()=>{if(f!==""&&!f.endsWith(`
49
+ `)&&!f.endsWith(";"))f+=`
50
+ `},h=(m,x)=>{let E=t.nodes.indexOf(m),O=E===p+1||E>p;p=Math.max(p,E);let J=m===t.nodes[0]?a.slice(u.length):m.leading??"";if(O&&(J.includes(`
51
+ `)||f===u||f.endsWith(";"))){f+=`${J}${x}${m.trailing??""}`;return}if(!f.endsWith(`
52
+ `))f+=`
53
+ `;let C=(m.trailing??"").replace(/^;/u,"");f+=`${J.includes(`
54
+ `)?J:r}${x}${C}`},g=(m)=>{for(let[x,E]of t.nodes.entries()){let O=o.get(E);if(O&&x<m&&x>p)d(),h(E,Uc(e,E,O))}};for(let[m,x]of n.entries()){let E=c.get(m);if(E){g(t.nodes.indexOf(E)),d();let O=qs(e,E,x)?Tr(E,e.previous.text):qc(e,E,x,Gs(E));h(E,O)}else d(),f+=ra(e,x,s,r)}return g(t.nodes.length),`${f}${t.trailing??""}`}function Ys(e,t,n){let r;try{r=n(e)}catch{return t}let s=n(t),o=tn(s.document);if(tn(r.document)===o)return e;let i={next:ea(s,t),previous:ea(r,e)},c=sa(i,dt(e,{storeLocations:!0}),dt(t,{storeLocations:!0}).nodes,"","",new Map);try{return tn(n(c).document)===o?c:t}catch{return t}}var Xs=v(()=>{Nr();K()});function la(e){return!/\p{Cs}/u.test(e)}function ca(e,t){try{return dt(`x ${e}`).nodes[0]?.entries[0]?.getValue()===t}catch{return!1}}function Rr(e){let t='"';for(let n of e)if(n==='"')t+=String.raw`\"`;else if(n==="\\")t+=String.raw`\\`;else if(n===`
55
+ `)t+=String.raw`\n`;else if(n==="\t")t+=String.raw`\t`;else if(n==="\r")t+=String.raw`\r`;else if(aa.test(n))t+=`\\u{${n.codePointAt(0)?.toString(16)}}`;else t+=n;return`${t}"`}function ua(e,t){let n="#";while(e.includes(t+n))n+="#";return n}function Xc(e,t){if(Gc.test(e))return null;let n=ua(e,'"""'),r=`${t}${ue}`,s=e.split(`
56
+ `).map((i)=>i===""?"":r+i),o=`${n}"""
57
+ ${s.join(`
58
+ `)}
59
+ ${r}"""${n}`;return ca(o,e)?o:null}function Qs(e,t,n){if(!la(e))throw new he(`${n} holds a lone surrogate, which Jx Notation has no way to spell`);if(ia.test(e))return e;if(e.includes(`
60
+ `)){let r=Xc(e,t);if(r)return r}else if((e.includes("\\")||e.includes('"'))&&!aa.test(e)){let r=ua(e,'"'),s=`${r}"${e}"${r}`;if(ca(s,e))return s}return Rr(e)}function Ee(e,t){if(!la(e))throw new he(`${t} is a key with a lone surrogate, which Jx Notation cannot spell`);return ia.test(e)?e:Rr(e)}function fe(e,t,n){if(e===null)return"#null";if(e===!0)return"#true";if(e===!1)return"#false";if(se(e))return Object.is(e,-0)?"-0":String(e);if(b(e))return Qs(e,t,n);return jr(e)?`(ref)${Rr(e.$ref)}`:null}function fa(e){if(!Ce(e)||e.$prototype!=="Function")return!1;let{$prototype:t,body:n,parameters:r,...s}=e,o=Object.values(s).every((l)=>fe(l,"","")!==null),i=r===void 0||Array.isArray(r)&&r.length>0&&r.every((l)=>b(l))&&n!==void 0,c=n===void 0||b(n)||Array.isArray(n),a=Array.isArray(n)&&n.length===0;return o&&i&&c&&!a}function pa(e,t,n,r){let{$prototype:s,body:o,parameters:i,...c}=t,a=[`${n}(fn)${Ee(e,r)}`];for(let[l,u]of Object.entries(c))a.push(`${Ee(l,r)}=${fe(u,n,Q(r,l))}`);if(Array.isArray(i))for(let l of i)a.push(Qs(String(l),n,Q(r,"parameters")));if(b(o))a.push(Qs(o,n,Q(r,"body")));else if(Array.isArray(o))return[`${a.join(" ")} {`,...o.flatMap((l,u)=>Oe("-",l,n+ue,Q(Q(r,"body"),u))),`${n}}`];return[a.join(" ")]}function Oe(e,t,n,r){let s=Ee(e,r),o=n+s,i=fe(t,n,r);if(i!==null)return[`${o} ${i}`];if(fa(t))return pa(e,t,n,r);if(Array.isArray(t)){if(t.length===0)return[`${n}(array)${s}`];let u=t.map((p,d)=>fe(p,n,Q(r,d)));if(t.length>1&&u.every((p)=>p!==null&&!p.includes(`
61
+ `))){let p=`${o} ${u.join(" ")}`;if(p.length<=Zs)return[p]}return[`${o} {`,...t.flatMap((p,d)=>Oe("-",p,n+ue,Q(r,d))),`${n}}`]}let c=Ce(t)?Object.entries(t):[];if(c.length===0)return[`${o} {}`];let a=c.every(([u])=>u==="-")?`${n}(object)${s}`:o,l=c.map(([u,f])=>{let p=fe(f,n,Q(r,u));return p===null||p.includes(`
62
+ `)?null:`${Ee(u,r)}=${p}`});if(l.every((u)=>u!==null)){let u=`${a} ${l.join(" ")}`;if(u.length<=Zs)return[u]}return[`${a} {`,...c.flatMap(([u,f])=>Oe(u,f,n+ue,Q(r,u))),`${n}}`]}function da(e,t,n,r){let s=Object.entries(t),o=n+Ee(e,r);if(s.length===0)return[`${o} {}`];let i=[],c=0;for(let[p,d]of s){let h=fe(d,n,Q(r,p));if(h===null||h.includes(`
63
+ `))break;i.push(`${Ee(p,r)}=${h}`),c+=1}let a=`${o} ${i.join(" ")}`,l=i.length>0&&a.length<=Zs,u=l?c:0,f=s.slice(u).flatMap(([p,d])=>{if(Ce(d)&&!jr(d))return da(p,d,n+ue,Q(r,p));return Oe(p,d,n+ue,Q(r,p))});if(l&&f.length===0)return[a];return[`${l?a:o} {`,...f,`${n}}`]}function Zc(e){if(!Ce(e)||e.$prototype!=="Array"||!Ce(e.map))return!1;let{$prototype:t,map:n,...r}=e;return Object.values(r).every((s)=>{let o=fe(s,"","");return o!==null&&!o.includes(`
64
+ `)})}function Qc(e,t,n){let{$prototype:r,map:s,...o}=e,i=[`${t}$array`];for(let[c,a]of Object.entries(o))i.push(`${Ee(c,n)}=${fe(a,t,Q(n,c))}`);return[`${i.join(" ")} {`,...vn(s??null,t+ue,Q(n,"map")),`${t}}`]}function vn(e,t,n){let r=fe(e,t,n);if(r!==null)return[`${t}- ${r}`];if(Zc(e))return Qc(e,t,n);if(Ce(e))return eo(e,t,n);throw new he(`${n} is a list inside a list of children, which has no spelling`)}function eu(e,t,n){let{tagName:r}=e;if(!b(r))return`${t}$element`;if(Yc.has(r)||r.startsWith("$")||r.startsWith("."))return`${t}$element ${Rr(r)}`;return t+Ee(r,n)}function tu(e,t){return t!==null&&!t.includes(`
65
+ `)&&!e.startsWith("on")&&!e.startsWith("$")&&!e.startsWith(".")}function eo(e,t,n){let r=[eu(e,t,n)],s=t+ue,o=[],i={},c=null;for(let[a,l]of Object.entries(e)){let u=Q(n,a);if(a==="tagName"&&b(l))continue;if(a==="children")continue;if(a==="textContent"){let f=fe(l,t,u);if(f===null||!b(e.tagName))oa(r,o,a,l,s,t,u);else c=f}else if(a==="attributes"&&Ce(l))for(let[f,p]of Object.entries(l)){let d=fe(p,t,Q(u,f));if(tu(f,d))r.push(`${Ee(f,u)}=${d}`);else i[f]=p}else if(a==="state")o.push(...Oe("state",l,s,u));else if(a==="style"&&Ce(l))o.push(...da("style",l,s,u));else if(a.startsWith("on")&&jr(l))r.push(`${Ee(a,u)}=${fe(l,t,u)}`);else if(a.startsWith("on"))o.push(...fa(l)?pa(a,l,s,u):Oe(a,l,s,u).map((f,p)=>p===0?f.replace(s,`${s}(on)`):f));else if(a.startsWith("$")){let f=fe(l,t,u);if(f===null||f.includes(`
66
+ `))o.push(...Oe(a,l,s,u));else r.push(`${Ee(a,u)}=${f}`)}else oa(r,o,a,l,s,t,u)}if(Object.keys(i).length>0)o.push(...Oe("attributes",i,s,Q(n,"attributes")));if(o.push(...nu(e.children,s,Q(n,"children"))),c!==null)r.push(c);return o.length===0?[r.join(" ")]:[`${r.join(" ")} {`,...o,`${t}}`]}function nu(e,t,n){if(e===void 0)return[];if(Array.isArray(e)){if(e.length===0)return[`${t}(array).children`];return e.flatMap((s,o)=>vn(s,t,Q(n,o)))}let r=fe(e,t,n);if(r!==null)return[`${t}.children ${r}`];return[`${t}.children {`,...vn(e,t+ue,n),`${t}}`]}function oa(e,t,n,r,s,o,i){let c=Ee(`.${n}`,i);if(n==="map"&&Ce(r)){t.push(`${s}${c} {`,...vn(r,s+ue,i),`${s}}`);return}if(n==="cases"&&Ce(r)){t.push(`${s}${c} {`);for(let[l,u]of Object.entries(r))t.push(`${s}${ue}${Ee(l,i)} {`,...vn(u,s+ue+ue,Q(i,l)),`${s}${ue}}`);t.push(`${s}}`);return}let a=fe(r,o,i);if(a===null||a.includes(`
67
+ `))t.push(...Oe(`.${n}`,r,s,i));else e.push(`${c}=${a}`)}function ru(e,t){return["$head {",...e.flatMap((n,r)=>Ce(n)&&!jr(n)&&b(n.tagName)&&!n.$ref?eo(n,t,`/$head/${r}`):Oe("-",n,t,`/$head/${r}`)),"}"]}function su(e){let{document:t,spans:n}=Hs(e);return{document:D(t)?t:null,spans:n}}function to(e,t){let n=ou(e);return t===void 0?n:Ys(t,n,su)}function ou(e){if(!D(e))throw new he("A document is an object");let t=e,n=["/- kdl-version 2"],r={};for(let[s,o]of Object.entries(t))if(s==="$head"&&Array.isArray(o))n.push(...ru(o,ue));else if(s==="$head")n.push(`(object)${Oe(s,o,"","/$head").join(`
68
+ `)}`);else if(s.startsWith("$"))n.push(...Oe(s,o,"",Q("",s)));else r[s]=o;if(Object.keys(r).length>0)n.push("",...eo(r,"",""));return`${n.join(`
69
+ `)}
70
+ `}var ue=" ",Zs=100,ia,aa,Gc,Yc,Ce=(e)=>D(e),jr=(e)=>Ce(e)&&b(e.$ref)&&Object.keys(e).length===1,Q=(e,t)=>`${e}/${String(t).replaceAll("~","~0").replaceAll("/","~1")}`;var ma=v(()=>{Nr();K();Jn();Cr();Xs();ia=/^(?![-+]?\.?\d)(?!(?:true|false|null|inf|-inf|nan)$)[^\s\\/(){};[\]"#=,\p{Cc}\p{Cf}\p{Zl}\p{Zp}]+$/u,aa=/[\p{Cc}\p{Zl}\p{Zp}‎‏‪-‮⁦-⁩]/u,Gc=/(?!\n)\p{Cc}|[\p{Zl}\p{Zp}‎‏‪-‮⁦-⁩]/u,Yc=new Set(["-","attributes","script","state","style"])});var _r=v(()=>{$s();Zi();Jn();Qi();Cr();Xs();ma()});function ya(e){if(!b(e))return null;let[t,...n]=e.split(";"),r=(t??"").indexOf("/");if(r===-1)return null;let s=(t??"").slice(0,r).trim().toLowerCase(),o=(t??"").slice(r+1).trim().toLowerCase();if(!ga.test(s)||!ga.test(o))return null;let i=o.lastIndexOf("+"),c=i===-1?null:o.slice(i+1),a=i===-1?o:o.slice(0,i);if(c==="")return null;let l=a.indexOf("."),u=l===-1?null:a.slice(0,l),f=u!==null&&iu.has(u)?u:null,p=f===null?a:a.slice(f.length+1);if(p==="")return null;let d={};for(let h of n){let g=h.indexOf("=");if(g===-1)return null;let m=h.slice(0,g).trim().toLowerCase(),x=h.slice(g+1).trim();if(m==="")return null;if(x.startsWith('"')&&x.endsWith('"')&&x.length>=2)x=x.slice(1,-1);d[m]=x}return{parameters:d,subtype:p,suffix:c,tree:f,type:s}}function $a(e){if(!b(e)||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(ya(e)===null)return`"${e}" is not a well-formed media type (RFC 6838 §4.2)`;return null}function Sa(e){let t=ya(e);if(t===null)return null;let n=t.tree===null?"":`${t.tree}.`,r=t.suffix===null?"":`+${t.suffix}`;return`${t.type}/${n}${t.subtype}${r}`}var ga,iu,ha="text/markdown; variant=GFM",xa="application/yaml",rm;var ba=v(()=>{K();ga=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,iu=new Set(["vnd","prs","x"]);rm={".jxn":"text/plain; charset=utf-8",".markdown":`${ha}; charset=utf-8`,".md":`${ha}; charset=utf-8`,".yaml":`${xa}; charset=utf-8`,".yml":`${xa}; charset=utf-8`}});function Na(e){if(e===null)throw TypeError("A class descriptor cannot be null");return D(e)?e:{}}class Tn{name;classPath;classDef;extensions;mediaType;mediaTypeEssence;documentKinds;exportTarget;remote;studio;project;server;connector;capabilities;#t;#e=null;constructor(e,t,n,r){this.name=e,this.classPath=t,this.classDef=n,this.#t=r;let{format:s}=n;this.extensions=(s?.extensions??[]).map((o)=>o.toLowerCase()),this.mediaType=s?.mediaType??null,this.mediaTypeEssence=Sa(this.mediaType),this.documentKinds=s?.documentKinds??[],this.exportTarget=s?.exportTarget===!0,this.remote=s?.remote===!0,this.studio=n.$studio??null,this.project=n.project??null,this.server=n.server??null,this.connector=n.connector??null,this.capabilities=lu(n)}implementation(){if(!this.#e){let e=this.classDef.$implementation;if(!e)return Promise.reject(Error(`Format class "${this.name}" has no $implementation to import`));this.#e=this.#t.importModule(this.#t.resolvePath(this.classPath,e))}return this.#e}async implementationExport(){return this.#n(await this.implementation())}#n(e){let t=this.classDef.title??this.name;return e[t]??e.default?.[t]??e.default}async call(e,...t){let n=this.capabilities[e];if(!n)throw Error(`Format class "${this.name}" does not declare a "${e}" capability`);let r=this.#n(await this.implementation()),s=r?.[n.identifier];if(!ye(s)){let i=this.classDef.title??this.name;throw TypeError(`Format class "${this.name}": implementation export "${i}" has no static "${n.identifier}" method`)}return await s.call(r,...t)}async parseDocument(e,t){return await this.call("parse",e,t)}}class kr{#t;get#e(){return[...this.#t,pu]}constructor(e){this.#t=e;for(let t of e)if(t.extensions.includes(".jxn"))throw Error(`Format "${t.name}" claims ".jxn", which is built in`);for(let t of e){if(t.mediaType===null)continue;let n=$a(t.mediaType);if(n!==null)throw Error(`Format "${t.name}" declares an invalid mediaType: ${n}`)}for(let t of Ea){let n=new Map;for(let r of e){if(!r.capabilities[t])continue;for(let s of r.extensions){let o=n.get(s);if(o)throw Error(`Format conflict: "${o.name}" and "${r.name}" both claim "${s}" with the "${t}" capability`);n.set(s,r)}}}}get entries(){return this.#t}byExtension(e,t){let n=wa(e);return this.#e.find((r)=>r.extensions.includes(n)&&(!t||r.capabilities[t]))}byName(e){return this.#t.find((t)=>t.name===e)}withCapability(e){return this.#e.filter((t)=>t.capabilities[e])}documentExtensions(e){let t=new Set;for(let n of this.#e){if(e&&!n.documentKinds.includes(e))continue;for(let r of n.extensions)t.add(r)}return t.delete(".json"),[...t]}has(e){let t=wa(e);return this.#e.some((n)=>n.extensions.includes(t))}}function lu(e){let t={},n=e.$defs?.methods??{};for(let[r,s]of Object.entries(n)){let{role:o}=s;if(!uu(o))continue;let i={identifier:s.identifier??r,timing:s.timing??au};if(b(s.discriminator))i.discriminator=s.discriminator;t[o]=i}return t}function uu(e){return e!==void 0&&cu.has(e)}function wa(e){let t=e.toLowerCase();return t.startsWith(".")?t:`.${t}`}var Ea,Ja,au,cu,fu,pu;var no=v(()=>{K();ba();Ea=["parse","serialize","rewrite","discover","load"],Ja=[...Ea,"projectData","resolvePaths","lower","emit","head","assets","mount","dialect","deploySchema","bindings","testConnection"];au=["compiler","server"];cu=new Set(Ja);fu={importModule:async()=>{await Promise.resolve().then(() => _r());return{JxNotation:{parse:(n)=>An(n),serialize:(n)=>to(n)}}},loadJson:()=>Promise.reject(Error("Jx Notation reads no file of its own")),resolvePath:(e,t)=>t},pu=new Tn("jxn","",{$defs:{methods:{parse:{role:"parse"},serialize:{role:"serialize"}}},$implementation:"jxn",format:{documentKinds:["page","component"],extensions:[".jxn"]},title:"JxNotation"},fu)});class Aa{#t;#e;#n;constructor(e){this.#t=e,this.#e=e.flatMap((s)=>s.classes);let t=new Map;for(let s of e)for(let o of s.classes){let i=t.get(o.name);if(i&&i!==s.specifier)throw Error(`Extension conflict: "${i}" and "${s.specifier}" both provide a class named "${o.name}"`);t.set(o.name,s.specifier)}let n=new Map;for(let s of this.#e){if(!s.project)continue;let o=n.get(s.project.key);if(o)throw Error(`Extension conflict: "${o.name}" and "${s.name}" both claim the project section "${s.project.key}"`);n.set(s.project.key,s)}let r=new Map;for(let s of this.#e){if(!s.server)continue;let{basePath:o}=s.server;if(!o.startsWith("/_jx/"))throw Error(`Extension "${s.name}": server basePath "${o}" must be under /_jx/`);let i=r.get(o);if(i)throw Error(`Extension conflict: "${i.name}" and "${s.name}" both mount "${o}"`);r.set(o,s)}this.#n=new kr(this.#e.filter((s)=>s.extensions.length>0))}get extensions(){return this.#t}get classes(){return this.#e}get formats(){return this.#n}byName(e){return this.#e.find((t)=>t.name===e)}projectContributions(){return this.#e.filter((e)=>e.project!==null)}byProjectKey(e){return this.#e.find((t)=>t.project?.key===e)}byPathsDiscriminator(e){return this.#e.find((t)=>t.capabilities.resolvePaths?.discriminator===e)}emitters(){return this.#e.filter((e)=>e.capabilities.emit!==void 0)}headProviders(){return this.#e.filter((e)=>e.capabilities.head!==void 0)}assetProviders(){return this.#e.filter((e)=>e.capabilities.assets!==void 0)}serverMounts(){return this.#e.filter((e)=>e.server!==null).toSorted((e,t)=>(e.server?.order??100)-(t.server?.order??100)||e.name.localeCompare(t.name))}connectors(){return this.#e.filter((e)=>e.connector!==null)}schemaFragments(e){return this.#t.map((t)=>t.schemas[e]).filter((t)=>typeof t==="string")}}async function Oa(e,t,n){let r=[];for(let s of e??[])r.push(await du(s,t,n));return new Aa(r)}async function du(e,t,n){let r;if(e.startsWith("./")||e.startsWith("../")){let a=t.resolvePath(n,e);r=t.resolvePath(`${a}/package.json`,`./${jn}`)}else try{r=t.resolvePath(n,`${e}/${jn}`)}catch(a){throw Error(`Extension "${e}" is not resolvable: it must export ${jn} (is the package installed, and does its exports map include it?): ${ro(a)}`,{cause:a})}let s;try{s=await t.loadJson(r)}catch(a){throw Error(`Extension "${e}": cannot read manifest ${r}: ${ro(a)}`,{cause:a})}if(!D(s)||!b(s.name))throw Error(`Extension "${e}": ${jn} must declare a "name"`);let o=s;if(!e.startsWith(".")&&o.name!==e)throw Error(`Extension "${e}": manifest name "${o.name}" does not match the specifier`);let i=[];for(let[a,l]of Object.entries(o.classes??{})){let u=t.resolvePath(r,l),f;try{f=await t.loadJson(u)}catch(p){throw Error(`Extension "${e}": cannot read class "${a}" at ${u}: ${ro(p)}`,{cause:p})}i.push(new Tn(a,u,Na(f),t))}let c={};if(o.schemas?.project)c.project=t.resolvePath(r,o.schemas.project);if(o.schemas?.document)c.document=t.resolvePath(r,o.schemas.document);if(o.schemas?.fields)c.fields=t.resolvePath(r,o.schemas.fields);return{specifier:e,manifestPath:r,manifest:o,classes:i,schemas:c}}function ro(e){return e instanceof Error?e.message:String(e)}var jn="jx-extension.json";var Ca=v(()=>{no();K();no()});var va=v(()=>{K()});var Ta="project.json";var ja=v(()=>{K();va();rr()});import{dirname as Em,join as mu}from"node:path";function Ra(e){return mu(e,Ta)}var _a=v(()=>{ja()});import{readFileSync as gu}from"node:fs";import{dirname as hu,isAbsolute as xu,resolve as ka,sep as Pr}from"node:path";import{pathToFileURL as yu}from"node:url";import{createRequire as $u}from"node:module";async function Su(e){let t=[e],n=`${Pr}src${Pr}`,r=`${Pr}dist${Pr}`;if(e.includes(n)){let o=e.replace(n,r);if(t.push(o),o.endsWith(".ts"))t.push(`${o.slice(0,-3)}.js`)}if(e.endsWith(".js"))t.push(`${e.slice(0,-3)}.ts`);let s;for(let o of t)try{return await import(yu(o).href)}catch(i){s=i}throw s instanceof Error?s:Error(String(s))}function bu(e,t){return $u(ka(e,"package.json")).resolve(t)}function wu(e){return{importModule:(t)=>Su(t),loadJson:async(t)=>JSON.parse(gu(t,"utf8")),resolvePath:(t,n)=>{if(n.startsWith("./")||n.startsWith("../"))return ka(hu(t),n);if(xu(n))return n;return bu(e,n)}}}async function _m(e,t){return Oa(t?.extensions,wu(e),Ra(e))}function Ir(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 so=v(()=>{Ca();K();_a()});async function Ma(e,t={}){let{resolveElementPath:n,$media:r,formats:s}=t,o=[],i=new Set;async function c(a,l){let u,f;if(b(a)){let{readFileSync:J}=await import("node:fs"),{resolve:C}=await import("node:path");if(f=l?C(l,a):C(a),i.has(f))return;if(i.add(f),On(f))u=Cn(J(f,"utf8"),f);else{let{extname:q}=await import("node:path"),S=q(f).toLowerCase(),y=s?.byExtension(S,"parse");if(!y){await Promise.resolve().then(() => so());throw Ir(f,S)}u=await y.parseDocument(J(f,"utf8"))}}else{if(u=a,f=null,u.tagName&&i.has(u.tagName))return;if(u.tagName)i.add(u.tagName)}let{tagName:p}=u;if(!p||!p.includes("-"))throw Error(`compileElement: tagName "${p}" must contain a hyphen`);let{dirname:d}=await import("node:path"),h=f?d(f):null,g=[];if(Array.isArray(u.$elements))for(let J of u.$elements){let C=H(J)?J.$ref:J;if(!b(C))continue;if(h)await c(C,h);let q=n?n(C,h):C.replace(/\.(?:json|jxn)$/i,".js");g.push(q)}let m=tr(p);if(r)u.$media={...r,...u.$media};let{rewriteSrc:x}=t,E=Rn(u,m,g,x?(J)=>x(J,h):void 0,Wn(u,t.defaults),t.serverBaseUrl),O=f?f.replace(/\.(?:json|jxn)$/i,".js"):`${p}.js`;o.push({content:E,path:O,tagName:p})}return await c(e,t.basePath??null),{files:o}}async function Eu(e,t={}){let{title:n="Jx App",reactivitySrc:r="https://esm.sh/@vue/reactivity@3.5.13",litHtmlSrc:s="https://esm.sh/lit-html@3.3.0"}=t,o=await Ma(e,t),i=o.files.at(-1);if(!i)throw Error("compileElementPage: no element modules were produced");let{basename:c}=await import("node:path"),a=c(i.path),l=`<!DOCTYPE html>
27
71
  <html lang="en">
28
72
  <head>
29
73
  <meta charset="utf-8">
30
74
  <meta name="viewport" content="width=device-width, initial-scale=1">
31
- <title>${j(n)}</title>
75
+ <title>${_(n)}</title>
32
76
  <script type="importmap">
33
77
  {
34
78
  "imports": {
@@ -42,76 +86,76 @@ ${p}`}let o=r?.componentDefs.get(s);if(o&&r)return Ys(e,o,t,n,r);let i=ve(e,t);i
42
86
  <${i.tagName}></${i.tagName}>
43
87
  <script type="module" src="./${a}"></script>
44
88
  </body>
45
- </html>`;return{files:o.files,html:c}}function bo(e){if(!C(e)||Array.isArray(e))return JSON.stringify(e);if("default"in e)return JSON.stringify(e.default);if($e(e))return;if(e.$prototype==="LocalStorage"||e.$prototype==="SessionStorage")return JSON.stringify(e.default??null);if(e.$prototype==="Request")return"null";if(le(e))return"null";return JSON.stringify(e)}function Jo(e){let t=new Set,n=new Set,r=(o)=>{if(o.startsWith("#/state/"))t.add(o.slice(8).split("/")[0])},s=(o)=>{if(J(o)){for(let u of o.matchAll(/\bstate\.([A-Za-z_$][\w$]*)\s*\(/g))t.add(u[1]);return}if(!C(o)||n.has(o))return;if(n.add(o),Array.isArray(o)){for(let u of o)s(u);return}let i=o;if(i.operator==="call"&&P(i.target))r(i.target.$ref);for(let[u,a]of Object.entries(i)){if(u.startsWith("on")&&u!=="observedAttributes"&&P(a))r(a.$ref);s(a)}};return s(e.children),s(e.state),t}function Qe(e,t,n,r,s=null,o="/_jx/server"){let i=["// Generated by @jxsuite/compiler — do not edit manually"];if(e.$id)i.push(`// Source: ${e.$id}`);for(let S of n)i.push(`import '${S}';`);let u=new Map,a=new Map,c=e.state??{},l=Jo(e);for(let[S,h]of Object.entries(c))if(G(h)&&h.$src){let b=h.$src;if(h.$lazy===!0){if(!l.has(S)&&!Mr.has(S))throw Error(`"${S}" declares "$lazy": true but is used as a computed value, not called. A lazily loaded function resolves to a promise; a computed must resolve now. Remove "$lazy", or call ${S}() from a handler instead of binding its value.`);let F=a.get(b);if(!F)F=[],a.set(b,F);F.push({binding:S,exportName:nn(S,h)});continue}let E=u.get(b);if(!E)E=[],u.set(b,E);E.push(ft(S,h))}for(let[S,h]of u){let b=r?r(S):S;i.push(`import { ${h.join(", ")} } from '${b}';`)}let p=Object.entries(c).flatMap(([S,h])=>ye(h)&&h.$prototype==="Request"?[[S,h]]:[]),g=Object.entries(c).flatMap(([S,h])=>le(h)?[[S,h]]:[]);if(i.push("import { reactive, computed, effect, stop } from '@vue/reactivity';","import { render, html, nothing } from 'lit-html';",St()),g.length>0)i.push(bt());let d=s===null&&Pe(e.children);if(d)i.push(fr());let x=0;for(let[S,h]of a){let b=r?r(S):S,E=`_jxLazy${x}`;x+=1,i.push(`let ${E};`,`const ${E}Load = () => (${E} ??= import('${b}'));`,...h.map(({binding:F,exportName:W})=>`const ${F} = (...args) => ${E}Load().then((m) => m.${W}(...args));`))}i.push("",`class ${t} extends HTMLElement {`," #effects = [];",...s===null?[]:[" #root = null;"],""," constructor() {"," super();");let f=[],m=[],y=[],w=[],O=[];for(let[S,h]of Object.entries(c))if(X(h))if(Ee(h))w.push([S,h]);else if(me(h.$expression.operator))y.push([S,h]);else m.push([S,h]);else if(G(h))if(h.$src&&!J(h.body))if(l.has(S)||Mr.has(S))y.push([S,h]);else m.push([S,h]);else if(J(h.body)&&we(h.body))m.push([S,h]);else y.push([S,h]);else if(J(h)&&h.includes("${"))O.push([S,h]);else{let b=bo(h);if(b!==void 0)f.push([S,b])}i.push(" this.state = reactive({");for(let[S,h]of f)i.push(` ${fe(S)}: ${h},`);i.push(" });");for(let[S,h]of y)if(i.push(""),X(h)){let b=q(h.$expression,{eventParam:"e",statePrefix:"s"});i.push(` ${R("this.state",B(S))} = (s, e) => { ${b}; };`)}else if(xe(h)){let b=ne(h.body,{dispatchTarget:"this",eventParam:"e",indent:" ",statePrefix:"this.state"});i.push(` ${R("this.state",B(S))} = (s, e) => {`,b," };")}else{let b=h.parameters?ce(h.parameters):h.arguments??["state"],E=b.join(", "),F=J(h.body)?h.body:"";if(b[0]==="state")if(h.$src)i.push(` ${R("this.state",B(S))} = (${E}) => ${S}(${E});`);else i.push(` ${R("this.state",B(S))} = (${E}) => {`,` ${F}`," };");else{let W=b.map((re)=>re==="state"?"state":"e").join(", ");if(h.$src)i.push(` ${R("this.state",B(S))} = (state, e) => ${S}(${W});`);else i.push(` ${R("this.state",B(S))} = (state, e) => {`,` const _fn = (${E}) => {`,` ${F}`," };",` return _fn(${W});`," };")}}for(let[S,h]of w){i.push("");let b=q(h.$expression,{eventParam:"e",statePrefix:"this.state"});i.push(` ${R("this.state",B(S))} = ${Ge(h,b)};`)}for(let[S,h]of O)i.push("",` ${R("this.state",B(S))} = computed(() => ${yt(h.replaceAll("state.","this.state."))});`);for(let[S,h]of m)if(i.push(""),X(h)){let b=q(h.$expression,{eventParam:"e",statePrefix:"this.state"});i.push(` ${R("this.state",B(S))} = computed(() => ${b});`)}else if(h.$src)i.push(` ${R("this.state",B(S))} = computed(() => ${S}(this.state));`);else{i.push(` ${R("this.state",B(S))} = computed(() => {`);let b=(J(h.body)?h.body:"").replaceAll("state.","this.state.");i.push(` ${b}`," });")}i.push(" }","");let v=[];if(Array.isArray(e.children)){let S={n:0};for(let h of e.children)Te(h,v,e.$media??{},"",S,e.tagName)}let A=Wr(),k=!Array.isArray(e.children)&&e.textContent!==void 0?` ${Rt(e.textContent)}`:jt(e.children,e.style," ",!1,!1,A);i.push(" template() {"," const s = this.state;",...A.decls," return html`",k," `;"," }","",...s===null?[]:[" #renderRoot() {"," if (this.#root) return this.#root;",s==="closed"?" this.#root = this.attachInternals().shadowRoot ?? this.attachShadow({ mode: 'closed' });":" this.#root = this.shadowRoot ?? this.attachShadow({ mode: 'open' });"," return this.#root;"," }",""]," connectedCallback() {"," const _pa = this.getAttribute('data-jx-props');"," if (_pa) {"," try {"," const _p = JSON.parse(_pa);"," for (const [k, v] of Object.entries(_p)) {"," if (k.startsWith('#')) continue;"," if (k in this.state) this.state[k] = v;"," }"," } catch {}"," this.removeAttribute('data-jx-props');"," }"," const _pn = this.getAttributeNames().filter(n => n.startsWith('props.') && n.length > 6);"," for (const _n of _pn) {"," const _k = _n.slice(6);"," if (_k.startsWith('#')) { this.removeAttribute(_n); continue; }"," if (_k in this.state) {"," this.state[_k] = this.getAttribute(_n);"," this.removeAttribute(_n);"," }"," }"," for (const key of Object.keys(this.state)) {"," if (key.startsWith('#')) continue;"," if (this.hasOwnProperty(key) && this[key] !== undefined) {"," this.state[key] = this[key];"," }"," }");for(let[S,h]of p)i.push(mt(S,h,{collect:"this.#effects",indent:" ",statePrefix:"this.state"}));for(let[S,h]of g)i.push(dt(S,h,{collect:"this.#effects",indent:" ",serverBaseUrl:o,statePrefix:"this.state"}));if(C(e.style)){let S=[];for(let[h,b]of Object.entries(e.style)){if(h.startsWith(":")||h.startsWith(".")||h.startsWith("&")||h.startsWith("[")||h.startsWith("@"))continue;if(J(b)&&b.includes("${"))S.push([z(h),b])}if(S.length>0){i.push(" this.#effects.push(effect(() => {");for(let[h,b]of S){let E=b.replaceAll(/\$\{([^}]+)\}/g,(F,W)=>`\${${W.replaceAll("state.","this.state.")}}`);i.push(` this.style['${h}'] = \`${E}\`;`)}i.push(" }));")}}if(d)i.push(` const _slotted = ${sn}(this);`);if(i.push(" if (this.hasAttribute('data-jx-prerendered')) {"," this.removeAttribute('data-jx-prerendered');"," }"),s===null)i.push(" this.replaceChildren();"," this.#effects.push(effect(() => render(this.template(), this)));");else i.push(" const _root = this.#renderRoot();"," for (const _n of [..._root.childNodes]) {"," if (!(_n.nodeType === 1 && _n.tagName === 'LINK')) _n.remove();"," }"," this.#effects.push(effect(() => render(this.template(), _root)));");if(d)i.push(` ${on}(this, _slotted);`);return i.push(" if (typeof this.state.onMount === 'function') {"," queueMicrotask(() => this.state.onMount(this.state));"," }"," }",""," disconnectedCallback() {"," for (const _e of this.#effects) { stop(_e); }"," this.#effects.length = 0;"," if (typeof this.state.onUnmount === 'function') { this.state.onUnmount(this.state); }"," }","}","",`customElements.define('${e.tagName}', ${t});`,""),i.join(`
46
- `)}function Wr(){return{byText:new Map,decls:[]}}function Vr(e,t){let n=e.byText.get(t);if(n)return n;let r=`_c${e.decls.length}`;e.decls.push(` const ${r} = html\`
89
+ </html>`;return{files:o.files,html:l}}function Ju(e){if(!A(e)||Array.isArray(e))return JSON.stringify(e);if("default"in e)return JSON.stringify(e.default);if(st(e))return;if(e.$prototype==="LocalStorage"||e.$prototype==="SessionStorage")return JSON.stringify(e.default??null);if(e.$prototype==="Request")return"null";if(He(e))return"null";return JSON.stringify(e)}function Nu(e){let t=new Set,n=new Set,r=(o)=>{if(o.startsWith("#/state/"))t.add(o.slice(8).split("/")[0])},s=(o)=>{if(b(o)){for(let c of o.matchAll(/\bstate\.([A-Za-z_$][\w$]*)\s*\(/g))t.add(c[1]);return}if(!A(o)||n.has(o))return;if(n.add(o),Array.isArray(o)){for(let c of o)s(c);return}let i=o;if(i.operator==="call"&&H(i.target))r(i.target.$ref);for(let[c,a]of Object.entries(i)){if(c.startsWith("on")&&c!=="observedAttributes"&&H(a))r(a.$ref);s(a)}};return s(e.children),s(e.state),t}function Rn(e,t,n,r,s=null,o="/_jx/server"){let i=["// Generated by @jxsuite/compiler — do not edit manually"];if(e.$id)i.push(`// Source: ${e.$id}`);for(let S of n)i.push(`import '${S}';`);let c=new Map,a=new Map,l=e.state??{},u=Nu(e);for(let[S,y]of Object.entries(l))if($e(y)&&y.$src){let w=y.$src;if(y.$lazy===!0){if(!u.has(S)&&!Pa.has(S))throw Error(`"${S}" declares "$lazy": true but is used as a computed value, not called. A lazily loaded function resolves to a promise; a computed must resolve now. Remove "$lazy", or call ${S}() from a handler instead of binding its value.`);let X=a.get(w);if(!X)X=[],a.set(w,X);X.push({binding:S,exportName:fs(S,y)});continue}let N=c.get(w);if(!N)N=[],c.set(w,N);N.push(Un(S,y))}for(let[S,y]of c){let w=r?r(S):S;i.push(`import { ${y.join(", ")} } from '${w}';`)}let f=Object.entries(l).flatMap(([S,y])=>rt(y)&&y.$prototype==="Request"?[[S,y]]:[]),p=Object.entries(l).flatMap(([S,y])=>He(y)?[[S,y]]:[]);if(i.push("import { reactive, computed, effect, stop } from '@vue/reactivity';","import { render, html, nothing } from 'lit-html';",Qn()),p.length>0)i.push(er());let d=s===null&&kt(e.children);if(d)i.push(ni());let h=0;for(let[S,y]of a){let w=r?r(S):S,N=`_jxLazy${h}`;h+=1,i.push(`let ${N};`,`const ${N}Load = () => (${N} ??= import('${w}'));`,...y.map(({binding:X,exportName:te})=>`const ${X} = (...args) => ${N}Load().then((m) => m.${te}(...args));`))}i.push("",`class ${t} extends HTMLElement {`," #effects = [];",...s===null?[]:[" #root = null;"],""," constructor() {"," super();");let g=[],m=[],x=[],E=[],O=[];for(let[S,y]of Object.entries(l))if(Se(y))if(gt(y))E.push([S,y]);else if(Ke(y.$expression.operator))x.push([S,y]);else m.push([S,y]);else if($e(y))if(y.$src&&!b(y.body))if(u.has(S)||Pa.has(S))x.push([S,y]);else m.push([S,y]);else if(b(y.body)&&ht(y.body))m.push([S,y]);else x.push([S,y]);else if(b(y)&&y.includes("${"))O.push([S,y]);else{let w=Ju(y);if(w!==void 0)g.push([S,w])}i.push(" this.state = reactive({");for(let[S,y]of g)i.push(` ${ze(S)}: ${y},`);i.push(" });");for(let[S,y]of x)if(i.push(""),Se(y)){let w=le(y.$expression,{eventParam:"e",statePrefix:"s"});i.push(` ${P("this.state",re(S))} = (s, e) => { ${w}; };`)}else if(nt(y)){let w=Ne(y.body,{dispatchTarget:"this",eventParam:"e",indent:" ",statePrefix:"this.state"});i.push(` ${P("this.state",re(S))} = (s, e) => {`,w," };")}else{let w=y.parameters?Be(y.parameters):y.arguments??["state"],N=w.join(", "),X=b(y.body)?y.body:"";if(w[0]==="state")if(y.$src)i.push(` ${P("this.state",re(S))} = (${N}) => ${S}(${N});`);else i.push(` ${P("this.state",re(S))} = (${N}) => {`,` ${X}`," };");else{let te=w.map((ve)=>ve==="state"?"state":"e").join(", ");if(y.$src)i.push(` ${P("this.state",re(S))} = (state, e) => ${S}(${te});`);else i.push(` ${P("this.state",re(S))} = (state, e) => {`,` const _fn = (${N}) => {`,` ${X}`," };",` return _fn(${te});`," };")}}for(let[S,y]of E){i.push("");let w=le(y.$expression,{eventParam:"e",statePrefix:"this.state"});i.push(` ${P("this.state",re(S))} = ${dn(y,w)};`)}for(let[S,y]of O)i.push("",` ${P("this.state",re(S))} = computed(() => ${Xn(y.replaceAll("state.","this.state."))});`);for(let[S,y]of m)if(i.push(""),Se(y)){let w=le(y.$expression,{eventParam:"e",statePrefix:"this.state"});i.push(` ${P("this.state",re(S))} = computed(() => ${w});`)}else if(y.$src)i.push(` ${P("this.state",re(S))} = computed(() => ${S}(this.state));`);else{i.push(` ${P("this.state",re(S))} = computed(() => {`);let w=(b(y.body)?y.body:"").replaceAll("state.","this.state.");i.push(` ${w}`," });")}i.push(" }","");let J=[];if(Array.isArray(e.children)){let S={n:0};for(let y of e.children)Pt(y,J,e.$media??{},"",S,e.tagName)}let C=La(),q=!Array.isArray(e.children)&&e.textContent!==void 0?` ${Lr(e.textContent)}`:Mr(e.children,e.style," ",!1,!1,C);i.push(" template() {"," const s = this.state;",...C.decls," return html`",q," `;"," }","",...s===null?[]:[" #renderRoot() {"," if (this.#root) return this.#root;",s==="closed"?" this.#root = this.attachInternals().shadowRoot ?? this.attachShadow({ mode: 'closed' });":" this.#root = this.shadowRoot ?? this.attachShadow({ mode: 'open' });"," return this.#root;"," }",""]," connectedCallback() {"," const _pa = this.getAttribute('data-jx-props');"," if (_pa) {"," try {"," const _p = JSON.parse(_pa);"," for (const [k, v] of Object.entries(_p)) {"," if (k.startsWith('#')) continue;"," if (k in this.state) this.state[k] = v;"," }"," } catch {}"," this.removeAttribute('data-jx-props');"," }"," const _pn = this.getAttributeNames().filter(n => n.startsWith('props.') && n.length > 6);"," for (const _n of _pn) {"," const _k = _n.slice(6);"," if (_k.startsWith('#')) { this.removeAttribute(_n); continue; }"," if (_k in this.state) {"," this.state[_k] = this.getAttribute(_n);"," this.removeAttribute(_n);"," }"," }"," for (const key of Object.keys(this.state)) {"," if (key.startsWith('#')) continue;"," if (this.hasOwnProperty(key) && this[key] !== undefined) {"," this.state[key] = this[key];"," }"," }");for(let[S,y]of f)i.push(qn(S,y,{collect:"this.#effects",indent:" ",statePrefix:"this.state"}));for(let[S,y]of p)i.push(zn(S,y,{collect:"this.#effects",indent:" ",serverBaseUrl:o,statePrefix:"this.state"}));if(A(e.style)){let S=[];for(let[y,w]of Object.entries(e.style)){if(y.startsWith(":")||y.startsWith(".")||y.startsWith("&")||y.startsWith("[")||y.startsWith("@"))continue;if(b(w)&&w.includes("${"))S.push([de(y),w])}if(S.length>0){i.push(" this.#effects.push(effect(() => {");for(let[y,w]of S){let N=w.replaceAll(/\$\{([^}]+)\}/g,(X,te)=>`\${${te.replaceAll("state.","this.state.")}}`);i.push(` this.style['${y}'] = \`${N}\`;`)}i.push(" }));")}}if(d)i.push(` const _slotted = ${ds}(this);`);if(i.push(" if (this.hasAttribute('data-jx-prerendered')) {"," this.removeAttribute('data-jx-prerendered');"," }"),s===null)i.push(" this.replaceChildren();"," this.#effects.push(effect(() => render(this.template(), this)));");else i.push(" const _root = this.#renderRoot();"," for (const _n of [..._root.childNodes]) {"," if (!(_n.nodeType === 1 && _n.tagName === 'LINK')) _n.remove();"," }"," this.#effects.push(effect(() => render(this.template(), _root)));");if(d)i.push(` ${ms}(this, _slotted);`);return i.push(" if (typeof this.state.onMount === 'function') {"," queueMicrotask(() => this.state.onMount(this.state));"," }"," }",""," disconnectedCallback() {"," for (const _e of this.#effects) { stop(_e); }"," this.#effects.length = 0;"," if (typeof this.state.onUnmount === 'function') { this.state.onUnmount(this.state); }"," }","}","",`customElements.define('${e.tagName}', ${t});`,""),i.join(`
90
+ `)}function La(){return{byText:new Map,decls:[]}}function Fa(e,t){let n=e.byText.get(t);if(n)return n;let r=`_c${e.decls.length}`;e.decls.push(` const ${r} = html\`
47
91
  ${t}
48
- \`;`);let s=`\${${r}}`;return e.byText.set(t,s),s}function jt(e,t,n,r=!1,s=!1,o=null,i=!1){if(!e)return"";let u=i?De:"";if(V(e))return`${Lr(e,n)}${u}`;if(!Array.isArray(e))return"";return e.map((a)=>{if(V(a))return`${Lr(a,n)}${u}`;let c=xn(a,r?"":n,r,s,o);return J(a)&&a.includes("${")||C(a)&&oe(a.tagName)?`${c}${u}`:c}).join(r?"":`
49
- `)}function xn(e,t,n=!1,r=!1,s=null,o=null){if(J(e)){if(e.includes("${"))return`${t}${Rt(e)}`;return`${t}${j(e)}`}if(ee(e)||K(e))return`${t}${j(String(e))}`;if(!C(e))return"";if(oe(e.tagName)){let f=e.tagName.$expression,m=de(f.target,{eventParam:"e",statePrefix:"s"}),y=f.operator==="?:"?[[!0,f.value],[!1,f.initial]]:[...Object.entries(f.cases),["__default__",f.default]],w=y.map(([,h])=>h),O=w.map((h)=>n||be.has(h)),v=null;if(s&&O.every((h)=>h===O[0])){let h=Ir(e,`${t} `,O[0]===!0,r,s,w.some((b)=>b.includes("-")));if(h.trim()!=="")v=Vr(s,h)}let A=y.map(([h,b])=>{let E={...e,tagName:b};return[h,xn(E,`${t} `,n,r,s,v)]});if(f.operator==="?:"){let[,h]=A[0],[,b]=A[1];return`${t}\${${m}
92
+ \`;`);let s=`\${${r}}`;return e.byText.set(t,s),s}function Mr(e,t,n,r=!1,s=!1,o=null,i=!1){if(!e)return"";let c=i?Mt:"";if(ne(e))return`${Da(e,n)}${c}`;if(!Array.isArray(e))return"";return e.map((a)=>{if(ne(a))return`${Da(a,n)}${c}`;let l=io(a,r?"":n,r,s,o);return b(a)&&a.includes("${")||A(a)&&Ie(a.tagName)?`${l}${c}`:l}).join(r?"":`
93
+ `)}function io(e,t,n=!1,r=!1,s=null,o=null){if(b(e)){if(e.includes("${"))return`${t}${Lr(e)}`;return`${t}${_(e)}`}if(se(e)||pe(e))return`${t}${_(String(e))}`;if(!A(e))return"";if(Ie(e.tagName)){let g=e.tagName.$expression,m=Ge(g.target,{eventParam:"e",statePrefix:"s"}),x=g.operator==="?:"?[[!0,g.value],[!1,g.initial]]:[...Object.entries(g.cases),["__default__",g.default]],E=x.map(([,y])=>y),O=E.map((y)=>n||it.has(y)),J=null;if(s&&O.every((y)=>y===O[0])){let y=Ia(e,`${t} `,O[0]===!0,r,s,E.some((w)=>w.includes("-")));if(y.trim()!=="")J=Fa(s,y)}let C=x.map(([y,w])=>{let N={...e,tagName:w};return[y,io(N,`${t} `,n,r,s,J)]});if(g.operator==="?:"){let[,y]=C[0],[,w]=C[1];return`${t}\${${m}
50
94
  ? html\`
51
- ${h}
95
+ ${y}
52
96
  \`
53
97
  : html\`
54
- ${b}
55
- \`}`}let k=A.flatMap(([h,b])=>h==="__default__"?[]:[` ${JSON.stringify(h)}: html\`
56
- ${b}
57
- \``]),[,S]=A.at(-1);return`${t}\${{
58
- ${k.join(`,
98
+ ${w}
99
+ \`}`}let q=C.flatMap(([y,w])=>y==="__default__"?[]:[` ${JSON.stringify(y)}: html\`
100
+ ${w}
101
+ \``]),[,S]=C.at(-1);return`${t}\${{
102
+ ${q.join(`,
59
103
  `)}
60
104
  }[String(${m})] ?? html\`
61
105
  ${S}
62
- \`}`}let i=e.tagName??"div",u=n||be.has(i),a=[];if(e.attributes)for(let[f,m]of Object.entries(e.attributes))if(P(m))a.push(`${f}="\${${_e}('${f}', ${ae(m.$ref)}) ?? nothing}"`);else if(J(m)&&Eo(m))a.push(`${f}="\${${_e}('${f}', ${Q(m).slice(2,-1)}) ?? nothing}"`);else if(J(m)&&m.includes("${"))a.push(`${f}="${Q(m)}"`);else if(K(m)){let y=Ce(f,m);if(y!==null)a.push(y===""?f:`${f}="${y}"`)}else a.push(`${f}="${m}"`);if(e.id)a.push(`id="${Q(String(e.id))}"`);if(e.className)a.push(`class="${Q(String(e.className))}"`);for(let[f,m]of Object.entries(e)){if(ge.has(f)||f.startsWith("$")||f.startsWith("on")||f==="tagName"||f==="id"||f==="className"||f==="style"||f==="children"||f==="textContent"||f==="innerHTML"||f==="attributes")continue;if(At(m))a.push(`.${f}="\${${ae(m.$ref)}}"`);else if(J(m)&&m.includes("${"))a.push(`.${f}="${Q(m)}"`);else a.push(`.${f}="\${${JSON.stringify(m)}}"`)}if(e.$props)for(let[f,m]of Object.entries(e.$props))if(At(m))a.push(`.${f}="\${${ae(m.$ref)}}"`);else if(J(m)&&m.includes("${"))a.push(`.${f}="${Q(m)}"`);else a.push(`.${f}="\${${JSON.stringify(m)}}"`);let c=r?"s.$map = $map; ":"";for(let[f,m]of Object.entries(e)){if(!f.startsWith("on")||f==="observedAttributes")continue;let y=f.slice(2).toLowerCase();if(At(m))a.push(c?`@${y}="\${(e) => { ${c}${ae(m.$ref)}(s, e); }}"`:`@${y}="\${(e) => ${ae(m.$ref)}(s, e)}"`);else if(C(m)&&"$expression"in m){let w=q(m.$expression,{eventParam:"e",statePrefix:"s"});a.push(`@${y}="\${(e) => { ${c}${w}; }}"`)}else if(G(m))a.push(`@${y}="\${(e) => { ${c}${wo(m)} }}"`)}let l=Br(e.style);if(l)a.push(`style="${l}"`);let p=a.length>0?`
106
+ \`}`}let i=e.tagName??"div",c=n||it.has(i),a=[];if(e.attributes)for(let[g,m]of Object.entries(e.attributes))if(H(m))a.push(`${g}="\${${Dt}('${g}', ${Ve(m.$ref)}) ?? nothing}"`);else if(b(m)&&Au(m))a.push(`${g}="\${${Dt}('${g}', ${Je(m).slice(2,-1)}) ?? nothing}"`);else if(b(m)&&m.includes("${"))a.push(`${g}="${Je(m)}"`);else if(pe(m)){let x=xt(g,m);if(x!==null)a.push(x===""?g:`${g}="${x}"`)}else a.push(`${g}="${m}"`);if(e.id)a.push(`id="${Je(String(e.id))}"`);if(e.className)a.push(`class="${Je(String(e.className))}"`);for(let[g,m]of Object.entries(e)){if(Ye.has(g)||g.startsWith("$")||g.startsWith("on")||g==="tagName"||g==="id"||g==="className"||g==="style"||g==="children"||g==="textContent"||g==="innerHTML"||g==="attributes")continue;if(Dr(m))a.push(`.${g}="\${${Ve(m.$ref)}}"`);else if(b(m)&&m.includes("${"))a.push(`.${g}="${Je(m)}"`);else a.push(`.${g}="\${${JSON.stringify(m)}}"`)}if(e.$props)for(let[g,m]of Object.entries(e.$props))if(Dr(m))a.push(`.${g}="\${${Ve(m.$ref)}}"`);else if(b(m)&&m.includes("${"))a.push(`.${g}="${Je(m)}"`);else a.push(`.${g}="\${${JSON.stringify(m)}}"`);let l=r?"s.$map = $map; ":"";for(let[g,m]of Object.entries(e)){if(!g.startsWith("on")||g==="observedAttributes")continue;let x=g.slice(2).toLowerCase();if(Dr(m))a.push(l?`@${x}="\${(e) => { ${l}${Ve(m.$ref)}(s, e); }}"`:`@${x}="\${(e) => ${Ve(m.$ref)}(s, e)}"`);else if(A(m)&&"$expression"in m){let E=le(m.$expression,{eventParam:"e",statePrefix:"s"});a.push(`@${x}="\${(e) => { ${l}${E}; }}"`)}else if($e(m))a.push(`@${x}="\${(e) => { ${l}${Ou(m)} }}"`)}let u=Va(e.style);if(u)a.push(`style="${u}"`);let f=a.length>0?`
63
107
  ${t} ${a.join(`
64
- ${t} `)}`:"";if(new Set(["input","br","hr","img","meta","link"]).has(i))return`${t}<${i}${p}
65
- ${t}>`;let d=o??Ir(e,t,u,r,s,i.includes("-")),x=i==="slot"?De:"";return u?`${x}<${i}${p}>${d}${x}</${i}>`:`${t}${x}<${i}${p}
66
- ${t}>${d}${x}</${i}>`}function Ir(e,t,n,r,s,o=!1){if(e.$switch){let i=P(e.$switch)?e.$switch.$ref:e.$switch,u=ae(i),a=[];for(let[g,d]of Object.entries(e.cases??{})){if(!d||P(d))continue;a.push([g,xn(d,`${t} `,!1,r,s)])}let c=a.map(([,g])=>g),l=new Set(c.filter((g,d)=>c.indexOf(g)!==d&&g.trim()!==""));return`\${{
67
- ${a.map(([g,d])=>{let x=s&&l.has(d)?Vr(s,d):d;return` ${JSON.stringify(g)}: html\`
68
- ${x}
108
+ ${t} `)}`:"";if(new Set(["input","br","hr","img","meta","link"]).has(i))return`${t}<${i}${f}
109
+ ${t}>`;let d=o??Ia(e,t,c,r,s,i.includes("-")),h=i==="slot"?Mt:"";return c?`${h}<${i}${f}>${d}${h}</${i}>`:`${t}${h}<${i}${f}
110
+ ${t}>${d}${h}</${i}>`}function Ia(e,t,n,r,s,o=!1){if(e.$switch){let i=H(e.$switch)?e.$switch.$ref:e.$switch,c=Ve(i),a=[];for(let[p,d]of Object.entries(e.cases??{})){if(!d||H(d))continue;a.push([p,io(d,`${t} `,!1,r,s)])}let l=a.map(([,p])=>p),u=new Set(l.filter((p,d)=>l.indexOf(p)!==d&&p.trim()!==""));return`\${{
111
+ ${a.map(([p,d])=>{let h=s&&u.has(d)?Fa(s,d):d;return` ${JSON.stringify(p)}: html\`
112
+ ${h}
69
113
  \``}).join(`,
70
114
  `)}
71
- }[${u}]}`}if(e.textContent!==void 0){let i=Rt(e.textContent),u=P(e.textContent)||J(e.textContent)&&e.textContent.includes("${");return o&&u?`${i}${De}`:i}if(e.innerHTML!==void 0)return e.innerHTML;if(e.children)return n?jt(e.children,e.style,"",!0,r,s,o):`
72
- ${jt(e.children,e.style,`${t} `,!1,r,s,o)}
73
- ${t}`;return""}function Lr(e,t){let n=P(e.items)?ae(e.items.$ref):"ITEMS",r=e.map;if(!r)return"";let s=r.tagName??"div",o=[];if(r.attributes)for(let[d,x]of Object.entries(r.attributes))if(P(x))o.push(`${d}="\${${hn(x.$ref)}}"`);else if(J(x)&&x.includes("${"))o.push(`${d}="${Q(x)}"`);else o.push(`${d}="${x}"`);if(r.id)o.push(`id="${Q(String(r.id))}"`);if(r.className)o.push(`class="${Q(String(r.className))}"`);for(let[d,x]of Object.entries(r)){if(ge.has(d)||d.startsWith("$")||d.startsWith("on")||d==="tagName"||d==="id"||d==="className"||d==="style"||d==="children"||d==="textContent"||d==="innerHTML"||d==="attributes")continue;if(At(x))o.push(`.${d}="\${${hn(x.$ref)}}"`);else if(J(x)&&x.includes("${"))o.push(`.${d}="${Q(x)}"`);else o.push(`.${d}="\${${JSON.stringify(x)}}"`)}if(r.$props)for(let[d,x]of Object.entries(r.$props))if(P(x))o.push(`.${d}="\${${hn(x.$ref)}}"`);else if(J(x)&&x.includes("${"))o.push(`.${d}="${Q(x)}"`);else o.push(`.${d}="\${${JSON.stringify(x)}}"`);let i=Br(r.style);if(i)o.push(`style="${i}"`);for(let[d,x]of Object.entries(r)){if(!d.startsWith("on"))continue;let f=d.slice(2).toLowerCase();if(P(x))o.push(`@${f}="\${(e) => { s.$map = $map; ${ae(x.$ref)}(s, e); }}"`);else if(X(x)){let m=q(x.$expression,{eventParam:"e",statePrefix:"s"});o.push(`@${f}="\${(e) => { s.$map = $map; ${m}; }}"`)}}let u=o.length>0?`
115
+ }[${c}]}`}if(e.textContent!==void 0){let i=Lr(e.textContent),c=H(e.textContent)||b(e.textContent)&&e.textContent.includes("${");return o&&c?`${i}${Mt}`:i}if(e.innerHTML!==void 0)return e.innerHTML;if(e.children)return n?Mr(e.children,e.style,"",!0,r,s,o):`
116
+ ${Mr(e.children,e.style,`${t} `,!1,r,s,o)}
117
+ ${t}`;return""}function Da(e,t){let n=H(e.items)?Ve(e.items.$ref):"ITEMS",r=e.map;if(!r)return"";let s=r.tagName??"div",o=[];if(r.attributes)for(let[d,h]of Object.entries(r.attributes))if(H(h))o.push(`${d}="\${${oo(h.$ref)}}"`);else if(b(h)&&h.includes("${"))o.push(`${d}="${Je(h)}"`);else o.push(`${d}="${h}"`);if(r.id)o.push(`id="${Je(String(r.id))}"`);if(r.className)o.push(`class="${Je(String(r.className))}"`);for(let[d,h]of Object.entries(r)){if(Ye.has(d)||d.startsWith("$")||d.startsWith("on")||d==="tagName"||d==="id"||d==="className"||d==="style"||d==="children"||d==="textContent"||d==="innerHTML"||d==="attributes")continue;if(Dr(h))o.push(`.${d}="\${${oo(h.$ref)}}"`);else if(b(h)&&h.includes("${"))o.push(`.${d}="${Je(h)}"`);else o.push(`.${d}="\${${JSON.stringify(h)}}"`)}if(r.$props)for(let[d,h]of Object.entries(r.$props))if(H(h))o.push(`.${d}="\${${oo(h.$ref)}}"`);else if(b(h)&&h.includes("${"))o.push(`.${d}="${Je(h)}"`);else o.push(`.${d}="\${${JSON.stringify(h)}}"`);let i=Va(r.style);if(i)o.push(`style="${i}"`);for(let[d,h]of Object.entries(r)){if(!d.startsWith("on"))continue;let g=d.slice(2).toLowerCase();if(H(h))o.push(`@${g}="\${(e) => { s.$map = $map; ${Ve(h.$ref)}(s, e); }}"`);else if(Se(h)){let m=le(h.$expression,{eventParam:"e",statePrefix:"s"});o.push(`@${g}="\${(e) => { s.$map = $map; ${m}; }}"`)}}let c=o.length>0?`
74
118
  ${t} ${o.join(`
75
- ${t} `)}`:"",a=Wr(),c="";if(r.textContent!==void 0)c=Rt(r.textContent);else if(r.children)c=`
76
- ${jt(r.children,null,`${t} `,!1,!0,a)}
77
- ${t} `;let l=`html\`
78
- ${t} <${s}${u}
79
- ${t} >${c}</${s}>
80
- ${t}\``,p=(l.includes("$map")?"const $map = { item, index }; ":"")+a.decls.map((d)=>`${d.trim()} `).join(""),g=p?`(item, index) => { ${p}return ${l}; }`:`(item, index) => ${l}`;return`${t}\${${n}.map(${g})}`}function At(e){return P(e)&&e.$ref!==""}function ae(e){if(e.startsWith("#/state/"))return R("s",e.slice(8));if(e.startsWith("$map/"))return Hr(e.slice(5));if(e.startsWith("parent#/"))return R("s",e.slice(8));if(e.startsWith("window#/"))return R("window",e.slice(8));if(e.startsWith("document#/"))return R("document",e.slice(10));return R("s",e)}function Hr(e){let[t,...n]=pe(e);return R(t??"",n.map((r)=>B(r)).join("/"))}function hn(e){if(e.startsWith("$map/"))return Hr(e.slice(5));return ae(e)}function Q(e){return e.replaceAll("state.","s.")}function Eo(e){return e.startsWith("${")&&e.endsWith("}")&&!e.slice(2).includes("${")}function Rt(e){if(P(e))return`\${${ae(e.$ref)}}`;if(J(e)&&e.includes("${"))return Q(e);return String(e)}function wo(e){if(xe(e))return ne(e.body,{dispatchTarget:"e.currentTarget",eventParam:"e",statePrefix:"s"});let t=J(e.body)?e.body:"",n=e.parameters?ce(e.parameters):e.arguments??[];if(n.length>0){let r=n.map((s)=>s==="state"?"s":"e").join(", ");return`((${n.join(", ")}) => { ${t} })(${r});`}return t.replaceAll(/(?<!this\.)state\./g,"s.").replaceAll(/(?<!this\.)state(?!\.)/g,"s")}function Br(e){if(!C(e))return"";let t=[];for(let[n,r]of Object.entries(e)){if(n.startsWith(":")||n.startsWith(".")||n.startsWith("&")||n.startsWith("[")||n.startsWith("@"))continue;if(J(r)&&r.includes("${")){let s=z(n);t.push(`${s}: ${Q(r)}`)}}return t.join("; ")}var Mr;var Nt=I(()=>{ze();Ie();H();pn();je();Mr=new Set(["onMount","onUnmount","onAdopted"])});function Ur(e,t){let{title:n="Jx App",reactivitySrc:r,litHtmlSrc:s}=t,o=ke(e,null,e.state??{},e.$media??{}),i=Me(e,e.$media??{},t.projectStyle??null),u=[],a=qr(e,!1,o,u),c=[],l="",p="";if(u.length>0){for(let x of u){let f=Qe(x.def,x.className,[],t.rewriteSrc);c.push({content:f,path:`_islands/${x.tagName}.js`,tagName:x.tagName})}l=`<script type="importmap">
119
+ ${t} `)}`:"",a=La(),l="";if(r.textContent!==void 0)l=Lr(r.textContent);else if(r.children)l=`
120
+ ${Mr(r.children,null,`${t} `,!1,!0,a)}
121
+ ${t} `;let u=`html\`
122
+ ${t} <${s}${c}
123
+ ${t} >${l}</${s}>
124
+ ${t}\``,f=(u.includes("$map")?"const $map = { item, index }; ":"")+a.decls.map((d)=>`${d.trim()} `).join(""),p=f?`(item, index) => { ${f}return ${u}; }`:`(item, index) => ${u}`;return`${t}\${${n}.map(${p})}`}function Dr(e){return H(e)&&e.$ref!==""}function Ve(e){if(e.startsWith("#/state/"))return P("s",e.slice(8));if(e.startsWith("$map/"))return Wa(e.slice(5));if(e.startsWith("parent#/"))return P("s",e.slice(8));if(e.startsWith("window#/"))return P("window",e.slice(8));if(e.startsWith("document#/"))return P("document",e.slice(10));return P("s",e)}function Wa(e){let[t,...n]=qe(e);return P(t??"",n.map((r)=>re(r)).join("/"))}function oo(e){if(e.startsWith("$map/"))return Wa(e.slice(5));return Ve(e)}function Je(e){return e.replaceAll("state.","s.")}function Au(e){return e.startsWith("${")&&e.endsWith("}")&&!e.slice(2).includes("${")}function Lr(e){if(H(e))return`\${${Ve(e.$ref)}}`;if(b(e)&&e.includes("${"))return Je(e);return String(e)}function Ou(e){if(nt(e))return Ne(e.body,{dispatchTarget:"e.currentTarget",eventParam:"e",statePrefix:"s"});let t=b(e.body)?e.body:"",n=e.parameters?Be(e.parameters):e.arguments??[];if(n.length>0){let r=n.map((s)=>s==="state"?"s":"e").join(", ");return`((${n.join(", ")}) => { ${t} })(${r});`}return t.replaceAll(/(?<!this\.)state\./g,"s.").replaceAll(/(?<!this\.)state(?!\.)/g,"s")}function Va(e){if(!A(e))return"";let t=[];for(let[n,r]of Object.entries(e)){if(n.startsWith(":")||n.startsWith(".")||n.startsWith("&")||n.startsWith("[")||n.startsWith("@"))continue;if(b(r)&&r.includes("${")){let s=de(n);t.push(`${s}: ${Je(r)}`)}}return t.join("; ")}var Pa;var Fr=v(()=>{fn();Ft();K();_r();jt();Pa=new Set(["onMount","onUnmount","onAdopted"])});function Ha(e,t){let{title:n="Jx App",reactivitySrc:r,litHtmlSrc:s}=t,o=It(e,null,e.state??{},e.$media??{}),i=Lt(e,e.$media??{},t.projectStyle??null),c=[],a=Ba(e,!1,o,c),l=[],u="",f="";if(c.length>0){for(let h of c){let g=Rn(h.def,h.className,[],t.rewriteSrc);l.push({content:g,path:`_islands/${h.tagName}.js`,tagName:h.tagName})}u=`<script type="importmap">
81
125
  {
82
126
  "imports": {
83
127
  "@vue/reactivity": "${r}",
84
128
  "lit-html": "${s}"
85
129
  }
86
130
  }
87
- </script>`,p=c.map((x)=>`<script type="module" src="./${x.path}"></script>`).join(`
88
- `)}let g=t.prePaintScheme!==!1&&Object.values(e.$media??{}).some((x)=>ue(String(x))!==null)?`<script>${$t()}</script>
131
+ </script>`,f=l.map((h)=>`<script type="module" src="./${h.path}"></script>`).join(`
132
+ `)}let p=t.prePaintScheme!==!1&&Object.values(e.$media??{}).some((h)=>Ue(String(h))!==null)?`<script>${Zn()}</script>
89
133
  `:"",d=`<!DOCTYPE html>
90
134
  <html lang="en">
91
135
  <head>
92
136
  <meta charset="utf-8">
93
137
  <meta name="viewport" content="width=device-width, initial-scale=1">
94
- <title>${j(n)}</title>
95
- ${g}${l}
138
+ <title>${_(n)}</title>
139
+ ${p}${u}
96
140
  ${i}
97
141
  </head>
98
142
  <body>
99
143
  ${a}
100
- ${p}
144
+ ${f}
101
145
  </body>
102
- </html>`;return{files:c,html:d}}function qr(e,t,n,r){if(J(e))return j(e);if(ee(e)||K(e))return j(String(e));if(!C(e))return"";let s=ke(e,n.scope,e.state??n.scopeDefs,e.$media??n.media);if(t){let c=r.length,l=`jx-island-${c}`,p=`JxIsland${c}`,g={...e,tagName:l};return r.push({className:p,def:g,tagName:l}),`<${l}></${l}>`}let o=cn(e.tagName,s.scope),i=ve(e,s.scope);if(ln.has(o))return`<${o}${i}>`;let u=n.preformatted===!0||be.has(o),a=Co(e,{...s,preformatted:u},r);return`<${o}${i}>${a}</${o}>`}function Co(e,t,n){if(e.textContent!==void 0){let r=T(e.textContent,t.scope);return r==null?"":j(String(r))}if(e.innerHTML){let r=T(e.innerHTML,t.scope);return r==null?e.innerHTML:String(r)}if(Array.isArray(e.children))return e.children.map((r)=>qr(r,ir(r),t,n)).join(Xe(t.preformatted));return""}var Kr=I(()=>{Ie();Nt();H()});function bn(e,t){let{title:n="Jx App",reactivitySrc:r=gt,litHtmlSrc:s=ht,modulePath:o="app.js",serverBaseUrl:i="/_jx/server"}=t,u=ke(e,null,e.state??{},e.$media??{}),a=Me(e,e.$media??{},t.projectStyle??null),c={h:0,l:0,m:0,needsLit:!1,s:0,sw:0,t:0},l=new Map,p=new Map,g=[],d=[],x=[],f=[],m=[],y=[],w=new Map,O=e.state??{};for(let[b,E]of Object.entries(O)){if(!C(E)||Array.isArray(E)){if(N(E))d.push([b,`() => ${yt(E)}`]);else g.push([b,E]);continue}if(X(E)){let F=E.$expression,W=q(F,{eventParam:"e",statePrefix:"state"});if(Ee(E))m.push(`state[${JSON.stringify(b)}] = ${Ge(E,W)};`);else if(me(F.operator))f.push([b,{args:["state","e"],body:W}]);else d.push([b,`() => ${W}`]);continue}if(G(E)){let F=E.parameters?ce(E.parameters):E.arguments,{body:W}=E;if(Array.isArray(W)){let re=ne(W,{eventParam:"e",statePrefix:"state"});if(E.parameters&&E.parameters.length>0)m.push(`state[${JSON.stringify(b)}] = ${Ge(E,`(() => {
103
- ${re}
104
- })()`)};`);else f.push([b,{args:["state","e"],body:re}])}else if(E.$src){let re=w.get(E.$src);if(!re)re=new Set,w.set(E.$src,re);re.add(ft(b,E)),d.push([b,`() => { return ${b}(state); }`])}else if(J(W)&&we(W))d.push([b,`() => { ${W} }`]);else f.push([b,{args:F??["state"],body:W}]);continue}if($e(E))continue;if(vn(E)){g.push([b,E.default]);continue}if(ye(E)){if(E.$prototype==="LocalStorage"||E.$prototype==="SessionStorage"){let F=E.$prototype==="LocalStorage"?"localStorage":"sessionStorage",W=E.key??b,re=E.default??null;g.push([b,null]),m.push(Oo(b,F,W,re));continue}if(E.$prototype==="Request"){g.push([b,null]),m.push(mt(b,E));continue}if(E.$prototype==="Cookie"){g.push([b,null]),m.push(Ao(b,E.name??b,E.default??null));continue}}if(le(E)){g.push([b,null]),y.push(dt(b,E,{serverBaseUrl:i}));continue}g.push([b,E])}let v=zr(e,u,l,p,c);for(let[b,E]of l)if(!x.some(([F])=>F===b))x.push([b,E]);for(let[b,E]of p)if(!f.some(([F])=>F===b))f.push([b,E]);let A=vo(g,d,x,f,m,y,w,c,r,t.rewriteSrc),k=[` "@vue/reactivity": "${r}"`,` "lit-html": "${s}"`],S=t.prePaintScheme!==!1&&Object.values(e.$media??{}).some((b)=>ue(String(b))!==null)?`<script>${$t()}</script>
105
- `:"",h=`<!DOCTYPE html>
146
+ </html>`;return{files:l,html:d}}function Ba(e,t,n,r){if(b(e))return _(e);if(se(e)||pe(e))return _(String(e));if(!A(e))return"";let s=It(e,n.scope,e.state??n.scopeDefs,e.$media??n.media);if(t){let l=r.length,u=`jx-island-${l}`,f=`JxIsland${l}`,p={...e,tagName:u};return r.push({className:f,def:p,tagName:u}),`<${u}></${u}>`}let o=xs(e.tagName,s.scope),i=yt(e,s.scope);if(hs.has(o))return`<${o}${i}>`;let c=n.preformatted===!0||it.has(o),a=Cu(e,{...s,preformatted:c},r);return`<${o}${i}>${a}</${o}>`}function Cu(e,t,n){if(e.textContent!==void 0){let r=B(e.textContent,t.scope);return r==null?"":_(String(r))}if(e.innerHTML){let r=B(e.innerHTML,t.scope);return r==null?e.innerHTML:String(r)}if(Array.isArray(e.children))return e.children.map((r)=>Ba(r,Yo(r),t,n)).join(mn(t.preformatted));return""}var Ua=v(()=>{Ft();Fr();K()});function uo(e,t){let{title:n="Jx App",reactivitySrc:r=Kn,litHtmlSrc:s=Gn,modulePath:o="app.js",serverBaseUrl:i="/_jx/server"}=t,c=It(e,null,e.state??{},e.$media??{}),a=Lt(e,e.$media??{},t.projectStyle??null),l={h:0,l:0,m:0,needsLit:!1,s:0,sw:0,t:0},u=new Map,f=new Map,p=[],d=[],h=[],g=[],m=[],x=[],E=new Map,O=e.state??{};for(let[w,N]of Object.entries(O)){if(!A(N)||Array.isArray(N)){if(L(N))d.push([w,`() => ${Xn(N)}`]);else p.push([w,N]);continue}if(Se(N)){let X=N.$expression,te=le(X,{eventParam:"e",statePrefix:"state"});if(gt(N))m.push(`state[${JSON.stringify(w)}] = ${dn(N,te)};`);else if(Ke(X.operator))g.push([w,{args:["state","e"],body:te}]);else d.push([w,`() => ${te}`]);continue}if($e(N)){let X=N.parameters?Be(N.parameters):N.arguments,{body:te}=N;if(Array.isArray(te)){let ve=Ne(te,{eventParam:"e",statePrefix:"state"});if(N.parameters&&N.parameters.length>0)m.push(`state[${JSON.stringify(w)}] = ${dn(N,`(() => {
147
+ ${ve}
148
+ })()`)};`);else g.push([w,{args:["state","e"],body:ve}])}else if(N.$src){let ve=E.get(N.$src);if(!ve)ve=new Set,E.set(N.$src,ve);ve.add(Un(w,N)),d.push([w,`() => { return ${w}(state); }`])}else if(b(te)&&ht(te))d.push([w,`() => { ${te} }`]);else g.push([w,{args:X??["state"],body:te}]);continue}if(st(N))continue;if(ho(N)){p.push([w,N.default]);continue}if(rt(N)){if(N.$prototype==="LocalStorage"||N.$prototype==="SessionStorage"){let X=N.$prototype==="LocalStorage"?"localStorage":"sessionStorage",te=N.key??w,ve=N.default??null;p.push([w,null]),m.push(Tu(w,X,te,ve));continue}if(N.$prototype==="Request"){p.push([w,null]),m.push(qn(w,N));continue}if(N.$prototype==="Cookie"){p.push([w,null]),m.push(ju(w,N.name??w,N.default??null));continue}}if(He(N)){p.push([w,null]),x.push(zn(w,N,{serverBaseUrl:i}));continue}p.push([w,N])}let J=qa(e,c,u,f,l);for(let[w,N]of u)if(!h.some(([X])=>X===w))h.push([w,N]);for(let[w,N]of f)if(!g.some(([X])=>X===w))g.push([w,N]);let C=vu(p,d,h,g,m,x,E,l,r,t.rewriteSrc),q=[` "@vue/reactivity": "${r}"`,` "lit-html": "${s}"`],S=t.prePaintScheme!==!1&&Object.values(e.$media??{}).some((w)=>Ue(String(w))!==null)?`<script>${Zn()}</script>
149
+ `:"",y=`<!DOCTYPE html>
106
150
  <html lang="en">
107
151
  <head>
108
152
  <meta charset="utf-8">
109
153
  <meta name="viewport" content="width=device-width, initial-scale=1">
110
- <title>${j(n)}</title>
154
+ <title>${_(n)}</title>
111
155
  ${S}<script type="importmap">
112
156
  {
113
157
  "imports": {
114
- ${k.join(`,
158
+ ${q.join(`,
115
159
  `)}
116
160
  }
117
161
  }
@@ -120,19 +164,19 @@ ${k.join(`,
120
164
  <script type="module" src="./${o}"></script>
121
165
  </head>
122
166
  <body>
123
- ${v}
167
+ ${J}
124
168
  </body>
125
- </html>`;return{files:[{content:A,path:o}],html:h}}function zr(e,t,n,r,s){if(J(e))return j(e);if(ee(e)||K(e))return j(String(e));if(!C(e))return"";let o=ke(e,t.scope,e.state??t.scopeDefs,e.$media??t.media);if(oe(e.tagName))throw Error(`A tag chosen at creation is not supported on a dynamic page yet (candidates: ${Oe(e.tagName).join(", ")}). Move the element into a component, or give it a literal tagName.`);let i=e.tagName??"div";o.preformatted=t.preformatted===!0||be.has(i);let u=[],a=!1;if(e.textContent!==void 0){let f=e.textContent;if(Y(f)){let m=Le(f.$ref);u.push(`:text-content="${m}"`),yn(n,m,f.$ref),a=!0}else if(N(f)){let m=`_t${s.t}`;s.t+=1,u.push(`:text-content="${m}"`),n.set(m,`() => \`${f}\``),a=!0}}for(let[f,m]of Object.entries(e)){if(!f.startsWith("on")||f==="observedAttributes")continue;let y=f.slice(2).toLowerCase();if(Y(m)){let w=Le(m.$ref);u.push(`@${y}="${w}"`),a=!0}else if(G(m)){let w=`_h${s.h}`;s.h+=1,u.push(`@${y}="${w}"`);let{body:O}=m;r.set(w,Array.isArray(O)?{args:["state","e"],body:ne(O,{eventParam:"e",statePrefix:"state"})}:{args:m.parameters?ce(m.parameters):m.arguments??["state","event"],body:O}),a=!0}else if(X(m)){let w=`_h${s.h}`;s.h+=1,u.push(`@${y}="${w}"`);let O=q(m.$expression,{eventParam:"e",statePrefix:"state"});r.set(w,{args:["state","e"],body:O}),a=!0}}if(C(e.style))for(let[f,m]of Object.entries(e.style)){if(f.startsWith(":")||f.startsWith(".")||f.startsWith("&")||f.startsWith("[")||f.startsWith("@"))continue;if(Gr(m))continue;if(N(m)){let y=`_s${s.s}`;s.s+=1,u.push(`:style.${z(f)}="${y}"`),n.set(y,`() => \`${m}\``),a=!0}}if(C(e.attributes)){for(let[f,m]of Object.entries(e.attributes))if(Y(m)){let y=Le(m.$ref);u.push(`:attr.${f}="${y}"`),yn(n,y,m.$ref),a=!0}else if(N(m)){let y=`_t${s.t}`;s.t+=1,u.push(`:attr.${f}="${y}"`),n.set(y,`() => \`${m}\``),a=!0}}for(let[f,m]of Object.entries(e)){if(ge.has(f)||f.startsWith("on")||f.startsWith("$")||f==="tagName"||f==="id"||f==="className"||f==="style"||f==="children"||f==="textContent"||f==="innerHTML"||f==="attributes")continue;if(Y(m)){let y=Le(m.$ref);u.push(`:${z(f)}="${y}"`),yn(n,y,m.$ref),a=!0}else if(N(m)){let y=`_t${s.t}`;s.t+=1,u.push(`:${z(f)}="${y}"`),n.set(y,`() => \`${m}\``),a=!0}}let c=ve(e,o.scope),l=a?" data-bind":"",p=u.length>0?` ${u.join(" ")}`:"",g="",d=e;if(d.$switch){s.needsLit=!0;let f=`_sw${s.sw}`;s.sw+=1;let m=Y(d.$switch)?Sn(d.$switch.$ref):`\`${String(d.$switch)}\``,y=d.cases??{},w=Object.entries(y).filter(([,v])=>v&&!Y(v)).map(([v,A])=>`${JSON.stringify(v)}: html\`${$n(A,o.preformatted)}\``);n.set(f,`() => ({${w.join(", ")}})[String(${m})] ?? html\`\``),u.push(`:render="${f}"`);let O=` ${u.join(" ")}`;return`<${i}${c} data-bind${O}></${i}>`}if(d.textContent!==void 0&&!a){let f=T(d.textContent,o.scope);g=f==null?"":j(String(f))}else if(d.textContent!==void 0&&a){let f=T(d.textContent,o.scope);g=f==null?"":j(String(f))}else if(d.innerHTML){let f=T(d.innerHTML,o.scope);g=f==null?d.innerHTML:String(f)}else if(V(d.children)){s.needsLit=!0;let f=`_list${s.l}`;s.l+=1;let m=d.children,y=Y(m.items)?Sn(m.items.$ref):JSON.stringify(m.items),w=Jn(m.map);n.set(f,`() => (${y} ?? []).map((item, index) => html\`${w}\`)`),u.push(`:render="${f}"`),a=!0;let O=" data-bind",v=` ${u.join(" ")}`;if(new Set(["input","br","hr","img","meta","link"]).has(i))return`<${i}${c}${O}${v}>`;return`<${i}${c}${O}${v}></${i}>`}else if(Array.isArray(d.children)&&d.children.some((f)=>V(f))){s.needsLit=!0;let f=`_children${s.l}`;s.l+=1;let m=d.children.map((w)=>$n(w,o.preformatted)).join(Xe(o.preformatted," "));n.set(f,o.preformatted?`() => html\`${m}\``:`() => html\`
169
+ </html>`;return{files:[{content:C,path:o}],html:y}}function qa(e,t,n,r,s){if(b(e))return _(e);if(se(e)||pe(e))return _(String(e));if(!A(e))return"";let o=It(e,t.scope,e.state??t.scopeDefs,e.$media??t.media);if(Ie(e.tagName))throw Error(`A tag chosen at creation is not supported on a dynamic page yet (candidates: ${vt(e.tagName).join(", ")}). Move the element into a component, or give it a literal tagName.`);let i=e.tagName??"div";o.preformatted=t.preformatted===!0||it.has(i);let c=[],a=!1;if(e.textContent!==void 0){let g=e.textContent;if(me(g)){let m=nn(g.$ref);c.push(`:text-content="${m}"`),ao(n,m,g.$ref),a=!0}else if(L(g)){let m=`_t${s.t}`;s.t+=1,c.push(`:text-content="${m}"`),n.set(m,`() => \`${g}\``),a=!0}}for(let[g,m]of Object.entries(e)){if(!g.startsWith("on")||g==="observedAttributes")continue;let x=g.slice(2).toLowerCase();if(me(m)){let E=nn(m.$ref);c.push(`@${x}="${E}"`),a=!0}else if($e(m)){let E=`_h${s.h}`;s.h+=1,c.push(`@${x}="${E}"`);let{body:O}=m;r.set(E,Array.isArray(O)?{args:["state","e"],body:Ne(O,{eventParam:"e",statePrefix:"state"})}:{args:m.parameters?Be(m.parameters):m.arguments??["state","event"],body:O}),a=!0}else if(Se(m)){let E=`_h${s.h}`;s.h+=1,c.push(`@${x}="${E}"`);let O=le(m.$expression,{eventParam:"e",statePrefix:"state"});r.set(E,{args:["state","e"],body:O}),a=!0}}if(A(e.style))for(let[g,m]of Object.entries(e.style)){if(g.startsWith(":")||g.startsWith(".")||g.startsWith("&")||g.startsWith("[")||g.startsWith("@"))continue;if(Ka(m))continue;if(L(m)){let x=`_s${s.s}`;s.s+=1,c.push(`:style.${de(g)}="${x}"`),n.set(x,`() => \`${m}\``),a=!0}}if(A(e.attributes)){for(let[g,m]of Object.entries(e.attributes))if(me(m)){let x=nn(m.$ref);c.push(`:attr.${g}="${x}"`),ao(n,x,m.$ref),a=!0}else if(L(m)){let x=`_t${s.t}`;s.t+=1,c.push(`:attr.${g}="${x}"`),n.set(x,`() => \`${m}\``),a=!0}}for(let[g,m]of Object.entries(e)){if(Ye.has(g)||g.startsWith("on")||g.startsWith("$")||g==="tagName"||g==="id"||g==="className"||g==="style"||g==="children"||g==="textContent"||g==="innerHTML"||g==="attributes")continue;if(me(m)){let x=nn(m.$ref);c.push(`:${de(g)}="${x}"`),ao(n,x,m.$ref),a=!0}else if(L(m)){let x=`_t${s.t}`;s.t+=1,c.push(`:${de(g)}="${x}"`),n.set(x,`() => \`${m}\``),a=!0}}let l=yt(e,o.scope),u=a?" data-bind":"",f=c.length>0?` ${c.join(" ")}`:"",p="",d=e;if(d.$switch){s.needsLit=!0;let g=`_sw${s.sw}`;s.sw+=1;let m=me(d.$switch)?co(d.$switch.$ref):`\`${String(d.$switch)}\``,x=d.cases??{},E=Object.entries(x).filter(([,J])=>J&&!me(J)).map(([J,C])=>`${JSON.stringify(J)}: html\`${lo(C,o.preformatted)}\``);n.set(g,`() => ({${E.join(", ")}})[String(${m})] ?? html\`\``),c.push(`:render="${g}"`);let O=` ${c.join(" ")}`;return`<${i}${l} data-bind${O}></${i}>`}if(d.textContent!==void 0&&!a){let g=B(d.textContent,o.scope);p=g==null?"":_(String(g))}else if(d.textContent!==void 0&&a){let g=B(d.textContent,o.scope);p=g==null?"":_(String(g))}else if(d.innerHTML){let g=B(d.innerHTML,o.scope);p=g==null?d.innerHTML:String(g)}else if(ne(d.children)){s.needsLit=!0;let g=`_list${s.l}`;s.l+=1;let m=d.children,x=me(m.items)?co(m.items.$ref):JSON.stringify(m.items),E=fo(m.map);n.set(g,`() => (${x} ?? []).map((item, index) => html\`${E}\`)`),c.push(`:render="${g}"`),a=!0;let O=" data-bind",J=` ${c.join(" ")}`;if(new Set(["input","br","hr","img","meta","link"]).has(i))return`<${i}${l}${O}${J}>`;return`<${i}${l}${O}${J}></${i}>`}else if(Array.isArray(d.children)&&d.children.some((g)=>ne(g))){s.needsLit=!0;let g=`_children${s.l}`;s.l+=1;let m=d.children.map((E)=>lo(E,o.preformatted)).join(mn(o.preformatted," "));n.set(g,o.preformatted?`() => html\`${m}\``:`() => html\`
126
170
  ${m}
127
- \``),u.push(`:render="${f}"`),a=!0;let y=` ${u.join(" ")}`;return`<${i}${c} data-bind${y}></${i}>`}else if(Array.isArray(d.children))g=d.children.map((f)=>zr(f,o,n,r,s)).join(Xe(o.preformatted));if(new Set(["input","br","hr","img","meta","link"]).has(i))return`<${i}${c}${l}${p}>`;return`<${i}${c}${l}${p}>${g}</${i}>`}function Jn(e,t=!1){if(!e)return"";if(oe(e.tagName))throw Error(`A tag chosen at creation is not supported inside a dynamic page's repeater yet (candidates: ${Oe(e.tagName).join(", ")}). Move the item into a component, or give it a literal tagName.`);let n=e.tagName??"div",r=t||be.has(n),s="";if(e.id)s+=` id="${e.id}"`;if(e.className)s+=` class="${Je(e.className)}"`;if(C(e.$props))for(let[a,c]of Object.entries(e.$props))if(Y(c))s+=` .${a}="\${${jo(c.$ref)}}"`;else if(N(c))s+=` .${a}="${Je(c)}"`;else s+=` .${a}="\${${JSON.stringify(c)}}"`;if(C(e.attributes))for(let[a,c]of Object.entries(e.attributes)){if(N(c)){s+=` ${a}="${Je(c)}"`;continue}if(K(c)){let l=Ce(a,c);if(l!==null)s+=l===""?` ${a}`:` ${a}="${j(l)}"`;continue}s+=` ${a}="${j(String(c))}"`}if(C(e.style)){let a=[];for(let[c,l]of Object.entries(e.style)){if(c.startsWith(":")||c.startsWith(".")||c.startsWith("&")||c.startsWith("[")||c.startsWith("@"))continue;if(Gr(l))continue;let p=z(c);if(N(String(l)))a.push(`${p}: ${Je(String(l))}`);else a.push(`${p}: ${l}`)}if(a.length>0)s+=` style="${a.join("; ")}"`}for(let[a,c]of Object.entries(e)){if(!a.startsWith("on")||a==="observedAttributes")continue;let l=a.slice(2).toLowerCase();if(Y(c)){let p=Le(c.$ref);s+=` @${l}=\${(e) => { state.$map = { item, index }; on.${p}(e); }}`}else if(xe(c)){let p=ne(c.body,{eventParam:"e",statePrefix:"state"});s+=` @${l}=\${(e) => { state.$map = { item, index }; ${p} }}`}else if(G(c)){let p=Je(c.body);s+=` @${l}=\${(e) => { ${p} }}`}else if(C(c)&&"$expression"in c){let p=q(c.$expression,{eventParam:"e",statePrefix:"state"});s+=` @${l}=\${(e) => { state.$map = { item, index }; ${p}; }}`}}if(e.contentEditable)s+=` contenteditable="${e.contentEditable}"`;let o=n.includes("-")?De:"",i="";if(e.textContent!==void 0){let a=String(e.textContent);if(N(a))i=`${Je(a)}${o}`;else if(Y(e.textContent))i=`\${state.${Le(e.textContent.$ref)}}${o}`;else i=j(a)}else if(e.innerHTML)i=Je(String(e.innerHTML));else if(V(e.children))i=`
128
- ${Yr(e.children)}${o}
129
- `;else if(Array.isArray(e.children)){let a=e.children.map((c)=>{let l=$n(c,r);return V(c)||J(c)&&N(c)?`${l}${o}`:l});i=r?a.join(""):`
171
+ \``),c.push(`:render="${g}"`),a=!0;let x=` ${c.join(" ")}`;return`<${i}${l} data-bind${x}></${i}>`}else if(Array.isArray(d.children))p=d.children.map((g)=>qa(g,o,n,r,s)).join(mn(o.preformatted));if(new Set(["input","br","hr","img","meta","link"]).has(i))return`<${i}${l}${u}${f}>`;return`<${i}${l}${u}${f}>${p}</${i}>`}function fo(e,t=!1){if(!e)return"";if(Ie(e.tagName))throw Error(`A tag chosen at creation is not supported inside a dynamic page's repeater yet (candidates: ${vt(e.tagName).join(", ")}). Move the item into a component, or give it a literal tagName.`);let n=e.tagName??"div",r=t||it.has(n),s="";if(e.id)s+=` id="${e.id}"`;if(e.className)s+=` class="${mt(e.className)}"`;if(A(e.$props))for(let[a,l]of Object.entries(e.$props))if(me(l))s+=` .${a}="\${${Ru(l.$ref)}}"`;else if(L(l))s+=` .${a}="${mt(l)}"`;else s+=` .${a}="\${${JSON.stringify(l)}}"`;if(A(e.attributes))for(let[a,l]of Object.entries(e.attributes)){if(L(l)){s+=` ${a}="${mt(l)}"`;continue}if(pe(l)){let u=xt(a,l);if(u!==null)s+=u===""?` ${a}`:` ${a}="${_(u)}"`;continue}s+=` ${a}="${_(String(l))}"`}if(A(e.style)){let a=[];for(let[l,u]of Object.entries(e.style)){if(l.startsWith(":")||l.startsWith(".")||l.startsWith("&")||l.startsWith("[")||l.startsWith("@"))continue;if(Ka(u))continue;let f=de(l);if(L(String(u)))a.push(`${f}: ${mt(String(u))}`);else a.push(`${f}: ${u}`)}if(a.length>0)s+=` style="${a.join("; ")}"`}for(let[a,l]of Object.entries(e)){if(!a.startsWith("on")||a==="observedAttributes")continue;let u=a.slice(2).toLowerCase();if(me(l)){let f=nn(l.$ref);s+=` @${u}=\${(e) => { state.$map = { item, index }; on.${f}(e); }}`}else if(nt(l)){let f=Ne(l.body,{eventParam:"e",statePrefix:"state"});s+=` @${u}=\${(e) => { state.$map = { item, index }; ${f} }}`}else if($e(l)){let f=mt(l.body);s+=` @${u}=\${(e) => { ${f} }}`}else if(A(l)&&"$expression"in l){let f=le(l.$expression,{eventParam:"e",statePrefix:"state"});s+=` @${u}=\${(e) => { state.$map = { item, index }; ${f}; }}`}}if(e.contentEditable)s+=` contenteditable="${e.contentEditable}"`;let o=n.includes("-")?Mt:"",i="";if(e.textContent!==void 0){let a=String(e.textContent);if(L(a))i=`${mt(a)}${o}`;else if(me(e.textContent))i=`\${state.${nn(e.textContent.$ref)}}${o}`;else i=_(a)}else if(e.innerHTML)i=mt(String(e.innerHTML));else if(ne(e.children))i=`
172
+ ${za(e.children)}${o}
173
+ `;else if(Array.isArray(e.children)){let a=e.children.map((l)=>{let u=lo(l,r);return ne(l)||b(l)&&L(l)?`${u}${o}`:u});i=r?a.join(""):`
130
174
  ${a.join(`
131
175
  `)}
132
- `}if(new Set(["input","br","hr","img","meta","link"]).has(n))return`<${n}${s}>`;return`<${n}${s}>${i}</${n}>`}function $n(e,t=!1){if(J(e))return N(e)?Je(e):j(e);if(ee(e)||K(e))return j(String(e));if(V(e))return Yr(e);return Jn(e,t)}function Yr(e){let{items:t}=e,n=Y(t)?Sn(t.$ref):JSON.stringify(t??[]),r=Jn(e.map);return`\${(${n} ?? []).map((item, index) => html\`${r}\`)}`}function Je(e){return e.replaceAll("$map.","")}function vo(e,t,n,r,s,o,i,u,a,c){let l=[],{needsLit:p}=u,g=t.length>0;l.push("// Generated by @jxsuite/compiler — do not edit manually");let d=["reactive","effect"];if(g)d.push("computed");if(l.push(`import { ${d.join(", ")} } from '@vue/reactivity';`),p)l.push("import { html, render } from 'lit-html';");for(let[x,f]of i){let m=c?c(x):x;l.push(`import { ${[...f].join(", ")} } from '${m}';`)}if(l.push("",St()),o.length>0)l.push("",bt());l.push("","const state = reactive({");for(let[x,f]of e)l.push(` ${fe(x)}: ${JSON.stringify(f)},`);if(l.push("});",""),s.length>0){for(let x of s)l.push(x);l.push("")}if(t.length>0){for(let[x,f]of t)l.push(`${R("state",B(x))} = computed(${f});`);l.push("")}if(o.length>0){for(let x of o)l.push(x);l.push("")}if(n.length>0){l.push("const bind = {");for(let[x,f]of n)l.push(` ${fe(x)}: ${f},`);l.push("};")}else l.push("const bind = {};");if(l.push(""),r.length>0){l.push("const on = {");for(let[x,f]of r){let m=f.args??["state"],y=m.map((w)=>w==="state"?"state":"e").join(", ");l.push(` ${fe(x)}: (e) => { const fn = (${m.join(", ")}) => { ${f.body} }; fn(${y}); },`)}l.push("};")}else l.push("const on = {};");if(l.push("","function hydrate(root) {"," root.querySelectorAll('[data-bind]').forEach(el => {"," [...el.attributes].forEach(a => {"," if (a.name.startsWith(':')) {"," const parts = a.name.slice(1).split('.');"," const key = a.value;"),p)l.push(" if (parts[0] === 'render') {"," effect(() => { render(bind[key](), el); });"," } else if (parts[0] === 'style' && parts.length > 1) {");else l.push(" if (parts[0] === 'style' && parts.length > 1) {");return l.push(" effect(() => { el.style[parts[1]] = bind[key](); });"," } else if (parts[0] === 'attr' && parts.length > 1) {"," effect(() => {",` const _t = ${_e}(parts[1], bind[key]());`," if (_t === null) { el.removeAttribute(parts[1]); }"," else { el.setAttribute(parts[1], _t); }"," });"," } else {"," const prop = parts[0].replace(/-([a-z])/g, (_, c) => c.toUpperCase());"," effect(() => { el[prop] = bind[key](); });"," }"," } else if (a.name.startsWith('@')) {"," el.addEventListener(a.name.slice(1), on[a.value]);"," }"," });"," });","}","","hydrate(document);",""),l.join(`
133
- `)}function Oo(e,t,n,r){return[`// ${e}: ${t} (key: "${n}")`,"try {",` const _s = ${t}.getItem(${JSON.stringify(n)});`,` state.${e} = _s !== null ? JSON.parse(_s) : ${JSON.stringify(r)};`,`} catch { state.${e} = ${JSON.stringify(r)}; }`,"effect(() => {",` const v = state.${e};`," try {",` if (v === null) ${t}.removeItem(${JSON.stringify(n)});`,` else ${t}.setItem(${JSON.stringify(n)}, JSON.stringify(v));`," } catch {}","});"].join(`
134
- `)}function Ao(e,t,n){return[`// ${e}: Cookie (name: "${t}")`,"{",` const _m = document.cookie.match(new RegExp("(?:^|; )${t}=([^;]*)"));`,` try { state.${e} = _m ? JSON.parse(decodeURIComponent(_m[1])) : ${JSON.stringify(n)}; }`,` catch { state.${e} = _m ? _m[1] : ${JSON.stringify(n)}; }`,"}"].join(`
135
- `)}function Gr(e){return e===null||C(e)}function jo(e){if(e.startsWith("$map/")){let[t,...n]=pe(e.slice(5));return R(t??"",n.map((r)=>B(r)).join("/"))}if(e.startsWith("#/state/"))return R("state",e.slice(8));return R("state",e)}function Sn(e){return _n("state",e.startsWith("#/state/")?e.slice(8):e)}function Le(e){return Dn(e.startsWith("#/state/")?e.slice(8):e)}function yn(e,t,n){if(e.has(t))return;e.set(t,`() => ${R("state",n.startsWith("#/state/")?n.slice(8):n)}`)}var En=I(()=>{ze();Ie();H();je()});function Ro(e,t){if(t.routing==="prefix-except-default"&&e===t.defaultLocale)return"/";return`/${e.toLowerCase()}/`}function Xr(e){if(e===null||e.locales.length<2)return"";let t=JSON.stringify(e.locales),n=JSON.stringify(e.defaultLocale),r=JSON.stringify(Object.fromEntries(e.locales.map((s)=>[s,Ro(s,e)])));return`
176
+ `}if(new Set(["input","br","hr","img","meta","link"]).has(n))return`<${n}${s}>`;return`<${n}${s}>${i}</${n}>`}function lo(e,t=!1){if(b(e))return L(e)?mt(e):_(e);if(se(e)||pe(e))return _(String(e));if(ne(e))return za(e);return fo(e,t)}function za(e){let{items:t}=e,n=me(t)?co(t.$ref):JSON.stringify(t??[]),r=fo(e.map);return`\${(${n} ?? []).map((item, index) => html\`${r}\`)}`}function mt(e){return e.replaceAll("$map.","")}function vu(e,t,n,r,s,o,i,c,a,l){let u=[],{needsLit:f}=c,p=t.length>0;u.push("// Generated by @jxsuite/compiler — do not edit manually");let d=["reactive","effect"];if(p)d.push("computed");if(u.push(`import { ${d.join(", ")} } from '@vue/reactivity';`),f)u.push("import { html, render } from 'lit-html';");for(let[h,g]of i){let m=l?l(h):h;u.push(`import { ${[...g].join(", ")} } from '${m}';`)}if(u.push("",Qn()),o.length>0)u.push("",er());u.push("","const state = reactive({");for(let[h,g]of e)u.push(` ${ze(h)}: ${JSON.stringify(g)},`);if(u.push("});",""),s.length>0){for(let h of s)u.push(h);u.push("")}if(t.length>0){for(let[h,g]of t)u.push(`${P("state",re(h))} = computed(${g});`);u.push("")}if(o.length>0){for(let h of o)u.push(h);u.push("")}if(n.length>0){u.push("const bind = {");for(let[h,g]of n)u.push(` ${ze(h)}: ${g},`);u.push("};")}else u.push("const bind = {};");if(u.push(""),r.length>0){u.push("const on = {");for(let[h,g]of r){let m=g.args??["state"],x=m.map((E)=>E==="state"?"state":"e").join(", ");u.push(` ${ze(h)}: (e) => { const fn = (${m.join(", ")}) => { ${g.body} }; fn(${x}); },`)}u.push("};")}else u.push("const on = {};");if(u.push("","function hydrate(root) {"," root.querySelectorAll('[data-bind]').forEach(el => {"," [...el.attributes].forEach(a => {"," if (a.name.startsWith(':')) {"," const parts = a.name.slice(1).split('.');"," const key = a.value;"),f)u.push(" if (parts[0] === 'render') {"," effect(() => { render(bind[key](), el); });"," } else if (parts[0] === 'style' && parts.length > 1) {");else u.push(" if (parts[0] === 'style' && parts.length > 1) {");return u.push(" effect(() => { el.style[parts[1]] = bind[key](); });"," } else if (parts[0] === 'attr' && parts.length > 1) {"," effect(() => {",` const _t = ${Dt}(parts[1], bind[key]());`," if (_t === null) { el.removeAttribute(parts[1]); }"," else { el.setAttribute(parts[1], _t); }"," });"," } else {"," const prop = parts[0].replace(/-([a-z])/g, (_, c) => c.toUpperCase());"," effect(() => { el[prop] = bind[key](); });"," }"," } else if (a.name.startsWith('@')) {"," el.addEventListener(a.name.slice(1), on[a.value]);"," }"," });"," });","}","","hydrate(document);",""),u.join(`
177
+ `)}function Tu(e,t,n,r){return[`// ${e}: ${t} (key: "${n}")`,"try {",` const _s = ${t}.getItem(${JSON.stringify(n)});`,` state.${e} = _s !== null ? JSON.parse(_s) : ${JSON.stringify(r)};`,`} catch { state.${e} = ${JSON.stringify(r)}; }`,"effect(() => {",` const v = state.${e};`," try {",` if (v === null) ${t}.removeItem(${JSON.stringify(n)});`,` else ${t}.setItem(${JSON.stringify(n)}, JSON.stringify(v));`," } catch {}","});"].join(`
178
+ `)}function ju(e,t,n){return[`// ${e}: Cookie (name: "${t}")`,"{",` const _m = document.cookie.match(new RegExp("(?:^|; )${t}=([^;]*)"));`,` try { state.${e} = _m ? JSON.parse(decodeURIComponent(_m[1])) : ${JSON.stringify(n)}; }`,` catch { state.${e} = _m ? _m[1] : ${JSON.stringify(n)}; }`,"}"].join(`
179
+ `)}function Ka(e){return e===null||A(e)}function Ru(e){if(e.startsWith("$map/")){let[t,...n]=qe(e.slice(5));return P(t??"",n.map((r)=>re(r)).join("/"))}if(e.startsWith("#/state/"))return P("state",e.slice(8));return P("state",e)}function co(e){return No("state",e.startsWith("#/state/")?e.slice(8):e)}function nn(e){return Ao(e.startsWith("#/state/")?e.slice(8):e)}function ao(e,t,n){if(e.has(t))return;e.set(t,`() => ${P("state",n.startsWith("#/state/")?n.slice(8):n)}`)}var po=v(()=>{fn();Ft();K();jt()});function _u(e,t){if(t.routing==="prefix-except-default"&&e===t.defaultLocale)return"/";return`/${e.toLowerCase()}/`}function Ga(e){if(e===null||e.locales.length<2)return"";let t=JSON.stringify(e.locales),n=JSON.stringify(e.defaultLocale),r=JSON.stringify(Object.fromEntries(e.locales.map((s)=>[s,_u(s,e)])));return`
136
180
  // ─── Locale negotiation (RFC 4647 Lookup over Accept-Language) ───────────────
137
181
  const JX_LOCALES = ${t}
138
182
  const JX_DEFAULT_LOCALE = ${n}
@@ -201,24 +245,24 @@ app.use('/', async (c, next) => {
201
245
  res.headers.set('Content-Language', locale)
202
246
  c.res = res
203
247
  })
204
- `}function No(e,t="/_jx/server"){return Yn(e,t)}function Po(e,t={}){let{adapter:n=null,mounts:r=[],connectors:s=[],i18n:o=null,base:i=""}=t,u=No(i,t.baseUrl);if(e.length===0&&r.length===0&&!n)return null;let a=e.map(({exportName:d,src:x})=>`import { ${d} } from '${x}'`).join(`
205
- `),c=To(r,s),l=e.map(({exportName:d})=>ko(d,u)).join(`
206
- `),p=n==="cloudflare-workers"||n==="cloudflare-pages"?`
248
+ `}function ku(e,t="/_jx/server"){return Lo(e,t)}function Pu(e,t={}){let{adapter:n=null,mounts:r=[],connectors:s=[],i18n:o=null,base:i=""}=t,c=ku(i,t.baseUrl);if(e.length===0&&r.length===0&&!n)return null;let a=e.map(({exportName:d,src:h})=>`import { ${d} } from '${h}'`).join(`
249
+ `),l=Iu(r,s),u=e.map(({exportName:d})=>Du(d,c)).join(`
250
+ `),f=n==="cloudflare-workers"||n==="cloudflare-pages"?`
207
251
  app.all('*', (c) => c.env.ASSETS.fetch(c.req.raw))
208
252
  `:`
209
- `,g=Xr(o);return`// Generated by @jxsuite/compiler — do not edit manually
253
+ `,p=Ga(o);return`// Generated by @jxsuite/compiler — do not edit manually
210
254
  import { Hono } from 'hono'
211
- ${a}${c.imports}
255
+ ${a}${l.imports}
212
256
 
213
257
  const app = new Hono()
214
- ${g}${c.routes}${l}
215
- ${p}
258
+ ${p}${l.routes}${u}
259
+ ${f}
216
260
  export default app
217
- `}function To(e,t){if(e.length===0)return{imports:"",routes:""};let n=e.toSorted((o,i)=>o.order-i.order),r=[];for(let o of n)r.push(`import { ${o.className} } from '${o.module}'`);for(let o of t)r.push(`import { ${o.className} } from '${o.module}'`);let s=["// Extension server mounts (specs/extensions.md §11): one shared ctx, mounted in order.","const jxCtx = {}",`const jxConnectors = { ${t.map((o)=>`${JSON.stringify(o.provider)}: ${o.className}`).join(", ")} }`];for(let[o,i]of n.entries()){let u=JSON.stringify(i.options);s.push(`const jxMount${o} = await ${i.className}.mount({ ...${u}, connectors: jxConnectors }, jxCtx)`,`app.all('${i.basePath}/*', (c) => jxMount${o}(c.req.raw, c.env))`,`app.all('${i.basePath}', (c) => jxMount${o}(c.req.raw, c.env))`)}return{imports:`
261
+ `}function Iu(e,t){if(e.length===0)return{imports:"",routes:""};let n=e.toSorted((o,i)=>o.order-i.order),r=[];for(let o of n)r.push(`import { ${o.className} } from '${o.module}'`);for(let o of t)r.push(`import { ${o.className} } from '${o.module}'`);let s=["// Extension server mounts (specs/extensions.md §11): one shared ctx, mounted in order.","const jxCtx = {}",`const jxConnectors = { ${t.map((o)=>`${JSON.stringify(o.provider)}: ${o.className}`).join(", ")} }`];for(let[o,i]of n.entries()){let c=JSON.stringify(i.options);s.push(`const jxMount${o} = await ${i.className}.mount({ ...${c}, connectors: jxConnectors }, jxCtx)`,`app.all('${i.basePath}/*', (c) => jxMount${o}(c.req.raw, c.env))`,`app.all('${i.basePath}', (c) => jxMount${o}(c.req.raw, c.env))`)}return{imports:`
218
262
  ${r.join(`
219
263
  `)}`,routes:`${s.join(`
220
264
  `)}
221
- `}}function ko(e,t){return`
265
+ `}}function Du(e,t){return`
222
266
  app.post('${t}/${e}', async (c) => {
223
267
  const args = await c.req.json().catch(() => ({}))
224
268
  try {
@@ -226,14 +270,14 @@ app.post('${t}/${e}', async (c) => {
226
270
  } catch (e) {
227
271
  return c.json({ ok: false, error: e?.message ?? 'Server error' }, 500)
228
272
  }
229
- })`}var Zr=I(()=>{Kt()});function es(e){let t=e.title;if(!t)throw Error("compileClassJson: missing title (class name)");let n=Do(e.extends),r=e.$defs,s=r?.fields??{},o=r?.constructor,i=_o(o)?o:void 0,u=r?.methods??{},a=["// Generated by @jxsuite/compiler from .class.json — do not edit manually"];if(e.$id)a.push(`// Source: ${e.$id}`);a.push("");let c=n!=="Object"?` extends ${n}`:"";a.push(`class ${t}${c} {`);for(let[l,p]of Object.entries(s)){if(p.scope!=="static")continue;let g=p.identifier??l,d=p.access==="private"?"#":"",x=p.initializer!==void 0?JSON.stringify(p.initializer):p.default!==void 0?JSON.stringify(p.default):"null";a.push(` static ${d}${g} = ${x};`)}for(let[l,p]of Object.entries(s)){if(p.scope==="static")continue;if(p.access!=="private")continue;let g=p.identifier??l;a.push(` #${g};`)}if(Object.keys(s).length>0)a.push("");if(a.push(" constructor(config = {}) {"),i?.superCall||n!=="Object"){let l=i?.superCall?.arguments?i.superCall.arguments.join(", "):"";a.push(` super(${l});`)}for(let[l,p]of Object.entries(s)){if(p.scope==="static")continue;let g=p.identifier??l,d=p.access==="private"?"#":"",x=p.initializer!==void 0?JSON.stringify(p.initializer):p.default!==void 0?JSON.stringify(p.default):"null";a.push(` this.${d}${g} = config.${g} !== undefined ? config.${g} : ${x};`)}if(i?.body){let l=Array.isArray(i.body)?i.body:[i.body];for(let p of l)a.push(` ${p}`)}a.push(" }");for(let[l,p]of Object.entries(u)){let g=p.identifier??l,d=p.scope==="static",f=p.access==="private"?"#":"",m=d?"static ":"",y=p.returnType?.$ref?.includes("Promise")||Io(p)?"async ":"",w=Qr(p.parameters??[]),O=Mo(p.body);if(a.push(""),p.role==="accessor"){if(p.getter)a.push(` ${m}get ${f}${g}() {`,` ${p.getter.body}`," }");if(p.setter){let v=Qr(p.setter.parameters??[]);a.push(` ${m}set ${f}${g}(${v}) {`,` ${p.setter.body}`," }")}}else{a.push(` ${m}${y}${f}${g}(${w}) {`);for(let v of O)a.push(` ${v}`);a.push(" }")}}return a.push("}","",`export { ${t} };`,`export default ${t};`,""),a.join(`
230
- `)}function _o(e){return typeof e==="object"}function Do(e){if(!e)return"Object";if(J(e))return e;if(e.$ref){let t=e.$ref.match(/([A-Za-z0-9_]+)\.class\.json/);return t?t[1]:"Object"}return"Object"}function Qr(e){return e.map((t)=>{if(t.$ref)return t.$ref.split("/").pop();let n=t.identifier??t.name;return J(n)?n:"arg"}).join(", ")}function Mo(e){if(!e)return[""];return Array.isArray(e)?e:[e]}function Io(e){return(Array.isArray(e.body)?e.body.join(`
231
- `):e.body??"").includes("await ")}var ts=I(()=>{H()});import{readFileSync as Lo}from"node:fs";async function Fo(e,t={}){let{title:n="Jx App",reactivitySrc:r=gt,litHtmlSrc:s=ht,projectStyle:o=null}=t,i;if(J(e)){let a=Lo(e,"utf8");if(e.endsWith(".json"))i=Et(a,e);else{let{extname:c}=await import("node:path"),l=c(e).toLowerCase(),p=t.formats?.byExtension(l,"parse");if(!p){await Promise.resolve().then(() => gn());throw Ot(e,l)}i=await p.parseDocument(a)}}else i=e;if(An(i)){await Promise.resolve().then(() => ts());let c=es(i),l=J(e)?e.replace(/\.class\.json$/,".js"):`${i.title}.js`;return{files:[{content:c,path:l}],html:""}}if(!xt(i))return Ur(i,{litHtmlSrc:s,projectStyle:o,reactivitySrc:r,...ns(t),title:n});if(i.tagName&&i.tagName.includes("-")){let{tagName:a}=i,c=Jt(a),p={content:Qe(i,c,[],t.rewriteSrc,null,t.serverBaseUrl),path:`${a}.js`,tagName:a},g=Me(i,i.$media??{},o),d=`<!DOCTYPE html>
273
+ })`}var Ya=v(()=>{ns()});function Za(e){let t=e.title;if(!t)throw Error("compileClassJson: missing title (class name)");let n=Lu(e.extends),r=e.$defs,s=r?.fields??{},o=r?.constructor,i=Mu(o)?o:void 0,c=r?.methods??{},a=["// Generated by @jxsuite/compiler from .class.json — do not edit manually"];if(e.$id)a.push(`// Source: ${e.$id}`);a.push("");let l=n!=="Object"?` extends ${n}`:"";a.push(`class ${t}${l} {`);for(let[u,f]of Object.entries(s)){if(f.scope!=="static")continue;let p=f.identifier??u,d=f.access==="private"?"#":"",h=f.initializer!==void 0?JSON.stringify(f.initializer):f.default!==void 0?JSON.stringify(f.default):"null";a.push(` static ${d}${p} = ${h};`)}for(let[u,f]of Object.entries(s)){if(f.scope==="static")continue;if(f.access!=="private")continue;let p=f.identifier??u;a.push(` #${p};`)}if(Object.keys(s).length>0)a.push("");if(a.push(" constructor(config = {}) {"),i?.superCall||n!=="Object"){let u=i?.superCall?.arguments?i.superCall.arguments.join(", "):"";a.push(` super(${u});`)}for(let[u,f]of Object.entries(s)){if(f.scope==="static")continue;let p=f.identifier??u,d=f.access==="private"?"#":"",h=f.initializer!==void 0?JSON.stringify(f.initializer):f.default!==void 0?JSON.stringify(f.default):"null";a.push(` this.${d}${p} = config.${p} !== undefined ? config.${p} : ${h};`)}if(i?.body){let u=Array.isArray(i.body)?i.body:[i.body];for(let f of u)a.push(` ${f}`)}a.push(" }");for(let[u,f]of Object.entries(c)){let p=f.identifier??u,d=f.scope==="static",g=f.access==="private"?"#":"",m=d?"static ":"",x=f.returnType?.$ref?.includes("Promise")||Wu(f)?"async ":"",E=Xa(f.parameters??[]),O=Fu(f.body);if(a.push(""),f.role==="accessor"){if(f.getter)a.push(` ${m}get ${g}${p}() {`,` ${f.getter.body}`," }");if(f.setter){let J=Xa(f.setter.parameters??[]);a.push(` ${m}set ${g}${p}(${J}) {`,` ${f.setter.body}`," }")}}else{a.push(` ${m}${x}${g}${p}(${E}) {`);for(let J of O)a.push(` ${J}`);a.push(" }")}}return a.push("}","",`export { ${t} };`,`export default ${t};`,""),a.join(`
274
+ `)}function Mu(e){return typeof e==="object"}function Lu(e){if(!e)return"Object";if(b(e))return e;if(e.$ref){let t=e.$ref.match(/([A-Za-z0-9_]+)\.class\.json/);return t?t[1]:"Object"}return"Object"}function Xa(e){return e.map((t)=>{if(t.$ref)return t.$ref.split("/").pop();let n=t.identifier??t.name;return b(n)?n:"arg"}).join(", ")}function Fu(e){if(!e)return[""];return Array.isArray(e)?e:[e]}function Wu(e){return(Array.isArray(e.body)?e.body.join(`
275
+ `):e.body??"").includes("await ")}var Qa=v(()=>{K()});import{readFileSync as Vu}from"node:fs";async function Hu(e,t={}){let{title:n="Jx App",reactivitySrc:r=Kn,litHtmlSrc:s=Gn,projectStyle:o=null}=t,i;if(b(e)){let a=Vu(e,"utf8");if(On(e))i=Cn(a,e);else{let{extname:l}=await import("node:path"),u=l(e).toLowerCase(),f=t.formats?.byExtension(u,"parse");if(!f){await Promise.resolve().then(() => so());throw Ir(e,u)}i=await f.parseDocument(a)}}else i=e;if(yo(i)){await Promise.resolve().then(() => Qa());let l=Za(i),u=b(e)?e.replace(/\.class\.json$/,".js"):`${i.title}.js`;return{files:[{content:l,path:u}],html:""}}if(!Yn(i))return Ha(i,{litHtmlSrc:s,projectStyle:o,reactivitySrc:r,...el(t),title:n});if(i.tagName&&i.tagName.includes("-")){let{tagName:a}=i,l=tr(a),f={content:Rn(i,l,[],t.rewriteSrc,null,t.serverBaseUrl),path:`${a}.js`,tagName:a},p=Lt(i,i.$media??{},o),d=`<!DOCTYPE html>
232
276
  <html lang="en">
233
277
  <head>
234
278
  <meta charset="utf-8">
235
279
  <meta name="viewport" content="width=device-width, initial-scale=1">
236
- <title>${j(n)}</title>
280
+ <title>${_(n)}</title>
237
281
  <script type="importmap">
238
282
  {
239
283
  "imports": {
@@ -242,10 +286,10 @@ app.post('${t}/${e}', async (c) => {
242
286
  }
243
287
  }
244
288
  </script>
245
- ${g}
289
+ ${p}
246
290
  </head>
247
291
  <body>
248
292
  <${a}></${a}>
249
293
  <script type="module" src="./${a}.js"></script>
250
294
  </body>
251
- </html>`;return{files:[p],html:d}}let u={litHtmlSrc:s,projectStyle:o,reactivitySrc:r,...ns(t),title:n};if(t.serverBaseUrl!==void 0)u.serverBaseUrl=t.serverBaseUrl;return bn(i,u)}function ns(e){let t={};if(e.prePaintScheme===!1)t.prePaintScheme=!1;if(e.rewriteSrc)t.rewriteSrc=e.rewriteSrc;return t}async function Ya(e,t){let n=await Fo(e),{writeFileSync:r,mkdirSync:s}=await import("node:fs"),{dirname:o,join:i}=await import("node:path");if(t){r(t,n.html,"utf8"),console.error(`Written to ${t}`);let u=o(t);for(let a of n.files){let c=i(u,a.path);s(o(c),{recursive:!0}),r(c,a.content,"utf8"),console.error(`Written to ${c}`)}}else process.stdout.write(n.html)}var Wo=I(()=>{Ie();Nt();Kr();En();H();pn();Ie();Zr();Nt();En()});Wo();export{Fo as compile,bn as compileClient,Fr as compileElement,So as compileElementPage,Po as compileSiteServer,xt as isDynamic,Ya as runCli};
295
+ </html>`;return{files:[f],html:d}}let c={litHtmlSrc:s,projectStyle:o,reactivitySrc:r,...el(t),title:n};if(t.serverBaseUrl!==void 0)c.serverBaseUrl=t.serverBaseUrl;return uo(i,c)}function el(e){let t={};if(e.prePaintScheme===!1)t.prePaintScheme=!1;if(e.rewriteSrc)t.rewriteSrc=e.rewriteSrc;return t}async function ug(e,t){let n=await Hu(e),{writeFileSync:r,mkdirSync:s}=await import("node:fs"),{dirname:o,join:i}=await import("node:path");if(t){r(t,n.html,"utf8"),console.error(`Written to ${t}`);let c=o(t);for(let a of n.files){let l=i(c,a.path);s(o(l),{recursive:!0}),r(l,a.content,"utf8"),console.error(`Written to ${l}`)}}else process.stdout.write(n.html)}var Bu=v(()=>{Ft();Fr();Ua();po();K();_r();Ft();Ya();Fr();po()});Bu();export{Hu as compile,uo as compileClient,Ma as compileElement,Eu as compileElementPage,Pu as compileSiteServer,Yn as isDynamic,ug as runCli};