!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";function n(e,t,r){return t=l(t),function(e,t){{if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined")}return function(e){if(void 0!==e)return e;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(e)}(e,i()?Reflect.construct(t,r||[],l(e).constructor):t.apply(e,r))}function o(e,t,r){if(i())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);n=new(e.bind.apply(e,n));return r&&h(n,r.prototype),n}function i(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(i=function(){return!!e})()}function t(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function r(n){for(var e=1;ee.length)&&(t=e.length);for(var r=0,n=new Array(t);ru.prec:r<=u.prec);)o=n.pop(),t=n.pop().value,c=n.pop(),e={type:l.BINARY_EXP,operator:t,left:c,right:o},n.push(e);(e=this.gobbleToken())||this.throwError("Expected expression after "+s),n.push(i,e)}for(e=n[a=n.length-1];1=t.length&&this.throwError("Unexpected token "+String.fromCharCode(e));break}if(i===l.COMMA_CODE){if(this.index++,++n!==t.length)if(e===l.CPAREN_CODE)this.throwError("Unexpected token ,");else if(e===l.CBRACK_CODE)for(var o=t.length;o":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10},right_associative:new Set,additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"}),v.max_unop_len=v.getMaxKeyLen(v.unary_ops),v.max_binop_len=v.getMaxKeyLen(v.binary_ops);var E=function(e){return new v(e).parse()};Object.getOwnPropertyNames(v).forEach(function(e){void 0===E[e]&&"prototype"!==e&&(E[e]=v[e])}),E.Jsep=v;b={name:"ternary",init:function(o){o.hooks.add("after-expression",function(e){if(e.node&&this.code===o.QUMARK_CODE){this.index++;var t=e.node,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===o.COLON_CODE){this.index++;var n=this.gobbleExpression();if(n||this.throwError("Expected expression"),e.node={type:"ConditionalExpression",test:t,consequent:r,alternate:n},t.operator&&o.binary_ops[t.operator]<=.9){for(var i=t;i.right.operator&&o.binary_ops[i.right.operator]<=.9;)i=i.right;e.node.test=i.right,i.right=e.node,e.node=t}}else this.throwError("Expected :")}})}};E.plugins.register(b);var b={name:"regex",init:function(s){s.hooks.add("gobble-token",function(e){if(47===this.code){for(var t=++this.index,r=!1;this.index>=",">>>=","&=","^=","|="]),updateOperators:[43,45],assignmentPrecedence:.9,init:function(t){var n=[t.IDENTIFIER,t.MEMBER_EXP];g.assignmentOperators.forEach(function(e){return t.addBinaryOp(e,g.assignmentPrecedence,!0)}),t.hooks.add("gobble-token",function(e){var t=this,r=this.code;g.updateOperators.some(function(e){return e===r&&e===t.expr.charCodeAt(t.index+1)})&&(this.index+=2,e.node={type:"UpdateExpression",operator:43===r?"++":"--",argument:this.gobbleTokenProperty(this.gobbleIdentifier()),prefix:!0},e.node.argument&&n.includes(e.node.argument.type)||this.throwError("Unexpected ".concat(e.node.operator)))}),t.hooks.add("after-token",function(e){var t,r=this;e.node&&(t=this.code,g.updateOperators.some(function(e){return e===t&&e===r.expr.charCodeAt(r.index+1)})&&(n.includes(e.node.type)||this.throwError("Unexpected ".concat(e.node.operator)),this.index+=2,e.node={type:"UpdateExpression",operator:43===t?"++":"--",argument:e.node,prefix:!1}))}),t.hooks.add("after-expression",function(e){e.node&&!function t(e){g.assignmentOperators.has(e.operator)?(e.type="AssignmentExpression",t(e.left),t(e.right)):e.operator||Object.values(e).forEach(function(e){e&&"object"===C(e)&&t(e)})}(e.node)})}},A=Object.prototype.hasOwnProperty;function w(e,t){return(e=e.slice()).push(t),e}function k(e,t){return(t=t.slice()).unshift(e),t}var x=function(){function r(e){var t;return s(this,r),(t=n(this,r,['JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'])).avoidNew=!0,t.value=e,t.name="NewError",t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}(r,p(Error)),c(r)}();function F(e,t,r,n,i){if(!(this instanceof F))try{return new F(e,t,r,n,i)}catch(e){if(!e.avoidNew)throw e;return e.value}"string"==typeof e&&(i=n,n=r,r=t,t=e,e=null);var o=e&&"object"===C(e);if(e=e||{},this.json=e.json||r,this.path=e.path||t,this.resultType=e.resultType||"value",this.flatten=e.flatten||!1,this.wrap=!A.call(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=e.parent||null,this.parentProperty=e.parentProperty||null,this.callback=e.callback||n||null,this.otherTypeCallback=e.otherTypeCallback||i||function(){throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")},!1!==e.autostart){var a={path:o?e.path:t};o?"json"in e&&(a.json=e.json):a.json=r;a=this.evaluate(a);if(!a||"object"!==C(a))throw new x(a);return a}}F.prototype.evaluate=function(e,t,r,n){var i=this,o=this.parent,a=this.parentProperty,s=this.flatten,u=this.wrap;if(this.currResultType=this.resultType,this.currEval=this.eval,this.currSandbox=this.sandbox,r=r||this.callback,this.currOtherTypeCallback=n||this.otherTypeCallback,t=t||this.json,(e=e||this.path)&&"object"===C(e)&&!Array.isArray(e)){if(!e.path&&""!==e.path)throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');if(!A.call(e,"json"))throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');t=e.json,s=A.call(e,"flatten")?e.flatten:s,this.currResultType=A.call(e,"resultType")?e.resultType:this.currResultType,this.currSandbox=A.call(e,"sandbox")?e.sandbox:this.currSandbox,u=A.call(e,"wrap")?e.wrap:u,this.currEval=A.call(e,"eval")?e.eval:this.currEval,r=A.call(e,"callback")?e.callback:r,this.currOtherTypeCallback=A.call(e,"otherTypeCallback")?e.otherTypeCallback:this.currOtherTypeCallback,o=A.call(e,"parent")?e.parent:o,a=A.call(e,"parentProperty")?e.parentProperty:a,e=e.path}if(o=o||null,a=a||null,Array.isArray(e)&&(e=F.toPathString(e)),(e||""===e)&&t){e=F.toPathArray(e);"$"===e[0]&&1@-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))(?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\)\])['\]]/g.exec(f);d?this._walk(n,function(e){var t=[d[2]],r=d[1]?n[e][d[1]]:n[e];0=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){a=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(a)throw i}}}}(c.split(","));try{for(E.s();!(g=E.n()).done;){var g=g.value;p(this._trace(k(g,l),n,i,o,a,s,!0))}}catch(e){E.e(e)}finally{E.f()}}else!r&&n&&A.call(n,c)&&p(this._trace(l,n[c],w(i,c),n,c,s,e,!0))}if(this._hasParentSelector)for(var x=0;x":function(e,t){return e>t()},"<=":function(e,t){return e<=t()},">=":function(e,t){return e>=t()},"<<":function(e,t){return e<>":function(e,t){return e>>t()},">>>":function(e,t){return e>>>t()},"+":function(e,t){return e+t()},"-":function(e,t){return e-t()},"*":function(e,t){return e*t()},"/":function(e,t){return e/t()},"%":function(e,t){return e%t()}}[e.operator](D.evalAst(e.left,t),function(){return D.evalAst(e.right,t)})},evalCompound:function(e,t){for(var r=0;r