23 lines
168 KiB
JavaScript
23 lines
168 KiB
JavaScript
|
|
"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
|
||
|
|
`),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("
|
||
|
|
|
||
|
|
`+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"
|
||
|
|
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.startsWit
|
||
|
|
|
||
|
|
`+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;})();
|