hyperscript.org
Version:
a small scripting language for the web
19 lines (17 loc) • 199 kB
JavaScript
(()=>{var Ji=Object.defineProperty;var q=(s,e)=>{for(var t in e)Ji(s,t,{get:e[t],enumerable:!0})};var xe=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}},be={"+":"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"},M=class s{#t="";#i=0;#s=0;#o=1;#a="<START>";#c=0;#n=[];#d=!1;#h;#l(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}#u(e){return e>="0"&&e<="9"}#p(e){return e===" "||e===" "||e==="\r"||e===`
`}#v(e){return e==="\r"||e===`
`}#g(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.#c=0,this.#n=[],this.#d=t||!1,this.#h="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.#d&&this.#c===0}#k(){return!this.#T()||this.#h==="command"}#E(){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}#L(){for(;this.#e()&&!this.#v(this.#e());)this.#r();this.#r()}#O(){for(var e=this.#m("WHITESPACE"),t="";this.#e()&&this.#p(this.#e());)this.#v(this.#e())&&(this.#h="indeterminant"),t+=this.#r();return e.value=t,e.end=this.#i,e}#I(){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.#g(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.#g(this.#e());)t+=this.#r();return e.value=t,e.end=this.#i,e}#C(){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}#F(){for(var e=this.#m("ATTRIBUTE_REF"),t=this.#r();this.#g(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.#N().value)),e.value=t,e.end=this.#i,e}#R(){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.#v(this.#e());)t+=this.#r();return this.#e()&&this.#v(this.#e())&&(this.#r(),t+=`
`,this.#h="indeterminant"),e.content=t,e.end=this.#i,e}#H(){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}#N(){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}#D(){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}#q(){for(var e=this.#A(),t=this.#r();this.#e()&&be[t+this.#e()];)t+=this.#r();return e.type=be[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.#j();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}#j(){if(!this.#e())return NaN;let e=16*Number.parseInt(this.#r(),16);return this.#e()?(e+=Number.parseInt(this.#r(),16),e):NaN}#W(){var e=this.#e(),t=this.#f(),r=this.#x(2);return e==="-"&&t==="-"&&(this.#p(r)||r===""||r==="-")||e==="/"&&t==="/"&&(this.#p(r)||r===""||r==="/")}#U(){for(;this.#i<this.#t.length;)if(this.#W())this.#L();else if(this.#p(this.#e()))this.#n.push(this.#O());else if(!this.#E()&&this.#e()==="."&&(this.#l(this.#f())||this.#f()==="{"||this.#f()==="-"))this.#n.push(this.#I());else if(!this.#E()&&this.#e()==="#"&&(this.#l(this.#f())||this.#f()==="{"))this.#d==="lines"&&this.#h==="indeterminant"?(this.#h="command",this.#n.push(this.#_())):this.#n.push(this.#M());else if(this.#d==="lines"&&this.#h==="indeterminant"&&this.#c===0)this.#h="template",this.#n.push(this.#P());else if(this.#e()==="["&&this.#f()==="@")this.#n.push(this.#C());else if(this.#e()==="@")this.#n.push(this.#F());else if(this.#e()==="*"&&this.#l(this.#f()))this.#n.push(this.#R());else if(this.#T()&&(this.#l(this.#e())||this.#e()==="\\")&&this.#h!=="command")this.#n.push(this.#H());else if(this.#k()&&(this.#l(this.#e())||this.#y(this.#e())))this.#n.push(this.#N());else if(this.#u(this.#e()))this.#n.push(this.#D());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.#q());else if(be[this.#e()])this.#a==="$"&&this.#e()==="{"&&this.#c++,this.#e()==="}"&&this.#c--,this.#n.push(this.#q());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 xe(this.#n,this.#t)}};var C=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}},E=class extends C{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)}},T=class extends C{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)}},N=class extends C{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 se=class extends T{constructor(){super(),this.type="emptyCommandListCommand"}resolve(e){return this.findNext(e)}},oe=class extends T{constructor(e,t){super(),this.type="unlessStatementModifier",this.root=e,this.args={conditional:t}}resolve(e,{conditional:t}){return t?this.next:this.root}},$=class extends C{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)}},Y=class extends N{constructor(e,t){super(),this.type="failedFeature",this.keyword=t,this.errors.push(e)}install(){}},ae=class extends T{constructor(e,t){super(),this.type="failedCommand",this.keyword=t,this.errors.push(e)}resolve(){}},le=class extends T{constructor(){super(),this.type="implicitReturn"}resolve(e){return e.meta.returned=!0,e.meta.resolve&&e.meta.resolve(),e.meta.runtime.HALT}};var Fe={};q(Fe,{ArrayLiteral:()=>Le,BooleanLiteral:()=>Se,NakedNamedArgumentList:()=>Me,NakedString:()=>B,NamedArgumentList:()=>ue,NullLiteral:()=>Ne,NumberLiteral:()=>qe,ObjectKey:()=>Oe,ObjectLiteral:()=>Ie,StringLike:()=>Ce,StringLiteral:()=>Ae});var B=class s extends E{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("")}},Se=class s extends E{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}},Ne=class s extends E{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}},qe=class s extends E{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}},Ae=class s extends E{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=M.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}},Le=class s extends E{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}},Oe=class s extends E{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}},Ie=class s extends E{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}},ue=class s extends E{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}},Me=class extends E{static grammarName="nakedNamedArgumentList";static parse=ue.parseNaked},Ce=class extends E{static grammarName="stringLike";static parse(e){return e.parseAnyOf(["string","nakedString"])}};var Re=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),c=[...i.entries()].sort((x,w)=>x[0]-w[0]),h=-1,d="";for(var[o,f]of c){(h!==-1&&o>h+1||h===-1&&o>0)&&(d+=" ".repeat(l+1)+`...
`),h=o;var p=String(o+1).padStart(l),m=r[o]||"";d+=" "+p+" | "+m+`
`,f.sort((w,b)=>(w.column||0)-(b.column||0));var v=Array(m.length+10).fill(" ");for(var n of f)for(var y=n.token?.line?n.token.column:Math.max(0,m.length-1),g=Math.max(1,n.token?.value?.length||1),k=0;k<g;k++)v[y+k]="^";d+=u+v.join("").trimEnd()+`
`;for(var n of f){var y=n.token?.line?n.token.column:0;d+=u+" ".repeat(y)+n.message+`
`}}return d}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 Re(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 B(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 B(t)}return this.requireElement("expression")}ensureTerminated(e){for(var t=new le,r=e;r.next;)r=r.next;r.next=t}};var ce=class{#t={};#i={};#s={};#o=[];#a=[];#c=[];#n=[];#d=[];#h=[];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 ae(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 se}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.#c.length;r++){var i=this.#c[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.#d)}parseAssignableExpression(e){e.matchToken("the");for(var t=e.parseElement("primaryExpression"),r=t;r&&r.type==="parenthesized";)r=r.expr;if(r&&this.#h.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 oe(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 Y(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 Y(n.parseError,r)),this.#l(e);else throw n}}}return new $(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 T){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 N){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.#h.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.#c.push(e),this.addGrammarElement(e,t)}addUnaryExpression(e,t){this.#n.push(e),this.addGrammarElement(e,t)}addTopExpression(e,t){this.#d.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 $([])),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 O={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 _e=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 ki(s){if(s instanceof Array)return s.map(r=>ki(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 Q={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 _e;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:ki,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 he=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 He=Symbol(),R=class{constructor(e,t,r,i){this._css=e,this.relativeToElement=t,this.escape=r,this._runtime=i,this[He]=!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)}},fe=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}},Pe=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})}},me=class{constructor(e,t,r){this.re=e,this.flags=t,this.str=r}[Symbol.iterator](){return new Pe(new RegExp(this.re,this.flags),this.str)}},de=class extends EventTarget{constructor(e){super(),this.module=e}toString(){return this.module.id}};var Zi=new he().proxy(),pe=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:Zi},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)}},ve=class s{static HALT={};HALT=s.HALT;#t;#i;#s;#o;#a;#c=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 c=u.evaluate(t);c&&c.then&&(r=!0),a.push(c)}else a.push(u)}i[n]=a}else if(o.evaluate){var c=o.evaluate(t);c&&c.then&&(r=!0),i[n]=c}else i[n]=o;return r?new Promise((h,d)=>{var f=Object.keys(i),p=Object.values(i).map(m=>Array.isArray(m)?Promise.all(m):m);Promise.all(p).then(function(m){try{var v={};f.forEach((y,g)=>v[y]=m[g]),h(e.resolve(t,v))}catch(y){d(y)}}).catch(function(m){d(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 pe(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)}#d(e){return e instanceof pe}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 c=this.#s[e];return this.#p(c),c}if(r==="element"){this.reactivity.isTracking&&this.reactivity.trackElementSymbol(e,t.meta.owner);var c=this.#l(t)[e];return this.#p(c),c}if(r==="inherited"){var n=this.#h(e,t,i);if(this.reactivity.isTracking){var o=n.element||i||t.meta?.owner;o&&this.reactivity.trackElementSymbol(e,o)}return this.#p(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.#d(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.#p(l),l;this.reactivity.isTracking&&this.reactivity.trackGlobalSymbol(e);var c=this.#s[e];return this.#p(c),c}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.#h(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.#d(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.#d(t)&&!this.#n(e)?t.locals[e]=i:t[e]=i}getInternalData(e){return e._hyperscript||(e._hyperscript={}),e._hyperscript}#h(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&&O.mutatingMethods[r];i&&i.includes(t)&&this.notifyMutation(e)}}#p(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}#v(e){return Array.isArray(e)||typeof NodeList<"u"&&(e instanceof NodeList||e instanceof HTMLCollection||e instanceof FileList)}#g(e){return typeof e=="object"&&Symbol.iterator in e&&typeof e[Symbol.iterator]=="function"}shouldAutoIterate(e){return e!=null&&e[He]||this.#v(e)}forEach(e,t){if(e!=null)if(this.#g(e))for(let i of e)t(i);else if(this.#v(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=Q.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=Q[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);O.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.#c==null&&(this.#c=O.attributes.replaceAll(" ","").split(",")),this.#c}#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(O.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(":"),c=u[1],h=parseInt(u[2]),d=t.__hs_scopes[c];d&&(a.elementScope[d.identifier]=d.source[h],d.indexIdentifier&&(a.elementScope[d.indexIdentifier]=h))}}}}#E=[];#b=[];addBeforeProcessHook(e){this.#E.push(e)}addAfterProcessHook(e){this.#b.push(e)}processNode(e){for(var t of this.#E)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 Vi(s,e){return s===e?s!==0||1/s===1/e:s!==s&&e!==e}var De=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),!Vi(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))}},ye=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