@hyperfixi/engine 4.1.0 → 4.2.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/CHANGELOG.md +184 -1
- package/dist/ast.d.ts +2 -0
- package/dist/commands/platform.d.ts +2 -0
- package/dist/common.js +2 -1
- package/dist/common.min.js +2 -2
- package/dist/core.js +2 -1
- package/dist/core.min.js +2 -2
- package/dist/full.js +3 -2
- package/dist/full.min.js +3 -3
- package/dist/hyperfixi-hs.dev.js +3 -2
- package/dist/hyperfixi-hs.js +3 -3
- package/dist/index.js +3 -2
- package/dist/minimal.js +2 -1
- package/dist/minimal.min.js +2 -2
- package/package.json +1 -1
package/dist/minimal.min.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
`,r:"\r",t:" ",v:"\v"},$=e=>e>="a"&&e<="z"||e>="A"&&e<="Z",U=e=>e>="0"&&e<="9",Le=e=>e===" "||e===" "||e==="\r"||e===`
|
|
3
3
|
`,qe=e=>$(e)||U(e)||e==="-"||e==="_"||e===":",_e=e=>$(e)||U(e)||e==="_"||e==="$";function fe(e,t=!1){let n=[],r=0,o=0,i=1,s="<START>",u=0,a=()=>e.charAt(r),l=h=>e.charAt(r+h),c=()=>(s=e.charAt(r++),s===`
|
|
4
4
|
`?(i++,o=0):o++,s),d=h=>({type:h,value:"",start:r,end:r+1,line:i,column:o}),m=(h,y)=>(h.value=y,h.end=r,h),f=h=>{let y="";for(;a()&&h(a());)y+=c();return y},p=()=>t&&u===0,g=()=>$(s)||U(s)||")\"'`}]".includes(s),w=(h,y)=>{let P=d(h),F=c();if(a()==="{"){if(P.template=!0,F+=c(),F+=f(Kt=>Kt!=="}"),a()!=="}")throw new Error("Unterminated "+(y?"class":"id")+" reference");let ye=c();y&&(F+=ye)}else if(y)for(;qe(a())||a()==="\\";)a()==="\\"&&c(),F+=c();else F+=f(qe);return m(P,F)},k=()=>{let h=d("STRING"),y=c();h.template=y==="`";let P="";for(;a()&&a()!==y;)if(a()==="\\"){c();let F=c();if(F in ut)P+=ut[F];else if(h.template&&F==="$")P+="\\$";else if(F==="x"){let ye=a()&&l(1)?parseInt(c()+c(),16):NaN;if(Number.isNaN(ye))throw new Error(`Invalid hexadecimal escape at [Line: ${h.line}, Column: ${h.column}]`);P+=String.fromCharCode(ye)}else P+=F}else P+=c();if(a()!==y)throw new Error(`Unterminated string at [Line: ${h.line}, Column: ${h.column}]`);return c(),m(h,P)},q=()=>{let h=d("IDENTIFIER"),y=c()+f(_e);return a()==="!"&&y==="beep"&&(y+=c()),m(h,y)},N=()=>{let h=d("IDENTIFIER"),y=c(),P=y==="\\";for(P&&(y="");(_e(a())||"\\{}".includes(a()||" "))&&!(a()==="$"&&!P);)a()==="\\"?(P=!0,c()):(P=!1,y+=c());return m(h,y)},C=()=>{let h=d("NUMBER"),y=c()+f(U);return a()==="."&&U(l(1))&&(y+=c()),y+=f(U),(a()==="e"||a()==="E")&&(U(l(1))?y+=c():l(1)==="-"&&(y+=c()+c())),m(h,y+f(U))},O=()=>{let h=d("OP");h.op=!0;let y=c();for(;a()&&at.has(y+a());)y+=c();return m(h,y)},_=()=>{let h=d("ATTRIBUTE_REF"),y=c();return y==="["?(y+=f(P=>P!=="]"),a()==="]"&&(y+=c())):(y+=f(qe),a()==="="&&(y+=c(),a()==='"'||a()==="'"?y+=k().value:_e(a())&&(y+=q().value))),m(h,y)},Z=()=>{let h=n.at(-1);return h?h.type==="IDENTIFIER"||h.type==="CLASS_REF"||h.type==="ID_REF"?!1:!(h.op&&(h.value===">"||h.value===")")):!0},J=()=>{let h=a(),y=l(2);return(h==="-"||h==="/")&&l(1)===h&&(Le(y)||y===""||y===h)};for(;r<e.length;){let h=a(),y=l(1);if(J())f(P=>P!=="\r"&&P!==`
|
|
5
|
-
`),c();else if(Le(h))n.push(m(d("WHITESPACE"),f(Le)));else if(!g()&&h==="."&&($(y)||y==="{"||y==="-"))n.push(w("CLASS_REF",!0));else if(!g()&&h==="#"&&($(y)||y==="{"))n.push(w("ID_REF",!1));else if(h==="@"||h==="["&&y==="@")n.push(_());else if(h==="*"&&$(y)){let P=d("STYLE_REF");n.push(m(P,c()+f(F=>$(F)||F==="-")))}else if(p()&&($(h)||h==="\\"))n.push(N());else if(!p()&&($(h)||h==="_"||h==="$"))n.push(q());else if(U(h))n.push(C());else if(!p()&&(h==='"'||h==="`"))n.push(k());else if(!p()&&h==="'")n.push(Z()?k():O());else if(at.has(h))s==="$"&&h==="{"&&u++,h==="}"&&u--,n.push(O());else if(p()||h==="`"){let P=d("RESERVED");n.push(m(P,c()))}else throw new Error("Unknown token: "+h+" ")}return n}function E(e){return e.match("the"),nn(e)}function nn(e){let t=lt(e),n,r=()=>e.match("and")??e.match("or");for(let o=r();o;o=r())n??=o.value,n!==o.value&&e.err("You must parenthesize logical operations with different operators"),t=rn(o.value,t,lt(e));return t}function rn(e,t,n){let r=e==="or";return{type:"logicalOperator",operator:e,left:t,right:n,start:t.start,end:n.end,ev:o=>T(t.ev(o),i=>!!i===r?i:n.ev(o))}}var on={"+":(e,t)=>Array.isArray(e)?e.concat(t):b(e)+b(t),"-":(e,t)=>b(e)-b(t),"*":(e,t)=>b(e)*b(t),"/":(e,t)=>b(e)/b(t),mod:(e,t)=>b(e)%b(t)};function De(e){let t=je(e),n,r=()=>e.matchAnyOp("+","-","*","/")??e.match("mod");for(let o=r();o;o=r()){n??=o.value,n!==o.value&&e.err("You must parenthesize math operations with different operators");let i=t,s=je(e),u=on[o.value];t={type:"mathOperator",operator:o.value,left:i,right:s,start:i.start,end:s.end,ev:l=>I([i.ev(l),s.ev(l)],([c,d])=>u(c,d))}}return t}function je(e){let t=G(e);for(let n=!0;n;){n=!1;for(let r of e.g.collections){let o=r(e,t);if(o){t=o,n=!0;break}}}return t}function G(e){e.match("the");let t=e.pos();if(e.match("not"))return He(e,"logicalNot",t,G(e),n=>!n);if(e.match("no"))return He(e,"noExpression",t,je(e),Fe);for(let n of e.g.unaries){let r=n(e);if(r)return D(e,r)}return an(e)}function He(e,t,n,r,o,i=t!=="negativeNumber"){let s={type:t,root:r,start:n,end:e.endPos(),ev:u=>T(r.ev(u),a=>o(a,u))};return i?D(e,s):s}var sn="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function an(e){let t=ht(e),n=e.matchAny(...sn)??e.matchOp("%");if(n)return ct(e,"stringPostfixExpression",t,n.value);let r=e.matchAny("s","seconds")?1e3:e.matchAny("ms","milliseconds")?1:0;if(r)return ct(e,"timeExpression",t,r);for(let o of e.g.postfixes){let i=o(e,t);if(i)return i}return t}function ct(e,t,n,r){let o=s=>typeof r=="number"?b(s)*r:`${s}${r}`,i={type:t,root:n,suffix:r,start:n.start,end:e.endPos(),ev:s=>T(n.ev(s),o)};return n.stat&&(i.stat=()=>o(de(n))),i}function ht(e){let t=e.pos();return e.matchOp("-")?He(e,"negativeNumber",t,ht(e),n=>-b(n)):pt(e)}function pt(e){let t=dn(e);return t?D(e,t):e.err("Unexpected value: "+e.cur().value)}function yt(e){return e.match("the"),Ue(e,pt(e))}function Ue(e,t){let n=un(t);return n.put||e.err(`A target expression must be writable. The expression type '${n.type}' is not.`),n}function un(e){let t=e;for(;t.type==="parenthesized"&&"expr"in t&&cn(t.expr);)t=t.expr;return t}var cn=e=>H(v(e,"ev"));function de(e){if(e.stat)return e.stat();throw new Error("This expression cannot be evaluated statically: "+e.type)}function ln(e){let t=e.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(t)return{operator:t.value,right:!0,isType:!1};let n=(a,l=!0,c=!1)=>({operator:a,right:l,isType:c}),r=()=>e.match("equal")&&e.match("to"),o=(a,l)=>(e.req("than"),e.match("or")?(e.req("equal"),e.req("to"),n(l)):n(a));if(e.match("is")||e.match("am")){let a=!!e.match("not"),l=a?"not ":"";return e.match("in")?n(l+"in"):e.match("a")||e.match("an")?n(l+"a",!1,!0):e.match("empty")?n(l+"empty",!1):e.match("between")?n(l+"between"):!a&&e.match("less")?o("<","<="):!a&&e.match("greater")?o(">",">="):e.match("really")?(r(),n(a?"!==":"===")):e.match("equal")?(e.match("to"),n(a?"!=":"==")):n(a?"is not":"is")}if(e.match("equals"))return n("==");if(e.match("really"))return e.req("equals"),n("===");if(e.matchAny("exist","exists"))return n("exist",!1);let i=!!e.matchAny("do","does");i&&e.req("not");let s=i?"not ":"",u=(a,l)=>e.match(a)??(i&&a!=="match"&&a!=="contain"?void 0:e.match(l));if(u("match","matches"))return n(s+"match");if(u("contain","contains"))return n(s+"contain");if(i&&e.match("exist"))return n("not exist",!1);if(u("include","includes"))return n(s+"include");if(e.match(i?"start":"starts"))return e.req("with"),n(s+"start with");if(e.match(i?"end":"ends"))return e.req("with"),n(s+"end with");if(u("precede","precedes"))return n(s+"precede");if(u("follow","follows"))return n(s+"follow");i&&e.expected("matches","contains","starts with","ends with","precede","follow")}function lt(e){let t=De(e),n=ln(e);if(!n)return t;let{operator:r}=n,o,i=!0,s,u;n.isType?(o=e.reqType("IDENTIFIER").value,i=!e.matchOp("!")):n.right&&(s=De(e),r.endsWith("match")&&(u=s.css));let a;r.endsWith("between")&&(e.req("and"),a=De(e));let l=!1;e.match("ignoring")&&(e.req("case"),l=!0);let c=f=>l&&typeof f=="string"?f.toLowerCase():f,d=s?.type==="symbol"&&"scope"in s&&s.scope==="local"&&s.name!=="undefined"&&s.name!=="null"?s.name:void 0;return{type:"comparisonOperator",operator:r,left:t,right:s,right2:a,typeName:o,ignoringCase:l,start:t.start,end:e.endPos(),ev:f=>I([t.ev(f),u??s?.ev(f),a?.ev(f)],([p,g,w])=>{if(o){let k=Ke(p,o,i);return r==="a"?k:!k}if(d&&g===void 0&&(r==="is"||r==="is not")){let k=!!ie(p,d);return r==="is"?k:!k}return gt(r,c(p),c(g),w)})}}function ft(e,t){let n=v(e,"contains")??v(e,"includes");if(!H(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,e,[t])}function fn(e,t){let n=v(e,"match")??v(e,"matches");if(!H(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,e,[t])}var dt=(e,t,n)=>e instanceof Node&&t instanceof Node&&(e.compareDocumentPosition(t)&n)!==0;function gt(e,t,n,r){if(e==="not between")return b(t)<b(n)||b(t)>b(r);if(e.startsWith("not "))return!gt(e.slice(4),t,n,r);switch(e){case"is":case"==":return t==n;case"is not":case"!=":return t!=n;case"===":return t===n;case"!==":return t!==n;case"<":return b(t)<b(n);case">":return b(t)>b(n);case"<=":return b(t)<=b(n);case">=":return b(t)>=b(n);case"match":return t!=null&&fn(t,n);case"in":return n!=null&&ft(n,t);case"contain":case"include":return t!=null&&ft(t,n);case"start with":return t!=null&&String(t).startsWith(String(n));case"end with":return t!=null&&String(t).endsWith(String(n));case"between":return b(t)>=b(n)&&b(t)<=b(r);case"precede":return dt(t,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return dt(t,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return Fe(t);case"exist":return Je(t)}throw new Error("Unknown comparison : "+e)}function dn(e){let t=e.cur();switch(t.type){case"NUMBER":return e.consume(),Me("number",parseFloat(t.value),t);case"STRING":return pn(e);case"ID_REF":return vn(e);case"CLASS_REF":return Q(e);case"ATTRIBUTE_REF":return V(e);case"STYLE_REF":return Et(e)}if(t.op){if(t.value==="(")return mn(e);if(t.value==="[")return yn(e);if(t.value==="{")return gn(e);if(t.value==="<")return bn(e)}let n=e.match("true")??e.match("false");if(n)return Me("boolean",n.value==="true",n);let r=e.match("null");if(r)return Me("null",null,r);for(let o of e.g.leaves){let i=o(e);if(i)return i}return wn(e)}function Me(e,t,n){return{type:e,value:t,start:n.start,end:n.end,ev:()=>t,stat:()=>t}}function mn(e){let t=e.pos();e.consume();let n=e.withoutFollows(()=>E(e));return e.reqOp(")"),{type:"parenthesized",expr:n,start:t,end:e.endPos(),ev:r=>n.ev(r)}}var hn=(e,t)=>I(e.map(n=>typeof n=="string"?n:n.ev(t)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function wt(e,t){let n=e.child(fe(t,!0),t),r=[],o="";do{o+=n.lastWs();let i=n.cur();if(i.value==="$"){n.consume();let s=n.matchOp("{");r.push(o,E(n)),o="",s&&n.reqOp("}")}else i.value==="\\"?(n.consume(),n.consume()):n.hasMore()&&(o+=n.consume().value)}while(n.hasMore());return r.push(o+n.lastWs()),r}function pn(e){let t=e.consume(),n=t.value,r={type:"string",value:n,start:t.start,end:t.end,ev:()=>n};if(t.template){let o=r.parts=wt(e,n);r.ev=i=>hn(o,i)}else r.stat=()=>n;return r}function yn(e){let t=e.pos();e.consume();let n=[];if(!e.matchOp("]")){do n.push(E(e));while(e.matchOp(","));e.reqOp("]")}return{type:"arrayLiteral",values:n,start:t,end:e.endPos(),ev:r=>I(n.map(o=>o.ev(r)),o=>o)}}function gn(e){let t=e.pos();e.consume();let n=[],r=[],o=()=>e.cur().op&&e.cur().value==="}";if(!e.matchOp("}")){do{let i=e.matchType("STRING");if(i)n.push(i.value);else if(e.matchOp("["))n.push(E(e)),e.reqOp("]");else{let s="";for(let u=e.matchType("IDENTIFIER")??e.matchOp("-");u;u=e.matchType("IDENTIFIER")??e.matchOp("-"))s+=u.value;n.push(s)}e.reqOp(":"),r.push(E(e))}while(e.matchOp(",")&&!o());e.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:t,end:e.endPos(),ev:i=>I([...n.map(s=>typeof s=="string"?s:s.ev(i)),...r.map(s=>s.ev(i))],s=>Object.fromEntries(n.map((u,a)=>[String(s[a]),s[n.length+a]])))}}function vt(e){return e.matchType("STRING")?.value??e.consumeUntil(void 0,"WHITESPACE").map(t=>t.value).join("")}function wn(e){let t=e.pos(),n;e.match("global")?n="global":e.match("element")?(n="element",e.matchOp("'")&&e.req("s")):e.match("dom")?n="inherited":e.match("local")&&(n="local");let r=e.matchOp(":"),o=!r&&e.matchOp("^"),i=e.matchType("IDENTIFIER");if(!i?.value)return;let s=(r?":":o?"^":"")+i.value,a=n??{$:"global",":":"element","^":"inherited"}[s[0]]??"local",l;return a==="inherited"&&e.match("on")&&(l=e.withFollow(["to","into","before","after","then"],()=>E(e))),{type:"symbol",name:s,scope:a,start:t,end:e.endPos(),ev:c=>rt(s,c,a,l?.ev(c)),lhs:()=>{},put:(c,d,m)=>ot(s,c,a,m,l?.ev(c))}}var bt=(e,t)=>{let n=t.value.substring(2);return E(e.child(fe(n),n))};function vn(e){let t=e.consume(),n=(o,i)=>Oe(o.me).getElementById(String(i)),r={type:"idRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(o,i,s)=>T(r.ev(o),u=>u&&ce(u,s))};if(t.template){let o=r.expr=bt(e,t);r.ev=i=>T(o.ev(i),s=>n(i,s))}else{let o=r.value=t.value.substring(1);r.css=t.value,r.ev=i=>n(i,o)}return r}function Q(e){let t=e.matchType("CLASS_REF");if(!t)return;let n={type:"classRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(r,o,i)=>T(n.ev(r),s=>ce(Array.from(s instanceof j?s:[]),i))};if(t.template){let r=n.expr=bt(e,t);n.ev=o=>T(r.ev(o),i=>new j("."+i,o.me,!0))}else{let r=n.css=t.value;n.className=r.slice(1),n.ev=o=>new j(r,o.me,!0)}return n}var $e=class extends j{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>R(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(R);n.forEach((o,i)=>o.setAttribute("data-hs-query-id",String(i)));let r=super.select();return n.forEach(o=>o.removeAttribute("data-hs-query-id")),r}};function bn(e){let t=e.pos();e.consume();let n=e.consumeUntil("/").map(o=>o.type==="STRING"?`"${o.value}"`:o.value).join("");e.reqOp("/"),e.reqOp(">");let r={type:"queryRef",css:n,start:t,end:e.endPos(),ev:o=>new j(n,o.me),lhs:()=>{},put:(o,i,s)=>T(r.ev(o),u=>ce(Array.from(u instanceof j?u:[]),s))};if(/\$[^=]/.test(n)){let o=r.parts=wt(e,n);r.ev=i=>I(o.map(s=>typeof s=="string"?s:s.ev(i)),s=>new $e(i.me,s))}return r}function V(e){let t=e.matchType("ATTRIBUTE_REF");if(!t)return;let n=t.value.startsWith("[")?t.value.slice(2,-1):t.value.slice(1),[r,o]=n.split("="),i=o&&/^["']/.test(o)?o.slice(1,-1):o;return{type:"attributeRef",name:r,value:i,css:`[${n}]`,start:t.start,end:t.end,ev:s=>ae(s.you||s.me,r),lhs:()=>{},put:(s,u,a)=>ue(s.you||s.me,r,a)}}function Et(e){let t=e.matchType("STYLE_REF");if(!t)return;let n=t.value.startsWith("*computed-"),r=t.value.slice(n?10:1);return{type:n?"computedStyleRef":"styleRef",name:r,start:t.start,end:t.end,ev:o=>(n?Ee:be)(o.you||o.me,r),lhs:()=>{},put:(o,i,s)=>xe(o.you||o.me,r,s)}}function xt(e){let t=e.pos();if(!e.matchOp("{"))return;let n=[""],r=[];for(;e.hasMore();){if(e.matchOp("\\"))e.consume();else{if(e.matchOp("}"))break;if(e.match("$")){let o=e.matchOp("{");r.push(E(e)),o&&e.reqOp("}"),n.push("")}else n[n.length-1]+=e.text(e.consume())}n[n.length-1]+=e.lastWs()}return{type:"styleLiteral",parts:n,exprs:r,start:t,end:e.endPos(),ev:o=>I(r.map(i=>i.ev(o)),i=>n.map((s,u)=>s+(u in i?`${i[u]}`:"")).join(""))}}function me(e){let t=e.endPos();return{type:"implicitMeTarget",start:t,end:t,ev:n=>n.you||n.me}}function kt(e){let t=e.matchType("IDENTIFIER");if(!t)return;let n=[t.value],r=e.matchOp(".")??e.matchOp(":");if(r)do n.push(e.reqType("IDENTIFIER","NUMBER").value);while(e.matchOp(r.value));return n.join(r?.value??"")}function Te(e,t="Expected event name"){return e.matchType("STRING")?.value??kt(e)??e.err(t)}function D(e,t){return xn(e,t)??kn(e,t)??Sn(e,t)??Tn(e,t)??Nn(e,t)??Pn(e,t)??Rn(e,t)??On(e,t)??En(e,t)??t}function En(e,t){for(let n of e.g.indirects){let r=n(e,t);if(r)return r}}function xn(e,t){if(!e.matchOp("."))return;let n=e.reqType("IDENTIFIER").value,r=e.text(t),o={type:"propertyAccess",root:t,prop:n,start:t.start,end:e.endPos(),ev:i=>T(o.root.ev(i),s=>ie(s,n)),lhs:i=>o.root.ev(i),put:(i,s,u)=>{A(s,r),ke(s,n,u)},del:(i,s)=>{A(s,r),S(s,u=>{M(u)&&delete u[n],x.wroteProperty(u)})}};return D(e,o)}function kn(e,t){if(!e.match("of"))return;let n=G(e),r,o=t;for(;o.root;)r=o,o=o.root;let s={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],u=o.name;if(!s||u===void 0)return e.err("Cannot take a property of a non-symbol: "+o.type);let a=e.text(n),l={property:ie,attribute:ae,style:be,computed:Ee}[s],c={type:"ofExpression",root:n,name:u,kind:s,start:t.start,end:e.endPos(),ev:d=>T(c.root.ev(d),m=>l(m,u)),lhs:d=>c.root.ev(d),put:(d,m,f)=>{A(m,a),s==="attribute"?ue(m,u,f):s==="property"?ke(m,u,f):xe(m,u,f)},del:(d,m)=>{A(m,a),S(m,f=>{s==="attribute"?R(f)&&f.removeAttribute(u):s==="property"?(M(f)&&delete f[u],x.wroteProperty(f)):f instanceof HTMLElement&&f.style.removeProperty(u)})}};return r?(r.root=c,D(e,t)):D(e,c)}function Tn(e,t){let n=e.matchOp("'"),r=t.type==="symbol"&&["my","its","your"].includes(t.name??"")&&["IDENTIFIER","ATTRIBUTE_REF","STYLE_REF"].includes(e.cur().type);if(!n&&!r)return;n&&e.req("s");let o=V(e)??Et(e),i=o?void 0:e.reqType("IDENTIFIER").value,s=e.text(t),u=l=>i!==void 0?ie(l,i):o?.type==="attributeRef"?ae(l,o.name):o?.type==="computedStyleRef"?Ee(l,o.name):o&&be(l,o.name),a={type:"possessive",root:t,prop:i,attribute:o,start:t.start,end:e.endPos(),ev:l=>T(a.root.ev(l),u),lhs:l=>a.root.ev(l),put:(l,c,d)=>{A(c,s),i!==void 0?ke(c,i,d):o?.type==="attributeRef"?ue(c,o.name,d):o&&xe(c,o.name,d)}};return D(e,a)}function Nn(e,t){if(!e.match("in"))return;let n=G(e),r=(s,u)=>{if(s==null)return[];let a=[],l=v(s,"css");if(typeof l=="string")S(u,c=>R(c)&&a.push(...Ie(c,l)));else if(R(s)){let c=!1;if(S(u,d=>{d instanceof Node&&d.contains(s)&&(c=!0)}),c)return s}else S(s,c=>S(u,d=>c===d&&a.push(c)));return a},o={type:"inExpression",root:t,target:n,start:t.start,end:e.endPos(),ev:s=>I([o.root.ev(s),n.ev(s)],([u,a])=>r(u,a)),lhs:s=>o.ev(s),put:(s,u,a)=>ce(u,a)},i;if(e.peek("where"))for(let s of e.g.collections)i??=s(e,o);return D(e,i??o)}function Pn(e,t){if(!e.match("as"))return;e.match("a")||e.match("an");let n=o=>{let i=kt(e)??e.err("Expected dotOrColonPath"),s={type:"asExpression",root:o,conversion:i,start:o.start,end:e.endPos(),ev:u=>T(s.root.ev(u),a=>Xe(a,i))};return s},r=n(t);for(;e.matchOp("|");)r=n(r);return D(e,r)}function Rn(e,t){if(!e.matchOp("("))return;let n=[];if(!e.matchOp(")")){do n.push(E(e));while(e.matchOp(","));e.reqOp(")")}let r=e.text(t),o=t.root?e.text(t.root):"",i={type:"functionCall",root:t,args:n,start:t.start,end:e.endPos(),ev:s=>{let u=i.root,a=u.prop,l=a===void 0?void 0:u.root;return I([(l??u).ev(s),...n.map(c=>c.ev(s))],([c,...d])=>{if(!l||a===void 0)return mt(c,void 0,d,s,r);A(c,o);let m=mt(v(c,a),c,d,s,r);return Ze(c,a),m})}};return D(e,i)}function mt(e,t,n,r,o){if(!H(e))throw A(e,o),new Error(`'${o}' is not a function`);return v(e,"hyperfunc")&&n.push(r),Reflect.apply(e,t,n)}function Sn(e,t){let n=V(e);return n&&Cn(e,t,n)}function Cn(e,t,n){let r=e.text(t),o={type:"attributeRefAccess",root:t,attribute:n,start:t.start,end:e.endPos(),ev:i=>T(o.root.ev(i),s=>ae(s,n.name)),lhs:i=>o.root.ev(i),put:(i,s,u)=>{A(s,r),ue(s,n.name,u)}};return o}function On(e,t){if(!e.matchOp("["))return;let n=!!e.matchOp(".."),r=E(e),o=!1,i;!n&&e.matchOp("..")&&(o=!0,e.cur().op&&e.cur().value==="]"||(i=E(e))),e.reqOp("]");let s=e.text(t),u=(c,d)=>b(d)<0?b(v(c,"length"))+b(d):b(d),a=(c,d,m)=>{let f=v(c,"slice");return H(f)?Reflect.apply(f,c,[d,m]):void 0},l={type:"arrayIndex",root:t,first:r,second:i,andBefore:n,andAfter:o,start:t.start,end:e.endPos(),ev:c=>I([l.root.ev(c),r.ev(c),i?.ev(c)],([d,m,f])=>d==null?null:n?a(d,0,u(d,m)+1):o?f==null?a(d,b(m)):a(d,b(m),u(d,f)+1):v(d,String(m))),lhs:c=>I([l.root.ev(c),r.ev(c)],d=>d),put:(c,d,m)=>{let[f,p]=Array.isArray(d)?d:[];A(f,s),M(f)&&(f[String(p)]=m)},del:(c,d)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[m,f]=Array.isArray(d)?d:[];A(m,s),Array.isArray(m)?m.splice(u(m,f),1):M(m)&&delete m[String(f)],x.wroteProperty(m)}};return D(e,l)}function Pt(e){let t=Q(e);if(!t)return;let n=[t];for(let r=Q(e);r;r=Q(e))n.push(r);return n}var Ge=(e,t)=>(e??[]).map(n=>T(n.ev(t),r=>String(v(r,"className")))),In=e=>e.split(";").map(t=>t.split(":")[0].trim()).filter(Boolean),We=e=>e instanceof HTMLElement||e instanceof SVGElement?e.style:void 0,Tt=(e,t,n,r,o)=>t?it(e,t,n,i=>R(i)&&r(i),i=>R(i)&&o(i)):S(e,i=>R(i)&&r(i)),he=(e,{name:t,value:n},r)=>r?e.setAttribute(t,String(n)):e.removeAttribute(t),Rt=(e,t,n,r,o,i)=>i?Tt(t,n,r,s=>he(s,i,e),s=>he(s,i,!e)):I(o.map(s=>Tt(t,n,r,u=>u.classList.toggle(String(s),e),u=>u.classList.toggle(String(s),!e))),()=>{});function St(e){let t=Pt(e),n=t?void 0:V(e);return{refs:t,attribute:n,css:t||n?void 0:xt(e)}}function Ct(e){e.commands.add=(t,n,r)=>{let{refs:o,attribute:i,css:s}=St(t),u;!o&&!i&&!s&&(u=t.withFollow(["to"],()=>E(t)),t.cur().value!=="to"&&t.err("Expected either a class reference or attribute expression"));let a=t.match("to")?E(t):me(t),l=t.match("when")?E(t):void 0,c=o||i?l:void 0,d=t.text(a);return{type:"addCommand",classRefs:o,attributeRef:i,css:s,value:u,to:a,when:c,start:r,end:t.endPos(),run:f=>I([a.ev(f),s?.ev(f),u?.ev(f),...Ge(o,f)],([p,g,w,...k])=>{if(A(p,d),u){if(Array.isArray(p))p.push(w);else if(p instanceof Set)p.add(w);else throw p instanceof Map?new Error("Use 'set myMap[key] to value' for Maps"):new Error("Cannot add to "+typeof p);x.wroteProperty(p)}else if(s)S(p,q=>{let N=We(q);N&&(N.cssText+=g)});else return Rt(!0,p,c,f,k,i)})}}}var An=e=>e instanceof Node||e instanceof NodeList||e instanceof HTMLCollection;function Ot(e){e.commands.remove=(t,n,r)=>{let{refs:o,attribute:i,css:s}=St(t),u=o||i||s?void 0:E(t),a=t.match("from")?E(t):u?void 0:me(t),l;t.match("when")&&(u&&t.err("'when' clause is not supported when removing elements"),l=E(t));let c=a?t.text(a):"",d=u?t.text(u):"",m=(p,g,w)=>{if(w==null&&u?.del&&u.lhs&&!An(g)){let k=u;return T(u.lhs(p),q=>k.del?.(p,q))}if(A(g,d),Array.isArray(w)){let k=w.indexOf(g);k>-1&&w.splice(k,1),x.wroteProperty(w)}else w instanceof Set||w instanceof Map?(w.delete(g),x.wroteProperty(w)):S(g,k=>{R(k)&&k.parentElement&&(w==null||w instanceof Node&&w.contains(k))&&k.parentElement.removeChild(k)})};return{type:"removeCommand",classRefs:o,attributeRef:i,css:s,element:u,from:a,when:l,start:r,end:t.endPos(),run:p=>I([a?.ev(p),s?.ev(p),u?.ev(p),...Ge(o,p)],([g,w,k,...q])=>{if(u)return m(p,k,g);if(A(g,c),s){let N=In(String(w));S(g,C=>N.forEach(O=>We(C)?.removeProperty(O)))}else return Rt(!1,g,l,p,q,i)})}}}var Nt=(e,t,n)=>(r,o,i)=>{i?o.style[e]=i:r==="toggle"?o.style[e]=getComputedStyle(o)[e]===t?n:t:o.style[e]=r==="hide"?t:n},It={display(e,t,n){if(!n&&t instanceof HTMLDialogElement){e==="hide"||e==="toggle"&&t.open?t.close():t.open||t.show();return}let r=W(t);n?t.style.display=n:e==="toggle"?It.display(getComputedStyle(t).display==="none"?"show":"hide",t):e==="hide"?(r.originalDisplay??=t.style.display,t.style.display="none"):r.originalDisplay&&r.originalDisplay!=="none"?t.style.display=r.originalDisplay:t.style.removeProperty("display")},visibility:Nt("visibility","hidden","visible"),opacity:Nt("opacity","0","1"),hidden(e,t){(e==="toggle"?!t.hasAttribute("hidden"):e==="hide")?t.setAttribute("hidden",""):t.removeAttribute("hidden")}};function Fn(e,t){let n=t??B.defaultHideShowStrategy??"display";return B.hideShowStrategies[n]??It[n]??e.err("Unknown show/hide strategy : "+n)}function At(e){e.commands.toggle=(t,n,r)=>{t.matchAny("the","my");let o={type:"toggleCommand",start:r,end:r,run:()=>{}},i;if(t.cur().type==="STYLE_REF"){let g=o.styleProp=t.consume().value.slice(1);i=Fn(t,g),o.on=t.match("of")?t.withFollow(["with","between"],()=>E(t)):me(t)}else if(t.match("between")){let g=Q(t);if(g)t.req("and"),o.between=[g,Q(t)??t.err("Expected classRef")];else{let w=V(t)??t.err("Expected either a class reference or attribute expression");t.req("and"),o.between=[w,V(t)??t.err("Expected attributeRef")]}}else if(!(o.classRefs=Pt(t))&&!(o.attributeRef=V(t))){let g=t.g.toggleElement;if(!g)o.target=t.withFollow(["between"],()=>yt(t));else{let w=t.withFollow(["between","as"],()=>G(t));if(!t.peek("between"))return g(t,w,r);o.target=Ue(t,w)}}if(!o.styleProp&&!o.target&&(o.on=t.match("on")?E(t):me(t)),t.match("between")){let g=o.betweenValues=t.withFollow(["and"],()=>{let w=[E(t)];for(;t.matchOp(",");)w.push(E(t));return w});t.req("and"),g.push(E(t))}o.target&&!o.betweenValues&&t.err("toggle <expression> requires 'between' with values"),t.peek("for")&&!t.peek("in",2)?(t.match("for"),o.time=E(t)):t.match("until")&&(o.until=Te(t),t.match("from")&&(o.from=E(t))),o.end=t.endPos();let{on:s,target:u,betweenValues:a,between:l,attributeRef:c,styleProp:d}=o,m=s?t.text(s):"",f=(g,w)=>g[(g.findIndex(k=>k==w)+1)%g.length],p=(g,w,k,q)=>{if(a&&u?.lhs&&u.put){let N=u;return I([u.ev(g),u.lhs(g)],([C,O])=>N.put?.(g,O,f(k,C)))}if(a&&d)return S(w,N=>{let C=We(N);if(!C||!R(N))return;let O=C.getPropertyValue(d)||getComputedStyle(N).getPropertyValue(d);C.setProperty(d,String(f(k,O)))});A(w,m),S(w,N=>{if(R(N))if(i)N instanceof HTMLElement&&i("toggle",N);else if(l){let[C,O]=l;if(C.type==="classRef"&&O.type==="classRef"){let[_,Z]=[String(C.className),String(O.className)],J=N.classList.contains(_);N.classList.toggle(_,!J),N.classList.toggle(Z,J)}else if(C.type==="attributeRef"&&O.type==="attributeRef"){let _=N.getAttribute(C.name)===String(C.value);he(N,_?C:O,!1),he(N,_?O:C,!0)}}else c?he(N,c,!N.hasAttribute(c.name)):q.forEach(C=>N.classList.toggle(String(C)))})};return o.run=g=>I([s?.ev(g),o.time?.ev(g),o.from?.ev(g),I((a??[]).map(w=>w.ev(g)),w=>w),...Ge(o.classRefs,g)],([w,k,q,N,...C])=>{let O=()=>p(g,w,Array.isArray(N)?N:[],C);if(o.time)return new Promise(_=>{O(),setTimeout(()=>{O(),_()},b(k))});if(o.until){let _=o.until,Z=q||g.me;return new Promise(J=>{z(Z)&&Z.addEventListener(_,()=>{O(),J()},{once:!0}),O()})}return T(O(),()=>{})}),o}}var Y=class extends Error{constructor(n,r,o,i){super(n);this.token=r;this.source=o;this.expected=i}written},Ft=()=>({commands:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),Ne=class e{constructor(t,n,r){this.g=t;this.tokens=n;this.src=r;let o=r.length;this.eof={type:"EOF",value:"<<<EOF>>>",start:o,end:o,line:0,column:0},this.last=this.eof,this.skipWs()}i=0;follows=[];eof;last;child(t,n){return new e(this.g,t,n)}tok(t=0,n=!1){let r=this.i;for(;;){if(!n)for(;this.tokens[r]?.type==="WHITESPACE";)r++;if(t--===0)return this.tokens[r]??this.eof;r++}}cur(){return this.tokens[this.i]??this.eof}hasMore(){return this.i<this.tokens.length}pos(){return this.cur().start}endPos(){return this.last.end}text(t){return this.src.substring(t.start,t.end)}match(t,n="IDENTIFIER"){if(this.follows.includes(t))return;let r=this.cur();if(r.value===t&&r.type===n)return this.consume()}matchOp(t){let n=this.cur();if(n.op&&n.value===t)return this.consume()}matchType(...t){if(t.includes(this.cur().type))return this.consume()}matchAny(...t){for(let n of t){let r=this.match(n);if(r)return r}}matchAnyOp(...t){for(let n of t){let r=this.matchOp(n);if(r)return r}}req(t){return this.match(t)??this.expected(t)}reqOp(t){return this.matchOp(t)??this.expected(t)}reqType(...t){return this.matchType(...t)??this.expected(...t)}peek(t,n=0,r="IDENTIFIER"){let o=this.tok(n);if(o.value===t&&o.type===r)return o}consume(){return this.hasMore()?(this.last=this.tokens[this.i++],this.skipWs(),this.last):this.eof}skipWs(){for(;this.tokens[this.i]?.type==="WHITESPACE";)this.i++}consumeUntil(t,n){let r=[],o=this.cur();for(;(n==null||o.type!==n)&&(t==null||o.value!==t)&&o.type!=="EOF";)r.push(o),this.i++,o=this.cur();return this.skipWs(),r}lastWs(){let t=this.tokens[this.i-1];return t?.type==="WHITESPACE"?t.value:""}pushFollow(...t){return this.follows.push(...t),t.length}popFollow(t=1){this.follows.length-=t}withFollow(t,n){let r=this.pushFollow(...t);try{return n()}finally{this.popFollow(r)}}withoutFollows(t){let n=this.follows;this.follows=[];try{return t()}finally{this.follows=n}}err(t,n){let r=this.cur();throw new Y(t??"Unexpected Token : "+r.value,r,this.src,n)}expected(...t){this.err(t.length===1?`Expected '${t[0]}' but found '${this.cur().value}'`:"Expected one of: "+t.map(n=>`'${n}'`).join(", "),t)}commandStart(t){return t.value in this.g.commands}featureStart(t){return t.value in this.g.features}commandBoundary(t){return["end","then","else","otherwise",")"].includes(t.value)||this.commandStart(t)||this.featureStart(t)||t.type==="EOF"}};function Ve(e){let t=e.source.split(`
|
|
5
|
+
`),c();else if(Le(h))n.push(m(d("WHITESPACE"),f(Le)));else if(!g()&&h==="."&&($(y)||y==="{"||y==="-"))n.push(w("CLASS_REF",!0));else if(!g()&&h==="#"&&($(y)||y==="{"))n.push(w("ID_REF",!1));else if(h==="@"||h==="["&&y==="@")n.push(_());else if(h==="*"&&$(y)){let P=d("STYLE_REF");n.push(m(P,c()+f(F=>$(F)||F==="-")))}else if(p()&&($(h)||h==="\\"))n.push(N());else if(!p()&&($(h)||h==="_"||h==="$"))n.push(q());else if(U(h))n.push(C());else if(!p()&&(h==='"'||h==="`"))n.push(k());else if(!p()&&h==="'")n.push(Z()?k():O());else if(at.has(h))s==="$"&&h==="{"&&u++,h==="}"&&u--,n.push(O());else if(p()||h==="`"){let P=d("RESERVED");n.push(m(P,c()))}else throw new Error("Unknown token: "+h+" ")}return n}function E(e){return e.match("the"),nn(e)}function nn(e){let t=lt(e),n,r=()=>e.match("and")??e.match("or");for(let o=r();o;o=r())n??=o.value,n!==o.value&&e.err("You must parenthesize logical operations with different operators"),t=rn(o.value,t,lt(e));return t}function rn(e,t,n){let r=e==="or";return{type:"logicalOperator",operator:e,left:t,right:n,start:t.start,end:n.end,ev:o=>T(t.ev(o),i=>!!i===r?i:n.ev(o))}}var on={"+":(e,t)=>Array.isArray(e)?e.concat(t):b(e)+b(t),"-":(e,t)=>b(e)-b(t),"*":(e,t)=>b(e)*b(t),"/":(e,t)=>b(e)/b(t),mod:(e,t)=>b(e)%b(t)};function De(e){let t=je(e),n,r=()=>e.matchAnyOp("+","-","*","/")??e.match("mod");for(let o=r();o;o=r()){n??=o.value,n!==o.value&&e.err("You must parenthesize math operations with different operators");let i=t,s=je(e),u=on[o.value];t={type:"mathOperator",operator:o.value,left:i,right:s,start:i.start,end:s.end,ev:l=>I([i.ev(l),s.ev(l)],([c,d])=>u(c,d))}}return t}function je(e){let t=G(e);for(let n=!0;n;){n=!1;for(let r of e.g.collections){let o=r(e,t);if(o){t=o,n=!0;break}}}return t}function G(e){e.match("the");let t=e.pos();if(e.match("not"))return He(e,"logicalNot",t,G(e),n=>!n);if(e.match("no"))return He(e,"noExpression",t,je(e),Fe);for(let n of e.g.unaries){let r=n(e);if(r)return D(e,r)}return an(e)}function He(e,t,n,r,o,i=t!=="negativeNumber"){let s={type:t,root:r,start:n,end:e.endPos(),ev:u=>T(r.ev(u),a=>o(a,u))};return i?D(e,s):s}var sn="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function an(e){let t=ht(e),n=e.matchAny(...sn)??e.matchOp("%");if(n)return ct(e,"stringPostfixExpression",t,n.value);let r=e.matchAny("s","seconds")?1e3:e.matchAny("ms","milliseconds")?1:0;if(r)return ct(e,"timeExpression",t,r);for(let o of e.g.postfixes){let i=o(e,t);if(i)return i}return t}function ct(e,t,n,r){let o=s=>typeof r=="number"?b(s)*r:`${s}${r}`,i={type:t,root:n,suffix:r,start:n.start,end:e.endPos(),ev:s=>T(n.ev(s),o)};return n.stat&&(i.stat=()=>o(de(n))),i}function ht(e){let t=e.pos();return e.matchOp("-")?He(e,"negativeNumber",t,ht(e),n=>-b(n)):pt(e)}function pt(e){let t=dn(e);return t?D(e,t):e.err("Unexpected value: "+e.cur().value)}function yt(e){return e.match("the"),Ue(e,pt(e))}function Ue(e,t){let n=un(t);return n.put||e.err(`A target expression must be writable. The expression type '${n.type}' is not.`),n}function un(e){let t=e;for(;t.type==="parenthesized"&&"expr"in t&&cn(t.expr);)t=t.expr;return t}var cn=e=>H(v(e,"ev"));function de(e){if(e.stat)return e.stat();throw new Error("This expression cannot be evaluated statically: "+e.type)}function ln(e){let t=e.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(t)return{operator:t.value,right:!0,isType:!1};let n=(a,l=!0,c=!1)=>({operator:a,right:l,isType:c}),r=()=>e.match("equal")&&e.match("to"),o=(a,l)=>(e.req("than"),e.match("or")?(e.req("equal"),e.req("to"),n(l)):n(a));if(e.match("is")||e.match("am")){let a=!!e.match("not"),l=a?"not ":"";return e.match("in")?n(l+"in"):e.match("a")||e.match("an")?n(l+"a",!1,!0):e.match("empty")?n(l+"empty",!1):e.match("between")?n(l+"between"):!a&&e.match("less")?o("<","<="):!a&&e.match("greater")?o(">",">="):e.match("really")?(r(),n(a?"!==":"===")):e.match("equal")?(e.match("to"),n(a?"!=":"==")):n(a?"is not":"is")}if(e.match("equals"))return n("==");if(e.match("really"))return e.req("equals"),n("===");if(e.matchAny("exist","exists"))return n("exist",!1);let i=!!e.matchAny("do","does");i&&e.req("not");let s=i?"not ":"",u=(a,l)=>e.match(a)??(i&&a!=="match"&&a!=="contain"?void 0:e.match(l));if(u("match","matches"))return n(s+"match");if(u("contain","contains"))return n(s+"contain");if(i&&e.match("exist"))return n("not exist",!1);if(u("include","includes"))return n(s+"include");if(e.match(i?"start":"starts"))return e.req("with"),n(s+"start with");if(e.match(i?"end":"ends"))return e.req("with"),n(s+"end with");if(u("precede","precedes"))return n(s+"precede");if(u("follow","follows"))return n(s+"follow");i&&e.expected("matches","contains","starts with","ends with","precede","follow")}function lt(e){let t=De(e),n=ln(e);if(!n)return t;let{operator:r}=n,o,i=!0,s,u;n.isType?(o=e.reqType("IDENTIFIER").value,i=!e.matchOp("!")):n.right&&(s=De(e),r.endsWith("match")&&(u=s.css));let a;r.endsWith("between")&&(e.req("and"),a=De(e));let l=!1;e.match("ignoring")&&(e.req("case"),l=!0);let c=f=>l&&typeof f=="string"?f.toLowerCase():f,d=s?.type==="symbol"&&"scope"in s&&s.scope==="local"&&s.name!=="undefined"&&s.name!=="null"?s.name:void 0;return{type:"comparisonOperator",operator:r,left:t,right:s,right2:a,typeName:o,ignoringCase:l,start:t.start,end:e.endPos(),ev:f=>I([t.ev(f),u??s?.ev(f),a?.ev(f)],([p,g,w])=>{if(o){let k=Ke(p,o,i);return r==="a"?k:!k}if(d&&g===void 0&&(r==="is"||r==="is not")){let k=!!ie(p,d);return r==="is"?k:!k}return gt(r,c(p),c(g),w)})}}function ft(e,t){let n=v(e,"contains")??v(e,"includes");if(!H(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,e,[t])}function fn(e,t){let n=v(e,"match")??v(e,"matches");if(!H(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,e,[t])}var dt=(e,t,n)=>e instanceof Node&&t instanceof Node&&(e.compareDocumentPosition(t)&n)!==0;function gt(e,t,n,r){if(e==="not between")return b(t)<b(n)||b(t)>b(r);if(e.startsWith("not "))return!gt(e.slice(4),t,n,r);switch(e){case"is":case"==":return t==n;case"is not":case"!=":return t!=n;case"===":return t===n;case"!==":return t!==n;case"<":return b(t)<b(n);case">":return b(t)>b(n);case"<=":return b(t)<=b(n);case">=":return b(t)>=b(n);case"match":return t!=null&&fn(t,n);case"in":return n!=null&&ft(n,t);case"contain":case"include":return t!=null&&ft(t,n);case"start with":return t!=null&&String(t).startsWith(String(n));case"end with":return t!=null&&String(t).endsWith(String(n));case"between":return b(t)>=b(n)&&b(t)<=b(r);case"precede":return dt(t,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return dt(t,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return Fe(t);case"exist":return Je(t)}throw new Error("Unknown comparison : "+e)}function dn(e){let t=e.cur();switch(t.type){case"NUMBER":return e.consume(),Me("number",parseFloat(t.value),t);case"STRING":return pn(e);case"ID_REF":return vn(e);case"CLASS_REF":return Q(e);case"ATTRIBUTE_REF":return V(e);case"STYLE_REF":return Et(e)}if(t.op){if(t.value==="(")return mn(e);if(t.value==="[")return yn(e);if(t.value==="{")return gn(e);if(t.value==="<")return bn(e)}let n=e.match("true")??e.match("false");if(n)return Me("boolean",n.value==="true",n);let r=e.match("null");if(r)return Me("null",null,r);for(let o of e.g.leaves){let i=o(e);if(i)return i}return wn(e)}function Me(e,t,n){return{type:e,value:t,start:n.start,end:n.end,ev:()=>t,stat:()=>t}}function mn(e){let t=e.pos();e.consume();let n=e.withoutFollows(()=>E(e));return e.reqOp(")"),{type:"parenthesized",expr:n,start:t,end:e.endPos(),ev:r=>n.ev(r)}}var hn=(e,t)=>I(e.map(n=>typeof n=="string"?n:n.ev(t)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function wt(e,t){let n=e.child(fe(t,!0),t),r=[],o="";do{o+=n.lastWs();let i=n.cur();if(i.value==="$"){n.consume();let s=n.matchOp("{");r.push(o,E(n)),o="",s&&n.reqOp("}")}else i.value==="\\"?(n.consume(),n.consume()):n.hasMore()&&(o+=n.consume().value)}while(n.hasMore());return r.push(o+n.lastWs()),r}function pn(e){let t=e.consume(),n=t.value,r={type:"string",value:n,start:t.start,end:t.end,ev:()=>n};if(t.template){let o=r.parts=wt(e,n);r.ev=i=>hn(o,i)}else r.stat=()=>n;return r}function yn(e){let t=e.pos();e.consume();let n=[];if(!e.matchOp("]")){do n.push(E(e));while(e.matchOp(","));e.reqOp("]")}return{type:"arrayLiteral",values:n,start:t,end:e.endPos(),ev:r=>I(n.map(o=>o.ev(r)),o=>o)}}function gn(e){let t=e.pos();e.consume();let n=[],r=[],o=()=>e.cur().op&&e.cur().value==="}";if(!e.matchOp("}")){do{let i=e.matchType("STRING");if(i)n.push(i.value);else if(e.matchOp("["))n.push(E(e)),e.reqOp("]");else{let s="";for(let u=e.matchType("IDENTIFIER")??e.matchOp("-");u;u=e.matchType("IDENTIFIER")??e.matchOp("-"))s+=u.value;n.push(s)}e.reqOp(":"),r.push(E(e))}while(e.matchOp(",")&&!o());e.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:t,end:e.endPos(),ev:i=>I([...n.map(s=>typeof s=="string"?s:s.ev(i)),...r.map(s=>s.ev(i))],s=>Object.fromEntries(n.map((u,a)=>[String(s[a]),s[n.length+a]])))}}function vt(e){return e.matchType("STRING")?.value??e.consumeUntil(void 0,"WHITESPACE").map(t=>t.value).join("")}function wn(e){let t=e.pos(),n;e.match("global")?n="global":e.match("element")?(n="element",e.matchOp("'")&&e.req("s")):e.match("dom")?n="inherited":e.match("local")&&(n="local");let r=e.matchOp(":"),o=!r&&e.matchOp("^"),i=e.matchType("IDENTIFIER");if(!i?.value)return;let s=(r?":":o?"^":"")+i.value,a=n??{$:"global",":":"element","^":"inherited"}[s[0]]??"local",l;return a==="inherited"&&e.match("on")&&(l=e.withFollow(["to","into","before","after","then"],()=>E(e))),{type:"symbol",name:s,scope:a,...l?{on:l}:{},start:t,end:e.endPos(),ev:c=>rt(s,c,a,l?.ev(c)),lhs:()=>{},put:(c,d,m)=>ot(s,c,a,m,l?.ev(c))}}var bt=(e,t)=>{let n=t.value.substring(2);return E(e.child(fe(n),n))};function vn(e){let t=e.consume(),n=(o,i)=>Oe(o.me).getElementById(String(i)),r={type:"idRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(o,i,s)=>T(r.ev(o),u=>u&&ce(u,s))};if(t.template){let o=r.expr=bt(e,t);r.ev=i=>T(o.ev(i),s=>n(i,s))}else{let o=r.value=t.value.substring(1);r.css=t.value,r.ev=i=>n(i,o)}return r}function Q(e){let t=e.matchType("CLASS_REF");if(!t)return;let n={type:"classRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(r,o,i)=>T(n.ev(r),s=>ce(Array.from(s instanceof j?s:[]),i))};if(t.template){let r=n.expr=bt(e,t);n.ev=o=>T(r.ev(o),i=>new j("."+i,o.me,!0))}else{let r=n.css=t.value;n.className=r.slice(1),n.ev=o=>new j(r,o.me,!0)}return n}var $e=class extends j{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>R(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(R);n.forEach((o,i)=>o.setAttribute("data-hs-query-id",String(i)));let r=super.select();return n.forEach(o=>o.removeAttribute("data-hs-query-id")),r}};function bn(e){let t=e.pos();e.consume();let n=e.consumeUntil("/").map(o=>o.type==="STRING"?`"${o.value}"`:o.value).join("");e.reqOp("/"),e.reqOp(">");let r={type:"queryRef",css:n,start:t,end:e.endPos(),ev:o=>new j(n,o.me),lhs:()=>{},put:(o,i,s)=>T(r.ev(o),u=>ce(Array.from(u instanceof j?u:[]),s))};if(/\$[^=]/.test(n)){let o=r.parts=wt(e,n);r.ev=i=>I(o.map(s=>typeof s=="string"?s:s.ev(i)),s=>new $e(i.me,s))}return r}function V(e){let t=e.matchType("ATTRIBUTE_REF");if(!t)return;let n=t.value.startsWith("[")?t.value.slice(2,-1):t.value.slice(1),[r,o]=n.split("="),i=o&&/^["']/.test(o)?o.slice(1,-1):o;return{type:"attributeRef",name:r,value:i,css:`[${n}]`,start:t.start,end:t.end,ev:s=>ae(s.you||s.me,r),lhs:()=>{},put:(s,u,a)=>ue(s.you||s.me,r,a)}}function Et(e){let t=e.matchType("STYLE_REF");if(!t)return;let n=t.value.startsWith("*computed-"),r=t.value.slice(n?10:1);return{type:n?"computedStyleRef":"styleRef",name:r,start:t.start,end:t.end,ev:o=>(n?Ee:be)(o.you||o.me,r),lhs:()=>{},put:(o,i,s)=>xe(o.you||o.me,r,s)}}function xt(e){let t=e.pos();if(!e.matchOp("{"))return;let n=[""],r=[];for(;e.hasMore();){if(e.matchOp("\\"))e.consume();else{if(e.matchOp("}"))break;if(e.match("$")){let o=e.matchOp("{");r.push(E(e)),o&&e.reqOp("}"),n.push("")}else n[n.length-1]+=e.text(e.consume())}n[n.length-1]+=e.lastWs()}return{type:"styleLiteral",parts:n,exprs:r,start:t,end:e.endPos(),ev:o=>I(r.map(i=>i.ev(o)),i=>n.map((s,u)=>s+(u in i?`${i[u]}`:"")).join(""))}}function me(e){let t=e.endPos();return{type:"implicitMeTarget",start:t,end:t,ev:n=>n.you||n.me}}function kt(e){let t=e.matchType("IDENTIFIER");if(!t)return;let n=[t.value],r=e.matchOp(".")??e.matchOp(":");if(r)do n.push(e.reqType("IDENTIFIER","NUMBER").value);while(e.matchOp(r.value));return n.join(r?.value??"")}function Te(e,t="Expected event name"){return e.matchType("STRING")?.value??kt(e)??e.err(t)}function D(e,t){return xn(e,t)??kn(e,t)??Sn(e,t)??Tn(e,t)??Nn(e,t)??Pn(e,t)??Rn(e,t)??On(e,t)??En(e,t)??t}function En(e,t){for(let n of e.g.indirects){let r=n(e,t);if(r)return r}}function xn(e,t){if(!e.matchOp("."))return;let n=e.reqType("IDENTIFIER").value,r=e.text(t),o={type:"propertyAccess",root:t,prop:n,start:t.start,end:e.endPos(),ev:i=>T(o.root.ev(i),s=>ie(s,n)),lhs:i=>o.root.ev(i),put:(i,s,u)=>{A(s,r),ke(s,n,u)},del:(i,s)=>{A(s,r),S(s,u=>{M(u)&&delete u[n],x.wroteProperty(u)})}};return D(e,o)}function kn(e,t){if(!e.match("of"))return;let n=G(e),r,o=t;for(;o.root;)r=o,o=o.root;let s={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],u=o.name;if(!s||u===void 0)return e.err("Cannot take a property of a non-symbol: "+o.type);let a=e.text(n),l={property:ie,attribute:ae,style:be,computed:Ee}[s],c={type:"ofExpression",root:n,name:u,kind:s,start:t.start,end:e.endPos(),ev:d=>T(c.root.ev(d),m=>l(m,u)),lhs:d=>c.root.ev(d),put:(d,m,f)=>{A(m,a),s==="attribute"?ue(m,u,f):s==="property"?ke(m,u,f):xe(m,u,f)},del:(d,m)=>{A(m,a),S(m,f=>{s==="attribute"?R(f)&&f.removeAttribute(u):s==="property"?(M(f)&&delete f[u],x.wroteProperty(f)):f instanceof HTMLElement&&f.style.removeProperty(u)})}};return r?(r.root=c,D(e,t)):D(e,c)}function Tn(e,t){let n=e.matchOp("'"),r=t.type==="symbol"&&["my","its","your"].includes(t.name??"")&&["IDENTIFIER","ATTRIBUTE_REF","STYLE_REF"].includes(e.cur().type);if(!n&&!r)return;n&&e.req("s");let o=V(e)??Et(e),i=o?void 0:e.reqType("IDENTIFIER").value,s=e.text(t),u=l=>i!==void 0?ie(l,i):o?.type==="attributeRef"?ae(l,o.name):o?.type==="computedStyleRef"?Ee(l,o.name):o&&be(l,o.name),a={type:"possessive",root:t,prop:i,attribute:o,start:t.start,end:e.endPos(),ev:l=>T(a.root.ev(l),u),lhs:l=>a.root.ev(l),put:(l,c,d)=>{A(c,s),i!==void 0?ke(c,i,d):o?.type==="attributeRef"?ue(c,o.name,d):o&&xe(c,o.name,d)}};return D(e,a)}function Nn(e,t){if(!e.match("in"))return;let n=G(e),r=(s,u)=>{if(s==null)return[];let a=[],l=v(s,"css");if(typeof l=="string")S(u,c=>R(c)&&a.push(...Ie(c,l)));else if(R(s)){let c=!1;if(S(u,d=>{d instanceof Node&&d.contains(s)&&(c=!0)}),c)return s}else S(s,c=>S(u,d=>c===d&&a.push(c)));return a},o={type:"inExpression",root:t,target:n,start:t.start,end:e.endPos(),ev:s=>I([o.root.ev(s),n.ev(s)],([u,a])=>r(u,a)),lhs:s=>o.ev(s),put:(s,u,a)=>ce(u,a)},i;if(e.peek("where"))for(let s of e.g.collections)i??=s(e,o);return D(e,i??o)}function Pn(e,t){if(!e.match("as"))return;e.match("a")||e.match("an");let n=o=>{let i=kt(e)??e.err("Expected dotOrColonPath"),s={type:"asExpression",root:o,conversion:i,start:o.start,end:e.endPos(),ev:u=>T(s.root.ev(u),a=>Xe(a,i))};return s},r=n(t);for(;e.matchOp("|");)r=n(r);return D(e,r)}function Rn(e,t){if(!e.matchOp("("))return;let n=[];if(!e.matchOp(")")){do n.push(E(e));while(e.matchOp(","));e.reqOp(")")}let r=e.text(t),o=t.root?e.text(t.root):"",i={type:"functionCall",root:t,args:n,start:t.start,end:e.endPos(),ev:s=>{let u=i.root,a=u.prop,l=a===void 0?void 0:u.root;return I([(l??u).ev(s),...n.map(c=>c.ev(s))],([c,...d])=>{if(!l||a===void 0)return mt(c,void 0,d,s,r);A(c,o);let m=mt(v(c,a),c,d,s,r);return Ze(c,a),m})}};return D(e,i)}function mt(e,t,n,r,o){if(!H(e))throw A(e,o),new Error(`'${o}' is not a function`);return v(e,"hyperfunc")&&n.push(r),Reflect.apply(e,t,n)}function Sn(e,t){let n=V(e);return n&&Cn(e,t,n)}function Cn(e,t,n){let r=e.text(t),o={type:"attributeRefAccess",root:t,attribute:n,start:t.start,end:e.endPos(),ev:i=>T(o.root.ev(i),s=>ae(s,n.name)),lhs:i=>o.root.ev(i),put:(i,s,u)=>{A(s,r),ue(s,n.name,u)}};return o}function On(e,t){if(!e.matchOp("["))return;let n=!!e.matchOp(".."),r=E(e),o=!1,i;!n&&e.matchOp("..")&&(o=!0,e.cur().op&&e.cur().value==="]"||(i=E(e))),e.reqOp("]");let s=e.text(t),u=(c,d)=>b(d)<0?b(v(c,"length"))+b(d):b(d),a=(c,d,m)=>{let f=v(c,"slice");return H(f)?Reflect.apply(f,c,[d,m]):void 0},l={type:"arrayIndex",root:t,first:r,second:i,andBefore:n,andAfter:o,start:t.start,end:e.endPos(),ev:c=>I([l.root.ev(c),r.ev(c),i?.ev(c)],([d,m,f])=>d==null?null:n?a(d,0,u(d,m)+1):o?f==null?a(d,b(m)):a(d,b(m),u(d,f)+1):v(d,String(m))),lhs:c=>I([l.root.ev(c),r.ev(c)],d=>d),put:(c,d,m)=>{let[f,p]=Array.isArray(d)?d:[];A(f,s),M(f)&&(f[String(p)]=m)},del:(c,d)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[m,f]=Array.isArray(d)?d:[];A(m,s),Array.isArray(m)?m.splice(u(m,f),1):M(m)&&delete m[String(f)],x.wroteProperty(m)}};return D(e,l)}function Pt(e){let t=Q(e);if(!t)return;let n=[t];for(let r=Q(e);r;r=Q(e))n.push(r);return n}var Ge=(e,t)=>(e??[]).map(n=>T(n.ev(t),r=>String(v(r,"className")))),In=e=>e.split(";").map(t=>t.split(":")[0].trim()).filter(Boolean),We=e=>e instanceof HTMLElement||e instanceof SVGElement?e.style:void 0,Tt=(e,t,n,r,o)=>t?it(e,t,n,i=>R(i)&&r(i),i=>R(i)&&o(i)):S(e,i=>R(i)&&r(i)),he=(e,{name:t,value:n},r)=>r?e.setAttribute(t,String(n)):e.removeAttribute(t),Rt=(e,t,n,r,o,i)=>i?Tt(t,n,r,s=>he(s,i,e),s=>he(s,i,!e)):I(o.map(s=>Tt(t,n,r,u=>u.classList.toggle(String(s),e),u=>u.classList.toggle(String(s),!e))),()=>{});function St(e){let t=Pt(e),n=t?void 0:V(e);return{refs:t,attribute:n,css:t||n?void 0:xt(e)}}function Ct(e){e.commands.add=(t,n,r)=>{let{refs:o,attribute:i,css:s}=St(t),u;!o&&!i&&!s&&(u=t.withFollow(["to"],()=>E(t)),t.cur().value!=="to"&&t.err("Expected either a class reference or attribute expression"));let a=t.match("to")?E(t):me(t),l=t.match("when")?E(t):void 0,c=o||i?l:void 0,d=t.text(a);return{type:"addCommand",classRefs:o,attributeRef:i,css:s,value:u,to:a,when:c,start:r,end:t.endPos(),run:f=>I([a.ev(f),s?.ev(f),u?.ev(f),...Ge(o,f)],([p,g,w,...k])=>{if(A(p,d),u){if(Array.isArray(p))p.push(w);else if(p instanceof Set)p.add(w);else throw p instanceof Map?new Error("Use 'set myMap[key] to value' for Maps"):new Error("Cannot add to "+typeof p);x.wroteProperty(p)}else if(s)S(p,q=>{let N=We(q);N&&(N.cssText+=g)});else return Rt(!0,p,c,f,k,i)})}}}var An=e=>e instanceof Node||e instanceof NodeList||e instanceof HTMLCollection;function Ot(e){e.commands.remove=(t,n,r)=>{let{refs:o,attribute:i,css:s}=St(t),u=o||i||s?void 0:E(t),a=t.match("from")?E(t):u?void 0:me(t),l;t.match("when")&&(u&&t.err("'when' clause is not supported when removing elements"),l=E(t));let c=a?t.text(a):"",d=u?t.text(u):"",m=(p,g,w)=>{if(w==null&&u?.del&&u.lhs&&!An(g)){let k=u;return T(u.lhs(p),q=>k.del?.(p,q))}if(A(g,d),Array.isArray(w)){let k=w.indexOf(g);k>-1&&w.splice(k,1),x.wroteProperty(w)}else w instanceof Set||w instanceof Map?(w.delete(g),x.wroteProperty(w)):S(g,k=>{R(k)&&k.parentElement&&(w==null||w instanceof Node&&w.contains(k))&&k.parentElement.removeChild(k)})};return{type:"removeCommand",classRefs:o,attributeRef:i,css:s,element:u,from:a,when:l,start:r,end:t.endPos(),run:p=>I([a?.ev(p),s?.ev(p),u?.ev(p),...Ge(o,p)],([g,w,k,...q])=>{if(u)return m(p,k,g);if(A(g,c),s){let N=In(String(w));S(g,C=>N.forEach(O=>We(C)?.removeProperty(O)))}else return Rt(!1,g,l,p,q,i)})}}}var Nt=(e,t,n)=>(r,o,i)=>{i?o.style[e]=i:r==="toggle"?o.style[e]=getComputedStyle(o)[e]===t?n:t:o.style[e]=r==="hide"?t:n},It={display(e,t,n){if(!n&&t instanceof HTMLDialogElement){e==="hide"||e==="toggle"&&t.open?t.close():t.open||t.show();return}let r=W(t);n?t.style.display=n:e==="toggle"?It.display(getComputedStyle(t).display==="none"?"show":"hide",t):e==="hide"?(r.originalDisplay??=t.style.display,t.style.display="none"):r.originalDisplay&&r.originalDisplay!=="none"?t.style.display=r.originalDisplay:t.style.removeProperty("display")},visibility:Nt("visibility","hidden","visible"),opacity:Nt("opacity","0","1"),hidden(e,t){(e==="toggle"?!t.hasAttribute("hidden"):e==="hide")?t.setAttribute("hidden",""):t.removeAttribute("hidden")}};function Fn(e,t){let n=t??B.defaultHideShowStrategy??"display";return B.hideShowStrategies[n]??It[n]??e.err("Unknown show/hide strategy : "+n)}function At(e){e.commands.toggle=(t,n,r)=>{t.matchAny("the","my");let o={type:"toggleCommand",start:r,end:r,run:()=>{}},i;if(t.cur().type==="STYLE_REF"){let g=o.styleProp=t.consume().value.slice(1);i=Fn(t,g),o.on=t.match("of")?t.withFollow(["with","between"],()=>E(t)):me(t)}else if(t.match("between")){let g=Q(t);if(g)t.req("and"),o.between=[g,Q(t)??t.err("Expected classRef")];else{let w=V(t)??t.err("Expected either a class reference or attribute expression");t.req("and"),o.between=[w,V(t)??t.err("Expected attributeRef")]}}else if(!(o.classRefs=Pt(t))&&!(o.attributeRef=V(t))){let g=t.g.toggleElement;if(!g)o.target=t.withFollow(["between"],()=>yt(t));else{let w=t.withFollow(["between","as"],()=>G(t));if(!t.peek("between"))return g(t,w,r);o.target=Ue(t,w)}}if(!o.styleProp&&!o.target&&(o.on=t.match("on")?E(t):me(t)),t.match("between")){let g=o.betweenValues=t.withFollow(["and"],()=>{let w=[E(t)];for(;t.matchOp(",");)w.push(E(t));return w});t.req("and"),g.push(E(t))}o.target&&!o.betweenValues&&t.err("toggle <expression> requires 'between' with values"),t.peek("for")&&!t.peek("in",2)?(t.match("for"),o.time=E(t)):t.match("until")&&(o.until=Te(t),t.match("from")&&(o.from=E(t))),o.end=t.endPos();let{on:s,target:u,betweenValues:a,between:l,attributeRef:c,styleProp:d}=o,m=s?t.text(s):"",f=(g,w)=>g[(g.findIndex(k=>k==w)+1)%g.length],p=(g,w,k,q)=>{if(a&&u?.lhs&&u.put){let N=u;return I([u.ev(g),u.lhs(g)],([C,O])=>N.put?.(g,O,f(k,C)))}if(a&&d)return S(w,N=>{let C=We(N);if(!C||!R(N))return;let O=C.getPropertyValue(d)||getComputedStyle(N).getPropertyValue(d);C.setProperty(d,String(f(k,O)))});A(w,m),S(w,N=>{if(R(N))if(i)N instanceof HTMLElement&&i("toggle",N);else if(l){let[C,O]=l;if(C.type==="classRef"&&O.type==="classRef"){let[_,Z]=[String(C.className),String(O.className)],J=N.classList.contains(_);N.classList.toggle(_,!J),N.classList.toggle(Z,J)}else if(C.type==="attributeRef"&&O.type==="attributeRef"){let _=N.getAttribute(C.name)===String(C.value);he(N,_?C:O,!1),he(N,_?O:C,!0)}}else c?he(N,c,!N.hasAttribute(c.name)):q.forEach(C=>N.classList.toggle(String(C)))})};return o.run=g=>I([s?.ev(g),o.time?.ev(g),o.from?.ev(g),I((a??[]).map(w=>w.ev(g)),w=>w),...Ge(o.classRefs,g)],([w,k,q,N,...C])=>{let O=()=>p(g,w,Array.isArray(N)?N:[],C);if(o.time)return new Promise(_=>{O(),setTimeout(()=>{O(),_()},b(k))});if(o.until){let _=o.until,Z=q||g.me;return new Promise(J=>{z(Z)&&Z.addEventListener(_,()=>{O(),J()},{once:!0}),O()})}return T(O(),()=>{})}),o}}var Y=class extends Error{constructor(n,r,o,i){super(n);this.token=r;this.source=o;this.expected=i}written},Ft=()=>({commands:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),Ne=class e{constructor(t,n,r){this.g=t;this.tokens=n;this.src=r;let o=r.length;this.eof={type:"EOF",value:"<<<EOF>>>",start:o,end:o,line:0,column:0},this.last=this.eof,this.skipWs()}i=0;follows=[];eof;last;child(t,n){return new e(this.g,t,n)}tok(t=0,n=!1){let r=this.i;for(;;){if(!n)for(;this.tokens[r]?.type==="WHITESPACE";)r++;if(t--===0)return this.tokens[r]??this.eof;r++}}cur(){return this.tokens[this.i]??this.eof}hasMore(){return this.i<this.tokens.length}pos(){return this.cur().start}endPos(){return this.last.end}text(t){return this.src.substring(t.start,t.end)}match(t,n="IDENTIFIER"){if(this.follows.includes(t))return;let r=this.cur();if(r.value===t&&r.type===n)return this.consume()}matchOp(t){let n=this.cur();if(n.op&&n.value===t)return this.consume()}matchType(...t){if(t.includes(this.cur().type))return this.consume()}matchAny(...t){for(let n of t){let r=this.match(n);if(r)return r}}matchAnyOp(...t){for(let n of t){let r=this.matchOp(n);if(r)return r}}req(t){return this.match(t)??this.expected(t)}reqOp(t){return this.matchOp(t)??this.expected(t)}reqType(...t){return this.matchType(...t)??this.expected(...t)}peek(t,n=0,r="IDENTIFIER"){let o=this.tok(n);if(o.value===t&&o.type===r)return o}consume(){return this.hasMore()?(this.last=this.tokens[this.i++],this.skipWs(),this.last):this.eof}skipWs(){for(;this.tokens[this.i]?.type==="WHITESPACE";)this.i++}consumeUntil(t,n){let r=[],o=this.cur();for(;(n==null||o.type!==n)&&(t==null||o.value!==t)&&o.type!=="EOF";)r.push(o),this.i++,o=this.cur();return this.skipWs(),r}lastWs(){let t=this.tokens[this.i-1];return t?.type==="WHITESPACE"?t.value:""}pushFollow(...t){return this.follows.push(...t),t.length}popFollow(t=1){this.follows.length-=t}withFollow(t,n){let r=this.pushFollow(...t);try{return n()}finally{this.popFollow(r)}}withoutFollows(t){let n=this.follows;this.follows=[];try{return t()}finally{this.follows=n}}err(t,n){let r=this.cur();throw new Y(t??"Unexpected Token : "+r.value,r,this.src,n)}expected(...t){this.err(t.length===1?`Expected '${t[0]}' but found '${this.cur().value}'`:"Expected one of: "+t.map(n=>`'${n}'`).join(", "),t)}commandStart(t){return t.value in this.g.commands}featureStart(t){return t.value in this.g.features}commandBoundary(t){return["end","then","else","otherwise",")"].includes(t.value)||this.commandStart(t)||this.featureStart(t)||t.type==="EOF"}};function Ve(e){let t=e.source.split(`
|
|
6
6
|
`),n=e.token.line?e.token.line-1:t.length-1,r=t[n]??"",o=e.token.line?e.token.column:Math.max(0,r.length-1),i=String(n+1).length,s=" ".repeat(i+5+o);return` ${n+1} | ${r}
|
|
7
7
|
`+s+"^".repeat(Math.max(1,e.token.value.length))+`
|
|
8
8
|
`+s+e.message+`
|
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
|
|
15
15
|
`+Ve(i)+s)}else L(e,"exception",{error:i}),console.error("hyperscript errors were found on the following element:",e,`
|
|
16
16
|
|
|
17
|
-
`,i)}}var Bt=[],Qt=[];function pe(e){if(!(e instanceof Element||e instanceof Document||e instanceof DocumentFragment))return;for(let n of Bt)n(e);let t=Wt().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";e instanceof Element&&e.matches(t)&&jt(e),e.querySelectorAll(t).forEach(jt);for(let n of Qt)n(e)}function Pe(e){let t=ee(e);if(t){L(e,"hyperscript:before:cleanup");for(let{target:n,event:r,handler:o}of t.listeners??[])n.removeEventListener(r,o);for(let n of t.observers??[])n.disconnect();for(let n of t.timers??[])clearTimeout(n);x.stop(e),e.querySelectorAll("[data-hyperscript-powered]").forEach(Pe),L(e,"hyperscript:after:cleanup"),e.removeAttribute("data-hyperscript-powered"),Ye(e)}}se.process=pe;function Dn(e){try{let t=Gt(e);return t.kind==="features"?{...t.program,errors:[]}:{...t.kind==="commands"?t.commands[0]:t.expression,errors:[]}}catch(t){if(t instanceof Y)return{errors:[t]};throw t}}var Yt=Object.assign(Mt,{config:Object.assign(B,{conversions:Object.assign(Se,{dynamicResolvers:Ce})}),use(e){e(Yt)},addBeforeProcessHook:e=>void Bt.push(e),addAfterProcessHook:e=>void Qt.push(e),addSourceTransform:e=>void zt.push(e),evaluate:Mt,parse:Dn,process:pe,processNode:pe,cleanup:Pe,internals:{runtime:{cleanup:Pe,processNode:pe}},version:"4.
|
|
17
|
+
`,i)}}var Bt=[],Qt=[];function pe(e){if(!(e instanceof Element||e instanceof Document||e instanceof DocumentFragment))return;for(let n of Bt)n(e);let t=Wt().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";e instanceof Element&&e.matches(t)&&jt(e),e.querySelectorAll(t).forEach(jt);for(let n of Qt)n(e)}function Pe(e){let t=ee(e);if(t){L(e,"hyperscript:before:cleanup");for(let{target:n,event:r,handler:o}of t.listeners??[])n.removeEventListener(r,o);for(let n of t.observers??[])n.disconnect();for(let n of t.timers??[])clearTimeout(n);x.stop(e),e.querySelectorAll("[data-hyperscript-powered]").forEach(Pe),L(e,"hyperscript:after:cleanup"),e.removeAttribute("data-hyperscript-powered"),Ye(e)}}se.process=pe;function Dn(e){try{let t=Gt(e);return t.kind==="features"?{...t.program,errors:[]}:{...t.kind==="commands"?t.commands[0]:t.expression,errors:[]}}catch(t){if(t instanceof Y)return{errors:[t]};throw t}}var Yt=Object.assign(Mt,{config:Object.assign(B,{conversions:Object.assign(Se,{dynamicResolvers:Ce})}),use(e){e(Yt)},addBeforeProcessHook:e=>void Bt.push(e),addAfterProcessHook:e=>void Qt.push(e),addSourceTransform:e=>void zt.push(e),evaluate:Mt,parse:Dn,process:pe,processNode:pe,cleanup:Pe,internals:{runtime:{cleanup:Pe,processNode:pe}},version:"4.2.0"});function Zt(){if(Object.assign(globalThis,{_hyperscript:Yt}),typeof document>"u")return;let e=()=>{pe(document.documentElement),document.dispatchEvent(new Event("hyperscript:ready"))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e)}function Mn(e,t){if(typeof e!="object"||e===null)return{queue:[],executing:!1};let n=W(e).eventQueues??=new Map,r=n.get(t);return r||n.set(t,r={queue:[],executing:!1}),r}function Be(e,t){let n=Mn(e.me,t);if(n.executing&&!t.every){if(t.queue==="none"||t.queue==="first"&&n.queue.length>0)return;t.queue!=="all"&&(n.queue.length=0),n.queue.push(e);return}n.executing=!0;let r=o=>{n.executing=!1;let i=n.queue.shift();if(i&&setTimeout(()=>Be(i,t),1),o){let{error:s}=o;console.error(v(s,"message")??s),console.error(v(s,"stack")),L(e.me,"exception",{error:s})}};oe(()=>T(st(e,t.body,t),()=>r()),o=>r({error:o}))}function jn(e,t){if(!z(t))return;let n=W(t),r=n.listeners??=[],o=n.observers??=[],i=n.timers??=new Set;for(let s of e.events){let u={execCount:0},a=s.elsewhere?[document]:s.from?s.from.ev(le(t,e,t,null)):[t];S(a,l=>{if(!z(l)){console.warn("'%s' feature ignored because target does not exists:",e.displayName,t);return}let c=s.on;if(s.mutationSpec&&l instanceof Node){c="hyperscript:mutation";let m=new MutationObserver(f=>L(l,c,{mutationList:f,observer:m}));m.observe(l,s.mutationSpec),o.push(m)}if(s.intersectionSpec&&l instanceof Element){c="hyperscript:intersection";let m=new IntersectionObserver(f=>{for(let p of f)L(l,c,{observer:m,entry:p,intersecting:p.isIntersecting,isIntersecting:p.isIntersecting,intersectionRatio:p.intersectionRatio})},s.intersectionSpec);m.observe(l),o.push(m)}if(s.resizeSpec&&l instanceof Element){c="hyperscript:resize";let m=new ResizeObserver(f=>{for(let p of f){let{width:g,height:w}=p.contentRect;L(l,c,{width:g,height:w,contentRect:p.contentRect,entry:p})}});m.observe(l),o.push(m)}let d=m=>{if(t instanceof Node&&l!==t&&!t.isConnected){l.removeEventListener(c,d);return}let f=le(t,e,t,m);if(!(s.elsewhere&&t instanceof Node&&m.target instanceof Node&&t.contains(m.target))){s.from&&(f.result=l);for(let p of s.args){let g=v(m,p);g!==void 0?f.locals[p]=g:f.detail!=null&&(f.locals[p]=v(f.detail,p))}if(s.filter){f.meta.context=m;try{if(!s.filter.ev(f))return}finally{f.meta.context=void 0}}if(s.inExpr?.css){let p=m.target instanceof Element?m.target:null;for(;p&&!p.matches(s.inExpr.css);)p=p.parentElement;if(!p)return;f.result=p}if(u.execCount++,s.startCount){let p=u.execCount;if(s.endCount?p<s.startCount||p>s.endCount:s.unbounded?p<s.startCount:p!==s.startCount)return}if(s.debounceTime){u.debounced&&(clearTimeout(u.debounced),i.delete(u.debounced)),i.add(u.debounced=setTimeout(()=>Be(f,e),s.debounceTime));return}if(s.throttleTime){if(u.lastExec&&Date.now()<u.lastExec+s.throttleTime)return;u.lastExec=Date.now()}Be(f,e)}};l.addEventListener(c,d),r.push({target:l,event:c,handler:d})})}}function Hn(e){if(!e.match("of"))return{attributes:!0,characterData:!0,childList:!0,attributeOldValue:!0,characterDataOldValue:!0};let t={};do if(e.match("anything"))Object.assign(t,{attributes:!0,subtree:!0,characterData:!0,childList:!0});else if(e.match("childList"))t.childList=!0;else if(e.match("attributes"))t.attributes=!0;else if(e.match("subtree"))t.subtree=!0;else if(e.match("characterData"))t.characterData=!0;else if(e.cur().type==="ATTRIBUTE_REF"){let n=e.consume().value;n.startsWith("@")||e.err("Only shorthand attribute references are allowed here"),(t.attributeFilter??=[]).push(n.substring(1))}else e.err("Unknown mutation config specification");while(e.match("or"));return(t.attributes||t.attributeFilter)&&(t.attributeOldValue=!0),t.characterData&&(t.characterDataOldValue=!0),t}function $n(e){let t={};if(e.match("with")){let n=de(E(e));n instanceof Element&&(t.root=n)}if(e.match("having"))do e.match("margin")?t.rootMargin=vt(e):e.match("threshold")?t.threshold=Number(de(E(e))):e.err("Unknown intersection config specification");while(e.match("and"));return t}function Un(e,t){let n=Te(e),r=Dt(e),o;e.matchOp("[")&&(o=E(e),e.reqOp("]"));let i,s,u=!1;t?i=1:e.cur().type==="NUMBER"&&(i=parseInt(e.consume().value),e.match("to")?s=parseInt(e.consume().value):e.match("and")&&(u=!0,e.req("on")));let a={on:n,args:r,filter:o,startCount:i,endCount:s,unbounded:u,elsewhere:!1,resizeSpec:n==="resize"};n==="intersection"?a.intersectionSpec=$n(e):n==="mutation"&&(a.mutationSpec=Hn(e)),e.match("from")&&(e.match("elsewhere")?a.elsewhere=!0:a.from=e.withFollow(["or"],()=>E(e))),!a.from&&!a.elsewhere&&e.match("elsewhere")&&(a.elsewhere=!0),e.match("in")&&(a.inExpr=G(e));let l=()=>(e.req("at"),Number(de(G(e))));return e.match("debounced")?a.debounceTime=l():e.match("throttled")&&(a.throttleTime=l()),a}function Jt(e){e.features.on=(t,n)=>{let r=!!t.match("every"),o=!r&&!!t.match("first"),i=[];do i.push(Un(t,o));while(t.match("or"));let s="last";!r&&t.match("queue")&&(t.match("all")?s="all":t.match("first")?s="first":t.match("none")?s="none":t.req("last"));let u=te(t),a={type:"onFeature",displayName:"on "+i.map(l=>l.on).join(" or "),events:i,body:u,every:r,queue:s,..._t(t),start:n,end:t.endPos(),install:l=>jn(a,l)};return a}}$t(Jt,Ct,Ot,At);Zt();})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperfixi/engine",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "A small, typed hyperscript engine, faithful to upstream _hyperscript: its test suite is the acceptance oracle. Ships hyperfixi-hs.js, the script-tag bundle",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|