@hyperfixi/engine 7.2.0 → 7.4.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 +84 -0
- package/README.md +22 -4
- package/dist/common.js +131 -12
- package/dist/common.min.js +9 -9
- package/dist/core.js +131 -12
- package/dist/core.min.js +9 -9
- package/dist/full.js +134 -15
- package/dist/full.min.js +11 -11
- package/dist/htmx-compat.d.ts +6 -0
- package/dist/hyperfixi-hs.dev.js +134 -15
- package/dist/hyperfixi-hs.js +11 -11
- package/dist/index.js +134 -15
- package/dist/minimal.js +131 -12
- package/dist/minimal.min.js +9 -9
- package/dist/runtime.d.ts +2 -1
- package/package.json +1 -1
package/dist/core.min.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";(()=>{var G=e=>typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function",E=(e,t)=>G(e)?e.then(t):t(e),S=(e,t)=>e.some(G)?Promise.all(e).then(t):t(e),C=e=>e!=null,L=e=>typeof e=="function",g=(e,t)=>C(e)?e[t]:void 0,z=(e,t,n)=>{C(e)&&(e[t]=n)},k=e=>e instanceof Element,B=e=>L(g(e,"addEventListener"));var v=e=>e;var
|
|
2
|
-
`,r:"\r",t:" ",v:"\v"},q=e=>e>="a"&&e<="z"||e>="A"&&e<="Z",_=e=>e>="0"&&e<="9",
|
|
3
|
-
`,
|
|
4
|
-
`?(i++,o=0):o++,s),p=f=>({type:f,value:"",start:r,end:r+1,line:i,column:o}),m=(f,h)=>(f.value=h,f.end=r,f),d=f=>{let h="";for(;
|
|
5
|
-
`),u();else if(xe(f))n.push(m(p("WHITESPACE"),d(xe)));else if(!I()&&f==="."&&(q(h)||h==="{"||h==="-"))n.push(j("CLASS_REF",!0));else if(!I()&&f==="#"&&(q(h)||h==="{"))n.push(j("ID_REF",!1));else if(f==="@"||f==="["&&h==="@")n.push(It());else if(f==="*"&&q(h)){let b=p("STYLE_REF");n.push(m(b,u()+d(T=>q(T)||T==="-")))}else if(y()&&(q(f)||f==="\\"))n.push(Rt());else if(!y()&&(q(f)||f==="_"||f==="$"))n.push(qe());else if(_(f))n.push(Ot());else if(!y()&&(f==='"'||f==="`"))n.push(F());else if(!y()&&f==="'")n.push(Ct()?F():_e());else if(Ve.has(f))s==="$"&&f==="{"&&c++,f==="}"&&c--,n.push(_e());else if(y()||f==="`"){let b=p("RESERVED");n.push(m(b,u()))}else throw new Error("Unknown token: "+f+" ")}return n}function x(e){return e.match("the"),Dt(e)}function Dt(e){let t=Je(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=Mt(o.value,t,Je(e));return t}function Mt(e,t,n){let r=e==="or";return{type:"logicalOperator",operator:e,left:t,right:n,start:t.start,end:n.end,ev:o=>E(t.ev(o),i=>!!i===r?i:n.ev(o))}}var jt={"+":(e,t)=>Array.isArray(e)?e.concat(t):v(e)+v(t),"-":(e,t)=>v(e)-v(t),"*":(e,t)=>v(e)*v(t),"/":(e,t)=>v(e)/v(t),mod:(e,t)=>v(e)%v(t)};function Pe(e){let t=Se(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=Se(e),c=jt[o.value];t={type:"mathOperator",operator:o.value,left:i,right:s,start:i.start,end:s.end,ev:l=>S([i.ev(l),s.ev(l)],([u,p])=>c(u,p))}}return t}function Se(e){let t=D(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 D(e){e.match("the");let t=e.pos();if(e.match("not"))return Re(e,"logicalNot",t,D(e),n=>!n);if(e.match("no"))return Re(e,"noExpression",t,Se(e),be);for(let n of e.g.unaries){let r=n(e);if(r)return O(e,r)}return $t(e)}function Re(e,t,n,r,o,i=t!=="negativeNumber"){let s={type:t,root:r,start:n,end:e.endPos(),ev:c=>E(r.ev(c),a=>o(a,c))};return i?O(e,s):s}var Ht="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function $t(e){let t=tt(e),n=e.matchAny(...Ht)??e.matchOp("%");if(n)return Ze(e,"stringPostfixExpression",t,n.value);let r=e.matchAny("s","seconds")?1e3:e.matchAny("ms","milliseconds")?1:0;if(r)return Ze(e,"timeExpression",t,r);for(let o of e.g.postfixes){let i=o(e,t);if(i)return i}return t}function Ze(e,t,n,r){let o=s=>typeof r=="number"?v(s)*r:`${s}${r}`,i={type:t,root:n,suffix:r,start:n.start,end:e.endPos(),ev:s=>E(n.ev(s),o)};return n.stat&&(i.stat=()=>o(ne(n))),i}function tt(e){let t=e.pos();return e.matchOp("-")?Re(e,"negativeNumber",t,tt(e),n=>-v(n)):Ut(e)}function Ut(e){let t=zt(e);return t?O(e,t):e.err("Unexpected value: "+e.cur().value)}function ne(e){if(e.stat)return e.stat();throw new Error("This expression cannot be evaluated statically: "+e.type)}function Wt(e){let t=e.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(t)return{operator:t.value,right:!0,isType:!1};let n=(a,l=!0,u=!1)=>({operator:a,right:l,isType:u}),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 ":"",c=(a,l)=>e.match(a)??(i&&a!=="match"&&a!=="contain"?void 0:e.match(l));if(c("match","matches"))return n(s+"match");if(c("contain","contains"))return n(s+"contain");if(i&&e.match("exist"))return n("not exist",!1);if(c("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(c("precede","precedes"))return n(s+"precede");if(c("follow","follows"))return n(s+"follow");i&&e.expected("matches","contains","starts with","ends with","precede","follow")}function Je(e){let t=Pe(e),n=Wt(e);if(!n)return t;let{operator:r}=n,o,i=!0,s,c;n.isType?(o=e.reqType("IDENTIFIER").value,i=!e.matchOp("!")):n.right&&(s=Pe(e),r.endsWith("match")&&(c=s.css));let a;r.endsWith("between")&&(e.req("and"),a=Pe(e));let l=!1;e.match("ignoring")&&(e.req("case"),l=!0);let u=d=>l&&typeof d=="string"?d.toLowerCase():d,p=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:d=>S([t.ev(d),c??s?.ev(d),a?.ev(d)],([y,I,j])=>{if(o){let F=He(y,o,i);return r==="a"?F:!F}if(p&&I===void 0&&(r==="is"||r==="is not")){let F=!!Z(y,p);return r==="is"?F:!F}return nt(r,u(y),u(I),j)})}}function Ke(e,t){let n=g(e,"contains")??g(e,"includes");if(!L(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,e,[t])}function Gt(e,t){let n=g(e,"match")??g(e,"matches");if(!L(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,e,[t])}var Xe=(e,t,n)=>e instanceof Node&&t instanceof Node&&(e.compareDocumentPosition(t)&n)!==0;function nt(e,t,n,r){if(e==="not between")return v(t)<v(n)||v(t)>v(r);if(e.startsWith("not "))return!nt(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 v(t)<v(n);case">":return v(t)>v(n);case"<=":return v(t)<=v(n);case">=":return v(t)>=v(n);case"match":return t!=null&&Gt(t,n);case"in":return n!=null&&Ke(n,t);case"contain":case"include":return t!=null&&Ke(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 v(t)>=v(n)&&v(t)<=v(r);case"precede":return Xe(t,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return Xe(t,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return be(t);case"exist":return je(t)}throw new Error("Unknown comparison : "+e)}function zt(e){let t=e.cur();switch(t.type){case"NUMBER":return e.consume(),Ne("number",parseFloat(t.value),t);case"STRING":return Vt(e);case"ID_REF":return Kt(e);case"CLASS_REF":return Xt(e);case"ATTRIBUTE_REF":return Ie(e);case"STYLE_REF":return it(e)}if(t.op){if(t.value==="(")return Bt(e);if(t.value==="[")return Yt(e);if(t.value==="{")return Zt(e);if(t.value==="<")return en(e)}let n=e.match("true")??e.match("false");if(n)return Ne("boolean",n.value==="true",n);let r=e.match("null");if(r)return Ne("null",null,r);for(let o of e.g.leaves){let i=o(e);if(i)return i}return Jt(e)}function Ne(e,t,n){return{type:e,value:t,start:n.start,end:n.end,ev:()=>t,stat:()=>t}}function Bt(e){let t=e.pos();e.consume();let n=e.withoutFollows(()=>x(e));return e.reqOp(")"),{type:"parenthesized",expr:n,start:t,end:e.endPos(),ev:r=>n.ev(r)}}var Qt=(e,t)=>S(e.map(n=>typeof n=="string"?n:n.ev(t)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function rt(e,t){let n=e.child(te(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,x(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 Vt(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=rt(e,n);r.ev=i=>Qt(o,i)}else r.stat=()=>n;return r}function Yt(e){let t=e.pos();e.consume();let n=[];if(!e.matchOp("]")){do n.push(x(e));while(e.matchOp(","));e.reqOp("]")}return{type:"arrayLiteral",values:n,start:t,end:e.endPos(),ev:r=>S(n.map(o=>o.ev(r)),o=>o)}}function Zt(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(x(e)),e.reqOp("]");else{let s="";for(let c=e.matchType("IDENTIFIER")??e.matchOp("-");c;c=e.matchType("IDENTIFIER")??e.matchOp("-"))s+=c.value;n.push(s)}e.reqOp(":"),r.push(x(e))}while(e.matchOp(",")&&!o());e.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:t,end:e.endPos(),ev:i=>S([...n.map(s=>typeof s=="string"?s:s.ev(i)),...r.map(s=>s.ev(i))],s=>Object.fromEntries(n.map((c,a)=>[String(s[a]),s[n.length+a]])))}}function ot(e){return e.matchType("STRING")?.value??e.consumeUntil(void 0,"WHITESPACE").map(t=>t.value).join("")}function Jt(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"],()=>x(e))),{type:"symbol",name:s,scope:a,...l?{on:l}:{},start:t,end:e.endPos(),ev:u=>ze(s,u,a,l?.ev(u)),lhs:()=>{},put:(u,p,m)=>Be(s,u,a,m,l?.ev(u))}}var st=(e,t)=>{let n=t.value.substring(2);return x(e.child(te(n),n))};function Kt(e){let t=e.consume(),n=(o,i)=>ve(o.me).getElementById(String(i)),r={type:"idRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(o,i,s)=>E(r.ev(o),c=>c&&X(c,s))};if(t.template){let o=r.expr=st(e,t);r.ev=i=>E(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 Xt(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)=>E(n.ev(r),s=>X(Array.from(s instanceof A?s:[]),i))};if(t.template){let r=n.expr=st(e,t);n.ev=o=>E(r.ev(o),i=>new A("."+i,o.me,!0))}else{let r=n.css=t.value;n.className=r.slice(1),n.ev=o=>new A(r,o.me,!0)}return n}var Oe=class extends A{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>k(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(k);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 en(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 A(n,o.me),lhs:()=>{},put:(o,i,s)=>E(r.ev(o),c=>X(Array.from(c instanceof A?c:[]),s))};if(/\$[^=]/.test(n)){let o=r.parts=rt(e,n);r.ev=i=>S(o.map(s=>typeof s=="string"?s:s.ev(i)),s=>new Oe(i.me,s))}return r}function Ie(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=>J(s.you||s.me,r),lhs:()=>{},put:(s,c,a)=>K(s.you||s.me,r,a)}}function it(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?le:ce)(o.you||o.me,r),lhs:()=>{},put:(o,i,s)=>fe(o.you||o.me,r,s)}}function at(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 ut(e,t="Expected event name"){return e.matchType("STRING")?.value??at(e)??e.err(t)}function O(e,t){return nn(e,t)??rn(e,t)??cn(e,t)??on(e,t)??sn(e,t)??an(e,t)??un(e,t)??fn(e,t)??tn(e,t)??t}function tn(e,t){for(let n of e.g.indirects){let r=n(e,t);if(r)return r}}function nn(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=>E(o.root.ev(i),s=>Z(s,n)),lhs:i=>o.root.ev(i),put:(i,s,c)=>{R(s,r),de(s,n,c)},del:(i,s)=>{R(s,r),P(s,c=>{C(c)&&delete c[n],w.wroteProperty(c)})}};return O(e,o)}function rn(e,t){if(!e.match("of"))return;let n=D(e),r,o=t;for(;o.root;)r=o,o=o.root;let s={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],c=o.name;if(!s||c===void 0)return e.err("Cannot take a property of a non-symbol: "+o.type);let a=e.text(n),l={property:Z,attribute:J,style:ce,computed:le}[s],u={type:"ofExpression",root:n,name:c,kind:s,start:t.start,end:e.endPos(),ev:p=>E(u.root.ev(p),m=>l(m,c)),lhs:p=>u.root.ev(p),put:(p,m,d)=>{R(m,a),s==="attribute"?K(m,c,d):s==="property"?de(m,c,d):fe(m,c,d)},del:(p,m)=>{R(m,a),P(m,d=>{s==="attribute"?k(d)&&d.removeAttribute(c):s==="property"?(C(d)&&delete d[c],w.wroteProperty(d)):d instanceof HTMLElement&&d.style.removeProperty(c)})}};return r?(r.root=u,O(e,t)):O(e,u)}function on(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=Ie(e)??it(e),i=o?void 0:e.reqType("IDENTIFIER").value,s=e.text(t),c=l=>i!==void 0?Z(l,i):o?.type==="attributeRef"?J(l,o.name):o?.type==="computedStyleRef"?le(l,o.name):o&&ce(l,o.name),a={type:"possessive",root:t,prop:i,attribute:o,start:t.start,end:e.endPos(),ev:l=>E(a.root.ev(l),c),lhs:l=>a.root.ev(l),put:(l,u,p)=>{R(u,s),i!==void 0?de(u,i,p):o?.type==="attributeRef"?K(u,o.name,p):o&&fe(u,o.name,p)}};return O(e,a)}function sn(e,t){if(!e.match("in"))return;let n=D(e),r=(s,c)=>{if(s==null)return[];let a=[],l=g(s,"css");if(typeof l=="string")P(c,u=>k(u)&&a.push(...we(u,l)));else if(k(s)){let u=!1;if(P(c,p=>{p instanceof Node&&p.contains(s)&&(u=!0)}),u)return s}else P(s,u=>P(c,p=>u===p&&a.push(u)));return a},o={type:"inExpression",root:t,target:n,start:t.start,end:e.endPos(),ev:s=>S([o.root.ev(s),n.ev(s)],([c,a])=>r(c,a)),lhs:s=>o.ev(s),put:(s,c,a)=>X(c,a)},i;if(e.peek("where"))for(let s of e.g.collections)i??=s(e,o);return O(e,i??o)}function an(e,t){if(!e.match("as"))return;e.match("a")||e.match("an");let n=o=>{let i=at(e)??e.err("Expected dotOrColonPath"),s={type:"asExpression",root:o,conversion:i,start:o.start,end:e.endPos(),ev:c=>E(s.root.ev(c),a=>$e(a,i))};return s},r=n(t);for(;e.matchOp("|");)r=n(r);return O(e,r)}function un(e,t){if(!e.matchOp("("))return;let n=[];if(!e.matchOp(")")){do n.push(x(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 c=i.root,a=c.prop,l=a===void 0?void 0:c.root;return S([(l??c).ev(s),...n.map(u=>u.ev(s))],([u,...p])=>{if(!l||a===void 0)return et(u,void 0,p,s,r);R(u,o);let m=et(g(u,a),u,p,s,r);return Me(u,a),m})}};return O(e,i)}function et(e,t,n,r,o){if(!L(e))throw R(e,o),new Error(`'${o}' is not a function`);return g(e,"hyperfunc")&&n.push(r),Reflect.apply(e,t,n)}function cn(e,t){let n=Ie(e);return n&&ln(e,t,n)}function ln(e,t,n){let r=e.text(t),o={type:"attributeRefAccess",root:t,attribute:n,start:t.start,end:e.endPos(),ev:i=>E(o.root.ev(i),s=>J(s,n.name)),lhs:i=>o.root.ev(i),put:(i,s,c)=>{R(s,r),K(s,n.name,c)}};return o}function fn(e,t){if(!e.matchOp("["))return;let n=!!e.matchOp(".."),r=x(e),o=!1,i;!n&&e.matchOp("..")&&(o=!0,e.cur().op&&e.cur().value==="]"||(i=x(e))),e.reqOp("]");let s=e.text(t),c=(u,p)=>v(p)<0?v(g(u,"length"))+v(p):v(p),a=(u,p,m)=>{let d=g(u,"slice");return L(d)?Reflect.apply(d,u,[p,m]):void 0},l={type:"arrayIndex",root:t,first:r,second:i,andBefore:n,andAfter:o,start:t.start,end:e.endPos(),ev:u=>S([l.root.ev(u),r.ev(u),i?.ev(u)],([p,m,d])=>p==null?null:n?a(p,0,c(p,m)+1):o?d==null?a(p,v(m)):a(p,v(m),c(p,d)+1):g(p,String(m))),lhs:u=>S([l.root.ev(u),r.ev(u)],p=>p),put:(u,p,m)=>{let[d,y]=Array.isArray(p)?p:[];R(d,s),C(d)&&(d[String(y)]=m)},del:(u,p)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[m,d]=Array.isArray(p)?p:[];R(m,s),Array.isArray(m)?m.splice(c(m,d),1):C(m)&&delete m[String(d)],w.wroteProperty(m)}};return O(e,l)}var M=class extends Error{constructor(n,r,o,i){super(n);this.token=r;this.source=o;this.expected=i}written},ct=()=>({commands:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),me=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 M(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 Ce(e){let t=e.source.split(`
|
|
1
|
+
"use strict";(()=>{var G=e=>typeof e=="object"&&e!==null&&"then"in e&&typeof e.then=="function",E=(e,t)=>G(e)?e.then(t):t(e),S=(e,t)=>e.some(G)?Promise.all(e).then(t):t(e),C=e=>e!=null,L=e=>typeof e=="function",g=(e,t)=>C(e)?e[t]:void 0,z=(e,t,n)=>{C(e)&&(e[t]=n)},k=e=>e instanceof Element,B=e=>L(g(e,"addEventListener"));var v=e=>e;var ie={attributes:"_, script, data-script",defaultTransition:"all 500ms ease-in",disableSelector:"[disable-scripting], [data-disable-scripting]",hideShowStrategies:{},fetchThrowsOn:[/^4/,/^5/]},ye=Object.assign(Object.create(null),{String:e=>String(e),Int:e=>parseInt(String(e)),Float:e=>parseFloat(String(e)),Number:e=>Number(e),Fragment:e=>Qe(e)}),ve=[],Y={process(e){},enter(e){}},je=new WeakMap;function we(e){if(e.window!==e)return e;let t=je.get(e);return t||je.set(e,t={}),t}var D=e=>we(e)._hyperscript;function Ue(e){let t=we(e),n=t._hyperscript!==void 0;return delete t._hyperscript,n}function U(e){return we(e)._hyperscript??={}}var w={tracking:!1,readGlobal(e){},readElement(e,t){},readProperty(e,t){},readAttribute(e,t){},readQuery(e){},wroteGlobal(e){},wroteElement(e,t){},wroteProperty(e){},stop(e){}},se=e=>(w.tracking&&typeof e=="object"&&e!==null&&w.readProperty(e,"__mutation__"),e),jt={Array:["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin"],Set:["add","delete","clear"],Map:["set","delete","clear"]};function We(e,t){let n=g(g(e,"constructor"),"name");typeof n=="string"&&jt[n]?.includes(t)&&w.wroteProperty(e)}var Ee=e=>{if(e instanceof Node){let t=e.getRootNode();if(t instanceof Document||t instanceof ShadowRoot)return t}return document},$t=e=>e.replace(/[:&()[\]/]/g,t=>"\\"+t);function xe(e,t){return w.tracking&&w.readQuery(e),e.querySelectorAll(t)}var A=class{constructor(t,n,r=!1){this.raw=t;this.relativeTo=n;this.escape=r}get css(){return this.escape?$t(this.raw):this.raw}get className(){return this.raw.slice(1)}get length(){return this.select().length}contains(t){for(let n of this)if(n.contains(t))return!0;return!1}select(){return xe(Ee(this.relativeTo),this.css)}[Symbol.iterator](){return this.select()[Symbol.iterator]()}},be=e=>e instanceof A||Array.isArray(e)||e instanceof NodeList||e instanceof HTMLCollection||e instanceof FileList;function P(e,t){if(be(e))for(let n of e)t(n);else t(e)}var ue=(e,t)=>{if(e==null)return;let n=t(e);if(n!==void 0)return n;if(be(e))return Array.from(e,t)},J=(e,t)=>(w.tracking&&w.readProperty(e,t),ue(e,n=>g(n,t))),Z=(e,t)=>(w.tracking&&w.readAttribute(e,t),ue(e,n=>k(n)?n.getAttribute(t):void 0)),ae=(e,t)=>ue(e,n=>g(g(n,"style"),t)),ce=(e,t)=>ue(e,n=>k(n)?getComputedStyle(n).getPropertyValue(t):void 0),X=(e,t,n)=>P(e,r=>{k(r)&&(n==null?r.removeAttribute(t):r.setAttribute(t,String(n)))}),le=(e,t,n)=>P(e,r=>z(g(r,"style"),t,n)),fe=(e,t,n)=>P(e,r=>{z(r,t,n),w.wroteProperty(r)});function R(e,t){if(e==null)throw new Error(`'${t}' is null`)}var ke=e=>e==null||g(e,"length")===0;function Ge(e){if(e==null)return!1;if(be(e)){for(let t of e)return!0;return!1}return!0}function ze(e,t,n){if(e==null&&n||Object.prototype.toString.call(e).slice(8,-1)===t)return!0;let r=g(globalThis,t);return L(r)&&e instanceof r}function Be(e,t){for(let r of ve){let o=r(t,e);if(o!==void 0)return o}if(e==null)return null;let n=ye[t];if(n)return n(e);throw new Error("Unknown conversion : "+t)}function Qe(e){let t=document.createDocumentFragment();return e==null?t.append("null"):P(e,n=>{if(n instanceof Node)t.append(n);else{let r=document.createElement("template");r.innerHTML=n===null?"":String(n),t.append(r.content)}}),t}function K(e,t){P(e,n=>{if(!k(n))return;let r=n.parentElement;n.replaceWith(t instanceof Node?t.cloneNode(!0):Qe(t)),r&&Y.process(r)})}function N(e,t,n={},r){if(!B(e))return!0;n.sender=r;let o=Object.assign(new Event(t,{bubbles:!0,cancelable:!0,composed:!0}),{detail:n});return e.dispatchEvent(o)}var Ve=(e,t="elementScope")=>(U(e).scopes??={})[t]??={},Ut=Object.create(null,{selection:{get:()=>getSelection()?.toString(),enumerable:!0},clipboard:{get:()=>navigator.clipboard.readText(),set:e=>void navigator.clipboard.writeText(String(e))}});function ee(e,t,n,r){let o=g(r,"detail"),i=Object.create(Ut);for(let s=k(e)?e:null;s;s=s.parentElement)Object.assign(i,D(s)?.features);return{meta:{owner:e,feature:t},locals:i,me:n,you:void 0,result:void 0,beingTested:null,event:r,target:g(r,"target")??null,detail:o??null,sender:g(o,"sender")??null,body:typeof document>"u"?null:document.body}}var ge=["meta","it","result","locals","event","target","detail","sender","body"],Q=e=>{let t=e.meta.owner,n=e.meta.feature?.behavior;return C(t)?Ve(t,n?n+"Scope":void 0):{}};function Ye(e,t,n){let r=k(n)?n:k(t.meta.owner)?t.meta.owner:null;for(;r;){let o=D(r)?.scopes?.elementScope;if(o&&e in o)return{value:o[e],element:r};let i=r.getAttribute("dom-scope");if(i==="isolated")break;let s=i?.match(/^closest\s+(.+)/),a=i?.match(/^parent\s+of\s+(.+)/);s?r=r.parentElement?.closest(s[1])??null:a?r=r.closest(a[1])?.parentElement??null:r=r.parentElement}return{value:void 0,element:null}}function Je(e,t,n,r){if(e==="me"||e==="my"||e==="I")return t.me;if(e==="it"||e==="its")return t.beingTested??t.result;if(e==="result")return t.result;if(e==="you"||e==="your"||e==="yourself")return t.you;let o=t.meta.owner,i=()=>(w.tracking&&w.readGlobal(e),se(g(globalThis,e)));if(n==="global")return i();if(n==="element")return w.tracking&&w.readElement(e,o),se(Q(t)[e]);if(n==="inherited"){let l=Ye(e,t,r);return w.tracking&&w.readElement(e,l.element??(k(r)?r:o)),se(l.value)}let s=t.meta.context;if(s!=null){let l=g(s,e);if(l!==void 0)return l;let c=g(g(s,"detail"),e);if(c!==void 0)return c}let a=ge.includes(e)?g(t,e):t.locals[e];if(a!==void 0)return a;let u=Q(t)[e];return u!==void 0?(w.tracking&&w.readElement(e,o),se(u)):i()}function Ze(e,t,n,r,o){if(n==="global")z(globalThis,e,r),w.wroteGlobal(e);else if(n==="element")Q(t)[e]=r,w.wroteElement(e,t.meta.owner);else if(n==="inherited"){let s=Ye(e,t,o).element??(k(o)?o:t.meta.owner);C(s)&&(Ve(s)[e]=r),w.wroteElement(e,s)}else!ge.includes(e)&&t.locals[e]!==void 0?t.locals[e]=r:Q(t)[e]!==void 0?(Q(t)[e]=r,w.wroteElement(e,t.meta.owner)):ge.includes(e)?z(t,e,r):t.locals[e]=r}function $(e,t,n=0){for(let r=n;r<e.length;r++){let o=e[r].run(t);if(G(o))return o.then(i=>i||$(e,t,r+1));if(o)return o}}function V(e,t){try{let n=e();return G(n)?n.then(void 0,t):n}catch(n){return t(n)}}function Xe(e,t,n){let{errorSymbol:r,errorHandler:o,finallyHandler:i}=n,s=()=>V(()=>E($(t,e),u=>{let l=g(u,"k");if(l==="break"||l==="continue")throw new Error(`Command \`${l}\` cannot be used outside of a \`repeat\` loop.`);return $e(u)}),u=>{if(!o||!r)throw u;return e.locals[r]=u,$(o,e)});if(!i)return s();let a=()=>V(()=>E($(i,e),()=>{}),u=>console.error(" Exception in finally block: ",u));return V(()=>E(s(),u=>E(a(),()=>$e(u))),u=>E(a(),()=>{throw u}))}var $e=e=>{let t=g(e,"k");if(t==="return")return{k:"return",value:g(e,"value")};if(t==="break"||t==="continue")return{k:t}};var Ke=new Set("+ - * / . .. \\ : % | ! ? # & $ ; , ( ) < > <= >= == === != !== { } [ ] = ~ ^".split(" ")),et={b:"\b",f:"\f",n:`
|
|
2
|
+
`,r:"\r",t:" ",v:"\v"},q=e=>e>="a"&&e<="z"||e>="A"&&e<="Z",_=e=>e>="0"&&e<="9",Te=e=>e===" "||e===" "||e==="\r"||e===`
|
|
3
|
+
`,Pe=e=>q(e)||_(e)||e==="-"||e==="_"||e===":",Ne=e=>q(e)||_(e)||e==="_"||e==="$";function te(e,t=!1){let n=[],r=0,o=0,i=1,s="<START>",a=0,u=()=>e.charAt(r),l=f=>e.charAt(r+f),c=()=>(s=e.charAt(r++),s===`
|
|
4
|
+
`?(i++,o=0):o++,s),p=f=>({type:f,value:"",start:r,end:r+1,line:i,column:o}),m=(f,h)=>(f.value=h,f.end=r,f),d=f=>{let h="";for(;u()&&f(u());)h+=c();return h},y=()=>t&&a===0,I=()=>q(s)||_(s)||")\"'`}]".includes(s),j=(f,h)=>{let x=p(f),T=c();if(u()==="{"){if(x.template=!0,T+=c(),T+=d(Ht=>Ht!=="}"),u()!=="}")throw new Error("Unterminated "+(h?"class":"id")+" reference");let oe=c();h&&(T+=oe)}else if(h)for(;Pe(u())||u()==="\\";)u()==="\\"&&c(),T+=c();else T+=d(Pe);return m(x,T)},F=()=>{let f=p("STRING"),h=c();f.template=h==="`";let x="";for(;u()&&u()!==h;)if(u()==="\\"){c();let T=c();if(T in et)x+=et[T];else if(f.template&&T==="$")x+="\\$";else if(T==="x"){let oe=u()&&l(1)?parseInt(c()+c(),16):NaN;if(Number.isNaN(oe))throw new Error(`Invalid hexadecimal escape at [Line: ${f.line}, Column: ${f.column}]`);x+=String.fromCharCode(oe)}else x+=T}else x+=c();if(u()!==h)throw new Error(`Unterminated string at [Line: ${f.line}, Column: ${f.column}]`);return c(),m(f,x)},Me=()=>{let f=p("IDENTIFIER"),h=c()+d(Ne);return u()==="!"&&h==="beep"&&(h+=c()),m(f,h)},qt=()=>{let f=p("IDENTIFIER"),h=c(),x=h==="\\";for(x&&(h="");(Ne(u())||"\\{}".includes(u()||" "))&&!(u()==="$"&&!x);)u()==="\\"?(x=!0,c()):(x=!1,h+=c());return m(f,h)},_t=()=>{let f=p("NUMBER"),h=c()+d(_);return u()==="."&&_(l(1))&&(h+=c()),h+=d(_),(u()==="e"||u()==="E")&&(_(l(1))?h+=c():l(1)==="-"&&(h+=c()+c())),m(f,h+d(_))},He=()=>{let f=p("OP");f.op=!0;let h=c();for(;u()&&Ke.has(h+u());)h+=c();return m(f,h)},Lt=()=>{let f=p("ATTRIBUTE_REF"),h=c();return h==="["?(h+=d(x=>x!=="]"),u()==="]"&&(h+=c())):(h+=d(Pe),u()==="="&&(h+=c(),u()==='"'||u()==="'"?h+=F().value:Ne(u())&&(h+=Me().value))),m(f,h)},Dt=()=>{let f=n.at(-1);return f?f.type==="IDENTIFIER"||f.type==="CLASS_REF"||f.type==="ID_REF"?!1:!(f.op&&(f.value===">"||f.value===")")):!0},Mt=()=>{let f=u(),h=l(2);return(f==="-"||f==="/")&&l(1)===f&&(Te(h)||h===""||h===f)};for(;r<e.length;){let f=u(),h=l(1);if(Mt())d(x=>x!=="\r"&&x!==`
|
|
5
|
+
`),c();else if(Te(f))n.push(m(p("WHITESPACE"),d(Te)));else if(!I()&&f==="."&&(q(h)||h==="{"||h==="-"))n.push(j("CLASS_REF",!0));else if(!I()&&f==="#"&&(q(h)||h==="{"))n.push(j("ID_REF",!1));else if(f==="@"||f==="["&&h==="@")n.push(Lt());else if(f==="*"&&q(h)){let x=p("STYLE_REF");n.push(m(x,c()+d(T=>q(T)||T==="-")))}else if(y()&&(q(f)||f==="\\"))n.push(qt());else if(!y()&&(q(f)||f==="_"||f==="$"))n.push(Me());else if(_(f))n.push(_t());else if(!y()&&(f==='"'||f==="`"))n.push(F());else if(!y()&&f==="'")n.push(Dt()?F():He());else if(Ke.has(f))s==="$"&&f==="{"&&a++,f==="}"&&a--,n.push(He());else if(y()||f==="`"){let x=p("RESERVED");n.push(m(x,c()))}else throw new Error("Unknown token: "+f+" ")}return n}function b(e){return e.match("the"),Wt(e)}function Wt(e){let t=nt(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=Gt(o.value,t,nt(e));return t}function Gt(e,t,n){let r=e==="or";return{type:"logicalOperator",operator:e,left:t,right:n,start:t.start,end:n.end,ev:o=>E(t.ev(o),i=>!!i===r?i:n.ev(o))}}var zt={"+":(e,t)=>Array.isArray(e)?e.concat(t):v(e)+v(t),"-":(e,t)=>v(e)-v(t),"*":(e,t)=>v(e)*v(t),"/":(e,t)=>v(e)/v(t),mod:(e,t)=>v(e)%v(t)};function Se(e){let t=Oe(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=Oe(e),a=zt[o.value];t={type:"mathOperator",operator:o.value,left:i,right:s,start:i.start,end:s.end,ev:l=>S([i.ev(l),s.ev(l)],([c,p])=>a(c,p))}}return t}function Oe(e){let t=M(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 M(e){e.match("the");let t=e.pos();if(e.match("not"))return Ie(e,"logicalNot",t,M(e),n=>!n);if(e.match("no"))return Ie(e,"noExpression",t,Oe(e),ke);for(let n of e.g.unaries){let r=n(e);if(r)return O(e,r)}return Qt(e)}function Ie(e,t,n,r,o,i=t!=="negativeNumber"){let s={type:t,root:r,start:n,end:e.endPos(),ev:a=>E(r.ev(a),u=>o(u,a))};return i?O(e,s):s}var Bt="em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q pc pt px".split(" ");function Qt(e){let t=it(e),n=e.matchAny(...Bt)??e.matchOp("%");if(n)return tt(e,"stringPostfixExpression",t,n.value);let r=e.matchAny("s","seconds")?1e3:e.matchAny("ms","milliseconds")?1:0;if(r)return tt(e,"timeExpression",t,r);for(let o of e.g.postfixes){let i=o(e,t);if(i)return i}return t}function tt(e,t,n,r){let o=s=>typeof r=="number"?v(s)*r:`${s}${r}`,i={type:t,root:n,suffix:r,start:n.start,end:e.endPos(),ev:s=>E(n.ev(s),o)};return n.stat&&(i.stat=()=>o(ne(n))),i}function it(e){let t=e.pos();return e.matchOp("-")?Ie(e,"negativeNumber",t,it(e),n=>-v(n)):Vt(e)}function Vt(e){let t=Zt(e);return t?O(e,t):e.err("Unexpected value: "+e.cur().value)}function ne(e){if(e.stat)return e.stat();throw new Error("This expression cannot be evaluated statically: "+e.type)}function Yt(e){let t=e.matchAnyOp("<",">","<=",">=","==","===","!=","!==");if(t)return{operator:t.value,right:!0,isType:!1};let n=(u,l=!0,c=!1)=>({operator:u,right:l,isType:c}),r=()=>e.match("equal")&&e.match("to"),o=(u,l)=>(e.req("than"),e.match("or")?(e.req("equal"),e.req("to"),n(l)):n(u));if(e.match("is")||e.match("am")){let u=!!e.match("not"),l=u?"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"):!u&&e.match("less")?o("<","<="):!u&&e.match("greater")?o(">",">="):e.match("really")?(r(),n(u?"!==":"===")):e.match("equal")?(e.match("to"),n(u?"!=":"==")):n(u?"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 ":"",a=(u,l)=>e.match(u)??(i&&u!=="match"&&u!=="contain"?void 0:e.match(l));if(a("match","matches"))return n(s+"match");if(a("contain","contains"))return n(s+"contain");if(i&&e.match("exist"))return n("not exist",!1);if(a("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(a("precede","precedes"))return n(s+"precede");if(a("follow","follows"))return n(s+"follow");i&&e.expected("matches","contains","starts with","ends with","precede","follow")}function nt(e){let t=Se(e),n=Yt(e);if(!n)return t;let{operator:r}=n,o,i=!0,s,a;n.isType?(o=e.reqType("IDENTIFIER").value,i=!e.matchOp("!")):n.right&&(s=Se(e),r.endsWith("match")&&(a=s.css));let u;r.endsWith("between")&&(e.req("and"),u=Se(e));let l=!1;e.match("ignoring")&&(e.req("case"),l=!0);let c=d=>l&&typeof d=="string"?d.toLowerCase():d,p=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:u,typeName:o,ignoringCase:l,start:t.start,end:e.endPos(),ev:d=>S([t.ev(d),a??s?.ev(d),u?.ev(d)],([y,I,j])=>{if(o){let F=ze(y,o,i);return r==="a"?F:!F}if(p&&I===void 0&&(r==="is"||r==="is not")){let F=!!J(y,p);return r==="is"?F:!F}return ut(r,c(y),c(I),j)})}}function rt(e,t){let n=g(e,"contains")??g(e,"includes");if(!L(n))throw new Error("The value does not have a contains or includes method on it");return!!Reflect.apply(n,e,[t])}function Jt(e,t){let n=g(e,"match")??g(e,"matches");if(!L(n))throw new Error("The value does not have a match or matches method on it");return!!Reflect.apply(n,e,[t])}var ot=(e,t,n)=>e instanceof Node&&t instanceof Node&&(e.compareDocumentPosition(t)&n)!==0;function ut(e,t,n,r){if(e==="not between")return v(t)<v(n)||v(t)>v(r);if(e.startsWith("not "))return!ut(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 v(t)<v(n);case">":return v(t)>v(n);case"<=":return v(t)<=v(n);case">=":return v(t)>=v(n);case"match":return t!=null&&Jt(t,n);case"in":return n!=null&&rt(n,t);case"contain":case"include":return t!=null&&rt(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 v(t)>=v(n)&&v(t)<=v(r);case"precede":return ot(t,n,Node.DOCUMENT_POSITION_FOLLOWING);case"follow":return ot(t,n,Node.DOCUMENT_POSITION_PRECEDING);case"empty":return ke(t);case"exist":return Ge(t)}throw new Error("Unknown comparison : "+e)}function Zt(e){let t=e.cur();switch(t.type){case"NUMBER":return e.consume(),Re("number",parseFloat(t.value),t);case"STRING":return en(e);case"ID_REF":return on(e);case"CLASS_REF":return sn(e);case"ATTRIBUTE_REF":return Ae(e);case"STYLE_REF":return ft(e)}if(t.op){if(t.value==="(")return Xt(e);if(t.value==="[")return tn(e);if(t.value==="{")return nn(e);if(t.value==="<")return un(e)}let n=e.match("true")??e.match("false");if(n)return Re("boolean",n.value==="true",n);let r=e.match("null");if(r)return Re("null",null,r);for(let o of e.g.leaves){let i=o(e);if(i)return i}return rn(e)}function Re(e,t,n){return{type:e,value:t,start:n.start,end:n.end,ev:()=>t,stat:()=>t}}function Xt(e){let t=e.pos();e.consume();let n=e.withoutFollows(()=>b(e));return e.reqOp(")"),{type:"parenthesized",expr:n,start:t,end:e.endPos(),ev:r=>n.ev(r)}}var Kt=(e,t)=>S(e.map(n=>typeof n=="string"?n:n.ev(t)),n=>n.map(r=>r===void 0?"":`${r}`).join(""));function at(e,t){let n=e.child(te(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,b(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 en(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=at(e,n);r.ev=i=>Kt(o,i)}else r.stat=()=>n;return r}function tn(e){let t=e.pos();e.consume();let n=[];if(!e.matchOp("]")){do n.push(b(e));while(e.matchOp(","));e.reqOp("]")}return{type:"arrayLiteral",values:n,start:t,end:e.endPos(),ev:r=>S(n.map(o=>o.ev(r)),o=>o)}}function nn(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(b(e)),e.reqOp("]");else{let s="";for(let a=e.matchType("IDENTIFIER")??e.matchOp("-");a;a=e.matchType("IDENTIFIER")??e.matchOp("-"))s+=a.value;n.push(s)}e.reqOp(":"),r.push(b(e))}while(e.matchOp(",")&&!o());e.reqOp("}")}return{type:"objectLiteral",keys:n,values:r,start:t,end:e.endPos(),ev:i=>S([...n.map(s=>typeof s=="string"?s:s.ev(i)),...r.map(s=>s.ev(i))],s=>Object.fromEntries(n.map((a,u)=>[String(s[u]),s[n.length+u]])))}}function ct(e){return e.matchType("STRING")?.value??e.consumeUntil(void 0,"WHITESPACE").map(t=>t.value).join("")}function rn(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,u=n??{$:"global",":":"element","^":"inherited"}[s[0]]??"local",l;return u==="inherited"&&e.match("on")&&(l=e.withFollow(["to","into","before","after","then"],()=>b(e))),{type:"symbol",name:s,scope:u,...l?{on:l}:{},start:t,end:e.endPos(),ev:c=>Je(s,c,u,l?.ev(c)),lhs:()=>{},put:(c,p,m)=>Ze(s,c,u,m,l?.ev(c))}}var lt=(e,t)=>{let n=t.value.substring(2);return b(e.child(te(n),n))};function on(e){let t=e.consume(),n=(o,i)=>Ee(o.me).getElementById(String(i)),r={type:"idRef",start:t.start,end:t.end,ev:()=>null,lhs:()=>{},put:(o,i,s)=>E(r.ev(o),a=>a&&K(a,s))};if(t.template){let o=r.expr=lt(e,t);r.ev=i=>E(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 sn(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)=>E(n.ev(r),s=>K(Array.from(s instanceof A?s:[]),i))};if(t.template){let r=n.expr=lt(e,t);n.ev=o=>E(r.ev(o),i=>new A("."+i,o.me,!0))}else{let r=n.css=t.value;n.className=r.slice(1),n.ev=o=>new A(r,o.me,!0)}return n}var Ce=class extends A{constructor(n,r){super("",n);this.parts=r}get css(){let n=0;return this.parts.map(r=>k(r)?`[data-hs-query-id='${n++}']`:`${r??""}`).join("")}select(){let n=this.parts.filter(k);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 un(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 A(n,o.me),lhs:()=>{},put:(o,i,s)=>E(r.ev(o),a=>K(Array.from(a instanceof A?a:[]),s))};if(/\$[^=]/.test(n)){let o=r.parts=at(e,n);r.ev=i=>S(o.map(s=>typeof s=="string"?s:s.ev(i)),s=>new Ce(i.me,s))}return r}function Ae(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=>Z(s.you||s.me,r),lhs:()=>{},put:(s,a,u)=>X(s.you||s.me,r,u)}}function ft(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?ce:ae)(o.you||o.me,r),lhs:()=>{},put:(o,i,s)=>le(o.you||o.me,r,s)}}function dt(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 mt(e,t="Expected event name"){return e.matchType("STRING")?.value??dt(e)??e.err(t)}function O(e,t){return cn(e,t)??ln(e,t)??hn(e,t)??fn(e,t)??dn(e,t)??mn(e,t)??pn(e,t)??yn(e,t)??an(e,t)??t}function an(e,t){for(let n of e.g.indirects){let r=n(e,t);if(r)return r}}function cn(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=>E(o.root.ev(i),s=>J(s,n)),lhs:i=>o.root.ev(i),put:(i,s,a)=>{R(s,r),fe(s,n,a)},del:(i,s)=>{R(s,r),P(s,a=>{C(a)&&delete a[n],w.wroteProperty(a)})}};return O(e,o)}function ln(e,t){if(!e.match("of"))return;let n=M(e),r,o=t;for(;o.root;)r=o,o=o.root;let s={symbol:"property",attributeRef:"attribute",styleRef:"style",computedStyleRef:"computed"}[o.type],a=o.name;if(!s||a===void 0)return e.err("Cannot take a property of a non-symbol: "+o.type);let u=e.text(n),l={property:J,attribute:Z,style:ae,computed:ce}[s],c={type:"ofExpression",root:n,name:a,kind:s,start:t.start,end:e.endPos(),ev:p=>E(c.root.ev(p),m=>l(m,a)),lhs:p=>c.root.ev(p),put:(p,m,d)=>{R(m,u),s==="attribute"?X(m,a,d):s==="property"?fe(m,a,d):le(m,a,d)},del:(p,m)=>{R(m,u),P(m,d=>{s==="attribute"?k(d)&&d.removeAttribute(a):s==="property"?(C(d)&&delete d[a],w.wroteProperty(d)):d instanceof HTMLElement&&d.style.removeProperty(a)})}};return r?(r.root=c,O(e,t)):O(e,c)}function fn(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=Ae(e)??ft(e),i=o?void 0:e.reqType("IDENTIFIER").value,s=e.text(t),a=l=>i!==void 0?J(l,i):o?.type==="attributeRef"?Z(l,o.name):o?.type==="computedStyleRef"?ce(l,o.name):o&&ae(l,o.name),u={type:"possessive",root:t,prop:i,attribute:o,start:t.start,end:e.endPos(),ev:l=>E(u.root.ev(l),a),lhs:l=>u.root.ev(l),put:(l,c,p)=>{R(c,s),i!==void 0?fe(c,i,p):o?.type==="attributeRef"?X(c,o.name,p):o&&le(c,o.name,p)}};return O(e,u)}function dn(e,t){if(!e.match("in"))return;let n=M(e),r=(s,a)=>{if(s==null)return[];let u=[],l=g(s,"css");if(typeof l=="string")P(a,c=>k(c)&&u.push(...xe(c,l)));else if(k(s)){let c=!1;if(P(a,p=>{p instanceof Node&&p.contains(s)&&(c=!0)}),c)return s}else P(s,c=>P(a,p=>c===p&&u.push(c)));return u},o={type:"inExpression",root:t,target:n,start:t.start,end:e.endPos(),ev:s=>S([o.root.ev(s),n.ev(s)],([a,u])=>r(a,u)),lhs:s=>o.ev(s),put:(s,a,u)=>K(a,u)},i;if(e.peek("where"))for(let s of e.g.collections)i??=s(e,o);return O(e,i??o)}function mn(e,t){if(!e.match("as"))return;e.match("a")||e.match("an");let n=o=>{let i=dt(e)??e.err("Expected dotOrColonPath"),s={type:"asExpression",root:o,conversion:i,start:o.start,end:e.endPos(),ev:a=>E(s.root.ev(a),u=>Be(u,i))};return s},r=n(t);for(;e.matchOp("|");)r=n(r);return O(e,r)}function pn(e,t){if(!e.matchOp("("))return;let n=[];if(!e.matchOp(")")){do n.push(b(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 a=i.root,u=a.prop,l=u===void 0?void 0:a.root;return S([(l??a).ev(s),...n.map(c=>c.ev(s))],([c,...p])=>{if(!l||u===void 0)return st(c,void 0,p,s,r);R(c,o);let m=st(g(c,u),c,p,s,r);return We(c,u),m})}};return O(e,i)}function st(e,t,n,r,o){if(!L(e))throw R(e,o),new Error(`'${o}' is not a function`);return g(e,"hyperfunc")&&n.push(r),Reflect.apply(e,t,n)}function hn(e,t){let n=Ae(e);return n&&gn(e,t,n)}function gn(e,t,n){let r=e.text(t),o={type:"attributeRefAccess",root:t,attribute:n,start:t.start,end:e.endPos(),ev:i=>E(o.root.ev(i),s=>Z(s,n.name)),lhs:i=>o.root.ev(i),put:(i,s,a)=>{R(s,r),X(s,n.name,a)}};return o}function yn(e,t){if(!e.matchOp("["))return;let n=!!e.matchOp(".."),r=b(e),o=!1,i;!n&&e.matchOp("..")&&(o=!0,e.cur().op&&e.cur().value==="]"||(i=b(e))),e.reqOp("]");let s=e.text(t),a=(c,p)=>v(p)<0?v(g(c,"length"))+v(p):v(p),u=(c,p,m)=>{let d=g(c,"slice");return L(d)?Reflect.apply(d,c,[p,m]):void 0},l={type:"arrayIndex",root:t,first:r,second:i,andBefore:n,andAfter:o,start:t.start,end:e.endPos(),ev:c=>S([l.root.ev(c),r.ev(c),i?.ev(c)],([p,m,d])=>p==null?null:n?u(p,0,a(p,m)+1):o?d==null?u(p,v(m)):u(p,v(m),a(p,d)+1):g(p,String(m))),lhs:c=>S([l.root.ev(c),r.ev(c)],p=>p),put:(c,p,m)=>{let[d,y]=Array.isArray(p)?p:[];R(d,s),C(d)&&(d[String(y)]=m)},del:(c,p)=>{if(n||o)throw new Error("Cannot remove a slice - use a single index");let[m,d]=Array.isArray(p)?p:[];R(m,s),Array.isArray(m)?m.splice(a(m,d),1):C(m)&&delete m[String(d)],w.wroteProperty(m)}};return O(e,l)}var pt=new WeakSet;function ht(e){if(pt.has(e))return;pt.add(e);let t=!1,n=o=>{let i=t;t=!0;try{o()}finally{t=i}};document.addEventListener("htmx:load",o=>n(()=>e.process(o.detail?.elt))),document.addEventListener("htmx:after:process",o=>n(()=>e.process(o.target))),document.addEventListener("fx:swapped",o=>{let i=o.detail?.cfg?.target;e.process(i instanceof Element&&i.isConnected?i.parentElement??i:document.body)});let r=Reflect.get(globalThis,"htmx");typeof r?.process=="function"&&(e.addAfterProcessHook(o=>{t||n(()=>r.process(o))}),r.version?.startsWith("4")&&r.registerExtension?.("hs-include",{htmx_config_request(o,i){let s=i?.ctx;if(!s)return;let a=vn(s.sourceElement||o);if(!a)return;let u=En(a.value,a.scopeElt),l=s.request?.body;if(l instanceof FormData)for(let c in u)l.set(c,u[c])}}))}function vn(e){let t=e.getAttribute("hs-include");if(t!==null)return{value:t,scopeElt:e};for(let n=e.parentElement;n;n=n.parentElement){let r=n.getAttribute("hs-include:inherited");if(r!==null)return{value:r,scopeElt:n}}return null}var me=e=>e&&D(e)?.scopes?.elementScope||{};function de(e){if(e==null)return"";if(typeof e=="object")try{return JSON.stringify(e)}catch{return""}return String(e)}function wn(e,t){for(let n=t;n;n=n.parentElement){let r=me(n);if(e in r)return r[e]}}function En(e,t){let n={},r=e.trim();if(r==="*"){let o=me(t);for(let i of Object.keys(o))n[i[0]===":"?i.slice(1):i]=de(o[i]);return n}for(let o of r.split(","))if(o=o.trim(),!!o){if(o[0]===":"){let i=me(t);o in i&&(n[o.slice(1)]=de(i[o]))}else if(o[0]==="^"){let i=wn(":"+o.slice(1),t);i!==void 0&&(n[o.slice(1)]=de(i))}else if(o[0]==="#"){let i=o.lastIndexOf(":");if(i>0){let s=me(document.querySelector(o.slice(0,i))),a=o.slice(i+1);":"+a in s&&(n[a]=de(s[":"+a]))}}}return n}var H=class extends Error{constructor(n,r,o,i){super(n);this.token=r;this.source=o;this.expected=i}written},gt=()=>({commands:Object.create(null),features:Object.create(null),leaves:[],indirects:[],unaries:[],postfixes:[],collections:[]}),pe=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 H(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 Fe(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+`
|
|
9
|
-
`}function
|
|
9
|
+
`}function yt(e){let t=e.pos();if(e.matchOp("(")){let u=yt(e)??e.err("Expected command");return e.reqOp(")"),u}let n=e.cur(),r=e.g.commands[n.value],o;if(r?o=e.match(n.value)&&r(e,n.value,t):n.type==="IDENTIFIER"&&(o=e.g.pseudo?.(e,t)),!o||!e.match("unless"))return o;let i=o,s=b(e);return{type:"unlessStatementModifier",command:i,condition:s,start:t,end:e.endPos(),run:u=>E(s.ev(u),l=>l?void 0:i.run(u))}}function W(e){let t=[];for(;e.hasMore();){let n=yt(e);if(!n)break;t.push(n),e.match("then")}return t}function vt(e){let t=e.pos();if(e.matchOp("(")){let o=vt(e);return e.reqOp(")"),o}let n=e.cur(),r=e.g.features[n.value];return!r||!e.match(n.value)?e.err("Expected feature"):r(e,t)}function qe(e){let t=e.pos(),n=[];for(;e.hasMore();){let r=e.cur();if(e.featureStart(r)||r.value==="(")n.push(vt(e)),e.match("end");else{if(r.value==="end")break;e.err()}}return{type:"hyperscript",features:n,start:t,end:e.endPos()}}function wt(e){let t={};return e.match("catch")&&(t.errorSymbol=e.reqType("IDENTIFIER").value,t.errorHandler=W(e)),e.match("finally")&&(t.finallyHandler=W(e)),t}function Et(e){let t=[],n=e.tok(1).value,r=e.tok(2).value;if(e.cur().value==="("&&(n===")"||r===","||r===")")){e.matchOp("(");do t.push(e.reqType("IDENTIFIER").value);while(e.matchOp(","));e.reqOp(")")}return t}var kt=gt();function Tt(...e){for(let t of e)t(kt)}var Pt=e=>new pe(kt,te(e),e);function xn(e){let t=Pt(e),n=qe(t);return t.hasMore()&&t.err(),n}function Nt(e){let t=Pt(e),n=t.cur(),r=t.commandStart(n)?{kind:"commands",commands:W(t)}:t.featureStart(n)?{kind:"features",program:qe(t)}:{kind:"expression",expression:b(t)};return t.hasMore()&&t.err(),r}function xt(e,t){let n;try{n=Nt(e)}catch(i){throw i instanceof H?new Error(i.message+`
|
|
10
10
|
|
|
11
|
-
`+
|
|
11
|
+
`+Fe(i)):i}let r=document.body;if(n.kind==="features"){for(let i of n.program.features)i.install(r,r);return}let o=Object.assign(ee(r,void 0,r,null),t);return n.kind==="expression"?n.expression.ev(o):E($(n.commands,o),i=>{let s=g(i,"k")==="return"?g(i,"value"):void 0;return s!==void 0?s:o.result})}var St=()=>ie.attributes.replaceAll(" ","").split(","),Rt=e=>e instanceof HTMLScriptElement&&e.type==="text/hyperscript";function bn(e){for(let t of St())if(e.hasAttribute(t))return e.getAttribute(t);return Rt(e)?e.innerText:null}var kn=e=>{let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return t},Ot=[];function bt(e){if(e.closest(ie.disableSelector))return;let t=bn(e);if(!t)return;let n=kn(t);if(D(e)?.initialized){if(D(e)?.scriptHash===n)return Y.enter(e);he(e)}if(!N(e,"hyperscript:before:init"))return;Object.assign(U(e),{initialized:!0,scriptHash:n});let r=Rt(e)?document.body:e,o=t;try{for(let s of Ot)o=s(o,e)??o;let{features:i}=xn(o);Y.enter(e);for(let s of i)s.install(r,e);e.setAttribute("data-hyperscript-powered","true"),N(e,"hyperscript:after:init"),setTimeout(()=>N(r,"load",{hyperscript:!0}),1)}catch(i){if(i instanceof H){o!==t&&(i.written=t),N(e,"hyperscript:parse-error",{errors:[i]});let s=i.written?`
|
|
12
12
|
rewritten from: ${i.written}
|
|
13
13
|
`:"";console.error("hyperscript: 1 parse error(s) on:",e,`
|
|
14
14
|
|
|
15
|
-
`+
|
|
15
|
+
`+Fe(i)+s)}else N(e,"exception",{error:i}),console.error("hyperscript errors were found on the following element:",e,`
|
|
16
16
|
|
|
17
|
-
`,i)}}var
|
|
17
|
+
`,i)}}var It=[],Ct=[],_e=new Set;function re(e){if((e instanceof Element||e instanceof Document||e instanceof DocumentFragment)&&!_e.has(e)){_e.add(e);try{for(let n of It)n(e);let t=St().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";e instanceof Element&&e.matches(t)&&bt(e),e.querySelectorAll(t).forEach(bt);for(let n of Ct)n(e)}finally{_e.delete(e)}}}function he(e){let t=D(e);if(t){N(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);w.stop(e),e.querySelectorAll("[data-hyperscript-powered]").forEach(he),N(e,"hyperscript:after:cleanup"),e.removeAttribute("data-hyperscript-powered"),Ue(e)}}Y.process=re;function Tn(e){try{let t=Nt(e);return t.kind==="features"?{...t.program,errors:[]}:{...t.kind==="commands"?t.commands[0]:t.expression,errors:[]}}catch(t){if(t instanceof H)return{errors:[t]};throw t}}var Le=Object.assign(xt,{config:Object.assign(ie,{conversions:Object.assign(ye,{dynamicResolvers:ve})}),use(e){e(Le)},addBeforeProcessHook:e=>void It.push(e),addAfterProcessHook:e=>void Ct.push(e),addSourceTransform:e=>void Ot.push(e),evaluate:xt,parse:Tn,process:re,processNode:re,cleanup:he,internals:{runtime:{cleanup:he,processNode:re}},version:"7.4.0"});function At(){if(Object.assign(globalThis,{_hyperscript:Le}),typeof document>"u")return;let e=()=>{re(document.documentElement),document.dispatchEvent(new Event("hyperscript:ready")),ht(Le)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e)}function Pn(e,t){if(typeof e!="object"||e===null)return{queue:[],executing:!1};let n=U(e).eventQueues??=new Map,r=n.get(t);return r||n.set(t,r={queue:[],executing:!1}),r}function De(e,t){let n=Pn(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(()=>De(i,t),1),o){let{error:s}=o;console.error(g(s,"message")??s),console.error(g(s,"stack")),N(e.me,"exception",{error:s})}};V(()=>E(Xe(e,t.body,t),()=>r()),o=>r({error:o}))}function Nn(e,t){if(!B(t))return;let n=U(t),r=n.listeners??=[],o=n.observers??=[],i=n.timers??=new Set;for(let s of e.events){let a={execCount:0},u=s.elsewhere?[document]:s.from?s.from.ev(ee(t,e,t,null)):[t];P(u,l=>{if(!B(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(d=>N(l,c,{mutationList:d,observer:m}));m.observe(l,s.mutationSpec),o.push(m)}if(s.intersectionSpec&&l instanceof Element){c="hyperscript:intersection";let m=new IntersectionObserver(d=>{for(let y of d)N(l,c,{observer:m,entry:y,intersecting:y.isIntersecting,isIntersecting:y.isIntersecting,intersectionRatio:y.intersectionRatio})},s.intersectionSpec);m.observe(l),o.push(m)}if(s.resizeSpec&&l instanceof Element){c="hyperscript:resize";let m=new ResizeObserver(d=>{for(let y of d){let{width:I,height:j}=y.contentRect;N(l,c,{width:I,height:j,contentRect:y.contentRect,entry:y})}});m.observe(l),o.push(m)}let p=m=>{if(t instanceof Node&&l!==t&&!t.isConnected){l.removeEventListener(c,p);return}let d=ee(t,e,t,m);if(!(s.elsewhere&&t instanceof Node&&m.target instanceof Node&&t.contains(m.target))){s.from&&(d.result=l);for(let y of s.args){let I=g(m,y);I!==void 0?d.locals[y]=I:d.detail!=null&&(d.locals[y]=g(d.detail,y))}if(s.filter){d.meta.context=m;try{if(!s.filter.ev(d))return}finally{d.meta.context=void 0}}if(s.inExpr?.css){let y=m.target instanceof Element?m.target:null;for(;y&&!y.matches(s.inExpr.css);)y=y.parentElement;if(!y)return;d.result=y}if(a.execCount++,s.startCount){let y=a.execCount;if(s.endCount?y<s.startCount||y>s.endCount:s.unbounded?y<s.startCount:y!==s.startCount)return}if(s.debounceTime){a.debounced&&(clearTimeout(a.debounced),i.delete(a.debounced)),i.add(a.debounced=setTimeout(()=>De(d,e),s.debounceTime));return}if(s.throttleTime){if(a.lastExec&&Date.now()<a.lastExec+s.throttleTime)return;a.lastExec=Date.now()}De(d,e)}};l.addEventListener(c,p),r.push({target:l,event:c,handler:p})})}}function Sn(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 Rn(e){let t={};if(e.match("with")){let n=ne(b(e));n instanceof Element&&(t.root=n)}if(e.match("having"))do e.match("margin")?t.rootMargin=ct(e):e.match("threshold")?t.threshold=Number(ne(b(e))):e.err("Unknown intersection config specification");while(e.match("and"));return t}function On(e,t){let n=mt(e),r=Et(e),o;e.matchOp("[")&&(o=b(e),e.reqOp("]"));let i,s,a=!1;t?i=1:e.cur().type==="NUMBER"&&(i=parseInt(e.consume().value),e.match("to")?s=parseInt(e.consume().value):e.match("and")&&(a=!0,e.req("on")));let u={on:n,args:r,filter:o,startCount:i,endCount:s,unbounded:a,elsewhere:!1,resizeSpec:n==="resize"};n==="intersection"?u.intersectionSpec=Rn(e):n==="mutation"&&(u.mutationSpec=Sn(e)),e.match("from")&&(e.match("elsewhere")?u.elsewhere=!0:u.from=e.withFollow(["or"],()=>b(e))),!u.from&&!u.elsewhere&&e.match("elsewhere")&&(u.elsewhere=!0),e.match("in")&&(u.inExpr=M(e));let l=()=>(e.req("at"),Number(ne(M(e))));return e.match("debounced")?u.debounceTime=l():e.match("throttled")&&(u.throttleTime=l()),u}function Ft(e){e.features.on=(t,n)=>{let r=!!t.match("every"),o=!r&&!!t.match("first"),i=[];do i.push(On(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 a=W(t),u={type:"onFeature",displayName:"on "+i.map(l=>l.on).join(" or "),events:i,body:a,every:r,queue:s,...wt(t),start:n,end:t.endPos(),install:l=>Nn(u,l)};return u}}Tt(Ft);At();})();
|
package/dist/full.js
CHANGED
|
@@ -38,13 +38,22 @@
|
|
|
38
38
|
enter(_elt) {
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
var windowHolders = /* @__PURE__ */ new WeakMap();
|
|
42
|
+
function holder(elt) {
|
|
43
|
+
if (elt.window !== elt) return elt;
|
|
44
|
+
let h = windowHolders.get(elt);
|
|
45
|
+
if (!h) windowHolders.set(elt, h = {});
|
|
46
|
+
return h;
|
|
47
|
+
}
|
|
48
|
+
var peekData = (elt) => holder(elt)._hyperscript;
|
|
49
|
+
function dropData(elt) {
|
|
50
|
+
const h = holder(elt);
|
|
51
|
+
const had = h._hyperscript !== void 0;
|
|
52
|
+
delete h._hyperscript;
|
|
53
|
+
return had;
|
|
54
|
+
}
|
|
44
55
|
function dataOf(elt) {
|
|
45
|
-
|
|
46
|
-
if (!d) store.set(elt, d = {});
|
|
47
|
-
return d;
|
|
56
|
+
return holder(elt)._hyperscript ??= {};
|
|
48
57
|
}
|
|
49
58
|
var rx = {
|
|
50
59
|
/** True while an effect is evaluating: reads are then recorded as its dependencies. */
|
|
@@ -1609,6 +1618,108 @@
|
|
|
1609
1618
|
return indirect(p, node);
|
|
1610
1619
|
}
|
|
1611
1620
|
|
|
1621
|
+
// src/htmx-compat.ts
|
|
1622
|
+
var installed = /* @__PURE__ */ new WeakSet();
|
|
1623
|
+
function installHtmxCompat(hs) {
|
|
1624
|
+
if (installed.has(hs)) return;
|
|
1625
|
+
installed.add(hs);
|
|
1626
|
+
let fromHtmx = false;
|
|
1627
|
+
const asHtmx = (f) => {
|
|
1628
|
+
const was = fromHtmx;
|
|
1629
|
+
fromHtmx = true;
|
|
1630
|
+
try {
|
|
1631
|
+
f();
|
|
1632
|
+
} finally {
|
|
1633
|
+
fromHtmx = was;
|
|
1634
|
+
}
|
|
1635
|
+
};
|
|
1636
|
+
document.addEventListener(
|
|
1637
|
+
"htmx:load",
|
|
1638
|
+
(evt) => asHtmx(() => hs.process(evt.detail?.elt))
|
|
1639
|
+
);
|
|
1640
|
+
document.addEventListener("htmx:after:process", (evt) => asHtmx(() => hs.process(evt.target)));
|
|
1641
|
+
document.addEventListener("fx:swapped", (evt) => {
|
|
1642
|
+
const target = evt.detail?.cfg?.target;
|
|
1643
|
+
hs.process(
|
|
1644
|
+
target instanceof Element && target.isConnected ? target.parentElement ?? target : document.body
|
|
1645
|
+
);
|
|
1646
|
+
});
|
|
1647
|
+
const htmx = Reflect.get(globalThis, "htmx");
|
|
1648
|
+
if (typeof htmx?.process !== "function") return;
|
|
1649
|
+
hs.addAfterProcessHook((elt) => {
|
|
1650
|
+
if (!fromHtmx) asHtmx(() => htmx.process(elt));
|
|
1651
|
+
});
|
|
1652
|
+
if (htmx.version?.startsWith("4")) {
|
|
1653
|
+
htmx.registerExtension?.("hs-include", {
|
|
1654
|
+
htmx_config_request(elt, detail) {
|
|
1655
|
+
const ctx = detail?.ctx;
|
|
1656
|
+
if (!ctx) return;
|
|
1657
|
+
const found = findHsInclude(ctx.sourceElement || elt);
|
|
1658
|
+
if (!found) return;
|
|
1659
|
+
const vars = resolveSpecifiers(found.value, found.scopeElt);
|
|
1660
|
+
const body = ctx.request?.body;
|
|
1661
|
+
if (body instanceof FormData) for (const k in vars) body.set(k, vars[k]);
|
|
1662
|
+
}
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
function findHsInclude(sourceElt) {
|
|
1667
|
+
const attr = sourceElt.getAttribute("hs-include");
|
|
1668
|
+
if (attr !== null) return { value: attr, scopeElt: sourceElt };
|
|
1669
|
+
for (let elt = sourceElt.parentElement; elt; elt = elt.parentElement) {
|
|
1670
|
+
const inherited2 = elt.getAttribute("hs-include:inherited");
|
|
1671
|
+
if (inherited2 !== null) return { value: inherited2, scopeElt: elt };
|
|
1672
|
+
}
|
|
1673
|
+
return null;
|
|
1674
|
+
}
|
|
1675
|
+
var readScope = (elt) => elt && peekData(elt)?.scopes?.elementScope || {};
|
|
1676
|
+
function serialize(value) {
|
|
1677
|
+
if (value == null) return "";
|
|
1678
|
+
if (typeof value === "object") {
|
|
1679
|
+
try {
|
|
1680
|
+
return JSON.stringify(value);
|
|
1681
|
+
} catch {
|
|
1682
|
+
return "";
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
return String(value);
|
|
1686
|
+
}
|
|
1687
|
+
function resolveInherited(scopeKey, startElt) {
|
|
1688
|
+
for (let elt = startElt; elt; elt = elt.parentElement) {
|
|
1689
|
+
const scope = readScope(elt);
|
|
1690
|
+
if (scopeKey in scope) return scope[scopeKey];
|
|
1691
|
+
}
|
|
1692
|
+
return void 0;
|
|
1693
|
+
}
|
|
1694
|
+
function resolveSpecifiers(attrValue, scopeElt) {
|
|
1695
|
+
const result = {};
|
|
1696
|
+
const raw = attrValue.trim();
|
|
1697
|
+
if (raw === "*") {
|
|
1698
|
+
const scope = readScope(scopeElt);
|
|
1699
|
+
for (const k of Object.keys(scope)) result[k[0] === ":" ? k.slice(1) : k] = serialize(scope[k]);
|
|
1700
|
+
return result;
|
|
1701
|
+
}
|
|
1702
|
+
for (let part of raw.split(",")) {
|
|
1703
|
+
part = part.trim();
|
|
1704
|
+
if (!part) continue;
|
|
1705
|
+
if (part[0] === ":") {
|
|
1706
|
+
const scope = readScope(scopeElt);
|
|
1707
|
+
if (part in scope) result[part.slice(1)] = serialize(scope[part]);
|
|
1708
|
+
} else if (part[0] === "^") {
|
|
1709
|
+
const value = resolveInherited(":" + part.slice(1), scopeElt);
|
|
1710
|
+
if (value !== void 0) result[part.slice(1)] = serialize(value);
|
|
1711
|
+
} else if (part[0] === "#") {
|
|
1712
|
+
const colon = part.lastIndexOf(":");
|
|
1713
|
+
if (colon > 0) {
|
|
1714
|
+
const scope = readScope(document.querySelector(part.slice(0, colon)));
|
|
1715
|
+
const name = part.slice(colon + 1);
|
|
1716
|
+
if (":" + name in scope) result[name] = serialize(scope[":" + name]);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
return result;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1612
1723
|
// src/parser.ts
|
|
1613
1724
|
var ParseError = class extends Error {
|
|
1614
1725
|
constructor(message, token, source, expected) {
|
|
@@ -1974,14 +2085,21 @@
|
|
|
1974
2085
|
}
|
|
1975
2086
|
var beforeProcess = [];
|
|
1976
2087
|
var afterProcess = [];
|
|
2088
|
+
var processing = /* @__PURE__ */ new Set();
|
|
1977
2089
|
function processNode(node) {
|
|
1978
2090
|
if (!(node instanceof Element || node instanceof Document || node instanceof DocumentFragment))
|
|
1979
2091
|
return;
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
2092
|
+
if (processing.has(node)) return;
|
|
2093
|
+
processing.add(node);
|
|
2094
|
+
try {
|
|
2095
|
+
for (const hook of beforeProcess) hook(node);
|
|
2096
|
+
const selector = attributes().map((a) => `[${a}]`).join(", ") + ", [type='text/hyperscript']";
|
|
2097
|
+
if (node instanceof Element && node.matches(selector)) initElement(node);
|
|
2098
|
+
node.querySelectorAll(selector).forEach(initElement);
|
|
2099
|
+
for (const hook of afterProcess) hook(node);
|
|
2100
|
+
} finally {
|
|
2101
|
+
processing.delete(node);
|
|
2102
|
+
}
|
|
1985
2103
|
}
|
|
1986
2104
|
function cleanup(elt) {
|
|
1987
2105
|
const data = peekData(elt);
|
|
@@ -2027,7 +2145,7 @@
|
|
|
2027
2145
|
cleanup,
|
|
2028
2146
|
/** The part of upstream's `internals` that pages and tests reach for. */
|
|
2029
2147
|
internals: { runtime: { cleanup, processNode } },
|
|
2030
|
-
version: false ? "dev" : "7.
|
|
2148
|
+
version: false ? "dev" : "7.4.0"
|
|
2031
2149
|
});
|
|
2032
2150
|
function boot() {
|
|
2033
2151
|
Object.assign(globalThis, { _hyperscript: api });
|
|
@@ -2035,6 +2153,7 @@
|
|
|
2035
2153
|
const start = () => {
|
|
2036
2154
|
processNode(document.documentElement);
|
|
2037
2155
|
document.dispatchEvent(new Event("hyperscript:ready"));
|
|
2156
|
+
installHtmxCompat(api);
|
|
2038
2157
|
};
|
|
2039
2158
|
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", start);
|
|
2040
2159
|
else setTimeout(start);
|
|
@@ -3871,9 +3990,9 @@ return { ${functions.map((name) => `${name}:${name}`).join(",")} } `
|
|
|
3871
3990
|
};
|
|
3872
3991
|
const pending2 = Reflect.apply(fetch, globalThis, [address, detail]);
|
|
3873
3992
|
return Promise.resolve(pending2).then((received) => {
|
|
3874
|
-
const
|
|
3875
|
-
triggerEvent(me, "fetch:afterResponse",
|
|
3876
|
-
const response =
|
|
3993
|
+
const holder2 = { response: received };
|
|
3994
|
+
triggerEvent(me, "fetch:afterResponse", holder2);
|
|
3995
|
+
const response = holder2.response;
|
|
3877
3996
|
if (!(response instanceof Response))
|
|
3878
3997
|
throw new Error("fetch did not return a Response");
|
|
3879
3998
|
if (!dontThrow && kind !== "response" && config.fetchThrowsOn.some((re) => re.test(String(response.status)))) {
|