text: !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self)._hyperscript=t()}(this,function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function t(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}function n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,o(e,t)}function r(e){return r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},r(e)}function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function i(e,t,n){return i=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(e,r));return n&&o(a,n.prototype),a},i.apply(null,arguments)}function u(e){var t="function"==typeof Map?new Map:void 0;return u=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return i(e,arguments,r(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),o(n,e)},u(e)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function l(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}function f(e,t){var n=e[t];if(n)return n;var r={};return e[t]=r,r}function m(e,t){return new(e.bind.apply(e,[e].concat(t)))}var p,v=globalThis,d=function(e){function n(e,t){this._css=e,this.relativeToElement=t}var r=n.prototype;return r.contains=function(e){for(var t,n=l(this);!(t=n()).done;)if(t.value.contains(e))return!0;return!1},r[e]=function(){return y.getRootNode(this.relativeToElement).querySelectorAll(this.css)[Symbol.iterator]()},t(n,[{key:"css",get:function(){return y.escapeSelector(this._css)}},{key:"className",get:function(){return this._css.substr(1)}},{key:"id",get:function(){return this.className()}}]),n}(Symbol.iterator),h=function(){var e={"+":"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"};function t(e){return i(e)||a(e)||"-"===e||"_"===e||":"===e}function n(e){return i(e)||a(e)||"-"===e||"_"===e||":"===e}function r(e){return" "===e||"\t"===e||o(e)}function o(e){return"\r"===e||"\n"===e}function a(e){return e>="0"&&e<="9"}function i(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}function u(e,t){return"_"===e||"$"===e}function s(e,t,n){o();var r=null;function o(){for(;"WHITESPACE"===f(0,!0).type;)t.push(e.shift())}function a(e,t){E.raiseParseError(e,t)}function i(e){if(m()&&m().op&&m().value===e)return l()}function u(e,t,n,r){if(m()&&m().type&&[e,t,n,r].indexOf(m().type)>=0)return l()}function s(e,t){if(-1===p.indexOf(e))return t=t||"IDENTIFIER",m()&&m().value===e&&m().type===t?l():void 0}function l(){var n=e.shift();return t.push(n),r=n,o(),n}function c(n,r){for(var a=[],i=f(0,!0);!(null!=r&&i.type===r||null!=n&&i.value===n||"EOF"===i.type);){var u=e.shift();t.push(u),a.push(i),i=f(0,!0)}return o(),a}function f(t,n){var r,o=0;do{if(!n)for(;e[o]&&"WHITESPACE"===e[o].type;)o++;r=e[o],t--,o++}while(t>-1);return r||{type:"EOF",value:"<<<EOF>>>"}}function m(){return f(0)}var p=[];return{pushFollow:function(e){p.push(e)},popFollow:function(){p.pop()},clearFollow:function(){var e=p;return p=[],e},restoreFollow:function(e){p=e},matchAnyToken:function(e,t,n){for(var r=0;r<arguments.length;r++){var o=arguments[r],a=s(o);if(a)return a}},matchAnyOpToken:function(e,t,n){for(var r=0;r<arguments.length;r++){var o=arguments[r],a=i(o);if(a)return a}},matchOpToken:i,requireOpToken:function(e){var t=i(e);if(t)return t;a(this,"Expected '"+e+"' but found '"+m().value+"'")},matchTokenType:u,requireTokenType:function(e,t,n,r){var o=u(e,t,n,r);if(o)return o;a(this,"Expected one of "+JSON.stringify([e,t,n]))},consumeToken:l,matchToken:s,requireToken:function(e,t){var n=s(e,t);if(n)return n;a(this,"Expected '"+e+"' but found '"+m().value+"'")},list:e,consumed:t,source:n,hasMore:function(){return e.length>0},currentToken:m,lastMatch:function(){return r},token:f,consumeUntil:c,consumeUntilWhitespace:function(){return c(null,"WHITESPACE")},lastWhitespace:function(){return t[t.length-1]&&"WHITESPACE"===t[t.length-1].type?t[t.length-1].value:""},sourceFor:function(){return n.substring(this.startToken.start,this.endToken.end)},lineFor:function(){return n.split("\n")[this.startToken.line-1]}}}function l(e){if(e.length>0){var t=e[e.length-1];if("IDENTIFIER"===t.type||"CLASS_REF"===t.type||"ID_REF"===t.type)return!1;if(t.op&&(">"===t.value||")"===t.value))return!1}return!0}return{tokenize:function(c,f){var m,p=[],v=c,d=0,h=0,E=1,T="<START>",y=0;function k(){return f&&0===y}for(;d<v.length;)if("-"!==L()||"-"!==A()||!r(C())&&""!==C())if(r(L()))p.push(M());else if(P()||"."!==L()||!i(A())&&"{"!==A())if(P()||"#"!==L()||!i(A())&&"{"!==A())if("["===L()&&"@"===A())p.push(q());else if("@"===L())p.push(w());else if(i(L())||!k()&&u(L()))p.push(I());else if(a(L()))p.push(O());else if(k()||'"'!==L()&&"`"!==L())if(k()||"'"!==L()){if(e[L()])"$"===T&&"{"===L()&&y++,"}"===L()&&y--,p.push(S());else if(k()||"`"===(m=L())||"^"===m)p.push(g("RESERVED",F()));else if(d<v.length)throw Error("Unknown token: "+L()+" ")}else l(p)?p.push(R()):p.push(S());else p.push(R());else p.push(N());else p.push(b());else x();return s(p,[],v);function g(e,t){return{type:e,value:t,start:d,end:d+1,column:h,line:E}}function x(){for(;L()&&!o(L());)F();F()}function b(){var e=g("CLASS_REF"),n=F();if("{"===L()){for(e.template=!0,n+=F();L()&&"}"!==L();)n+=F();if("}"!==L())throw Error("Unterminated class reference");n+=F()}else for(;t(L());)n+=F();return e.value=n,e.end=d,e}function q(){for(var e=g("ATTRIBUTE_REF"),t=F();d<v.length&&"]"!==L();)t+=F();return"]"===L()&&(t+=F()),e.value=t,e.end=d,e}function w(){for(var e=g("ATTRIBUTE_REF"),t=F();n(L());)t+=F();return e.value=t,e.end=d,e}function N(){var e=g("ID_REF"),t=F();if("{"===L()){for(e.template=!0,t+=F();L()&&"}"!==L();)t+=F();if("}"!==L())throw Error("Unterminated id reference");F()}else for(;n(L());)t+=F();return e.value=t,e.end=d,e}function I(){for(var e=g("IDENTIFIER"),t=F();i(L())||u(L());)t+=F();return e.value=t,e.end=d,e}function O(){for(var e=g("NUMBER"),t=F();a(L());)t+=F();for("."===L()&&a(A())&&(t+=F());a(L());)t+=F();return e.value=t,e.end=d,e}function S(){for(var t=(r=void 0,(r=g(void 0,void 0)).op=!0,r),n=F();L()&&e[n+L()];)n+=F();var r;return t.type=e[n],t.value=n,t.end=d,t}function R(){for(var e,t=g("STRING"),n=F(),r="";L()&&L()!==n;)"\\"===L()&&F(),r+=F();if(L()!==n)throw Error("Unterminated string at [Line: "+(e=t).line+", Column: "+e.column+"]");return F(),t.value=r,t.end=d,t.template="`"===n,t}function L(){return v.charAt(d)}function A(){return v.charAt(d+1)}function C(){return v.charAt(d+2)}function F(){return T=L(),d++,h++,T}function P(){return i(T)||a(T)||")"===T||"}"===T||"]"===T}function M(){for(var e=g("WHITESPACE"),t="";L()&&r(L());)o(L())&&(h=0,E++),t+=F();return e.value=t,e.end=d,e}},makeTokensObject:s}}(),E=function(){var e={},t={},n={},r=[],o=[];function a(e,t,n){e.startToken=t,e.sourceFor=n.sourceFor,e.lineFor=n.lineFor,e.programSource=n.source}function i(t,n,r){return void 0===r&&(r=void 0),function(r){var o=e[t];if(o){var i=n.currentToken(),u=o(E,y,n,r);if(u)for(a(u,i,n),u.endToken=u.endToken||n.lastMatch(),r=u.root;null!=r;)a(r,i,n),r=r.root;return u}}(r)}function u(e,t,n,r){var o=i(e,t,r);return o||c(t,n||"Expected "+e),o}function s(e,t){for(var n=0;n<e.length;n++){var r=i(e[n],t);if(r)return r}}function l(t,n){e[t]=n}function c(e,t){t=(t||"Unexpected Token : "+e.currentToken().value)+"\n\n"+function(e){var t=e.currentToken(),n=e.source.split("\n"),r=n[t&&t.line?t.line-1:n.length-1];return r+"\n"+" ".repeat(t&&t.line?t.column:r.length-1)+"^^\n\n"}(e);var n=new Error(t);throw n.tokens=e,n}function f(e){return t[e.value]}function m(e){return n[e.value]}return l("feature",function(e,t,r){if(r.matchOpToken("(")){var o=e.requireElement("feature",r);return r.requireOpToken(")"),o}var a=n[r.currentToken().value];if(a)return a(e,t,r)}),l("command",function(e,n,r){if(r.matchOpToken("(")){var o=e.requireElement("command",r);return r.requireOpToken(")"),o}var a,i=t[r.currentToken().value];return i?a=i(e,n,r):"IDENTIFIER"===r.currentToken().type&&"("===r.token(1).value&&(a=e.requireElement("pseudoCommand",r)),a?e.parseElement("indirectStatement",r,a):a}),l("commandList",function(e,t,n){var r=e.parseElement("command",n);if(r){n.matchToken("then");var o=e.parseElement("commandList",n);return o&&(r.next=o),r}}),l("leaf",function(e,t,n){var o=s(r,n);return null==o?i("symbol",n):o}),l("indirectExpression",function(e,t,n,r){for(var a=0;a<o.length;a++){var i=o[a];r.endToken=n.lastMatch();var u=e.parseElement(i,n,r);if(u)return u}return r}),l("indirectStatement",function(e,t,n,r){if(n.matchToken("unless")){r.endToken=n.lastMatch();var o={type:"unlessStatementModifier",args:[e.requireElement("expression",n)],op:function(e,t){return t?this.next:r},execute:function(e){return t.unifiedExec(this,e)}};return r.parent=o,o}return r}),l("primaryExpression",function(e,t,n){var r=e.parseElement("leaf",n);if(r)return e.parseElement("indirectExpression",n,r);e.raiseParseError(n,"Unexpected value: "+n.currentToken().value)}),{setParent:function e(t,n){t&&(t.parent=n,e(t.next,n))},requireElement:u,parseElement:i,featureStart:m,commandStart:f,commandBoundary:function(e){return!("end"!=e.value&&"then"!=e.value&&"else"!=e.value&&")"!=e.value&&!f(e)&&!m(e)&&"EOF"!=e.type)},parseAnyOf:s,parseHyperScript:function(e){var t=i("hyperscript",e);if(e.hasMore()&&c(e),t)return t},raiseParseError:c,addGrammarElement:l,addCommand:function(n,r){var o=n+"Command",a=function(e,t,n){var a=r(e,t,n);if(a)return a.type=o,a.execute=function(e){return e.meta.command=a,t.unifiedExec(this,e)},a};e[o]=a,t[n]=a},addFeature:function(t,r){var o=t+"Feature",a=function(e,n,a){var i=r(e,n,a);if(i)return i.keyword=t,i.type=o,i};e[o]=a,n[t]=a},addLeafExpression:function(e,t){r.push(e),l(e,t)},addIndirectExpression:function(e,t){o.push(e),l(e,t)},parseStringTemplate:function(e){var t=[""];do{if(t.push(e.lastWhitespace()),"$"===e.currentToken().value){e.consumeToken();var n=e.matchOpToken("{");t.push(u("expression",e)),n&&e.requireOpToken("}"),t.push("")}else if("\\"===e.currentToken().value)e.consumeToken(),e.consumeToken();else{var r=e.consumeToken();t[t.length-1]+=r?r.value:""}}while(e.hasMore());return t.push(e.lastWhitespace()),t}}}(),T={dynamicResolvers:[],String:function(e){return e.toString?e.toString():""+e},Int:function(e){return parseInt(e)},Float:function(e){return parseFloat(e)},Number:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){return console.log(e),Number(e)}),Date:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){return new Date(e)}),Array:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){return Array.from(e)}),JSON:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){return JSON.stringify(e)}),Object:function(e){return e instanceof String&&(e=e.toString()),"string"==typeof e?JSON.parse(e):c({},e)}},y=function(){function e(e,t){var n=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;return n&&n.call(e,t)}function t(e,t,n){(n=n||{}).sentBy=e;var r=function(e,t){var n;return v.Event&&"function"==typeof v.Event?(n=new Event(e,{bubbles:!0,cancelable:!0})).detail=t:(n=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,t),n}(t,n);return e.dispatchEvent(r)}function r(e){return Array.isArray(e)||"undefined"!=typeof NodeList&&e instanceof NodeList}function o(e){return e instanceof d||r(e)}function a(e,t){if(null==e);else if(function(e){return"object"==typeof e&&Symbol.iterator in e&&"function"==typeof e[Symbol.iterator]}(e))for(var n,o=l(e);!(n=o()).done;)t(n.value);else if(r(e))for(var a=0;a<e.length;a++)t(e[a]);else t(e)}var i={array_sentinel:!0};function s(e){for(var t=0;t<e.length;t++){var n=e[t];if(n.asyncWrapper&&(e[t]=n.value),Array.isArray(n))for(var r=0;r<n.length;r++){var o=n[r];o.asyncWrapper&&(n[r]=o.value)}}}var m={};function k(e,t){for(;;){try{var n=g(e,t)}catch(r){if(y.registerHyperTrace(t,r),t.meta.errorHandler&&!t.meta.handlingError){t.meta.handlingError=!0,t[t.meta.errorSymmbol]=r,e=t.meta.errorHandler;continue}if(!t.meta.reject)throw r;t.meta.reject(r),n=m}if(null==n)return void console.error(e," did not return a next element to execute! context: ",t);if(n.then)return void n.then(function(e){k(e,t)}).catch(function(e){if(y.registerHyperTrace(t,e),t.meta.errorHandler&&!t.meta.handlingError)t.meta.handlingError=!0,t[t.meta.errorSymmbol]=e,k(t.meta.errorHandler,t);else{if(!t.meta.reject)throw e;t.meta.reject(e)}});if(n===m)return;e=n}}function g(e,t){var n=[t],r=!1,o=!1;if(e.args)for(var a=0;a<e.args.length;a++){var u=e.args[a];if(null==u)n.push(null);else if(Array.isArray(u)){for(var l=[],c=0;c<u.length;c++){var f=u[c];(m=f?f.evaluate(t):null)&&(m.then?r=!0:m.asyncWrapper&&(o=!0)),l.push(m)}n.push(l)}else if(u.evaluate){var m;(m=u.evaluate(t))&&(m.then?r=!0:m.asyncWrapper&&(o=!0)),n.push(m)}else n.push(u)}return r?new Promise(function(r,a){var u=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];if(Array.isArray(r)){t.push(i);for(var o=0;o<r.length;o++)t.push(r[o]);t.push(i)}else t.push(r)}return t}(n);Promise.all(u).then(function(t){t=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];if(r===i){r=e[++n];var o=[];for(t.push(o);r!==i;)o.push(r),r=e[++n]}else t.push(r)}return t}(t),o&&s(t);try{var n=e.op.apply(e,t);r(n)}catch(e){a(e)}}).catch(function(e){t.meta.errorHandler&&!t.meta.handlingError?(t.meta.handlingError=!0,t[t.meta.errorSymmbol]=e,k(t.meta.errorHandler,t)):t.meta.reject&&t.meta.reject(e)})}):(o&&s(n),e.op.apply(e,n))}var x=null;function b(){return null==x&&(x=p.config.attributes.replace(/ /g,"").split(",")),x}function q(e){for(var t=0;t<b().length;t++){var n=b()[t];if(e.hasAttribute&&e.hasAttribute(n))return e.getAttribute(n)}return e instanceof HTMLScriptElement&&"text/hyperscript"===e.type?e.innerText:null}var w=new WeakMap;function N(e){var t=w.get(e);return void 0===t&&w.set(e,t={}),t}function I(e,t){e&&(c(t,N(e)),I(e.parentElement,t))}function O(e,t,n,r){var o={meta:{parser:E,lexer:h,runtime:y,owner:e,feature:t,iterators:{}},me:n,event:r,target:r?r.target:null,detail:r?r.detail:null,body:"document"in v?document.body:null};return o.meta.ctx=o,I(e,o),o}function S(e){var t=h.tokenize(e);if(E.commandStart(t.currentToken())){for(var n=E.requireElement("commandList",t),r=n;r.next;)r=r.next;return r.next={op:function(){return m}},n}return E.featureStart(t.currentToken())?E.requireElement("hyperscript",t):E.requireElement("expression",t)}function R(e,n){if(!e.closest||!e.closest(p.config.disableSelector)){var r=A(e);if(!r.initialized){var o=q(e);if(o)try{r.initialized=!0,r.script=o;var a=h.tokenize(o),i=E.parseHyperScript(a);if(!i)return;i.apply(n||e,e),setTimeout(function(){t(n||e,"load",{hyperscript:!0})},1)}catch(t){y.triggerEvent(e,"exception",{error:t}),console.error("hyperscript errors were found on the following element:",e,"\n\n",t.message,t.stack)}}}}var L=new WeakMap;function A(e){var t=L.get(e);return void 0===t&&L.set(e,t={}),t}function C(e){var t=e.meta&&e.meta.owner;if(t){var n=A(t),r="elementScope";return e.meta.feature&&e.meta.feature.behavior&&(r=e.meta.feature.behavior+"Scope"),f(n,r)}return{}}return{typeCheck:function(e,t,n){return!(null!=e||!n)||Object.prototype.toString.call(e).slice(8,-1)===t},forEach:a,implicitLoop:function(e,t){if(o(e))for(var n,r=l(e);!(n=r()).done;)t(n.value);else t(e)},triggerEvent:t,matchesSelector:e,getScript:q,processNode:function(t){var n=y.getScriptSelector();e(t,n)&&R(t,t),t instanceof HTMLScriptElement&&"text/hyperscript"===t.type&&R(t,document.body),t.querySelectorAll&&a(t.querySelectorAll(n+", [type='text/hyperscript']"),function(e){R(e,e instanceof HTMLScriptElement&&"text/hyperscript"===e.type?document.body:e)})},evaluate:function(e,t,r){var o=function(e){function t(t){var n;return(n=e.call(this)||this).module=t,n}return n(t,e),t.prototype.toString=function(){return this.module.id},t}(u(EventTarget)),a="document"in v?v.document.body:new o(r&&r.module);t=c(O(a,null,a,null),t||{});var i=S(e);return i.execute?(i.execute(t),t.result):i.apply?(i.apply(a,a,r),N(a)):i.evaluate(t)},evaluateNoPromise:function(e,t){var n=e.evaluate(t);if(n.next)throw new Error(e.sourceFor()+" returned a Promise in a context that they are not allowed.");return n},parse:S,getScriptSelector:function(){return b().map(function(e){return"["+e+"]"}).join(", ")},resolveSymbol:function(e,t,n){if("me"===e||"my"===e||"I"===e)return t.me;if("it"===e||"its"===e)return t.result;if("you"===e||"your"===e||"yourself"===e)return t.beingTold;if("global"===n)return v[e];if("element"===n)return C(t)[e];if("local"===n)return t[e];if(t.meta&&t.meta.context){var r=t.meta.context[e];if(void 0!==r)return r}var o=t[e];return void 0!==o||void 0!==(o=C(t)[e])?o:v[e]},setSymbol:function(e,t,n,r){if("global"===n)v[e]=r;else if("element"===n)(o=C(t))[e]=r;else if("local"===n)t[e]=r;else{var o,a=t[e];void 0!==a?t[e]=r:void 0!==(a=(o=C(t))[e])?o[e]=r:void 0!==(a=v[e])?v[e]=r:t[e]=r}},makeContext:O,findNext:function e(t,n){if(t)return t.resolveNext?t.resolveNext(n):t.next?t.next:e(t.parent,n)},unifiedEval:g,convertValue:function(e,t){for(var n=T.dynamicResolvers,r=0;r<n.length;r++){var o=(0,n[r])(t,e);if(void 0!==o)return o}if(null==e)return null;var a=T[t];if(a)return a(e);throw"Unknown conversion : "+t},unifiedExec:k,resolveProperty:function(e,t,n){if(null!=e){var r=n&&e.getAttribute?e.getAttribute(t):e[t];if(void 0!==r)return r;if(o(e)){for(var a,i=[],u=l(e);!(a=u()).done;){var s=a.value,c=n?s.getAttribute(t):s[t];c&&i.push(c)}return i}}},assignToNamespace:function(e,t,n,r){var o;for(o="undefined"!=typeof document&&e===document.body?v:N(e);t.length>0;){var a=t.shift(),i=o[a];null==i&&(o[a]=i={}),o=i}o[n]=r},registerHyperTrace:function(e,t){for(var n=[],r=null;null!=e;)n.push(e),r=e,e=e.meta.caller;null==r.meta.traceMap&&(r.meta.traceMap=new Map),r.meta.traceMap.get(t)||r.meta.traceMap.set(t,{trace:n,print:function(e){(e=e||console.error)("hypertrace /// ");for(var t=0,r=0;r<n.length;r++)t=Math.max(t,n[r].meta.feature.displayName.length);for(r=0;r<n.length;r++){var o=n[r];e("  ->",o.meta.feature.displayName.padEnd(t+2),"-",o.meta.owner)}}})},getHyperTrace:function(e,t){for(var n=e;n.meta.caller;)n=n.meta.caller;if(n.meta.traceMap)return n.meta.traceMap.get(t,[])},getInternalData:A,getHyperscriptFeatures:N,escapeSelector:function(e){return e.replace(/:/g,function(e){return"\\"+e})},nullCheck:function(e,t){if(null==e)throw new Error(t.sourceFor()+" is null")},isEmpty:function(e){return null==e||0===e.length},getRootNode:function(e){var t=e.getRootNode();return t instanceof Document||t instanceof ShadowRoot?t:document},hyperscriptUrl:"document"in v?"undefined"==typeof document&&"undefined"==typeof location?new(require("url").URL)("file:"+__filename).href:"undefined"==typeof document?location.href:document.currentScript&&document.currentScript.src||new URL("_hyperscript_web.min.js",document.baseURI).href:null,HALT:m}}(),k=function(e,t,n){if(t.contains)return t.contains(n);if(t.includes)return t.includes(n);throw Error("The value of "+e.sourceFor()+" does not have a contains or includes method on it")},g=function(e,t,n){if(t.match)return!!t.match(n);if(t.matches)return t.matches(n);throw Error("The value of "+e.sourceFor()+" does not have a match or matches method on it")},x=function(e,t,n,r){var o=t.requireElement("eventName",r),a=t.parseElement("namedArgumentList",r);if("send"===e&&r.matchToken("to")||"trigger"===e&&r.matchToken("on"))var i=t.requireElement("expression",r);else i=t.requireElement("implicitMeTarget",r);var u={eventName:o,details:a,to:i,args:[i,o,a],op:function(e,t,r,o){return n.forEach(t,function(e){n.triggerEvent(e,r,o||{})}),n.findNext(u,e)}};return u};E.addLeafExpression("parenthesized",function(e,t,n){if(n.matchOpToken("(")){var r=n.clearFollow();try{var o=e.requireElement("expression",n)}finally{n.restoreFollow(r)}return n.requireOpToken(")"),o}}),E.addLeafExpression("string",function(e,t,n){var r=n.matchTokenType("STRING");if(r){var o,a=r.value;if(r.template){var i=h.tokenize(a,!0);o=e.parseStringTemplate(i)}else o=[];return{type:"string",token:r,args:o,op:function(e){for(var t="",n=1;n<arguments.length;n++){var r=arguments[n];void 0!==r&&(t+=r)}return t},evaluate:function(e){return 0===o.length?a:t.unifiedEval(this,e)}}}}),E.addGrammarElement("nakedString",function(e,t,n){if(n.hasMore()){var r=n.consumeUntilWhitespace();return n.matchTokenType("WHITESPACE"),{type:"nakedString",tokens:r,evaluate:function(e){return r.map(function(e){return e.value}).join("")}}}}),E.addLeafExpression("number",function(e,t,n){var r=n.matchTokenType("NUMBER");if(r){var o=r,a=parseFloat(r.value);return{type:"number",value:a,numberToken:o,evaluate:function(){return a}}}}),E.addLeafExpression("idRef",function(e,t,n){var r=n.matchTokenType("ID_REF");if(r){if(r.template){var o=r.value.substr(2,r.value.length-2),a=h.tokenize(o);return{type:"idRefTemplate",args:[e.requireElement("expression",a)],op:function(e,n){return t.getRootNode(e.me).getElementById(n)},evaluate:function(e){return t.unifiedEval(this,e)}}}var i=r.value.substr(1);return{type:"idRef",css:r.value,value:i,evaluate:function(e){return t.getRootNode(e.me).getElementById(i)}}}}),E.addLeafExpression("classRef",function(e,t,n){var r=n.matchTokenType("CLASS_REF");if(r){if(r.template){var o=r.value.substr(2,r.value.length-2),a=h.tokenize(o);return{type:"classRefTemplate",args:[e.requireElement("expression",a)],op:function(e,t){return new d("."+t,e.me)},evaluate:function(e){return t.unifiedEval(this,e)}}}var i=r.value;return{type:"classRef",css:i,evaluate:function(e){return new d(i,e.me)}}}});var b=function(e,r){function o(t,n,r){var o;return(o=e.call(this,t,n)||this).templateParts=r,o.elements=r.filter(function(e){return e instanceof Element}),o}return n(o,e),o.prototype[r]=function(){this.elements.forEach(function(e,t){return e.dataset.hsQueryId=t});var t=e.prototype[Symbol.iterator].call(this);return this.elements.forEach(function(e){return e.removeAttribute("data-hs-query-id")}),t},t(o,[{key:"css",get:function(){for(var e,t="",n=0,r=l(this.templateParts);!(e=r()).done;){var o=e.value;o instanceof Element?t+="[data-hs-query-id='"+n+++"']":t+=o}return t}}]),o}(d,Symbol.iterator);E.addLeafExpression("queryRef",function(e,t,n){if(n.matchOpToken("<")){var r=n.consumeUntil("/");n.requireOpToken("/"),n.requireOpToken(">");var o=r.map(function(e){return"STRING"===e.type?'"'+e.value+'"':e.value}).join("");if(o.indexOf("$")>=0)var a=!0,i=h.tokenize(o,!0),u=e.parseStringTemplate(i);return{type:"queryRef",css:o,args:u,op:function(e){return a?new b(o,e.me,[].slice.call(arguments,1)):new d(o,e.me)},evaluate:function(e){return t.unifiedEval(this,e)}}}}),E.addLeafExpression("attributeRef",function(e,t,n){var r=n.matchTokenType("ATTRIBUTE_REF");if(r){var o=r.value;if(0===o.indexOf("["))var a=o.substring(2,o.length-1);else a=o.substring(1);var i="["+a+"]",u=a.split("="),s=u[0],l=u[1];return l&&0===l.indexOf('"')&&(l=l.substring(1,l.length-1)),{type:"attributeRef",name:s,css:i,value:l,op:function(e){var t=e.beingTold||e.me;if(t)return t.getAttribute(s)},evaluate:function(e){return t.unifiedEval(this,e)}}}}),E.addGrammarElement("objectKey",function(e,t,n){var r;if(r=n.matchTokenType("STRING"))return{type:"objectKey",key:r.value,evaluate:function(){return r.value}};if(n.matchOpToken("[")){var o=e.parseElement("expression",n);return n.requireOpToken("]"),{type:"objectKey",expr:o,args:[o],op:function(e,t){return t},evaluate:function(e){return t.unifiedEval(this,e)}}}var a="";do{(r=n.matchTokenType("IDENTIFIER")||n.matchOpToken("-"))&&(a+=r.value)}while(r);return{type:"objectKey",key:a,evaluate:function(){return a}}}),E.addLeafExpression("objectLiteral",function(e,t,n){if(n.matchOpToken("{")){var r=[],o=[];if(!n.matchOpToken("}")){do{var a=e.requireElement("objectKey",n);n.requireOpToken(":");var i=e.requireElement("expression",n);o.push(i),r.push(a)}while(n.matchOpToken(","));n.requireOpToken("}")}return{type:"objectLiteral",args:[r,o],op:function(e,t,n){for(var r={},o=0;o<t.length;o++)r[t[o]]=n[o];return r},evaluate:function(e){return t.unifiedEval(this,e)}}}}),E.addGrammarElement("nakedNamedArgumentList",function(e,t,n){var r=[],o=[];if("IDENTIFIER"===n.currentToken().type)do{var a=n.requireTokenType("IDENTIFIER");n.requireOpToken(":");var i=e.requireElement("expression",n);o.push(i),r.push({name:a,value:i})}while(n.matchOpToken(","));return{type:"namedArgumentList",fields:r,args:[o],op:function(e,t){for(var n={_namedArgList_:!0},o=0;o<t.length;o++)n[r[o].name.value]=t[o];return n},evaluate:function(e){return t.unifiedEval(this,e)}}}),E.addGrammarElement("namedArgumentList",function(e,t,n){if(n.matchOpToken("(")){var r=e.requireElement("nakedNamedArgumentList",n);return n.requireOpToken(")"),r}}),E.addGrammarElement("symbol",function(e,t,n){var r="default";n.matchToken("global")?r="global":n.matchToken("element")||n.matchToken("module")?(r="element",n.matchOpToken("'")&&n.requireToken("s")):n.matchToken("local")&&(r="local");var o=n.matchTokenType("IDENTIFIER");if(o){var a=o.value;return{type:"symbol",symbolType:r,token:o,name:a,evaluate:function(e){return t.resolveSymbol(a,e,r)}}}}),E.addGrammarElement("implicitMeTarget",function(e,t,n){return{type:"implicitMeTarget",evaluate:function(e){return e.beingTold||e.me}}}),E.addLeafExpression("boolean",function(e,t,n){var r=n.matchToken("true")||n.matchToken("false");if(r){var o="true"===r.value;return{type:"boolean",evaluate:function(e){return o}}}}),E.addLeafExpression("null",function(e,t,n){if(n.matchToken("null"))return{type:"null",evaluate:function(e){return null}}}),E.addLeafExpression("arrayLiteral",function(e,t,n){if(n.matchOpToken("[")){var r=[];if(!n.matchOpToken("]")){do{var o=e.requireElement("expression",n);r.push(o)}while(n.matchOpToken(","));n.requireOpToken("]")}return{type:"arrayLiteral",values:r,args:[r],op:function(e,t){return t},evaluate:function(e){return t.unifiedEval(this,e)}}}}),E.addLeafExpression("blockLiteral",function(e,t,n){if(n.matchOpToken("\\")){var r=[],o=n.matchTokenType("IDENTIFIER");if(o)for(r.push(o);n.matchOpToken(",");)r.push(n.requireTokenType("IDENTIFIER"));n.requireOpToken("-"),n.requireOpToken(">");var a=e.requireElement("expression",n);return{type:"blockLiteral",args:r,expr:a,evaluate:function(e){return function(){for(var t=0;t<r.length;t++)e[r[t].value]=arguments[t];return a.evaluate(e)}}}}}),E.addGrammarElement("timeExpression",function(e,t,n){var r=e.requireElement("expression",n),o=1;return n.matchToken("s")||n.matchToken("seconds")?o=1e3:n.matchToken("ms")||n.matchToken("milliseconds"),{type:"timeExpression",time:r,factor:o,args:[r],op:function(e,t){return t*o},evaluate:function(e){return t.unifiedEval(this,e)}}}),E.addIndirectExpression("propertyAccess",function(e,t,n,r){if(n.matchOpToken(".")){var o=n.requireTokenType("IDENTIFIER");return e.parseElement("indirectExpression",n,{type:"propertyAccess",root:r,prop:o,args:[r],op:function(e,n){return t.resolveProperty(n,o.value,!1)},evaluate:function(e){return t.unifiedEval(this,e)}})}}),E.addIndirectExpression("of",function(e,t,n,r){if(n.matchToken("of")){for(var o=e.requireElement("expression",n),a=null,i=r;i.root;)a=i,i=i.root;"symbol"!==i.type&&"attributeRef"!==i.type&&e.raiseParseError(n,"Cannot take a property of a non-symbol: "+i.type);var u="attributeRef"===i.type,s=i.name,l={type:"ofExpression",prop:i.token,root:o,attribute:u,expression:r,args:[o],op:function(e,n){return t.resolveProperty(n,s,u)},evaluate:function(e){return t.unifiedEval(this,e)}};return"attributeRef"===i.type&&(l.attribute=i),a?(a.root=l,a.args=[l]):r=l,e.parseElement("indirectExpression",n,r)}}),E.addIndirectExpression("possessive",function(e,t,n,r){if(!e.possessivesDisabled){var o=n.matchOpToken("'");if(o||"symbol"===r.type&&("my"===r.name||"its"===r.name||"your"===r.name)&&"IDENTIFIER"===n.currentToken().type){o&&n.requireToken("s");var a=e.parseElement("attributeRef",n);if(null==a)var i=n.requireTokenType("IDENTIFIER");return e.parseElement("indirectExpression",n,{type:"possessive",root:r,attribute:a,prop:i,args:[r],op:function(e,n){if(a)var r=t.resolveProperty(n,a.name,!0);else r=t.resolveProperty(n,i.value,!1);return r},evaluate:function(e){return t.unifiedEval(this,e)}})}}}),E.addIndirectExpression("inExpression",function(e,t,n,r){if(n.matchToken("in")){if("idRef"!==r.type&&"queryRef"===r.type||"classRef"===r.type)var o=!0;var a=e.requireElement("expression",n),i={type:"inExpression",root:r,args:[o?null:r,a],op:function(e,n,a){var i=[];return o?t.forEach(a,function(e){for(var t=e.querySelectorAll(r.css),n=0;n<t.length;n++)i.push(t[n])}):t.forEach(n,function(e){t.forEach(a,function(t){e===t&&i.push(e)})}),i.length>0?i:null},evaluate:function(e){return t.unifiedEval(this,e)}};return e.parseElement("indirectExpression",n,i)}}),E.addIndirectExpression("asExpression",function(e,t,n,r){if(n.matchToken("as")){n.matchToken("a")||n.matchToken("an");var o=e.requireElement("dotOrColonPath",n).evaluate();return e.parseElement("indirectExpression",n,{type:"asExpression",root:r,args:[r],op:function(e,n){return t.convertValue(n,o)},evaluate:function(e){return t.unifiedEval(this,e)}})}}),E.addIndirectExpression("functionCall",function(e,t,n,r){if(n.matchOpToken("(")){var o=[];if(!n.matchOpToken(")")){do{o.push(e.requireElement("expression",n))}while(n.matchOpToken(","));n.requireOpToken(")")}if(r.root)var a={type:"functionCall",root:r,argExressions:o,args:[r.root,o],op:function(e,n,o){t.nullCheck(n,r.root);var a=n[r.prop.value];return t.nullCheck(a,r),a.hyperfunc&&o.push(e),a.apply(n,o)},evaluate:function(e){return t.unifiedEval(this,e)}};else a={type:"functionCall",root:r,argExressions:o,args:[r,o],op:function(e,n,o){return t.nullCheck(n,r),n.hyperfunc&&o.push(e),n.apply(null,o)},evaluate:function(e){return t.unifiedEval(this,e)}};return e.parseElement("indirectExpression",n,a)}}),E.addIndirectExpression("attributeRefAccess",function(e,t,n,r){var o=e.parseElement("attributeRef",n);if(o)return{type:"attributeRefAccess",root:r,attribute:o,args:[r],op:function(e,n){return t.resolveProperty(n,o.name,!0)},evaluate:function(e){return y.unifiedEval(this,e)}}}),E.addIndirectExpression("arrayIndex",function(e,t,n,r){if(n.matchOpToken("[")){var o=!1,a=!1,i=null,u=null;n.matchOpToken("..")?(o=!0,i=e.requireElement("expression",n)):(i=e.requireElement("expression",n),n.matchOpToken("..")&&(a=!0,"R_BRACKET"!==n.currentToken().type&&(u=e.parseElement("expression",n)))),n.requireOpToken("]");var s={type:"arrayIndex",root:r,firstIndex:i,secondIndex:u,args:[r,i,u],op:function(e,t,n,r){return o?t.slice(0,n+1):a?null!=r?t.slice(n,r+1):t.slice(n):t[n]},evaluate:function(e){return y.unifiedEval(this,e)}};return E.parseElement("indirectExpression",n,s)}}),E.addGrammarElement("postfixExpression",function(e,t,n){var r=e.parseElement("primaryExpression",n);if(n.matchOpToken(":")){var o=n.requireTokenType("IDENTIFIER"),a=!n.matchOpToken("!");return{type:"typeCheck",typeName:o,nullOk:a,args:[r],op:function(e,n){if(t.typeCheck(n,o.value,a))return n;throw new Error("Typecheck failed!  Expected: "+o.value)},evaluate:function(e){return t.unifiedEval(this,e)}}}return r}),E.addGrammarElement("logicalNot",function(e,t,n){if(n.matchToken("not")){var r=e.requireElement("unaryExpression",n);return{type:"logicalNot",root:r,args:[r],op:function(e,t){return!t},evaluate:function(e){return t.unifiedEval(this,e)}}}}),E.addGrammarElement("noExpression",function(e,t,n){if(n.matchToken("no")){var r=e.requireElement("unaryExpression",n);return{type:"noExpression",root:r,args:[r],op:function(e,n){return t.isEmpty(n)},evaluate:function(e){return t.unifiedEval(this,e)}}}}),E.addGrammarElement("negativeNumber",function(e,t,n){if(n.matchOpToken("-")){var r=e.requireElement("unaryExpression",n);return{type:"negativeNumber",root:r,args:[r],op:function(e,t){return-1*t},evaluate:function(e){return t.unifiedEval(this,e)}}}}),E.addGrammarElement("unaryExpression",function(e,t,n){return e.parseAnyOf(["logicalNot","relativePositionalExpression","positionalExpression","noExpression","negativeNumber","postfixExpression"],n)});var q=function(e,t,n,r){var o=[];y.forEach(t,function(t){(t.matches(n)||t===e)&&o.push(t)});for(var a=0;a<o.length-1;a++)if(o[a]===e)return o[a+1];if(r){var i=o[0];if(i&&i.matches(n))return i}};E.addGrammarElement("relativePositionalExpression",function(e,t,n){var r=n.matchAnyToken("next","previous");if(r){if("next"===r.value)var o=!0;var a=e.parseElement("expression",n);if(n.matchToken("from")){n.pushFollow("in");try{var i=e.requireElement("expression",n)}finally{n.popFollow()}}else i=e.requireElement("implicitMeTarget",n);var u,s=!1;if(n.matchToken("in")){s=!0;var l=e.requireElement("expression",n)}else u=n.matchToken("within")?e.requireElement("expression",n):document.body;var c=!1;return n.matchToken("with")&&(n.requireToken("wrapping"),c=!0),{type:"relativePositionalExpression",from:i,forwardSearch:o,inSearch:s,wrapping:c,inElt:l,withinElt:u,operator:r.value,args:[a,i,l,u],op:function(e,t,n,r,a){var i,u,l=t.css;if(null==l)throw"Expected a CSS value";if(s){if(r)return o?q(n,r,l,c):(i=l,u=c,q(n,Array.from(r).reverse(),i,u))}else if(a)return o?function(e,t,n,r){for(var o=t.querySelectorAll(n),a=0;a<o.length;a++){var i=o[a];if(i.compareDocumentPosition(e)===Node.DOCUMENT_POSITION_PRECEDING)return i}if(r)return o[0]}(n,a,l,c):function(e,t,n,r){for(var o=t.querySelectorAll(n),a=o.length-1;a>=0;a--){var i=o[a];if(i.compareDocumentPosition(e)===Node.DOCUMENT_POSITION_FOLLOWING)return i}if(r)return o[o.length-1]}(n,a,l,c)},evaluate:function(e){return t.unifiedEval(this,e)}}}}),E.addGrammarElement("positionalExpression",function(e,t,n){var r=n.matchAnyToken("first","last","random");if(r){n.matchAnyToken("in","from","of");var o=e.requireElement("unaryExpression",n),a=r.value;return{type:"positionalExpression",rhs:o,operator:r.value,args:[o],op:function(e,t){if(t&&!Array.isArray(t)&&(t=t.children?t.children:Array.from(t)),t){if("first"===a)return t[0];if("last"===a)return t[t.length-1];if("random"===a)return t[Math.floor(Math.random()*t.length)]}},evaluate:function(e){return t.unifiedEval(this,e)}}}}),E.addGrammarElement("mathOperator",function(e,t,n){var r,o=e.parseElement("unaryExpression",n),a=null;for(r=n.matchAnyOpToken("+","-","*","/","%");r;){var i=r.value;(a=a||r).value!==i&&e.raiseParseError(n,"You must parenthesize math operations with different operators");var u=e.parseElement("unaryExpression",n);o={type:"mathOperator",lhs:o,rhs:u,operator:i,args:[o,u],op:function(e,t,n){return"+"===i?t+n:"-"===i?t-n:"*"===i?t*n:"/"===i?t/n:"%"===i?t%n:void 0},evaluate:function(e){return t.unifiedEval(this,e)}},r=n.matchAnyOpToken("+","-","*","/","%")}return o}),E.addGrammarElement("mathExpression",function(e,t,n){return e.parseAnyOf(["mathOperator","unaryExpression"],n)}),E.addGrammarElement("comparisonOperator",function(e,t,n){var r=e.parseElement("mathExpression",n),o=n.matchAnyOpToken("<",">","<=",">=","==","===","!=","!=="),a=o?o.value:null,i=!0,u=!1;if(null==a&&(n.matchToken("is")||n.matchToken("am")?n.matchToken("not")?n.matchToken("in")?a="not in":n.matchToken("a")?(a="not a",u=!0):n.matchToken("empty")?(a="not empty",i=!1):a="!=":n.matchToken("in")?a="in":n.matchToken("a")?(a="a",u=!0):n.matchToken("empty")?(a="empty",i=!1):n.matchToken("less")?(n.requireToken("than"),n.matchToken("or")?(n.requireToken("equal"),n.requireToken("to"),a="<="):a="<"):n.matchToken("greater")?(n.requireToken("than"),n.matchToken("or")?(n.requireToken("equal"),n.requireToken("to"),a=">="):a=">"):a="==":n.matchToken("matches")||n.matchToken("match")?a="match":n.matchToken("contains")||n.matchToken("contain")?a="contain":n.matchToken("includes")||n.matchToken("include")?a="include":(n.matchToken("do")||n.matchToken("does"))&&(n.requireToken("not"),n.matchToken("matches")||n.matchToken("match")?a="not match":n.matchToken("contains")||n.matchToken("contain")?a="not contain":n.matchToken("include")?a="not include":e.raiseParseError(n,"Expected matches or contains"))),a){if(u)var s=n.requireTokenType("IDENTIFIER"),l=!n.matchOpToken("!");else if(i){var c=e.requireElement("mathExpression",n);"match"!==a&&"not match"!==a||(c=c.css?c.css:c)}var f=r;r={type:"comparisonOperator",operator:a,typeName:s,nullOk:l,lhs:r,rhs:c,args:[r,c],op:function(e,n,r){if("=="===a)return n==r;if("!="===a)return n!=r;if("match"===a)return null!=n&&g(f,n,r);if("not match"===a)return null==n||!g(f,n,r);if("in"===a)return null!=r&&k(c,r,n);if("not in"===a)return null==r||!k(c,r,n);if("contain"===a)return null!=n&&k(f,n,r);if("not contain"===a)return null==n||!k(f,n,r);if("include"===a)return null!=n&&k(f,n,r);if("not include"===a)return null==n||!k(f,n,r);if("==="===a)return n===r;if("!=="===a)return n!==r;if("<"===a)return n<r;if(">"===a)return n>r;if("<="===a)return n<=r;if(">="===a)return n>=r;if("empty"===a)return t.isEmpty(n);if("not empty"===a)return!t.isEmpty(n);if("a"===a)return t.typeCheck(n,s.value,l);if("not a"===a)return!t.typeCheck(n,s.value,l);throw"Unknown comparison : "+a},evaluate:function(e){return t.unifiedEval(this,e)}}}return r}),E.addGrammarElement("comparisonExpression",function(e,t,n){return e.parseAnyOf(["comparisonOperator","mathExpression"],n)}),E.addGrammarElement("logicalOperator",function(e,t,n){var r,o=e.parseElement("comparisonExpression",n),a=null;r=n.matchToken("and")||n.matchToken("or");for(var i=function(){(a=a||r).value!==r.value&&e.raiseParseError(n,"You must parenthesize logical operations with different operators"),u=e.requireElement("comparisonExpression",n);var i=r.value;o={type:"logicalOperator",operator:i,lhs:o,rhs:u,args:[o,u],op:function(e,t,n){return"and"===i?t&&n:t||n},evaluate:function(e){return t.unifiedEval(this,e)}},r=n.matchToken("and")||n.matchToken("or")};r;){var u;i()}return o}),E.addGrammarElement("logicalExpression",function(e,t,n){return e.parseAnyOf(["logicalOperator","mathExpression"],n)}),E.addGrammarElement("asyncExpression",function(e,t,n){return n.matchToken("async")?{type:"asyncExpression",value:e.requireElement("logicalExpression",n),evaluate:function(e){return{asyncWrapper:!0,value:this.value.evaluate(e)}}}:e.parseElement("logicalExpression",n)}),E.addGrammarElement("expression",function(e,t,n){return n.matchToken("the"),e.parseElement("asyncExpression",n)}),E.addGrammarElement("assignableExpression",function(e,t,n){n.matchToken("the");var r=e.parseElement("primaryExpression",n);return!r||"symbol"!==r.type&&"ofExpression"!==r.type&&"propertyAccess"!==r.type&&"attributeRefAccess"!==r.type&&"attributeRef"!==r.type&&"possessive"!==r.type?(E.raiseParseError(n,"A target expression must be writable.  The expression type '"+(r&&r.type)+"' is not."),r):r}),E.addGrammarElement("hyperscript",function(e,t,n){var r=[];if(n.hasMore())for(;e.featureStart(n.currentToken())||"("===n.currentToken().value;){var o=e.requireElement("feature",n);r.push(o),n.matchToken("end")}return{type:"hyperscript",features:r,apply:function(e,t,n){for(var o,a=l(r);!(o=a()).done;)o.value.install(e,t,n)}}});var w=function(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.addFeature("on",function(e,t,n){if(n.matchToken("on")){var r=!1;n.matchToken("every")&&(r=!0);var o=[],a=null;do{var i=e.requireElement("eventName",n,"Expected event name").evaluate();a=a?a+" or "+i:"on "+i;var u=w(n),s=null;if(n.matchOpToken("[")&&(s=e.requireElement("expression",n),n.requireOpToken("]")),"NUMBER"===n.currentToken().type){var f=n.consumeToken(),m=parseInt(f.value);if(n.matchToken("to"))var p=n.consumeToken(),v=parseInt(p.value);else if(n.matchToken("and")){var d=!0;n.requireToken("on")}}if("intersection"===i){var h={};if(n.matchToken("with")&&(h.with=e.requireElement("expression",n).evaluate()),n.matchToken("having"))do{n.matchToken("margin")?h.rootMargin=e.requireElement("stringLike",n).evaluate():n.matchToken("threshold")?h.threshold=e.requireElement("expression",n).evaluate():e.raiseParseError(n,"Unknown intersection config specification")}while(n.matchToken("and"))}else if("mutation"===i){var E={};if(n.matchToken("of"))do{if(n.matchToken("anything"))E.attributes=!0,E.subtree=!0,E.characterData=!0,E.childList=!0;else if(n.matchToken("childList"))E.childList=!0;else if(n.matchToken("attributes"))E.attributes=!0,E.attributeOldValue=!0;else if(n.matchToken("subtree"))E.subtree=!0;else if(n.matchToken("characterData"))E.characterData=!0,E.characterDataOldValue=!0;else if("ATTRIBUTE_REF"===n.currentToken().type){var T=n.consumeToken();null==E.attributeFilter&&(E.attributeFilter=[]),0==T.value.indexOf("@")?E.attributeFilter.push(T.value.substring(1)):e.raiseParseError(n,"Only shorthand attribute references are allowed here")}else e.raiseParseError(n,"Unknown mutation config specification")}while(n.matchToken("or"));else E.attributes=!0,E.characterData=!0,E.childList=!0}var k=null,g=!1;if(n.matchToken("from")&&(n.matchToken("elsewhere")?g=!0:(k=e.parseElement("expression",n))||e.raiseParseError(n,'Expected either target value or "elsewhere".')),null===k&&!1===g&&n.matchToken("elsewhere")&&(g=!0),n.matchToken("in"))var x=e.parseAnyOf(["idRef","queryRef","classRef"],n);if(n.matchToken("debounced")){n.requireToken("at");var b=e.requireElement("timeExpression",n).evaluate({})}else if(n.matchToken("throttled")){n.requireToken("at");var q=e.requireElement("timeExpression",n).evaluate({})}o.push({execCount:0,every:r,on:i,args:u,filter:s,from:k,inExpr:x,elsewhere:g,startCount:m,endCount:v,unbounded:d,debounceTime:b,throttleTime:q,mutationSpec:E,intersectionSpec:h,debounced:void 0,lastExec:void 0})}while(n.matchToken("or"));var N=[],I=!0;if(!r&&n.matchToken("queue"))if(n.matchToken("all"))I=!1;else if(n.matchToken("first"))var O=!0;else if(n.matchToken("none"))var S=!0;else n.requireToken("last");var R=e.parseElement("commandList",n),L={type:"implicitReturn",op:function(e){return e.meta.resolve(),t.HALT},execute:function(e){}};if(R){for(var A=R,C=A;C.next;)C=C.next;C.next=L}else A=L;var F={displayName:a,events:o,start:A,every:r,executing:!1,execCount:0,queue:N,execute:function(e){if(this.executing&&!1===r){if(S||O&&N.length>0)return;return I&&(F.queue.length=0),void F.queue.push(e)}F.execCount++,this.executing=!0,e.meta.resolve=function(){F.executing=!1;var e=F.queue.shift();e&&setTimeout(function(){F.execute(e)},1)},e.meta.reject=function(n){console.error(n.message?n.message:n);var r=t.getHyperTrace(e,n);r&&r.print(),t.triggerEvent(e.me,"exception",{error:n}),F.executing=!1;var o=F.queue.shift();o&&setTimeout(function(){F.execute(o)},1)},A.execute(e)},install:function(e,n){for(var r,o=function(){var n=r.value;i=n.elsewhere?[document]:n.from?n.from.evaluate(t.makeContext(e,F,e,null)):[e],t.forEach(i,function(r){var o=n.on;if(n.mutationSpec&&(o="hyperscript:mutation",new MutationObserver(function(e,t){console.log(r,e),F.executing||y.triggerEvent(r,o,{mutationList:e,observer:t})}).observe(r,n.mutationSpec)),n.intersectionSpec){o="hyperscript:insersection";var a=new IntersectionObserver(function(e){for(var t,n=l(e);!(t=n()).done;){var i=t.value,u={observer:a};(u=c(u,i)).intersecting=i.isIntersecting,y.triggerEvent(r,o,u)}},n.intersectionSpec);a.observe(r)}(r.addEventListener||r.on).call(r,o,function a(i){if("undefined"!=typeof Node&&e instanceof Node&&r!==e&&!e.isConnected)r.removeEventListener(o,a);else{var u=t.makeContext(e,F,e,i);if(!n.elsewhere||!e.contains(i.target)){n.from&&(u.result=r);for(var s,c=l(n.args);!(s=c()).done;){var f=s.value;u[f.value]=u.event[f.value]||("detail"in u.event?u.event.detail[f.value]:null)}if(n.filter){var m=u.meta.context;u.meta.context=u.event;try{if(!n.filter.evaluate(u))return}finally{u.meta.context=m}}if(n.inExpr)for(var p=i.target;;){if(p.matches&&p.matches(n.inExpr.css)){u.result=p;break}if(null==(p=p.parentElement))return}if(n.execCount++,n.startCount)if(n.endCount){if(n.execCount<n.startCount||n.execCount>n.endCount)return}else if(n.unbounded){if(n.execCount<n.startCount)return}else if(n.execCount!==n.startCount)return;if(n.debounceTime)return n.debounced&&clearTimeout(n.debounced),void(n.debounced=setTimeout(function(){F.execute(u)},n.debounceTime));if(n.throttleTime){if(n.lastExec&&Date.now()<n.lastExec+n.throttleTime)return;n.lastExec=Date.now()}F.execute(u)}}})})},a=l(F.events);!(r=a()).done;){var i;o()}}};return e.setParent(A,F),F}}),E.addFeature("def",function(e,t,n){if(n.matchToken("def")){var r=e.requireElement("dotOrColonPath",n).evaluate(),o=r.split("."),a=o.pop(),i=[];if(n.matchOpToken("("))if(n.matchOpToken(")"));else{do{i.push(n.requireTokenType("IDENTIFIER"))}while(n.matchOpToken(","));n.requireOpToken(")")}var u=e.requireElement("commandList",n);if(n.matchToken("catch"))var s=n.requireTokenType("IDENTIFIER").value,l=e.parseElement("commandList",n);var c={displayName:a+"("+i.map(function(e){return e.value}).join(", ")+")",name:a,args:i,start:u,errorHandler:l,errorSymbol:s,install:function(e,n){var f=function(){var r=t.makeContext(n,c,e,null);r.meta.errorHandler=l,r.meta.errorSymmbol=s;for(var o=0;o<i.length;o++){var a=i[o],f=arguments[o];a&&(r[a.value]=f)}r.meta.caller=arguments[i.length],r.meta.caller&&(r.meta.callingCommand=r.meta.caller.meta.command);var m,p=null,v=new Promise(function(e,t){m=e,p=t});return u.execute(r),r.meta.returned?r.meta.returnValue:(r.meta.resolve=m,r.meta.reject=p,v)};f.hyperfunc=!0,f.hypername=r,t.assignToNamespace(e,o,a,f)}},f={type:"implicitReturn",op:function(e){return e.meta.returned=!0,e.meta.resolve&&e.meta.resolve(),t.HALT},execute:function(e){}};if(u){for(var m=u;m.next;)m=m.next;m.next=f}else c.start=f;if(l){for(m=l;m.next;)m=m.next;m.next=f}return e.setParent(u,c),c}}),E.addFeature("init",function(e,t,n){if(n.matchToken("init")){n.matchToken("immediately");var r=e.parseElement("commandList",n),o={start:r,install:function(e,n){setTimeout(function(){r&&r.execute(t.makeContext(e,o,e,null))},0)}},a={type:"implicitReturn",op:function(e){return t.HALT},execute:function(e){}};if(r){for(var i=r;i.next;)i=i.next;i.next=a}else o.start=a;return e.setParent(r,o),o}}),E.addFeature("worker",function(e,t,n){n.matchToken("worker")&&e.raiseParseError(n,"In order to use the 'worker' feature, include the _hyperscript worker plugin. See https://hyperscript.org/features/worker/ for more info.")}),E.addFeature("behavior",function(e,t,n){if(n.matchToken("behavior")){var r=e.requireElement("dotOrColonPath",n).evaluate(),o=r.split("."),a=o.pop(),i=[];if(n.matchOpToken("(")&&!n.matchOpToken(")")){do{i.push(n.requireTokenType("IDENTIFIER").value)}while(n.matchOpToken(","));n.requireOpToken(")")}for(var u=e.requireElement("hyperscript",n),s=0;s<u.features.length;s++)u.features[s].behavior=r;return{install:function(e,n){t.assignToNamespace(v.document&&v.document.body,o,a,function(e,n,o){for(var a=f(t.getInternalData(e),r+"Scope"),s=0;s<i.length;s++)a[i[s]]=o[i[s]];u.apply(e,n)})}}}}),E.addFeature("install",function(e,t,n){if(n.matchToken("install")){var r,o=e.requireElement("dotOrColonPath",n).evaluate(),a=o.split("."),i=e.parseElement("namedArgumentList",n);return r={install:function(e,n){t.unifiedEval({args:[i],op:function(t,r){for(var i=v,u=0;u<a.length;u++)if("object"!=typeof(i=i[a[u]])&&"function"!=typeof i)throw new Error("No such behavior defined as "+o);if(!(i instanceof Function))throw new Error(o+" is not a behavior");i(e,n,r)}},t.makeContext(e,r,e))}}}}),E.addGrammarElement("jsBody",function(e,t,n){for(var r=n.currentToken().start,o=n.currentToken(),a=[],i="",u=!1;n.hasMore();){o=n.consumeToken();var s=n.token(0,!0);if("IDENTIFIER"===s.type&&"end"===s.value)break;u?"IDENTIFIER"===o.type||"NUMBER"===o.type?i+=o.value:(""!==i&&a.push(i),i="",u=!1):"IDENTIFIER"===o.type&&"function"===o.value&&(u=!0)}return{type:"jsBody",exposedFunctionNames:a,jsSource:n.source.substring(r,o.end+1)}}),E.addFeature("js",function(e,t,n){if(n.matchToken("js")){var r=e.requireElement("jsBody",n),o=r.jsSource+"\nreturn { "+r.exposedFunctionNames.map(function(e){return e+":"+e}).join(",")+" } ",a=new Function(o);return{jsSource:o,function:a,exposedFunctionNames:r.exposedFunctionNames,install:function(){c(v,a())}}}}),E.addCommand("js",function(e,t,n){if(n.matchToken("js")){var r=[];if(n.matchOpToken("("))if(n.matchOpToken(")"));else{do{var o=n.requireTokenType("IDENTIFIER");r.push(o.value)}while(n.matchOpToken(","));n.requireOpToken(")")}var a=e.requireElement("jsBody",n);n.matchToken("end");var i=m(Function,r.concat([a.jsSource]));return{jsSource:a.jsSource,function:i,inputs:r,op:function(e){var n=[];r.forEach(function(r){n.push(t.resolveSymbol(r,e,"default"))});var o=i.apply(v,n);return o&&"function"==typeof o.then?new Promise(function(n){o.then(function(r){e.result=r,n(t.findNext(this,e))})}):(e.result=o,t.findNext(this,e))}}}}),E.addCommand("async",function(e,t,n){if(n.matchToken("async")){if(n.matchToken("do")){for(var r=o=e.requireElement("commandList",n);r.next;)r=r.next;r.next=t.HALT,n.requireToken("end")}else var o=e.requireElement("command",n);return{body:o,op:function(e){return setTimeout(function(){o.execute(e)}),t.findNext(this,e)}}}}),E.addCommand("tell",function(e,t,n){var r=n.currentToken();if(n.matchToken("tell")){var o=e.requireElement("expression",n),a=e.requireElement("commandList",n);n.hasMore()&&!e.featureStart(n.currentToken())&&n.requireToken("end");var i="tell_"+r.start,u={value:o,body:a,args:[o],resolveNext:function(e){var n=e.meta.iterators[i];return n.index<n.value.length?(e.beingTold=n.value[n.index++],a):(e.beingTold=n.originalBeingTold,this.next?this.next:t.findNext(this.parent,e))},op:function(e,t){return null==t?t=[]:Array.isArray(t)||t instanceof NodeList||(t=[t]),e.meta.iterators[i]={originalBeingTold:e.beingTold,index:0,value:t},this.resolveNext(e)}};return e.setParent(a,u),u}}),E.addCommand("wait",function(e,t,n){if(n.matchToken("wait")){var r,o;if(n.matchToken("for")){n.matchToken("a");var a=[];do{var i=n.token(0);a.push("NUMBER"===i.type||"L_PAREN"===i.type?{time:e.requireElement("timeExpression",n).evaluate()}:{name:E.requireElement("dotOrColonPath",n,"Expected event name").evaluate(),args:w(n)})}while(n.matchToken("or"));if(n.matchToken("from"))var u=e.requireElement("expression",n);return r={event:a,on:u,args:[u],op:function(e,n){var r=this,o=n||e.me;if(!(o instanceof EventTarget))throw new Error("Not a valid event target: "+this.on.sourceFor());return new Promise(function(n){for(var i,u=!1,s=function(){var a=i.value;f=function(o){e.result=o;for(var i,s=l(a.args);!(i=s()).done;){var c=i.value;e[c.value]=o[c.value]||(o.detail?o.detail[c.value]:null)}u||(u=!0,n(t.findNext(r,e)))},a.name?o.addEventListener(a.name,f,{once:!0}):a.time&&setTimeout(f,a.time,a.time)},c=l(a);!(i=c()).done;){var f;s()}})}},r}return n.matchToken("a")?(n.requireToken("tick"),o=0):o=E.requireElement("timeExpression",n),{type:"waitCmd",time:o,args:[o],op:function(e,n){var r=this;return new Promise(function(o){setTimeout(function(){o(t.findNext(r,e))},n)})},execute:function(e){return t.unifiedExec(this,e)}}}}),E.addGrammarElement("dotOrColonPath",function(e,t,n){var r=n.matchTokenType("IDENTIFIER");if(r){var o=[r.value],a=n.matchOpToken(".")||n.matchOpToken(":");if(a)do{o.push(n.requireTokenType("IDENTIFIER").value)}while(n.matchOpToken(a.value));return{type:"dotOrColonPath",path:o,evaluate:function(){return o.join(a?a.value:"")}}}}),E.addGrammarElement("eventName",function(e,t,n){var r;return(r=n.matchTokenType("STRING"))?{evaluate:function(){return r.value}}:e.parseElement("dotOrColonPath",n)}),E.addCommand("trigger",function(e,t,n){if(n.matchToken("trigger"))return x("trigger",e,t,n)}),E.addCommand("send",function(e,t,n){if(n.matchToken("send"))return x("send",e,t,n)});var N=function(e,t,n,r){if(r)var o=e.requireElement("expression",n);var a={value:o,args:[o],op:function(e,n){var r=e.meta.resolve;return e.meta.returned=!0,r?n?r(n):r():(e.meta.returned=!0,e.meta.returnValue=n),t.HALT}};return a};E.addCommand("return",function(e,t,n){if(n.matchToken("return"))return N(e,t,n,!0)}),E.addCommand("exit",function(e,t,n){if(n.matchToken("exit"))return N(e,t,n,!1)}),E.addCommand("halt",function(e,t,n){if(n.matchToken("halt")){if(n.matchToken("the")){n.requireToken("event"),n.matchOpToken("'")&&n.requireToken("s");var r=!0}if(n.matchToken("bubbling"))var o=!0;else if(n.matchToken("default"))var a=!0;var i=N(e,t,n,!1);return{keepExecuting:!0,bubbling:o,haltDefault:a,exit:i,op:function(e){if(e.event)return o?e.event.stopPropagation():(a||e.event.stopPropagation(),e.event.preventDefault()),r?t.findNext(this,e):i}}}}),E.addCommand("log",function(e,t,n){if(n.matchToken("log")){for(var r=[e.parseElement("expression",n)];n.matchOpToken(",");)r.push(e.requireElement("expression",n));if(n.matchToken("with"))var o=e.requireElement("expression",n);var a={exprs:r,withExpr:o,args:[o,r],op:function(e,n,r){return n?n.apply(null,r):console.log.apply(null,r),t.findNext(this,e)}};return a}}),E.addCommand("throw",function(e,t,n){if(n.matchToken("throw")){var r=e.requireElement("expression",n),o={expr:r,args:[r],op:function(e,n){t.registerHyperTrace(e,n);var r=e.meta&&e.meta.reject;if(r)return r(n),t.HALT;throw n}};return o}});var I=function(e,t,n){var r=e.requireElement("expression",n),o={expr:r,args:[r],op:function(e,n){return e.result=n,t.findNext(o,e)}};return o};E.addCommand("call",function(e,t,n){if(n.matchToken("call")){var r=I(e,t,n);return r.expr&&"functionCall"!==r.expr.type&&e.raiseParseError(n,"Must be a function invocation"),r}}),E.addCommand("get",function(e,t,n){if(n.matchToken("get"))return I(e,t,n)}),E.addCommand("make",function(e,t,n){if(n.matchToken("make")){n.matchToken("a")||n.matchToken("an");var r,o=e.requireElement("expression",n),a=[];if("queryRef"!==o.type&&n.matchToken("from"))do{a.push(e.requireElement("expression",n))}while(n.matchOpToken(","));if(n.matchToken("called"))var i=n.requireTokenType("IDENTIFIER").value;return"queryRef"===o.type?r={op:function(e){for(var n,r,a="div",u=[],s=/(?:(^|#|\.)([^#\. ]+))/g;n=s.exec(o.css);)""===n[1]?a=n[2].trim():"#"===n[1]?r=n[2].trim():u.push(n[2].trim());var l=document.createElement(a);void 0!==r&&(l.id=r);for(var c=0;c<u.length;c++)l.classList.add(u[c]);return e.result=l,i&&(e[i]=l),t.findNext(this,e)}}:(r={args:[o,a],op:function(e,n,r){return e.result=m(n,r),i&&(e[i]=e.result),t.findNext(this,e)}},r)}}),E.addGrammarElement("pseudoCommand",function(e,t,n){try{var r=e.requireElement("primaryExpression",n)}finally{n.popFollow()}"functionCall"!==r.type&&"symbol"!==r.root.type&&null!=r.root.root&&e.raiseParseError(n,"Implicit function calls must start with a simple function");var o=r.root.name;if(n.matchAnyToken("the","to","on","with","into","from","at"))var a=e.requireElement("expression",n);else n.matchToken("me")&&(a=e.requireElement("implicitMeTarget",n));var i={type:"pseudoCommand",expr:r,args:[a,r.argExressions],op:function(e,n,r){if(n)var a=n[o];else a=t.resolveSymbol(o,e);a.hyperfunc&&r.push(e);var u=a.apply(n,r);return e.result=u,t.findNext(i,e)},execute:function(e){return t.unifiedExec(this,e)}};return i});var O=function(e,t,n,r,o){var a="symbol"===r.type,i="attributeRef"===r.type;i||a||null!=r.root||e.raiseParseError(n,"Can only put directly into symbols, not references");var u=null,s=null;if(a);else if(i){u=e.requireElement("implicitMeTarget",n);var l=r}else s=r.prop?r.prop.value:null,l=r.attribute,u=r.root;var c={target:r,symbolWrite:a,value:o,args:[u,o],op:function(e,n,o){return a?t.setSymbol(r.name,e,r.symbolType,o):t.implicitLoop(n,function(e){l?null==o?e.removeAttribute(l.name):e.setAttribute(l.name,o):e[s]=o}),t.findNext(this,e)}};return c};E.addCommand("default",function(e,t,n){if(n.matchToken("default")){var r=e.requireElement("assignableExpression",n);n.requireToken("to");var o=e.requireElement("expression",n),a=O(e,t,n,r,o),i={target:r,value:o,setter:a,args:[r],op:function(e,n){return n?t.findNext(this,e):a}};return a.parent=i,i}}),E.addCommand("set",function(e,t,n){if(n.matchToken("set")){if("L_BRACE"===n.currentToken().type){var r=e.requireElement("objectLiteral",n);n.requireToken("on");var o={objectLiteral:r,target:a=e.requireElement("expression",n),args:[r,a],op:function(e,n,r){return c(r,n),t.findNext(this,e)}};return o}try{n.pushFollow("to");var a=e.requireElement("assignableExpression",n)}finally{n.popFollow()}n.requireToken("to");var i=e.requireElement("expression",n);return O(e,t,n,a,i)}}),E.addCommand("if",function(e,t,n){if(n.matchToken("if")){var r=e.requireElement("expression",n);n.matchToken("then");var o=e.parseElement("commandList",n);if(n.matchToken("else"))var a=e.parseElement("commandList",n);n.hasMore()&&n.requireToken("end");var i={expr:r,trueBranch:o,falseBranch:a,args:[r],op:function(e,n){return n?o:a||t.findNext(this,e)}};return e.setParent(o,i),e.setParent(a,i),i}});var S=function(e,t,n,r){var o,a=t.currentToken();if(t.matchToken("for")||r){var i=t.requireTokenType("IDENTIFIER");o=i.value,t.requireToken("in");var u=e.requireElement("expression",t)}else if(t.matchToken("in"))o="it",u=e.requireElement("expression",t);else if(t.matchToken("while"))var s=e.requireElement("expression",t);else if(t.matchToken("until")){var l=!0;if(t.matchToken("event")){var c=E.requireElement("dotOrColonPath",t,"Expected event name");if(t.matchToken("from"))var f=e.requireElement("expression",t)}else s=e.requireElement("expression",t)}else if(t.matchTokenType("NUMBER")){var m=parseFloat(a.value);t.requireToken("times")}else{t.matchToken("forever");var p=!0}if(t.matchToken("index"))var v=(i=t.requireTokenType("IDENTIFIER")).value;var d=e.parseElement("commandList",t);if(d&&c){for(var h=d;h.next;)h=h.next;var T={type:"waitATick",op:function(){return new Promise(function(e){setTimeout(function(){e(n.findNext(T))},0)})}};h.next=T}if(t.hasMore()&&t.requireToken("end"),null==o)var y=o="_implicit_repeat_"+a.start;else y=o+"_"+a.start;var k={identifier:o,indexIdentifier:v,slot:y,expression:u,forever:p,times:m,until:l,event:c,on:f,whileExpr:s,resolveNext:function(){return this},loop:d,args:[s],op:function(e,t){var r=e.meta.iterators[y],a=!1,i=null;if(this.forever)a=!0;else if(this.until)a=c?!1===e.meta.iterators[y].eventFired:!0!==t;else if(s)a=t;else if(m)a=r.index<this.times;else{var u=r.iterator.next();a=!u.done,i=u.value}return a?(e.result=r.value?e[o]=i:r.index,v&&(e[v]=r.index),r.index++,d):(e.meta.iterators[y]=null,n.findNext(this.parent,e))}};e.setParent(d,k);var g={name:"repeatInit",args:[u,c,f],op:function(e,t,n,r){var o={index:0,value:t,eventFired:!1};return e.meta.iterators[y]=o,t&&t[Symbol.iterator]&&(o.iterator=t[Symbol.iterator]()),c&&(r||e.me).addEventListener(n,function(t){e.meta.iterators[y].eventFired=!0},{once:!0}),k},execute:function(e){return n.unifiedExec(this,e)}};return e.setParent(k,g),g};if(E.addCommand("repeat",function(e,t,n){if(n.matchToken("repeat"))return S(e,n,t,!1)}),E.addCommand("for",function(e,t,n){if(n.matchToken("for"))return S(e,n,t,!0)}),E.addCommand("continue",function(e,t,n){if(n.matchToken("continue"))return{op:function(t){for(var r=this.parent;;r=r.parent)if(null==r&&e.raiseParseError(n,"Command `continue` cannot be used outside of a `repeat` loop."),null!=r.loop)return r.resolveNext(t)}}}),E.addGrammarElement("stringLike",function(e,t,n){return E.parseAnyOf(["string","nakedString"],n)}),E.addCommand("append",function(e,t,n){if(n.matchToken("append")){var r=null,o=null,a=e.requireElement("expression",n);if(n.matchToken("to")&&(r=e.requireElement("expression",n)),null==r)o="result";else if("symbol"===r.type)o=r.name;else{if("propertyAccess"!==r.type)throw"Unable to append to "+r.type;o=r.prop.value}var i={value:a,target:r,args:[a],op:function(e,n){if(Array.isArray(e[o]))e[o].push(n);else if(e[o]instanceof Element){if("string"!=typeof n)throw"Don't know how to append non-strings to an HTML Element yet.";e[o].innerHTML+=n}else e[o]+=n;return t.findNext(this,e)},execute:function(e){return t.unifiedExec(this,e)}};return i}}),E.addCommand("increment",function(e,t,n){if(n.matchToken("increment")){var r,o=e.parseElement("assignableExpression",n);n.matchToken("by")&&(r=e.requireElement("expression",n));var a={target:o,args:[o,r],op:function(r,a,i){var u=(a=a?parseFloat(a):0)+(i=i?parseFloat(i):1),s=O(e,t,n,o,u);return r.result=u,s.parent=this,s},execute:function(e){return t.unifiedExec(this,e)}};return a}}),E.addCommand("decrement",function(e,t,n){if(n.matchToken("decrement")){var r,o=e.parseElement("assignableExpression",n);n.matchToken("by")&&(r=e.requireElement("expression",n));var a={target:o,args:[o,r],op:function(r,a,i){var u=(a=a?parseFloat(a):0)-(i=i?parseFloat(i):1),s=O(e,t,n,o,u);return r.result=u,s.parent=this,s},execute:function(e){return t.unifiedExec(this,e)}};return a}}),E.addCommand("fetch",function(e,t,n){if(n.matchToken("fetch")){var r=e.requireElement("stringLike",n);if(n.matchToken("with"))var o=e.parseElement("nakedNamedArgumentList",n);else o=e.parseElement("objectLiteral",n);var a,i="text";n.matchToken("as")&&(n.matchToken("a")||n.matchToken("an"),n.matchToken("json")||n.matchToken("Object")?i="json":n.matchToken("response")?i="response":n.matchToken("html")?i="html":n.matchToken("text")||(a=e.requireElement("dotOrColonPath",n).evaluate()));var u={url:r,argExpressions:o,args:[r,o],op:function(e,n,r){var o=r||{};return o.sentBy=e.me,t.triggerEvent(e.me,"hyperscript:beforeFetch",o),r=o,fetch(n,r).then(function(n){return"response"===i?(e.result=n,t.findNext(u,e)):"json"===i?n.json().then(function(n){return e.result=n,t.findNext(u,e)}):n.text().then(function(n){return a&&(n=t.convertValue(n,a)),"html"===i&&(n=t.convertValue(n,"Fragment")),e.result=n,t.findNext(u,e)})}).catch(function(n){throw t.triggerEvent(e.me,"fetch:error",{reason:n}),n})}};return u}}),"document"in v){var R=Array.from(document.querySelectorAll("script[type='text/hyperscript'][src]"));Promise.all(R.map(function(e){return fetch(e.src).then(function(e){return e.text()}).then(function(e){return y.evaluate(e)})})).then(function(){var e;e=function(){var e,t;(t=(e=document.querySelector('meta[name="htmx-config"]'))?function(e){try{return JSON.parse(e)}catch(e){return t=e,console.error?console.error(t):console.log&&console.log("ERROR: ",t),null}var t}(e.content):null)&&(p.config=c(p.config,t)),y.processNode(document.documentElement),document.addEventListener("htmx:load",function(e){y.processNode(e.detail.elt)})},"loading"!==document.readyState?setTimeout(e):document.addEventListener("DOMContentLoaded",e)})}var L=p=c(function(e,t){return y.evaluate(e,t)},{internals:{lexer:h,parser:E,runtime:y},ElementCollection:d,addFeature:function(e,t){E.addFeature(e,t)},addCommand:function(e,t){E.addCommand(e,t)},addLeafExpression:function(e,t){E.addLeafExpression(e,t)},addIndirectExpression:function(e,t){E.addIndirectExpression(e,t)},evaluate:y.evaluate.bind(y),parse:y.parse.bind(y),processNode:y.processNode.bind(y),config:{attributes:"_, script, data-script",defaultTransition:"all 500ms ease-in",disableSelector:"[disable-scripting], [data-disable-scripting]",conversions:T}});return function(e){e.addCommand("settle",function(e,t,n){if(n.matchToken("settle")){if(e.commandBoundary(n.currentToken()))r=e.requireElement("implicitMeTarget",n);else var r=e.requireElement("expression",n);var o={type:"settleCmd",args:[r],op:function(e,n){var r=null,a=!1,i=new Promise(function(e){r=e});return n.addEventListener("transitionstart",function(){a=!0},{once:!0}),setTimeout(function(){a||r(t.findNext(o,e))},500),n.addEventListener("transitionend",function(){r(t.findNext(o,e))},{once:!0}),i},execute:function(e){return t.unifiedExec(this,e)}};return o}}),e.addCommand("add",function(e,t,n){if(n.matchToken("add")){var r=e.parseElement("classRef",n),o=null,a=null;if(null==r)null==(o=e.parseElement("attributeRef",n))&&null==(a=e.parseElement("styleLiteral",n))&&e.raiseParseError(n,"Expected either a class reference or attribute expression");else for(var i=[r];r=e.parseElement("classRef",n);)i.push(r);if(n.matchToken("to"))var u=e.requireElement("expression",n);else u=e.parseElement("implicitMeTarget",n);return i?{classRefs:i,to:u,args:[u,i],op:function(e,n,r){return t.forEach(r,function(e){t.implicitLoop(n,function(t){t instanceof Element&&t.classList.add(e.className)})}),t.findNext(this,e)}}:o?{type:"addCmd",attributeRef:o,to:u,args:[u],op:function(e,n,r){return t.implicitLoop(n,function(e){e.setAttribute(o.name,o.value)}),t.findNext(this,e)},execute:function(e){return t.unifiedExec(this,e)}}:{type:"addCmd",cssDeclaration:a,to:u,args:[u,a],op:function(e,n,r){return t.implicitLoop(n,function(e){e.style.cssText+=r}),t.findNext(this,e)},execute:function(e){return t.unifiedExec(this,e)}}}}),e.internals.parser.addGrammarElement("styleLiteral",function(e,t,n){if(n.matchOpToken("{")){for(var r=[""],o=[];n.hasMore();){if(n.matchOpToken("\\"))n.consumeToken();else{if(n.matchOpToken("}"))break;if(n.matchToken("$")){var a=n.matchOpToken("{"),i=e.parseElement("expression",n);a&&n.requireOpToken("}"),o.push(i),r.push("")}else{var u=n.consumeToken();r[r.length-1]+=n.source.substring(u.start,u.end)}}r[r.length-1]+=n.lastWhitespace()}return{type:"styleLiteral",args:[o],op:function(e,t){var n="";return r.forEach(function(e,r){n+=e,r in t&&(n+=t[r])}),n},evaluate:function(e){return t.unifiedEval(this,e)}}}}),e.addCommand("remove",function(e,t,n){if(n.matchToken("remove")){var r=e.parseElement("classRef",n),o=null,a=null;if(null==r)null==(o=e.parseElement("attributeRef",n))&&null==(a=e.parseElement("expression",n))&&e.raiseParseError(n,"Expected either a class reference, attribute expression or value expression");else for(var i=[r];r=e.parseElement("classRef",n);)i.push(r);if(n.matchToken("from"))var u=e.requireElement("expression",n);else u=e.requireElement("implicitMeTarget",n);return a?{elementExpr:a,from:u,args:[a],op:function(e,n){return t.implicitLoop(n,function(e){e.parentElement&&e.parentElement.removeChild(e)}),t.findNext(this,e)}}:{classRefs:i,attributeRef:o,elementExpr:a,from:u,args:[i,u],op:function(e,n,r){return n?t.forEach(n,function(e){t.implicitLoop(r,function(t){t.classList.remove(e.className)})}):t.implicitLoop(r,function(e){e.removeAttribute(o.name)}),t.findNext(this,e)}}}}),e.addCommand("toggle",function(e,t,n){if(n.matchToken("toggle")){if(n.matchToken("between")){var r=!0,o=e.parseElement("classRef",n);n.requireToken("and");var a=e.requireElement("classRef",n)}else{o=e.parseElement("classRef",n);var i=null;if(null==o)null==(i=e.parseElement("attributeRef",n))&&e.raiseParseError(n,"Expected either a class reference or attribute expression");else for(var u=[o];o=e.parseElement("classRef",n);)u.push(o)}if(n.matchToken("on"))var s=e.requireElement("expression",n);else s=e.requireElement("implicitMeTarget",n);if(n.matchToken("for"))var l=e.requireElement("timeExpression",n);else if(n.matchToken("until")){var c=e.requireElement("dotOrColonPath",n,"Expected event name");if(n.matchToken("from"))var f=e.requireElement("expression",n)}var m={classRef:o,classRef2:a,classRefs:u,attributeRef:i,on:s,time:l,evt:c,from:f,toggle:function(e,n,o,a){r?t.implicitLoop(e,function(e){e.classList.contains(n.className)?(e.classList.remove(n.className),e.classList.add(o.className)):(e.classList.add(n.className),e.classList.remove(o.className))}):a?t.forEach(a,function(n){t.implicitLoop(e,function(e){e.classList.toggle(n.className)})}):t.forEach(e,function(e){e.hasAttribute(i.name)?e.removeAttribute(i.name):e.setAttribute(i.name,i.value)})},args:[s,l,c,f,o,a,u],op:function(e,n,r,o,a,i,u,s){return r?new Promise(function(o){m.toggle(n,i,u,s),setTimeout(function(){m.toggle(n,i,u,s),o(t.findNext(m,e))},r)}):o?new Promise(function(r){(a||e.me).addEventListener(o,function(){m.toggle(n,i,u,s),r(t.findNext(m,e))},{once:!0}),m.toggle(n,i,u,s)}):(this.toggle(n,i,u,s),t.findNext(m,e))}};return m}});var t={display:function(t,n,r){if(r)n.style.display=r;else if("hide"===t){var o=e.internals.runtime.getInternalData(n);null==o.originalDisplay&&(o.originalDisplay=n.style.display),n.style.display="none"}else{var a=e.internals.runtime.getInternalData(n);a.originalDisplay?n.style.display=a.originalDisplay:n.style.removeProperty("display")}},visibility:function(e,t,n){t.style.visibility=n||("hide"===e?"hidden":"visible")},opacity:function(e,t,n){t.style.opacity=n||("hide"===e?"0":"1")}},n=function(e,t,n){var r=n.currentToken();return"when"===r.value||"with"===r.value||e.commandBoundary(r)?e.parseElement("implicitMeTarget",n):e.parseElement("expression",n)},r=function(n,r,o){var a=e.config.defaultHideShowStrategy,i=t;e.config.hideShowStrategies&&(i=c(i,e.config.hideShowStrategies));var u=i[o=o||a||"display"];return null==u&&n.raiseParseError(r,"Unknown show/hide strategy : "+o),u};function o(t,n,r,o){if(r)var a=t.resolveSymbol(r,n);else a=n;if(a instanceof Element||a instanceof HTMLDocument){for(;a.firstChild;)a.removeChild(a.firstChild);a.append(e.internals.runtime.convertValue(o,"Fragment"))}else{if(!r)throw"Don't know how to put a value into "+typeof n;t.setSymbol(r,n,null,o)}}function a(e,t,n){var r;if(n.matchToken("the")||n.matchToken("element")||n.matchToken("elements")||"CLASS_REF"===n.currentToken().type||"ID_REF"===n.currentToken().type||n.currentToken().op&&"<"===n.currentToken().value){e.possessivesDisabled=!0;try{r=e.parseElement("expression",n)}finally{delete e.possessivesDisabled}n.matchOpToken("'")&&n.requireToken("s")}else if("IDENTIFIER"===n.currentToken().type&&"its"===n.currentToken().value){var o=n.matchToken("its");r={type:"pseudopossessiveIts",token:o,name:o.value,evaluate:function(e){return t.resolveSymbol("it",e)}}}else n.matchToken("my")||n.matchToken("me"),r=e.parseElement("implicitMeTarget",n);return r}e.addCommand("hide",function(e,t,o){if(o.matchToken("hide")){var a=n(e,0,o),i=null;o.matchToken("with")&&(i=o.requireTokenType("IDENTIFIER").value);var u=r(e,o,i);return{target:a,args:[a],op:function(e,n){return t.implicitLoop(n,function(e){u("hide",e)}),t.findNext(this,e)}}}}),e.addCommand("show",function(e,t,o){if(o.matchToken("show")){var a=n(e,0,o),i=null;o.matchToken("with")&&(i=o.requireTokenType("IDENTIFIER").value);var u=null;if(o.matchOpToken(":")){var s=o.consumeUntilWhitespace();o.matchTokenType("WHITESPACE"),u=s.map(function(e){return e.value}).join("")}if(o.matchToken("when"))var l=e.requireElement("expression",o);var c=r(e,o,i);return{target:a,when:l,args:[a],op:function(e,n){return t.implicitLoop(n,function(n){l?(e.result=n,t.evaluateNoPromise(l,e)?c("show",n,u):c("hide",n),e.result=null):c("show",n,u)}),t.findNext(this,e)}}}}),e.addCommand("take",function(e,t,n){if(n.matchToken("take")){var r=e.parseElement("classRef",n);if(n.matchToken("from"))var o=e.requireElement("expression",n);else o=r;if(n.matchToken("for"))var a=e.requireElement("expression",n);else a=e.requireElement("implicitMeTarget",n);var i={classRef:r,from:o,forElt:a,args:[r,o,a],op:function(e,n,r,o){var a=n.className;return t.implicitLoop(r,function(e){e.classList.remove(a)}),t.implicitLoop(o,function(e){e.classList.add(a)}),t.findNext(this,e)}};return i}}),e.addCommand("put",function(e,t,n){if(n.matchToken("put")){var r=e.requireElement("expression",n),a=n.matchAnyToken("into","before","after");null==a&&n.matchToken("at")&&(n.matchToken("the"),a=n.matchAnyToken("start","end"),n.requireToken("of")),null==a&&e.raiseParseError(n,"Expected one of 'into', 'before', 'at start of', 'at end of', 'after'");var i=e.requireElement("expression",n),u=a.value,s=!1,l=null,c=null;if(i.prop&&i.root&&"into"===u)c=i.prop.value,l=i.root;else if("symbol"===i.type&&"into"===u)s=!0,c=i.name;else if("attributeRef"===i.type&&"into"===u){var f=!0;c=i.name,l=e.requireElement("implicitMeTarget",n)}else i.attribute&&"into"===u?(f=!0,c=i.attribute.name,l=i.root):l=i;return{target:i,operation:u,symbolWrite:s,value:r,args:[l,r],op:function(e,n,r){if(s)o(t,e,c,r);else if("into"===u)t.implicitLoop(n,f?function(e){e.setAttribute(c,r)}:function(e){o(t,e,c,r)});else{var a="before"===u?Element.prototype.before:"after"===u?Element.prototype.after:"start"===u?Element.prototype.prepend:Element.prototype.append;n&&t.implicitLoop(n,function(e){a.call(e,r instanceof Node?r:t.convertValue(r,"Fragment"))})}return t.findNext(this,e)}}}}),e.addCommand("transition",function(t,n,r){if(r.matchToken("transition")){for(var o=a(t,n,r),i=[],u=[],s=[],l=r.currentToken();!t.commandBoundary(l)&&"over"!==l.value&&"using"!==l.value;)i.push(t.requireElement("stringLike",r)),r.matchToken("from")?u.push(t.requireElement("stringLike",r)):u.push(null),r.requireToken("to"),s.push(t.requireElement("stringLike",r)),l=r.currentToken();if(r.matchToken("over"))var c=t.requireElement("timeExpression",r);else if(r.matchToken("using"))var f=t.requireElement("expression",r);var m={to:s,args:[o,i,u,s,f,c],op:function(t,r,o,a,i,u,s){var l=[];return n.implicitLoop(r,function(t){var r=new Promise(function(r,l){var c=t.style.transition;t.style.transition=s?"all "+s+"ms ease-in":u||e.config.defaultTransition;for(var f=n.getInternalData(t),m=getComputedStyle(t),p={},v=0;v<m.length;v++){var d=m[v];p[d]=m[d]}for(f.initalStyles||(f.initalStyles=p),v=0;v<o.length;v++){var h=o[v],E=a[v];t.style[h]="computed"==E||null==E?p[h]:E}setTimeout(function(){for(var e=0;e<o.length;e++){var n=o[e],a=i[e];t.style[n]="initial"==a?f.initalStyles[n]:a}t.addEventListener("transitionend",function(){t.style.transition=c,r()},{once:!0})},5)});l.push(r)}),Promise.all(l).then(function(){return n.findNext(m,t)})}};return m}}),e.addCommand("measure",function(e,t,n){if(n.matchToken("measure")){var r=a(e,t,n),o=[];if(!e.commandBoundary(n.currentToken()))do{o.push(n.matchTokenType("IDENTIFIER").value)}while(n.matchOpToken(","));return{properties:o,args:[r],op:function(e,n){0 in n&&(n=n[0]);var r=n.getBoundingClientRect(),a={top:n.scrollTop,left:n.scrollLeft,topMax:n.scrollTopMax,leftMax:n.scrollLeftMax,height:n.scrollHeight,width:n.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:a.left,scrollTop:a.top,scrollLeftMax:a.leftMax,scrollTopMax:a.topMax,scrollWidth:a.width,scrollHeight:a.height,scroll:a},t.forEach(o,function(t){if(!(t in e.result))throw"No such measurement as "+t;e[t]=e.result[t]}),t.findNext(this,e)}}}}),e.addLeafExpression("closestExpr",function(e,t,n){if(n.matchToken("closest")){if(n.matchToken("parent"))var r=!0;var o=null;if("ATTRIBUTE_REF"===n.currentToken().type){var a=e.parseElement("attributeRefAccess",n,null);o="["+a.attribute.name+"]"}if(null==o){var i=e.parseElement("expression",n);null==i.css?e.raiseParseError(n,"Expected a CSS expression"):o=i.css}if(n.matchToken("to"))var u=e.parseElement("expression",n);else u=e.parseElement("implicitMeTarget",n);var s={type:"closestExpr",parentSearch:r,expr:i,css:o,to:u,args:[u],op:function(e,t){if(null!=t&&t instanceof Element){if(r)var n=t.parentElement?t.parentElement.closest(o):null;else n=t.closest(o);return n}return null},evaluate:function(e){return t.unifiedEval(this,e)}};return a?(a.root=s,a.args=[s],a):s}}),e.addCommand("go",function(e,t,n){if(n.matchToken("go")){if(n.matchToken("back"))var r=!0;else if(n.matchToken("to"),n.matchToken("url")){var o=e.requireElement("stringLike",n),a=!0;if(n.matchToken("in")){n.requireToken("new"),n.requireToken("window");var i=!0}}else{n.matchToken("the");var u=n.matchAnyToken("top","bottom","middle"),s=n.matchAnyToken("left","center","right");(u||s)&&n.requireToken("of"),o=e.requireElement("expression",n);var l=n.matchAnyToken("smoothly","instantly"),c={};u&&("top"===u.value?c.block="start":"bottom"===u.value?c.block="end":"middle"===u.value&&(c.block="center")),s&&("left"===s.value?c.inline="start":"center"===s.value?c.inline="center":"right"===s.value&&(c.inline="end")),l&&("smoothly"===l.value?c.behavior="smooth":"instantly"===l.value&&(c.behavior="instant"))}var f={target:o,args:[o],op:function(e,n){return r?window.history.back():a?n&&(0!==n.indexOf("#")||i?window.open(n,i?"_blank":null):window.location.href=n):t.forEach(n,function(e){e.scrollIntoView(c)}),t.findNext(f)}};return f}}),e.config.conversions.Values=function(t){var n={};return(0,e.internals.runtime.implicitLoop)(t,function(e){var t=o(e);void 0===t?null!=e.querySelectorAll&&e.querySelectorAll("input,select,textarea").forEach(r):n[t.name]=t.value}),n;function r(e){var t=o(e);null!=t&&(null!=n[t.name]?Array.isArray(n[t.name])&&Array.isArray(t.value)&&(n[t.name]=[].concat(n[t.name],t.value)):n[t.name]=t.value)}function o(e){try{var t={name:e.name,value:e.value};if(null==t.name||null==t.value)return;if("radio"==e.type&&0==e.checked)return;if("checkbox"==e.type&&(0==e.checked?t.value=void 0:"string"==typeof t.value&&(t.value=[t.value])),"select-multiple"==e.type){var n=e.querySelectorAll("option[selected]");t.value=[];for(var r=0;r<n.length;r++)t.value.push(n[r].value)}return t}catch(e){return}}},e.config.conversions.HTML=function(e){return function e(t){if(t instanceof Array)return t.map(function(t){return e(t)}).join("");if(t instanceof HTMLElement)return t.outerHTML;if(t instanceof NodeList){for(var n="",r=0;r<t.length;r++){var o=t[r];o instanceof HTMLElement&&(n+=o.outerHTML)}return n}return t.toString?t.toString():""}(e)},e.config.conversions.Fragment=function(t){var n=document.createDocumentFragment();return e.internals.runtime.implicitLoop(t,function(e){if(e instanceof Node)n.append(e);else{var t=document.createElement("template");t.innerHTML=e,n.append(t.content)}}),n}}(L),L});
  //# sourceMappingURL=_hyperscript_web.min.js.map
  