diff --git a/CHANGES.md b/CHANGES.md index d3def89..f9e4f53 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,13 +13,16 @@ that usage and call JSONPath.clearCache() when cache invalidation is needed. Other changes: +- feat: add `customTypes` option for providing own other type callbacks (e.g., `@blob()`) (@brettz9) - fix(slice): explicit zero end no longer returns the whole array (#265) (@spokodev) -- fix: separate JSONPath path and script caches +- fix: indicate that the `OtherTypeCallback` callback type can accept a `parentPropName` with type `number` (@brettz9) +- fix: separate JSONPath path and script caches (@brettz9) - fix: restore `JSONPath.prototype.evaluate`, `safeVm`, and `vm` compatibility - fix(safe-eval): harden operator lookup against prototype inheritance (@brettz9) - refactor: expose JSONPathClass prototype through JSONPath for compatibility - docs: security notes - test(safe-eval): guard bind() escape route for constructor access (@brettz9) +- test: restore full test coverage (@brettz9) - chore: pnpm update (@brettz9) - refactor: implement TypeScript-as-JSDoc and auto-build declaration files from this (avoiding need for maintaining declaration file manually) - chore: update devDeps diff --git a/README.md b/README.md index 09386c5..4a04500 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,11 @@ evaluate method (as the first argument) include: and it should return a boolean indicating whether the supplied value belongs to the "other" type or not (or it may handle transformations and return false). +- ***customTypes*** (**default: {}**) - A key-value map of type names to functions. + This allows creating custom type operators that can be used in queries + (e.g., `@myType()`). The function will be invoked with the value of the item, + its path, its parent, and its parent's property name. It should return a + boolean indicating whether the supplied value matches the custom type. ### Instance methods diff --git a/badges/coverage-badge.svg b/badges/coverage-badge.svg index 6be9d19..b368212 100644 --- a/badges/coverage-badge.svg +++ b/badges/coverage-badge.svg @@ -1 +1 @@ -Statements 99.89%Statements 99.89%Branches 99.74%Branches 99.74%Lines 99.89%Lines 99.89%Functions 98.43%Functions 98.43% +Statements 100%Statements 100%Branches 100%Branches 100%Lines 100%Lines 100%Functions 98.43%Functions 98.43% diff --git a/badges/tests-badge.svg b/badges/tests-badge.svg index 671e0d3..78ade2a 100644 --- a/badges/tests-badge.svg +++ b/badges/tests-badge.svg @@ -1 +1 @@ -TestsTests315/315315/315 \ No newline at end of file +TestsTests320/320320/320 \ No newline at end of file diff --git a/dist/index-browser-esm.js b/dist/index-browser-esm.js index f177731..ecda1d6 100644 --- a/dist/index-browser-esm.js +++ b/dist/index-browser-esm.js @@ -1591,7 +1591,7 @@ function unshift(item, arr) { * @param {unknown} val * @param {ExpressionArray} path * @param {ParentValue} parent - * @param {string|null} parentPropName + * @param {string|number|null} parentPropName * @returns {boolean|null} */ @@ -1667,6 +1667,8 @@ function unshift(item, arr) { * @property {JSONPathCallback} [callback] * @property {OtherTypeCallback} [otherTypeCallback] Defaults to * function which throws on encountering `@other` + * @property {Record} [customTypes] Map of custom + * type operator names to their evaluation callbacks * @property {boolean} [autostart=true] * @property {boolean} [ignoreEvalErrors=false] */ @@ -1795,6 +1797,9 @@ class JSONPathClass { /** @type {OtherTypeCallback|undefined} */ this.currOtherTypeCallback = undefined; + /** @type {Record|undefined} */ + this.currCustomTypes = undefined; + /** @type {SandboxType|undefined} */ this.currSandbox = undefined; this._hasParentSelector = false; @@ -1813,6 +1818,7 @@ class JSONPathClass { this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function () { throw new TypeError('You must supply an otherTypeCallback callback option ' + 'with the @other() operator.'); }; + this.customTypes = opts.customTypes || {}; if (opts.autostart !== false) { const args = /** @type {JSONPathOptions} */{ path: optObj ? opts.path : expr @@ -1873,6 +1879,7 @@ class JSONPathClass { this.currSandbox = this.sandbox; callback ||= this.callback; this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback; + this.currCustomTypes = this.customTypes; if (expr && typeof expr === 'object' && !Array.isArray(expr)) { const exprObj = expr; if (!exprObj.path && exprObj.path !== '') { @@ -1891,6 +1898,7 @@ class JSONPathClass { this.currEval = Object.hasOwn(exprObj, 'eval') ? exprObj.eval : this.currEval; callback = Object.hasOwn(exprObj, 'callback') ? exprObj.callback : callback; this.currOtherTypeCallback = Object.hasOwn(exprObj, 'otherTypeCallback') ? exprObj.otherTypeCallback : this.currOtherTypeCallback; + this.currCustomTypes = Object.hasOwn(exprObj, 'customTypes') ? exprObj.customTypes : this.currCustomTypes; currParent = Object.hasOwn(exprObj, 'parent') ? exprObj.parent : currParent; currParentProperty = Object.hasOwn(exprObj, 'parentProperty') ? exprObj.parentProperty : currParentProperty; expr = exprObj.path; @@ -2151,7 +2159,7 @@ class JSONPathClass { } else if (loc[0] === '@') { // value type: @boolean(), etc. let addType = false; - const valueType = /** @type {ValueType} */loc.slice(1, -2); + const valueType = /** @type {ValueType|string} */loc.slice(1, -2); switch (valueType) { case 'scalar': if (!val || !['object', 'function'].includes(typeof val)) { @@ -2192,7 +2200,7 @@ class JSONPathClass { } break; case 'other': - addType = this.currOtherTypeCallback?.(val, path, parent, /** @type {string|null} */parentPropName) ?? false; + addType = /** @type {OtherTypeCallback} */this.currOtherTypeCallback(val, path, parent, parentPropName) || false; break; case 'null': if (val === null) { @@ -2201,7 +2209,11 @@ class JSONPathClass { break; /* c8 ignore next 2 */ default: - throw new TypeError('Unknown value type ' + valueType); + if (this.currCustomTypes && Object.hasOwn(this.currCustomTypes, valueType)) { + addType = this.currCustomTypes[valueType](val, path, parent, parentPropName) || false; + } else { + throw new TypeError('Unknown value type ' + valueType); + } } if (addType) { retObj = { @@ -2473,7 +2485,7 @@ JSONPath.toPathArray = function (expr) { const subx = []; const normalized = expr // Properties - .replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ';$&;') + .replaceAll(/@[\w$-]+\(\)/gu, ';$&;') // Parenthetical evaluations (filtering and otherwise), directly // within brackets or single quotes .replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function ($0, $1) { diff --git a/dist/index-browser-esm.min.js b/dist/index-browser-esm.min.js index 0af3f9c..688ab17 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,n){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,n?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 n={context:this,node:r};return e.hooks.run(t,n),n.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,n,s=[];for(;this.index0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.lengthi.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;s.length>2&&h(s[s.length-2]);)a=s.pop(),r=s.pop().value,o=s.pop(),t={type:e.BINARY_EXP,operator:r,left:o,right:a},s.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+l),s.push(i,t)}for(h=s.length-1,t=s[h];h>1;)t={type:e.BINARY_EXP,operator:s[h-1].value,left:s[h-2],right:t},h-=2;return t}gobbleToken(){let t,r,n,s;if(this.gobbleSpaces(),s=this.searchHook("gobble-token"),s)return this.runHook("after-token",s);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)s=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)s=this.gobbleArray();else{for(r=this.expr.substr(this.index,e.max_unop_len),n=r.length;n>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++,s++,s!==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(),n=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(e).filter(e=>!n.includes(e)&&void 0===r[e]).forEach(t=>{r[t]=e[t]}),r.Jsep=e;var s={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,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const s=this.gobbleExpression();if(s||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:s},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}};r.plugins.register(s);var i={name:"regex",init(e){e.hooks.add("gobble-token",function(t){if(47===this.code){const r=++this.index;let n=!1;for(;this.index=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;i+=this.char}try{s=new RegExp(n,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:s,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!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]),l=e=>"function"==typeof e&&h.has(e),c=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()}),p=Object.assign(Object.create(null),{"-":e=>-e,"!":e=>!e,"~":e=>~e,"+":e=>+e,typeof:e=>typeof e,void:()=>{}}),u={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return u.evalBinaryExpression(e,t);case"Compound":return u.evalCompound(e,t);case"ConditionalExpression":return u.evalConditionalExpression(e,t);case"Identifier":return u.evalIdentifier(e,t);case"Literal":return u.evalLiteral(e);case"MemberExpression":return u.evalMemberExpression(e,t);case"UnaryExpression":return u.evalUnaryExpression(e,t);case"ArrayExpression":return u.evalArrayExpression(e,t);case"CallExpression":return u.evalCallExpression(e,t);case"AssignmentExpression":return u.evalAssignmentExpression(e,t);default:throw new SyntaxError("Unexpected expression",{cause:e})}},evalBinaryExpression(e,t){if(!Object.hasOwn(c,e.operator))throw new SyntaxError(`Unknown binary operator: ${e.operator}`);return c[e.operator](u.evalAst(e.left,t),()=>u.evalAst(e.right,t))},evalCompound(e,t){let r;for(let n=0;nu.evalAst(e.test,t)?u.evalAst(e.consequent,t):u.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?u.evalAst(e.property,t):e.property.name),n=u.evalAst(e.object,t);if(null==n)throw new TypeError(`Cannot read properties of ${n} (reading '${r}')`);if(!Object.hasOwn(n,r)&&a.has(r))throw new TypeError(`Cannot read properties of ${n} (reading '${r}')`);const s=n[r];if(l(s))throw new TypeError("Function constructor is disabled");return"function"==typeof s?s.bind(n):s},evalUnaryExpression(e,t){if(!Object.hasOwn(p,e.operator))throw new SyntaxError(`Unknown unary operator: ${e.operator}`);const r=u.evalAst(e.argument,t);return p[e.operator](r)},evalArrayExpression:(e,t)=>e.elements.map(e=>u.evalAst(e,t)),evalCallExpression(e,t){const r=e.arguments.map(e=>u.evalAst(e,t)),n=u.evalAst(e.callee,t);if(l(n)||r.some(e=>l(e)))throw new Error("Function constructor is disabled");return n(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw new SyntaxError("Invalid left-hand side in assignment");const r=e.left.name,n=u.evalAst(e.right,t);return t[r]=n,t[r]}};const d=new Map,f=new Map;function b(e,t){return(e=e.slice()).push(t),e}function E(e,t){return(t=t.slice()).unshift(e),t}function y(e,t,r,n,s){try{return e&&"object"==typeof e?new x(e):new x(e,t,r,n,s)}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,n,s){"string"==typeof e&&(s=n,n=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.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||n||null,this.otherTypeCallback=e.otherTypeCallback||s||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){const n={path:i?e.path:t};i||void 0===r?"json"in e&&(n.json=e.json):n.json=r;const s=this.evaluate(n);if(!s||"object"!=typeof s){const e=new Error('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');throw e.value=s,e}return s}}evaluate(e,t,r,n){let s=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=n||this.otherTypeCallback,e&&"object"==typeof e&&!Array.isArray(e)){const n=e;if(!n.path&&""!==n.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(n,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=n),o=Object.hasOwn(n,"flatten")?n.flatten:o,this.currResultType=Object.hasOwn(n,"resultType")?n.resultType:this.currResultType,this.currSandbox=Object.hasOwn(n,"sandbox")?n.sandbox:this.currSandbox,a=Object.hasOwn(n,"wrap")?n.wrap:a,this.currEval=Object.hasOwn(n,"eval")?n.eval:this.currEval,r=Object.hasOwn(n,"callback")?n.callback:r,this.currOtherTypeCallback=Object.hasOwn(n,"otherTypeCallback")?n.otherTypeCallback:this.currOtherTypeCallback,s=Object.hasOwn(n,"parent")?n.parent:s,i=Object.hasOwn(n,"parentProperty")?n.parentProperty:i,e=n.path}else t||=this.json,e||=this.path;if(s||=null,i||=null,Array.isArray(e)&&(e=y.toPathString(e)),!t||!e&&""!==e)return;const h=y.toPathArray(e);"$"===h[0]&&h.length>1&&h.shift(),this._hasParentSelector=!1;const l=this._trace(h,t,["$"],s,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:y.toPathArray(e.path);return e.pointer=y.toPointer(t),e.path="string"==typeof e.path?e.path:y.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return"string"==typeof e.path?e.path:y.toPathString(e.path);case"pointer":{const t=Array.isArray(e.path)?e.path:y.toPathArray(e.path);return y.toPointer(t)}default:throw new TypeError("Unknown result type")}}_handleCallback(e,t,r){if(!t)return;const n=this._getPreferredOutput(e);Array.isArray(e.path)&&(e.path=y.toPathString(e.path)),t(n,r,e)}_trace(e,t,r,n,s,i,o,a){let h;if(!e.length)return h={path:r,value:t,parent:n,parentProperty:s,hasArrExpr:o},this._handleCallback(h,i,"value"),h;const l=e[0],c=e.slice(1),p=[];function u(e){Array.isArray(e)?e.forEach(e=>{p.push(e)}):p.push(e)}if(t&&("string"!=typeof l||a)&&Object.hasOwn(t,l)){const e=t;u(this._trace(c,e[l],b(r,l),t,l,i,o))}else if("*"===l)this._walk(t,e=>{const n=t;u(this._trace(c,n[e],b(r,e),t,e,i,!0,!0))});else if(".."===l)u(this._trace(c,t,r,n,s,i,o)),this._walk(t,n=>{const s=t;"object"==typeof s[n]&&u(this._trace(e.slice(),s[n],b(r,n),t,n,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:b(r,l),value:s,parent:n,parentProperty:null},this._handleCallback(h,i,"property"),h;if("$"===l)u(this._trace(c,t,r,null,null,i,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(l)){const e=this._slice(l,c,t,r,n,s,i);e&&u(e)}else if(0===l.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=l.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);if(o)this._walk(t,e=>{const a=[o[2]],h=t,l=o[1]?h[e][o[1]]:h[e],p=this._trace(a,l,r,n,s,i,!0);(Array.isArray(p)?p:[p]).length>0&&u(this._trace(c,h[e],b(r,e),t,e,i,!0))});else{const o=t;this._walk(t,a=>{this._eval(e,o[a],a,r,n,s)&&u(this._trace(c,o[a],b(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),n,s),a=void 0!==e?e:"";u(this._trace(E(a,c),t,r,n,s,i,o))}else if("@"===l[0]){let e=!1;const o=l.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback?.(t,r,n,s)??!1;break;case"null":null===t&&(e=!0);break;default:throw new TypeError("Unknown value type "+o)}if(e)return h={path:r,value:t,parent:n,parentProperty:s},this._handleCallback(h,i,"value"),h}else if(t&&"`"===l[0]&&Object.hasOwn(t,l.slice(1))){const e=l.slice(1),n=t;u(this._trace(c,n[e],b(r,e),t,e,i,o,!0))}else if(l.includes(",")){const e=l.split(",");for(const o of e)u(this._trace(E(o,c),t,r,n,s,i,!0))}else if(!a&&t&&Object.hasOwn(t,l)){const e=t;u(this._trace(c,e[l],b(r,l),t,l,i,o,!0))}}if(this._hasParentSelector)for(let e=0;e{t(e)})}_slice(e,t,r,n,s,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,n,s,i){this.currSandbox&&(this.currSandbox._$_parentProperty=i,this.currSandbox._$_parent=s,this.currSandbox._$_property=r,this.currSandbox._$_root=this.json,this.currSandbox._$_v=t);const o=e.includes("@path");if(o){(this.currSandbox??{})._$_path=y.toPathString(n.concat([r]))}const a=this.currEval+"Script:"+e;if(!d.has(a)){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");o&&(t=t.replaceAll("@path","_$_path"));const r=this.currEval;if(["safe",!0,void 0].includes(r))d.set(a,new this.safeVm.Script(t));else if("native"===this.currEval)d.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;d.set(a,new e(t))}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);{const e=this.currEval;d.set(a,{runInNewContext:r=>e(t,r)})}}}try{return d.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 u.evalAst(this.ast,t)}}},y.prototype=x.prototype,y.clearCache=function(){f.clear(),d.clear()},y.toPathString=function(e){const t=e,r=t.length;let n="$";for(let e=1;e"function"==typeof e[t]);const s=r.map(t=>e[t]);t=n.reduce((t,r)=>{let n=e[r].toString();return/function/u.test(n)||(n="function "+n),"var "+r+"="+n+";"+t},"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const i=t.lastIndexOf(";"),o=-1!==i?t.slice(0,i+1)+" return "+t.slice(i+1):" return "+t;return new Function(...r,o)(...s)}}x.prototype.vm={Script:g};export{y as JSONPath,x as JSONPathClass,g 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 "+l),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]),l=e=>"function"==typeof e&&h.has(e),c=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()}),p=Object.assign(Object.create(null),{"-":e=>-e,"!":e=>!e,"~":e=>~e,"+":e=>+e,typeof:e=>typeof e,void:()=>{}}),u={evalAst(e,t){switch(e.type){case"BinaryExpression":case"LogicalExpression":return u.evalBinaryExpression(e,t);case"Compound":return u.evalCompound(e,t);case"ConditionalExpression":return u.evalConditionalExpression(e,t);case"Identifier":return u.evalIdentifier(e,t);case"Literal":return u.evalLiteral(e);case"MemberExpression":return u.evalMemberExpression(e,t);case"UnaryExpression":return u.evalUnaryExpression(e,t);case"ArrayExpression":return u.evalArrayExpression(e,t);case"CallExpression":return u.evalCallExpression(e,t);case"AssignmentExpression":return u.evalAssignmentExpression(e,t);default:throw new SyntaxError("Unexpected expression",{cause:e})}},evalBinaryExpression(e,t){if(!Object.hasOwn(c,e.operator))throw new SyntaxError(`Unknown binary operator: ${e.operator}`);return c[e.operator](u.evalAst(e.left,t),()=>u.evalAst(e.right,t))},evalCompound(e,t){let r;for(let s=0;su.evalAst(e.test,t)?u.evalAst(e.consequent,t):u.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?u.evalAst(e.property,t):e.property.name),s=u.evalAst(e.object,t);if(null==s)throw new TypeError(`Cannot read properties of ${s} (reading '${r}')`);if(!Object.hasOwn(s,r)&&a.has(r))throw new TypeError(`Cannot read properties of ${s} (reading '${r}')`);const n=s[r];if(l(n))throw new TypeError("Function constructor is disabled");return"function"==typeof n?n.bind(s):n},evalUnaryExpression(e,t){if(!Object.hasOwn(p,e.operator))throw new SyntaxError(`Unknown unary operator: ${e.operator}`);const r=u.evalAst(e.argument,t);return p[e.operator](r)},evalArrayExpression:(e,t)=>e.elements.map(e=>u.evalAst(e,t)),evalCallExpression(e,t){const r=e.arguments.map(e=>u.evalAst(e,t)),s=u.evalAst(e.callee,t);if(l(s)||r.some(e=>l(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=u.evalAst(e.right,t);return t[r]=s,t[r]}};const d=new Map,f=new Map;function b(e,t){return(e=e.slice()).push(t),e}function E(e,t){return(t=t.slice()).unshift(e),t}function y(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){const s={path:i?e.path:t};i||void 0===r?"json"in e&&(s.json=e.json):s.json=r;const n=this.evaluate(s);if(!n||"object"!=typeof n){const e=new Error('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');throw e.value=n,e}return n}}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=y.toPathString(e)),!t||!e&&""!==e)return;const h=y.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:y.toPathArray(e.path);return e.pointer=y.toPointer(t),e.path="string"==typeof e.path?e.path:y.toPathString(e.path),e}case"value":case"parent":case"parentProperty":return e[t];case"path":return"string"==typeof e.path?e.path:y.toPathString(e.path);case"pointer":{const t=Array.isArray(e.path)?e.path:y.toPathArray(e.path);return y.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=y.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),p=[];function u(e){Array.isArray(e)?e.forEach(e=>{p.push(e)}):p.push(e)}if(t&&("string"!=typeof l||a)&&Object.hasOwn(t,l)){const e=t;u(this._trace(c,e[l],b(r,l),t,l,i,o))}else if("*"===l)this._walk(t,e=>{const s=t;u(this._trace(c,s[e],b(r,e),t,e,i,!0,!0))});else if(".."===l)u(this._trace(c,t,r,s,n,i,o)),this._walk(t,s=>{const n=t;"object"==typeof n[s]&&u(this._trace(e.slice(),n[s],b(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:b(r,l),value:n,parent:s,parentProperty:null},this._handleCallback(h,i,"property"),h;if("$"===l)u(this._trace(c,t,r,null,null,i,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(l)){const e=this._slice(l,c,t,r,s,n,i);e&&u(e)}else if(0===l.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=l.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);if(o)this._walk(t,e=>{const a=[o[2]],h=t,l=o[1]?h[e][o[1]]:h[e],p=this._trace(a,l,r,s,n,i,!0);(Array.isArray(p)?p:[p]).length>0&&u(this._trace(c,h[e],b(r,e),t,e,i,!0))});else{const o=t;this._walk(t,a=>{this._eval(e,o[a],a,r,s,n)&&u(this._trace(c,o[a],b(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:"";u(this._trace(E(a,c),t,r,s,n,i,o))}else if("@"===l[0]){let e=!1;const o=l.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback(t,r,s,n)||!1;break;case"null":null===t&&(e=!0);break;default:if(!this.currCustomTypes||!Object.hasOwn(this.currCustomTypes,o))throw new TypeError("Unknown value type "+o);e=this.currCustomTypes[o](t,r,s,n)||!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;u(this._trace(c,s[e],b(r,e),t,e,i,o,!0))}else if(l.includes(",")){const e=l.split(",");for(const o of e)u(this._trace(E(o,c),t,r,s,n,i,!0))}else if(!a&&t&&Object.hasOwn(t,l)){const e=t;u(this._trace(c,e[l],b(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=y.toPathString(s.concat([r]))}const a=this.currEval+"Script:"+e;if(!d.has(a)){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");o&&(t=t.replaceAll("@path","_$_path"));const r=this.currEval;if(["safe",!0,void 0].includes(r))d.set(a,new this.safeVm.Script(t));else if("native"===this.currEval)d.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;d.set(a,new e(t))}else{if("function"!=typeof this.currEval)throw new TypeError(`Unknown "eval" property "${this.currEval}"`);{const e=this.currEval;d.set(a,{runInNewContext:r=>e(t,r)})}}}try{return d.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 u.evalAst(this.ast,t)}}},y.prototype=x.prototype,y.clearCache=function(){f.clear(),d.clear()},y.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/u.test(s)||(s="function "+s),"var "+r+"="+s+";"+t},"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");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:g};export{y as JSONPath,x as JSONPathClass,g 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 f16732a..cbd8a7c 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/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/** @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]);\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 * @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 if (SafeEval.evalAst(ast.test, subs)) {\n return SafeEval.evalAst(ast.consequent, subs);\n }\n return 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 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 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};\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} from './Safe-Script.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\"} 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|null} parentPropName\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 {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 {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 : false;\n this.wrap = Object.hasOwn(opts, 'wrap') ? opts.wrap : true;\n this.sandbox = opts.sandbox || {};\n this.eval = opts.eval === undefined ? 'safe' : opts.eval;\n this.ignoreEvalErrors = (typeof opts.ignoreEvalErrors === 'undefined')\n ? false\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\n if (opts.autostart !== false) {\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 // eslint-disable-next-line @stylistic/max-len -- Long\n // @ts-expect-error - Constructor returns evaluate result for legacy API\n // eslint-disable-next-line no-constructor-return -- Legacy API\n return ret;\n }\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\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 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*)$/u).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(/^\\?\\((.*?)\\)$/u, '$1');\n // check for a nested filter expression\n\n const nested = (/@.?([^?]*)[['](\\??\\(.*?\\))(?!.\\)\\])[\\]']/gu).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 const nvalue = /** @type {ValueType} */ (nested[1]\n ? /** @type {Record} */ (\n valObj2[m]\n )[nested[1]]\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 let addType = false;\n const valueType = /** @type {ValueType} */ (loc).slice(1, -2);\n switch (valueType) {\n case 'scalar':\n if (!val || !(['object', 'function'].includes(typeof val))) {\n addType = true;\n }\n break;\n case 'boolean': case 'string': case 'undefined': case 'function':\n if (typeof val === valueType) {\n addType = true;\n }\n break;\n case 'integer':\n if (Number.isFinite(val) &&\n !(/** @type {number} */ (val) % 1)) {\n addType = true;\n }\n break;\n case 'number':\n if (Number.isFinite(val)) {\n addType = true;\n }\n break;\n case 'nonFinite':\n if (typeof val === 'number' && !Number.isFinite(val)) {\n addType = true;\n }\n break;\n case 'object':\n if (val && typeof val === valueType) {\n addType = true;\n }\n break;\n case 'array':\n if (Array.isArray(val)) {\n addType = true;\n }\n break;\n case 'other':\n addType = this.currOtherTypeCallback?.(\n val, path, parent,\n /** @type {string|null} */ (parentPropName)\n ) ?? false;\n break;\n case 'null':\n if (val === null) {\n addType = true;\n }\n break;\n /* c8 ignore next 2 */\n default:\n throw new TypeError('Unknown value type ' + valueType);\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.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 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 }\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 .replaceAll(/@([.\\s)[])/gu, '_$_v$1');\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 (!(/^(~|\\^|@.*?\\(\\))$/u).test(x[i])) {\n p += (/^[0-9*]+$/u).test(x[i]) ? ('[' + x[i] + ']') : (\"['\" + x[i] + \"']\");\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 (!(/^(~|\\^|@.*?\\(\\))$/u).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 /@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\\(\\)/gu,\n ';$&;'\n )\n // Parenthetical evaluations (filtering and otherwise), directly\n // within brackets or single quotes\n .replaceAll(/[['](\\??\\(.*?\\))[\\]'](?!.\\])/gu, 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 // Escape periods and tildes within properties\n .replaceAll(/\\[['\"]([^'\\]]*)['\"]\\]/gu, 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(/['\"]?\\.['\"]?(?![^[]*\\])|\\[['\"]?/gu, ';')\n // Reinsert periods within properties\n .replaceAll('%@%', '.')\n // Reinsert tildes within properties\n .replaceAll('%%@@%%', '~')\n // Parent\n .replaceAll(/(?:;)?(\\^+)(?:;)?/gu, function ($0, ups) {\n return ';' + ups.split('').join(';') + ';';\n })\n // Descendents\n .replaceAll(/;;;|;;/gu, ';..;')\n // Remove trailing\n .replaceAll(/;$|'?\\]|'$/gu, '');\n\n const exprList = normalized.split(';').map(function (exp) {\n const match = exp.match(/#(\\d+)/u);\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/u).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/u).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*$/u, '');\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","isBlockedFunction","BINOPS","create","||","a","b","&&","|","^","&","==","!=","===","!==","<",">","<=",">=","<<",">>",">>>","+","-","*","/","%","UNOPS","typeof","void","SafeEval","evalAst","ast","subs","evalBinaryExpression","evalCompound","evalConditionalExpression","evalIdentifier","evalLiteral","evalMemberExpression","evalUnaryExpression","evalArrayExpression","evalCallExpression","evalAssignmentExpression","SyntaxError","cause","hasOwn","last","ReferenceError","TypeError","result","operand","el","func","id","scriptCache","Map","pathCache","arr","item","unshift","JSONPath","opts","otherTypeCallback","JSONPathClass","optObj","currResultType","currEval","currOtherTypeCallback","currSandbox","_hasParentSelector","json","path","resultType","flatten","wrap","sandbox","eval","ignoreEvalErrors","parent","parentProperty","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","valueType","Number","isFinite","locProp","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","replaceAll","evalType","set","safeVm","Script","vm","CurrEval","evalFunc","runInNewContext","get","keyMap","clearCache","clear","pathArr","p","subx","$0","$1","ups","join","exp","match","funcs","source","target","conditionCb","il","moveToAnotherArray","key","vr","s","fString","lastStatementEnd","lastIndexOf"],"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,kBAAkBE,OAAOb,GAExBJ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,EAAU,IAAMD,GAC9C,IAEiBtX,EAGd,sBAAuBoJ,KAAKpJ,IAAUS,EAAKuI,SAAS,eACtDhJ,EAAO,6BAA+BA,GAM1CA,EAAOA,EAAK6S,QAAQ,SAAU,IAG9B,MAAM2E,EAAmBxX,EAAKyX,YAAY,KACpCtX,GACmB,IAArBqX,EACMxX,EAAKmH,MAAM,EAAGqQ,EAAmB,GACjC,WACAxX,EAAKmH,MAAMqQ,EAAmB,GAC9B,WAAaxX,EAGvB,OAAO,IAAI6K,YAAYpK,EAAMN,EAAtB,IAA+BgK,EAC1C,EAIqBgF,EAAuB,UAAG0G,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/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/** @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]);\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 * @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 if (SafeEval.evalAst(ast.test, subs)) {\n return SafeEval.evalAst(ast.consequent, subs);\n }\n return 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 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 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};\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} from './Safe-Script.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\"} 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 * @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 custom\n * 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 : false;\n this.wrap = Object.hasOwn(opts, 'wrap') ? opts.wrap : true;\n this.sandbox = opts.sandbox || {};\n this.eval = opts.eval === undefined ? 'safe' : opts.eval;\n this.ignoreEvalErrors = (typeof opts.ignoreEvalErrors === 'undefined')\n ? false\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 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 // eslint-disable-next-line @stylistic/max-len -- Long\n // @ts-expect-error - Constructor returns evaluate result for legacy API\n // eslint-disable-next-line no-constructor-return -- Legacy API\n return ret;\n }\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*)$/u).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(/^\\?\\((.*?)\\)$/u, '$1');\n // check for a nested filter expression\n\n const nested = (/@.?([^?]*)[['](\\??\\(.*?\\))(?!.\\)\\])[\\]']/gu).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 const nvalue = /** @type {ValueType} */ (nested[1]\n ? /** @type {Record} */ (\n valObj2[m]\n )[nested[1]]\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 let addType = false;\n const valueType = /** @type {ValueType|string} */ (\n loc\n ).slice(1, -2);\n switch (valueType) {\n case 'scalar':\n if (!val || !(['object', 'function'].includes(typeof val))) {\n addType = true;\n }\n break;\n case 'boolean': case 'string': case 'undefined': case 'function':\n if (typeof val === valueType) {\n addType = true;\n }\n break;\n case 'integer':\n if (Number.isFinite(val) &&\n !(/** @type {number} */ (val) % 1)) {\n addType = true;\n }\n break;\n case 'number':\n if (Number.isFinite(val)) {\n addType = true;\n }\n break;\n case 'nonFinite':\n if (typeof val === 'number' && !Number.isFinite(val)) {\n addType = true;\n }\n break;\n case 'object':\n if (val && typeof val === valueType) {\n addType = true;\n }\n break;\n case 'array':\n if (Array.isArray(val)) {\n addType = true;\n }\n break;\n case 'other':\n addType = /** @type {OtherTypeCallback} */ (\n this.currOtherTypeCallback\n )(\n val, path, parent, parentPropName\n ) || false;\n break;\n case 'null':\n if (val === null) {\n addType = true;\n }\n break;\n /* c8 ignore next 2 */\n default:\n if (this.currCustomTypes &&\n Object.hasOwn(this.currCustomTypes, valueType)\n ) {\n addType = this.currCustomTypes[valueType](\n val, path, parent, parentPropName\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.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 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 }\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 .replaceAll(/@([.\\s)[])/gu, '_$_v$1');\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 (!(/^(~|\\^|@.*?\\(\\))$/u).test(x[i])) {\n p += (/^[0-9*]+$/u).test(x[i]) ? ('[' + x[i] + ']') : (\"['\" + x[i] + \"']\");\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 (!(/^(~|\\^|@.*?\\(\\))$/u).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$-]+\\(\\)/gu,\n ';$&;'\n )\n // Parenthetical evaluations (filtering and otherwise), directly\n // within brackets or single quotes\n .replaceAll(/[['](\\??\\(.*?\\))[\\]'](?!.\\])/gu, 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 // Escape periods and tildes within properties\n .replaceAll(/\\[['\"]([^'\\]]*)['\"]\\]/gu, 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(/['\"]?\\.['\"]?(?![^[]*\\])|\\[['\"]?/gu, ';')\n // Reinsert periods within properties\n .replaceAll('%@%', '.')\n // Reinsert tildes within properties\n .replaceAll('%%@@%%', '~')\n // Parent\n .replaceAll(/(?:;)?(\\^+)(?:;)?/gu, function ($0, ups) {\n return ';' + ups.split('').join(';') + ';';\n })\n // Descendents\n .replaceAll(/;;;|;;/gu, ';..;')\n // Remove trailing\n .replaceAll(/;$|'?\\]|'$/gu, '');\n\n const exprList = normalized.split(';').map(function (exp) {\n const match = exp.match(/#(\\d+)/u);\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/u).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/u).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*$/u, '');\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","isBlockedFunction","BINOPS","create","||","a","b","&&","|","^","&","==","!=","===","!==","<",">","<=",">=","<<",">>",">>>","+","-","*","/","%","UNOPS","typeof","void","SafeEval","evalAst","ast","subs","evalBinaryExpression","evalCompound","evalConditionalExpression","evalIdentifier","evalLiteral","evalMemberExpression","evalUnaryExpression","evalArrayExpression","evalCallExpression","evalAssignmentExpression","SyntaxError","cause","hasOwn","last","ReferenceError","TypeError","result","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","valueType","Number","isFinite","locProp","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","replaceAll","evalType","set","safeVm","Script","vm","CurrEval","evalFunc","runInNewContext","get","keyMap","clearCache","clear","pathArr","p","subx","$0","$1","ups","join","exp","match","funcs","source","target","conditionCb","il","moveToAnotherArray","key","vr","s","fString","lastStatementEnd","lastIndexOf"],"mappings":"AAgGA,MAAMA,EAIL,kBAAWC,GAEV,MAAO,OACR,CAKA,eAAOC,GACN,MAAO,wCAA0CF,EAAKC,OACvD,CAQA,iBAAOE,CAA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AI5V,EAAM8Q,GACYlC,EAAUuH,IAAInW,GAAO0R,QACzD,EC1lCA,MAAMoE,EAIF,WAAAzV,CAAaL,GACTD,KAAKI,KAAOH,CAChB,CAOA,eAAAkW,CAAiBnU,GACb,IAAI/B,EAAOD,KAAKI,KAChB,MAAMM,EAAOD,OAAOC,KAAKsB,GACnBiV,EAAiC,IA7BpB,SAAUC,EAAQC,EAAQC,GACjD,MAAMC,EAAKH,EAAO3Y,OAClB,IAAK,IAAI2F,EAAI,EAAGA,EAAImT,EAAInT,IAEhBkT,EADSF,EAAOhT,KAEhBiT,EAAO9T,KAAK6T,EAAOzC,OAAOvQ,IAAK,GAAG,GAG9C,CAsBQoT,CAAmB5W,EAAMuW,EAAQM,GACE,mBAAjBvV,EAAQuV,IAE1B,MAAMnN,EAAS1J,EAAKC,IAAK6W,GACdxV,EAAQwV,IAWnBvX,EARmBgX,EAAMzF,OAAO,CAACiG,EAAGhJ,KAChC,IAAIiJ,EAAU1V,EAAQyM,GAAMxQ,WAI5B,MAHM,YAAaoL,KAAKqO,KACpBA,EAAU,YAAcA,GAErB,OAASjJ,EAAO,IAAMiJ,EAAU,IAAMD,GAC9C,IAEiBxX,EAGd,sBAAuBoJ,KAAKpJ,IAAUS,EAAKuI,SAAS,eACtDhJ,EAAO,6BAA+BA,GAM1CA,EAAOA,EAAK+S,QAAQ,SAAU,IAG9B,MAAM2E,EAAmB1X,EAAK2X,YAAY,KACpCxX,GACmB,IAArBuX,EACM1X,EAAKmH,MAAM,EAAGuQ,EAAmB,GACjC,WACA1X,EAAKmH,MAAMuQ,EAAmB,GAC9B,WAAa1X,EAGvB,OAAO,IAAI6K,YAAYpK,EAAMN,EAAtB,IAA+BgK,EAC1C,EAIqBgF,EAAuB,UAAG4G,GAAK,CACpDD","x_google_ignoreList":[0,1,2]} \ No newline at end of file diff --git a/dist/index-browser-umd.cjs b/dist/index-browser-umd.cjs index 0c6c65a..327ced4 100644 --- a/dist/index-browser-umd.cjs +++ b/dist/index-browser-umd.cjs @@ -1597,7 +1597,7 @@ * @param {unknown} val * @param {ExpressionArray} path * @param {ParentValue} parent - * @param {string|null} parentPropName + * @param {string|number|null} parentPropName * @returns {boolean|null} */ @@ -1673,6 +1673,8 @@ * @property {JSONPathCallback} [callback] * @property {OtherTypeCallback} [otherTypeCallback] Defaults to * function which throws on encountering `@other` + * @property {Record} [customTypes] Map of custom + * type operator names to their evaluation callbacks * @property {boolean} [autostart=true] * @property {boolean} [ignoreEvalErrors=false] */ @@ -1801,6 +1803,9 @@ /** @type {OtherTypeCallback|undefined} */ this.currOtherTypeCallback = undefined; + /** @type {Record|undefined} */ + this.currCustomTypes = undefined; + /** @type {SandboxType|undefined} */ this.currSandbox = undefined; this._hasParentSelector = false; @@ -1819,6 +1824,7 @@ this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function () { throw new TypeError('You must supply an otherTypeCallback callback option ' + 'with the @other() operator.'); }; + this.customTypes = opts.customTypes || {}; if (opts.autostart !== false) { const args = /** @type {JSONPathOptions} */{ path: optObj ? opts.path : expr @@ -1879,6 +1885,7 @@ this.currSandbox = this.sandbox; callback ||= this.callback; this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback; + this.currCustomTypes = this.customTypes; if (expr && typeof expr === 'object' && !Array.isArray(expr)) { const exprObj = expr; if (!exprObj.path && exprObj.path !== '') { @@ -1897,6 +1904,7 @@ this.currEval = Object.hasOwn(exprObj, 'eval') ? exprObj.eval : this.currEval; callback = Object.hasOwn(exprObj, 'callback') ? exprObj.callback : callback; this.currOtherTypeCallback = Object.hasOwn(exprObj, 'otherTypeCallback') ? exprObj.otherTypeCallback : this.currOtherTypeCallback; + this.currCustomTypes = Object.hasOwn(exprObj, 'customTypes') ? exprObj.customTypes : this.currCustomTypes; currParent = Object.hasOwn(exprObj, 'parent') ? exprObj.parent : currParent; currParentProperty = Object.hasOwn(exprObj, 'parentProperty') ? exprObj.parentProperty : currParentProperty; expr = exprObj.path; @@ -2157,7 +2165,7 @@ } else if (loc[0] === '@') { // value type: @boolean(), etc. let addType = false; - const valueType = /** @type {ValueType} */loc.slice(1, -2); + const valueType = /** @type {ValueType|string} */loc.slice(1, -2); switch (valueType) { case 'scalar': if (!val || !['object', 'function'].includes(typeof val)) { @@ -2198,7 +2206,7 @@ } break; case 'other': - addType = this.currOtherTypeCallback?.(val, path, parent, /** @type {string|null} */parentPropName) ?? false; + addType = /** @type {OtherTypeCallback} */this.currOtherTypeCallback(val, path, parent, parentPropName) || false; break; case 'null': if (val === null) { @@ -2207,7 +2215,11 @@ break; /* c8 ignore next 2 */ default: - throw new TypeError('Unknown value type ' + valueType); + if (this.currCustomTypes && Object.hasOwn(this.currCustomTypes, valueType)) { + addType = this.currCustomTypes[valueType](val, path, parent, parentPropName) || false; + } else { + throw new TypeError('Unknown value type ' + valueType); + } } if (addType) { retObj = { @@ -2479,7 +2491,7 @@ const subx = []; const normalized = expr // Properties - .replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ';$&;') + .replaceAll(/@[\w$-]+\(\)/gu, ';$&;') // Parenthetical evaluations (filtering and otherwise), directly // within brackets or single quotes .replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function ($0, $1) { diff --git a/dist/index-browser-umd.min.cjs b/dist/index-browser-umd.min.cjs index a24c3d5..06e814f 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,n){return t.max_binop_len=Math.max(e.length,t.max_binop_len),t.binary_ops[e]=r,n?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 n={context:this,node:r};return t.hooks.run(e,n),n.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,n,s=[];for(;this.index0;){if(t.binary_ops.hasOwnProperty(e)&&(!t.isIdentifierStart(this.code)||this.index+e.lengthi.right_a&&e.right_a?n>e.prec:n<=e.prec;for(;s.length>2&&h(s[s.length-2]);)a=s.pop(),r=s.pop().value,o=s.pop(),e={type:t.BINARY_EXP,operator:r,left:o,right:a},s.push(e);e=this.gobbleToken(),e||this.throwError("Expected expression after "+l),s.push(i,e)}for(h=s.length-1,e=s[h];h>1;)e={type:t.BINARY_EXP,operator:s[h-1].value,left:s[h-2],right:e},h-=2;return e}gobbleToken(){let e,r,n,s;if(this.gobbleSpaces(),s=this.searchHook("gobble-token"),s)return this.runHook("after-token",s);if(e=this.code,t.isDecimalDigit(e)||e===t.PERIOD_CODE)return this.gobbleNumericLiteral();if(e===t.SQUOTE_CODE||e===t.DQUOTE_CODE)s=this.gobbleStringLiteral();else if(e===t.OBRACK_CODE)s=this.gobbleArray();else{for(r=this.expr.substr(this.index,t.max_unop_len),n=r.length;n>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++,s++,s!==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 n=e=>new t(e).parse(),s=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(t).filter(e=>!s.includes(e)&&void 0===n[e]).forEach(e=>{n[e]=t[e]}),n.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,n=this.gobbleExpression();if(n||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const s=this.gobbleExpression();if(s||this.throwError("Expected expression"),t.node={type:"ConditionalExpression",test:r,consequent:n,alternate:s},r.operator&&e.binary_ops[r.operator]<=.9){let n=r;for(;n.right.operator&&e.binary_ops[n.right.operator]<=.9;)n=n.right;t.node.test=n.right,n.right=t.node,t.node=r}}else this.throwError("Expected :")}})}};n.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 n=!1;for(;this.index=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57))break;i+=this.char}try{s=new RegExp(n,i)}catch(e){this.throwError(e.message)}return t.node={type:e.LITERAL,value:s,raw:this.expr.slice(r-1,this.index)},t.node=this.gobbleTokenProperty(t.node),t.node}this.code===e.OBRACK_CODE?n=!0:n&&this.code===e.CBRACK_CODE&&(n=!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)})}};n.plugins.register(o,a),n.addUnaryOp("typeof"),n.addUnaryOp("void"),n.addLiteral("null",null),n.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]),c=e=>"function"==typeof e&&l.has(e),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 n=0;nd.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),n=d.evalAst(e.object,t);if(null==n)throw new TypeError(`Cannot read properties of ${n} (reading '${r}')`);if(!Object.hasOwn(n,r)&&h.has(r))throw new TypeError(`Cannot read properties of ${n} (reading '${r}')`);const s=n[r];if(c(s))throw new TypeError("Function constructor is disabled");return"function"==typeof s?s.bind(n):s},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)),n=d.evalAst(e.callee,t);if(c(n)||r.some(e=>c(e)))throw new Error("Function constructor is disabled");return n(...r)},evalAssignmentExpression(e,t){if("Identifier"!==e.left.type)throw new SyntaxError("Invalid left-hand side in assignment");const r=e.left.name,n=d.evalAst(e.right,t);return t[r]=n,t[r]}};const f=new Map,b=new Map;function E(e,t){return(e=e.slice()).push(t),e}function y(e,t){return(t=t.slice()).unshift(e),t}function x(e,t,r,n,s){try{return e&&"object"==typeof e?new g(e):new g(e,t,r,n,s)}catch(e){if(new.target)throw e;if(e&&"object"==typeof e&&"value"in e)return e.value;throw e}}class g{constructor(e,t,r,n,s){"string"==typeof e&&(s=n,n=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.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||n||null,this.otherTypeCallback=e.otherTypeCallback||s||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){const n={path:i?e.path:t};i||void 0===r?"json"in e&&(n.json=e.json):n.json=r;const s=this.evaluate(n);if(!s||"object"!=typeof s){const e=new Error('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');throw e.value=s,e}return s}}evaluate(e,t,r,n){let s=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=n||this.otherTypeCallback,e&&"object"==typeof e&&!Array.isArray(e)){const n=e;if(!n.path&&""!==n.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!Object.hasOwn(n,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');({json:t}=n),o=Object.hasOwn(n,"flatten")?n.flatten:o,this.currResultType=Object.hasOwn(n,"resultType")?n.resultType:this.currResultType,this.currSandbox=Object.hasOwn(n,"sandbox")?n.sandbox:this.currSandbox,a=Object.hasOwn(n,"wrap")?n.wrap:a,this.currEval=Object.hasOwn(n,"eval")?n.eval:this.currEval,r=Object.hasOwn(n,"callback")?n.callback:r,this.currOtherTypeCallback=Object.hasOwn(n,"otherTypeCallback")?n.otherTypeCallback:this.currOtherTypeCallback,s=Object.hasOwn(n,"parent")?n.parent:s,i=Object.hasOwn(n,"parentProperty")?n.parentProperty:i,e=n.path}else t||=this.json,e||=this.path;if(s||=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,["$"],s,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 n=this._getPreferredOutput(e);Array.isArray(e.path)&&(e.path=x.toPathString(e.path)),t(n,r,e)}_trace(e,t,r,n,s,i,o,a){let h;if(!e.length)return h={path:r,value:t,parent:n,parentProperty:s,hasArrExpr:o},this._handleCallback(h,i,"value"),h;const l=e[0],c=e.slice(1),p=[];function u(e){Array.isArray(e)?e.forEach(e=>{p.push(e)}):p.push(e)}if(t&&("string"!=typeof l||a)&&Object.hasOwn(t,l)){const e=t;u(this._trace(c,e[l],E(r,l),t,l,i,o))}else if("*"===l)this._walk(t,e=>{const n=t;u(this._trace(c,n[e],E(r,e),t,e,i,!0,!0))});else if(".."===l)u(this._trace(c,t,r,n,s,i,o)),this._walk(t,n=>{const s=t;"object"==typeof s[n]&&u(this._trace(e.slice(),s[n],E(r,n),t,n,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:s,parent:n,parentProperty:null},this._handleCallback(h,i,"property"),h;if("$"===l)u(this._trace(c,t,r,null,null,i,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(l)){const e=this._slice(l,c,t,r,n,s,i);e&&u(e)}else if(0===l.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=l.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);if(o)this._walk(t,e=>{const a=[o[2]],h=t,l=o[1]?h[e][o[1]]:h[e],p=this._trace(a,l,r,n,s,i,!0);(Array.isArray(p)?p:[p]).length>0&&u(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,n,s)&&u(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),n,s),a=void 0!==e?e:"";u(this._trace(y(a,c),t,r,n,s,i,o))}else if("@"===l[0]){let e=!1;const o=l.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback?.(t,r,n,s)??!1;break;case"null":null===t&&(e=!0);break;default:throw new TypeError("Unknown value type "+o)}if(e)return h={path:r,value:t,parent:n,parentProperty:s},this._handleCallback(h,i,"value"),h}else if(t&&"`"===l[0]&&Object.hasOwn(t,l.slice(1))){const e=l.slice(1),n=t;u(this._trace(c,n[e],E(r,e),t,e,i,o,!0))}else if(l.includes(",")){const e=l.split(",");for(const o of e)u(this._trace(y(o,c),t,r,n,s,i,!0))}else if(!a&&t&&Object.hasOwn(t,l)){const e=t;u(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,n,s,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,n,s,i){this.currSandbox&&(this.currSandbox._$_parentProperty=i,this.currSandbox._$_parent=s,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(n.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)[])/gu,"_$_v$1");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})}}}g.prototype.safeVm={Script:class{constructor(e){this.code=e,this.ast=n(this.code)}runInNewContext(e){const t=Object.assign(Object.create(null),e);return d.evalAst(this.ast,t)}}},x.prototype=g.prototype,x.clearCache=function(){b.clear(),f.clear()},x.toPathString=function(e){const t=e,r=t.length;let n="$";for(let e=1;e"function"==typeof e[t]);const s=r.map(t=>e[t]);t=n.reduce((t,r)=>{let n=e[r].toString();return/function/u.test(n)||(n="function "+n),"var "+r+"="+n+";"+t},"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");const i=t.lastIndexOf(";"),o=-1!==i?t.slice(0,i+1)+" return "+t.slice(i+1):" return "+t;return new Function(...r,o)(...s)}}g.prototype.vm={Script:_},e.JSONPath=x,e.JSONPathClass=g,e.Script=_}); +!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]),c=e=>"function"==typeof e&&l.has(e),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);if(null==s)throw new TypeError(`Cannot read properties of ${s} (reading '${r}')`);if(!Object.hasOwn(s,r)&&h.has(r))throw new TypeError(`Cannot read properties of ${s} (reading '${r}')`);const n=s[r];if(c(n))throw new TypeError("Function constructor is disabled");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 x(e,t,r,s,n){try{return e&&"object"==typeof e?new g(e):new g(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 g{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){const s={path:i?e.path:t};i||void 0===r?"json"in e&&(s.json=e.json):s.json=r;const n=this.evaluate(s);if(!n||"object"!=typeof n){const e=new Error('JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)');throw e.value=n,e}return n}}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),p=[];function u(e){Array.isArray(e)?e.forEach(e=>{p.push(e)}):p.push(e)}if(t&&("string"!=typeof l||a)&&Object.hasOwn(t,l)){const e=t;u(this._trace(c,e[l],y(r,l),t,l,i,o))}else if("*"===l)this._walk(t,e=>{const s=t;u(this._trace(c,s[e],y(r,e),t,e,i,!0,!0))});else if(".."===l)u(this._trace(c,t,r,s,n,i,o)),this._walk(t,s=>{const n=t;"object"==typeof n[s]&&u(this._trace(e.slice(),n[s],y(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:y(r,l),value:n,parent:s,parentProperty:null},this._handleCallback(h,i,"property"),h;if("$"===l)u(this._trace(c,t,r,null,null,i,o));else if(/^(-?\d*):(-?\d*):?(\d*)$/u.test(l)){const e=this._slice(l,c,t,r,s,n,i);e&&u(e)}else if(0===l.indexOf("?(")){if(!1===this.currEval)throw new Error("Eval [?(expr)] prevented in JSONPath expression.");const e=l.replace(/^\?\((.*?)\)$/u,"$1"),o=/@.?([^?]*)[['](\??\(.*?\))(?!.\)\])[\]']/gu.exec(e);if(o)this._walk(t,e=>{const a=[o[2]],h=t,l=o[1]?h[e][o[1]]:h[e],p=this._trace(a,l,r,s,n,i,!0);(Array.isArray(p)?p:[p]).length>0&&u(this._trace(c,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)&&u(this._trace(c,o[a],y(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:"";u(this._trace(E(a,c),t,r,s,n,i,o))}else if("@"===l[0]){let e=!1;const o=l.slice(1,-2);switch(o){case"scalar":t&&["object","function"].includes(typeof t)||(e=!0);break;case"boolean":case"string":case"undefined":case"function":typeof t===o&&(e=!0);break;case"integer":!Number.isFinite(t)||t%1||(e=!0);break;case"number":Number.isFinite(t)&&(e=!0);break;case"nonFinite":"number"!=typeof t||Number.isFinite(t)||(e=!0);break;case"object":t&&typeof t===o&&(e=!0);break;case"array":Array.isArray(t)&&(e=!0);break;case"other":e=this.currOtherTypeCallback(t,r,s,n)||!1;break;case"null":null===t&&(e=!0);break;default:if(!this.currCustomTypes||!Object.hasOwn(this.currCustomTypes,o))throw new TypeError("Unknown value type "+o);e=this.currCustomTypes[o](t,r,s,n)||!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;u(this._trace(c,s[e],y(r,e),t,e,i,o,!0))}else if(l.includes(",")){const e=l.split(",");for(const o of e)u(this._trace(E(o,c),t,r,s,n,i,!0))}else if(!a&&t&&Object.hasOwn(t,l)){const e=t;u(this._trace(c,e[l],y(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(!f.has(a)){let t=e.replaceAll("@parentProperty","_$_parentProperty").replaceAll("@parent","_$_parent").replaceAll("@property","_$_property").replaceAll("@root","_$_root").replaceAll(/@([.\s)[])/gu,"_$_v$1");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})}}}g.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 d.evalAst(this.ast,t)}}},x.prototype=g.prototype,x.clearCache=function(){b.clear(),f.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/u.test(s)||(s="function "+s),"var "+r+"="+s+";"+t},"")+t,/(['"])use strict\1/u.test(t)||r.includes("arguments")||(t="var arguments = undefined;"+t),t=t.replace(/;\s*$/u,"");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)}}g.prototype.vm={Script:_},e.JSONPath=x,e.JSONPathClass=g,e.Script=_}); //# 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 dec02a2..e596b23 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/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/** @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]);\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 * @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 if (SafeEval.evalAst(ast.test, subs)) {\n return SafeEval.evalAst(ast.consequent, subs);\n }\n return 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 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 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};\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} from './Safe-Script.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\"} 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|null} parentPropName\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 {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 {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 : false;\n this.wrap = Object.hasOwn(opts, 'wrap') ? opts.wrap : true;\n this.sandbox = opts.sandbox || {};\n this.eval = opts.eval === undefined ? 'safe' : opts.eval;\n this.ignoreEvalErrors = (typeof opts.ignoreEvalErrors === 'undefined')\n ? false\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\n if (opts.autostart !== false) {\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 // eslint-disable-next-line @stylistic/max-len -- Long\n // @ts-expect-error - Constructor returns evaluate result for legacy API\n // eslint-disable-next-line no-constructor-return -- Legacy API\n return ret;\n }\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\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 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*)$/u).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(/^\\?\\((.*?)\\)$/u, '$1');\n // check for a nested filter expression\n\n const nested = (/@.?([^?]*)[['](\\??\\(.*?\\))(?!.\\)\\])[\\]']/gu).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 const nvalue = /** @type {ValueType} */ (nested[1]\n ? /** @type {Record} */ (\n valObj2[m]\n )[nested[1]]\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 let addType = false;\n const valueType = /** @type {ValueType} */ (loc).slice(1, -2);\n switch (valueType) {\n case 'scalar':\n if (!val || !(['object', 'function'].includes(typeof val))) {\n addType = true;\n }\n break;\n case 'boolean': case 'string': case 'undefined': case 'function':\n if (typeof val === valueType) {\n addType = true;\n }\n break;\n case 'integer':\n if (Number.isFinite(val) &&\n !(/** @type {number} */ (val) % 1)) {\n addType = true;\n }\n break;\n case 'number':\n if (Number.isFinite(val)) {\n addType = true;\n }\n break;\n case 'nonFinite':\n if (typeof val === 'number' && !Number.isFinite(val)) {\n addType = true;\n }\n break;\n case 'object':\n if (val && typeof val === valueType) {\n addType = true;\n }\n break;\n case 'array':\n if (Array.isArray(val)) {\n addType = true;\n }\n break;\n case 'other':\n addType = this.currOtherTypeCallback?.(\n val, path, parent,\n /** @type {string|null} */ (parentPropName)\n ) ?? false;\n break;\n case 'null':\n if (val === null) {\n addType = true;\n }\n break;\n /* c8 ignore next 2 */\n default:\n throw new TypeError('Unknown value type ' + valueType);\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.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 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 }\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 .replaceAll(/@([.\\s)[])/gu, '_$_v$1');\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 (!(/^(~|\\^|@.*?\\(\\))$/u).test(x[i])) {\n p += (/^[0-9*]+$/u).test(x[i]) ? ('[' + x[i] + ']') : (\"['\" + x[i] + \"']\");\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 (!(/^(~|\\^|@.*?\\(\\))$/u).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 /@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\\(\\)/gu,\n ';$&;'\n )\n // Parenthetical evaluations (filtering and otherwise), directly\n // within brackets or single quotes\n .replaceAll(/[['](\\??\\(.*?\\))[\\]'](?!.\\])/gu, 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 // Escape periods and tildes within properties\n .replaceAll(/\\[['\"]([^'\\]]*)['\"]\\]/gu, 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(/['\"]?\\.['\"]?(?![^[]*\\])|\\[['\"]?/gu, ';')\n // Reinsert periods within properties\n .replaceAll('%@%', '.')\n // Reinsert tildes within properties\n .replaceAll('%%@@%%', '~')\n // Parent\n .replaceAll(/(?:;)?(\\^+)(?:;)?/gu, function ($0, ups) {\n return ';' + ups.split('').join(';') + ';';\n })\n // Descendents\n .replaceAll(/;;;|;;/gu, ';..;')\n // Remove trailing\n .replaceAll(/;$|'?\\]|'$/gu, '');\n\n const exprList = normalized.split(';').map(function (exp) {\n const match = exp.match(/#(\\d+)/u);\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/u).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/u).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*$/u, '');\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","isBlockedFunction","BINOPS","create","||","a","b","&&","|","^","&","==","!=","===","!==","<",">","<=",">=","<<",">>",">>>","+","-","*","/","%","UNOPS","typeof","void","SafeEval","evalAst","ast","subs","evalBinaryExpression","evalCompound","evalConditionalExpression","evalIdentifier","evalLiteral","evalMemberExpression","evalUnaryExpression","evalArrayExpression","evalCallExpression","evalAssignmentExpression","SyntaxError","cause","hasOwn","last","ReferenceError","TypeError","result","operand","el","func","id","scriptCache","Map","pathCache","arr","item","unshift","JSONPath","opts","otherTypeCallback","JSONPathClass","optObj","currResultType","currEval","currOtherTypeCallback","currSandbox","_hasParentSelector","json","path","resultType","flatten","wrap","sandbox","eval","ignoreEvalErrors","parent","parentProperty","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","valueType","Number","isFinite","locProp","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","replaceAll","evalType","set","safeVm","Script","vm","CurrEval","evalFunc","runInNewContext","get","keyMap","clearCache","clear","pathArr","p","subx","$0","$1","ups","join","exp","match","funcs","source","target","conditionCb","il","moveToAnotherArray","key","vr","s","fString","lastStatementEnd","lastIndexOf"],"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,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AAM+I,EAAU,IAAMD,GAC9C,IAEiBtX,EAGd,sBAAuBoJ,KAAKpJ,IAAUS,EAAKuI,SAAS,eACtDhJ,EAAO,6BAA+BA,GAM1CA,EAAOA,EAAK6S,QAAQ,SAAU,IAG9B,MAAM2E,EAAmBxX,EAAKyX,YAAY,KACpCtX,GACmB,IAArBqX,EACMxX,EAAKmH,MAAM,EAAGqQ,EAAmB,GACjC,WACAxX,EAAKmH,MAAMqQ,EAAmB,GAC9B,WAAaxX,EAGvB,OAAO,IAAI6K,YAAYpK,EAAMN,EAAtB,IAA+BgK,EAC1C,EAIqBgF,EAAuB,UAAG0G,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/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/** @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]);\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 * @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 if (SafeEval.evalAst(ast.test, subs)) {\n return SafeEval.evalAst(ast.consequent, subs);\n }\n return 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 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 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};\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} from './Safe-Script.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\"} 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 * @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 custom\n * 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 : false;\n this.wrap = Object.hasOwn(opts, 'wrap') ? opts.wrap : true;\n this.sandbox = opts.sandbox || {};\n this.eval = opts.eval === undefined ? 'safe' : opts.eval;\n this.ignoreEvalErrors = (typeof opts.ignoreEvalErrors === 'undefined')\n ? false\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 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 // eslint-disable-next-line @stylistic/max-len -- Long\n // @ts-expect-error - Constructor returns evaluate result for legacy API\n // eslint-disable-next-line no-constructor-return -- Legacy API\n return ret;\n }\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*)$/u).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(/^\\?\\((.*?)\\)$/u, '$1');\n // check for a nested filter expression\n\n const nested = (/@.?([^?]*)[['](\\??\\(.*?\\))(?!.\\)\\])[\\]']/gu).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 const nvalue = /** @type {ValueType} */ (nested[1]\n ? /** @type {Record} */ (\n valObj2[m]\n )[nested[1]]\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 let addType = false;\n const valueType = /** @type {ValueType|string} */ (\n loc\n ).slice(1, -2);\n switch (valueType) {\n case 'scalar':\n if (!val || !(['object', 'function'].includes(typeof val))) {\n addType = true;\n }\n break;\n case 'boolean': case 'string': case 'undefined': case 'function':\n if (typeof val === valueType) {\n addType = true;\n }\n break;\n case 'integer':\n if (Number.isFinite(val) &&\n !(/** @type {number} */ (val) % 1)) {\n addType = true;\n }\n break;\n case 'number':\n if (Number.isFinite(val)) {\n addType = true;\n }\n break;\n case 'nonFinite':\n if (typeof val === 'number' && !Number.isFinite(val)) {\n addType = true;\n }\n break;\n case 'object':\n if (val && typeof val === valueType) {\n addType = true;\n }\n break;\n case 'array':\n if (Array.isArray(val)) {\n addType = true;\n }\n break;\n case 'other':\n addType = /** @type {OtherTypeCallback} */ (\n this.currOtherTypeCallback\n )(\n val, path, parent, parentPropName\n ) || false;\n break;\n case 'null':\n if (val === null) {\n addType = true;\n }\n break;\n /* c8 ignore next 2 */\n default:\n if (this.currCustomTypes &&\n Object.hasOwn(this.currCustomTypes, valueType)\n ) {\n addType = this.currCustomTypes[valueType](\n val, path, parent, parentPropName\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.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 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 }\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 .replaceAll(/@([.\\s)[])/gu, '_$_v$1');\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 (!(/^(~|\\^|@.*?\\(\\))$/u).test(x[i])) {\n p += (/^[0-9*]+$/u).test(x[i]) ? ('[' + x[i] + ']') : (\"['\" + x[i] + \"']\");\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 (!(/^(~|\\^|@.*?\\(\\))$/u).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$-]+\\(\\)/gu,\n ';$&;'\n )\n // Parenthetical evaluations (filtering and otherwise), directly\n // within brackets or single quotes\n .replaceAll(/[['](\\??\\(.*?\\))[\\]'](?!.\\])/gu, 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 // Escape periods and tildes within properties\n .replaceAll(/\\[['\"]([^'\\]]*)['\"]\\]/gu, 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(/['\"]?\\.['\"]?(?![^[]*\\])|\\[['\"]?/gu, ';')\n // Reinsert periods within properties\n .replaceAll('%@%', '.')\n // Reinsert tildes within properties\n .replaceAll('%%@@%%', '~')\n // Parent\n .replaceAll(/(?:;)?(\\^+)(?:;)?/gu, function ($0, ups) {\n return ';' + ups.split('').join(';') + ';';\n })\n // Descendents\n .replaceAll(/;;;|;;/gu, ';..;')\n // Remove trailing\n .replaceAll(/;$|'?\\]|'$/gu, '');\n\n const exprList = normalized.split(';').map(function (exp) {\n const match = exp.match(/#(\\d+)/u);\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/u).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/u).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*$/u, '');\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","isBlockedFunction","BINOPS","create","||","a","b","&&","|","^","&","==","!=","===","!==","<",">","<=",">=","<<",">>",">>>","+","-","*","/","%","UNOPS","typeof","void","SafeEval","evalAst","ast","subs","evalBinaryExpression","evalCompound","evalConditionalExpression","evalIdentifier","evalLiteral","evalMemberExpression","evalUnaryExpression","evalArrayExpression","evalCallExpression","evalAssignmentExpression","SyntaxError","cause","hasOwn","last","ReferenceError","TypeError","result","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","valueType","Number","isFinite","locProp","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","replaceAll","evalType","set","safeVm","Script","vm","CurrEval","evalFunc","runInNewContext","get","keyMap","clearCache","clear","pathArr","p","subx","$0","$1","ups","join","exp","match","funcs","source","target","conditionCb","il","moveToAnotherArray","key","vr","s","fString","lastStatementEnd","lastIndexOf"],"mappings":"+OAgGA,MAAMA,EAIL,kBAAWC,GAEV,MAAO,OACR,CAKA,eAAOC,GACN,MAAO,wCAA0CF,EAAKC,OACvD,CAQA,iB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/dist/index-node-cjs.cjs @@ -1595,7 +1595,7 @@ function unshift(item, arr) { * @param {unknown} val * @param {ExpressionArray} path * @param {ParentValue} parent - * @param {string|null} parentPropName + * @param {string|number|null} parentPropName * @returns {boolean|null} */ @@ -1671,6 +1671,8 @@ function unshift(item, arr) { * @property {JSONPathCallback} [callback] * @property {OtherTypeCallback} [otherTypeCallback] Defaults to * function which throws on encountering `@other` + * @property {Record} [customTypes] Map of custom + * type operator names to their evaluation callbacks * @property {boolean} [autostart=true] * @property {boolean} [ignoreEvalErrors=false] */ @@ -1799,6 +1801,9 @@ class JSONPathClass { /** @type {OtherTypeCallback|undefined} */ this.currOtherTypeCallback = undefined; + /** @type {Record|undefined} */ + this.currCustomTypes = undefined; + /** @type {SandboxType|undefined} */ this.currSandbox = undefined; this._hasParentSelector = false; @@ -1817,6 +1822,7 @@ class JSONPathClass { this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function () { throw new TypeError('You must supply an otherTypeCallback callback option ' + 'with the @other() operator.'); }; + this.customTypes = opts.customTypes || {}; if (opts.autostart !== false) { const args = /** @type {JSONPathOptions} */{ path: optObj ? opts.path : expr @@ -1877,6 +1883,7 @@ class JSONPathClass { this.currSandbox = this.sandbox; callback ||= this.callback; this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback; + this.currCustomTypes = this.customTypes; if (expr && typeof expr === 'object' && !Array.isArray(expr)) { const exprObj = expr; if (!exprObj.path && exprObj.path !== '') { @@ -1895,6 +1902,7 @@ class JSONPathClass { this.currEval = Object.hasOwn(exprObj, 'eval') ? exprObj.eval : this.currEval; callback = Object.hasOwn(exprObj, 'callback') ? exprObj.callback : callback; this.currOtherTypeCallback = Object.hasOwn(exprObj, 'otherTypeCallback') ? exprObj.otherTypeCallback : this.currOtherTypeCallback; + this.currCustomTypes = Object.hasOwn(exprObj, 'customTypes') ? exprObj.customTypes : this.currCustomTypes; currParent = Object.hasOwn(exprObj, 'parent') ? exprObj.parent : currParent; currParentProperty = Object.hasOwn(exprObj, 'parentProperty') ? exprObj.parentProperty : currParentProperty; expr = exprObj.path; @@ -2155,7 +2163,7 @@ class JSONPathClass { } else if (loc[0] === '@') { // value type: @boolean(), etc. let addType = false; - const valueType = /** @type {ValueType} */loc.slice(1, -2); + const valueType = /** @type {ValueType|string} */loc.slice(1, -2); switch (valueType) { case 'scalar': if (!val || !['object', 'function'].includes(typeof val)) { @@ -2196,7 +2204,7 @@ class JSONPathClass { } break; case 'other': - addType = this.currOtherTypeCallback?.(val, path, parent, /** @type {string|null} */parentPropName) ?? false; + addType = /** @type {OtherTypeCallback} */this.currOtherTypeCallback(val, path, parent, parentPropName) || false; break; case 'null': if (val === null) { @@ -2205,7 +2213,11 @@ class JSONPathClass { break; /* c8 ignore next 2 */ default: - throw new TypeError('Unknown value type ' + valueType); + if (this.currCustomTypes && Object.hasOwn(this.currCustomTypes, valueType)) { + addType = this.currCustomTypes[valueType](val, path, parent, parentPropName) || false; + } else { + throw new TypeError('Unknown value type ' + valueType); + } } if (addType) { retObj = { @@ -2477,7 +2489,7 @@ JSONPath.toPathArray = function (expr) { const subx = []; const normalized = expr // Properties - .replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ';$&;') + .replaceAll(/@[\w$-]+\(\)/gu, ';$&;') // Parenthetical evaluations (filtering and otherwise), directly // within brackets or single quotes .replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function ($0, $1) { diff --git a/dist/index-node-esm.js b/dist/index-node-esm.js index fdcb80b..904caf0 100644 --- a/dist/index-node-esm.js +++ b/dist/index-node-esm.js @@ -1593,7 +1593,7 @@ function unshift(item, arr) { * @param {unknown} val * @param {ExpressionArray} path * @param {ParentValue} parent - * @param {string|null} parentPropName + * @param {string|number|null} parentPropName * @returns {boolean|null} */ @@ -1669,6 +1669,8 @@ function unshift(item, arr) { * @property {JSONPathCallback} [callback] * @property {OtherTypeCallback} [otherTypeCallback] Defaults to * function which throws on encountering `@other` + * @property {Record} [customTypes] Map of custom + * type operator names to their evaluation callbacks * @property {boolean} [autostart=true] * @property {boolean} [ignoreEvalErrors=false] */ @@ -1797,6 +1799,9 @@ class JSONPathClass { /** @type {OtherTypeCallback|undefined} */ this.currOtherTypeCallback = undefined; + /** @type {Record|undefined} */ + this.currCustomTypes = undefined; + /** @type {SandboxType|undefined} */ this.currSandbox = undefined; this._hasParentSelector = false; @@ -1815,6 +1820,7 @@ class JSONPathClass { this.otherTypeCallback = opts.otherTypeCallback || otherTypeCallback || function () { throw new TypeError('You must supply an otherTypeCallback callback option ' + 'with the @other() operator.'); }; + this.customTypes = opts.customTypes || {}; if (opts.autostart !== false) { const args = /** @type {JSONPathOptions} */{ path: optObj ? opts.path : expr @@ -1875,6 +1881,7 @@ class JSONPathClass { this.currSandbox = this.sandbox; callback ||= this.callback; this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback; + this.currCustomTypes = this.customTypes; if (expr && typeof expr === 'object' && !Array.isArray(expr)) { const exprObj = expr; if (!exprObj.path && exprObj.path !== '') { @@ -1893,6 +1900,7 @@ class JSONPathClass { this.currEval = Object.hasOwn(exprObj, 'eval') ? exprObj.eval : this.currEval; callback = Object.hasOwn(exprObj, 'callback') ? exprObj.callback : callback; this.currOtherTypeCallback = Object.hasOwn(exprObj, 'otherTypeCallback') ? exprObj.otherTypeCallback : this.currOtherTypeCallback; + this.currCustomTypes = Object.hasOwn(exprObj, 'customTypes') ? exprObj.customTypes : this.currCustomTypes; currParent = Object.hasOwn(exprObj, 'parent') ? exprObj.parent : currParent; currParentProperty = Object.hasOwn(exprObj, 'parentProperty') ? exprObj.parentProperty : currParentProperty; expr = exprObj.path; @@ -2153,7 +2161,7 @@ class JSONPathClass { } else if (loc[0] === '@') { // value type: @boolean(), etc. let addType = false; - const valueType = /** @type {ValueType} */loc.slice(1, -2); + const valueType = /** @type {ValueType|string} */loc.slice(1, -2); switch (valueType) { case 'scalar': if (!val || !['object', 'function'].includes(typeof val)) { @@ -2194,7 +2202,7 @@ class JSONPathClass { } break; case 'other': - addType = this.currOtherTypeCallback?.(val, path, parent, /** @type {string|null} */parentPropName) ?? false; + addType = /** @type {OtherTypeCallback} */this.currOtherTypeCallback(val, path, parent, parentPropName) || false; break; case 'null': if (val === null) { @@ -2203,7 +2211,11 @@ class JSONPathClass { break; /* c8 ignore next 2 */ default: - throw new TypeError('Unknown value type ' + valueType); + if (this.currCustomTypes && Object.hasOwn(this.currCustomTypes, valueType)) { + addType = this.currCustomTypes[valueType](val, path, parent, parentPropName) || false; + } else { + throw new TypeError('Unknown value type ' + valueType); + } } if (addType) { retObj = { @@ -2475,7 +2487,7 @@ JSONPath.toPathArray = function (expr) { const subx = []; const normalized = expr // Properties - .replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, ';$&;') + .replaceAll(/@[\w$-]+\(\)/gu, ';$&;') // Parenthetical evaluations (filtering and otherwise), directly // within brackets or single quotes .replaceAll(/[['](\??\(.*?\))[\]'](?!.\])/gu, function ($0, $1) { diff --git a/src/jsonpath.js b/src/jsonpath.js index c9422f4..c604531 100644 --- a/src/jsonpath.js +++ b/src/jsonpath.js @@ -95,7 +95,7 @@ function unshift (item, arr) { * @param {unknown} val * @param {ExpressionArray} path * @param {ParentValue} parent - * @param {string|null} parentPropName + * @param {string|number|null} parentPropName * @returns {boolean|null} */ @@ -171,6 +171,8 @@ function unshift (item, arr) { * @property {JSONPathCallback} [callback] * @property {OtherTypeCallback} [otherTypeCallback] Defaults to * function which throws on encountering `@other` + * @property {Record} [customTypes] Map of custom + * type operator names to their evaluation callbacks * @property {boolean} [autostart=true] * @property {boolean} [ignoreEvalErrors=false] */ @@ -308,6 +310,9 @@ class JSONPathClass { /** @type {OtherTypeCallback|undefined} */ this.currOtherTypeCallback = undefined; + /** @type {Record|undefined} */ + this.currCustomTypes = undefined; + /** @type {SandboxType|undefined} */ this.currSandbox = undefined; @@ -339,6 +344,7 @@ class JSONPathClass { 'with the @other() operator.' ); }; + this.customTypes = opts.customTypes || {}; if (opts.autostart !== false) { const args = /** @type {JSONPathOptions} */ ({ @@ -405,6 +411,7 @@ class JSONPathClass { callback ||= this.callback; this.currOtherTypeCallback = otherTypeCallback || this.otherTypeCallback; + this.currCustomTypes = this.customTypes; if (expr && typeof expr === 'object' && !Array.isArray(expr)) { const exprObj = expr; @@ -442,6 +449,11 @@ class JSONPathClass { ) ? exprObj.otherTypeCallback : this.currOtherTypeCallback; + this.currCustomTypes = Object.hasOwn( + exprObj, 'customTypes' + ) + ? exprObj.customTypes + : this.currCustomTypes; currParent = Object.hasOwn(exprObj, 'parent') ? exprObj.parent : currParent; @@ -764,7 +776,9 @@ class JSONPathClass { ), val, path, parent, parentPropName, callback, hasArrExpr)); } else if (loc[0] === '@') { // value type: @boolean(), etc. let addType = false; - const valueType = /** @type {ValueType} */ (loc).slice(1, -2); + const valueType = /** @type {ValueType|string} */ ( + loc + ).slice(1, -2); switch (valueType) { case 'scalar': if (!val || !(['object', 'function'].includes(typeof val))) { @@ -803,10 +817,11 @@ class JSONPathClass { } break; case 'other': - addType = this.currOtherTypeCallback?.( - val, path, parent, - /** @type {string|null} */ (parentPropName) - ) ?? false; + addType = /** @type {OtherTypeCallback} */ ( + this.currOtherTypeCallback + )( + val, path, parent, parentPropName + ) || false; break; case 'null': if (val === null) { @@ -815,7 +830,15 @@ class JSONPathClass { break; /* c8 ignore next 2 */ default: - throw new TypeError('Unknown value type ' + valueType); + if (this.currCustomTypes && + Object.hasOwn(this.currCustomTypes, valueType) + ) { + addType = this.currCustomTypes[valueType]( + val, path, parent, parentPropName + ) || false; + } else { + throw new TypeError('Unknown value type ' + valueType); + } } if (addType) { retObj = { @@ -1147,7 +1170,7 @@ JSONPath.toPathArray = function (expr) { const normalized = expr // Properties .replaceAll( - /@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/gu, + /@[\w$-]+\(\)/gu, ';$&;' ) // Parenthetical evaluations (filtering and otherwise), directly diff --git a/test/test.safe-eval.js b/test/test.safe-eval.js index beec1a3..4ea6d8e 100644 --- a/test/test.safe-eval.js +++ b/test/test.safe-eval.js @@ -375,6 +375,21 @@ checkBuiltInVMAndNodeVM(function (vmType, setBuiltInState) { } }); + it("passing blocked function as argument is blocked", () => { + assert.throws(() => { + const path = "$[?(dummy(blocked))]"; + jsonpath({ + path, + json: [1], + sandbox: { + // eslint-disable-next-line no-empty-function -- Test dummy + dummy () {}, + blocked: Function + } + }); + }, "Function constructor is disabled"); + }); + it("bind() escape guard: function.prototype.constructor blocked", () => { // Regression: bound functions (with no .prototype) are returned to // prevent @.f.prototype.constructor → Function constructor escape. diff --git a/test/test.type-operators.js b/test/test.type-operators.js index b77fc7a..d0bd5cb 100644 --- a/test/test.type-operators.js +++ b/test/test.type-operators.js @@ -229,4 +229,65 @@ describe('JSONPath - Type Operators', function () { pointer: '/a' }]); }); + + describe('customTypes', () => { + it('allows custom type operators', () => { + // @ts-ignore -- Blob may not have construct signature in this TS environment + const blobObj = typeof Blob !== 'undefined' + ? new Blob(['test']) + : {[Symbol.toStringTag]: 'Blob'}; + const jsonMixed = { + nested: { + a: blobObj, + b: null, + c: { + d: 7 + } + } + }; + const expected = [blobObj]; + + const result = jsonpath({ + json: jsonMixed, + path: '$..*@blob()', + flatten: true, + customTypes: { + blob: (/** @type {any} */ val) => Object.prototype.toString.call(val) === '[object Blob]' + } + }); + assert.deepEqual(result, expected); + }); + + it('allows custom type operators via evaluate method', () => { + // @ts-ignore -- Blob may not have construct signature in this TS environment + const blobObj = typeof Blob !== 'undefined' + ? new Blob(['test']) + : {[Symbol.toStringTag]: 'Blob'}; + const jsonMixed = {a: blobObj}; + const expected = [blobObj]; + const jp = jsonpath({autostart: false}); + const result = jp.evaluate({ + json: jsonMixed, + path: '$..*@blob()', + flatten: true, + customTypes: { + blob: (/** @type {any} */ val) => Object.prototype.toString.call(val) === '[object Blob]' + } + }); + assert.deepEqual(result, expected); + }); + + it('throws on unregistered custom type operator', () => { + expect(() => { + jsonpath({ + json: {a: 1}, + path: '$..*@unregisteredType()', + flatten: true, + customTypes: { + blob: (val) => Object.prototype.toString.call(val) === '[object Blob]' + } + }); + }).to.throw(TypeError, 'Unknown value type unregisteredType'); + }); + }); });