diff --git a/CHANGES.md b/CHANGES.md index 6e3964c..5ebd7d6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # CHANGES for jsonpath-plus +## 11.2.1 + +- fix(safe eval): support the `??` and `**` operators + ## 11.2.0 - feat: allow arg to other type callbacks diff --git a/badges/tests-badge.svg b/badges/tests-badge.svg index d83b52a..946b3d1 100644 --- a/badges/tests-badge.svg +++ b/badges/tests-badge.svg @@ -1 +1 @@ -TestsTests362/362362/362 \ No newline at end of file +TestsTests366/366366/366 \ No newline at end of file diff --git a/dist/index-browser-esm.js b/dist/index-browser-esm.js index 42d2cef..f3e26a2 100644 --- a/dist/index-browser-esm.js +++ b/dist/index-browser-esm.js @@ -1279,6 +1279,7 @@ const getSafeProperty = (obj, prop) => { // eslint-disable-next-line @stylistic/max-len -- Long const BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */{ '||': (a, b) => a || b(), + '??': (a, b) => a ?? b(), '&&': (a, b) => a && b(), '|': (a, b) => a | b(), '^': (a, b) => a ^ b(), @@ -1300,7 +1301,8 @@ const BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */{ '-': (a, b) => a - b(), '*': (a, b) => a * b(), '/': (a, b) => a / b(), - '%': (a, b) => a % b() + '%': (a, b) => a % b(), + '**': (a, b) => a ** b() }); /** diff --git a/dist/index-browser-esm.min.js b/dist/index-browser-esm.min.js index c813a26..fc384fc 100644 --- a/dist/index-browser-esm.min.js +++ b/dist/index-browser-esm.min.js @@ -1,2 +1,2 @@ -class e{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+e.version}static addUnaryOp(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}static addBinaryOp(t,r,s){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,s?e.right_associative.add(t):e.right_associative.delete(t),e}static addIdentifierChar(t){return e.additional_identifier_chars.add(t),e}static addLiteral(t,r){return e.literals[t]=r,e}static removeUnaryOp(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}static removeAllUnaryOps(){return e.unary_ops={},e.max_unop_len=0,e}static removeIdentifierChar(t){return e.additional_identifier_chars.delete(t),e}static removeBinaryOp(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}static removeAllBinaryOps(){return e.binary_ops={},e.max_binop_len=0,e}static removeLiteral(t){return delete e.literals[t],e}static removeAllLiterals(){return e.literals={},e}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(t){return new e(t).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(e=>e.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(t){return e.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(t,r){if(e.hooks[t]){const s={context:this,node:r};return e.hooks.run(t,s),s.node}return r}searchHook(t){if(e.hooks[t]){const r={context:this};return e.hooks[t].find(function(e){return e.call(r.context,r),r.node}),r.node}}gobbleSpaces(){let t=this.code;for(;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const t=this.gobbleExpressions(),r=1===t.length?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}gobbleExpressions(t){let r,s,n=[];for(;this.index0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.lengthi.right_a&&e.right_a?s>e.prec:s<=e.prec;for(;n.length>2&&h(n[n.length-2]);)a=n.pop(),r=n.pop().value,o=n.pop(),t={type:e.BINARY_EXP,operator:r,left:o,right:a},n.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+c),n.push(i,t)}for(h=n.length-1,t=n[h];h>1;)t={type:e.BINARY_EXP,operator:n[h-1].value,left:n[h-2],right:t},h-=2;return t}gobbleToken(){let t,r,s,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)n=this.gobbleArray();else{for(r=this.expr.substr(this.index,e.max_unop_len),s=r.length;s>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(i===e.COMMA_CODE){if(this.index++,n++,n!==r.length)if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(let e=r.length;e{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(e),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),e.max_unop_len=e.getMaxKeyLen(e.unary_ops),e.max_binop_len=e.getMaxKeyLen(e.binary_ops);const r=t=>new e(t).parse(),s=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(e).filter(e=>!s.includes(e)&&void 0===r[e]).forEach(t=>{r[t]=e[t]}),r.Jsep=e;var n={name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,s=this.gobbleExpression();if(s||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const n=this.gobbleExpression();if(n||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:s,alternate:n},r.operator&&e.binary_ops[r.operator]<=.9){let s=r;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;t.node.test=s.right,s.right=t.node,t.node=r}}else this.throwError("Expected :")}})}};r.plugins.register(n);var i={name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){const r=++this.index;let s=!1;for(;this.index=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;i+=this.char}try{n=new RegExp(s,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?s=!0:s&&this.code===e.CBRACK_CODE&&(s=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}};const o={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){o.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach(e=>{e&&"object"==typeof e&&r(e)})}o.assignmentOperators.forEach(t=>e.addBinaryOp(t,o.assignmentPrecedence,!0)),e.hooks.add("gobble-token",function(e){const r=this.code;o.updateOperators.some(e=>e===r&&e===this.expr.charCodeAt(this.index+1))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))}),e.hooks.add("after-token",function(e){if(e.node){const r=this.code;o.updateOperators.some(e=>e===r&&e===this.expr.charCodeAt(this.index+1))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}}),e.hooks.add("after-expression",function(e){e.node&&r(e.node)})}};r.plugins.register(i,o),r.addUnaryOp("typeof"),r.addUnaryOp("void"),r.addLiteral("null",null),r.addLiteral("undefined",void 0);const a=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),h=new WeakSet([Function,function*(){}.constructor,async function(){}.constructor,async function*(){}.constructor,Function.prototype.call,Function.prototype.apply,Function.prototype.bind,Reflect.apply,Reflect.construct,...[...a].map(e=>Reflect.get(Object.prototype,e)).filter(e=>"function"==typeof e)]),c=e=>"function"==typeof e&&h.has(e),l=(e,t)=>{if(null==e)throw new TypeError(`Cannot read properties of ${e} (reading '${t}')`);if(!Object.hasOwn(e,t)&&a.has(t))throw new TypeError(`Cannot read properties of ${e} (reading '${t}')`);const r=e[t];if(c(r))throw new TypeError("Function constructor is disabled");return r},p=Object.assign(Object.create(null),{"||":(e,t)=>e||t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t()}),u=Object.assign(Object.create(null),{"-":e=>-e,"!":e=>!e,"~":e=>~e,"+":e=>+e,typeof:e=>typeof e,void:()=>{}}),d={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return d.evalBinaryExpression(e,t);case"Compound":return d.evalCompound(e,t);case"ConditionalExpression":return d.evalConditionalExpression(e,t);case"Identifier":return d.evalIdentifier(e,t);case"Literal":return d.evalLiteral(e);case"MemberExpression":return d.evalMemberExpression(e,t);case"UnaryExpression":return d.evalUnaryExpression(e,t);case"ArrayExpression":return d.evalArrayExpression(e,t);case"CallExpression":return d.evalCallExpression(e,t);case"AssignmentExpression":return d.evalAssignmentExpression(e,t);default:throw new SyntaxError("Unexpected expression",{cause:e})}},evalBinaryExpression(e,t){if(!Object.hasOwn(p,e.operator))throw new SyntaxError(`Unknown binary operator: ${e.operator}`);return p[e.operator](d.evalAst(e.left,t),()=>d.evalAst(e.right,t))},evalCompound(e,t){let r;for(let s=0;sd.evalAst(e.test,t)?d.evalAst(e.consequent,t):d.evalAst(e.alternate,t),evalIdentifier(e,t){if(Object.hasOwn(t,e.name))return t[e.name];throw new ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){const r=String(e.computed?d.evalAst(e.property,t):e.property.name),s=d.evalAst(e.object,t),n=l(s,r);return"function"==typeof n?n.bind(s):n},evalUnaryExpression(e,t){if(!Object.hasOwn(u,e.operator))throw new SyntaxError(`Unknown unary operator: ${e.operator}`);const r=d.evalAst(e.argument,t);return u[e.operator](r)},evalArrayExpression:(e,t)=>e.elements.map(e=>d.evalAst(e,t)),evalCallExpression(e,t){const r=e.arguments.map(e=>d.evalAst(e,t)),s=d.evalAst(e.callee,t);if(c(s)||r.some(e=>c(e)))throw new Error("Function constructor is disabled");return s(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw new SyntaxError("Invalid left-hand side in assignment");const r=e.left.name,s=d.evalAst(e.right,t);return t[r]=s,t[r]}};const f=new Map,b=new Map;function y(e,t){return(e=e.slice()).push(t),e}function E(e,t){return(t=t.slice()).unshift(e),t}function g(e,t,r,s,n){try{return e&&"object"==typeof e?new x(e):new x(e,t,r,s,n)}catch(e){if(new.target)throw e;if(e&&"object"==typeof e&&"value"in e)return e.value;throw e}}class x{constructor(e,t,r,s,n){"string"==typeof e&&(n=s,s=r,r=t,t=e,e=null);const i=e&&"object"==typeof e;if(e||={},this.currResultType=void 0,this.currEval=void 0,this.currOtherTypeCallback=void 0,this.currCustomTypes=void 0,this.currSandbox=void 0,this._hasParentSelector=!1,this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=Object.hasOwn(e,"flatten")&&e.flatten,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=Object.hasOwn(e,"parent")?e.parent:null,this.parentProperty=Object.hasOwn(e,"parentProperty")?e.parentProperty:null,this.callback=e.callback||s||null,this.otherTypeCallback=e.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},this.customTypes=e.customTypes||{},!1===e.autostart)return;const o={path:i?e.path:t};i||void 0===r?"json"in e&&(o.json=e.json):o.json=r;const a=this.evaluate(o);if(!a||"object"!=typeof a){const e=new Error('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');throw e.value=a,e}return a}evaluate(e,t,r,s){let n=this.parent,i=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r||=this.callback,this.currOtherTypeCallback=s||this.otherTypeCallback,this.currCustomTypes=this.customTypes,e&&"object"==typeof e&&!Array.isArray(e)){const s=e;if(!s.path&&""!==s.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(s,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=s),o=Object.hasOwn(s,"flatten")?s.flatten:o,this.currResultType=Object.hasOwn(s,"resultType")?s.resultType:this.currResultType,this.currSandbox=Object.hasOwn(s,"sandbox")?s.sandbox:this.currSandbox,a=Object.hasOwn(s,"wrap")?s.wrap:a,this.currEval=Object.hasOwn(s,"eval")?s.eval:this.currEval,r=Object.hasOwn(s,"callback")?s.callback:r,this.currOtherTypeCallback=Object.hasOwn(s,"otherTypeCallback")?s.otherTypeCallback:this.currOtherTypeCallback,this.currCustomTypes=Object.hasOwn(s,"customTypes")?s.customTypes:this.currCustomTypes,n=Object.hasOwn(s,"parent")?s.parent:n,i=Object.hasOwn(s,"parentProperty")?s.parentProperty:i,e=s.path}else t||=this.json,e||=this.path;if(n||=null,i||=null,Array.isArray(e)&&(e=g.toPathString(e)),!t||!e&&""!==e)return;const h=g.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=!1;const c=this._trace(h,t,["$"],n,i,r??void 0,void 0),l=(Array.isArray(c)?c:[c]).filter(e=>e&&!e.isParentSelector);if(!l.length)return a?[]:void 0;if(!a&&1===l.length&&!l[0].hasArrExpr){return this._getPreferredOutput(l[0])}return l.reduce((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e},[])}_getPreferredOutput(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:g.toPathArray(e.path);return e.pointer=g.toPointer(t),e.path="string"==typeof e.path?e.path:g.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return"string"==typeof e.path?e.path:g.toPathString(e.path);case"pointer":{const t=Array.isArray(e.path)?e.path:g.toPathArray(e.path);return g.toPointer(t)}default:throw new TypeError("Unknown result type")}}_handleCallback(e,t,r){if(!t)return;const s=this._getPreferredOutput(e);Array.isArray(e.path)&&(e.path=g.toPathString(e.path)),t(s,r,e)}_trace(e,t,r,s,n,i,o,a){let h;if(!e.length)return h={path:r,value:t,parent:s,parentProperty:n,hasArrExpr:o},this._handleCallback(h,i,"value"),h;const c=e[0],p=e.slice(1),u=[];function d(e){Array.isArray(e)?e.forEach(e=>{u.push(e)}):u.push(e)}if(t&&("string"!=typeof c||a)&&Object.hasOwn(t,c)){const e=t;d(this._trace(p,e[c],y(r,c),t,c,i,o))}else if("*"===c)this._walk(t,e=>{const s=t;d(this._trace(p,s[e],y(r,e),t,e,i,!0,!0))});else if(".."===c)d(this._trace(p,t,r,s,n,i,o)),this._walk(t,s=>{const n=t;"object"==typeof n[s]&&d(this._trace(e.slice(),n[s],y(r,s),t,s,i,!0))});else{if("^"===c)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:p,isParentSelector:!0,value:void 0,parent:void 0,parentProperty:null};if("~"===c)return h={path:y(r,c),value:n,parent:s,parentProperty:null},this._handleCallback(h,i,"property"),h;if("$"===c)d(this._trace(p,t,r,null,null,i,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/v.test(c)){const e=this._slice(c,p,t,r,s,n,i);e&&d(e)}else if(0===c.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=c.replace(/^\?\((.*?)\)$/v,"$1"),o=/@.?([^?]*)[\['](\??\(.*?\))(?!.\)\])[\]']/gv.exec(e);if(o)this._walk(t,e=>{const a=[o[2]],h=t,c=o[1]?l(h[e],o[1]):h[e],u=this._trace(a,c,r,s,n,i,!0);(Array.isArray(u)?u:[u]).length>0&&d(this._trace(p,h[e],y(r,e),t,e,i,!0))});else{const o=t;this._walk(t,a=>{this._eval(e,o[a],a,r,s,n)&&d(this._trace(p,o[a],y(r,a),t,a,i,!0))})}}else if("("===c[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");const e=this._eval(c,t,r.at(-1),r.slice(0,-1),s,n),a=void 0!==e?e:"";d(this._trace(E(a,p),t,r,s,n,i,o))}else if("@"===c[0]){let e=!1;const o=c.indexOf("("),a=c.slice(1,o),l=c.lastIndexOf(")"),p=c.slice(o+1,l),u=p?JSON.parse(p):void 0;switch(a){case"scalar":e=!t||!["object","function"].includes(typeof t);break;case"boolean":case"string":case"undefined":case"function":e=typeof t===a;break;case"integer":e=Number.isFinite(t)&&!(t%1);break;case"number":e=Number.isFinite(t);break;case"nonFinite":e="number"==typeof t&&!Number.isFinite(t);break;case"object":e=Boolean(t)&&typeof t===a;break;case"array":e=Array.isArray(t);break;case"other":e=this.currOtherTypeCallback(t,r,s,n,u)||!1;break;case"null":e=null===t;break;case"symbol":e="symbol"==typeof t;break;case"BigInt":e="bigint"==typeof t;break;case"Promise":e="Promise"===(e=>Object.prototype.toString.call(e).slice(8,-1))(t);break;case"jsonReference":e=Boolean(t)&&"object"==typeof t&&Object.hasOwn(t,"$ref");break;default:if(!this.currCustomTypes||!Object.hasOwn(this.currCustomTypes,a))throw new TypeError("Unknown value type "+a);e=this.currCustomTypes[a](t,r,s,n,u)||!1}if(e)return h={path:r,value:t,parent:s,parentProperty:n},this._handleCallback(h,i,"value"),h}else if(t&&"`"===c[0]&&Object.hasOwn(t,c.slice(1))){const e=c.slice(1),s=t;d(this._trace(p,s[e],y(r,e),t,e,i,o,!0))}else if("'"===c[0]||'"'===c[0])for(const[,e,s]of c.matchAll(/'((?:\\.|[^'\\])*)'|"((?:\\.|[^"\\])*)"/gv)){const n=(e??s).replaceAll(/\\(['"\\])/gv,"$1");if(!t||!Object.hasOwn(t,n))continue;const o=t;d(this._trace(p,o[n],y(r,n),t,n,i,!0))}else if(c.includes(",")){const e=c.split(",");for(const o of e)d(this._trace(E(o,p),t,r,s,n,i,!0))}else if(!a&&t&&Object.hasOwn(t,c)){const e=t;d(this._trace(p,e[c],y(r,c),t,c,i,o,!0))}}if(this._hasParentSelector)for(let e=0;e{t(e)})}_slice(e,t,r,s,n,i,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),c=h[2]&&Number(h[2])||1;let l=h[0]&&Number(h[0])||0,p=h[1]?Number(h[1]):a;l=l<0?Math.max(0,l+a):Math.min(a,l),p=p<0?Math.max(0,p+a):Math.min(a,p);const u=[];for(let e=l;e{u.push(e)})}return u}_eval(e,t,r,s,n,i){this.currSandbox&&(this.currSandbox._$_parentProperty=i,this.currSandbox._$_parent=n,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t);const o=e.includes("@path");if(o){(this.currSandbox??{})._$_path=g.toPathString(s.concat([r]))}const a=this.currEval+"Script:"+e;if(!f.has(a)){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/('(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|(?<=(?:^|[\(,=:\[!\|?\{\};+\-*%<>~^]|&)\s*)\/(?:\\.|\[(?:\\.|[^\]\\])*\]|[^\/\\\[])+\/[dgimsuvy]*)|@(?![\w$])/gv,(e,t)=>t??"_$_v");o&&(t=t.replaceAll("@path","_$_path"));const r=this.currEval;if(["safe",!0,void 0].includes(r))f.set(a,new this.safeVm.Script(t));else if("native"===this.currEval)f.set(a,new this.vm.Script(t));else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;f.set(a,new e(t))}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);{const e=this.currEval;f.set(a,{runInNewContext:r=>e(t,r)})}}}try{return f.get(a).runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e,{cause:t})}}}x.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=r(this.code)}runInNewContext(e){const t=Object.assign(Object.create(null),e);return d.evalAst(this.ast,t)}}},g.prototype=x.prototype,g.clearCache=function(){b.clear(),f.clear()},g.toPathString=function(e){const t=e,r=t.length;let s="$";for(let e=1;e"function"==typeof e[t]);const n=r.map(t=>e[t]);t=s.reduce((t,r)=>{let s=e[r].toString();return/function/v.test(s)||(s="function "+s),"var "+r+"="+s+";"+t},"")+t,/(['"])use strict\1/v.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/v,"");const i=t.lastIndexOf(";"),o=-1!==i?t.slice(0,i+1)+" return "+t.slice(i+1):" return "+t;return new Function(...r,o)(...n)}}x.prototype.vm={Script:_};export{g as JSONPath,x as JSONPathClass,_ as Script}; +class e{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+e.version}static addUnaryOp(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}static addBinaryOp(t,r,s){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,s?e.right_associative.add(t):e.right_associative.delete(t),e}static addIdentifierChar(t){return e.additional_identifier_chars.add(t),e}static addLiteral(t,r){return e.literals[t]=r,e}static removeUnaryOp(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}static removeAllUnaryOps(){return e.unary_ops={},e.max_unop_len=0,e}static removeIdentifierChar(t){return e.additional_identifier_chars.delete(t),e}static removeBinaryOp(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}static removeAllBinaryOps(){return e.binary_ops={},e.max_binop_len=0,e}static removeLiteral(t){return delete e.literals[t],e}static removeAllLiterals(){return e.literals={},e}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(t){return new e(t).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(e=>e.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(t){return e.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(t,r){if(e.hooks[t]){const s={context:this,node:r};return e.hooks.run(t,s),s.node}return r}searchHook(t){if(e.hooks[t]){const r={context:this};return e.hooks[t].find(function(e){return e.call(r.context,r),r.node}),r.node}}gobbleSpaces(){let t=this.code;for(;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const t=this.gobbleExpressions(),r=1===t.length?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}gobbleExpressions(t){let r,s,n=[];for(;this.index0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.lengthi.right_a&&e.right_a?s>e.prec:s<=e.prec;for(;n.length>2&&h(n[n.length-2]);)a=n.pop(),r=n.pop().value,o=n.pop(),t={type:e.BINARY_EXP,operator:r,left:o,right:a},n.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+c),n.push(i,t)}for(h=n.length-1,t=n[h];h>1;)t={type:e.BINARY_EXP,operator:n[h-1].value,left:n[h-2],right:t},h-=2;return t}gobbleToken(){let t,r,s,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)n=this.gobbleArray();else{for(r=this.expr.substr(this.index,e.max_unop_len),s=r.length;s>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}if(i===e.COMMA_CODE){if(this.index++,n++,n!==r.length)if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(let e=r.length;e{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(e),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),e.max_unop_len=e.getMaxKeyLen(e.unary_ops),e.max_binop_len=e.getMaxKeyLen(e.binary_ops);const r=t=>new e(t).parse(),s=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(e).filter(e=>!s.includes(e)&&void 0===r[e]).forEach(t=>{r[t]=e[t]}),r.Jsep=e;var n={name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,s=this.gobbleExpression();if(s||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const n=this.gobbleExpression();if(n||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:s,alternate:n},r.operator&&e.binary_ops[r.operator]<=.9){let s=r;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;t.node.test=s.right,s.right=t.node,t.node=r}}else this.throwError("Expected :")}})}};r.plugins.register(n);var i={name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){const r=++this.index;let s=!1;for(;this.index=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;i+=this.char}try{n=new RegExp(s,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?s=!0:s&&this.code===e.CBRACK_CODE&&(s=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}};const o={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){o.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach(e=>{e&&"object"==typeof e&&r(e)})}o.assignmentOperators.forEach(t=>e.addBinaryOp(t,o.assignmentPrecedence,!0)),e.hooks.add("gobble-token",function(e){const r=this.code;o.updateOperators.some(e=>e===r&&e===this.expr.charCodeAt(this.index+1))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))}),e.hooks.add("after-token",function(e){if(e.node){const r=this.code;o.updateOperators.some(e=>e===r&&e===this.expr.charCodeAt(this.index+1))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}}),e.hooks.add("after-expression",function(e){e.node&&r(e.node)})}};r.plugins.register(i,o),r.addUnaryOp("typeof"),r.addUnaryOp("void"),r.addLiteral("null",null),r.addLiteral("undefined",void 0);const a=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),h=new WeakSet([Function,function*(){}.constructor,async function(){}.constructor,async function*(){}.constructor,Function.prototype.call,Function.prototype.apply,Function.prototype.bind,Reflect.apply,Reflect.construct,...[...a].map(e=>Reflect.get(Object.prototype,e)).filter(e=>"function"==typeof e)]),c=e=>"function"==typeof e&&h.has(e),l=(e,t)=>{if(null==e)throw new TypeError(`Cannot read properties of ${e} (reading '${t}')`);if(!Object.hasOwn(e,t)&&a.has(t))throw new TypeError(`Cannot read properties of ${e} (reading '${t}')`);const r=e[t];if(c(r))throw new TypeError("Function constructor is disabled");return r},p=Object.assign(Object.create(null),{"||":(e,t)=>e||t(),"??":(e,t)=>e??t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t(),"**":(e,t)=>e**t()}),u=Object.assign(Object.create(null),{"-":e=>-e,"!":e=>!e,"~":e=>~e,"+":e=>+e,typeof:e=>typeof e,void:()=>{}}),d={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return d.evalBinaryExpression(e,t);case"Compound":return d.evalCompound(e,t);case"ConditionalExpression":return d.evalConditionalExpression(e,t);case"Identifier":return d.evalIdentifier(e,t);case"Literal":return d.evalLiteral(e);case"MemberExpression":return d.evalMemberExpression(e,t);case"UnaryExpression":return d.evalUnaryExpression(e,t);case"ArrayExpression":return d.evalArrayExpression(e,t);case"CallExpression":return d.evalCallExpression(e,t);case"AssignmentExpression":return d.evalAssignmentExpression(e,t);default:throw new SyntaxError("Unexpected expression",{cause:e})}},evalBinaryExpression(e,t){if(!Object.hasOwn(p,e.operator))throw new SyntaxError(`Unknown binary operator: ${e.operator}`);return p[e.operator](d.evalAst(e.left,t),()=>d.evalAst(e.right,t))},evalCompound(e,t){let r;for(let s=0;sd.evalAst(e.test,t)?d.evalAst(e.consequent,t):d.evalAst(e.alternate,t),evalIdentifier(e,t){if(Object.hasOwn(t,e.name))return t[e.name];throw new ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){const r=String(e.computed?d.evalAst(e.property,t):e.property.name),s=d.evalAst(e.object,t),n=l(s,r);return"function"==typeof n?n.bind(s):n},evalUnaryExpression(e,t){if(!Object.hasOwn(u,e.operator))throw new SyntaxError(`Unknown unary operator: ${e.operator}`);const r=d.evalAst(e.argument,t);return u[e.operator](r)},evalArrayExpression:(e,t)=>e.elements.map(e=>d.evalAst(e,t)),evalCallExpression(e,t){const r=e.arguments.map(e=>d.evalAst(e,t)),s=d.evalAst(e.callee,t);if(c(s)||r.some(e=>c(e)))throw new Error("Function constructor is disabled");return s(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw new SyntaxError("Invalid left-hand side in assignment");const r=e.left.name,s=d.evalAst(e.right,t);return t[r]=s,t[r]}};const f=new Map,b=new Map;function y(e,t){return(e=e.slice()).push(t),e}function E(e,t){return(t=t.slice()).unshift(e),t}function g(e,t,r,s,n){try{return e&&"object"==typeof e?new x(e):new x(e,t,r,s,n)}catch(e){if(new.target)throw e;if(e&&"object"==typeof e&&"value"in e)return e.value;throw e}}class x{constructor(e,t,r,s,n){"string"==typeof e&&(n=s,s=r,r=t,t=e,e=null);const i=e&&"object"==typeof e;if(e||={},this.currResultType=void 0,this.currEval=void 0,this.currOtherTypeCallback=void 0,this.currCustomTypes=void 0,this.currSandbox=void 0,this._hasParentSelector=!1,this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=Object.hasOwn(e,"flatten")&&e.flatten,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=Object.hasOwn(e,"parent")?e.parent:null,this.parentProperty=Object.hasOwn(e,"parentProperty")?e.parentProperty:null,this.callback=e.callback||s||null,this.otherTypeCallback=e.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},this.customTypes=e.customTypes||{},!1===e.autostart)return;const o={path:i?e.path:t};i||void 0===r?"json"in e&&(o.json=e.json):o.json=r;const a=this.evaluate(o);if(!a||"object"!=typeof a){const e=new Error('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');throw e.value=a,e}return a}evaluate(e,t,r,s){let n=this.parent,i=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r||=this.callback,this.currOtherTypeCallback=s||this.otherTypeCallback,this.currCustomTypes=this.customTypes,e&&"object"==typeof e&&!Array.isArray(e)){const s=e;if(!s.path&&""!==s.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(s,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=s),o=Object.hasOwn(s,"flatten")?s.flatten:o,this.currResultType=Object.hasOwn(s,"resultType")?s.resultType:this.currResultType,this.currSandbox=Object.hasOwn(s,"sandbox")?s.sandbox:this.currSandbox,a=Object.hasOwn(s,"wrap")?s.wrap:a,this.currEval=Object.hasOwn(s,"eval")?s.eval:this.currEval,r=Object.hasOwn(s,"callback")?s.callback:r,this.currOtherTypeCallback=Object.hasOwn(s,"otherTypeCallback")?s.otherTypeCallback:this.currOtherTypeCallback,this.currCustomTypes=Object.hasOwn(s,"customTypes")?s.customTypes:this.currCustomTypes,n=Object.hasOwn(s,"parent")?s.parent:n,i=Object.hasOwn(s,"parentProperty")?s.parentProperty:i,e=s.path}else t||=this.json,e||=this.path;if(n||=null,i||=null,Array.isArray(e)&&(e=g.toPathString(e)),!t||!e&&""!==e)return;const h=g.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=!1;const c=this._trace(h,t,["$"],n,i,r??void 0,void 0),l=(Array.isArray(c)?c:[c]).filter(e=>e&&!e.isParentSelector);if(!l.length)return a?[]:void 0;if(!a&&1===l.length&&!l[0].hasArrExpr){return this._getPreferredOutput(l[0])}return l.reduce((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e},[])}_getPreferredOutput(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:g.toPathArray(e.path);return e.pointer=g.toPointer(t),e.path="string"==typeof e.path?e.path:g.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return"string"==typeof e.path?e.path:g.toPathString(e.path);case"pointer":{const t=Array.isArray(e.path)?e.path:g.toPathArray(e.path);return g.toPointer(t)}default:throw new TypeError("Unknown result type")}}_handleCallback(e,t,r){if(!t)return;const s=this._getPreferredOutput(e);Array.isArray(e.path)&&(e.path=g.toPathString(e.path)),t(s,r,e)}_trace(e,t,r,s,n,i,o,a){let h;if(!e.length)return h={path:r,value:t,parent:s,parentProperty:n,hasArrExpr:o},this._handleCallback(h,i,"value"),h;const c=e[0],p=e.slice(1),u=[];function d(e){Array.isArray(e)?e.forEach(e=>{u.push(e)}):u.push(e)}if(t&&("string"!=typeof c||a)&&Object.hasOwn(t,c)){const e=t;d(this._trace(p,e[c],y(r,c),t,c,i,o))}else if("*"===c)this._walk(t,e=>{const s=t;d(this._trace(p,s[e],y(r,e),t,e,i,!0,!0))});else if(".."===c)d(this._trace(p,t,r,s,n,i,o)),this._walk(t,s=>{const n=t;"object"==typeof n[s]&&d(this._trace(e.slice(),n[s],y(r,s),t,s,i,!0))});else{if("^"===c)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:p,isParentSelector:!0,value:void 0,parent:void 0,parentProperty:null};if("~"===c)return h={path:y(r,c),value:n,parent:s,parentProperty:null},this._handleCallback(h,i,"property"),h;if("$"===c)d(this._trace(p,t,r,null,null,i,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/v.test(c)){const e=this._slice(c,p,t,r,s,n,i);e&&d(e)}else if(0===c.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=c.replace(/^\?\((.*?)\)$/v,"$1"),o=/@.?([^?]*)[\['](\??\(.*?\))(?!.\)\])[\]']/gv.exec(e);if(o)this._walk(t,e=>{const a=[o[2]],h=t,c=o[1]?l(h[e],o[1]):h[e],u=this._trace(a,c,r,s,n,i,!0);(Array.isArray(u)?u:[u]).length>0&&d(this._trace(p,h[e],y(r,e),t,e,i,!0))});else{const o=t;this._walk(t,a=>{this._eval(e,o[a],a,r,s,n)&&d(this._trace(p,o[a],y(r,a),t,a,i,!0))})}}else if("("===c[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");const e=this._eval(c,t,r.at(-1),r.slice(0,-1),s,n),a=void 0!==e?e:"";d(this._trace(E(a,p),t,r,s,n,i,o))}else if("@"===c[0]){let e=!1;const o=c.indexOf("("),a=c.slice(1,o),l=c.lastIndexOf(")"),p=c.slice(o+1,l),u=p?JSON.parse(p):void 0;switch(a){case"scalar":e=!t||!["object","function"].includes(typeof t);break;case"boolean":case"string":case"undefined":case"function":e=typeof t===a;break;case"integer":e=Number.isFinite(t)&&!(t%1);break;case"number":e=Number.isFinite(t);break;case"nonFinite":e="number"==typeof t&&!Number.isFinite(t);break;case"object":e=Boolean(t)&&typeof t===a;break;case"array":e=Array.isArray(t);break;case"other":e=this.currOtherTypeCallback(t,r,s,n,u)||!1;break;case"null":e=null===t;break;case"symbol":e="symbol"==typeof t;break;case"BigInt":e="bigint"==typeof t;break;case"Promise":e="Promise"===(e=>Object.prototype.toString.call(e).slice(8,-1))(t);break;case"jsonReference":e=Boolean(t)&&"object"==typeof t&&Object.hasOwn(t,"$ref");break;default:if(!this.currCustomTypes||!Object.hasOwn(this.currCustomTypes,a))throw new TypeError("Unknown value type "+a);e=this.currCustomTypes[a](t,r,s,n,u)||!1}if(e)return h={path:r,value:t,parent:s,parentProperty:n},this._handleCallback(h,i,"value"),h}else if(t&&"`"===c[0]&&Object.hasOwn(t,c.slice(1))){const e=c.slice(1),s=t;d(this._trace(p,s[e],y(r,e),t,e,i,o,!0))}else if("'"===c[0]||'"'===c[0])for(const[,e,s]of c.matchAll(/'((?:\\.|[^'\\])*)'|"((?:\\.|[^"\\])*)"/gv)){const n=(e??s).replaceAll(/\\(['"\\])/gv,"$1");if(!t||!Object.hasOwn(t,n))continue;const o=t;d(this._trace(p,o[n],y(r,n),t,n,i,!0))}else if(c.includes(",")){const e=c.split(",");for(const o of e)d(this._trace(E(o,p),t,r,s,n,i,!0))}else if(!a&&t&&Object.hasOwn(t,c)){const e=t;d(this._trace(p,e[c],y(r,c),t,c,i,o,!0))}}if(this._hasParentSelector)for(let e=0;e{t(e)})}_slice(e,t,r,s,n,i,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),c=h[2]&&Number(h[2])||1;let l=h[0]&&Number(h[0])||0,p=h[1]?Number(h[1]):a;l=l<0?Math.max(0,l+a):Math.min(a,l),p=p<0?Math.max(0,p+a):Math.min(a,p);const u=[];for(let e=l;e{u.push(e)})}return u}_eval(e,t,r,s,n,i){this.currSandbox&&(this.currSandbox._$_parentProperty=i,this.currSandbox._$_parent=n,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t);const o=e.includes("@path");if(o){(this.currSandbox??{})._$_path=g.toPathString(s.concat([r]))}const a=this.currEval+"Script:"+e;if(!f.has(a)){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/('(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|(?<=(?:^|[\(,=:\[!\|?\{\};+\-*%<>~^]|&)\s*)\/(?:\\.|\[(?:\\.|[^\]\\])*\]|[^\/\\\[])+\/[dgimsuvy]*)|@(?![\w$])/gv,(e,t)=>t??"_$_v");o&&(t=t.replaceAll("@path","_$_path"));const r=this.currEval;if(["safe",!0,void 0].includes(r))f.set(a,new this.safeVm.Script(t));else if("native"===this.currEval)f.set(a,new this.vm.Script(t));else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;f.set(a,new e(t))}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);{const e=this.currEval;f.set(a,{runInNewContext:r=>e(t,r)})}}}try{return f.get(a).runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e,{cause:t})}}}x.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=r(this.code)}runInNewContext(e){const t=Object.assign(Object.create(null),e);return d.evalAst(this.ast,t)}}},g.prototype=x.prototype,g.clearCache=function(){b.clear(),f.clear()},g.toPathString=function(e){const t=e,r=t.length;let s="$";for(let e=1;e"function"==typeof e[t]);const n=r.map(t=>e[t]);t=s.reduce((t,r)=>{let s=e[r].toString();return/function/v.test(s)||(s="function "+s),"var "+r+"="+s+";"+t},"")+t,/(['"])use strict\1/v.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/v,"");const i=t.lastIndexOf(";"),o=-1!==i?t.slice(0,i+1)+" return "+t.slice(i+1):" return "+t;return new Function(...r,o)(...n)}}x.prototype.vm={Script:_};export{g as JSONPath,x as JSONPathClass,_ as Script}; //# sourceMappingURL=index-browser-esm.min.js.map diff --git a/dist/index-browser-esm.min.js.map b/dist/index-browser-esm.min.js.map index e392d4b..3d750e0 100644 --- a/dist/index-browser-esm.min.js.map +++ b/dist/index-browser-esm.min.js.map @@ -1 +1 @@ -{"version":3,"file":"index-browser-esm.min.js","sources":["../node_modules/.pnpm/jsep@1.4.0/node_modules/jsep/dist/jsep.js","../node_modules/.pnpm/@jsep-plugin+regex@1.0.4_jsep@1.4.0/node_modules/@jsep-plugin/regex/dist/index.js","../node_modules/.pnpm/@jsep-plugin+assignment@1.3.0_jsep@1.4.0/node_modules/@jsep-plugin/assignment/dist/index.js","../src/Safe-Script.js","../src/utils.js","../src/jsonpath.js","../src/jsonpath-browser.js"],"sourcesContent":["/**\n * @implements {IHooks}\n */\nclass Hooks {\n\t/**\n\t * @callback HookCallback\n\t * @this {*|Jsep} this\n\t * @param {Jsep} env\n\t * @returns: void\n\t */\n\t/**\n\t * Adds the given callback to the list of callbacks for the given hook.\n\t *\n\t * The callback will be invoked when the hook it is registered for is run.\n\t *\n\t * One callback function can be registered to multiple hooks and the same hook multiple times.\n\t *\n\t * @param {string|object} name The name of the hook, or an object of callbacks keyed by name\n\t * @param {HookCallback|boolean} callback The callback function which is given environment variables.\n\t * @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)\n\t * @public\n\t */\n\tadd(name, callback, first) {\n\t\tif (typeof arguments[0] != 'string') {\n\t\t\t// Multiple hook callbacks, keyed by name\n\t\t\tfor (let name in arguments[0]) {\n\t\t\t\tthis.add(name, arguments[0][name], arguments[1]);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t(Array.isArray(name) ? name : [name]).forEach(function (name) {\n\t\t\t\tthis[name] = this[name] || [];\n\n\t\t\t\tif (callback) {\n\t\t\t\t\tthis[name][first ? 'unshift' : 'push'](callback);\n\t\t\t\t}\n\t\t\t}, this);\n\t\t}\n\t}\n\n\t/**\n\t * Runs a hook invoking all registered callbacks with the given environment variables.\n\t *\n\t * Callbacks will be invoked synchronously and in the order in which they were registered.\n\t *\n\t * @param {string} name The name of the hook.\n\t * @param {Object} env The environment variables of the hook passed to all callbacks registered.\n\t * @public\n\t */\n\trun(name, env) {\n\t\tthis[name] = this[name] || [];\n\t\tthis[name].forEach(function (callback) {\n\t\t\tcallback.call(env && env.context ? env.context : env, env);\n\t\t});\n\t}\n}\n\n/**\n * @implements {IPlugins}\n */\nclass Plugins {\n\tconstructor(jsep) {\n\t\tthis.jsep = jsep;\n\t\tthis.registered = {};\n\t}\n\n\t/**\n\t * @callback PluginSetup\n\t * @this {Jsep} jsep\n\t * @returns: void\n\t */\n\t/**\n\t * Adds the given plugin(s) to the registry\n\t *\n\t * @param {object} plugins\n\t * @param {string} plugins.name The name of the plugin\n\t * @param {PluginSetup} plugins.init The init function\n\t * @public\n\t */\n\tregister(...plugins) {\n\t\tplugins.forEach((plugin) => {\n\t\t\tif (typeof plugin !== 'object' || !plugin.name || !plugin.init) {\n\t\t\t\tthrow new Error('Invalid JSEP plugin format');\n\t\t\t}\n\t\t\tif (this.registered[plugin.name]) {\n\t\t\t\t// already registered. Ignore.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tplugin.init(this.jsep);\n\t\t\tthis.registered[plugin.name] = plugin;\n\t\t});\n\t}\n}\n\n// JavaScript Expression Parser (JSEP) 1.4.0\n\nclass Jsep {\n\t/**\n\t * @returns {string}\n\t */\n\tstatic get version() {\n\t\t// To be filled in by the template\n\t\treturn '1.4.0';\n\t}\n\n\t/**\n\t * @returns {string}\n\t */\n\tstatic toString() {\n\t\treturn 'JavaScript Expression Parser (JSEP) v' + Jsep.version;\n\t};\n\n\t// ==================== CONFIG ================================\n\t/**\n\t * @method addUnaryOp\n\t * @param {string} op_name The name of the unary op to add\n\t * @returns {Jsep}\n\t */\n\tstatic addUnaryOp(op_name) {\n\t\tJsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);\n\t\tJsep.unary_ops[op_name] = 1;\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method jsep.addBinaryOp\n\t * @param {string} op_name The name of the binary op to add\n\t * @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence\n\t * @param {boolean} [isRightAssociative=false] whether operator is right-associative\n\t * @returns {Jsep}\n\t */\n\tstatic addBinaryOp(op_name, precedence, isRightAssociative) {\n\t\tJsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);\n\t\tJsep.binary_ops[op_name] = precedence;\n\t\tif (isRightAssociative) {\n\t\t\tJsep.right_associative.add(op_name);\n\t\t}\n\t\telse {\n\t\t\tJsep.right_associative.delete(op_name);\n\t\t}\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method addIdentifierChar\n\t * @param {string} char The additional character to treat as a valid part of an identifier\n\t * @returns {Jsep}\n\t */\n\tstatic addIdentifierChar(char) {\n\t\tJsep.additional_identifier_chars.add(char);\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method addLiteral\n\t * @param {string} literal_name The name of the literal to add\n\t * @param {*} literal_value The value of the literal\n\t * @returns {Jsep}\n\t */\n\tstatic addLiteral(literal_name, literal_value) {\n\t\tJsep.literals[literal_name] = literal_value;\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeUnaryOp\n\t * @param {string} op_name The name of the unary op to remove\n\t * @returns {Jsep}\n\t */\n\tstatic removeUnaryOp(op_name) {\n\t\tdelete Jsep.unary_ops[op_name];\n\t\tif (op_name.length === Jsep.max_unop_len) {\n\t\t\tJsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);\n\t\t}\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeAllUnaryOps\n\t * @returns {Jsep}\n\t */\n\tstatic removeAllUnaryOps() {\n\t\tJsep.unary_ops = {};\n\t\tJsep.max_unop_len = 0;\n\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeIdentifierChar\n\t * @param {string} char The additional character to stop treating as a valid part of an identifier\n\t * @returns {Jsep}\n\t */\n\tstatic removeIdentifierChar(char) {\n\t\tJsep.additional_identifier_chars.delete(char);\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeBinaryOp\n\t * @param {string} op_name The name of the binary op to remove\n\t * @returns {Jsep}\n\t */\n\tstatic removeBinaryOp(op_name) {\n\t\tdelete Jsep.binary_ops[op_name];\n\n\t\tif (op_name.length === Jsep.max_binop_len) {\n\t\t\tJsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);\n\t\t}\n\t\tJsep.right_associative.delete(op_name);\n\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeAllBinaryOps\n\t * @returns {Jsep}\n\t */\n\tstatic removeAllBinaryOps() {\n\t\tJsep.binary_ops = {};\n\t\tJsep.max_binop_len = 0;\n\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeLiteral\n\t * @param {string} literal_name The name of the literal to remove\n\t * @returns {Jsep}\n\t */\n\tstatic removeLiteral(literal_name) {\n\t\tdelete Jsep.literals[literal_name];\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeAllLiterals\n\t * @returns {Jsep}\n\t */\n\tstatic removeAllLiterals() {\n\t\tJsep.literals = {};\n\n\t\treturn Jsep;\n\t}\n\t// ==================== END CONFIG ============================\n\n\n\t/**\n\t * @returns {string}\n\t */\n\tget char() {\n\t\treturn this.expr.charAt(this.index);\n\t}\n\n\t/**\n\t * @returns {number}\n\t */\n\tget code() {\n\t\treturn this.expr.charCodeAt(this.index);\n\t};\n\n\n\t/**\n\t * @param {string} expr a string with the passed in express\n\t * @returns Jsep\n\t */\n\tconstructor(expr) {\n\t\t// `index` stores the character number we are currently at\n\t\t// All of the gobbles below will modify `index` as we move along\n\t\tthis.expr = expr;\n\t\tthis.index = 0;\n\t}\n\n\t/**\n\t * static top-level parser\n\t * @returns {jsep.Expression}\n\t */\n\tstatic parse(expr) {\n\t\treturn (new Jsep(expr)).parse();\n\t}\n\n\t/**\n\t * Get the longest key length of any object\n\t * @param {object} obj\n\t * @returns {number}\n\t */\n\tstatic getMaxKeyLen(obj) {\n\t\treturn Math.max(0, ...Object.keys(obj).map(k => k.length));\n\t}\n\n\t/**\n\t * `ch` is a character code in the next three functions\n\t * @param {number} ch\n\t * @returns {boolean}\n\t */\n\tstatic isDecimalDigit(ch) {\n\t\treturn (ch >= 48 && ch <= 57); // 0...9\n\t}\n\n\t/**\n\t * Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.\n\t * @param {string} op_val\n\t * @returns {number}\n\t */\n\tstatic binaryPrecedence(op_val) {\n\t\treturn Jsep.binary_ops[op_val] || 0;\n\t}\n\n\t/**\n\t * Looks for start of identifier\n\t * @param {number} ch\n\t * @returns {boolean}\n\t */\n\tstatic isIdentifierStart(ch) {\n\t\treturn (ch >= 65 && ch <= 90) || // A...Z\n\t\t\t(ch >= 97 && ch <= 122) || // a...z\n\t\t\t(ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)]) || // any non-ASCII that is not an operator\n\t\t\t(Jsep.additional_identifier_chars.has(String.fromCharCode(ch))); // additional characters\n\t}\n\n\t/**\n\t * @param {number} ch\n\t * @returns {boolean}\n\t */\n\tstatic isIdentifierPart(ch) {\n\t\treturn Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);\n\t}\n\n\t/**\n\t * throw error at index of the expression\n\t * @param {string} message\n\t * @throws\n\t */\n\tthrowError(message) {\n\t\tconst error = new Error(message + ' at character ' + this.index);\n\t\terror.index = this.index;\n\t\terror.description = message;\n\t\tthrow error;\n\t}\n\n\t/**\n\t * Run a given hook\n\t * @param {string} name\n\t * @param {jsep.Expression|false} [node]\n\t * @returns {?jsep.Expression}\n\t */\n\trunHook(name, node) {\n\t\tif (Jsep.hooks[name]) {\n\t\t\tconst env = { context: this, node };\n\t\t\tJsep.hooks.run(name, env);\n\t\t\treturn env.node;\n\t\t}\n\t\treturn node;\n\t}\n\n\t/**\n\t * Runs a given hook until one returns a node\n\t * @param {string} name\n\t * @returns {?jsep.Expression}\n\t */\n\tsearchHook(name) {\n\t\tif (Jsep.hooks[name]) {\n\t\t\tconst env = { context: this };\n\t\t\tJsep.hooks[name].find(function (callback) {\n\t\t\t\tcallback.call(env.context, env);\n\t\t\t\treturn env.node;\n\t\t\t});\n\t\t\treturn env.node;\n\t\t}\n\t}\n\n\t/**\n\t * Push `index` up to the next non-space character\n\t */\n\tgobbleSpaces() {\n\t\tlet ch = this.code;\n\t\t// Whitespace\n\t\twhile (ch === Jsep.SPACE_CODE\n\t\t|| ch === Jsep.TAB_CODE\n\t\t|| ch === Jsep.LF_CODE\n\t\t|| ch === Jsep.CR_CODE) {\n\t\t\tch = this.expr.charCodeAt(++this.index);\n\t\t}\n\t\tthis.runHook('gobble-spaces');\n\t}\n\n\t/**\n\t * Top-level method to parse all expressions and returns compound or single node\n\t * @returns {jsep.Expression}\n\t */\n\tparse() {\n\t\tthis.runHook('before-all');\n\t\tconst nodes = this.gobbleExpressions();\n\n\t\t// If there's only one expression just try returning the expression\n\t\tconst node = nodes.length === 1\n\t\t ? nodes[0]\n\t\t\t: {\n\t\t\t\ttype: Jsep.COMPOUND,\n\t\t\t\tbody: nodes\n\t\t\t};\n\t\treturn this.runHook('after-all', node);\n\t}\n\n\t/**\n\t * top-level parser (but can be reused within as well)\n\t * @param {number} [untilICode]\n\t * @returns {jsep.Expression[]}\n\t */\n\tgobbleExpressions(untilICode) {\n\t\tlet nodes = [], ch_i, node;\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tch_i = this.code;\n\n\t\t\t// Expressions can be separated by semicolons, commas, or just inferred without any\n\t\t\t// separators\n\t\t\tif (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {\n\t\t\t\tthis.index++; // ignore separators\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Try to gobble each expression individually\n\t\t\t\tif (node = this.gobbleExpression()) {\n\t\t\t\t\tnodes.push(node);\n\t\t\t\t\t// If we weren't able to find a binary expression and are out of room, then\n\t\t\t\t\t// the expression passed in probably has too much\n\t\t\t\t}\n\t\t\t\telse if (this.index < this.expr.length) {\n\t\t\t\t\tif (ch_i === untilICode) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tthis.throwError('Unexpected \"' + this.char + '\"');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn nodes;\n\t}\n\n\t/**\n\t * The main parsing function.\n\t * @returns {?jsep.Expression}\n\t */\n\tgobbleExpression() {\n\t\tconst node = this.searchHook('gobble-expression') || this.gobbleBinaryExpression();\n\t\tthis.gobbleSpaces();\n\n\t\treturn this.runHook('after-expression', node);\n\t}\n\n\t/**\n\t * Search for the operation portion of the string (e.g. `+`, `===`)\n\t * Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)\n\t * and move down from 3 to 2 to 1 character until a matching binary operation is found\n\t * then, return that binary operation\n\t * @returns {string|boolean}\n\t */\n\tgobbleBinaryOp() {\n\t\tthis.gobbleSpaces();\n\t\tlet to_check = this.expr.substr(this.index, Jsep.max_binop_len);\n\t\tlet tc_len = to_check.length;\n\n\t\twhile (tc_len > 0) {\n\t\t\t// Don't accept a binary op when it is an identifier.\n\t\t\t// Binary ops that start with a identifier-valid character must be followed\n\t\t\t// by a non identifier-part valid character\n\t\t\tif (Jsep.binary_ops.hasOwnProperty(to_check) && (\n\t\t\t\t!Jsep.isIdentifierStart(this.code) ||\n\t\t\t\t(this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))\n\t\t\t)) {\n\t\t\t\tthis.index += tc_len;\n\t\t\t\treturn to_check;\n\t\t\t}\n\t\t\tto_check = to_check.substr(0, --tc_len);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * This function is responsible for gobbling an individual expression,\n\t * e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`\n\t * @returns {?jsep.BinaryExpression}\n\t */\n\tgobbleBinaryExpression() {\n\t\tlet node, biop, prec, stack, biop_info, left, right, i, cur_biop;\n\n\t\t// First, try to get the leftmost thing\n\t\t// Then, check to see if there's a binary operator operating on that leftmost thing\n\t\t// Don't gobbleBinaryOp without a left-hand-side\n\t\tleft = this.gobbleToken();\n\t\tif (!left) {\n\t\t\treturn left;\n\t\t}\n\t\tbiop = this.gobbleBinaryOp();\n\n\t\t// If there wasn't a binary operator, just return the leftmost node\n\t\tif (!biop) {\n\t\t\treturn left;\n\t\t}\n\n\t\t// Otherwise, we need to start a stack to properly place the binary operations in their\n\t\t// precedence structure\n\t\tbiop_info = { value: biop, prec: Jsep.binaryPrecedence(biop), right_a: Jsep.right_associative.has(biop) };\n\n\t\tright = this.gobbleToken();\n\n\t\tif (!right) {\n\t\t\tthis.throwError(\"Expected expression after \" + biop);\n\t\t}\n\n\t\tstack = [left, biop_info, right];\n\n\t\t// Properly deal with precedence using [recursive descent](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm)\n\t\twhile ((biop = this.gobbleBinaryOp())) {\n\t\t\tprec = Jsep.binaryPrecedence(biop);\n\n\t\t\tif (prec === 0) {\n\t\t\t\tthis.index -= biop.length;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tbiop_info = { value: biop, prec, right_a: Jsep.right_associative.has(biop) };\n\n\t\t\tcur_biop = biop;\n\n\t\t\t// Reduce: make a binary expression from the three topmost entries.\n\t\t\tconst comparePrev = prev => biop_info.right_a && prev.right_a\n\t\t\t\t? prec > prev.prec\n\t\t\t\t: prec <= prev.prec;\n\t\t\twhile ((stack.length > 2) && comparePrev(stack[stack.length - 2])) {\n\t\t\t\tright = stack.pop();\n\t\t\t\tbiop = stack.pop().value;\n\t\t\t\tleft = stack.pop();\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.BINARY_EXP,\n\t\t\t\t\toperator: biop,\n\t\t\t\t\tleft,\n\t\t\t\t\tright\n\t\t\t\t};\n\t\t\t\tstack.push(node);\n\t\t\t}\n\n\t\t\tnode = this.gobbleToken();\n\n\t\t\tif (!node) {\n\t\t\t\tthis.throwError(\"Expected expression after \" + cur_biop);\n\t\t\t}\n\n\t\t\tstack.push(biop_info, node);\n\t\t}\n\n\t\ti = stack.length - 1;\n\t\tnode = stack[i];\n\n\t\twhile (i > 1) {\n\t\t\tnode = {\n\t\t\t\ttype: Jsep.BINARY_EXP,\n\t\t\t\toperator: stack[i - 1].value,\n\t\t\t\tleft: stack[i - 2],\n\t\t\t\tright: node\n\t\t\t};\n\t\t\ti -= 2;\n\t\t}\n\n\t\treturn node;\n\t}\n\n\t/**\n\t * An individual part of a binary expression:\n\t * e.g. `foo.bar(baz)`, `1`, `\"abc\"`, `(a % 2)` (because it's in parenthesis)\n\t * @returns {boolean|jsep.Expression}\n\t */\n\tgobbleToken() {\n\t\tlet ch, to_check, tc_len, node;\n\n\t\tthis.gobbleSpaces();\n\t\tnode = this.searchHook('gobble-token');\n\t\tif (node) {\n\t\t\treturn this.runHook('after-token', node);\n\t\t}\n\n\t\tch = this.code;\n\n\t\tif (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {\n\t\t\t// Char code 46 is a dot `.` which can start off a numeric literal\n\t\t\treturn this.gobbleNumericLiteral();\n\t\t}\n\n\t\tif (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {\n\t\t\t// Single or double quotes\n\t\t\tnode = this.gobbleStringLiteral();\n\t\t}\n\t\telse if (ch === Jsep.OBRACK_CODE) {\n\t\t\tnode = this.gobbleArray();\n\t\t}\n\t\telse {\n\t\t\tto_check = this.expr.substr(this.index, Jsep.max_unop_len);\n\t\t\ttc_len = to_check.length;\n\n\t\t\twhile (tc_len > 0) {\n\t\t\t\t// Don't accept an unary op when it is an identifier.\n\t\t\t\t// Unary ops that start with a identifier-valid character must be followed\n\t\t\t\t// by a non identifier-part valid character\n\t\t\t\tif (Jsep.unary_ops.hasOwnProperty(to_check) && (\n\t\t\t\t\t!Jsep.isIdentifierStart(this.code) ||\n\t\t\t\t\t(this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))\n\t\t\t\t)) {\n\t\t\t\t\tthis.index += tc_len;\n\t\t\t\t\tconst argument = this.gobbleToken();\n\t\t\t\t\tif (!argument) {\n\t\t\t\t\t\tthis.throwError('missing unaryOp argument');\n\t\t\t\t\t}\n\t\t\t\t\treturn this.runHook('after-token', {\n\t\t\t\t\t\ttype: Jsep.UNARY_EXP,\n\t\t\t\t\t\toperator: to_check,\n\t\t\t\t\t\targument,\n\t\t\t\t\t\tprefix: true\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tto_check = to_check.substr(0, --tc_len);\n\t\t\t}\n\n\t\t\tif (Jsep.isIdentifierStart(ch)) {\n\t\t\t\tnode = this.gobbleIdentifier();\n\t\t\t\tif (Jsep.literals.hasOwnProperty(node.name)) {\n\t\t\t\t\tnode = {\n\t\t\t\t\t\ttype: Jsep.LITERAL,\n\t\t\t\t\t\tvalue: Jsep.literals[node.name],\n\t\t\t\t\t\traw: node.name,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (node.name === Jsep.this_str) {\n\t\t\t\t\tnode = { type: Jsep.THIS_EXP };\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (ch === Jsep.OPAREN_CODE) { // open parenthesis\n\t\t\t\tnode = this.gobbleGroup();\n\t\t\t}\n\t\t}\n\n\t\tif (!node) {\n\t\t\treturn this.runHook('after-token', false);\n\t\t}\n\n\t\tnode = this.gobbleTokenProperty(node);\n\t\treturn this.runHook('after-token', node);\n\t}\n\n\t/**\n\t * Gobble properties of of identifiers/strings/arrays/groups.\n\t * e.g. `foo`, `bar.baz`, `foo['bar'].baz`\n\t * It also gobbles function calls:\n\t * e.g. `Math.acos(obj.angle)`\n\t * @param {jsep.Expression} node\n\t * @returns {jsep.Expression}\n\t */\n\tgobbleTokenProperty(node) {\n\t\tthis.gobbleSpaces();\n\n\t\tlet ch = this.code;\n\t\twhile (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {\n\t\t\tlet optional;\n\t\t\tif (ch === Jsep.QUMARK_CODE) {\n\t\t\t\tif (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\toptional = true;\n\t\t\t\tthis.index += 2;\n\t\t\t\tthis.gobbleSpaces();\n\t\t\t\tch = this.code;\n\t\t\t}\n\t\t\tthis.index++;\n\n\t\t\tif (ch === Jsep.OBRACK_CODE) {\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.MEMBER_EXP,\n\t\t\t\t\tcomputed: true,\n\t\t\t\t\tobject: node,\n\t\t\t\t\tproperty: this.gobbleExpression()\n\t\t\t\t};\n\t\t\t\tif (!node.property) {\n\t\t\t\t\tthis.throwError('Unexpected \"' + this.char + '\"');\n\t\t\t\t}\n\t\t\t\tthis.gobbleSpaces();\n\t\t\t\tch = this.code;\n\t\t\t\tif (ch !== Jsep.CBRACK_CODE) {\n\t\t\t\t\tthis.throwError('Unclosed [');\n\t\t\t\t}\n\t\t\t\tthis.index++;\n\t\t\t}\n\t\t\telse if (ch === Jsep.OPAREN_CODE) {\n\t\t\t\t// A function call is being made; gobble all the arguments\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.CALL_EXP,\n\t\t\t\t\t'arguments': this.gobbleArguments(Jsep.CPAREN_CODE),\n\t\t\t\t\tcallee: node\n\t\t\t\t};\n\t\t\t}\n\t\t\telse if (ch === Jsep.PERIOD_CODE || optional) {\n\t\t\t\tif (optional) {\n\t\t\t\t\tthis.index--;\n\t\t\t\t}\n\t\t\t\tthis.gobbleSpaces();\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.MEMBER_EXP,\n\t\t\t\t\tcomputed: false,\n\t\t\t\t\tobject: node,\n\t\t\t\t\tproperty: this.gobbleIdentifier(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (optional) {\n\t\t\t\tnode.optional = true;\n\t\t\t} // else leave undefined for compatibility with esprima\n\n\t\t\tthis.gobbleSpaces();\n\t\t\tch = this.code;\n\t\t}\n\n\t\treturn node;\n\t}\n\n\t/**\n\t * Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to\n\t * keep track of everything in the numeric literal and then calling `parseFloat` on that string\n\t * @returns {jsep.Literal}\n\t */\n\tgobbleNumericLiteral() {\n\t\tlet number = '', ch, chCode;\n\n\t\twhile (Jsep.isDecimalDigit(this.code)) {\n\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t}\n\n\t\tif (this.code === Jsep.PERIOD_CODE) { // can start with a decimal marker\n\t\t\tnumber += this.expr.charAt(this.index++);\n\n\t\t\twhile (Jsep.isDecimalDigit(this.code)) {\n\t\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\t}\n\t\t}\n\n\t\tch = this.char;\n\n\t\tif (ch === 'e' || ch === 'E') { // exponent marker\n\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\tch = this.char;\n\n\t\t\tif (ch === '+' || ch === '-') { // exponent sign\n\t\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\t}\n\n\t\t\twhile (Jsep.isDecimalDigit(this.code)) { // exponent itself\n\t\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\t}\n\n\t\t\tif (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1)) ) {\n\t\t\t\tthis.throwError('Expected exponent (' + number + this.char + ')');\n\t\t\t}\n\t\t}\n\n\t\tchCode = this.code;\n\n\t\t// Check to make sure this isn't a variable name that start with a number (123abc)\n\t\tif (Jsep.isIdentifierStart(chCode)) {\n\t\t\tthis.throwError('Variable names cannot start with a number (' +\n\t\t\t\tnumber + this.char + ')');\n\t\t}\n\t\telse if (chCode === Jsep.PERIOD_CODE || (number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE)) {\n\t\t\tthis.throwError('Unexpected period');\n\t\t}\n\n\t\treturn {\n\t\t\ttype: Jsep.LITERAL,\n\t\t\tvalue: parseFloat(number),\n\t\t\traw: number\n\t\t};\n\t}\n\n\t/**\n\t * Parses a string literal, staring with single or double quotes with basic support for escape codes\n\t * e.g. `\"hello world\"`, `'this is\\nJSEP'`\n\t * @returns {jsep.Literal}\n\t */\n\tgobbleStringLiteral() {\n\t\tlet str = '';\n\t\tconst startIndex = this.index;\n\t\tconst quote = this.expr.charAt(this.index++);\n\t\tlet closed = false;\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tlet ch = this.expr.charAt(this.index++);\n\n\t\t\tif (ch === quote) {\n\t\t\t\tclosed = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (ch === '\\\\') {\n\t\t\t\t// Check for all of the common escape codes\n\t\t\t\tch = this.expr.charAt(this.index++);\n\n\t\t\t\tswitch (ch) {\n\t\t\t\t\tcase 'n': str += '\\n'; break;\n\t\t\t\t\tcase 'r': str += '\\r'; break;\n\t\t\t\t\tcase 't': str += '\\t'; break;\n\t\t\t\t\tcase 'b': str += '\\b'; break;\n\t\t\t\t\tcase 'f': str += '\\f'; break;\n\t\t\t\t\tcase 'v': str += '\\x0B'; break;\n\t\t\t\t\tdefault : str += ch;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tstr += ch;\n\t\t\t}\n\t\t}\n\n\t\tif (!closed) {\n\t\t\tthis.throwError('Unclosed quote after \"' + str + '\"');\n\t\t}\n\n\t\treturn {\n\t\t\ttype: Jsep.LITERAL,\n\t\t\tvalue: str,\n\t\t\traw: this.expr.substring(startIndex, this.index),\n\t\t};\n\t}\n\n\t/**\n\t * Gobbles only identifiers\n\t * e.g.: `foo`, `_value`, `$x1`\n\t * Also, this function checks if that identifier is a literal:\n\t * (e.g. `true`, `false`, `null`) or `this`\n\t * @returns {jsep.Identifier}\n\t */\n\tgobbleIdentifier() {\n\t\tlet ch = this.code, start = this.index;\n\n\t\tif (Jsep.isIdentifierStart(ch)) {\n\t\t\tthis.index++;\n\t\t}\n\t\telse {\n\t\t\tthis.throwError('Unexpected ' + this.char);\n\t\t}\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tch = this.code;\n\n\t\t\tif (Jsep.isIdentifierPart(ch)) {\n\t\t\t\tthis.index++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\ttype: Jsep.IDENTIFIER,\n\t\t\tname: this.expr.slice(start, this.index),\n\t\t};\n\t}\n\n\t/**\n\t * Gobbles a list of arguments within the context of a function call\n\t * or array literal. This function also assumes that the opening character\n\t * `(` or `[` has already been gobbled, and gobbles expressions and commas\n\t * until the terminator character `)` or `]` is encountered.\n\t * e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`\n\t * @param {number} termination\n\t * @returns {jsep.Expression[]}\n\t */\n\tgobbleArguments(termination) {\n\t\tconst args = [];\n\t\tlet closed = false;\n\t\tlet separator_count = 0;\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tthis.gobbleSpaces();\n\t\t\tlet ch_i = this.code;\n\n\t\t\tif (ch_i === termination) { // done parsing\n\t\t\t\tclosed = true;\n\t\t\t\tthis.index++;\n\n\t\t\t\tif (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length){\n\t\t\t\t\tthis.throwError('Unexpected token ' + String.fromCharCode(termination));\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (ch_i === Jsep.COMMA_CODE) { // between expressions\n\t\t\t\tthis.index++;\n\t\t\t\tseparator_count++;\n\n\t\t\t\tif (separator_count !== args.length) { // missing argument\n\t\t\t\t\tif (termination === Jsep.CPAREN_CODE) {\n\t\t\t\t\t\tthis.throwError('Unexpected token ,');\n\t\t\t\t\t}\n\t\t\t\t\telse if (termination === Jsep.CBRACK_CODE) {\n\t\t\t\t\t\tfor (let arg = args.length; arg < separator_count; arg++) {\n\t\t\t\t\t\t\targs.push(null);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (args.length !== separator_count && separator_count !== 0) {\n\t\t\t\t// NOTE: `&& separator_count !== 0` allows for either all commas, or all spaces as arguments\n\t\t\t\tthis.throwError('Expected comma');\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconst node = this.gobbleExpression();\n\n\t\t\t\tif (!node || node.type === Jsep.COMPOUND) {\n\t\t\t\t\tthis.throwError('Expected comma');\n\t\t\t\t}\n\n\t\t\t\targs.push(node);\n\t\t\t}\n\t\t}\n\n\t\tif (!closed) {\n\t\t\tthis.throwError('Expected ' + String.fromCharCode(termination));\n\t\t}\n\n\t\treturn args;\n\t}\n\n\t/**\n\t * Responsible for parsing a group of things within parentheses `()`\n\t * that have no identifier in front (so not a function call)\n\t * This function assumes that it needs to gobble the opening parenthesis\n\t * and then tries to gobble everything within that parenthesis, assuming\n\t * that the next thing it should see is the close parenthesis. If not,\n\t * then the expression probably doesn't have a `)`\n\t * @returns {boolean|jsep.Expression}\n\t */\n\tgobbleGroup() {\n\t\tthis.index++;\n\t\tlet nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);\n\t\tif (this.code === Jsep.CPAREN_CODE) {\n\t\t\tthis.index++;\n\t\t\tif (nodes.length === 1) {\n\t\t\t\treturn nodes[0];\n\t\t\t}\n\t\t\telse if (!nodes.length) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn {\n\t\t\t\t\ttype: Jsep.SEQUENCE_EXP,\n\t\t\t\t\texpressions: nodes,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tthis.throwError('Unclosed (');\n\t\t}\n\t}\n\n\t/**\n\t * Responsible for parsing Array literals `[1, 2, 3]`\n\t * This function assumes that it needs to gobble the opening bracket\n\t * and then tries to gobble the expressions as arguments.\n\t * @returns {jsep.ArrayExpression}\n\t */\n\tgobbleArray() {\n\t\tthis.index++;\n\n\t\treturn {\n\t\t\ttype: Jsep.ARRAY_EXP,\n\t\t\telements: this.gobbleArguments(Jsep.CBRACK_CODE)\n\t\t};\n\t}\n}\n\n// Static fields:\nconst hooks = new Hooks();\nObject.assign(Jsep, {\n\thooks,\n\tplugins: new Plugins(Jsep),\n\n\t// Node Types\n\t// ----------\n\t// This is the full set of types that any JSEP node can be.\n\t// Store them here to save space when minified\n\tCOMPOUND: 'Compound',\n\tSEQUENCE_EXP: 'SequenceExpression',\n\tIDENTIFIER: 'Identifier',\n\tMEMBER_EXP: 'MemberExpression',\n\tLITERAL: 'Literal',\n\tTHIS_EXP: 'ThisExpression',\n\tCALL_EXP: 'CallExpression',\n\tUNARY_EXP: 'UnaryExpression',\n\tBINARY_EXP: 'BinaryExpression',\n\tARRAY_EXP: 'ArrayExpression',\n\n\tTAB_CODE: 9,\n\tLF_CODE: 10,\n\tCR_CODE: 13,\n\tSPACE_CODE: 32,\n\tPERIOD_CODE: 46, // '.'\n\tCOMMA_CODE: 44, // ','\n\tSQUOTE_CODE: 39, // single quote\n\tDQUOTE_CODE: 34, // double quotes\n\tOPAREN_CODE: 40, // (\n\tCPAREN_CODE: 41, // )\n\tOBRACK_CODE: 91, // [\n\tCBRACK_CODE: 93, // ]\n\tQUMARK_CODE: 63, // ?\n\tSEMCOL_CODE: 59, // ;\n\tCOLON_CODE: 58, // :\n\n\n\t// Operations\n\t// ----------\n\t// Use a quickly-accessible map to store all of the unary operators\n\t// Values are set to `1` (it really doesn't matter)\n\tunary_ops: {\n\t\t'-': 1,\n\t\t'!': 1,\n\t\t'~': 1,\n\t\t'+': 1\n\t},\n\n\t// Also use a map for the binary operations but set their values to their\n\t// binary precedence for quick reference (higher number = higher precedence)\n\t// see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)\n\tbinary_ops: {\n\t\t'||': 1, '??': 1,\n\t\t'&&': 2, '|': 3, '^': 4, '&': 5,\n\t\t'==': 6, '!=': 6, '===': 6, '!==': 6,\n\t\t'<': 7, '>': 7, '<=': 7, '>=': 7,\n\t\t'<<': 8, '>>': 8, '>>>': 8,\n\t\t'+': 9, '-': 9,\n\t\t'*': 10, '/': 10, '%': 10,\n\t\t'**': 11,\n\t},\n\n\t// sets specific binary_ops as right-associative\n\tright_associative: new Set(['**']),\n\n\t// Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)\n\tadditional_identifier_chars: new Set(['$', '_']),\n\n\t// Literals\n\t// ----------\n\t// Store the values to return for the various literals we may encounter\n\tliterals: {\n\t\t'true': true,\n\t\t'false': false,\n\t\t'null': null\n\t},\n\n\t// Except for `this`, which is special. This could be changed to something like `'self'` as well\n\tthis_str: 'this',\n});\nJsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);\nJsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);\n\n// Backward Compatibility:\nconst jsep = expr => (new Jsep(expr)).parse();\nconst stdClassProps = Object.getOwnPropertyNames(class Test{});\nObject.getOwnPropertyNames(Jsep)\n\t.filter(prop => !stdClassProps.includes(prop) && jsep[prop] === undefined)\n\t.forEach((m) => {\n\t\tjsep[m] = Jsep[m];\n\t});\njsep.Jsep = Jsep; // allows for const { Jsep } = require('jsep');\n\nconst CONDITIONAL_EXP = 'ConditionalExpression';\n\nvar ternary = {\n\tname: 'ternary',\n\n\tinit(jsep) {\n\t\t// Ternary expression: test ? consequent : alternate\n\t\tjsep.hooks.add('after-expression', function gobbleTernary(env) {\n\t\t\tif (env.node && this.code === jsep.QUMARK_CODE) {\n\t\t\t\tthis.index++;\n\t\t\t\tconst test = env.node;\n\t\t\t\tconst consequent = this.gobbleExpression();\n\n\t\t\t\tif (!consequent) {\n\t\t\t\t\tthis.throwError('Expected expression');\n\t\t\t\t}\n\n\t\t\t\tthis.gobbleSpaces();\n\n\t\t\t\tif (this.code === jsep.COLON_CODE) {\n\t\t\t\t\tthis.index++;\n\t\t\t\t\tconst alternate = this.gobbleExpression();\n\n\t\t\t\t\tif (!alternate) {\n\t\t\t\t\t\tthis.throwError('Expected expression');\n\t\t\t\t\t}\n\t\t\t\t\tenv.node = {\n\t\t\t\t\t\ttype: CONDITIONAL_EXP,\n\t\t\t\t\t\ttest,\n\t\t\t\t\t\tconsequent,\n\t\t\t\t\t\talternate,\n\t\t\t\t\t};\n\n\t\t\t\t\t// check for operators of higher priority than ternary (i.e. assignment)\n\t\t\t\t\t// jsep sets || at 1, and assignment at 0.9, and conditional should be between them\n\t\t\t\t\tif (test.operator && jsep.binary_ops[test.operator] <= 0.9) {\n\t\t\t\t\t\tlet newTest = test;\n\t\t\t\t\t\twhile (newTest.right.operator && jsep.binary_ops[newTest.right.operator] <= 0.9) {\n\t\t\t\t\t\t\tnewTest = newTest.right;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tenv.node.test = newTest.right;\n\t\t\t\t\t\tnewTest.right = env.node;\n\t\t\t\t\t\tenv.node = test;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.throwError('Expected :');\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t},\n};\n\n// Add default plugins:\n\njsep.plugins.register(ternary);\n\nexport { Jsep, jsep as default };\n","const FSLASH_CODE = 47; // '/'\nconst BSLASH_CODE = 92; // '\\\\'\n\nvar index = {\n\tname: 'regex',\n\n\tinit(jsep) {\n\t\t// Regex literal: /abc123/ig\n\t\tjsep.hooks.add('gobble-token', function gobbleRegexLiteral(env) {\n\t\t\tif (this.code === FSLASH_CODE) {\n\t\t\t\tconst patternIndex = ++this.index;\n\n\t\t\t\tlet inCharSet = false;\n\t\t\t\twhile (this.index < this.expr.length) {\n\t\t\t\t\tif (this.code === FSLASH_CODE && !inCharSet) {\n\t\t\t\t\t\tconst pattern = this.expr.slice(patternIndex, this.index);\n\n\t\t\t\t\t\tlet flags = '';\n\t\t\t\t\t\twhile (++this.index < this.expr.length) {\n\t\t\t\t\t\t\tconst code = this.code;\n\t\t\t\t\t\t\tif ((code >= 97 && code <= 122) // a...z\n\t\t\t\t\t\t\t\t|| (code >= 65 && code <= 90) // A...Z\n\t\t\t\t\t\t\t\t|| (code >= 48 && code <= 57)) { // 0-9\n\t\t\t\t\t\t\t\tflags += this.char;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet value;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tvalue = new RegExp(pattern, flags);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\tthis.throwError(e.message);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tenv.node = {\n\t\t\t\t\t\t\ttype: jsep.LITERAL,\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\traw: this.expr.slice(patternIndex - 1, this.index),\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// allow . [] and () after regex: /regex/.test(a)\n\t\t\t\t\t\tenv.node = this.gobbleTokenProperty(env.node);\n\t\t\t\t\t\treturn env.node;\n\t\t\t\t\t}\n\t\t\t\t\tif (this.code === jsep.OBRACK_CODE) {\n\t\t\t\t\t\tinCharSet = true;\n\t\t\t\t\t}\n\t\t\t\t\telse if (inCharSet && this.code === jsep.CBRACK_CODE) {\n\t\t\t\t\t\tinCharSet = false;\n\t\t\t\t\t}\n\t\t\t\t\tthis.index += this.code === BSLASH_CODE ? 2 : 1;\n\t\t\t\t}\n\t\t\t\tthis.throwError('Unclosed Regex');\n\t\t\t}\n\t\t});\n\t},\n};\n\nexport { index as default };\n","const PLUS_CODE = 43; // +\nconst MINUS_CODE = 45; // -\n\nconst plugin = {\n\tname: 'assignment',\n\n\tassignmentOperators: new Set([\n\t\t'=',\n\t\t'*=',\n\t\t'**=',\n\t\t'/=',\n\t\t'%=',\n\t\t'+=',\n\t\t'-=',\n\t\t'<<=',\n\t\t'>>=',\n\t\t'>>>=',\n\t\t'&=',\n\t\t'^=',\n\t\t'|=',\n\t\t'||=',\n\t\t'&&=',\n\t\t'??=',\n\t]),\n\tupdateOperators: [PLUS_CODE, MINUS_CODE],\n\tassignmentPrecedence: 0.9,\n\n\tinit(jsep) {\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\n\t\tplugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence, true));\n\n\t\tjsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) {\n\t\t\tconst code = this.code;\n\t\t\tif (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\n\t\t\t\tthis.index += 2;\n\t\t\t\tenv.node = {\n\t\t\t\t\ttype: 'UpdateExpression',\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\n\t\t\t\t\targument: this.gobbleTokenProperty(this.gobbleIdentifier()),\n\t\t\t\t\tprefix: true,\n\t\t\t\t};\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\n\t\t\tif (env.node) {\n\t\t\t\tconst code = this.code;\n\t\t\t\tif (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\n\t\t\t\t\t}\n\t\t\t\t\tthis.index += 2;\n\t\t\t\t\tenv.node = {\n\t\t\t\t\t\ttype: 'UpdateExpression',\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\n\t\t\t\t\t\targument: env.node,\n\t\t\t\t\t\tprefix: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\n\t\t\tif (env.node) {\n\t\t\t\t// Note: Binaries can be chained in a single expression to respect\n\t\t\t\t// operator precedence (i.e. a = b = 1 + 2 + 3)\n\t\t\t\t// Update all binary assignment nodes in the tree\n\t\t\t\tupdateBinariesToAssignments(env.node);\n\t\t\t}\n\t\t});\n\n\t\tfunction updateBinariesToAssignments(node) {\n\t\t\tif (plugin.assignmentOperators.has(node.operator)) {\n\t\t\t\tnode.type = 'AssignmentExpression';\n\t\t\t\tupdateBinariesToAssignments(node.left);\n\t\t\t\tupdateBinariesToAssignments(node.right);\n\t\t\t}\n\t\t\telse if (!node.operator) {\n\t\t\t\tObject.values(node).forEach((val) => {\n\t\t\t\t\tif (val && typeof val === 'object') {\n\t\t\t\t\t\tupdateBinariesToAssignments(val);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t},\n};\n\nexport { plugin as default };\n","/* eslint-disable unicorn/no-top-level-side-effects -- Temporary? */\n/* eslint-disable no-bitwise -- Convenient */\nimport jsep from 'jsep';\nimport jsepRegex from '@jsep-plugin/regex';\nimport jsepAssignment from '@jsep-plugin/assignment';\n\n/**\n * @import {EvaluatedResult, UnknownResult} from './jsonpath.js';\n */\n\n/**\n * @typedef {any} AssignmentExpression\n */\n\n/**\n * @typedef {any} Substitution\n */\n\n/**\n * @typedef {any} AnyParameter\n */\n\n/**\n * @typedef {Record} Substitutions\n */\n\n// register plugins\njsep.plugins.register(jsepRegex, jsepAssignment);\njsep.addUnaryOp('typeof');\njsep.addUnaryOp('void');\njsep.addLiteral('null', null);\njsep.addLiteral('undefined', undefined);\n\nconst BLOCKED_PROTO_PROPERTIES = new Set([\n 'constructor',\n '__proto__',\n '__defineGetter__',\n '__defineSetter__',\n '__lookupGetter__',\n '__lookupSetter__'\n]);\n\n// Every function-constructor variant, along with the invocation helpers which\n// could otherwise reach them indirectly, e.g., `Function.call(0, 'code')()`,\n// plus whichever BLOCKED_PROTO_PROPERTIES names resolve to an own method on\n// Object.prototype (e.g. `__defineGetter__`) - an own-property access on a\n// shared prototype (`@.prototype.__defineGetter__`) bypasses the\n// inherited-only name check below, so those methods need blocking by value.\n/** @type {WeakSet} */\nconst BLOCKED_FUNCTIONS = new WeakSet([\n Function,\n // eslint-disable-next-line no-empty-function -- Only need the constructor\n function *() {}.constructor,\n // eslint-disable-next-line no-empty-function -- Only need the constructor\n async function () {}.constructor,\n // eslint-disable-next-line no-empty-function -- Only need the constructor\n async function *() {}.constructor,\n Function.prototype.call,\n Function.prototype.apply,\n Function.prototype.bind,\n Reflect.apply,\n Reflect.construct,\n ...[...BLOCKED_PROTO_PROPERTIES]\n .map((name) => Reflect.get(Object.prototype, name))\n .filter((value) => typeof value === 'function')\n]);\n\n/**\n * @param {UnknownResult} value\n * @returns {boolean}\n */\nconst isBlockedFunction = (value) => {\n return typeof value === 'function' && BLOCKED_FUNCTIONS.has(value);\n};\n\n/**\n * Guarded `obj[prop]`, applying the same restrictions as a MemberExpression.\n * @param {UnknownResult} obj\n * @param {string} prop\n * @returns {UnknownResult}\n */\nconst getSafeProperty = (obj, prop) => {\n if (obj === undefined || obj === null) {\n throw new TypeError(\n `Cannot read properties of ${obj} (reading '${prop}')`\n );\n }\n if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {\n throw new TypeError(\n `Cannot read properties of ${obj} (reading '${prop}')`\n );\n }\n const result = /** @type {Record} */ (obj)[prop];\n if (isBlockedFunction(result)) {\n throw new TypeError('Function constructor is disabled');\n }\n return result;\n};\n\n/**\n * @typedef {Record<\n * string,\n * (a: AnyParameter, b: AnyParameter) => UnknownResult\n * >} OperatorTable\n */\n\n// eslint-disable-next-line @stylistic/max-len -- Long\nconst BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */ ({\n '||': (a, b) => a || b(),\n '&&': (a, b) => a && b(),\n '|': (a, b) => a | b(),\n '^': (a, b) => a ^ b(),\n '&': (a, b) => a & b(),\n // eslint-disable-next-line eqeqeq -- API\n '==': (a, b) => a == b(),\n // eslint-disable-next-line eqeqeq -- API\n '!=': (a, b) => a != b(),\n '===': (a, b) => a === b(),\n '!==': (a, b) => a !== b(),\n '<': (a, b) => a < b(),\n '>': (a, b) => a > b(),\n '<=': (a, b) => a <= b(),\n '>=': (a, b) => a >= b(),\n '<<': (a, b) => a << b(),\n '>>': (a, b) => a >> b(),\n '>>>': (a, b) => a >>> b(),\n '+': (a, b) => a + b(),\n '-': (a, b) => a - b(),\n '*': (a, b) => a * b(),\n '/': (a, b) => a / b(),\n '%': (a, b) => a % b()\n}));\n\n/**\n * @typedef {{\n * [key: string]: (a: AnyParameter) => UnknownResult\n * }} UnaryOperatorTable\n */\n\n// eslint-disable-next-line @stylistic/max-len -- Long\nconst UNOPS = Object.assign(Object.create(null), /** @type {UnaryOperatorTable} */ ({\n '-': (a) => -(/** @type {EvaluatedResult} */ (a)),\n '!': (a) => !a,\n '~': (a) => ~(/** @type {EvaluatedResult} */ (a)),\n // eslint-disable-next-line no-implicit-coercion -- API\n '+': (a) => +(/** @type {EvaluatedResult} */ (a)),\n typeof: (a) => typeof a,\n void: () => undefined\n}));\n\nconst SafeEval = {\n /**\n * @param {jsep.Expression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalAst (ast, subs) {\n switch (ast.type) {\n case 'BinaryExpression':\n case 'LogicalExpression':\n return SafeEval.evalBinaryExpression(\n /** @type {jsep.BinaryExpression} */ (ast),\n subs\n );\n case 'Compound':\n return SafeEval.evalCompound(\n /** @type {jsep.Compound} */ (ast),\n subs\n );\n case 'ConditionalExpression':\n return SafeEval.evalConditionalExpression(\n /** @type {jsep.ConditionalExpression} */ (ast),\n subs\n );\n case 'Identifier':\n return SafeEval.evalIdentifier(\n /** @type {jsep.Identifier} */ (ast),\n subs\n );\n case 'Literal':\n return SafeEval.evalLiteral(/** @type {jsep.Literal} */ (ast));\n case 'MemberExpression':\n return SafeEval.evalMemberExpression(\n /** @type {jsep.MemberExpression} */ (ast),\n subs\n );\n case 'UnaryExpression':\n return SafeEval.evalUnaryExpression(\n /** @type {jsep.UnaryExpression} */ (ast),\n subs\n );\n case 'ArrayExpression':\n return SafeEval.evalArrayExpression(\n /** @type {jsep.ArrayExpression} */ (ast),\n subs\n );\n case 'CallExpression':\n return SafeEval.evalCallExpression(\n /** @type {jsep.CallExpression} */ (ast),\n subs\n );\n case 'AssignmentExpression':\n return SafeEval.evalAssignmentExpression(\n /** @type {AssignmentExpression} */ (ast),\n subs\n );\n default:\n throw new SyntaxError('Unexpected expression', {\n cause: ast\n });\n }\n },\n\n /**\n * @param {jsep.BinaryExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalBinaryExpression (ast, subs) {\n /* c8 ignore next 3 -- Defensive guard for malformed ASTs */\n if (!Object.hasOwn(BINOPS, ast.operator)) {\n throw new SyntaxError(`Unknown binary operator: ${ast.operator}`);\n }\n const result = BINOPS[ast.operator](\n SafeEval.evalAst(ast.left, subs),\n () => SafeEval.evalAst(ast.right, subs)\n );\n return result;\n },\n\n /**\n * @param {jsep.Compound} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalCompound (ast, subs) {\n let last;\n for (let i = 0; i < ast.body.length; i++) {\n if (\n ast.body[i].type === 'Identifier' &&\n ['var', 'let', 'const'].includes(\n /** @type {jsep.Identifier} */\n (ast.body[i]).name\n ) &&\n Object.hasOwn(ast.body, i + 1) &&\n ast.body[i + 1].type === 'AssignmentExpression'\n ) {\n // var x=2; is detected as\n // [{Identifier var}, {AssignmentExpression x=2}]\n i += 1;\n }\n const expr = ast.body[i];\n last = SafeEval.evalAst(expr, subs);\n }\n return last;\n },\n\n /**\n * @param {jsep.ConditionalExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalConditionalExpression (ast, subs) {\n return SafeEval.evalAst(ast.test, subs)\n ? SafeEval.evalAst(ast.consequent, subs)\n : SafeEval.evalAst(ast.alternate, subs);\n },\n\n /**\n * @param {jsep.Identifier} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalIdentifier (ast, subs) {\n if (Object.hasOwn(subs, ast.name)) {\n return subs[ast.name];\n }\n throw new ReferenceError(`${ast.name} is not defined`);\n },\n\n /**\n * @param {jsep.Literal} ast\n * @returns {UnknownResult}\n */\n evalLiteral (ast) {\n return ast.value;\n },\n\n /**\n * @param {jsep.MemberExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalMemberExpression (ast, subs) {\n const prop = String(\n // NOTE: `String(value)` throws error when\n // value has overwritten the toString method to return non-string\n // i.e. `value = {toString: () => []}`\n ast.computed\n ? SafeEval.evalAst(ast.property, subs) // `object[property]`\n : ast.property.name // `object.property` property is Identifier\n );\n const obj = SafeEval.evalAst(ast.object, subs);\n const result = getSafeProperty(obj, prop);\n if (typeof result === 'function') {\n return result.bind(obj); // arrow functions aren't affected by bind.\n }\n return result;\n },\n\n /**\n * @param {jsep.UnaryExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalUnaryExpression (ast, subs) {\n /* c8 ignore next 3 -- Defensive guard for malformed ASTs */\n if (!Object.hasOwn(UNOPS, ast.operator)) {\n throw new SyntaxError(`Unknown unary operator: ${ast.operator}`);\n }\n const operand = SafeEval.evalAst(ast.argument, subs);\n return UNOPS[ast.operator](operand);\n },\n\n /**\n * @param {jsep.ArrayExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalArrayExpression (ast, subs) {\n return ast.elements.map((el) => SafeEval.evalAst(\n /** @type {jsep.Expression} */\n (el),\n subs\n ));\n },\n\n /**\n * @param {jsep.CallExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalCallExpression (ast, subs) {\n const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));\n const func = SafeEval.evalAst(ast.callee, subs);\n if (\n isBlockedFunction(func) ||\n args.some((arg) => isBlockedFunction(arg))\n ) {\n throw new Error('Function constructor is disabled');\n }\n return (/** @type {(...args: AnyParameter[]) => UnknownResult} */ (\n func\n ))(...args);\n },\n\n /**\n * @param {AssignmentExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalAssignmentExpression (ast, subs) {\n if (ast.left.type !== 'Identifier') {\n throw new SyntaxError('Invalid left-hand side in assignment');\n }\n const id = /** @type {jsep.Identifier} */ (\n ast.left\n ).name;\n const value = SafeEval.evalAst(ast.right, subs);\n subs[id] = value;\n return subs[id];\n }\n};\n\n/**\n * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly.\n */\nclass SafeScript {\n /**\n * @param {string} expr Expression to evaluate\n */\n constructor (expr) {\n this.code = expr;\n this.ast = /** @type {unknown} */ (jsep(this.code));\n }\n\n /**\n * @param {object} context Object whose items will be added\n * to evaluation\n * @returns {EvaluatedResult} Result of evaluated code\n */\n runInNewContext (context) {\n // `Object.create(null)` creates a prototypeless object\n const keyMap = Object.assign(Object.create(null), context);\n return SafeEval.evalAst(\n /** @type {jsep.Expression} */ (this.ast),\n keyMap\n );\n }\n}\n\nexport {SafeScript, getSafeProperty};\n","/**\n * @param {unknown} val\n */\nexport const toStringTag = (val) => {\n return Object.prototype.toString.call(val).slice(8, -1);\n};\n\n/**\n * @param {unknown} a\n * @param {unknown} b\n */\nexport const hasConstructor = (a, b) => {\n return Function.prototype.toString.call(\n Object.getPrototypeOf(a).constructor\n ) === Function.prototype.toString.call(\n b\n );\n};\n","/* eslint-disable camelcase -- Convenient for escaping */\n/* eslint-disable class-methods-use-this -- Consistent monkey-patching */\n/* eslint-disable unicorn/prefer-private-class-fields -- Allow\n monkey-patching */\nimport {SafeScript, getSafeProperty} from './Safe-Script.js';\nimport {toStringTag} from './utils.js';\n\nconst scriptCache = new Map();\nconst pathCache = new Map();\n\n/**\n * @typedef {any} AnyInput\n */\n\n/**\n * @typedef {((...args: any[]) => any)} SandboxCallback\n */\n\n/**\n * @typedef {any|SandboxCallback} SandboxPropertyValue\n */\n\n/**\n * @typedef {(string|number)[]} ExpressionArray\n */\n\n/**\n * @typedef {\"scalar\"|\"boolean\"|\"string\"|\"undefined\"\n * |\"function\"|\"integer\"|\"number\"|\"nonFinite\"|\"object\"\n * |\"array\"|\"other\"|\"null\"|\"symbol\"|\"Promise\"|\"BigInt\"\n * |\"jsonReference\"} ValueType\n */\n\n/**\n * @typedef {unknown} ParentValue\n */\n\n/**\n * @typedef {unknown} UnknownResult\n */\n\n/**\n * @typedef {string|number|null} ParentProperty\n */\n\n/**\n * @typedef {ReturnObject|string|number|boolean|null|unknown[]\n * |Record} PreferredOutput\n */\n\n/**\n * Copies array and then pushes item into it.\n * @param {ExpressionArray} arr Array to copy and into which to push\n * @param {string|number} item Array item to add (to end)\n * @returns {ExpressionArray} Copy of the original array\n */\nfunction push (arr, item) {\n arr = arr.slice();\n arr.push(item);\n return arr;\n}\n/**\n * Copies array and then unshifts item into it.\n * @param {string|number} item Array item to add (to beginning)\n * @param {ExpressionArray} arr Array to copy and into which to unshift\n * @returns {ExpressionArray} Copy of the original array\n */\nfunction unshift (item, arr) {\n arr = arr.slice();\n arr.unshift(item);\n return arr;\n}\n\n/**\n * @typedef {object} ReturnObject\n * @property {ExpressionArray|string} path\n * @property {unknown} value\n * @property {ParentValue} parent\n * @property {ParentProperty} parentProperty\n * @property {boolean} [isParentSelector]\n * @property {boolean} [hasArrExpr]\n * @property {ExpressionArray} [expr]\n * @property {string} [pointer]\n */\n\n/**\n * @callback JSONPathCallback\n * @param {any} preferredOutput Using `any` type instead of `PreferredOutput` so\n * that user can supply flexible type\n * @param {\"value\"|\"property\"} type\n * @param {ReturnObject} fullRetObj\n * @returns {void}\n */\n\n/**\n * @callback OtherTypeCallback\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {string|number|null} parentPropName\n * @param {string} arg\n * @returns {boolean|null}\n */\n\n/**\n * @typedef {any} ContextItem\n */\n\n/**\n * @typedef {any} EvaluatedResult\n */\n\n/**\n * @callback EvalCallback\n * @param {string} code\n * @param {ContextItem} context\n * @returns {EvaluatedResult}\n */\n\n/**\n * @typedef {new (expr: string) => {\n * runInNewContext: (context: object) => EvaluatedResult\n * }} ScriptConstructor\n */\n\n/**\n * @typedef {ScriptConstructor} EvalClass\n */\n\n/**\n * @typedef {\"value\"|\"path\"|\"pointer\"|\"parent\"|\"parentProperty\"\n * |\"all\"} ResultType\n */\n\n/**\n * @typedef {EvalCallback|EvalClass|'safe'|'native'|boolean} EvalValue\n */\n\n/**\n * @typedef {string|string[]} PathType\n */\n\n/**\n * @typedef {{Script: ScriptConstructor}} SafeScriptType\n */\n\n/**\n * @typedef {{Script: ScriptConstructor}} ScriptType\n */\n\n/**\n * @typedef {{\n * _$_path?: string,\n * _$_parentProperty?: ParentProperty,\n * _$_parent?: ParentValue,\n * _$_property?: string|number,\n * _$_root?: AnyInput,\n * _$_v?: unknown,\n * [key: string]: SandboxPropertyValue\n * }} SandboxType\n */\n\n/**\n * @typedef {object} JSONPathOptions\n * @property {AnyInput} [json]\n * @property {PathType} [path]\n * @property {ResultType} [resultType=\"value\"]\n * @property {boolean} [flatten=false]\n * @property {boolean} [wrap=true]\n * @property {SandboxType} [sandbox={}]\n * @property {EvalValue} [eval='safe']\n * @property {any|null} [parent=null]\n * @property {ParentProperty} [parentProperty=null]\n * @property {JSONPathCallback} [callback]\n * @property {OtherTypeCallback} [otherTypeCallback] Defaults to\n * function which throws on encountering `@other`\n * @property {Record} [customTypes] Map of\n * custom type operator names to their evaluation callbacks\n * @property {boolean} [autostart=true]\n * @property {boolean} [ignoreEvalErrors=false]\n */\n\n\n/**\n * @overload\n * @param {string} opts JSON path to evaluate\n * @param {AnyInput} [expr] JSON object to evaluate against\n * @param {JSONPathCallback} [obj] Passed 3 arguments: 1) desired\n * payload per `resultType`, 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [callback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n * @param {undefined} [otherTypeCallback]\n * @returns {unknown} The string form always has `autostart` implicitly\n * `true`, so the result is the evaluated value, not a `JSONPathClass`\n */\n/**\n * @overload\n * @param {JSONPathOptions & {autostart: false}} opts An options object\n * with `autostart` explicitly set to `false` defers evaluation and\n * returns the `JSONPathClass` instance instead\n * @returns {JSONPathClass}\n */\n/**\n * @overload\n * @param {JSONPathOptions} opts If a string, will be treated as\n * `expr`\n * @returns {unknown}\n */\n/**\n * @param {JSONPathOptions|string} opts If a string, will be treated as `expr`\n * @param {string|AnyInput} [expr] JSON path to evaluate\n * @param {AnyInput|JSONPathCallback} [obj] JSON object to evaluate against\n * @param {JSONPathCallback|OtherTypeCallback} [callback] Passed 3\n * arguments: 1) desired payload per `resultType`,\n * 2) `\"value\"|\"property\"`, 3) Full returned object with\n * all payloads\n * @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the end\n * of one's query, this will be invoked with the value of the item, its\n * path, its parent, and its parent's property name, and it should return\n * a boolean indicating whether the supplied value belongs to the \"other\"\n * type or not (or it may handle transformations and return `false`).\n * @throws {Error}\n * @returns {unknown|JSONPathClass}\n */\nfunction JSONPath (opts, expr, obj, callback, otherTypeCallback) {\n try {\n if (opts && typeof opts === 'object') {\n return new JSONPathClass(opts);\n }\n return new JSONPathClass(\n opts,\n expr,\n /** @type {JSONPathCallback|undefined} */ (obj),\n /** @type {OtherTypeCallback|undefined} */ (callback),\n /** @type {undefined} */ (otherTypeCallback)\n );\n } catch (e) {\n if (new.target) {\n throw e;\n }\n if (e && typeof e === 'object' && 'value' in e) {\n return /** @type {{value: UnknownResult}} */ (e).value;\n }\n throw e;\n }\n}\n\n/**\n *\n */\nclass JSONPathClass {\n /**\n * @overload\n * @param {string} opts JSON path to evaluate\n * @param {AnyInput} [expr] JSON object to evaluate against\n * @param {JSONPathCallback} [obj] Passed 3 arguments: 1) desired\n * payload per `resultType`, 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [callback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n * @param {undefined} [otherTypeCallback]\n */\n /**\n * @overload\n * @param {JSONPathOptions} opts If a string, will be treated as\n * `expr`\n */\n /**\n * @param {null|string|JSONPathOptions} opts If a string, will be treated as\n * `expr`\n * @param {string|AnyInput} [expr] JSON path to evaluate\n * @param {AnyInput|JSONPathCallback} [obj] JSON object to evaluate against\n * @param {JSONPathCallback|OtherTypeCallback} [callback] Passed 3\n * arguments: 1) desired payload per `resultType`,\n * 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n */\n constructor (opts, expr, obj, callback, otherTypeCallback) {\n if (typeof opts === 'string') {\n otherTypeCallback = /** @type {OtherTypeCallback} */ (\n callback\n );\n callback = /** @type {JSONPathCallback} */ (\n obj\n );\n obj = expr;\n expr = opts;\n opts = null;\n }\n const optObj = opts && typeof opts === 'object';\n opts ||= /** @type {JSONPathOptions} */ ({});\n /** @type {ResultType|undefined} */\n this.currResultType = undefined;\n\n /** @type {EvalValue|undefined} */\n this.currEval = undefined;\n\n /** @type {OtherTypeCallback|undefined} */\n this.currOtherTypeCallback = undefined;\n\n /** @type {Record|undefined} */\n this.currCustomTypes = undefined;\n\n /** @type {SandboxType|undefined} */\n this.currSandbox = undefined;\n\n this._hasParentSelector = false;\n\n this.json = opts.json || obj;\n this.path = opts.path || expr;\n this.resultType = opts.resultType || 'value';\n this.flatten = Object.hasOwn(opts, 'flatten') && opts.flatten;\n this.wrap = !Object.hasOwn(opts, 'wrap') || opts.wrap;\n this.sandbox = opts.sandbox || {};\n this.eval = opts.eval === undefined ? 'safe' : opts.eval;\n this.ignoreEvalErrors = (\n typeof opts.ignoreEvalErrors !== 'undefined'\n ) && opts.ignoreEvalErrors;\n this.parent = Object.hasOwn(opts, 'parent') ? opts.parent : null;\n this.parentProperty = Object.hasOwn(opts, 'parentProperty')\n ? opts.parentProperty\n : null;\n this.callback = opts.callback ||\n /** @type {JSONPathCallback} */\n (callback) ||\n null;\n this.otherTypeCallback = opts.otherTypeCallback ||\n otherTypeCallback ||\n function () {\n throw new TypeError(\n 'You must supply an otherTypeCallback callback option ' +\n 'with the @other() operator.'\n );\n };\n this.customTypes = opts.customTypes || {};\n\n if (opts.autostart === false) {\n return;\n }\n\n const args = /** @type {JSONPathOptions} */ ({\n path: (optObj ? opts.path : expr)\n });\n if (!optObj && obj !== undefined) {\n args.json = obj;\n } else if ('json' in opts) {\n args.json = opts.json;\n }\n const ret = this.evaluate(args);\n if (!ret || typeof ret !== 'object') {\n const err = /** @type {Error & {value: UnknownResult}} */ (\n new Error(\n 'JSONPath should not be called with \"new\" (it ' +\n 'prevents return of (unwrapped) scalar values)'\n )\n );\n err.value = ret;\n throw err;\n }\n\n // @ts-expect-error - Constructor returns evaluate result for legacy API\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line consistent-return, no-constructor-return -- Legacy API\n return ret;\n }\n\n // PUBLIC METHODS\n\n /**\n * @overload\n * @param {JSONPathOptions} [expr]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n\n /**\n * @overload\n * @param {PathType|undefined} [expr]\n * @param {AnyInput} [json]\n * @param {JSONPathCallback|null} [callback]\n * @param {OtherTypeCallback} [otherTypeCallback]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n\n /**\n * @param {PathType|JSONPathOptions|undefined} [expr]\n * @param {AnyInput} [json]\n * @param {JSONPathCallback|null} [callback]\n * @param {OtherTypeCallback} [otherTypeCallback]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n evaluate (\n expr, json, callback, otherTypeCallback\n ) {\n let currParent = this.parent,\n currParentProperty = this.parentProperty;\n let {flatten, wrap} = this;\n\n this.currResultType = this.resultType;\n this.currEval = this.eval;\n this.currSandbox = this.sandbox;\n callback ||= this.callback;\n this.currOtherTypeCallback = otherTypeCallback ||\n this.otherTypeCallback;\n this.currCustomTypes = this.customTypes;\n\n if (expr && typeof expr === 'object' && !Array.isArray(expr)) {\n const exprObj = expr;\n if (!exprObj.path && exprObj.path !== '') {\n throw new TypeError(\n 'You must supply a \"path\" property when providing an ' +\n 'object argument to JSONPath.evaluate().'\n );\n }\n if (!(Object.hasOwn(exprObj, 'json'))) {\n throw new TypeError(\n 'You must supply a \"json\" property when providing an ' +\n 'object argument to JSONPath.evaluate().'\n );\n }\n ({json} = exprObj);\n flatten = Object.hasOwn(exprObj, 'flatten')\n ? exprObj.flatten\n : flatten;\n this.currResultType = Object.hasOwn(exprObj, 'resultType')\n ? exprObj.resultType\n : this.currResultType;\n this.currSandbox = Object.hasOwn(exprObj, 'sandbox')\n ? exprObj.sandbox\n : this.currSandbox;\n wrap = Object.hasOwn(exprObj, 'wrap') ? exprObj.wrap : wrap;\n this.currEval = Object.hasOwn(exprObj, 'eval')\n ? exprObj.eval\n : this.currEval;\n callback = Object.hasOwn(exprObj, 'callback')\n ? exprObj.callback\n : callback;\n this.currOtherTypeCallback = Object.hasOwn(\n exprObj, 'otherTypeCallback'\n )\n ? exprObj.otherTypeCallback\n : this.currOtherTypeCallback;\n this.currCustomTypes = Object.hasOwn(\n exprObj, 'customTypes'\n )\n ? exprObj.customTypes\n : this.currCustomTypes;\n currParent = Object.hasOwn(exprObj, 'parent')\n ? exprObj.parent\n : currParent;\n currParentProperty = Object.hasOwn(exprObj, 'parentProperty')\n ? exprObj.parentProperty\n : currParentProperty;\n expr = exprObj.path;\n } else {\n json ||= this.json;\n expr ||= this.path;\n }\n currParent ||= null;\n currParentProperty ||= null;\n\n if (Array.isArray(expr)) {\n expr = JSONPath.toPathString(expr);\n }\n if (!json || (!expr && expr !== '')) {\n return undefined;\n }\n\n const exprList = JSONPath.toPathArray(\n /** @type {string} */\n (expr)\n );\n if (exprList[0] === '$' && exprList.length > 1) {\n exprList.shift();\n }\n this._hasParentSelector = false;\n const traceResult = this._trace(\n exprList, json, ['$'], currParent,\n currParentProperty,\n callback ?? undefined,\n undefined\n );\n\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next 2 -- Unreachable: _trace returns array when hasArrExpr set */\n const result = (\n Array.isArray(traceResult) ? traceResult : [traceResult]\n ).filter((ea) => {\n return ea && !ea.isParentSelector;\n });\n\n if (!result.length) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: valid queries always produce results */\n return wrap ? [] : undefined;\n }\n if (!wrap && result.length === 1 && !result[0].hasArrExpr) {\n const preferredOutput = this._getPreferredOutput(result[0]);\n return preferredOutput;\n }\n const reduced = result.reduce(\n (rslt, ea) => {\n const valOrPath = this._getPreferredOutput(ea);\n if (flatten && Array.isArray(valOrPath)) {\n rslt = rslt.concat(valOrPath);\n } else {\n rslt.push(valOrPath);\n }\n return rslt;\n },\n /** @type {UnknownResult[]} */\n ([])\n );\n\n return reduced;\n }\n\n // PRIVATE METHODS\n\n /**\n * @param {ReturnObject} ea\n * @returns {PreferredOutput}\n */\n _getPreferredOutput (ea) {\n const resultType = this.currResultType;\n switch (resultType) {\n case 'all': {\n const path = Array.isArray(ea.path)\n ? ea.path\n : JSONPath.toPathArray(ea.path);\n ea.pointer = JSONPath.toPointer(/** @type {string[]} */ (path));\n ea.path = typeof ea.path === 'string'\n ? ea.path\n : JSONPath.toPathString(/** @type {string[]} */ (ea.path));\n return ea;\n } case 'value': case 'parent': case 'parentProperty':\n return /** @type {PreferredOutput} */ (ea[resultType]);\n case 'path':\n if (typeof ea.path === 'string') {\n return ea.path;\n }\n return JSONPath.toPathString(/** @type {string[]} */ (ea.path));\n case 'pointer': {\n const pathArray = Array.isArray(ea.path)\n ? ea.path\n : JSONPath.toPathArray(ea.path);\n return JSONPath.toPointer(/** @type {string[]} */ (pathArray));\n }\n default:\n throw new TypeError('Unknown result type');\n }\n }\n\n /**\n * @param {ReturnObject} fullRetObj\n * @param {JSONPathCallback|undefined} callback\n * @param {\"value\"|\"property\"} type\n * @returns {void}\n */\n _handleCallback (fullRetObj, callback, type) {\n // Early return if no callback provided (defensive\n // check for internal calls)\n if (!callback) {\n return;\n }\n const preferredOutput = this._getPreferredOutput(fullRetObj);\n if (Array.isArray(fullRetObj.path)) {\n fullRetObj.path = JSONPath.toPathString(\n /** @type {string[]} */ (fullRetObj.path)\n );\n }\n callback(preferredOutput, type, fullRetObj);\n }\n\n /**\n *\n * @param {ExpressionArray} expr\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @param {JSONPathCallback|undefined} callback\n * @param {boolean|undefined} hasArrExpr\n * @param {boolean} [literalPriority]\n * @returns {ReturnObject|ReturnObject[]}\n */\n _trace (\n expr, val, path, parent, parentPropName, callback, hasArrExpr,\n literalPriority\n ) {\n // No expr to follow? return path and value as the result of\n // this trace branch\n let retObj;\n if (!expr.length) {\n retObj = {\n path,\n value: val,\n parent,\n parentProperty: parentPropName,\n hasArrExpr\n };\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n\n const loc = /** @type {string} */ (expr[0]), x = expr.slice(1);\n\n // We need to gather the return value of recursive trace calls in order\n // to do the parent sel computation.\n /** @type {ReturnObject[]} */\n const ret = [];\n /**\n *\n * @param {ReturnObject|ReturnObject[]} elems\n * @returns {void}\n */\n function addRet (elems) {\n if (Array.isArray(elems)) {\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test:\n // `ret.push(...elems);`\n elems.forEach((t) => {\n ret.push(t);\n });\n } else {\n ret.push(elems);\n }\n }\n if (val && (typeof loc !== 'string' || literalPriority) &&\n Object.hasOwn(val, /** @type {PropertyKey} */ (loc))\n ) { // simple case--directly follow property\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[/** @type {string} */ (loc)],\n push(path, loc),\n val, /** @type {string|number} */ (loc), callback,\n hasArrExpr\n ));\n // eslint-disable-next-line unicorn/prefer-switch -- Part of larger `if`\n } else if (loc === '*') { // all child properties\n this._walk(val, (m) => {\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[m], push(path, m), val, m, callback, true, true\n ));\n });\n } else if (loc === '..') { // all descendent parent properties\n // Check remaining expression with val's immediate children\n addRet(\n this._trace(x, val, path, parent, parentPropName, callback,\n hasArrExpr)\n );\n this._walk(val, (m) => {\n // We don't join m and x here because we only want parents,\n // not scalar values\n const valObj = /** @type {Record} */ (val);\n if (typeof valObj[m] === 'object') {\n // Keep going with recursive descent on val's\n // object children\n addRet(this._trace(\n expr.slice(),\n valObj[m],\n push(path, m),\n val,\n m,\n callback,\n true\n ));\n }\n });\n // The parent sel computation is handled in the frame above using the\n // ancestor object of val\n } else if (loc === '^') {\n // This is not a final endpoint, so we do not invoke the\n // callback here\n this._hasParentSelector = true;\n return /** @type {ReturnObject} */ ({\n path: path.slice(0, -1),\n expr: x,\n isParentSelector: true,\n value: undefined,\n parent: undefined,\n parentProperty: null\n });\n } else if (loc === '~') { // property name\n retObj = {\n path: push(path, loc),\n value: parentPropName,\n parent,\n parentProperty: null\n };\n this._handleCallback(retObj, callback, 'property');\n return retObj;\n } else if (loc === '$') { // root only\n addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));\n } else if ((/^(-?\\d*):(-?\\d*):?(\\d*)$/v).test(loc)) { // [start:end:step] Python slice syntax\n const sliceResult = this._slice(\n loc, x, val, path, parent, parentPropName, callback\n );\n if (sliceResult) {\n addRet(sliceResult);\n }\n } else if (loc.indexOf('?(') === 0) { // [?(expr)] (filtering)\n if (this.currEval === false) {\n throw new Error(\n 'Eval [?(expr)] prevented in JSONPath expression.'\n );\n }\n const safeLoc = loc.replace(/^\\?\\((.*?)\\)$/v, '$1');\n // check for a nested filter expression\n\n const nested = (/@.?([^?]*)[\\['](\\??\\(.*?\\))(?!.\\)\\])[\\]']/gv).exec(safeLoc);\n if (nested) {\n // find if there are matches in the nested expression\n // add them to the result set if there is at least one match\n this._walk(val, (m) => {\n const npath = [nested[2]];\n const valObj2 = /** @type {Record} */ (\n val\n );\n // guard against nested[1] resolving to `constructor`\n const nvalue = /** @type {ValueType} */ (nested[1]\n ? getSafeProperty(\n /** @type {Record} */ (\n valObj2[m]\n ),\n nested[1]\n )\n : valObj2[m]);\n const filterResults = this._trace(npath, nvalue, path,\n parent, parentPropName, callback, true);\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next 3 -- Unreachable: _trace always returns array for nested filters */\n const filterArray = Array.isArray(filterResults)\n ? filterResults\n : [filterResults];\n if (filterArray.length > 0) {\n addRet(this._trace(x, valObj2[m], push(path, m), val,\n m, callback, true));\n }\n });\n } else {\n const valObj3 = /** @type {Record} */ (val);\n this._walk(val, (m) => {\n if (this._eval(safeLoc, valObj3[m], m, path, parent,\n parentPropName)) {\n addRet(this._trace(x, valObj3[m], push(path, m), val, m,\n callback, true));\n }\n });\n }\n } else if (loc[0] === '(') { // [(expr)] (dynamic property/index)\n if (this.currEval === false) {\n throw new Error(\n 'Eval [(expr)] prevented in JSONPath expression.'\n );\n }\n // As this will resolve to a property name (but we don't know it\n // yet), property and parent information is relative to the\n const evalResult = this._eval(\n /** @type {string} */ (loc),\n val, /** @type {string|number} */ (path.at(-1)),\n path.slice(0, -1), parent, parentPropName\n );\n const exprToUse = /** @type {string|number} */ (\n evalResult !== undefined ? evalResult : ''\n );\n addRet(this._trace(unshift(\n exprToUse,\n x\n ), val, path, parent, parentPropName, callback, hasArrExpr));\n } else if (loc[0] === '@') { // value type: @boolean(), etc.\n // eslint-disable-next-line no-useless-assignment -- ESLint bug\n let addType = false;\n const parenthIndex = loc.indexOf('(');\n const valueType = /** @type {ValueType|string} */ (\n loc\n ).slice(1, parenthIndex);\n const lastParenth = loc.lastIndexOf(')');\n const argRaw = loc.slice(parenthIndex + 1, lastParenth);\n const arg = argRaw ? JSON.parse(argRaw) : undefined;\n switch (valueType) {\n case 'scalar':\n addType = !val ||\n !(['object', 'function'].includes(typeof val));\n break;\n case 'boolean': case 'string': case 'undefined': case 'function':\n addType = typeof val === valueType;\n break;\n case 'integer':\n addType = Number.isFinite(val) &&\n !(/** @type {number} */ (val) % 1);\n break;\n case 'number':\n addType = Number.isFinite(val);\n break;\n case 'nonFinite':\n addType = typeof val === 'number' && !Number.isFinite(val);\n break;\n case 'object':\n addType = Boolean(val) && typeof val === valueType;\n break;\n case 'array':\n addType = Array.isArray(val);\n break;\n case 'other':\n addType = /** @type {OtherTypeCallback} */ (\n this.currOtherTypeCallback\n )(\n val, path, parent, parentPropName, arg\n ) || false;\n break;\n case 'null':\n addType = val === null;\n break;\n case 'symbol':\n addType = typeof val === 'symbol';\n break;\n case 'BigInt':\n addType = typeof val === 'bigint';\n break;\n case 'Promise':\n addType = toStringTag(val) === 'Promise';\n break;\n case 'jsonReference':\n addType = Boolean(val) && typeof val === 'object' &&\n Object.hasOwn(/** @type {object} */ (val), '$ref');\n break;\n default:\n if (this.currCustomTypes &&\n Object.hasOwn(this.currCustomTypes, valueType)\n ) {\n addType = this.currCustomTypes[valueType](\n val, path, parent, parentPropName, arg\n ) || false;\n } else {\n throw new TypeError('Unknown value type ' + valueType);\n }\n }\n if (addType) {\n retObj = {\n path, value: val, parent, parentProperty: parentPropName\n };\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n // `-escaped property\n } else if (val && loc[0] === '`' &&\n Object.hasOwn(val, loc.slice(1))\n ) {\n const locProp = loc.slice(1);\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[locProp], push(path, locProp), val, locProp, callback,\n hasArrExpr, true\n ));\n } else if (loc[0] === \"'\" || loc[0] === '\"') { // ['name1','name2',...]\n // Quoted members are literal property names\n for (const [, single, double] of loc.matchAll(\n /'((?:\\\\.|[^'\\\\])*)'|\"((?:\\\\.|[^\"\\\\])*)\"/gv\n )) {\n const prop = (single ?? double).replaceAll(\n /\\\\(['\"\\\\])/gv, '$1'\n );\n if (!val || !Object.hasOwn(val, prop)) {\n continue;\n }\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[prop], push(path, prop), val, prop,\n callback, true\n ));\n }\n } else if (loc.includes(',')) { // [name1,name2,...]\n const parts = loc.split(',');\n for (const part of parts) {\n addRet(this._trace(\n unshift(part, x),\n val,\n path,\n parent,\n parentPropName,\n callback,\n true\n ));\n }\n // simple case--directly follow property\n } else if (\n !literalPriority && val && Object.hasOwn(val, loc)\n ) {\n const valObj = /** @type {Record} */ (val);\n addRet(\n this._trace(x, valObj[loc], push(path, loc), val, loc, callback,\n hasArrExpr, true)\n );\n }\n\n // We check the resulting values for parent selections. For parent\n // selections we discard the value object and continue the trace with\n // the current val object\n if (this._hasParentSelector) {\n for (let t = 0; t < ret.length; t++) {\n const rett = ret[t];\n if (!rett || !rett.isParentSelector) {\n continue;\n }\n\n const exprToUse = /** @type {ExpressionArray} */ (\n rett.expr\n );\n const pathToUse = /** @type {ExpressionArray} */ (\n rett.path\n );\n const tmp = this._trace(\n exprToUse,\n val,\n pathToUse,\n parent,\n parentPropName,\n callback,\n hasArrExpr\n );\n if (Array.isArray(tmp)) {\n ret[t] = tmp[0];\n const tl = tmp.length;\n for (let tt = 1; tt < tl; tt++) {\n t++;\n ret.splice(t, 0, tmp[tt]);\n }\n } else {\n ret[t] = tmp;\n }\n }\n }\n return ret;\n }\n\n /**\n * @param {unknown} val\n * @param {(prop: string|number) => void} f\n * @returns {void}\n */\n _walk (val, f) {\n if (Array.isArray(val)) {\n const n = val.length;\n for (let i = 0; i < n; i++) {\n f(i);\n }\n } else if (val && typeof val === 'object') {\n Object.keys(val).forEach((m) => {\n f(m);\n });\n }\n }\n\n /**\n * @param {string} loc\n * @param {ExpressionArray} expr\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @param {JSONPathCallback|undefined} callback\n * @returns {ReturnObject[]|undefined}\n */\n _slice (\n loc, expr, val, path, parent, parentPropName, callback\n ) {\n if (!Array.isArray(val)) {\n return undefined;\n }\n const len = val.length, parts = loc.split(':'),\n step = (parts[2] && Number(parts[2])) || 1;\n let start = (parts[0] && Number(parts[0])) || 0,\n end = parts[1] ? Number(parts[1]) : len;\n start = (start < 0) ? Math.max(0, start + len) : Math.min(len, start);\n end = (end < 0) ? Math.max(0, end + len) : Math.min(len, end);\n /** @type {ReturnObject[]} */\n const ret = [];\n for (let i = start; i < end; i += step) {\n const tmp = this._trace(\n unshift(i, expr),\n val,\n path,\n parent,\n parentPropName,\n callback,\n true\n );\n // Should only be possible to be an array here since first part of\n // ``unshift(i, expr)` passed in above would not be empty,\n // nor `~`, nor begin with `@` (as could return objects)\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test: `ret.push(...tmp);`\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: _trace returns array when expr non-empty */\n const tmpArray = Array.isArray(tmp) ? tmp : [tmp];\n tmpArray.forEach((t) => {\n ret.push(t);\n });\n }\n return ret;\n }\n\n /**\n * @param {string} code\n * @param {unknown} _v\n * @param {string|number} _vname\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @returns {UnknownResult}\n */\n _eval (\n code, _v, _vname, path, parent, parentPropName\n ) {\n if (this.currSandbox) {\n this.currSandbox._$_parentProperty = parentPropName;\n this.currSandbox._$_parent = parent;\n this.currSandbox._$_property = _vname;\n this.currSandbox._$_root = this.json;\n this.currSandbox._$_v = _v;\n }\n\n const containsPath = code.includes('@path');\n if (containsPath) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: currSandbox set in evaluate() before _eval */\n const currSandbox = this.currSandbox ?? {};\n currSandbox._$_path = JSONPath.toPathString(\n /** @type {string[]} */ (path.concat([_vname]))\n );\n }\n\n const scriptCacheKey = this.currEval + 'Script:' + code;\n if (!scriptCache.has(scriptCacheKey)) {\n let script = code\n .replaceAll('@parentProperty', '_$_parentProperty')\n .replaceAll('@parent', '_$_parent')\n .replaceAll('@property', '_$_property')\n .replaceAll('@root', '_$_root')\n // Replace a bare `@` (not followed by an identifier\n // character) while leaving quoted string literals and\n // regex literals (a `/` where an operand is expected,\n // as opposed to division) intact\n .replaceAll(\n /('(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\"|(?<=(?:^|[\\(,=:\\[!\\|?\\{\\};+\\-*%<>~^]|&)\\s*)\\/(?:\\\\.|\\[(?:\\\\.|[^\\]\\\\])*\\]|[^\\/\\\\\\[])+\\/[dgimsuvy]*)|@(?![\\w$])/gv,\n (_, literal) => literal ?? '_$_v'\n );\n if (containsPath) {\n script = script.replaceAll('@path', '_$_path');\n }\n const evalType = /** @type {string|boolean|undefined} */ (\n this.currEval\n );\n if (['safe', true, undefined].includes(evalType)) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-disable unicorn/no-undeclared-class-members -- Prototype members */\n scriptCache.set(scriptCacheKey, new (\n /**\n * @type {JSONPathClass & {\n * safeVm: SafeScriptType,\n * vm: ScriptType\n * }}\n */ (/** @type {unknown} */ (this))\n ).safeVm.Script(script));\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-enable unicorn/no-undeclared-class-members -- End prototype member scope */\n } else if (this.currEval === 'native') {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-disable unicorn/no-undeclared-class-members -- Prototype members */\n scriptCache.set(scriptCacheKey, new (\n /**\n * @type {JSONPathClass & {\n * safeVm: SafeScriptType,\n * vm: ScriptType\n * }}\n */ (/** @type {unknown} */ (this))\n ).vm.Script(script));\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-enable unicorn/no-undeclared-class-members -- End prototype member scope */\n } else if (\n typeof this.currEval === 'function' &&\n this.currEval.prototype &&\n Object.hasOwn(this.currEval.prototype, 'runInNewContext')\n ) {\n const CurrEval = this.currEval;\n // eslint-disable-next-line @stylistic/max-len -- Long\n // @ts-expect-error - Type checked above to have proper constructor\n scriptCache.set(scriptCacheKey, new CurrEval(script));\n } else if (typeof this.currEval === 'function') {\n // Type narrowing: at this point currEval is a function\n // but not a constructor\n const evalFunc = /** @type {EvalCallback} */ (this.currEval);\n scriptCache.set(scriptCacheKey, {\n runInNewContext: (\n /** @type {ContextItem} */ context\n ) => evalFunc(script, context)\n });\n } else {\n throw new TypeError(\n `Unknown \"eval\" property \"${this.currEval}\"`\n );\n }\n }\n\n try {\n /**\n * @typedef {{\n * runInNewContext: (\n * ctx: SandboxType|undefined\n * ) => EvaluatedResult\n * }} RunInNewContext\n */\n\n return /** @type {RunInNewContext} */ (\n scriptCache.get(scriptCacheKey)\n ).runInNewContext(\n this.currSandbox\n );\n } catch (e) {\n if (this.ignoreEvalErrors) {\n return false;\n }\n const error = /** @type {Error} */ (e);\n throw new Error('jsonPath: ' + error.message + ': ' + code, {\n cause: e\n });\n }\n }\n}\n\n/** @type {{safeVm: SafeScriptType}} */\n(/** @type {unknown} */ (JSONPathClass.prototype)).safeVm = {\n Script: SafeScript\n};\n\nJSONPath.prototype = JSONPathClass.prototype;\n\n// PUBLIC CLASS PROPERTIES AND METHODS\n\n/**\n * Clears cached parsed paths and compiled scripts.\n * @returns {void}\n */\nJSONPath.clearCache = function () {\n pathCache.clear();\n scriptCache.clear();\n};\n\n/**\n * @param {string[]} pathArr Array to convert\n * @returns {string} The path string\n */\nJSONPath.toPathString = function (pathArr) {\n const x = pathArr, n = x.length;\n let p = '$';\n for (let i = 1; i < n; i++) {\n if (!(/^(~|\\^|@.*?\\(\\))$/v).test(x[i])) {\n p += (/^[0-9*]+$/v).test(x[i])\n ? ('[' + x[i] + ']')\n : (\"['\" + String(x[i]).replaceAll(/['\\\\]/gv, String.raw`\\$&`) + \"']\");\n }\n }\n return p;\n};\n\n/**\n * @param {string[]} pointer JSON Path array\n * @returns {string} JSON Pointer\n */\nJSONPath.toPointer = function (pointer) {\n const x = pointer, n = x.length;\n let p = '';\n for (let i = 1; i < n; i++) {\n if (!(/^(~|\\^|@.*?\\(\\))$/v).test(x[i])) {\n p += '/' + x[i].toString()\n .replaceAll('~', '~0')\n .replaceAll('/', '~1');\n }\n }\n return p;\n};\n\n/**\n * @param {string} expr Expression to convert\n * @returns {string[]}\n */\nJSONPath.toPathArray = function (expr) {\n if (pathCache.has(expr)) {\n return /** @type {string[]} */ (pathCache.get(expr)).concat();\n }\n /** @type {string[]} */\n const subx = [];\n const normalized = expr\n // Properties\n .replaceAll(\n /@[\\w$\\-]+\\([^\\)]*\\)/gv,\n ';$&;'\n )\n // Parenthetical evaluations (filtering and otherwise), directly\n // within brackets or single quotes\n .replaceAll(/[\\['](\\??\\(.*?\\))[\\]'](?!.\\])/gv, function ($0, $1) {\n return '[#' +\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line unicorn/no-return-array-push -- Optimization\n (subx.push($1) - 1) +\n ']';\n })\n // Unions of quoted property names (e.g., `['x','y']`) and quoted\n // names with commas or backslash escapes, kept intact (with\n // quotes) so their members survive tokenization\n .replaceAll(\n /\\[\\s*((?:'(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\")(?:\\s*,\\s*(?:'(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\"))*)\\s*\\]/gv,\n function ($0, $1) {\n if (!(/[,\\\\]/v).test($1)) {\n return $0;\n }\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line unicorn/no-return-array-push -- Optimization\n return '[#' + (subx.push($1) - 1) + ']';\n }\n )\n // Escape periods and tildes within properties\n .replaceAll(/\\[['\"]([^'\\]]*)['\"]\\]/gv, function ($0, prop) {\n return \"['\" + prop\n .replaceAll('.', '%@%')\n .replaceAll('~', '%%@@%%') +\n \"']\";\n })\n // Properties operator\n .replaceAll('~', ';~;')\n // Split by property boundaries\n\n .replaceAll(/['\"]?\\.['\"]?(?![^\\[]*\\])|\\[['\"]?/gv, ';')\n // Reinsert periods within properties\n .replaceAll('%@%', '.')\n // Reinsert tildes within properties\n .replaceAll('%%@@%%', '~')\n // Parent\n .replaceAll(/(?:;)?(\\^+)(?:;)?/gv, function ($0, ups) {\n return ';' + ups.split('').join(';') + ';';\n })\n // Descendents\n .replaceAll(/;;;|;;/gv, ';..;')\n // Remove trailing\n .replaceAll(/;$|'?\\]|'$/gv, '');\n\n const exprList = normalized.split(';').map(function (exp) {\n const match = exp.match(/#(\\d+)/v);\n return !match || !match[1] ? exp : subx[Number(match[1])];\n });\n pathCache.set(expr, exprList);\n return /** @type {string[]} */ (pathCache.get(expr)).concat();\n};\n\nexport {JSONPath, JSONPathClass};\n","import {JSONPath, JSONPathClass} from './jsonpath.js';\n\n/**\n * @typedef {import('./jsonpath.js').AnyInput} AnyInput\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxCallback} SandboxCallback\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxPropertyValue} SandboxPropertyValue\n */\n/**\n * @typedef {import('./jsonpath.js').ExpressionArray} ExpressionArray\n */\n/**\n * @typedef {import('./jsonpath.js').ValueType} ValueType\n */\n/**\n * @typedef {import('./jsonpath.js').ParentValue} ParentValue\n */\n/**\n * @typedef {import('./jsonpath.js').UnknownResult} UnknownResult\n */\n/**\n * @typedef {import('./jsonpath.js').ParentProperty} ParentProperty\n */\n/**\n * @typedef {import('./jsonpath.js').PreferredOutput} PreferredOutput\n */\n/**\n * @typedef {import('./jsonpath.js').ReturnObject} ReturnObject\n */\n/**\n * @typedef {import('./jsonpath.js').JSONPathCallback} JSONPathCallback\n */\n/**\n * @typedef {import('./jsonpath.js').OtherTypeCallback} OtherTypeCallback\n */\n/**\n * @typedef {import('./jsonpath.js').ContextItem} ContextItem\n */\n/**\n * @typedef {import('./jsonpath.js').EvaluatedResult} EvaluatedResult\n */\n/**\n * @typedef {import('./jsonpath.js').EvalCallback} EvalCallback\n */\n/**\n * @typedef {import('./jsonpath.js').EvalClass} EvalClass\n */\n/**\n * @typedef {import('./jsonpath.js').ResultType} ResultType\n */\n/**\n * @typedef {import('./jsonpath.js').EvalValue} EvalValue\n */\n/**\n * @typedef {import('./jsonpath.js').PathType} PathType\n */\n/**\n * @typedef {import('./jsonpath.js').SafeScriptType} SafeScriptType\n */\n/**\n * @typedef {import('./jsonpath.js').ScriptType} ScriptType\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxType} SandboxType\n */\n/**\n * @typedef {import('./jsonpath.js').JSONPathOptions} JSONPathOptions\n */\n\n/**\n * @template T\n * @callback ConditionCallback\n * @param {T} item\n * @returns {boolean}\n */\n\n/**\n * Copy items out of one array into another.\n * @template T\n * @param {T[]} source Array with items to copy\n * @param {T[]} target Array to which to copy\n * @param {ConditionCallback} conditionCb Callback passed the current item;\n * will move item if evaluates to `true`\n * @returns {void}\n */\nconst moveToAnotherArray = function (source, target, conditionCb) {\n const il = source.length;\n for (let i = 0; i < il; i++) {\n const item = source[i];\n if (conditionCb(item)) {\n target.push(source.splice(i--, 1)[0]);\n }\n }\n};\n\n/**\n * In-browser replacement for NodeJS' VM.Script.\n */\nclass Script {\n /**\n * @param {string} expr Expression to evaluate\n */\n constructor (expr) {\n this.code = expr;\n }\n\n /**\n * @param {SandboxType} context Object whose items will be added\n * to evaluation\n * @returns {EvaluatedResult} Result of evaluated code\n */\n runInNewContext (context) {\n let expr = this.code;\n const keys = Object.keys(context);\n const funcs = /** @type {string[]} */ ([]);\n moveToAnotherArray(keys, funcs, (key) => {\n return typeof context[key] === 'function';\n });\n const values = keys.map((vr) => {\n return context[vr];\n });\n\n const funcString = funcs.reduce((s, func) => {\n let fString = context[func].toString();\n if (!(/function/v).test(fString)) {\n fString = 'function ' + fString;\n }\n return 'var ' + func + '=' + fString + ';' + s;\n }, '');\n\n expr = funcString + expr;\n\n // Mitigate https://perfectionkills.com/global-eval-what-are-the-options/#new_function\n if (!(/(['\"])use strict\\1/v).test(expr) && !keys.includes('arguments')) {\n expr = 'var arguments = undefined;' + expr;\n }\n\n // Remove last semi so `return` will be inserted before\n // the previous one instead, allowing for the return\n // of a bare ending expression\n expr = expr.replace(/;\\s*$/v, '');\n\n // Insert `return`\n const lastStatementEnd = expr.lastIndexOf(';');\n const code =\n lastStatementEnd !== -1\n ? expr.slice(0, lastStatementEnd + 1) +\n ' return ' +\n expr.slice(lastStatementEnd + 1)\n : ' return ' + expr;\n\n // eslint-disable-next-line no-new-func -- User's choice\n return new Function(...keys, code)(...values);\n }\n}\n\n/** @type {{vm: ScriptType}} */\n(/** @type {unknown} */ (JSONPathClass.prototype)).vm = {\n Script\n};\n\nexport {JSONPath, JSONPathClass, Script};\n"],"names":["Jsep","version","toString","addUnaryOp","op_name","max_unop_len","Math","max","length","unary_ops","addBinaryOp","precedence","isRightAssociative","max_binop_len","binary_ops","right_associative","add","delete","addIdentifierChar","char","additional_identifier_chars","addLiteral","literal_name","literal_value","literals","removeUnaryOp","getMaxKeyLen","removeAllUnaryOps","removeIdentifierChar","removeBinaryOp","removeAllBinaryOps","removeLiteral","removeAllLiterals","this","expr","charAt","index","code","charCodeAt","constructor","parse","obj","Object","keys","map","k","isDecimalDigit","ch","binaryPrecedence","op_val","isIdentifierStart","String","fromCharCode","has","isIdentifierPart","throwError","message","error","Error","description","runHook","name","node","hooks","env","context","run","searchHook","find","callback","call","gobbleSpaces","SPACE_CODE","TAB_CODE","LF_CODE","CR_CODE","nodes","gobbleExpressions","type","COMPOUND","body","untilICode","ch_i","SEMCOL_CODE","COMMA_CODE","gobbleExpression","push","gobbleBinaryExpression","gobbleBinaryOp","to_check","substr","tc_len","hasOwnProperty","biop","prec","stack","biop_info","left","right","i","cur_biop","gobbleToken","value","right_a","comparePrev","prev","pop","BINARY_EXP","operator","PERIOD_CODE","gobbleNumericLiteral","SQUOTE_CODE","DQUOTE_CODE","gobbleStringLiteral","OBRACK_CODE","gobbleArray","argument","UNARY_EXP","prefix","gobbleIdentifier","LITERAL","raw","this_str","THIS_EXP","OPAREN_CODE","gobbleGroup","gobbleTokenProperty","QUMARK_CODE","optional","MEMBER_EXP","computed","object","property","CBRACK_CODE","CALL_EXP","arguments","gobbleArguments","CPAREN_CODE","callee","chCode","number","parseFloat","str","startIndex","quote","closed","substring","start","IDENTIFIER","slice","termination","args","separator_count","arg","SEQUENCE_EXP","expressions","ARRAY_EXP","elements","first","Array","isArray","forEach","assign","plugins","jsep","registered","register","plugin","init","COLON_CODE","Set","true","false","null","stdClassProps","getOwnPropertyNames","filter","prop","includes","undefined","m","ternary","test","consequent","alternate","newTest","patternIndex","inCharSet","pattern","flags","RegExp","e","assignmentOperators","updateOperators","assignmentPrecedence","updateNodeTypes","updateBinariesToAssignments","values","val","op","some","c","jsepRegex","jsepAssignment","BLOCKED_PROTO_PROPERTIES","BLOCKED_FUNCTIONS","WeakSet","Function","async","prototype","apply","bind","Reflect","construct","get","isBlockedFunction","getSafeProperty","TypeError","hasOwn","result","BINOPS","create","||","a","b","&&","|","^","&","==","!=","===","!==","<",">","<=",">=","<<",">>",">>>","+","-","*","/","%","UNOPS","typeof","void","SafeEval","evalAst","ast","subs","evalBinaryExpression","evalCompound","evalConditionalExpression","evalIdentifier","evalLiteral","evalMemberExpression","evalUnaryExpression","evalArrayExpression","evalCallExpression","evalAssignmentExpression","SyntaxError","cause","last","ReferenceError","operand","el","func","id","scriptCache","Map","pathCache","arr","item","unshift","JSONPath","opts","otherTypeCallback","JSONPathClass","optObj","currResultType","currEval","currOtherTypeCallback","currCustomTypes","currSandbox","_hasParentSelector","json","path","resultType","flatten","wrap","sandbox","eval","ignoreEvalErrors","parent","parentProperty","customTypes","autostart","ret","evaluate","err","currParent","currParentProperty","exprObj","toPathString","exprList","toPathArray","shift","traceResult","_trace","ea","isParentSelector","hasArrExpr","_getPreferredOutput","reduce","rslt","valOrPath","concat","pointer","toPointer","pathArray","_handleCallback","fullRetObj","preferredOutput","parentPropName","literalPriority","retObj","loc","x","addRet","elems","t","valObj","_walk","sliceResult","_slice","indexOf","safeLoc","replace","nested","exec","npath","valObj2","nvalue","filterResults","valObj3","_eval","evalResult","at","exprToUse","addType","parenthIndex","valueType","lastParenth","lastIndexOf","argRaw","JSON","Number","isFinite","Boolean","toStringTag","locProp","single","double","matchAll","replaceAll","parts","split","part","rett","pathToUse","tmp","tl","tt","splice","f","n","len","step","end","min","_v","_vname","_$_parentProperty","_$_parent","_$_property","_$_root","_$_v","containsPath","_$_path","scriptCacheKey","script","_","literal","evalType","set","safeVm","Script","vm","CurrEval","evalFunc","runInNewContext","keyMap","clearCache","clear","pathArr","p","subx","$0","$1","ups","join","exp","match","funcs","source","target","conditionCb","il","moveToAnotherArray","key","vr","s","fString","lastStatementEnd"],"mappings":"AAgGA,MAAMA,EAIL,kBAAWC,GAEV,MAAO,OACR,CAKA,eAAOC,GACN,MAAO,wCAA0CF,EAAKC,OACvD,CAQA,iBAAOE,CAAWC,GAGjB,OAFAJ,EAAKK,aAAeC,KAAKC,IAAIH,EAAQI,OAAQR,EAAKK,cAClDL,EAAKS,UAAUL,GAAW,EACnBJ,CACR,CASA,kBAAOU,CAAYN,EAASO,EAAYC,GASvC,OARAZ,EAAKa,cAAgBP,KAAKC,IAAIH,EAAQI,OAAQR,EAAKa,eACnDb,EAAKc,WAAWV,GAAWO,EACvBC,EACHZ,EAAKe,kBAAkBC,IAAIZ,GAG3BJ,EAAKe,k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KAAK0U,EAAOzC,OAAOpR,IAAK,GAAG,GAG9C,CAsBQiU,CAAmBzX,EAAMoX,EAAQM,GACE,mBAAjBpW,EAAQoW,IAE1B,MAAMhO,EAAS1J,EAAKC,IAAK0X,GACdrW,EAAQqW,IAWnBpY,EARmB6X,EAAMpG,OAAO,CAAC4G,EAAG3J,KAChC,IAAI4J,EAAUvW,EAAQ2M,GAAM1Q,WAI5B,MAHM,YAAaoL,KAAKkP,KACpBA,EAAU,YAAcA,GAErB,OAAS5J,EAAO,IAAM4J,EAAU,IAAMD,GAC9C,IAEiBrY,EAGd,sBAAuBoJ,KAAKpJ,IAAUS,EAAKuI,SAAS,eACtDhJ,EAAO,6BAA+BA,GAM1CA,EAAOA,EAAKiT,QAAQ,SAAU,IAG9B,MAAMsF,EAAmBvY,EAAKiU,YAAY,KACpC9T,GACmB,IAArBoY,EACMvY,EAAKmH,MAAM,EAAGoR,EAAmB,GACjC,WACAvY,EAAKmH,MAAMoR,EAAmB,GAC9B,WAAavY,EAGvB,OAAO,IAAI6K,YAAYpK,EAAMN,EAAtB,IAA+BgK,EAC1C,EAIqBkF,EAAuB,UAAGwH,GAAK,CACpDD","x_google_ignoreList":[0,1,2]} \ No newline at end of file +{"version":3,"file":"index-browser-esm.min.js","sources":["../node_modules/.pnpm/jsep@1.4.0/node_modules/jsep/dist/jsep.js","../node_modules/.pnpm/@jsep-plugin+regex@1.0.4_jsep@1.4.0/node_modules/@jsep-plugin/regex/dist/index.js","../node_modules/.pnpm/@jsep-plugin+assignment@1.3.0_jsep@1.4.0/node_modules/@jsep-plugin/assignment/dist/index.js","../src/Safe-Script.js","../src/utils.js","../src/jsonpath.js","../src/jsonpath-browser.js"],"sourcesContent":["/**\n * @implements {IHooks}\n */\nclass Hooks {\n\t/**\n\t * @callback HookCallback\n\t * @this {*|Jsep} this\n\t * @param {Jsep} env\n\t * @returns: void\n\t */\n\t/**\n\t * Adds the given callback to the list of callbacks for the given hook.\n\t *\n\t * The callback will be invoked when the hook it is registered for is run.\n\t *\n\t * One callback function can be registered to multiple hooks and the same hook multiple times.\n\t *\n\t * @param {string|object} name The name of the hook, or an object of callbacks keyed by name\n\t * @param {HookCallback|boolean} callback The callback function which is given environment variables.\n\t * @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)\n\t * @public\n\t */\n\tadd(name, callback, first) {\n\t\tif (typeof arguments[0] != 'string') {\n\t\t\t// Multiple hook callbacks, keyed by name\n\t\t\tfor (let name in arguments[0]) {\n\t\t\t\tthis.add(name, arguments[0][name], arguments[1]);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t(Array.isArray(name) ? name : [name]).forEach(function (name) {\n\t\t\t\tthis[name] = this[name] || [];\n\n\t\t\t\tif (callback) {\n\t\t\t\t\tthis[name][first ? 'unshift' : 'push'](callback);\n\t\t\t\t}\n\t\t\t}, this);\n\t\t}\n\t}\n\n\t/**\n\t * Runs a hook invoking all registered callbacks with the given environment variables.\n\t *\n\t * Callbacks will be invoked synchronously and in the order in which they were registered.\n\t *\n\t * @param {string} name The name of the hook.\n\t * @param {Object} env The environment variables of the hook passed to all callbacks registered.\n\t * @public\n\t */\n\trun(name, env) {\n\t\tthis[name] = this[name] || [];\n\t\tthis[name].forEach(function (callback) {\n\t\t\tcallback.call(env && env.context ? env.context : env, env);\n\t\t});\n\t}\n}\n\n/**\n * @implements {IPlugins}\n */\nclass Plugins {\n\tconstructor(jsep) {\n\t\tthis.jsep = jsep;\n\t\tthis.registered = {};\n\t}\n\n\t/**\n\t * @callback PluginSetup\n\t * @this {Jsep} jsep\n\t * @returns: void\n\t */\n\t/**\n\t * Adds the given plugin(s) to the registry\n\t *\n\t * @param {object} plugins\n\t * @param {string} plugins.name The name of the plugin\n\t * @param {PluginSetup} plugins.init The init function\n\t * @public\n\t */\n\tregister(...plugins) {\n\t\tplugins.forEach((plugin) => {\n\t\t\tif (typeof plugin !== 'object' || !plugin.name || !plugin.init) {\n\t\t\t\tthrow new Error('Invalid JSEP plugin format');\n\t\t\t}\n\t\t\tif (this.registered[plugin.name]) {\n\t\t\t\t// already registered. Ignore.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tplugin.init(this.jsep);\n\t\t\tthis.registered[plugin.name] = plugin;\n\t\t});\n\t}\n}\n\n// JavaScript Expression Parser (JSEP) 1.4.0\n\nclass Jsep {\n\t/**\n\t * @returns {string}\n\t */\n\tstatic get version() {\n\t\t// To be filled in by the template\n\t\treturn '1.4.0';\n\t}\n\n\t/**\n\t * @returns {string}\n\t */\n\tstatic toString() {\n\t\treturn 'JavaScript Expression Parser (JSEP) v' + Jsep.version;\n\t};\n\n\t// ==================== CONFIG ================================\n\t/**\n\t * @method addUnaryOp\n\t * @param {string} op_name The name of the unary op to add\n\t * @returns {Jsep}\n\t */\n\tstatic addUnaryOp(op_name) {\n\t\tJsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);\n\t\tJsep.unary_ops[op_name] = 1;\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method jsep.addBinaryOp\n\t * @param {string} op_name The name of the binary op to add\n\t * @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence\n\t * @param {boolean} [isRightAssociative=false] whether operator is right-associative\n\t * @returns {Jsep}\n\t */\n\tstatic addBinaryOp(op_name, precedence, isRightAssociative) {\n\t\tJsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);\n\t\tJsep.binary_ops[op_name] = precedence;\n\t\tif (isRightAssociative) {\n\t\t\tJsep.right_associative.add(op_name);\n\t\t}\n\t\telse {\n\t\t\tJsep.right_associative.delete(op_name);\n\t\t}\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method addIdentifierChar\n\t * @param {string} char The additional character to treat as a valid part of an identifier\n\t * @returns {Jsep}\n\t */\n\tstatic addIdentifierChar(char) {\n\t\tJsep.additional_identifier_chars.add(char);\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method addLiteral\n\t * @param {string} literal_name The name of the literal to add\n\t * @param {*} literal_value The value of the literal\n\t * @returns {Jsep}\n\t */\n\tstatic addLiteral(literal_name, literal_value) {\n\t\tJsep.literals[literal_name] = literal_value;\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeUnaryOp\n\t * @param {string} op_name The name of the unary op to remove\n\t * @returns {Jsep}\n\t */\n\tstatic removeUnaryOp(op_name) {\n\t\tdelete Jsep.unary_ops[op_name];\n\t\tif (op_name.length === Jsep.max_unop_len) {\n\t\t\tJsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);\n\t\t}\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeAllUnaryOps\n\t * @returns {Jsep}\n\t */\n\tstatic removeAllUnaryOps() {\n\t\tJsep.unary_ops = {};\n\t\tJsep.max_unop_len = 0;\n\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeIdentifierChar\n\t * @param {string} char The additional character to stop treating as a valid part of an identifier\n\t * @returns {Jsep}\n\t */\n\tstatic removeIdentifierChar(char) {\n\t\tJsep.additional_identifier_chars.delete(char);\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeBinaryOp\n\t * @param {string} op_name The name of the binary op to remove\n\t * @returns {Jsep}\n\t */\n\tstatic removeBinaryOp(op_name) {\n\t\tdelete Jsep.binary_ops[op_name];\n\n\t\tif (op_name.length === Jsep.max_binop_len) {\n\t\t\tJsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);\n\t\t}\n\t\tJsep.right_associative.delete(op_name);\n\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeAllBinaryOps\n\t * @returns {Jsep}\n\t */\n\tstatic removeAllBinaryOps() {\n\t\tJsep.binary_ops = {};\n\t\tJsep.max_binop_len = 0;\n\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeLiteral\n\t * @param {string} literal_name The name of the literal to remove\n\t * @returns {Jsep}\n\t */\n\tstatic removeLiteral(literal_name) {\n\t\tdelete Jsep.literals[literal_name];\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeAllLiterals\n\t * @returns {Jsep}\n\t */\n\tstatic removeAllLiterals() {\n\t\tJsep.literals = {};\n\n\t\treturn Jsep;\n\t}\n\t// ==================== END CONFIG ============================\n\n\n\t/**\n\t * @returns {string}\n\t */\n\tget char() {\n\t\treturn this.expr.charAt(this.index);\n\t}\n\n\t/**\n\t * @returns {number}\n\t */\n\tget code() {\n\t\treturn this.expr.charCodeAt(this.index);\n\t};\n\n\n\t/**\n\t * @param {string} expr a string with the passed in express\n\t * @returns Jsep\n\t */\n\tconstructor(expr) {\n\t\t// `index` stores the character number we are currently at\n\t\t// All of the gobbles below will modify `index` as we move along\n\t\tthis.expr = expr;\n\t\tthis.index = 0;\n\t}\n\n\t/**\n\t * static top-level parser\n\t * @returns {jsep.Expression}\n\t */\n\tstatic parse(expr) {\n\t\treturn (new Jsep(expr)).parse();\n\t}\n\n\t/**\n\t * Get the longest key length of any object\n\t * @param {object} obj\n\t * @returns {number}\n\t */\n\tstatic getMaxKeyLen(obj) {\n\t\treturn Math.max(0, ...Object.keys(obj).map(k => k.length));\n\t}\n\n\t/**\n\t * `ch` is a character code in the next three functions\n\t * @param {number} ch\n\t * @returns {boolean}\n\t */\n\tstatic isDecimalDigit(ch) {\n\t\treturn (ch >= 48 && ch <= 57); // 0...9\n\t}\n\n\t/**\n\t * Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.\n\t * @param {string} op_val\n\t * @returns {number}\n\t */\n\tstatic binaryPrecedence(op_val) {\n\t\treturn Jsep.binary_ops[op_val] || 0;\n\t}\n\n\t/**\n\t * Looks for start of identifier\n\t * @param {number} ch\n\t * @returns {boolean}\n\t */\n\tstatic isIdentifierStart(ch) {\n\t\treturn (ch >= 65 && ch <= 90) || // A...Z\n\t\t\t(ch >= 97 && ch <= 122) || // a...z\n\t\t\t(ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)]) || // any non-ASCII that is not an operator\n\t\t\t(Jsep.additional_identifier_chars.has(String.fromCharCode(ch))); // additional characters\n\t}\n\n\t/**\n\t * @param {number} ch\n\t * @returns {boolean}\n\t */\n\tstatic isIdentifierPart(ch) {\n\t\treturn Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);\n\t}\n\n\t/**\n\t * throw error at index of the expression\n\t * @param {string} message\n\t * @throws\n\t */\n\tthrowError(message) {\n\t\tconst error = new Error(message + ' at character ' + this.index);\n\t\terror.index = this.index;\n\t\terror.description = message;\n\t\tthrow error;\n\t}\n\n\t/**\n\t * Run a given hook\n\t * @param {string} name\n\t * @param {jsep.Expression|false} [node]\n\t * @returns {?jsep.Expression}\n\t */\n\trunHook(name, node) {\n\t\tif (Jsep.hooks[name]) {\n\t\t\tconst env = { context: this, node };\n\t\t\tJsep.hooks.run(name, env);\n\t\t\treturn env.node;\n\t\t}\n\t\treturn node;\n\t}\n\n\t/**\n\t * Runs a given hook until one returns a node\n\t * @param {string} name\n\t * @returns {?jsep.Expression}\n\t */\n\tsearchHook(name) {\n\t\tif (Jsep.hooks[name]) {\n\t\t\tconst env = { context: this };\n\t\t\tJsep.hooks[name].find(function (callback) {\n\t\t\t\tcallback.call(env.context, env);\n\t\t\t\treturn env.node;\n\t\t\t});\n\t\t\treturn env.node;\n\t\t}\n\t}\n\n\t/**\n\t * Push `index` up to the next non-space character\n\t */\n\tgobbleSpaces() {\n\t\tlet ch = this.code;\n\t\t// Whitespace\n\t\twhile (ch === Jsep.SPACE_CODE\n\t\t|| ch === Jsep.TAB_CODE\n\t\t|| ch === Jsep.LF_CODE\n\t\t|| ch === Jsep.CR_CODE) {\n\t\t\tch = this.expr.charCodeAt(++this.index);\n\t\t}\n\t\tthis.runHook('gobble-spaces');\n\t}\n\n\t/**\n\t * Top-level method to parse all expressions and returns compound or single node\n\t * @returns {jsep.Expression}\n\t */\n\tparse() {\n\t\tthis.runHook('before-all');\n\t\tconst nodes = this.gobbleExpressions();\n\n\t\t// If there's only one expression just try returning the expression\n\t\tconst node = nodes.length === 1\n\t\t ? nodes[0]\n\t\t\t: {\n\t\t\t\ttype: Jsep.COMPOUND,\n\t\t\t\tbody: nodes\n\t\t\t};\n\t\treturn this.runHook('after-all', node);\n\t}\n\n\t/**\n\t * top-level parser (but can be reused within as well)\n\t * @param {number} [untilICode]\n\t * @returns {jsep.Expression[]}\n\t */\n\tgobbleExpressions(untilICode) {\n\t\tlet nodes = [], ch_i, node;\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tch_i = this.code;\n\n\t\t\t// Expressions can be separated by semicolons, commas, or just inferred without any\n\t\t\t// separators\n\t\t\tif (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {\n\t\t\t\tthis.index++; // ignore separators\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Try to gobble each expression individually\n\t\t\t\tif (node = this.gobbleExpression()) {\n\t\t\t\t\tnodes.push(node);\n\t\t\t\t\t// If we weren't able to find a binary expression and are out of room, then\n\t\t\t\t\t// the expression passed in probably has too much\n\t\t\t\t}\n\t\t\t\telse if (this.index < this.expr.length) {\n\t\t\t\t\tif (ch_i === untilICode) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tthis.throwError('Unexpected \"' + this.char + '\"');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn nodes;\n\t}\n\n\t/**\n\t * The main parsing function.\n\t * @returns {?jsep.Expression}\n\t */\n\tgobbleExpression() {\n\t\tconst node = this.searchHook('gobble-expression') || this.gobbleBinaryExpression();\n\t\tthis.gobbleSpaces();\n\n\t\treturn this.runHook('after-expression', node);\n\t}\n\n\t/**\n\t * Search for the operation portion of the string (e.g. `+`, `===`)\n\t * Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)\n\t * and move down from 3 to 2 to 1 character until a matching binary operation is found\n\t * then, return that binary operation\n\t * @returns {string|boolean}\n\t */\n\tgobbleBinaryOp() {\n\t\tthis.gobbleSpaces();\n\t\tlet to_check = this.expr.substr(this.index, Jsep.max_binop_len);\n\t\tlet tc_len = to_check.length;\n\n\t\twhile (tc_len > 0) {\n\t\t\t// Don't accept a binary op when it is an identifier.\n\t\t\t// Binary ops that start with a identifier-valid character must be followed\n\t\t\t// by a non identifier-part valid character\n\t\t\tif (Jsep.binary_ops.hasOwnProperty(to_check) && (\n\t\t\t\t!Jsep.isIdentifierStart(this.code) ||\n\t\t\t\t(this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))\n\t\t\t)) {\n\t\t\t\tthis.index += tc_len;\n\t\t\t\treturn to_check;\n\t\t\t}\n\t\t\tto_check = to_check.substr(0, --tc_len);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * This function is responsible for gobbling an individual expression,\n\t * e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`\n\t * @returns {?jsep.BinaryExpression}\n\t */\n\tgobbleBinaryExpression() {\n\t\tlet node, biop, prec, stack, biop_info, left, right, i, cur_biop;\n\n\t\t// First, try to get the leftmost thing\n\t\t// Then, check to see if there's a binary operator operating on that leftmost thing\n\t\t// Don't gobbleBinaryOp without a left-hand-side\n\t\tleft = this.gobbleToken();\n\t\tif (!left) {\n\t\t\treturn left;\n\t\t}\n\t\tbiop = this.gobbleBinaryOp();\n\n\t\t// If there wasn't a binary operator, just return the leftmost node\n\t\tif (!biop) {\n\t\t\treturn left;\n\t\t}\n\n\t\t// Otherwise, we need to start a stack to properly place the binary operations in their\n\t\t// precedence structure\n\t\tbiop_info = { value: biop, prec: Jsep.binaryPrecedence(biop), right_a: Jsep.right_associative.has(biop) };\n\n\t\tright = this.gobbleToken();\n\n\t\tif (!right) {\n\t\t\tthis.throwError(\"Expected expression after \" + biop);\n\t\t}\n\n\t\tstack = [left, biop_info, right];\n\n\t\t// Properly deal with precedence using [recursive descent](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm)\n\t\twhile ((biop = this.gobbleBinaryOp())) {\n\t\t\tprec = Jsep.binaryPrecedence(biop);\n\n\t\t\tif (prec === 0) {\n\t\t\t\tthis.index -= biop.length;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tbiop_info = { value: biop, prec, right_a: Jsep.right_associative.has(biop) };\n\n\t\t\tcur_biop = biop;\n\n\t\t\t// Reduce: make a binary expression from the three topmost entries.\n\t\t\tconst comparePrev = prev => biop_info.right_a && prev.right_a\n\t\t\t\t? prec > prev.prec\n\t\t\t\t: prec <= prev.prec;\n\t\t\twhile ((stack.length > 2) && comparePrev(stack[stack.length - 2])) {\n\t\t\t\tright = stack.pop();\n\t\t\t\tbiop = stack.pop().value;\n\t\t\t\tleft = stack.pop();\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.BINARY_EXP,\n\t\t\t\t\toperator: biop,\n\t\t\t\t\tleft,\n\t\t\t\t\tright\n\t\t\t\t};\n\t\t\t\tstack.push(node);\n\t\t\t}\n\n\t\t\tnode = this.gobbleToken();\n\n\t\t\tif (!node) {\n\t\t\t\tthis.throwError(\"Expected expression after \" + cur_biop);\n\t\t\t}\n\n\t\t\tstack.push(biop_info, node);\n\t\t}\n\n\t\ti = stack.length - 1;\n\t\tnode = stack[i];\n\n\t\twhile (i > 1) {\n\t\t\tnode = {\n\t\t\t\ttype: Jsep.BINARY_EXP,\n\t\t\t\toperator: stack[i - 1].value,\n\t\t\t\tleft: stack[i - 2],\n\t\t\t\tright: node\n\t\t\t};\n\t\t\ti -= 2;\n\t\t}\n\n\t\treturn node;\n\t}\n\n\t/**\n\t * An individual part of a binary expression:\n\t * e.g. `foo.bar(baz)`, `1`, `\"abc\"`, `(a % 2)` (because it's in parenthesis)\n\t * @returns {boolean|jsep.Expression}\n\t */\n\tgobbleToken() {\n\t\tlet ch, to_check, tc_len, node;\n\n\t\tthis.gobbleSpaces();\n\t\tnode = this.searchHook('gobble-token');\n\t\tif (node) {\n\t\t\treturn this.runHook('after-token', node);\n\t\t}\n\n\t\tch = this.code;\n\n\t\tif (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {\n\t\t\t// Char code 46 is a dot `.` which can start off a numeric literal\n\t\t\treturn this.gobbleNumericLiteral();\n\t\t}\n\n\t\tif (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {\n\t\t\t// Single or double quotes\n\t\t\tnode = this.gobbleStringLiteral();\n\t\t}\n\t\telse if (ch === Jsep.OBRACK_CODE) {\n\t\t\tnode = this.gobbleArray();\n\t\t}\n\t\telse {\n\t\t\tto_check = this.expr.substr(this.index, Jsep.max_unop_len);\n\t\t\ttc_len = to_check.length;\n\n\t\t\twhile (tc_len > 0) {\n\t\t\t\t// Don't accept an unary op when it is an identifier.\n\t\t\t\t// Unary ops that start with a identifier-valid character must be followed\n\t\t\t\t// by a non identifier-part valid character\n\t\t\t\tif (Jsep.unary_ops.hasOwnProperty(to_check) && (\n\t\t\t\t\t!Jsep.isIdentifierStart(this.code) ||\n\t\t\t\t\t(this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))\n\t\t\t\t)) {\n\t\t\t\t\tthis.index += tc_len;\n\t\t\t\t\tconst argument = this.gobbleToken();\n\t\t\t\t\tif (!argument) {\n\t\t\t\t\t\tthis.throwError('missing unaryOp argument');\n\t\t\t\t\t}\n\t\t\t\t\treturn this.runHook('after-token', {\n\t\t\t\t\t\ttype: Jsep.UNARY_EXP,\n\t\t\t\t\t\toperator: to_check,\n\t\t\t\t\t\targument,\n\t\t\t\t\t\tprefix: true\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tto_check = to_check.substr(0, --tc_len);\n\t\t\t}\n\n\t\t\tif (Jsep.isIdentifierStart(ch)) {\n\t\t\t\tnode = this.gobbleIdentifier();\n\t\t\t\tif (Jsep.literals.hasOwnProperty(node.name)) {\n\t\t\t\t\tnode = {\n\t\t\t\t\t\ttype: Jsep.LITERAL,\n\t\t\t\t\t\tvalue: Jsep.literals[node.name],\n\t\t\t\t\t\traw: node.name,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (node.name === Jsep.this_str) {\n\t\t\t\t\tnode = { type: Jsep.THIS_EXP };\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (ch === Jsep.OPAREN_CODE) { // open parenthesis\n\t\t\t\tnode = this.gobbleGroup();\n\t\t\t}\n\t\t}\n\n\t\tif (!node) {\n\t\t\treturn this.runHook('after-token', false);\n\t\t}\n\n\t\tnode = this.gobbleTokenProperty(node);\n\t\treturn this.runHook('after-token', node);\n\t}\n\n\t/**\n\t * Gobble properties of of identifiers/strings/arrays/groups.\n\t * e.g. `foo`, `bar.baz`, `foo['bar'].baz`\n\t * It also gobbles function calls:\n\t * e.g. `Math.acos(obj.angle)`\n\t * @param {jsep.Expression} node\n\t * @returns {jsep.Expression}\n\t */\n\tgobbleTokenProperty(node) {\n\t\tthis.gobbleSpaces();\n\n\t\tlet ch = this.code;\n\t\twhile (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {\n\t\t\tlet optional;\n\t\t\tif (ch === Jsep.QUMARK_CODE) {\n\t\t\t\tif (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\toptional = true;\n\t\t\t\tthis.index += 2;\n\t\t\t\tthis.gobbleSpaces();\n\t\t\t\tch = this.code;\n\t\t\t}\n\t\t\tthis.index++;\n\n\t\t\tif (ch === Jsep.OBRACK_CODE) {\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.MEMBER_EXP,\n\t\t\t\t\tcomputed: true,\n\t\t\t\t\tobject: node,\n\t\t\t\t\tproperty: this.gobbleExpression()\n\t\t\t\t};\n\t\t\t\tif (!node.property) {\n\t\t\t\t\tthis.throwError('Unexpected \"' + this.char + '\"');\n\t\t\t\t}\n\t\t\t\tthis.gobbleSpaces();\n\t\t\t\tch = this.code;\n\t\t\t\tif (ch !== Jsep.CBRACK_CODE) {\n\t\t\t\t\tthis.throwError('Unclosed [');\n\t\t\t\t}\n\t\t\t\tthis.index++;\n\t\t\t}\n\t\t\telse if (ch === Jsep.OPAREN_CODE) {\n\t\t\t\t// A function call is being made; gobble all the arguments\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.CALL_EXP,\n\t\t\t\t\t'arguments': this.gobbleArguments(Jsep.CPAREN_CODE),\n\t\t\t\t\tcallee: node\n\t\t\t\t};\n\t\t\t}\n\t\t\telse if (ch === Jsep.PERIOD_CODE || optional) {\n\t\t\t\tif (optional) {\n\t\t\t\t\tthis.index--;\n\t\t\t\t}\n\t\t\t\tthis.gobbleSpaces();\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.MEMBER_EXP,\n\t\t\t\t\tcomputed: false,\n\t\t\t\t\tobject: node,\n\t\t\t\t\tproperty: this.gobbleIdentifier(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (optional) {\n\t\t\t\tnode.optional = true;\n\t\t\t} // else leave undefined for compatibility with esprima\n\n\t\t\tthis.gobbleSpaces();\n\t\t\tch = this.code;\n\t\t}\n\n\t\treturn node;\n\t}\n\n\t/**\n\t * Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to\n\t * keep track of everything in the numeric literal and then calling `parseFloat` on that string\n\t * @returns {jsep.Literal}\n\t */\n\tgobbleNumericLiteral() {\n\t\tlet number = '', ch, chCode;\n\n\t\twhile (Jsep.isDecimalDigit(this.code)) {\n\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t}\n\n\t\tif (this.code === Jsep.PERIOD_CODE) { // can start with a decimal marker\n\t\t\tnumber += this.expr.charAt(this.index++);\n\n\t\t\twhile (Jsep.isDecimalDigit(this.code)) {\n\t\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\t}\n\t\t}\n\n\t\tch = this.char;\n\n\t\tif (ch === 'e' || ch === 'E') { // exponent marker\n\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\tch = this.char;\n\n\t\t\tif (ch === '+' || ch === '-') { // exponent sign\n\t\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\t}\n\n\t\t\twhile (Jsep.isDecimalDigit(this.code)) { // exponent itself\n\t\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\t}\n\n\t\t\tif (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1)) ) {\n\t\t\t\tthis.throwError('Expected exponent (' + number + this.char + ')');\n\t\t\t}\n\t\t}\n\n\t\tchCode = this.code;\n\n\t\t// Check to make sure this isn't a variable name that start with a number (123abc)\n\t\tif (Jsep.isIdentifierStart(chCode)) {\n\t\t\tthis.throwError('Variable names cannot start with a number (' +\n\t\t\t\tnumber + this.char + ')');\n\t\t}\n\t\telse if (chCode === Jsep.PERIOD_CODE || (number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE)) {\n\t\t\tthis.throwError('Unexpected period');\n\t\t}\n\n\t\treturn {\n\t\t\ttype: Jsep.LITERAL,\n\t\t\tvalue: parseFloat(number),\n\t\t\traw: number\n\t\t};\n\t}\n\n\t/**\n\t * Parses a string literal, staring with single or double quotes with basic support for escape codes\n\t * e.g. `\"hello world\"`, `'this is\\nJSEP'`\n\t * @returns {jsep.Literal}\n\t */\n\tgobbleStringLiteral() {\n\t\tlet str = '';\n\t\tconst startIndex = this.index;\n\t\tconst quote = this.expr.charAt(this.index++);\n\t\tlet closed = false;\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tlet ch = this.expr.charAt(this.index++);\n\n\t\t\tif (ch === quote) {\n\t\t\t\tclosed = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (ch === '\\\\') {\n\t\t\t\t// Check for all of the common escape codes\n\t\t\t\tch = this.expr.charAt(this.index++);\n\n\t\t\t\tswitch (ch) {\n\t\t\t\t\tcase 'n': str += '\\n'; break;\n\t\t\t\t\tcase 'r': str += '\\r'; break;\n\t\t\t\t\tcase 't': str += '\\t'; break;\n\t\t\t\t\tcase 'b': str += '\\b'; break;\n\t\t\t\t\tcase 'f': str += '\\f'; break;\n\t\t\t\t\tcase 'v': str += '\\x0B'; break;\n\t\t\t\t\tdefault : str += ch;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tstr += ch;\n\t\t\t}\n\t\t}\n\n\t\tif (!closed) {\n\t\t\tthis.throwError('Unclosed quote after \"' + str + '\"');\n\t\t}\n\n\t\treturn {\n\t\t\ttype: Jsep.LITERAL,\n\t\t\tvalue: str,\n\t\t\traw: this.expr.substring(startIndex, this.index),\n\t\t};\n\t}\n\n\t/**\n\t * Gobbles only identifiers\n\t * e.g.: `foo`, `_value`, `$x1`\n\t * Also, this function checks if that identifier is a literal:\n\t * (e.g. `true`, `false`, `null`) or `this`\n\t * @returns {jsep.Identifier}\n\t */\n\tgobbleIdentifier() {\n\t\tlet ch = this.code, start = this.index;\n\n\t\tif (Jsep.isIdentifierStart(ch)) {\n\t\t\tthis.index++;\n\t\t}\n\t\telse {\n\t\t\tthis.throwError('Unexpected ' + this.char);\n\t\t}\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tch = this.code;\n\n\t\t\tif (Jsep.isIdentifierPart(ch)) {\n\t\t\t\tthis.index++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\ttype: Jsep.IDENTIFIER,\n\t\t\tname: this.expr.slice(start, this.index),\n\t\t};\n\t}\n\n\t/**\n\t * Gobbles a list of arguments within the context of a function call\n\t * or array literal. This function also assumes that the opening character\n\t * `(` or `[` has already been gobbled, and gobbles expressions and commas\n\t * until the terminator character `)` or `]` is encountered.\n\t * e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`\n\t * @param {number} termination\n\t * @returns {jsep.Expression[]}\n\t */\n\tgobbleArguments(termination) {\n\t\tconst args = [];\n\t\tlet closed = false;\n\t\tlet separator_count = 0;\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tthis.gobbleSpaces();\n\t\t\tlet ch_i = this.code;\n\n\t\t\tif (ch_i === termination) { // done parsing\n\t\t\t\tclosed = true;\n\t\t\t\tthis.index++;\n\n\t\t\t\tif (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length){\n\t\t\t\t\tthis.throwError('Unexpected token ' + String.fromCharCode(termination));\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (ch_i === Jsep.COMMA_CODE) { // between expressions\n\t\t\t\tthis.index++;\n\t\t\t\tseparator_count++;\n\n\t\t\t\tif (separator_count !== args.length) { // missing argument\n\t\t\t\t\tif (termination === Jsep.CPAREN_CODE) {\n\t\t\t\t\t\tthis.throwError('Unexpected token ,');\n\t\t\t\t\t}\n\t\t\t\t\telse if (termination === Jsep.CBRACK_CODE) {\n\t\t\t\t\t\tfor (let arg = args.length; arg < separator_count; arg++) {\n\t\t\t\t\t\t\targs.push(null);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (args.length !== separator_count && separator_count !== 0) {\n\t\t\t\t// NOTE: `&& separator_count !== 0` allows for either all commas, or all spaces as arguments\n\t\t\t\tthis.throwError('Expected comma');\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconst node = this.gobbleExpression();\n\n\t\t\t\tif (!node || node.type === Jsep.COMPOUND) {\n\t\t\t\t\tthis.throwError('Expected comma');\n\t\t\t\t}\n\n\t\t\t\targs.push(node);\n\t\t\t}\n\t\t}\n\n\t\tif (!closed) {\n\t\t\tthis.throwError('Expected ' + String.fromCharCode(termination));\n\t\t}\n\n\t\treturn args;\n\t}\n\n\t/**\n\t * Responsible for parsing a group of things within parentheses `()`\n\t * that have no identifier in front (so not a function call)\n\t * This function assumes that it needs to gobble the opening parenthesis\n\t * and then tries to gobble everything within that parenthesis, assuming\n\t * that the next thing it should see is the close parenthesis. If not,\n\t * then the expression probably doesn't have a `)`\n\t * @returns {boolean|jsep.Expression}\n\t */\n\tgobbleGroup() {\n\t\tthis.index++;\n\t\tlet nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);\n\t\tif (this.code === Jsep.CPAREN_CODE) {\n\t\t\tthis.index++;\n\t\t\tif (nodes.length === 1) {\n\t\t\t\treturn nodes[0];\n\t\t\t}\n\t\t\telse if (!nodes.length) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn {\n\t\t\t\t\ttype: Jsep.SEQUENCE_EXP,\n\t\t\t\t\texpressions: nodes,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tthis.throwError('Unclosed (');\n\t\t}\n\t}\n\n\t/**\n\t * Responsible for parsing Array literals `[1, 2, 3]`\n\t * This function assumes that it needs to gobble the opening bracket\n\t * and then tries to gobble the expressions as arguments.\n\t * @returns {jsep.ArrayExpression}\n\t */\n\tgobbleArray() {\n\t\tthis.index++;\n\n\t\treturn {\n\t\t\ttype: Jsep.ARRAY_EXP,\n\t\t\telements: this.gobbleArguments(Jsep.CBRACK_CODE)\n\t\t};\n\t}\n}\n\n// Static fields:\nconst hooks = new Hooks();\nObject.assign(Jsep, {\n\thooks,\n\tplugins: new Plugins(Jsep),\n\n\t// Node Types\n\t// ----------\n\t// This is the full set of types that any JSEP node can be.\n\t// Store them here to save space when minified\n\tCOMPOUND: 'Compound',\n\tSEQUENCE_EXP: 'SequenceExpression',\n\tIDENTIFIER: 'Identifier',\n\tMEMBER_EXP: 'MemberExpression',\n\tLITERAL: 'Literal',\n\tTHIS_EXP: 'ThisExpression',\n\tCALL_EXP: 'CallExpression',\n\tUNARY_EXP: 'UnaryExpression',\n\tBINARY_EXP: 'BinaryExpression',\n\tARRAY_EXP: 'ArrayExpression',\n\n\tTAB_CODE: 9,\n\tLF_CODE: 10,\n\tCR_CODE: 13,\n\tSPACE_CODE: 32,\n\tPERIOD_CODE: 46, // '.'\n\tCOMMA_CODE: 44, // ','\n\tSQUOTE_CODE: 39, // single quote\n\tDQUOTE_CODE: 34, // double quotes\n\tOPAREN_CODE: 40, // (\n\tCPAREN_CODE: 41, // )\n\tOBRACK_CODE: 91, // [\n\tCBRACK_CODE: 93, // ]\n\tQUMARK_CODE: 63, // ?\n\tSEMCOL_CODE: 59, // ;\n\tCOLON_CODE: 58, // :\n\n\n\t// Operations\n\t// ----------\n\t// Use a quickly-accessible map to store all of the unary operators\n\t// Values are set to `1` (it really doesn't matter)\n\tunary_ops: {\n\t\t'-': 1,\n\t\t'!': 1,\n\t\t'~': 1,\n\t\t'+': 1\n\t},\n\n\t// Also use a map for the binary operations but set their values to their\n\t// binary precedence for quick reference (higher number = higher precedence)\n\t// see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)\n\tbinary_ops: {\n\t\t'||': 1, '??': 1,\n\t\t'&&': 2, '|': 3, '^': 4, '&': 5,\n\t\t'==': 6, '!=': 6, '===': 6, '!==': 6,\n\t\t'<': 7, '>': 7, '<=': 7, '>=': 7,\n\t\t'<<': 8, '>>': 8, '>>>': 8,\n\t\t'+': 9, '-': 9,\n\t\t'*': 10, '/': 10, '%': 10,\n\t\t'**': 11,\n\t},\n\n\t// sets specific binary_ops as right-associative\n\tright_associative: new Set(['**']),\n\n\t// Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)\n\tadditional_identifier_chars: new Set(['$', '_']),\n\n\t// Literals\n\t// ----------\n\t// Store the values to return for the various literals we may encounter\n\tliterals: {\n\t\t'true': true,\n\t\t'false': false,\n\t\t'null': null\n\t},\n\n\t// Except for `this`, which is special. This could be changed to something like `'self'` as well\n\tthis_str: 'this',\n});\nJsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);\nJsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);\n\n// Backward Compatibility:\nconst jsep = expr => (new Jsep(expr)).parse();\nconst stdClassProps = Object.getOwnPropertyNames(class Test{});\nObject.getOwnPropertyNames(Jsep)\n\t.filter(prop => !stdClassProps.includes(prop) && jsep[prop] === undefined)\n\t.forEach((m) => {\n\t\tjsep[m] = Jsep[m];\n\t});\njsep.Jsep = Jsep; // allows for const { Jsep } = require('jsep');\n\nconst CONDITIONAL_EXP = 'ConditionalExpression';\n\nvar ternary = {\n\tname: 'ternary',\n\n\tinit(jsep) {\n\t\t// Ternary expression: test ? consequent : alternate\n\t\tjsep.hooks.add('after-expression', function gobbleTernary(env) {\n\t\t\tif (env.node && this.code === jsep.QUMARK_CODE) {\n\t\t\t\tthis.index++;\n\t\t\t\tconst test = env.node;\n\t\t\t\tconst consequent = this.gobbleExpression();\n\n\t\t\t\tif (!consequent) {\n\t\t\t\t\tthis.throwError('Expected expression');\n\t\t\t\t}\n\n\t\t\t\tthis.gobbleSpaces();\n\n\t\t\t\tif (this.code === jsep.COLON_CODE) {\n\t\t\t\t\tthis.index++;\n\t\t\t\t\tconst alternate = this.gobbleExpression();\n\n\t\t\t\t\tif (!alternate) {\n\t\t\t\t\t\tthis.throwError('Expected expression');\n\t\t\t\t\t}\n\t\t\t\t\tenv.node = {\n\t\t\t\t\t\ttype: CONDITIONAL_EXP,\n\t\t\t\t\t\ttest,\n\t\t\t\t\t\tconsequent,\n\t\t\t\t\t\talternate,\n\t\t\t\t\t};\n\n\t\t\t\t\t// check for operators of higher priority than ternary (i.e. assignment)\n\t\t\t\t\t// jsep sets || at 1, and assignment at 0.9, and conditional should be between them\n\t\t\t\t\tif (test.operator && jsep.binary_ops[test.operator] <= 0.9) {\n\t\t\t\t\t\tlet newTest = test;\n\t\t\t\t\t\twhile (newTest.right.operator && jsep.binary_ops[newTest.right.operator] <= 0.9) {\n\t\t\t\t\t\t\tnewTest = newTest.right;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tenv.node.test = newTest.right;\n\t\t\t\t\t\tnewTest.right = env.node;\n\t\t\t\t\t\tenv.node = test;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.throwError('Expected :');\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t},\n};\n\n// Add default plugins:\n\njsep.plugins.register(ternary);\n\nexport { Jsep, jsep as default };\n","const FSLASH_CODE = 47; // '/'\nconst BSLASH_CODE = 92; // '\\\\'\n\nvar index = {\n\tname: 'regex',\n\n\tinit(jsep) {\n\t\t// Regex literal: /abc123/ig\n\t\tjsep.hooks.add('gobble-token', function gobbleRegexLiteral(env) {\n\t\t\tif (this.code === FSLASH_CODE) {\n\t\t\t\tconst patternIndex = ++this.index;\n\n\t\t\t\tlet inCharSet = false;\n\t\t\t\twhile (this.index < this.expr.length) {\n\t\t\t\t\tif (this.code === FSLASH_CODE && !inCharSet) {\n\t\t\t\t\t\tconst pattern = this.expr.slice(patternIndex, this.index);\n\n\t\t\t\t\t\tlet flags = '';\n\t\t\t\t\t\twhile (++this.index < this.expr.length) {\n\t\t\t\t\t\t\tconst code = this.code;\n\t\t\t\t\t\t\tif ((code >= 97 && code <= 122) // a...z\n\t\t\t\t\t\t\t\t|| (code >= 65 && code <= 90) // A...Z\n\t\t\t\t\t\t\t\t|| (code >= 48 && code <= 57)) { // 0-9\n\t\t\t\t\t\t\t\tflags += this.char;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet value;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tvalue = new RegExp(pattern, flags);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\tthis.throwError(e.message);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tenv.node = {\n\t\t\t\t\t\t\ttype: jsep.LITERAL,\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\traw: this.expr.slice(patternIndex - 1, this.index),\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// allow . [] and () after regex: /regex/.test(a)\n\t\t\t\t\t\tenv.node = this.gobbleTokenProperty(env.node);\n\t\t\t\t\t\treturn env.node;\n\t\t\t\t\t}\n\t\t\t\t\tif (this.code === jsep.OBRACK_CODE) {\n\t\t\t\t\t\tinCharSet = true;\n\t\t\t\t\t}\n\t\t\t\t\telse if (inCharSet && this.code === jsep.CBRACK_CODE) {\n\t\t\t\t\t\tinCharSet = false;\n\t\t\t\t\t}\n\t\t\t\t\tthis.index += this.code === BSLASH_CODE ? 2 : 1;\n\t\t\t\t}\n\t\t\t\tthis.throwError('Unclosed Regex');\n\t\t\t}\n\t\t});\n\t},\n};\n\nexport { index as default };\n","const PLUS_CODE = 43; // +\nconst MINUS_CODE = 45; // -\n\nconst plugin = {\n\tname: 'assignment',\n\n\tassignmentOperators: new Set([\n\t\t'=',\n\t\t'*=',\n\t\t'**=',\n\t\t'/=',\n\t\t'%=',\n\t\t'+=',\n\t\t'-=',\n\t\t'<<=',\n\t\t'>>=',\n\t\t'>>>=',\n\t\t'&=',\n\t\t'^=',\n\t\t'|=',\n\t\t'||=',\n\t\t'&&=',\n\t\t'??=',\n\t]),\n\tupdateOperators: [PLUS_CODE, MINUS_CODE],\n\tassignmentPrecedence: 0.9,\n\n\tinit(jsep) {\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\n\t\tplugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence, true));\n\n\t\tjsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) {\n\t\t\tconst code = this.code;\n\t\t\tif (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\n\t\t\t\tthis.index += 2;\n\t\t\t\tenv.node = {\n\t\t\t\t\ttype: 'UpdateExpression',\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\n\t\t\t\t\targument: this.gobbleTokenProperty(this.gobbleIdentifier()),\n\t\t\t\t\tprefix: true,\n\t\t\t\t};\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\n\t\t\tif (env.node) {\n\t\t\t\tconst code = this.code;\n\t\t\t\tif (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\n\t\t\t\t\t}\n\t\t\t\t\tthis.index += 2;\n\t\t\t\t\tenv.node = {\n\t\t\t\t\t\ttype: 'UpdateExpression',\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\n\t\t\t\t\t\targument: env.node,\n\t\t\t\t\t\tprefix: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\n\t\t\tif (env.node) {\n\t\t\t\t// Note: Binaries can be chained in a single expression to respect\n\t\t\t\t// operator precedence (i.e. a = b = 1 + 2 + 3)\n\t\t\t\t// Update all binary assignment nodes in the tree\n\t\t\t\tupdateBinariesToAssignments(env.node);\n\t\t\t}\n\t\t});\n\n\t\tfunction updateBinariesToAssignments(node) {\n\t\t\tif (plugin.assignmentOperators.has(node.operator)) {\n\t\t\t\tnode.type = 'AssignmentExpression';\n\t\t\t\tupdateBinariesToAssignments(node.left);\n\t\t\t\tupdateBinariesToAssignments(node.right);\n\t\t\t}\n\t\t\telse if (!node.operator) {\n\t\t\t\tObject.values(node).forEach((val) => {\n\t\t\t\t\tif (val && typeof val === 'object') {\n\t\t\t\t\t\tupdateBinariesToAssignments(val);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t},\n};\n\nexport { plugin as default };\n","/* eslint-disable unicorn/no-top-level-side-effects -- Temporary? */\n/* eslint-disable no-bitwise -- Convenient */\nimport jsep from 'jsep';\nimport jsepRegex from '@jsep-plugin/regex';\nimport jsepAssignment from '@jsep-plugin/assignment';\n\n/**\n * @import {EvaluatedResult, UnknownResult} from './jsonpath.js';\n */\n\n/**\n * @typedef {any} AssignmentExpression\n */\n\n/**\n * @typedef {any} Substitution\n */\n\n/**\n * @typedef {any} AnyParameter\n */\n\n/**\n * @typedef {Record} Substitutions\n */\n\n// register plugins\njsep.plugins.register(jsepRegex, jsepAssignment);\njsep.addUnaryOp('typeof');\njsep.addUnaryOp('void');\njsep.addLiteral('null', null);\njsep.addLiteral('undefined', undefined);\n\nconst BLOCKED_PROTO_PROPERTIES = new Set([\n 'constructor',\n '__proto__',\n '__defineGetter__',\n '__defineSetter__',\n '__lookupGetter__',\n '__lookupSetter__'\n]);\n\n// Every function-constructor variant, along with the invocation helpers which\n// could otherwise reach them indirectly, e.g., `Function.call(0, 'code')()`,\n// plus whichever BLOCKED_PROTO_PROPERTIES names resolve to an own method on\n// Object.prototype (e.g. `__defineGetter__`) - an own-property access on a\n// shared prototype (`@.prototype.__defineGetter__`) bypasses the\n// inherited-only name check below, so those methods need blocking by value.\n/** @type {WeakSet} */\nconst BLOCKED_FUNCTIONS = new WeakSet([\n Function,\n // eslint-disable-next-line no-empty-function -- Only need the constructor\n function *() {}.constructor,\n // eslint-disable-next-line no-empty-function -- Only need the constructor\n async function () {}.constructor,\n // eslint-disable-next-line no-empty-function -- Only need the constructor\n async function *() {}.constructor,\n Function.prototype.call,\n Function.prototype.apply,\n Function.prototype.bind,\n Reflect.apply,\n Reflect.construct,\n ...[...BLOCKED_PROTO_PROPERTIES]\n .map((name) => Reflect.get(Object.prototype, name))\n .filter((value) => typeof value === 'function')\n]);\n\n/**\n * @param {UnknownResult} value\n * @returns {boolean}\n */\nconst isBlockedFunction = (value) => {\n return typeof value === 'function' && BLOCKED_FUNCTIONS.has(value);\n};\n\n/**\n * Guarded `obj[prop]`, applying the same restrictions as a MemberExpression.\n * @param {UnknownResult} obj\n * @param {string} prop\n * @returns {UnknownResult}\n */\nconst getSafeProperty = (obj, prop) => {\n if (obj === undefined || obj === null) {\n throw new TypeError(\n `Cannot read properties of ${obj} (reading '${prop}')`\n );\n }\n if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {\n throw new TypeError(\n `Cannot read properties of ${obj} (reading '${prop}')`\n );\n }\n const result = /** @type {Record} */ (obj)[prop];\n if (isBlockedFunction(result)) {\n throw new TypeError('Function constructor is disabled');\n }\n return result;\n};\n\n/**\n * @typedef {Record<\n * string,\n * (a: AnyParameter, b: AnyParameter) => UnknownResult\n * >} OperatorTable\n */\n\n// eslint-disable-next-line @stylistic/max-len -- Long\nconst BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */ ({\n '||': (a, b) => a || b(),\n '??': (a, b) => a ?? b(),\n '&&': (a, b) => a && b(),\n '|': (a, b) => a | b(),\n '^': (a, b) => a ^ b(),\n '&': (a, b) => a & b(),\n // eslint-disable-next-line eqeqeq -- API\n '==': (a, b) => a == b(),\n // eslint-disable-next-line eqeqeq -- API\n '!=': (a, b) => a != b(),\n '===': (a, b) => a === b(),\n '!==': (a, b) => a !== b(),\n '<': (a, b) => a < b(),\n '>': (a, b) => a > b(),\n '<=': (a, b) => a <= b(),\n '>=': (a, b) => a >= b(),\n '<<': (a, b) => a << b(),\n '>>': (a, b) => a >> b(),\n '>>>': (a, b) => a >>> b(),\n '+': (a, b) => a + b(),\n '-': (a, b) => a - b(),\n '*': (a, b) => a * b(),\n '/': (a, b) => a / b(),\n '%': (a, b) => a % b(),\n '**': (a, b) => a ** b()\n}));\n\n/**\n * @typedef {{\n * [key: string]: (a: AnyParameter) => UnknownResult\n * }} UnaryOperatorTable\n */\n\n// eslint-disable-next-line @stylistic/max-len -- Long\nconst UNOPS = Object.assign(Object.create(null), /** @type {UnaryOperatorTable} */ ({\n '-': (a) => -(/** @type {EvaluatedResult} */ (a)),\n '!': (a) => !a,\n '~': (a) => ~(/** @type {EvaluatedResult} */ (a)),\n // eslint-disable-next-line no-implicit-coercion -- API\n '+': (a) => +(/** @type {EvaluatedResult} */ (a)),\n typeof: (a) => typeof a,\n void: () => undefined\n}));\n\nconst SafeEval = {\n /**\n * @param {jsep.Expression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalAst (ast, subs) {\n switch (ast.type) {\n case 'BinaryExpression':\n case 'LogicalExpression':\n return SafeEval.evalBinaryExpression(\n /** @type {jsep.BinaryExpression} */ (ast),\n subs\n );\n case 'Compound':\n return SafeEval.evalCompound(\n /** @type {jsep.Compound} */ (ast),\n subs\n );\n case 'ConditionalExpression':\n return SafeEval.evalConditionalExpression(\n /** @type {jsep.ConditionalExpression} */ (ast),\n subs\n );\n case 'Identifier':\n return SafeEval.evalIdentifier(\n /** @type {jsep.Identifier} */ (ast),\n subs\n );\n case 'Literal':\n return SafeEval.evalLiteral(/** @type {jsep.Literal} */ (ast));\n case 'MemberExpression':\n return SafeEval.evalMemberExpression(\n /** @type {jsep.MemberExpression} */ (ast),\n subs\n );\n case 'UnaryExpression':\n return SafeEval.evalUnaryExpression(\n /** @type {jsep.UnaryExpression} */ (ast),\n subs\n );\n case 'ArrayExpression':\n return SafeEval.evalArrayExpression(\n /** @type {jsep.ArrayExpression} */ (ast),\n subs\n );\n case 'CallExpression':\n return SafeEval.evalCallExpression(\n /** @type {jsep.CallExpression} */ (ast),\n subs\n );\n case 'AssignmentExpression':\n return SafeEval.evalAssignmentExpression(\n /** @type {AssignmentExpression} */ (ast),\n subs\n );\n default:\n throw new SyntaxError('Unexpected expression', {\n cause: ast\n });\n }\n },\n\n /**\n * @param {jsep.BinaryExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalBinaryExpression (ast, subs) {\n /* c8 ignore next 3 -- Defensive guard for malformed ASTs */\n if (!Object.hasOwn(BINOPS, ast.operator)) {\n throw new SyntaxError(`Unknown binary operator: ${ast.operator}`);\n }\n const result = BINOPS[ast.operator](\n SafeEval.evalAst(ast.left, subs),\n () => SafeEval.evalAst(ast.right, subs)\n );\n return result;\n },\n\n /**\n * @param {jsep.Compound} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalCompound (ast, subs) {\n let last;\n for (let i = 0; i < ast.body.length; i++) {\n if (\n ast.body[i].type === 'Identifier' &&\n ['var', 'let', 'const'].includes(\n /** @type {jsep.Identifier} */\n (ast.body[i]).name\n ) &&\n Object.hasOwn(ast.body, i + 1) &&\n ast.body[i + 1].type === 'AssignmentExpression'\n ) {\n // var x=2; is detected as\n // [{Identifier var}, {AssignmentExpression x=2}]\n i += 1;\n }\n const expr = ast.body[i];\n last = SafeEval.evalAst(expr, subs);\n }\n return last;\n },\n\n /**\n * @param {jsep.ConditionalExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalConditionalExpression (ast, subs) {\n return SafeEval.evalAst(ast.test, subs)\n ? SafeEval.evalAst(ast.consequent, subs)\n : SafeEval.evalAst(ast.alternate, subs);\n },\n\n /**\n * @param {jsep.Identifier} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalIdentifier (ast, subs) {\n if (Object.hasOwn(subs, ast.name)) {\n return subs[ast.name];\n }\n throw new ReferenceError(`${ast.name} is not defined`);\n },\n\n /**\n * @param {jsep.Literal} ast\n * @returns {UnknownResult}\n */\n evalLiteral (ast) {\n return ast.value;\n },\n\n /**\n * @param {jsep.MemberExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalMemberExpression (ast, subs) {\n const prop = String(\n // NOTE: `String(value)` throws error when\n // value has overwritten the toString method to return non-string\n // i.e. `value = {toString: () => []}`\n ast.computed\n ? SafeEval.evalAst(ast.property, subs) // `object[property]`\n : ast.property.name // `object.property` property is Identifier\n );\n const obj = SafeEval.evalAst(ast.object, subs);\n const result = getSafeProperty(obj, prop);\n if (typeof result === 'function') {\n return result.bind(obj); // arrow functions aren't affected by bind.\n }\n return result;\n },\n\n /**\n * @param {jsep.UnaryExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalUnaryExpression (ast, subs) {\n /* c8 ignore next 3 -- Defensive guard for malformed ASTs */\n if (!Object.hasOwn(UNOPS, ast.operator)) {\n throw new SyntaxError(`Unknown unary operator: ${ast.operator}`);\n }\n const operand = SafeEval.evalAst(ast.argument, subs);\n return UNOPS[ast.operator](operand);\n },\n\n /**\n * @param {jsep.ArrayExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalArrayExpression (ast, subs) {\n return ast.elements.map((el) => SafeEval.evalAst(\n /** @type {jsep.Expression} */\n (el),\n subs\n ));\n },\n\n /**\n * @param {jsep.CallExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalCallExpression (ast, subs) {\n const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));\n const func = SafeEval.evalAst(ast.callee, subs);\n if (\n isBlockedFunction(func) ||\n args.some((arg) => isBlockedFunction(arg))\n ) {\n throw new Error('Function constructor is disabled');\n }\n return (/** @type {(...args: AnyParameter[]) => UnknownResult} */ (\n func\n ))(...args);\n },\n\n /**\n * @param {AssignmentExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalAssignmentExpression (ast, subs) {\n if (ast.left.type !== 'Identifier') {\n throw new SyntaxError('Invalid left-hand side in assignment');\n }\n const id = /** @type {jsep.Identifier} */ (\n ast.left\n ).name;\n const value = SafeEval.evalAst(ast.right, subs);\n subs[id] = value;\n return subs[id];\n }\n};\n\n/**\n * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly.\n */\nclass SafeScript {\n /**\n * @param {string} expr Expression to evaluate\n */\n constructor (expr) {\n this.code = expr;\n this.ast = /** @type {unknown} */ (jsep(this.code));\n }\n\n /**\n * @param {object} context Object whose items will be added\n * to evaluation\n * @returns {EvaluatedResult} Result of evaluated code\n */\n runInNewContext (context) {\n // `Object.create(null)` creates a prototypeless object\n const keyMap = Object.assign(Object.create(null), context);\n return SafeEval.evalAst(\n /** @type {jsep.Expression} */ (this.ast),\n keyMap\n );\n }\n}\n\nexport {SafeScript, getSafeProperty};\n","/**\n * @param {unknown} val\n */\nexport const toStringTag = (val) => {\n return Object.prototype.toString.call(val).slice(8, -1);\n};\n\n/**\n * @param {unknown} a\n * @param {unknown} b\n */\nexport const hasConstructor = (a, b) => {\n return Function.prototype.toString.call(\n Object.getPrototypeOf(a).constructor\n ) === Function.prototype.toString.call(\n b\n );\n};\n","/* eslint-disable camelcase -- Convenient for escaping */\n/* eslint-disable class-methods-use-this -- Consistent monkey-patching */\n/* eslint-disable unicorn/prefer-private-class-fields -- Allow\n monkey-patching */\nimport {SafeScript, getSafeProperty} from './Safe-Script.js';\nimport {toStringTag} from './utils.js';\n\nconst scriptCache = new Map();\nconst pathCache = new Map();\n\n/**\n * @typedef {any} AnyInput\n */\n\n/**\n * @typedef {((...args: any[]) => any)} SandboxCallback\n */\n\n/**\n * @typedef {any|SandboxCallback} SandboxPropertyValue\n */\n\n/**\n * @typedef {(string|number)[]} ExpressionArray\n */\n\n/**\n * @typedef {\"scalar\"|\"boolean\"|\"string\"|\"undefined\"\n * |\"function\"|\"integer\"|\"number\"|\"nonFinite\"|\"object\"\n * |\"array\"|\"other\"|\"null\"|\"symbol\"|\"Promise\"|\"BigInt\"\n * |\"jsonReference\"} ValueType\n */\n\n/**\n * @typedef {unknown} ParentValue\n */\n\n/**\n * @typedef {unknown} UnknownResult\n */\n\n/**\n * @typedef {string|number|null} ParentProperty\n */\n\n/**\n * @typedef {ReturnObject|string|number|boolean|null|unknown[]\n * |Record} PreferredOutput\n */\n\n/**\n * Copies array and then pushes item into it.\n * @param {ExpressionArray} arr Array to copy and into which to push\n * @param {string|number} item Array item to add (to end)\n * @returns {ExpressionArray} Copy of the original array\n */\nfunction push (arr, item) {\n arr = arr.slice();\n arr.push(item);\n return arr;\n}\n/**\n * Copies array and then unshifts item into it.\n * @param {string|number} item Array item to add (to beginning)\n * @param {ExpressionArray} arr Array to copy and into which to unshift\n * @returns {ExpressionArray} Copy of the original array\n */\nfunction unshift (item, arr) {\n arr = arr.slice();\n arr.unshift(item);\n return arr;\n}\n\n/**\n * @typedef {object} ReturnObject\n * @property {ExpressionArray|string} path\n * @property {unknown} value\n * @property {ParentValue} parent\n * @property {ParentProperty} parentProperty\n * @property {boolean} [isParentSelector]\n * @property {boolean} [hasArrExpr]\n * @property {ExpressionArray} [expr]\n * @property {string} [pointer]\n */\n\n/**\n * @callback JSONPathCallback\n * @param {any} preferredOutput Using `any` type instead of `PreferredOutput` so\n * that user can supply flexible type\n * @param {\"value\"|\"property\"} type\n * @param {ReturnObject} fullRetObj\n * @returns {void}\n */\n\n/**\n * @callback OtherTypeCallback\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {string|number|null} parentPropName\n * @param {string} arg\n * @returns {boolean|null}\n */\n\n/**\n * @typedef {any} ContextItem\n */\n\n/**\n * @typedef {any} EvaluatedResult\n */\n\n/**\n * @callback EvalCallback\n * @param {string} code\n * @param {ContextItem} context\n * @returns {EvaluatedResult}\n */\n\n/**\n * @typedef {new (expr: string) => {\n * runInNewContext: (context: object) => EvaluatedResult\n * }} ScriptConstructor\n */\n\n/**\n * @typedef {ScriptConstructor} EvalClass\n */\n\n/**\n * @typedef {\"value\"|\"path\"|\"pointer\"|\"parent\"|\"parentProperty\"\n * |\"all\"} ResultType\n */\n\n/**\n * @typedef {EvalCallback|EvalClass|'safe'|'native'|boolean} EvalValue\n */\n\n/**\n * @typedef {string|string[]} PathType\n */\n\n/**\n * @typedef {{Script: ScriptConstructor}} SafeScriptType\n */\n\n/**\n * @typedef {{Script: ScriptConstructor}} ScriptType\n */\n\n/**\n * @typedef {{\n * _$_path?: string,\n * _$_parentProperty?: ParentProperty,\n * _$_parent?: ParentValue,\n * _$_property?: string|number,\n * _$_root?: AnyInput,\n * _$_v?: unknown,\n * [key: string]: SandboxPropertyValue\n * }} SandboxType\n */\n\n/**\n * @typedef {object} JSONPathOptions\n * @property {AnyInput} [json]\n * @property {PathType} [path]\n * @property {ResultType} [resultType=\"value\"]\n * @property {boolean} [flatten=false]\n * @property {boolean} [wrap=true]\n * @property {SandboxType} [sandbox={}]\n * @property {EvalValue} [eval='safe']\n * @property {any|null} [parent=null]\n * @property {ParentProperty} [parentProperty=null]\n * @property {JSONPathCallback} [callback]\n * @property {OtherTypeCallback} [otherTypeCallback] Defaults to\n * function which throws on encountering `@other`\n * @property {Record} [customTypes] Map of\n * custom type operator names to their evaluation callbacks\n * @property {boolean} [autostart=true]\n * @property {boolean} [ignoreEvalErrors=false]\n */\n\n\n/**\n * @overload\n * @param {string} opts JSON path to evaluate\n * @param {AnyInput} [expr] JSON object to evaluate against\n * @param {JSONPathCallback} [obj] Passed 3 arguments: 1) desired\n * payload per `resultType`, 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [callback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n * @param {undefined} [otherTypeCallback]\n * @returns {unknown} The string form always has `autostart` implicitly\n * `true`, so the result is the evaluated value, not a `JSONPathClass`\n */\n/**\n * @overload\n * @param {JSONPathOptions & {autostart: false}} opts An options object\n * with `autostart` explicitly set to `false` defers evaluation and\n * returns the `JSONPathClass` instance instead\n * @returns {JSONPathClass}\n */\n/**\n * @overload\n * @param {JSONPathOptions} opts If a string, will be treated as\n * `expr`\n * @returns {unknown}\n */\n/**\n * @param {JSONPathOptions|string} opts If a string, will be treated as `expr`\n * @param {string|AnyInput} [expr] JSON path to evaluate\n * @param {AnyInput|JSONPathCallback} [obj] JSON object to evaluate against\n * @param {JSONPathCallback|OtherTypeCallback} [callback] Passed 3\n * arguments: 1) desired payload per `resultType`,\n * 2) `\"value\"|\"property\"`, 3) Full returned object with\n * all payloads\n * @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the end\n * of one's query, this will be invoked with the value of the item, its\n * path, its parent, and its parent's property name, and it should return\n * a boolean indicating whether the supplied value belongs to the \"other\"\n * type or not (or it may handle transformations and return `false`).\n * @throws {Error}\n * @returns {unknown|JSONPathClass}\n */\nfunction JSONPath (opts, expr, obj, callback, otherTypeCallback) {\n try {\n if (opts && typeof opts === 'object') {\n return new JSONPathClass(opts);\n }\n return new JSONPathClass(\n opts,\n expr,\n /** @type {JSONPathCallback|undefined} */ (obj),\n /** @type {OtherTypeCallback|undefined} */ (callback),\n /** @type {undefined} */ (otherTypeCallback)\n );\n } catch (e) {\n if (new.target) {\n throw e;\n }\n if (e && typeof e === 'object' && 'value' in e) {\n return /** @type {{value: UnknownResult}} */ (e).value;\n }\n throw e;\n }\n}\n\n/**\n *\n */\nclass JSONPathClass {\n /**\n * @overload\n * @param {string} opts JSON path to evaluate\n * @param {AnyInput} [expr] JSON object to evaluate against\n * @param {JSONPathCallback} [obj] Passed 3 arguments: 1) desired\n * payload per `resultType`, 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [callback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n * @param {undefined} [otherTypeCallback]\n */\n /**\n * @overload\n * @param {JSONPathOptions} opts If a string, will be treated as\n * `expr`\n */\n /**\n * @param {null|string|JSONPathOptions} opts If a string, will be treated as\n * `expr`\n * @param {string|AnyInput} [expr] JSON path to evaluate\n * @param {AnyInput|JSONPathCallback} [obj] JSON object to evaluate against\n * @param {JSONPathCallback|OtherTypeCallback} [callback] Passed 3\n * arguments: 1) desired payload per `resultType`,\n * 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n */\n constructor (opts, expr, obj, callback, otherTypeCallback) {\n if (typeof opts === 'string') {\n otherTypeCallback = /** @type {OtherTypeCallback} */ (\n callback\n );\n callback = /** @type {JSONPathCallback} */ (\n obj\n );\n obj = expr;\n expr = opts;\n opts = null;\n }\n const optObj = opts && typeof opts === 'object';\n opts ||= /** @type {JSONPathOptions} */ ({});\n /** @type {ResultType|undefined} */\n this.currResultType = undefined;\n\n /** @type {EvalValue|undefined} */\n this.currEval = undefined;\n\n /** @type {OtherTypeCallback|undefined} */\n this.currOtherTypeCallback = undefined;\n\n /** @type {Record|undefined} */\n this.currCustomTypes = undefined;\n\n /** @type {SandboxType|undefined} */\n this.currSandbox = undefined;\n\n this._hasParentSelector = false;\n\n this.json = opts.json || obj;\n this.path = opts.path || expr;\n this.resultType = opts.resultType || 'value';\n this.flatten = Object.hasOwn(opts, 'flatten') && opts.flatten;\n this.wrap = !Object.hasOwn(opts, 'wrap') || opts.wrap;\n this.sandbox = opts.sandbox || {};\n this.eval = opts.eval === undefined ? 'safe' : opts.eval;\n this.ignoreEvalErrors = (\n typeof opts.ignoreEvalErrors !== 'undefined'\n ) && opts.ignoreEvalErrors;\n this.parent = Object.hasOwn(opts, 'parent') ? opts.parent : null;\n this.parentProperty = Object.hasOwn(opts, 'parentProperty')\n ? opts.parentProperty\n : null;\n this.callback = opts.callback ||\n /** @type {JSONPathCallback} */\n (callback) ||\n null;\n this.otherTypeCallback = opts.otherTypeCallback ||\n otherTypeCallback ||\n function () {\n throw new TypeError(\n 'You must supply an otherTypeCallback callback option ' +\n 'with the @other() operator.'\n );\n };\n this.customTypes = opts.customTypes || {};\n\n if (opts.autostart === false) {\n return;\n }\n\n const args = /** @type {JSONPathOptions} */ ({\n path: (optObj ? opts.path : expr)\n });\n if (!optObj && obj !== undefined) {\n args.json = obj;\n } else if ('json' in opts) {\n args.json = opts.json;\n }\n const ret = this.evaluate(args);\n if (!ret || typeof ret !== 'object') {\n const err = /** @type {Error & {value: UnknownResult}} */ (\n new Error(\n 'JSONPath should not be called with \"new\" (it ' +\n 'prevents return of (unwrapped) scalar values)'\n )\n );\n err.value = ret;\n throw err;\n }\n\n // @ts-expect-error - Constructor returns evaluate result for legacy API\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line consistent-return, no-constructor-return -- Legacy API\n return ret;\n }\n\n // PUBLIC METHODS\n\n /**\n * @overload\n * @param {JSONPathOptions} [expr]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n\n /**\n * @overload\n * @param {PathType|undefined} [expr]\n * @param {AnyInput} [json]\n * @param {JSONPathCallback|null} [callback]\n * @param {OtherTypeCallback} [otherTypeCallback]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n\n /**\n * @param {PathType|JSONPathOptions|undefined} [expr]\n * @param {AnyInput} [json]\n * @param {JSONPathCallback|null} [callback]\n * @param {OtherTypeCallback} [otherTypeCallback]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n evaluate (\n expr, json, callback, otherTypeCallback\n ) {\n let currParent = this.parent,\n currParentProperty = this.parentProperty;\n let {flatten, wrap} = this;\n\n this.currResultType = this.resultType;\n this.currEval = this.eval;\n this.currSandbox = this.sandbox;\n callback ||= this.callback;\n this.currOtherTypeCallback = otherTypeCallback ||\n this.otherTypeCallback;\n this.currCustomTypes = this.customTypes;\n\n if (expr && typeof expr === 'object' && !Array.isArray(expr)) {\n const exprObj = expr;\n if (!exprObj.path && exprObj.path !== '') {\n throw new TypeError(\n 'You must supply a \"path\" property when providing an ' +\n 'object argument to JSONPath.evaluate().'\n );\n }\n if (!(Object.hasOwn(exprObj, 'json'))) {\n throw new TypeError(\n 'You must supply a \"json\" property when providing an ' +\n 'object argument to JSONPath.evaluate().'\n );\n }\n ({json} = exprObj);\n flatten = Object.hasOwn(exprObj, 'flatten')\n ? exprObj.flatten\n : flatten;\n this.currResultType = Object.hasOwn(exprObj, 'resultType')\n ? exprObj.resultType\n : this.currResultType;\n this.currSandbox = Object.hasOwn(exprObj, 'sandbox')\n ? exprObj.sandbox\n : this.currSandbox;\n wrap = Object.hasOwn(exprObj, 'wrap') ? exprObj.wrap : wrap;\n this.currEval = Object.hasOwn(exprObj, 'eval')\n ? exprObj.eval\n : this.currEval;\n callback = Object.hasOwn(exprObj, 'callback')\n ? exprObj.callback\n : callback;\n this.currOtherTypeCallback = Object.hasOwn(\n exprObj, 'otherTypeCallback'\n )\n ? exprObj.otherTypeCallback\n : this.currOtherTypeCallback;\n this.currCustomTypes = Object.hasOwn(\n exprObj, 'customTypes'\n )\n ? exprObj.customTypes\n : this.currCustomTypes;\n currParent = Object.hasOwn(exprObj, 'parent')\n ? exprObj.parent\n : currParent;\n currParentProperty = Object.hasOwn(exprObj, 'parentProperty')\n ? exprObj.parentProperty\n : currParentProperty;\n expr = exprObj.path;\n } else {\n json ||= this.json;\n expr ||= this.path;\n }\n currParent ||= null;\n currParentProperty ||= null;\n\n if (Array.isArray(expr)) {\n expr = JSONPath.toPathString(expr);\n }\n if (!json || (!expr && expr !== '')) {\n return undefined;\n }\n\n const exprList = JSONPath.toPathArray(\n /** @type {string} */\n (expr)\n );\n if (exprList[0] === '$' && exprList.length > 1) {\n exprList.shift();\n }\n this._hasParentSelector = false;\n const traceResult = this._trace(\n exprList, json, ['$'], currParent,\n currParentProperty,\n callback ?? undefined,\n undefined\n );\n\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next 2 -- Unreachable: _trace returns array when hasArrExpr set */\n const result = (\n Array.isArray(traceResult) ? traceResult : [traceResult]\n ).filter((ea) => {\n return ea && !ea.isParentSelector;\n });\n\n if (!result.length) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: valid queries always produce results */\n return wrap ? [] : undefined;\n }\n if (!wrap && result.length === 1 && !result[0].hasArrExpr) {\n const preferredOutput = this._getPreferredOutput(result[0]);\n return preferredOutput;\n }\n const reduced = result.reduce(\n (rslt, ea) => {\n const valOrPath = this._getPreferredOutput(ea);\n if (flatten && Array.isArray(valOrPath)) {\n rslt = rslt.concat(valOrPath);\n } else {\n rslt.push(valOrPath);\n }\n return rslt;\n },\n /** @type {UnknownResult[]} */\n ([])\n );\n\n return reduced;\n }\n\n // PRIVATE METHODS\n\n /**\n * @param {ReturnObject} ea\n * @returns {PreferredOutput}\n */\n _getPreferredOutput (ea) {\n const resultType = this.currResultType;\n switch (resultType) {\n case 'all': {\n const path = Array.isArray(ea.path)\n ? ea.path\n : JSONPath.toPathArray(ea.path);\n ea.pointer = JSONPath.toPointer(/** @type {string[]} */ (path));\n ea.path = typeof ea.path === 'string'\n ? ea.path\n : JSONPath.toPathString(/** @type {string[]} */ (ea.path));\n return ea;\n } case 'value': case 'parent': case 'parentProperty':\n return /** @type {PreferredOutput} */ (ea[resultType]);\n case 'path':\n if (typeof ea.path === 'string') {\n return ea.path;\n }\n return JSONPath.toPathString(/** @type {string[]} */ (ea.path));\n case 'pointer': {\n const pathArray = Array.isArray(ea.path)\n ? ea.path\n : JSONPath.toPathArray(ea.path);\n return JSONPath.toPointer(/** @type {string[]} */ (pathArray));\n }\n default:\n throw new TypeError('Unknown result type');\n }\n }\n\n /**\n * @param {ReturnObject} fullRetObj\n * @param {JSONPathCallback|undefined} callback\n * @param {\"value\"|\"property\"} type\n * @returns {void}\n */\n _handleCallback (fullRetObj, callback, type) {\n // Early return if no callback provided (defensive\n // check for internal calls)\n if (!callback) {\n return;\n }\n const preferredOutput = this._getPreferredOutput(fullRetObj);\n if (Array.isArray(fullRetObj.path)) {\n fullRetObj.path = JSONPath.toPathString(\n /** @type {string[]} */ (fullRetObj.path)\n );\n }\n callback(preferredOutput, type, fullRetObj);\n }\n\n /**\n *\n * @param {ExpressionArray} expr\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @param {JSONPathCallback|undefined} callback\n * @param {boolean|undefined} hasArrExpr\n * @param {boolean} [literalPriority]\n * @returns {ReturnObject|ReturnObject[]}\n */\n _trace (\n expr, val, path, parent, parentPropName, callback, hasArrExpr,\n literalPriority\n ) {\n // No expr to follow? return path and value as the result of\n // this trace branch\n let retObj;\n if (!expr.length) {\n retObj = {\n path,\n value: val,\n parent,\n parentProperty: parentPropName,\n hasArrExpr\n };\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n\n const loc = /** @type {string} */ (expr[0]), x = expr.slice(1);\n\n // We need to gather the return value of recursive trace calls in order\n // to do the parent sel computation.\n /** @type {ReturnObject[]} */\n const ret = [];\n /**\n *\n * @param {ReturnObject|ReturnObject[]} elems\n * @returns {void}\n */\n function addRet (elems) {\n if (Array.isArray(elems)) {\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test:\n // `ret.push(...elems);`\n elems.forEach((t) => {\n ret.push(t);\n });\n } else {\n ret.push(elems);\n }\n }\n if (val && (typeof loc !== 'string' || literalPriority) &&\n Object.hasOwn(val, /** @type {PropertyKey} */ (loc))\n ) { // simple case--directly follow property\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[/** @type {string} */ (loc)],\n push(path, loc),\n val, /** @type {string|number} */ (loc), callback,\n hasArrExpr\n ));\n // eslint-disable-next-line unicorn/prefer-switch -- Part of larger `if`\n } else if (loc === '*') { // all child properties\n this._walk(val, (m) => {\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[m], push(path, m), val, m, callback, true, true\n ));\n });\n } else if (loc === '..') { // all descendent parent properties\n // Check remaining expression with val's immediate children\n addRet(\n this._trace(x, val, path, parent, parentPropName, callback,\n hasArrExpr)\n );\n this._walk(val, (m) => {\n // We don't join m and x here because we only want parents,\n // not scalar values\n const valObj = /** @type {Record} */ (val);\n if (typeof valObj[m] === 'object') {\n // Keep going with recursive descent on val's\n // object children\n addRet(this._trace(\n expr.slice(),\n valObj[m],\n push(path, m),\n val,\n m,\n callback,\n true\n ));\n }\n });\n // The parent sel computation is handled in the frame above using the\n // ancestor object of val\n } else if (loc === '^') {\n // This is not a final endpoint, so we do not invoke the\n // callback here\n this._hasParentSelector = true;\n return /** @type {ReturnObject} */ ({\n path: path.slice(0, -1),\n expr: x,\n isParentSelector: true,\n value: undefined,\n parent: undefined,\n parentProperty: null\n });\n } else if (loc === '~') { // property name\n retObj = {\n path: push(path, loc),\n value: parentPropName,\n parent,\n parentProperty: null\n };\n this._handleCallback(retObj, callback, 'property');\n return retObj;\n } else if (loc === '$') { // root only\n addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));\n } else if ((/^(-?\\d*):(-?\\d*):?(\\d*)$/v).test(loc)) { // [start:end:step] Python slice syntax\n const sliceResult = this._slice(\n loc, x, val, path, parent, parentPropName, callback\n );\n if (sliceResult) {\n addRet(sliceResult);\n }\n } else if (loc.indexOf('?(') === 0) { // [?(expr)] (filtering)\n if (this.currEval === false) {\n throw new Error(\n 'Eval [?(expr)] prevented in JSONPath expression.'\n );\n }\n const safeLoc = loc.replace(/^\\?\\((.*?)\\)$/v, '$1');\n // check for a nested filter expression\n\n const nested = (/@.?([^?]*)[\\['](\\??\\(.*?\\))(?!.\\)\\])[\\]']/gv).exec(safeLoc);\n if (nested) {\n // find if there are matches in the nested expression\n // add them to the result set if there is at least one match\n this._walk(val, (m) => {\n const npath = [nested[2]];\n const valObj2 = /** @type {Record} */ (\n val\n );\n // guard against nested[1] resolving to `constructor`\n const nvalue = /** @type {ValueType} */ (nested[1]\n ? getSafeProperty(\n /** @type {Record} */ (\n valObj2[m]\n ),\n nested[1]\n )\n : valObj2[m]);\n const filterResults = this._trace(npath, nvalue, path,\n parent, parentPropName, callback, true);\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next 3 -- Unreachable: _trace always returns array for nested filters */\n const filterArray = Array.isArray(filterResults)\n ? filterResults\n : [filterResults];\n if (filterArray.length > 0) {\n addRet(this._trace(x, valObj2[m], push(path, m), val,\n m, callback, true));\n }\n });\n } else {\n const valObj3 = /** @type {Record} */ (val);\n this._walk(val, (m) => {\n if (this._eval(safeLoc, valObj3[m], m, path, parent,\n parentPropName)) {\n addRet(this._trace(x, valObj3[m], push(path, m), val, m,\n callback, true));\n }\n });\n }\n } else if (loc[0] === '(') { // [(expr)] (dynamic property/index)\n if (this.currEval === false) {\n throw new Error(\n 'Eval [(expr)] prevented in JSONPath expression.'\n );\n }\n // As this will resolve to a property name (but we don't know it\n // yet), property and parent information is relative to the\n const evalResult = this._eval(\n /** @type {string} */ (loc),\n val, /** @type {string|number} */ (path.at(-1)),\n path.slice(0, -1), parent, parentPropName\n );\n const exprToUse = /** @type {string|number} */ (\n evalResult !== undefined ? evalResult : ''\n );\n addRet(this._trace(unshift(\n exprToUse,\n x\n ), val, path, parent, parentPropName, callback, hasArrExpr));\n } else if (loc[0] === '@') { // value type: @boolean(), etc.\n // eslint-disable-next-line no-useless-assignment -- ESLint bug\n let addType = false;\n const parenthIndex = loc.indexOf('(');\n const valueType = /** @type {ValueType|string} */ (\n loc\n ).slice(1, parenthIndex);\n const lastParenth = loc.lastIndexOf(')');\n const argRaw = loc.slice(parenthIndex + 1, lastParenth);\n const arg = argRaw ? JSON.parse(argRaw) : undefined;\n switch (valueType) {\n case 'scalar':\n addType = !val ||\n !(['object', 'function'].includes(typeof val));\n break;\n case 'boolean': case 'string': case 'undefined': case 'function':\n addType = typeof val === valueType;\n break;\n case 'integer':\n addType = Number.isFinite(val) &&\n !(/** @type {number} */ (val) % 1);\n break;\n case 'number':\n addType = Number.isFinite(val);\n break;\n case 'nonFinite':\n addType = typeof val === 'number' && !Number.isFinite(val);\n break;\n case 'object':\n addType = Boolean(val) && typeof val === valueType;\n break;\n case 'array':\n addType = Array.isArray(val);\n break;\n case 'other':\n addType = /** @type {OtherTypeCallback} */ (\n this.currOtherTypeCallback\n )(\n val, path, parent, parentPropName, arg\n ) || false;\n break;\n case 'null':\n addType = val === null;\n break;\n case 'symbol':\n addType = typeof val === 'symbol';\n break;\n case 'BigInt':\n addType = typeof val === 'bigint';\n break;\n case 'Promise':\n addType = toStringTag(val) === 'Promise';\n break;\n case 'jsonReference':\n addType = Boolean(val) && typeof val === 'object' &&\n Object.hasOwn(/** @type {object} */ (val), '$ref');\n break;\n default:\n if (this.currCustomTypes &&\n Object.hasOwn(this.currCustomTypes, valueType)\n ) {\n addType = this.currCustomTypes[valueType](\n val, path, parent, parentPropName, arg\n ) || false;\n } else {\n throw new TypeError('Unknown value type ' + valueType);\n }\n }\n if (addType) {\n retObj = {\n path, value: val, parent, parentProperty: parentPropName\n };\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n // `-escaped property\n } else if (val && loc[0] === '`' &&\n Object.hasOwn(val, loc.slice(1))\n ) {\n const locProp = loc.slice(1);\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[locProp], push(path, locProp), val, locProp, callback,\n hasArrExpr, true\n ));\n } else if (loc[0] === \"'\" || loc[0] === '\"') { // ['name1','name2',...]\n // Quoted members are literal property names\n for (const [, single, double] of loc.matchAll(\n /'((?:\\\\.|[^'\\\\])*)'|\"((?:\\\\.|[^\"\\\\])*)\"/gv\n )) {\n const prop = (single ?? double).replaceAll(\n /\\\\(['\"\\\\])/gv, '$1'\n );\n if (!val || !Object.hasOwn(val, prop)) {\n continue;\n }\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[prop], push(path, prop), val, prop,\n callback, true\n ));\n }\n } else if (loc.includes(',')) { // [name1,name2,...]\n const parts = loc.split(',');\n for (const part of parts) {\n addRet(this._trace(\n unshift(part, x),\n val,\n path,\n parent,\n parentPropName,\n callback,\n true\n ));\n }\n // simple case--directly follow property\n } else if (\n !literalPriority && val && Object.hasOwn(val, loc)\n ) {\n const valObj = /** @type {Record} */ (val);\n addRet(\n this._trace(x, valObj[loc], push(path, loc), val, loc, callback,\n hasArrExpr, true)\n );\n }\n\n // We check the resulting values for parent selections. For parent\n // selections we discard the value object and continue the trace with\n // the current val object\n if (this._hasParentSelector) {\n for (let t = 0; t < ret.length; t++) {\n const rett = ret[t];\n if (!rett || !rett.isParentSelector) {\n continue;\n }\n\n const exprToUse = /** @type {ExpressionArray} */ (\n rett.expr\n );\n const pathToUse = /** @type {ExpressionArray} */ (\n rett.path\n );\n const tmp = this._trace(\n exprToUse,\n val,\n pathToUse,\n parent,\n parentPropName,\n callback,\n hasArrExpr\n );\n if (Array.isArray(tmp)) {\n ret[t] = tmp[0];\n const tl = tmp.length;\n for (let tt = 1; tt < tl; tt++) {\n t++;\n ret.splice(t, 0, tmp[tt]);\n }\n } else {\n ret[t] = tmp;\n }\n }\n }\n return ret;\n }\n\n /**\n * @param {unknown} val\n * @param {(prop: string|number) => void} f\n * @returns {void}\n */\n _walk (val, f) {\n if (Array.isArray(val)) {\n const n = val.length;\n for (let i = 0; i < n; i++) {\n f(i);\n }\n } else if (val && typeof val === 'object') {\n Object.keys(val).forEach((m) => {\n f(m);\n });\n }\n }\n\n /**\n * @param {string} loc\n * @param {ExpressionArray} expr\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @param {JSONPathCallback|undefined} callback\n * @returns {ReturnObject[]|undefined}\n */\n _slice (\n loc, expr, val, path, parent, parentPropName, callback\n ) {\n if (!Array.isArray(val)) {\n return undefined;\n }\n const len = val.length, parts = loc.split(':'),\n step = (parts[2] && Number(parts[2])) || 1;\n let start = (parts[0] && Number(parts[0])) || 0,\n end = parts[1] ? Number(parts[1]) : len;\n start = (start < 0) ? Math.max(0, start + len) : Math.min(len, start);\n end = (end < 0) ? Math.max(0, end + len) : Math.min(len, end);\n /** @type {ReturnObject[]} */\n const ret = [];\n for (let i = start; i < end; i += step) {\n const tmp = this._trace(\n unshift(i, expr),\n val,\n path,\n parent,\n parentPropName,\n callback,\n true\n );\n // Should only be possible to be an array here since first part of\n // ``unshift(i, expr)` passed in above would not be empty,\n // nor `~`, nor begin with `@` (as could return objects)\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test: `ret.push(...tmp);`\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: _trace returns array when expr non-empty */\n const tmpArray = Array.isArray(tmp) ? tmp : [tmp];\n tmpArray.forEach((t) => {\n ret.push(t);\n });\n }\n return ret;\n }\n\n /**\n * @param {string} code\n * @param {unknown} _v\n * @param {string|number} _vname\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @returns {UnknownResult}\n */\n _eval (\n code, _v, _vname, path, parent, parentPropName\n ) {\n if (this.currSandbox) {\n this.currSandbox._$_parentProperty = parentPropName;\n this.currSandbox._$_parent = parent;\n this.currSandbox._$_property = _vname;\n this.currSandbox._$_root = this.json;\n this.currSandbox._$_v = _v;\n }\n\n const containsPath = code.includes('@path');\n if (containsPath) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: currSandbox set in evaluate() before _eval */\n const currSandbox = this.currSandbox ?? {};\n currSandbox._$_path = JSONPath.toPathString(\n /** @type {string[]} */ (path.concat([_vname]))\n );\n }\n\n const scriptCacheKey = this.currEval + 'Script:' + code;\n if (!scriptCache.has(scriptCacheKey)) {\n let script = code\n .replaceAll('@parentProperty', '_$_parentProperty')\n .replaceAll('@parent', '_$_parent')\n .replaceAll('@property', '_$_property')\n .replaceAll('@root', '_$_root')\n // Replace a bare `@` (not followed by an identifier\n // character) while leaving quoted string literals and\n // regex literals (a `/` where an operand is expected,\n // as opposed to division) intact\n .replaceAll(\n /('(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\"|(?<=(?:^|[\\(,=:\\[!\\|?\\{\\};+\\-*%<>~^]|&)\\s*)\\/(?:\\\\.|\\[(?:\\\\.|[^\\]\\\\])*\\]|[^\\/\\\\\\[])+\\/[dgimsuvy]*)|@(?![\\w$])/gv,\n (_, literal) => literal ?? '_$_v'\n );\n if (containsPath) {\n script = script.replaceAll('@path', '_$_path');\n }\n const evalType = /** @type {string|boolean|undefined} */ (\n this.currEval\n );\n if (['safe', true, undefined].includes(evalType)) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-disable unicorn/no-undeclared-class-members -- Prototype members */\n scriptCache.set(scriptCacheKey, new (\n /**\n * @type {JSONPathClass & {\n * safeVm: SafeScriptType,\n * vm: ScriptType\n * }}\n */ (/** @type {unknown} */ (this))\n ).safeVm.Script(script));\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-enable unicorn/no-undeclared-class-members -- End prototype member scope */\n } else if (this.currEval === 'native') {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-disable unicorn/no-undeclared-class-members -- Prototype members */\n scriptCache.set(scriptCacheKey, new (\n /**\n * @type {JSONPathClass & {\n * safeVm: SafeScriptType,\n * vm: ScriptType\n * }}\n */ (/** @type {unknown} */ (this))\n ).vm.Script(script));\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-enable unicorn/no-undeclared-class-members -- End prototype member scope */\n } else if (\n typeof this.currEval === 'function' &&\n this.currEval.prototype &&\n Object.hasOwn(this.currEval.prototype, 'runInNewContext')\n ) {\n const CurrEval = this.currEval;\n // eslint-disable-next-line @stylistic/max-len -- Long\n // @ts-expect-error - Type checked above to have proper constructor\n scriptCache.set(scriptCacheKey, new CurrEval(script));\n } else if (typeof this.currEval === 'function') {\n // Type narrowing: at this point currEval is a function\n // but not a constructor\n const evalFunc = /** @type {EvalCallback} */ (this.currEval);\n scriptCache.set(scriptCacheKey, {\n runInNewContext: (\n /** @type {ContextItem} */ context\n ) => evalFunc(script, context)\n });\n } else {\n throw new TypeError(\n `Unknown \"eval\" property \"${this.currEval}\"`\n );\n }\n }\n\n try {\n /**\n * @typedef {{\n * runInNewContext: (\n * ctx: SandboxType|undefined\n * ) => EvaluatedResult\n * }} RunInNewContext\n */\n\n return /** @type {RunInNewContext} */ (\n scriptCache.get(scriptCacheKey)\n ).runInNewContext(\n this.currSandbox\n );\n } catch (e) {\n if (this.ignoreEvalErrors) {\n return false;\n }\n const error = /** @type {Error} */ (e);\n throw new Error('jsonPath: ' + error.message + ': ' + code, {\n cause: e\n });\n }\n }\n}\n\n/** @type {{safeVm: SafeScriptType}} */\n(/** @type {unknown} */ (JSONPathClass.prototype)).safeVm = {\n Script: SafeScript\n};\n\nJSONPath.prototype = JSONPathClass.prototype;\n\n// PUBLIC CLASS PROPERTIES AND METHODS\n\n/**\n * Clears cached parsed paths and compiled scripts.\n * @returns {void}\n */\nJSONPath.clearCache = function () {\n pathCache.clear();\n scriptCache.clear();\n};\n\n/**\n * @param {string[]} pathArr Array to convert\n * @returns {string} The path string\n */\nJSONPath.toPathString = function (pathArr) {\n const x = pathArr, n = x.length;\n let p = '$';\n for (let i = 1; i < n; i++) {\n if (!(/^(~|\\^|@.*?\\(\\))$/v).test(x[i])) {\n p += (/^[0-9*]+$/v).test(x[i])\n ? ('[' + x[i] + ']')\n : (\"['\" + String(x[i]).replaceAll(/['\\\\]/gv, String.raw`\\$&`) + \"']\");\n }\n }\n return p;\n};\n\n/**\n * @param {string[]} pointer JSON Path array\n * @returns {string} JSON Pointer\n */\nJSONPath.toPointer = function (pointer) {\n const x = pointer, n = x.length;\n let p = '';\n for (let i = 1; i < n; i++) {\n if (!(/^(~|\\^|@.*?\\(\\))$/v).test(x[i])) {\n p += '/' + x[i].toString()\n .replaceAll('~', '~0')\n .replaceAll('/', '~1');\n }\n }\n return p;\n};\n\n/**\n * @param {string} expr Expression to convert\n * @returns {string[]}\n */\nJSONPath.toPathArray = function (expr) {\n if (pathCache.has(expr)) {\n return /** @type {string[]} */ (pathCache.get(expr)).concat();\n }\n /** @type {string[]} */\n const subx = [];\n const normalized = expr\n // Properties\n .replaceAll(\n /@[\\w$\\-]+\\([^\\)]*\\)/gv,\n ';$&;'\n )\n // Parenthetical evaluations (filtering and otherwise), directly\n // within brackets or single quotes\n .replaceAll(/[\\['](\\??\\(.*?\\))[\\]'](?!.\\])/gv, function ($0, $1) {\n return '[#' +\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line unicorn/no-return-array-push -- Optimization\n (subx.push($1) - 1) +\n ']';\n })\n // Unions of quoted property names (e.g., `['x','y']`) and quoted\n // names with commas or backslash escapes, kept intact (with\n // quotes) so their members survive tokenization\n .replaceAll(\n /\\[\\s*((?:'(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\")(?:\\s*,\\s*(?:'(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\"))*)\\s*\\]/gv,\n function ($0, $1) {\n if (!(/[,\\\\]/v).test($1)) {\n return $0;\n }\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line unicorn/no-return-array-push -- Optimization\n return '[#' + (subx.push($1) - 1) + ']';\n }\n )\n // Escape periods and tildes within properties\n .replaceAll(/\\[['\"]([^'\\]]*)['\"]\\]/gv, function ($0, prop) {\n return \"['\" + prop\n .replaceAll('.', '%@%')\n .replaceAll('~', '%%@@%%') +\n \"']\";\n })\n // Properties operator\n .replaceAll('~', ';~;')\n // Split by property boundaries\n\n .replaceAll(/['\"]?\\.['\"]?(?![^\\[]*\\])|\\[['\"]?/gv, ';')\n // Reinsert periods within properties\n .replaceAll('%@%', '.')\n // Reinsert tildes within properties\n .replaceAll('%%@@%%', '~')\n // Parent\n .replaceAll(/(?:;)?(\\^+)(?:;)?/gv, function ($0, ups) {\n return ';' + ups.split('').join(';') + ';';\n })\n // Descendents\n .replaceAll(/;;;|;;/gv, ';..;')\n // Remove trailing\n .replaceAll(/;$|'?\\]|'$/gv, '');\n\n const exprList = normalized.split(';').map(function (exp) {\n const match = exp.match(/#(\\d+)/v);\n return !match || !match[1] ? exp : subx[Number(match[1])];\n });\n pathCache.set(expr, exprList);\n return /** @type {string[]} */ (pathCache.get(expr)).concat();\n};\n\nexport {JSONPath, JSONPathClass};\n","import {JSONPath, JSONPathClass} from './jsonpath.js';\n\n/**\n * @typedef {import('./jsonpath.js').AnyInput} AnyInput\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxCallback} SandboxCallback\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxPropertyValue} SandboxPropertyValue\n */\n/**\n * @typedef {import('./jsonpath.js').ExpressionArray} ExpressionArray\n */\n/**\n * @typedef {import('./jsonpath.js').ValueType} ValueType\n */\n/**\n * @typedef {import('./jsonpath.js').ParentValue} ParentValue\n */\n/**\n * @typedef {import('./jsonpath.js').UnknownResult} UnknownResult\n */\n/**\n * @typedef {import('./jsonpath.js').ParentProperty} ParentProperty\n */\n/**\n * @typedef {import('./jsonpath.js').PreferredOutput} PreferredOutput\n */\n/**\n * @typedef {import('./jsonpath.js').ReturnObject} ReturnObject\n */\n/**\n * @typedef {import('./jsonpath.js').JSONPathCallback} JSONPathCallback\n */\n/**\n * @typedef {import('./jsonpath.js').OtherTypeCallback} OtherTypeCallback\n */\n/**\n * @typedef {import('./jsonpath.js').ContextItem} ContextItem\n */\n/**\n * @typedef {import('./jsonpath.js').EvaluatedResult} EvaluatedResult\n */\n/**\n * @typedef {import('./jsonpath.js').EvalCallback} EvalCallback\n */\n/**\n * @typedef {import('./jsonpath.js').EvalClass} EvalClass\n */\n/**\n * @typedef {import('./jsonpath.js').ResultType} ResultType\n */\n/**\n * @typedef {import('./jsonpath.js').EvalValue} EvalValue\n */\n/**\n * @typedef {import('./jsonpath.js').PathType} PathType\n */\n/**\n * @typedef {import('./jsonpath.js').SafeScriptType} SafeScriptType\n */\n/**\n * @typedef {import('./jsonpath.js').ScriptType} ScriptType\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxType} SandboxType\n */\n/**\n * @typedef {import('./jsonpath.js').JSONPathOptions} JSONPathOptions\n */\n\n/**\n * @template T\n * @callback ConditionCallback\n * @param {T} item\n * @returns {boolean}\n */\n\n/**\n * Copy items out of one array into another.\n * @template T\n * @param {T[]} source Array with items to copy\n * @param {T[]} target Array to which to copy\n * @param {ConditionCallback} conditionCb Callback passed the current item;\n * will move item if evaluates to `true`\n * @returns {void}\n */\nconst moveToAnotherArray = function (source, target, conditionCb) {\n const il = source.length;\n for (let i = 0; i < il; i++) {\n const item = source[i];\n if (conditionCb(item)) {\n target.push(source.splice(i--, 1)[0]);\n }\n }\n};\n\n/**\n * In-browser replacement for NodeJS' VM.Script.\n */\nclass Script {\n /**\n * @param {string} expr Expression to evaluate\n */\n constructor (expr) {\n this.code = expr;\n }\n\n /**\n * @param {SandboxType} context Object whose items will be added\n * to evaluation\n * @returns {EvaluatedResult} Result of evaluated code\n */\n runInNewContext (context) {\n let expr = this.code;\n const keys = Object.keys(context);\n const funcs = /** @type {string[]} */ ([]);\n moveToAnotherArray(keys, funcs, (key) => {\n return typeof context[key] === 'function';\n });\n const values = keys.map((vr) => {\n return context[vr];\n });\n\n const funcString = funcs.reduce((s, func) => {\n let fString = context[func].toString();\n if (!(/function/v).test(fString)) {\n fString = 'function ' + fString;\n }\n return 'var ' + func + '=' + fString + ';' + s;\n }, '');\n\n expr = funcString + expr;\n\n // Mitigate https://perfectionkills.com/global-eval-what-are-the-options/#new_function\n if (!(/(['\"])use strict\\1/v).test(expr) && !keys.includes('arguments')) {\n expr = 'var arguments = undefined;' + expr;\n }\n\n // Remove last semi so `return` will be inserted before\n // the previous one instead, allowing for the return\n // of a bare ending expression\n expr = expr.replace(/;\\s*$/v, '');\n\n // Insert `return`\n const lastStatementEnd = expr.lastIndexOf(';');\n const code =\n lastStatementEnd !== -1\n ? expr.slice(0, lastStatementEnd + 1) +\n ' return ' +\n expr.slice(lastStatementEnd + 1)\n : ' return ' + expr;\n\n // eslint-disable-next-line no-new-func -- User's choice\n return new Function(...keys, code)(...values);\n }\n}\n\n/** @type {{vm: ScriptType}} */\n(/** @type {unknown} */ (JSONPathClass.prototype)).vm = {\n Script\n};\n\nexport {JSONPath, JSONPathClass, Script};\n"],"names":["Jsep","version","toString","addUnaryOp","op_name","max_unop_len","Math","max","length","unary_ops","addBinaryOp","precedence","isRightAssociative","max_binop_len","binary_ops","right_associative","add","delete","addIdentifierChar","char","additional_identifier_chars","addLiteral","literal_name","literal_value","literals","removeUnaryOp","getMaxKeyLen","removeAllUnaryOps","removeIdentifierChar","removeBinaryOp","removeAllBinaryOps","removeLiteral","removeAllLiterals","this","expr","charAt","index","code","charCodeAt","constructor","parse","obj","Object","keys","map","k","isDecimalDigit","ch","binaryPrecedence","op_val","isIdentifierStart","String","fromCharCode","has","isIdentifierPart","throwError","message","error","Error","description","runHook","name","node","hooks","env","context","run","searchHook","find","callback","call","gobbleSpaces","SPACE_CODE","TAB_CODE","LF_CODE","CR_CODE","nodes","gobbleExpressions","type","COMPOUND","body","untilICode","ch_i","SEMCOL_CODE","COMMA_CODE","gobbleExpression","push","gobbleBinaryExpression","gobbleBinaryOp","to_check","substr","tc_len","hasOwnProperty","biop","prec","stack","biop_info","left","right","i","cur_biop","gobbleToken","value","right_a","comparePrev","prev","pop","BINARY_EXP","operator","PERIOD_CODE","gobbleNumericLiteral","SQUOTE_CODE","DQUOTE_CODE","gobbleStringLiteral","OBRACK_CODE","gobbleArray","argument","UNARY_EXP","prefix","gobbleIdentifier","LITERAL","raw","this_str","THIS_EXP","OPAREN_CODE","gobbleGroup","gobbleTokenProperty","QUMARK_CODE","optional","MEMBER_EXP","computed","object","property","CBRACK_CODE","CALL_EXP","arguments","gobbleArguments","CPAREN_CODE","callee","chCode","number","parseFloat","str","startIndex","quote","closed","substring","start","IDENTIFIER","slice","termination","args","separator_count","arg","SEQUENCE_EXP","expressions","ARRAY_EXP","elements","first","Array","isArray","forEach","assign","plugins","jsep","registered","register","plugin","init","COLON_CODE","Set","true","false","null","stdClassProps","getOwnPropertyNames","filter","prop","includes","undefined","m","ternary","test","consequent","alternate","newTest","patternIndex","inCharSet","pattern","flags","RegExp","e","assignmentOperators","updateOperators","assignmentPrecedence","updateNodeTypes","updateBinariesToAssignments","values","val","op","some","c","jsepRegex","jsepAssignment","BLOCKED_PROTO_PROPERTIES","BLOCKED_FUNCTIONS","WeakSet","Function","async","prototype","apply","bind","Reflect","construct","get","isBlockedFunction","getSafeProperty","TypeError","hasOwn","result","BINOPS","create","||","a","b","??","&&","|","^","&","==","!=","===","!==","<",">","<=",">=","<<",">>",">>>","+","-","*","/","%","**","UNOPS","typeof","void","SafeEval","evalAst","ast","subs","evalBinaryExpression","evalCompound","evalConditionalExpression","evalIdentifier","evalLiteral","evalMemberExpression","evalUnaryExpression","evalArrayExpression","evalCallExpression","evalAssignmentExpression","SyntaxError","cause","last","ReferenceError","operand","el","func","id","scriptCache","Map","pathCache","arr","item","unshift","JSONPath","opts","otherTypeCallback","JSONPathClass","optObj","currResultType","currEval","currOtherTypeCallback","currCustomTypes","currSandbox","_hasParentSelector","json","path","resultType","flatten","wrap","sandbox","eval","ignoreEvalErrors","parent","parentProperty","customTypes","autostart","ret","evaluate","err","currParent","currParentProperty","exprObj","toPathString","exprList","toPathArray","shift","traceResult","_trace","ea","isParentSelector","hasArrExpr","_getPreferredOutput","reduce","rslt","valOrPath","concat","pointer","toPointer","pathArray","_handleCallback","fullRetObj","preferredOutput","parentPropName","literalPriority","retObj","loc","x","addRet","elems","t","valObj","_walk","sliceResult","_slice","indexOf","safeLoc","replace","nested","exec","npath","valObj2","nvalue","filterResults","valObj3","_eval","evalResult","at","exprToUse","addType","parenthIndex","valueType","lastParenth","lastIndexOf","argRaw","JSON","Number","isFinite","Boolean","toStringTag","locProp","single","double","matchAll","replaceAll","parts","split","part","rett","pathToUse","tmp","tl","tt","splice","f","n","len","step","end","min","_v","_vname","_$_parentProperty","_$_parent","_$_property","_$_root","_$_v","containsPath","_$_path","scriptCacheKey","script","_","literal","evalType","set","safeVm","Script","vm","CurrEval","evalFunc","runInNewContext","keyMap","clearCache","clear","pathArr","p","subx","$0","$1","ups","join","exp","match","funcs","source","target","conditionCb","il","moveToAnotherArray","key","vr","s","fString","lastStatementEnd"],"mappings":"AAgGA,MAAMA,EAIL,kBAAWC,GAEV,MAAO,O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7b759f1..08ced31 100644 --- a/dist/index-browser-umd.cjs +++ b/dist/index-browser-umd.cjs @@ -1285,6 +1285,7 @@ // eslint-disable-next-line @stylistic/max-len -- Long const BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */{ '||': (a, b) => a || b(), + '??': (a, b) => a ?? b(), '&&': (a, b) => a && b(), '|': (a, b) => a | b(), '^': (a, b) => a ^ b(), @@ -1306,7 +1307,8 @@ '-': (a, b) => a - b(), '*': (a, b) => a * b(), '/': (a, b) => a / b(), - '%': (a, b) => a % b() + '%': (a, b) => a % b(), + '**': (a, b) => a ** b() }); /** diff --git a/dist/index-browser-umd.min.cjs b/dist/index-browser-umd.min.cjs index 3d3ee9b..752fea4 100644 --- a/dist/index-browser-umd.min.cjs +++ b/dist/index-browser-umd.min.cjs @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSONPath={})}(this,function(e){"use strict";class t{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+t.version}static addUnaryOp(e){return t.max_unop_len=Math.max(e.length,t.max_unop_len),t.unary_ops[e]=1,t}static addBinaryOp(e,r,s){return t.max_binop_len=Math.max(e.length,t.max_binop_len),t.binary_ops[e]=r,s?t.right_associative.add(e):t.right_associative.delete(e),t}static addIdentifierChar(e){return t.additional_identifier_chars.add(e),t}static addLiteral(e,r){return t.literals[e]=r,t}static removeUnaryOp(e){return delete t.unary_ops[e],e.length===t.max_unop_len&&(t.max_unop_len=t.getMaxKeyLen(t.unary_ops)),t}static removeAllUnaryOps(){return t.unary_ops={},t.max_unop_len=0,t}static removeIdentifierChar(e){return t.additional_identifier_chars.delete(e),t}static removeBinaryOp(e){return delete t.binary_ops[e],e.length===t.max_binop_len&&(t.max_binop_len=t.getMaxKeyLen(t.binary_ops)),t.right_associative.delete(e),t}static removeAllBinaryOps(){return t.binary_ops={},t.max_binop_len=0,t}static removeLiteral(e){return delete t.literals[e],t}static removeAllLiterals(){return t.literals={},t}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new t(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(e=>e.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return t.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!t.binary_ops[String.fromCharCode(e)]||t.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return t.isIdentifierStart(e)||t.isDecimalDigit(e)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,r){if(t.hooks[e]){const s={context:this,node:r};return t.hooks.run(e,s),s.node}return r}searchHook(e){if(t.hooks[e]){const r={context:this};return t.hooks[e].find(function(e){return e.call(r.context,r),r.node}),r.node}}gobbleSpaces(){let e=this.code;for(;e===t.SPACE_CODE||e===t.TAB_CODE||e===t.LF_CODE||e===t.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const e=this.gobbleExpressions(),r=1===e.length?e[0]:{type:t.COMPOUND,body:e};return this.runHook("after-all",r)}gobbleExpressions(e){let r,s,n=[];for(;this.index0;){if(t.binary_ops.hasOwnProperty(e)&&(!t.isIdentifierStart(this.code)||this.index+e.lengthi.right_a&&e.right_a?s>e.prec:s<=e.prec;for(;n.length>2&&h(n[n.length-2]);)a=n.pop(),r=n.pop().value,o=n.pop(),e={type:t.BINARY_EXP,operator:r,left:o,right:a},n.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),n.push(i,e)}for(h=n.length-1,e=n[h];h>1;)e={type:t.BINARY_EXP,operator:n[h-1].value,left:n[h-2],right:e},h-=2;return e}gobbleToken(){let e,r,s,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(e=this.code,t.isDecimalDigit(e)||e===t.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===t.SQUOTE_CODE||e===t.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===t.OBRACK_CODE)n=this.gobbleArray();else{for(r=this.expr.substr(this.index,t.max_unop_len),s=r.length;s>0;){if(t.unary_ops.hasOwnProperty(r)&&(!t.isIdentifierStart(this.code)||this.index+r.length=r.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(i===t.COMMA_CODE){if(this.index++,n++,n!==r.length)if(e===t.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===t.CBRACK_CODE)for(let e=r.length;e{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(t),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),t.max_unop_len=t.getMaxKeyLen(t.unary_ops),t.max_binop_len=t.getMaxKeyLen(t.binary_ops);const s=e=>new t(e).parse(),n=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(t).filter(e=>!n.includes(e)&&void 0===s[e]).forEach(e=>{s[e]=t[e]}),s.Jsep=t;var i={name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,s=this.gobbleExpression();if(s||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const n=this.gobbleExpression();if(n||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:s,alternate:n},r.operator&&e.binary_ops[r.operator]<=.9){let s=r;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;t.node.test=s.right,s.right=t.node,t.node=r}}else this.throwError("Expected :")}})}};s.plugins.register(i);var o={name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){const r=++this.index;let s=!1;for(;this.index=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;i+=this.char}try{n=new RegExp(s,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?s=!0:s&&this.code===e.CBRACK_CODE&&(s=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}};const a={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){a.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach(e=>{e&&"object"==typeof e&&r(e)})}a.assignmentOperators.forEach(t=>e.addBinaryOp(t,a.assignmentPrecedence,!0)),e.hooks.add("gobble-token",function(e){const r=this.code;a.updateOperators.some(e=>e===r&&e===this.expr.charCodeAt(this.index+1))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))}),e.hooks.add("after-token",function(e){if(e.node){const r=this.code;a.updateOperators.some(e=>e===r&&e===this.expr.charCodeAt(this.index+1))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}}),e.hooks.add("after-expression",function(e){e.node&&r(e.node)})}};s.plugins.register(o,a),s.addUnaryOp("typeof"),s.addUnaryOp("void"),s.addLiteral("null",null),s.addLiteral("undefined",void 0);const h=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),l=new WeakSet([Function,function*(){}.constructor,async function(){}.constructor,async function*(){}.constructor,Function.prototype.call,Function.prototype.apply,Function.prototype.bind,Reflect.apply,Reflect.construct,...[...h].map(e=>Reflect.get(Object.prototype,e)).filter(e=>"function"==typeof e)]),c=e=>"function"==typeof e&&l.has(e),p=(e,t)=>{if(null==e)throw new TypeError(`Cannot read properties of ${e} (reading '${t}')`);if(!Object.hasOwn(e,t)&&h.has(t))throw new TypeError(`Cannot read properties of ${e} (reading '${t}')`);const r=e[t];if(c(r))throw new TypeError("Function constructor is disabled");return r},u=Object.assign(Object.create(null),{"||":(e,t)=>e||t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t()}),d=Object.assign(Object.create(null),{"-":e=>-e,"!":e=>!e,"~":e=>~e,"+":e=>+e,typeof:e=>typeof e,void:()=>{}}),f={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return f.evalBinaryExpression(e,t);case"Compound":return f.evalCompound(e,t);case"ConditionalExpression":return f.evalConditionalExpression(e,t);case"Identifier":return f.evalIdentifier(e,t);case"Literal":return f.evalLiteral(e);case"MemberExpression":return f.evalMemberExpression(e,t);case"UnaryExpression":return f.evalUnaryExpression(e,t);case"ArrayExpression":return f.evalArrayExpression(e,t);case"CallExpression":return f.evalCallExpression(e,t);case"AssignmentExpression":return f.evalAssignmentExpression(e,t);default:throw new SyntaxError("Unexpected expression",{cause:e})}},evalBinaryExpression(e,t){if(!Object.hasOwn(u,e.operator))throw new SyntaxError(`Unknown binary operator: ${e.operator}`);return u[e.operator](f.evalAst(e.left,t),()=>f.evalAst(e.right,t))},evalCompound(e,t){let r;for(let s=0;sf.evalAst(e.test,t)?f.evalAst(e.consequent,t):f.evalAst(e.alternate,t),evalIdentifier(e,t){if(Object.hasOwn(t,e.name))return t[e.name];throw new ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){const r=String(e.computed?f.evalAst(e.property,t):e.property.name),s=f.evalAst(e.object,t),n=p(s,r);return"function"==typeof n?n.bind(s):n},evalUnaryExpression(e,t){if(!Object.hasOwn(d,e.operator))throw new SyntaxError(`Unknown unary operator: ${e.operator}`);const r=f.evalAst(e.argument,t);return d[e.operator](r)},evalArrayExpression:(e,t)=>e.elements.map(e=>f.evalAst(e,t)),evalCallExpression(e,t){const r=e.arguments.map(e=>f.evalAst(e,t)),s=f.evalAst(e.callee,t);if(c(s)||r.some(e=>c(e)))throw new Error("Function constructor is disabled");return s(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw new SyntaxError("Invalid left-hand side in assignment");const r=e.left.name,s=f.evalAst(e.right,t);return t[r]=s,t[r]}};const b=new Map,y=new Map;function E(e,t){return(e=e.slice()).push(t),e}function g(e,t){return(t=t.slice()).unshift(e),t}function x(e,t,r,s,n){try{return e&&"object"==typeof e?new _(e):new _(e,t,r,s,n)}catch(e){if(new.target)throw e;if(e&&"object"==typeof e&&"value"in e)return e.value;throw e}}class _{constructor(e,t,r,s,n){"string"==typeof e&&(n=s,s=r,r=t,t=e,e=null);const i=e&&"object"==typeof e;if(e||={},this.currResultType=void 0,this.currEval=void 0,this.currOtherTypeCallback=void 0,this.currCustomTypes=void 0,this.currSandbox=void 0,this._hasParentSelector=!1,this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=Object.hasOwn(e,"flatten")&&e.flatten,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=Object.hasOwn(e,"parent")?e.parent:null,this.parentProperty=Object.hasOwn(e,"parentProperty")?e.parentProperty:null,this.callback=e.callback||s||null,this.otherTypeCallback=e.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},this.customTypes=e.customTypes||{},!1===e.autostart)return;const o={path:i?e.path:t};i||void 0===r?"json"in e&&(o.json=e.json):o.json=r;const a=this.evaluate(o);if(!a||"object"!=typeof a){const e=new Error('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');throw e.value=a,e}return a}evaluate(e,t,r,s){let n=this.parent,i=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r||=this.callback,this.currOtherTypeCallback=s||this.otherTypeCallback,this.currCustomTypes=this.customTypes,e&&"object"==typeof e&&!Array.isArray(e)){const s=e;if(!s.path&&""!==s.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(s,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=s),o=Object.hasOwn(s,"flatten")?s.flatten:o,this.currResultType=Object.hasOwn(s,"resultType")?s.resultType:this.currResultType,this.currSandbox=Object.hasOwn(s,"sandbox")?s.sandbox:this.currSandbox,a=Object.hasOwn(s,"wrap")?s.wrap:a,this.currEval=Object.hasOwn(s,"eval")?s.eval:this.currEval,r=Object.hasOwn(s,"callback")?s.callback:r,this.currOtherTypeCallback=Object.hasOwn(s,"otherTypeCallback")?s.otherTypeCallback:this.currOtherTypeCallback,this.currCustomTypes=Object.hasOwn(s,"customTypes")?s.customTypes:this.currCustomTypes,n=Object.hasOwn(s,"parent")?s.parent:n,i=Object.hasOwn(s,"parentProperty")?s.parentProperty:i,e=s.path}else t||=this.json,e||=this.path;if(n||=null,i||=null,Array.isArray(e)&&(e=x.toPathString(e)),!t||!e&&""!==e)return;const h=x.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=!1;const l=this._trace(h,t,["$"],n,i,r??void 0,void 0),c=(Array.isArray(l)?l:[l]).filter(e=>e&&!e.isParentSelector);if(!c.length)return a?[]:void 0;if(!a&&1===c.length&&!c[0].hasArrExpr){return this._getPreferredOutput(c[0])}return c.reduce((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e},[])}_getPreferredOutput(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:x.toPathArray(e.path);return e.pointer=x.toPointer(t),e.path="string"==typeof e.path?e.path:x.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return"string"==typeof e.path?e.path:x.toPathString(e.path);case"pointer":{const t=Array.isArray(e.path)?e.path:x.toPathArray(e.path);return x.toPointer(t)}default:throw new TypeError("Unknown result type")}}_handleCallback(e,t,r){if(!t)return;const s=this._getPreferredOutput(e);Array.isArray(e.path)&&(e.path=x.toPathString(e.path)),t(s,r,e)}_trace(e,t,r,s,n,i,o,a){let h;if(!e.length)return h={path:r,value:t,parent:s,parentProperty:n,hasArrExpr:o},this._handleCallback(h,i,"value"),h;const l=e[0],c=e.slice(1),u=[];function d(e){Array.isArray(e)?e.forEach(e=>{u.push(e)}):u.push(e)}if(t&&("string"!=typeof l||a)&&Object.hasOwn(t,l)){const e=t;d(this._trace(c,e[l],E(r,l),t,l,i,o))}else if("*"===l)this._walk(t,e=>{const s=t;d(this._trace(c,s[e],E(r,e),t,e,i,!0,!0))});else if(".."===l)d(this._trace(c,t,r,s,n,i,o)),this._walk(t,s=>{const n=t;"object"==typeof n[s]&&d(this._trace(e.slice(),n[s],E(r,s),t,s,i,!0))});else{if("^"===l)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:c,isParentSelector:!0,value:void 0,parent:void 0,parentProperty:null};if("~"===l)return h={path:E(r,l),value:n,parent:s,parentProperty:null},this._handleCallback(h,i,"property"),h;if("$"===l)d(this._trace(c,t,r,null,null,i,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/v.test(l)){const e=this._slice(l,c,t,r,s,n,i);e&&d(e)}else if(0===l.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=l.replace(/^\?\((.*?)\)$/v,"$1"),o=/@.?([^?]*)[\['](\??\(.*?\))(?!.\)\])[\]']/gv.exec(e);if(o)this._walk(t,e=>{const a=[o[2]],h=t,l=o[1]?p(h[e],o[1]):h[e],u=this._trace(a,l,r,s,n,i,!0);(Array.isArray(u)?u:[u]).length>0&&d(this._trace(c,h[e],E(r,e),t,e,i,!0))});else{const o=t;this._walk(t,a=>{this._eval(e,o[a],a,r,s,n)&&d(this._trace(c,o[a],E(r,a),t,a,i,!0))})}}else if("("===l[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");const e=this._eval(l,t,r.at(-1),r.slice(0,-1),s,n),a=void 0!==e?e:"";d(this._trace(g(a,c),t,r,s,n,i,o))}else if("@"===l[0]){let e=!1;const o=l.indexOf("("),a=l.slice(1,o),c=l.lastIndexOf(")"),p=l.slice(o+1,c),u=p?JSON.parse(p):void 0;switch(a){case"scalar":e=!t||!["object","function"].includes(typeof t);break;case"boolean":case"string":case"undefined":case"function":e=typeof t===a;break;case"integer":e=Number.isFinite(t)&&!(t%1);break;case"number":e=Number.isFinite(t);break;case"nonFinite":e="number"==typeof t&&!Number.isFinite(t);break;case"object":e=Boolean(t)&&typeof t===a;break;case"array":e=Array.isArray(t);break;case"other":e=this.currOtherTypeCallback(t,r,s,n,u)||!1;break;case"null":e=null===t;break;case"symbol":e="symbol"==typeof t;break;case"BigInt":e="bigint"==typeof t;break;case"Promise":e="Promise"===(e=>Object.prototype.toString.call(e).slice(8,-1))(t);break;case"jsonReference":e=Boolean(t)&&"object"==typeof t&&Object.hasOwn(t,"$ref");break;default:if(!this.currCustomTypes||!Object.hasOwn(this.currCustomTypes,a))throw new TypeError("Unknown value type "+a);e=this.currCustomTypes[a](t,r,s,n,u)||!1}if(e)return h={path:r,value:t,parent:s,parentProperty:n},this._handleCallback(h,i,"value"),h}else if(t&&"`"===l[0]&&Object.hasOwn(t,l.slice(1))){const e=l.slice(1),s=t;d(this._trace(c,s[e],E(r,e),t,e,i,o,!0))}else if("'"===l[0]||'"'===l[0])for(const[,e,s]of l.matchAll(/'((?:\\.|[^'\\])*)'|"((?:\\.|[^"\\])*)"/gv)){const n=(e??s).replaceAll(/\\(['"\\])/gv,"$1");if(!t||!Object.hasOwn(t,n))continue;const o=t;d(this._trace(c,o[n],E(r,n),t,n,i,!0))}else if(l.includes(",")){const e=l.split(",");for(const o of e)d(this._trace(g(o,c),t,r,s,n,i,!0))}else if(!a&&t&&Object.hasOwn(t,l)){const e=t;d(this._trace(c,e[l],E(r,l),t,l,i,o,!0))}}if(this._hasParentSelector)for(let e=0;e{t(e)})}_slice(e,t,r,s,n,i,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),l=h[2]&&Number(h[2])||1;let c=h[0]&&Number(h[0])||0,p=h[1]?Number(h[1]):a;c=c<0?Math.max(0,c+a):Math.min(a,c),p=p<0?Math.max(0,p+a):Math.min(a,p);const u=[];for(let e=c;e{u.push(e)})}return u}_eval(e,t,r,s,n,i){this.currSandbox&&(this.currSandbox._$_parentProperty=i,this.currSandbox._$_parent=n,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t);const o=e.includes("@path");if(o){(this.currSandbox??{})._$_path=x.toPathString(s.concat([r]))}const a=this.currEval+"Script:"+e;if(!b.has(a)){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/('(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|(?<=(?:^|[\(,=:\[!\|?\{\};+\-*%<>~^]|&)\s*)\/(?:\\.|\[(?:\\.|[^\]\\])*\]|[^\/\\\[])+\/[dgimsuvy]*)|@(?![\w$])/gv,(e,t)=>t??"_$_v");o&&(t=t.replaceAll("@path","_$_path"));const r=this.currEval;if(["safe",!0,void 0].includes(r))b.set(a,new this.safeVm.Script(t));else if("native"===this.currEval)b.set(a,new this.vm.Script(t));else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;b.set(a,new e(t))}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);{const e=this.currEval;b.set(a,{runInNewContext:r=>e(t,r)})}}}try{return b.get(a).runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e,{cause:t})}}}_.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=s(this.code)}runInNewContext(e){const t=Object.assign(Object.create(null),e);return f.evalAst(this.ast,t)}}},x.prototype=_.prototype,x.clearCache=function(){y.clear(),b.clear()},x.toPathString=function(e){const t=e,r=t.length;let s="$";for(let e=1;e"function"==typeof e[t]);const n=r.map(t=>e[t]);t=s.reduce((t,r)=>{let s=e[r].toString();return/function/v.test(s)||(s="function "+s),"var "+r+"="+s+";"+t},"")+t,/(['"])use strict\1/v.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/v,"");const i=t.lastIndexOf(";"),o=-1!==i?t.slice(0,i+1)+" return "+t.slice(i+1):" return "+t;return new Function(...r,o)(...n)}}_.prototype.vm={Script:O},e.JSONPath=x,e.JSONPathClass=_,e.Script=O}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSONPath={})}(this,function(e){"use strict";class t{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+t.version}static addUnaryOp(e){return t.max_unop_len=Math.max(e.length,t.max_unop_len),t.unary_ops[e]=1,t}static addBinaryOp(e,r,s){return t.max_binop_len=Math.max(e.length,t.max_binop_len),t.binary_ops[e]=r,s?t.right_associative.add(e):t.right_associative.delete(e),t}static addIdentifierChar(e){return t.additional_identifier_chars.add(e),t}static addLiteral(e,r){return t.literals[e]=r,t}static removeUnaryOp(e){return delete t.unary_ops[e],e.length===t.max_unop_len&&(t.max_unop_len=t.getMaxKeyLen(t.unary_ops)),t}static removeAllUnaryOps(){return t.unary_ops={},t.max_unop_len=0,t}static removeIdentifierChar(e){return t.additional_identifier_chars.delete(e),t}static removeBinaryOp(e){return delete t.binary_ops[e],e.length===t.max_binop_len&&(t.max_binop_len=t.getMaxKeyLen(t.binary_ops)),t.right_associative.delete(e),t}static removeAllBinaryOps(){return t.binary_ops={},t.max_binop_len=0,t}static removeLiteral(e){return delete t.literals[e],t}static removeAllLiterals(){return t.literals={},t}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(e){this.expr=e,this.index=0}static parse(e){return new t(e).parse()}static getMaxKeyLen(e){return Math.max(0,...Object.keys(e).map(e=>e.length))}static isDecimalDigit(e){return e>=48&&e<=57}static binaryPrecedence(e){return t.binary_ops[e]||0}static isIdentifierStart(e){return e>=65&&e<=90||e>=97&&e<=122||e>=128&&!t.binary_ops[String.fromCharCode(e)]||t.additional_identifier_chars.has(String.fromCharCode(e))}static isIdentifierPart(e){return t.isIdentifierStart(e)||t.isDecimalDigit(e)}throwError(e){const t=new Error(e+" at character "+this.index);throw t.index=this.index,t.description=e,t}runHook(e,r){if(t.hooks[e]){const s={context:this,node:r};return t.hooks.run(e,s),s.node}return r}searchHook(e){if(t.hooks[e]){const r={context:this};return t.hooks[e].find(function(e){return e.call(r.context,r),r.node}),r.node}}gobbleSpaces(){let e=this.code;for(;e===t.SPACE_CODE||e===t.TAB_CODE||e===t.LF_CODE||e===t.CR_CODE;)e=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");const e=this.gobbleExpressions(),r=1===e.length?e[0]:{type:t.COMPOUND,body:e};return this.runHook("after-all",r)}gobbleExpressions(e){let r,s,n=[];for(;this.index0;){if(t.binary_ops.hasOwnProperty(e)&&(!t.isIdentifierStart(this.code)||this.index+e.lengthi.right_a&&e.right_a?s>e.prec:s<=e.prec;for(;n.length>2&&h(n[n.length-2]);)a=n.pop(),r=n.pop().value,o=n.pop(),e={type:t.BINARY_EXP,operator:r,left:o,right:a},n.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),n.push(i,e)}for(h=n.length-1,e=n[h];h>1;)e={type:t.BINARY_EXP,operator:n[h-1].value,left:n[h-2],right:e},h-=2;return e}gobbleToken(){let e,r,s,n;if(this.gobbleSpaces(),n=this.searchHook("gobble-token"),n)return this.runHook("after-token",n);if(e=this.code,t.isDecimalDigit(e)||e===t.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===t.SQUOTE_CODE||e===t.DQUOTE_CODE)n=this.gobbleStringLiteral();else if(e===t.OBRACK_CODE)n=this.gobbleArray();else{for(r=this.expr.substr(this.index,t.max_unop_len),s=r.length;s>0;){if(t.unary_ops.hasOwnProperty(r)&&(!t.isIdentifierStart(this.code)||this.index+r.length=r.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(i===t.COMMA_CODE){if(this.index++,n++,n!==r.length)if(e===t.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===t.CBRACK_CODE)for(let e=r.length;e{if("object"!=typeof e||!e.name||!e.init)throw new Error("Invalid JSEP plugin format");this.registered[e.name]||(e.init(this.jsep),this.registered[e.name]=e)})}}(t),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),t.max_unop_len=t.getMaxKeyLen(t.unary_ops),t.max_binop_len=t.getMaxKeyLen(t.binary_ops);const s=e=>new t(e).parse(),n=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(t).filter(e=>!n.includes(e)&&void 0===s[e]).forEach(e=>{s[e]=t[e]}),s.Jsep=t;var i={name:"ternary",init(e){e.hooks.add("after-expression",function(t){if(t.node&&this.code===e.QUMARK_CODE){this.index++;const r=t.node,s=this.gobbleExpression();if(s||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const n=this.gobbleExpression();if(n||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:s,alternate:n},r.operator&&e.binary_ops[r.operator]<=.9){let s=r;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;t.node.test=s.right,s.right=t.node,t.node=r}}else this.throwError("Expected :")}})}};s.plugins.register(i);var o={name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){const r=++this.index;let s=!1;for(;this.index=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;i+=this.char}try{n=new RegExp(s,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:n,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?s=!0:s&&this.code===e.CBRACK_CODE&&(s=!1),this.index+=92===this.code?2:1}this.throwError("Unclosed Regex")}})}};const a={name:"assignment",assignmentOperators:new Set(["=","*=","**=","/=","%=","+=","-=","<<=",">>=",">>>=","&=","^=","|=","||=","&&=","??="]),updateOperators:[43,45],assignmentPrecedence:.9,init(e){const t=[e.IDENTIFIER,e.MEMBER_EXP];function r(e){a.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",r(e.left),r(e.right)):e.operator||Object.values(e).forEach(e=>{e&&"object"==typeof e&&r(e)})}a.assignmentOperators.forEach(t=>e.addBinaryOp(t,a.assignmentPrecedence,!0)),e.hooks.add("gobble-token",function(e){const r=this.code;a.updateOperators.some(e=>e===r&&e===this.expr.charCodeAt(this.index+1))&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&t.includes(e.node.argument.type)||this.throwError(`Unexpected ${e.node.operator}`))}),e.hooks.add("after-token",function(e){if(e.node){const r=this.code;a.updateOperators.some(e=>e===r&&e===this.expr.charCodeAt(this.index+1))&&(t.includes(e.node.type)||this.throwError(`Unexpected ${e.node.operator}`),this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:e.node,prefix:!1})}}),e.hooks.add("after-expression",function(e){e.node&&r(e.node)})}};s.plugins.register(o,a),s.addUnaryOp("typeof"),s.addUnaryOp("void"),s.addLiteral("null",null),s.addLiteral("undefined",void 0);const h=new Set(["constructor","__proto__","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),l=new WeakSet([Function,function*(){}.constructor,async function(){}.constructor,async function*(){}.constructor,Function.prototype.call,Function.prototype.apply,Function.prototype.bind,Reflect.apply,Reflect.construct,...[...h].map(e=>Reflect.get(Object.prototype,e)).filter(e=>"function"==typeof e)]),c=e=>"function"==typeof e&&l.has(e),p=(e,t)=>{if(null==e)throw new TypeError(`Cannot read properties of ${e} (reading '${t}')`);if(!Object.hasOwn(e,t)&&h.has(t))throw new TypeError(`Cannot read properties of ${e} (reading '${t}')`);const r=e[t];if(c(r))throw new TypeError("Function constructor is disabled");return r},u=Object.assign(Object.create(null),{"||":(e,t)=>e||t(),"??":(e,t)=>e??t(),"&&":(e,t)=>e&&t(),"|":(e,t)=>e|t(),"^":(e,t)=>e^t(),"&":(e,t)=>e&t(),"==":(e,t)=>e==t(),"!=":(e,t)=>e!=t(),"===":(e,t)=>e===t(),"!==":(e,t)=>e!==t(),"<":(e,t)=>e":(e,t)=>e>t(),"<=":(e,t)=>e<=t(),">=":(e,t)=>e>=t(),"<<":(e,t)=>e<>":(e,t)=>e>>t(),">>>":(e,t)=>e>>>t(),"+":(e,t)=>e+t(),"-":(e,t)=>e-t(),"*":(e,t)=>e*t(),"/":(e,t)=>e/t(),"%":(e,t)=>e%t(),"**":(e,t)=>e**t()}),d=Object.assign(Object.create(null),{"-":e=>-e,"!":e=>!e,"~":e=>~e,"+":e=>+e,typeof:e=>typeof e,void:()=>{}}),f={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return f.evalBinaryExpression(e,t);case"Compound":return f.evalCompound(e,t);case"ConditionalExpression":return f.evalConditionalExpression(e,t);case"Identifier":return f.evalIdentifier(e,t);case"Literal":return f.evalLiteral(e);case"MemberExpression":return f.evalMemberExpression(e,t);case"UnaryExpression":return f.evalUnaryExpression(e,t);case"ArrayExpression":return f.evalArrayExpression(e,t);case"CallExpression":return f.evalCallExpression(e,t);case"AssignmentExpression":return f.evalAssignmentExpression(e,t);default:throw new SyntaxError("Unexpected expression",{cause:e})}},evalBinaryExpression(e,t){if(!Object.hasOwn(u,e.operator))throw new SyntaxError(`Unknown binary operator: ${e.operator}`);return u[e.operator](f.evalAst(e.left,t),()=>f.evalAst(e.right,t))},evalCompound(e,t){let r;for(let s=0;sf.evalAst(e.test,t)?f.evalAst(e.consequent,t):f.evalAst(e.alternate,t),evalIdentifier(e,t){if(Object.hasOwn(t,e.name))return t[e.name];throw new ReferenceError(`${e.name} is not defined`)},evalLiteral:e=>e.value,evalMemberExpression(e,t){const r=String(e.computed?f.evalAst(e.property,t):e.property.name),s=f.evalAst(e.object,t),n=p(s,r);return"function"==typeof n?n.bind(s):n},evalUnaryExpression(e,t){if(!Object.hasOwn(d,e.operator))throw new SyntaxError(`Unknown unary operator: ${e.operator}`);const r=f.evalAst(e.argument,t);return d[e.operator](r)},evalArrayExpression:(e,t)=>e.elements.map(e=>f.evalAst(e,t)),evalCallExpression(e,t){const r=e.arguments.map(e=>f.evalAst(e,t)),s=f.evalAst(e.callee,t);if(c(s)||r.some(e=>c(e)))throw new Error("Function constructor is disabled");return s(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw new SyntaxError("Invalid left-hand side in assignment");const r=e.left.name,s=f.evalAst(e.right,t);return t[r]=s,t[r]}};const b=new Map,y=new Map;function E(e,t){return(e=e.slice()).push(t),e}function g(e,t){return(t=t.slice()).unshift(e),t}function x(e,t,r,s,n){try{return e&&"object"==typeof e?new _(e):new _(e,t,r,s,n)}catch(e){if(new.target)throw e;if(e&&"object"==typeof e&&"value"in e)return e.value;throw e}}class _{constructor(e,t,r,s,n){"string"==typeof e&&(n=s,s=r,r=t,t=e,e=null);const i=e&&"object"==typeof e;if(e||={},this.currResultType=void 0,this.currEval=void 0,this.currOtherTypeCallback=void 0,this.currCustomTypes=void 0,this.currSandbox=void 0,this._hasParentSelector=!1,this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=Object.hasOwn(e,"flatten")&&e.flatten,this.wrap=!Object.hasOwn(e,"wrap")||e.wrap,this.sandbox=e.sandbox||{},this.eval=void 0===e.eval?"safe":e.eval,this.ignoreEvalErrors=void 0!==e.ignoreEvalErrors&&e.ignoreEvalErrors,this.parent=Object.hasOwn(e,"parent")?e.parent:null,this.parentProperty=Object.hasOwn(e,"parentProperty")?e.parentProperty:null,this.callback=e.callback||s||null,this.otherTypeCallback=e.otherTypeCallback||n||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},this.customTypes=e.customTypes||{},!1===e.autostart)return;const o={path:i?e.path:t};i||void 0===r?"json"in e&&(o.json=e.json):o.json=r;const a=this.evaluate(o);if(!a||"object"!=typeof a){const e=new Error('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');throw e.value=a,e}return a}evaluate(e,t,r,s){let n=this.parent,i=this.parentProperty,{flatten:o,wrap:a}=this;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r||=this.callback,this.currOtherTypeCallback=s||this.otherTypeCallback,this.currCustomTypes=this.customTypes,e&&"object"==typeof e&&!Array.isArray(e)){const s=e;if(!s.path&&""!==s.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(s,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=s),o=Object.hasOwn(s,"flatten")?s.flatten:o,this.currResultType=Object.hasOwn(s,"resultType")?s.resultType:this.currResultType,this.currSandbox=Object.hasOwn(s,"sandbox")?s.sandbox:this.currSandbox,a=Object.hasOwn(s,"wrap")?s.wrap:a,this.currEval=Object.hasOwn(s,"eval")?s.eval:this.currEval,r=Object.hasOwn(s,"callback")?s.callback:r,this.currOtherTypeCallback=Object.hasOwn(s,"otherTypeCallback")?s.otherTypeCallback:this.currOtherTypeCallback,this.currCustomTypes=Object.hasOwn(s,"customTypes")?s.customTypes:this.currCustomTypes,n=Object.hasOwn(s,"parent")?s.parent:n,i=Object.hasOwn(s,"parentProperty")?s.parentProperty:i,e=s.path}else t||=this.json,e||=this.path;if(n||=null,i||=null,Array.isArray(e)&&(e=x.toPathString(e)),!t||!e&&""!==e)return;const h=x.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=!1;const l=this._trace(h,t,["$"],n,i,r??void 0,void 0),c=(Array.isArray(l)?l:[l]).filter(e=>e&&!e.isParentSelector);if(!c.length)return a?[]:void 0;if(!a&&1===c.length&&!c[0].hasArrExpr){return this._getPreferredOutput(c[0])}return c.reduce((e,t)=>{const r=this._getPreferredOutput(t);return o&&Array.isArray(r)?e=e.concat(r):e.push(r),e},[])}_getPreferredOutput(e){const t=this.currResultType;switch(t){case"all":{const t=Array.isArray(e.path)?e.path:x.toPathArray(e.path);return e.pointer=x.toPointer(t),e.path="string"==typeof e.path?e.path:x.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return"string"==typeof e.path?e.path:x.toPathString(e.path);case"pointer":{const t=Array.isArray(e.path)?e.path:x.toPathArray(e.path);return x.toPointer(t)}default:throw new TypeError("Unknown result type")}}_handleCallback(e,t,r){if(!t)return;const s=this._getPreferredOutput(e);Array.isArray(e.path)&&(e.path=x.toPathString(e.path)),t(s,r,e)}_trace(e,t,r,s,n,i,o,a){let h;if(!e.length)return h={path:r,value:t,parent:s,parentProperty:n,hasArrExpr:o},this._handleCallback(h,i,"value"),h;const l=e[0],c=e.slice(1),u=[];function d(e){Array.isArray(e)?e.forEach(e=>{u.push(e)}):u.push(e)}if(t&&("string"!=typeof l||a)&&Object.hasOwn(t,l)){const e=t;d(this._trace(c,e[l],E(r,l),t,l,i,o))}else if("*"===l)this._walk(t,e=>{const s=t;d(this._trace(c,s[e],E(r,e),t,e,i,!0,!0))});else if(".."===l)d(this._trace(c,t,r,s,n,i,o)),this._walk(t,s=>{const n=t;"object"==typeof n[s]&&d(this._trace(e.slice(),n[s],E(r,s),t,s,i,!0))});else{if("^"===l)return this._hasParentSelector=!0,{path:r.slice(0,-1),expr:c,isParentSelector:!0,value:void 0,parent:void 0,parentProperty:null};if("~"===l)return h={path:E(r,l),value:n,parent:s,parentProperty:null},this._handleCallback(h,i,"property"),h;if("$"===l)d(this._trace(c,t,r,null,null,i,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/v.test(l)){const e=this._slice(l,c,t,r,s,n,i);e&&d(e)}else if(0===l.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=l.replace(/^\?\((.*?)\)$/v,"$1"),o=/@.?([^?]*)[\['](\??\(.*?\))(?!.\)\])[\]']/gv.exec(e);if(o)this._walk(t,e=>{const a=[o[2]],h=t,l=o[1]?p(h[e],o[1]):h[e],u=this._trace(a,l,r,s,n,i,!0);(Array.isArray(u)?u:[u]).length>0&&d(this._trace(c,h[e],E(r,e),t,e,i,!0))});else{const o=t;this._walk(t,a=>{this._eval(e,o[a],a,r,s,n)&&d(this._trace(c,o[a],E(r,a),t,a,i,!0))})}}else if("("===l[0]){if(!1===this.currEval)throw new Error("Eval [(expr)] prevented in JSONPath expression.");const e=this._eval(l,t,r.at(-1),r.slice(0,-1),s,n),a=void 0!==e?e:"";d(this._trace(g(a,c),t,r,s,n,i,o))}else if("@"===l[0]){let e=!1;const o=l.indexOf("("),a=l.slice(1,o),c=l.lastIndexOf(")"),p=l.slice(o+1,c),u=p?JSON.parse(p):void 0;switch(a){case"scalar":e=!t||!["object","function"].includes(typeof t);break;case"boolean":case"string":case"undefined":case"function":e=typeof t===a;break;case"integer":e=Number.isFinite(t)&&!(t%1);break;case"number":e=Number.isFinite(t);break;case"nonFinite":e="number"==typeof t&&!Number.isFinite(t);break;case"object":e=Boolean(t)&&typeof t===a;break;case"array":e=Array.isArray(t);break;case"other":e=this.currOtherTypeCallback(t,r,s,n,u)||!1;break;case"null":e=null===t;break;case"symbol":e="symbol"==typeof t;break;case"BigInt":e="bigint"==typeof t;break;case"Promise":e="Promise"===(e=>Object.prototype.toString.call(e).slice(8,-1))(t);break;case"jsonReference":e=Boolean(t)&&"object"==typeof t&&Object.hasOwn(t,"$ref");break;default:if(!this.currCustomTypes||!Object.hasOwn(this.currCustomTypes,a))throw new TypeError("Unknown value type "+a);e=this.currCustomTypes[a](t,r,s,n,u)||!1}if(e)return h={path:r,value:t,parent:s,parentProperty:n},this._handleCallback(h,i,"value"),h}else if(t&&"`"===l[0]&&Object.hasOwn(t,l.slice(1))){const e=l.slice(1),s=t;d(this._trace(c,s[e],E(r,e),t,e,i,o,!0))}else if("'"===l[0]||'"'===l[0])for(const[,e,s]of l.matchAll(/'((?:\\.|[^'\\])*)'|"((?:\\.|[^"\\])*)"/gv)){const n=(e??s).replaceAll(/\\(['"\\])/gv,"$1");if(!t||!Object.hasOwn(t,n))continue;const o=t;d(this._trace(c,o[n],E(r,n),t,n,i,!0))}else if(l.includes(",")){const e=l.split(",");for(const o of e)d(this._trace(g(o,c),t,r,s,n,i,!0))}else if(!a&&t&&Object.hasOwn(t,l)){const e=t;d(this._trace(c,e[l],E(r,l),t,l,i,o,!0))}}if(this._hasParentSelector)for(let e=0;e{t(e)})}_slice(e,t,r,s,n,i,o){if(!Array.isArray(r))return;const a=r.length,h=e.split(":"),l=h[2]&&Number(h[2])||1;let c=h[0]&&Number(h[0])||0,p=h[1]?Number(h[1]):a;c=c<0?Math.max(0,c+a):Math.min(a,c),p=p<0?Math.max(0,p+a):Math.min(a,p);const u=[];for(let e=c;e{u.push(e)})}return u}_eval(e,t,r,s,n,i){this.currSandbox&&(this.currSandbox._$_parentProperty=i,this.currSandbox._$_parent=n,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t);const o=e.includes("@path");if(o){(this.currSandbox??{})._$_path=x.toPathString(s.concat([r]))}const a=this.currEval+"Script:"+e;if(!b.has(a)){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/('(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|(?<=(?:^|[\(,=:\[!\|?\{\};+\-*%<>~^]|&)\s*)\/(?:\\.|\[(?:\\.|[^\]\\])*\]|[^\/\\\[])+\/[dgimsuvy]*)|@(?![\w$])/gv,(e,t)=>t??"_$_v");o&&(t=t.replaceAll("@path","_$_path"));const r=this.currEval;if(["safe",!0,void 0].includes(r))b.set(a,new this.safeVm.Script(t));else if("native"===this.currEval)b.set(a,new this.vm.Script(t));else if("function"==typeof this.currEval&&this.currEval.prototype&&Object.hasOwn(this.currEval.prototype,"runInNewContext")){const e=this.currEval;b.set(a,new e(t))}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);{const e=this.currEval;b.set(a,{runInNewContext:r=>e(t,r)})}}}try{return b.get(a).runInNewContext(this.currSandbox)}catch(t){if(this.ignoreEvalErrors)return!1;throw new Error("jsonPath: "+t.message+": "+e,{cause:t})}}}_.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=s(this.code)}runInNewContext(e){const t=Object.assign(Object.create(null),e);return f.evalAst(this.ast,t)}}},x.prototype=_.prototype,x.clearCache=function(){y.clear(),b.clear()},x.toPathString=function(e){const t=e,r=t.length;let s="$";for(let e=1;e"function"==typeof e[t]);const n=r.map(t=>e[t]);t=s.reduce((t,r)=>{let s=e[r].toString();return/function/v.test(s)||(s="function "+s),"var "+r+"="+s+";"+t},"")+t,/(['"])use strict\1/v.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/v,"");const i=t.lastIndexOf(";"),o=-1!==i?t.slice(0,i+1)+" return "+t.slice(i+1):" return "+t;return new Function(...r,o)(...n)}}_.prototype.vm={Script:O},e.JSONPath=x,e.JSONPathClass=_,e.Script=O}); //# sourceMappingURL=index-browser-umd.min.cjs.map diff --git a/dist/index-browser-umd.min.cjs.map b/dist/index-browser-umd.min.cjs.map index e12eed7..8405680 100644 --- a/dist/index-browser-umd.min.cjs.map +++ b/dist/index-browser-umd.min.cjs.map @@ -1 +1 @@ -{"version":3,"file":"index-browser-umd.min.cjs","sources":["../node_modules/.pnpm/jsep@1.4.0/node_modules/jsep/dist/jsep.js","../node_modules/.pnpm/@jsep-plugin+regex@1.0.4_jsep@1.4.0/node_modules/@jsep-plugin/regex/dist/index.js","../node_modules/.pnpm/@jsep-plugin+assignment@1.3.0_jsep@1.4.0/node_modules/@jsep-plugin/assignment/dist/index.js","../src/Safe-Script.js","../src/utils.js","../src/jsonpath.js","../src/jsonpath-browser.js"],"sourcesContent":["/**\n * @implements {IHooks}\n */\nclass Hooks {\n\t/**\n\t * @callback HookCallback\n\t * @this {*|Jsep} this\n\t * @param {Jsep} env\n\t * @returns: void\n\t */\n\t/**\n\t * Adds the given callback to the list of callbacks for the given hook.\n\t *\n\t * The callback will be invoked when the hook it is registered for is run.\n\t *\n\t * One callback function can be registered to multiple hooks and the same hook multiple times.\n\t *\n\t * @param {string|object} name The name of the hook, or an object of callbacks keyed by name\n\t * @param {HookCallback|boolean} callback The callback function which is given environment variables.\n\t * @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)\n\t * @public\n\t */\n\tadd(name, callback, first) {\n\t\tif (typeof arguments[0] != 'string') {\n\t\t\t// Multiple hook callbacks, keyed by name\n\t\t\tfor (let name in arguments[0]) {\n\t\t\t\tthis.add(name, arguments[0][name], arguments[1]);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t(Array.isArray(name) ? name : [name]).forEach(function (name) {\n\t\t\t\tthis[name] = this[name] || [];\n\n\t\t\t\tif (callback) {\n\t\t\t\t\tthis[name][first ? 'unshift' : 'push'](callback);\n\t\t\t\t}\n\t\t\t}, this);\n\t\t}\n\t}\n\n\t/**\n\t * Runs a hook invoking all registered callbacks with the given environment variables.\n\t *\n\t * Callbacks will be invoked synchronously and in the order in which they were registered.\n\t *\n\t * @param {string} name The name of the hook.\n\t * @param {Object} env The environment variables of the hook passed to all callbacks registered.\n\t * @public\n\t */\n\trun(name, env) {\n\t\tthis[name] = this[name] || [];\n\t\tthis[name].forEach(function (callback) {\n\t\t\tcallback.call(env && env.context ? env.context : env, env);\n\t\t});\n\t}\n}\n\n/**\n * @implements {IPlugins}\n */\nclass Plugins {\n\tconstructor(jsep) {\n\t\tthis.jsep = jsep;\n\t\tthis.registered = {};\n\t}\n\n\t/**\n\t * @callback PluginSetup\n\t * @this {Jsep} jsep\n\t * @returns: void\n\t */\n\t/**\n\t * Adds the given plugin(s) to the registry\n\t *\n\t * @param {object} plugins\n\t * @param {string} plugins.name The name of the plugin\n\t * @param {PluginSetup} plugins.init The init function\n\t * @public\n\t */\n\tregister(...plugins) {\n\t\tplugins.forEach((plugin) => {\n\t\t\tif (typeof plugin !== 'object' || !plugin.name || !plugin.init) {\n\t\t\t\tthrow new Error('Invalid JSEP plugin format');\n\t\t\t}\n\t\t\tif (this.registered[plugin.name]) {\n\t\t\t\t// already registered. Ignore.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tplugin.init(this.jsep);\n\t\t\tthis.registered[plugin.name] = plugin;\n\t\t});\n\t}\n}\n\n// JavaScript Expression Parser (JSEP) 1.4.0\n\nclass Jsep {\n\t/**\n\t * @returns {string}\n\t */\n\tstatic get version() {\n\t\t// To be filled in by the template\n\t\treturn '1.4.0';\n\t}\n\n\t/**\n\t * @returns {string}\n\t */\n\tstatic toString() {\n\t\treturn 'JavaScript Expression Parser (JSEP) v' + Jsep.version;\n\t};\n\n\t// ==================== CONFIG ================================\n\t/**\n\t * @method addUnaryOp\n\t * @param {string} op_name The name of the unary op to add\n\t * @returns {Jsep}\n\t */\n\tstatic addUnaryOp(op_name) {\n\t\tJsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);\n\t\tJsep.unary_ops[op_name] = 1;\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method jsep.addBinaryOp\n\t * @param {string} op_name The name of the binary op to add\n\t * @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence\n\t * @param {boolean} [isRightAssociative=false] whether operator is right-associative\n\t * @returns {Jsep}\n\t */\n\tstatic addBinaryOp(op_name, precedence, isRightAssociative) {\n\t\tJsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);\n\t\tJsep.binary_ops[op_name] = precedence;\n\t\tif (isRightAssociative) {\n\t\t\tJsep.right_associative.add(op_name);\n\t\t}\n\t\telse {\n\t\t\tJsep.right_associative.delete(op_name);\n\t\t}\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method addIdentifierChar\n\t * @param {string} char The additional character to treat as a valid part of an identifier\n\t * @returns {Jsep}\n\t */\n\tstatic addIdentifierChar(char) {\n\t\tJsep.additional_identifier_chars.add(char);\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method addLiteral\n\t * @param {string} literal_name The name of the literal to add\n\t * @param {*} literal_value The value of the literal\n\t * @returns {Jsep}\n\t */\n\tstatic addLiteral(literal_name, literal_value) {\n\t\tJsep.literals[literal_name] = literal_value;\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeUnaryOp\n\t * @param {string} op_name The name of the unary op to remove\n\t * @returns {Jsep}\n\t */\n\tstatic removeUnaryOp(op_name) {\n\t\tdelete Jsep.unary_ops[op_name];\n\t\tif (op_name.length === Jsep.max_unop_len) {\n\t\t\tJsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);\n\t\t}\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeAllUnaryOps\n\t * @returns {Jsep}\n\t */\n\tstatic removeAllUnaryOps() {\n\t\tJsep.unary_ops = {};\n\t\tJsep.max_unop_len = 0;\n\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeIdentifierChar\n\t * @param {string} char The additional character to stop treating as a valid part of an identifier\n\t * @returns {Jsep}\n\t */\n\tstatic removeIdentifierChar(char) {\n\t\tJsep.additional_identifier_chars.delete(char);\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeBinaryOp\n\t * @param {string} op_name The name of the binary op to remove\n\t * @returns {Jsep}\n\t */\n\tstatic removeBinaryOp(op_name) {\n\t\tdelete Jsep.binary_ops[op_name];\n\n\t\tif (op_name.length === Jsep.max_binop_len) {\n\t\t\tJsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);\n\t\t}\n\t\tJsep.right_associative.delete(op_name);\n\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeAllBinaryOps\n\t * @returns {Jsep}\n\t */\n\tstatic removeAllBinaryOps() {\n\t\tJsep.binary_ops = {};\n\t\tJsep.max_binop_len = 0;\n\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeLiteral\n\t * @param {string} literal_name The name of the literal to remove\n\t * @returns {Jsep}\n\t */\n\tstatic removeLiteral(literal_name) {\n\t\tdelete Jsep.literals[literal_name];\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeAllLiterals\n\t * @returns {Jsep}\n\t */\n\tstatic removeAllLiterals() {\n\t\tJsep.literals = {};\n\n\t\treturn Jsep;\n\t}\n\t// ==================== END CONFIG ============================\n\n\n\t/**\n\t * @returns {string}\n\t */\n\tget char() {\n\t\treturn this.expr.charAt(this.index);\n\t}\n\n\t/**\n\t * @returns {number}\n\t */\n\tget code() {\n\t\treturn this.expr.charCodeAt(this.index);\n\t};\n\n\n\t/**\n\t * @param {string} expr a string with the passed in express\n\t * @returns Jsep\n\t */\n\tconstructor(expr) {\n\t\t// `index` stores the character number we are currently at\n\t\t// All of the gobbles below will modify `index` as we move along\n\t\tthis.expr = expr;\n\t\tthis.index = 0;\n\t}\n\n\t/**\n\t * static top-level parser\n\t * @returns {jsep.Expression}\n\t */\n\tstatic parse(expr) {\n\t\treturn (new Jsep(expr)).parse();\n\t}\n\n\t/**\n\t * Get the longest key length of any object\n\t * @param {object} obj\n\t * @returns {number}\n\t */\n\tstatic getMaxKeyLen(obj) {\n\t\treturn Math.max(0, ...Object.keys(obj).map(k => k.length));\n\t}\n\n\t/**\n\t * `ch` is a character code in the next three functions\n\t * @param {number} ch\n\t * @returns {boolean}\n\t */\n\tstatic isDecimalDigit(ch) {\n\t\treturn (ch >= 48 && ch <= 57); // 0...9\n\t}\n\n\t/**\n\t * Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.\n\t * @param {string} op_val\n\t * @returns {number}\n\t */\n\tstatic binaryPrecedence(op_val) {\n\t\treturn Jsep.binary_ops[op_val] || 0;\n\t}\n\n\t/**\n\t * Looks for start of identifier\n\t * @param {number} ch\n\t * @returns {boolean}\n\t */\n\tstatic isIdentifierStart(ch) {\n\t\treturn (ch >= 65 && ch <= 90) || // A...Z\n\t\t\t(ch >= 97 && ch <= 122) || // a...z\n\t\t\t(ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)]) || // any non-ASCII that is not an operator\n\t\t\t(Jsep.additional_identifier_chars.has(String.fromCharCode(ch))); // additional characters\n\t}\n\n\t/**\n\t * @param {number} ch\n\t * @returns {boolean}\n\t */\n\tstatic isIdentifierPart(ch) {\n\t\treturn Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);\n\t}\n\n\t/**\n\t * throw error at index of the expression\n\t * @param {string} message\n\t * @throws\n\t */\n\tthrowError(message) {\n\t\tconst error = new Error(message + ' at character ' + this.index);\n\t\terror.index = this.index;\n\t\terror.description = message;\n\t\tthrow error;\n\t}\n\n\t/**\n\t * Run a given hook\n\t * @param {string} name\n\t * @param {jsep.Expression|false} [node]\n\t * @returns {?jsep.Expression}\n\t */\n\trunHook(name, node) {\n\t\tif (Jsep.hooks[name]) {\n\t\t\tconst env = { context: this, node };\n\t\t\tJsep.hooks.run(name, env);\n\t\t\treturn env.node;\n\t\t}\n\t\treturn node;\n\t}\n\n\t/**\n\t * Runs a given hook until one returns a node\n\t * @param {string} name\n\t * @returns {?jsep.Expression}\n\t */\n\tsearchHook(name) {\n\t\tif (Jsep.hooks[name]) {\n\t\t\tconst env = { context: this };\n\t\t\tJsep.hooks[name].find(function (callback) {\n\t\t\t\tcallback.call(env.context, env);\n\t\t\t\treturn env.node;\n\t\t\t});\n\t\t\treturn env.node;\n\t\t}\n\t}\n\n\t/**\n\t * Push `index` up to the next non-space character\n\t */\n\tgobbleSpaces() {\n\t\tlet ch = this.code;\n\t\t// Whitespace\n\t\twhile (ch === Jsep.SPACE_CODE\n\t\t|| ch === Jsep.TAB_CODE\n\t\t|| ch === Jsep.LF_CODE\n\t\t|| ch === Jsep.CR_CODE) {\n\t\t\tch = this.expr.charCodeAt(++this.index);\n\t\t}\n\t\tthis.runHook('gobble-spaces');\n\t}\n\n\t/**\n\t * Top-level method to parse all expressions and returns compound or single node\n\t * @returns {jsep.Expression}\n\t */\n\tparse() {\n\t\tthis.runHook('before-all');\n\t\tconst nodes = this.gobbleExpressions();\n\n\t\t// If there's only one expression just try returning the expression\n\t\tconst node = nodes.length === 1\n\t\t ? nodes[0]\n\t\t\t: {\n\t\t\t\ttype: Jsep.COMPOUND,\n\t\t\t\tbody: nodes\n\t\t\t};\n\t\treturn this.runHook('after-all', node);\n\t}\n\n\t/**\n\t * top-level parser (but can be reused within as well)\n\t * @param {number} [untilICode]\n\t * @returns {jsep.Expression[]}\n\t */\n\tgobbleExpressions(untilICode) {\n\t\tlet nodes = [], ch_i, node;\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tch_i = this.code;\n\n\t\t\t// Expressions can be separated by semicolons, commas, or just inferred without any\n\t\t\t// separators\n\t\t\tif (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {\n\t\t\t\tthis.index++; // ignore separators\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Try to gobble each expression individually\n\t\t\t\tif (node = this.gobbleExpression()) {\n\t\t\t\t\tnodes.push(node);\n\t\t\t\t\t// If we weren't able to find a binary expression and are out of room, then\n\t\t\t\t\t// the expression passed in probably has too much\n\t\t\t\t}\n\t\t\t\telse if (this.index < this.expr.length) {\n\t\t\t\t\tif (ch_i === untilICode) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tthis.throwError('Unexpected \"' + this.char + '\"');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn nodes;\n\t}\n\n\t/**\n\t * The main parsing function.\n\t * @returns {?jsep.Expression}\n\t */\n\tgobbleExpression() {\n\t\tconst node = this.searchHook('gobble-expression') || this.gobbleBinaryExpression();\n\t\tthis.gobbleSpaces();\n\n\t\treturn this.runHook('after-expression', node);\n\t}\n\n\t/**\n\t * Search for the operation portion of the string (e.g. `+`, `===`)\n\t * Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)\n\t * and move down from 3 to 2 to 1 character until a matching binary operation is found\n\t * then, return that binary operation\n\t * @returns {string|boolean}\n\t */\n\tgobbleBinaryOp() {\n\t\tthis.gobbleSpaces();\n\t\tlet to_check = this.expr.substr(this.index, Jsep.max_binop_len);\n\t\tlet tc_len = to_check.length;\n\n\t\twhile (tc_len > 0) {\n\t\t\t// Don't accept a binary op when it is an identifier.\n\t\t\t// Binary ops that start with a identifier-valid character must be followed\n\t\t\t// by a non identifier-part valid character\n\t\t\tif (Jsep.binary_ops.hasOwnProperty(to_check) && (\n\t\t\t\t!Jsep.isIdentifierStart(this.code) ||\n\t\t\t\t(this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))\n\t\t\t)) {\n\t\t\t\tthis.index += tc_len;\n\t\t\t\treturn to_check;\n\t\t\t}\n\t\t\tto_check = to_check.substr(0, --tc_len);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * This function is responsible for gobbling an individual expression,\n\t * e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`\n\t * @returns {?jsep.BinaryExpression}\n\t */\n\tgobbleBinaryExpression() {\n\t\tlet node, biop, prec, stack, biop_info, left, right, i, cur_biop;\n\n\t\t// First, try to get the leftmost thing\n\t\t// Then, check to see if there's a binary operator operating on that leftmost thing\n\t\t// Don't gobbleBinaryOp without a left-hand-side\n\t\tleft = this.gobbleToken();\n\t\tif (!left) {\n\t\t\treturn left;\n\t\t}\n\t\tbiop = this.gobbleBinaryOp();\n\n\t\t// If there wasn't a binary operator, just return the leftmost node\n\t\tif (!biop) {\n\t\t\treturn left;\n\t\t}\n\n\t\t// Otherwise, we need to start a stack to properly place the binary operations in their\n\t\t// precedence structure\n\t\tbiop_info = { value: biop, prec: Jsep.binaryPrecedence(biop), right_a: Jsep.right_associative.has(biop) };\n\n\t\tright = this.gobbleToken();\n\n\t\tif (!right) {\n\t\t\tthis.throwError(\"Expected expression after \" + biop);\n\t\t}\n\n\t\tstack = [left, biop_info, right];\n\n\t\t// Properly deal with precedence using [recursive descent](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm)\n\t\twhile ((biop = this.gobbleBinaryOp())) {\n\t\t\tprec = Jsep.binaryPrecedence(biop);\n\n\t\t\tif (prec === 0) {\n\t\t\t\tthis.index -= biop.length;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tbiop_info = { value: biop, prec, right_a: Jsep.right_associative.has(biop) };\n\n\t\t\tcur_biop = biop;\n\n\t\t\t// Reduce: make a binary expression from the three topmost entries.\n\t\t\tconst comparePrev = prev => biop_info.right_a && prev.right_a\n\t\t\t\t? prec > prev.prec\n\t\t\t\t: prec <= prev.prec;\n\t\t\twhile ((stack.length > 2) && comparePrev(stack[stack.length - 2])) {\n\t\t\t\tright = stack.pop();\n\t\t\t\tbiop = stack.pop().value;\n\t\t\t\tleft = stack.pop();\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.BINARY_EXP,\n\t\t\t\t\toperator: biop,\n\t\t\t\t\tleft,\n\t\t\t\t\tright\n\t\t\t\t};\n\t\t\t\tstack.push(node);\n\t\t\t}\n\n\t\t\tnode = this.gobbleToken();\n\n\t\t\tif (!node) {\n\t\t\t\tthis.throwError(\"Expected expression after \" + cur_biop);\n\t\t\t}\n\n\t\t\tstack.push(biop_info, node);\n\t\t}\n\n\t\ti = stack.length - 1;\n\t\tnode = stack[i];\n\n\t\twhile (i > 1) {\n\t\t\tnode = {\n\t\t\t\ttype: Jsep.BINARY_EXP,\n\t\t\t\toperator: stack[i - 1].value,\n\t\t\t\tleft: stack[i - 2],\n\t\t\t\tright: node\n\t\t\t};\n\t\t\ti -= 2;\n\t\t}\n\n\t\treturn node;\n\t}\n\n\t/**\n\t * An individual part of a binary expression:\n\t * e.g. `foo.bar(baz)`, `1`, `\"abc\"`, `(a % 2)` (because it's in parenthesis)\n\t * @returns {boolean|jsep.Expression}\n\t */\n\tgobbleToken() {\n\t\tlet ch, to_check, tc_len, node;\n\n\t\tthis.gobbleSpaces();\n\t\tnode = this.searchHook('gobble-token');\n\t\tif (node) {\n\t\t\treturn this.runHook('after-token', node);\n\t\t}\n\n\t\tch = this.code;\n\n\t\tif (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {\n\t\t\t// Char code 46 is a dot `.` which can start off a numeric literal\n\t\t\treturn this.gobbleNumericLiteral();\n\t\t}\n\n\t\tif (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {\n\t\t\t// Single or double quotes\n\t\t\tnode = this.gobbleStringLiteral();\n\t\t}\n\t\telse if (ch === Jsep.OBRACK_CODE) {\n\t\t\tnode = this.gobbleArray();\n\t\t}\n\t\telse {\n\t\t\tto_check = this.expr.substr(this.index, Jsep.max_unop_len);\n\t\t\ttc_len = to_check.length;\n\n\t\t\twhile (tc_len > 0) {\n\t\t\t\t// Don't accept an unary op when it is an identifier.\n\t\t\t\t// Unary ops that start with a identifier-valid character must be followed\n\t\t\t\t// by a non identifier-part valid character\n\t\t\t\tif (Jsep.unary_ops.hasOwnProperty(to_check) && (\n\t\t\t\t\t!Jsep.isIdentifierStart(this.code) ||\n\t\t\t\t\t(this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))\n\t\t\t\t)) {\n\t\t\t\t\tthis.index += tc_len;\n\t\t\t\t\tconst argument = this.gobbleToken();\n\t\t\t\t\tif (!argument) {\n\t\t\t\t\t\tthis.throwError('missing unaryOp argument');\n\t\t\t\t\t}\n\t\t\t\t\treturn this.runHook('after-token', {\n\t\t\t\t\t\ttype: Jsep.UNARY_EXP,\n\t\t\t\t\t\toperator: to_check,\n\t\t\t\t\t\targument,\n\t\t\t\t\t\tprefix: true\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tto_check = to_check.substr(0, --tc_len);\n\t\t\t}\n\n\t\t\tif (Jsep.isIdentifierStart(ch)) {\n\t\t\t\tnode = this.gobbleIdentifier();\n\t\t\t\tif (Jsep.literals.hasOwnProperty(node.name)) {\n\t\t\t\t\tnode = {\n\t\t\t\t\t\ttype: Jsep.LITERAL,\n\t\t\t\t\t\tvalue: Jsep.literals[node.name],\n\t\t\t\t\t\traw: node.name,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (node.name === Jsep.this_str) {\n\t\t\t\t\tnode = { type: Jsep.THIS_EXP };\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (ch === Jsep.OPAREN_CODE) { // open parenthesis\n\t\t\t\tnode = this.gobbleGroup();\n\t\t\t}\n\t\t}\n\n\t\tif (!node) {\n\t\t\treturn this.runHook('after-token', false);\n\t\t}\n\n\t\tnode = this.gobbleTokenProperty(node);\n\t\treturn this.runHook('after-token', node);\n\t}\n\n\t/**\n\t * Gobble properties of of identifiers/strings/arrays/groups.\n\t * e.g. `foo`, `bar.baz`, `foo['bar'].baz`\n\t * It also gobbles function calls:\n\t * e.g. `Math.acos(obj.angle)`\n\t * @param {jsep.Expression} node\n\t * @returns {jsep.Expression}\n\t */\n\tgobbleTokenProperty(node) {\n\t\tthis.gobbleSpaces();\n\n\t\tlet ch = this.code;\n\t\twhile (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {\n\t\t\tlet optional;\n\t\t\tif (ch === Jsep.QUMARK_CODE) {\n\t\t\t\tif (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\toptional = true;\n\t\t\t\tthis.index += 2;\n\t\t\t\tthis.gobbleSpaces();\n\t\t\t\tch = this.code;\n\t\t\t}\n\t\t\tthis.index++;\n\n\t\t\tif (ch === Jsep.OBRACK_CODE) {\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.MEMBER_EXP,\n\t\t\t\t\tcomputed: true,\n\t\t\t\t\tobject: node,\n\t\t\t\t\tproperty: this.gobbleExpression()\n\t\t\t\t};\n\t\t\t\tif (!node.property) {\n\t\t\t\t\tthis.throwError('Unexpected \"' + this.char + '\"');\n\t\t\t\t}\n\t\t\t\tthis.gobbleSpaces();\n\t\t\t\tch = this.code;\n\t\t\t\tif (ch !== Jsep.CBRACK_CODE) {\n\t\t\t\t\tthis.throwError('Unclosed [');\n\t\t\t\t}\n\t\t\t\tthis.index++;\n\t\t\t}\n\t\t\telse if (ch === Jsep.OPAREN_CODE) {\n\t\t\t\t// A function call is being made; gobble all the arguments\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.CALL_EXP,\n\t\t\t\t\t'arguments': this.gobbleArguments(Jsep.CPAREN_CODE),\n\t\t\t\t\tcallee: node\n\t\t\t\t};\n\t\t\t}\n\t\t\telse if (ch === Jsep.PERIOD_CODE || optional) {\n\t\t\t\tif (optional) {\n\t\t\t\t\tthis.index--;\n\t\t\t\t}\n\t\t\t\tthis.gobbleSpaces();\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.MEMBER_EXP,\n\t\t\t\t\tcomputed: false,\n\t\t\t\t\tobject: node,\n\t\t\t\t\tproperty: this.gobbleIdentifier(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (optional) {\n\t\t\t\tnode.optional = true;\n\t\t\t} // else leave undefined for compatibility with esprima\n\n\t\t\tthis.gobbleSpaces();\n\t\t\tch = this.code;\n\t\t}\n\n\t\treturn node;\n\t}\n\n\t/**\n\t * Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to\n\t * keep track of everything in the numeric literal and then calling `parseFloat` on that string\n\t * @returns {jsep.Literal}\n\t */\n\tgobbleNumericLiteral() {\n\t\tlet number = '', ch, chCode;\n\n\t\twhile (Jsep.isDecimalDigit(this.code)) {\n\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t}\n\n\t\tif (this.code === Jsep.PERIOD_CODE) { // can start with a decimal marker\n\t\t\tnumber += this.expr.charAt(this.index++);\n\n\t\t\twhile (Jsep.isDecimalDigit(this.code)) {\n\t\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\t}\n\t\t}\n\n\t\tch = this.char;\n\n\t\tif (ch === 'e' || ch === 'E') { // exponent marker\n\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\tch = this.char;\n\n\t\t\tif (ch === '+' || ch === '-') { // exponent sign\n\t\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\t}\n\n\t\t\twhile (Jsep.isDecimalDigit(this.code)) { // exponent itself\n\t\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\t}\n\n\t\t\tif (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1)) ) {\n\t\t\t\tthis.throwError('Expected exponent (' + number + this.char + ')');\n\t\t\t}\n\t\t}\n\n\t\tchCode = this.code;\n\n\t\t// Check to make sure this isn't a variable name that start with a number (123abc)\n\t\tif (Jsep.isIdentifierStart(chCode)) {\n\t\t\tthis.throwError('Variable names cannot start with a number (' +\n\t\t\t\tnumber + this.char + ')');\n\t\t}\n\t\telse if (chCode === Jsep.PERIOD_CODE || (number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE)) {\n\t\t\tthis.throwError('Unexpected period');\n\t\t}\n\n\t\treturn {\n\t\t\ttype: Jsep.LITERAL,\n\t\t\tvalue: parseFloat(number),\n\t\t\traw: number\n\t\t};\n\t}\n\n\t/**\n\t * Parses a string literal, staring with single or double quotes with basic support for escape codes\n\t * e.g. `\"hello world\"`, `'this is\\nJSEP'`\n\t * @returns {jsep.Literal}\n\t */\n\tgobbleStringLiteral() {\n\t\tlet str = '';\n\t\tconst startIndex = this.index;\n\t\tconst quote = this.expr.charAt(this.index++);\n\t\tlet closed = false;\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tlet ch = this.expr.charAt(this.index++);\n\n\t\t\tif (ch === quote) {\n\t\t\t\tclosed = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (ch === '\\\\') {\n\t\t\t\t// Check for all of the common escape codes\n\t\t\t\tch = this.expr.charAt(this.index++);\n\n\t\t\t\tswitch (ch) {\n\t\t\t\t\tcase 'n': str += '\\n'; break;\n\t\t\t\t\tcase 'r': str += '\\r'; break;\n\t\t\t\t\tcase 't': str += '\\t'; break;\n\t\t\t\t\tcase 'b': str += '\\b'; break;\n\t\t\t\t\tcase 'f': str += '\\f'; break;\n\t\t\t\t\tcase 'v': str += '\\x0B'; break;\n\t\t\t\t\tdefault : str += ch;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tstr += ch;\n\t\t\t}\n\t\t}\n\n\t\tif (!closed) {\n\t\t\tthis.throwError('Unclosed quote after \"' + str + '\"');\n\t\t}\n\n\t\treturn {\n\t\t\ttype: Jsep.LITERAL,\n\t\t\tvalue: str,\n\t\t\traw: this.expr.substring(startIndex, this.index),\n\t\t};\n\t}\n\n\t/**\n\t * Gobbles only identifiers\n\t * e.g.: `foo`, `_value`, `$x1`\n\t * Also, this function checks if that identifier is a literal:\n\t * (e.g. `true`, `false`, `null`) or `this`\n\t * @returns {jsep.Identifier}\n\t */\n\tgobbleIdentifier() {\n\t\tlet ch = this.code, start = this.index;\n\n\t\tif (Jsep.isIdentifierStart(ch)) {\n\t\t\tthis.index++;\n\t\t}\n\t\telse {\n\t\t\tthis.throwError('Unexpected ' + this.char);\n\t\t}\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tch = this.code;\n\n\t\t\tif (Jsep.isIdentifierPart(ch)) {\n\t\t\t\tthis.index++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\ttype: Jsep.IDENTIFIER,\n\t\t\tname: this.expr.slice(start, this.index),\n\t\t};\n\t}\n\n\t/**\n\t * Gobbles a list of arguments within the context of a function call\n\t * or array literal. This function also assumes that the opening character\n\t * `(` or `[` has already been gobbled, and gobbles expressions and commas\n\t * until the terminator character `)` or `]` is encountered.\n\t * e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`\n\t * @param {number} termination\n\t * @returns {jsep.Expression[]}\n\t */\n\tgobbleArguments(termination) {\n\t\tconst args = [];\n\t\tlet closed = false;\n\t\tlet separator_count = 0;\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tthis.gobbleSpaces();\n\t\t\tlet ch_i = this.code;\n\n\t\t\tif (ch_i === termination) { // done parsing\n\t\t\t\tclosed = true;\n\t\t\t\tthis.index++;\n\n\t\t\t\tif (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length){\n\t\t\t\t\tthis.throwError('Unexpected token ' + String.fromCharCode(termination));\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (ch_i === Jsep.COMMA_CODE) { // between expressions\n\t\t\t\tthis.index++;\n\t\t\t\tseparator_count++;\n\n\t\t\t\tif (separator_count !== args.length) { // missing argument\n\t\t\t\t\tif (termination === Jsep.CPAREN_CODE) {\n\t\t\t\t\t\tthis.throwError('Unexpected token ,');\n\t\t\t\t\t}\n\t\t\t\t\telse if (termination === Jsep.CBRACK_CODE) {\n\t\t\t\t\t\tfor (let arg = args.length; arg < separator_count; arg++) {\n\t\t\t\t\t\t\targs.push(null);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (args.length !== separator_count && separator_count !== 0) {\n\t\t\t\t// NOTE: `&& separator_count !== 0` allows for either all commas, or all spaces as arguments\n\t\t\t\tthis.throwError('Expected comma');\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconst node = this.gobbleExpression();\n\n\t\t\t\tif (!node || node.type === Jsep.COMPOUND) {\n\t\t\t\t\tthis.throwError('Expected comma');\n\t\t\t\t}\n\n\t\t\t\targs.push(node);\n\t\t\t}\n\t\t}\n\n\t\tif (!closed) {\n\t\t\tthis.throwError('Expected ' + String.fromCharCode(termination));\n\t\t}\n\n\t\treturn args;\n\t}\n\n\t/**\n\t * Responsible for parsing a group of things within parentheses `()`\n\t * that have no identifier in front (so not a function call)\n\t * This function assumes that it needs to gobble the opening parenthesis\n\t * and then tries to gobble everything within that parenthesis, assuming\n\t * that the next thing it should see is the close parenthesis. If not,\n\t * then the expression probably doesn't have a `)`\n\t * @returns {boolean|jsep.Expression}\n\t */\n\tgobbleGroup() {\n\t\tthis.index++;\n\t\tlet nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);\n\t\tif (this.code === Jsep.CPAREN_CODE) {\n\t\t\tthis.index++;\n\t\t\tif (nodes.length === 1) {\n\t\t\t\treturn nodes[0];\n\t\t\t}\n\t\t\telse if (!nodes.length) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn {\n\t\t\t\t\ttype: Jsep.SEQUENCE_EXP,\n\t\t\t\t\texpressions: nodes,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tthis.throwError('Unclosed (');\n\t\t}\n\t}\n\n\t/**\n\t * Responsible for parsing Array literals `[1, 2, 3]`\n\t * This function assumes that it needs to gobble the opening bracket\n\t * and then tries to gobble the expressions as arguments.\n\t * @returns {jsep.ArrayExpression}\n\t */\n\tgobbleArray() {\n\t\tthis.index++;\n\n\t\treturn {\n\t\t\ttype: Jsep.ARRAY_EXP,\n\t\t\telements: this.gobbleArguments(Jsep.CBRACK_CODE)\n\t\t};\n\t}\n}\n\n// Static fields:\nconst hooks = new Hooks();\nObject.assign(Jsep, {\n\thooks,\n\tplugins: new Plugins(Jsep),\n\n\t// Node Types\n\t// ----------\n\t// This is the full set of types that any JSEP node can be.\n\t// Store them here to save space when minified\n\tCOMPOUND: 'Compound',\n\tSEQUENCE_EXP: 'SequenceExpression',\n\tIDENTIFIER: 'Identifier',\n\tMEMBER_EXP: 'MemberExpression',\n\tLITERAL: 'Literal',\n\tTHIS_EXP: 'ThisExpression',\n\tCALL_EXP: 'CallExpression',\n\tUNARY_EXP: 'UnaryExpression',\n\tBINARY_EXP: 'BinaryExpression',\n\tARRAY_EXP: 'ArrayExpression',\n\n\tTAB_CODE: 9,\n\tLF_CODE: 10,\n\tCR_CODE: 13,\n\tSPACE_CODE: 32,\n\tPERIOD_CODE: 46, // '.'\n\tCOMMA_CODE: 44, // ','\n\tSQUOTE_CODE: 39, // single quote\n\tDQUOTE_CODE: 34, // double quotes\n\tOPAREN_CODE: 40, // (\n\tCPAREN_CODE: 41, // )\n\tOBRACK_CODE: 91, // [\n\tCBRACK_CODE: 93, // ]\n\tQUMARK_CODE: 63, // ?\n\tSEMCOL_CODE: 59, // ;\n\tCOLON_CODE: 58, // :\n\n\n\t// Operations\n\t// ----------\n\t// Use a quickly-accessible map to store all of the unary operators\n\t// Values are set to `1` (it really doesn't matter)\n\tunary_ops: {\n\t\t'-': 1,\n\t\t'!': 1,\n\t\t'~': 1,\n\t\t'+': 1\n\t},\n\n\t// Also use a map for the binary operations but set their values to their\n\t// binary precedence for quick reference (higher number = higher precedence)\n\t// see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)\n\tbinary_ops: {\n\t\t'||': 1, '??': 1,\n\t\t'&&': 2, '|': 3, '^': 4, '&': 5,\n\t\t'==': 6, '!=': 6, '===': 6, '!==': 6,\n\t\t'<': 7, '>': 7, '<=': 7, '>=': 7,\n\t\t'<<': 8, '>>': 8, '>>>': 8,\n\t\t'+': 9, '-': 9,\n\t\t'*': 10, '/': 10, '%': 10,\n\t\t'**': 11,\n\t},\n\n\t// sets specific binary_ops as right-associative\n\tright_associative: new Set(['**']),\n\n\t// Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)\n\tadditional_identifier_chars: new Set(['$', '_']),\n\n\t// Literals\n\t// ----------\n\t// Store the values to return for the various literals we may encounter\n\tliterals: {\n\t\t'true': true,\n\t\t'false': false,\n\t\t'null': null\n\t},\n\n\t// Except for `this`, which is special. This could be changed to something like `'self'` as well\n\tthis_str: 'this',\n});\nJsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);\nJsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);\n\n// Backward Compatibility:\nconst jsep = expr => (new Jsep(expr)).parse();\nconst stdClassProps = Object.getOwnPropertyNames(class Test{});\nObject.getOwnPropertyNames(Jsep)\n\t.filter(prop => !stdClassProps.includes(prop) && jsep[prop] === undefined)\n\t.forEach((m) => {\n\t\tjsep[m] = Jsep[m];\n\t});\njsep.Jsep = Jsep; // allows for const { Jsep } = require('jsep');\n\nconst CONDITIONAL_EXP = 'ConditionalExpression';\n\nvar ternary = {\n\tname: 'ternary',\n\n\tinit(jsep) {\n\t\t// Ternary expression: test ? consequent : alternate\n\t\tjsep.hooks.add('after-expression', function gobbleTernary(env) {\n\t\t\tif (env.node && this.code === jsep.QUMARK_CODE) {\n\t\t\t\tthis.index++;\n\t\t\t\tconst test = env.node;\n\t\t\t\tconst consequent = this.gobbleExpression();\n\n\t\t\t\tif (!consequent) {\n\t\t\t\t\tthis.throwError('Expected expression');\n\t\t\t\t}\n\n\t\t\t\tthis.gobbleSpaces();\n\n\t\t\t\tif (this.code === jsep.COLON_CODE) {\n\t\t\t\t\tthis.index++;\n\t\t\t\t\tconst alternate = this.gobbleExpression();\n\n\t\t\t\t\tif (!alternate) {\n\t\t\t\t\t\tthis.throwError('Expected expression');\n\t\t\t\t\t}\n\t\t\t\t\tenv.node = {\n\t\t\t\t\t\ttype: CONDITIONAL_EXP,\n\t\t\t\t\t\ttest,\n\t\t\t\t\t\tconsequent,\n\t\t\t\t\t\talternate,\n\t\t\t\t\t};\n\n\t\t\t\t\t// check for operators of higher priority than ternary (i.e. assignment)\n\t\t\t\t\t// jsep sets || at 1, and assignment at 0.9, and conditional should be between them\n\t\t\t\t\tif (test.operator && jsep.binary_ops[test.operator] <= 0.9) {\n\t\t\t\t\t\tlet newTest = test;\n\t\t\t\t\t\twhile (newTest.right.operator && jsep.binary_ops[newTest.right.operator] <= 0.9) {\n\t\t\t\t\t\t\tnewTest = newTest.right;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tenv.node.test = newTest.right;\n\t\t\t\t\t\tnewTest.right = env.node;\n\t\t\t\t\t\tenv.node = test;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.throwError('Expected :');\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t},\n};\n\n// Add default plugins:\n\njsep.plugins.register(ternary);\n\nexport { Jsep, jsep as default };\n","const FSLASH_CODE = 47; // '/'\nconst BSLASH_CODE = 92; // '\\\\'\n\nvar index = {\n\tname: 'regex',\n\n\tinit(jsep) {\n\t\t// Regex literal: /abc123/ig\n\t\tjsep.hooks.add('gobble-token', function gobbleRegexLiteral(env) {\n\t\t\tif (this.code === FSLASH_CODE) {\n\t\t\t\tconst patternIndex = ++this.index;\n\n\t\t\t\tlet inCharSet = false;\n\t\t\t\twhile (this.index < this.expr.length) {\n\t\t\t\t\tif (this.code === FSLASH_CODE && !inCharSet) {\n\t\t\t\t\t\tconst pattern = this.expr.slice(patternIndex, this.index);\n\n\t\t\t\t\t\tlet flags = '';\n\t\t\t\t\t\twhile (++this.index < this.expr.length) {\n\t\t\t\t\t\t\tconst code = this.code;\n\t\t\t\t\t\t\tif ((code >= 97 && code <= 122) // a...z\n\t\t\t\t\t\t\t\t|| (code >= 65 && code <= 90) // A...Z\n\t\t\t\t\t\t\t\t|| (code >= 48 && code <= 57)) { // 0-9\n\t\t\t\t\t\t\t\tflags += this.char;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet value;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tvalue = new RegExp(pattern, flags);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\tthis.throwError(e.message);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tenv.node = {\n\t\t\t\t\t\t\ttype: jsep.LITERAL,\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\traw: this.expr.slice(patternIndex - 1, this.index),\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// allow . [] and () after regex: /regex/.test(a)\n\t\t\t\t\t\tenv.node = this.gobbleTokenProperty(env.node);\n\t\t\t\t\t\treturn env.node;\n\t\t\t\t\t}\n\t\t\t\t\tif (this.code === jsep.OBRACK_CODE) {\n\t\t\t\t\t\tinCharSet = true;\n\t\t\t\t\t}\n\t\t\t\t\telse if (inCharSet && this.code === jsep.CBRACK_CODE) {\n\t\t\t\t\t\tinCharSet = false;\n\t\t\t\t\t}\n\t\t\t\t\tthis.index += this.code === BSLASH_CODE ? 2 : 1;\n\t\t\t\t}\n\t\t\t\tthis.throwError('Unclosed Regex');\n\t\t\t}\n\t\t});\n\t},\n};\n\nexport { index as default };\n","const PLUS_CODE = 43; // +\nconst MINUS_CODE = 45; // -\n\nconst plugin = {\n\tname: 'assignment',\n\n\tassignmentOperators: new Set([\n\t\t'=',\n\t\t'*=',\n\t\t'**=',\n\t\t'/=',\n\t\t'%=',\n\t\t'+=',\n\t\t'-=',\n\t\t'<<=',\n\t\t'>>=',\n\t\t'>>>=',\n\t\t'&=',\n\t\t'^=',\n\t\t'|=',\n\t\t'||=',\n\t\t'&&=',\n\t\t'??=',\n\t]),\n\tupdateOperators: [PLUS_CODE, MINUS_CODE],\n\tassignmentPrecedence: 0.9,\n\n\tinit(jsep) {\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\n\t\tplugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence, true));\n\n\t\tjsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) {\n\t\t\tconst code = this.code;\n\t\t\tif (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\n\t\t\t\tthis.index += 2;\n\t\t\t\tenv.node = {\n\t\t\t\t\ttype: 'UpdateExpression',\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\n\t\t\t\t\targument: this.gobbleTokenProperty(this.gobbleIdentifier()),\n\t\t\t\t\tprefix: true,\n\t\t\t\t};\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\n\t\t\tif (env.node) {\n\t\t\t\tconst code = this.code;\n\t\t\t\tif (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\n\t\t\t\t\t}\n\t\t\t\t\tthis.index += 2;\n\t\t\t\t\tenv.node = {\n\t\t\t\t\t\ttype: 'UpdateExpression',\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\n\t\t\t\t\t\targument: env.node,\n\t\t\t\t\t\tprefix: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\n\t\t\tif (env.node) {\n\t\t\t\t// Note: Binaries can be chained in a single expression to respect\n\t\t\t\t// operator precedence (i.e. a = b = 1 + 2 + 3)\n\t\t\t\t// Update all binary assignment nodes in the tree\n\t\t\t\tupdateBinariesToAssignments(env.node);\n\t\t\t}\n\t\t});\n\n\t\tfunction updateBinariesToAssignments(node) {\n\t\t\tif (plugin.assignmentOperators.has(node.operator)) {\n\t\t\t\tnode.type = 'AssignmentExpression';\n\t\t\t\tupdateBinariesToAssignments(node.left);\n\t\t\t\tupdateBinariesToAssignments(node.right);\n\t\t\t}\n\t\t\telse if (!node.operator) {\n\t\t\t\tObject.values(node).forEach((val) => {\n\t\t\t\t\tif (val && typeof val === 'object') {\n\t\t\t\t\t\tupdateBinariesToAssignments(val);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t},\n};\n\nexport { plugin as default };\n","/* eslint-disable unicorn/no-top-level-side-effects -- Temporary? */\n/* eslint-disable no-bitwise -- Convenient */\nimport jsep from 'jsep';\nimport jsepRegex from '@jsep-plugin/regex';\nimport jsepAssignment from '@jsep-plugin/assignment';\n\n/**\n * @import {EvaluatedResult, UnknownResult} from './jsonpath.js';\n */\n\n/**\n * @typedef {any} AssignmentExpression\n */\n\n/**\n * @typedef {any} Substitution\n */\n\n/**\n * @typedef {any} AnyParameter\n */\n\n/**\n * @typedef {Record} Substitutions\n */\n\n// register plugins\njsep.plugins.register(jsepRegex, jsepAssignment);\njsep.addUnaryOp('typeof');\njsep.addUnaryOp('void');\njsep.addLiteral('null', null);\njsep.addLiteral('undefined', undefined);\n\nconst BLOCKED_PROTO_PROPERTIES = new Set([\n 'constructor',\n '__proto__',\n '__defineGetter__',\n '__defineSetter__',\n '__lookupGetter__',\n '__lookupSetter__'\n]);\n\n// Every function-constructor variant, along with the invocation helpers which\n// could otherwise reach them indirectly, e.g., `Function.call(0, 'code')()`,\n// plus whichever BLOCKED_PROTO_PROPERTIES names resolve to an own method on\n// Object.prototype (e.g. `__defineGetter__`) - an own-property access on a\n// shared prototype (`@.prototype.__defineGetter__`) bypasses the\n// inherited-only name check below, so those methods need blocking by value.\n/** @type {WeakSet} */\nconst BLOCKED_FUNCTIONS = new WeakSet([\n Function,\n // eslint-disable-next-line no-empty-function -- Only need the constructor\n function *() {}.constructor,\n // eslint-disable-next-line no-empty-function -- Only need the constructor\n async function () {}.constructor,\n // eslint-disable-next-line no-empty-function -- Only need the constructor\n async function *() {}.constructor,\n Function.prototype.call,\n Function.prototype.apply,\n Function.prototype.bind,\n Reflect.apply,\n Reflect.construct,\n ...[...BLOCKED_PROTO_PROPERTIES]\n .map((name) => Reflect.get(Object.prototype, name))\n .filter((value) => typeof value === 'function')\n]);\n\n/**\n * @param {UnknownResult} value\n * @returns {boolean}\n */\nconst isBlockedFunction = (value) => {\n return typeof value === 'function' && BLOCKED_FUNCTIONS.has(value);\n};\n\n/**\n * Guarded `obj[prop]`, applying the same restrictions as a MemberExpression.\n * @param {UnknownResult} obj\n * @param {string} prop\n * @returns {UnknownResult}\n */\nconst getSafeProperty = (obj, prop) => {\n if (obj === undefined || obj === null) {\n throw new TypeError(\n `Cannot read properties of ${obj} (reading '${prop}')`\n );\n }\n if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {\n throw new TypeError(\n `Cannot read properties of ${obj} (reading '${prop}')`\n );\n }\n const result = /** @type {Record} */ (obj)[prop];\n if (isBlockedFunction(result)) {\n throw new TypeError('Function constructor is disabled');\n }\n return result;\n};\n\n/**\n * @typedef {Record<\n * string,\n * (a: AnyParameter, b: AnyParameter) => UnknownResult\n * >} OperatorTable\n */\n\n// eslint-disable-next-line @stylistic/max-len -- Long\nconst BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */ ({\n '||': (a, b) => a || b(),\n '&&': (a, b) => a && b(),\n '|': (a, b) => a | b(),\n '^': (a, b) => a ^ b(),\n '&': (a, b) => a & b(),\n // eslint-disable-next-line eqeqeq -- API\n '==': (a, b) => a == b(),\n // eslint-disable-next-line eqeqeq -- API\n '!=': (a, b) => a != b(),\n '===': (a, b) => a === b(),\n '!==': (a, b) => a !== b(),\n '<': (a, b) => a < b(),\n '>': (a, b) => a > b(),\n '<=': (a, b) => a <= b(),\n '>=': (a, b) => a >= b(),\n '<<': (a, b) => a << b(),\n '>>': (a, b) => a >> b(),\n '>>>': (a, b) => a >>> b(),\n '+': (a, b) => a + b(),\n '-': (a, b) => a - b(),\n '*': (a, b) => a * b(),\n '/': (a, b) => a / b(),\n '%': (a, b) => a % b()\n}));\n\n/**\n * @typedef {{\n * [key: string]: (a: AnyParameter) => UnknownResult\n * }} UnaryOperatorTable\n */\n\n// eslint-disable-next-line @stylistic/max-len -- Long\nconst UNOPS = Object.assign(Object.create(null), /** @type {UnaryOperatorTable} */ ({\n '-': (a) => -(/** @type {EvaluatedResult} */ (a)),\n '!': (a) => !a,\n '~': (a) => ~(/** @type {EvaluatedResult} */ (a)),\n // eslint-disable-next-line no-implicit-coercion -- API\n '+': (a) => +(/** @type {EvaluatedResult} */ (a)),\n typeof: (a) => typeof a,\n void: () => undefined\n}));\n\nconst SafeEval = {\n /**\n * @param {jsep.Expression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalAst (ast, subs) {\n switch (ast.type) {\n case 'BinaryExpression':\n case 'LogicalExpression':\n return SafeEval.evalBinaryExpression(\n /** @type {jsep.BinaryExpression} */ (ast),\n subs\n );\n case 'Compound':\n return SafeEval.evalCompound(\n /** @type {jsep.Compound} */ (ast),\n subs\n );\n case 'ConditionalExpression':\n return SafeEval.evalConditionalExpression(\n /** @type {jsep.ConditionalExpression} */ (ast),\n subs\n );\n case 'Identifier':\n return SafeEval.evalIdentifier(\n /** @type {jsep.Identifier} */ (ast),\n subs\n );\n case 'Literal':\n return SafeEval.evalLiteral(/** @type {jsep.Literal} */ (ast));\n case 'MemberExpression':\n return SafeEval.evalMemberExpression(\n /** @type {jsep.MemberExpression} */ (ast),\n subs\n );\n case 'UnaryExpression':\n return SafeEval.evalUnaryExpression(\n /** @type {jsep.UnaryExpression} */ (ast),\n subs\n );\n case 'ArrayExpression':\n return SafeEval.evalArrayExpression(\n /** @type {jsep.ArrayExpression} */ (ast),\n subs\n );\n case 'CallExpression':\n return SafeEval.evalCallExpression(\n /** @type {jsep.CallExpression} */ (ast),\n subs\n );\n case 'AssignmentExpression':\n return SafeEval.evalAssignmentExpression(\n /** @type {AssignmentExpression} */ (ast),\n subs\n );\n default:\n throw new SyntaxError('Unexpected expression', {\n cause: ast\n });\n }\n },\n\n /**\n * @param {jsep.BinaryExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalBinaryExpression (ast, subs) {\n /* c8 ignore next 3 -- Defensive guard for malformed ASTs */\n if (!Object.hasOwn(BINOPS, ast.operator)) {\n throw new SyntaxError(`Unknown binary operator: ${ast.operator}`);\n }\n const result = BINOPS[ast.operator](\n SafeEval.evalAst(ast.left, subs),\n () => SafeEval.evalAst(ast.right, subs)\n );\n return result;\n },\n\n /**\n * @param {jsep.Compound} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalCompound (ast, subs) {\n let last;\n for (let i = 0; i < ast.body.length; i++) {\n if (\n ast.body[i].type === 'Identifier' &&\n ['var', 'let', 'const'].includes(\n /** @type {jsep.Identifier} */\n (ast.body[i]).name\n ) &&\n Object.hasOwn(ast.body, i + 1) &&\n ast.body[i + 1].type === 'AssignmentExpression'\n ) {\n // var x=2; is detected as\n // [{Identifier var}, {AssignmentExpression x=2}]\n i += 1;\n }\n const expr = ast.body[i];\n last = SafeEval.evalAst(expr, subs);\n }\n return last;\n },\n\n /**\n * @param {jsep.ConditionalExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalConditionalExpression (ast, subs) {\n return SafeEval.evalAst(ast.test, subs)\n ? SafeEval.evalAst(ast.consequent, subs)\n : SafeEval.evalAst(ast.alternate, subs);\n },\n\n /**\n * @param {jsep.Identifier} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalIdentifier (ast, subs) {\n if (Object.hasOwn(subs, ast.name)) {\n return subs[ast.name];\n }\n throw new ReferenceError(`${ast.name} is not defined`);\n },\n\n /**\n * @param {jsep.Literal} ast\n * @returns {UnknownResult}\n */\n evalLiteral (ast) {\n return ast.value;\n },\n\n /**\n * @param {jsep.MemberExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalMemberExpression (ast, subs) {\n const prop = String(\n // NOTE: `String(value)` throws error when\n // value has overwritten the toString method to return non-string\n // i.e. `value = {toString: () => []}`\n ast.computed\n ? SafeEval.evalAst(ast.property, subs) // `object[property]`\n : ast.property.name // `object.property` property is Identifier\n );\n const obj = SafeEval.evalAst(ast.object, subs);\n const result = getSafeProperty(obj, prop);\n if (typeof result === 'function') {\n return result.bind(obj); // arrow functions aren't affected by bind.\n }\n return result;\n },\n\n /**\n * @param {jsep.UnaryExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalUnaryExpression (ast, subs) {\n /* c8 ignore next 3 -- Defensive guard for malformed ASTs */\n if (!Object.hasOwn(UNOPS, ast.operator)) {\n throw new SyntaxError(`Unknown unary operator: ${ast.operator}`);\n }\n const operand = SafeEval.evalAst(ast.argument, subs);\n return UNOPS[ast.operator](operand);\n },\n\n /**\n * @param {jsep.ArrayExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalArrayExpression (ast, subs) {\n return ast.elements.map((el) => SafeEval.evalAst(\n /** @type {jsep.Expression} */\n (el),\n subs\n ));\n },\n\n /**\n * @param {jsep.CallExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalCallExpression (ast, subs) {\n const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));\n const func = SafeEval.evalAst(ast.callee, subs);\n if (\n isBlockedFunction(func) ||\n args.some((arg) => isBlockedFunction(arg))\n ) {\n throw new Error('Function constructor is disabled');\n }\n return (/** @type {(...args: AnyParameter[]) => UnknownResult} */ (\n func\n ))(...args);\n },\n\n /**\n * @param {AssignmentExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalAssignmentExpression (ast, subs) {\n if (ast.left.type !== 'Identifier') {\n throw new SyntaxError('Invalid left-hand side in assignment');\n }\n const id = /** @type {jsep.Identifier} */ (\n ast.left\n ).name;\n const value = SafeEval.evalAst(ast.right, subs);\n subs[id] = value;\n return subs[id];\n }\n};\n\n/**\n * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly.\n */\nclass SafeScript {\n /**\n * @param {string} expr Expression to evaluate\n */\n constructor (expr) {\n this.code = expr;\n this.ast = /** @type {unknown} */ (jsep(this.code));\n }\n\n /**\n * @param {object} context Object whose items will be added\n * to evaluation\n * @returns {EvaluatedResult} Result of evaluated code\n */\n runInNewContext (context) {\n // `Object.create(null)` creates a prototypeless object\n const keyMap = Object.assign(Object.create(null), context);\n return SafeEval.evalAst(\n /** @type {jsep.Expression} */ (this.ast),\n keyMap\n );\n }\n}\n\nexport {SafeScript, getSafeProperty};\n","/**\n * @param {unknown} val\n */\nexport const toStringTag = (val) => {\n return Object.prototype.toString.call(val).slice(8, -1);\n};\n\n/**\n * @param {unknown} a\n * @param {unknown} b\n */\nexport const hasConstructor = (a, b) => {\n return Function.prototype.toString.call(\n Object.getPrototypeOf(a).constructor\n ) === Function.prototype.toString.call(\n b\n );\n};\n","/* eslint-disable camelcase -- Convenient for escaping */\n/* eslint-disable class-methods-use-this -- Consistent monkey-patching */\n/* eslint-disable unicorn/prefer-private-class-fields -- Allow\n monkey-patching */\nimport {SafeScript, getSafeProperty} from './Safe-Script.js';\nimport {toStringTag} from './utils.js';\n\nconst scriptCache = new Map();\nconst pathCache = new Map();\n\n/**\n * @typedef {any} AnyInput\n */\n\n/**\n * @typedef {((...args: any[]) => any)} SandboxCallback\n */\n\n/**\n * @typedef {any|SandboxCallback} SandboxPropertyValue\n */\n\n/**\n * @typedef {(string|number)[]} ExpressionArray\n */\n\n/**\n * @typedef {\"scalar\"|\"boolean\"|\"string\"|\"undefined\"\n * |\"function\"|\"integer\"|\"number\"|\"nonFinite\"|\"object\"\n * |\"array\"|\"other\"|\"null\"|\"symbol\"|\"Promise\"|\"BigInt\"\n * |\"jsonReference\"} ValueType\n */\n\n/**\n * @typedef {unknown} ParentValue\n */\n\n/**\n * @typedef {unknown} UnknownResult\n */\n\n/**\n * @typedef {string|number|null} ParentProperty\n */\n\n/**\n * @typedef {ReturnObject|string|number|boolean|null|unknown[]\n * |Record} PreferredOutput\n */\n\n/**\n * Copies array and then pushes item into it.\n * @param {ExpressionArray} arr Array to copy and into which to push\n * @param {string|number} item Array item to add (to end)\n * @returns {ExpressionArray} Copy of the original array\n */\nfunction push (arr, item) {\n arr = arr.slice();\n arr.push(item);\n return arr;\n}\n/**\n * Copies array and then unshifts item into it.\n * @param {string|number} item Array item to add (to beginning)\n * @param {ExpressionArray} arr Array to copy and into which to unshift\n * @returns {ExpressionArray} Copy of the original array\n */\nfunction unshift (item, arr) {\n arr = arr.slice();\n arr.unshift(item);\n return arr;\n}\n\n/**\n * @typedef {object} ReturnObject\n * @property {ExpressionArray|string} path\n * @property {unknown} value\n * @property {ParentValue} parent\n * @property {ParentProperty} parentProperty\n * @property {boolean} [isParentSelector]\n * @property {boolean} [hasArrExpr]\n * @property {ExpressionArray} [expr]\n * @property {string} [pointer]\n */\n\n/**\n * @callback JSONPathCallback\n * @param {any} preferredOutput Using `any` type instead of `PreferredOutput` so\n * that user can supply flexible type\n * @param {\"value\"|\"property\"} type\n * @param {ReturnObject} fullRetObj\n * @returns {void}\n */\n\n/**\n * @callback OtherTypeCallback\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {string|number|null} parentPropName\n * @param {string} arg\n * @returns {boolean|null}\n */\n\n/**\n * @typedef {any} ContextItem\n */\n\n/**\n * @typedef {any} EvaluatedResult\n */\n\n/**\n * @callback EvalCallback\n * @param {string} code\n * @param {ContextItem} context\n * @returns {EvaluatedResult}\n */\n\n/**\n * @typedef {new (expr: string) => {\n * runInNewContext: (context: object) => EvaluatedResult\n * }} ScriptConstructor\n */\n\n/**\n * @typedef {ScriptConstructor} EvalClass\n */\n\n/**\n * @typedef {\"value\"|\"path\"|\"pointer\"|\"parent\"|\"parentProperty\"\n * |\"all\"} ResultType\n */\n\n/**\n * @typedef {EvalCallback|EvalClass|'safe'|'native'|boolean} EvalValue\n */\n\n/**\n * @typedef {string|string[]} PathType\n */\n\n/**\n * @typedef {{Script: ScriptConstructor}} SafeScriptType\n */\n\n/**\n * @typedef {{Script: ScriptConstructor}} ScriptType\n */\n\n/**\n * @typedef {{\n * _$_path?: string,\n * _$_parentProperty?: ParentProperty,\n * _$_parent?: ParentValue,\n * _$_property?: string|number,\n * _$_root?: AnyInput,\n * _$_v?: unknown,\n * [key: string]: SandboxPropertyValue\n * }} SandboxType\n */\n\n/**\n * @typedef {object} JSONPathOptions\n * @property {AnyInput} [json]\n * @property {PathType} [path]\n * @property {ResultType} [resultType=\"value\"]\n * @property {boolean} [flatten=false]\n * @property {boolean} [wrap=true]\n * @property {SandboxType} [sandbox={}]\n * @property {EvalValue} [eval='safe']\n * @property {any|null} [parent=null]\n * @property {ParentProperty} [parentProperty=null]\n * @property {JSONPathCallback} [callback]\n * @property {OtherTypeCallback} [otherTypeCallback] Defaults to\n * function which throws on encountering `@other`\n * @property {Record} [customTypes] Map of\n * custom type operator names to their evaluation callbacks\n * @property {boolean} [autostart=true]\n * @property {boolean} [ignoreEvalErrors=false]\n */\n\n\n/**\n * @overload\n * @param {string} opts JSON path to evaluate\n * @param {AnyInput} [expr] JSON object to evaluate against\n * @param {JSONPathCallback} [obj] Passed 3 arguments: 1) desired\n * payload per `resultType`, 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [callback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n * @param {undefined} [otherTypeCallback]\n * @returns {unknown} The string form always has `autostart` implicitly\n * `true`, so the result is the evaluated value, not a `JSONPathClass`\n */\n/**\n * @overload\n * @param {JSONPathOptions & {autostart: false}} opts An options object\n * with `autostart` explicitly set to `false` defers evaluation and\n * returns the `JSONPathClass` instance instead\n * @returns {JSONPathClass}\n */\n/**\n * @overload\n * @param {JSONPathOptions} opts If a string, will be treated as\n * `expr`\n * @returns {unknown}\n */\n/**\n * @param {JSONPathOptions|string} opts If a string, will be treated as `expr`\n * @param {string|AnyInput} [expr] JSON path to evaluate\n * @param {AnyInput|JSONPathCallback} [obj] JSON object to evaluate against\n * @param {JSONPathCallback|OtherTypeCallback} [callback] Passed 3\n * arguments: 1) desired payload per `resultType`,\n * 2) `\"value\"|\"property\"`, 3) Full returned object with\n * all payloads\n * @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the end\n * of one's query, this will be invoked with the value of the item, its\n * path, its parent, and its parent's property name, and it should return\n * a boolean indicating whether the supplied value belongs to the \"other\"\n * type or not (or it may handle transformations and return `false`).\n * @throws {Error}\n * @returns {unknown|JSONPathClass}\n */\nfunction JSONPath (opts, expr, obj, callback, otherTypeCallback) {\n try {\n if (opts && typeof opts === 'object') {\n return new JSONPathClass(opts);\n }\n return new JSONPathClass(\n opts,\n expr,\n /** @type {JSONPathCallback|undefined} */ (obj),\n /** @type {OtherTypeCallback|undefined} */ (callback),\n /** @type {undefined} */ (otherTypeCallback)\n );\n } catch (e) {\n if (new.target) {\n throw e;\n }\n if (e && typeof e === 'object' && 'value' in e) {\n return /** @type {{value: UnknownResult}} */ (e).value;\n }\n throw e;\n }\n}\n\n/**\n *\n */\nclass JSONPathClass {\n /**\n * @overload\n * @param {string} opts JSON path to evaluate\n * @param {AnyInput} [expr] JSON object to evaluate against\n * @param {JSONPathCallback} [obj] Passed 3 arguments: 1) desired\n * payload per `resultType`, 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [callback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n * @param {undefined} [otherTypeCallback]\n */\n /**\n * @overload\n * @param {JSONPathOptions} opts If a string, will be treated as\n * `expr`\n */\n /**\n * @param {null|string|JSONPathOptions} opts If a string, will be treated as\n * `expr`\n * @param {string|AnyInput} [expr] JSON path to evaluate\n * @param {AnyInput|JSONPathCallback} [obj] JSON object to evaluate against\n * @param {JSONPathCallback|OtherTypeCallback} [callback] Passed 3\n * arguments: 1) desired payload per `resultType`,\n * 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n */\n constructor (opts, expr, obj, callback, otherTypeCallback) {\n if (typeof opts === 'string') {\n otherTypeCallback = /** @type {OtherTypeCallback} */ (\n callback\n );\n callback = /** @type {JSONPathCallback} */ (\n obj\n );\n obj = expr;\n expr = opts;\n opts = null;\n }\n const optObj = opts && typeof opts === 'object';\n opts ||= /** @type {JSONPathOptions} */ ({});\n /** @type {ResultType|undefined} */\n this.currResultType = undefined;\n\n /** @type {EvalValue|undefined} */\n this.currEval = undefined;\n\n /** @type {OtherTypeCallback|undefined} */\n this.currOtherTypeCallback = undefined;\n\n /** @type {Record|undefined} */\n this.currCustomTypes = undefined;\n\n /** @type {SandboxType|undefined} */\n this.currSandbox = undefined;\n\n this._hasParentSelector = false;\n\n this.json = opts.json || obj;\n this.path = opts.path || expr;\n this.resultType = opts.resultType || 'value';\n this.flatten = Object.hasOwn(opts, 'flatten') && opts.flatten;\n this.wrap = !Object.hasOwn(opts, 'wrap') || opts.wrap;\n this.sandbox = opts.sandbox || {};\n this.eval = opts.eval === undefined ? 'safe' : opts.eval;\n this.ignoreEvalErrors = (\n typeof opts.ignoreEvalErrors !== 'undefined'\n ) && opts.ignoreEvalErrors;\n this.parent = Object.hasOwn(opts, 'parent') ? opts.parent : null;\n this.parentProperty = Object.hasOwn(opts, 'parentProperty')\n ? opts.parentProperty\n : null;\n this.callback = opts.callback ||\n /** @type {JSONPathCallback} */\n (callback) ||\n null;\n this.otherTypeCallback = opts.otherTypeCallback ||\n otherTypeCallback ||\n function () {\n throw new TypeError(\n 'You must supply an otherTypeCallback callback option ' +\n 'with the @other() operator.'\n );\n };\n this.customTypes = opts.customTypes || {};\n\n if (opts.autostart === false) {\n return;\n }\n\n const args = /** @type {JSONPathOptions} */ ({\n path: (optObj ? opts.path : expr)\n });\n if (!optObj && obj !== undefined) {\n args.json = obj;\n } else if ('json' in opts) {\n args.json = opts.json;\n }\n const ret = this.evaluate(args);\n if (!ret || typeof ret !== 'object') {\n const err = /** @type {Error & {value: UnknownResult}} */ (\n new Error(\n 'JSONPath should not be called with \"new\" (it ' +\n 'prevents return of (unwrapped) scalar values)'\n )\n );\n err.value = ret;\n throw err;\n }\n\n // @ts-expect-error - Constructor returns evaluate result for legacy API\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line consistent-return, no-constructor-return -- Legacy API\n return ret;\n }\n\n // PUBLIC METHODS\n\n /**\n * @overload\n * @param {JSONPathOptions} [expr]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n\n /**\n * @overload\n * @param {PathType|undefined} [expr]\n * @param {AnyInput} [json]\n * @param {JSONPathCallback|null} [callback]\n * @param {OtherTypeCallback} [otherTypeCallback]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n\n /**\n * @param {PathType|JSONPathOptions|undefined} [expr]\n * @param {AnyInput} [json]\n * @param {JSONPathCallback|null} [callback]\n * @param {OtherTypeCallback} [otherTypeCallback]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n evaluate (\n expr, json, callback, otherTypeCallback\n ) {\n let currParent = this.parent,\n currParentProperty = this.parentProperty;\n let {flatten, wrap} = this;\n\n this.currResultType = this.resultType;\n this.currEval = this.eval;\n this.currSandbox = this.sandbox;\n callback ||= this.callback;\n this.currOtherTypeCallback = otherTypeCallback ||\n this.otherTypeCallback;\n this.currCustomTypes = this.customTypes;\n\n if (expr && typeof expr === 'object' && !Array.isArray(expr)) {\n const exprObj = expr;\n if (!exprObj.path && exprObj.path !== '') {\n throw new TypeError(\n 'You must supply a \"path\" property when providing an ' +\n 'object argument to JSONPath.evaluate().'\n );\n }\n if (!(Object.hasOwn(exprObj, 'json'))) {\n throw new TypeError(\n 'You must supply a \"json\" property when providing an ' +\n 'object argument to JSONPath.evaluate().'\n );\n }\n ({json} = exprObj);\n flatten = Object.hasOwn(exprObj, 'flatten')\n ? exprObj.flatten\n : flatten;\n this.currResultType = Object.hasOwn(exprObj, 'resultType')\n ? exprObj.resultType\n : this.currResultType;\n this.currSandbox = Object.hasOwn(exprObj, 'sandbox')\n ? exprObj.sandbox\n : this.currSandbox;\n wrap = Object.hasOwn(exprObj, 'wrap') ? exprObj.wrap : wrap;\n this.currEval = Object.hasOwn(exprObj, 'eval')\n ? exprObj.eval\n : this.currEval;\n callback = Object.hasOwn(exprObj, 'callback')\n ? exprObj.callback\n : callback;\n this.currOtherTypeCallback = Object.hasOwn(\n exprObj, 'otherTypeCallback'\n )\n ? exprObj.otherTypeCallback\n : this.currOtherTypeCallback;\n this.currCustomTypes = Object.hasOwn(\n exprObj, 'customTypes'\n )\n ? exprObj.customTypes\n : this.currCustomTypes;\n currParent = Object.hasOwn(exprObj, 'parent')\n ? exprObj.parent\n : currParent;\n currParentProperty = Object.hasOwn(exprObj, 'parentProperty')\n ? exprObj.parentProperty\n : currParentProperty;\n expr = exprObj.path;\n } else {\n json ||= this.json;\n expr ||= this.path;\n }\n currParent ||= null;\n currParentProperty ||= null;\n\n if (Array.isArray(expr)) {\n expr = JSONPath.toPathString(expr);\n }\n if (!json || (!expr && expr !== '')) {\n return undefined;\n }\n\n const exprList = JSONPath.toPathArray(\n /** @type {string} */\n (expr)\n );\n if (exprList[0] === '$' && exprList.length > 1) {\n exprList.shift();\n }\n this._hasParentSelector = false;\n const traceResult = this._trace(\n exprList, json, ['$'], currParent,\n currParentProperty,\n callback ?? undefined,\n undefined\n );\n\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next 2 -- Unreachable: _trace returns array when hasArrExpr set */\n const result = (\n Array.isArray(traceResult) ? traceResult : [traceResult]\n ).filter((ea) => {\n return ea && !ea.isParentSelector;\n });\n\n if (!result.length) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: valid queries always produce results */\n return wrap ? [] : undefined;\n }\n if (!wrap && result.length === 1 && !result[0].hasArrExpr) {\n const preferredOutput = this._getPreferredOutput(result[0]);\n return preferredOutput;\n }\n const reduced = result.reduce(\n (rslt, ea) => {\n const valOrPath = this._getPreferredOutput(ea);\n if (flatten && Array.isArray(valOrPath)) {\n rslt = rslt.concat(valOrPath);\n } else {\n rslt.push(valOrPath);\n }\n return rslt;\n },\n /** @type {UnknownResult[]} */\n ([])\n );\n\n return reduced;\n }\n\n // PRIVATE METHODS\n\n /**\n * @param {ReturnObject} ea\n * @returns {PreferredOutput}\n */\n _getPreferredOutput (ea) {\n const resultType = this.currResultType;\n switch (resultType) {\n case 'all': {\n const path = Array.isArray(ea.path)\n ? ea.path\n : JSONPath.toPathArray(ea.path);\n ea.pointer = JSONPath.toPointer(/** @type {string[]} */ (path));\n ea.path = typeof ea.path === 'string'\n ? ea.path\n : JSONPath.toPathString(/** @type {string[]} */ (ea.path));\n return ea;\n } case 'value': case 'parent': case 'parentProperty':\n return /** @type {PreferredOutput} */ (ea[resultType]);\n case 'path':\n if (typeof ea.path === 'string') {\n return ea.path;\n }\n return JSONPath.toPathString(/** @type {string[]} */ (ea.path));\n case 'pointer': {\n const pathArray = Array.isArray(ea.path)\n ? ea.path\n : JSONPath.toPathArray(ea.path);\n return JSONPath.toPointer(/** @type {string[]} */ (pathArray));\n }\n default:\n throw new TypeError('Unknown result type');\n }\n }\n\n /**\n * @param {ReturnObject} fullRetObj\n * @param {JSONPathCallback|undefined} callback\n * @param {\"value\"|\"property\"} type\n * @returns {void}\n */\n _handleCallback (fullRetObj, callback, type) {\n // Early return if no callback provided (defensive\n // check for internal calls)\n if (!callback) {\n return;\n }\n const preferredOutput = this._getPreferredOutput(fullRetObj);\n if (Array.isArray(fullRetObj.path)) {\n fullRetObj.path = JSONPath.toPathString(\n /** @type {string[]} */ (fullRetObj.path)\n );\n }\n callback(preferredOutput, type, fullRetObj);\n }\n\n /**\n *\n * @param {ExpressionArray} expr\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @param {JSONPathCallback|undefined} callback\n * @param {boolean|undefined} hasArrExpr\n * @param {boolean} [literalPriority]\n * @returns {ReturnObject|ReturnObject[]}\n */\n _trace (\n expr, val, path, parent, parentPropName, callback, hasArrExpr,\n literalPriority\n ) {\n // No expr to follow? return path and value as the result of\n // this trace branch\n let retObj;\n if (!expr.length) {\n retObj = {\n path,\n value: val,\n parent,\n parentProperty: parentPropName,\n hasArrExpr\n };\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n\n const loc = /** @type {string} */ (expr[0]), x = expr.slice(1);\n\n // We need to gather the return value of recursive trace calls in order\n // to do the parent sel computation.\n /** @type {ReturnObject[]} */\n const ret = [];\n /**\n *\n * @param {ReturnObject|ReturnObject[]} elems\n * @returns {void}\n */\n function addRet (elems) {\n if (Array.isArray(elems)) {\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test:\n // `ret.push(...elems);`\n elems.forEach((t) => {\n ret.push(t);\n });\n } else {\n ret.push(elems);\n }\n }\n if (val && (typeof loc !== 'string' || literalPriority) &&\n Object.hasOwn(val, /** @type {PropertyKey} */ (loc))\n ) { // simple case--directly follow property\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[/** @type {string} */ (loc)],\n push(path, loc),\n val, /** @type {string|number} */ (loc), callback,\n hasArrExpr\n ));\n // eslint-disable-next-line unicorn/prefer-switch -- Part of larger `if`\n } else if (loc === '*') { // all child properties\n this._walk(val, (m) => {\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[m], push(path, m), val, m, callback, true, true\n ));\n });\n } else if (loc === '..') { // all descendent parent properties\n // Check remaining expression with val's immediate children\n addRet(\n this._trace(x, val, path, parent, parentPropName, callback,\n hasArrExpr)\n );\n this._walk(val, (m) => {\n // We don't join m and x here because we only want parents,\n // not scalar values\n const valObj = /** @type {Record} */ (val);\n if (typeof valObj[m] === 'object') {\n // Keep going with recursive descent on val's\n // object children\n addRet(this._trace(\n expr.slice(),\n valObj[m],\n push(path, m),\n val,\n m,\n callback,\n true\n ));\n }\n });\n // The parent sel computation is handled in the frame above using the\n // ancestor object of val\n } else if (loc === '^') {\n // This is not a final endpoint, so we do not invoke the\n // callback here\n this._hasParentSelector = true;\n return /** @type {ReturnObject} */ ({\n path: path.slice(0, -1),\n expr: x,\n isParentSelector: true,\n value: undefined,\n parent: undefined,\n parentProperty: null\n });\n } else if (loc === '~') { // property name\n retObj = {\n path: push(path, loc),\n value: parentPropName,\n parent,\n parentProperty: null\n };\n this._handleCallback(retObj, callback, 'property');\n return retObj;\n } else if (loc === '$') { // root only\n addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));\n } else if ((/^(-?\\d*):(-?\\d*):?(\\d*)$/v).test(loc)) { // [start:end:step] Python slice syntax\n const sliceResult = this._slice(\n loc, x, val, path, parent, parentPropName, callback\n );\n if (sliceResult) {\n addRet(sliceResult);\n }\n } else if (loc.indexOf('?(') === 0) { // [?(expr)] (filtering)\n if (this.currEval === false) {\n throw new Error(\n 'Eval [?(expr)] prevented in JSONPath expression.'\n );\n }\n const safeLoc = loc.replace(/^\\?\\((.*?)\\)$/v, '$1');\n // check for a nested filter expression\n\n const nested = (/@.?([^?]*)[\\['](\\??\\(.*?\\))(?!.\\)\\])[\\]']/gv).exec(safeLoc);\n if (nested) {\n // find if there are matches in the nested expression\n // add them to the result set if there is at least one match\n this._walk(val, (m) => {\n const npath = [nested[2]];\n const valObj2 = /** @type {Record} */ (\n val\n );\n // guard against nested[1] resolving to `constructor`\n const nvalue = /** @type {ValueType} */ (nested[1]\n ? getSafeProperty(\n /** @type {Record} */ (\n valObj2[m]\n ),\n nested[1]\n )\n : valObj2[m]);\n const filterResults = this._trace(npath, nvalue, path,\n parent, parentPropName, callback, true);\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next 3 -- Unreachable: _trace always returns array for nested filters */\n const filterArray = Array.isArray(filterResults)\n ? filterResults\n : [filterResults];\n if (filterArray.length > 0) {\n addRet(this._trace(x, valObj2[m], push(path, m), val,\n m, callback, true));\n }\n });\n } else {\n const valObj3 = /** @type {Record} */ (val);\n this._walk(val, (m) => {\n if (this._eval(safeLoc, valObj3[m], m, path, parent,\n parentPropName)) {\n addRet(this._trace(x, valObj3[m], push(path, m), val, m,\n callback, true));\n }\n });\n }\n } else if (loc[0] === '(') { // [(expr)] (dynamic property/index)\n if (this.currEval === false) {\n throw new Error(\n 'Eval [(expr)] prevented in JSONPath expression.'\n );\n }\n // As this will resolve to a property name (but we don't know it\n // yet), property and parent information is relative to the\n const evalResult = this._eval(\n /** @type {string} */ (loc),\n val, /** @type {string|number} */ (path.at(-1)),\n path.slice(0, -1), parent, parentPropName\n );\n const exprToUse = /** @type {string|number} */ (\n evalResult !== undefined ? evalResult : ''\n );\n addRet(this._trace(unshift(\n exprToUse,\n x\n ), val, path, parent, parentPropName, callback, hasArrExpr));\n } else if (loc[0] === '@') { // value type: @boolean(), etc.\n // eslint-disable-next-line no-useless-assignment -- ESLint bug\n let addType = false;\n const parenthIndex = loc.indexOf('(');\n const valueType = /** @type {ValueType|string} */ (\n loc\n ).slice(1, parenthIndex);\n const lastParenth = loc.lastIndexOf(')');\n const argRaw = loc.slice(parenthIndex + 1, lastParenth);\n const arg = argRaw ? JSON.parse(argRaw) : undefined;\n switch (valueType) {\n case 'scalar':\n addType = !val ||\n !(['object', 'function'].includes(typeof val));\n break;\n case 'boolean': case 'string': case 'undefined': case 'function':\n addType = typeof val === valueType;\n break;\n case 'integer':\n addType = Number.isFinite(val) &&\n !(/** @type {number} */ (val) % 1);\n break;\n case 'number':\n addType = Number.isFinite(val);\n break;\n case 'nonFinite':\n addType = typeof val === 'number' && !Number.isFinite(val);\n break;\n case 'object':\n addType = Boolean(val) && typeof val === valueType;\n break;\n case 'array':\n addType = Array.isArray(val);\n break;\n case 'other':\n addType = /** @type {OtherTypeCallback} */ (\n this.currOtherTypeCallback\n )(\n val, path, parent, parentPropName, arg\n ) || false;\n break;\n case 'null':\n addType = val === null;\n break;\n case 'symbol':\n addType = typeof val === 'symbol';\n break;\n case 'BigInt':\n addType = typeof val === 'bigint';\n break;\n case 'Promise':\n addType = toStringTag(val) === 'Promise';\n break;\n case 'jsonReference':\n addType = Boolean(val) && typeof val === 'object' &&\n Object.hasOwn(/** @type {object} */ (val), '$ref');\n break;\n default:\n if (this.currCustomTypes &&\n Object.hasOwn(this.currCustomTypes, valueType)\n ) {\n addType = this.currCustomTypes[valueType](\n val, path, parent, parentPropName, arg\n ) || false;\n } else {\n throw new TypeError('Unknown value type ' + valueType);\n }\n }\n if (addType) {\n retObj = {\n path, value: val, parent, parentProperty: parentPropName\n };\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n // `-escaped property\n } else if (val && loc[0] === '`' &&\n Object.hasOwn(val, loc.slice(1))\n ) {\n const locProp = loc.slice(1);\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[locProp], push(path, locProp), val, locProp, callback,\n hasArrExpr, true\n ));\n } else if (loc[0] === \"'\" || loc[0] === '\"') { // ['name1','name2',...]\n // Quoted members are literal property names\n for (const [, single, double] of loc.matchAll(\n /'((?:\\\\.|[^'\\\\])*)'|\"((?:\\\\.|[^\"\\\\])*)\"/gv\n )) {\n const prop = (single ?? double).replaceAll(\n /\\\\(['\"\\\\])/gv, '$1'\n );\n if (!val || !Object.hasOwn(val, prop)) {\n continue;\n }\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[prop], push(path, prop), val, prop,\n callback, true\n ));\n }\n } else if (loc.includes(',')) { // [name1,name2,...]\n const parts = loc.split(',');\n for (const part of parts) {\n addRet(this._trace(\n unshift(part, x),\n val,\n path,\n parent,\n parentPropName,\n callback,\n true\n ));\n }\n // simple case--directly follow property\n } else if (\n !literalPriority && val && Object.hasOwn(val, loc)\n ) {\n const valObj = /** @type {Record} */ (val);\n addRet(\n this._trace(x, valObj[loc], push(path, loc), val, loc, callback,\n hasArrExpr, true)\n );\n }\n\n // We check the resulting values for parent selections. For parent\n // selections we discard the value object and continue the trace with\n // the current val object\n if (this._hasParentSelector) {\n for (let t = 0; t < ret.length; t++) {\n const rett = ret[t];\n if (!rett || !rett.isParentSelector) {\n continue;\n }\n\n const exprToUse = /** @type {ExpressionArray} */ (\n rett.expr\n );\n const pathToUse = /** @type {ExpressionArray} */ (\n rett.path\n );\n const tmp = this._trace(\n exprToUse,\n val,\n pathToUse,\n parent,\n parentPropName,\n callback,\n hasArrExpr\n );\n if (Array.isArray(tmp)) {\n ret[t] = tmp[0];\n const tl = tmp.length;\n for (let tt = 1; tt < tl; tt++) {\n t++;\n ret.splice(t, 0, tmp[tt]);\n }\n } else {\n ret[t] = tmp;\n }\n }\n }\n return ret;\n }\n\n /**\n * @param {unknown} val\n * @param {(prop: string|number) => void} f\n * @returns {void}\n */\n _walk (val, f) {\n if (Array.isArray(val)) {\n const n = val.length;\n for (let i = 0; i < n; i++) {\n f(i);\n }\n } else if (val && typeof val === 'object') {\n Object.keys(val).forEach((m) => {\n f(m);\n });\n }\n }\n\n /**\n * @param {string} loc\n * @param {ExpressionArray} expr\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @param {JSONPathCallback|undefined} callback\n * @returns {ReturnObject[]|undefined}\n */\n _slice (\n loc, expr, val, path, parent, parentPropName, callback\n ) {\n if (!Array.isArray(val)) {\n return undefined;\n }\n const len = val.length, parts = loc.split(':'),\n step = (parts[2] && Number(parts[2])) || 1;\n let start = (parts[0] && Number(parts[0])) || 0,\n end = parts[1] ? Number(parts[1]) : len;\n start = (start < 0) ? Math.max(0, start + len) : Math.min(len, start);\n end = (end < 0) ? Math.max(0, end + len) : Math.min(len, end);\n /** @type {ReturnObject[]} */\n const ret = [];\n for (let i = start; i < end; i += step) {\n const tmp = this._trace(\n unshift(i, expr),\n val,\n path,\n parent,\n parentPropName,\n callback,\n true\n );\n // Should only be possible to be an array here since first part of\n // ``unshift(i, expr)` passed in above would not be empty,\n // nor `~`, nor begin with `@` (as could return objects)\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test: `ret.push(...tmp);`\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: _trace returns array when expr non-empty */\n const tmpArray = Array.isArray(tmp) ? tmp : [tmp];\n tmpArray.forEach((t) => {\n ret.push(t);\n });\n }\n return ret;\n }\n\n /**\n * @param {string} code\n * @param {unknown} _v\n * @param {string|number} _vname\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @returns {UnknownResult}\n */\n _eval (\n code, _v, _vname, path, parent, parentPropName\n ) {\n if (this.currSandbox) {\n this.currSandbox._$_parentProperty = parentPropName;\n this.currSandbox._$_parent = parent;\n this.currSandbox._$_property = _vname;\n this.currSandbox._$_root = this.json;\n this.currSandbox._$_v = _v;\n }\n\n const containsPath = code.includes('@path');\n if (containsPath) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: currSandbox set in evaluate() before _eval */\n const currSandbox = this.currSandbox ?? {};\n currSandbox._$_path = JSONPath.toPathString(\n /** @type {string[]} */ (path.concat([_vname]))\n );\n }\n\n const scriptCacheKey = this.currEval + 'Script:' + code;\n if (!scriptCache.has(scriptCacheKey)) {\n let script = code\n .replaceAll('@parentProperty', '_$_parentProperty')\n .replaceAll('@parent', '_$_parent')\n .replaceAll('@property', '_$_property')\n .replaceAll('@root', '_$_root')\n // Replace a bare `@` (not followed by an identifier\n // character) while leaving quoted string literals and\n // regex literals (a `/` where an operand is expected,\n // as opposed to division) intact\n .replaceAll(\n /('(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\"|(?<=(?:^|[\\(,=:\\[!\\|?\\{\\};+\\-*%<>~^]|&)\\s*)\\/(?:\\\\.|\\[(?:\\\\.|[^\\]\\\\])*\\]|[^\\/\\\\\\[])+\\/[dgimsuvy]*)|@(?![\\w$])/gv,\n (_, literal) => literal ?? '_$_v'\n );\n if (containsPath) {\n script = script.replaceAll('@path', '_$_path');\n }\n const evalType = /** @type {string|boolean|undefined} */ (\n this.currEval\n );\n if (['safe', true, undefined].includes(evalType)) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-disable unicorn/no-undeclared-class-members -- Prototype members */\n scriptCache.set(scriptCacheKey, new (\n /**\n * @type {JSONPathClass & {\n * safeVm: SafeScriptType,\n * vm: ScriptType\n * }}\n */ (/** @type {unknown} */ (this))\n ).safeVm.Script(script));\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-enable unicorn/no-undeclared-class-members -- End prototype member scope */\n } else if (this.currEval === 'native') {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-disable unicorn/no-undeclared-class-members -- Prototype members */\n scriptCache.set(scriptCacheKey, new (\n /**\n * @type {JSONPathClass & {\n * safeVm: SafeScriptType,\n * vm: ScriptType\n * }}\n */ (/** @type {unknown} */ (this))\n ).vm.Script(script));\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-enable unicorn/no-undeclared-class-members -- End prototype member scope */\n } else if (\n typeof this.currEval === 'function' &&\n this.currEval.prototype &&\n Object.hasOwn(this.currEval.prototype, 'runInNewContext')\n ) {\n const CurrEval = this.currEval;\n // eslint-disable-next-line @stylistic/max-len -- Long\n // @ts-expect-error - Type checked above to have proper constructor\n scriptCache.set(scriptCacheKey, new CurrEval(script));\n } else if (typeof this.currEval === 'function') {\n // Type narrowing: at this point currEval is a function\n // but not a constructor\n const evalFunc = /** @type {EvalCallback} */ (this.currEval);\n scriptCache.set(scriptCacheKey, {\n runInNewContext: (\n /** @type {ContextItem} */ context\n ) => evalFunc(script, context)\n });\n } else {\n throw new TypeError(\n `Unknown \"eval\" property \"${this.currEval}\"`\n );\n }\n }\n\n try {\n /**\n * @typedef {{\n * runInNewContext: (\n * ctx: SandboxType|undefined\n * ) => EvaluatedResult\n * }} RunInNewContext\n */\n\n return /** @type {RunInNewContext} */ (\n scriptCache.get(scriptCacheKey)\n ).runInNewContext(\n this.currSandbox\n );\n } catch (e) {\n if (this.ignoreEvalErrors) {\n return false;\n }\n const error = /** @type {Error} */ (e);\n throw new Error('jsonPath: ' + error.message + ': ' + code, {\n cause: e\n });\n }\n }\n}\n\n/** @type {{safeVm: SafeScriptType}} */\n(/** @type {unknown} */ (JSONPathClass.prototype)).safeVm = {\n Script: SafeScript\n};\n\nJSONPath.prototype = JSONPathClass.prototype;\n\n// PUBLIC CLASS PROPERTIES AND METHODS\n\n/**\n * Clears cached parsed paths and compiled scripts.\n * @returns {void}\n */\nJSONPath.clearCache = function () {\n pathCache.clear();\n scriptCache.clear();\n};\n\n/**\n * @param {string[]} pathArr Array to convert\n * @returns {string} The path string\n */\nJSONPath.toPathString = function (pathArr) {\n const x = pathArr, n = x.length;\n let p = '$';\n for (let i = 1; i < n; i++) {\n if (!(/^(~|\\^|@.*?\\(\\))$/v).test(x[i])) {\n p += (/^[0-9*]+$/v).test(x[i])\n ? ('[' + x[i] + ']')\n : (\"['\" + String(x[i]).replaceAll(/['\\\\]/gv, String.raw`\\$&`) + \"']\");\n }\n }\n return p;\n};\n\n/**\n * @param {string[]} pointer JSON Path array\n * @returns {string} JSON Pointer\n */\nJSONPath.toPointer = function (pointer) {\n const x = pointer, n = x.length;\n let p = '';\n for (let i = 1; i < n; i++) {\n if (!(/^(~|\\^|@.*?\\(\\))$/v).test(x[i])) {\n p += '/' + x[i].toString()\n .replaceAll('~', '~0')\n .replaceAll('/', '~1');\n }\n }\n return p;\n};\n\n/**\n * @param {string} expr Expression to convert\n * @returns {string[]}\n */\nJSONPath.toPathArray = function (expr) {\n if (pathCache.has(expr)) {\n return /** @type {string[]} */ (pathCache.get(expr)).concat();\n }\n /** @type {string[]} */\n const subx = [];\n const normalized = expr\n // Properties\n .replaceAll(\n /@[\\w$\\-]+\\([^\\)]*\\)/gv,\n ';$&;'\n )\n // Parenthetical evaluations (filtering and otherwise), directly\n // within brackets or single quotes\n .replaceAll(/[\\['](\\??\\(.*?\\))[\\]'](?!.\\])/gv, function ($0, $1) {\n return '[#' +\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line unicorn/no-return-array-push -- Optimization\n (subx.push($1) - 1) +\n ']';\n })\n // Unions of quoted property names (e.g., `['x','y']`) and quoted\n // names with commas or backslash escapes, kept intact (with\n // quotes) so their members survive tokenization\n .replaceAll(\n /\\[\\s*((?:'(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\")(?:\\s*,\\s*(?:'(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\"))*)\\s*\\]/gv,\n function ($0, $1) {\n if (!(/[,\\\\]/v).test($1)) {\n return $0;\n }\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line unicorn/no-return-array-push -- Optimization\n return '[#' + (subx.push($1) - 1) + ']';\n }\n )\n // Escape periods and tildes within properties\n .replaceAll(/\\[['\"]([^'\\]]*)['\"]\\]/gv, function ($0, prop) {\n return \"['\" + prop\n .replaceAll('.', '%@%')\n .replaceAll('~', '%%@@%%') +\n \"']\";\n })\n // Properties operator\n .replaceAll('~', ';~;')\n // Split by property boundaries\n\n .replaceAll(/['\"]?\\.['\"]?(?![^\\[]*\\])|\\[['\"]?/gv, ';')\n // Reinsert periods within properties\n .replaceAll('%@%', '.')\n // Reinsert tildes within properties\n .replaceAll('%%@@%%', '~')\n // Parent\n .replaceAll(/(?:;)?(\\^+)(?:;)?/gv, function ($0, ups) {\n return ';' + ups.split('').join(';') + ';';\n })\n // Descendents\n .replaceAll(/;;;|;;/gv, ';..;')\n // Remove trailing\n .replaceAll(/;$|'?\\]|'$/gv, '');\n\n const exprList = normalized.split(';').map(function (exp) {\n const match = exp.match(/#(\\d+)/v);\n return !match || !match[1] ? exp : subx[Number(match[1])];\n });\n pathCache.set(expr, exprList);\n return /** @type {string[]} */ (pathCache.get(expr)).concat();\n};\n\nexport {JSONPath, JSONPathClass};\n","import {JSONPath, JSONPathClass} from './jsonpath.js';\n\n/**\n * @typedef {import('./jsonpath.js').AnyInput} AnyInput\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxCallback} SandboxCallback\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxPropertyValue} SandboxPropertyValue\n */\n/**\n * @typedef {import('./jsonpath.js').ExpressionArray} ExpressionArray\n */\n/**\n * @typedef {import('./jsonpath.js').ValueType} ValueType\n */\n/**\n * @typedef {import('./jsonpath.js').ParentValue} ParentValue\n */\n/**\n * @typedef {import('./jsonpath.js').UnknownResult} UnknownResult\n */\n/**\n * @typedef {import('./jsonpath.js').ParentProperty} ParentProperty\n */\n/**\n * @typedef {import('./jsonpath.js').PreferredOutput} PreferredOutput\n */\n/**\n * @typedef {import('./jsonpath.js').ReturnObject} ReturnObject\n */\n/**\n * @typedef {import('./jsonpath.js').JSONPathCallback} JSONPathCallback\n */\n/**\n * @typedef {import('./jsonpath.js').OtherTypeCallback} OtherTypeCallback\n */\n/**\n * @typedef {import('./jsonpath.js').ContextItem} ContextItem\n */\n/**\n * @typedef {import('./jsonpath.js').EvaluatedResult} EvaluatedResult\n */\n/**\n * @typedef {import('./jsonpath.js').EvalCallback} EvalCallback\n */\n/**\n * @typedef {import('./jsonpath.js').EvalClass} EvalClass\n */\n/**\n * @typedef {import('./jsonpath.js').ResultType} ResultType\n */\n/**\n * @typedef {import('./jsonpath.js').EvalValue} EvalValue\n */\n/**\n * @typedef {import('./jsonpath.js').PathType} PathType\n */\n/**\n * @typedef {import('./jsonpath.js').SafeScriptType} SafeScriptType\n */\n/**\n * @typedef {import('./jsonpath.js').ScriptType} ScriptType\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxType} SandboxType\n */\n/**\n * @typedef {import('./jsonpath.js').JSONPathOptions} JSONPathOptions\n */\n\n/**\n * @template T\n * @callback ConditionCallback\n * @param {T} item\n * @returns {boolean}\n */\n\n/**\n * Copy items out of one array into another.\n * @template T\n * @param {T[]} source Array with items to copy\n * @param {T[]} target Array to which to copy\n * @param {ConditionCallback} conditionCb Callback passed the current item;\n * will move item if evaluates to `true`\n * @returns {void}\n */\nconst moveToAnotherArray = function (source, target, conditionCb) {\n const il = source.length;\n for (let i = 0; i < il; i++) {\n const item = source[i];\n if (conditionCb(item)) {\n target.push(source.splice(i--, 1)[0]);\n }\n }\n};\n\n/**\n * In-browser replacement for NodeJS' VM.Script.\n */\nclass Script {\n /**\n * @param {string} expr Expression to evaluate\n */\n constructor (expr) {\n this.code = expr;\n }\n\n /**\n * @param {SandboxType} context Object whose items will be added\n * to evaluation\n * @returns {EvaluatedResult} Result of evaluated code\n */\n runInNewContext (context) {\n let expr = this.code;\n const keys = Object.keys(context);\n const funcs = /** @type {string[]} */ ([]);\n moveToAnotherArray(keys, funcs, (key) => {\n return typeof context[key] === 'function';\n });\n const values = keys.map((vr) => {\n return context[vr];\n });\n\n const funcString = funcs.reduce((s, func) => {\n let fString = context[func].toString();\n if (!(/function/v).test(fString)) {\n fString = 'function ' + fString;\n }\n return 'var ' + func + '=' + fString + ';' + s;\n }, '');\n\n expr = funcString + expr;\n\n // Mitigate https://perfectionkills.com/global-eval-what-are-the-options/#new_function\n if (!(/(['\"])use strict\\1/v).test(expr) && !keys.includes('arguments')) {\n expr = 'var arguments = undefined;' + expr;\n }\n\n // Remove last semi so `return` will be inserted before\n // the previous one instead, allowing for the return\n // of a bare ending expression\n expr = expr.replace(/;\\s*$/v, '');\n\n // Insert `return`\n const lastStatementEnd = expr.lastIndexOf(';');\n const code =\n lastStatementEnd !== -1\n ? expr.slice(0, lastStatementEnd + 1) +\n ' return ' +\n expr.slice(lastStatementEnd + 1)\n : ' return ' + expr;\n\n // eslint-disable-next-line no-new-func -- User's choice\n return new Function(...keys, code)(...values);\n }\n}\n\n/** @type {{vm: ScriptType}} */\n(/** @type {unknown} */ (JSONPathClass.prototype)).vm = {\n Script\n};\n\nexport {JSONPath, JSONPathClass, Script};\n"],"names":["Jsep","version","toString","addUnaryOp","op_name","max_unop_len","Math","max","length","unary_ops","addBinaryOp","precedence","isRightAssociative","max_binop_len","binary_ops","right_associative","add","delete","addIdentifierChar","char","additional_identifier_chars","addLiteral","literal_name","literal_value","literals","removeUnaryOp","getMaxKeyLen","removeAllUnaryOps","removeIdentifierChar","removeBinaryOp","removeAllBinaryOps","removeLiteral","removeAllLiterals","this","expr","charAt","index","code","charCodeAt","constructor","parse","obj","Object","keys","map","k","isDecimalDigit","ch","binaryPrecedence","op_val","isIdentifierStart","String","fromCharCode","has","isIdentifierPart","throwError","message","error","Error","description","runHook","name","node","hooks","env","context","run","searchHook","find","callback","call","gobbleSpaces","SPACE_CODE","TAB_CODE","LF_CODE","CR_CODE","nodes","gobbleExpressions","type","COMPOUND","body","untilICode","ch_i","SEMCOL_CODE","COMMA_CODE","gobbleExpression","push","gobbleBinaryExpression","gobbleBinaryOp","to_check","substr","tc_len","hasOwnProperty","biop","prec","stack","biop_info","left","right","i","cur_biop","gobbleToken","value","right_a","comparePrev","prev","pop","BINARY_EXP","operator","PERIOD_CODE","gobbleNumericLiteral","SQUOTE_CODE","DQUOTE_CODE","gobbleStringLiteral","OBRACK_CODE","gobbleArray","argument","UNARY_EXP","prefix","gobbleIdentifier","LITERAL","raw","this_str","THIS_EXP","OPAREN_CODE","gobbleGroup","gobbleTokenProperty","QUMARK_CODE","optional","MEMBER_EXP","computed","object","property","CBRACK_CODE","CALL_EXP","arguments","gobbleArguments","CPAREN_CODE","callee","chCode","number","parseFloat","str","startIndex","quote","closed","substring","start","IDENTIFIER","slice","termination","args","separator_count","arg","SEQUENCE_EXP","expressions","ARRAY_EXP","elements","first","Array","isArray","forEach","assign","plugins","jsep","registered","register","plugin","init","COLON_CODE","Set","true","false","null","stdClassProps","getOwnPropertyNames","filter","prop","includes","undefined","m","ternary","test","consequent","alternate","newTest","patternIndex","inCharSet","pattern","flags","RegExp","e","assignmentOperators","updateOperators","assignmentPrecedence","updateNodeTypes","updateBinariesToAssignments","values","val","op","some","c","jsepRegex","jsepAssignment","BLOCKED_PROTO_PROPERTIES","BLOCKED_FUNCTIONS","WeakSet","Function","async","prototype","apply","bind","Reflect","construct","get","isBlockedFunction","getSafeProperty","TypeError","hasOwn","result","BINOPS","create","||","a","b","&&","|","^","&","==","!=","===","!==","<",">","<=",">=","<<",">>",">>>","+","-","*","/","%","UNOPS","typeof","void","SafeEval","evalAst","ast","subs","evalBinaryExpression","evalCompound","evalConditionalExpression","evalIdentifier","evalLiteral","evalMemberExpression","evalUnaryExpression","evalArrayExpression","evalCallExpression","evalAssignmentExpression","SyntaxError","cause","last","ReferenceError","operand","el","func","id","scriptCache","Map","pathCache","arr","item","unshift","JSONPath","opts","otherTypeCallback","JSONPathClass","optObj","currResultType","currEval","currOtherTypeCallback","currCustomTypes","currSandbox","_hasParentSelector","json","path","resultType","flatten","wrap","sandbox","eval","ignoreEvalErrors","parent","parentProperty","customTypes","autostart","ret","evaluate","err","currParent","currParentProperty","exprObj","toPathString","exprList","toPathArray","shift","traceResult","_trace","ea","isParentSelector","hasArrExpr","_getPreferredOutput","reduce","rslt","valOrPath","concat","pointer","toPointer","pathArray","_handleCallback","fullRetObj","preferredOutput","parentPropName","literalPriority","retObj","loc","x","addRet","elems","t","valObj","_walk","sliceResult","_slice","indexOf","safeLoc","replace","nested","exec","npath","valObj2","nvalue","filterResults","valObj3","_eval","evalResult","at","exprToUse","addType","parenthIndex","valueType","lastParenth","lastIndexOf","argRaw","JSON","Number","isFinite","Boolean","toStringTag","locProp","single","double","matchAll","replaceAll","parts","split","part","rett","pathToUse","tmp","tl","tt","splice","f","n","len","step","end","min","_v","_vname","_$_parentProperty","_$_parent","_$_property","_$_root","_$_v","containsPath","_$_path","scriptCacheKey","script","_","literal","evalType","set","safeVm","Script","vm","CurrEval","evalFunc","runInNewContext","keyMap","clearCache","clear","pathArr","p","subx","$0","$1","ups","join","exp","match","funcs","source","target","conditionCb","il","moveToAnotherArray","key","vr","s","fString","lastStatementEnd"],"mappings":"+OAgGA,MAAMA,EAIL,kBAAWC,GAEV,MAAO,OACR,CAKA,eAAOC,GACN,MAAO,wCAA0CF,EAAKC,OACvD,CAQA,iBAAOE,CAAWC,GAGjB,OAFAJ,EAAKK,aAAeC,KAAKC,IAAIH,EAAQI,OAAQR,EAAKK,cAClDL,EAAKS,UAAUL,GAAW,EACnBJ,CACR,CASA,kBAAOU,CAAYN,EAASO,EAAYC,GASvC,OARAZ,EAAKa,cAAgBP,KAAKC,IAAIH,EAAQI,OAAQR,EAAKa,eACnDb,EAAKc,WAAWV,GAAWO,EACvBC,EACHZ,EAAKe,kBAAkBC,IAAIZ,GAG3BJ,EAAKe,kBAAkBE,OAAOb,GAExBJ,CACR,CAOA,wBAAOkB,CAAkBC,GAExB,OADAnB,EAAKoB,4BAA4BJ,IAAIG,GAC9BnB,CACR,CAQA,iBAAOqB,CAAWC,EAAcC,GAE/B,OADAvB,EAA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qW,IAWnBpY,EARmB6X,EAAMpG,OAAO,CAAC4G,EAAG3J,KAChC,IAAI4J,EAAUvW,EAAQ2M,GAAM1Q,WAI5B,MAHM,YAAaoL,KAAKkP,KACpBA,EAAU,YAAcA,GAErB,OAAS5J,EAAO,IAAM4J,EAAU,IAAMD,GAC9C,IAEiBrY,EAGd,sBAAuBoJ,KAAKpJ,IAAUS,EAAKuI,SAAS,eACtDhJ,EAAO,6BAA+BA,GAM1CA,EAAOA,EAAKiT,QAAQ,SAAU,IAG9B,MAAMsF,EAAmBvY,EAAKiU,YAAY,KACpC9T,GACmB,IAArBoY,EACMvY,EAAKmH,MAAM,EAAGoR,EAAmB,GACjC,WACAvY,EAAKmH,MAAMoR,EAAmB,GAC9B,WAAavY,EAGvB,OAAO,IAAI6K,YAAYpK,EAAMN,EAAtB,IAA+BgK,EAC1C,EAIqBkF,EAAuB,UAAGwH,GAAK,CACpDD","x_google_ignoreList":[0,1,2]} \ No newline at end of file +{"version":3,"file":"index-browser-umd.min.cjs","sources":["../node_modules/.pnpm/jsep@1.4.0/node_modules/jsep/dist/jsep.js","../node_modules/.pnpm/@jsep-plugin+regex@1.0.4_jsep@1.4.0/node_modules/@jsep-plugin/regex/dist/index.js","../node_modules/.pnpm/@jsep-plugin+assignment@1.3.0_jsep@1.4.0/node_modules/@jsep-plugin/assignment/dist/index.js","../src/Safe-Script.js","../src/utils.js","../src/jsonpath.js","../src/jsonpath-browser.js"],"sourcesContent":["/**\n * @implements {IHooks}\n */\nclass Hooks {\n\t/**\n\t * @callback HookCallback\n\t * @this {*|Jsep} this\n\t * @param {Jsep} env\n\t * @returns: void\n\t */\n\t/**\n\t * Adds the given callback to the list of callbacks for the given hook.\n\t *\n\t * The callback will be invoked when the hook it is registered for is run.\n\t *\n\t * One callback function can be registered to multiple hooks and the same hook multiple times.\n\t *\n\t * @param {string|object} name The name of the hook, or an object of callbacks keyed by name\n\t * @param {HookCallback|boolean} callback The callback function which is given environment variables.\n\t * @param {?boolean} [first=false] Will add the hook to the top of the list (defaults to the bottom)\n\t * @public\n\t */\n\tadd(name, callback, first) {\n\t\tif (typeof arguments[0] != 'string') {\n\t\t\t// Multiple hook callbacks, keyed by name\n\t\t\tfor (let name in arguments[0]) {\n\t\t\t\tthis.add(name, arguments[0][name], arguments[1]);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\t(Array.isArray(name) ? name : [name]).forEach(function (name) {\n\t\t\t\tthis[name] = this[name] || [];\n\n\t\t\t\tif (callback) {\n\t\t\t\t\tthis[name][first ? 'unshift' : 'push'](callback);\n\t\t\t\t}\n\t\t\t}, this);\n\t\t}\n\t}\n\n\t/**\n\t * Runs a hook invoking all registered callbacks with the given environment variables.\n\t *\n\t * Callbacks will be invoked synchronously and in the order in which they were registered.\n\t *\n\t * @param {string} name The name of the hook.\n\t * @param {Object} env The environment variables of the hook passed to all callbacks registered.\n\t * @public\n\t */\n\trun(name, env) {\n\t\tthis[name] = this[name] || [];\n\t\tthis[name].forEach(function (callback) {\n\t\t\tcallback.call(env && env.context ? env.context : env, env);\n\t\t});\n\t}\n}\n\n/**\n * @implements {IPlugins}\n */\nclass Plugins {\n\tconstructor(jsep) {\n\t\tthis.jsep = jsep;\n\t\tthis.registered = {};\n\t}\n\n\t/**\n\t * @callback PluginSetup\n\t * @this {Jsep} jsep\n\t * @returns: void\n\t */\n\t/**\n\t * Adds the given plugin(s) to the registry\n\t *\n\t * @param {object} plugins\n\t * @param {string} plugins.name The name of the plugin\n\t * @param {PluginSetup} plugins.init The init function\n\t * @public\n\t */\n\tregister(...plugins) {\n\t\tplugins.forEach((plugin) => {\n\t\t\tif (typeof plugin !== 'object' || !plugin.name || !plugin.init) {\n\t\t\t\tthrow new Error('Invalid JSEP plugin format');\n\t\t\t}\n\t\t\tif (this.registered[plugin.name]) {\n\t\t\t\t// already registered. Ignore.\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tplugin.init(this.jsep);\n\t\t\tthis.registered[plugin.name] = plugin;\n\t\t});\n\t}\n}\n\n// JavaScript Expression Parser (JSEP) 1.4.0\n\nclass Jsep {\n\t/**\n\t * @returns {string}\n\t */\n\tstatic get version() {\n\t\t// To be filled in by the template\n\t\treturn '1.4.0';\n\t}\n\n\t/**\n\t * @returns {string}\n\t */\n\tstatic toString() {\n\t\treturn 'JavaScript Expression Parser (JSEP) v' + Jsep.version;\n\t};\n\n\t// ==================== CONFIG ================================\n\t/**\n\t * @method addUnaryOp\n\t * @param {string} op_name The name of the unary op to add\n\t * @returns {Jsep}\n\t */\n\tstatic addUnaryOp(op_name) {\n\t\tJsep.max_unop_len = Math.max(op_name.length, Jsep.max_unop_len);\n\t\tJsep.unary_ops[op_name] = 1;\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method jsep.addBinaryOp\n\t * @param {string} op_name The name of the binary op to add\n\t * @param {number} precedence The precedence of the binary op (can be a float). Higher number = higher precedence\n\t * @param {boolean} [isRightAssociative=false] whether operator is right-associative\n\t * @returns {Jsep}\n\t */\n\tstatic addBinaryOp(op_name, precedence, isRightAssociative) {\n\t\tJsep.max_binop_len = Math.max(op_name.length, Jsep.max_binop_len);\n\t\tJsep.binary_ops[op_name] = precedence;\n\t\tif (isRightAssociative) {\n\t\t\tJsep.right_associative.add(op_name);\n\t\t}\n\t\telse {\n\t\t\tJsep.right_associative.delete(op_name);\n\t\t}\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method addIdentifierChar\n\t * @param {string} char The additional character to treat as a valid part of an identifier\n\t * @returns {Jsep}\n\t */\n\tstatic addIdentifierChar(char) {\n\t\tJsep.additional_identifier_chars.add(char);\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method addLiteral\n\t * @param {string} literal_name The name of the literal to add\n\t * @param {*} literal_value The value of the literal\n\t * @returns {Jsep}\n\t */\n\tstatic addLiteral(literal_name, literal_value) {\n\t\tJsep.literals[literal_name] = literal_value;\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeUnaryOp\n\t * @param {string} op_name The name of the unary op to remove\n\t * @returns {Jsep}\n\t */\n\tstatic removeUnaryOp(op_name) {\n\t\tdelete Jsep.unary_ops[op_name];\n\t\tif (op_name.length === Jsep.max_unop_len) {\n\t\t\tJsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);\n\t\t}\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeAllUnaryOps\n\t * @returns {Jsep}\n\t */\n\tstatic removeAllUnaryOps() {\n\t\tJsep.unary_ops = {};\n\t\tJsep.max_unop_len = 0;\n\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeIdentifierChar\n\t * @param {string} char The additional character to stop treating as a valid part of an identifier\n\t * @returns {Jsep}\n\t */\n\tstatic removeIdentifierChar(char) {\n\t\tJsep.additional_identifier_chars.delete(char);\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeBinaryOp\n\t * @param {string} op_name The name of the binary op to remove\n\t * @returns {Jsep}\n\t */\n\tstatic removeBinaryOp(op_name) {\n\t\tdelete Jsep.binary_ops[op_name];\n\n\t\tif (op_name.length === Jsep.max_binop_len) {\n\t\t\tJsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);\n\t\t}\n\t\tJsep.right_associative.delete(op_name);\n\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeAllBinaryOps\n\t * @returns {Jsep}\n\t */\n\tstatic removeAllBinaryOps() {\n\t\tJsep.binary_ops = {};\n\t\tJsep.max_binop_len = 0;\n\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeLiteral\n\t * @param {string} literal_name The name of the literal to remove\n\t * @returns {Jsep}\n\t */\n\tstatic removeLiteral(literal_name) {\n\t\tdelete Jsep.literals[literal_name];\n\t\treturn Jsep;\n\t}\n\n\t/**\n\t * @method removeAllLiterals\n\t * @returns {Jsep}\n\t */\n\tstatic removeAllLiterals() {\n\t\tJsep.literals = {};\n\n\t\treturn Jsep;\n\t}\n\t// ==================== END CONFIG ============================\n\n\n\t/**\n\t * @returns {string}\n\t */\n\tget char() {\n\t\treturn this.expr.charAt(this.index);\n\t}\n\n\t/**\n\t * @returns {number}\n\t */\n\tget code() {\n\t\treturn this.expr.charCodeAt(this.index);\n\t};\n\n\n\t/**\n\t * @param {string} expr a string with the passed in express\n\t * @returns Jsep\n\t */\n\tconstructor(expr) {\n\t\t// `index` stores the character number we are currently at\n\t\t// All of the gobbles below will modify `index` as we move along\n\t\tthis.expr = expr;\n\t\tthis.index = 0;\n\t}\n\n\t/**\n\t * static top-level parser\n\t * @returns {jsep.Expression}\n\t */\n\tstatic parse(expr) {\n\t\treturn (new Jsep(expr)).parse();\n\t}\n\n\t/**\n\t * Get the longest key length of any object\n\t * @param {object} obj\n\t * @returns {number}\n\t */\n\tstatic getMaxKeyLen(obj) {\n\t\treturn Math.max(0, ...Object.keys(obj).map(k => k.length));\n\t}\n\n\t/**\n\t * `ch` is a character code in the next three functions\n\t * @param {number} ch\n\t * @returns {boolean}\n\t */\n\tstatic isDecimalDigit(ch) {\n\t\treturn (ch >= 48 && ch <= 57); // 0...9\n\t}\n\n\t/**\n\t * Returns the precedence of a binary operator or `0` if it isn't a binary operator. Can be float.\n\t * @param {string} op_val\n\t * @returns {number}\n\t */\n\tstatic binaryPrecedence(op_val) {\n\t\treturn Jsep.binary_ops[op_val] || 0;\n\t}\n\n\t/**\n\t * Looks for start of identifier\n\t * @param {number} ch\n\t * @returns {boolean}\n\t */\n\tstatic isIdentifierStart(ch) {\n\t\treturn (ch >= 65 && ch <= 90) || // A...Z\n\t\t\t(ch >= 97 && ch <= 122) || // a...z\n\t\t\t(ch >= 128 && !Jsep.binary_ops[String.fromCharCode(ch)]) || // any non-ASCII that is not an operator\n\t\t\t(Jsep.additional_identifier_chars.has(String.fromCharCode(ch))); // additional characters\n\t}\n\n\t/**\n\t * @param {number} ch\n\t * @returns {boolean}\n\t */\n\tstatic isIdentifierPart(ch) {\n\t\treturn Jsep.isIdentifierStart(ch) || Jsep.isDecimalDigit(ch);\n\t}\n\n\t/**\n\t * throw error at index of the expression\n\t * @param {string} message\n\t * @throws\n\t */\n\tthrowError(message) {\n\t\tconst error = new Error(message + ' at character ' + this.index);\n\t\terror.index = this.index;\n\t\terror.description = message;\n\t\tthrow error;\n\t}\n\n\t/**\n\t * Run a given hook\n\t * @param {string} name\n\t * @param {jsep.Expression|false} [node]\n\t * @returns {?jsep.Expression}\n\t */\n\trunHook(name, node) {\n\t\tif (Jsep.hooks[name]) {\n\t\t\tconst env = { context: this, node };\n\t\t\tJsep.hooks.run(name, env);\n\t\t\treturn env.node;\n\t\t}\n\t\treturn node;\n\t}\n\n\t/**\n\t * Runs a given hook until one returns a node\n\t * @param {string} name\n\t * @returns {?jsep.Expression}\n\t */\n\tsearchHook(name) {\n\t\tif (Jsep.hooks[name]) {\n\t\t\tconst env = { context: this };\n\t\t\tJsep.hooks[name].find(function (callback) {\n\t\t\t\tcallback.call(env.context, env);\n\t\t\t\treturn env.node;\n\t\t\t});\n\t\t\treturn env.node;\n\t\t}\n\t}\n\n\t/**\n\t * Push `index` up to the next non-space character\n\t */\n\tgobbleSpaces() {\n\t\tlet ch = this.code;\n\t\t// Whitespace\n\t\twhile (ch === Jsep.SPACE_CODE\n\t\t|| ch === Jsep.TAB_CODE\n\t\t|| ch === Jsep.LF_CODE\n\t\t|| ch === Jsep.CR_CODE) {\n\t\t\tch = this.expr.charCodeAt(++this.index);\n\t\t}\n\t\tthis.runHook('gobble-spaces');\n\t}\n\n\t/**\n\t * Top-level method to parse all expressions and returns compound or single node\n\t * @returns {jsep.Expression}\n\t */\n\tparse() {\n\t\tthis.runHook('before-all');\n\t\tconst nodes = this.gobbleExpressions();\n\n\t\t// If there's only one expression just try returning the expression\n\t\tconst node = nodes.length === 1\n\t\t ? nodes[0]\n\t\t\t: {\n\t\t\t\ttype: Jsep.COMPOUND,\n\t\t\t\tbody: nodes\n\t\t\t};\n\t\treturn this.runHook('after-all', node);\n\t}\n\n\t/**\n\t * top-level parser (but can be reused within as well)\n\t * @param {number} [untilICode]\n\t * @returns {jsep.Expression[]}\n\t */\n\tgobbleExpressions(untilICode) {\n\t\tlet nodes = [], ch_i, node;\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tch_i = this.code;\n\n\t\t\t// Expressions can be separated by semicolons, commas, or just inferred without any\n\t\t\t// separators\n\t\t\tif (ch_i === Jsep.SEMCOL_CODE || ch_i === Jsep.COMMA_CODE) {\n\t\t\t\tthis.index++; // ignore separators\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Try to gobble each expression individually\n\t\t\t\tif (node = this.gobbleExpression()) {\n\t\t\t\t\tnodes.push(node);\n\t\t\t\t\t// If we weren't able to find a binary expression and are out of room, then\n\t\t\t\t\t// the expression passed in probably has too much\n\t\t\t\t}\n\t\t\t\telse if (this.index < this.expr.length) {\n\t\t\t\t\tif (ch_i === untilICode) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tthis.throwError('Unexpected \"' + this.char + '\"');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn nodes;\n\t}\n\n\t/**\n\t * The main parsing function.\n\t * @returns {?jsep.Expression}\n\t */\n\tgobbleExpression() {\n\t\tconst node = this.searchHook('gobble-expression') || this.gobbleBinaryExpression();\n\t\tthis.gobbleSpaces();\n\n\t\treturn this.runHook('after-expression', node);\n\t}\n\n\t/**\n\t * Search for the operation portion of the string (e.g. `+`, `===`)\n\t * Start by taking the longest possible binary operations (3 characters: `===`, `!==`, `>>>`)\n\t * and move down from 3 to 2 to 1 character until a matching binary operation is found\n\t * then, return that binary operation\n\t * @returns {string|boolean}\n\t */\n\tgobbleBinaryOp() {\n\t\tthis.gobbleSpaces();\n\t\tlet to_check = this.expr.substr(this.index, Jsep.max_binop_len);\n\t\tlet tc_len = to_check.length;\n\n\t\twhile (tc_len > 0) {\n\t\t\t// Don't accept a binary op when it is an identifier.\n\t\t\t// Binary ops that start with a identifier-valid character must be followed\n\t\t\t// by a non identifier-part valid character\n\t\t\tif (Jsep.binary_ops.hasOwnProperty(to_check) && (\n\t\t\t\t!Jsep.isIdentifierStart(this.code) ||\n\t\t\t\t(this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))\n\t\t\t)) {\n\t\t\t\tthis.index += tc_len;\n\t\t\t\treturn to_check;\n\t\t\t}\n\t\t\tto_check = to_check.substr(0, --tc_len);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * This function is responsible for gobbling an individual expression,\n\t * e.g. `1`, `1+2`, `a+(b*2)-Math.sqrt(2)`\n\t * @returns {?jsep.BinaryExpression}\n\t */\n\tgobbleBinaryExpression() {\n\t\tlet node, biop, prec, stack, biop_info, left, right, i, cur_biop;\n\n\t\t// First, try to get the leftmost thing\n\t\t// Then, check to see if there's a binary operator operating on that leftmost thing\n\t\t// Don't gobbleBinaryOp without a left-hand-side\n\t\tleft = this.gobbleToken();\n\t\tif (!left) {\n\t\t\treturn left;\n\t\t}\n\t\tbiop = this.gobbleBinaryOp();\n\n\t\t// If there wasn't a binary operator, just return the leftmost node\n\t\tif (!biop) {\n\t\t\treturn left;\n\t\t}\n\n\t\t// Otherwise, we need to start a stack to properly place the binary operations in their\n\t\t// precedence structure\n\t\tbiop_info = { value: biop, prec: Jsep.binaryPrecedence(biop), right_a: Jsep.right_associative.has(biop) };\n\n\t\tright = this.gobbleToken();\n\n\t\tif (!right) {\n\t\t\tthis.throwError(\"Expected expression after \" + biop);\n\t\t}\n\n\t\tstack = [left, biop_info, right];\n\n\t\t// Properly deal with precedence using [recursive descent](http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm)\n\t\twhile ((biop = this.gobbleBinaryOp())) {\n\t\t\tprec = Jsep.binaryPrecedence(biop);\n\n\t\t\tif (prec === 0) {\n\t\t\t\tthis.index -= biop.length;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tbiop_info = { value: biop, prec, right_a: Jsep.right_associative.has(biop) };\n\n\t\t\tcur_biop = biop;\n\n\t\t\t// Reduce: make a binary expression from the three topmost entries.\n\t\t\tconst comparePrev = prev => biop_info.right_a && prev.right_a\n\t\t\t\t? prec > prev.prec\n\t\t\t\t: prec <= prev.prec;\n\t\t\twhile ((stack.length > 2) && comparePrev(stack[stack.length - 2])) {\n\t\t\t\tright = stack.pop();\n\t\t\t\tbiop = stack.pop().value;\n\t\t\t\tleft = stack.pop();\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.BINARY_EXP,\n\t\t\t\t\toperator: biop,\n\t\t\t\t\tleft,\n\t\t\t\t\tright\n\t\t\t\t};\n\t\t\t\tstack.push(node);\n\t\t\t}\n\n\t\t\tnode = this.gobbleToken();\n\n\t\t\tif (!node) {\n\t\t\t\tthis.throwError(\"Expected expression after \" + cur_biop);\n\t\t\t}\n\n\t\t\tstack.push(biop_info, node);\n\t\t}\n\n\t\ti = stack.length - 1;\n\t\tnode = stack[i];\n\n\t\twhile (i > 1) {\n\t\t\tnode = {\n\t\t\t\ttype: Jsep.BINARY_EXP,\n\t\t\t\toperator: stack[i - 1].value,\n\t\t\t\tleft: stack[i - 2],\n\t\t\t\tright: node\n\t\t\t};\n\t\t\ti -= 2;\n\t\t}\n\n\t\treturn node;\n\t}\n\n\t/**\n\t * An individual part of a binary expression:\n\t * e.g. `foo.bar(baz)`, `1`, `\"abc\"`, `(a % 2)` (because it's in parenthesis)\n\t * @returns {boolean|jsep.Expression}\n\t */\n\tgobbleToken() {\n\t\tlet ch, to_check, tc_len, node;\n\n\t\tthis.gobbleSpaces();\n\t\tnode = this.searchHook('gobble-token');\n\t\tif (node) {\n\t\t\treturn this.runHook('after-token', node);\n\t\t}\n\n\t\tch = this.code;\n\n\t\tif (Jsep.isDecimalDigit(ch) || ch === Jsep.PERIOD_CODE) {\n\t\t\t// Char code 46 is a dot `.` which can start off a numeric literal\n\t\t\treturn this.gobbleNumericLiteral();\n\t\t}\n\n\t\tif (ch === Jsep.SQUOTE_CODE || ch === Jsep.DQUOTE_CODE) {\n\t\t\t// Single or double quotes\n\t\t\tnode = this.gobbleStringLiteral();\n\t\t}\n\t\telse if (ch === Jsep.OBRACK_CODE) {\n\t\t\tnode = this.gobbleArray();\n\t\t}\n\t\telse {\n\t\t\tto_check = this.expr.substr(this.index, Jsep.max_unop_len);\n\t\t\ttc_len = to_check.length;\n\n\t\t\twhile (tc_len > 0) {\n\t\t\t\t// Don't accept an unary op when it is an identifier.\n\t\t\t\t// Unary ops that start with a identifier-valid character must be followed\n\t\t\t\t// by a non identifier-part valid character\n\t\t\t\tif (Jsep.unary_ops.hasOwnProperty(to_check) && (\n\t\t\t\t\t!Jsep.isIdentifierStart(this.code) ||\n\t\t\t\t\t(this.index + to_check.length < this.expr.length && !Jsep.isIdentifierPart(this.expr.charCodeAt(this.index + to_check.length)))\n\t\t\t\t)) {\n\t\t\t\t\tthis.index += tc_len;\n\t\t\t\t\tconst argument = this.gobbleToken();\n\t\t\t\t\tif (!argument) {\n\t\t\t\t\t\tthis.throwError('missing unaryOp argument');\n\t\t\t\t\t}\n\t\t\t\t\treturn this.runHook('after-token', {\n\t\t\t\t\t\ttype: Jsep.UNARY_EXP,\n\t\t\t\t\t\toperator: to_check,\n\t\t\t\t\t\targument,\n\t\t\t\t\t\tprefix: true\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tto_check = to_check.substr(0, --tc_len);\n\t\t\t}\n\n\t\t\tif (Jsep.isIdentifierStart(ch)) {\n\t\t\t\tnode = this.gobbleIdentifier();\n\t\t\t\tif (Jsep.literals.hasOwnProperty(node.name)) {\n\t\t\t\t\tnode = {\n\t\t\t\t\t\ttype: Jsep.LITERAL,\n\t\t\t\t\t\tvalue: Jsep.literals[node.name],\n\t\t\t\t\t\traw: node.name,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\telse if (node.name === Jsep.this_str) {\n\t\t\t\t\tnode = { type: Jsep.THIS_EXP };\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (ch === Jsep.OPAREN_CODE) { // open parenthesis\n\t\t\t\tnode = this.gobbleGroup();\n\t\t\t}\n\t\t}\n\n\t\tif (!node) {\n\t\t\treturn this.runHook('after-token', false);\n\t\t}\n\n\t\tnode = this.gobbleTokenProperty(node);\n\t\treturn this.runHook('after-token', node);\n\t}\n\n\t/**\n\t * Gobble properties of of identifiers/strings/arrays/groups.\n\t * e.g. `foo`, `bar.baz`, `foo['bar'].baz`\n\t * It also gobbles function calls:\n\t * e.g. `Math.acos(obj.angle)`\n\t * @param {jsep.Expression} node\n\t * @returns {jsep.Expression}\n\t */\n\tgobbleTokenProperty(node) {\n\t\tthis.gobbleSpaces();\n\n\t\tlet ch = this.code;\n\t\twhile (ch === Jsep.PERIOD_CODE || ch === Jsep.OBRACK_CODE || ch === Jsep.OPAREN_CODE || ch === Jsep.QUMARK_CODE) {\n\t\t\tlet optional;\n\t\t\tif (ch === Jsep.QUMARK_CODE) {\n\t\t\t\tif (this.expr.charCodeAt(this.index + 1) !== Jsep.PERIOD_CODE) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\toptional = true;\n\t\t\t\tthis.index += 2;\n\t\t\t\tthis.gobbleSpaces();\n\t\t\t\tch = this.code;\n\t\t\t}\n\t\t\tthis.index++;\n\n\t\t\tif (ch === Jsep.OBRACK_CODE) {\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.MEMBER_EXP,\n\t\t\t\t\tcomputed: true,\n\t\t\t\t\tobject: node,\n\t\t\t\t\tproperty: this.gobbleExpression()\n\t\t\t\t};\n\t\t\t\tif (!node.property) {\n\t\t\t\t\tthis.throwError('Unexpected \"' + this.char + '\"');\n\t\t\t\t}\n\t\t\t\tthis.gobbleSpaces();\n\t\t\t\tch = this.code;\n\t\t\t\tif (ch !== Jsep.CBRACK_CODE) {\n\t\t\t\t\tthis.throwError('Unclosed [');\n\t\t\t\t}\n\t\t\t\tthis.index++;\n\t\t\t}\n\t\t\telse if (ch === Jsep.OPAREN_CODE) {\n\t\t\t\t// A function call is being made; gobble all the arguments\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.CALL_EXP,\n\t\t\t\t\t'arguments': this.gobbleArguments(Jsep.CPAREN_CODE),\n\t\t\t\t\tcallee: node\n\t\t\t\t};\n\t\t\t}\n\t\t\telse if (ch === Jsep.PERIOD_CODE || optional) {\n\t\t\t\tif (optional) {\n\t\t\t\t\tthis.index--;\n\t\t\t\t}\n\t\t\t\tthis.gobbleSpaces();\n\t\t\t\tnode = {\n\t\t\t\t\ttype: Jsep.MEMBER_EXP,\n\t\t\t\t\tcomputed: false,\n\t\t\t\t\tobject: node,\n\t\t\t\t\tproperty: this.gobbleIdentifier(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (optional) {\n\t\t\t\tnode.optional = true;\n\t\t\t} // else leave undefined for compatibility with esprima\n\n\t\t\tthis.gobbleSpaces();\n\t\t\tch = this.code;\n\t\t}\n\n\t\treturn node;\n\t}\n\n\t/**\n\t * Parse simple numeric literals: `12`, `3.4`, `.5`. Do this by using a string to\n\t * keep track of everything in the numeric literal and then calling `parseFloat` on that string\n\t * @returns {jsep.Literal}\n\t */\n\tgobbleNumericLiteral() {\n\t\tlet number = '', ch, chCode;\n\n\t\twhile (Jsep.isDecimalDigit(this.code)) {\n\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t}\n\n\t\tif (this.code === Jsep.PERIOD_CODE) { // can start with a decimal marker\n\t\t\tnumber += this.expr.charAt(this.index++);\n\n\t\t\twhile (Jsep.isDecimalDigit(this.code)) {\n\t\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\t}\n\t\t}\n\n\t\tch = this.char;\n\n\t\tif (ch === 'e' || ch === 'E') { // exponent marker\n\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\tch = this.char;\n\n\t\t\tif (ch === '+' || ch === '-') { // exponent sign\n\t\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\t}\n\n\t\t\twhile (Jsep.isDecimalDigit(this.code)) { // exponent itself\n\t\t\t\tnumber += this.expr.charAt(this.index++);\n\t\t\t}\n\n\t\t\tif (!Jsep.isDecimalDigit(this.expr.charCodeAt(this.index - 1)) ) {\n\t\t\t\tthis.throwError('Expected exponent (' + number + this.char + ')');\n\t\t\t}\n\t\t}\n\n\t\tchCode = this.code;\n\n\t\t// Check to make sure this isn't a variable name that start with a number (123abc)\n\t\tif (Jsep.isIdentifierStart(chCode)) {\n\t\t\tthis.throwError('Variable names cannot start with a number (' +\n\t\t\t\tnumber + this.char + ')');\n\t\t}\n\t\telse if (chCode === Jsep.PERIOD_CODE || (number.length === 1 && number.charCodeAt(0) === Jsep.PERIOD_CODE)) {\n\t\t\tthis.throwError('Unexpected period');\n\t\t}\n\n\t\treturn {\n\t\t\ttype: Jsep.LITERAL,\n\t\t\tvalue: parseFloat(number),\n\t\t\traw: number\n\t\t};\n\t}\n\n\t/**\n\t * Parses a string literal, staring with single or double quotes with basic support for escape codes\n\t * e.g. `\"hello world\"`, `'this is\\nJSEP'`\n\t * @returns {jsep.Literal}\n\t */\n\tgobbleStringLiteral() {\n\t\tlet str = '';\n\t\tconst startIndex = this.index;\n\t\tconst quote = this.expr.charAt(this.index++);\n\t\tlet closed = false;\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tlet ch = this.expr.charAt(this.index++);\n\n\t\t\tif (ch === quote) {\n\t\t\t\tclosed = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (ch === '\\\\') {\n\t\t\t\t// Check for all of the common escape codes\n\t\t\t\tch = this.expr.charAt(this.index++);\n\n\t\t\t\tswitch (ch) {\n\t\t\t\t\tcase 'n': str += '\\n'; break;\n\t\t\t\t\tcase 'r': str += '\\r'; break;\n\t\t\t\t\tcase 't': str += '\\t'; break;\n\t\t\t\t\tcase 'b': str += '\\b'; break;\n\t\t\t\t\tcase 'f': str += '\\f'; break;\n\t\t\t\t\tcase 'v': str += '\\x0B'; break;\n\t\t\t\t\tdefault : str += ch;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tstr += ch;\n\t\t\t}\n\t\t}\n\n\t\tif (!closed) {\n\t\t\tthis.throwError('Unclosed quote after \"' + str + '\"');\n\t\t}\n\n\t\treturn {\n\t\t\ttype: Jsep.LITERAL,\n\t\t\tvalue: str,\n\t\t\traw: this.expr.substring(startIndex, this.index),\n\t\t};\n\t}\n\n\t/**\n\t * Gobbles only identifiers\n\t * e.g.: `foo`, `_value`, `$x1`\n\t * Also, this function checks if that identifier is a literal:\n\t * (e.g. `true`, `false`, `null`) or `this`\n\t * @returns {jsep.Identifier}\n\t */\n\tgobbleIdentifier() {\n\t\tlet ch = this.code, start = this.index;\n\n\t\tif (Jsep.isIdentifierStart(ch)) {\n\t\t\tthis.index++;\n\t\t}\n\t\telse {\n\t\t\tthis.throwError('Unexpected ' + this.char);\n\t\t}\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tch = this.code;\n\n\t\t\tif (Jsep.isIdentifierPart(ch)) {\n\t\t\t\tthis.index++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\ttype: Jsep.IDENTIFIER,\n\t\t\tname: this.expr.slice(start, this.index),\n\t\t};\n\t}\n\n\t/**\n\t * Gobbles a list of arguments within the context of a function call\n\t * or array literal. This function also assumes that the opening character\n\t * `(` or `[` has already been gobbled, and gobbles expressions and commas\n\t * until the terminator character `)` or `]` is encountered.\n\t * e.g. `foo(bar, baz)`, `my_func()`, or `[bar, baz]`\n\t * @param {number} termination\n\t * @returns {jsep.Expression[]}\n\t */\n\tgobbleArguments(termination) {\n\t\tconst args = [];\n\t\tlet closed = false;\n\t\tlet separator_count = 0;\n\n\t\twhile (this.index < this.expr.length) {\n\t\t\tthis.gobbleSpaces();\n\t\t\tlet ch_i = this.code;\n\n\t\t\tif (ch_i === termination) { // done parsing\n\t\t\t\tclosed = true;\n\t\t\t\tthis.index++;\n\n\t\t\t\tif (termination === Jsep.CPAREN_CODE && separator_count && separator_count >= args.length){\n\t\t\t\t\tthis.throwError('Unexpected token ' + String.fromCharCode(termination));\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (ch_i === Jsep.COMMA_CODE) { // between expressions\n\t\t\t\tthis.index++;\n\t\t\t\tseparator_count++;\n\n\t\t\t\tif (separator_count !== args.length) { // missing argument\n\t\t\t\t\tif (termination === Jsep.CPAREN_CODE) {\n\t\t\t\t\t\tthis.throwError('Unexpected token ,');\n\t\t\t\t\t}\n\t\t\t\t\telse if (termination === Jsep.CBRACK_CODE) {\n\t\t\t\t\t\tfor (let arg = args.length; arg < separator_count; arg++) {\n\t\t\t\t\t\t\targs.push(null);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (args.length !== separator_count && separator_count !== 0) {\n\t\t\t\t// NOTE: `&& separator_count !== 0` allows for either all commas, or all spaces as arguments\n\t\t\t\tthis.throwError('Expected comma');\n\t\t\t}\n\t\t\telse {\n\t\t\t\tconst node = this.gobbleExpression();\n\n\t\t\t\tif (!node || node.type === Jsep.COMPOUND) {\n\t\t\t\t\tthis.throwError('Expected comma');\n\t\t\t\t}\n\n\t\t\t\targs.push(node);\n\t\t\t}\n\t\t}\n\n\t\tif (!closed) {\n\t\t\tthis.throwError('Expected ' + String.fromCharCode(termination));\n\t\t}\n\n\t\treturn args;\n\t}\n\n\t/**\n\t * Responsible for parsing a group of things within parentheses `()`\n\t * that have no identifier in front (so not a function call)\n\t * This function assumes that it needs to gobble the opening parenthesis\n\t * and then tries to gobble everything within that parenthesis, assuming\n\t * that the next thing it should see is the close parenthesis. If not,\n\t * then the expression probably doesn't have a `)`\n\t * @returns {boolean|jsep.Expression}\n\t */\n\tgobbleGroup() {\n\t\tthis.index++;\n\t\tlet nodes = this.gobbleExpressions(Jsep.CPAREN_CODE);\n\t\tif (this.code === Jsep.CPAREN_CODE) {\n\t\t\tthis.index++;\n\t\t\tif (nodes.length === 1) {\n\t\t\t\treturn nodes[0];\n\t\t\t}\n\t\t\telse if (!nodes.length) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treturn {\n\t\t\t\t\ttype: Jsep.SEQUENCE_EXP,\n\t\t\t\t\texpressions: nodes,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tthis.throwError('Unclosed (');\n\t\t}\n\t}\n\n\t/**\n\t * Responsible for parsing Array literals `[1, 2, 3]`\n\t * This function assumes that it needs to gobble the opening bracket\n\t * and then tries to gobble the expressions as arguments.\n\t * @returns {jsep.ArrayExpression}\n\t */\n\tgobbleArray() {\n\t\tthis.index++;\n\n\t\treturn {\n\t\t\ttype: Jsep.ARRAY_EXP,\n\t\t\telements: this.gobbleArguments(Jsep.CBRACK_CODE)\n\t\t};\n\t}\n}\n\n// Static fields:\nconst hooks = new Hooks();\nObject.assign(Jsep, {\n\thooks,\n\tplugins: new Plugins(Jsep),\n\n\t// Node Types\n\t// ----------\n\t// This is the full set of types that any JSEP node can be.\n\t// Store them here to save space when minified\n\tCOMPOUND: 'Compound',\n\tSEQUENCE_EXP: 'SequenceExpression',\n\tIDENTIFIER: 'Identifier',\n\tMEMBER_EXP: 'MemberExpression',\n\tLITERAL: 'Literal',\n\tTHIS_EXP: 'ThisExpression',\n\tCALL_EXP: 'CallExpression',\n\tUNARY_EXP: 'UnaryExpression',\n\tBINARY_EXP: 'BinaryExpression',\n\tARRAY_EXP: 'ArrayExpression',\n\n\tTAB_CODE: 9,\n\tLF_CODE: 10,\n\tCR_CODE: 13,\n\tSPACE_CODE: 32,\n\tPERIOD_CODE: 46, // '.'\n\tCOMMA_CODE: 44, // ','\n\tSQUOTE_CODE: 39, // single quote\n\tDQUOTE_CODE: 34, // double quotes\n\tOPAREN_CODE: 40, // (\n\tCPAREN_CODE: 41, // )\n\tOBRACK_CODE: 91, // [\n\tCBRACK_CODE: 93, // ]\n\tQUMARK_CODE: 63, // ?\n\tSEMCOL_CODE: 59, // ;\n\tCOLON_CODE: 58, // :\n\n\n\t// Operations\n\t// ----------\n\t// Use a quickly-accessible map to store all of the unary operators\n\t// Values are set to `1` (it really doesn't matter)\n\tunary_ops: {\n\t\t'-': 1,\n\t\t'!': 1,\n\t\t'~': 1,\n\t\t'+': 1\n\t},\n\n\t// Also use a map for the binary operations but set their values to their\n\t// binary precedence for quick reference (higher number = higher precedence)\n\t// see [Order of operations](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence)\n\tbinary_ops: {\n\t\t'||': 1, '??': 1,\n\t\t'&&': 2, '|': 3, '^': 4, '&': 5,\n\t\t'==': 6, '!=': 6, '===': 6, '!==': 6,\n\t\t'<': 7, '>': 7, '<=': 7, '>=': 7,\n\t\t'<<': 8, '>>': 8, '>>>': 8,\n\t\t'+': 9, '-': 9,\n\t\t'*': 10, '/': 10, '%': 10,\n\t\t'**': 11,\n\t},\n\n\t// sets specific binary_ops as right-associative\n\tright_associative: new Set(['**']),\n\n\t// Additional valid identifier chars, apart from a-z, A-Z and 0-9 (except on the starting char)\n\tadditional_identifier_chars: new Set(['$', '_']),\n\n\t// Literals\n\t// ----------\n\t// Store the values to return for the various literals we may encounter\n\tliterals: {\n\t\t'true': true,\n\t\t'false': false,\n\t\t'null': null\n\t},\n\n\t// Except for `this`, which is special. This could be changed to something like `'self'` as well\n\tthis_str: 'this',\n});\nJsep.max_unop_len = Jsep.getMaxKeyLen(Jsep.unary_ops);\nJsep.max_binop_len = Jsep.getMaxKeyLen(Jsep.binary_ops);\n\n// Backward Compatibility:\nconst jsep = expr => (new Jsep(expr)).parse();\nconst stdClassProps = Object.getOwnPropertyNames(class Test{});\nObject.getOwnPropertyNames(Jsep)\n\t.filter(prop => !stdClassProps.includes(prop) && jsep[prop] === undefined)\n\t.forEach((m) => {\n\t\tjsep[m] = Jsep[m];\n\t});\njsep.Jsep = Jsep; // allows for const { Jsep } = require('jsep');\n\nconst CONDITIONAL_EXP = 'ConditionalExpression';\n\nvar ternary = {\n\tname: 'ternary',\n\n\tinit(jsep) {\n\t\t// Ternary expression: test ? consequent : alternate\n\t\tjsep.hooks.add('after-expression', function gobbleTernary(env) {\n\t\t\tif (env.node && this.code === jsep.QUMARK_CODE) {\n\t\t\t\tthis.index++;\n\t\t\t\tconst test = env.node;\n\t\t\t\tconst consequent = this.gobbleExpression();\n\n\t\t\t\tif (!consequent) {\n\t\t\t\t\tthis.throwError('Expected expression');\n\t\t\t\t}\n\n\t\t\t\tthis.gobbleSpaces();\n\n\t\t\t\tif (this.code === jsep.COLON_CODE) {\n\t\t\t\t\tthis.index++;\n\t\t\t\t\tconst alternate = this.gobbleExpression();\n\n\t\t\t\t\tif (!alternate) {\n\t\t\t\t\t\tthis.throwError('Expected expression');\n\t\t\t\t\t}\n\t\t\t\t\tenv.node = {\n\t\t\t\t\t\ttype: CONDITIONAL_EXP,\n\t\t\t\t\t\ttest,\n\t\t\t\t\t\tconsequent,\n\t\t\t\t\t\talternate,\n\t\t\t\t\t};\n\n\t\t\t\t\t// check for operators of higher priority than ternary (i.e. assignment)\n\t\t\t\t\t// jsep sets || at 1, and assignment at 0.9, and conditional should be between them\n\t\t\t\t\tif (test.operator && jsep.binary_ops[test.operator] <= 0.9) {\n\t\t\t\t\t\tlet newTest = test;\n\t\t\t\t\t\twhile (newTest.right.operator && jsep.binary_ops[newTest.right.operator] <= 0.9) {\n\t\t\t\t\t\t\tnewTest = newTest.right;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tenv.node.test = newTest.right;\n\t\t\t\t\t\tnewTest.right = env.node;\n\t\t\t\t\t\tenv.node = test;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.throwError('Expected :');\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t},\n};\n\n// Add default plugins:\n\njsep.plugins.register(ternary);\n\nexport { Jsep, jsep as default };\n","const FSLASH_CODE = 47; // '/'\nconst BSLASH_CODE = 92; // '\\\\'\n\nvar index = {\n\tname: 'regex',\n\n\tinit(jsep) {\n\t\t// Regex literal: /abc123/ig\n\t\tjsep.hooks.add('gobble-token', function gobbleRegexLiteral(env) {\n\t\t\tif (this.code === FSLASH_CODE) {\n\t\t\t\tconst patternIndex = ++this.index;\n\n\t\t\t\tlet inCharSet = false;\n\t\t\t\twhile (this.index < this.expr.length) {\n\t\t\t\t\tif (this.code === FSLASH_CODE && !inCharSet) {\n\t\t\t\t\t\tconst pattern = this.expr.slice(patternIndex, this.index);\n\n\t\t\t\t\t\tlet flags = '';\n\t\t\t\t\t\twhile (++this.index < this.expr.length) {\n\t\t\t\t\t\t\tconst code = this.code;\n\t\t\t\t\t\t\tif ((code >= 97 && code <= 122) // a...z\n\t\t\t\t\t\t\t\t|| (code >= 65 && code <= 90) // A...Z\n\t\t\t\t\t\t\t\t|| (code >= 48 && code <= 57)) { // 0-9\n\t\t\t\t\t\t\t\tflags += this.char;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet value;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tvalue = new RegExp(pattern, flags);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t\tthis.throwError(e.message);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tenv.node = {\n\t\t\t\t\t\t\ttype: jsep.LITERAL,\n\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\traw: this.expr.slice(patternIndex - 1, this.index),\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\t// allow . [] and () after regex: /regex/.test(a)\n\t\t\t\t\t\tenv.node = this.gobbleTokenProperty(env.node);\n\t\t\t\t\t\treturn env.node;\n\t\t\t\t\t}\n\t\t\t\t\tif (this.code === jsep.OBRACK_CODE) {\n\t\t\t\t\t\tinCharSet = true;\n\t\t\t\t\t}\n\t\t\t\t\telse if (inCharSet && this.code === jsep.CBRACK_CODE) {\n\t\t\t\t\t\tinCharSet = false;\n\t\t\t\t\t}\n\t\t\t\t\tthis.index += this.code === BSLASH_CODE ? 2 : 1;\n\t\t\t\t}\n\t\t\t\tthis.throwError('Unclosed Regex');\n\t\t\t}\n\t\t});\n\t},\n};\n\nexport { index as default };\n","const PLUS_CODE = 43; // +\nconst MINUS_CODE = 45; // -\n\nconst plugin = {\n\tname: 'assignment',\n\n\tassignmentOperators: new Set([\n\t\t'=',\n\t\t'*=',\n\t\t'**=',\n\t\t'/=',\n\t\t'%=',\n\t\t'+=',\n\t\t'-=',\n\t\t'<<=',\n\t\t'>>=',\n\t\t'>>>=',\n\t\t'&=',\n\t\t'^=',\n\t\t'|=',\n\t\t'||=',\n\t\t'&&=',\n\t\t'??=',\n\t]),\n\tupdateOperators: [PLUS_CODE, MINUS_CODE],\n\tassignmentPrecedence: 0.9,\n\n\tinit(jsep) {\n\t\tconst updateNodeTypes = [jsep.IDENTIFIER, jsep.MEMBER_EXP];\n\t\tplugin.assignmentOperators.forEach(op => jsep.addBinaryOp(op, plugin.assignmentPrecedence, true));\n\n\t\tjsep.hooks.add('gobble-token', function gobbleUpdatePrefix(env) {\n\t\t\tconst code = this.code;\n\t\t\tif (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\n\t\t\t\tthis.index += 2;\n\t\t\t\tenv.node = {\n\t\t\t\t\ttype: 'UpdateExpression',\n\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\n\t\t\t\t\targument: this.gobbleTokenProperty(this.gobbleIdentifier()),\n\t\t\t\t\tprefix: true,\n\t\t\t\t};\n\t\t\t\tif (!env.node.argument || !updateNodeTypes.includes(env.node.argument.type)) {\n\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tjsep.hooks.add('after-token', function gobbleUpdatePostfix(env) {\n\t\t\tif (env.node) {\n\t\t\t\tconst code = this.code;\n\t\t\t\tif (plugin.updateOperators.some(c => c === code && c === this.expr.charCodeAt(this.index + 1))) {\n\t\t\t\t\tif (!updateNodeTypes.includes(env.node.type)) {\n\t\t\t\t\t\tthis.throwError(`Unexpected ${env.node.operator}`);\n\t\t\t\t\t}\n\t\t\t\t\tthis.index += 2;\n\t\t\t\t\tenv.node = {\n\t\t\t\t\t\ttype: 'UpdateExpression',\n\t\t\t\t\t\toperator: code === PLUS_CODE ? '++' : '--',\n\t\t\t\t\t\targument: env.node,\n\t\t\t\t\t\tprefix: false,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tjsep.hooks.add('after-expression', function gobbleAssignment(env) {\n\t\t\tif (env.node) {\n\t\t\t\t// Note: Binaries can be chained in a single expression to respect\n\t\t\t\t// operator precedence (i.e. a = b = 1 + 2 + 3)\n\t\t\t\t// Update all binary assignment nodes in the tree\n\t\t\t\tupdateBinariesToAssignments(env.node);\n\t\t\t}\n\t\t});\n\n\t\tfunction updateBinariesToAssignments(node) {\n\t\t\tif (plugin.assignmentOperators.has(node.operator)) {\n\t\t\t\tnode.type = 'AssignmentExpression';\n\t\t\t\tupdateBinariesToAssignments(node.left);\n\t\t\t\tupdateBinariesToAssignments(node.right);\n\t\t\t}\n\t\t\telse if (!node.operator) {\n\t\t\t\tObject.values(node).forEach((val) => {\n\t\t\t\t\tif (val && typeof val === 'object') {\n\t\t\t\t\t\tupdateBinariesToAssignments(val);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t},\n};\n\nexport { plugin as default };\n","/* eslint-disable unicorn/no-top-level-side-effects -- Temporary? */\n/* eslint-disable no-bitwise -- Convenient */\nimport jsep from 'jsep';\nimport jsepRegex from '@jsep-plugin/regex';\nimport jsepAssignment from '@jsep-plugin/assignment';\n\n/**\n * @import {EvaluatedResult, UnknownResult} from './jsonpath.js';\n */\n\n/**\n * @typedef {any} AssignmentExpression\n */\n\n/**\n * @typedef {any} Substitution\n */\n\n/**\n * @typedef {any} AnyParameter\n */\n\n/**\n * @typedef {Record} Substitutions\n */\n\n// register plugins\njsep.plugins.register(jsepRegex, jsepAssignment);\njsep.addUnaryOp('typeof');\njsep.addUnaryOp('void');\njsep.addLiteral('null', null);\njsep.addLiteral('undefined', undefined);\n\nconst BLOCKED_PROTO_PROPERTIES = new Set([\n 'constructor',\n '__proto__',\n '__defineGetter__',\n '__defineSetter__',\n '__lookupGetter__',\n '__lookupSetter__'\n]);\n\n// Every function-constructor variant, along with the invocation helpers which\n// could otherwise reach them indirectly, e.g., `Function.call(0, 'code')()`,\n// plus whichever BLOCKED_PROTO_PROPERTIES names resolve to an own method on\n// Object.prototype (e.g. `__defineGetter__`) - an own-property access on a\n// shared prototype (`@.prototype.__defineGetter__`) bypasses the\n// inherited-only name check below, so those methods need blocking by value.\n/** @type {WeakSet} */\nconst BLOCKED_FUNCTIONS = new WeakSet([\n Function,\n // eslint-disable-next-line no-empty-function -- Only need the constructor\n function *() {}.constructor,\n // eslint-disable-next-line no-empty-function -- Only need the constructor\n async function () {}.constructor,\n // eslint-disable-next-line no-empty-function -- Only need the constructor\n async function *() {}.constructor,\n Function.prototype.call,\n Function.prototype.apply,\n Function.prototype.bind,\n Reflect.apply,\n Reflect.construct,\n ...[...BLOCKED_PROTO_PROPERTIES]\n .map((name) => Reflect.get(Object.prototype, name))\n .filter((value) => typeof value === 'function')\n]);\n\n/**\n * @param {UnknownResult} value\n * @returns {boolean}\n */\nconst isBlockedFunction = (value) => {\n return typeof value === 'function' && BLOCKED_FUNCTIONS.has(value);\n};\n\n/**\n * Guarded `obj[prop]`, applying the same restrictions as a MemberExpression.\n * @param {UnknownResult} obj\n * @param {string} prop\n * @returns {UnknownResult}\n */\nconst getSafeProperty = (obj, prop) => {\n if (obj === undefined || obj === null) {\n throw new TypeError(\n `Cannot read properties of ${obj} (reading '${prop}')`\n );\n }\n if (!Object.hasOwn(obj, prop) && BLOCKED_PROTO_PROPERTIES.has(prop)) {\n throw new TypeError(\n `Cannot read properties of ${obj} (reading '${prop}')`\n );\n }\n const result = /** @type {Record} */ (obj)[prop];\n if (isBlockedFunction(result)) {\n throw new TypeError('Function constructor is disabled');\n }\n return result;\n};\n\n/**\n * @typedef {Record<\n * string,\n * (a: AnyParameter, b: AnyParameter) => UnknownResult\n * >} OperatorTable\n */\n\n// eslint-disable-next-line @stylistic/max-len -- Long\nconst BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */ ({\n '||': (a, b) => a || b(),\n '??': (a, b) => a ?? b(),\n '&&': (a, b) => a && b(),\n '|': (a, b) => a | b(),\n '^': (a, b) => a ^ b(),\n '&': (a, b) => a & b(),\n // eslint-disable-next-line eqeqeq -- API\n '==': (a, b) => a == b(),\n // eslint-disable-next-line eqeqeq -- API\n '!=': (a, b) => a != b(),\n '===': (a, b) => a === b(),\n '!==': (a, b) => a !== b(),\n '<': (a, b) => a < b(),\n '>': (a, b) => a > b(),\n '<=': (a, b) => a <= b(),\n '>=': (a, b) => a >= b(),\n '<<': (a, b) => a << b(),\n '>>': (a, b) => a >> b(),\n '>>>': (a, b) => a >>> b(),\n '+': (a, b) => a + b(),\n '-': (a, b) => a - b(),\n '*': (a, b) => a * b(),\n '/': (a, b) => a / b(),\n '%': (a, b) => a % b(),\n '**': (a, b) => a ** b()\n}));\n\n/**\n * @typedef {{\n * [key: string]: (a: AnyParameter) => UnknownResult\n * }} UnaryOperatorTable\n */\n\n// eslint-disable-next-line @stylistic/max-len -- Long\nconst UNOPS = Object.assign(Object.create(null), /** @type {UnaryOperatorTable} */ ({\n '-': (a) => -(/** @type {EvaluatedResult} */ (a)),\n '!': (a) => !a,\n '~': (a) => ~(/** @type {EvaluatedResult} */ (a)),\n // eslint-disable-next-line no-implicit-coercion -- API\n '+': (a) => +(/** @type {EvaluatedResult} */ (a)),\n typeof: (a) => typeof a,\n void: () => undefined\n}));\n\nconst SafeEval = {\n /**\n * @param {jsep.Expression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalAst (ast, subs) {\n switch (ast.type) {\n case 'BinaryExpression':\n case 'LogicalExpression':\n return SafeEval.evalBinaryExpression(\n /** @type {jsep.BinaryExpression} */ (ast),\n subs\n );\n case 'Compound':\n return SafeEval.evalCompound(\n /** @type {jsep.Compound} */ (ast),\n subs\n );\n case 'ConditionalExpression':\n return SafeEval.evalConditionalExpression(\n /** @type {jsep.ConditionalExpression} */ (ast),\n subs\n );\n case 'Identifier':\n return SafeEval.evalIdentifier(\n /** @type {jsep.Identifier} */ (ast),\n subs\n );\n case 'Literal':\n return SafeEval.evalLiteral(/** @type {jsep.Literal} */ (ast));\n case 'MemberExpression':\n return SafeEval.evalMemberExpression(\n /** @type {jsep.MemberExpression} */ (ast),\n subs\n );\n case 'UnaryExpression':\n return SafeEval.evalUnaryExpression(\n /** @type {jsep.UnaryExpression} */ (ast),\n subs\n );\n case 'ArrayExpression':\n return SafeEval.evalArrayExpression(\n /** @type {jsep.ArrayExpression} */ (ast),\n subs\n );\n case 'CallExpression':\n return SafeEval.evalCallExpression(\n /** @type {jsep.CallExpression} */ (ast),\n subs\n );\n case 'AssignmentExpression':\n return SafeEval.evalAssignmentExpression(\n /** @type {AssignmentExpression} */ (ast),\n subs\n );\n default:\n throw new SyntaxError('Unexpected expression', {\n cause: ast\n });\n }\n },\n\n /**\n * @param {jsep.BinaryExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalBinaryExpression (ast, subs) {\n /* c8 ignore next 3 -- Defensive guard for malformed ASTs */\n if (!Object.hasOwn(BINOPS, ast.operator)) {\n throw new SyntaxError(`Unknown binary operator: ${ast.operator}`);\n }\n const result = BINOPS[ast.operator](\n SafeEval.evalAst(ast.left, subs),\n () => SafeEval.evalAst(ast.right, subs)\n );\n return result;\n },\n\n /**\n * @param {jsep.Compound} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalCompound (ast, subs) {\n let last;\n for (let i = 0; i < ast.body.length; i++) {\n if (\n ast.body[i].type === 'Identifier' &&\n ['var', 'let', 'const'].includes(\n /** @type {jsep.Identifier} */\n (ast.body[i]).name\n ) &&\n Object.hasOwn(ast.body, i + 1) &&\n ast.body[i + 1].type === 'AssignmentExpression'\n ) {\n // var x=2; is detected as\n // [{Identifier var}, {AssignmentExpression x=2}]\n i += 1;\n }\n const expr = ast.body[i];\n last = SafeEval.evalAst(expr, subs);\n }\n return last;\n },\n\n /**\n * @param {jsep.ConditionalExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalConditionalExpression (ast, subs) {\n return SafeEval.evalAst(ast.test, subs)\n ? SafeEval.evalAst(ast.consequent, subs)\n : SafeEval.evalAst(ast.alternate, subs);\n },\n\n /**\n * @param {jsep.Identifier} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalIdentifier (ast, subs) {\n if (Object.hasOwn(subs, ast.name)) {\n return subs[ast.name];\n }\n throw new ReferenceError(`${ast.name} is not defined`);\n },\n\n /**\n * @param {jsep.Literal} ast\n * @returns {UnknownResult}\n */\n evalLiteral (ast) {\n return ast.value;\n },\n\n /**\n * @param {jsep.MemberExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalMemberExpression (ast, subs) {\n const prop = String(\n // NOTE: `String(value)` throws error when\n // value has overwritten the toString method to return non-string\n // i.e. `value = {toString: () => []}`\n ast.computed\n ? SafeEval.evalAst(ast.property, subs) // `object[property]`\n : ast.property.name // `object.property` property is Identifier\n );\n const obj = SafeEval.evalAst(ast.object, subs);\n const result = getSafeProperty(obj, prop);\n if (typeof result === 'function') {\n return result.bind(obj); // arrow functions aren't affected by bind.\n }\n return result;\n },\n\n /**\n * @param {jsep.UnaryExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalUnaryExpression (ast, subs) {\n /* c8 ignore next 3 -- Defensive guard for malformed ASTs */\n if (!Object.hasOwn(UNOPS, ast.operator)) {\n throw new SyntaxError(`Unknown unary operator: ${ast.operator}`);\n }\n const operand = SafeEval.evalAst(ast.argument, subs);\n return UNOPS[ast.operator](operand);\n },\n\n /**\n * @param {jsep.ArrayExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalArrayExpression (ast, subs) {\n return ast.elements.map((el) => SafeEval.evalAst(\n /** @type {jsep.Expression} */\n (el),\n subs\n ));\n },\n\n /**\n * @param {jsep.CallExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalCallExpression (ast, subs) {\n const args = ast.arguments.map((arg) => SafeEval.evalAst(arg, subs));\n const func = SafeEval.evalAst(ast.callee, subs);\n if (\n isBlockedFunction(func) ||\n args.some((arg) => isBlockedFunction(arg))\n ) {\n throw new Error('Function constructor is disabled');\n }\n return (/** @type {(...args: AnyParameter[]) => UnknownResult} */ (\n func\n ))(...args);\n },\n\n /**\n * @param {AssignmentExpression} ast\n * @param {Substitutions} subs\n * @returns {UnknownResult}\n */\n evalAssignmentExpression (ast, subs) {\n if (ast.left.type !== 'Identifier') {\n throw new SyntaxError('Invalid left-hand side in assignment');\n }\n const id = /** @type {jsep.Identifier} */ (\n ast.left\n ).name;\n const value = SafeEval.evalAst(ast.right, subs);\n subs[id] = value;\n return subs[id];\n }\n};\n\n/**\n * A replacement for NodeJS' VM.Script which is also {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | Content Security Policy} friendly.\n */\nclass SafeScript {\n /**\n * @param {string} expr Expression to evaluate\n */\n constructor (expr) {\n this.code = expr;\n this.ast = /** @type {unknown} */ (jsep(this.code));\n }\n\n /**\n * @param {object} context Object whose items will be added\n * to evaluation\n * @returns {EvaluatedResult} Result of evaluated code\n */\n runInNewContext (context) {\n // `Object.create(null)` creates a prototypeless object\n const keyMap = Object.assign(Object.create(null), context);\n return SafeEval.evalAst(\n /** @type {jsep.Expression} */ (this.ast),\n keyMap\n );\n }\n}\n\nexport {SafeScript, getSafeProperty};\n","/**\n * @param {unknown} val\n */\nexport const toStringTag = (val) => {\n return Object.prototype.toString.call(val).slice(8, -1);\n};\n\n/**\n * @param {unknown} a\n * @param {unknown} b\n */\nexport const hasConstructor = (a, b) => {\n return Function.prototype.toString.call(\n Object.getPrototypeOf(a).constructor\n ) === Function.prototype.toString.call(\n b\n );\n};\n","/* eslint-disable camelcase -- Convenient for escaping */\n/* eslint-disable class-methods-use-this -- Consistent monkey-patching */\n/* eslint-disable unicorn/prefer-private-class-fields -- Allow\n monkey-patching */\nimport {SafeScript, getSafeProperty} from './Safe-Script.js';\nimport {toStringTag} from './utils.js';\n\nconst scriptCache = new Map();\nconst pathCache = new Map();\n\n/**\n * @typedef {any} AnyInput\n */\n\n/**\n * @typedef {((...args: any[]) => any)} SandboxCallback\n */\n\n/**\n * @typedef {any|SandboxCallback} SandboxPropertyValue\n */\n\n/**\n * @typedef {(string|number)[]} ExpressionArray\n */\n\n/**\n * @typedef {\"scalar\"|\"boolean\"|\"string\"|\"undefined\"\n * |\"function\"|\"integer\"|\"number\"|\"nonFinite\"|\"object\"\n * |\"array\"|\"other\"|\"null\"|\"symbol\"|\"Promise\"|\"BigInt\"\n * |\"jsonReference\"} ValueType\n */\n\n/**\n * @typedef {unknown} ParentValue\n */\n\n/**\n * @typedef {unknown} UnknownResult\n */\n\n/**\n * @typedef {string|number|null} ParentProperty\n */\n\n/**\n * @typedef {ReturnObject|string|number|boolean|null|unknown[]\n * |Record} PreferredOutput\n */\n\n/**\n * Copies array and then pushes item into it.\n * @param {ExpressionArray} arr Array to copy and into which to push\n * @param {string|number} item Array item to add (to end)\n * @returns {ExpressionArray} Copy of the original array\n */\nfunction push (arr, item) {\n arr = arr.slice();\n arr.push(item);\n return arr;\n}\n/**\n * Copies array and then unshifts item into it.\n * @param {string|number} item Array item to add (to beginning)\n * @param {ExpressionArray} arr Array to copy and into which to unshift\n * @returns {ExpressionArray} Copy of the original array\n */\nfunction unshift (item, arr) {\n arr = arr.slice();\n arr.unshift(item);\n return arr;\n}\n\n/**\n * @typedef {object} ReturnObject\n * @property {ExpressionArray|string} path\n * @property {unknown} value\n * @property {ParentValue} parent\n * @property {ParentProperty} parentProperty\n * @property {boolean} [isParentSelector]\n * @property {boolean} [hasArrExpr]\n * @property {ExpressionArray} [expr]\n * @property {string} [pointer]\n */\n\n/**\n * @callback JSONPathCallback\n * @param {any} preferredOutput Using `any` type instead of `PreferredOutput` so\n * that user can supply flexible type\n * @param {\"value\"|\"property\"} type\n * @param {ReturnObject} fullRetObj\n * @returns {void}\n */\n\n/**\n * @callback OtherTypeCallback\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {string|number|null} parentPropName\n * @param {string} arg\n * @returns {boolean|null}\n */\n\n/**\n * @typedef {any} ContextItem\n */\n\n/**\n * @typedef {any} EvaluatedResult\n */\n\n/**\n * @callback EvalCallback\n * @param {string} code\n * @param {ContextItem} context\n * @returns {EvaluatedResult}\n */\n\n/**\n * @typedef {new (expr: string) => {\n * runInNewContext: (context: object) => EvaluatedResult\n * }} ScriptConstructor\n */\n\n/**\n * @typedef {ScriptConstructor} EvalClass\n */\n\n/**\n * @typedef {\"value\"|\"path\"|\"pointer\"|\"parent\"|\"parentProperty\"\n * |\"all\"} ResultType\n */\n\n/**\n * @typedef {EvalCallback|EvalClass|'safe'|'native'|boolean} EvalValue\n */\n\n/**\n * @typedef {string|string[]} PathType\n */\n\n/**\n * @typedef {{Script: ScriptConstructor}} SafeScriptType\n */\n\n/**\n * @typedef {{Script: ScriptConstructor}} ScriptType\n */\n\n/**\n * @typedef {{\n * _$_path?: string,\n * _$_parentProperty?: ParentProperty,\n * _$_parent?: ParentValue,\n * _$_property?: string|number,\n * _$_root?: AnyInput,\n * _$_v?: unknown,\n * [key: string]: SandboxPropertyValue\n * }} SandboxType\n */\n\n/**\n * @typedef {object} JSONPathOptions\n * @property {AnyInput} [json]\n * @property {PathType} [path]\n * @property {ResultType} [resultType=\"value\"]\n * @property {boolean} [flatten=false]\n * @property {boolean} [wrap=true]\n * @property {SandboxType} [sandbox={}]\n * @property {EvalValue} [eval='safe']\n * @property {any|null} [parent=null]\n * @property {ParentProperty} [parentProperty=null]\n * @property {JSONPathCallback} [callback]\n * @property {OtherTypeCallback} [otherTypeCallback] Defaults to\n * function which throws on encountering `@other`\n * @property {Record} [customTypes] Map of\n * custom type operator names to their evaluation callbacks\n * @property {boolean} [autostart=true]\n * @property {boolean} [ignoreEvalErrors=false]\n */\n\n\n/**\n * @overload\n * @param {string} opts JSON path to evaluate\n * @param {AnyInput} [expr] JSON object to evaluate against\n * @param {JSONPathCallback} [obj] Passed 3 arguments: 1) desired\n * payload per `resultType`, 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [callback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n * @param {undefined} [otherTypeCallback]\n * @returns {unknown} The string form always has `autostart` implicitly\n * `true`, so the result is the evaluated value, not a `JSONPathClass`\n */\n/**\n * @overload\n * @param {JSONPathOptions & {autostart: false}} opts An options object\n * with `autostart` explicitly set to `false` defers evaluation and\n * returns the `JSONPathClass` instance instead\n * @returns {JSONPathClass}\n */\n/**\n * @overload\n * @param {JSONPathOptions} opts If a string, will be treated as\n * `expr`\n * @returns {unknown}\n */\n/**\n * @param {JSONPathOptions|string} opts If a string, will be treated as `expr`\n * @param {string|AnyInput} [expr] JSON path to evaluate\n * @param {AnyInput|JSONPathCallback} [obj] JSON object to evaluate against\n * @param {JSONPathCallback|OtherTypeCallback} [callback] Passed 3\n * arguments: 1) desired payload per `resultType`,\n * 2) `\"value\"|\"property\"`, 3) Full returned object with\n * all payloads\n * @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the end\n * of one's query, this will be invoked with the value of the item, its\n * path, its parent, and its parent's property name, and it should return\n * a boolean indicating whether the supplied value belongs to the \"other\"\n * type or not (or it may handle transformations and return `false`).\n * @throws {Error}\n * @returns {unknown|JSONPathClass}\n */\nfunction JSONPath (opts, expr, obj, callback, otherTypeCallback) {\n try {\n if (opts && typeof opts === 'object') {\n return new JSONPathClass(opts);\n }\n return new JSONPathClass(\n opts,\n expr,\n /** @type {JSONPathCallback|undefined} */ (obj),\n /** @type {OtherTypeCallback|undefined} */ (callback),\n /** @type {undefined} */ (otherTypeCallback)\n );\n } catch (e) {\n if (new.target) {\n throw e;\n }\n if (e && typeof e === 'object' && 'value' in e) {\n return /** @type {{value: UnknownResult}} */ (e).value;\n }\n throw e;\n }\n}\n\n/**\n *\n */\nclass JSONPathClass {\n /**\n * @overload\n * @param {string} opts JSON path to evaluate\n * @param {AnyInput} [expr] JSON object to evaluate against\n * @param {JSONPathCallback} [obj] Passed 3 arguments: 1) desired\n * payload per `resultType`, 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [callback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n * @param {undefined} [otherTypeCallback]\n */\n /**\n * @overload\n * @param {JSONPathOptions} opts If a string, will be treated as\n * `expr`\n */\n /**\n * @param {null|string|JSONPathOptions} opts If a string, will be treated as\n * `expr`\n * @param {string|AnyInput} [expr] JSON path to evaluate\n * @param {AnyInput|JSONPathCallback} [obj] JSON object to evaluate against\n * @param {JSONPathCallback|OtherTypeCallback} [callback] Passed 3\n * arguments: 1) desired payload per `resultType`,\n * 2) `\"value\"|\"property\"`, 3) Full returned\n * object with all payloads\n * @param {OtherTypeCallback} [otherTypeCallback] If `@other()` is at the\n * end of one's query, this will be invoked with the value of the item,\n * its path, its parent, and its parent's property name, and it should\n * return a boolean indicating whether the supplied value belongs to the\n * \"other\" type or not (or it may handle transformations and return\n * `false`).\n */\n constructor (opts, expr, obj, callback, otherTypeCallback) {\n if (typeof opts === 'string') {\n otherTypeCallback = /** @type {OtherTypeCallback} */ (\n callback\n );\n callback = /** @type {JSONPathCallback} */ (\n obj\n );\n obj = expr;\n expr = opts;\n opts = null;\n }\n const optObj = opts && typeof opts === 'object';\n opts ||= /** @type {JSONPathOptions} */ ({});\n /** @type {ResultType|undefined} */\n this.currResultType = undefined;\n\n /** @type {EvalValue|undefined} */\n this.currEval = undefined;\n\n /** @type {OtherTypeCallback|undefined} */\n this.currOtherTypeCallback = undefined;\n\n /** @type {Record|undefined} */\n this.currCustomTypes = undefined;\n\n /** @type {SandboxType|undefined} */\n this.currSandbox = undefined;\n\n this._hasParentSelector = false;\n\n this.json = opts.json || obj;\n this.path = opts.path || expr;\n this.resultType = opts.resultType || 'value';\n this.flatten = Object.hasOwn(opts, 'flatten') && opts.flatten;\n this.wrap = !Object.hasOwn(opts, 'wrap') || opts.wrap;\n this.sandbox = opts.sandbox || {};\n this.eval = opts.eval === undefined ? 'safe' : opts.eval;\n this.ignoreEvalErrors = (\n typeof opts.ignoreEvalErrors !== 'undefined'\n ) && opts.ignoreEvalErrors;\n this.parent = Object.hasOwn(opts, 'parent') ? opts.parent : null;\n this.parentProperty = Object.hasOwn(opts, 'parentProperty')\n ? opts.parentProperty\n : null;\n this.callback = opts.callback ||\n /** @type {JSONPathCallback} */\n (callback) ||\n null;\n this.otherTypeCallback = opts.otherTypeCallback ||\n otherTypeCallback ||\n function () {\n throw new TypeError(\n 'You must supply an otherTypeCallback callback option ' +\n 'with the @other() operator.'\n );\n };\n this.customTypes = opts.customTypes || {};\n\n if (opts.autostart === false) {\n return;\n }\n\n const args = /** @type {JSONPathOptions} */ ({\n path: (optObj ? opts.path : expr)\n });\n if (!optObj && obj !== undefined) {\n args.json = obj;\n } else if ('json' in opts) {\n args.json = opts.json;\n }\n const ret = this.evaluate(args);\n if (!ret || typeof ret !== 'object') {\n const err = /** @type {Error & {value: UnknownResult}} */ (\n new Error(\n 'JSONPath should not be called with \"new\" (it ' +\n 'prevents return of (unwrapped) scalar values)'\n )\n );\n err.value = ret;\n throw err;\n }\n\n // @ts-expect-error - Constructor returns evaluate result for legacy API\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line consistent-return, no-constructor-return -- Legacy API\n return ret;\n }\n\n // PUBLIC METHODS\n\n /**\n * @overload\n * @param {JSONPathOptions} [expr]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n\n /**\n * @overload\n * @param {PathType|undefined} [expr]\n * @param {AnyInput} [json]\n * @param {JSONPathCallback|null} [callback]\n * @param {OtherTypeCallback} [otherTypeCallback]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n\n /**\n * @param {PathType|JSONPathOptions|undefined} [expr]\n * @param {AnyInput} [json]\n * @param {JSONPathCallback|null} [callback]\n * @param {OtherTypeCallback} [otherTypeCallback]\n * @returns {ReturnObject|ReturnObject[]|undefined|unknown}\n */\n evaluate (\n expr, json, callback, otherTypeCallback\n ) {\n let currParent = this.parent,\n currParentProperty = this.parentProperty;\n let {flatten, wrap} = this;\n\n this.currResultType = this.resultType;\n this.currEval = this.eval;\n this.currSandbox = this.sandbox;\n callback ||= this.callback;\n this.currOtherTypeCallback = otherTypeCallback ||\n this.otherTypeCallback;\n this.currCustomTypes = this.customTypes;\n\n if (expr && typeof expr === 'object' && !Array.isArray(expr)) {\n const exprObj = expr;\n if (!exprObj.path && exprObj.path !== '') {\n throw new TypeError(\n 'You must supply a \"path\" property when providing an ' +\n 'object argument to JSONPath.evaluate().'\n );\n }\n if (!(Object.hasOwn(exprObj, 'json'))) {\n throw new TypeError(\n 'You must supply a \"json\" property when providing an ' +\n 'object argument to JSONPath.evaluate().'\n );\n }\n ({json} = exprObj);\n flatten = Object.hasOwn(exprObj, 'flatten')\n ? exprObj.flatten\n : flatten;\n this.currResultType = Object.hasOwn(exprObj, 'resultType')\n ? exprObj.resultType\n : this.currResultType;\n this.currSandbox = Object.hasOwn(exprObj, 'sandbox')\n ? exprObj.sandbox\n : this.currSandbox;\n wrap = Object.hasOwn(exprObj, 'wrap') ? exprObj.wrap : wrap;\n this.currEval = Object.hasOwn(exprObj, 'eval')\n ? exprObj.eval\n : this.currEval;\n callback = Object.hasOwn(exprObj, 'callback')\n ? exprObj.callback\n : callback;\n this.currOtherTypeCallback = Object.hasOwn(\n exprObj, 'otherTypeCallback'\n )\n ? exprObj.otherTypeCallback\n : this.currOtherTypeCallback;\n this.currCustomTypes = Object.hasOwn(\n exprObj, 'customTypes'\n )\n ? exprObj.customTypes\n : this.currCustomTypes;\n currParent = Object.hasOwn(exprObj, 'parent')\n ? exprObj.parent\n : currParent;\n currParentProperty = Object.hasOwn(exprObj, 'parentProperty')\n ? exprObj.parentProperty\n : currParentProperty;\n expr = exprObj.path;\n } else {\n json ||= this.json;\n expr ||= this.path;\n }\n currParent ||= null;\n currParentProperty ||= null;\n\n if (Array.isArray(expr)) {\n expr = JSONPath.toPathString(expr);\n }\n if (!json || (!expr && expr !== '')) {\n return undefined;\n }\n\n const exprList = JSONPath.toPathArray(\n /** @type {string} */\n (expr)\n );\n if (exprList[0] === '$' && exprList.length > 1) {\n exprList.shift();\n }\n this._hasParentSelector = false;\n const traceResult = this._trace(\n exprList, json, ['$'], currParent,\n currParentProperty,\n callback ?? undefined,\n undefined\n );\n\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next 2 -- Unreachable: _trace returns array when hasArrExpr set */\n const result = (\n Array.isArray(traceResult) ? traceResult : [traceResult]\n ).filter((ea) => {\n return ea && !ea.isParentSelector;\n });\n\n if (!result.length) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: valid queries always produce results */\n return wrap ? [] : undefined;\n }\n if (!wrap && result.length === 1 && !result[0].hasArrExpr) {\n const preferredOutput = this._getPreferredOutput(result[0]);\n return preferredOutput;\n }\n const reduced = result.reduce(\n (rslt, ea) => {\n const valOrPath = this._getPreferredOutput(ea);\n if (flatten && Array.isArray(valOrPath)) {\n rslt = rslt.concat(valOrPath);\n } else {\n rslt.push(valOrPath);\n }\n return rslt;\n },\n /** @type {UnknownResult[]} */\n ([])\n );\n\n return reduced;\n }\n\n // PRIVATE METHODS\n\n /**\n * @param {ReturnObject} ea\n * @returns {PreferredOutput}\n */\n _getPreferredOutput (ea) {\n const resultType = this.currResultType;\n switch (resultType) {\n case 'all': {\n const path = Array.isArray(ea.path)\n ? ea.path\n : JSONPath.toPathArray(ea.path);\n ea.pointer = JSONPath.toPointer(/** @type {string[]} */ (path));\n ea.path = typeof ea.path === 'string'\n ? ea.path\n : JSONPath.toPathString(/** @type {string[]} */ (ea.path));\n return ea;\n } case 'value': case 'parent': case 'parentProperty':\n return /** @type {PreferredOutput} */ (ea[resultType]);\n case 'path':\n if (typeof ea.path === 'string') {\n return ea.path;\n }\n return JSONPath.toPathString(/** @type {string[]} */ (ea.path));\n case 'pointer': {\n const pathArray = Array.isArray(ea.path)\n ? ea.path\n : JSONPath.toPathArray(ea.path);\n return JSONPath.toPointer(/** @type {string[]} */ (pathArray));\n }\n default:\n throw new TypeError('Unknown result type');\n }\n }\n\n /**\n * @param {ReturnObject} fullRetObj\n * @param {JSONPathCallback|undefined} callback\n * @param {\"value\"|\"property\"} type\n * @returns {void}\n */\n _handleCallback (fullRetObj, callback, type) {\n // Early return if no callback provided (defensive\n // check for internal calls)\n if (!callback) {\n return;\n }\n const preferredOutput = this._getPreferredOutput(fullRetObj);\n if (Array.isArray(fullRetObj.path)) {\n fullRetObj.path = JSONPath.toPathString(\n /** @type {string[]} */ (fullRetObj.path)\n );\n }\n callback(preferredOutput, type, fullRetObj);\n }\n\n /**\n *\n * @param {ExpressionArray} expr\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @param {JSONPathCallback|undefined} callback\n * @param {boolean|undefined} hasArrExpr\n * @param {boolean} [literalPriority]\n * @returns {ReturnObject|ReturnObject[]}\n */\n _trace (\n expr, val, path, parent, parentPropName, callback, hasArrExpr,\n literalPriority\n ) {\n // No expr to follow? return path and value as the result of\n // this trace branch\n let retObj;\n if (!expr.length) {\n retObj = {\n path,\n value: val,\n parent,\n parentProperty: parentPropName,\n hasArrExpr\n };\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n\n const loc = /** @type {string} */ (expr[0]), x = expr.slice(1);\n\n // We need to gather the return value of recursive trace calls in order\n // to do the parent sel computation.\n /** @type {ReturnObject[]} */\n const ret = [];\n /**\n *\n * @param {ReturnObject|ReturnObject[]} elems\n * @returns {void}\n */\n function addRet (elems) {\n if (Array.isArray(elems)) {\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test:\n // `ret.push(...elems);`\n elems.forEach((t) => {\n ret.push(t);\n });\n } else {\n ret.push(elems);\n }\n }\n if (val && (typeof loc !== 'string' || literalPriority) &&\n Object.hasOwn(val, /** @type {PropertyKey} */ (loc))\n ) { // simple case--directly follow property\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[/** @type {string} */ (loc)],\n push(path, loc),\n val, /** @type {string|number} */ (loc), callback,\n hasArrExpr\n ));\n // eslint-disable-next-line unicorn/prefer-switch -- Part of larger `if`\n } else if (loc === '*') { // all child properties\n this._walk(val, (m) => {\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[m], push(path, m), val, m, callback, true, true\n ));\n });\n } else if (loc === '..') { // all descendent parent properties\n // Check remaining expression with val's immediate children\n addRet(\n this._trace(x, val, path, parent, parentPropName, callback,\n hasArrExpr)\n );\n this._walk(val, (m) => {\n // We don't join m and x here because we only want parents,\n // not scalar values\n const valObj = /** @type {Record} */ (val);\n if (typeof valObj[m] === 'object') {\n // Keep going with recursive descent on val's\n // object children\n addRet(this._trace(\n expr.slice(),\n valObj[m],\n push(path, m),\n val,\n m,\n callback,\n true\n ));\n }\n });\n // The parent sel computation is handled in the frame above using the\n // ancestor object of val\n } else if (loc === '^') {\n // This is not a final endpoint, so we do not invoke the\n // callback here\n this._hasParentSelector = true;\n return /** @type {ReturnObject} */ ({\n path: path.slice(0, -1),\n expr: x,\n isParentSelector: true,\n value: undefined,\n parent: undefined,\n parentProperty: null\n });\n } else if (loc === '~') { // property name\n retObj = {\n path: push(path, loc),\n value: parentPropName,\n parent,\n parentProperty: null\n };\n this._handleCallback(retObj, callback, 'property');\n return retObj;\n } else if (loc === '$') { // root only\n addRet(this._trace(x, val, path, null, null, callback, hasArrExpr));\n } else if ((/^(-?\\d*):(-?\\d*):?(\\d*)$/v).test(loc)) { // [start:end:step] Python slice syntax\n const sliceResult = this._slice(\n loc, x, val, path, parent, parentPropName, callback\n );\n if (sliceResult) {\n addRet(sliceResult);\n }\n } else if (loc.indexOf('?(') === 0) { // [?(expr)] (filtering)\n if (this.currEval === false) {\n throw new Error(\n 'Eval [?(expr)] prevented in JSONPath expression.'\n );\n }\n const safeLoc = loc.replace(/^\\?\\((.*?)\\)$/v, '$1');\n // check for a nested filter expression\n\n const nested = (/@.?([^?]*)[\\['](\\??\\(.*?\\))(?!.\\)\\])[\\]']/gv).exec(safeLoc);\n if (nested) {\n // find if there are matches in the nested expression\n // add them to the result set if there is at least one match\n this._walk(val, (m) => {\n const npath = [nested[2]];\n const valObj2 = /** @type {Record} */ (\n val\n );\n // guard against nested[1] resolving to `constructor`\n const nvalue = /** @type {ValueType} */ (nested[1]\n ? getSafeProperty(\n /** @type {Record} */ (\n valObj2[m]\n ),\n nested[1]\n )\n : valObj2[m]);\n const filterResults = this._trace(npath, nvalue, path,\n parent, parentPropName, callback, true);\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next 3 -- Unreachable: _trace always returns array for nested filters */\n const filterArray = Array.isArray(filterResults)\n ? filterResults\n : [filterResults];\n if (filterArray.length > 0) {\n addRet(this._trace(x, valObj2[m], push(path, m), val,\n m, callback, true));\n }\n });\n } else {\n const valObj3 = /** @type {Record} */ (val);\n this._walk(val, (m) => {\n if (this._eval(safeLoc, valObj3[m], m, path, parent,\n parentPropName)) {\n addRet(this._trace(x, valObj3[m], push(path, m), val, m,\n callback, true));\n }\n });\n }\n } else if (loc[0] === '(') { // [(expr)] (dynamic property/index)\n if (this.currEval === false) {\n throw new Error(\n 'Eval [(expr)] prevented in JSONPath expression.'\n );\n }\n // As this will resolve to a property name (but we don't know it\n // yet), property and parent information is relative to the\n const evalResult = this._eval(\n /** @type {string} */ (loc),\n val, /** @type {string|number} */ (path.at(-1)),\n path.slice(0, -1), parent, parentPropName\n );\n const exprToUse = /** @type {string|number} */ (\n evalResult !== undefined ? evalResult : ''\n );\n addRet(this._trace(unshift(\n exprToUse,\n x\n ), val, path, parent, parentPropName, callback, hasArrExpr));\n } else if (loc[0] === '@') { // value type: @boolean(), etc.\n // eslint-disable-next-line no-useless-assignment -- ESLint bug\n let addType = false;\n const parenthIndex = loc.indexOf('(');\n const valueType = /** @type {ValueType|string} */ (\n loc\n ).slice(1, parenthIndex);\n const lastParenth = loc.lastIndexOf(')');\n const argRaw = loc.slice(parenthIndex + 1, lastParenth);\n const arg = argRaw ? JSON.parse(argRaw) : undefined;\n switch (valueType) {\n case 'scalar':\n addType = !val ||\n !(['object', 'function'].includes(typeof val));\n break;\n case 'boolean': case 'string': case 'undefined': case 'function':\n addType = typeof val === valueType;\n break;\n case 'integer':\n addType = Number.isFinite(val) &&\n !(/** @type {number} */ (val) % 1);\n break;\n case 'number':\n addType = Number.isFinite(val);\n break;\n case 'nonFinite':\n addType = typeof val === 'number' && !Number.isFinite(val);\n break;\n case 'object':\n addType = Boolean(val) && typeof val === valueType;\n break;\n case 'array':\n addType = Array.isArray(val);\n break;\n case 'other':\n addType = /** @type {OtherTypeCallback} */ (\n this.currOtherTypeCallback\n )(\n val, path, parent, parentPropName, arg\n ) || false;\n break;\n case 'null':\n addType = val === null;\n break;\n case 'symbol':\n addType = typeof val === 'symbol';\n break;\n case 'BigInt':\n addType = typeof val === 'bigint';\n break;\n case 'Promise':\n addType = toStringTag(val) === 'Promise';\n break;\n case 'jsonReference':\n addType = Boolean(val) && typeof val === 'object' &&\n Object.hasOwn(/** @type {object} */ (val), '$ref');\n break;\n default:\n if (this.currCustomTypes &&\n Object.hasOwn(this.currCustomTypes, valueType)\n ) {\n addType = this.currCustomTypes[valueType](\n val, path, parent, parentPropName, arg\n ) || false;\n } else {\n throw new TypeError('Unknown value type ' + valueType);\n }\n }\n if (addType) {\n retObj = {\n path, value: val, parent, parentProperty: parentPropName\n };\n this._handleCallback(retObj, callback, 'value');\n return retObj;\n }\n // `-escaped property\n } else if (val && loc[0] === '`' &&\n Object.hasOwn(val, loc.slice(1))\n ) {\n const locProp = loc.slice(1);\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[locProp], push(path, locProp), val, locProp, callback,\n hasArrExpr, true\n ));\n } else if (loc[0] === \"'\" || loc[0] === '\"') { // ['name1','name2',...]\n // Quoted members are literal property names\n for (const [, single, double] of loc.matchAll(\n /'((?:\\\\.|[^'\\\\])*)'|\"((?:\\\\.|[^\"\\\\])*)\"/gv\n )) {\n const prop = (single ?? double).replaceAll(\n /\\\\(['\"\\\\])/gv, '$1'\n );\n if (!val || !Object.hasOwn(val, prop)) {\n continue;\n }\n const valObj = /** @type {Record} */ (val);\n addRet(this._trace(\n x, valObj[prop], push(path, prop), val, prop,\n callback, true\n ));\n }\n } else if (loc.includes(',')) { // [name1,name2,...]\n const parts = loc.split(',');\n for (const part of parts) {\n addRet(this._trace(\n unshift(part, x),\n val,\n path,\n parent,\n parentPropName,\n callback,\n true\n ));\n }\n // simple case--directly follow property\n } else if (\n !literalPriority && val && Object.hasOwn(val, loc)\n ) {\n const valObj = /** @type {Record} */ (val);\n addRet(\n this._trace(x, valObj[loc], push(path, loc), val, loc, callback,\n hasArrExpr, true)\n );\n }\n\n // We check the resulting values for parent selections. For parent\n // selections we discard the value object and continue the trace with\n // the current val object\n if (this._hasParentSelector) {\n for (let t = 0; t < ret.length; t++) {\n const rett = ret[t];\n if (!rett || !rett.isParentSelector) {\n continue;\n }\n\n const exprToUse = /** @type {ExpressionArray} */ (\n rett.expr\n );\n const pathToUse = /** @type {ExpressionArray} */ (\n rett.path\n );\n const tmp = this._trace(\n exprToUse,\n val,\n pathToUse,\n parent,\n parentPropName,\n callback,\n hasArrExpr\n );\n if (Array.isArray(tmp)) {\n ret[t] = tmp[0];\n const tl = tmp.length;\n for (let tt = 1; tt < tl; tt++) {\n t++;\n ret.splice(t, 0, tmp[tt]);\n }\n } else {\n ret[t] = tmp;\n }\n }\n }\n return ret;\n }\n\n /**\n * @param {unknown} val\n * @param {(prop: string|number) => void} f\n * @returns {void}\n */\n _walk (val, f) {\n if (Array.isArray(val)) {\n const n = val.length;\n for (let i = 0; i < n; i++) {\n f(i);\n }\n } else if (val && typeof val === 'object') {\n Object.keys(val).forEach((m) => {\n f(m);\n });\n }\n }\n\n /**\n * @param {string} loc\n * @param {ExpressionArray} expr\n * @param {unknown} val\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @param {JSONPathCallback|undefined} callback\n * @returns {ReturnObject[]|undefined}\n */\n _slice (\n loc, expr, val, path, parent, parentPropName, callback\n ) {\n if (!Array.isArray(val)) {\n return undefined;\n }\n const len = val.length, parts = loc.split(':'),\n step = (parts[2] && Number(parts[2])) || 1;\n let start = (parts[0] && Number(parts[0])) || 0,\n end = parts[1] ? Number(parts[1]) : len;\n start = (start < 0) ? Math.max(0, start + len) : Math.min(len, start);\n end = (end < 0) ? Math.max(0, end + len) : Math.min(len, end);\n /** @type {ReturnObject[]} */\n const ret = [];\n for (let i = start; i < end; i += step) {\n const tmp = this._trace(\n unshift(i, expr),\n val,\n path,\n parent,\n parentPropName,\n callback,\n true\n );\n // Should only be possible to be an array here since first part of\n // ``unshift(i, expr)` passed in above would not be empty,\n // nor `~`, nor begin with `@` (as could return objects)\n // This was causing excessive stack size in Node (with or\n // without Babel) against our performance test: `ret.push(...tmp);`\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: _trace returns array when expr non-empty */\n const tmpArray = Array.isArray(tmp) ? tmp : [tmp];\n tmpArray.forEach((t) => {\n ret.push(t);\n });\n }\n return ret;\n }\n\n /**\n * @param {string} code\n * @param {unknown} _v\n * @param {string|number} _vname\n * @param {ExpressionArray} path\n * @param {ParentValue} parent\n * @param {ParentProperty} parentPropName\n * @returns {UnknownResult}\n */\n _eval (\n code, _v, _vname, path, parent, parentPropName\n ) {\n if (this.currSandbox) {\n this.currSandbox._$_parentProperty = parentPropName;\n this.currSandbox._$_parent = parent;\n this.currSandbox._$_property = _vname;\n this.currSandbox._$_root = this.json;\n this.currSandbox._$_v = _v;\n }\n\n const containsPath = code.includes('@path');\n if (containsPath) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* c8 ignore next -- Unreachable: currSandbox set in evaluate() before _eval */\n const currSandbox = this.currSandbox ?? {};\n currSandbox._$_path = JSONPath.toPathString(\n /** @type {string[]} */ (path.concat([_vname]))\n );\n }\n\n const scriptCacheKey = this.currEval + 'Script:' + code;\n if (!scriptCache.has(scriptCacheKey)) {\n let script = code\n .replaceAll('@parentProperty', '_$_parentProperty')\n .replaceAll('@parent', '_$_parent')\n .replaceAll('@property', '_$_property')\n .replaceAll('@root', '_$_root')\n // Replace a bare `@` (not followed by an identifier\n // character) while leaving quoted string literals and\n // regex literals (a `/` where an operand is expected,\n // as opposed to division) intact\n .replaceAll(\n /('(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\"|(?<=(?:^|[\\(,=:\\[!\\|?\\{\\};+\\-*%<>~^]|&)\\s*)\\/(?:\\\\.|\\[(?:\\\\.|[^\\]\\\\])*\\]|[^\\/\\\\\\[])+\\/[dgimsuvy]*)|@(?![\\w$])/gv,\n (_, literal) => literal ?? '_$_v'\n );\n if (containsPath) {\n script = script.replaceAll('@path', '_$_path');\n }\n const evalType = /** @type {string|boolean|undefined} */ (\n this.currEval\n );\n if (['safe', true, undefined].includes(evalType)) {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-disable unicorn/no-undeclared-class-members -- Prototype members */\n scriptCache.set(scriptCacheKey, new (\n /**\n * @type {JSONPathClass & {\n * safeVm: SafeScriptType,\n * vm: ScriptType\n * }}\n */ (/** @type {unknown} */ (this))\n ).safeVm.Script(script));\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-enable unicorn/no-undeclared-class-members -- End prototype member scope */\n } else if (this.currEval === 'native') {\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-disable unicorn/no-undeclared-class-members -- Prototype members */\n scriptCache.set(scriptCacheKey, new (\n /**\n * @type {JSONPathClass & {\n * safeVm: SafeScriptType,\n * vm: ScriptType\n * }}\n */ (/** @type {unknown} */ (this))\n ).vm.Script(script));\n // eslint-disable-next-line @stylistic/max-len -- Long\n /* eslint-enable unicorn/no-undeclared-class-members -- End prototype member scope */\n } else if (\n typeof this.currEval === 'function' &&\n this.currEval.prototype &&\n Object.hasOwn(this.currEval.prototype, 'runInNewContext')\n ) {\n const CurrEval = this.currEval;\n // eslint-disable-next-line @stylistic/max-len -- Long\n // @ts-expect-error - Type checked above to have proper constructor\n scriptCache.set(scriptCacheKey, new CurrEval(script));\n } else if (typeof this.currEval === 'function') {\n // Type narrowing: at this point currEval is a function\n // but not a constructor\n const evalFunc = /** @type {EvalCallback} */ (this.currEval);\n scriptCache.set(scriptCacheKey, {\n runInNewContext: (\n /** @type {ContextItem} */ context\n ) => evalFunc(script, context)\n });\n } else {\n throw new TypeError(\n `Unknown \"eval\" property \"${this.currEval}\"`\n );\n }\n }\n\n try {\n /**\n * @typedef {{\n * runInNewContext: (\n * ctx: SandboxType|undefined\n * ) => EvaluatedResult\n * }} RunInNewContext\n */\n\n return /** @type {RunInNewContext} */ (\n scriptCache.get(scriptCacheKey)\n ).runInNewContext(\n this.currSandbox\n );\n } catch (e) {\n if (this.ignoreEvalErrors) {\n return false;\n }\n const error = /** @type {Error} */ (e);\n throw new Error('jsonPath: ' + error.message + ': ' + code, {\n cause: e\n });\n }\n }\n}\n\n/** @type {{safeVm: SafeScriptType}} */\n(/** @type {unknown} */ (JSONPathClass.prototype)).safeVm = {\n Script: SafeScript\n};\n\nJSONPath.prototype = JSONPathClass.prototype;\n\n// PUBLIC CLASS PROPERTIES AND METHODS\n\n/**\n * Clears cached parsed paths and compiled scripts.\n * @returns {void}\n */\nJSONPath.clearCache = function () {\n pathCache.clear();\n scriptCache.clear();\n};\n\n/**\n * @param {string[]} pathArr Array to convert\n * @returns {string} The path string\n */\nJSONPath.toPathString = function (pathArr) {\n const x = pathArr, n = x.length;\n let p = '$';\n for (let i = 1; i < n; i++) {\n if (!(/^(~|\\^|@.*?\\(\\))$/v).test(x[i])) {\n p += (/^[0-9*]+$/v).test(x[i])\n ? ('[' + x[i] + ']')\n : (\"['\" + String(x[i]).replaceAll(/['\\\\]/gv, String.raw`\\$&`) + \"']\");\n }\n }\n return p;\n};\n\n/**\n * @param {string[]} pointer JSON Path array\n * @returns {string} JSON Pointer\n */\nJSONPath.toPointer = function (pointer) {\n const x = pointer, n = x.length;\n let p = '';\n for (let i = 1; i < n; i++) {\n if (!(/^(~|\\^|@.*?\\(\\))$/v).test(x[i])) {\n p += '/' + x[i].toString()\n .replaceAll('~', '~0')\n .replaceAll('/', '~1');\n }\n }\n return p;\n};\n\n/**\n * @param {string} expr Expression to convert\n * @returns {string[]}\n */\nJSONPath.toPathArray = function (expr) {\n if (pathCache.has(expr)) {\n return /** @type {string[]} */ (pathCache.get(expr)).concat();\n }\n /** @type {string[]} */\n const subx = [];\n const normalized = expr\n // Properties\n .replaceAll(\n /@[\\w$\\-]+\\([^\\)]*\\)/gv,\n ';$&;'\n )\n // Parenthetical evaluations (filtering and otherwise), directly\n // within brackets or single quotes\n .replaceAll(/[\\['](\\??\\(.*?\\))[\\]'](?!.\\])/gv, function ($0, $1) {\n return '[#' +\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line unicorn/no-return-array-push -- Optimization\n (subx.push($1) - 1) +\n ']';\n })\n // Unions of quoted property names (e.g., `['x','y']`) and quoted\n // names with commas or backslash escapes, kept intact (with\n // quotes) so their members survive tokenization\n .replaceAll(\n /\\[\\s*((?:'(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\")(?:\\s*,\\s*(?:'(?:\\\\.|[^'\\\\])*'|\"(?:\\\\.|[^\"\\\\])*\"))*)\\s*\\]/gv,\n function ($0, $1) {\n if (!(/[,\\\\]/v).test($1)) {\n return $0;\n }\n // eslint-disable-next-line @stylistic/max-len -- Long\n // eslint-disable-next-line unicorn/no-return-array-push -- Optimization\n return '[#' + (subx.push($1) - 1) + ']';\n }\n )\n // Escape periods and tildes within properties\n .replaceAll(/\\[['\"]([^'\\]]*)['\"]\\]/gv, function ($0, prop) {\n return \"['\" + prop\n .replaceAll('.', '%@%')\n .replaceAll('~', '%%@@%%') +\n \"']\";\n })\n // Properties operator\n .replaceAll('~', ';~;')\n // Split by property boundaries\n\n .replaceAll(/['\"]?\\.['\"]?(?![^\\[]*\\])|\\[['\"]?/gv, ';')\n // Reinsert periods within properties\n .replaceAll('%@%', '.')\n // Reinsert tildes within properties\n .replaceAll('%%@@%%', '~')\n // Parent\n .replaceAll(/(?:;)?(\\^+)(?:;)?/gv, function ($0, ups) {\n return ';' + ups.split('').join(';') + ';';\n })\n // Descendents\n .replaceAll(/;;;|;;/gv, ';..;')\n // Remove trailing\n .replaceAll(/;$|'?\\]|'$/gv, '');\n\n const exprList = normalized.split(';').map(function (exp) {\n const match = exp.match(/#(\\d+)/v);\n return !match || !match[1] ? exp : subx[Number(match[1])];\n });\n pathCache.set(expr, exprList);\n return /** @type {string[]} */ (pathCache.get(expr)).concat();\n};\n\nexport {JSONPath, JSONPathClass};\n","import {JSONPath, JSONPathClass} from './jsonpath.js';\n\n/**\n * @typedef {import('./jsonpath.js').AnyInput} AnyInput\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxCallback} SandboxCallback\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxPropertyValue} SandboxPropertyValue\n */\n/**\n * @typedef {import('./jsonpath.js').ExpressionArray} ExpressionArray\n */\n/**\n * @typedef {import('./jsonpath.js').ValueType} ValueType\n */\n/**\n * @typedef {import('./jsonpath.js').ParentValue} ParentValue\n */\n/**\n * @typedef {import('./jsonpath.js').UnknownResult} UnknownResult\n */\n/**\n * @typedef {import('./jsonpath.js').ParentProperty} ParentProperty\n */\n/**\n * @typedef {import('./jsonpath.js').PreferredOutput} PreferredOutput\n */\n/**\n * @typedef {import('./jsonpath.js').ReturnObject} ReturnObject\n */\n/**\n * @typedef {import('./jsonpath.js').JSONPathCallback} JSONPathCallback\n */\n/**\n * @typedef {import('./jsonpath.js').OtherTypeCallback} OtherTypeCallback\n */\n/**\n * @typedef {import('./jsonpath.js').ContextItem} ContextItem\n */\n/**\n * @typedef {import('./jsonpath.js').EvaluatedResult} EvaluatedResult\n */\n/**\n * @typedef {import('./jsonpath.js').EvalCallback} EvalCallback\n */\n/**\n * @typedef {import('./jsonpath.js').EvalClass} EvalClass\n */\n/**\n * @typedef {import('./jsonpath.js').ResultType} ResultType\n */\n/**\n * @typedef {import('./jsonpath.js').EvalValue} EvalValue\n */\n/**\n * @typedef {import('./jsonpath.js').PathType} PathType\n */\n/**\n * @typedef {import('./jsonpath.js').SafeScriptType} SafeScriptType\n */\n/**\n * @typedef {import('./jsonpath.js').ScriptType} ScriptType\n */\n/**\n * @typedef {import('./jsonpath.js').SandboxType} SandboxType\n */\n/**\n * @typedef {import('./jsonpath.js').JSONPathOptions} JSONPathOptions\n */\n\n/**\n * @template T\n * @callback ConditionCallback\n * @param {T} item\n * @returns {boolean}\n */\n\n/**\n * Copy items out of one array into another.\n * @template T\n * @param {T[]} source Array with items to copy\n * @param {T[]} target Array to which to copy\n * @param {ConditionCallback} conditionCb Callback passed the current item;\n * will move item if evaluates to `true`\n * @returns {void}\n */\nconst moveToAnotherArray = function (source, target, conditionCb) {\n const il = source.length;\n for (let i = 0; i < il; i++) {\n const item = source[i];\n if (conditionCb(item)) {\n target.push(source.splice(i--, 1)[0]);\n }\n }\n};\n\n/**\n * In-browser replacement for NodeJS' VM.Script.\n */\nclass Script {\n /**\n * @param {string} expr Expression to evaluate\n */\n constructor (expr) {\n this.code = expr;\n }\n\n /**\n * @param {SandboxType} context Object whose items will be added\n * to evaluation\n * @returns {EvaluatedResult} Result of evaluated code\n */\n runInNewContext (context) {\n let expr = this.code;\n const keys = Object.keys(context);\n const funcs = /** @type {string[]} */ ([]);\n moveToAnotherArray(keys, funcs, (key) => {\n return typeof context[key] === 'function';\n });\n const values = keys.map((vr) => {\n return context[vr];\n });\n\n const funcString = funcs.reduce((s, func) => {\n let fString = context[func].toString();\n if (!(/function/v).test(fString)) {\n fString = 'function ' + fString;\n }\n return 'var ' + func + '=' + fString + ';' + s;\n }, '');\n\n expr = funcString + expr;\n\n // Mitigate https://perfectionkills.com/global-eval-what-are-the-options/#new_function\n if (!(/(['\"])use strict\\1/v).test(expr) && !keys.includes('arguments')) {\n expr = 'var arguments = undefined;' + expr;\n }\n\n // Remove last semi so `return` will be inserted before\n // the previous one instead, allowing for the return\n // of a bare ending expression\n expr = expr.replace(/;\\s*$/v, '');\n\n // Insert `return`\n const lastStatementEnd = expr.lastIndexOf(';');\n const code =\n lastStatementEnd !== -1\n ? expr.slice(0, lastStatementEnd + 1) +\n ' return ' +\n expr.slice(lastStatementEnd + 1)\n : ' return ' + expr;\n\n // eslint-disable-next-line no-new-func -- User's choice\n return new Function(...keys, code)(...values);\n }\n}\n\n/** @type {{vm: ScriptType}} */\n(/** @type {unknown} */ (JSONPathClass.prototype)).vm = {\n Script\n};\n\nexport {JSONPath, JSONPathClass, Script};\n"],"names":["Jsep","version","toString","addUnaryOp","op_name","max_unop_len","Math","max","length","unary_ops","addBinaryOp","precedence","isRightAssociative","max_binop_len","binary_ops","right_associative","add","delete","addIdentifierChar","char","additional_identifier_chars","addLiteral","literal_name","literal_value","literals","removeUnaryOp","getMaxKeyLen","removeAllUnaryOps","removeIdentifierChar","removeBinaryOp","removeAllBinaryOps","removeLiteral","removeAllLiterals","this","expr","charAt","index","code","charCodeAt","constructor","parse","obj","Object","keys","map","k","isDecimalDigit","ch","binaryPrecedence","op_val","isIdentifierStart","String","fromCharCode","has","isIdentifierPart","throwError","message","error","Error","description","runHook","name","node","hooks","env","context","run","searchHook","find","callback","call","gobbleSpaces","SPACE_CODE","TAB_CODE","LF_CODE","CR_CODE","nodes","gobbleExpressions","type","COMPOUND","body","untilICode","ch_i","SEMCOL_CODE","COMMA_CODE","gobbleExpression","push","gobbleBinaryExpression","gobbleBinaryOp","to_check","substr","tc_len","hasOwnProperty","biop","prec","stack","biop_info","left","right","i","cur_biop","gobbleToken","value","right_a","comparePrev","prev","pop","BINARY_EXP","operator","PERIOD_CODE","gobbleNumericLiteral","SQUOTE_CODE","DQUOTE_CODE","gobbleStringLiteral","OBRACK_CODE","gobbleArray","argument","UNARY_EXP","prefix","gobbleIdentifier","LITERAL","raw","this_str","THIS_EXP","OPAREN_CODE","gobbleGroup","gobbleTokenProperty","QUMARK_CODE","optional","MEMBER_EXP","computed","object","property","CBRACK_CODE","CALL_EXP","arguments","gobbleArguments","CPAREN_CODE","callee","chCode","number","parseFloat","str","startIndex","quote","closed","substring","start","IDENTIFIER","slice","termination","args","separator_count","arg","SEQUENCE_EXP","expressions","ARRAY_EXP","elements","first","Array","isArray","forEach","assign","plugins","jsep","registered","register","plugin","init","COLON_CODE","Set","true","false","null","stdClassProps","getOwnPropertyNames","filter","prop","includes","undefined","m","ternary","test","consequent","alternate","newTest","patternIndex","inCharSet","pattern","flags","RegExp","e","assignmentOperators","updateOperators","assignmentPrecedence","updateNodeTypes","updateBinariesToAssignments","values","val","op","some","c","jsepRegex","jsepAssignment","BLOCKED_PROTO_PROPERTIES","BLOCKED_FUNCTIONS","WeakSet","Function","async","prototype","apply","bind","Reflect","construct","get","isBlockedFunction","getSafeProperty","TypeError","hasOwn","result","BINOPS","create","||","a","b","??","&&","|","^","&","==","!=","===","!==","<",">","<=",">=","<<",">>",">>>","+","-","*","/","%","**","UNOPS","typeof","void","SafeEval","evalAst","ast","subs","evalBinaryExpression","evalCompound","evalConditionalExpression","evalIdentifier","evalLiteral","evalMemberExpression","evalUnaryExpression","evalArrayExpression","evalCallExpression","evalAssignmentExpression","SyntaxError","cause","last","ReferenceError","operand","el","func","id","scriptCache","Map","pathCache","arr","item","unshift","JSONPath","opts","otherTypeCallback","JSONPathClass","optObj","currResultType","currEval","currOtherTypeCallback","currCustomTypes","currSandbox","_hasParentSelector","json","path","resultType","flatten","wrap","sandbox","eval","ignoreEvalErrors","parent","parentProperty","customTypes","autostart","ret","evaluate","err","currParent","currParentProperty","exprObj","toPathString","exprList","toPathArray","shift","traceResult","_trace","ea","isParentSelector","hasArrExpr","_getPreferredOutput","reduce","rslt","valOrPath","concat","pointer","toPointer","pathArray","_handleCallback","fullRetObj","preferredOutput","parentPropName","literalPriority","retObj","loc","x","addRet","elems","t","valObj","_walk","sliceResult","_slice","indexOf","safeLoc","replace","nested","exec","npath","valObj2","nvalue","filterResults","valObj3","_eval","evalResult","at","exprToUse","addType","parenthIndex","valueType","lastParenth","lastIndexOf","argRaw","JSON","Number","isFinite","Boolean","toStringTag","locProp","single","double","matchAll","replaceAll","parts","split","part","rett","pathToUse","tmp","tl","tt","splice","f","n","len","step","end","min","_v","_vname","_$_parentProperty","_$_parent","_$_property","_$_root","_$_v","containsPath","_$_path","scriptCacheKey","script","_","literal","evalType","set","safeVm","Script","vm","CurrEval","evalFunc","runInNewContext","keyMap","clearCache","clear","pathArr","p","subx","$0","$1","ups","join","exp","match","funcs","source","target","conditionCb","il","moveToAnotherArray","key","vr","s","fString","lastStatementEnd"],"mappings":"+OAgGA,MAAMA,EAIL,kBAAWC,GAEV,MAAO,OACR,CAKA,eAAOC,GACN,MAAO,wCAA0CF,EAAKC,OACvD,CAQA,iBAAOE,CAAWC,GAGjB,OAFAJ,EAAKK,aAAeC,KAAKC,IAAIH,EAAQI,OAAQR,EAAKK,cAClDL,EAAKS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TD,KAAKI,KAAOH,CAChB,CAOA,eAAAkX,CAAiBnV,GACb,IAAI/B,EAAOD,KAAKI,KAChB,MAAMM,EAAOD,OAAOC,KAAKsB,GACnBgW,EAAiC,IA7BpB,SAAUC,EAAQC,EAAQC,GACjD,MAAMC,EAAKH,EAAO1Z,OAClB,IAAK,IAAI2F,EAAI,EAAGA,EAAIkU,EAAIlU,IAEhBiU,EADSF,EAAO/T,KAEhBgU,EAAO7U,KAAK4U,EAAOzC,OAAOtR,IAAK,GAAG,GAG9C,CAsBQmU,CAAmB3X,EAAMsX,EAAQM,GACE,mBAAjBtW,EAAQsW,IAE1B,MAAMlO,EAAS1J,EAAKC,IAAK4X,GACdvW,EAAQuW,IAWnBtY,EARmB+X,EAAMpG,OAAO,CAAC4G,EAAG3J,KAChC,IAAI4J,EAAUzW,EAAQ6M,GAAM5Q,WAI5B,MAHM,YAAaoL,KAAKoP,KACpBA,EAAU,YAAcA,GAErB,OAAS5J,EAAO,IAAM4J,EAAU,IAAMD,GAC9C,IAEiBvY,EAGd,sBAAuBoJ,KAAKpJ,IAAUS,EAAKuI,SAAS,eACtDhJ,EAAO,6BAA+BA,GAM1CA,EAAOA,EAAKmT,QAAQ,SAAU,IAG9B,MAAMsF,EAAmBzY,EAAKmU,YAAY,KACpChU,GACmB,IAArBsY,EACMzY,EAAKmH,MAAM,EAAGsR,EAAmB,GACjC,WACAzY,EAAKmH,MAAMsR,EAAmB,GAC9B,WAAazY,EAGvB,OAAO,IAAI6K,YAAYpK,EAAMN,EAAtB,IAA+BgK,EAC1C,EAIqBoF,EAAuB,UAAGwH,GAAK,CACpDD","x_google_ignoreList":[0,1,2]} \ No newline at end of file diff --git a/dist/index-node-cjs.cjs b/dist/index-node-cjs.cjs index 734142e..c425fb4 100644 --- a/dist/index-node-cjs.cjs +++ b/dist/index-node-cjs.cjs @@ -1283,6 +1283,7 @@ const getSafeProperty = (obj, prop) => { // eslint-disable-next-line @stylistic/max-len -- Long const BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */{ '||': (a, b) => a || b(), + '??': (a, b) => a ?? b(), '&&': (a, b) => a && b(), '|': (a, b) => a | b(), '^': (a, b) => a ^ b(), @@ -1304,7 +1305,8 @@ const BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */{ '-': (a, b) => a - b(), '*': (a, b) => a * b(), '/': (a, b) => a / b(), - '%': (a, b) => a % b() + '%': (a, b) => a % b(), + '**': (a, b) => a ** b() }); /** diff --git a/dist/index-node-esm.js b/dist/index-node-esm.js index 6a262d1..79dd355 100644 --- a/dist/index-node-esm.js +++ b/dist/index-node-esm.js @@ -1281,6 +1281,7 @@ const getSafeProperty = (obj, prop) => { // eslint-disable-next-line @stylistic/max-len -- Long const BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */{ '||': (a, b) => a || b(), + '??': (a, b) => a ?? b(), '&&': (a, b) => a && b(), '|': (a, b) => a | b(), '^': (a, b) => a ^ b(), @@ -1302,7 +1303,8 @@ const BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */{ '-': (a, b) => a - b(), '*': (a, b) => a * b(), '/': (a, b) => a / b(), - '%': (a, b) => a % b() + '%': (a, b) => a % b(), + '**': (a, b) => a ** b() }); /** diff --git a/package.json b/package.json index a409327..430965c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Stefan Goessner", "name": "jsonpath-plus", - "version": "11.2.0", + "version": "11.2.1", "type": "module", "bin": { "jsonpath": "./bin/jsonpath-cli.js", diff --git a/src/Safe-Script.js b/src/Safe-Script.js index e0a50f6..ef04021 100644 --- a/src/Safe-Script.js +++ b/src/Safe-Script.js @@ -107,6 +107,7 @@ const getSafeProperty = (obj, prop) => { // eslint-disable-next-line @stylistic/max-len -- Long const BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */ ({ '||': (a, b) => a || b(), + '??': (a, b) => a ?? b(), '&&': (a, b) => a && b(), '|': (a, b) => a | b(), '^': (a, b) => a ^ b(), @@ -128,7 +129,8 @@ const BINOPS = Object.assign(Object.create(null), /** @type {OperatorTable} */ ( '-': (a, b) => a - b(), '*': (a, b) => a * b(), '/': (a, b) => a / b(), - '%': (a, b) => a % b() + '%': (a, b) => a % b(), + '**': (a, b) => a ** b() })); /** diff --git a/test/test.safe-eval.js b/test/test.safe-eval.js index f84ac78..8025935 100644 --- a/test/test.safe-eval.js +++ b/test/test.safe-eval.js @@ -243,6 +243,8 @@ checkBuiltInVMAndNodeVM(function (vmType, setBuiltInState) { ['*', '$..[?(@ && @.shelf * 2 === 2)]', [json.store.book]], ['/', '$..[?(@ && @.shelf / 2 === 1)]', [json.store.books[0]]], ['%', '$..[?(@ && @.shelf % 2 === 0)]', [json.store.books[0]]], + ['**', '$..[?(@ && @.shelf ** 2 === 9)]', [json.store.books[1]]], + ['??', '$..[?(@ && (@.isbn ?? "none") === "none" && @.shelf)]', [json.store.book, json.store.books[0]]], ['!', '$..[?(@ && @.emptyArray && !@.emptyArray.length)]', [json.store.books[1]]], ['~', '$..[?(@ && ~@.shelf === -2)]', [json.store.book]], ['+ (unary)', '$..[?(@ && +@.meta === 12)]', [json.store.book]],