Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@webqit/subscript

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webqit/subscript - npm Package Compare versions

Comparing version 1.1.7 to 1.1.8

src/grammar/VariableDec.js

2

dist/main.js

@@ -1,2 +0,2 @@

!function(t){var e={};function r(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,s){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(s,n,function(e){return t[e]}.bind(null,n));return s},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([,function(t,e,r){"use strict";r.r(e);var s=function(t){return Array.isArray(t)},n=function(t){return"function"==typeof t},i=function(t){return n(t)||t&&"[object function]"==={}.toString.call(t)},o=function(t){return!Array.isArray(t)&&"object"==typeof t&&t},a=function(t){return Array.isArray(t)||"object"==typeof t&&t||n(t)},c=function(t){return t instanceof Number||"number"==typeof t},h=function(t){return c(t)||!0!==t&&!1!==t&&null!==t&&""!==t&&!isNaN(1*t)},l=function(t,e){var r=[];return function(t,e){e=(e=e||Object.prototype)&&!s(e)?[e]:e;var r=[];for(t=t;t&&(!e||e.indexOf(t)<0)&&"default"!==t.name;)r.push(t),t=t?Object.getPrototypeOf(t):null;return r}(t,e).forEach(t=>{!function(t,...e){e.forEach(e=>{t.indexOf(e)<0&&t.push(e)})}(r,...Object.getOwnPropertyNames(t))}),r};function u(t,e,r=!1,n=!1,c=!1){var p=0,f=t.shift();if((h(f)||!0===f||!1===f)&&(p=f,f=t.shift()),!t.length)throw new Error("_merge() requires two or more array/objects.");return t.forEach((t,g)=>{(a(t)||i(t))&&(r?l(t):Object.getOwnPropertyNames(t)).forEach(i=>{if(e(i,f,t,g)){var a=f[i],l=t[i];if((s(a)&&s(l)||o(a)&&o(l))&&(!0===p||p>0))f[i]=s(a)&&s(l)?[]:{},u([h(p)?p-1:p,f[i],a,l],e,r,n,c);else if(s(f)&&s(t))n?f[i]=l:f.push(l);else try{c?Object.defineProperty(f,i,Object.getOwnPropertyDescriptor(t,i)):f[i]=t[i]}catch(t){}}})}),f}var p=function(...t){return u(t,(t,e,r)=>!0,!1,!1,!1)},f=function(t){return null===t||""===t},g=function(t){return arguments.length&&(void 0===t||void 0===t)},m=function(t){return o(t)&&Object.getPrototypeOf(t)===Object.prototype},d=function(t){return!0===t||!1===t},v=function(t,e){var r=void 0;return a(t)&&Object.keys(t).forEach((s,n)=>{!1!==r&&(r=e(h(s)?parseFloat(s):s,t[s],n))}),r};const y=function(t,e,r=!0,n=1){if(s(t)&&s(e)&&t.length!==e.length)return!r;if(o(t)&&o(e)){var h=Object.keys(t),l=Object.keys(e);if(!h.length&&!l.length)return m(t)&&m(e)?r:t===e===r;if(!y(h,l))return!r}if(n>0&&(s(t)&&s(e)||o(t)&&o(e))){var u=function(t,e,r=!0,n=!0,i=!1,c=!1){if(s(t)&&s(e)){var h=[],l=!0;return t.forEach(t=>{if(l){var u=!1;v(e,(e,i)=>{(!u||n&&a(t))&&(u=r(t,i),(s(u)&&!u.length||o(u)&&!Object.keys(u).length)&&(u=!1),a(u)&&n&&(t=u))}),a(u)?h.push(n?u:t):d(u)?i&&!u||!i&&u?h.push(t):c&&(l=!1):h.push(u)}}),h}if(o(t)&&o(e)){h={},l=!0;return Object.keys(t).forEach(u=>{if(l){var p=r(t[u],e[u]);(s(p)&&!p.length||o(p)&&!Object.keys(p).length)&&(p=!1),a(p)?h[u]=n?p:t[u]:d(p)?i&&!p||!i&&p?h[u]=t[u]:c&&(l=!1):h[u]=p}}),h}}(t,e,(t,e)=>y(t,e,r,n-1),!1,!1,!0);return s(u)?u.length===t.length&&u.length===e.length:o(u)&&o(t)?Object.keys(u).length===Object.keys(t).length&&Object.keys(u).length===Object.keys(e).length:u}return i(r)?r(t,e):c(t)&&c(e)&&isNaN(t)&&isNaN(e)?r:t===e===r};var b=y,w=class{even(t){return!(!o(t)||t.jsenType!==this.jsenType)&&b(t,this)}inherit(t){return this}withComments(t){return this.meta||(this.meta={}),this.meta.comments=t,this}withVars(t){return this.meta||(this.meta={}),this.meta.vars=t,this}};const x=class extends w{};Object.defineProperty(x.prototype,"jsenType",{get:()=>"Reference"});var j=x;const k=class extends w{};Object.defineProperty(k.prototype,"jsenType",{get:()=>"CallExpression"});var O=k,E=class extends w{};const T=class extends w{};Object.defineProperty(T.prototype,"jsenType",{get:()=>"IfConstruct"});var S=T,$=class extends Error{constructor(...t){super(...t),this.name="Syntax Error"}};var P=function(t,e,r){return t.startsWith(e)&&t.endsWith(r)},C=function(t,e,r=!1){if(""==e)return t;var s=r?t.lastIndexOf(e):t.indexOf(e);return-1===s?"":t.substr(s+e.length)},_=function(t,e,r=!1){if(""==e)return t;var s=r?t.lastIndexOf(e):t.indexOf(e);return-1===s?t:t.substr(0,s)},W=function(t,e,r){return function(t,e){return _(t,e,!0)}(C(t,e),r)},A=function(t){return t instanceof String||"string"==typeof t&&null!==t},F=function(t,e=!0){return s(t)?t:!e&&o(t)?[t]:!1!==t&&0!==t&&function(t){return f(t)||g(t)||!1===t||0===t||a(t)&&!Object.keys(t).length}(t)?[]:function(t){return!A(t)&&!g(t.length)}(t)?Array.prototype.slice.call(t):o(t)?Object.values(t):[t]};const N=function(t,e=1,r=!0){return!h(e)||e<=0?t:(!s(t)&&o(t)&&r&&(t=Object.values(t)),s(t)?t.reduce((t,n)=>s(n)||o(n)&&r?t.concat(N(s(n)?n:Object.values(n),e-1,r)):t.concat(n),[]):t)};var D=N,q=function(t,e=1){var r=0;t.forEach(t=>{r++});var s=t.slice(t.length-r,e);return arguments.length>1?s:s[0]},I=function(t,e=1){return arguments.length>1?q(t.slice().reverse(),e).reverse():q(t.slice().reverse())},R=function(t,e=[]){return u([{},t],(t,r,n)=>{if(!i(n[t]))return i(e)?e(t):!s(e)||!e.length||e.indexOf(t)>-1},!1,!1,!1)};class L{static lex(t,e,r={}){if(!A(t+=""))throw new Error("Argument1 must be a string!");var s=t=>({delims:t.delims.slice(),options:R(t.options),nesting:t.nesting.slice(),maxDepth:t.maxDepth,comments:t.comments.slice(),tokens:t.tokens.slice(),matches:t.matches.slice(),matchesi:R(t.matchesi)});if(L.$cache[t]&&!1!==r.cache)for(var n=0;n<L.$cache[t].length;n++){var i=L.$cache[t][n];if(b(i.delims,e))return s(i)}var o=new L(t,r).lex(e);return!1!==r.cache&&(L.$cache[t]=L.$cache[t]||[],L.$cache[t].push(o)),s(o)}static split(t,e,r){return L.lex(t,e,r).tokens}static match(t,e,r){return L.lex(t,e,r).matches}constructor(t,e){if(!A(t))throw new Error("Lexer requires the first argument to be a string.");this.$str=t,this.$options=e||{},this.$options.blocks||(this.$options.blocks=L.$blocks),this.$options.quotes||(this.$options.quotes=L.$quotes),this.$options.comments||(this.$options.comments=L.$comments)}lex(t,e){for(var r={delims:F(t),options:p(!0,{},this.$options,e||{}),nesting:[],maxDepth:0,comments:[],tokens:[],matches:[],matchesi:{}},s=0;"number"==typeof s;)s=this._evalCharsAt(r,s);if(r.nesting.length)throw new Error("Error parsing the string: "+this.$str+". Unterminated blocks: "+D(r.nesting).join(", "));return r}_evalCharsAt(t,e){if(!(e>=this.$str.length)){var r=1,s={},n={},i={};if(t.openComment||(n=this._testQuotes(t,e)),t.openQuote||(s=this._testComments(t,e)),t.openComment||s.ending)if(t.nesting.length||i.ending)this._push(t,this.$str[e]);else r=(a=s.starting||s.ending||this.$str[e]).length,this._push(t,a,"comments",s.starting);else if(t.openQuote||n.ending)this._push(t,this.$str[e]);else{if(t.options.limit&&t.matches.length===t.options.limit)return this._push(t,this.$str[e]),e+1;i=this._testNesting(t,e);i=this._testNesting(t,e);var o=this._testChars(t.options.stopChars||[],t,e);if(!t.nesting.length&&!1!==o)return t.options.stopChar=o,void(t.options.stopCharForward=this.$str.substr(e));if(t.delims.length)if(t.nesting.length||i.ending){var a;r=(a=i.starting||i.ending||this.$str[e]).length,this._push(t,a)}else{this._push(t,"");var c=this._testChars(t.delims,t,e);if(!1!==c&&(t.matches.push(c),t.matchesi[e]=c,r=c.length||1,!t.options.preserveDelims)){var h=e+(c.length||1);return h===this.$str.length&&this._push(t,""),h}this._push(t,c||this.$str[e])}else 2===t.nesting.length&&i.starting?(t.matches.push(null),this._push(t,i.starting),r=i.starting.length):!t.nesting.length&&i.ending?(this._push(t,i.ending),r=i.ending.length,t.matches.push(null)):this._push(t,this.$str[e])}return e+r}}_testQuotes(t,e){var r={};return(t.options.quotes||[]).forEach(s=>{this.$str.substr(e,1)===s&&(t.openQuote?s===t.openQuote&&(t.openQuote=!1,r.ending=s):(t.openQuote=s,r.starting=s))}),r}_testComments(t,e){var r={};return(t.options.comments||[]).forEach(s=>{if(t.openComment){if(I(s)===I(t.openComment)){var n=I(s);this.$str.substr(e).startsWith(n)&&(t.openComment=!1,r.ending=n)}}else{var i=q(s);this.$str.substr(e).startsWith(i)&&(t.openComment=s,r.starting=i)}}),r}_testNesting(t,e){var r={};return(t.options.blocks||[]).forEach(s=>{var n=q(s);if(this.$str.substr(e).startsWith(n))t.nesting=t.nesting.concat([s]),r.starting=n;else if(t.nesting.length&&I(s)===I(I(t.nesting))){var i=I(s);this.$str.substr(e).startsWith(i)&&(t.nesting=t.nesting.slice(0,-1),r.ending=i)}}),t.maxDepth=Math.max(t.maxDepth,t.nesting.length),r}_testChars(t,e,r){for(var s=0;s<t.length;s++){var n=t[s];if(i(n)){var o=n(this.$str.substr(0,r),this.$str.substr(r));if(!1!==o)return o}if(e.options.useRegex){var a=this.$str.substr(r).match(new RegExp("^"+n,!0!==e.options.useRegex?e.options.useRegex:""));if(a)return a[0]}if(!e.options.ci&&this.$str.substr(r,n.length)===n||e.options.ci&&this.$str.substr(r,n.length).toLowerCase()===n.toLowerCase())return n}return!1}_push(t,e,r="tokens",s=!1){var n=t.matches.length;if(g(t.tokens[n])&&(t.tokens[n]=""),"comments"===r){t.tokens[n].comments||(t.tokens[n]=new String(t.tokens[n]),t.tokens[n].comments=[]);var i=t.tokens[n].comments.length-(!t.tokens[n].comments.length||s?0:1);t.tokens[n].comments[i]=(t.tokens[n].comments[i]||"")+e}else{t.tokens[n].comments;t.tokens[n]=t.tokens[n]+e}}split(t,e,r){return this.lex(e,r).tokens}match(t,e,r){return this.lex(e,r).matches}regParse(t,e){return this.lex(t,p({useRegex:!0},e||{}))}regSplit(t,e){return this.regParse(t,e).tokens}regMatch(t,e){return this.regParse(t,e).matches}}L.$blocks=[["(",")"],["[","]"],["{","}"]],L.$quotes=['"',"'","`"],L.$comments=[["/*","*/"],["//","\n"]],L.$cache=Object.create(null);const M=class extends w{};Object.defineProperty(M.prototype,"jsenType",{get:()=>"Abstraction"});const Q=class extends w{};Object.defineProperty(Q.prototype,"jsenType",{get:()=>"ArrayType"});var U=function(t){return t.filter((t,e,r)=>r.indexOf(t)===e)};const B=class extends w{};Object.defineProperty(B.prototype,"jsenType",{get:()=>"AssertionExpression"});var K=B;const V=class extends K{constructor(t,e){super(),this.exprs=t,this.logic=e}eval(t=null,e={}){var r=this.constructor;if(this.logic.toLowerCase()===r.negation.toLowerCase())return!q(this.exprs).eval(t,e);D(r.operators);for(var s=(this.logic||"").trim().toUpperCase(),n=s===(r.operators.or||"").trim().toUpperCase(),i=s===(r.operators.nor||"").trim().toUpperCase(),o=s===(r.operators.and||"").trim().toUpperCase(),a=s===(r.operators.nand||"").trim().toUpperCase(),c=!0,h=0,l=0;l<this.exprs.length;l++){if(c=this.exprs[l].eval(t,e),o&&!c)return!1;if(a&&!c)return!0;if(n&&c)return c;h+=c?1:0}return n?c:o||a?o:i&&0===h}toString(){return this.stringify()}stringify(t={}){var e=this.constructor;return this.logic.toLowerCase()===e.negation.toLowerCase()?this.logic+q(this.exprs).stringify(t):this.exprs.map(e=>e.stringify(t)).join(" "+this.logic.trim()+" ")}static parse(t,e,r={}){if(t.toUpperCase().startsWith(this.negation.toUpperCase()))return new this([e(t.substr(this.negation.length))],this.negation);var s=L.lex(t,D(this.operators));if(s.tokens.length>1){var n=U(s.matches);if(n.length>1)throw new Error('"AND" and "OR" logic cannot be asserted in the same expression: '+t+"!");return new this(s.tokens.map(t=>e(t.trim())),q(n))}}};V.negation="!",V.operators={and:"&&",or:"||"};const z=class extends w{};Object.defineProperty(z.prototype,"jsenType",{get:()=>"AssignmentExpression"});var G=z,X=class extends Error{constructor(...t){super(...t),this.name="Reference Error"}};const H=class extends G{constructor(t,e,r,s="=",n=!1){super(),this.initKeyword=t,this.reference=e,this.val=r,this.operator=s,this.postIncrDecr=n}eval(t=null,e={}){var r,n,i=this.reference.getEval(t,e);if(["++","--"].includes(this.operator)){if(n=this.reference.eval(t,e),!c(n))throw new Error(this.reference+" must be a number!");r="++"===this.operator?n+1:n-1}else if(["+=","-=","*=","/="].includes(this.operator)){var o=i.get(),a=this.val.eval(t,e);if(!("+="===this.operator||c(o)&&c(a)))throw new Error(this+" - operands must each be a number!");r="*="===this.operator?o*a:"/="===this.operator?o/a:"-="===this.operator?o-a:o+a}else r=this.val.eval(t,e);try{return i.set(r,this.initKeyword),e&&s(e.references)&&_pushUnique(e.references,this.reference.toString()),this.postIncrDecr?n:r}catch(t){throw t instanceof X?new X("["+this+"]: "+t.message):t}}toString(){return this.stringify()}stringify(t={}){return["++","--"].includes(this.operator)?this.postIncrDecr?this.reference.stringify(t)+this.operator:this.operator+this.reference.stringify(t):(this.initKeyword?this.initKeyword+" ":"")+[this.reference.stringify(t),this.operator.trim(),this.val.stringify(t)].join(" ")}static parse(t,e,r={}){var s=L.lex(t,this.operators.concat([J]));if(s.matches.length){var n,i,o,a,c=s.matches[0].trim(),h=["++","--"].includes(c);if(h?(a=t.trim().endsWith("++")||t.trim().endsWith("--"),i=s.tokens[a?"shift":"pop"]().trim()):(i=s.tokens.shift().trim(),o=s.tokens.shift().trim()),["var","let","const"].includes(_(i," "))){if("="!==c)throw new $("Invalid declaration: "+t);n=_(i," "),i=C(i," ").trim()}if(!((i=e(i,null,{role:"ASSIGNMENT_SPECIFIER"}))instanceof j)||!h&&!(o=e(o)))throw new $(t);return new this(n,i,o,c,a)}}};H.operators=["+=","-=","*=","/=","++","--"];const J=(t,e)=>!(t.endsWith("=")||!e.startsWith("=")||e.startsWith("=>")||e.startsWith("==")||e.startsWith("==="))&&"=";const Y=class extends w{};Object.defineProperty(Y.prototype,"jsenType",{get:()=>"BooleanType"});const Z=class extends w{};Object.defineProperty(Z.prototype,"jsenType",{get:()=>"Arguments"});const tt=class extends w{};Object.defineProperty(tt.prototype,"jsenType",{get:()=>"ComparisonExpression"});var et=tt;class rt extends et{constructor(t,e,r){super(),this.operand1=t,this.operand2=e,this.operator=r}eval(t=null,e={}){return this.constructor.compare(this.operand1.eval(t,e),this.operand2.eval(t,e),this.operator)}toString(){return this.stringify()}stringify(t={}){return[this.operand1.stringify(t),this.operator,this.operand2.stringify(t)].join(" ")}static parse(t,e,r={}){var s=D(this.operators).map(t=>" "+t+" "),n=L.lex(t,s);if(n.tokens.length>1){if(n.tokens.length>2)throw new Error('Malformed "Comparison" expression: '+t+"!");return new this(e(q(n.tokens).trim()),e(I(n.tokens).trim()),n.matches[0].trim())}}static compare(t,e,r="=="){if(-1===D(this.operators).indexOf(r))throw new Error('The operator "'+r+'" is not recognized.');switch(r){case"===":return t===e;case"==":case"=":return t==e;case">":return t>e;case"<":return t<e;case">=":return t>=e;case"<=":return t<=e;case"!=":return t!=e;case"<>":case"!==":return t!==e;case"^=":return A(t)&&t.startsWith(e);case"$=":return A(t)&&t.endsWith(e);case"*=":return!(!s(e)&&!A(e))&&t.indexOf(e)>-1;case"~=":return A(t)&&A(e)&&(" "+t+" ").indexOf(" "+e+" ")>-1;case">=<":if(!s(e)||2!==e.length)throw new Error("A 'Between' comparison requires argument 2 to be an array of exactly 2 values.");return t>=e[0]&&t<=e[1];case"/**/":return e.match(new RegExp(t));default:return!1}}static diff(t,e,r){return!this.compare(t,e,r?"===":"==")}}rt.operators={exact:{is:"===",isNull:"===",equalsTo:"==",strictlyNotEqualsTo:"!==",notEqualsTo:"!="},relative:{lesserThan:"<",greaterThan:">",lesserThanOrEqualsTo:"<=",greaterThanOrEqualsTo:">=",between:">=<"},partial:{startsWith:"^=",endsWith:"$=",contains:"*=",any:"~=",in:"~=",matches:"/**/"}};const st=class extends w{};Object.defineProperty(st.prototype,"jsenType",{get:()=>"TernaryConditional"});var nt=st;class it extends nt{constructor(t,e,r){super(),this.assertion=t,this.onTrue=e,this.onFalse=r}eval(t=null,e={}){return this.assertion.eval(t,e)?this.onTrue.eval(t,e):this.onFalse.eval(t,e)}toString(){return this.stringify()}stringify(t={}){return[this.assertion.stringify(t),this.constructor.operators[0],this.onTrue.stringify(t),this.constructor.operators[1],this.onFalse.stringify(t)].join(" ")}static parse(t,e,r={}){var s=L.split(t,this.operators);if(s.length>1){if(2===s.length)throw new Error("Malformed ternary expression: "+t+"!");return new this(e(s[0].trim()),e(s[1].trim()),e(s[2].trim()))}}}it.operators=["?",":"];const ot=class extends w{};Object.defineProperty(ot.prototype,"jsenType",{get:()=>"DeleteExpression"});var at=ot;const ct=class extends at{constructor(t,e="delete"){super(),this.reference=t,this.operator=e}eval(t=null,e={}){try{return this.reference.getEval(t,e).del()}catch(t){throw t instanceof X?new X("["+this+"]: "+t.message):t}}toString(){return this.stringify()}stringify(t={}){return this.operator+" "+this.reference.stringify(t)}static parse(t,e,r={}){var s=L.lex(t,Object.values(this.operators));if(1===s.matches.length&&t.startsWith(s.matches[0]+" ")){var n;if(!((n=e(s.tokens.pop().trim(),null,{role:"DELETION_SPECIFIER"}))instanceof j))throw new $(t);return new this(n,s.matches[0].trim())}}};ct.operators={red:"reduce",del:"delete"};const ht=class extends E{};Object.defineProperty(ht.prototype,"jsenType",{get:()=>"FunctionType"});var lt=ht;function ut(t,e,r=null,s=!1){var n=function(t,e,r=null,s=!1){return e.length>t.length?-1:("number"==typeof r?s?t.slice(0,r+1+(r<0?t.length:0)):t.slice(r):t).reduce((t,r,n)=>{var[i,o,a]=t;if(!s&&i>-1)return[i,o,a];var c=a+1,h=r===e[c]?0===c?[n,0]:[o,c]:[-1,-1];return h[1]===e.length-1&&(h[1]=-1,h[0]>-1)?[h[0]].concat(h):[i].concat(h)},[-1,-1,-1])[0]+(s||"number"!=typeof r?0:r>-1?r:t.length-r)}(t,e,r,s);return-1===n?[]:t.slice(n+e.length)}function pt(t,e,r=null){return r||!1!==r&&t.dotSafe&&e.dotSafe?(t.join(".")+".").startsWith(e.join(".")+"."):e.reduce((e,r,s)=>e&&r===t[s],!0)}const ft=class extends w{};Object.defineProperty(ft.prototype,"jsenType",{get:()=>"Block"});var gt=ft;const mt=class extends w{};Object.defineProperty(mt.prototype,"jsenType",{get:()=>"ReturnDirective"});var dt=mt;const vt=class extends w{};Object.defineProperty(vt.prototype,"jsenType",{get:()=>"NumberType"});var yt=vt;const bt=class extends w{};Object.defineProperty(bt.prototype,"jsenType",{get:()=>"StringType"});var wt=bt;function xt(t){return t.map(t=>{var e=t,r=[];r.dotSafe=!0;do{e instanceof O&&(r.splice(0),e=e.reference),A(e.name)?(r.unshift(e.name),r.dotSafe=r.dotSafe&&!e.name.includes(".")):e.name instanceof yt?(r.unshift(e.name.int),r.dotSafe=r.dotSafe&&!(e.name.int+"").includes(".")):e.name instanceof wt?(r.unshift(e.name.expr),r.dotSafe=r.dotSafe&&!e.name.expr.includes(".")):r.splice(0)}while(e=e.context);return r.dotSafe?(new jt).concat(r):r})}class jt extends Array{static resolve(t){return t.every(t=>!(t+"").includes("."))?(new jt).concat(t):t}get dotSafe(){return!0}}class kt{constructor(t,e={}){if(!("main"in t))throw new Error('A "main" context must be provided!');Object.defineProperty(this,"stack",{value:t||{},enumerable:!1}),Object.defineProperty(this,"params",{value:e||{},enumerable:!1}),t.super&&Object.defineProperty(this.stack,"super",{value:kt.create(t.super,{errorLevel:e.errorLevel}),enumerable:!1}),Object.defineProperty(this.stack,"local",{value:t.local||{},enumerable:!1}),Object.defineProperty(this.stack,"$local",{value:t.$local||{},enumerable:!1})}observe(t,e,r={}){this.stack.super&&this.stack.super.observe(t,r=>{if(r.props.filter(e=>!Et(this.stack.local,e,t)&&!Et(this.stack.main,e,t)).length)return r.scope="super",e(r)},r);var s={...r};s.subtree=s.subtree||!0,s.tags=(s.tags||[]).slice(0),s.tags.push(this,"jsen-context"),s.diff=!0,t.observe(this.stack,r=>{var s=[];if(r.forEach(t=>{if("main"===t.name)if(t.path.length>1)s.push(jt.resolve(t.path.slice(1)));else{var e=U((a(t.value)?Object.keys(t.value):[]).concat(t.oldValue&&a(t.oldValue)?Object.keys(t.oldValue):[]));s.push(...e.map(t=>jt.resolve([t])))}}),(s=s.filter(e=>!Et(this.stack.local,e[0],t))).length){var n=s.map(t=>t[0]);return e({props:n,references:s,scope:"local"})}},s)}unobserve(t,e={}){this.stack.super&&this.stack.super.unobserve(t,e);var r={...e};r.tags=(r.tags||[]).slice(0),r.tags.push(this,"jsen-context"),t.unobserve(this.stack,null,null,r)}handle(t,e,r,s=0){var n=()=>e(this.stack.main,null,()=>this.stack.super?this.stack.super.handle(t,e,r,s+1):r?r():void 0,s);return"toString"===t&&this.stack.local.toString===Object.prototype.toString?n():e(this.stack.local,this.stack.$local,n,s)}get(t,e={},r=!0){return t instanceof String&&(t+=""),this.handle(t,(s,o,a,c)=>{var h=Ot(s,t,e);return!g(h)||Et(s,t,e)?i(h)&&!function(t){return n(t)&&/^class\s?/.test(Function.prototype.toString.call(t))}(h)&&r?h.bind(s):h:a()})}set(t,e,r={},s=!1,n=!0){if(2===this.params.type&&"var"===s&&this.stack.super)return this.stack.super.set(t,e,r,s);t instanceof String&&(t+="");const i=(t,e,r,s)=>s.set?s.set(t,e,r):(t[e]=r,!0);return this.handle(!!s||t,(n,o,a,c)=>{if(o&&"const"===o[t])throw new LogicalError("CONST "+t+" cannot be modified!");if(s)return o[t]=s,i(n,t,e,r);if(Et(n,t,r))return i(n,t,e,r);try{return a()}catch(s){if(s instanceof X&&n&&!o&&0===c&&!1===this.params.strictMode)return i(n,t,e,r);throw s}},()=>{throw new X('"'+t+'" does not exist in scope!')})}del(t,e={}){return t instanceof String&&(t+=""),this.handle(t,(r,s,n)=>Et(r,t,e)?(s&&delete s[t],e.deleteProperty||e.del?(e.deleteProperty||e.del)(r,t):(delete r[t],!0)):n())}has(t,e,r={}){return t instanceof String&&(t+=""),e instanceof String&&(e+=""),this.handle(t,(s,n,i)=>{if(Et(s,t,r)){var o=Ot(s,t,r);return Et(o,e,r)}return i()},()=>{throw new X('"'+t+'" is undefined!')})}exec(t,e,r={}){return t instanceof String&&(t+=""),this.handle(t,(s,n,o)=>{var a=Ot(s,t,r);if(!g(a)||Et(s,t,r)){if(!i(a)){if(r.exec)return r.exec(s,t,e);throw new X('"'+t+'" is not a function! (Called on type: '+typeof s+".)")}return r.apply?r.apply(a,s,e):a.apply(s,e)}return o()},()=>{if(r.execUnknown)return r.execUnknown(this,t,e);throw new X('"'+t+'()" is undefined!')})}static create(t,e={},r={}){if(t instanceof kt)return t;var s={};return r.set?r.set(s,"main",t):s.main=t,new kt(s,e)}static createStack(t,e={},r={}){return t.reverse().reduce((t,s,n)=>{if(s instanceof kt){if(0===n)return s;throw new Error("Only the top-most context is allowed to be an instance of Scope.")}var i={};return r.set?r.set(i,"main",s):i.main=s,i.super=t,new kt(i,e)},null)}}const Ot=(t,e,r)=>{if(!f(t)&&!g(t))return r.get&&a(t)?r.get(t,e):t[e]},Et=(t,e,r)=>!f(t)&&!g(t)&&(r.has&&a(t)?r.has(t,e):a(t)?e in t:!g(t[e]));class Tt extends gt{constructor(t,e){super(),this.stmts=t||[],this.delim=e}eval(t=null,e={}){var r,s=(e={...e}).returnCallback;e.returnCallback=t=>{r=t},t=kt.create(t);for(var n=(t,e,r)=>{try{return t.eval(e,r)}catch(t){r.catch&&r.catch(t)}},i=[],o=0;o<this.stmts.length;o++){var a=this.stmts[o],c=St(a),h=St(a,!0),l=(e.references||[]).filter(t=>c.filter(e=>pt(e,t)).length),u=(e.references||[]).filter(t=>h.filter(e=>pt(e,t)).length),p=!e.references||!e.references.length||(l=l.length)||(u=u.length);e.references&&2===t.params.type&&a instanceof G&&a.initKeyword;if(p){var f=e;if(l&&delete(f={...e}).references,i[o]=n(a,t,f),a instanceof dt||r)return s&&s(!0),i[o];(a instanceof S&&a.abortive||!1===r)&&(!0,s&&s(!1)),e.references&&(a instanceof G||a instanceof at)&&(e.references=e.references.concat(xt([a.reference])))}else if(e.references&&a instanceof G&&a.val instanceof j){e.references=e.references.slice(0);let t=xt([a.reference])[0],r=xt([a.val])[0];e.references.forEach(s=>{pt(s,r)&&e.references.push(t.concat(ut(s,r)))})}}return i}toString(){return this.stringify()}stringify(t={}){return this.stmts.map(e=>e.stringify(t)).join(this.delim)}static parse(t,e,r={}){var s=L.lex(t+";",D(this.operators).concat([Tt.testBlockEnd]));if(s.matches.length)return new this(s.tokens.map(t=>e(t.trim())).filter(t=>t),s.matches[0].trim())}static testBlockEnd(t,e){return!(!t.endsWith("}")||e.trim().startsWith("else"))&&""}}Tt.operators=[";","\r\n"];const St=(t,e=!1)=>(t.$readPaths||(t.$readPaths=xt(t.meta.reads||[]),t.$deepReadPaths=xt(t.meta.deep.reads||[])),e?t.$deepReadPaths:t.$readPaths),$t=class extends lt{constructor(t,e,r={}){super(),this.paramters=t||{},this.statements=e,this.statements.isIndependent=!0,this.arrowFunctionFormatting=r}inherit(t){if(t instanceof lt){for(var e=Object.keys(t.paramters),r=Object.keys(this.paramters),s=0;s<Math.max(r.length,e.length);s++){var n=e[s],i=r[s];if(!i&&n)throw new Error("Parameter #"+s+" ("+n+") in parent function must be implemented.");if(i&&n){var o=t.paramters[n],a=this.paramters[i];if(a&&!o)throw new Error("Parameter #"+s+" ("+i+") must not have a default value as established in parent function.");if(a&&o&&a.jsenType!==o.jsenType)throw new Error("Default value for parameter #"+s+" ("+i+") must be of type "+o.jsenType+" as established in parent function.")}}this.sup=t}return this}eval(t=null,e={}){var r=this;return delete(e={...e}).returnCallback,function(...s){var n={};v(Object.keys(r.paramters),(i,o)=>{var a=r.paramters[o];if(s.length-1<i&&!a)throw new Error('The parameter "'+o+'" is required.');n[o]=s.length>i?s[i]:r.paramters[o]?r.paramters[o].eval(t,e):null}),r.arrowFunctionFormatting||(n.this=this);var i=t instanceof kt?t.params.errorLevel:void 0,o=new kt({main:n,super:t},{errorLevel:i}),a=r.statements.eval(o,e);return!1===r.arrowFunctionFormatting.body?a[0]:a}}toString(){return this.stringify()}stringify(t={}){var e=[];if(v(this.paramters,(r,s)=>{e.push(r+(s?"="+s.stringify(t):""))}),this.arrowFunctionFormatting){var r=!1===this.arrowFunctionFormatting.head||1===e.length&&-1===e[0].indexOf("="),s=!1===this.arrowFunctionFormatting.body;return(r?e[0]:"("+e.join(", ")+")")+" => "+(s?this.statements.stringify(t):"{"+this.statements.stringify(t)+"}")}return"function ("+e.join(", ")+") {"+this.statements.stringify(t)+"}"}static parse(t,e,r={}){var s;if((t=t.trim()).startsWith("function")&&(s=L.split(t,[]).slice(1).filter(t=>t.trim()))&&2===s.length)var n=!1,i=W(s.shift().trim(),"(",")"),o=W(s.shift().trim(),"{","}");else{if(t.startsWith("function")||!(s=L.split(t,["=>"]))||2!==s.length)return;i=s.shift().trim(),o=s.shift().trim(),n={};P(i,"(",")")?i=W(i,"(",")"):n.head=!1,P(o,"{","}")?o=W(o,"{","}"):n.body=!1}var a={};L.split(i,[","]).forEach(t=>{var r=t.split("=");r[1]?a[r[0].trim()]=e(r[1].trim(),null,{meta:null}):a[t.trim()]=null});var c=e(o,[Tt],{assert:!1})||e(o,null,{meta:null});return new this(a,"Block"===c.jsenType?c:new Tt([c]),n)}};$t.operators=["=>"];var Pt=function(t,e,r=null){return s(e)?t.filter(t=>r?e.filter(e=>r(t,e)).length:-1!==e.indexOf(t)):[]};const Ct=class extends w{};Object.defineProperty(Ct.prototype,"jsenType",{get:()=>"MathExpression"});var _t=Ct;const Wt=class extends _t{constructor(t,e){super(),this.val=t,this.exprs=e}eval(t=null,e={}){return this.exprs.reduce((r,s)=>{var n=s.val.eval(t,e),i=s.operator.trim();if(!(h(r)&&h(n)||"+"===i))throw new Error("Invalid Math expression: "+this.toString()+"!");switch(i){case"+":return r+n;case"-":return r-n;case"*":return r*n;case"/":return r/n}},this.val.eval(t,e))}toString(){return this.stringify()}stringify(t={}){return[this.val.stringify(t)].concat(this.exprs.map(e=>e.operator+" "+e.val.stringify(t))).join(" ")}static parse(t,e,r={}){var s=L.lex(t,D(this.operators));if(s.tokens.filter(t=>t).length>1&&s.matches.length===s.tokens.length-1){var n=U(s.matches);if(Pt(n,this.operators.sup).length&&Pt(n,this.operators.sub).length)throw new Error('"Addition/subtraction" and "multiplication/division" operators cannot be used in the same expression: '+t+"!");return new this(e(s.tokens.shift().trim()),s.tokens.map((t,r)=>({operator:s.matches[r],val:e(t.trim())})))}}};Wt.operators={sup:["*","/"],sub:["+","-"]};const At=class extends w{};Object.defineProperty(At.prototype,"jsenType",{get:()=>"ObjectType"});var Ft=At;const Nt=class extends Ft{constructor(t){super(),this.entries=t||{}}inherit(t){return t instanceof Ft&&v(t.entries,(t,e)=>{t in this.entries||(this.entries[t]=e)}),this}eval(t=null,e={}){var r={};return v(this.entries,(s,n)=>{r[s]=n.eval(t,e)}),r}toString(){return this.stringify()}stringify(t={}){var e=[];return v(this.entries,(r,s)=>{e.push(r+Nt.operators.sub+s.stringify(t))}),"{"+e.join(Nt.operators.sup)+"}"}static parse(t,e,r={}){if(P(t,"{","}")&&!L.match(t.trim(),[" "]).length){var s={},n=L.split(W(t,"{","}"),[Nt.operators.sup]).map(t=>t.trim()).filter(t=>t);return v(n,(t,r)=>{var n=L.split(r,[Nt.operators.sub],{limit:1});s[q(n).trim()]=e(I(n).trim())}),new this(s)}}};Nt.operators={sup:",",sub:":"};const Dt=class extends w{};Object.defineProperty(Dt.prototype,"jsenType",{get:()=>"PresenceOperator"});var qt=Dt;const It=class extends qt{constructor(t,e,r="in"){super(),this.prop=t,this.reference=e,this.operator=r}eval(t=null,e={}){var r=this.prop.eval(t,e);try{return this.reference.getEval(t,e).has(r)}catch(t){throw t instanceof X?new X("["+this+"]: "+t.message):t}}toString(){return this.stringify()}stringify(t={}){return[this.prop.stringify(t),this.operator,this.reference.stringify(t)].join(" ")}static parse(t,e,r={}){var s=L.lex(t,this.operators);if(2===s.tokens.length){var n,i;if(!((n=e(s.tokens.shift().trim()))&&(i=e(s.tokens.shift().trim()))instanceof j))throw new $(t);return new this(n,i,s.matches[0].trim())}}};It.operators=[" in "];class Rt extends j{constructor(t,e,r=!1){super(),this.context=t,this.name=e,this.backticks=r}getEval(t=null,e={}){var r=t,s=this.name;this.context&&(s instanceof w&&(s=s.eval(t,e)),r=this.context.eval(t,e));var n=!this.context;return{get:()=>kt.create(r,e).get(s,e.trap),del:()=>kt.create(r,e).del(s,e.trap),has:t=>kt.create(r,e).has(s,t,e.trap),set:(t,i=null)=>kt.create(r,e).set(s,t,e.trap,i,n),exec:t=>kt.create(r,e).exec(s,t,e.trap)}}eval(t=null,e={}){try{return this.getEval(t,e).get()}catch(t){throw t instanceof X?new X("["+this+"]: "+t.message):t}}toString(){return this.stringify()}stringify(t={}){var e=this.name;if(this.context){var r=this.context.stringify(t);e instanceof w?e="["+e.stringify(t)+"]":this.backticks&&(e="`"+e+"`")}else{r=t.context;this.backticks&&(e="`"+e+"`")}return(r||"")+(r&&!e.startsWith("[")?Rt.separator:"")+e}static parse(t,e,r={}){if(!L.match(t.trim(),[" "]).length){var s,n,i=L.split(t,[]),o=i.pop(),a=L.split(o.trim(),[this.separator],{preserveDelims:!0});if(a.length>1&&(o=a.pop().substr(1),i=i.concat(a)),P(o,"`","`")&&(o=W(o,"`","`"),n=!0),i.length&&(s=e(i.join(""),null,{role:"CONTEXT"})),P(o,"[","]")){if(!s)throw new $(t);o=e(W(o,"[","]"))}return new this(s,o,n)}}}Rt.separator=".";const Lt=class extends w{};Object.defineProperty(Lt.prototype,"jsenType",{get:()=>"Void"});window.WebQit||(window.WebQit={}),window.WebQit.Subscript=void 0}]);
!function(t){var e={};function r(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,s){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(s,n,function(e){return t[e]}.bind(null,n));return s},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([,function(t,e,r){"use strict";r.r(e);var s=function(t){return Array.isArray(t)},n=function(t){return"function"==typeof t},i=function(t){return n(t)||t&&"[object function]"==={}.toString.call(t)},o=function(t){return!Array.isArray(t)&&"object"==typeof t&&t},a=function(t){return Array.isArray(t)||"object"==typeof t&&t||n(t)},c=function(t){return t instanceof Number||"number"==typeof t},h=function(t){return c(t)||!0!==t&&!1!==t&&null!==t&&""!==t&&!isNaN(1*t)},l=function(t,e){var r=[];return function(t,e){e=(e=e||Object.prototype)&&!s(e)?[e]:e;var r=[];for(t=t;t&&(!e||e.indexOf(t)<0)&&"default"!==t.name;)r.push(t),t=t?Object.getPrototypeOf(t):null;return r}(t,e).forEach(t=>{!function(t,...e){e.forEach(e=>{t.indexOf(e)<0&&t.push(e)})}(r,...Object.getOwnPropertyNames(t))}),r};function u(t,e,r=!1,n=!1,c=!1){var p=0,f=t.shift();if((h(f)||!0===f||!1===f)&&(p=f,f=t.shift()),!t.length)throw new Error("_merge() requires two or more array/objects.");return t.forEach((t,g)=>{(a(t)||i(t))&&(r?l(t):Object.getOwnPropertyNames(t)).forEach(i=>{if(e(i,f,t,g)){var a=f[i],l=t[i];if((s(a)&&s(l)||o(a)&&o(l))&&(!0===p||p>0))f[i]=s(a)&&s(l)?[]:{},u([h(p)?p-1:p,f[i],a,l],e,r,n,c);else if(s(f)&&s(t))n?f[i]=l:f.push(l);else try{c?Object.defineProperty(f,i,Object.getOwnPropertyDescriptor(t,i)):f[i]=t[i]}catch(t){}}})}),f}var p=function(...t){return u(t,(t,e,r)=>!0,!1,!1,!1)},f=function(t){return null===t||""===t},g=function(t){return arguments.length&&(void 0===t||void 0===t)},m=function(t){return o(t)&&Object.getPrototypeOf(t)===Object.prototype},d=function(t){return!0===t||!1===t},v=function(t,e){var r=void 0;return a(t)&&Object.keys(t).forEach((s,n)=>{!1!==r&&(r=e(h(s)?parseFloat(s):s,t[s],n))}),r};const y=function(t,e,r=!0,n=1){if(s(t)&&s(e)&&t.length!==e.length)return!r;if(o(t)&&o(e)){var h=Object.keys(t),l=Object.keys(e);if(!h.length&&!l.length)return m(t)&&m(e)?r:t===e===r;if(!y(h,l))return!r}if(n>0&&(s(t)&&s(e)||o(t)&&o(e))){var u=function(t,e,r=!0,n=!0,i=!1,c=!1){if(s(t)&&s(e)){var h=[],l=!0;return t.forEach(t=>{if(l){var u=!1;v(e,(e,i)=>{(!u||n&&a(t))&&(u=r(t,i),(s(u)&&!u.length||o(u)&&!Object.keys(u).length)&&(u=!1),a(u)&&n&&(t=u))}),a(u)?h.push(n?u:t):d(u)?i&&!u||!i&&u?h.push(t):c&&(l=!1):h.push(u)}}),h}if(o(t)&&o(e)){h={},l=!0;return Object.keys(t).forEach(u=>{if(l){var p=r(t[u],e[u]);(s(p)&&!p.length||o(p)&&!Object.keys(p).length)&&(p=!1),a(p)?h[u]=n?p:t[u]:d(p)?i&&!p||!i&&p?h[u]=t[u]:c&&(l=!1):h[u]=p}}),h}}(t,e,(t,e)=>y(t,e,r,n-1),!1,!1,!0);return s(u)?u.length===t.length&&u.length===e.length:o(u)&&o(t)?Object.keys(u).length===Object.keys(t).length&&Object.keys(u).length===Object.keys(e).length:u}return i(r)?r(t,e):c(t)&&c(e)&&isNaN(t)&&isNaN(e)?r:t===e===r};var b=y,x=class{even(t){return!(!o(t)||t.jsenType!==this.jsenType)&&b(t,this)}inherit(t){return this}withComments(t){return this.meta||(this.meta={}),this.meta.comments=t,this}withVars(t){return this.meta||(this.meta={}),this.meta.vars=t,this}};const w=class extends x{};Object.defineProperty(w.prototype,"jsenType",{get:()=>"Reference"});var j=w;const k=class extends x{};Object.defineProperty(k.prototype,"jsenType",{get:()=>"CallExpression"});var O=k,E=class extends x{};const T=class extends x{};Object.defineProperty(T.prototype,"jsenType",{get:()=>"IfConstruct"});var P=T,S=class extends Error{constructor(...t){super(...t),this.name="Syntax Error"}};var $=function(t,e,r){return t.startsWith(e)&&t.endsWith(r)},C=function(t,e,r=!1){if(""==e)return t;var s=r?t.lastIndexOf(e):t.indexOf(e);return-1===s?"":t.substr(s+e.length)},W=function(t,e,r){return function(t,e){return function(t,e,r=!1){if(""==e)return t;var s=r?t.lastIndexOf(e):t.indexOf(e);return-1===s?t:t.substr(0,s)}(t,e,!0)}(C(t,e),r)},_=function(t){return t instanceof String||"string"==typeof t&&null!==t},A=function(t,e=!0){return s(t)?t:!e&&o(t)?[t]:!1!==t&&0!==t&&function(t){return f(t)||g(t)||!1===t||0===t||a(t)&&!Object.keys(t).length}(t)?[]:function(t){return!_(t)&&!g(t.length)}(t)?Array.prototype.slice.call(t):o(t)?Object.values(t):[t]};const F=function(t,e=1,r=!0){return!h(e)||e<=0?t:(!s(t)&&o(t)&&r&&(t=Object.values(t)),s(t)?t.reduce((t,n)=>s(n)||o(n)&&r?t.concat(F(s(n)?n:Object.values(n),e-1,r)):t.concat(n),[]):t)};var N=F,D=function(t,e=1){var r=0;t.forEach(t=>{r++});var s=t.slice(t.length-r,e);return arguments.length>1?s:s[0]},M=function(t,e=1){return arguments.length>1?D(t.slice().reverse(),e).reverse():D(t.slice().reverse())},q=function(t,e=[]){return u([{},t],(t,r,n)=>{if(!i(n[t]))return i(e)?e(t):!s(e)||!e.length||e.indexOf(t)>-1},!1,!1,!1)};class I{static lex(t,e,r={}){if(!_(t+=""))throw new Error("Argument1 must be a string!");var s=t=>({delims:t.delims.slice(),options:q(t.options),nesting:t.nesting.slice(),maxDepth:t.maxDepth,comments:t.comments.slice(),tokens:t.tokens.slice(),matches:t.matches.slice(),matchesi:q(t.matchesi)});if(I.$cache[t]&&!1!==r.cache)for(var n=0;n<I.$cache[t].length;n++){var i=I.$cache[t][n];if(b(i.delims,e))return s(i)}var o=new I(t,r).lex(e);return!1!==r.cache&&(I.$cache[t]=I.$cache[t]||[],I.$cache[t].push(o)),s(o)}static split(t,e,r){return I.lex(t,e,r).tokens}static match(t,e,r){return I.lex(t,e,r).matches}constructor(t,e){if(!_(t))throw new Error("Lexer requires the first argument to be a string.");this.$str=t,this.$options=e||{},this.$options.blocks||(this.$options.blocks=I.$blocks),this.$options.quotes||(this.$options.quotes=I.$quotes),this.$options.comments||(this.$options.comments=I.$comments)}lex(t,e){for(var r={delims:A(t),options:p(!0,{},this.$options,e||{}),nesting:[],maxDepth:0,comments:[],tokens:[],matches:[],matchesi:{}},s=0;"number"==typeof s;)s=this._evalCharsAt(r,s);if(r.nesting.length)throw new Error("Error parsing the string: "+this.$str+". Unterminated blocks: "+N(r.nesting).join(", "));return r}_evalCharsAt(t,e){if(!(e>=this.$str.length)){var r=1,s={},n={},i={};if(t.openComment||(n=this._testQuotes(t,e)),t.openQuote||(s=this._testComments(t,e)),t.openComment||s.ending)if(t.nesting.length||i.ending)this._push(t,this.$str[e]);else r=(a=s.starting||s.ending||this.$str[e]).length,this._push(t,a,"comments",s.starting);else if(t.openQuote||n.ending)this._push(t,this.$str[e]);else{if(t.options.limit&&t.matches.length===t.options.limit)return this._push(t,this.$str[e]),e+1;i=this._testNesting(t,e);i=this._testNesting(t,e);var o=this._testChars(t.options.stopChars||[],t,e);if(!t.nesting.length&&!1!==o)return t.options.stopChar=o,void(t.options.stopCharForward=this.$str.substr(e));if(t.delims.length)if(t.nesting.length||i.ending){var a;r=(a=i.starting||i.ending||this.$str[e]).length,this._push(t,a)}else{this._push(t,"");var c=this._testChars(t.delims,t,e);if(!1!==c&&(t.matches.push(c),t.matchesi[e]=c,r=c.length||1,!t.options.preserveDelims)){var h=e+(c.length||1);return h===this.$str.length&&this._push(t,""),h}this._push(t,c||this.$str[e])}else 2===t.nesting.length&&i.starting?(t.matches.push(null),this._push(t,i.starting),r=i.starting.length):!t.nesting.length&&i.ending?(this._push(t,i.ending),r=i.ending.length,t.matches.push(null)):this._push(t,this.$str[e])}return e+r}}_testQuotes(t,e){var r={};return(t.options.quotes||[]).forEach(s=>{this.$str.substr(e,1)===s&&(t.openQuote?s===t.openQuote&&(t.openQuote=!1,r.ending=s):(t.openQuote=s,r.starting=s))}),r}_testComments(t,e){var r={};return(t.options.comments||[]).forEach(s=>{if(t.openComment){if(M(s)===M(t.openComment)){var n=M(s);this.$str.substr(e).startsWith(n)&&(t.openComment=!1,r.ending=n)}}else{var i=D(s);this.$str.substr(e).startsWith(i)&&(t.openComment=s,r.starting=i)}}),r}_testNesting(t,e){var r={};return(t.options.blocks||[]).forEach(s=>{var n=D(s);if(this.$str.substr(e).startsWith(n))t.nesting=t.nesting.concat([s]),r.starting=n;else if(t.nesting.length&&M(s)===M(M(t.nesting))){var i=M(s);this.$str.substr(e).startsWith(i)&&(t.nesting=t.nesting.slice(0,-1),r.ending=i)}}),t.maxDepth=Math.max(t.maxDepth,t.nesting.length),r}_testChars(t,e,r){for(var s=0;s<t.length;s++){var n=t[s];if(i(n)){var o=n(this.$str.substr(0,r),this.$str.substr(r),e.tokens.slice());if(!1!==o)return o}if(e.options.useRegex){var a=this.$str.substr(r).match(new RegExp("^"+n,!0!==e.options.useRegex?e.options.useRegex:""));if(a)return a[0]}if(!e.options.ci&&this.$str.substr(r,n.length)===n||e.options.ci&&this.$str.substr(r,n.length).toLowerCase()===n.toLowerCase())return n}return!1}_push(t,e,r="tokens",s=!1){var n=t.matches.length;if(g(t.tokens[n])&&(t.tokens[n]=""),"comments"===r){t.tokens[n].comments||(t.tokens[n]=new String(t.tokens[n]),t.tokens[n].comments=[]);var i=t.tokens[n].comments.length-(!t.tokens[n].comments.length||s?0:1);t.tokens[n].comments[i]=(t.tokens[n].comments[i]||"")+e}else{t.tokens[n].comments;t.tokens[n]=t.tokens[n]+e}}split(t,e,r){return this.lex(e,r).tokens}match(t,e,r){return this.lex(e,r).matches}regParse(t,e){return this.lex(t,p({useRegex:!0},e||{}))}regSplit(t,e){return this.regParse(t,e).tokens}regMatch(t,e){return this.regParse(t,e).matches}}I.$blocks=[["(",")"],["[","]"],["{","}"]],I.$quotes=['"',"'","`"],I.$comments=[["/*","*/"],["//","\n"]],I.$cache=Object.create(null);const R=class extends x{};Object.defineProperty(R.prototype,"jsenType",{get:()=>"Abstraction"});function L(t,e,r=null,s=!1){var n=function(t,e,r=null,s=!1){return e.length>t.length?-1:("number"==typeof r?s?t.slice(0,r+1+(r<0?t.length:0)):t.slice(r):t).reduce((t,r,n)=>{var[i,o,a]=t;if(!s&&i>-1)return[i,o,a];var c=a+1,h=r===e[c]?0===c?[n,0]:[o,c]:[-1,-1];return h[1]===e.length-1&&(h[1]=-1,h[0]>-1)?[h[0]].concat(h):[i].concat(h)},[-1,-1,-1])[0]+(s||"number"!=typeof r?0:r>-1?r:t.length-r)}(t,e,r,s);return-1===n?[]:t.slice(n+e.length)}function Q(t,e,r=null){return r||!1!==r&&t.dotSafe&&e.dotSafe?(t.join(".")+".").startsWith(e.join(".")+"."):e.reduce((e,r,s)=>e&&r===t[s],!0)}const U=class extends x{};Object.defineProperty(U.prototype,"jsenType",{get:()=>"Block"});var B=U;const V=class extends x{};Object.defineProperty(V.prototype,"jsenType",{get:()=>"ReturnDirective"});var K=V;const z=class extends x{};Object.defineProperty(z.prototype,"jsenType",{get:()=>"AssignmentExpression"});var G=z;const X=class extends x{};Object.defineProperty(X.prototype,"jsenType",{get:()=>"DeleteExpression"});var H=X;const J=class extends x{};Object.defineProperty(J.prototype,"jsenType",{get:()=>"VariableDeclarations"});var Y=J;const Z=class extends x{};Object.defineProperty(Z.prototype,"jsenType",{get:()=>"NumberType"});var tt=Z;const et=class extends x{};Object.defineProperty(et.prototype,"jsenType",{get:()=>"StringType"});var rt=et;function st(t){return t.map(t=>{var e=t,r=[];r.dotSafe=!0;do{e instanceof O&&(r.splice(0),e=e.reference),_(e.name)?(r.unshift(e.name),r.dotSafe=r.dotSafe&&!e.name.includes(".")):e.name instanceof tt?(r.unshift(e.name.int),r.dotSafe=r.dotSafe&&!(e.name.int+"").includes(".")):e.name instanceof rt?(r.unshift(e.name.expr),r.dotSafe=r.dotSafe&&!e.name.expr.includes(".")):r.splice(0)}while(e=e.context);return r.dotSafe?(new nt).concat(r):r})}class nt extends Array{static resolve(t){return t.every(t=>!(t+"").includes("."))?(new nt).concat(t):t}get dotSafe(){return!0}}var it=function(t){return t.filter((t,e,r)=>r.indexOf(t)===e)},ot=class extends Error{constructor(...t){super(...t),this.name="Reference Error"}};class at{constructor(t,e={}){if(!("main"in t))throw new Error('A "main" context must be provided!');Object.defineProperty(this,"stack",{value:t||{},enumerable:!1}),Object.defineProperty(this,"params",{value:e||{},enumerable:!1}),t.super&&Object.defineProperty(this.stack,"super",{value:at.create(t.super,{errorLevel:e.errorLevel}),enumerable:!1}),Object.defineProperty(this.stack,"local",{value:t.local||{},enumerable:!1}),Object.defineProperty(this.stack,"$local",{value:t.$local||{},enumerable:!1})}observe(t,e,r={}){this.stack.super&&this.stack.super.observe(t,r=>{if(r.props.filter(e=>!ht(this.stack.local,e,t)&&!ht(this.stack.main,e,t)).length)return r.scope="super",e(r)},r);var s={...r};s.subtree=s.subtree||!0,s.tags=(s.tags||[]).slice(0),s.tags.push(this,"jsen-context"),s.diff=!0,t.observe(this.stack,r=>{var s=[];if(r.forEach(t=>{if("main"===t.name)if(t.path.length>1)s.push(nt.resolve(t.path.slice(1)));else{var e=it((a(t.value)?Object.keys(t.value):[]).concat(t.oldValue&&a(t.oldValue)?Object.keys(t.oldValue):[]));s.push(...e.map(t=>nt.resolve([t])))}}),(s=s.filter(e=>!ht(this.stack.local,e[0],t))).length){var n=s.map(t=>t[0]);return e({props:n,references:s,scope:"local"})}},s)}unobserve(t,e={}){this.stack.super&&this.stack.super.unobserve(t,e);var r={...e};r.tags=(r.tags||[]).slice(0),r.tags.push(this,"jsen-context"),t.unobserve(this.stack,null,null,r)}handle(t,e,r,s=0){var n=()=>e(this.stack.main,null,()=>this.stack.super?this.stack.super.handle(t,e,r,s+1):r?r():void 0,s);return"toString"===t&&this.stack.local.toString===Object.prototype.toString?n():e(this.stack.local,this.stack.$local,n,s)}get(t,e={},r=!0){return t instanceof String&&(t+=""),this.handle(t,(s,o,a,c)=>{var h=ct(s,t,e);return!g(h)||ht(s,t,e)?i(h)&&!function(t){return n(t)&&/^class\s?/.test(Function.prototype.toString.call(t))}(h)&&r?h.bind(s):h:a()})}set(t,e,r={},s=!1,n=!0){if(2===this.params.scopeType&&"var"===s&&this.stack.super)return this.stack.super.set(t,e,r,s);t instanceof String&&(t+="");const i=(t,e,r,s)=>s.set?s.set(t,e,r):(t[e]=r,!0);return this.handle(!!s||t,(o,a,c,h)=>{if(a&&"const"===a[t])throw new LogicalError("CONST "+t+" cannot be modified!");if(s)return a[t]=s,i(o,t,e,r);if(ht(o,t,r))return i(o,t,e,r);try{return c()}catch(s){if(s instanceof ot&&o&&(!n||!1===this.params.strictMode)&&!a&&0===h)return i(o,t,e,r);throw s}},()=>{throw new ot('"'+t+'" does not exist in scope!')})}del(t,e={}){return t instanceof String&&(t+=""),this.handle(t,(r,s,n)=>ht(r,t,e)?(s&&delete s[t],e.deleteProperty||e.del?(e.deleteProperty||e.del)(r,t):(delete r[t],!0)):n())}has(t,e,r={}){return t instanceof String&&(t+=""),e instanceof String&&(e+=""),this.handle(t,(s,n,i)=>{if(ht(s,t,r)){var o=ct(s,t,r);return ht(o,e,r)}return i()},()=>{throw new ot('"'+t+'" is undefined!')})}exec(t,e,r={}){return t instanceof String&&(t+=""),this.handle(t,(s,n,o)=>{var a=ct(s,t,r);if(!g(a)||ht(s,t,r)){if(!i(a)){if(r.exec)return r.exec(s,t,e);throw new ot('"'+t+'" is not a function! (Called on type: '+typeof s+".)")}return r.apply?r.apply(a,s,e):a.apply(s,e)}return o()},()=>{if(r.execUnknown)return r.execUnknown(this,t,e);throw new ot('"'+t+'()" is undefined!')})}static create(t,e={},r={}){if(t instanceof at)return t;var s=e.scopeObj||{};return r.set?r.set(s,"main",t):s.main=t,new at(s,e)}static createStack(t,e={},r={}){return t.reverse().reduce((t,s,n)=>{if(s instanceof at){if(0===n)return s;throw new Error("Only the top-most context is allowed to be an instance of Scope.")}var i={};return r.set?r.set(i,"main",s):i.main=s,i.super=t,new at(i,e)},null)}}const ct=(t,e,r)=>{if(!f(t)&&!g(t))return r.get&&a(t)?r.get(t,e):t[e]},ht=(t,e,r)=>!f(t)&&!g(t)&&(r.has&&a(t)?r.has(t,e):a(t)?e in t:!g(t[e]));class lt extends B{constructor(t,e){super(),this.stmts=t||[],this.delims=e}eval(t=null,e={}){var r,s=(e={...e}).returnCallback;e.returnCallback=t=>{r=t},t=at.create(t,e);for(var n=(t,e,r)=>{try{return t.eval(e,r)}catch(t){r.catch&&r.catch(t)}},i=[],o=0;o<this.stmts.length;o++){var a=this.stmts[o],c=ut(a),h=ut(a,!0),l=(e.references||[]).filter(t=>c.filter(e=>Q(e,t)).length),u=(e.references||[]).filter(t=>h.filter(e=>Q(e,t)).length),p=!e.references||!e.references.length||(l=l.length)||(u=u.length),f=(e.references&&2===t.params.scopeType&&a instanceof G&&a.initKeyword,[]);if(p){var g=e;if(l&&delete(g={...e}).references,i[o]=n(a,t,g),a instanceof K||r)return s&&s(!0),i[o];(a instanceof P&&a.abortive||!1===r)&&(!0,s&&s(!1)),e.references&&((a instanceof G||a instanceof H)&&(f=[a])||a instanceof Y&&(f=a.declarations))&&(e.references=e.references.concat(st(f.map(t=>t.reference))))}else e.references&&(a instanceof G&&(f=[a])||a instanceof Y&&(f=a.declarations))&&f.forEach(t=>{if(t.val instanceof j){e.references=e.references.slice(0);let r=st([t.reference])[0],s=st([t.val])[0];e.references.forEach(t=>{Q(t,s)&&e.references.push(r.concat(L(t,s)))})}})}return","===this.delims[this.delims.length-1]?i.pop():i}toString(){return this.stringify()}stringify(t={}){return this.stmts.map((e,r)=>e.stringify(t)+(this.delims[r]||"")).join(" ")}static parse(t,e,r={}){var s;if(","===r.delim?(delete(r={...r}).delim,s=I.lex(t,[","])):s=I.lex(t,[lt.testBlockEnd]),s.matches.length){var n=[],i=[];return s.tokens.forEach((t,e)=>{(t=t.trim())&&(n.push(t),i.push(s.matches[e]))}),i.pop(),new this(n.map(t=>e(t,null,r)),i)}}static parseSingleOrMultiple(t,e,r={}){var s=e(t,[this],{...r,delim:",",assert:!1});return s?1===s.stmts.length&&(s=s.stmts[0]):s=e(t,null,r),s}static testBlockEnd(t,e,r){if(t.endsWith("}")&&!e.trim().startsWith("else"))return"";if(e.startsWith("\r\n"))return"\r\n";if(e.startsWith(";"))return";";if(e.startsWith(",")){var s=r.length&&r[r.length-1];return!(s.startsWith("var")||s.startsWith("let")||s.startsWith("const")||s.startsWith("return"))&&","}return!1}}lt.operators=[];const ut=(t,e=!1)=>(t.$readPaths||(t.$readPaths=st(t.meta.reads||[]),t.$deepReadPaths=st(t.meta.deep.reads||[])),e?t.$deepReadPaths:t.$readPaths);const pt=class extends x{};Object.defineProperty(pt.prototype,"jsenType",{get:()=>"ArrayType"});const ft=class extends x{};Object.defineProperty(ft.prototype,"jsenType",{get:()=>"AssertionExpression"});var gt=ft;const mt=class extends gt{constructor(t,e){super(),this.exprs=t,this.logic=e}eval(t=null,e={}){var r=this.constructor;if(this.logic.toLowerCase()===r.negation.toLowerCase())return!D(this.exprs).eval(t,e);N(r.operators);for(var s=(this.logic||"").trim().toUpperCase(),n=s===(r.operators.or||"").trim().toUpperCase(),i=s===(r.operators.nor||"").trim().toUpperCase(),o=s===(r.operators.and||"").trim().toUpperCase(),a=s===(r.operators.nand||"").trim().toUpperCase(),c=!0,h=0,l=0;l<this.exprs.length;l++){if(c=this.exprs[l].eval(t,e),o&&!c)return!1;if(a&&!c)return!0;if(n&&c)return c;h+=c?1:0}return n?c:o||a?o:i&&0===h}toString(){return this.stringify()}stringify(t={}){var e=this.constructor;return this.logic.toLowerCase()===e.negation.toLowerCase()?this.logic+D(this.exprs).stringify(t):this.exprs.map(e=>e.stringify(t)).join(" "+this.logic.trim()+" ")}static parse(t,e,r={}){if(t.toUpperCase().startsWith(this.negation.toUpperCase()))return new this([e(t.substr(this.negation.length),null,r)],this.negation);var s=I.lex(t,N(this.operators));if(s.tokens.length>1){var n=it(s.matches);if(n.length>1)throw new Error('"AND" and "OR" logic cannot be asserted in the same expression: '+t+"!");return new this(s.tokens.map(t=>e(t.trim(),null,r)),D(n))}}};mt.negation="!",mt.operators={and:"&&",or:"||"};const dt=class extends G{constructor(t,e,r="=",s=!1){super(),this.reference=t,this.val=e,this.operator=r,this.incrDecrIsPost=s}eval(t=null,e={}){var r,n,i,o=this.reference.getEval(t,e);if(["++","--"].includes(this.operator)){if(i=this.reference.eval(t,e),!c(i))throw new Error(this.reference+" must be a number!");r="++"===this.operator?i+1:i-1}else if(["+=","-=","*=","/="].includes(this.operator)){var a=o.get(),h=this.val.eval(t,e);if(!("+="===this.operator||c(a)&&c(h)))throw new Error(this+" - operands must each be a number!");r="*="===this.operator?a*h:"/="===this.operator?a/h:"-="===this.operator?a-h:a+h}else n=e.initKeyword,r=this.val?this.val.eval(t,e):void 0;try{return o.set(r,n),e&&s(e.references)&&_pushUnique(e.references,this.reference.toString()),this.incrDecrIsPost?i:r}catch(t){throw t instanceof ot?new ot("["+this+"]: "+t.message):t}}toString(){return this.stringify()}stringify(t={}){return["++","--"].includes(this.operator)?this.incrDecrIsPost?this.reference.stringify(t)+this.operator:this.operator+this.reference.stringify(t):[this.reference.stringify(t),this.operator.trim(),this.val?this.val.stringify(t):""].filter(t=>t).join(" ")}static parse(t,e,r={}){t=t.trim();var s,n=I.lex(t,this.operators.concat([vt]));if(r.isDeclaration&&(delete(r={...r}).isDeclaration,s=!0),n.matches.length||s){var i,o,a,c=(n.matches[0]||"").trim(),h=["++","--"].includes(c);if(h?(a=t.trim().endsWith("++")||t.trim().endsWith("--"),i=n.tokens[a?"shift":"pop"]().trim()):(i=n.tokens.shift().trim(),o=(n.tokens.shift()||"").trim()),!((i=e(i,null,{...r,role:"ASSIGNMENT_SPECIFIER"}))instanceof j)||!h&&o&&!(o=e(o,null,r))&&!s)throw new S(t);return new this(i,o,c,a)}}};dt.operators=["+=","-=","*=","/=","++","--"];const vt=(t,e)=>!(t.endsWith("=")||!e.startsWith("=")||e.startsWith("=>")||e.startsWith("==")||e.startsWith("==="))&&"=";const yt=class extends x{};Object.defineProperty(yt.prototype,"jsenType",{get:()=>"BooleanType"});const bt=class extends x{};Object.defineProperty(bt.prototype,"jsenType",{get:()=>"Arguments"});const xt=class extends x{};Object.defineProperty(xt.prototype,"jsenType",{get:()=>"ComparisonExpression"});var wt=xt;class jt extends wt{constructor(t,e,r){super(),this.operand1=t,this.operand2=e,this.operator=r}eval(t=null,e={}){return this.constructor.compare(this.operand1.eval(t,e),this.operand2.eval(t,e),this.operator)}toString(){return this.stringify()}stringify(t={}){return[this.operand1.stringify(t),this.operator,this.operand2.stringify(t)].join(" ")}static parse(t,e,r={}){var s=N(this.operators).map(t=>" "+t+" "),n=I.lex(t,s);if(n.tokens.length>1){if(n.tokens.length>2)throw new Error('Malformed "Comparison" expression: '+t+"!");return new this(e(D(n.tokens).trim(),null,r),e(M(n.tokens).trim(),null,r),n.matches[0].trim())}}static compare(t,e,r="=="){if(-1===N(this.operators).indexOf(r))throw new Error('The operator "'+r+'" is not recognized.');switch(r){case"===":return t===e;case"==":case"=":return t==e;case">":return t>e;case"<":return t<e;case">=":return t>=e;case"<=":return t<=e;case"!=":return t!=e;case"<>":case"!==":return t!==e;case"^=":return _(t)&&t.startsWith(e);case"$=":return _(t)&&t.endsWith(e);case"*=":return!(!s(e)&&!_(e))&&t.indexOf(e)>-1;case"~=":return _(t)&&_(e)&&(" "+t+" ").indexOf(" "+e+" ")>-1;case">=<":if(!s(e)||2!==e.length)throw new Error("A 'Between' comparison requires argument 2 to be an array of exactly 2 values.");return t>=e[0]&&t<=e[1];case"/**/":return e.match(new RegExp(t));default:return!1}}static diff(t,e,r){return!this.compare(t,e,r?"===":"==")}}jt.operators={exact:{is:"===",isNull:"===",equalsTo:"==",strictlyNotEqualsTo:"!==",notEqualsTo:"!="},relative:{lesserThan:"<",greaterThan:">",lesserThanOrEqualsTo:"<=",greaterThanOrEqualsTo:">=",between:">=<"},partial:{startsWith:"^=",endsWith:"$=",contains:"*=",any:"~=",in:"~=",matches:"/**/"}};const kt=class extends x{};Object.defineProperty(kt.prototype,"jsenType",{get:()=>"TernaryConditional"});var Ot=kt;class Et extends Ot{constructor(t,e,r){super(),this.assertion=t,this.onTrue=e,this.onFalse=r}eval(t=null,e={}){return this.assertion.eval(t,e)?this.onTrue.eval(t,e):this.onFalse.eval(t,e)}toString(){return this.stringify()}stringify(t={}){return[this.assertion.stringify(t),this.constructor.operators[0],this.onTrue.stringify(t),this.constructor.operators[1],this.onFalse.stringify(t)].join(" ")}static parse(t,e,r={}){var s=I.split(t,this.operators);if(s.length>1){if(2===s.length)throw new Error("Malformed ternary expression: "+t+"!");return new this(e(s[0].trim(),null,r),e(s[1].trim(),null,r),e(s[2].trim(),null,r))}}}Et.operators=["?",":"];const Tt=class extends H{constructor(t,e="delete"){super(),this.reference=t,this.operator=e}eval(t=null,e={}){try{return this.reference.getEval(t,e).del()}catch(t){throw t instanceof ot?new ot("["+this+"]: "+t.message):t}}toString(){return this.stringify()}stringify(t={}){return this.operator+" "+this.reference.stringify(t)}static parse(t,e,r={}){var s=I.lex(t,Object.values(this.operators));if(1===s.matches.length&&t.startsWith(s.matches[0]+" ")){var n;if(!((n=e(s.tokens.pop().trim(),null,{...r,role:"DELETION_SPECIFIER"}))instanceof j))throw new S(t);return new this(n,s.matches[0].trim())}}};Tt.operators={red:"reduce",del:"delete"};const Pt=class extends E{};Object.defineProperty(Pt.prototype,"jsenType",{get:()=>"FunctionType"});var St=Pt;const $t=class extends St{constructor(t,e,r={}){super(),this.paramters=t||{},this.statements=e,this.statements.isIndependent=!0,this.arrowFunctionFormatting=r}inherit(t){if(t instanceof St){for(var e=Object.keys(t.paramters),r=Object.keys(this.paramters),s=0;s<Math.max(r.length,e.length);s++){var n=e[s],i=r[s];if(!i&&n)throw new Error("Parameter #"+s+" ("+n+") in parent function must be implemented.");if(i&&n){var o=t.paramters[n],a=this.paramters[i];if(a&&!o)throw new Error("Parameter #"+s+" ("+i+") must not have a default value as established in parent function.");if(a&&o&&a.jsenType!==o.jsenType)throw new Error("Default value for parameter #"+s+" ("+i+") must be of type "+o.jsenType+" as established in parent function.")}}this.sup=t}return this}eval(t=null,e={}){var r=this;return delete(e={...e}).returnCallback,function(...s){var n={};v(Object.keys(r.paramters),(i,o)=>{var a=r.paramters[o];if(s.length-1<i&&!a)throw new Error('The parameter "'+o+'" is required.');n[o]=s.length>i?s[i]:r.paramters[o]?r.paramters[o].eval(t,e):null}),r.arrowFunctionFormatting||(n.this=this);var i=t instanceof at?t.params.errorLevel:void 0,o={main:n,super:t,local:{},$local:{}};e.scopeObj&&(e.scopeObj.subscopes||(e.scopeObj.subscopes=[]),e.scopeObj.subscopes.push(o));var a=new at(o,{errorLevel:i}),c=r.statements.eval(a,e);return!1===r.arrowFunctionFormatting.body?c[0]:c}}toString(){return this.stringify()}stringify(t={}){var e=[];if(v(this.paramters,(r,s)=>{e.push(r+(s?"="+s.stringify(t):""))}),this.arrowFunctionFormatting){var r=!1===this.arrowFunctionFormatting.head||1===e.length&&-1===e[0].indexOf("="),s=!1===this.arrowFunctionFormatting.body;return(r?e[0]:"("+e.join(", ")+")")+" => "+(s?this.statements.stringify(t):"{"+this.statements.stringify(t)+"}")}return"function ("+e.join(", ")+") {"+this.statements.stringify(t)+"}"}static parse(t,e,r={}){var s;if((t=t.trim()).startsWith("function")&&(s=I.split(t,[]).slice(1).filter(t=>t.trim()))&&2===s.length)var n=!1,i=W(s.shift().trim(),"(",")"),o=W(s.shift().trim(),"{","}");else{if(t.startsWith("function")||!(s=I.split(t,["=>"]))||2!==s.length)return;i=s.shift().trim(),o=s.shift().trim(),n={};$(i,"(",")")?i=W(i,"(",")"):n.head=!1,$(o,"{","}")?o=W(o,"{","}"):n.body=!1}var a={};I.split(i,[","]).forEach(t=>{var s=t.split("=");s[1]?a[s[0].trim()]=e(s[1].trim(),null,{...r,meta:null}):a[t.trim()]=null});var c=e(o,[lt],{assert:!1})||e(o,null,{...r,meta:null});return new this(a,"Block"===c.jsenType?c:new lt([c]),n)}};$t.operators=["=>"];var Ct=function(t,e,r=null){return s(e)?t.filter(t=>r?e.filter(e=>r(t,e)).length:-1!==e.indexOf(t)):[]};const Wt=class extends x{};Object.defineProperty(Wt.prototype,"jsenType",{get:()=>"MathExpression"});var _t=Wt;const At=class extends _t{constructor(t,e){super(),this.val=t,this.exprs=e}eval(t=null,e={}){return this.exprs.reduce((r,s)=>{var n=s.val.eval(t,e),i=s.operator.trim();if(!(h(r)&&h(n)||"+"===i))throw new Error("Invalid Math expression: "+this.toString()+"!");switch(i){case"+":return r+n;case"-":return r-n;case"*":return r*n;case"/":return r/n}},this.val.eval(t,e))}toString(){return this.stringify()}stringify(t={}){return[this.val.stringify(t)].concat(this.exprs.map(e=>e.operator+" "+e.val.stringify(t))).join(" ")}static parse(t,e,r={}){var s=I.lex(t,N(this.operators));if(s.tokens.filter(t=>t).length>1&&s.matches.length===s.tokens.length-1){var n=it(s.matches);if(Ct(n,this.operators.sup).length&&Ct(n,this.operators.sub).length)throw new Error('"Addition/subtraction" and "multiplication/division" operators cannot be used in the same expression: '+t+"!");return new this(e(s.tokens.shift().trim(),null,r),s.tokens.map((t,n)=>({operator:s.matches[n],val:e(t.trim(),null,r)})))}}};At.operators={sup:["*","/"],sub:["+","-"]};new Map;const Ft=class extends x{};Object.defineProperty(Ft.prototype,"jsenType",{get:()=>"ObjectType"});var Nt=Ft;const Dt=class extends Nt{constructor(t){super(),this.entries=t||new Map}inherit(t){return t instanceof Nt&&Array.from(t.entries.keys()).forEach(e=>{this.entries.has(e)||this.entries.set(e,t.entries.get(e))}),this}eval(t=null,e={}){var r={};return Array.from(this.entries.keys()).forEach(s=>{var n=_(s)?s:s.eval(t,e),i=this.entries.get(s);i=i?i.eval(t,e):n,r[n]=i}),r}toString(){return this.stringify()}stringify(t={}){var e=[];return Array.from(this.entries.keys()).forEach(r=>{var s=r,n=this.entries.get(r);_(s)||(s=r.stringify(t),r instanceof rt||(s=`[${s}]`)),n&&!n.byShorthand?e.push(s+Dt.operators.sub+" "+n.stringify(t)):e.push(s)}),"{ "+e.join(Dt.operators.sup+" ")+" }"}static parse(t,e,r={}){if($(t,"{","}")&&!I.match(t.trim(),[" "]).length){var s=new Map,n=I.split(W(t,"{","}"),[Dt.operators.sup]).map(t=>t.trim()).filter(t=>t);return v(n,(t,n)=>{var i,o=I.split(n,[Dt.operators.sub],{limit:1}),a=o.shift().trim();if($(a,'"','"')||$(a,"'","'")||$(a,"[","]")){if($(a,"[","]"))a=a.slice(1,-1);else if(!o.length)return;a=e(a,null,r)}if(o.length){if(!o[0])return;i=e(o[0].trim(),null,r)}else _(a)&&((i=e(a,null,r)).byShorthand=!0);s.set(a,i)}),new this(s)}}};Dt.operators={sup:",",sub:":"};const Mt=class extends x{};Object.defineProperty(Mt.prototype,"jsenType",{get:()=>"PresenceOperator"});var qt=Mt;const It=class extends qt{constructor(t,e,r="in"){super(),this.prop=t,this.reference=e,this.operator=r}eval(t=null,e={}){var r=this.prop.eval(t,e);try{return this.reference.getEval(t,e).has(r)}catch(t){throw t instanceof ot?new ot("["+this+"]: "+t.message):t}}toString(){return this.stringify()}stringify(t={}){return[this.prop.stringify(t),this.operator,this.reference.stringify(t)].join(" ")}static parse(t,e,r={}){var s=I.lex(t,this.operators);if(2===s.tokens.length){var n,i;if(!((n=e(s.tokens.shift().trim(),null,r))&&(i=e(s.tokens.shift().trim(),null,r))instanceof j))throw new S(t);return new this(n,i,s.matches[0].trim())}}};It.operators=[" in "];class Rt extends j{constructor(t,e,r=!1){super(),this.context=t,this.name=e,this.backticks=r}getEval(t=null,e={}){var r=t,s=this.name;this.context&&(s instanceof x&&(s=s.eval(t,e)),r=this.context.eval(t,e));var n=!this.context;return{get:()=>at.create(r,e).get(s,e.trap),del:()=>at.create(r,e).del(s,e.trap),has:t=>at.create(r,e).has(s,t,e.trap),set:(t,i=null)=>at.create(r,e).set(s,t,e.trap,i,n),exec:t=>at.create(r,e).exec(s,t,e.trap)}}eval(t=null,e={}){try{return this.getEval(t,e).get()}catch(t){throw t instanceof ot?new ot("["+this+"]: "+t.message):t}}toString(){return this.stringify()}stringify(t={}){var e=this.name;if(this.context){var r=this.context.stringify(t);e instanceof x?e="["+e.stringify(t)+"]":this.backticks&&(e="`"+e+"`")}else{r=t.context;this.backticks&&(e="`"+e+"`")}return(r||"")+(r&&!e.startsWith("[")?Rt.separator:"")+e}static parse(t,e,r={}){if(!I.match(t.trim(),[" "]).length){var s,n,i=I.split(t,[]),o=i.pop(),a=I.split(o.trim(),[this.separator],{preserveDelims:!0});if(a.length>1&&(o=a.pop().substr(1),i=i.concat(a)),$(o,"`","`")&&(o=W(o,"`","`"),n=!0),i.length&&(s=e(i.join(""),null,{...r,role:"CONTEXT"})),$(o,"[","]")){if(!s)throw new S(t);o=e(W(o,"[","]"),null,r)}return new this(s,o,n)}}}Rt.separator=".";const Lt=class extends x{};Object.defineProperty(Lt.prototype,"jsenType",{get:()=>"Void"});window.WebQit||(window.WebQit={}),window.WebQit.Subscript=void 0}]);
//# sourceMappingURL=main.js.map

@@ -11,3 +11,3 @@ {

"homepage": "https://webqit.io/tooling/subscript",
"version": "1.1.7",
"version": "1.1.8",
"license": "MIT",

@@ -33,3 +33,3 @@ "repository": {

"dependencies": {
"@webqit/util": "^0.8.7"
"@webqit/util": "^0.8.8"
},

@@ -36,0 +36,0 @@ "devDependencies": {

@@ -47,2 +47,4 @@

import StrInterface from './grammar/StrInterface.js';
import VariableDec from './grammar/VariableDec.js';
import VariableDecInterface from './grammar/VariableDecInterface.js';
import Void from './grammar/Void.js';

@@ -59,2 +61,3 @@ import VoidInterface from './grammar/VoidInterface.js';

Deletion: Deletion, // delete field1
VariableDec: VariableDec, // var field1 = {}, field2 = 3, field4
Assignment: Assignment, // field1[key1].key2 = k

@@ -106,2 +109,3 @@ Presence: Presence, // key1 in field1

Str,
VariableDec,
Void,

@@ -130,3 +134,4 @@ };

StrInterface,
VariableDecInterface,
VoidInterface,
};

@@ -9,2 +9,3 @@

import AbstractionInterface from './AbstractionInterface.js';
import Block from './Block.js';

@@ -53,5 +54,3 @@ /**

if (_wrapped(expr, '(', ')') && !Lexer.match(expr, [' ']).length && Lexer.split(expr, []).length === 2/* recognizing the first empty slot */) {
return new this(
parseCallback(_unwrap(expr, '(', ')'))
);
return new this(Block.parseSingleOrMultiple(_unwrap(expr, '(', ')'), parseCallback, params));
}

@@ -58,0 +57,0 @@ }

@@ -54,3 +54,3 @@

return new this(
Lexer.split(_unwrap(expr, '(', ')'), [',']).map(arg => parseCallback(arg.trim()))
Lexer.split(_unwrap(expr, '(', ')'), [',']).map(arg => parseCallback(arg.trim(), null, params))
);

@@ -57,0 +57,0 @@ }

@@ -66,3 +66,3 @@

var splits = Lexer.split(_unwrap(expr, '[', ']'), [','])
.map(n => n.trim()).filter(n => n).map(expr => parseCallback(expr));
.map(n => n.trim()).filter(n => n).map(expr => parseCallback(expr, null, params));
return new this(splits);

@@ -69,0 +69,0 @@ }

@@ -95,3 +95,3 @@

return new this(
[parseCallback(expr.substr(this.negation.length))],
[parseCallback(expr.substr(this.negation.length), null, params)],
this.negation

@@ -107,3 +107,3 @@ );

return new this(
parse.tokens.map(expr => parseCallback(expr.trim())),
parse.tokens.map(expr => parseCallback(expr.trim(), null, params)),
_first(logic)

@@ -110,0 +110,0 @@ );

@@ -5,8 +5,4 @@

*/
import _last from '@webqit/util/arr/last.js';
import _before from '@webqit/util/str/before.js';
import _after from '@webqit/util/str/after.js';
import _isNumber from '@webqit/util/js/isNumber.js';
import _isArray from '@webqit/util/js/isArray.js';
import _isUndefined from '@webqit/util/js/isUndefined.js';
import Lexer from '@webqit/util/str/Lexer.js';

@@ -29,9 +25,8 @@ import AssignmentInterface from './AssignmentInterface.js';

*/
constructor(initKeyword, reference, val, operator = '=', postIncrDecr = false) {
constructor(reference, val, operator = '=', incrDecrIsPost = false) {
super();
this.initKeyword = initKeyword;
this.reference = reference;
this.val = val;
this.operator = operator;
this.postIncrDecr = postIncrDecr;
this.incrDecrIsPost = incrDecrIsPost;
}

@@ -43,3 +38,3 @@

eval(context = null, params = {}) {
var val, initialVal, reference = this.reference.getEval(context, params);
var val, initKeyword, initialVal, reference = this.reference.getEval(context, params);
if (['++', '--'].includes(this.operator)) {

@@ -71,10 +66,11 @@ initialVal = this.reference.eval(context, params);

} else {
val = this.val.eval(context, params);
initKeyword = params.initKeyword;
val = this.val ? this.val.eval(context, params) : undefined;
}
try {
reference.set(val, this.initKeyword);
reference.set(val, initKeyword);
if (params && _isArray(params.references)) {
_pushUnique(params.references, this.reference.toString());
}
return this.postIncrDecr ? initialVal : val;
return this.incrDecrIsPost ? initialVal : val;
} catch(e) {

@@ -101,8 +97,7 @@ if (e instanceof ReferenceError) {

if (['++', '--'].includes(this.operator)) {
return this.postIncrDecr
return this.incrDecrIsPost
? this.reference.stringify(params) + this.operator
: this.operator + this.reference.stringify(params);
}
return (this.initKeyword ? this.initKeyword + ' ' : '')
+ [this.reference.stringify(params), this.operator.trim(), this.val.stringify(params)].join(' ');
return [this.reference.stringify(params), this.operator.trim(), this.val ? this.val.stringify(params) : ''].filter(a => a).join(' ');
}

@@ -114,24 +109,27 @@

static parse(expr, parseCallback, params = {}) {
var parse = Lexer.lex(expr, this.operators.concat([testBlockEnd]));
if (parse.matches.length) {
var initKeyword, reference, val, operator = parse.matches[0].trim(), isIncrDecr = ['++', '--'].includes(operator), postIncrDecr;
expr = expr.trim();
var isDeclaration, parse = Lexer.lex(expr, this.operators.concat([testBlockEnd]));
if (params.isDeclaration) {
params = { ...params };
delete params.isDeclaration;
isDeclaration = true;
}
if (parse.matches.length || isDeclaration) {
var reference,
val,
operator = (parse.matches[0] || '').trim(),
isIncrDecr = ['++', '--'].includes(operator),
incrDecrIsPost;
if (isIncrDecr) {
postIncrDecr = (expr.trim().endsWith('++') || expr.trim().endsWith('--'));
reference = parse.tokens[postIncrDecr ? 'shift' : 'pop']().trim();
incrDecrIsPost = (expr.trim().endsWith('++') || expr.trim().endsWith('--'));
reference = parse.tokens[incrDecrIsPost ? 'shift' : 'pop']().trim();
} else {
reference = parse.tokens.shift().trim();
val = parse.tokens.shift().trim();
val = (parse.tokens.shift() || '').trim();
}
if (['var', 'let', 'const'].includes(_before(reference, ' '))) {
if (operator !== '=') {
throw new SyntaxError('Invalid declaration: ' + expr);
}
initKeyword = _before(reference, ' ');
reference = _after(reference, ' ').trim();
}
if (!((reference = parseCallback(reference, null, {role: 'ASSIGNMENT_SPECIFIER'})) instanceof ReferenceInterface)
|| (!isIncrDecr && !(val = parseCallback(val)))) {
if (!((reference = parseCallback(reference, null, { ...params, role: 'ASSIGNMENT_SPECIFIER' })) instanceof ReferenceInterface)
|| (!isIncrDecr && (val && !(val = parseCallback(val, null, params)) && !isDeclaration))) {
throw new SyntaxError(expr);
}
return new this(initKeyword, reference, val, operator, postIncrDecr);
return new this(reference, val, operator, incrDecrIsPost);
}

@@ -138,0 +136,0 @@ }

@@ -16,2 +16,3 @@

import ReferenceInterface from './ReferenceInterface.js';
import VariableDecInterface from './VariableDecInterface.js';
import { referencesToPaths } from '../util.js';

@@ -31,6 +32,6 @@ import Scope from '../Scope.js';

*/
constructor(stmts, delim) {
constructor(stmts, delims) {
super();
this.stmts = stmts || [];
this.delim = delim;
this.delims = delims;
}

@@ -43,3 +44,3 @@

params = {...params};
params = { ...params };
var returned, returnCallback = params.returnCallback;

@@ -51,3 +52,3 @@ params.returnCallback = flag => {

// Current!
context = Scope.create(context);
context = Scope.create(context, params);
var callEval = (stmt, context, _params) => {

@@ -72,3 +73,4 @@ try {

var isFirstRunOrDirectOrIndirectReference = !params.references || !params.references.length || (isDirectEventTarget = isDirectEventTarget.length) || (isIndirectEventTarget = isIndirectEventTarget.length);
var isLocalAssignmentInEventbasedRuntime = params.references/** On the event-based runtime for... */ && context.params.type === 2/** ...onTrue/onFalse blocks */ && (stmt instanceof AssignmentInterface) && stmt.initKeyword/** Local assignments within it ... might be needed by selected references */;
var isLocalAssignmentInEventbasedRuntime = params.references/** On the event-based runtime for... */ && context.params.scopeType === 2/** ...onTrue/onFalse blocks */ && (stmt instanceof AssignmentInterface) && stmt.initKeyword/** Local assignments within it ... might be needed by selected references */;
var changedVariables = [];
if (isFirstRunOrDirectOrIndirectReference/** || (isLocalAssignmentInEventbasedRuntime Experimental and currently disabled */) {

@@ -95,15 +97,24 @@ var _params = params;

// This is a local change!
if (params.references && ((stmt instanceof AssignmentInterface) || (stmt instanceof DeletionInterface))) {
params.references = params.references.concat(referencesToPaths([stmt.reference]));
if (params.references) {
if ((((stmt instanceof AssignmentInterface) || (stmt instanceof DeletionInterface)) && (changedVariables = [stmt]))
|| ((stmt instanceof VariableDecInterface) && (changedVariables = stmt.declarations))) {
params.references = params.references.concat(referencesToPaths(changedVariables.map(stmt => stmt.reference)));
}
}
} else if (params.references && (stmt instanceof AssignmentInterface) && (stmt.val instanceof ReferenceInterface)) {
// E.g: app = document.state; (This statement won't evaluate above if reference was "document.state.something")
// So we need to record that app.something has changed
params.references = params.references.slice(0);
let basePath = referencesToPaths([stmt.reference])[0], // app
leafPath = referencesToPaths([stmt.val])[0]; // document.state
params.references.forEach(ref/** document.state.something */ => {
if (_arrStartsWith(ref, leafPath)) {
// app.something
params.references.push(basePath.concat(_arrAfter(ref, leafPath)));
} else if (params.references && (
((stmt instanceof AssignmentInterface) && (changedVariables = [stmt])) || ((stmt instanceof VariableDecInterface) && (changedVariables = stmt.declarations))
)) {
changedVariables.forEach(stmt => {
if (stmt.val instanceof ReferenceInterface) {
// E.g: app = document.state; (This statement won't evaluate above if reference was "document.state.something")
// So we need to record that app.something has changed
params.references = params.references.slice(0);
let basePath = referencesToPaths([stmt.reference])[0], // app
leafPath = referencesToPaths([stmt.val])[0]; // document.state
params.references.forEach(ref/** document.state.something */ => {
if (_arrStartsWith(ref, leafPath)) {
// app.something
params.references.push(basePath.concat(_arrAfter(ref, leafPath)));
}
});
}

@@ -114,3 +125,3 @@ });

return results;
return this.delims[this.delims.length - 1] === ',' ? results.pop() : results;
}

@@ -129,3 +140,3 @@

stringify(params = {}) {
return this.stmts.map(stmt => stmt.stringify(params)).join(this.delim);
return this.stmts.map((stmt, i) => stmt.stringify(params) + (this.delims[i] || '')).join(' ');
}

@@ -137,12 +148,43 @@

static parse(expr, parseCallback, params = {}) {
var parse = Lexer.lex(expr + ';', _flatten(this.operators).concat([Block.testBlockEnd]));
if (parse.matches.length) {
var _parse;
if (params.delim === ',') {
params = { ...params };
delete params.delim;
_parse = Lexer.lex(expr, [',']);
} else {
_parse = Lexer.lex(expr, [ Block.testBlockEnd ]);
}
if (_parse.matches.length) {
var statements = [];
var delims = [];
_parse.tokens.forEach((stmt, i) => {
if (!(stmt = stmt.trim())) {
return;
}
statements.push(stmt);
delims.push(_parse.matches[i]);
});
delims.pop(); // IMPORTANT: The last one that will always be undefined
return new this(
parse.tokens.map(stmt => parseCallback(stmt.trim())).filter(a => a),
parse.matches[0].trim()
statements.map(stmt => parseCallback(stmt, null, params)),
delims,
);
}
}
/**
* @inheritdoc
*/
static testBlockEnd(a, b) {
static parseSingleOrMultiple(expr, parseCallback, params = {}) {
var _parse = parseCallback(expr, [ this ], { ...params, delim: ',', assert: false });
if (!_parse) {
_parse = parseCallback(expr, null, params);
} else if (_parse.stmts.length === 1) {
_parse = _parse.stmts[0];
}
return _parse;
}
static testBlockEnd(a, b, tokens) {
// Cases of code blocks that won't end in ";"

@@ -152,2 +194,15 @@ if (a.endsWith('}') && !b.trim().startsWith('else')) {

}
if (b.startsWith("\r\n")) {
return "\r\n";
}
if (b.startsWith(';')) {
return ';';
}
if (b.startsWith(',')) {
var ongoingToken = tokens.length && tokens[tokens.length - 1];
if (ongoingToken.startsWith('var') || ongoingToken.startsWith('let') || ongoingToken.startsWith('const') || ongoingToken.startsWith('return')) {
return false;
}
return ',';
}
return false;

@@ -160,6 +215,3 @@ }

*/
Block.operators = [
';',
"\r\n",
];
Block.operators = [];

@@ -166,0 +218,0 @@ const getReadPaths = (stmt, deep = false) => {

@@ -67,4 +67,4 @@

var reference, args = tokens.pop();
if (!((reference = parseCallback(tokens.join(''), null, {role: 'CALL_SPECIFIER'})) instanceof ReferenceInterface)
|| !(args = parseCallback(args, [Arguments]))) {
if (!((reference = parseCallback(tokens.join(''), null, { ...params, role: 'CALL_SPECIFIER' })) instanceof ReferenceInterface)
|| !(args = parseCallback(args, [ Arguments ], params))) {
throw new SyntaxError(expr);

@@ -71,0 +71,0 @@ }

@@ -83,3 +83,3 @@

if (_expr) {
_expr = parseCallback(_expr);
_expr = parseCallback(_expr, null, params);
_expr.meta.commenta = _comments;

@@ -86,0 +86,0 @@ return _expr;

@@ -74,4 +74,4 @@

return new this(
parseCallback(_first(parse.tokens).trim()),
parseCallback(_last(parse.tokens).trim()),
parseCallback(_first(parse.tokens).trim(), null, params),
parseCallback(_last(parse.tokens).trim(), null, params),
parse.matches[0].trim()

@@ -78,0 +78,0 @@ );

@@ -65,5 +65,5 @@

return new this(
parseCallback(splits[0].trim()),
parseCallback(splits[1].trim()),
parseCallback(splits[2].trim())
parseCallback(splits[0].trim(), null, params),
parseCallback(splits[1].trim(), null, params),
parseCallback(splits[2].trim(), null, params)
);

@@ -70,0 +70,0 @@ }

@@ -66,3 +66,3 @@

var reference;
if (!((reference = parseCallback(parse.tokens.pop().trim(), null, {role: 'DELETION_SPECIFIER'})) instanceof ReferenceInterface)) {
if (!((reference = parseCallback(parse.tokens.pop().trim(), null, { ...params, role: 'DELETION_SPECIFIER' })) instanceof ReferenceInterface)) {
throw new SyntaxError(expr);

@@ -69,0 +69,0 @@ }

@@ -88,3 +88,15 @@

var errorLevel = context instanceof Scope ? context.params.errorLevel : undefined;
var nestedContext = new Scope({main:newMainContext, super:context}, {errorLevel});
var subscope = {
main: newMainContext,
super: context,
local: {},
$local: {},
};
if (params.scopeObj) {
if (!params.scopeObj.subscopes) {
params.scopeObj.subscopes = [];
}
params.scopeObj.subscopes.push(subscope);
}
var nestedContext = new Scope(subscope, { errorLevel });
var retrn = instance.statements.eval(nestedContext, params);

@@ -156,2 +168,3 @@ if (instance.arrowFunctionFormatting.body === false) {

paramters[paramSplit[0].trim()] = parseCallback(paramSplit[1].trim(), null, {
...params,
// Any varaibles should be added to public vars

@@ -165,2 +178,3 @@ meta: null,

var block = parseCallback(funcBody, [Block], {assert:false}) || parseCallback(funcBody, null, {
...params,
// Any varaibles should be added to public vars

@@ -167,0 +181,0 @@ meta: null,

@@ -37,6 +37,15 @@

var errorLevel = context instanceof Scope ? context.params.errorLevel : undefined;
var _context = new Scope({
main:{},
super:context,
}, {type: 2, errorLevel});
var subscope = {
main: {},
super: context,
local: {},
$local: {},
};
if (params.scopeObj) {
if (!params.scopeObj.subscopes) {
params.scopeObj.subscopes = [];
}
params.scopeObj.subscopes.push(subscope);
}
var _context = new Scope(subscope, { scopeType: 2, errorLevel });
return this.assertion.eval(context/** original context */, params)

@@ -75,3 +84,3 @@ ? (this.onTrue ? this.onTrue.eval(_context, params) : undefined)

&& (splits = Lexer.split(expr, [], {limit:2}/*IMPORTANT*/).slice(1).filter(b => b.trim())) && splits.length === 2) {
var assertion = parseCallback(_unwrap(splits.shift().trim(), '(', ')').trim());
var assertion = parseCallback(_unwrap(splits.shift().trim(), '(', ')').trim(), null, params);
var rest = Lexer.split(splits.shift().trim(), ['else'], {limit:1}/*IMPORTANT*/);

@@ -85,3 +94,3 @@ var abortive;

}
onTrue = parseCallback(onTrue, [Block], {assert:false, meta:null}) || parseCallback(onTrue, null, {meta:null});
onTrue = parseCallback(onTrue, [ Block ], { ...params, assert: false, meta: null }) || parseCallback(onTrue, null, { ...params, meta:null });
if (onFalse) {

@@ -93,3 +102,3 @@ if (_wrapped(onFalse, '{', '}')) {

}
onFalse = parseCallback(onFalse, [Block], {assert:false, meta:null}) || parseCallback(onFalse, null, {meta:null});
onFalse = parseCallback(onFalse, [ Block ], { ...params, assert:false, meta:null }) || parseCallback(onFalse, null, { ...params, meta:null });
} else if (onTrue) {

@@ -96,0 +105,0 @@ abortive = onTrue.stmts.filter(stmt => stmt instanceof ReturnInterface).length;

@@ -79,6 +79,6 @@

return new this(
parseCallback(parse.tokens.shift().trim()),
parseCallback(parse.tokens.shift().trim(), null, params),
parse.tokens.map((expr, i) => {return {
operator: parse.matches[i],
val: parseCallback(expr.trim())
val: parseCallback(expr.trim(), null, params)
};})

@@ -85,0 +85,0 @@ );

@@ -7,6 +7,6 @@

import _unwrap from '@webqit/util/str/unwrap.js';
import _first from '@webqit/util/arr/first.js';
import _last from '@webqit/util/arr/last.js';
import _each from '@webqit/util/obj/each.js';
import { _isString } from '@webqit/util/js/index.js';
import ObjInterface from './ObjInterface.js';
import StrInterface from './StrInterface.js';
import Lexer from '@webqit/util/str/Lexer.js';

@@ -27,3 +27,3 @@

super();
this.entries = entries || {};
this.entries = entries || new Map;
}

@@ -36,5 +36,5 @@

if (Super instanceof ObjInterface) {
_each(Super.entries, (name, val) => {
if (!(name in this.entries)) {
this.entries[name] = val;
Array.from(Super.entries.keys()).forEach(key => {
if (!this.entries.has(key)) {
this.entries.set(key, Super.entries.get(key));
}

@@ -51,4 +51,11 @@ });

var items = {};
_each(this.entries, (key, expr) => {
items[key] = expr.eval(context, params);
Array.from(this.entries.keys()).forEach(key => {
var name = _isString(key) ? key : key.eval(context, params);
var val = this.entries.get(key);
if (val) {
val = val.eval(context, params);
} else {
val = name;
}
items[name] = val;
});

@@ -70,6 +77,17 @@ return items;

var str = [];
_each(this.entries, (key, expr) => {
str.push(key + Obj.operators.sub + expr.stringify(params));
Array.from(this.entries.keys()).forEach(key => {
var name = key, value = this.entries.get(key);
if (!_isString(name)) {
name = key.stringify(params);
if (!(key instanceof StrInterface)) {
name = `[${name}]`;
}
}
if (value && !value.byShorthand) {
str.push(name + Obj.operators.sub + ' ' + value.stringify(params));
} else {
str.push(name);
}
});
return '{' + str.join(Obj.operators.sup) + '}';
return '{ ' + str.join(Obj.operators.sup + ' ') + ' }';
}

@@ -82,3 +100,3 @@

if (_wrapped(expr, '{', '}') && !Lexer.match(expr.trim(), [' ']).length) {
var entries = {};
var entries = new Map;
var _entriesSplit = Lexer.split(_unwrap(expr, '{', '}'), [Obj.operators.sup])

@@ -88,3 +106,23 @@ .map(n => n.trim()).filter(n => n);

var entry = Lexer.split(expr, [Obj.operators.sub], {limit:1}/*IMPORTANT*/);
entries[_first(entry).trim()] = parseCallback(_last(entry).trim());
var name = entry.shift().trim(), value;
if (_wrapped(name, '"', '"') || _wrapped(name, "'", "'") || _wrapped(name, '[', ']')) {
if (_wrapped(name, '[', ']')) {
name = name.slice(1, -1);
} else if (!entry.length) {
// Syntax error
return;
}
name = parseCallback(name, null, params);
}
if (entry.length) {
if (!entry[0]) {
// Syntax error
return;
}
value = parseCallback(entry[0].trim(), null, params);
} else if (_isString(name)) {
value = parseCallback(name, null, params);
value.byShorthand = true;
}
entries.set(name, value);
});

@@ -91,0 +129,0 @@ return new this(entries);

@@ -68,4 +68,4 @@

var prop, reference;
if (!(prop = parseCallback(parse.tokens.shift().trim()))
|| !((reference = parseCallback(parse.tokens.shift().trim())) instanceof ReferenceInterface)) {
if (!(prop = parseCallback(parse.tokens.shift().trim(), null, params))
|| !((reference = parseCallback(parse.tokens.shift().trim(), null, params)) instanceof ReferenceInterface)) {
throw new SyntaxError(expr);

@@ -72,0 +72,0 @@ }

@@ -63,3 +63,3 @@

}
/**

@@ -131,3 +131,3 @@ * @inheritdoc

if (splits.length) {
context = parseCallback(splits.join(''), null, {role: 'CONTEXT'});
context = parseCallback(splits.join(''), null, { ...params, role: 'CONTEXT' });
}

@@ -138,3 +138,3 @@ if (_wrapped(name, '[', ']')) {

}
name = parseCallback(_unwrap(name, '[', ']'));
name = parseCallback(_unwrap(name, '[', ']'), null, params);
}

@@ -141,0 +141,0 @@ return new this(context, name, backticks);

@@ -5,3 +5,2 @@

*/
import Lexer from '@webqit/util/str/Lexer.js';
import ReturnInterface from './ReturnInterface.js';

@@ -56,5 +55,3 @@

if (exprLc.startsWith('return ') || exprLc === 'return') {
return new this(
parseCallback(expr.substr(6).trim())
);
return new this(Block.parseSingleOrMultiple(expr.substr(6).trim(), parseCallback, params));
}

@@ -61,0 +58,0 @@ }

@@ -39,3 +39,3 @@

super:context,
}, {type: 2, errorLevel});
}, { scopeType: 2, errorLevel });
return this.assertion.eval(context/** original context */, params)

@@ -74,3 +74,3 @@ ? (this.onTrue ? this.onTrue.eval(_context, params) : undefined)

&& (splits = Lexer.split(expr, [], {limit:2}/*IMPORTANT*/).slice(1).filter(b => b.trim())) && splits.length === 2) {
var assertion = parseCallback(_unwrap(splits.shift().trim(), '(', ')').trim());
var assertion = parseCallback(_unwrap(splits.shift().trim(), '(', ')').trim(), null, params);
var rest = Lexer.split(splits.shift().trim(), ['else'], {limit:1}/*IMPORTANT*/);

@@ -83,3 +83,3 @@ var onTrue = rest.shift().trim(), onTrueIsBlock, onFalse = (rest.shift() || '').trim(), onFalseIsBlock;

}
onTrue = parseCallback(onTrue, [Block], {assert:false, meta:null}) || parseCallback(onTrue, null, {meta:null});
onTrue = parseCallback(onTrue, [ Block ], { ...params, assert:false, meta:null }) || parseCallback(onTrue, null, { ...params, meta:null });
if (onFalse) {

@@ -91,3 +91,3 @@ if (_wrapped(onFalse, '{', '}')) {

}
onFalse = parseCallback(onFalse, [Block], {assert:false, meta:null}) || parseCallback(onFalse, null, {meta:null});
onFalse = parseCallback(onFalse, [ Block ], { ...params, assert:false, meta:null }) || parseCallback(onFalse, null, { ...params, meta:null });
}

@@ -94,0 +94,0 @@ return new this(assertion, onTrue, onFalse, {

@@ -60,4 +60,4 @@

var meta = createMeta();
var parsed = Expr.parse(expr, (_expr, _grammar, _params = {}) => {
var subStmt = this.parse(_expr, _grammar, _params ? _merge({}, params, _params) : params);
var parsed = Expr.parse(expr, (_expr, _grammar, _params = null) => {
var subStmt = this.parse(_expr, _grammar, _params ? _params : params);
if (subStmt instanceof ReferenceInterface) {

@@ -129,2 +129,3 @@ var hasCallHead, _context = subStmt;

}
};

@@ -131,0 +132,0 @@

@@ -35,9 +35,9 @@

}
Object.defineProperty(this, 'stack', {value: stack || {}, enumerable: false});
Object.defineProperty(this, 'params', {value: params || {}, enumerable: false});
Object.defineProperty(this, 'stack', { value: stack || {}, enumerable: false });
Object.defineProperty(this, 'params', { value: params || {}, enumerable: false });
if (stack.super) {
Object.defineProperty(this.stack, 'super', {value: Scope.create(stack.super, {errorLevel: params.errorLevel}), enumerable: false});
Object.defineProperty(this.stack, 'super', { value: Scope.create(stack.super, { errorLevel: params.errorLevel }), enumerable: false });
}
Object.defineProperty(this.stack, 'local', {value: stack.local || {}, enumerable: false});
Object.defineProperty(this.stack, '$local', {value: stack.$local || {}, enumerable: false});
Object.defineProperty(this.stack, 'local', { value: stack.local || {}, enumerable: false });
Object.defineProperty(this.stack, '$local', { value: stack.$local || {}, enumerable: false });
}

@@ -185,3 +185,3 @@

set(prop, val, trap = {}, initKeyword = false, isRootVar = true) {
if (this.params.type === 2 && initKeyword === 'var' && this.stack.super) {
if (this.params.scopeType === 2 && initKeyword === 'var' && this.stack.super) {
return this.stack.super.set(prop, val, trap, initKeyword);

@@ -217,3 +217,3 @@ }

} catch(e) {
if ((e instanceof ReferenceError) && contxtObj && !localContxtMeta && level === 0 && this.params.strictMode === false) {
if ((e instanceof ReferenceError) && contxtObj && (!isRootVar || this.params.strictMode === false) && !localContxtMeta/* when on main */ && level === 0) {
// Assign to undeclared variables

@@ -332,3 +332,3 @@ return _set(contxtObj, prop, val, trap);

}
var scopeObj = {};
var scopeObj = params.scopeObj || {};
if (trap.set) {

@@ -335,0 +335,0 @@ trap.set(scopeObj, 'main', cntxt);

@@ -6,10 +6,112 @@

import { expect } from 'chai';
import { Parser } from '../src/index.js';
import { Block } from '../src/grammar.js';
describe(`Test: AST`, function() {
/**
before('Import into DB', async function() {
describe(`Object syntax`, function() {
it(`Should parse simple object expression: { prop1: value1, prop2: "String value2", prop3: 3 }`, function() {
var expr = `{ prop1: value1, prop2: "String value2", prop3: 3 }`;
var AST = Parser.parse(expr);
var VAL = AST.eval();
expect(AST + '').to.eq(expr);
expect(VAL).to.eql({ prop1: undefined, prop2: 'String value2', prop3: 3 });
});
it(`Should parse dynamic object expression: { [prop1]: value1, "prop 2": "String value2", prop3, [prop4], 'ddd': 'ddd' }`, function() {
var expr = `{ [prop1]: value1, "prop 2": "String value2", prop3, [prop4], 'ddd': 'ddd' }`;
var AST = Parser.parse(expr);
var VAL = AST.eval({ prop4: 'dynamicProp' });
expect(AST + '').to.eq(expr);
expect(VAL).to.eql({ undefined: undefined, 'prop 2': 'String value2', prop3: undefined, dynamicProp: 'dynamicProp', ddd: 'ddd' });
});
});
*/
describe(`Abstraction () syntax`, function() {
it(`Should parse simple abstraction expression: (4 + 10)`, function() {
var expr = `(4 + 10)`;
var AST = Parser.parse(expr);
var VAL = AST.eval();
expect(AST + '').to.eq(expr);
expect(VAL).to.eql(14);
});
it(`Should parse multiple statement abstraction expression: (4 + 10, 555 + 1)`, function() {
var expr = `(4 + 10, 555 + 1)`;
var AST = Parser.parse(expr);
var VAL = AST.eval();
expect(AST + '').to.eq(expr);
expect(VAL).to.eql(556);
});
});
describe(`Assignment syntax`, function() {
it(`Should parse simple assignment expression: aa = 4 + 10`, function() {
var expr = `aa = 4 + 10`;
var AST = Parser.parse(expr);
var CONTEXT = { aa: 0 };
var VAL = AST.eval(CONTEXT, {strictMode: false});
expect(AST + '').to.eq(expr);
expect(VAL).to.eq(14);
expect(CONTEXT).to.eql({ aa: 14 });
});
it(`Should parse path assignment expression: bb.rr = 4 + 10`, function() {
var expr = `bb.rr = 4 + 10`;
var AST = Parser.parse(expr);
var CONTEXT = { bb: {} };
var VAL = AST.eval(CONTEXT);
expect(AST + '').to.eq(expr);
expect(VAL).to.eq(14);
expect(CONTEXT).to.eql({ bb: { rr: 14 } });
});
});
describe(`Variable decalarations syntax`, function() {
it(`Should parse simple variable decalaration: var aa = 4 + 10`, function() {
var expr = `var aa = 4 + 10`;
var AST = Parser.parse(expr);
var SCOPEOBJ = {};
var CONTEXT = {};
var VAL = AST.eval(CONTEXT, { scopeObj: SCOPEOBJ });
expect(SCOPEOBJ.local).to.eql({ aa: 14 });
});
it(`Should parse multiple variable decalarations: var aa = 4 + 10, bb = 2, cc, dd = 3, ee`, function() {
var expr = `var aa = 4 + 10, bb = 2, cc, dd = 3, ee`;
var AST = Parser.parse(expr);
var SCOPEOBJ = {};
var CONTEXT = {};
var VAL = AST.eval(CONTEXT, { scopeObj: SCOPEOBJ });
expect(SCOPEOBJ.local).to.eql({ aa: 14, bb: 2, cc: undefined, dd: 3, ee: undefined });
});
});
describe(`Statement block syntax`, function() {
it(`Should parse simple statement block: var aa = 4 + 10; console.log(aa);`, function() {
var expr = `var aa = 4 + 10; console.log(aa);`;
var AST = Parser.parse(expr, [ Block ]);
var SCOPEOBJ = {};
var CONTEXT = {};
var VAL = AST.eval(CONTEXT, { scopeObj: SCOPEOBJ });
expect(SCOPEOBJ.local).to.eql({ aa: 14 });
});
it(`Should parse complex statement block: var aa = 4 + 10, bb = 2, cc, dd = 3, ee = (b, 20); if (w) {} console.log(aa), console.log(bb);`, function() {
var expr = `var aa = 4 + 10, bb = 2, cc, dd = 3, ee = (b, 20); if (w) {} console.log(aa)\r\n console.log(bb);`;
var AST = Parser.parse(expr, [ Block ]);
var SCOPEOBJ = {};
var CONTEXT = {};
var VAL = AST.eval(CONTEXT, { scopeObj: SCOPEOBJ });
expect(SCOPEOBJ.local).to.eql({ aa: 14, bb: 2, cc: undefined, dd: 3, ee: 20 });
});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc