"use strict";(()=>{var Ri=Object.defineProperty;var N=(s,e)=>{for(var t in e)Ri(s,t,{get:e[t],enumerable:!0})};var pe=class{#t;#i=[];#s=null;#o=[];source;constructor(e,t){this.#t=e,this.source=t,this.consumeWhitespace()}get list(){return this.#t}get consumed(){return this.#i}toString(){var e=this.currentToken(),t=this.source.split(`
`),r=e?.line?e.line-1:t.length-1,i=e?.line?e.column:0,n=t[r]||"",o=Math.max(1,e?.value?.length||1),a=String(r+1).length,l="Tokens(";return l+=this.#i.filter(u=>u.type!=="WHITESPACE").length+" consumed, ",l+=this.#t.filter(u=>u.type!=="WHITESPACE").length+" remaining",l+=", line "+(r+1)+`)
`,l+="  "+String(r+1).padStart(a)+" | "+n+`
`,l+=" ".repeat(a+5)+" ".repeat(i)+"^".repeat(o),e&&(l+=" "+e.type+" '"+e.value+"'"),l}currentToken(){return this.token(0)}token(e,t){var r,i=0;do{if(!t)for(;this.#t[i]&&this.#t[i].type==="WHITESPACE";)i++;r=this.#t[i],e--,i++}while(e>-1);return r||{type:"EOF",value:"<<<EOF>>>"}}hasMore(){return this.#t.length>0}lastMatch(){return this.#s}matchToken(e,t){if(!this.#o.includes(e)&&(t=t||"IDENTIFIER",this.currentToken()&&this.currentToken().value===e&&this.currentToken().type===t))return this.consumeToken()}matchOpToken(e){if(this.currentToken()&&this.currentToken().op&&this.currentToken().value===e)return this.consumeToken()}matchTokenType(...e){if(this.currentToken()&&this.currentToken().type&&e.includes(this.currentToken().type))return this.consumeToken()}matchAnyToken(...e){for(var t=0;t<e.length;t++){var r=this.matchToken(e[t]);if(r)return r}}matchAnyOpToken(...e){for(var t=0;t<e.length;t++){var r=this.matchOpToken(e[t]);if(r)return r}}consumeToken(){var e=this.#t.shift();return this.#i.push(e),this.#s=e,this.consumeWhitespace(),e}consumeWhitespace(){for(;this.token(0,!0).type==="WHITESPACE";)this.#i.push(this.#t.shift())}consumeUntil(e,t){for(var r=[],i=this.token(0,!0);(t==null||i.type!==t)&&(e==null||i.value!==e)&&i.type!=="EOF";){var n=this.#t.shift();this.#i.push(n),r.push(i),i=this.token(0,!0)}return this.consumeWhitespace(),r}consumeUntilWhitespace(){return this.consumeUntil(null,"WHITESPACE")}peekToken(e,t,r){t=t||0,r=r||"IDENTIFIER";let i=0;for(;t>0;)i++,this.#t[i]?.type!=="WHITESPACE"&&t--;if(this.#t[i]&&this.#t[i].value===e&&this.#t[i].type===r)return this.#t[i]}lastWhitespace(){var e=this.#i.at(-1);return e&&e.type==="WHITESPACE"?e.value:""}pushFollow(e){this.#o.push(e)}popFollow(){this.#o.pop()}pushFollows(...e){for(var t=0;t<e.length;t++)this.#o.push(e[t]);return e.length}popFollows(e){for(var t=0;t<e;t++)this.#o.pop()}clearFollows(){var e=this.#o;return this.#o=[],e}restoreFollows(e){this.#o=e}},me={"+":"PLUS","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",".":"PERIOD","..":"ELLIPSIS","\\":"BACKSLASH",":":"COLON","%":"PERCENT","|":"PIPE","!":"EXCLAMATION","?":"QUESTION","#":"POUND","&":"AMPERSAND",$:"DOLLAR",";":"SEMI",",":"COMMA","(":"L_PAREN",")":"R_PAREN","<":"L_ANG",">":"R_ANG","<=":"LTE_ANG",">=":"GTE_ANG","==":"EQ","===":"EQQ","!=":"NEQ","!==":"NEQQ","{":"L_BRACE","}":"R_BRACE","[":"L_BRACKET","]":"R_BRACKET","=":"EQUALS","~":"TILDE","^":"CARET"},O=class s{#t="";#i=0;#s=0;#o=1;#a="<START>";#h=0;#n=[];#p=!1;#c;#l(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}#u(e){return e>="0"&&e<="9"}#v(e){return e===" "||e==="	"||e==="\r"||e===`
`}#d(e){return e==="\r"||e===`
`}#E(e){return this.#l(e)||this.#u(e)||e==="-"||e==="_"||e===":"}#y(e){return e==="_"||e==="$"}#w(e){return e==="`"}static tokenize(e,t){return new s().tokenize(e,t)}tokenize(e,t){return this.#t=e,this.#i=0,this.#s=0,this.#o=1,this.#a="<START>",this.#h=0,this.#n=[],this.#p=t||!1,this.#c="indeterminant",this.#U()}#e(){return this.#t.charAt(this.#i)}#f(){return this.#t.charAt(this.#i+1)}#x(e=1){return this.#t.charAt(this.#i+e)}#r(){return this.#a=this.#e(),this.#i++,this.#a===`
`?(this.#o++,this.#s=0):this.#s++,this.#a}#T(){return this.#p&&this.#h===0}#k(){return!this.#T()||this.#c==="command"}#g(){return this.#l(this.#a)||this.#u(this.#a)||this.#a===")"||this.#a==='"'||this.#a==="'"||this.#a==="`"||this.#a==="}"||this.#a==="]"}#b(){if(this.#n.length>0){var e=this.#n.at(-1);if(e.type==="IDENTIFIER"||e.type==="CLASS_REF"||e.type==="ID_REF"||e.op&&(e.value===">"||e.value===")"))return!1}return!0}#m(e,t){return{type:e,value:t||"",start:this.#i,end:this.#i+1,column:this.#s,line:this.#o}}#A(e,t){var r=this.#m(e,t);return r.op=!0,r}#I(){for(;this.#e()&&!this.#d(this.#e());)this.#r();this.#r()}#L(){for(var e=this.#m("WHITESPACE"),t="";this.#e()&&this.#v(this.#e());)this.#d(this.#e())&&(this.#c="indeterminant"),t+=this.#r();return e.value=t,e.end=this.#i,e}#O(){var e=this.#m("CLASS_REF"),t=this.#r();if(this.#e()==="{"){for(e.template=!0,t+=this.#r();this.#e()&&this.#e()!=="}";)t+=this.#r();if(this.#e()!=="}")throw new Error("Unterminated class reference");t+=this.#r()}else for(;this.#E(this.#e())||this.#e()==="\\";)this.#e()==="\\"&&this.#r(),t+=this.#r();return e.value=t,e.end=this.#i,e}#M(){var e=this.#m("ID_REF"),t=this.#r();if(this.#e()==="{"){for(e.template=!0,t+=this.#r();this.#e()&&this.#e()!=="}";)t+=this.#r();if(this.#e()!=="}")throw new Error("Unterminated id reference");this.#r()}else for(;this.#E(this.#e());)t+=this.#r();return e.value=t,e.end=this.#i,e}#F(){for(var e=this.#m("ATTRIBUTE_REF"),t=this.#r();this.#i<this.#t.length&&this.#e()!=="]";)t+=this.#r();return this.#e()==="]"&&(t+=this.#r()),e.value=t,e.end=this.#i,e}#R(){for(var e=this.#m("ATTRIBUTE_REF"),t=this.#r();this.#E(this.#e());)t+=this.#r();return this.#e()==="="&&(t+=this.#r(),this.#e()==='"'||this.#e()==="'"?t+=this.#S().value:(this.#l(this.#e())||this.#u(this.#e())||this.#y(this.#e()))&&(t+=this.#q().value)),e.value=t,e.end=this.#i,e}#C(){for(var e=this.#m("STYLE_REF"),t=this.#r();this.#l(this.#e())||this.#e()==="-";)t+=this.#r();return e.value=t,e.end=this.#i,e}#_(){var e=this.#m("IDENTIFIER");this.#r();for(var t="";this.#l(this.#e());)t+=this.#r();return e.value=t,e.end=this.#i,e}#P(){var e=this.#m("TEMPLATE_LINE");e.value="TEMPLATE_LINE";for(var t="";this.#e()&&!this.#d(this.#e());)t+=this.#r();return this.#e()&&this.#d(this.#e())&&(this.#r(),t+=`
`,this.#c="indeterminant"),e.content=t,e.end=this.#i,e}#D(){var e=this.#m("IDENTIFIER"),t=this.#r(),r=t==="\\";for(r&&(t="");(this.#l(this.#e())||this.#u(this.#e())||this.#y(this.#e())||this.#e()==="\\"||this.#e()==="{"||this.#e()==="}")&&!(this.#e()==="$"&&!r);)this.#e()==="\\"?(r=!0,this.#r()):(r=!1,t+=this.#r());return this.#e()==="!"&&t==="beep"&&(t+=this.#r()),e.value=t,e.end=this.#i,e}#q(){for(var e=this.#m("IDENTIFIER"),t=this.#r();this.#l(this.#e())||this.#u(this.#e())||this.#y(this.#e());)t+=this.#r();return this.#e()==="!"&&t==="beep"&&(t+=this.#r()),e.value=t,e.end=this.#i,e}#H(){for(var e=this.#m("NUMBER"),t=this.#r();this.#u(this.#e());)t+=this.#r();for(this.#e()==="."&&this.#u(this.#f())&&(t+=this.#r());this.#u(this.#e());)t+=this.#r();for((this.#e()==="e"||this.#e()==="E")&&(this.#u(this.#f())?t+=this.#r():this.#f()==="-"&&(t+=this.#r(),t+=this.#r()));this.#u(this.#e());)t+=this.#r();return e.value=t,e.end=this.#i,e}#N(){for(var e=this.#A(),t=this.#r();this.#e()&&me[t+this.#e()];)t+=this.#r();return e.type=me[t],e.value=t,e.end=this.#i,e}#S(){var e=this.#m("STRING"),t=this.#r();e.template=t==="`";for(var r="";this.#e()&&this.#e()!==t;)if(this.#e()==="\\"){this.#r();let i=this.#r();if(i==="b")r+="\b";else if(i==="f")r+="\f";else if(i==="n")r+=`
`;else if(i==="r")r+="\r";else if(i==="t")r+="	";else if(i==="v")r+="\v";else if(e.template&&i==="$")r+="\\$";else if(i==="x"){let n=this.#W();if(Number.isNaN(n))throw new Error("Invalid hexadecimal escape at [Line: "+e.line+", Column: "+e.column+"]");r+=String.fromCharCode(n)}else r+=i}else r+=this.#r();if(this.#e()!==t)throw new Error("Unterminated string at [Line: "+e.line+", Column: "+e.column+"]");return this.#r(),e.value=r,e.end=this.#i,e}#W(){if(!this.#e())return NaN;let e=16*Number.parseInt(this.#r(),16);return this.#e()?(e+=Number.parseInt(this.#r(),16),e):NaN}#j(){var e=this.#e(),t=this.#f(),r=this.#x(2);return e==="-"&&t==="-"&&(this.#v(r)||r===""||r==="-")||e==="/"&&t==="/"&&(this.#v(r)||r===""||r==="/")}#U(){for(;this.#i<this.#t.length;)if(this.#j())this.#I();else if(this.#v(this.#e()))this.#n.push(this.#L());else if(!this.#g()&&this.#e()==="."&&(this.#l(this.#f())||this.#f()==="{"||this.#f()==="-"))this.#n.push(this.#O());else if(!this.#g()&&this.#e()==="#"&&(this.#l(this.#f())||this.#f()==="{"))this.#p==="lines"&&this.#c==="indeterminant"?(this.#c="command",this.#n.push(this.#_())):this.#n.push(this.#M());else if(this.#p==="lines"&&this.#c==="indeterminant"&&this.#h===0)this.#c="template",this.#n.push(this.#P());else if(this.#e()==="["&&this.#f()==="@")this.#n.push(this.#F());else if(this.#e()==="@")this.#n.push(this.#R());else if(this.#e()==="*"&&this.#l(this.#f()))this.#n.push(this.#C());else if(this.#T()&&(this.#l(this.#e())||this.#e()==="\\")&&this.#c!=="command")this.#n.push(this.#D());else if(this.#k()&&(this.#l(this.#e())||this.#y(this.#e())))this.#n.push(this.#q());else if(this.#u(this.#e()))this.#n.push(this.#H());else if(this.#k()&&(this.#e()==='"'||this.#e()==="`"))this.#n.push(this.#S());else if(this.#k()&&this.#e()==="'")this.#b()?this.#n.push(this.#S()):this.#n.push(this.#N());else if(me[this.#e()])this.#a==="$"&&this.#e()==="{"&&this.#h++,this.#e()==="}"&&this.#h--,this.#n.push(this.#N());else if(this.#T()||this.#w(this.#e()))this.#n.push(this.#m("RESERVED",this.#r()));else if(this.#i<this.#t.length)throw new Error("Unknown token: "+this.#e()+" ");return new pe(this.#n,this.#t)}};var I=class s{errors=[];collectErrors(e){if(e||(e=new Set),e.has(this))return[];e.add(this);var t=[...this.errors];for(var r of Object.keys(this))for(var i of[this[r]].flat())i instanceof s&&t.push(...i.collectErrors(e));return t}sourceFor(){return this.programSource.substring(this.startToken.start,this.endToken.end)}lineFor(){return this.programSource.split(`
`)[this.startToken.line-1]}static parseEventArgs(e){var t=[];if(e.token(0).value==="("&&(e.token(1).value===")"||e.token(2).value===","||e.token(2).value===")")){e.matchOpToken("(");do t.push(e.requireTokenType("IDENTIFIER"));while(e.matchOpToken(","));e.requireOpToken(")")}return t}},y=class extends I{constructor(){super(),this.constructor.grammarName&&(this.type=this.constructor.grammarName)}evaluate(e){return e.meta.runtime.unifiedEval(this,e)}evalStatically(){throw new Error("This expression cannot be evaluated statically: "+this.type)}},d=class extends I{constructor(){super(),this.constructor.keyword&&(this.type=this.constructor.keyword+"Command")}execute(e){return e.meta.command=this,e.meta.runtime.unifiedExec(this,e)}findNext(e){return e.meta.runtime.findNext(this,e)}},S=class extends I{isFeature=!0;constructor(){super(),this.constructor.keyword&&(this.type=this.constructor.keyword+"Feature")}install(e,t,r,i){}static parseErrorAndFinally(e){var t,r,i;return e.matchToken("catch")&&(t=e.requireTokenType("IDENTIFIER").value,r=e.requireElement("commandList"),e.ensureTerminated(r)),e.matchToken("finally")&&(i=e.requireElement("commandList"),e.ensureTerminated(i)),{errorHandler:r,errorSymbol:t,finallyHandler:i}}};var K=class extends d{constructor(){super(),this.type="emptyCommandListCommand"}resolve(e){return this.findNext(e)}},J=class extends d{constructor(e,t){super(),this.type="unlessStatementModifier",this.root=e,this.args={conditional:t}}resolve(e,{conditional:t}){return t?this.next:this.root}},U=class extends I{constructor(e){super(),this.type="hyperscript",this.features=e}apply(e,t,r,i){for(let n of this.features)n.install(e,t,r,i)}},B=class extends S{constructor(e,t){super(),this.type="failedFeature",this.keyword=t,this.errors.push(e)}install(){}},X=class extends d{constructor(e,t){super(),this.type="failedCommand",this.keyword=t,this.errors.push(e)}resolve(){}},Z=class extends d{constructor(){super(),this.type="implicitReturn"}resolve(e){return e.meta.returned=!0,e.meta.resolve&&e.meta.resolve(),e.meta.runtime.HALT}};var xe={};N(xe,{ArrayLiteral:()=>ke,BooleanLiteral:()=>ve,NakedNamedArgumentList:()=>we,NakedString:()=>W,NamedArgumentList:()=>V,NullLiteral:()=>de,NumberLiteral:()=>ye,ObjectKey:()=>Ee,ObjectLiteral:()=>ge,StringLike:()=>be,StringLiteral:()=>Te});var W=class s extends y{static grammarName="nakedString";constructor(e){super(),this.tokens=e}static parse(e){if(e.hasMore()){var t=e.consumeUntilWhitespace();return e.matchTokenType("WHITESPACE"),new s(t)}}evalStatically(){return this.resolve()}resolve(e){return this.tokens.map(function(t){return t.value}).join("")}},ve=class s extends y{static grammarName="boolean";static expressionType="leaf";constructor(e){super(),this.value=e}static parse(e){var t=e.matchToken("true")||e.matchToken("false");if(!t)return;let r=t.value==="true";return new s(r)}evalStatically(){return this.value}resolve(e){return this.value}},de=class s extends y{static grammarName="null";static expressionType="leaf";constructor(){super()}static parse(e){if(e.matchToken("null"))return new s}evalStatically(){return null}resolve(e){return null}},ye=class s extends y{static grammarName="number";static expressionType="leaf";constructor(e,t){super(),this.value=e,this.numberToken=t}static parse(e){var t=e.matchTokenType("NUMBER");if(t){var r=t,i=parseFloat(t.value);return new s(i,r)}}evalStatically(){return this.value}resolve(e){return this.value}},Te=class s extends y{static grammarName="string";static expressionType="leaf";constructor(e,t,r){super(),this.token=e,this.rawValue=t,this.args=r.length>0?{parts:r}:null}static parse(e){var t=e.matchTokenType("STRING");if(t){var r=t.value,i;if(t.template){var n=O.tokenize(r,!0),o=e.createChildParser(n);i=o.parseStringTemplate()}else i=[];return new s(t,r,i)}}evalStatically(){return this.args===null?this.rawValue:super.evalStatically()}resolve(e,{parts:t}={}){if(!t||t.length===0)return this.rawValue;for(var r="",i=0;i<t.length;i++){var n=t[i];n!==void 0&&(r+=n)}return r}},ke=class s extends y{static grammarName="arrayLiteral";static expressionType="leaf";constructor(e){super(),this.values=e,this.args={values:e}}static parse(e){if(e.matchOpToken("[")){var t=[];if(!e.matchOpToken("]")){do{var r=e.requireElement("expression");t.push(r)}while(e.matchOpToken(","));e.requireOpToken("]")}return new s(t)}}resolve(e,{values:t}){return t}},Ee=class s extends y{static grammarName="objectKey";constructor(e,t,r){super(),this.key=e,this.expr=t,this.args=r}static parse(e){var t;if(t=e.matchTokenType("STRING"))return new s(t.value,null,null);if(e.matchOpToken("[")){var r=e.parseElement("expression");return e.requireOpToken("]"),new s(null,r,{value:r})}else{var i="";do t=e.matchTokenType("IDENTIFIER")||e.matchOpToken("-"),t&&(i+=t.value);while(t);return new s(i,null,null)}}evalStatically(){return this.expr?super.evalStatically():this.key}resolve(e,{value:t}={}){return this.expr?t:this.key}},ge=class s extends y{static grammarName="objectLiteral";static expressionType="leaf";constructor(e,t){super(),this.keyExpressions=e,this.valueExpressions=t,this.args={keys:e,values:t}}static parse(e){if(e.matchOpToken("{")){var t=[],r=[];if(!e.matchOpToken("}")){do{var i=e.requireElement("objectKey");e.requireOpToken(":");var n=e.requireElement("expression");r.push(n),t.push(i)}while(e.matchOpToken(",")&&!e.peekToken("}",0,"R_BRACE"));e.requireOpToken("}")}return new s(t,r)}}resolve(e,{keys:t,values:r}){for(var i={},n=0;n<t.length;n++)i[t[n]]=r[n];return i}},V=class s extends y{static grammarName="namedArgumentList";constructor(e,t){super(),this.fields=e,this.args={values:t}}static parseNaked(e){var t=[],r=[];if(e.currentToken().type==="IDENTIFIER")do{var i=e.requireTokenType("IDENTIFIER");e.requireOpToken(":");var n=e.requireElement("expression");r.push(n),t.push({name:i,value:n})}while(e.matchOpToken(","));return new s(t,r)}static parse(e){if(e.matchOpToken("(")){var t=s.parseNaked(e);return e.requireOpToken(")"),t}}resolve(e,{values:t}){for(var r={_namedArgList_:!0},i=0;i<t.length;i++){var n=this.fields[i];r[n.name.value]=t[i]}return r}},we=class extends y{static grammarName="nakedNamedArgumentList";static parse=V.parseNaked},be=class extends y{static grammarName="stringLike";static parse(e){return e.parseAnyOf(["string","nakedString"])}};var Se=class{constructor(e,t,r,i){this.message=e,this.token=t,this.source=r,this.expected=i||null,this.line=t?.line??null,this.column=t?.column??null}},D=class extends Error{constructor(e){super(e.message),this.parseError=e}},F=class s{#t;constructor(e,t){this.#t=e,this.tokens=t}toString(){this.tokens.matched}static formatErrors(e){if(!e.length)return"";var t=e[0].source,r=t.split(`
`),i=new Map;for(var n of e){var o=n.token?.line?n.token.line-1:r.length-1;i.has(o)||i.set(o,[]),i.get(o).push(n)}var a=Math.max(...i.keys())+1,l=String(a).length,u=" ".repeat(l+5),h=[...i.entries()].sort((x,E)=>x[0]-E[0]),f=-1,p="";for(var[o,c]of h){(f!==-1&&o>f+1||f===-1&&o>0)&&(p+=" ".repeat(l+1)+`...
`),f=o;var T=String(o+1).padStart(l),m=r[o]||"";p+="  "+T+" | "+m+`
`,c.sort((E,q)=>(E.column||0)-(q.column||0));var v=Array(m.length+10).fill(" ");for(var n of c)for(var k=n.token?.line?n.token.column:Math.max(0,m.length-1),b=Math.max(1,n.token?.value?.length||1),g=0;g<b;g++)v[k+g]="^";p+=u+v.join("").trimEnd()+`
`;for(var n of c){var k=n.token?.line?n.token.column:0;p+=u+" ".repeat(k)+n.message+`
`}}return p}consumeWhitespace(){return this.tokens.consumeWhitespace()}requireOpToken(e){var t=this.matchOpToken(e);if(t)return t;this.raiseExpected(e)}matchAnyOpToken(...e){return this.tokens.matchAnyOpToken(...e)}matchAnyToken(...e){return this.tokens.matchAnyToken(...e)}matchOpToken(e){return this.tokens.matchOpToken(e)}requireTokenType(...e){var t=this.matchTokenType(...e);if(t)return t;this.raiseExpected(...e)}matchTokenType(...e){return this.tokens.matchTokenType(...e)}requireToken(e,t){var r=this.matchToken(e,t);if(r)return r;this.raiseExpected(e)}peekToken(e,t,r){return this.tokens.peekToken(e,t,r)}matchToken(e,t){return this.tokens.matchToken(e,t)}consumeToken(){return this.tokens.consumeToken()}consumeUntil(e,t){return this.tokens.consumeUntil(e,t)}lastWhitespace(){return this.tokens.lastWhitespace()}consumeUntilWhitespace(){return this.tokens.consumeUntilWhitespace()}hasMore(){return this.tokens.hasMore()}token(e,t){return this.tokens.token(e,t)}currentToken(){return this.tokens.currentToken()}lastMatch(){return this.tokens.lastMatch()}pushFollow(e){return this.tokens.pushFollow(e)}popFollow(){return this.tokens.popFollow()}pushFollows(...e){return this.tokens.pushFollows(...e)}popFollows(e){return this.tokens.popFollows(e)}clearFollows(){return this.tokens.clearFollows()}restoreFollows(e){return this.tokens.restoreFollows(e)}get source(){return this.tokens.source}get consumed(){return this.tokens.consumed}get list(){return this.tokens.list}createChildParser(e){return new s(this.#t,e)}parseElement(e,t=null){return this.#t.parseElement(e,this,t)}requireElement(e,t,r){return this.#t.requireElement(e,this,t,r)}parseAnyOf(e){return this.#t.parseAnyOf(e,this)}raiseError(e,t){e=e||"Unexpected Token : "+this.currentToken().value;var r=new Se(e,this.currentToken(),this.source,t);throw new D(r)}raiseExpected(...e){var t=e.length===1?"Expected '"+e[0]+"' but found '"+this.currentToken().value+"'":"Expected one of: "+e.map(r=>"'"+r+"'").join(", ");this.raiseError(t,e)}parseStringTemplate(){var e=[""];do if(e.push(this.lastWhitespace()),this.currentToken().value==="$"){this.consumeToken();var t=this.matchOpToken("{");e.push(this.requireElement("expression")),t&&this.requireOpToken("}"),e.push("")}else if(this.currentToken().value==="\\")this.consumeToken(),this.consumeToken();else{var r=this.consumeToken();e[e.length-1]+=r?r.value:""}while(this.hasMore());return e.push(this.lastWhitespace()),e}commandBoundary(e){return!!(e.value=="end"||e.value=="then"||e.value=="else"||e.value=="otherwise"||e.value==")"||this.commandStart(e)||this.featureStart(e)||e.type=="EOF")}commandStart(e){return this.#t.commandStart(e)}featureStart(e){return this.#t.featureStart(e)}setParent(e,t){typeof e=="object"&&(e.parent=t,typeof t=="object"&&(t.children=t.children||new Set,t.children.add(e)),this.setParent(e.next,t))}parseURLOrExpression(){var e=this.currentToken();if(e.value==="/"&&e.type==="DIVIDE"){var t=this.consumeUntilWhitespace();return this.matchTokenType("WHITESPACE"),new W(t)}if(e.type==="IDENTIFIER"&&(e.value==="http"||e.value==="https"||e.value==="ws"||e.value==="wss")){var t=this.consumeUntilWhitespace();return this.matchTokenType("WHITESPACE"),new W(t)}return this.requireElement("expression")}ensureTerminated(e){for(var t=new Z,r=e;r.next;)r=r.next;r.next=t}};var ee=class{#t={};#i={};#s={};#o=[];#a=[];#h=[];#n=[];#p=[];#c=[];constructor(){this.addGrammarElement("hyperscript",this.parseHyperscriptProgram.bind(this)),this.addGrammarElement("feature",this.parseFeature.bind(this)),this.addGrammarElement("commandList",this.parseCommandList.bind(this)),this.addGrammarElement("command",this.parseCommand.bind(this)),this.addGrammarElement("indirectStatement",this.parseIndirectStatement.bind(this)),this.addGrammarElement("expression",this.parseExpression.bind(this)),this.addGrammarElement("assignableExpression",this.parseAssignableExpression.bind(this)),this.addGrammarElement("unaryExpression",this.parseUnaryExpression.bind(this)),this.addGrammarElement("postfixExpression",this.parsePostfixExpression.bind(this)),this.addGrammarElement("primaryExpression",this.parsePrimaryExpression.bind(this)),this.addGrammarElement("indirectExpression",this.parseIndirectExpression.bind(this)),this.addGrammarElement("leaf",this.parseLeaf.bind(this))}parseFeature(e){if(e.matchOpToken("(")){var t=e.requireElement("feature");return e.requireOpToken(")"),t}var r=this.#s[e.currentToken().value||""];if(r)return r(e)}parseCommand(e){if(e.matchOpToken("(")){let i=e.requireElement("command");return e.requireOpToken(")"),i}var t=this.#i[e.currentToken().value||""];let r;return t?r=t(e):e.currentToken().type==="IDENTIFIER"&&(r=e.parseElement("pseudoCommand")),r&&this.parseElement("indirectStatement",e,r)}parseCommandList(e){if(e.hasMore()){var t=e.currentToken().value,r;try{r=e.parseElement("command")}catch(i){if(i instanceof D)r=new X(i.parseError,t),this.#u(e);else throw i}if(r){e.matchToken("then");let i=e.parseElement("commandList");return i&&(r.next=i),r}}return new K}parseLeaf(e){var t=e.parseAnyOf(this.#o);return t??e.parseElement("symbol")}parseIndirectExpression(e,t){for(var r=0;r<this.#a.length;r++){var i=this.#a[r];t.endToken=e.lastMatch();var n=this.parseElement(i,e,t);if(n)return n}return t}parsePostfixExpression(e){for(var t=e.parseElement("negativeNumber"),r=0;r<this.#h.length;r++){var i=this.#h[r],n=this.parseElement(i,e,t);if(n)return n}return t}parseUnaryExpression(e){e.matchToken("the");var t=e.parseAnyOf(this.#n);return t?this.parseElement("indirectExpression",e,t):e.parseElement("postfixExpression")}parseExpression(e){return e.matchToken("the"),e.parseAnyOf(this.#p)}parseAssignableExpression(e){e.matchToken("the");for(var t=e.parseElement("primaryExpression"),r=t;r&&r.type==="parenthesized";)r=r.expr;if(r&&this.#c.includes(r.type))return t;e.raiseError("A target expression must be writable.  The expression type '"+(r&&r.type)+"' is not.")}parseIndirectStatement(e,t){if(e.matchToken("unless")){t.endToken=e.lastMatch();var r=e.requireElement("expression"),i=new J(t,r);return t.parent=i,i}return t}parsePrimaryExpression(e){var t=e.parseElement("leaf");if(t)return this.parseElement("indirectExpression",e,t);e.raiseError("Unexpected value: "+e.currentToken().value)}parseHyperscriptProgram(e){var t=[];if(e.hasMore())for(;e.currentToken().type!=="EOF";){var r=e.currentToken().value;if(e.featureStart(e.currentToken())||e.currentToken().value==="(")try{var i=e.requireElement("feature");t.push(i),e.matchToken("end")}catch(n){if(n instanceof D)t.push(new B(n.parseError,r)),this.#l(e);else throw n}else{if(e.currentToken().value==="end")break;try{e.raiseError()}catch(n){if(n instanceof D)t.push(new B(n.parseError,r)),this.#l(e);else throw n}}}return new U(t)}use(e){return e(this),this}initElt(e,t,r){e.startToken=t,e.programSource=r.source}parseElement(e,t,r=void 0){var i=this.#t[e];if(i){var n=t.tokens,o=n.currentToken(),a=i(t,r);if(a){this.initElt(a,o,n),a.endToken=a.endToken||n.lastMatch();for(var r=a.root;r!=null;)this.initElt(r,o,n),r=r.root}return a}}requireElement(e,t,r,i){var n=this.parseElement(e,t,i);return n||t.raiseError(r||"Expected "+e),n}parseAnyOf(e,t){for(var r=0;r<e.length;r++){var i=e[r],n=this.parseElement(i,t);if(n)return n}}addGrammarElement(e,t){if(this.#t[e])throw new Error(`Grammar element '${e}' already exists`);this.#t[e]=t}addCommand(e,t){var r=e+"Command";this.#t[r]=t,this.#i[e]=t}addCommands(...e){for(let i of e){if(!i.keyword)throw new Error(`Command class ${i.name} must have a static 'keyword' property`);if(!i.parse)throw new Error(`Command class ${i.name} must have a static 'parse' method`);var t=Array.isArray(i.keyword)?i.keyword:[i.keyword];for(var r of t)this.addCommand(r,i.parse)}}addFeatures(...e){for(let t of e){if(!t.keyword)throw new Error(`Feature class ${t.name} must have a static 'keyword' property`);if(!t.parse)throw new Error(`Feature class ${t.name} must have a static 'parse' method`);this.addFeature(t.keyword,t.parse)}}addFeature(e,t){var r=e+"Feature";this.#t[r]=t,this.#s[e]=t}registerParseElement(e){if(!e.parse)return;let t=e.parse.bind(e);if(e.keyword&&e.prototype instanceof d){var r=Array.isArray(e.keyword)?e.keyword:[e.keyword];for(var i of r)this.addCommand(i,t);return}if(e.keyword&&e.prototype instanceof S){var r=Array.isArray(e.keyword)?e.keyword:[e.keyword];for(var i of r)this.addFeature(i,t);return}let n=e.grammarName;if(n){switch(e.expressionType){case"leaf":this.addLeafExpression(n,t);break;case"indirect":this.addIndirectExpression(n,t);break;case"unary":this.addUnaryExpression(n,t);break;case"top":this.addTopExpression(n,t);break;case"postfix":this.addPostfixExpression(n,t);break;default:this.addGrammarElement(n,t);break}e.assignable&&this.#c.push(n)}}registerModule(e){for(let t of Object.values(e))typeof t=="function"&&t.parse&&this.registerParseElement(t)}addLeafExpression(e,t){this.#o.push(e),this.addGrammarElement(e,t)}addIndirectExpression(e,t){this.#a.push(e),this.addGrammarElement(e,t)}addPostfixExpression(e,t){this.#h.push(e),this.addGrammarElement(e,t)}addUnaryExpression(e,t){this.#n.push(e),this.addGrammarElement(e,t)}addTopExpression(e,t){this.#p.push(e),this.addGrammarElement(e,t)}commandStart(e){return this.#i[e.value||""]}featureStart(e){return this.#s[e.value||""]}parseHyperScript(e){var t=new F(this,e),r,i=null;try{r=t.parseElement("hyperscript"),e.hasMore()&&t.raiseError()}catch(n){if(!(n instanceof D))throw n;i=n.parseError}return r||(r=new U([])),r.errors=r.collectErrors(),i&&r.errors.push(i),r}#l(e){for(e.tokens.clearFollows();e.hasMore()&&!e.featureStart(e.currentToken())&&e.currentToken().value!=="end"&&e.currentToken().type!=="EOF";)e.tokens.consumeToken()}#u(e){for(e.tokens.clearFollows();e.hasMore()&&!e.commandBoundary(e.currentToken());)e.tokens.consumeToken();e.hasMore()&&e.currentToken().value==="then"&&e.tokens.consumeToken()}parse(e,t){var r=e.tokenize(t),i=new F(this,r),n,o;try{i.commandStart(r.currentToken())?(n=this.requireElement("commandList",i),r.hasMore()&&i.raiseError(),i.ensureTerminated(n)):i.featureStart(r.currentToken())?(n=this.requireElement("hyperscript",i),r.hasMore()&&i.raiseError()):(n=this.requireElement("expression",i),r.hasMore()&&i.raiseError())}catch(a){if(!(a instanceof D))throw a;o=a.parseError}return!n&&o?n={type:"empty",errors:[o]}:n&&(n.errors=n.collectErrors(),o&&n.errors.push(o)),n}};var A={attributes:"_, script, data-script",defaultTransition:"all 500ms ease-in",disableSelector:"[disable-scripting], [data-disable-scripting]",fetchThrowsOn:[/4.*/,/5.*/],hideShowStrategies:{},logAll:!1,mutatingMethods:{Array:["push","pop","shift","unshift","splice","sort","reverse","fill","copyWithin"],Set:["add","delete","clear"],Map:["set","delete","clear"]}};var qe=class{result={};addElement(e){if(!(e.name==null||e.value==null)&&!(e.type==="radio"&&!e.checked)){var t=e.name,r;if(e.type==="checkbox"?r=e.checked?[e.value]:void 0:e.type==="select-multiple"?r=Array.from(e.options).filter(n=>n.selected).map(n=>n.value):r=e.value,r!=null)if(this.result[t]==null)this.result[t]=r;else{var i=Array.isArray(this.result[t])?this.result[t]:[this.result[t]];this.result[t]=i.concat(r)}}}addContainer(e){if(e.name!=null&&e.value!=null){this.addElement(e);return}e.querySelectorAll&&e.querySelectorAll("input,select,textarea").forEach(t=>this.addElement(t))}};function ui(s){if(s instanceof Array)return s.map(r=>ui(r)).join("");if(s instanceof HTMLElement)return s.outerHTML;if(s instanceof NodeList){for(var e="",t=0;t<s.length;t++)s[t]instanceof HTMLElement&&(e+=s[t].outerHTML);return e}return s.toString?s.toString():""}var z={dynamicResolvers:[function(s,e){if(s==="Fixed")return Number(e).toFixed();if(s.startsWith("Fixed:")){let t=s.split(":")[1];return Number(e).toFixed(parseInt(t))}},function(s,e,t){if(s==="Values"){var r=new qe;return t.implicitLoop(e,i=>r.addContainer(i)),r.result}}],String:function(s){return s.toString?s.toString():""+s},Int:function(s){return parseInt(s)},Float:function(s){return parseFloat(s)},Number:function(s){return Number(s)},Boolean:function(s){return!!s},Date:function(s){return new Date(s)},Array:function(s){return Array.from(s)},JSON:function(s){return typeof Response<"u"&&s instanceof Response?s.json():JSON.parse(s)},JSONString:function(s){return JSON.stringify(s)},Object:function(s){return s instanceof String&&(s=s.toString()),typeof s=="string"?JSON.parse(s):Object.assign({},s)},FormEncoded:function(s){return new URLSearchParams(s).toString()},Set:function(s){return new Set(s)},Map:function(s){return new Map(Object.entries(s))},Keys:function(s){return s instanceof Map?Array.from(s.keys()):Object.keys(s)},Entries:function(s){return s instanceof Map?Array.from(s.entries()):Object.entries(s)},Reversed:function(s){return Array.from(s).reverse()},Unique:function(s){return[...new Set(s)]},Flat:function(s){return Array.from(s).flat()},HTML:ui,Stream:function(){throw new Error("The Stream conversion requires the SSE extension. Include dist/ext/sse.js or dist/ext/sse.esm.js after hyperscript.")},Fragment:function(s,e){var t=document.createDocumentFragment();return e.implicitLoop(s,r=>{if(r instanceof Node)t.append(r);else{var i=document.createElement("template");i.innerHTML=r,t.append(i.content)}}),t}};var te=class{#t(){return document.cookie?document.cookie.split("; ").map(e=>{var t=e.indexOf("=");return{name:e.slice(0,t),value:decodeURIComponent(e.slice(t+1))}}):[]}get(e,t){if(t==="then")return null;if(t==="length")return this.#t().length;if(t==="clear")return n=>{document.cookie=n+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT"};if(t==="clearAll")return()=>{for(let n of this.#t())document.cookie=n.name+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT"};if(t===Symbol.iterator){var r=this.#t();return r[Symbol.iterator].bind(r)}else if(typeof t=="string"){if(!isNaN(t))return this.#t()[parseInt(t)];var i=this.#t().find(n=>n.name===t);return i?i.value:void 0}}set(e,t,r){var i=[];return typeof r=="string"?(i.push(encodeURIComponent(r)),i.push("samesite=lax")):(i.push(encodeURIComponent(r.value)),r.expires&&i.push("expires="+r.expires),r.maxAge&&i.push("max-age="+r.maxAge),r.partitioned&&i.push("partitioned="+r.partitioned),r.path&&i.push("path="+r.path),r.samesite&&i.push("samesite="+r.samesite),r.secure&&i.push("secure")),document.cookie=String(t)+"="+i.join(";"),!0}proxy(){return new Proxy({},this)}};var Ae=Symbol(),R=class{constructor(e,t,r,i){this._css=e,this.relativeToElement=t,this.escape=r,this._runtime=i,this[Ae]=!0}get css(){return this.escape?this._runtime.escapeSelector(this._css):this._css}get className(){return this._css.slice(1)}get id(){return this.className}contains(e){for(let t of this)if(t.contains(e))return!0;return!1}get length(){return this.selectMatches().length}[Symbol.iterator](){return this.selectMatches()[Symbol.iterator]()}selectMatches(){return this._runtime.getRootNode(this.relativeToElement).querySelectorAll(this.css)}},re=class extends R{constructor(e,t,r,i){super(e,t,!1,i),this.templateParts=r,this.elements=r.filter(n=>n instanceof Element)}get css(){let e="",t=0;for(let r of this.templateParts)r instanceof Element?e+="[data-hs-query-id='"+t+++"']":e+=r;return e}[Symbol.iterator](){this.elements.forEach((t,r)=>t.dataset.hsQueryId=r);let e=super[Symbol.iterator]();return this.elements.forEach(t=>t.removeAttribute("data-hs-query-id")),e}},Ne=class{constructor(e,t){this.re=e,this.str=t}next(){let e=this.re.exec(this.str);return e===null?{done:!0}:(e[0].length===0&&this.re.lastIndex++,{value:e})}},ie=class{constructor(e,t,r){this.re=e,this.flags=t,this.str=r}[Symbol.iterator](){return new Ne(new RegExp(this.re,this.flags),this.str)}},ne=class extends EventTarget{constructor(e){super(),this.module=e}toString(){return this.module.id}};var Ci=new te().proxy(),se=class{constructor(e,t,r,i,n,o,a,l){this.meta={parser:a,tokenizer:l,runtime:n,owner:e,feature:t,iterators:{},ctx:this},this.locals={cookies:Ci},typeof navigator<"u"&&navigator.clipboard&&Object.defineProperty(this.locals,"clipboard",{get(){return navigator.clipboard.readText()},set(u){navigator.clipboard.writeText(String(u))},enumerable:!1,configurable:!0}),typeof window<"u"&&window.getSelection&&Object.defineProperty(this.locals,"selection",{get(){return window.getSelection().toString()},enumerable:!0,configurable:!0}),this.me=r,this.you=void 0,this.result=void 0,this.beingTested=null,this.event=i,this.target=i?.target??null,this.detail=i?.detail??null,this.sender=i?.detail?.sender??null,this.body="document"in o?document.body:null,n.addFeatures(e,this)}},oe=class s{static HALT={};HALT=s.HALT;#t;#i;#s;#o;#a;#h=null;constructor(e,t,r,i,n){this.#s=e,this.#t=t,this.#i=r,this.#o=i,this.#a=n}get globalScope(){return this.#s}get reactivity(){return this.#o}unifiedExec(e,t){for(;;){try{var r=this.unifiedEval(e,t)}catch(i){if(t.meta.handlingFinally)console.error(" Exception in finally block: ",i),r=s.HALT;else if(this.registerHyperTrace(t,i),t.meta.errorHandler&&!t.meta.handlingError){t.meta.handlingError=!0,t.locals[t.meta.errorSymbol]=i,e=t.meta.errorHandler;continue}else t.meta.currentException=i,r=s.HALT}if(r==null)throw new Error("Command "+(e.type||"unknown")+" did not return a next element to execute");if(r.then){r.then(i=>{this.unifiedExec(i,t)}).catch(i=>{this.unifiedExec({resolve:function(){throw i}},t)});return}else if(r===s.HALT)if(t.meta.finallyHandler&&!t.meta.handlingFinally)t.meta.handlingFinally=!0,e=t.meta.finallyHandler;else if(t.meta.onHalt&&t.meta.onHalt(),t.meta.currentException)if(t.meta.reject){t.meta.reject(t.meta.currentException);return}else throw t.meta.currentException;else return;else e=r}}unifiedEval(e,t){var r=!1,i={};if(e.args)for(var[n,o]of Object.entries(e.args))if(o==null)i[n]=null;else if(Array.isArray(o)){for(var a=[],l=0;l<o.length;l++){var u=o[l];if(u==null)a.push(null);else if(u.evaluate){var h=u.evaluate(t);h&&h.then&&(r=!0),a.push(h)}else a.push(u)}i[n]=a}else if(o.evaluate){var h=o.evaluate(t);h&&h.then&&(r=!0),i[n]=h}else i[n]=o;return r?new Promise((f,p)=>{var c=Object.keys(i),T=Object.values(i).map(m=>Array.isArray(m)?Promise.all(m):m);Promise.all(T).then(function(m){try{var v={};c.forEach((k,b)=>v[k]=m[b]),f(e.resolve(t,v))}catch(k){p(k)}}).catch(function(m){p(m)})}):e.resolve(t,i)}findNext(e,t){if(e)return e.resolveNext?e.resolveNext(t):e.next?e.next:this.findNext(e.parent,t)}makeContext(e,t,r,i){return new se(e,t,r,i,this,this.#s,this.#t,this.#i)}getHyperscriptFeatures(e){var t=this.getInternalData(e);return t.features||(t.features={}),t.features}addFeatures(e,t){e&&(Object.assign(t.locals,this.getHyperscriptFeatures(e)),this.addFeatures(e.parentElement,t))}#n(e){return["meta","it","result","locals","event","target","detail","sender","body"].includes(e)}#p(e){return e instanceof se}resolveSymbol(e,t,r,i){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;if(r==="global"){this.reactivity.isTracking&&this.reactivity.trackGlobalSymbol(e);var h=this.#s[e];return this.#v(h),h}if(r==="element"){this.reactivity.isTracking&&this.reactivity.trackElementSymbol(e,t.meta.owner);var h=this.#l(t)[e];return this.#v(h),h}if(r==="inherited"){var n=this.#c(e,t,i);if(this.reactivity.isTracking){var o=n.element||i||t.meta?.owner;o&&this.reactivity.trackElementSymbol(e,o)}return this.#v(n.value),n.value}if(t.meta?.context){var a=t.meta.context[e];if(typeof a<"u"||t.meta.context.detail&&(a=t.meta.context.detail[e],typeof a<"u"))return a}var l=this.#p(t)&&!this.#n(e)?t.locals[e]:t[e];if(typeof l<"u")return l;var u=this.#l(t);if(l=u[e],typeof l<"u")return this.reactivity.isTracking&&this.reactivity.trackElementSymbol(e,t.meta.owner),this.#v(l),l;this.reactivity.isTracking&&this.reactivity.trackGlobalSymbol(e);var h=this.#s[e];return this.#v(h),h}setSymbol(e,t,r,i,n){if(r==="global"){this.#s[e]=i,this.reactivity.notifyGlobalSymbol(e);return}if(r==="element"){this.#l(t)[e]=i,this.reactivity.notifyElementSymbol(e,t.meta.owner);return}if(r==="inherited"){var o=this.#c(e,t,n);if(o.element)this.getInternalData(o.element).elementScope[e]=i,this.reactivity.notifyElementSymbol(e,o.element);else{var a=n||t.meta?.owner;if(a){var l=this.getInternalData(a);l.elementScope||(l.elementScope={}),l.elementScope[e]=i,this.reactivity.notifyElementSymbol(e,a)}}return}if(this.#p(t)&&!this.#n(e)&&typeof t.locals[e]<"u"){t.locals[e]=i;return}var u=this.#l(t);typeof u[e]<"u"?(u[e]=i,this.reactivity.notifyElementSymbol(e,t.meta.owner)):this.#p(t)&&!this.#n(e)?t.locals[e]=i:t[e]=i}getInternalData(e){return e._hyperscript||(e._hyperscript={}),e._hyperscript}#c(e,t,r){for(var i=r||t.meta&&t.meta.owner;i;){var n=i._hyperscript;if(n&&n.elementScope&&e in n.elementScope)return{value:n.elementScope[e],element:i};var o=i.getAttribute&&i.getAttribute("dom-scope");if(o){if(o==="isolated")return{value:void 0,element:null};var a=o.match(/^closest\s+(.+)/);if(a){i=i.parentElement&&i.parentElement.closest(a[1]);continue}if(a=o.match(/^parent\s+of\s+(.+)/),a){var l=i.closest(a[1]);i=l&&l.parentElement;continue}}i=i.parentElement}return{value:void 0,element:null}}#l(e){var t=e.meta&&e.meta.owner;if(t){var r=this.getInternalData(t),i="elementScope";e.meta.feature&&e.meta.feature.behavior&&(i=e.meta.feature.behavior+"Scope");var n=r[i];return n||(n={},r[i]=n),n}else return{}}#u(e,t,r){if(e!=null){var i=r(e,t);if(typeof i<"u")return i;if(this.shouldAutoIterate(e)){var n=[];for(var o of e){var a=r(o,t);n.push(a)}return n}}}resolveProperty(e,t){return this.reactivity.isTracking&&this.reactivity.trackProperty(e,t),this.#u(e,t,(r,i)=>r[i])}setProperty(e,t,r){e[t]=r,this.reactivity.notifyProperty(e)}notifyMutation(e){this.reactivity.notifyProperty(e)}morph(e,t){this.#a.morph(e,t,{beforeNodeRemoved:r=>{r.nodeType===1&&this.cleanup(r)},afterNodeAdded:r=>{r.nodeType===1&&this.processNode(r)},afterNodeMorphed:r=>{r.nodeType===1&&this.processNode(r)}})}replaceInDom(e,t){this.implicitLoop(e,r=>{var i=r.parentElement;t instanceof Node?r.replaceWith(t.cloneNode(!0)):r.replaceWith(this.convertValue(t,"Fragment")),i&&this.processNode(i)})}maybeNotify(e,t){if(!(e==null||typeof e!="object")){var r=e.constructor&&e.constructor.name,i=r&&A.mutatingMethods[r];i&&i.includes(t)&&this.notifyMutation(e)}}#v(e){this.reactivity.isTracking&&e!=null&&typeof e=="object"&&this.reactivity.trackProperty(e,"__mutation__")}resolveAttribute(e,t){return this.reactivity.isTracking&&this.reactivity.trackAttribute(e,t),this.#u(e,t,(r,i)=>r.getAttribute&&r.getAttribute(i))}resolveStyle(e,t){return this.#u(e,t,(r,i)=>r.style&&r.style[i])}resolveComputedStyle(e,t){return this.#u(e,t,(r,i)=>getComputedStyle(r).getPropertyValue(i))}assignToNamespace(e,t,r,i){let n;e==null||typeof document<"u"&&e===document.body?n=this.#s:n=this.getHyperscriptFeatures(e);for(var o;(o=t.shift())!==void 0;){var a=n[o];a==null&&(a={},n[o]=a),n=a}n[r]=i}#d(e){return Array.isArray(e)||typeof NodeList<"u"&&(e instanceof NodeList||e instanceof HTMLCollection||e instanceof FileList)}#E(e){return typeof e=="object"&&Symbol.iterator in e&&typeof e[Symbol.iterator]=="function"}shouldAutoIterate(e){return e!=null&&e[Ae]||this.#d(e)}forEach(e,t){if(e!=null)if(this.#E(e))for(let i of e)t(i);else if(this.#d(e))for(var r=0;r<e.length;r++)t(e[r]);else t(e)}implicitLoop(e,t){if(this.shouldAutoIterate(e))for(let r of e)t(r);else t(e)}implicitLoopWhen(e,t,r,i,n){var o=[];this.implicitLoop(e,function(u){o.push(u)});var a=o.map(function(u){return r.beingTested=u,t.evaluate(r)});r.beingTested=null;var l=a.some(function(u){return u&&typeof u.then=="function"});if(l)return Promise.all(a).then(u=>{r.result=this.#y(o,u,i,n)});r.result=this.#y(o,a,i,n)}#y(e,t,r,i){for(var n=[],o=0;o<e.length;o++)t[o]?(r(e[o]),n.push(e[o])):i(e[o]);return n}convertValue(e,t){for(var r=z.dynamicResolvers,i=0;i<r.length;i++){var n=r[i],o=n(t,e,this);if(o!==void 0)return o}if(e==null)return null;var a=z[t];if(a)return a(e,this);throw new Error("Unknown conversion : "+t)}evaluateNoPromise(e,t){let r=e.evaluate(t);if(r&&typeof r.then=="function")throw new Error(e.sourceFor()+" returned a Promise in a context that they are not allowed.");return r}typeCheck(e,t,r){if(e==null&&r)return!0;var i=Object.prototype.toString.call(e).slice(8,-1);if(i===t)return!0;var n=typeof globalThis<"u"&&globalThis[t];return typeof n=="function"&&e instanceof n}nullCheck(e,t){if(e==null)throw new Error("'"+t.sourceFor()+"' is null")}isEmpty(e){return e==null||e.length===0}doesExist(e){if(e==null)return!1;if(this.shouldAutoIterate(e)){for(let t of e)return!0;return!1}return!0}matchesSelector(e,t){return e.matches&&e.matches(t)}makeEvent(e,t){var r=new Event(e,{bubbles:!0,cancelable:!0,composed:!0});return r.detail=t,r}triggerEvent(e,t,r,i){r=r||{},r.sender=i;var n=this.makeEvent(t,r);A.logAll&&console.log(t,r,e);var o=e.dispatchEvent(n);return o}getRootNode(e){if(e&&e instanceof Node){var t=e.getRootNode();if(t instanceof Document||t instanceof ShadowRoot)return t}return document}escapeSelector(e){return e.replace(/[:&()\[\]\/]/g,function(t){return"\\"+t})}getEventQueueFor(e,t){let r=this.getInternalData(e);var i=r.eventQueues;i==null&&(i=new Map,r.eventQueues=i);var n=i.get(t);return n==null&&(n={queue:[],executing:!1},i.set(t,n)),n}#w(){return this.#h==null&&(this.#h=A.attributes.replaceAll(" ","").split(",")),this.#h}#e(e){for(var t=this.#w(),r=0;r<t.length;r++){var i=t[r];if(e.hasAttribute&&e.hasAttribute(i))return e.getAttribute(i)}return e instanceof HTMLScriptElement&&e.type==="text/hyperscript"?e.innerText:null}#f;#x(){return this.#f||(this.#f=this.#w().map(e=>"["+e+"]").join(", ")),this.#f}#r(e){for(var t=5381,r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r);return t}cleanup(e){if(e._hyperscript){this.triggerEvent(e,"hyperscript:before:cleanup");var t=e._hyperscript;if(t.listeners)for(var r of t.listeners)r.target.removeEventListener(r.event,r.handler);if(t.observers)for(var i of t.observers)i.disconnect();if(t.eventState)for(var n of t.eventState.values())n.debounced&&clearTimeout(n.debounced);if(this.reactivity.stopElementEffects(e),e.querySelectorAll)for(var o of e.querySelectorAll("[data-hyperscript-powered]"))this.cleanup(o);this.triggerEvent(e,"hyperscript:after:cleanup"),e.removeAttribute("data-hyperscript-powered"),delete e._hyperscript}}#T(e,t){if(!(e.closest&&e.closest(A.disableSelector))){var r=this.getInternalData(e),i=this.#e(e);if(i){var n=this.#r(i);if(r.initialized){if(r.scriptHash===n){this.#k(e);return}this.cleanup(e),r=this.getInternalData(e)}if(this.triggerEvent(e,"hyperscript:before:init")){r.initialized=!0,r.scriptHash=n;try{var o=this.#i.tokenize(i),a=this.#t.parseHyperScript(o);if(!a)return;if(a.errors?.length){this.triggerEvent(e,"hyperscript:parse-error",{errors:a.errors}),console.error("hyperscript: "+a.errors.length+" parse error(s) on:",e,`

`+F.formatErrors(a.errors));return}this.#k(e),a.apply(t||e,e,null,this),e.setAttribute("data-hyperscript-powered","true"),this.triggerEvent(e,"hyperscript:after:init"),setTimeout(()=>{this.triggerEvent(t||e,"load",{hyperscript:!0})},1)}catch(l){this.triggerEvent(e,"exception",{error:l}),console.error("hyperscript errors were found on the following element:",e,`

`,l.message,l.stack)}}}}}#k(e){var t=e.closest('[data-live-template], [dom-scope="isolated"]');if(!(!t||!t.__hs_scopes)){for(var r=[],i=e;i&&i!==t;){for(var n=i.previousSibling;n;){if(n.nodeType===8){var o=n.data;if(o.startsWith("hs-scope:")){r.push(o);break}}n=n.previousSibling}i=i.parentElement}if(r.length){var a=this.getInternalData(e);a.elementScope||(a.elementScope={});for(var l=0;l<r.length;l++){var u=r[l].split(":"),h=u[1],f=parseInt(u[2]),p=t.__hs_scopes[h];p&&(a.elementScope[p.identifier]=p.source[f],p.indexIdentifier&&(a.elementScope[p.indexIdentifier]=f))}}}}#g=[];#b=[];addBeforeProcessHook(e){this.#g.push(e)}addAfterProcessHook(e){this.#b.push(e)}processNode(e){for(var t of this.#g)t(e);var r=this.#x();this.matchesSelector(e,r)&&this.#T(e,e),e instanceof HTMLScriptElement&&e.type==="text/hyperscript"&&this.#T(e,document.body),e.querySelectorAll&&this.forEach(e.querySelectorAll(r+", [type='text/hyperscript']"),i=>{this.#T(i,i instanceof HTMLScriptElement&&i.type==="text/hyperscript"?document.body:i)});for(var t of this.#b)t(e)}getHyperTrace(e,t){for(var r=[],i=e;i.meta.caller;)i=i.meta.caller;if(i.meta.traceMap)return i.meta.traceMap.get(t,r)}registerHyperTrace(e,t){for(var r=[],i=null;e!=null;)r.push(e),i=e,e=e.meta.caller;if(i.meta.traceMap==null&&(i.meta.traceMap=new Map),!i.meta.traceMap.get(t)){var n={trace:r,print:function(o){o=o||console.error,o("hypertrace /// ");for(var a=0,l=0;l<r.length;l++)a=Math.max(a,r[l].meta.feature.displayName.length);for(var l=0;l<r.length;l++){var u=r[l];o("  ->",u.meta.feature.displayName.padEnd(a+2),"-",u.meta.owner)}}};i.meta.traceMap.set(t,n)}}beepValueToConsole(e,t,r){if(this.triggerEvent(e,"hyperscript:beep",{element:e,expression:t,value:r})){var i=r?r instanceof R?"ElementCollection":r.constructor?.name||"unknown":"object (null)",n=i==="String"?'"'+r+'"':r instanceof R?Array.from(r):r;console.log("///_ BEEP! The expression ("+t.sourceFor().replace("beep! ","")+") evaluates to:",n,"of type "+i)}}};function _i(s,e){return s===e?s!==0||1/s===1/e:s!==s&&e!==e}var Ie=class{constructor(e,t,r,i){this.expression=e,this.handler=t,this.element=r,this._reactivity=i,this.dependencies=new Map,this._lastValue=void 0,this._isStopped=!1,this._consecutiveTriggers=0}initialize(){var e=this._reactivity,t=e._currentEffect;e._currentEffect=this;try{this._lastValue=this.expression()}catch(r){console.error("Error in reactive expression:",r)}if(e._currentEffect=t,e._subscribeEffect(this),this._lastValue!=null)try{this.handler(this._lastValue)}catch(r){console.error("Error in reactive handler:",r)}}run(){if(this._consecutiveTriggers++,this._consecutiveTriggers>100)return console.error("Reactivity loop detected: an effect triggered 100 consecutive times without settling. This usually means an effect is modifying a variable it also depends on.",this.element||this),!1;var e=this._reactivity;e._unsubscribeEffect(this);var t=this.dependencies;this.dependencies=new Map;var r=e._currentEffect;e._currentEffect=this;var i;try{i=this.expression()}catch(n){return console.error("Error in reactive expression:",n),this.dependencies=t,e._currentEffect=r,e._subscribeEffect(this),!0}if(e._currentEffect=r,e._subscribeEffect(this),e._cleanupOrphanedDeps(t),!_i(i,this._lastValue)){this._lastValue=i;try{this.handler(i)}catch(n){console.error("Error in reactive handler:",n)}}return!0}resetTriggerCount(){this._consecutiveTriggers=0}stop(){this._isStopped||(this._isStopped=!0,this._reactivity._unsubscribeEffect(this),this._reactivity._cleanupOrphanedDeps(this.dependencies),this._reactivity._pendingEffects.delete(this))}},ae=class{constructor(){this._objectState=new WeakMap,this._globalSubscriptions=new Map,this._nextId=0,this._currentEffect=null,this._pendingEffects=new Set,this._isRunScheduled=!1}_getObjectState(e){var t=this._objectState.get(e);return t||this._objectState.set(e,t={id:String(++this._nextId),subscriptions:null,propertyHandler:null,attributeObservers:null}),t}get isTracking(){return this._currentEffect!==null}trackGlobalSymbol(e){this._currentEffect.dependencies.set("symbol:global:"+e,{type:"symbol",name:e,scope:"global"})}trackElementSymbol(e,t){if(t){var r=this._getObjectState(t).id;this._currentEffect.dependencies.set("symbol:element:"+e+":"+r,{type:"symbol",name:e,scope:"element",element:t})}}trackProperty(e,t){e==null||typeof e!="object"||e._hsSkipTracking||this._currentEffect.dependencies.set("property:"+this._getObjectState(e).id,{type:"property",object:e,name:t})}trackAttribute(e,t){e instanceof Element&&this._currentEffect.dependencies.set("attribute:"+t+":"+this._getObjectState(e).id,{type:"attribute",element:e,name:t})}notifyGlobalSymbol(e){var t=this._globalSubscriptions.get(e);if(t)for(var r of t)this._scheduleEffect(r)}notifyElementSymbol(e,t){if(t){var r=this._getObjectState(t);if(r.subscriptions){var i=r.subscriptions.get(e);if(i)for(var n of i)this._scheduleEffect(n)}}}notifyProperty(e){if(!(e==null||typeof e!="object"||e._hsSkipTracking)){var t=this._objectState.get(e);t&&t.propertyHandler&&t.propertyHandler.queueAll()}}_scheduleEffect(e){if(!e._isStopped&&(this._pendingEffects.add(e),!this._isRunScheduled)){this._isRunScheduled=!0;var t=this;queueMicrotask(function(){t._runPendingEffects()})}}_runPendingEffects(){this._isRunScheduled=!1;var e=Array.from(this._pendingEffects);this._pendingEffects.clear();for(var t=0;t<e.length;t++){var r=e[t];if(!r._isStopped){if(r.element&&!r.element.isConnected){r.stop();continue}r.run()}}if(this._pendingEffects.size===0)for(var t=0;t<e.length;t++)e[t]._isStopped||e[t].resetTriggerCount()}_subscribeEffect(e){var t=this;for(var[r,i]of e.dependencies)if(i.type==="symbol"&&i.scope==="global")t._globalSubscriptions.has(i.name)||t._globalSubscriptions.set(i.name,new Set),t._globalSubscriptions.get(i.name).add(e);else if(i.type==="symbol"&&i.scope==="element"){var n=t._getObjectState(i.element);n.subscriptions||(n.subscriptions=new Map),n.subscriptions.has(i.name)||n.subscriptions.set(i.name,new Set),n.subscriptions.get(i.name).add(e)}else i.type==="attribute"?t._subscribeAttributeDependency(i.element,i.name,e):i.type==="property"&&t._subscribePropertyDependency(i.object,i.name,e)}_subscribeAttributeDependency(e,t,r){var i=this,n=i._getObjectState(e);if(n.attributeObservers||(n.attributeObservers={}),!n.attributeObservers[t]){var o=new Set,a=new MutationObserver(function(){for(var l of o)i._scheduleEffect(l)});a.observe(e,{attributes:!0,attributeFilter:[t]}),n.attributeObservers[t]={effects:o,observer:a}}n.attributeObservers[t].effects.add(r)}_subscribePropertyDependency(e,t,r){var i=this,n=i._getObjectState(e);if(!n.propertyHandler){var o=new Set,a=function(){for(var u of o)i._scheduleEffect(u)},l;e instanceof Element?(e.addEventListener("input",a),e.addEventListener("change",a),l=function(){e.removeEventListener("input",a),e.removeEventListener("change",a)}):l=function(){},n.propertyHandler={effects:o,queueAll:a,remove:l}}n.propertyHandler.effects.add(r)}_unsubscribeEffect(e){var t=this;for(var[r,i]of e.dependencies)if(i.type==="symbol"&&i.scope==="global"){var n=t._globalSubscriptions.get(i.name);n&&(n.delete(e),n.size===0&&t._globalSubscriptions.delete(i.name))}else if(i.type==="symbol"&&i.scope==="element"){var o=t._getObjectState(i.element);if(o.subscriptions){var n=o.subscriptions.get(i.name);n&&(n.delete(e),n.size===0&&o.subscriptions.delete(i.name))}}else if(i.type==="attribute"&&i.element){var o=t._getObjectState(i.element);o.attributeObservers&&o.attributeObservers[i.name]&&o.attributeObservers[i.name].effects.delete(e)}else if(i.type==="property"&&i.object){var o=t._getObjectState(i.object);o.propertyHandler&&o.propertyHandler.effects.delete(e)}}_cleanupOrphanedDeps(e){var t=this;for(var[r,i]of e)if(i.type==="attribute"&&i.element){var n=t._getObjectState(i.element);if(n.attributeObservers&&n.attributeObservers[i.name]){var o=n.attributeObservers[i.name];o.effects.size===0&&(o.observer.disconnect(),delete n.attributeObservers[i.name])}}else if(i.type==="property"&&i.object){var n=t._getObjectState(i.object);n.propertyHandler&&n.propertyHandler.effects.size===0&&(n.propertyHandler.remove(),n.propertyHandler=null)}}createEffect(e,t,r){var i=new Ie(e,t,r&&r.element||null,this);if(i.initialize(),i.element){var n=i.element._hyperscript??={};n.effects??=new Set,n.effects.add(i)}return function(){i.stop()}}stopElementEffects(e){var t=e._hyperscript;if(!(!t||!t.effects)){for(var r of t.effects)r.stop();delete t.effects}}};var le=class{morph(e,t,r={}){var i;if(typeof t=="string"){var n=document.createElement("template");n.innerHTML=t,i=n.content}else if(t instanceof DocumentFragment)i=t;else if(t instanceof Element)i=document.createDocumentFragment(),i.append(t.cloneNode(!0));else throw new Error("morph requires an HTML string, element, or document fragment");var o=i.firstElementChild;o&&!o.nextElementSibling&&o.tagName===e.tagName&&(vi(e,o),i=o);var{persistentIds:a,idMap:l}=Hi(e,i),u=document.createElement("div");u.hidden=!0,(document.body||e.parentElement).after(u);var h={target:e,idMap:l,persistentIds:a,pantry:u,futureMatches:new WeakSet,callbacks:r};mi(h,e,i),r.beforeNodeRemoved?.(u),u.remove()}};function mi(s,e,t,r=null,i=null){e instanceof HTMLTemplateElement&&t instanceof HTMLTemplateElement&&(e=e.content,t=t.content),r||=e.firstChild;let n=t.firstChild;for(;n;){let o;if(r&&r!==i&&(o=Pi(s,n,r,i),o&&o!==r)){let l=r;for(;l&&l!==o;){let u=l;l=l.nextSibling,u instanceof Element&&(s.idMap.has(u)||pi(s,u,n))?Le(e,u,i):ci(s,u)}}if(!o&&n instanceof Element&&s.persistentIds.has(n.id)){let l=CSS.escape(n.id);o=s.target.id===n.id&&s.target||s.target.querySelector('[id="'+l+'"]')||s.pantry.querySelector('[id="'+l+'"]');let u=o;for(;u=u.parentNode;){let h=s.idMap.get(u);h&&(h.delete(o.id),h.size||s.idMap.delete(u))}Le(e,o,r)}if(o){hi(o,n,s),r=o.nextSibling,n=n.nextSibling;continue}let a=n.nextSibling;if(s.idMap.has(n)){let l=document.createElement(n.tagName);e.insertBefore(l,r),hi(l,n,s),r=l.nextSibling}else e.insertBefore(n,r),s.callbacks.afterNodeAdded?.(n),r=n.nextSibling;n=a}for(;r&&r!==i;){let o=r;r=r.nextSibling,ci(s,o)}}function hi(s,e,t){s instanceof Element&&(vi(s,e),s instanceof HTMLTextAreaElement&&s.defaultValue!==e.defaultValue&&(s.value=e.value),(!s.isEqualNode(e)||e.tagName==="TEMPLATE"||e.querySelector?.("template"))&&mi(t,s,e),t.callbacks.afterNodeMorphed?.(s))}function Pi(s,e,t,r){if(!(e instanceof Element))return null;var i=null,n=0,o=10,a=s.idMap.get(e),l=a?.size||0;if(e.id&&!a)return null;for(var u=t;u&&u!==r;){var h=s.idMap.get(u);if(Di(u,e)){if(h&&a&&[...h].some(f=>a.has(f)))return u;if(!h){if(o>0&&u.isEqualNode(e))return u;i||(i=u)}}if(n+=h?.size||0,n>l||u.contains(document.activeElement)||--o<1&&l===0)break;u=u.nextSibling}return i&&pi(s,i,e)?null:i}function pi(s,e,t){if(s.futureMatches.has(e))return!0;for(var r=t.nextSibling,i=0;r&&i<10;r=r.nextSibling,i++)if(r instanceof Element&&e.isEqualNode(r))return s.futureMatches.add(e),!0;return!1}function ci(s,e){s.idMap.has(e)?Le(s.pantry,e,null):(s.callbacks.beforeNodeRemoved?.(e),e.remove())}function Le(s,e,t){if(s.moveBefore)try{s.moveBefore(e,t);return}catch{}s.insertBefore(e,t)}function vi(s,e){for(var t of e.attributes)s.getAttribute(t.name)!==t.value&&(s.setAttribute(t.name,t.value),t.name==="value"&&s instanceof HTMLInputElement&&s.type!=="file"&&(s.value=t.value));for(var r=s.attributes.length-1;r>=0;r--){var t=s.attributes[r];t&&!e.hasAttribute(t.name)&&s.removeAttribute(t.name)}}function Di(s,e){return!(s instanceof Element)||s.tagName!==e.tagName||s.tagName==="SCRIPT"&&!s.isEqualNode(e)?!1:!s.id||s.id===e.id}function Hi(s,e){var t=ji(s,"[id]"),r=e.querySelectorAll("[id]"),i=Wi(t,r),n=new Map;return fi(n,i,s.parentElement,t),fi(n,i,e,r),{persistentIds:i,idMap:n}}function Wi(s,e){var t=new Set,r=new Map;for(var{id:i,tagName:n}of s)r.has(i)?t.add(i):i&&r.set(i,n);var o=new Set;for(var{id:i,tagName:n}of e)o.has(i)?t.add(i):r.get(i)===n&&o.add(i);for(var i of t)o.delete(i);return o}function fi(s,e,t,r){for(var i of r)if(e.has(i.id))for(var n=i;n&&n!==t;){var o=s.get(n);o==null&&(o=new Set,s.set(n,o)),o.add(i.id),n=n.parentElement}}function ji(s,e){var t=[...s.querySelectorAll?.(e)??[]];return s.matches?.(e)&&t.unshift(s),t}var ue=class s{#t=!1;constructor(e,t){this.globalScope=e,this.hyperscript=t}init(){var e=this,t=this.globalScope,r=this.hyperscript;t.document.addEventListener("htmx:load",function(i){e.#t=!0,r.process(i.detail.elt),e.#t=!1}),t.document.addEventListener("htmx:after:process",function(i){e.#t=!0,r.process(i.target),e.#t=!1}),typeof htmx<"u"&&(r.addAfterProcessHook(function(i){e.#t||htmx.process(i)}),htmx.version?.startsWith("4")&&htmx.registerExtension("hs-include",{htmx_config_request:function(i,n){var o=n?.ctx;if(o){var a=o.sourceElement||i,l=s.#i(a);if(l){var u=s.#h(l.value,l.scopeElt),h=o.request?.body;if(h instanceof FormData)for(var f in u)h.set(f,u[f])}}}}))}static#i(e){var t=e.getAttribute("hs-include");if(t!==null)return{value:t,scopeElt:e};for(var r=e.parentElement;r;){if(t=r.getAttribute("hs-include:inherited"),t!==null)return{value:t,scopeElt:r};r=r.parentElement}return null}static#s(e){return e?._hyperscript?.elementScope||{}}static#o(e){if(e==null)return"";if(typeof e=="object")try{return JSON.stringify(e)}catch{return""}return String(e)}static#a(e,t){for(var r=t;r;){var i=r._hyperscript?.elementScope;if(i&&e in i)return i[e];r=r.parentElement}}static#h(e,t){var r={},i=e.trim();if(i==="*"){var n=this.#s(t);for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o[0]===":"?o.slice(1):o]=this.#o(n[o]));return r}var a=this;return i.split(",").forEach(function(l){if(l=l.trim(),!!l){if(l[0]===":"){var u=l.slice(1),h=a.#s(t),f=":"+u;f in h&&(r[u]=a.#o(h[f]))}else if(l[0]==="^"){var u=l.slice(1),p=a.#a(":"+u,t);p!==void 0&&(r[u]=a.#o(p))}else if(l[0]==="#"){var c=l.lastIndexOf(":");if(c>0){var T=l.slice(0,c),u=l.slice(c+1),m=document.querySelector(T);if(m){var h=a.#s(m),f=":"+u;f in h&&(r[u]=a.#o(h[f]))}}}}}),r}};var tt={};N(tt,{ArrayIndex:()=>Be,AsExpression:()=>je,AttributeRefAccess:()=>G,BeepExpression:()=>_e,BlockLiteral:()=>Me,CollectionExpression:()=>Ye,ComparisonOperator:()=>Ge,DotOrColonPath:()=>et,FunctionCall:()=>Ue,InExpression:()=>We,LogicalNot:()=>Re,LogicalOperator:()=>$e,MathOperator:()=>ze,NegativeNumber:()=>Fe,OfExpression:()=>De,ParenthesizedExpression:()=>Oe,PossessiveExpression:()=>He,PropertyAccess:()=>Pe,SymbolRef:()=>Ce});var Oe=class s extends y{static grammarName="parenthesized";static expressionType="leaf";constructor(e){super(),this.expr=e,this.args={value:e}}static parse(e){if(e.matchOpToken("(")){var t=e.clearFollows();try{var r=e.requireElement("expression")}finally{e.restoreFollows(t)}return e.requireOpToken(")"),new s(r)}}resolve(e,{value:t}){return t}},Me=class s extends y{static grammarName="blockLiteral";static expressionType="leaf";constructor(e,t){super(),this.params=e,this.expr=t}static parse(e){if(e.matchOpToken("\\")){var t=[],r=e.matchTokenType("IDENTIFIER");if(r)for(t.push(r);e.matchOpToken(",");)t.push(e.requireTokenType("IDENTIFIER"));e.requireOpToken("-"),e.requireOpToken(">");var i=e.requireElement("expression");return new s(t,i)}}resolve(e){var t=this.params,r=this.expr;return function(){for(var i=0;i<t.length;i++)e.locals[t[i].value]=arguments[i];return r.evaluate(e)}}},Fe=class s extends y{static grammarName="negativeNumber";constructor(e){super(),this.root=e,this.args={value:e}}static parse(e){if(e.matchOpToken("-")){var t=e.requireElement("negativeNumber");return new s(t)}else return e.requireElement("primaryExpression")}resolve(e,{value:t}){return-t}},Re=class s extends y{static grammarName="logicalNot";static expressionType="unary";constructor(e){super(),this.root=e,this.args={value:e}}static parse(e){if(e.matchToken("not")){var t=e.requireElement("unaryExpression");return new s(t)}}resolve(e,{value:t}){return!t}},Ce=class s extends y{static grammarName="symbol";static assignable=!0;constructor(e,t,r,i){super(),this.token=e,this.scope=t,this.name=r,this.targetExpr=i||null}static parse(e){var t=null;e.matchToken("global")?t="global":e.matchToken("element")?(t="element",e.matchOpToken("'")&&e.requireToken("s")):e.matchToken("dom")?t="inherited":e.matchToken("local")&&(t="local");let r=e.matchOpToken(":"),i=!r&&e.matchOpToken("^"),n=e.matchTokenType("IDENTIFIER");if(n&&n.value){var o=n.value;r?o=":"+o:i&&(o="^"+o),t===null&&(o.startsWith("$")?t="global":o.startsWith(":")?t="element":o.startsWith("^")?t="inherited":t="local");var a=null;if(t==="inherited"&&e.matchToken("on")){var l=e.pushFollows("to","into","before","after","then");try{a=e.requireElement("expression")}finally{e.popFollows(l)}}return new s(n,t,o,a)}}resolve(e){return e.meta.runtime.resolveSymbol(this.name,e,this.scope,this.targetExpr?this.targetExpr.evaluate(e):null)}get lhs(){return{}}set(e,t,r){e.meta.runtime.setSymbol(this.name,e,this.scope,r,this.targetExpr?this.targetExpr.evaluate(e):null)}},_e=class s extends y{static grammarName="beepExpression";static expressionType="unary";constructor(e){super(),this.expression=e,this.expression.booped=!0,this.args={value:e}}static parse(e){if(e.matchToken("beep!")){var t=e.parseElement("unaryExpression");if(t)return new s(t)}}resolve(e,{value:t}){return e.meta.runtime.beepValueToConsole(e.me,this.expression,t),t}},Pe=class s extends y{static grammarName="propertyAccess";static expressionType="indirect";static assignable=!0;constructor(e,t){super(),this.root=e,this.prop=t,this.args={root:e}}static parse(e,t){if(e.matchOpToken(".")){var r=e.requireTokenType("IDENTIFIER"),i=new s(t,r);return e.parseElement("indirectExpression",i)}}resolve(e,{root:t}){return e.meta.runtime.resolveProperty(t,this.prop.value)}get lhs(){return{root:this.root}}set(e,t,r){e.meta.runtime.nullCheck(t.root,this.root);var i=e.meta.runtime;i.implicitLoop(t.root,n=>{i.setProperty(n,this.prop.value,r)})}delete(e,t){e.meta.runtime.nullCheck(t.root,this.root);var r=e.meta.runtime,i=this.prop.value;r.implicitLoop(t.root,n=>{delete n[i],r.notifyMutation(n)})}},De=class s extends y{static grammarName="ofExpression";static expressionType="indirect";static assignable=!0;constructor(e,t,r,i,n,o){super(),this.prop=e,this.root=t,this.attribute=r,this.expression=i,this.args=n,this._urRoot=o,this._prop=o.name,this._isAttribute=o.type==="attributeRef",this._isStyle=o.type==="styleRef",this._isComputed=o.type==="computedStyleRef"}static parse(e,t){if(e.matchToken("of")){for(var r=e.requireElement("unaryExpression"),i=null,n=t;n.root;)i=n,n=n.root;var o=["symbol","attributeRef","styleRef","computedStyleRef"];o.includes(n.type)||e.raiseError("Cannot take a property of a non-symbol: "+n.type);var a=n.type==="attributeRef",l=n.type==="styleRef"||n.type==="computedStyleRef",u=a||l?n:null,h=n.name,f=new s(n.token,r,u,t,{root:r},n);return n.type==="attributeRef"&&(f.attribute=n),i?(i.root=f,i.args={root:f}):t=f,e.parseElement("indirectExpression",t)}}resolve(e,{root:t}){return this._isAttribute?e.meta.runtime.resolveAttribute(t,this._prop):this._isComputed?e.meta.runtime.resolveComputedStyle(t,this._prop):this._isStyle?e.meta.runtime.resolveStyle(t,this._prop):e.meta.runtime.resolveProperty(t,this._prop)}get lhs(){return{root:this.root}}set(e,t,r){if(e.meta.runtime.nullCheck(t.root,this.root),this._isAttribute)e.meta.runtime.implicitLoop(t.root,n=>{r==null?n.removeAttribute(this._prop):n.setAttribute(this._prop,r)});else if(this._isStyle)e.meta.runtime.implicitLoop(t.root,n=>{n.style[this._prop]=r});else{var i=e.meta.runtime;i.implicitLoop(t.root,n=>{i.setProperty(n,this._prop,r)})}}delete(e,t){e.meta.runtime.nullCheck(t.root,this.root);var r=e.meta.runtime,i=this._prop;this._isAttribute?r.implicitLoop(t.root,n=>n.removeAttribute(i)):this._isStyle?r.implicitLoop(t.root,n=>n.style.removeProperty(i)):r.implicitLoop(t.root,n=>{delete n[i],r.notifyMutation(n)})}},He=class s extends y{static grammarName="possessive";static expressionType="indirect";static assignable=!0;constructor(e,t,r){super(),this.root=e,this.attribute=t,this.prop=r,this.args={root:e}}static parse(e,t){var r=e.matchOpToken("'");if(r||t.type==="symbol"&&(t.name==="my"||t.name==="its"||t.name==="your")&&(e.currentToken().type==="IDENTIFIER"||e.currentToken().type==="ATTRIBUTE_REF"||e.currentToken().type==="STYLE_REF")){r&&e.requireToken("s");var i,n,o;i=e.parseElement("attributeRef"),i==null&&(n=e.parseElement("styleRef"),n==null&&(o=e.requireTokenType("IDENTIFIER")));var a=new s(t,i||n,o);return e.parseElement("indirectExpression",a)}}resolve(e,{root:t}){var r;return this.attribute?this.attribute.type==="computedStyleRef"?r=e.meta.runtime.resolveComputedStyle(t,this.attribute.name):this.attribute.type==="styleRef"?r=e.meta.runtime.resolveStyle(t,this.attribute.name):r=e.meta.runtime.resolveAttribute(t,this.attribute.name):r=e.meta.runtime.resolveProperty(t,this.prop.value),r}get lhs(){return{root:this.root}}set(e,t,r){if(e.meta.runtime.nullCheck(t.root,this.root),this.attribute){var i=this.attribute.name;this.attribute.type==="styleRef"?e.meta.runtime.implicitLoop(t.root,a=>{a.style[i]=r}):e.meta.runtime.implicitLoop(t.root,a=>{r==null?a.removeAttribute(i):a.setAttribute(i,r)})}else{var n=e.meta.runtime,o=this.prop.value;n.implicitLoop(t.root,a=>{n.setProperty(a,o,r)})}}},We=class s extends y{static grammarName="inExpression";static expressionType="indirect";static assignable=!0;constructor(e,t){super(),this.root=e,this.target=t,this.args={root:e,target:t}}static parse(e,t){if(e.matchToken("in")){var r=e.requireElement("unaryExpression"),i=new s(t,r);return e.parseElement("indirectExpression",i)}}resolve(e,{root:t,target:r}){if(t==null)return[];var i=[];if(t.css)e.meta.runtime.implicitLoop(r,function(o){for(var a=o.querySelectorAll(t.css),l=0;l<a.length;l++)i.push(a[l])});else if(t instanceof Element){var n=!1;if(e.meta.runtime.implicitLoop(r,function(o){o.contains(t)&&(n=!0)}),n)return t}else e.meta.runtime.implicitLoop(t,function(o){e.meta.runtime.implicitLoop(r,function(a){o===a&&i.push(o)})});return i}get lhs(){return{root:this.root,target:this.target}}set(e,t,r){var i=this.resolve(e,t);e.meta.runtime.replaceInDom(i,r)}},je=class s extends y{static grammarName="asExpression";static expressionType="indirect";constructor(e,t){super(),this.root=e,this.conversion=t,this.args={root:e}}static parse(e,t){if(e.matchToken("as")){e.matchToken("a")||e.matchToken("an");for(var r=e.requireElement("dotOrColonPath").evalStatically(),i=new s(t,r);e.matchOpToken("|");)r=e.requireElement("dotOrColonPath").evalStatically(),i=new s(i,r);return e.parseElement("indirectExpression",i)}}resolve(e,{root:t}){return e.meta.runtime.convertValue(t,this.conversion)}},Ue=class s extends y{static grammarName="functionCall";static expressionType="indirect";constructor(e,t,r,i){super(),this.root=e,this.argExpressions=t,this.args=r,this._isMethodCall=i,this._parseRoot=e}static parse(e,t){if(e.matchOpToken("(")){var r=[];if(!e.matchOpToken(")")){do r.push(e.requireElement("expression"));while(e.matchOpToken(","));e.requireOpToken(")")}var i;return t.root?i=new s(t,r,{target:t.root,argVals:r},!0):i=new s(t,r,{target:t,argVals:r},!1),e.parseElement("indirectExpression",i)}}resolve(e,{target:t,argVals:r}){if(this._isMethodCall){e.meta.runtime.nullCheck(t,this._parseRoot.root);var i=this._parseRoot.prop.value,n=t[i];e.meta.runtime.nullCheck(n,this._parseRoot),n.hyperfunc&&r.push(e);var o=n.apply(t,r);return e.meta.runtime.maybeNotify(t,i),o}else return e.meta.runtime.nullCheck(t,this._parseRoot),t.hyperfunc&&r.push(e),t(...r)}},G=class s extends y{static grammarName="attributeRefAccess";static expressionType="indirect";static assignable=!0;constructor(e,t){super(),this.root=e,this.attribute=t,this.args={root:e}}static parse(e,t){var r=e.parseElement("attributeRef");if(r)return new s(t,r)}resolve(e,{root:t}){return e.meta.runtime.resolveAttribute(t,this.attribute.name)}get lhs(){return{root:this.root}}set(e,t,r){e.meta.runtime.nullCheck(t.root,this.root),e.meta.runtime.implicitLoop(t.root,i=>{r==null?i.removeAttribute(this.attribute.name):i.setAttribute(this.attribute.name,r)})}},Be=class s extends y{static grammarName="arrayIndex";static expressionType="indirect";static assignable=!0;constructor(e,t,r,i,n){super(),this.root=e,this.prop=t,this.firstIndex=t,this.secondIndex=r,this.andBefore=i,this.andAfter=n,this.args={root:e,firstIndex:t,secondIndex:r}}static parse(e,t){if(e.matchOpToken("[")){var r=!1,i=!1,n=null,o=null;if(e.matchOpToken(".."))r=!0,n=e.requireElement("expression");else if(n=e.requireElement("expression"),e.matchOpToken("..")){i=!0;var a=e.currentToken();a.type!=="R_BRACKET"&&(o=e.parseElement("expression"))}e.requireOpToken("]");var l=new s(t,n,o,r,i);return e.parseElement("indirectExpression",l)}}resolve(e,{root:t,firstIndex:r,secondIndex:i}){return t==null?null:this.andBefore?(r<0&&(r=t.length+r),t.slice(0,r+1)):this.andAfter?i!=null?(i<0&&(i=t.length+i),t.slice(r,i+1)):t.slice(r):t[r]}get lhs(){return{root:this.root,index:this.firstIndex}}set(e,t,r){e.meta.runtime.nullCheck(t.root,this.root),t.root[t.index]=r}delete(e,t){if(this.andBefore||this.andAfter)throw new Error("Cannot remove a slice - use a single index");e.meta.runtime.nullCheck(t.root,this.root);var r=e.meta.runtime,i=t.root,n=t.index;Array.isArray(i)?(n<0&&(n=i.length+n),i.splice(n,1)):delete i[n],r.notifyMutation(i)}},ze=class s extends y{static grammarName="mathOperator";constructor(e,t,r){super(),this.lhs=e,this.rhs=r,this.operator=t,this.args={lhs:e,rhs:r}}static parse(e){var t=e.parseElement("collectionExpression"),r,i=null;for(r=e.matchAnyOpToken("+","-","*","/")||e.matchToken("mod");r;){i=i||r;var n=r.value;i.value!==n&&e.raiseError("You must parenthesize math operations with different operators");var o=e.parseElement("collectionExpression");t=new s(t,n,o),r=e.matchAnyOpToken("+","-","*","/")||e.matchToken("mod")}return t}resolve(e,{lhs:t,rhs:r}){if(this.operator==="+")return Array.isArray(t)?t.concat(r):t+r;if(this.operator==="-")return t-r;if(this.operator==="*")return t*r;if(this.operator==="/")return t/r;if(this.operator==="mod")return t%r}},Ge=class s extends y{static grammarName="comparisonOperator";constructor(e,t,r,i,n,o,a){super(),this.operator=t,this.typeName=i,this.nullOk=n,this.ignoringCase=o,this.lhs=e,this.rhs=r,this.rhs2=a,this.args={lhs:e,rhs:r,rhs2:a}}sloppyContains(e,t,r){if(t.contains)return t.contains(r);if(t.includes)return t.includes(r);throw new Error("The value of "+e.sourceFor()+" does not have a contains or includes method on it")}sloppyMatches(e,t,r){if(t.match)return!!t.match(r);if(t.matches)return t.matches(r);throw new Error("The value of "+e.sourceFor()+" does not have a match or matches method on it")}static parse(e){var t=e.parseElement("mathOperator"),r=e.matchAnyOpToken("<",">","<=",">=","==","===","!=","!=="),i=r?r.value:null,n=!0,o=!1;if(i==null&&(e.matchToken("is")||e.matchToken("am")?e.matchToken("not")?e.matchToken("in")?i="not in":e.matchToken("a")||e.matchToken("an")?(i="not a",o=!0):e.matchToken("empty")?(i="not empty",n=!1):e.matchToken("between")?i="not between":e.matchToken("really")?(i="!==",e.matchToken("equal")&&e.matchToken("to")):e.matchToken("equal")?(e.matchToken("to"),i="!="):i="is not":e.matchToken("in")?i="in":e.matchToken("a")||e.matchToken("an")?(i="a",o=!0):e.matchToken("empty")?(i="empty",n=!1):e.matchToken("between")?i="between":e.matchToken("less")?(e.requireToken("than"),e.matchToken("or")?(e.requireToken("equal"),e.requireToken("to"),i="<="):i="<"):e.matchToken("greater")?(e.requireToken("than"),e.matchToken("or")?(e.requireToken("equal"),e.requireToken("to"),i=">="):i=">"):e.matchToken("really")?(i="===",e.matchToken("equal")&&e.matchToken("to")):e.matchToken("equal")?(e.matchToken("to"),i="=="):i="is":e.matchToken("equals")?i="==":e.matchToken("really")?(e.requireToken("equals"),i="==="):e.matchToken("exist")||e.matchToken("exists")?(i="exist",n=!1):e.matchToken("matches")||e.matchToken("match")?i="match":e.matchToken("contains")||e.matchToken("contain")?i="contain":e.matchToken("includes")||e.matchToken("include")?i="include":e.matchToken("starts")?(e.requireToken("with"),i="start with"):e.matchToken("ends")?(e.requireToken("with"),i="end with"):e.matchToken("precedes")||e.matchToken("precede")?i="precede":e.matchToken("follows")||e.matchToken("follow")?i="follow":(e.matchToken("do")||e.matchToken("does"))&&(e.requireToken("not"),e.matchToken("matches")||e.matchToken("match")?i="not match":e.matchToken("contains")||e.matchToken("contain")?i="not contain":e.matchToken("exist")?(i="not exist",n=!1):e.matchToken("include")?i="not include":e.matchToken("start")?(e.requireToken("with"),i="not start with"):e.matchToken("end")?(e.requireToken("with"),i="not end with"):e.matchToken("precede")?i="not precede":e.matchToken("follow")?i="not follow":e.raiseExpected("matches","contains","starts with","ends with","precede","follow"))),i){var a,l,u;o?(a=e.requireTokenType("IDENTIFIER"),l=!e.matchOpToken("!")):n&&(u=e.requireElement("mathOperator"),(i==="match"||i==="not match")&&(u=u.css?u.css:u));var h=null;(i==="between"||i==="not between")&&(e.requireToken("and"),h=e.requireElement("mathOperator"));var f=!1;e.matchToken("ignoring")&&(e.requireToken("case"),f=!0);var p=t;t=new s(p,i,u,a,l,f,h)}return t}resolve(e,{lhs:t,rhs:r,rhs2:i}){let n=this.operator,o=this.lhs,a=this.rhs,l=this.typeName,u=this.nullOk;if(this.ignoringCase&&(typeof t=="string"&&(t=t.toLowerCase()),typeof r=="string"&&(r=r.toLowerCase())),n==="is")return r===void 0&&a.type==="symbol"&&a.scope==="local"&&a.name!=="undefined"&&a.name!=="null"?!!e.meta.runtime.resolveProperty(t,a.name):t==r;if(n==="is not")return r===void 0&&a.type==="symbol"&&a.scope==="local"&&a.name!=="undefined"&&a.name!=="null"?!e.meta.runtime.resolveProperty(t,a.name):t!=r;if(n==="==")return t==r;if(n==="!=")return t!=r;if(n==="===")return t===r;if(n==="!==")return t!==r;if(n==="<")return t<r;if(n===">")return t>r;if(n==="<=")return t<=r;if(n===">=")return t>=r;if(n==="match")return t!=null&&this.sloppyMatches(o,t,r);if(n==="not match")return t==null||!this.sloppyMatches(o,t,r);if(n==="in")return r!=null&&this.sloppyContains(a,r,t);if(n==="not in")return r==null||!this.sloppyContains(a,r,t);if(n==="contain"||n==="include")return t!=null&&this.sloppyContains(o,t,r);if(n==="not contain"||n==="not include")return t==null||!this.sloppyContains(o,t,r);if(n==="start with")return t!=null&&String(t).startsWith(r);if(n==="not start with")return t==null||!String(t).startsWith(r);if(n==="end with")return t!=null&&String(t).endsWith(r);if(n==="not end with")return t==null||!String(t).endsWith(r);if(n==="between")return t>=r&&t<=i;if(n==="not between")return t<r||t>i;if(n==="precede")return t!=null&&r!=null&&(t.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_FOLLOWING)!==0;if(n==="not precede")return t==null||r==null||(t.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_FOLLOWING)===0;if(n==="follow")return t!=null&&r!=null&&(t.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_PRECEDING)!==0;if(n==="not follow")return t==null||r==null||(t.compareDocumentPosition(r)&Node.DOCUMENT_POSITION_PRECEDING)===0;if(n==="empty")return e.meta.runtime.isEmpty(t);if(n==="not empty")return!e.meta.runtime.isEmpty(t);if(n==="exist")return e.meta.runtime.doesExist(t);if(n==="not exist")return!e.meta.runtime.doesExist(t);if(n==="a")return e.meta.runtime.typeCheck(t,l.value,u);if(n==="not a")return!e.meta.runtime.typeCheck(t,l.value,u);throw new Error("Unknown comparison : "+n)}},$e=class s extends y{static grammarName="logicalOperator";static expressionType="top";constructor(e,t,r){super(),this.operator=t,this.lhs=e,this.rhs=r,this.args={lhs:e,rhs:r}}static parse(e){var t=e.parseElement("comparisonOperator"),r,i=null;for(r=e.matchToken("and")||e.matchToken("or");r;){i=i||r,i.value!==r.value&&e.raiseError("You must parenthesize logical operations with different operators");var n=e.requireElement("comparisonOperator");let o=r.value;t=new s(t,o,n),r=e.matchToken("and")||e.matchToken("or")}return t}resolve(e,{lhs:t,rhs:r}){return this.operator==="and"?t&&r:t||r}evaluate(e){var t=this,r=this.operator==="or",i=this.lhs.evaluate(e),n=function(o){if(!!o===r)return o;var a=t.rhs.evaluate(e);return a&&a.then?a.then(l=>t.resolve(e,{lhs:o,rhs:l})):t.resolve(e,{lhs:o,rhs:a})};return i&&i.then?i.then(n):n(i)}},Qe=class extends y{constructor(e,t){super(),this.type="dotOrColonPath",this.path=e,this.separator=t}evalStatically(){return this.path.join(this.separator?this.separator:"")}resolve(){return this.evalStatically()}},Ye=class extends y{static grammarName="collectionExpression";static KEYWORDS=["where","sorted","mapped","split","joined"];static parseOperand(e){var t=e.pushFollows(...this.KEYWORDS);try{return e.requireElement("expression")}finally{e.popFollows(t)}}static parse(e){for(var t=e.parseElement("unaryExpression"),r=!0;r;)if(r=!1,e.matchToken("where"))t=new Ke(t,this.parseOperand(e)),r=!0;else if(e.matchToken("sorted")){e.requireToken("by");var i=this.parseOperand(e),n=e.matchToken("descending");t=new Je(t,i,!!n),r=!0}else e.matchToken("mapped")?(e.requireToken("to"),t=new Xe(t,this.parseOperand(e)),r=!0):e.matchToken("split")?(e.requireToken("by"),t=new Ze(t,this.parseOperand(e)),r=!0):e.matchToken("joined")&&(e.requireToken("by"),t=new Ve(t,this.parseOperand(e)),r=!0);return t}},Ke=class extends y{constructor(e,t){super(),this.root=e,this.condition=t,this.args={root:e}}resolve(e,{root:t}){if(!t)return t;for(var r=[],i=Array.from(t),n=0;n<i.length;n++)e.beingTested=i[n],this.varName&&(e.locals[this.varName]=i[n]),this.condition.evaluate(e)&&r.push(i[n]);return e.beingTested=null,r}},Je=class extends y{constructor(e,t,r){super(),this.root=e,this.key=t,this.descending=r,this.args={root:e}}resolve(e,{root:t}){if(!t)return t;for(var r=Array.from(t),i=[],n=0;n<r.length;n++)e.beingTested=r[n],i.push(this.key.evaluate(e));e.beingTested=null;var o=r.map(function(l,u){return u}),a=this.descending?-1:1;return o.sort(function(l,u){var h=i[l],f=i[u];return h==f?0:(h<f?-1:1)*a}),o.map(function(l){return r[l]})}},Xe=class extends y{constructor(e,t){super(),this.root=e,this.projection=t,this.args={root:e}}resolve(e,{root:t}){if(!t)return t;for(var r=Array.from(t),i=[],n=0;n<r.length;n++)e.beingTested=r[n],i.push(this.projection.evaluate(e));return e.beingTested=null,i}},Ze=class extends y{constructor(e,t){super(),this.args={root:e,delimiter:t}}resolve(e,{root:t,delimiter:r}){return t&&String(t).split(r)}},Ve=class extends y{constructor(e,t){super(),this.args={root:e,delimiter:t}}resolve(e,{root:t,delimiter:r}){return t&&Array.from(t).join(r)}},et=class extends y{static grammarName="dotOrColonPath";static parse(e){var t=e.matchTokenType("IDENTIFIER");if(t){var r=[t.value],i=e.matchOpToken(".")||e.matchOpToken(":");if(i)do r.push(e.requireTokenType("IDENTIFIER","NUMBER").value);while(e.matchOpToken(i.value));return new Qe(r,i?i.value:null)}}};var lt={};N(lt,{AttributeRef:()=>st,ClassRef:()=>it,IdRef:()=>rt,QueryRef:()=>nt,StyleLiteral:()=>at,StyleRef:()=>ot});var rt=class s extends y{static grammarName="idRef";static expressionType="leaf";static assignable=!0;constructor(e,t,r,i){super(),this.variant=e,this.type=e==="template"?"idRefTemplate":"idRef",this.css=t,this.value=r,this.args=e==="template"?{expr:i}:null}static parse(e){var t=e.matchTokenType("ID_REF");if(t&&t.value)if(t.template){var r=t.value.substring(2),i=O.tokenize(r),n=e.createChildParser(i),o=n.requireElement("expression");return new s("template",null,null,o)}else{let a=t.value.substring(1);return new s("static",t.value,a,null)}}resolve(e,{expr:t}={}){return this.variant==="template"?e.meta.runtime.getRootNode(e.me).getElementById(t):e.meta.runtime.getRootNode(e.me).getElementById(this.value)}get lhs(){return{}}set(e,t,r){var i=this.resolve(e);i&&e.meta.runtime.replaceInDom(i,r)}},it=class s extends y{static grammarName="classRef";static expressionType="leaf";static assignable=!0;constructor(e,t,r,i){super(),this.variant=e,this.type=e==="template"?"classRefTemplate":"classRef",this.css=t,this.className=r,this.args=e==="template"?{expr:i}:null}static parse(e){var t=e.matchTokenType("CLASS_REF");if(t&&t.value)if(t.template){var r=t.value.substring(2),i=O.tokenize(r),n=e.createChildParser(i),o=n.requireElement("expression");return new s("template",null,null,o)}else{let a=t.value,l=a.slice(1);return new s("static",a,l,null)}}resolve(e,{expr:t}={}){return this.variant==="template"?new R("."+t,e.me,!0,e.meta.runtime):new R(this.css,e.me,!0,e.meta.runtime)}get lhs(){return{}}set(e,t,r){var i=Array.from(this.resolve(e));e.meta.runtime.replaceInDom(i,r)}},nt=class s extends y{static grammarName="queryRef";static expressionType="leaf";static assignable=!0;constructor(e,t,r){super(),this.css=e,this.templateArgs=t,this.args=r?{parts:t}:null,this.template=r}static parse(e){var t=e.matchOpToken("<");if(t){var r=e.consumeUntil("/");e.requireOpToken("/"),e.requireOpToken(">");var i=r.map(function(u){return u.type==="STRING"?'"'+u.value+'"':u.value}).join(""),n,o,a;if(/\$[^=]/.test(i)){n=!0,o=O.tokenize(i,!0);var l=e.createChildParser(o);a=l.parseStringTemplate()}return new s(i,a,n)}}resolve(e,{parts:t}={}){return this.template?new re(this.css,e.me,t,e.meta.runtime):new R(this.css,e.me,!1,e.meta.runtime)}get lhs(){return this.template?{parts:this.templateArgs}:{}}set(e,t,r){var i=Array.from(this.resolve(e,t));e.meta.runtime.replaceInDom(i,r)}},st=class s extends y{static grammarName="attributeRef";static expressionType="leaf";static assignable=!0;constructor(e,t,r){super(),this.name=e,this.css=t,this.value=r}static parse(e){var t=e.matchTokenType("ATTRIBUTE_REF");if(t&&t.value){var r=t.value;if(r.startsWith("["))var i=r.substring(2,r.length-1);else var i=r.substring(1);var n="["+i+"]",o=i.split("="),a=o[0],l=o[1];return l&&(l.startsWith('"')||l.startsWith("'"))&&(l=l.substring(1,l.length-1)),new s(a,n,l)}}resolve(e){var t=e.you||e.me;if(t)return e.meta.runtime.resolveAttribute(t,this.name)}get lhs(){return{}}set(e,t,r){var i=e.you||e.me;i&&(r==null?i.removeAttribute(this.name):i.setAttribute(this.name,r))}},ot=class s extends y{static grammarName="styleRef";static expressionType="leaf";static assignable=!0;constructor(e,t){super(),this.variant=e,this.type=e==="computed"?"computedStyleRef":"styleRef",this.name=t}static parse(e){var t=e.matchTokenType("STYLE_REF");if(t&&t.value){var r=t.value.slice(1);return r.startsWith("computed-")?(r=r.slice(9),new s("computed",r)):new s("style",r)}}resolve(e){var t=e.you||e.me;if(t)return this.variant==="computed"?e.meta.runtime.resolveComputedStyle(t,this.name):e.meta.runtime.resolveStyle(t,this.name)}get lhs(){return{}}set(e,t,r){var i=e.you||e.me;i&&(i.style[this.name]=r)}},at=class s extends y{static grammarName="styleLiteral";constructor(e,t){super(),this.stringParts=e,this.args={exprs:t}}static parse(e){if(e.matchOpToken("{")){for(var t=[""],r=[];e.hasMore();){if(e.matchOpToken("\\"))e.consumeToken();else{if(e.matchOpToken("}"))break;if(e.matchToken("$")){var i=e.matchOpToken("{"),n=e.parseElement("expression");i&&e.requireOpToken("}"),r.push(n),t.push("")}else{var o=e.consumeToken();t[t.length-1]+=e.source.substring(o.start,o.end)}}t[t.length-1]+=e.lastWhitespace()}return new s(t,r)}}resolve(e,{exprs:t}){var r="";return this.stringParts.forEach(function(n,o){r+=n,o in t&&(r+=t[o])}),r}};var ft={};N(ft,{StringPostfixExpression:()=>ut,TimeExpression:()=>ht,TypeCheckExpression:()=>ct});var Ui=["em","ex","cap","ch","ic","rem","lh","rlh","vw","vh","vi","vb","vmin","vmax","cm","mm","Q","pc","pt","px"],ut=class s extends y{static grammarName="stringPostfixExpression";static expressionType="postfix";constructor(e,t){super(),this.postfix=t,this.args={value:e}}static parse(e,t){let r=e.matchAnyToken(...Ui)||e.matchOpToken("%");if(r)return new s(t,r.value)}resolve(e,{value:t}){return""+t+this.postfix}},ht=class s extends y{static grammarName="timeExpression";static expressionType="postfix";constructor(e,t){super(),this.time=e,this.factor=t,this.args={value:e}}static parse(e,t){var r=null;if(e.matchToken("s")||e.matchToken("seconds")?r=1e3:(e.matchToken("ms")||e.matchToken("milliseconds"))&&(r=1),!!r)return new s(t,r)}evalStatically(){return this.time.evalStatically()*this.factor}resolve(e,{value:t}){return t*this.factor}},ct=class s extends y{static grammarName="typeCheckExpression";static expressionType="postfix";constructor(e,t,r){super(),this.typeName=t,this.nullOk=r,this.args={value:e}}static parse(e,t){if(e.matchOpToken(":")){var r=e.requireTokenType("IDENTIFIER");if(r.value){var i=!e.matchOpToken("!");return new s(t,r,i)}}}resolve(e,{value:t}){var r=e.meta.runtime.typeCheck(t,this.typeName.value,this.nullOk);if(r)return t;throw new Error("Typecheck failed!  Expected: "+this.typeName.value)}};var yt={};N(yt,{ClosestExpr:()=>dt,PositionalExpression:()=>pt,RelativePositionalExpression:()=>mt});var mt=class s extends y{static grammarName="relativePositionalExpression";static expressionType="unary";constructor(e,t,r,i,n,o,a,l){super(),this.thingElt=e,this.from=t,this.forwardSearch=r,this.inSearch=i,this.wrapping=n,this.inElt=o,this.withinElt=a,this.operator=l,this.args={thing:e,from:t,inElt:o,withinElt:a}}static parse(e){var t=e.matchAnyToken("next","previous");if(t){var r=t.value==="next",i=e.parseElement("leaf");if(e.matchToken("from")){e.pushFollow("in");try{var n=e.requireElement("unaryExpression")}finally{e.popFollow()}}else var n=e.requireElement("implicitMeTarget");var o=!1,a;if(e.matchToken("in")){o=!0;var l=e.requireElement("unaryExpression")}else e.matchToken("within")?a=e.requireElement("unaryExpression"):a=null;var u=!1;return e.matchToken("with")&&(e.requireToken("wrapping"),u=!0),new s(i,n,r,o,u,l,a,t.value)}}scanForwardQuery(e,t,r,i){for(var n=t.querySelectorAll(r),o=0;o<n.length;o++){var a=n[o];if(a.compareDocumentPosition(e)===Node.DOCUMENT_POSITION_PRECEDING)return a}if(i)return n[0]}scanBackwardsQuery(e,t,r,i){for(var n=t.querySelectorAll(r),o=n.length-1;o>=0;o--){var a=n[o];if(a.compareDocumentPosition(e)===Node.DOCUMENT_POSITION_FOLLOWING)return a}if(i)return n[n.length-1]}scanForwardArray(e,t,r,i){var n=[];for(var o of t)(o.matches(r)||o===e)&&n.push(o);for(var a=0;a<n.length-1;a++){var o=n[a];if(o===e)return n[a+1]}if(i){var l=n[0];if(l&&l.matches(r))return l}}scanBackwardsArray(e,t,r,i){return this.scanForwardArray(e,Array.from(t).reverse(),r,i)}resolve(e,{thing:t,from:r,inElt:i,withinElt:n}){var o=t.css;if(o==null)throw new Error("Expected a CSS value to be returned by "+this.thingElt.sourceFor());if(this.inSearch){if(i)return this.forwardSearch?this.scanForwardArray(r,i,o,this.wrapping):this.scanBackwardsArray(r,i,o,this.wrapping)}else{var a=n??document.body;return this.forwardSearch?this.scanForwardQuery(r,a,o,this.wrapping):this.scanBackwardsQuery(r,a,o,this.wrapping)}}},pt=class s extends y{static grammarName="positionalExpression";static expressionType="unary";constructor(e,t){super(),this.rhs=e,this.operator=t,this.args={value:e}}static parse(e){var t=e.matchAnyToken("first","last","random");if(t){e.matchAnyToken("in","from","of");var r=e.requireElement("unaryExpression");return new s(r,t.value)}}resolve(e,{value:t}){if(t&&!Array.isArray(t)&&(t.children?t=t.children:t=Array.from(t)),t){if(this.operator==="first")return t[0];if(this.operator==="last")return t[t.length-1];if(this.operator==="random")return t[Math.floor(Math.random()*t.length)]}}},vt=class extends y{constructor(e,t,r,i){super(),this.type="closestExpr",this.parentSearch=e,this.expr=t,this.css=r,this.to=i,this.args={to:i}}resolve(e,{to:t}){if(t==null)return null;let r=[],i=this.css,n=this.parentSearch;return e.meta.runtime.implicitLoop(t,function(o){n?r.push(o.parentElement?o.parentElement.closest(i):null):r.push(o.closest(i))}),e.meta.runtime.shouldAutoIterate(t)?r:r[0]}get lhs(){return{to:this.to}}set(e,t,r){var i=this.resolve(e,t);i&&e.meta.runtime.replaceInDom(i,r)}},dt=class extends y{static grammarName="closestExpr";static expressionType="leaf";static assignable=!0;static parse(e){if(e.matchToken("closest")){var t=!1;e.matchToken("parent")&&(t=!0);var r=null,i=null;if(e.currentToken().type==="ATTRIBUTE_REF"&&(i=e.requireElement("attributeRefAccess",null),r="["+i.attribute.name+"]"),r==null){var n=e.requireElement("unaryExpression");n.css==null?e.raiseError("Expected a CSS expression"):r=n.css}if(e.matchToken("to"))var o=e.parseElement("expression");else var o=e.parseElement("implicitMeTarget");var a=new vt(t,n,r,o);return i?new G(a,i.attribute):a}}};var Et={};N(Et,{NoExpression:()=>Tt,SomeExpression:()=>kt});var Tt=class s extends y{static grammarName="noExpression";static expressionType="unary";constructor(e){super(),this.root=e,this.args={value:e}}static parse(e){if(e.matchToken("no")){var t=e.requireElement("collectionExpression");return new s(t)}}resolve(e,{value:t}){return e.meta.runtime.isEmpty(t)}},kt=class s extends y{static grammarName="some";static expressionType="leaf";constructor(e){super(),this.root=e,this.args={value:e}}static parse(e){if(e.matchToken("some")){var t=e.requireElement("expression");return new s(t)}}resolve(e,{value:t}){return!e.meta.runtime.isEmpty(t)}};var wt={};N(wt,{ImplicitMeTarget:()=>gt});var gt=class s extends y{static grammarName="implicitMeTarget";constructor(){super()}static parse(e){return new s}resolve(e){return e.you||e.me}};var Ct={};N(Ct,{AppendCommand:()=>Lt,BeepCommand:()=>St,ExitCommand:()=>he,FetchCommand:()=>Mt,GoCommand:()=>Rt,HaltCommand:()=>At,LogCommand:()=>xt,MakeCommand:()=>It,PickCommand:()=>Ot,ReturnCommand:()=>Nt,ScrollCommand:()=>Ft,ThrowCommand:()=>qt});var bt=class extends y{constructor(){super(),this.type="symbol"}resolve(e){return e.meta.runtime.resolveSymbol("result",e)}get lhs(){return{}}set(e,t,r){e.meta.runtime.setSymbol("result",e,null,r)}},xt=class s extends d{static keyword="log";constructor(e,t){super(),this.exprs=e,this.withExpr=t,this.args={logger:t,values:e}}static parse(e){if(e.matchToken("log")){for(var t=[e.parseElement("expression")];e.matchOpToken(",");)t.push(e.requireElement("expression"));if(e.matchToken("with"))var r=e.requireElement("expression");return new s(t,r)}}resolve(e,{logger:t,values:r}){return t?t(...r):console.log(...r),this.findNext(e)}},St=class s extends d{static keyword="beep!";constructor(e){super(),this.exprs=e,this.args={values:e}}static parse(e){if(e.matchToken("beep!")){for(var t=[e.parseElement("expression")];e.matchOpToken(",");)t.push(e.requireElement("expression"));return new s(t)}}resolve(e,{values:t}){for(let r=0;r<this.exprs.length;r++){let i=this.exprs[r],n=t[r];e.meta.runtime.beepValueToConsole(e.me,i,n)}return this.findNext(e)}},qt=class s extends d{static keyword="throw";constructor(e){super(),this.expr=e,this.args={value:e}}static parse(e){if(e.matchToken("throw")){var t=e.requireElement("expression");return new s(t)}}resolve(e,{value:t}){throw e.meta.runtime.registerHyperTrace(e,t),t}},Nt=class s extends d{static keyword="return";constructor(e){super(),this.value=e,this.args={value:e}}static parse(e){if(e.matchToken("return")){var t;return e.commandBoundary(e.currentToken())||(t=e.requireElement("expression")),new s(t)}}resolve(e,{value:t}){var r=e.meta.resolve;return e.meta.returned=!0,e.meta.returnValue=t,r&&r(t),e.meta.runtime.HALT}},he=class s extends d{static keyword="exit";static parse(e){if(e.matchToken("exit"))return new s}resolve(e){var t=e.meta.resolve;return e.meta.returned=!0,e.meta.returnValue=null,t&&t(),e.meta.runtime.HALT}},At=class s extends d{static keyword="halt";constructor(e,t,r,i){super(),this.keepExecuting=r,this.bubbling=e,this.haltDefault=t,this.exit=i}static parse(e){if(e.matchToken("halt")){if(e.matchToken("the")){e.requireToken("event"),e.matchOpToken("'")&&e.requireToken("s");var t=!0}if(e.matchToken("bubbling"))var r=!0;else if(e.matchToken("default"))var i=!0;var n=new he;return new s(r,i,t,n)}}resolve(e){return e.event&&(this.bubbling?e.event.stopPropagation():(this.haltDefault||e.event.stopPropagation(),e.event.preventDefault())),this.keepExecuting?this.findNext(e):this.exit}},It=class s extends d{static keyword="make";constructor(e,t,r,i){super(),this.variant=e,this.expr=t,this.constructorArgs=r,this.target=i,this.args=e==="queryRef"?null:{expr:t,constructorArgs:r}}static parse(e){if(e.matchToken("make")){e.matchToken("a")||e.matchToken("an");var t=e.requireElement("expression"),r=[];if(t.type!=="queryRef"&&e.matchToken("from"))do r.push(e.requireElement("expression"));while(e.matchOpToken(","));if(e.matchToken("called"))var i=e.requireElement("symbol");return t.type==="queryRef"?new s("queryRef",t,null,i):new s("constructor",t,r,i)}}resolve(e,{expr:t,constructorArgs:r}={}){if(this.variant==="queryRef"){for(var i,n="div",o,a=[],l=/(?:(^|#|\.)([^#\. ]+))/g;i=l.exec(this.expr.css);)i[1]===""?n=i[2].trim():i[1]==="#"?o=i[2].trim():a.push(i[2].trim());var u=document.createElement(n);o!==void 0&&(u.id=o),u.classList.add(...a),e.result=u}else e.result=new t(...r);return this.target&&e.meta.runtime.setSymbol(this.target.name,e,this.target.scope,e.result),this.findNext(e)}},Lt=class s extends d{static keyword="append";constructor(e,t,r){super(),this.value=e,this._target=t,this.assignable=r,r?this.args={target:t,value:e,...t.lhs}:this.args={target:t,value:e}}static parse(e){if(e.matchToken("append")){var t=null,r=e.requireElement("expression");e.matchToken("to")?t=e.requireElement("expression"):t=new bt;for(var i=t;i.type==="parenthesized";)i=i.expr;var n=i.set!=null;return new s(r,t,n)}}resolve(e,t){var{target:r,value:i,...n}=t;if(Array.isArray(r))r.push(i),e.meta.runtime.notifyMutation(r);else if(r instanceof Set)r.add(i),e.meta.runtime.notifyMutation(r);else if(r instanceof Element)i instanceof Element?r.insertAdjacentElement("beforeend",i):r.insertAdjacentHTML("beforeend",i),e.meta.runtime.processNode(r);else if(this.assignable)this._target.set(e,n,(r||"")+i);else throw new Error("Unable to append a value!");return this.findNext(e)}},Ot=class s extends d{static keyword="pick";constructor(e,t,r,i,n,o){super(),this.variant=e,this.range=r,this.flags=n,e==="range"?this.args={root:t,from:r.from,to:r.to}:e==="first"||e==="last"||e==="random"?this.args={root:t,count:o}:this.args={root:t,re:i}}static parsePickRange(e){e.matchToken("at")||e.matchToken("from");var t={includeStart:!0,includeEnd:!1};return t.from=e.matchToken("start")?0:e.requireElement("expression"),(e.matchToken("to")||e.matchOpToken(".."))&&(e.matchToken("end")?t.toEnd=!0:t.to=e.requireElement("expression")),e.matchToken("inclusive")?t.includeEnd=!0:e.matchToken("exclusive")&&(t.includeStart=!1),t}static parseSource(e){return e.matchAnyToken("of","from")||e.raiseExpected("of","from"),e.requireElement("expression")}static parse(e){if(e.matchToken("pick")){if(e.matchToken("the"),e.matchToken("first")){var t=e.pushFollows("of","from");try{var r=e.requireElement("expression")}finally{e.popFollows(t)}var i=s.parseSource(e);return new s("first",i,null,null,null,r)}if(e.matchToken("last")){var t=e.pushFollows("of","from");try{var r=e.requireElement("expression")}finally{e.popFollows(t)}var i=s.parseSource(e);return new s("last",i,null,null,null,r)}if(e.matchToken("random")){var r=null;if(e.currentToken().type==="NUMBER"){var t=e.pushFollows("of","from");try{r=e.requireElement("expression")}finally{e.popFollows(t)}}var i=s.parseSource(e);return new s("random",i,null,null,null,r)}if(e.matchToken("item")||e.matchToken("items")||e.matchToken("character")||e.matchToken("characters")){var t=e.pushFollows("of","from");try{var n=s.parsePickRange(e)}finally{e.popFollows(t)}var i=s.parseSource(e);return new s("range",i,n,null,null)}if(e.matchToken("match")){e.matchToken("of");var t=e.pushFollows("of","from");try{var o=e.parseElement("expression"),a="";e.matchOpToken("|")&&(a=e.requireTokenType("IDENTIFIER").value)}finally{e.popFollows(t)}var i=s.parseSource(e);return new s("match",i,null,o,a)}if(e.matchToken("matches")){e.matchToken("of");var t=e.pushFollows("of","from");try{var o=e.parseElement("expression"),a="gu";e.matchOpToken("|")&&(a="g"+e.requireTokenType("IDENTIFIER").value.replace("g",""))}finally{e.popFollows(t)}var i=s.parseSource(e);return new s("matches",i,null,o,a)}}}resolve(e,{root:t,from:r,to:i,re:n,count:o}){if(t==null)return e.result=t,this.findNext(e);if(this.variant==="first")e.result=t.slice(0,o);else if(this.variant==="last")e.result=t.slice(-o);else if(this.variant==="random")if(o==null)e.result=t[Math.floor(Math.random()*t.length)];else{for(var a=Array.from(t),l=[],u=0;u<o&&a.length>0;u++){var h=Math.floor(Math.random()*a.length);l.push(a.splice(h,1)[0])}e.result=l}else this.variant==="range"?(this.range.toEnd&&(i=t.length),this.range.includeStart||r++,this.range.includeEnd&&i++,i==null&&(i=r+1),e.result=t.slice(r,i)):this.variant==="match"?e.result=new RegExp(n,this.flags).exec(t):e.result=new ie(n,this.flags,t);return this.findNext(e)}},Mt=class s extends d{static keyword="fetch";constructor(e,t,r,i,n){super(),this.url=e,this.argExpressions=t,this.args={url:e,options:t},this.conversionType=r,this.conversion=i,this.dontThrow=n}static parseConversionInfo(e){var t="text",r;return e.matchToken("a")||e.matchToken("an"),e.matchToken("json")||e.matchToken("JSON")||e.matchToken("Object")?t="json":e.matchToken("response")||e.matchToken("Response")?t="response":e.matchToken("html")||e.matchToken("HTML")?t="html":e.matchToken("text")||e.matchToken("Text")||e.matchToken("String")||(r=e.requireElement("dotOrColonPath").evalStatically()),{type:t,conversion:r}}static parse(e){if(e.matchToken("fetch")){var t=e.parseURLOrExpression();if(e.matchToken("as"))var r=s.parseConversionInfo(e);if(e.matchToken("with")&&e.currentToken().value!=="{")var i=e.parseElement("nakedNamedArgumentList");else var i=e.parseElement("objectLiteral");r==null&&e.matchToken("as")&&(r=s.parseConversionInfo(e));var n=!1;e.matchToken("do")?(e.requireToken("not"),e.requireToken("throw"),n=!0):e.currentToken().value==="don"&&e.token(1).value==="'"&&e.token(2).value==="t"&&e.token(1).start===e.currentToken().end&&e.token(2).start===e.token(1).end&&(e.consumeToken(),e.consumeToken(),e.consumeToken(),e.requireToken("throw"),n=!0);var o=r?r.type:"text",a=r?r.conversion:null;return new s(t,i,o,a,n)}}resolve(e,{url:t,options:r}){var i=r||{};i.sender=e.me,i.headers=i.headers||{};var n=new AbortController,o=()=>n.abort();e.me.addEventListener("fetch:abort",o,{once:!0}),i.signal=n.signal,e.meta.runtime.triggerEvent(e.me,"hyperscript:beforeFetch",i),e.meta.runtime.triggerEvent(e.me,"fetch:beforeRequest",i);var a=!1;i.timeout&&setTimeout(()=>{a||n.abort()},i.timeout);var l=h=>(e.result=h,e.meta.runtime.triggerEvent(e.me,"fetch:afterRequest",{result:h}),a=!0,this.findNext(e)),u=!this.dontThrow&&this.conversionType!=="response";return fetch(t,i).then(h=>{var f={response:h};if(e.meta.runtime.triggerEvent(e.me,"fetch:afterResponse",f),h=f.response,u){for(var p=String(h.status),c=A.fetchThrowsOn||[],T=0;T<c.length;T++)if(c[T].test(p)){var m=new Error("fetch failed: "+h.status+" "+h.statusText+" ("+t+")");throw m.response=h,m.status=h.status,m}}if(this.conversionType==="response")return l(h);if(this.conversionType==="json")return h.json().then(l);if(this.conversion){var v=A.conversions[this.conversion];if(v&&v._rawResponse)return l(v(h,e.meta.runtime,e))}return h.text().then(k=>(this.conversion&&(k=e.meta.runtime.convertValue(k,this.conversion)),this.conversionType==="html"&&(k=e.meta.runtime.convertValue(k,"Fragment")),l(k)))}).catch(h=>{throw e.meta.runtime.triggerEvent(e.me,"fetch:error",{reason:h}),h}).finally(()=>{e.me.removeEventListener("fetch:abort",o)})}};function di(s){s.matchToken("the");var e=s.matchAnyToken("top","middle","bottom"),t=s.matchAnyToken("left","center","right");(e||t)&&s.requireToken("of");var r=s.requireElement("unaryExpression"),i=s.matchAnyOpToken("+","-"),n;if(i){s.pushFollow("px");try{n=s.requireElement("expression")}finally{s.popFollow()}}s.matchToken("px");var o;s.matchToken("in")&&(o=s.requireElement("unaryExpression"));var a=s.matchAnyToken("smoothly","instantly"),l={block:"start",inline:"nearest"},u={top:"start",bottom:"end",middle:"center"},h={left:"start",center:"center",right:"end"},f={smoothly:"smooth",instantly:"instant"};return e&&(l.block=u[e.value]),t&&(l.inline=h[t.value]),a&&(l.behavior=f[a.value]),{target:r,offset:n,plusOrMinus:i,scrollOptions:l,container:o}}function Bi(s){var e=s.matchAnyToken("smoothly","instantly");if(e)return e.value==="smoothly"?"smooth":"instant"}function yi(s,e,t,r,i,n){s.meta.runtime.implicitLoop(e,function(o){if(o===window&&(o=document.body),n){var a=(n instanceof Element,n),l=o.offsetTop-a.offsetTop,u=o.offsetLeft-a.offsetLeft;if(r){var h=r.value==="+"?t:t*-1;l+=h}a.scrollTo({top:l,left:u,behavior:i.behavior||"auto"});return}if(r){var f=o.getBoundingClientRect(),p=document.createElement("div"),c=r.value==="+"?t:t*-1,T=i.inline=="start"||i.inline=="end"?c:0,m=i.block=="start"||i.block=="end"?c:0;p.style.position="absolute",p.style.top=f.top+window.scrollY+m+"px",p.style.left=f.left+window.scrollX+T+"px",p.style.height=f.height+"px",p.style.width=f.width+"px",p.style.zIndex=""+Number.MIN_SAFE_INTEGER,p.style.opacity="0",document.body.appendChild(p),setTimeout(function(){document.body.removeChild(p)},100),o=p}o.scrollIntoView(i)})}var Ft=class s extends d{static keyword="scroll";constructor(e,t,r,i,n,o){super(),this.target=e,this.plusOrMinus=r,this.scrollOptions=i,this.byMode=o,this.args={target:e,offset:t,container:n}}static parse(e){if(e.matchToken("scroll")){if(e.matchToken("to")){var t=di(e);return new s(t.target,t.offset,t.plusOrMinus,t.scrollOptions,t.container)}var r=e.matchAnyToken("up","down","left","right"),i;!r&&e.currentToken().value!=="by"&&(i=e.requireElement("unaryExpression"),r=e.matchAnyToken("up","down","left","right")),e.requireToken("by"),e.pushFollow("px");var n;try{n=e.requireElement("expression")}finally{e.popFollow()}e.matchToken("px");var o=Bi(e),a={};o&&(a.behavior=o);var l={direction:r?r.value:"down"};return new s(i,n,null,a,null,l)}}resolve(e,{target:t,offset:r,container:i}){if(this.byMode){var n=t||document.documentElement,o=this.byMode.direction,a=0,l=0;o==="up"?a=-r:o==="down"?a=r:o==="left"?l=-r:o==="right"&&(l=r);var u={top:a,left:l};this.scrollOptions.behavior&&(u.behavior=this.scrollOptions.behavior),n.scrollBy(u)}else yi(e,t,r,this.plusOrMinus,this.scrollOptions,i);return this.findNext(e)}},Rt=class s extends d{static keyword="go";constructor(e,t,r,i,n,o){super(),this.target=e,this.args={target:e,offset:t},this.back=r,this.newWindow=i,this.plusOrMinus=n,this.scrollOptions=o}static parse(e){if(e.matchToken("go")){if(e.matchToken("back"))return new s(null,null,!0);if(e.matchToken("to"),e.matchToken("url")){var i=e.requireElement("stringLike"),n=!1;return e.matchToken("in")&&(e.requireToken("new"),e.requireToken("window"),n=!0),new s(i,null,!1,n)}var t=e.currentToken();if(t.value==="the"||t.value==="top"||t.value==="middle"||t.value==="bottom"||t.value==="left"||t.value==="center"||t.value==="right"){var r=di(e);return new s(r.target,r.offset,!1,!1,r.plusOrMinus,r.scrollOptions)}var i=e.parseURLOrExpression(),n=!1;return e.matchToken("in")&&(e.requireToken("new"),e.requireToken("window"),n=!0),new s(i,null,!1,n)}}resolve(e,{target:t,offset:r}){if(this.back)window.history.back();else if(this.scrollOptions)yi(e,t,r,this.plusOrMinus,this.scrollOptions);else if(t!=null)if(t instanceof Element)t.scrollIntoView({block:"start",inline:"nearest"});else{var i=String(t);i.startsWith("#")?window.location.hash=i:this.newWindow?window.open(i):window.location.href=i}return this.findNext(e)}};var jt={};N(jt,{DecrementCommand:()=>Dt,DefaultCommand:()=>_t,IncrementCommand:()=>Pt,PutCommand:()=>Wt,SetCommand:()=>ce,SwapCommand:()=>Ht});var ce=class s extends d{static keyword="set";constructor(e,t,r=null){super(),this.target=e,this.objectLiteral=r,r?this.args={obj:r,setTarget:e}:this.args={...e.lhs,value:t}}static parse(e){if(e.matchToken("set")){if(e.currentToken().type==="L_BRACE"){var t=e.requireElement("objectLiteral");e.requireToken("on");var r=e.requireElement("expression");return new s(r,null,t)}try{e.pushFollow("to");var r=e.requireElement("assignableExpression")}finally{e.popFollow()}for(;r.type==="parenthesized";)r=r.expr;e.requireToken("to");var i=e.requireElement("expression");return new s(r,i)}}resolve(e,t){if(this.objectLiteral){var{obj:r,setTarget:i}=t;Object.assign(i,r)}else{var{value:n,...o}=t;this.target.set(e,o,n)}return this.findNext(e)}},_t=class s extends d{static keyword="default";constructor(e,t){super(),this.target=e,this.setter=t,this.args={targetValue:e}}static parse(e){if(e.matchToken("default")){try{e.pushFollow("to");var t=e.requireElement("assignableExpression")}finally{e.popFollow()}for(;t.type==="parenthesized";)t=t.expr;e.requireToken("to");var r=e.requireElement("expression"),i=new ce(t,r),n=new s(t,i);return i.parent=n,n}}resolve(e,{targetValue:t}){return t!=null&&t!==""?this.findNext(e):this.setter}},Pt=class s extends d{static keyword="increment";constructor(e,t){super(),this.target=e,this.amountExpr=t,this.args={targetValue:e,amount:t,...e.lhs}}static parse(e){if(e.matchToken("increment")){for(var t,r=e.parseElement("assignableExpression");r.type==="parenthesized";)r=r.expr;return e.matchToken("by")&&(t=e.requireElement("expression")),new s(r,t)}}resolve(e,t){var{targetValue:r,amount:i,...n}=t;r=r?parseFloat(r):0,i=this.amountExpr?parseFloat(i):1;var o=r+i;return e.result=o,this.target.set(e,n,o),this.findNext(e)}},Dt=class s extends d{static keyword="decrement";constructor(e,t){super(),this.target=e,this.amountExpr=t,this.args={targetValue:e,amount:t,...e.lhs}}static parse(e){if(e.matchToken("decrement")){var t;try{e.pushFollow("by");var r=e.parseElement("assignableExpression")}finally{e.popFollow()}for(;r.type==="parenthesized";)r=r.expr;return e.matchToken("by")&&(t=e.requireElement("expression")),new s(r,t)}}resolve(e,t){var{targetValue:r,amount:i,...n}=t;r=r?parseFloat(r):0,i=this.amountExpr?parseFloat(i):1;var o=r-i;return e.result=o,this.target.set(e,n,o),this.findNext(e)}},Ht=class s extends d{static keyword="swap";constructor(e,t){super(),this.target1=e,this.target2=t,this.args={value1:e,value2:t,root1:e.lhs.root,index1:e.lhs.index,root2:t.lhs.root,index2:t.lhs.index}}static parse(e){if(e.matchToken("swap")){try{e.pushFollow("with");var t=e.requireElement("assignableExpression")}finally{e.popFollow()}for(;t.type==="parenthesized";)t=t.expr;e.requireToken("with");for(var r=e.requireElement("assignableExpression");r.type==="parenthesized";)r=r.expr;return new s(t,r)}}resolve(e,{value1:t,value2:r,root1:i,index1:n,root2:o,index2:a}){if(t instanceof Element&&r instanceof Element){var l=document.createComment("");t.replaceWith(l),r.replaceWith(t),l.replaceWith(r)}else this.target1.set(e,{root:i,index:n},r),this.target2.set(e,{root:o,index:a},t);return this.findNext(e)}},Wt=class s extends d{static keyword="put";constructor(e,t,r,i){super(),this.target=e,this.operation=t,this.value=r,this.rootExpr=i,this.symbolWrite=e.type==="symbol"&&t==="into",this.arrayIndex=e.type==="arrayIndex",this.attributeWrite=(e.type==="attributeRef"||e.attribute&&e.attribute.type==="attributeRef")&&t==="into",this.styleWrite=(e.type==="styleRef"||e.attribute&&e.attribute.type==="styleRef")&&t==="into",this.arrayIndex?this.prop=e.prop:this.symbolWrite?this.prop=e.name:e.type==="attributeRef"||e.type==="styleRef"?this.prop=e.name:e.attribute?this.prop=e.attribute.name:e.prop?this.prop=e.prop.value:this.prop=null,this.args={root:i,prop:this.prop,value:r}}static parse(e){if(e.matchToken("put")){var t=e.requireElement("expression"),r=e.matchAnyToken("into","before","after");r==null&&e.matchToken("at")&&(e.matchToken("the"),r=e.matchAnyToken("start","end"),e.requireToken("of")),r==null&&e.raiseExpected("into","before","at start of","at end of","after");for(var i=e.requireElement("expression");i.type==="parenthesized";)i=i.expr;var n=r.value,o;return i.type==="arrayIndex"&&n==="into"||i.prop&&i.root&&n==="into"?o=i.root:i.type==="symbol"&&n==="into"?o=null:i.type==="attributeRef"&&n==="into"||i.type==="styleRef"&&n==="into"?o=e.requireElement("implicitMeTarget"):i.attribute&&n==="into"?o=i.root:o=i,new s(i,n,t,o)}}putInto(e,t,r,i){if(t==null)var n=e.meta.runtime.resolveSymbol(r,e);else var n=t;if((t==null||r==null)&&(n instanceof Element||n instanceof Document)){for(;n.firstChild;)n.removeChild(n.firstChild);n.append(e.meta.runtime.convertValue(i,"Fragment")),e.meta.runtime.processNode(n)}else t==null?e.meta.runtime.setSymbol(r,e,null,i):t[r]=i}resolve(e,{root:t,prop:r,value:i}){if(this.symbolWrite)this.putInto(e,t,r,i);else if(e.meta.runtime.nullCheck(t,this.rootExpr),this.operation==="into")if(this.attributeWrite)e.meta.runtime.implicitLoop(t,function(l){i==null?l.removeAttribute(r):l.setAttribute(r,i)});else if(this.styleWrite)e.meta.runtime.implicitLoop(t,function(l){l.style[r]=i});else if(this.arrayIndex)t[r]=i;else{var n=this;e.meta.runtime.implicitLoop(t,function(l){n.putInto(e,l,r,i)})}else if(Array.isArray(t))this.operation==="start"?t.unshift(i):t.push(i),e.meta.runtime.notifyMutation(t);else{var o={before:Element.prototype.before,after:Element.prototype.after,start:Element.prototype.prepend,end:Element.prototype.append},a=o[this.operation]||Element.prototype.append;e.meta.runtime.implicitLoop(t,function(l){a.call(l,i instanceof Node?i:e.meta.runtime.convertValue(i,"Fragment")),l.parentElement?e.meta.runtime.processNode(l.parentElement):e.meta.runtime.processNode(l)})}return this.findNext(e)}};var Gt={};N(Gt,{EventName:()=>zt,SendCommand:()=>Bt,WaitCommand:()=>Ut});var Ut=class s extends d{static keyword="wait";constructor(e,t,r,i){super(),this.variant=e,this.event=t,this.on=r,this.time=i,this.args=e==="event"?{on:r}:{time:i}}static parse(e){if(e.matchToken("wait"))if(e.matchToken("for")){e.matchToken("a");var t=[];do{var r=e.token(0);r.type==="NUMBER"||r.type==="L_PAREN"?t.push(e.requireElement("expression")):t.push({name:e.requireElement("dotOrColonPath","Expected event name").evalStatically(),args:I.parseEventArgs(e)})}while(e.matchToken("or"));if(e.matchToken("from"))var i=e.requireElement("expression");return new s("event",t,i,null)}else{var n;return e.matchToken("a")?(e.requireToken("tick"),n=0):n=e.requireElement("expression"),new s("time",null,null,n)}}resolve(e,{on:t,time:r}){if(this.variant==="event"){var i=t||e.me;if(!(i instanceof EventTarget))throw new Error("Not a valid event target: "+this.on.sourceFor());let n=this.event;return new Promise(o=>{var a=!1;for(let u of n){var l=h=>{if(e.result=h,u.name&&u.args)for(let f of u.args)e.locals[f.value]=h[f.value]||(h.detail?h.detail[f.value]:null);a||(a=!0,o(this.findNext(e)))};if(u.name)i.addEventListener(u.name,l,{once:!0});else{let h=u.evaluate(e);setTimeout(l,h,h)}}})}else return new Promise(n=>{setTimeout(()=>{n(this.findNext(e))},r)})}},Bt=class s extends d{static keyword=["send","trigger"];constructor(e,t,r){super(),this.eventName=e,this.details=t,this.to=r,this.args={to:r,eventName:e,details:t},this.toExpr=r}static parse(e){var t=e.matchToken("trigger");if(!(!t&&!e.matchToken("send"))){var r=e.requireElement("eventName"),i=e.parseElement("namedArgumentList");if(e.matchToken(t?"on":"to"))var n=e.requireElement("expression");else var n=e.requireElement("implicitMeTarget");return new s(r,i,n)}}resolve(e,{to:t,eventName:r,details:i}){return e.meta.runtime.nullCheck(t,this.toExpr),e.meta.runtime.implicitLoop(t,function(n){e.meta.runtime.triggerEvent(n,r,i,e.me)}),this.findNext(e)}},zt=class s extends y{static grammarName="eventName";constructor(e){super(),this.value=e}evalStatically(){return this.value}resolve(e){return this.value}static parse(e){var t;return(t=e.matchTokenType("STRING"))?new s(t.value):e.parseElement("dotOrColonPath")}};var Vt={};N(Vt,{BreakCommand:()=>Xt,ContinueCommand:()=>Jt,IfCommand:()=>Yt,RepeatCommand:()=>Kt,TellCommand:()=>Zt});var $t=class extends d{constructor(){super(),this.type="waitATick"}resolve(e){return new Promise(t=>{setTimeout(()=>t(e.meta.runtime.findNext(this)),0)})}},Qt=class extends d{constructor(e,t,r){super(),this.identifier=e.identifier,this.indexIdentifier=e.indexIdentifier,this.slot=e.slot,this.expression=e.expression,this.forever=e.forever,this.times=e.times,this.until=e.until,this.event=e.event,this.on=e.on,this.whileExpr=e.whileExpr,this.bottomTested=e.bottomTested,this.loop=t,this.elseBranch=r,this.args={whileValue:e.whileExpr,times:e.times}}resolveNext(){return this}resolve(e,{whileValue:t,times:r}){var i=e.meta.iterators[this.slot],n=!1,o=null;if(this.bottomTested&&i.index===0)n=!0;else if(this.forever)n=!0;else if(this.until)this.event?n=e.meta.iterators[this.slot].eventFired===!1:n=t!==!0;else if(this.whileExpr)n=t;else if(r)n=i.index<r;else if(i.iterator){if(i.async){var a=this;return i.iterator.next().then(function(u){return u.done?a._endLoop(e,i):a._continueLoop(e,i,u.value)})}var l=i.iterator.next();n=!l.done,o=l.value}return n?this._continueLoop(e,i,o):this._endLoop(e,i)}_continueLoop(e,t,r){var i=t.index;if(t.value?e.result=e.locals[this.identifier]=r:e.result=i,this.indexIdentifier&&(e.locals[this.indexIdentifier]=i),e.meta.__ht_template_result&&t.value){var n=e.meta.__ht_scopes||(e.meta.__ht_scopes={});n[this.slot]||(n[this.slot]={identifier:this.identifier,indexIdentifier:this.indexIdentifier,source:t.value}),e.meta.__ht_template_result.push("<!--hs-scope:"+this.slot+":"+i+"-->")}return t.didIterate=!0,t.index++,this.loop}_endLoop(e,t){var r=t.didIterate;return e.meta.iterators[this.slot]=null,!r&&this.elseBranch?this.elseBranch:e.meta.runtime.findNext(this.parent,e)}},Yt=class s extends d{static keyword="if";constructor(e,t,r){super(),this.expr=e,this.trueBranch=t,this.falseBranch=r,this.args={value:e}}static parse(e){if(!e.matchToken("if"))return;var t=e.requireElement("expression");e.matchToken("then");var r=e.parseElement("commandList"),i=!1;let n=e.matchToken("else")||e.matchToken("otherwise");if(n){let l=e.peekToken("if");if(i=l!=null&&l.line===n.line,i)var o=e.parseElement("command");else var o=e.parseElement("commandList")}e.hasMore()&&!i&&e.requireToken("end");var a=new s(t,r,o);return e.setParent(r,a),e.setParent(o,a),a}resolve(e,{value:t}){return t?this.trueBranch:this.falseBranch?this.falseBranch:this.findNext(e)}},Kt=class s extends d{static keyword=["repeat","for"];constructor(e,t,r,i,n){super(),this.expression=e,this.evt=t,this.on=r,this.slot=i,this.repeatLoopCommand=n,this.args={value:e,event:t,on:r}}static parseRepeatExpression(e,t){var r=e.currentToken(),i;if(e.matchToken("for")||t){var n=e.requireTokenType("IDENTIFIER");i=n.value,e.requireToken("in");for(var o=e.requireElement("expression"),a=o;a;)a.condition&&(a.varName=i),a=a.root}else if(e.matchToken("in")){i="it";var o=e.requireElement("expression")}else if(e.matchToken("while"))var l=e.requireElement("expression");else if(e.matchToken("until")){var u=!0;if(e.matchToken("event")){var h=e.requireElement("dotOrColonPath","Expected event name");if(e.matchToken("from"))var f=e.requireElement("expression")}else var l=e.requireElement("expression")}else if(!e.commandBoundary(e.currentToken())&&e.currentToken().value!=="forever"){var p=e.requireElement("expression");e.requireToken("times")}else{e.matchToken("forever");var c=!0}if(e.matchToken("index"))var n=e.requireTokenType("IDENTIFIER"),T=n.value;else if(e.matchToken("indexed")){e.requireToken("by");var n=e.requireTokenType("IDENTIFIER"),T=n.value}var m=e.parseElement("commandList");if(m&&h){for(var v=m;v.next;)v=v.next;var k=new $t;v.next=k}var b=!1;c&&e.hasMore()&&(e.matchToken("until")?(c=!1,u=!0,b=!0,l=e.requireElement("expression")):e.matchToken("while")&&(c=!1,b=!0,l=e.requireElement("expression")));var g=null;if(e.matchToken("else")&&(g=e.parseElement("commandList")),e.hasMore()&&e.requireToken("end"),i==null){i="_implicit_repeat_"+r.start;var x=i}else var x=i+"_"+r.start;let E={identifier:i,indexIdentifier:T,slot:x,expression:o,forever:c,times:p,until:u,event:h,on:f,whileExpr:l,bottomTested:b},q=new Qt(E,m,g),M=new s(o,h,f,x,q);return e.setParent(m,q),g&&e.setParent(g,M),e.setParent(q,M),M}static parse(e){if(e.matchToken("for"))return s.parseRepeatExpression(e,!0);if(e.matchToken("repeat"))return s.parseRepeatExpression(e,!1)}resolve(e,{value:t,event:r,on:i}){var n={index:0,value:t,eventFired:!1};if(e.meta.iterators[this.slot]=n,t?t[Symbol.asyncIterator]?(n.iterator=t[Symbol.asyncIterator](),n.async=!0):t[Symbol.iterator]?n.iterator=t[Symbol.iterator]():n.iterator=Object.keys(t)[Symbol.iterator]():this.repeatLoopCommand.elseBranch&&(n.iterator=[][Symbol.iterator]()),this.evt){var o=i||e.me;let a=this.slot;o.addEventListener(r,function(l){e.meta.iterators[a].eventFired=!0},{once:!0})}return this.repeatLoopCommand}},Jt=class s extends d{static keyword="continue";static parse(e){if(e.matchToken("continue"))return new s}resolve(e){for(var t=this.parent;t;t=t.parent)if(t.loop!=null)return t.resolveNext(e);throw new Error("Command `continue` cannot be used outside of a `repeat` loop.")}},Xt=class s extends d{static keyword="break";static parse(e){if(e.matchToken("break"))return new s}resolve(e){for(var t=this.parent;t;t=t.parent)if(t.loop!=null)return e.meta.runtime.findNext(t.parent,e);throw new Error("Command `break` cannot be used outside of a `repeat` loop.")}},Zt=class s extends d{static keyword="tell";constructor(e,t,r){super(),this.value=e,this.body=t,this.slot=r,this.args={value:e}}static parse(e){var t=e.currentToken();if(e.matchToken("tell")){var r=e.requireElement("expression"),i=e.requireElement("commandList");e.hasMore()&&!e.featureStart(e.currentToken())&&e.requireToken("end");var n="tell_"+t.start,o=new s(r,i,n);return e.setParent(i,o),o}}resolveNext(e){var t=e.meta.iterators[this.slot];return t.index<t.value.length?(e.you=t.value[t.index++],this.body):(e.you=t.originalYou,this.next?this.next:e.meta.runtime.findNext(this.parent,e))}resolve(e,{value:t}){return t==null?t=[]:Array.isArray(t)||t instanceof NodeList||(t=[t]),e.meta.iterators[this.slot]={originalYou:e.you,index:0,value:t},this.resolveNext(e)}};var ir={};N(ir,{GetCommand:()=>rr,JsBody:()=>er,JsCommand:()=>tr});var er=class s{static grammarName="jsBody";constructor(e,t){this.type="jsBody",this.jsSource=e,this.exposedFunctionNames=t}static parse(e){for(var t=e.currentToken().start,r=e.currentToken(),i=[],n="",o=!1;e.hasMore();){r=e.consumeToken();var a=e.token(0,!0);if(a.type==="IDENTIFIER"&&a.value==="end")break;o?r.type==="IDENTIFIER"||r.type==="NUMBER"?n+=r.value:(n!==""&&i.push(n),n="",o=!1):r.type==="IDENTIFIER"&&r.value==="function"&&(o=!0)}var l=r.end+1;return new s(e.source.substring(t,l),i)}},tr=class s extends d{static keyword="js";constructor(e,t,r){super(),this.jsSource=e,this.function=t,this.inputs=r}static parse(e){if(e.matchToken("js")){var t=[];if(e.matchOpToken("(")&&!e.matchOpToken(")")){do{var r=e.requireTokenType("IDENTIFIER");t.push(r.value)}while(e.matchOpToken(","));e.requireOpToken(")")}var i=e.requireElement("jsBody");e.matchToken("end");var n=new Function(...t,i.jsSource);return new s(i.jsSource,n,t)}}resolve(e){var t=this.inputs.map(i=>e.meta.runtime.resolveSymbol(i,e,"local")),r=this.function.apply(e.meta.runtime.globalScope,t);return r&&typeof r.then=="function"?r.then(i=>(e.result=i,this.findNext(e))):(e.result=r,this.findNext(e))}},rr=class s extends d{static keyword=["get","call"];constructor(e){super(),this.expr=e,this.args={result:e}}static parse(e){var t=e.matchToken("call");if(!(!t&&!e.matchToken("get"))){var r=e.requireElement("expression");return t&&r&&r.type!=="functionCall"&&e.raiseError("Must be a function invocation"),new s(r)}}resolve(e,{result:t}){return e.result=t,this.findNext(e)}};var sr={};N(sr,{PseudoCommand:()=>nr});var nr=class s extends d{static grammarName="pseudoCommand";constructor(e,t,r,i){super(),this.variant=e,this.expr=t,this._root=i,this._realRoot=r,e==="target"?(this.root=r,this.argExpressions=i.argExpressions,this.args={target:r,argVals:i.argExpressions}):this.args={result:t}}static parse(e){let t=e.token(1);if(!(t&&t.op&&(t.value==="."||t.value==="(")))return null;for(var r=e.requireElement("primaryExpression"),i=r.root,n=r;i.root!=null;)n=n.root,i=i.root;if(r.type!=="functionCall"&&e.raiseError("Pseudo-commands must be function calls"),n.type==="functionCall"&&n.root.root==null){if(e.matchAnyToken("the","to","on","with","into","from","at"))var o=e.requireElement("expression");else if(e.matchToken("me"))var o=e.requireElement("implicitMeTarget")}return o?new s("target",r,o,n):new s("simple",r,null,null)}resolve(e,{target:t,argVals:r,result:i}){if(this.variant==="target"){e.meta.runtime.nullCheck(t,this._realRoot);var n=this._root.root.name,o=t[n];e.meta.runtime.nullCheck(o,this._root),o.hyperfunc&&r.push(e),e.result=o.apply(t,r),e.meta.runtime.maybeNotify(t,n)}else e.result=i;return this.findNext(e)}};var xr={};N(xr,{AddCommand:()=>or,AnswerCommand:()=>wr,AskCommand:()=>gr,BlurCommand:()=>pr,CloseCommand:()=>Tr,EmptyCommand:()=>vr,FocusCommand:()=>mr,HideCommand:()=>ur,MeasureCommand:()=>fr,MorphCommand:()=>br,OpenCommand:()=>yr,RemoveCommand:()=>ar,ResetCommand:()=>dr,SelectCommand:()=>Er,ShowCommand:()=>hr,SpeakCommand:()=>kr,TakeCommand:()=>cr,ToggleCommand:()=>lr});var H={display:function(s,e,t,r){if(!t&&e instanceof HTMLDialogElement){s==="hide"?e.close():s==="show"?e.open||e.show():s==="toggle"&&(e.open?e.close():e.show());return}if(t)e.style.display=t;else if(s==="toggle")getComputedStyle(e).display==="none"?H.display("show",e,t,r):H.display("hide",e,t,r);else if(s==="hide"){let i=r.getInternalData(e);i.originalDisplay==null&&(i.originalDisplay=e.style.display),e.style.display="none"}else{let i=r.getInternalData(e);i.originalDisplay&&i.originalDisplay!=="none"?e.style.display=i.originalDisplay:e.style.removeProperty("display")}},visibility:function(s,e,t){t?e.style.visibility=t:s==="toggle"?getComputedStyle(e).visibility==="hidden"?H.visibility("show",e,t):H.visibility("hide",e,t):s==="hide"?e.style.visibility="hidden":e.style.visibility="visible"},opacity:function(s,e,t){t?e.style.opacity=t:s==="toggle"?getComputedStyle(e).opacity==="0"?H.opacity("show",e,t):H.opacity("hide",e,t):s==="hide"?e.style.opacity="0":e.style.opacity="1"},hidden:function(s,e){s==="toggle"&&(s=e.hasAttribute("hidden")?"show":"hide"),s==="hide"?e.setAttribute("hidden",""):e.removeAttribute("hidden")}};function Ti(s){return s.split(";").map(function(e){return e.split(":")[0].trim()}).filter(Boolean)}function ki(s,e){for(var t=0;t<e.length;t++)s.style.removeProperty(e[t])}var C=class extends d{static parseShowHideTarget(e){var t=e.currentToken();return t.value==="when"||t.value==="with"||e.commandBoundary(t)?e.parseElement("implicitMeTarget"):e.parseElement("expression")}static resolveHideShowStrategy(e,t){var r=A.defaultHideShowStrategy,i=H;A.hideShowStrategies&&(i=Object.assign({},i,A.hideShowStrategies)),t=t||r||"display";var n=i[t];return n==null&&e.raiseError("Unknown show/hide strategy : "+t),n}},or=class s extends d{static keyword="add";constructor(e,t,r,i,n,o,a){super(),this.variant=e,this.classRefs=t,this.attributeRef=r,this.cssDeclaration=i,this.to=n,this.toExpr=n,this.when=o,this.valueExpr=a,e==="class"?this.args={to:n,classRefs:t}:e==="attribute"?this.args={to:n}:e==="collection"?this.args={to:n,value:a}:this.args={to:n,css:i}}static parse(e){if(e.matchToken("add")){var t=e.parseElement("classRef"),r=null,i=null,n=null;if(t==null){if(r=e.parseElement("attributeRef"),r==null&&(i=e.parseElement("styleLiteral"),i==null)){e.pushFollow("to");try{n=e.parseElement("expression")}finally{e.popFollow()}(n==null||!e.currentToken()||e.currentToken().value!=="to")&&e.raiseError("Expected either a class reference or attribute expression")}}else for(var o=[t];t=e.parseElement("classRef");)o.push(t);if(e.matchToken("to"))var a=e.requireElement("expression");else var a=e.requireElement("implicitMeTarget");if(e.matchToken("when"))var l=e.requireElement("expression");return o?new s("class",o,null,null,a,l):r?new s("attribute",null,r,null,a,l):i?new s("css",null,null,i,a,null):new s("collection",null,null,null,a,null,n)}}resolve(e,{to:t,classRefs:r,css:i,value:n}){var o=e.meta.runtime,a=this;o.nullCheck(t,this.toExpr);var l;if(this.variant==="collection"){if(Array.isArray(t))t.push(n);else if(t instanceof Set)t.add(n);else throw t instanceof Map?new Error("Use 'set myMap[key] to value' for Maps"):new Error("Cannot add to "+typeof t);return o.notifyMutation(t),o.findNext(this,e)}else if(this.variant==="class")o.forEach(r,function(f){a.when?l=o.implicitLoopWhen(t,a.when,e,function(p){p instanceof Element&&p.classList.add(f.className)},function(p){p instanceof Element&&p.classList.remove(f.className)}):o.implicitLoop(t,function(p){p instanceof Element&&p.classList.add(f.className)})});else if(this.variant==="attribute"){var u=this.attributeRef;this.when?l=o.implicitLoopWhen(t,this.when,e,function(f){f.setAttribute(u.name,u.value)},function(f){f.removeAttribute(u.name)}):o.implicitLoop(t,function(f){f.setAttribute(u.name,u.value)})}else if(this.when){var h=Ti(i);l=o.implicitLoopWhen(t,this.when,e,function(f){f.style.cssText+=i},function(f){ki(f,h)})}else o.implicitLoop(t,function(f){f.style.cssText+=i});return l&&l.then?l.then(function(){return o.findNext(a,e)}):o.findNext(this,e)}},ar=class s extends d{static keyword="remove";constructor(e,t,r,i,n,o,a){super(),this.variant=e,this.elementExpr=t,this.classRefs=r,this.attributeRef=i,this.cssDeclaration=n,this.from=o,this.fromExpr=o,this.when=a,e==="element"?this.args={element:t,from:o}:e==="css"?this.args={css:n,from:o}:this.args={classRefs:r,from:o}}static parse(e){if(e.matchToken("remove")){var t=e.parseElement("classRef"),r=null,i=null,n=null;if(t==null)r=e.parseElement("attributeRef"),r==null&&(i=e.parseElement("styleLiteral"),i==null&&(n=e.parseElement("expression"),n==null&&e.raiseError("Expected either a class reference, attribute expression or value expression")));else for(var o=[t];t=e.parseElement("classRef");)o.push(t);if(e.matchToken("from"))var a=e.requireElement("expression");else if(n==null)var a=e.requireElement("implicitMeTarget");if(e.matchToken("when")){n&&e.raiseError("'when' clause is not supported when removing elements");var l=e.requireElement("expression")}return n?new s("element",n,null,null,null,a):i?new s("css",null,null,null,i,a,l):new s("classOrAttr",null,o,r,null,a,l)}}resolve(e,{element:t,classRefs:r,css:i,from:n}){var o=e.meta.runtime,a=this,l;if(this.variant==="element"){if(n==null&&typeof this.elementExpr.delete=="function"){var u=this.isDOMTarget(t);if(!u){var h=this.elementExpr.lhs,f={};for(var p in h){var c=h[p];f[p]=c&&c.evaluate?c.evaluate(e):c}return this.elementExpr.delete(e,f),this.findNext(e)}}if(o.nullCheck(t,this.elementExpr),n!=null&&Array.isArray(n)){var T=n.indexOf(t);T>-1&&n.splice(T,1),o.notifyMutation(n)}else n instanceof Set||n instanceof Map?(n.delete(t),o.notifyMutation(n)):o.implicitLoop(t,function(k){k.parentElement&&(n==null||n.contains(k))&&k.parentElement.removeChild(k)})}else if(this.variant==="css"){o.nullCheck(n,this.fromExpr);var m=Ti(i);o.implicitLoop(n,function(k){ki(k,m)})}else if(o.nullCheck(n,this.fromExpr),r)o.forEach(r,function(k){a.when?l=o.implicitLoopWhen(n,a.when,e,function(b){b.classList.remove(k.className)},function(b){b.classList.add(k.className)}):o.implicitLoop(n,function(b){b.classList.remove(k.className)})});else{var v=this.attributeRef;this.when?l=o.implicitLoopWhen(n,this.when,e,function(k){k.removeAttribute(v.name)},function(k){k.setAttribute(v.name,v.value)}):o.implicitLoop(n,function(k){k.removeAttribute(v.name)})}return l&&l.then?l.then(function(){return o.findNext(a,e)}):o.findNext(this,e)}isDOMTarget(e){return e instanceof Node||e instanceof NodeList||e instanceof HTMLCollection}},lr=class s extends C{static keyword="toggle";constructor(e,t,r,i,n,o,a,l,u,h,f,p,c,T,m,v){super(),this.classRef=e,this.classRef2=t,this.classRefs=r,this.attributeRef=i,this.attributeRef2=n,this.on=o,this.time=a,this.evt=l,this.from=u,this.visibility=h,this.betweenClass=f,this.betweenAttr=p,this.hideShowStrategy=c,this.betweenValues=T,this.toggleExpr=m,this.styleProp=v,this.onExpr=o,this.args={on:o,time:a,evt:l,from:u,classRef:e,classRef2:t,classRefs:r,betweenValues:T}}static parse(e){if(e.matchToken("toggle")){e.matchAnyToken("the","my");var t=!1,r=null,i=null,n=null,o=null,a=null,l=null,u=null,h=!1,f=!1,p=null,c=null;if(e.currentToken().type==="STYLE_REF")if(c=e.consumeToken().value.slice(1),t=!0,r=C.resolveHideShowStrategy(e,c),e.matchToken("of")){var T=e.pushFollows("with","between");try{i=e.requireElement("expression")}finally{e.popFollows(T)}}else i=e.requireElement("implicitMeTarget");else if(e.matchToken("between"))n=e.parseElement("classRef"),n!=null?(h=!0,e.requireToken("and"),o=e.requireElement("classRef")):(f=!0,l=e.parseElement("attributeRef"),l==null&&e.raiseError("Expected either a class reference or attribute expression"),e.requireToken("and"),u=e.requireElement("attributeRef"));else if(n=e.parseElement("classRef"))for(a=[n];n=e.parseElement("classRef");)a.push(n);else(l=e.parseElement("attributeRef"))||(e.pushFollow("between"),p=e.parseElement("assignableExpression"),e.popFollow(),p==null&&e.raiseError("Expected a class reference, attribute, style property, or settable expression"));!t&&!p&&(e.matchToken("on")?i=e.requireElement("expression"):i=e.requireElement("implicitMeTarget"));var m=null;if(e.matchToken("between")){for(e.pushFollow("and"),m=[e.requireElement("expression")];e.matchOpToken(",");)m.push(e.requireElement("expression"));e.popFollow(),e.requireToken("and"),m.push(e.requireElement("expression"))}p&&!m&&e.raiseError("toggle <expression> requires 'between' with values");var v=null,k=null,b=null;return e.peekToken("for")&&!e.peekToken("in",2)?(e.matchToken("for"),v=e.requireElement("expression")):e.matchToken("until")&&(k=e.requireElement("dotOrColonPath","Expected event name"),e.matchToken("from")&&(b=e.requireElement("expression"))),new s(n,o,a,l,u,i,v,k,b,t,h,f,r,m,p,c)}}toggle(e,t,r,i,n,o){if(this.betweenValues){if(this.visibility)e.meta.runtime.implicitLoop(t,c=>{var T=c.style[this.styleProp]||getComputedStyle(c)[this.styleProp],m=o.findIndex(v=>v==T);c.style[this.styleProp]=o[(m+1)%o.length]});else{var a=this.toggleExpr.evaluate(e),l=o.findIndex(c=>c==a),u=o[(l+1)%o.length],h={};for(var f in this.toggleExpr.lhs){var p=this.toggleExpr.lhs[f];h[f]=p&&p.evaluate?p.evaluate(e):p}this.toggleExpr.set(e,h,u)}return}e.meta.runtime.nullCheck(t,this.onExpr),this.visibility?e.meta.runtime.implicitLoop(t,c=>{this.hideShowStrategy("toggle",c,null,e.meta.runtime)}):this.betweenClass?e.meta.runtime.implicitLoop(t,c=>{c.classList.contains(r.className)?(c.classList.remove(r.className),c.classList.add(i.className)):(c.classList.add(r.className),c.classList.remove(i.className))}):this.betweenAttr?e.meta.runtime.implicitLoop(t,c=>{c.hasAttribute(this.attributeRef.name)&&c.getAttribute(this.attributeRef.name)===this.attributeRef.value?(c.removeAttribute(this.attributeRef.name),c.setAttribute(this.attributeRef2.name,this.attributeRef2.value)):(c.hasAttribute(this.attributeRef2.name)&&c.removeAttribute(this.attributeRef2.name),c.setAttribute(this.attributeRef.name,this.attributeRef.value))}):n?e.meta.runtime.forEach(n,c=>{e.meta.runtime.implicitLoop(t,T=>{T.classList.toggle(c.className)})}):e.meta.runtime.implicitLoop(t,c=>{c.hasAttribute(this.attributeRef.name)?c.removeAttribute(this.attributeRef.name):c.setAttribute(this.attributeRef.name,this.attributeRef.value)})}resolve(e,{on:t,time:r,evt:i,from:n,classRef:o,classRef2:a,classRefs:l,betweenValues:u}){return r?new Promise(h=>{this.toggle(e,t,o,a,l,u),setTimeout(()=>{this.toggle(e,t,o,a,l,u),h(this.findNext(e))},r)}):i?new Promise(h=>{var f=n||e.me;f.addEventListener(i,()=>{this.toggle(e,t,o,a,l,u),h(this.findNext(e))},{once:!0}),this.toggle(e,t,o,a,l,u)}):(this.toggle(e,t,o,a,l,u),this.findNext(e))}},ur=class s extends C{static keyword="hide";constructor(e,t,r){super(),this.target=e,this.targetExpr=e,this.when=t,this.hideShowStrategy=r,this.args={target:e}}static parse(e){if(e.matchToken("hide")){var t=C.parseShowHideTarget(e),r=null;if(e.matchToken("with")&&(r=e.requireTokenType("IDENTIFIER","STYLE_REF").value,r.startsWith("*")&&(r=r.slice(1))),e.matchToken("when"))var i=e.requireElement("expression");var n=C.resolveHideShowStrategy(e,r);return new s(t,i,n)}}resolve(e,{target:t}){var r=e.meta.runtime,i=this;if(r.nullCheck(t,this.targetExpr),this.when){var n=r.implicitLoopWhen(t,this.when,e,function(o){i.hideShowStrategy("hide",o,null,r)},function(o){i.hideShowStrategy("show",o,null,r)});if(n&&n.then)return n.then(function(){return r.findNext(i,e)})}else r.implicitLoop(t,function(o){i.hideShowStrategy("hide",o,null,r)});return r.findNext(this,e)}},hr=class s extends C{static keyword="show";constructor(e,t,r,i){super(),this.target=e,this.targetExpr=e,this.when=t,this.arg=r,this.hideShowStrategy=i,this.args={target:e}}static parse(e){if(e.matchToken("show")){var t=C.parseShowHideTarget(e),r=null;e.matchToken("with")&&(r=e.requireTokenType("IDENTIFIER","STYLE_REF").value,r.startsWith("*")&&(r=r.slice(1)));var i=null;if(e.matchOpToken(":")){var n=e.consumeUntilWhitespace();e.matchTokenType("WHITESPACE"),i=n.map(function(l){return l.value}).join("")}if(e.matchToken("when"))var o=e.requireElement("expression");var a=C.resolveHideShowStrategy(e,r);return new s(t,o,i,a)}}resolve(e,{target:t}){var r=e.meta.runtime,i=this;if(r.nullCheck(t,this.targetExpr),this.when){var n=r.implicitLoopWhen(t,this.when,e,function(o){i.hideShowStrategy("show",o,i.arg,r)},function(o){i.hideShowStrategy("hide",o,null,r)});if(n&&n.then)return n.then(function(){return r.findNext(i,e)})}else r.implicitLoop(t,function(o){i.hideShowStrategy("show",o,i.arg,r)});return r.findNext(this,e)}},cr=class s extends d{static keyword="take";constructor(e,t,r,i,n,o,a){super(),this.variant=e,this.classRefs=t,this.attributeRef=r,this.from=i,this.fromExpr=i,this.forElt=n,this.forExpr=n,this.replacementValue=o,this.replacementClass=a,e==="class"?this.args={classRefs:t,from:i,forElt:n}:this.args={from:i,forElt:n,replacementValue:o}}static parse(e){if(e.matchToken("take")){let a=null,l=[];for(;a=e.parseElement("classRef");)l.push(a);var t=null,r=null,i=null;let u=l.length>0;if(u?e.matchToken("with")&&(l.length>1&&e.raiseError("`with` cannot be combined with multiple class refs"),i=e.requireElement("classRef")):(t=e.parseElement("attributeRef"),t==null&&e.raiseError("Expected either a class reference or attribute expression"),e.matchToken("with")&&(r=e.requireElement("expression"))),e.matchToken("from")){var n=e.requireElement("expression");e.matchToken("giving")&&(u?(i&&e.raiseError("`giving` cannot be combined with `with`"),l.length>1&&e.raiseError("`giving` cannot be combined with multiple class refs"),i=e.requireElement("classRef")):(r&&e.raiseError("`giving` cannot be combined with `with`"),r=e.requireElement("expression")))}if(e.matchToken("for"))var o=e.requireElement("expression");else var o=e.requireElement("implicitMeTarget");return u?new s("class",l,null,n,o,null,i):new s("attribute",null,t,n,o,r,null)}}resolve(e,{classRefs:t,from:r,forElt:i,replacementValue:n}){if(this.variant==="class"){e.meta.runtime.nullCheck(i,this.forExpr);var o=this.replacementClass?this.replacementClass.className:null;e.meta.runtime.implicitLoop(t,a=>{var l=a.className;r?e.meta.runtime.implicitLoop(r,u=>{u.classList.remove(l),o&&u.classList.add(o)}):e.meta.runtime.implicitLoop(a,u=>{u.classList.remove(l),o&&u.classList.add(o)}),e.meta.runtime.implicitLoop(i,u=>{u.classList.add(l),o&&u.classList.remove(o)})})}else e.meta.runtime.nullCheck(r,this.fromExpr),e.meta.runtime.nullCheck(i,this.forExpr),e.meta.runtime.implicitLoop(r,a=>{n?a.setAttribute(this.attributeRef.name,n):a.removeAttribute(this.attributeRef.name)}),e.meta.runtime.implicitLoop(i,a=>{a.setAttribute(this.attributeRef.name,this.attributeRef.value||"")});return this.findNext(e)}},fr=class s extends d{static keyword="measure";constructor(e,t){super(),this.properties=t,this.targetExpr=e,this.args={target:e}}static parse(e){if(e.matchToken("measure")){var t,r=[],i=["x","y","left","top","right","bottom","width","height","bounds","scrollLeft","scrollTop","scrollLeftMax","scrollTopMax","scrollWidth","scrollHeight","scroll"];if(e.commandBoundary(e.currentToken()))t=e.parseElement("implicitMeTarget");else{var n=e.requireElement("expression");n.type==="symbol"&&i.includes(n.name)?(t=e.parseElement("implicitMeTarget"),r.push(n.name)):n.type==="possessive"&&n.prop||n.type==="ofExpression"&&n.prop?(t=n.root,r.push(n.prop.value)):t=n}for(;e.matchOpToken(",");)r.push(e.requireTokenType("IDENTIFIER").value);return new s(t,r)}}resolve(e,{target:t}){e.meta.runtime.nullCheck(t,this.targetExpr),0 in t&&(t=t[0]);var r=t.getBoundingClientRect(),i={top:t.scrollTop,left:t.scrollLeft,topMax:t.scrollTopMax,leftMax:t.scrollLeftMax,height:t.scrollHeight,width:t.scrollWidth};return e.result={x:r.x,y:r.y,left:r.left,top:r.top,right:r.right,bottom:r.bottom,width:r.width,height:r.height,bounds:r,scrollLeft:i.left,scrollTop:i.top,scrollLeftMax:i.leftMax,scrollTopMax:i.topMax,scrollWidth:i.width,scrollHeight:i.height,scroll:i},e.meta.runtime.forEach(this.properties,n=>{if(n in e.result)e.locals[n]=e.result[n];else throw new Error("No such measurement as "+n)}),this.findNext(e)}},mr=class s extends d{static keyword="focus";constructor(e){super(),this.args={target:e}}static parse(e){if(e.matchToken("focus")){var t=null;return e.commandBoundary(e.currentToken())||(t=e.requireElement("expression")),new s(t)}}resolve(e,{target:t}){return(t||e.me).focus(),this.findNext(e)}},pr=class s extends d{static keyword="blur";constructor(e){super(),this.args={target:e}}static parse(e){if(e.matchToken("blur")){var t=null;return e.commandBoundary(e.currentToken())||(t=e.requireElement("expression")),new s(t)}}resolve(e,{target:t}){return(t||e.me).blur(),this.findNext(e)}},vr=class s extends d{static keyword=["empty","clear"];constructor(e){super(),this.args={target:e}}static parse(e){if(!(!e.matchToken("empty")&&!e.matchToken("clear"))){var t=null;return e.commandBoundary(e.currentToken())||(t=e.requireElement("expression")),new s(t)}}resolve(e,{target:t}){var r=t||e.me;return Array.isArray(r)?(r.splice(0),e.meta.runtime.notifyMutation(r)):r instanceof Set||r instanceof Map?(r.clear(),e.meta.runtime.notifyMutation(r)):e.meta.runtime.implicitLoop(r,function(i){var n=i.tagName;n==="INPUT"?i.type==="checkbox"||i.type==="radio"?i.checked=!1:i.value="":n==="TEXTAREA"?i.value="":n==="SELECT"?i.selectedIndex=-1:n==="FORM"?i.querySelectorAll("input, textarea, select").forEach(function(o){o.tagName==="INPUT"?o.type==="checkbox"||o.type==="radio"?o.checked=!1:o.value="":o.tagName==="TEXTAREA"?o.value="":o.tagName==="SELECT"&&(o.selectedIndex=-1)}):i.replaceChildren()}),this.findNext(e)}},dr=class s extends d{static keyword="reset";constructor(e){super(),this.args={target:e}}static parse(e){if(e.matchToken("reset")){var t=null;return e.commandBoundary(e.currentToken())||(t=e.requireElement("expression")),new s(t)}}resolve(e,{target:t}){var r=t||e.me;return e.meta.runtime.implicitLoop(r,function(i){var n=i.tagName;if(n==="FORM")i.reset();else if(n==="INPUT")i.type==="checkbox"||i.type==="radio"?i.checked=i.defaultChecked:i.value=i.defaultValue;else if(n==="TEXTAREA")i.value=i.defaultValue;else if(n==="SELECT")for(var o=0;o<i.options.length;o++)i.options[o].selected=i.options[o].defaultSelected}),this.findNext(e)}};function zi(s){s instanceof HTMLDialogElement?s.open||s.showModal():s instanceof HTMLDetailsElement?s.open=!0:s.hasAttribute&&s.hasAttribute("popover")?s.showPopover():typeof s.open=="function"&&s.open()}function Gi(s){s instanceof HTMLDialogElement?s.close():s instanceof HTMLDetailsElement?s.open=!1:s.hasAttribute&&s.hasAttribute("popover")?s.hidePopover():typeof s.close=="function"&&s.close()}var yr=class s extends d{static keyword="open";constructor(e,t){super(),this.fullscreen=t,this.args={target:e}}static parse(e){if(e.matchToken("open")){var t=e.matchToken("fullscreen"),r=null;return e.commandBoundary(e.currentToken())||(r=e.requireElement("expression")),new s(r,!!t)}}resolve(e,{target:t}){var r=t||e.me;return this.fullscreen?(t||document.documentElement).requestFullscreen().then(()=>this.findNext(e)):(e.meta.runtime.implicitLoop(r,zi),this.findNext(e))}},Tr=class s extends d{static keyword="close";constructor(e,t){super(),this.fullscreen=t,this.args={target:e}}static parse(e){if(e.matchToken("close")){var t=e.matchToken("fullscreen"),r=null;return e.commandBoundary(e.currentToken())||(r=e.requireElement("expression")),new s(r,!!t)}}resolve(e,{target:t}){if(this.fullscreen)return document.exitFullscreen().then(()=>this.findNext(e));var r=t||e.me;return e.meta.runtime.implicitLoop(r,Gi),this.findNext(e)}},kr=class s extends d{static keyword="speak";constructor(e,t,r,i,n){super(),this.voice=t,this.rate=r,this.pitch=i,this.volume=n,this.args={text:e,voice:t,rate:r,pitch:i,volume:n}}static parse(e){if(e.matchToken("speak")){for(var t=e.requireElement("expression"),r=null,i=null,n=null,o=null;e.matchToken("with");)e.matchToken("voice")?r=e.requireElement("expression"):e.matchToken("rate")?i=e.requireElement("expression"):e.matchToken("pitch")?n=e.requireElement("expression"):e.matchToken("volume")?o=e.requireElement("expression"):e.raiseExpected("voice","rate","pitch","volume");return new s(t,r,i,n,o)}}resolve(e,{text:t,voice:r,rate:i,pitch:n,volume:o}){var a=new SpeechSynthesisUtterance(String(t));if(r){var l=speechSynthesis.getVoices(),u=l.find(f=>f.name===r);u&&(a.voice=u)}i!=null&&(a.rate=i),n!=null&&(a.pitch=n),o!=null&&(a.volume=o);var h=this;return new Promise(function(f){a.onend=function(){f(e.meta.runtime.findNext(h,e))},speechSynthesis.speak(a)})}},Er=class s extends d{static keyword="select";constructor(e){super(),this.args={target:e}}static parse(e){if(e.matchToken("select")){var t=null;return e.commandBoundary(e.currentToken())||(t=e.requireElement("expression")),new s(t)}}resolve(e,{target:t}){var r=t||e.me;return typeof r.select=="function"&&r.select(),this.findNext(e)}},gr=class s extends d{static keyword="ask";constructor(e){super(),this.args={message:e}}static parse(e){if(e.matchToken("ask")){var t=e.requireElement("expression");return new s(t)}}resolve(e,{message:t}){return e.result=prompt(String(t)),this.findNext(e)}},wr=class s extends d{static keyword="answer";constructor(e,t,r){super(),this.choiceA=t,this.choiceB=r,this.args={message:e,choiceA:t,choiceB:r}}static parse(e){if(e.matchToken("answer")){var t=e.requireElement("expression"),r=null,i=null;if(e.matchToken("with")){e.pushFollow("or");try{r=e.requireElement("expression")}finally{e.popFollow()}e.requireToken("or"),i=e.requireElement("expression")}return new s(t,r,i)}}resolve(e,{message:t,choiceA:r,choiceB:i}){return r?e.result=confirm(String(t))?r:i:alert(String(t)),this.findNext(e)}},br=class s extends d{static keyword="morph";constructor(e,t){super(),this.args={target:e,content:t}}static parse(e){if(e.matchToken("morph")){var t=e.requireElement("expression");e.requireToken("to");var r=e.requireElement("expression");return new s(t,r)}}resolve(e,{target:t,content:r}){return e.meta.runtime.implicitLoop(t,function(i){e.meta.runtime.morph(i,r)}),this.findNext(e)}};var Or={};N(Or,{SettleCommand:()=>Sr,TransitionCommand:()=>qr,ViewTransitionCommand:()=>Lr});var Sr=class s extends d{static keyword="settle";constructor(e){super(),this.onExpr=e,this.args={on:e}}static parse(e){if(e.matchToken("settle")){if(e.commandBoundary(e.currentToken()))var t=e.requireElement("implicitMeTarget");else var t=e.requireElement("expression");return new s(t)}}resolve(e,{on:t}){e.meta.runtime.nullCheck(t,this.onExpr);var r=this,i=t instanceof Element?[t]:Array.from(t);return Promise.all(i.map($i)).then(function(){return e.meta.runtime.findNext(r,e)})}};function $i(s){return new Promise(function(e){var t=!1,r=!1;s.addEventListener("transitionstart",function(){r=!0},{once:!0}),setTimeout(function(){!r&&!t&&(t=!0,e())},500),s.addEventListener("transitionend",function(){t||(t=!0,e())},{once:!0})})}var qr=class s extends d{static keyword="transition";constructor(e,t,r,i,n){super(),this.propExprs=e,this.from=t,this.to=r,this.usingExpr=i,this.over=n,this.args={from:t,to:r,using:i,over:n}}static parse(e){if(e.matchToken("transition")){var t=[],r=[],i=[];do{var n=e.pushFollows("from","to");try{t.push(e.requireElement("expression"))}finally{e.popFollows(n)}r.push(e.matchToken("from")?e.requireElement("expression"):null),e.requireToken("to"),i.push(e.matchToken("initial")?"initial":e.requireElement("expression"))}while(!e.commandBoundary(e.currentToken())&&e.currentToken().value!=="over"&&e.currentToken().value!=="using");var o,a;return e.matchToken("over")?o=e.requireElement("expression"):e.matchToken("using")&&(a=e.requireElement("expression")),new s(t,r,i,a,o)}}resolve(e,{from:t,to:r,using:i,over:n}){var o=this,a=e.meta.runtime,l;this.propExprs[0].root?(l=this.propExprs[0].root.evaluate(e),a.nullCheck(l,this.propExprs[0].root)):l=e.me;var u=[];return a.implicitLoop(l,function(h){u.push(new Promise(function(f){var p=h.style.transition;n?h.style.transition="all "+n+"ms ease-in":i?h.style.transition=i:h.style.transition=A.defaultTransition;var c=a.getInternalData(h);c.transitionInitials||(c.transitionInitials={});for(var T=c.transitionInitials,m=0;m<o.propExprs.length;m++)m in T||(T[m]=o.propExprs[m].evaluate(e));for(var m=0;m<o.propExprs.length;m++)if(t[m]!=null){var v={};for(var k in o.propExprs[m].lhs){var b=o.propExprs[m].lhs[k];v[k]=b&&b.evaluate?b.evaluate(e):b}o.propExprs[m].set(e,v,t[m])}var g=!1,x=!1;h.addEventListener("transitionend",function(){x||(h.style.transition=p,x=!0,f())},{once:!0}),h.addEventListener("transitionstart",function(){g=!0},{once:!0}),setTimeout(function(){!x&&!g&&(h.style.transition=p,x=!0,f())},100),setTimeout(function(){for(var E=0;E<o.propExprs.length;E++){var q={};for(var M in o.propExprs[E].lhs){var L=o.propExprs[E].lhs[M];q[M]=L&&L.evaluate?L.evaluate(e):L}var P=r[E]==="initial"?T[E]:r[E];o.propExprs[E].set(e,q,P)}},0)}))}),Promise.all(u).then(function(){return o.findNext(e)})}},Nr=class extends d{constructor(){super(),this.type="abortViewTransition"}resolve(e){var t=e.meta.viewTransition;return t&&(console.warn("hyperscript: view transition skipped due to early exit (return, halt, or break)"),e.meta.viewTransition=null,t.finished.catch(function(){}),t.transition.skipTransition(),t.bodyDone()),e.meta.runtime.findNext(this)}},Qi=new Set(["returnCommand","exitCommand","haltCommand","breakCommand","continueCommand"]),Yi=new Set(["breakCommand","continueCommand"]);function Ei(s,e,t){if(t||(t=new Set),!(!s||t.has(s))){t.add(s);var r=e||s.loop!==void 0;for(var i of Object.keys(s))if(i!=="parent"){var n=s[i];if(n instanceof I&&Qi.has(n.type)&&(!Yi.has(n.type)||!e)){var o=new Nr;o.next=n,s[i]=o,t.add(o)}for(var a of[n].flat())a instanceof I&&Ei(a,r,t)}}}var Ar=class extends d{constructor(){super(),this.type="viewTransitionTick"}resolve(e){return new Promise(t=>{setTimeout(()=>t(e.meta.runtime.findNext(this)),0)})}},Ir=class extends d{constructor(){super(),this.type="viewTransitionEnd"}resolve(e){var t=e.meta.viewTransition;return t?(t.bodyDone(),t.finished.then(()=>(e.meta.viewTransition=null,e.meta.runtime.findNext(this.parent,e)))):e.meta.runtime.findNext(this.parent,e)}},Lr=class s extends d{static keyword="start";constructor(e,t){super(),this.body=e,this.transitionType=t,this.args={type:t}}static parse(e){if(e.matchToken("start")){e.matchToken("a"),e.requireToken("view"),e.requireToken("transition"),e.matchToken("using");var t=e.matchTokenType("STRING"),r=t?t.value:null,i=e.requireElement("commandList"),n=new Ar;n.next=i;for(var o=new Ir,a=i;a.next;)a=a.next;a.next=o,e.hasMore()&&e.requireToken("end"),Ei(i,!1);var l=new s(n,r);return e.setParent(n,l),e.setParent(i,l),o.parent=l,l}}resolve(e,{type:t}){if(!document.startViewTransition)return this.body;if(e.meta.viewTransition)throw new Error("A view transition is already in progress");var r,i=new Promise(function(a){r=a}),n=function(){return i};t&&(n={update:function(){return i},types:[t]});var o=document.startViewTransition(n);return e.meta.viewTransition={bodyDone:r,finished:o.finished,transition:o},this.body}};var Fr={};N(Fr,{BreakpointCommand:()=>Mr});var Mr=class s extends d{static keyword="breakpoint";static parse(e){if(e.matchToken("breakpoint"))return new s}resolve(e){debugger;return this.findNext(e)}};var Cr={};N(Cr,{OnFeature:()=>Rr});var Rr=class s extends S{static keyword="on";constructor(e,t,r,i,n,o,a,l,u,h,f){super(),this.displayName=e,this.events=t,this.start=r,this.every=i,this.errorHandler=n,this.errorSymbol=o,this.finallyHandler=a,this.queueAll=l,this.queueFirst=u,this.queueNone=h,this.queueLast=f}execute(e){let t=this,r=this.every,i=this.queueNone,n=this.queueFirst,o=this.queueLast,a=this.start,l=e.meta.runtime.getEventQueueFor(e.me,t);if(l.executing&&r===!1){if(i||n&&l.queue.length>0)return;o&&(l.queue.length=0),l.queue.push(e);return}l.executing=!0,e.meta.onHalt=function(){l.executing=!1;var u=l.queue.shift();u&&setTimeout(function(){t.execute(u)},1)},e.meta.reject=function(u){console.error(u.message?u.message:u),console.error(u.stack);var h=e.meta.runtime.getHyperTrace(e,u);h&&h.print(),e.meta.runtime.triggerEvent(e.me,"exception",{error:u})},a.execute(e)}install(e,t,r,i){let n=this,o=this.displayName,a=this.errorHandler,l=this.errorSymbol,u=this.finallyHandler;for(let c of n.events){var h;c.elsewhere?h=[document]:c.from?h=c.from.evaluate(i.makeContext(e,n,e,null)):h=[e];var f=i.getInternalData(e);f.eventState||(f.eventState=new Map),f.eventState.has(c)||f.eventState.set(c,{execCount:0,debounced:void 0,lastExec:void 0});var p=f.eventState.get(c);i.implicitLoop(h,function(T){var m=c.on;if(T==null){console.warn("'%s' feature ignored because target does not exists:",o,e);return}var v=i.getInternalData(e);if(v.listeners||(v.listeners=[]),v.observers||(v.observers=[]),c.mutationSpec){m="hyperscript:mutation";let g=new MutationObserver(function(x,E){n.executing||i.triggerEvent(T,m,{mutationList:x,observer:E})});g.observe(T,c.mutationSpec),v.observers.push(g)}if(c.intersectionSpec){m="hyperscript:intersection";let g=new IntersectionObserver(function(x){for(let q of x){var E={observer:g};E=Object.assign(E,q),E.intersecting=q.isIntersecting,i.triggerEvent(T,m,E)}},c.intersectionSpec);g.observe(T),v.observers.push(g)}if(c.resizeSpec&&T instanceof Element){m="hyperscript:resize";let g=new ResizeObserver(function(x){for(let q of x){var E={width:q.contentRect.width,height:q.contentRect.height,contentRect:q.contentRect,entry:q};i.triggerEvent(T,m,E)}});g.observe(T),v.observers.push(g)}var k=T.addEventListener||T.on,b;k.call(T,m,b=function g(x){if(typeof Node<"u"&&e instanceof Node&&T!==e&&!e.isConnected){T.removeEventListener(m,g);return}var E=i.makeContext(e,n,e,x);if(!(c.elsewhere&&e.contains(x.target))){c.from&&(E.result=T);for(let P of c.args){let Y=E.event[P.value];Y!==void 0?E.locals[P.value]=Y:E.event.detail!=null&&(E.locals[P.value]=E.event.detail[P.value])}if(E.meta.errorHandler=a,E.meta.errorSymbol=l,E.meta.finallyHandler=u,c.filter){var q=E.meta.context;E.meta.context=E.event;try{var M=c.filter.evaluate(E);if(!M)return}finally{E.meta.context=q}}if(c.inExpr){for(var L=x.target;;)if(L.matches&&L.matches(c.inExpr.css)){E.result=L;break}else if(L=L.parentElement,L==null)return}if(p.execCount++,c.startCount){if(c.endCount){if(p.execCount<c.startCount||p.execCount>c.endCount)return}else if(c.unbounded){if(p.execCount<c.startCount)return}else if(p.execCount!==c.startCount)return}if(c.debounceTime){p.debounced&&clearTimeout(p.debounced),p.debounced=setTimeout(function(){n.execute(E)},c.debounceTime);return}if(c.throttleTime){if(p.lastExec&&Date.now()<p.lastExec+c.throttleTime)return;p.lastExec=Date.now()}n.execute(E)}}),v.listeners.push({target:T,event:m,handler:b})})}}static parse(e){if(e.matchToken("on")){var t=!1,r=!1;e.matchToken("every")?t=!0:e.matchToken("first")&&(r=!0);var i=[],n=null;do{var o=e.requireElement("eventName","Expected event name"),a=o.evalStatically();n?n=n+" or "+a:n="on "+a;var l=I.parseEventArgs(e),u=null;e.matchOpToken("[")&&(u=e.requireElement("expression"),e.requireOpToken("]"));var h,f,p;if(r)h=1;else if(e.currentToken().type==="NUMBER"){var c=e.consumeToken();if(!c.value)return;if(h=parseInt(c.value),e.matchToken("to")){var T=e.consumeToken();if(!T.value)return;f=parseInt(T.value)}else e.matchToken("and")&&(p=!0,e.requireToken("on"))}var m,v,k;if(a==="resize")k=!0;else if(a==="intersection"){if(m={},e.matchToken("with")&&(m.with=e.requireElement("expression").evalStatically()),e.matchToken("having"))do e.matchToken("margin")?m.rootMargin=e.requireElement("stringLike").evalStatically():e.matchToken("threshold")?m.threshold=e.requireElement("expression").evalStatically():e.raiseError("Unknown intersection config specification");while(e.matchToken("and"))}else if(a==="mutation")if(v={},e.matchToken("of")){do if(e.matchToken("anything"))v.attributes=!0,v.subtree=!0,v.characterData=!0,v.childList=!0;else if(e.matchToken("childList"))v.childList=!0;else if(e.matchToken("attributes"))v.attributes=!0;else if(e.matchToken("subtree"))v.subtree=!0;else if(e.matchToken("characterData"))v.characterData=!0;else if(e.currentToken().type==="ATTRIBUTE_REF"){var b=e.consumeToken();v.attributeFilter==null&&(v.attributeFilter=[]),b.value.startsWith("@")?v.attributeFilter.push(b.value.substring(1)):e.raiseError("Only shorthand attribute references are allowed here")}else e.raiseError("Unknown mutation config specification");while(e.matchToken("or"));(v.attributes||v.attributeFilter)&&(v.attributeOldValue=!0),v.characterData&&(v.characterDataOldValue=!0)}else v.attributes=!0,v.characterData=!0,v.childList=!0,v.attributeOldValue=!0,v.characterDataOldValue=!0;var g=null,x=!1;if(e.matchToken("from"))if(e.matchToken("elsewhere"))x=!0;else{e.pushFollow("or");try{g=e.requireElement("expression")}finally{e.popFollow()}g||e.raiseError('Expected either target value or "elsewhere".')}if(g===null&&x===!1&&e.matchToken("elsewhere")&&(x=!0),e.matchToken("in"))var E=e.parseElement("unaryExpression");if(e.matchToken("debounced")){e.requireToken("at");var q=e.requireElement("unaryExpression"),M=q.evalStatically()}else if(e.matchToken("throttled")){e.requireToken("at");var q=e.requireElement("unaryExpression"),L=q.evalStatically()}i.push({every:t,on:a,args:l,filter:u,from:g,inExpr:E,elsewhere:x,startCount:h,endCount:f,unbounded:p,debounceTime:M,throttleTime:L,mutationSpec:v,intersectionSpec:m,resizeSpec:k})}while(e.matchToken("or"));var P=!0;if(!t&&e.matchToken("queue"))if(e.matchToken("all"))var Y=!0,P=!1;else if(e.matchToken("first"))var Ii=!0;else if(e.matchToken("none"))var Li=!0;else e.requireToken("last");var fe=e.requireElement("commandList");e.ensureTerminated(fe);var{errorHandler:Oi,errorSymbol:Mi,finallyHandler:Fi}=S.parseErrorAndFinally(e),li=new s(n,i,fe,t,Oi,Mi,Fi,Y,Ii,Li,P);return e.setParent(fe,li),li}}};var Pr={};N(Pr,{DefFeature:()=>_r});var _r=class s extends S{static keyword="def";constructor(e,t,r,i,n,o,a,l){super(),this.displayName=e+"("+i.map(function(u){return u.value}).join(", ")+")",this.name=e,this.args=i,this.start=n,this.errorHandler=o,this.errorSymbol=a,this.finallyHandler=l,this.nameSpace=t,this.nameVal=r}install(e,t,r,i){let n=this.args,o=this.start,a=this.errorHandler,l=this.errorSymbol,u=this.finallyHandler,h=this.nameVal,f=this.nameSpace,p=this.name,c=this;var T=function(){var m=i.makeContext(t,c,e,null);m.meta.errorHandler=a,m.meta.errorSymbol=l,m.meta.finallyHandler=u;for(var v=0;v<n.length;v++){var k=n[v],b=arguments[v];k&&(m.locals[k.value]=b)}m.meta.caller=arguments[n.length],m.meta.caller&&(m.meta.callingCommand=m.meta.caller.meta.command);var g,x,E=new Promise(function(q,M){g=q,x=M});return o.execute(m),m.meta.returned?m.meta.returnValue:(m.meta.resolve=g,m.meta.reject=x,E)};T.hyperfunc=!0,T.hypername=h,i.assignToNamespace(e,f,p,T)}static parse(e){if(e.matchToken("def")){var t=e.requireElement("dotOrColonPath"),r=t.evalStatically(),i=r.split("."),n=i.pop(),o=[];if(e.matchOpToken("(")&&!e.matchOpToken(")")){do o.push(e.requireTokenType("IDENTIFIER"));while(e.matchOpToken(","));e.requireOpToken(")")}var a=e.requireElement("commandList"),{errorHandler:l,errorSymbol:u,finallyHandler:h}=S.parseErrorAndFinally(e),f=new s(n,i,r,o,a,l,u,h);return e.ensureTerminated(a),l&&e.ensureTerminated(l),e.setParent(a,f),f}}};var Hr={};N(Hr,{SetFeature:()=>Dr});var Dr=class s extends S{static keyword="set";constructor(e){super(),this.start=e}install(e,t,r,i){this.start&&this.start.execute(i.makeContext(e,this,e,null))}static parse(e){let t=e.parseElement("setCommand");if(t){t.target.scope==="local"&&e.raiseError("variables declared at the feature level cannot be locally scoped (use :foo, ^foo, $foo, or an @attribute target instead).");let r=new s(t);return e.ensureTerminated(t),r}}};var jr={};N(jr,{InitFeature:()=>Wr});var Wr=class s extends S{static keyword="init";constructor(e,t){super(),this.start=e,this.immediately=t}install(e,t,r,i){var n=()=>{this.start?.execute(i.makeContext(e,this,e,null))};this.immediately?n():queueMicrotask(n)}static parse(e){if(e.matchToken("init")){var t=e.matchToken("immediately"),r=e.requireElement("commandList"),i=new s(r,t);return e.ensureTerminated(r),e.setParent(r,i),i}}};var Br={};N(Br,{WorkerFeature:()=>Ur});var Ur=class extends S{static keyword="worker";static parse(e){if(e.matchToken("worker")){e.raiseError("In order to use the 'worker' feature, include the _hyperscript worker plugin. See https://hyperscript.org/features/worker/ for more info.");return}}};var Gr={};N(Gr,{BehaviorFeature:()=>zr});var zr=class s extends S{static keyword="behavior";constructor(e,t,r,i,n){super(),this.path=e,this.nameSpace=t,this.name=r,this.formalParams=i,this.hs=n}install(e,t,r,i){let n=this.path,o=this.nameSpace,a=this.name,l=this.formalParams,u=this.hs;i.assignToNamespace(null,o,a,function(h,f,p){for(var c=i.getInternalData(h),T=n+"Scope",m=c[T]||(c[T]={}),v=0;v<l.length;v++)m[l[v]]=p[l[v]];u.apply(h,f,null,i)})}static parse(e){if(e.matchToken("behavior")){var t=e.requireElement("dotOrColonPath").evalStatically(),r=t.split("."),i=r.pop(),n=[];if(e.matchOpToken("(")&&!e.matchOpToken(")")){do n.push(e.requireTokenType("IDENTIFIER").value);while(e.matchOpToken(","));e.requireOpToken(")")}for(var o=e.requireElement("hyperscript"),a=0;a<o.features.length;a++){var l=o.features[a];l.behavior=t}return new s(t,r,i,n,o)}}};var Qr={};N(Qr,{InstallFeature:()=>$r});var $r=class s extends S{static keyword="install";constructor(e,t,r){super(),this.behaviorPath=e,this.behaviorNamespace=t,this.behaviorArgs=r}install(e,t,r,i){for(var n=i.makeContext(e,this,e,null),o=this.behaviorArgs?this.behaviorArgs.evaluate(n):null,a=i.globalScope,l=0;l<this.behaviorNamespace.length;l++)if(a=a[this.behaviorNamespace[l]],typeof a!="object"&&typeof a!="function")throw new Error("No such behavior defined as "+this.behaviorPath);if(!(a instanceof Function))throw new Error(this.behaviorPath+" is not a behavior");a(e,t,o)}static parse(e){if(e.matchToken("install")){var t=e.requireElement("dotOrColonPath").evalStatically(),r=t.split("."),i=e.parseElement("namedArgumentList");return new s(t,r,i)}}};var Kr={};N(Kr,{JsFeature:()=>Yr});var Yr=class s extends S{static keyword="js";constructor(e,t,r){super(),this.jsSource=e,this.function=t,this.exposedFunctionNames=r}install(e,t,r,i){Object.assign(i.globalScope,this.function())}static parse(e){if(e.matchToken("js")){var t=e.requireElement("jsBody"),r=t.jsSource+`
return { `+t.exposedFunctionNames.map(function(n){return n+":"+n}).join(",")+" } ",i=new Function(r);return new s(r,i,t.exposedFunctionNames)}}};var Xr={};N(Xr,{WhenFeature:()=>Jr});var Jr=class s extends S{static keyword="when";static parse(e){if(e.matchToken("when")){var t=[];do{e.pushFollow("or");try{t.push(e.requireElement("expression"))}finally{e.popFollow()}}while(e.matchToken("or"));for(var r=0;r<t.length;r++){var i=t[r];i.type==="symbol"&&i.scope==="local"&&!i.name.startsWith("$")&&!i.name.startsWith(":")&&e.raiseError("Cannot watch local variable '"+i.name+"'. Local variables are not reactive. Use '$"+i.name+"' (global) or ':"+i.name+"' (element-scoped) instead.")}e.requireToken("changes");var n=e.requireElement("commandList");e.ensureTerminated(n);var o=new s(t,n);return e.setParent(n,o),o}}constructor(e,t){super(),this.exprs=e,this.start=t,this.displayName="when ... changes"}install(e,t,r,i){var n=this;queueMicrotask(function(){for(var o=0;o<n.exprs.length;o++)(function(a){i.reactivity.createEffect(function(){return a.evaluate(i.makeContext(e,n,e,null))},function(l){var u=i.makeContext(e,n,e,null);u.result=l,u.meta.reject=function(h){console.error(h.message?h.message:h),i.triggerEvent(e,"exception",{error:h})},u.meta.onHalt=function(){},n.start.execute(u)},{element:e})})(n.exprs[o])})}};var Vr={};N(Vr,{BindFeature:()=>Zr});var Zr=class s extends S{static keyword="bind";static parse(e){if(e.matchToken("bind")){var t=e.pushFollows("and","with","to"),r;try{r=e.requireElement("expression")}finally{e.popFollows(t)}!e.matchToken("and")&&!e.matchToken("with")&&!e.matchToken("to")&&e.raiseExpected("and","with","to");var i=e.requireElement("expression");return new s(r,i)}}constructor(e,t){super(),this.left=e,this.right=t,this.displayName="bind"}install(e,t,r,i){var n=this;queueMicrotask(function(){try{Ji(n.left,n.right,e,n,i)}catch(o){console.error(o.message||o)}})}};function Ki(s,e,t,r,i){var n=s.getInternalData(e);n.listeners||(n.listeners=[]),n.listeners.push({target:t,event:r,handler:i})}function gi(s){return s.type==="classRef"||s.type==="attributeRef"?!0:typeof s.set=="function"}function Ji(s,e,t,r,i){var n=i.makeContext(t,r,t,null),o=wi(s,t,r,i,n),a=wi(e,t,r,i,n),l=o.element||gi(s),u=a.element||gi(e);if(!l&&!u)throw new Error("bind requires at least one writable side");l&&i.reactivity.createEffect(function(){return a.read()},function(h){o.write(h)},{element:t}),u&&i.reactivity.createEffect(function(){return o.read()},function(h){a.write(h)},{element:t}),Vi(o,a,t,i)}function wi(s,e,t,r,i){var n=s.evaluate(i);return n instanceof Element?Xi(n,r):Zi(s,e,t,r)}var bi={"INPUT:checkbox":"checked","INPUT:number":"valueAsNumber","INPUT:range":"valueAsNumber",INPUT:"value",TEXTAREA:"value",SELECT:"value"};function Xi(s,e){var t=s.tagName,r=t==="INPUT"?s.getAttribute("type")||"text":null;if(t==="INPUT"&&r==="radio"){var i=s.value;return{element:s,read:function(){var a=e.resolveProperty(s,"checked");return a?i:void 0},write:function(a){s.checked=a===i}}}var n=bi[t+":"+r]||bi[t];if(!n&&s.hasAttribute("contenteditable")&&s.getAttribute("contenteditable")!=="false"&&(n="textContent"),!n&&t.includes("-")&&"value"in s&&(n="value"),!n)throw new Error("bind cannot auto-detect a property for <"+t.toLowerCase()+">. Use an explicit property (e.g. 'bind $var to #el's value').");var o=n==="valueAsNumber";return{element:s,read:function(){var a=e.resolveProperty(s,n);return o&&a!==a?null:a},write:function(a){s[n]=a}}}function Zi(s,e,t,r){return s.type==="classRef"?{read:function(){return r.resolveAttribute(e,"class"),e.classList.contains(s.className)},write:function(i){i?e.classList.add(s.className):e.classList.remove(s.className)}}:{read:function(){return s.evaluate(r.makeContext(e,t,e,null))},write:function(i){var n=r.makeContext(e,t,e,null);tn(r,s,n,i)}}}function Vi(s,e,t,r){xi(s,e,t,r),xi(e,s,t,r)}function xi(s,e,t,r){if(s.element){var i=s.element.closest("form");if(i){var n=()=>{setTimeout(()=>{t.isConnected&&e.write(s.read())},0)};i.addEventListener("reset",n),Ki(r,t,i,"reset",n)}}}function en(s,e,t){typeof t=="boolean"?e.startsWith("aria-")?s.setAttribute(e,String(t)):t?s.setAttribute(e,""):s.removeAttribute(e):t==null?s.removeAttribute(e):s.setAttribute(e,t)}function tn(s,e,t,r){if(e.type==="classRef"){var i=t.you||t.me;i&&(r?i.classList.add(e.className):i.classList.remove(e.className))}else if(e.type==="attributeRef"&&typeof r=="boolean"){var i=t.you||t.me;i&&en(i,e.name,r)}else{var n={};if(e.lhs)for(var o in e.lhs){var a=e.lhs[o];n[o]=a&&a.evaluate?a.evaluate(t):a}e.set(t,n,r)}}var ti={};N(ti,{LiveFeature:()=>ei});var ei=class s extends S{static keyword="live";constructor(e){super(),this.commands=e,this.displayName="live"}static parse(e){if(e.matchToken("live")){var t=e.requireElement("commandList"),r=new s(t);return e.ensureTerminated(t),e.setParent(t,r),r}}install(e,t,r,i){var n=this;queueMicrotask(function(){i.reactivity.createEffect(function(){n.commands.execute(i.makeContext(e,n,e,null))},function(){},{element:e})})}};var oi={};N(oi,{EscapeExpression:()=>ni,RenderCommand:()=>ii,TemplateTextCommand:()=>ri,initLiveTemplates:()=>si});function qi(s){return s.textContent}var rn='script[type="text/hyperscript-template"][live]';function si(s,e,t,r,i){var n=new WeakSet;s.addBeforeProcessHook(function(o){!o||!o.querySelectorAll||o.querySelectorAll(rn).forEach(function(a){if(n.has(a))return;n.add(a);var l=qi(a),u=a.getAttribute("_")||a.getAttribute("data-script")||"";a.removeAttribute("_"),a.removeAttribute("data-script");var h=document.createElement("div");h.style.display="contents",h.setAttribute("data-live-template",""),a.after(h),u&&(h.setAttribute("_",u),s.processNode(h));var f=!1;function p(m){f?s.morph(h,m):(h.innerHTML=m,s.processNode(h),f=!0)}function c(){var m=s.makeContext(h,null,h,null),v=[];m.meta.__ht_template_result=v;var k=e.tokenize(l,"lines"),b=new t(r,k),g;try{g=b.parseElement("commandList"),b.ensureTerminated(g)}catch(q){return console.error("live-template parse error:",q.message||q),""}if(g.execute(m),h.__hs_scopes=m.meta.__ht_scopes||null,m.meta.returned||!m.meta.resolve)return v.join("");var x,E=new Promise(function(q){x=q});return m.meta.resolve=x,E.then(function(){return v.join("")})}queueMicrotask(function(){var m=c();m&&m.then?m.then(function(v){p(v),T()}):(p(m),T())});function T(){i.createEffect(c,p,{element:h})}})})}function Si(s,e){return e.type==="literal"?s:s==null?"":e.escape?Ni(String(s)):String(s)}function Ni(s){return String(s).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}var ri=class s extends d{static keyword="TEMPLATE_LINE";constructor(e,t){super(),this.parts=e,this.errors=t}static parse(e){var t=e.currentToken();if(t.type==="TEMPLATE_LINE"){e.consumeToken();for(var r=[],i=[],n=t.content,o=0;o<n.length;){var a=n.indexOf("${",o);if(a===-1){o<n.length&&r.push({type:"literal",value:n.slice(o)});break}a>o&&r.push({type:"literal",value:n.slice(o,a)});for(var l=1,u=a+2;u<n.length&&l>0;)n[u]==="{"?l++:n[u]==="}"&&l--,u++;if(l>0){i.push({line:t.line,message:"Unterminated ${} expression",expr:n.slice(a)}),r.push({type:"literal",value:""});break}var h=n.slice(a+2,u-1),f=!0;try{var p=new O().tokenize(h),c=e.createChildParser(p);c.matchToken("unescaped")&&(f=!1);var T=c.requireElement("expression");if(c.matchToken("if")){var m=c.requireElement("expression"),v=c.matchToken("else")?c.requireElement("expression"):null;r.push({type:"conditional",valueNode:T,conditionNode:m,elseNode:v,escape:f})}else r.push({type:"expr",node:T,escape:f})}catch(k){i.push({line:t.line,column:t.column+a,message:k.message||String(k),expr:h}),r.push({type:"literal",value:""})}o=u}return new s(r,i)}}resolve(e){var t=this.parts,r=t.map(i=>{if(i.type==="literal")return i.value;if(i.type==="conditional"){var n=i.conditionNode.evaluate(e);return n?i.valueNode.evaluate(e):i.elseNode?i.elseNode.evaluate(e):void 0}return i.node.evaluate(e)});return r.some(i=>i&&i.then)?Promise.all(r).then(i=>(e.meta.__ht_template_result.push(i.map((n,o)=>Si(n,t[o])).join("")),this.findNext(e))):(e.meta.__ht_template_result.push(r.map((i,n)=>Si(i,t[n])).join("")),this.findNext(e))}},ii=class s extends d{static keyword="render";constructor(e,t,r,i){super(),this.template_=e,this.insertHere=r,this.args={template:e,templateArgs:t,target:i}}static parse(e){if(e.matchToken("render")){var t=e.requireElement("expression"),r={};e.matchToken("with")&&(r=e.parseElement("nakedNamedArgumentList"));var i=!!e.matchToken("here"),n=null;!i&&e.matchToken("into")&&(n=e.requireElement("expression"));var o=new s(t,r,i,n);return o._parser=e,o}}resolve(e,{template:t,templateArgs:r,target:i}){if(!(t instanceof Element))throw new Error(this.template_.sourceFor()+" is not an element");var n=[],o=e.meta.runtime,a=o.makeContext(e.me,null,e.me,null);a.locals=Object.assign({},e.locals,r),a.meta.__ht_template_result=n;var l=new O().tokenize(qi(t),"lines"),u=this._parser.createChildParser(l),h;try{h=u.parseElement("commandList"),u.ensureTerminated(h)}catch(g){return console.error("hyperscript template parse error:",g.parseError?.message||g.message||g),e.result="",o.findNext(this,e)}var f=h.collectErrors();if(f.length)for(var p of f)console.error("hyperscript template error (line "+p.line+"): "+p.message+(p.expr?" in ${"+p.expr+"}":""));var c,T,m=new Promise(function(g,x){c=g,T=x});h.execute(a);var v=a.meta.__ht_scopes||null,k=/<!--hs-scope:[^>]*-->/g,b=g=>(e.result=g.replace(k,""),this.insertHere&&(e.me.__hs_scopes=v,e.me.innerHTML=g),i&&(i.__hs_scopes=v,i.innerHTML=g),o.findNext(this,e));return a.meta.returned?b(n.join("")):(a.meta.resolve=c,a.meta.reject=T,m.then(()=>b(n.join(""))))}},ni=class s extends y{static grammarName="escape";static expressionType="leaf";constructor(e,t,r){super(),this.unescaped=t,this.escapeType=r,this.args={value:e}}static parse(e){if(e.matchToken("escape")){var t=e.matchTokenType("IDENTIFIER").value,r=e.matchToken("unescaped"),i=e.requireElement("expression");return new s(i,r,t)}}resolve(e,{value:t}){if(this.unescaped)return t;if(t==null)return"";if(this.escapeType==="html")return Ni(t);throw new Error("Unknown escape: "+this.escapeType)}};var $=typeof self<"u"?self:typeof global<"u"?global:void 0;A.conversions=z;var w=new ee,Q=new O,ai=new ae,nn=new le,_=new oe($,w,Q,ai,nn);w.registerModule(tt);w.registerModule(xe);w.registerModule(lt);w.registerModule(ft);w.registerModule(yt);w.registerModule(Et);w.registerModule(wt);w.registerModule(Ct);w.registerModule(jt);w.registerModule(Gt);w.registerModule(Vt);w.registerModule(ir);w.registerModule(sr);w.registerModule(xr);w.registerModule(Or);w.registerModule(Fr);w.registerModule(Cr);w.registerModule(Pr);w.registerModule(Hr);w.registerModule(jr);w.registerModule(Br);w.registerModule(Gr);w.registerModule(Qr);w.registerModule(Kr);w.registerModule(Xr);w.registerModule(Vr);w.registerModule(ti);w.registerModule(oi);si(_,Q,F,w,ai);function Ai(s,e,t){let r;"document"in $?r=$.document.body:r=new ne(t&&t.module),e=Object.assign(_.makeContext(r,null,r,null),e||{});let i=w.parse(Q,s);if(i&&i.errors&&i.errors.length>0)throw new Error(i.errors[0].message+`

`+F.formatErrors(i.errors));return i.execute?(i.execute(e),e.meta.returnValue!==void 0?e.meta.returnValue:e.result):i.apply?(i.apply(r,r,t,_),_.getHyperscriptFeatures(r)):i.evaluate(e)}var j=Object.assign(Ai,{config:A,use(s){s(j)},internals:{tokenizer:Q,runtime:_,reactivity:ai,createParser:s=>new F(w,s)},addFeature:w.addFeature.bind(w),addCommand:w.addCommand.bind(w),addLeafExpression:w.addLeafExpression.bind(w),addBeforeProcessHook:s=>_.addBeforeProcessHook(s),addAfterProcessHook:s=>_.addAfterProcessHook(s),evaluate:Ai,parse:s=>w.parse(Q,s),process:s=>_.processNode(s),processNode:s=>_.processNode(s),cleanup:s=>_.cleanup(s),version:"0.9.91"});function sn(s){document.readyState!=="loading"?setTimeout(s):document.addEventListener("DOMContentLoaded",s)}function on(){let s=document.querySelector('meta[name="htmx-config"]');if(s){let e=JSON.parse(s.content);Object.assign(A,e)}}typeof document<"u"&&(async function(){on();let s=$.document.querySelectorAll("script[type='text/hyperscript'][src]"),e=Array.from(s);(await Promise.all(e.map(async r=>(await fetch(r.src)).text()))).forEach(r=>j(r)),sn(()=>{j.process(document.documentElement),document.dispatchEvent(new Event("hyperscript:ready")),new ue($,j).init()})})();typeof self<"u"&&(self._hyperscript=j);var As=j;})();
