json-p3 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +0 -1
  2. package/dist/json-p3.browser.js +5303 -0
  3. package/dist/json-p3.browser.min.js +2 -0
  4. package/dist/json-p3.browser.min.js.map +1 -0
  5. package/dist/json-p3.cjs.js +70 -97
  6. package/dist/json-p3.esm.js +70 -97
  7. package/dist/json-p3.iife.min.js +1 -1
  8. package/dist/json-p3.iife.min.js.map +1 -1
  9. package/package.json +11 -24
  10. package/dist/deep_equals.d.ts +0 -10
  11. package/dist/index.d.ts +0 -10
  12. package/dist/json-p3.iife.js +0 -5366
  13. package/dist/patch/errors.d.ts +0 -11
  14. package/dist/patch/index.d.ts +0 -11
  15. package/dist/patch/patch.d.ts +0 -161
  16. package/dist/path/environment.d.ts +0 -165
  17. package/dist/path/errors.d.ts +0 -65
  18. package/dist/path/expression.d.ts +0 -101
  19. package/dist/path/extra/expression.d.ts +0 -6
  20. package/dist/path/extra/index.d.ts +0 -0
  21. package/dist/path/extra/selectors.d.ts +0 -35
  22. package/dist/path/functions/count.d.ts +0 -7
  23. package/dist/path/functions/function.d.ts +0 -26
  24. package/dist/path/functions/has.d.ts +0 -44
  25. package/dist/path/functions/index.d.ts +0 -11
  26. package/dist/path/functions/length.d.ts +0 -7
  27. package/dist/path/functions/match.d.ts +0 -33
  28. package/dist/path/functions/pattern.d.ts +0 -2
  29. package/dist/path/functions/search.d.ts +0 -34
  30. package/dist/path/functions/value.d.ts +0 -7
  31. package/dist/path/index.d.ts +0 -76
  32. package/dist/path/lex.d.ts +0 -74
  33. package/dist/path/lru_cache.d.ts +0 -10
  34. package/dist/path/node.d.ts +0 -84
  35. package/dist/path/parse.d.ts +0 -61
  36. package/dist/path/path.d.ts +0 -42
  37. package/dist/path/segments.d.ts +0 -39
  38. package/dist/path/selectors.d.ts +0 -85
  39. package/dist/path/serialize.d.ts +0 -6
  40. package/dist/path/token.d.ts +0 -70
  41. package/dist/path/types.d.ts +0 -46
  42. package/dist/pointer/errors.d.ts +0 -42
  43. package/dist/pointer/index.d.ts +0 -24
  44. package/dist/pointer/pointer.d.ts +0 -106
  45. package/dist/tsconfig.tsbuildinfo +0 -1
  46. package/dist/types.d.ts +0 -25
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-p3.browser.min.js","sources":["../src/path/errors.ts","../src/types.ts","../src/deep_equals.ts","../src/path/functions/function.ts","../src/pointer/errors.ts","../src/pointer/pointer.ts","../src/pointer/index.ts","../src/path/serialize.ts","../src/path/types.ts","../src/path/node.ts","../src/path/expression.ts","../src/path/functions/count.ts","../src/path/functions/length.ts","../src/path/lru_cache.ts","../src/path/functions/pattern.ts","../node_modules/iregexp-check/dist/iregexp-check.esm.js","../src/path/functions/match.ts","../src/path/functions/search.ts","../src/path/functions/value.ts","../src/path/token.ts","../src/path/lex.ts","../src/path/selectors.ts","../src/path/segments.ts","../src/path/path.ts","../src/path/extra/expression.ts","../src/path/extra/selectors.ts","../src/path/parse.ts","../src/path/environment.ts","../src/path/functions/has.ts","../src/path/index.ts","../src/patch/errors.ts","../src/patch/patch.ts","../src/patch/index.ts","../src/index.ts"],"sourcesContent":["import { Token } from \"./token\";\n\n/**\n * Base class for all JSONPath errors.\n */\nexport class JSONPathError extends Error {\n constructor(\n readonly message: string,\n readonly token: Token,\n ) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPathError\";\n this.message = withErrorContext(message, token);\n }\n}\n\nfunction withErrorContext(message: string, token: Token): string {\n if (token.input.length <= 9) {\n return `${message} ('${token.input}':${token.index})`;\n }\n\n if (token.index > token.input.length - 5) {\n return `${message} ('${token.input.slice(token.input.length - 9)}':${\n token.index\n })`;\n }\n\n if (token.index - 4 < 0) {\n return `${message} ('${token.input.slice(0, 9)}':${token.index})`;\n }\n\n return `${message} ('${token.input.slice(\n token.index - 4,\n token.index + 5,\n )}':${token.index})`;\n}\n\n/**\n * Error thrown due to unexpected, internal path tokenization problems.\n */\nexport class JSONPathLexerError extends JSONPathError {\n constructor(\n readonly message: string,\n readonly token: Token,\n ) {\n super(message, token);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPathLexerError\";\n this.message = withErrorContext(message, token);\n }\n}\n\n/**\n * Error thrown due to type errors when evaluating filter expressions.\n */\nexport class JSONPathTypeError extends JSONPathError {\n constructor(\n readonly message: string,\n readonly token: Token,\n ) {\n super(message, token);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPathTypeError\";\n this.message = withErrorContext(message, token);\n }\n}\n\n/**\n * Error thrown due to out of range indices.\n */\nexport class JSONPathIndexError extends JSONPathError {\n constructor(\n readonly message: string,\n readonly token: Token,\n ) {\n super(message, token);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPathIndexError\";\n this.message = withErrorContext(message, token);\n }\n}\n\n/**\n * Error thrown when attempting to retrieve a filter function that has not\n * been registered.\n */\nexport class UndefinedFilterFunctionError extends JSONPathError {\n constructor(\n readonly message: string,\n readonly token: Token,\n ) {\n super(message, token);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"UndefinedFilterFunctionError\";\n this.message = withErrorContext(message, token);\n }\n}\n\n/**\n * Error thrown due to syntax errors found during parsing a JSONPath query.\n */\nexport class JSONPathSyntaxError extends JSONPathError {\n constructor(\n readonly message: string,\n readonly token: Token,\n ) {\n super(message, token);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPathSyntaxError\";\n this.message = withErrorContext(message, token);\n }\n}\n\n/**\n * Error thrown when the maximum recursion depth is reached.\n */\nexport class JSONPathRecursionLimitError extends JSONPathError {\n constructor(\n readonly message: string,\n readonly token: Token,\n ) {\n super(message, token);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPathRecursionLimitError\";\n this.message = withErrorContext(message, token);\n }\n}\n\n/**\n * Error thrown due to invalid I-Regexp syntax.\n */\nexport class IRegexpError extends Error {\n constructor(readonly message: string) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"IRegexpError\";\n }\n}\n","/**\n * Common types and type predicates.\n */\n\n/**\n * A JSON-like value.\n */\nexport type JSONValue =\n | string\n | number\n | null\n | undefined\n | boolean\n | JSONValue[]\n | { [key: string]: JSONValue };\n\n/**\n * A type predicate for the Array object.\n */\nexport function isArray(value: unknown): value is unknown[] {\n return Array.isArray(value);\n}\n\n/**\n * A type predicate for object.\n */\nexport function isObject(value: unknown): value is object {\n const _type = typeof value;\n return (value !== null && _type === \"object\") || _type === \"function\"\n ? true\n : false;\n}\n\n/**\n * A type predicate for a string primitive.\n */\nexport function isString(value: unknown): value is string {\n return typeof value === \"string\";\n}\n\n/**\n * A type predicate for a number primitive.\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === \"number\";\n}\n","/**\n * Deep equality of JSON-like values.\n *\n * No attempt is made to handle function objects, recursive data\n * structures, NaNs, sparse arrays, primitive wrapper objects....\n *\n * We're not using JSON.stringify because we want objects with the same\n * entries in a different order to compare equal.\n */\n\nimport { isObject } from \"./types\";\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nexport function deepEquals(a: unknown, b: unknown): boolean {\n if (a === b) {\n return true;\n }\n\n if (Array.isArray(a)) {\n if (Array.isArray(b)) {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (!deepEquals(a[i], b[i])) {\n return false;\n }\n }\n return true;\n }\n return false;\n } else if (isObject(a) && isObject(b)) {\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n for (const key of keysA) {\n if (!deepEquals(a[key as keyof typeof a], b[key as keyof typeof b])) {\n return false;\n }\n }\n\n return true;\n }\n\n return false;\n}\n","/**\n * The type of a JSONPath filter function parameter or return value, as\n * described in See section 2.4.1 of RFC 9535.\n */\nexport enum FunctionExpressionType {\n ValueType = \"ValueType\",\n LogicalType = \"LogicalType\",\n NodesType = \"NodesType\",\n}\n\n/**\n * A JSONPath filter function definition.\n */\nexport interface FilterFunction {\n /**\n * Argument types expected by the filter function.\n */\n argTypes: FunctionExpressionType[];\n\n /**\n * The type of the value returned by the filter function.\n */\n returnType: FunctionExpressionType;\n\n /**\n * A function with unknown number and type of arguments.\n */\n call(...args: unknown[]): unknown;\n}\n","/**\n * Base class for all JSON Pointer errors.\n */\nexport class JSONPointerError extends Error {\n constructor(readonly message: string) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPointerError\";\n }\n}\n\n/**\n * Base class for JSON Pointer resolution errors.\n */\nexport class JSONPointerResolutionError extends JSONPointerError {\n constructor(readonly message: string) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPointerResolutionError\";\n }\n}\n\n/**\n * Error thrown due to an out of range index when resolving a JSON Pointer.\n */\nexport class JSONPointerIndexError extends JSONPointerResolutionError {\n constructor(readonly message: string) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPointerIndexError\";\n }\n}\n\n/**\n * Error thrown due to a missing property when resolving a JSON Pointer.\n */\nexport class JSONPointerKeyError extends JSONPointerResolutionError {\n constructor(readonly message: string) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPointerKeyError\";\n }\n}\n\n/**\n * Error thrown due to invalid JSON Pointer syntax.\n */\nexport class JSONPointerSyntaxError extends JSONPointerError {\n constructor(readonly message: string) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPointerSyntaxError\";\n }\n}\n\n/**\n * Error thrown when trying to resolve a property or index against a primitive value.\n */\nexport class JSONPointerTypeError extends JSONPointerResolutionError {\n constructor(readonly message: string) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPointerTypeError\";\n }\n}\n","import { JSONValue, isArray, isNumber, isObject, isString } from \"../types\";\nimport {\n JSONPointerIndexError,\n JSONPointerKeyError,\n JSONPointerResolutionError,\n JSONPointerSyntaxError,\n JSONPointerTypeError,\n} from \"./errors\";\n\n/**\n * The symbol indicating the absence of a JSON value.\n */\nexport const UNDEFINED = Symbol.for(\"jsonpointer.undefined\");\n\nexport type MaybeJSONValue = JSONValue | typeof UNDEFINED;\n\n/**\n * Identify a single value in JSON-like data, as per RFC 6901.\n */\nexport class JSONPointer {\n #pointer: string;\n tokens: string[];\n\n /**\n * @param pointer - A string representation of a JSON Pointer.\n */\n constructor(pointer: string) {\n this.tokens = this.parse(pointer);\n this.#pointer = JSONPointer.encode(this.tokens);\n }\n\n static encode(tokens: string[]) {\n if (!tokens.length) return \"\";\n return (\n \"/\" +\n tokens\n .map((token) => token.replaceAll(\"~\", \"~0\").replaceAll(\"/\", \"~1\"))\n .join(\"/\")\n );\n }\n\n /**\n * Resolve this pointer against JSON-like data _value_.\n *\n * @param value - The target JSON-like value, possibly loaded using\n * `JSON.parse()`.\n * @param fallback - A default value to return if _value_ has no\n * path matching `pointer`.\n * @returns The value identified by _pointer_ or, if given, the fallback\n * value in the even of a `JSONPointerResolutionError`.\n *\n * @throws {@link JSONPointerResolutionError}\n * If the value pointed to by _pointer_ does not exist in _value_, and\n * no fallback value is given.\n */\n public resolve(\n value: JSONValue,\n fallback: MaybeJSONValue = UNDEFINED,\n ): JSONValue {\n try {\n return this.tokens.reduce(this.getItem.bind(this), value);\n } catch (error) {\n if (\n error instanceof JSONPointerResolutionError &&\n fallback !== UNDEFINED\n ) {\n return fallback;\n }\n throw error;\n }\n }\n\n /**\n *\n * @param value -\n * @returns\n */\n public resolveWithParent(value: JSONValue): [MaybeJSONValue, MaybeJSONValue] {\n if (!this.tokens.length) return [UNDEFINED, this.resolve(value)];\n\n const parent = this.tokens\n .slice(0, this.tokens.length - 1)\n .reduce(this.getItem.bind(this), value);\n\n try {\n return [\n parent,\n this.getItem(\n parent,\n this.tokens[this.tokens.length - 1],\n this.tokens.length - 1,\n ),\n ];\n } catch (error) {\n if (\n error instanceof JSONPointerIndexError ||\n error instanceof JSONPointerKeyError\n ) {\n return [parent, UNDEFINED];\n }\n throw error;\n }\n }\n\n /**\n *\n * @returns\n */\n public toString(): string {\n return this.#pointer;\n }\n\n /**\n * Return _true_ if this pointer points to a child of _pointer_.\n */\n public isRelativeTo(pointer: JSONPointer): boolean {\n return (\n pointer.tokens.length < this.tokens.length &&\n this.tokens\n .slice(0, pointer.tokens.length)\n .every((t, i) => t === pointer.tokens[i])\n );\n }\n\n protected parse(pointer: string): string[] {\n if (pointer.length && !pointer.startsWith(\"/\")) {\n throw new JSONPointerSyntaxError(\n `\"${pointer}\" pointers must start with a slash or be the empty string`,\n );\n }\n\n return pointer\n .split(\"/\")\n .map((token) => token.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\"))\n .slice(1);\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n protected getItem(val: JSONValue, token: string, idx: number): JSONValue {\n // NOTE:\n // - string primitives \"have own\" indices and `length`.\n // - Arrays have a `length` property.\n // - A property might exist with the value `undefined` or `null`.\n // - obj[1] is equivalent to obj[\"1\"].\n if (isArray(val)) {\n if (token !== \"length\" && Object.hasOwn(val, token)) {\n return val[Number(token)];\n } else if (token.startsWith(\"#\")) {\n // handle non-standard '#' from relative json pointer\n const maybeIndex = token.slice(1);\n if (RE_INT.test(maybeIndex) && Object.hasOwn(val, maybeIndex)) {\n return Number(maybeIndex);\n } else {\n throw new JSONPointerIndexError(\n `index out of range '${JSONPointer.encode(\n this.tokens.slice(0, idx + 1),\n )}'`,\n );\n }\n } else {\n throw new JSONPointerIndexError(\n `index out of range '${JSONPointer.encode(\n this.tokens.slice(0, idx + 1),\n )}'`,\n );\n }\n } else if (isObject(val)) {\n if (Object.hasOwn(val, token)) {\n return val[token];\n } else if (token.startsWith(\"#\") && Object.hasOwn(val, token.slice(1))) {\n // handle non-standard '#' from relative json pointer\n return token.slice(1);\n } else {\n throw new JSONPointerKeyError(\n `no such property '${JSONPointer.encode(\n this.tokens.slice(0, idx + 1),\n )}'`,\n );\n }\n }\n throw new JSONPointerTypeError(\n `found primitive value, expected an object '${JSONPointer.encode(\n this.tokens.slice(0, idx + 1),\n )}'`,\n );\n }\n\n private _join(pointer: string): JSONPointer {\n if (!isString(pointer)) {\n throw new JSONPointerTypeError(\n `join() requires string arguments, found ${typeof pointer}`,\n );\n }\n\n if (pointer.startsWith(\"/\")) {\n return new JSONPointer(pointer);\n }\n\n const tokens = this.tokens.concat(\n pointer\n .split(\"/\")\n .map((token) => token.replaceAll(\"~1\", \"/\").replaceAll(\"~0\", \"~\")),\n );\n\n return new JSONPointer(JSONPointer.encode(tokens));\n }\n\n /**\n * Join this pointer with _tokens_.\n *\n * @param tokens - JSON Pointer strings, possibly without leading slashes.\n * If a token or \"part\" does have a leading slash, the previous pointer is\n * ignored and a new `JSONPointer` is created, then processing of the\n * remaining tokens continues.\n *\n * @returns A new JSON Pointer that is the concatenation of all tokens or\n * \"parts\".\n */\n public join(...tokens: string[]): JSONPointer {\n if (!tokens.length) {\n return this;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let pointer: JSONPointer = this;\n for (const tok of tokens) {\n pointer = pointer._join(tok);\n }\n return pointer;\n }\n\n /**\n * Return _true_ if this pointer can be resolved against _value_.\n *\n * Note that `JSONPointer.resolve()` can return legitimate falsy values\n * that form part of the target JSON document. This method will return\n * `true` if a falsy value is found.\n */\n public exists(value: JSONValue): boolean {\n try {\n this.resolve(value);\n } catch (error) {\n if (error instanceof JSONPointerResolutionError) {\n return false;\n }\n throw error;\n }\n return true;\n }\n\n /**\n * Return this pointer's parent as a new `JSONPointer`.\n *\n * If this pointer points to the document root, _this_ is returned.\n */\n public parent(): JSONPointer {\n if (!this.tokens.length) {\n return this;\n }\n\n return new JSONPointer(\n JSONPointer.encode(this.tokens.slice(0, this.tokens.length - 1)),\n );\n }\n\n public to(rel: string | RelativeJSONPointer): JSONPointer {\n const relativePointer = isString(rel) ? new RelativeJSONPointer(rel) : rel;\n return relativePointer.to(this);\n }\n}\n\nconst RE_RELATIVE_POINTER =\n /(?<ORIGIN>\\d+)(?<INDEX_G>(?<SIGN>[+-])(?<INDEX>\\d))?(?<POINTER>.*)/s;\n\nconst RE_INT = /(0|[1-9]\\d*)/;\n\n/**\n * A relative JSON Pointer.\n *\n * See https://datatracker.ietf.org/doc/html/draft-hha-relative-json-pointer\n */\nexport class RelativeJSONPointer {\n readonly origin: number;\n readonly index: number;\n readonly pointer: string | JSONPointer;\n\n /**\n *\n * @param rel -\n */\n constructor(rel: string) {\n [this.origin, this.index, this.pointer] = this.parse(rel);\n }\n\n /**\n *\n * @returns\n */\n public toString(): string {\n const sign = this.index > 0 ? \"+\" : \"\";\n const index = this.index === 0 ? \"\" : `${sign}${this.index}`;\n return `${this.origin}${index}${this.pointer}`;\n }\n\n /**\n *\n * @param pointer -\n */\n public to(pointer: string | JSONPointer): JSONPointer {\n const p = isString(pointer) ? new JSONPointer(pointer) : pointer;\n\n // move to origin\n if (this.origin > p.tokens.length) {\n throw new JSONPointerIndexError(\n `origin (${this.origin}) exceeds root (${p.tokens.length})`,\n );\n }\n\n const tokens =\n this.origin < 1 ? p.tokens.slice() : p.tokens.slice(0, -this.origin);\n\n // array index offset\n if (this.index && tokens.length && this.isIntLike(tokens.at(-1))) {\n const newIndex = Number(tokens.at(-1)) + this.index;\n if (newIndex < 0) {\n throw new JSONPointerIndexError(\n `index offset out of range (${newIndex})`,\n );\n }\n tokens[tokens.length - 1] = String(newIndex);\n }\n\n // pointer or index/property\n if (this.pointer instanceof JSONPointer) {\n tokens.push(...this.pointer.tokens);\n } else {\n tokens[tokens.length - 1] = `#${tokens[tokens.length - 1]}`;\n }\n\n return new JSONPointer(JSONPointer.encode(tokens));\n }\n\n protected parse(rel: string): [number, number, string | JSONPointer] {\n const match = RE_RELATIVE_POINTER.exec(rel);\n if (!match || !match.groups) {\n throw new JSONPointerSyntaxError(\"failed to parse relative pointer\");\n }\n\n // steps to move\n const origin = this.parseInt(match.groups.ORIGIN);\n\n // optional index manipulation\n let index = 0;\n if (match.groups[\"INDEX_G\"]) {\n index = this.parseInt(match.groups.INDEX);\n if (index === 0) {\n throw new JSONPointerSyntaxError(\"index offset can't be zero\");\n }\n if (match.groups.SIGN === \"-\") {\n index = -index;\n }\n }\n\n // pointer or '#'. an empty string is OK.\n if (match.groups.POINTER === \"#\") {\n return [origin, index, \"#\"];\n }\n\n return [origin, index, new JSONPointer(match.groups.POINTER)];\n }\n\n protected parseInt(s: string): number {\n if (s.startsWith(\"0\") && s.length > 1) {\n throw new JSONPointerSyntaxError(\"unexpected leading zero\");\n }\n\n if (RE_INT.test(s)) {\n return Number(s);\n }\n\n throw new JSONPointerSyntaxError(`expected an integer, found '${s}'`);\n }\n\n protected isIntLike(value: string | number | undefined): boolean {\n if (value === undefined || isNumber(value)) {\n return true;\n } else {\n return RE_INT.test(value);\n }\n }\n}\n","import { JSONValue } from \"../types\";\nimport { JSONPointer, MaybeJSONValue, UNDEFINED } from \"./pointer\";\n\nexport { JSONPointer, RelativeJSONPointer, UNDEFINED } from \"./pointer\";\nexport type { MaybeJSONValue } from \"./pointer\";\n\nexport {\n JSONPointerError,\n JSONPointerResolutionError,\n JSONPointerIndexError,\n JSONPointerKeyError,\n JSONPointerSyntaxError,\n JSONPointerTypeError,\n} from \"./errors\";\n\n/**\n * Resolve JSON Pointer _pointer_ against JSON-like data _value_.\n *\n * @param pointer - A string representation of a JSON pointer.\n * @param value - The target JSON-like value, possibly loaded using\n * `JSON.parse()`.\n * @param fallback - A default value to return if _value_ has no\n * path matching `pointer`.\n * @returns The value identified by _pointer_ or, if given, the fallback\n * value in the even of a `JSONPointerResolutionError`.\n *\n * @throws {@link JSONPointerResolutionError}\n * If the value pointed to by _pointer_ does not exist in _value_, and\n * no fallback value is given.\n *\n * @throws {@link JSONPointerSyntaxError}\n * If _pointer_ is malformed according to RFC 6901.\n */\nexport function resolve(\n pointer: string,\n value: JSONValue,\n fallback: MaybeJSONValue = UNDEFINED,\n): JSONValue {\n return new JSONPointer(pointer).resolve(value, fallback);\n}\n","/**\n * An identifier that is allowed in both JS and JSONPath.\n * JSONPath identifiers are generally much more permissive than JS ones, but\n * they don't allow the character \"$\", so we take the intersection of the two\n * when deciding whether to use dot shorthand for canonical serialization of\n * simple names.\n */\nconst SHORTHAND_COMPATIBLE_IDENTIFIER = /^[\\p{ID_Start}_]\\p{ID_Continue}*$/u;\n\n/** Usable in a quoted path. */\nexport function toQuoted(name: string): string {\n return name.includes(\"'\") && !name.includes('\"')\n ? JSON.stringify(name)\n : toCanonical(name);\n}\n\n/** Usable in a normalized path. */\nexport function toCanonical(name: string): string {\n return `'${JSON.stringify(name).slice(1, -1).replaceAll('\\\\\"', '\"').replaceAll(\"'\", \"\\\\'\")}'`;\n}\n\n/** Usable in a shorthand path. */\nexport function toShorthand(name: string): string | null {\n return SHORTHAND_COMPATIBLE_IDENTIFIER.test(name) ? name : null;\n}\n","import { JSONValue, isObject } from \"../types\";\nimport { JSONPathEnvironment } from \"./environment\";\n\nexport const Nothing = Symbol.for(\"jsonpath.nothing\");\n\n/**\n * ValueType for JSONPath function expression tye system.\n */\nexport type JSONPathValue = JSONValue | typeof Nothing;\n\n/**\n * Object passed to `FilterExpression.evaluate()`.\n */\nexport type FilterContext = {\n environment: JSONPathEnvironment;\n currentValue: JSONValue;\n rootValue: JSONValue;\n lazy?: boolean;\n currentKey?: string | number;\n};\n\n/**\n * A type predicate for an object with a string property.\n */\nexport function hasStringKey(\n value: unknown,\n key: string,\n): value is { [key: string]: unknown } {\n return isObject(value) && Object.hasOwn(value, key);\n}\n\nexport const KEY_MARK = \"\\x02\";\n\n/**\n * Options for serializing paths.\n */\nexport type SerializationOptions = {\n /**\n * `pretty` paths always use:\n * - shorthand notation rather than dot notation where possible\n * - double quotes rather than single quotes for string literals and where shorthand\n * notation is not possible\n * - short escape sequences for common non-printing characters such as `\\n` and `\\t`\n *\n * `canonical` paths always use:\n * - bracket notation for name and wildcard selectors\n * - single quotes for name selectors and string literals\n * - short escape sequences for common non-printing characters such as `\\n` and `\\t`\n *\n * `canonical` paths will produce a normalized path where available, but cannot be\n * considered normalized paths if the query does not represent a singular, absolute node.\n */\n form: \"pretty\" | \"canonical\";\n};\n\nexport const defaultSerializationOptions: SerializationOptions = {\n form: \"pretty\",\n};\n","import { JSONPointer } from \"../pointer\";\nimport { JSONValue, isString } from \"../types\";\nimport { toCanonical, toQuoted, toShorthand } from \"./serialize\";\nimport {\n type SerializationOptions,\n defaultSerializationOptions,\n KEY_MARK,\n} from \"./types\";\n\n/**\n * The pair of a JSON value and its location found in the target JSON value.\n */\nexport class JSONPathNode {\n /**\n * @param value - The JSON value found at _location_.\n * @param location - The parts of a normalized path to _value_.\n * @param root - The target value at the top of the JSON node tree.\n */\n constructor(\n readonly value: JSONValue,\n readonly location: Array<string | number>,\n readonly root: JSONValue,\n ) {}\n\n /**\n * @deprecated Use {@link getPath} with `options.form` set to `canonical` instead.\n */\n public get path(): string {\n return this.getPath({ form: \"canonical\" });\n }\n\n /**\n * Get the path to this node in the target JSON value.\n *\n * Given that the path refers to the singular current node, the returned path\n * will always be a normalized path if `options.form` is set to `canonical`,\n * following section 2.7 of RFC 9535.\n */\n public getPath(options?: SerializationOptions): string {\n const opts = { ...defaultSerializationOptions, ...options };\n\n return (\n \"$\" +\n this.location\n .map((s) => (isString(s) ? this.decodeNameLocation(s, opts) : `[${s}]`))\n .join(\"\")\n );\n }\n\n /**\n * Return this node's location as a {@link JSONPointer}.\n */\n public toPointer(): JSONPointer {\n if (!this.location.length) {\n return new JSONPointer(\"\");\n }\n return new JSONPointer(JSONPointer.encode(this.location.map(String)));\n }\n\n private decodeNameLocation(\n name: string,\n options: SerializationOptions,\n ): string {\n const normalized = options.form === \"canonical\";\n const serialize = normalized ? toCanonical : toQuoted;\n const hasKeyMark = name.startsWith(KEY_MARK);\n if (hasKeyMark) name = name.slice(1);\n const shorthand = toShorthand(name);\n\n if (hasKeyMark) {\n return normalized || shorthand == null\n ? `[~${serialize(name)}]`\n : `.~${shorthand}`;\n }\n\n return normalized || shorthand == null\n ? `[${serialize(name)}]`\n : `.${shorthand}`;\n }\n}\n\n/**\n *\n */\nexport class JSONPathNodeList {\n constructor(readonly nodes: JSONPathNode[]) {}\n\n /**\n * @returns an iterator over nodes in the list.\n */\n [Symbol.iterator](): Iterator<JSONPathNode> {\n return this.nodes[Symbol.iterator]();\n }\n\n /**\n * @returns `true` if the node list is empty.\n */\n public empty(): boolean {\n return this.nodes.length === 0;\n }\n\n /**\n * @returns An array containing the values at each node in the list.\n *\n * @see {@link valuesOrSingular} to unpack the array if there is only\n * one node in the list.\n */\n public values(): JSONValue[] {\n return this.nodes.map((node) => node.value);\n }\n\n /**\n * Like {@link values}, but returns the node's value is there is only one\n * node in the list.\n */\n public valuesOrSingular(): JSONValue {\n if (this.nodes.length === 1) return this.nodes[0].value;\n return this.nodes.map((node) => node.value);\n }\n\n /**\n * @returns An array of locations for each node in the node list.\n *\n * A location is an array of property names and array indices that were\n * required to reach the node's value in the target JSON value.\n */\n public locations(): Array<Array<string | number>> {\n return this.nodes.map((node) => node.location);\n }\n\n /**\n * @returns An array of normalized path strings for each node in the list.\n *\n * A normalized path contains only property name and index selectors, and\n * always uses bracketed segments, never shorthand selectors.\n */\n public paths(options?: SerializationOptions): string[] {\n return this.nodes.map((node) => node.getPath(options));\n }\n\n /**\n * @returns An array of {@link JSONPointer} instances, one for each node\n * in the list.\n */\n public pointers(): JSONPointer[] {\n return this.nodes.map((node) => node.toPointer());\n }\n\n /**\n * @returns The number of nodes in the node list.\n */\n public get length(): number {\n return this.nodes.length;\n }\n}\n","import { deepEquals } from \"../deep_equals\";\nimport { JSONPathTypeError, UndefinedFilterFunctionError } from \"./errors\";\nimport { FunctionExpressionType } from \"./functions/function\";\nimport { JSONPathNodeList } from \"./node\";\nimport { JSONPathQuery } from \"./path\";\nimport { Token } from \"./token\";\nimport { FilterContext, Nothing, SerializationOptions } from \"./types\";\nimport { isNumber, isString } from \"../types\";\nimport { toCanonical } from \"./serialize\";\n\n/**\n * Base class for all filter expressions.\n */\nexport abstract class FilterExpression {\n constructor(readonly token: Token) {}\n\n /**\n * Evaluate the filter expression in the given context.\n * @param context - Evaluation context.\n */\n public abstract evaluate(context: FilterContext): unknown;\n\n /**\n * Return a string representation of the expression.\n */\n public abstract toString(options?: SerializationOptions): string;\n}\n\n/**\n * Base class for JSONPath ValueType literals.\n */\nexport abstract class FilterExpressionLiteral extends FilterExpression {}\n\nexport class NullLiteral extends FilterExpressionLiteral {\n public evaluate(): null {\n return null;\n }\n\n public toString(): string {\n return \"null\";\n }\n}\n\nexport class BooleanLiteral extends FilterExpressionLiteral {\n constructor(\n readonly token: Token,\n readonly value: boolean,\n ) {\n super(token);\n }\n\n public evaluate(): boolean {\n return this.value;\n }\n\n public toString(): string {\n return String(this.value);\n }\n}\n\nexport class StringLiteral extends FilterExpressionLiteral {\n constructor(\n readonly token: Token,\n readonly value: string,\n ) {\n super(token);\n }\n\n public evaluate(): string {\n return this.value;\n }\n\n public toString(): string {\n return toCanonical(this.value);\n }\n}\n\nexport class NumberLiteral extends FilterExpressionLiteral {\n constructor(\n readonly token: Token,\n readonly value: number,\n ) {\n super(token);\n }\n\n public evaluate(): number {\n return this.value;\n }\n\n public toString(): string {\n return String(this.value);\n }\n}\n\nexport class PrefixExpression extends FilterExpression {\n constructor(\n readonly token: Token,\n readonly operator: string,\n readonly right: FilterExpression,\n ) {\n super(token);\n }\n\n public evaluate(context: FilterContext): boolean {\n if (this.operator === \"!\") {\n const value = this.right.evaluate(context);\n if (value instanceof JSONPathNodeList) return value.nodes.length === 0; // negated existence\n return !isTruthy(value);\n }\n throw new JSONPathTypeError(\n `unknown operator '${this.operator}'`,\n this.token,\n );\n }\n\n public toString(options?: SerializationOptions): string {\n return `${this.operator}${this.right.toString(options)}`;\n }\n}\n\nconst PRECEDENCE_LOGICAL_OR = 4;\nconst PRECEDENCE_LOGICAL_AND = 5;\nconst PRECEDENCE_PREFIX = 7;\n\nexport class InfixExpression extends FilterExpression {\n readonly logical: boolean;\n\n constructor(\n readonly token: Token,\n readonly left: FilterExpression,\n readonly operator: string,\n readonly right: FilterExpression,\n ) {\n super(token);\n this.logical = operator === \"&&\" || operator === \"||\";\n }\n\n public evaluate(context: FilterContext): boolean {\n let left = this.left.evaluate(context);\n if (\n !this.logical &&\n left instanceof JSONPathNodeList &&\n left.nodes.length === 1\n )\n left = left.nodes[0].value;\n\n let right = this.right.evaluate(context);\n if (\n !this.logical &&\n right instanceof JSONPathNodeList &&\n right.nodes.length === 1\n )\n right = right.nodes[0].value;\n\n if (this.operator === \"&&\") {\n return isTruthy(left) && isTruthy(right);\n }\n\n if (this.operator === \"||\") {\n return isTruthy(left) || isTruthy(right);\n }\n\n return compare(left, this.operator, right);\n }\n\n public toString(options?: SerializationOptions): string {\n // Note that `LogicalExpression.toString()` does not call this.\n if (this.logical) {\n return `(${this.left.toString(options)} ${\n this.operator\n } ${this.right.toString(options)})`;\n }\n return `${this.left.toString(options)} ${this.operator} ${this.right.toString(options)}`;\n }\n}\n\nexport class LogicalExpression extends FilterExpression {\n constructor(\n readonly token: Token,\n readonly expression: FilterExpression,\n ) {\n super(token);\n }\n\n public evaluate(context: FilterContext): boolean {\n const value = this.expression.evaluate(context);\n if (value instanceof JSONPathNodeList) return value.nodes.length > 0; // existence\n return isTruthy(value);\n }\n\n public toString(options?: SerializationOptions): string {\n // Minimize parentheses in logical expressions.\n function _toString(\n expression: FilterExpression,\n parentPrecedence: number,\n ): string {\n if (expression instanceof InfixExpression) {\n let precedence: number;\n let op: string;\n let left: string;\n let right: string;\n\n if (expression.operator === \"&&\") {\n precedence = PRECEDENCE_LOGICAL_AND;\n op = \"&&\";\n left = _toString(expression.left, precedence);\n right = _toString(expression.right, precedence);\n } else if (expression.operator === \"||\") {\n precedence = PRECEDENCE_LOGICAL_OR;\n op = \"||\";\n left = _toString(expression.left, precedence);\n right = _toString(expression.right, precedence);\n } else {\n return expression.toString(options);\n }\n\n const expr = `${left} ${op} ${right}`;\n return precedence < parentPrecedence ? `(${expr})` : expr;\n }\n\n if (expression instanceof PrefixExpression) {\n const operand = _toString(expression.right, PRECEDENCE_PREFIX);\n const expr = `!${operand}`;\n return parentPrecedence > PRECEDENCE_PREFIX ? `(${expr})` : expr;\n }\n\n return expression.toString(options);\n }\n\n return _toString(this.expression, 0);\n }\n}\n\n/**\n * Base class for relative and absolute JSONPath query expressions.\n */\nexport abstract class FilterQuery extends FilterExpression {\n constructor(\n readonly token: Token,\n readonly path: JSONPathQuery,\n ) {\n super(token);\n }\n}\n\nexport class RelativeQuery extends FilterQuery {\n public evaluate(context: FilterContext): JSONPathNodeList {\n return context.lazy\n ? new JSONPathNodeList(\n Array.from(this.path.lazyQuery(context.currentValue)),\n )\n : this.path.query(context.currentValue);\n }\n\n public toString(options?: SerializationOptions): string {\n return `@${this.path.toString(options).slice(1)}`;\n }\n}\n\nexport class RootQuery extends FilterQuery {\n public evaluate(context: FilterContext): JSONPathNodeList {\n return context.lazy\n ? new JSONPathNodeList(Array.from(this.path.lazyQuery(context.rootValue)))\n : this.path.query(context.rootValue);\n }\n\n public toString(options?: SerializationOptions): string {\n return this.path.toString(options);\n }\n}\n\nexport class FunctionExtension extends FilterExpression {\n constructor(\n readonly token: Token,\n readonly name: string,\n readonly args: FilterExpression[],\n ) {\n super(token);\n }\n\n public evaluate(context: FilterContext): unknown {\n const func = context.environment.functionRegister.get(this.name);\n if (!func) {\n throw new UndefinedFilterFunctionError(\n `filter function '${this.name}' is undefined`,\n this.token,\n );\n }\n\n const args = this.args\n .map((arg) => arg.evaluate(context))\n .map((arg, idx) =>\n func.argTypes[idx] !== FunctionExpressionType.NodesType &&\n arg instanceof JSONPathNodeList\n ? this.unpack_node_list(arg)\n : arg,\n );\n return func.call(...args);\n }\n\n public toString(options?: SerializationOptions): string {\n return `${this.name}(${this.args.map((e) => e.toString(options)).join(\", \")})`;\n }\n\n private unpack_node_list(arg: JSONPathNodeList): unknown {\n switch (arg.length) {\n case 0:\n // If the query results in an empty node list, the argument\n // is the special result Nothing.\n return Nothing;\n case 1:\n // If the query results in a node list consisting of a single\n // node, the argument is the value of the node\n return arg.nodes[0].value;\n default:\n return arg;\n }\n }\n}\n\n/**\n *\n * @param value -\n */\nfunction isTruthy(value: unknown): boolean {\n if (value instanceof JSONPathNodeList && value.empty()) return false;\n return !(typeof value === \"boolean\" && value === false);\n}\n\nexport function compare(\n left: unknown,\n operator: string,\n right: unknown,\n): boolean {\n switch (operator) {\n case \"==\":\n return eq(left, right);\n case \"!=\":\n return !eq(left, right);\n case \"<\":\n return lt(left, right);\n case \">\":\n return lt(right, left);\n case \">=\":\n return lt(right, left) || eq(left, right);\n case \"<=\":\n return lt(left, right) || eq(left, right);\n default:\n return false;\n }\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nfunction eq(left: unknown, right: unknown): boolean {\n if (right instanceof JSONPathNodeList) [left, right] = [right, left];\n if (left instanceof JSONPathNodeList) {\n if (right instanceof JSONPathNodeList) {\n if (left.empty() && right.empty()) return true;\n if (left.nodes.length === 1 && right.nodes.length === 1)\n return deepEquals(left.nodes[0].value, right.nodes[0].value);\n }\n if (left.empty()) return right === Nothing;\n if (left.nodes.length === 1) return deepEquals(left.nodes[0].value, right);\n return false;\n }\n if (left === Nothing && right === Nothing) return true;\n return deepEquals(left, right);\n}\n\nfunction lt(left: unknown, right: unknown): boolean {\n if (\n (isString(left) && isString(right)) ||\n (isNumber(left) && isNumber(right))\n )\n return left < right;\n return false;\n}\n","import { JSONPathNodeList } from \"../node\";\nimport { FilterFunction, FunctionExpressionType } from \"./function\";\n\nexport class Count implements FilterFunction {\n readonly argTypes = [FunctionExpressionType.NodesType];\n readonly returnType = FunctionExpressionType.ValueType;\n\n public call(nodes: JSONPathNodeList): number {\n return nodes.length;\n }\n}\n","import { FilterFunction, FunctionExpressionType } from \"./function\";\nimport { Nothing } from \"../types\";\nimport { isArray, isObject, isString } from \"../../types\";\n\nexport class Length implements FilterFunction {\n readonly argTypes = [FunctionExpressionType.ValueType];\n readonly returnType = FunctionExpressionType.ValueType;\n\n public call(value: unknown): number | typeof Nothing {\n if (isArray(value) || isString(value)) return value.length;\n if (isObject(value)) return Object.keys(value).length;\n return Nothing;\n }\n}\n","/**\n * A Least Recently Used cache, implemented as an extended Map.\n */\nexport class LRUCache<K, V> extends Map<K, V> {\n readonly maxSize: number;\n\n constructor(maxSize: number = 128, entries?: Iterable<[K, V]>) {\n if (entries !== undefined) {\n super(entries);\n } else {\n super();\n }\n this.maxSize = maxSize;\n }\n\n get(key: K): V | undefined {\n const val = super.get(key);\n if (this.has(key)) {\n this.delete(key);\n this.set(key, val as V);\n }\n return val;\n }\n\n set(key: K, value: V): this {\n if (this.has(key)) {\n this.delete(key);\n } else if (this.size >= this.maxSize) {\n const first = this.first();\n if (first !== undefined) {\n this.delete(first);\n }\n }\n return super.set(key, value);\n }\n\n first() {\n return this.keys().next().value;\n }\n}\n","// See https://datatracker.ietf.org/doc/html/rfc9485#name-ecmascript-regexps\nexport function mapRegexp(pattern: string): string {\n let escaped = false;\n let charClass = false;\n const parts: string[] = [];\n for (const ch of pattern) {\n if (escaped) {\n parts.push(ch);\n escaped = false;\n continue;\n }\n\n switch (ch) {\n case \".\":\n if (!charClass) {\n parts.push(\"(?:(?![\\r\\n])\\\\P{Cs}|\\\\p{Cs}\\\\p{Cs})\");\n } else {\n parts.push(ch);\n }\n break;\n case \"\\\\\":\n escaped = true;\n parts.push(ch);\n break;\n case \"[\":\n charClass = true;\n parts.push(ch);\n break;\n case \"]\":\n charClass = false;\n parts.push(ch);\n break;\n default:\n parts.push(ch);\n break;\n }\n }\n return parts.join(\"\");\n}\n\nexport function fullMatch(pattern: string): string {\n const parts: string[] = [];\n const explicitCaret = pattern.startsWith(\"^\");\n const explicitDollar = pattern.endsWith(\"$\");\n if (!explicitCaret && !explicitDollar) parts.push(\"^(?:\");\n parts.push(mapRegexp(pattern));\n if (!explicitCaret && !explicitDollar) parts.push(\")$\");\n return parts.join(\"\");\n}\n","/*\n * iregexp-check version 0.1.2\n * https://github.com/jg-rp/js-iregexp\n * \n * MIT License\n * \n * Copyright (c) 2024 James Prior\n * \n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * \n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n * \n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n * \n */\nfunction isNormalChar(c) {\n return c < \"\\u0027\" || c === \",\" || c === \"-\" || c >= \"\\u002F\" && c <= \"\\u003E\" ||\n // / .. >\n c >= \"\\u0040\" && c <= \"\\u005A\" ||\n // @ .. Z\n c >= \"\\u005E\" && c <= \"\\u007A\" ||\n // ^ .. z\n c >= \"\\u007E\" && c <= \"\\uD7FF\" ||\n // skip surrogate code points\n c >= \"\\uE000\";\n}\nfunction isCCChar(c) {\n return c < \"\\u002C\" || c >= \"\\u002E\" && c <= \"\\u005A\" ||\n // '.' .. Z\n c >= \"\\u005E\" && c <= \"\\uD7FF\" ||\n // skip surrogate code points\n c >= \"\\uE000\";\n}\nfunction peg$subclass(child, parent) {\n function C() {\n this.constructor = child;\n }\n C.prototype = parent.prototype;\n child.prototype = new C();\n}\nfunction peg$SyntaxError(message, expected, found, location) {\n var self = Error.call(this, message);\n // istanbul ignore next Check is a necessary evil to support older environments\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(self, peg$SyntaxError.prototype);\n }\n self.expected = expected;\n self.found = found;\n self.location = location;\n self.name = \"SyntaxError\";\n return self;\n}\npeg$subclass(peg$SyntaxError, Error);\nfunction peg$padEnd(str, targetLength, padString) {\n padString = padString || \" \";\n if (str.length > targetLength) {\n return str;\n }\n targetLength -= str.length;\n padString += padString.repeat(targetLength);\n return str + padString.slice(0, targetLength);\n}\npeg$SyntaxError.prototype.format = function (sources) {\n var str = \"Error: \" + this.message;\n if (this.location) {\n var src = null;\n var k;\n for (k = 0; k < sources.length; k++) {\n if (sources[k].source === this.location.source) {\n src = sources[k].text.split(/\\r\\n|\\n|\\r/g);\n break;\n }\n }\n var s = this.location.start;\n var offset_s = this.location.source && typeof this.location.source.offset === \"function\" ? this.location.source.offset(s) : s;\n var loc = this.location.source + \":\" + offset_s.line + \":\" + offset_s.column;\n if (src) {\n var e = this.location.end;\n var filler = peg$padEnd(\"\", offset_s.line.toString().length, ' ');\n var line = src[s.line - 1];\n var last = s.line === e.line ? e.column : line.length + 1;\n var hatLen = last - s.column || 1;\n str += \"\\n --> \" + loc + \"\\n\" + filler + \" |\\n\" + offset_s.line + \" | \" + line + \"\\n\" + filler + \" | \" + peg$padEnd(\"\", s.column - 1, ' ') + peg$padEnd(\"\", hatLen, \"^\");\n } else {\n str += \"\\n at \" + loc;\n }\n }\n return str;\n};\npeg$SyntaxError.buildMessage = function (expected, found) {\n var DESCRIBE_EXPECTATION_FNS = {\n literal: function (expectation) {\n return \"\\\"\" + literalEscape(expectation.text) + \"\\\"\";\n },\n class: function (expectation) {\n var escapedParts = expectation.parts.map(function (part) {\n return Array.isArray(part) ? classEscape(part[0]) + \"-\" + classEscape(part[1]) : classEscape(part);\n });\n return \"[\" + (expectation.inverted ? \"^\" : \"\") + escapedParts.join(\"\") + \"]\";\n },\n any: function () {\n return \"any character\";\n },\n end: function () {\n return \"end of input\";\n },\n other: function (expectation) {\n return expectation.description;\n }\n };\n function hex(ch) {\n return ch.charCodeAt(0).toString(16).toUpperCase();\n }\n function literalEscape(s) {\n return s.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, \"\\\\\\\"\").replace(/\\0/g, \"\\\\0\").replace(/\\t/g, \"\\\\t\").replace(/\\n/g, \"\\\\n\").replace(/\\r/g, \"\\\\r\").replace(/[\\x00-\\x0F]/g, function (ch) {\n return \"\\\\x0\" + hex(ch);\n }).replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function (ch) {\n return \"\\\\x\" + hex(ch);\n });\n }\n function classEscape(s) {\n return s.replace(/\\\\/g, \"\\\\\\\\\").replace(/\\]/g, \"\\\\]\").replace(/\\^/g, \"\\\\^\").replace(/-/g, \"\\\\-\").replace(/\\0/g, \"\\\\0\").replace(/\\t/g, \"\\\\t\").replace(/\\n/g, \"\\\\n\").replace(/\\r/g, \"\\\\r\").replace(/[\\x00-\\x0F]/g, function (ch) {\n return \"\\\\x0\" + hex(ch);\n }).replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function (ch) {\n return \"\\\\x\" + hex(ch);\n });\n }\n function describeExpectation(expectation) {\n return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);\n }\n function describeExpected(expected) {\n var descriptions = expected.map(describeExpectation);\n var i, j;\n descriptions.sort();\n if (descriptions.length > 0) {\n for (i = 1, j = 1; i < descriptions.length; i++) {\n if (descriptions[i - 1] !== descriptions[i]) {\n descriptions[j] = descriptions[i];\n j++;\n }\n }\n descriptions.length = j;\n }\n switch (descriptions.length) {\n case 1:\n return descriptions[0];\n case 2:\n return descriptions[0] + \" or \" + descriptions[1];\n default:\n return descriptions.slice(0, -1).join(\", \") + \", or \" + descriptions[descriptions.length - 1];\n }\n }\n function describeFound(found) {\n return found ? \"\\\"\" + literalEscape(found) + \"\\\"\" : \"end of input\";\n }\n return \"Expected \" + describeExpected(expected) + \" but \" + describeFound(found) + \" found.\";\n};\nfunction peg$parse(input, options) {\n options = options !== undefined ? options : {};\n var peg$FAILED = {};\n var peg$source = options.grammarSource;\n var peg$startRuleFunctions = {\n start: peg$parsestart\n };\n var peg$startRuleFunction = peg$parsestart;\n var peg$c0 = \"|\";\n var peg$c1 = \"{\";\n var peg$c2 = \",\";\n var peg$c3 = \"}\";\n var peg$c4 = \"(\";\n var peg$c5 = \")\";\n var peg$c6 = \".\";\n var peg$c7 = \"\\\\\";\n var peg$c8 = \"[\";\n var peg$c9 = \"^\";\n var peg$c10 = \"-\";\n var peg$c11 = \"]\";\n var peg$c12 = \"\\\\p{\";\n var peg$c13 = \"\\\\P{\";\n var peg$c14 = \"L\";\n var peg$c15 = \"M\";\n var peg$c16 = \"N\";\n var peg$c17 = \"P\";\n var peg$c18 = \"Z\";\n var peg$c19 = \"S\";\n var peg$c20 = \"C\";\n var peg$r0 = /^[*-+?]/;\n var peg$r1 = /^[0-9]/;\n var peg$r2 = /^[(-+\\--.?[-\\^nrt{-}]/;\n var peg$r3 = /^[l-mot-u]/;\n var peg$r4 = /^[cen]/;\n var peg$r5 = /^[dlo]/;\n var peg$r6 = /^[c-fios]/;\n var peg$r7 = /^[lps]/;\n var peg$r8 = /^[ckmo]/;\n var peg$r9 = /^[cfn-o]/;\n var peg$e0 = peg$literalExpectation(\"|\", false);\n var peg$e1 = peg$classExpectation([[\"*\", \"+\"], \"?\"], false, false);\n var peg$e2 = peg$literalExpectation(\"{\", false);\n var peg$e3 = peg$classExpectation([[\"0\", \"9\"]], false, false);\n var peg$e4 = peg$literalExpectation(\",\", false);\n var peg$e5 = peg$literalExpectation(\"}\", false);\n var peg$e6 = peg$literalExpectation(\"(\", false);\n var peg$e7 = peg$literalExpectation(\")\", false);\n var peg$e8 = peg$anyExpectation();\n var peg$e9 = peg$literalExpectation(\".\", false);\n var peg$e10 = peg$literalExpectation(\"\\\\\", false);\n var peg$e11 = peg$classExpectation([[\"(\", \"+\"], [\"-\", \".\"], \"?\", [\"[\", \"^\"], \"n\", \"r\", \"t\", [\"{\", \"}\"]], false, false);\n var peg$e12 = peg$literalExpectation(\"[\", false);\n var peg$e13 = peg$literalExpectation(\"^\", false);\n var peg$e14 = peg$literalExpectation(\"-\", false);\n var peg$e15 = peg$literalExpectation(\"]\", false);\n var peg$e16 = peg$literalExpectation(\"\\\\p{\", false);\n var peg$e17 = peg$literalExpectation(\"\\\\P{\", false);\n var peg$e18 = peg$literalExpectation(\"L\", false);\n var peg$e19 = peg$classExpectation([[\"l\", \"m\"], \"o\", [\"t\", \"u\"]], false, false);\n var peg$e20 = peg$literalExpectation(\"M\", false);\n var peg$e21 = peg$classExpectation([\"c\", \"e\", \"n\"], false, false);\n var peg$e22 = peg$literalExpectation(\"N\", false);\n var peg$e23 = peg$classExpectation([\"d\", \"l\", \"o\"], false, false);\n var peg$e24 = peg$literalExpectation(\"P\", false);\n var peg$e25 = peg$classExpectation([[\"c\", \"f\"], \"i\", \"o\", \"s\"], false, false);\n var peg$e26 = peg$literalExpectation(\"Z\", false);\n var peg$e27 = peg$classExpectation([\"l\", \"p\", \"s\"], false, false);\n var peg$e28 = peg$literalExpectation(\"S\", false);\n var peg$e29 = peg$classExpectation([\"c\", \"k\", \"m\", \"o\"], false, false);\n var peg$e30 = peg$literalExpectation(\"C\", false);\n var peg$e31 = peg$classExpectation([\"c\", \"f\", [\"n\", \"o\"]], false, false);\n var peg$f0 = function (c) {\n return isNormalChar(c);\n };\n var peg$f1 = function (c) {\n return isCCChar(c);\n };\n var peg$currPos = options.peg$currPos | 0;\n var peg$posDetailsCache = [{\n line: 1,\n column: 1\n }];\n var peg$maxFailPos = peg$currPos;\n var peg$maxFailExpected = options.peg$maxFailExpected || [];\n var peg$silentFails = options.peg$silentFails | 0;\n var peg$result;\n if (options.startRule) {\n if (!(options.startRule in peg$startRuleFunctions)) {\n throw new Error(\"Can't start parsing from rule \\\"\" + options.startRule + \"\\\".\");\n }\n peg$startRuleFunction = peg$startRuleFunctions[options.startRule];\n }\n function peg$literalExpectation(text, ignoreCase) {\n return {\n type: \"literal\",\n text: text,\n ignoreCase: ignoreCase\n };\n }\n function peg$classExpectation(parts, inverted, ignoreCase) {\n return {\n type: \"class\",\n parts: parts,\n inverted: inverted,\n ignoreCase: ignoreCase\n };\n }\n function peg$anyExpectation() {\n return {\n type: \"any\"\n };\n }\n function peg$endExpectation() {\n return {\n type: \"end\"\n };\n }\n function peg$computePosDetails(pos) {\n var details = peg$posDetailsCache[pos];\n var p;\n if (details) {\n return details;\n } else {\n if (pos >= peg$posDetailsCache.length) {\n p = peg$posDetailsCache.length - 1;\n } else {\n p = pos;\n while (!peg$posDetailsCache[--p]) {}\n }\n details = peg$posDetailsCache[p];\n details = {\n line: details.line,\n column: details.column\n };\n while (p < pos) {\n if (input.charCodeAt(p) === 10) {\n details.line++;\n details.column = 1;\n } else {\n details.column++;\n }\n p++;\n }\n peg$posDetailsCache[pos] = details;\n return details;\n }\n }\n function peg$computeLocation(startPos, endPos, offset) {\n var startPosDetails = peg$computePosDetails(startPos);\n var endPosDetails = peg$computePosDetails(endPos);\n var res = {\n source: peg$source,\n start: {\n offset: startPos,\n line: startPosDetails.line,\n column: startPosDetails.column\n },\n end: {\n offset: endPos,\n line: endPosDetails.line,\n column: endPosDetails.column\n }\n };\n return res;\n }\n function peg$fail(expected) {\n if (peg$currPos < peg$maxFailPos) {\n return;\n }\n if (peg$currPos > peg$maxFailPos) {\n peg$maxFailPos = peg$currPos;\n peg$maxFailExpected = [];\n }\n peg$maxFailExpected.push(expected);\n }\n function peg$buildStructuredError(expected, found, location) {\n return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);\n }\n function peg$parsestart() {\n var s0;\n s0 = peg$parseiregexp();\n return s0;\n }\n function peg$parseiregexp() {\n var s0, s1, s2, s3, s4, s5;\n s0 = peg$currPos;\n s1 = peg$parsebranch();\n s2 = [];\n s3 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 124) {\n s4 = peg$c0;\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e0);\n }\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parsebranch();\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$FAILED;\n }\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 124) {\n s4 = peg$c0;\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e0);\n }\n }\n if (s4 !== peg$FAILED) {\n s5 = peg$parsebranch();\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$FAILED;\n }\n }\n s1 = [s1, s2];\n s0 = s1;\n return s0;\n }\n function peg$parsebranch() {\n var s0, s1;\n s0 = [];\n s1 = peg$parsepiece();\n while (s1 !== peg$FAILED) {\n s0.push(s1);\n s1 = peg$parsepiece();\n }\n return s0;\n }\n function peg$parsepiece() {\n var s0, s1, s2;\n s0 = peg$currPos;\n s1 = peg$parseatom();\n if (s1 !== peg$FAILED) {\n s2 = peg$parsequantifier();\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parsequantifier() {\n var s0;\n s0 = input.charAt(peg$currPos);\n if (peg$r0.test(s0)) {\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e1);\n }\n }\n if (s0 === peg$FAILED) {\n s0 = peg$parserange_quantifier();\n }\n return s0;\n }\n function peg$parserange_quantifier() {\n var s0, s1, s2, s3, s4, s5, s6;\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 123) {\n s1 = peg$c1;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e2);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = [];\n s3 = input.charAt(peg$currPos);\n if (peg$r1.test(s3)) {\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e3);\n }\n }\n if (s3 !== peg$FAILED) {\n while (s3 !== peg$FAILED) {\n s2.push(s3);\n s3 = input.charAt(peg$currPos);\n if (peg$r1.test(s3)) {\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e3);\n }\n }\n }\n } else {\n s2 = peg$FAILED;\n }\n if (s2 !== peg$FAILED) {\n s3 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 44) {\n s4 = peg$c2;\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e4);\n }\n }\n if (s4 !== peg$FAILED) {\n s5 = [];\n s6 = input.charAt(peg$currPos);\n if (peg$r1.test(s6)) {\n peg$currPos++;\n } else {\n s6 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e3);\n }\n }\n while (s6 !== peg$FAILED) {\n s5.push(s6);\n s6 = input.charAt(peg$currPos);\n if (peg$r1.test(s6)) {\n peg$currPos++;\n } else {\n s6 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e3);\n }\n }\n }\n s4 = [s4, s5];\n s3 = s4;\n } else {\n peg$currPos = s3;\n s3 = peg$FAILED;\n }\n if (s3 === peg$FAILED) {\n s3 = null;\n }\n if (input.charCodeAt(peg$currPos) === 125) {\n s4 = peg$c3;\n peg$currPos++;\n } else {\n s4 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e5);\n }\n }\n if (s4 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parseatom() {\n var s0, s1, s2, s3;\n s0 = peg$parsenormal_char();\n if (s0 === peg$FAILED) {\n s0 = peg$parsechar_class();\n if (s0 === peg$FAILED) {\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 40) {\n s1 = peg$c4;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e6);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parseiregexp();\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 41) {\n s3 = peg$c5;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e7);\n }\n }\n if (s3 !== peg$FAILED) {\n s1 = [s1, s2, s3];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n }\n }\n return s0;\n }\n function peg$parsenormal_char() {\n var s0, s1, s2;\n s0 = peg$currPos;\n if (input.length > peg$currPos) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e8);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$f0(s1);\n if (s2) {\n s2 = undefined;\n } else {\n s2 = peg$FAILED;\n }\n if (s2 !== peg$FAILED) {\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parsechar_class() {\n var s0;\n if (input.charCodeAt(peg$currPos) === 46) {\n s0 = peg$c6;\n peg$currPos++;\n } else {\n s0 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e9);\n }\n }\n if (s0 === peg$FAILED) {\n s0 = peg$parsesingle_char_esc();\n if (s0 === peg$FAILED) {\n s0 = peg$parsechar_class_esc();\n if (s0 === peg$FAILED) {\n s0 = peg$parsechar_class_expr();\n }\n }\n }\n return s0;\n }\n function peg$parsesingle_char_esc() {\n var s0, s1, s2;\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 92) {\n s1 = peg$c7;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e10);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = input.charAt(peg$currPos);\n if (peg$r2.test(s2)) {\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e11);\n }\n }\n if (s2 !== peg$FAILED) {\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parsechar_class_esc() {\n var s0;\n s0 = peg$parsecat_esc();\n if (s0 === peg$FAILED) {\n s0 = peg$parsecompl_esc();\n }\n return s0;\n }\n function peg$parsechar_class_expr() {\n var s0, s1, s2, s3, s4, s5, s6;\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 91) {\n s1 = peg$c8;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e12);\n }\n }\n if (s1 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 94) {\n s2 = peg$c9;\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e13);\n }\n }\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n if (input.charCodeAt(peg$currPos) === 45) {\n s3 = peg$c10;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e14);\n }\n }\n if (s3 === peg$FAILED) {\n s3 = peg$parsecce1();\n }\n if (s3 !== peg$FAILED) {\n s4 = [];\n s5 = peg$parsecce1();\n while (s5 !== peg$FAILED) {\n s4.push(s5);\n s5 = peg$parsecce1();\n }\n if (input.charCodeAt(peg$currPos) === 45) {\n s5 = peg$c10;\n peg$currPos++;\n } else {\n s5 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e14);\n }\n }\n if (s5 === peg$FAILED) {\n s5 = null;\n }\n if (input.charCodeAt(peg$currPos) === 93) {\n s6 = peg$c11;\n peg$currPos++;\n } else {\n s6 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e15);\n }\n }\n if (s6 !== peg$FAILED) {\n s1 = [s1, s2, s3, s4, s5, s6];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parsecce1() {\n var s0, s1, s2, s3, s4;\n s0 = peg$currPos;\n s1 = peg$parsecc_char();\n if (s1 !== peg$FAILED) {\n s2 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 45) {\n s3 = peg$c10;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e14);\n }\n }\n if (s3 !== peg$FAILED) {\n s4 = peg$parsecc_char();\n if (s4 !== peg$FAILED) {\n s3 = [s3, s4];\n s2 = s3;\n } else {\n peg$currPos = s2;\n s2 = peg$FAILED;\n }\n } else {\n peg$currPos = s2;\n s2 = peg$FAILED;\n }\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$parsechar_class_esc();\n }\n return s0;\n }\n function peg$parsecc_char() {\n var s0, s1, s2;\n s0 = peg$currPos;\n if (input.length > peg$currPos) {\n s1 = input.charAt(peg$currPos);\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e8);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$f1(s1);\n if (s2) {\n s2 = undefined;\n } else {\n s2 = peg$FAILED;\n }\n if (s2 !== peg$FAILED) {\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n if (s0 === peg$FAILED) {\n s0 = peg$parsesingle_char_esc();\n }\n return s0;\n }\n function peg$parsecat_esc() {\n var s0, s1, s2, s3;\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 3) === peg$c12) {\n s1 = peg$c12;\n peg$currPos += 3;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e16);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parseis_category();\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 125) {\n s3 = peg$c3;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e5);\n }\n }\n if (s3 !== peg$FAILED) {\n s1 = [s1, s2, s3];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parsecompl_esc() {\n var s0, s1, s2, s3;\n s0 = peg$currPos;\n if (input.substr(peg$currPos, 3) === peg$c13) {\n s1 = peg$c13;\n peg$currPos += 3;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e17);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = peg$parseis_category();\n if (s2 !== peg$FAILED) {\n if (input.charCodeAt(peg$currPos) === 125) {\n s3 = peg$c3;\n peg$currPos++;\n } else {\n s3 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e5);\n }\n }\n if (s3 !== peg$FAILED) {\n s1 = [s1, s2, s3];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parseis_category() {\n var s0;\n s0 = peg$parseletters();\n if (s0 === peg$FAILED) {\n s0 = peg$parsemarks();\n if (s0 === peg$FAILED) {\n s0 = peg$parsenumbers();\n if (s0 === peg$FAILED) {\n s0 = peg$parsepunctuation();\n if (s0 === peg$FAILED) {\n s0 = peg$parseseparators();\n if (s0 === peg$FAILED) {\n s0 = peg$parsesymbols();\n if (s0 === peg$FAILED) {\n s0 = peg$parseothers();\n }\n }\n }\n }\n }\n }\n return s0;\n }\n function peg$parseletters() {\n var s0, s1, s2;\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 76) {\n s1 = peg$c14;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e18);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = input.charAt(peg$currPos);\n if (peg$r3.test(s2)) {\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e19);\n }\n }\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parsemarks() {\n var s0, s1, s2;\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 77) {\n s1 = peg$c15;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e20);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = input.charAt(peg$currPos);\n if (peg$r4.test(s2)) {\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e21);\n }\n }\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parsenumbers() {\n var s0, s1, s2;\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 78) {\n s1 = peg$c16;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e22);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = input.charAt(peg$currPos);\n if (peg$r5.test(s2)) {\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e23);\n }\n }\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parsepunctuation() {\n var s0, s1, s2;\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 80) {\n s1 = peg$c17;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e24);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = input.charAt(peg$currPos);\n if (peg$r6.test(s2)) {\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e25);\n }\n }\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parseseparators() {\n var s0, s1, s2;\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 90) {\n s1 = peg$c18;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e26);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = input.charAt(peg$currPos);\n if (peg$r7.test(s2)) {\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e27);\n }\n }\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parsesymbols() {\n var s0, s1, s2;\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 83) {\n s1 = peg$c19;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e28);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = input.charAt(peg$currPos);\n if (peg$r8.test(s2)) {\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e29);\n }\n }\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n function peg$parseothers() {\n var s0, s1, s2;\n s0 = peg$currPos;\n if (input.charCodeAt(peg$currPos) === 67) {\n s1 = peg$c20;\n peg$currPos++;\n } else {\n s1 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e30);\n }\n }\n if (s1 !== peg$FAILED) {\n s2 = input.charAt(peg$currPos);\n if (peg$r9.test(s2)) {\n peg$currPos++;\n } else {\n s2 = peg$FAILED;\n if (peg$silentFails === 0) {\n peg$fail(peg$e31);\n }\n }\n if (s2 === peg$FAILED) {\n s2 = null;\n }\n s1 = [s1, s2];\n s0 = s1;\n } else {\n peg$currPos = s0;\n s0 = peg$FAILED;\n }\n return s0;\n }\n peg$result = peg$startRuleFunction();\n if (options.peg$library) {\n return /** @type {any} */{\n peg$result,\n peg$currPos,\n peg$FAILED,\n peg$maxFailExpected,\n peg$maxFailPos\n };\n }\n if (peg$result !== peg$FAILED && peg$currPos === input.length) {\n return peg$result;\n } else {\n if (peg$result !== peg$FAILED && peg$currPos < input.length) {\n peg$fail(peg$endExpectation());\n }\n throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));\n }\n}\nvar iregexp$1 = {\n StartRules: [\"start\"],\n SyntaxError: peg$SyntaxError,\n parse: peg$parse\n};\n\nconst iregexp = iregexp$1;\n\n/**\n * Return _true_ if _pattern_ is a valid I-Regexp\n * @param {string} pattern - Regular expression pattern to check.\n * @returns true if _pattern_ is valid, or false otherwise.\n */\nfunction check(pattern) {\n try {\n iregexp.parse(pattern, {});\n } catch (error) {\n if (error instanceof iregexp.SyntaxError) {\n return false;\n }\n throw error;\n }\n return true;\n}\nvar check_1 = {\n check\n};\n\nconst version = \"0.1.2\";\n\nvar check$1 = check_1.check;\nexport { check$1 as check, version };\n","import { isString } from \"../../types\";\nimport { IRegexpError } from \"../errors\";\nimport { LRUCache } from \"../lru_cache\";\nimport { FilterFunction, FunctionExpressionType } from \"./function\";\nimport { fullMatch } from \"./pattern\";\nimport { check } from \"iregexp-check\";\n\nexport type MatchFilterFunctionOptions = {\n /**\n * The maximum number of regular expressions to cache.\n */\n cacheSize?: number;\n\n /**\n * If _true_, throw errors from regex checking, construction and matching.\n * The standard and default behavior is to ignore these errors and return\n * _false_.\n */\n throwErrors?: boolean;\n\n /**\n * If _true_, check that regexp patterns are valid according to I-Regexp.\n * The standard and default behavior is to silently return _false_ if a\n * pattern is invalid.\n *\n * If `iRegexpCheck` is _true_ and `throwErrors` is _true_, an `IRegexpError`\n * will be thrown.\n */\n iRegexpCheck?: boolean;\n};\n\nexport class Match implements FilterFunction {\n readonly argTypes = [\n FunctionExpressionType.ValueType,\n FunctionExpressionType.ValueType,\n ];\n\n readonly returnType = FunctionExpressionType.LogicalType;\n\n readonly cacheSize: number;\n readonly throwErrors: boolean;\n readonly iRegexpCheck: boolean;\n #cache: LRUCache<string, RegExp>;\n\n constructor(readonly options: MatchFilterFunctionOptions = {}) {\n this.cacheSize = options.cacheSize ?? 10;\n this.throwErrors = options.throwErrors ?? false;\n this.iRegexpCheck = options.iRegexpCheck ?? true;\n this.#cache = new LRUCache(this.cacheSize);\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n public call(s: string, pattern: string): boolean {\n if (this.cacheSize > 0) {\n const re = this.#cache.get(pattern);\n if (re) {\n try {\n return re.test(s);\n } catch (error) {\n if (this.throwErrors) throw error;\n return false;\n }\n }\n }\n\n if (!isString(pattern)) {\n if (this.throwErrors) {\n throw new IRegexpError(\n `match() expected a string pattern, found ${pattern}`,\n );\n }\n return false;\n }\n\n if (this.iRegexpCheck && !check(pattern)) {\n if (this.throwErrors) {\n throw new IRegexpError(\n `pattern ${pattern} is not a valid I-Regexp pattern`,\n );\n }\n return false;\n }\n\n try {\n const re = new RegExp(fullMatch(pattern), \"u\");\n if (this.cacheSize > 0) this.#cache.set(pattern, re);\n return re.test(s);\n } catch (error) {\n if (this.throwErrors) throw error;\n return false;\n }\n }\n}\n","import { check } from \"iregexp-check\";\nimport { LRUCache } from \"../lru_cache\";\nimport { FilterFunction, FunctionExpressionType } from \"./function\";\nimport { mapRegexp } from \"./pattern\";\nimport { IRegexpError } from \"../errors\";\nimport { isString } from \"../../types\";\n\nexport type SearchFilterFunctionOptions = {\n /**\n * The maximum number of regular expressions to cache. Defaults\n * to 10.\n */\n cacheSize?: number;\n\n /**\n * If _true_, throw errors from regex construction and matching.\n * The standard and default behavior is to ignore these errors\n * and return _false_.\n */\n throwErrors?: boolean;\n\n /**\n * If _true_, check that regexp patterns are valid according to I-Regexp.\n * The standard and default behavior is to silently return _false_ if a\n * pattern is invalid.\n *\n * If `iRegexpCheck` is _true_ and `throwErrors` is _true_, an `IRegexpError`\n * will be thrown.\n */\n iRegexpCheck?: boolean;\n};\n\nexport class Search implements FilterFunction {\n readonly argTypes = [\n FunctionExpressionType.ValueType,\n FunctionExpressionType.ValueType,\n ];\n\n readonly returnType = FunctionExpressionType.LogicalType;\n\n readonly cacheSize: number;\n readonly throwErrors: boolean;\n readonly iRegexpCheck: boolean;\n #cache: LRUCache<string, RegExp>;\n\n constructor(readonly options: SearchFilterFunctionOptions = {}) {\n this.cacheSize = options.cacheSize ?? 10;\n this.throwErrors = options.throwErrors ?? false;\n this.iRegexpCheck = options.iRegexpCheck ?? true;\n this.#cache = new LRUCache(this.cacheSize);\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n public call(s: string, pattern: string): boolean {\n if (this.cacheSize > 0) {\n const re = this.#cache.get(pattern);\n if (re) {\n try {\n return !!s.match(re);\n } catch (error) {\n if (this.throwErrors) throw error;\n return false;\n }\n }\n }\n\n if (!isString(pattern)) {\n if (this.throwErrors) {\n throw new IRegexpError(\n `match() expected a string pattern, found ${pattern}`,\n );\n }\n return false;\n }\n\n if (this.iRegexpCheck && !check(pattern)) {\n if (this.throwErrors) {\n throw new IRegexpError(\n `pattern ${pattern} is not a valid I-Regexp pattern`,\n );\n }\n return false;\n }\n\n try {\n const re = new RegExp(mapRegexp(pattern), \"u\");\n if (this.cacheSize > 0) this.#cache.set(pattern, re);\n return !!s.match(re);\n } catch (error) {\n if (this.throwErrors) throw error;\n return false;\n }\n }\n}\n","import { JSONPathNodeList } from \"../node\";\nimport { Nothing } from \"../types\";\nimport { FilterFunction, FunctionExpressionType } from \"./function\";\n\nexport class Value implements FilterFunction {\n readonly argTypes = [FunctionExpressionType.NodesType];\n readonly returnType = FunctionExpressionType.ValueType;\n\n public call(nodes: JSONPathNodeList): unknown {\n if (nodes.length === 1) return nodes.nodes[0].value;\n return Nothing;\n }\n}\n","import { JSONPathSyntaxError } from \"./errors\";\n\n/**\n *\n */\nexport enum TokenKind {\n AND = \"TOKEN_AND\",\n COLON = \"TOKEN_COLON\",\n COMMA = \"TOKEN_COMMA\",\n CURRENT = \"TOKEN_CURRENT_VALUE\",\n CURRENT_KEY = \"TOKEN_CURRENT_KEY\", // non-standard, default `#`\n DDOT = \"TOKEN_DDOT\",\n DOT = \"TOKEN_DOT\",\n DOUBLE_QUOTE_STRING = \"TOKEN_DOUBLE_QUOTE_STRING\",\n EOF = \"TOKEN_EOF\",\n EQ = \"TOKEN_EQ\",\n ERROR = \"TOKEN_ERROR\",\n FALSE = \"TOKEN_FALSE\",\n FILTER = \"TOKEN_FILTER_START\",\n FUNCTION = \"TOKEN_FUNCTION\",\n GE = \"TOKEN_GE\",\n GT = \"TOKEN_GT\",\n INDEX = \"TOKEN_INDEX\",\n KEY = \"TOKEN_KEY\", // non-standard, default `~<name>`\n KEY_DOUBLE_QUOTE_STRING = \"TOKEN_KEY_DOUBLE_QUOTE_STRING\", // non-standard, `~\"<name>\"`\n KEY_SINGLE_QUOTE_STRING = \"TOKEN_KEY_SINGLE_QUOTE_STRING\", // non-standard, `~'<name>'`\n KEYS = \"TOKEN_KEYS\", // non-standard, default `~`\n KEYS_FILTER = \"TOKEN_KEYS_FILTER\", // non-standard, `~?<expression>`\n LBRACKET = \"TOKEN_LBRACKET\",\n LE = \"TOKEN_LE\",\n LG = \"TOKEN_LG\",\n LPAREN = \"TOKEN_LPAREN\",\n LT = \"TOKEN_LT\",\n NAME = \"TOKEN_NAME\",\n NE = \"TOKEN_NE\",\n NOT = \"TOKEN_NOT\",\n NULL = \"TOKEN_NULL\",\n NUMBER = \"NUMBER\",\n OR = \"TOKEN_OR\",\n RBRACKET = \"TOKEN_RBRACKET\",\n ROOT = \"TOKEN_ROOT\",\n RPAREN = \"TOKEN_RPAREN\",\n SINGLE_QUOTE_STRING = \"TOKEN_SINGLE_QUOTE_STRING\",\n TRUE = \"TOKEN_TRUE\",\n WILD = \"TOKEN_WILD\",\n}\n\n/**\n *\n */\nexport class Token {\n constructor(\n readonly kind: TokenKind,\n readonly value: string,\n readonly index: number,\n readonly input: string,\n ) {}\n}\n\nexport const EOF = new Token(TokenKind.EOF, \"\", -1, \"\");\n\n/**\n *\n */\nexport class TokenStream {\n #pos: number = 0;\n\n constructor(private tokens: Token[]) {}\n\n public get current(): Token {\n return this.tokens[this.#pos];\n }\n\n public get peek(): Token {\n if (this.#pos >= this.tokens.length - 1)\n return this.tokens[this.tokens.length - 1];\n return this.tokens[this.#pos + 1];\n }\n\n public next(): Token {\n const current = this.current;\n this.#pos += 1;\n return current;\n }\n\n public backup(): void {\n if (this.#pos > 0) this.#pos -= 1;\n }\n\n public expect(kind: TokenKind): void {\n if (this.current.kind !== kind) {\n throw new JSONPathSyntaxError(\n `expected token '${kind}', found '${this.current.kind}'`,\n this.current,\n );\n }\n }\n\n public expectPeek(kind: TokenKind): void {\n const peeked = this.peek;\n if (peeked.kind !== kind) {\n throw new JSONPathSyntaxError(\n `expected token '${kind}', found '${peeked.kind}'`,\n peeked,\n );\n }\n }\n\n public expectPeekNot(kind: TokenKind, message: string): void {\n const peeked = this.peek;\n if (peeked.kind === kind) {\n throw new JSONPathSyntaxError(message, peeked);\n }\n }\n}\n","/** A lexer that accepts additional, non-standard tokens. */\nimport { JSONPathEnvironment } from \"./environment\";\nimport { JSONPathLexerError, JSONPathSyntaxError } from \"./errors\";\nimport { Token, TokenKind } from \"./token\";\n\n// These regular expressions are to be used with Lexer.acceptMatchRun(),\n// which expects the sticky flag to be set.\nconst exponentPattern = /[eE][+-]?\\d+/y;\nconst functionNamePattern = /[a-z][a-z_0-9]*/y;\nconst indexPattern = /-?\\d+/y;\nconst intPattern = /-?\\d+/y;\nconst namePattern = /[\\u0080-\\uFFFFa-zA-Z_][\\u0080-\\uFFFFa-zA-Z0-9_-]*/y;\n\nconst whitespace = new Set([\" \", \"\\n\", \"\\t\", \"\\r\"]);\nconst nameFirstPattern = /[\\u0080-\\uFFFFa-zA-Z_]/; // don't set sticky bit\n\n/**\n * JSONPath lexical scanner.\n *\n * Lexer state is shared between this class and the current state function. A\n * new _Lexer_ instance is automatically created every time a path is tokenized.\n *\n * Use {@link tokenize} to get an array of {@link Token}'s for a JSONPath query.\n */\nclass Lexer {\n /**\n * Filter nesting level.\n */\n public filterLevel: number = 0;\n\n /**\n * A running count of parentheses for each, possibly nested, function call.\n *\n * If the stack is empty, we are not in a function call. Remember that\n * function arguments can use arbitrarily nested in parentheses.\n */\n public funcCallStack: number[] = [];\n\n /**\n * A stack of parentheses and square brackets used to check for balanced\n * brackets.\n */\n public bracketStack: Array<[string, number]> = [];\n\n /** Tokens resulting from tokenizing a JSONPath query. */\n public tokens: Token[] = [];\n\n #start: number = 0;\n #pos: number = 0;\n\n /**\n * @param path - A JSONPath query.\n */\n constructor(\n readonly environment: JSONPathEnvironment,\n readonly path: string,\n ) {}\n\n public get pos(): number {\n return this.#pos;\n }\n\n public get start(): number {\n return this.#start;\n }\n\n public run(): void {\n let state: StateFn | null = lexRoot;\n while (state) {\n state = state(this);\n }\n }\n\n public emit(t: TokenKind): void {\n this.tokens.push(\n new Token(\n t,\n this.path.slice(this.#start, this.#pos),\n this.#start,\n this.path,\n ),\n );\n this.#start = this.#pos;\n }\n\n public next(): string {\n if (this.#pos >= this.path.length) return \"\";\n const s = this.path[this.#pos];\n this.#pos += 1;\n return s;\n }\n\n public ignore(): void {\n this.#start = this.#pos;\n }\n\n public backup(): void {\n if (this.#pos <= this.#start) {\n const msg = \"can't backup beyond start\";\n throw new JSONPathLexerError(\n msg,\n new Token(TokenKind.ERROR, msg, this.#pos, this.path),\n );\n }\n this.#pos -= 1;\n }\n\n public peek(): string {\n const ch = this.next();\n if (ch) this.backup();\n return ch;\n }\n\n public peekMatch(pattern: RegExp): boolean {\n const ch = this.next();\n if (ch) this.backup();\n return pattern.test(ch);\n }\n\n public accept(valid: Set<string>): boolean {\n const ch = this.next();\n if (valid.has(ch)) return true;\n if (ch) this.backup();\n return false;\n }\n\n public acceptMatch(pattern: RegExp): boolean {\n const ch = this.next();\n if (pattern.test(ch)) return true;\n if (ch) this.backup();\n return false;\n }\n\n public acceptRun(valid: Set<string>): boolean {\n let found = false;\n let ch = this.next();\n while (valid.has(ch)) {\n ch = this.next();\n found = true;\n }\n if (ch) this.backup();\n return found;\n }\n\n public acceptMatchRun(pattern: RegExp): boolean {\n pattern.lastIndex = this.#pos;\n const match = pattern.exec(this.path);\n pattern.lastIndex = 0;\n if (match) {\n this.#pos += match[0].length;\n return true;\n }\n return false;\n }\n\n public ignoreWhitespace(): boolean {\n if (this.#pos !== this.#start) {\n const msg = `must emit or ignore before consuming whitespace ('${this.path.slice(\n this.#start,\n this.#pos,\n )}':${this.pos})`;\n\n throw new JSONPathLexerError(\n msg,\n new Token(TokenKind.ERROR, msg, this.pos, this.path),\n );\n }\n if (this.acceptRun(whitespace)) {\n this.ignore();\n return true;\n }\n return false;\n }\n\n public error(msg: string): void {\n this.tokens.push(new Token(TokenKind.ERROR, msg, this.#pos, this.path));\n }\n}\n\ntype StateFn = (l: Lexer) => StateFn | null;\n\n/**\n * Return a lexer for _path_ and an array to be populated with Tokens.\n *\n * `lexer.run()` must be called to populate the returned tokens array.\n *\n * You probably want to use {@link tokenize} instead of _lex_. This function\n * is mostly for internal use, where we want to test the state of the returned\n * _lexer_ after tokens have been populated.\n *\n * @param path - A JSONPath query.\n * @returns A two-tuple containing a lexer for _path_ and an array to populate\n * with tokens.\n */\nexport function lex(\n environment: JSONPathEnvironment,\n path: string,\n): [Lexer, Token[]] {\n const lexer = new Lexer(environment, path);\n return [lexer, lexer.tokens];\n}\n\n/**\n * Scan _path_ and return an array of tokens to be parsed by the parser.\n * @param path - A JSONPath query.\n * @returns Tokens to be parsed by the parser.\n */\nexport function tokenize(\n environment: JSONPathEnvironment,\n path: string,\n): Token[] {\n const [lexer, tokens] = lex(environment, path);\n lexer.run();\n\n // If there's an error, it will be the last token with kind set to ERROR.\n if (tokens.length && tokens[tokens.length - 1].kind === TokenKind.ERROR) {\n throw new JSONPathSyntaxError(\n tokens[tokens.length - 1].value,\n tokens[tokens.length - 1],\n );\n }\n\n // If the bracket stack is not empty, we hav unbalanced brackets.\n // This might not be reachable.\n if (lexer.bracketStack.length !== 0) {\n const [ch, index] = lexer.bracketStack[lexer.bracketStack.length - 1];\n const msg = \"unbalanced brackets\";\n throw new JSONPathSyntaxError(\n msg,\n new Token(TokenKind.ERROR, ch, index, path),\n );\n }\n\n return tokens;\n}\n\nfunction lexRoot(l: Lexer): StateFn | null {\n const ch = l.next();\n if (ch !== \"$\") {\n l.backup();\n l.error(`expected '$', found '${ch}'`);\n return null;\n }\n l.emit(TokenKind.ROOT);\n return lexSegment;\n}\n\nfunction lexSegment(l: Lexer): StateFn | null {\n if (l.ignoreWhitespace() && !l.peek()) {\n l.error(\"trailing whitespace\");\n }\n const ch = l.next();\n switch (ch) {\n case \"\":\n l.emit(TokenKind.EOF);\n return null;\n case \".\":\n if (l.peek() === \".\") {\n l.next();\n l.emit(TokenKind.DDOT);\n return lexDescendantSelection;\n }\n return lexDotSelector;\n case \"[\":\n l.bracketStack.push([\"[\", l.start]);\n l.emit(TokenKind.LBRACKET);\n return lexInsideBracketedSelection;\n default:\n l.backup();\n if (l.filterLevel) return lexInsideFilter;\n l.error(`expected '.', '..' or a bracketed selection, found '${ch}'`);\n return null;\n }\n}\n\n/**\n * Similar to _lexSegment_, but ..\n * - no leading whitespace\n * - no extra dot before a property name\n * - there must be a selector, so EOF would be an error\n * @param l -\n * @returns -\n */\nfunction lexDescendantSelection(l: Lexer): StateFn | null {\n if (l.acceptMatchRun(namePattern)) {\n // Shorthand name\n l.emit(TokenKind.NAME);\n return lexSegment;\n }\n\n if (!l.environment.strict) {\n // We're effectively disabling the _key selector_ and _keys filter selector_ if a\n // custom _keys selector_ is set.\n if (l.environment.keysPattern.source === \"~\" && l.peek() === \"~\") {\n l.next();\n if (l.peekMatch(nameFirstPattern)) {\n // Non-standard key selector\n l.ignore(); // ignore ~\n l.acceptMatchRun(namePattern);\n l.emit(TokenKind.KEY);\n return lexSegment;\n } else {\n // Non-standard keys selector\n l.emit(TokenKind.KEYS);\n return lexSegment;\n }\n } else if (l.acceptMatchRun(l.environment.keysPattern)) {\n // NOTE: A custom keys pattern does not play well with other non-standard key selectors.\n // We leave this here for backwards compatibility.\n l.emit(TokenKind.KEYS);\n return lexSegment;\n }\n }\n\n const ch = l.next();\n switch (ch) {\n case \"\":\n l.error(\"bald descendant segment\");\n return null;\n case \"*\":\n l.emit(TokenKind.WILD);\n return lexSegment;\n case \"[\":\n l.bracketStack.push([\"[\", l.start]);\n l.emit(TokenKind.LBRACKET);\n return lexInsideBracketedSelection;\n default:\n l.backup();\n l.error(`unexpected descendent selection token '${ch}'`);\n return null;\n }\n}\n\nfunction lexDotSelector(l: Lexer): StateFn | null {\n l.ignore();\n\n if (l.ignoreWhitespace()) {\n l.error(\"unexpected whitespace after dot\");\n return null;\n }\n\n if (!l.environment.strict) {\n // We're effectively disabling the _key selector_ and _keys filter selector_ if a\n // custom _keys selector_ is set.\n if (l.environment.keysPattern.source === \"~\" && l.peek() === \"~\") {\n l.next();\n if (l.peekMatch(nameFirstPattern)) {\n // Non-standard key selector\n l.ignore(); // ignore ~\n l.acceptMatchRun(namePattern);\n l.emit(TokenKind.KEY);\n return lexSegment;\n } else {\n // Non-standard keys selector\n l.emit(TokenKind.KEYS);\n return lexSegment;\n }\n } else if (l.acceptMatchRun(l.environment.keysPattern)) {\n // NOTE: A custom keys pattern does not play well with other non-standard key selectors.\n // We leave this here for backwards compatibility.\n l.emit(TokenKind.KEYS);\n return lexSegment;\n }\n }\n\n if (l.acceptMatchRun(namePattern)) {\n l.emit(TokenKind.NAME);\n return lexSegment;\n }\n\n const ch = l.next();\n if (ch === \"*\") {\n l.emit(TokenKind.WILD);\n return lexSegment;\n }\n\n l.backup();\n l.error(`unexpected shorthand selector '${ch}'`);\n return null;\n}\n\nfunction lexInsideBracketedSelection(l: Lexer): StateFn | null {\n for (;;) {\n l.ignoreWhitespace();\n\n if (l.acceptMatchRun(indexPattern)) {\n l.emit(TokenKind.INDEX);\n continue;\n }\n\n if (!l.environment.strict && l.acceptMatchRun(l.environment.keysPattern)) {\n switch (l.peek()) {\n case \"'\":\n l.ignore(); // ~\n l.next();\n return lexSingleQuoteKeyString(l);\n case '\"':\n l.ignore(); // ~\n l.next();\n return lexDoubleQuoteKeyString(l);\n case \"?\":\n l.next();\n l.emit(TokenKind.KEYS_FILTER);\n l.filterLevel += 1;\n return lexInsideFilter;\n default:\n l.emit(TokenKind.KEYS);\n continue;\n }\n }\n\n const ch = l.next();\n switch (ch) {\n case \"]\":\n if (\n l.bracketStack.length === 0 ||\n l.bracketStack[l.bracketStack.length - 1][0] !== \"[\"\n ) {\n l.backup();\n l.error(\"unbalanced brackets\");\n return null;\n }\n\n l.bracketStack.pop();\n l.emit(TokenKind.RBRACKET);\n return lexSegment;\n case \"\":\n l.error(\"unclosed bracketed selection\");\n return null;\n case \"*\":\n l.emit(TokenKind.WILD);\n continue;\n case \"?\":\n l.emit(TokenKind.FILTER);\n l.filterLevel += 1;\n return lexInsideFilter;\n case \",\":\n l.emit(TokenKind.COMMA);\n continue;\n case \":\":\n l.emit(TokenKind.COLON);\n continue;\n case \"'\":\n return lexSingleQuoteStringInsideBracketSelection;\n case '\"':\n return lexDoubleQuoteStringInsideBracketSelection;\n default:\n l.backup();\n l.error(`unexpected token '${ch}' in bracketed selection`);\n return null;\n }\n }\n}\n\n// eslint-disable-next-line sonarjs/cognitive-complexity\nfunction lexInsideFilter(l: Lexer): StateFn | null {\n for (;;) {\n l.ignoreWhitespace();\n const ch = l.next();\n switch (ch) {\n case \"\":\n l.error(\"unclosed bracketed selection\");\n return null;\n case \"]\":\n l.filterLevel -= 1;\n l.backup();\n return lexInsideBracketedSelection;\n case \",\":\n l.emit(TokenKind.COMMA);\n // If we have unbalanced parens, we are inside a function call and a\n // comma separates arguments. Otherwise a comma separates selectors.\n if (l.funcCallStack.length) continue;\n l.filterLevel -= 1;\n return lexInsideBracketedSelection;\n case \"'\":\n return lexSingleQuoteStringInsideFilterExpression;\n case '\"':\n return lexDoubleQuoteStringInsideFilterExpression;\n case \"(\":\n l.bracketStack.push([\"(\", l.start]);\n l.emit(TokenKind.LPAREN);\n // Are we in a function call? If so, a function argument contains parens.\n if (l.funcCallStack.length)\n l.funcCallStack[l.funcCallStack.length - 1] += 1;\n continue;\n case \")\":\n if (\n l.bracketStack.length === 0 ||\n l.bracketStack[l.bracketStack.length - 1][0] !== \"(\"\n ) {\n l.backup();\n l.error(\"unbalanced brackets\");\n return null;\n }\n\n l.bracketStack.pop();\n l.emit(TokenKind.RPAREN);\n // Are we closing a function call or a parenthesized expression?\n if (l.funcCallStack.length) {\n if (l.funcCallStack[l.funcCallStack.length - 1] === 1) {\n l.funcCallStack.pop();\n } else {\n l.funcCallStack[l.funcCallStack.length - 1] -= 1;\n }\n }\n continue;\n case \"$\":\n l.emit(TokenKind.ROOT);\n return lexSegment;\n case \"@\":\n l.emit(TokenKind.CURRENT);\n return lexSegment;\n case \"#\":\n if (l.environment.strict) {\n l.backup();\n l.error(`unexpected filter selector token '${ch}'`);\n return null;\n }\n l.emit(TokenKind.CURRENT_KEY);\n return lexSegment;\n case \".\":\n l.backup();\n return lexSegment;\n case \"!\":\n if (l.peek() === \"=\") {\n l.next();\n l.emit(TokenKind.NE);\n } else {\n l.emit(TokenKind.NOT);\n }\n continue;\n case \"=\":\n if (l.peek() === \"=\") {\n l.next();\n l.emit(TokenKind.EQ);\n continue;\n } else {\n l.backup();\n l.error(`unexpected filter selector token '${ch}'`);\n return null;\n }\n case \"<\":\n if (l.peek() === \"=\") {\n l.next();\n l.emit(TokenKind.LE);\n } else {\n l.emit(TokenKind.LT);\n }\n continue;\n case \">\":\n if (l.peek() === \"=\") {\n l.next();\n l.emit(TokenKind.GE);\n } else {\n l.emit(TokenKind.GT);\n }\n continue;\n default:\n l.backup();\n\n // numbers\n if (l.acceptMatchRun(intPattern)) {\n if (l.peek() === \".\") {\n // A float.\n l.next();\n if (!l.acceptMatchRun(intPattern)) {\n // Need at least one digit after a decimal place.\n l.error(\"a fractional digit is required after a decimal point\");\n return null;\n }\n }\n l.acceptMatchRun(exponentPattern);\n l.emit(TokenKind.NUMBER);\n continue;\n }\n\n if (l.acceptMatchRun(/&&/y)) {\n l.emit(TokenKind.AND);\n continue;\n }\n\n if (l.acceptMatchRun(/\\|\\|/y)) {\n l.emit(TokenKind.OR);\n continue;\n }\n\n if (l.acceptMatchRun(/true/y)) {\n l.emit(TokenKind.TRUE);\n continue;\n }\n if (l.acceptMatchRun(/false/y)) {\n l.emit(TokenKind.FALSE);\n continue;\n }\n\n if (l.acceptMatchRun(/null/y)) {\n l.emit(TokenKind.NULL);\n continue;\n }\n\n // functions\n if (l.acceptMatchRun(functionNamePattern) && l.peek() === \"(\") {\n // Keep track of parentheses for this function call.\n l.funcCallStack.push(1);\n l.emit(TokenKind.FUNCTION);\n l.bracketStack.push([\"(\", l.start]);\n l.next();\n l.ignore();\n continue;\n }\n }\n\n l.error(`unexpected filter selector token '${ch}'`);\n return null;\n }\n}\n\n/**\n * Return a state function tokenizing string literals using _quote_ and\n * returning control to _state_.\n * @param quote - One of `'` or `\"`.\n * @param state - The state function to return control to.\n * @returns String tokenizing state function.\n */\nfunction makeLexString(\n quote: string,\n state: StateFn,\n token_kind: TokenKind,\n): StateFn {\n function _lexString(l: Lexer): StateFn | null {\n l.ignore();\n\n if (l.peek() === quote) {\n // empty string\n l.emit(\n quote === \"'\"\n ? TokenKind.SINGLE_QUOTE_STRING\n : TokenKind.DOUBLE_QUOTE_STRING,\n );\n l.next();\n l.ignore();\n return state;\n }\n\n for (;;) {\n const la = l.path.slice(l.pos, l.pos + 2);\n const ch = l.next();\n if (la === \"\\\\\\\\\" || la === `\\\\${quote}`) {\n l.next();\n continue;\n } else if (ch === \"\\\\\" && !la.match(/\\\\[bfnrtu/]/)) {\n l.error(`invalid escape`);\n return null;\n }\n\n if (!ch) {\n l.error(`unclosed string starting at index ${l.start}`);\n return null;\n }\n\n if (ch === quote) {\n l.backup();\n l.emit(token_kind);\n l.next();\n l.ignore();\n return state;\n }\n }\n }\n return _lexString;\n}\n\nconst lexSingleQuoteStringInsideBracketSelection = makeLexString(\n \"'\",\n lexInsideBracketedSelection,\n TokenKind.SINGLE_QUOTE_STRING,\n);\n\nconst lexDoubleQuoteStringInsideBracketSelection = makeLexString(\n '\"',\n lexInsideBracketedSelection,\n TokenKind.DOUBLE_QUOTE_STRING,\n);\n\nconst lexSingleQuoteStringInsideFilterExpression = makeLexString(\n \"'\",\n lexInsideFilter,\n TokenKind.SINGLE_QUOTE_STRING,\n);\n\nconst lexDoubleQuoteStringInsideFilterExpression = makeLexString(\n '\"',\n lexInsideFilter,\n TokenKind.DOUBLE_QUOTE_STRING,\n);\n\nconst lexSingleQuoteKeyString = makeLexString(\n \"'\",\n lexInsideBracketedSelection,\n TokenKind.KEY_SINGLE_QUOTE_STRING,\n);\n\nconst lexDoubleQuoteKeyString = makeLexString(\n '\"',\n lexInsideBracketedSelection,\n TokenKind.KEY_DOUBLE_QUOTE_STRING,\n);\n","import { JSONPathEnvironment } from \"./environment\";\nimport { JSONPathIndexError } from \"./errors\";\nimport { LogicalExpression } from \"./expression\";\nimport { JSONPathNode } from \"./node\";\nimport { Token } from \"./token\";\nimport {\n type FilterContext,\n type SerializationOptions,\n defaultSerializationOptions,\n hasStringKey,\n} from \"./types\";\nimport { isArray, isObject, isString, JSONValue } from \"../types\";\nimport { toCanonical, toQuoted, toShorthand } from \"./serialize\";\n\n/**\n * Base class for all JSONPath segments and selectors.\n */\nexport abstract class JSONPathSelector {\n /**\n * @param token - The token at the start of this selector.\n */\n constructor(\n readonly environment: JSONPathEnvironment,\n readonly token: Token,\n ) {}\n\n /**\n * @param node - Nodes matched by preceding selectors.\n */\n public abstract resolve(node: JSONPathNode): JSONPathNode[];\n\n /**\n * @param node - Nodes matched by preceding selectors.\n */\n public abstract lazyResolve(node: JSONPathNode): Generator<JSONPathNode>;\n\n /**\n * Return a canonical string representation of this selector.\n */\n public abstract toString(options?: SerializationOptions): string;\n}\n\n/**\n * Shorthand and quoted name selector.\n */\nexport class NameSelector extends JSONPathSelector {\n constructor(\n readonly environment: JSONPathEnvironment,\n readonly token: Token,\n readonly name: string,\n ) {\n super(environment, token);\n }\n\n public resolve(node: JSONPathNode): JSONPathNode[] {\n const rv: JSONPathNode[] = [];\n if (!isArray(node.value) && hasStringKey(node.value, this.name)) {\n rv.push(\n new JSONPathNode(\n node.value[this.name],\n node.location.concat(this.name),\n node.root,\n ),\n );\n }\n return rv;\n }\n\n public *lazyResolve(node: JSONPathNode): Generator<JSONPathNode> {\n if (!isArray(node.value) && hasStringKey(node.value, this.name)) {\n yield new JSONPathNode(\n node.value[this.name],\n node.location.concat(this.name),\n node.root,\n );\n }\n }\n\n public toString(options?: SerializationOptions): string {\n const { form } = { ...defaultSerializationOptions, ...options };\n return form === \"canonical\" ? toCanonical(this.name) : toQuoted(this.name);\n }\n\n public shorthand(): string | null {\n return toShorthand(this.name);\n }\n}\n\n/**\n * Array index selector.\n */\nexport class IndexSelector extends JSONPathSelector {\n constructor(\n readonly environment: JSONPathEnvironment,\n readonly token: Token,\n readonly index: number,\n ) {\n super(environment, token);\n if (\n index < this.environment.minIntIndex ||\n index > this.environment.maxIntIndex\n ) {\n throw new JSONPathIndexError(\"index out of range\", this.token);\n }\n }\n\n public resolve(node: JSONPathNode): JSONPathNode[] {\n const rv: JSONPathNode[] = [];\n if (isArray(node.value)) {\n const normIndex = this.normalizedIndex(node.value.length);\n if (normIndex in node.value) {\n rv.push(\n new JSONPathNode(\n node.value[normIndex],\n node.location.concat(normIndex),\n node.root,\n ),\n );\n }\n }\n return rv;\n }\n\n public *lazyResolve(node: JSONPathNode): Generator<JSONPathNode> {\n if (isArray(node.value)) {\n const normIndex = this.normalizedIndex(node.value.length);\n if (normIndex in node.value) {\n yield new JSONPathNode(\n node.value[normIndex],\n node.location.concat(normIndex),\n node.root,\n );\n }\n }\n }\n\n public toString(): string {\n return String(this.index);\n }\n\n private normalizedIndex(length: number): number {\n if (this.index < 0 && length >= Math.abs(this.index))\n return length + this.index;\n return this.index;\n }\n}\n\nexport class SliceSelector extends JSONPathSelector {\n constructor(\n readonly environment: JSONPathEnvironment,\n readonly token: Token,\n readonly start?: number,\n readonly stop?: number,\n readonly step?: number,\n ) {\n super(environment, token);\n this.checkRange(start, stop, step);\n }\n\n public resolve(node: JSONPathNode): JSONPathNode[] {\n const rv: JSONPathNode[] = [];\n if (!isArray(node.value)) return rv;\n\n for (const [i, value] of this.slice(\n node.value,\n this.start,\n this.stop,\n this.step,\n )) {\n rv.push(new JSONPathNode(value, node.location.concat(i), node.root));\n }\n\n return rv;\n }\n\n public *lazyResolve(node: JSONPathNode): Generator<JSONPathNode> {\n if (isArray(node.value)) {\n for (const [i, value] of this.lazySlice(\n node.value,\n this.start,\n this.stop,\n this.step,\n )) {\n yield new JSONPathNode(value, node.location.concat(i), node.root);\n }\n }\n }\n\n public toString(): string {\n const start = this.start ? this.start : \"\";\n const stop = this.stop ? this.stop : \"\";\n const step = this.step ? this.step : \"1\";\n return `${start}:${stop}:${step}`;\n }\n\n private checkRange(...indices: Array<number | undefined>): void {\n for (const index of indices) {\n if (\n index !== undefined &&\n (index < this.environment.minIntIndex ||\n index > this.environment.maxIntIndex)\n ) {\n throw new JSONPathIndexError(\"index out of range\", this.token);\n }\n }\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n private slice(\n arr: JSONValue[],\n start?: number,\n stop?: number,\n step?: number,\n ): Array<[number, JSONValue]> {\n if (!arr.length) return [];\n\n // Handle negative start and stop values\n if (start === undefined || start === null) {\n start = step && step < 0 ? arr.length - 1 : 0;\n } else if (start < 0) {\n start = Math.max(arr.length + start, 0);\n } else {\n start = Math.min(start, arr.length - 1);\n }\n\n if (stop === undefined || stop === null) {\n stop = step && step < 0 ? -1 : arr.length;\n } else if (stop < 0) {\n stop = Math.max(arr.length + stop, -1);\n } else {\n stop = Math.min(stop, arr.length);\n }\n\n // Handle step value\n if (step === 0) {\n return [];\n }\n if (!step) {\n step = 1;\n }\n\n // Perform the slice\n const slicedArray: Array<[number, JSONValue]> = [];\n if (step > 0) {\n for (let i = start; i < stop; i += step) {\n slicedArray.push([i, arr[i]]);\n }\n } else {\n for (let i = start; i > stop; i += step) {\n slicedArray.push([i, arr[i]]);\n }\n }\n\n return slicedArray;\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n private *lazySlice(\n arr: JSONValue[],\n start?: number,\n stop?: number,\n step?: number,\n ): Generator<[number, JSONValue]> {\n if (!arr.length) return;\n\n // Handle negative and undefined start values\n if (start === undefined || start === null) {\n start = step && step < 0 ? arr.length - 1 : 0;\n } else if (start < 0) {\n start = Math.max(arr.length + start, 0);\n } else {\n start = Math.min(start, arr.length - 1);\n }\n\n // Handle negative and undefined stop values\n if (stop === undefined || stop === null) {\n stop = step && step < 0 ? -1 : arr.length;\n } else if (stop < 0) {\n stop = Math.max(arr.length + stop, -1);\n } else {\n stop = Math.min(stop, arr.length);\n }\n\n // Perform the slice\n if (step === undefined) {\n // Default to a step of 1\n for (let i = start; i < stop; i += 1) {\n yield [i, arr[i]];\n }\n } else if (step > 0) {\n for (let i = start; i < stop; i += step) {\n yield [i, arr[i]];\n }\n } else if (step < 0) {\n for (let i = start; i > stop; i += step) {\n yield [i, arr[i]];\n }\n }\n }\n}\n\nexport class WildcardSelector extends JSONPathSelector {\n constructor(\n readonly environment: JSONPathEnvironment,\n readonly token: Token,\n ) {\n super(environment, token);\n }\n\n public resolve(node: JSONPathNode): JSONPathNode[] {\n const rv: JSONPathNode[] = [];\n if (node.value instanceof String) return rv;\n if (isArray(node.value)) {\n for (let i = 0; i < node.value.length; i++) {\n rv.push(\n new JSONPathNode(node.value[i], node.location.concat(i), node.root),\n );\n }\n } else if (isObject(node.value)) {\n for (const [key, value] of this.environment.entries(node.value)) {\n rv.push(new JSONPathNode(value, node.location.concat(key), node.root));\n }\n }\n return rv;\n }\n\n public *lazyResolve(node: JSONPathNode): Generator<JSONPathNode> {\n if (isArray(node.value)) {\n for (let i = 0; i < node.value.length; i++) {\n yield new JSONPathNode(\n node.value[i],\n node.location.concat(i),\n node.root,\n );\n }\n } else if (isObject(node.value) && !isString(node.value)) {\n for (const [key, value] of this.environment.entries(node.value)) {\n yield new JSONPathNode(value, node.location.concat(key), node.root);\n }\n }\n }\n\n public toString(): string {\n return \"*\";\n }\n}\n\nexport class FilterSelector extends JSONPathSelector {\n constructor(\n readonly environment: JSONPathEnvironment,\n readonly token: Token,\n readonly expression: LogicalExpression,\n ) {\n super(environment, token);\n }\n\n public resolve(node: JSONPathNode): JSONPathNode[] {\n const rv: JSONPathNode[] = [];\n if (node.value instanceof String) return rv;\n if (isArray(node.value)) {\n for (let i = 0; i < node.value.length; i++) {\n const value = node.value[i];\n const filterContext: FilterContext = {\n environment: this.environment,\n currentValue: value,\n rootValue: node.root,\n currentKey: i,\n };\n if (this.expression.evaluate(filterContext)) {\n rv.push(new JSONPathNode(value, node.location.concat(i), node.root));\n }\n }\n } else if (isObject(node.value)) {\n for (const [key, value] of this.environment.entries(node.value)) {\n const filterContext: FilterContext = {\n environment: this.environment,\n currentValue: value,\n rootValue: node.root,\n currentKey: key,\n };\n if (this.expression.evaluate(filterContext)) {\n rv.push(\n new JSONPathNode(value, node.location.concat(key), node.root),\n );\n }\n }\n }\n return rv;\n }\n\n public *lazyResolve(node: JSONPathNode): Generator<JSONPathNode> {\n if (isArray(node.value)) {\n for (let i = 0; i < node.value.length; i++) {\n const value = node.value[i];\n const filterContext: FilterContext = {\n environment: this.environment,\n currentValue: value,\n rootValue: node.root,\n lazy: true,\n currentKey: i,\n };\n if (this.expression.evaluate(filterContext)) {\n yield new JSONPathNode(value, node.location.concat(i), node.root);\n }\n }\n } else if (isObject(node.value) && !isString(node.value)) {\n for (const [key, value] of this.environment.entries(node.value)) {\n const filterContext: FilterContext = {\n environment: this.environment,\n currentValue: value,\n rootValue: node.root,\n lazy: true,\n currentKey: key,\n };\n if (this.expression.evaluate(filterContext)) {\n yield new JSONPathNode(value, node.location.concat(key), node.root);\n }\n }\n }\n }\n\n public toString(options?: SerializationOptions): string {\n return `?${this.expression.toString(options)}`;\n }\n}\n","import { isArray, isObject, isString } from \"../types\";\nimport { JSONPathEnvironment } from \"./environment\";\nimport { JSONPathRecursionLimitError } from \"./errors\";\nimport { JSONPathNode } from \"./node\";\nimport { JSONPathSelector, NameSelector } from \"./selectors\";\nimport { Token } from \"./token\";\nimport {\n type SerializationOptions,\n defaultSerializationOptions,\n} from \"./types\";\n\n/** Base class for all JSONPath segments. Both shorthand and bracketed. */\nexport abstract class JSONPathSegment {\n constructor(\n readonly environment: JSONPathEnvironment,\n readonly token: Token,\n readonly selectors: JSONPathSelector[],\n ) {}\n\n /**\n * @param nodes - Nodes matched by preceding segments.\n */\n public abstract resolve(nodes: JSONPathNode[]): JSONPathNode[];\n\n /**\n * @param nodes - Nodes matched by preceding segments.\n */\n public abstract lazyResolve(\n nodes: Iterable<JSONPathNode>,\n ): Generator<JSONPathNode>;\n\n /**\n * Return a string representation of this segment.\n */\n public abstract toString(options?: SerializationOptions): string;\n}\n\n/** The child selection segment. */\nexport class ChildSegment extends JSONPathSegment {\n public resolve(nodes: JSONPathNode[]): JSONPathNode[] {\n const rv: JSONPathNode[] = [];\n for (const node of nodes) {\n for (const selector of this.selectors) {\n rv.push(...selector.resolve(node));\n }\n }\n return rv;\n }\n\n public *lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode> {\n for (const node of nodes) {\n for (const selector of this.selectors) {\n yield* selector.resolve(node);\n }\n }\n }\n\n public toString(options?: SerializationOptions): string {\n const { form } = { ...defaultSerializationOptions, ...options };\n\n if (\n form === \"pretty\" &&\n this.selectors.length === 1 &&\n this.selectors[0] instanceof NameSelector\n ) {\n const shorthand = this.selectors[0].shorthand();\n if (shorthand != null) return `.${shorthand}`;\n }\n\n return `[${this.selectors.map((s) => s.toString(options)).join(\", \")}]`;\n }\n}\n\n/** The recursive descent segment. */\nexport class DescendantSegment extends JSONPathSegment {\n public resolve(nodes: JSONPathNode[]): JSONPathNode[] {\n const rv: JSONPathNode[] = [];\n\n const visitor = (\n this.environment.nondeterministic\n ? this.nondeterministicVisit\n : this.visit\n ).bind(this);\n\n for (const node of nodes) {\n for (const _node of visitor(node)) {\n for (const selector of this.selectors) {\n rv.push(...selector.resolve(_node));\n }\n }\n }\n\n return rv;\n }\n\n public *lazyResolve(nodes: Iterable<JSONPathNode>): Generator<JSONPathNode> {\n for (const node of nodes) {\n for (const _node of this.visit(node)) {\n for (const selector of this.selectors) {\n yield* selector.resolve(_node);\n }\n }\n }\n }\n\n public toString(options?: SerializationOptions): string {\n return `..[${this.selectors.map((s) => s.toString(options)).join(\", \")}]`;\n }\n\n private *visit(\n node: JSONPathNode,\n depth: number = 1,\n ): Generator<JSONPathNode> {\n if (depth >= this.environment.maxRecursionDepth) {\n throw new JSONPathRecursionLimitError(\n \"recursion limit reached\",\n this.token,\n );\n }\n\n yield node;\n\n if (isArray(node.value)) {\n for (let i = 0; i < node.value.length; i++) {\n const _node = new JSONPathNode(\n node.value[i],\n node.location.concat(i),\n node.root,\n );\n yield* this.visit(_node, depth + 1);\n }\n } else if (isObject(node.value)) {\n for (const [key, value] of this.environment.entries(node.value)) {\n const _node = new JSONPathNode(\n value,\n node.location.concat(key),\n node.root,\n );\n yield* this.visit(_node, depth + 1);\n }\n }\n }\n\n private *nondeterministicVisit(\n root: JSONPathNode,\n depth: number = 1,\n ): Generator<JSONPathNode> {\n let queue: Array<[JSONPathNode, number]> = Array.from(\n this.nondeterministicChildren(root),\n ).map((node) => [node, depth]);\n\n yield root;\n\n while (queue.length) {\n const [node, _depth] = queue.shift() as [JSONPathNode, number];\n yield node;\n\n if (_depth >= this.environment.maxRecursionDepth) {\n throw new JSONPathRecursionLimitError(\n \"recursion limit reached\",\n this.token,\n );\n }\n\n // Visit child nodes now or queue them for later?\n const visitChildren = Math.random() < 0.5;\n\n for (const child of this.nondeterministicChildren(node)) {\n if (visitChildren) {\n yield child;\n\n const grandchildren: Array<[JSONPathNode, number]> = Array.from(\n this.nondeterministicChildren(child),\n ).map((n) => [n, _depth + 2]);\n\n queue = interleave(queue, grandchildren);\n } else {\n queue.push([child, _depth + 1]);\n }\n }\n }\n }\n\n private *nondeterministicChildren(\n node: JSONPathNode,\n ): Generator<JSONPathNode> {\n if (isString(node.value)) return;\n if (isArray(node.value)) {\n for (let i = 0; i < node.value.length; i++) {\n yield new JSONPathNode(\n node.value[i],\n node.location.concat(i),\n node.root,\n );\n }\n } else if (isObject(node.value)) {\n for (const [key, value] of this.environment.entries(node.value)) {\n yield new JSONPathNode(value, node.location.concat(key), node.root);\n }\n }\n }\n}\n\n/**\n * Randomly interleave elements from two arrays while maintaining relative\n * order of each input array.\n *\n * If _arrayA_ is empty, _arrayB_ is returned, and vice versa.\n */\nfunction interleave<T, U>(arrayA: T[], arrayB: U[]): Array<T | U> {\n if (arrayA.length === 0) {\n return arrayB;\n }\n\n if (arrayB.length === 0) {\n return arrayA;\n }\n\n // An array of iterators\n const iterators: Array<Iterator<T> | Iterator<U>> = [];\n const itA = arrayA[Symbol.iterator]();\n const itB = arrayB[Symbol.iterator]();\n\n for (let i = 0; i < arrayA.length; i++) {\n iterators.push(itA);\n }\n\n for (let i = 0; i < arrayB.length; i++) {\n iterators.push(itB);\n }\n\n shuffle(iterators);\n return iterators.map((it) => it.next().value);\n}\n\nfunction shuffle<T>(entries: T[]): T[] {\n for (let i = entries.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [entries[i], entries[j]] = [entries[j], entries[i]];\n }\n return entries;\n}\n","import { JSONPathEnvironment } from \"./environment\";\nimport { JSONPathNode, JSONPathNodeList } from \"./node\";\nimport { IndexSelector, NameSelector } from \"./selectors\";\nimport { JSONValue } from \"../types\";\nimport { JSONPathSegment, DescendantSegment } from \"./segments\";\nimport { SerializationOptions } from \"./types\";\n\n/**\n * A compiled JSONPath query ready to be applied to different data repeatedly.\n */\nexport class JSONPathQuery {\n constructor(\n readonly environment: JSONPathEnvironment,\n readonly segments: JSONPathSegment[],\n ) {}\n\n /**\n * Apply this JSONPath query to _value_.\n * @param value - A JSON-like object to apply this query to.\n * @returns Nodes matched by applying this query to _value_.\n */\n public query(value: JSONValue): JSONPathNodeList {\n let nodes = [new JSONPathNode(value, [], value)];\n for (const segment of this.segments) {\n nodes = segment.resolve(nodes);\n }\n return new JSONPathNodeList(nodes);\n }\n\n /**\n * Apply this JSONPath query to _value_.\n * @param value - A JSON-like object to apply this query to.\n * @returns An iterator over nodes matched by applying this query to _value_.\n */\n public lazyQuery(value: JSONValue): IterableIterator<JSONPathNode> {\n let nodes: IterableIterator<JSONPathNode> = [\n new JSONPathNode(value, [], value),\n ][Symbol.iterator]();\n for (const segment of this.segments) {\n nodes = segment.lazyResolve(nodes);\n }\n return nodes;\n }\n\n /**\n * Return a {@link JSONPathNode} instance for the first object found in\n * _value_ matching this query.\n *\n * @param value - JSON-like data to which this query will be applied.\n * @returns The first node in _value_ matching this query, or `undefined` if\n * there are no matches.\n */\n public match(value: JSONValue): JSONPathNode | undefined {\n const it = this.lazyQuery(value);\n const rv = it.next();\n if (rv.done) return undefined;\n return rv.value;\n }\n\n /**\n * Return a string representation of this query.\n */\n public toString(options?: SerializationOptions): string {\n return `$${this.segments.map((s) => s.toString(options)).join(\"\")}`;\n }\n\n /**\n * Return `true` if this query is a _singular query_, or `false` otherwise.\n */\n public singularQuery(): boolean {\n for (const segment of this.segments) {\n if (segment instanceof DescendantSegment) return false;\n\n if (\n segment.selectors.length === 1 &&\n (segment.selectors[0] instanceof NameSelector ||\n segment.selectors[0] instanceof IndexSelector)\n ) {\n continue;\n }\n return false;\n }\n return true;\n }\n}\n","import { FilterExpression } from \"../expression\";\nimport { FilterContext, Nothing } from \"../types\";\n\nexport class CurrentKey extends FilterExpression {\n public evaluate(context: FilterContext): string | number | typeof Nothing {\n return context.currentKey ?? Nothing;\n }\n\n public toString(): string {\n return \"#\";\n }\n}\n","import { isArray, isObject, isString } from \"../../types\";\nimport { JSONPathEnvironment } from \"../environment\";\nimport { LogicalExpression } from \"../expression\";\nimport { JSONPathNode } from \"../node\";\nimport { JSONPathSelector } from \"../selectors\";\nimport { toCanonical, toQuoted } from \"../serialize\";\nimport { Token } from \"../token\";\nimport {\n type FilterContext,\n type SerializationOptions,\n KEY_MARK,\n defaultSerializationOptions,\n hasStringKey,\n} from \"../types\";\n\nexport class KeySelector extends JSONPathSelector {\n constructor(\n readonly environment: JSONPathEnvironment,\n readonly token: Token,\n readonly key: string,\n ) {\n super(environment, token);\n }\n\n public resolve(node: JSONPathNode): JSONPathNode[] {\n const rv: JSONPathNode[] = [];\n if (node.value instanceof String || isArray(node.value)) return rv;\n if (isObject(node.value) && hasStringKey(node.value, this.key)) {\n rv.push(\n new JSONPathNode(\n this.key,\n node.location.concat(`${KEY_MARK}${this.key}`),\n node.root,\n ),\n );\n }\n return rv;\n }\n\n public *lazyResolve(node: JSONPathNode): Generator<JSONPathNode> {\n if (\n !isString(node.value) &&\n isObject(node.value) &&\n hasStringKey(node.value, this.key)\n ) {\n yield new JSONPathNode(\n this.key,\n node.location.concat(`${KEY_MARK}${this.key}`),\n node.root,\n );\n }\n }\n\n public toString(options?: SerializationOptions): string {\n const { form } = { ...defaultSerializationOptions, ...options };\n const serialize = form === \"canonical\" ? toCanonical : toQuoted;\n return `~${serialize(this.key)}`;\n }\n}\n\n/**\n * Object property name selector or array index selector.\n */\nexport class KeysSelector extends JSONPathSelector {\n constructor(\n readonly environment: JSONPathEnvironment,\n readonly token: Token,\n ) {\n super(environment, token);\n }\n\n public resolve(node: JSONPathNode): JSONPathNode[] {\n const rv: JSONPathNode[] = [];\n if (node.value instanceof String || isArray(node.value)) return rv;\n if (isObject(node.value)) {\n for (const [key, _] of this.environment.entries(node.value)) {\n rv.push(\n new JSONPathNode(\n key,\n node.location.concat(`${KEY_MARK}${key}`),\n node.root,\n ),\n );\n }\n }\n return rv;\n }\n\n public *lazyResolve(node: JSONPathNode): Generator<JSONPathNode> {\n if (isObject(node.value) && !isString(node.value) && !isArray(node.value)) {\n for (const [key, _] of this.environment.entries(node.value)) {\n yield new JSONPathNode(\n key,\n node.location.concat(`${KEY_MARK}${key}`),\n node.root,\n );\n }\n }\n }\n\n public toString(): string {\n return \"~\";\n }\n}\n\nexport class KeysFilterSelector extends JSONPathSelector {\n constructor(\n readonly environment: JSONPathEnvironment,\n readonly token: Token,\n readonly expression: LogicalExpression,\n ) {\n super(environment, token);\n }\n\n public resolve(node: JSONPathNode): JSONPathNode[] {\n const rv: JSONPathNode[] = [];\n if (node.value instanceof String || isArray(node.value)) return rv;\n if (isObject(node.value)) {\n for (const [key, value] of this.environment.entries(node.value)) {\n const filterContext: FilterContext = {\n environment: this.environment,\n currentValue: value,\n rootValue: node.root,\n currentKey: key,\n };\n if (this.expression.evaluate(filterContext)) {\n rv.push(\n new JSONPathNode(\n key,\n node.location.concat(`${KEY_MARK}${key}`),\n node.root,\n ),\n );\n }\n }\n }\n return rv;\n }\n\n public *lazyResolve(node: JSONPathNode): Generator<JSONPathNode> {\n if (node.value instanceof String || isArray(node.value)) return;\n if (isObject(node.value)) {\n for (const [key, value] of this.environment.entries(node.value)) {\n const filterContext: FilterContext = {\n environment: this.environment,\n currentValue: value,\n rootValue: node.root,\n lazy: true,\n currentKey: key,\n };\n if (this.expression.evaluate(filterContext)) {\n yield new JSONPathNode(\n key,\n node.location.concat(`${KEY_MARK}${key}`),\n node.root,\n );\n }\n }\n }\n }\n\n public toString(options?: SerializationOptions): string {\n return `~?${this.expression.toString(options)}`;\n }\n}\n","import { JSONPathEnvironment } from \"./environment\";\nimport { JSONPathSyntaxError, JSONPathTypeError } from \"./errors\";\nimport {\n BooleanLiteral,\n FilterExpression,\n FilterExpressionLiteral,\n FunctionExtension,\n InfixExpression,\n LogicalExpression,\n NullLiteral,\n NumberLiteral,\n PrefixExpression,\n RelativeQuery,\n RootQuery,\n StringLiteral,\n} from \"./expression\";\nimport { FunctionExpressionType } from \"./functions/function\";\nimport { JSONPathQuery } from \"./path\";\nimport {\n FilterSelector,\n IndexSelector,\n JSONPathSelector,\n NameSelector,\n SliceSelector,\n WildcardSelector,\n} from \"./selectors\";\nimport { DescendantSegment, ChildSegment, JSONPathSegment } from \"./segments\";\nimport { Token, TokenKind, TokenStream } from \"./token\";\nimport { CurrentKey } from \"./extra/expression\";\nimport {\n KeySelector,\n KeysSelector,\n KeysFilterSelector,\n} from \"./extra/selectors\";\n\nconst PRECEDENCE_LOWEST = 1;\nconst PRECEDENCE_LOGICAL_OR = 4;\nconst PRECEDENCE_LOGICAL_AND = 5;\nconst PRECEDENCE_COMPARISON = 6;\nconst PRECEDENCE_PREFIX = 7;\n\nconst PRECEDENCES: Map<TokenKind, number> = new Map([\n [TokenKind.AND, PRECEDENCE_LOGICAL_AND],\n [TokenKind.EQ, PRECEDENCE_COMPARISON],\n [TokenKind.GE, PRECEDENCE_COMPARISON],\n [TokenKind.GT, PRECEDENCE_COMPARISON],\n [TokenKind.LE, PRECEDENCE_COMPARISON],\n [TokenKind.LT, PRECEDENCE_COMPARISON],\n [TokenKind.NE, PRECEDENCE_COMPARISON],\n [TokenKind.NOT, PRECEDENCE_PREFIX],\n [TokenKind.OR, PRECEDENCE_LOGICAL_OR],\n [TokenKind.RPAREN, PRECEDENCE_LOWEST],\n]);\n\nconst BINARY_OPERATORS: Map<TokenKind, string> = new Map([\n [TokenKind.AND, \"&&\"],\n [TokenKind.EQ, \"==\"],\n [TokenKind.GE, \">=\"],\n [TokenKind.GT, \">\"],\n [TokenKind.LE, \"<=\"],\n [TokenKind.LT, \"<\"],\n [TokenKind.NE, \"!=\"],\n [TokenKind.OR, \"||\"],\n]);\n\nconst COMPARISON_OPERATORS = new Set([\"==\", \">=\", \">\", \"<=\", \"<\", \"!=\"]);\n\n/**\n * JSONPath token stream parser.\n */\nexport class Parser {\n protected tokenMap: Map<string, (stream: TokenStream) => FilterExpression>;\n\n constructor(readonly environment: JSONPathEnvironment) {\n this.tokenMap = new Map([\n [TokenKind.FALSE, this.parseBoolean],\n [TokenKind.NUMBER, this.parseNumber],\n [TokenKind.LPAREN, this.parseGroupedExpression],\n [TokenKind.NOT, this.parsePrefixExpression],\n [TokenKind.NULL, this.parseNull],\n [TokenKind.ROOT, this.parseRootQuery],\n [TokenKind.CURRENT, this.parseRelativeQuery],\n [TokenKind.SINGLE_QUOTE_STRING, this.parseString],\n [TokenKind.DOUBLE_QUOTE_STRING, this.parseString],\n [TokenKind.TRUE, this.parseBoolean],\n [TokenKind.FUNCTION, this.parseFunction],\n [TokenKind.CURRENT_KEY, this.parseCurrentKey],\n ]);\n }\n\n public parse(stream: TokenStream): JSONPathSegment[] {\n if (stream.current.kind === TokenKind.ROOT) stream.next();\n const segments = this.parseQuery(stream);\n if (stream.current.kind !== TokenKind.EOF) {\n throw new JSONPathSyntaxError(\n `unexpected token '${stream.current.kind}'`,\n stream.current,\n );\n }\n return segments;\n }\n\n protected parseQuery(\n stream: TokenStream,\n inFilter: boolean = false,\n ): JSONPathSegment[] {\n const segments: JSONPathSegment[] = [];\n loop: for (;;) {\n switch (stream.current.kind) {\n case TokenKind.DDOT: {\n const token = stream.next();\n const selectors = this.parseSelectors(stream);\n segments.push(\n new DescendantSegment(this.environment, token, selectors),\n );\n break;\n }\n case TokenKind.LBRACKET:\n case TokenKind.KEY:\n case TokenKind.KEYS:\n case TokenKind.NAME:\n case TokenKind.WILD: {\n const token = stream.current;\n const selectors = this.parseSelectors(stream);\n segments.push(new ChildSegment(this.environment, token, selectors));\n break;\n }\n default: {\n if (inFilter) stream.backup();\n break loop;\n }\n }\n\n stream.next();\n }\n return segments;\n }\n\n protected parseSelectors(stream: TokenStream): JSONPathSelector[] {\n switch (stream.current.kind) {\n case TokenKind.NAME:\n return [\n new NameSelector(\n this.environment,\n stream.current,\n stream.current.value,\n ),\n ];\n case TokenKind.WILD:\n return [new WildcardSelector(this.environment, stream.current)];\n case TokenKind.KEY:\n return [\n new KeySelector(\n this.environment,\n stream.current,\n stream.current.value,\n ),\n ];\n case TokenKind.KEYS:\n return [new KeysSelector(this.environment, stream.current)];\n case TokenKind.LBRACKET:\n return this.parseBracketedSelection(stream);\n default:\n return [];\n }\n }\n\n protected parseIndex(stream: TokenStream): IndexSelector {\n if (\n (stream.current.value.length > 1 &&\n stream.current.value.startsWith(\"0\")) ||\n stream.current.value.startsWith(\"-0\")\n ) {\n throw new JSONPathSyntaxError(\n \"leading zero in index selector\",\n stream.current,\n );\n }\n\n return new IndexSelector(\n this.environment,\n stream.current,\n Number(stream.current.value),\n );\n }\n\n protected parseSlice(stream: TokenStream): SliceSelector {\n const tok = stream.current;\n const indices: Array<number | undefined> = [];\n\n function maybeIndex(token: Token): boolean {\n if (token.kind === TokenKind.INDEX) {\n if (\n (token.value.length > 1 && token.value.startsWith(\"0\")) ||\n token.value.startsWith(\"-0\")\n ) {\n throw new JSONPathSyntaxError(\n \"leading zero in index selector\",\n token,\n );\n }\n return true;\n }\n return false;\n }\n\n // 1: or :\n if (maybeIndex(stream.current)) {\n indices.push(Number(stream.current.value));\n stream.next();\n stream.expect(TokenKind.COLON);\n stream.next();\n } else {\n indices.push(undefined);\n stream.expect(TokenKind.COLON);\n stream.next();\n }\n\n // 1 or 1: or : or ?\n if (maybeIndex(stream.current)) {\n indices.push(Number(stream.current.value));\n stream.next();\n if (stream.current.kind === TokenKind.COLON) {\n stream.next();\n }\n } else if (stream.current.kind === TokenKind.COLON) {\n indices.push(undefined);\n stream.expect(TokenKind.COLON);\n stream.next();\n }\n\n // 1 or ?\n if (maybeIndex(stream.current)) {\n indices.push(Number(stream.current.value));\n stream.next();\n }\n\n stream.backup();\n return new SliceSelector(this.environment, tok, ...indices);\n }\n\n protected parseBracketedSelection(stream: TokenStream): JSONPathSelector[] {\n const token = stream.next();\n const selectors: JSONPathSelector[] = [];\n\n while (stream.current.kind !== TokenKind.RBRACKET) {\n switch (stream.current.kind) {\n case TokenKind.SINGLE_QUOTE_STRING:\n case TokenKind.DOUBLE_QUOTE_STRING:\n selectors.push(\n new NameSelector(\n this.environment,\n stream.current,\n this.decodeString(stream.current),\n ),\n );\n break;\n case TokenKind.FILTER:\n selectors.push(this.parseFilter(stream));\n break;\n case TokenKind.INDEX:\n if (stream.peek.kind === TokenKind.COLON) {\n selectors.push(this.parseSlice(stream));\n } else {\n selectors.push(this.parseIndex(stream));\n }\n break;\n case TokenKind.COLON:\n selectors.push(this.parseSlice(stream));\n break;\n case TokenKind.WILD:\n selectors.push(\n new WildcardSelector(this.environment, stream.current),\n );\n break;\n case TokenKind.KEY_SINGLE_QUOTE_STRING:\n case TokenKind.KEY_DOUBLE_QUOTE_STRING:\n selectors.push(\n new KeySelector(\n this.environment,\n stream.current,\n this.decodeString(stream.current),\n ),\n );\n break;\n case TokenKind.KEYS_FILTER:\n selectors.push(this.parseFilter(stream, true));\n break;\n case TokenKind.KEYS:\n selectors.push(new KeysSelector(this.environment, stream.current));\n break;\n case TokenKind.EOF:\n throw new JSONPathSyntaxError(\n \"unexpected end of query\",\n stream.current,\n );\n default:\n throw new JSONPathSyntaxError(\n `unexpected token in bracketed selection '${stream.current.kind}'`,\n stream.current,\n );\n }\n\n if (stream.peek.kind !== TokenKind.RBRACKET) {\n stream.expectPeek(TokenKind.COMMA);\n stream.next();\n stream.expectPeekNot(TokenKind.RBRACKET, \"unexpected trailing comma\");\n }\n\n stream.next();\n }\n\n if (!selectors.length) {\n throw new JSONPathSyntaxError(\"empty bracketed segment\", token);\n }\n\n return selectors;\n }\n\n protected parseFilter(\n stream: TokenStream,\n keys: boolean = false,\n ): FilterSelector {\n const tok = stream.next();\n const expr = this.parseFilterExpression(stream);\n if (expr instanceof FunctionExtension) {\n const func = this.environment.functionRegister.get(expr.name);\n if (func && func.returnType === FunctionExpressionType.ValueType) {\n throw new JSONPathTypeError(\n `result of ${expr.name}() must be compared`,\n expr.token,\n );\n }\n }\n\n this.throwForLiteral(expr);\n\n return keys\n ? new KeysFilterSelector(\n this.environment,\n tok,\n new LogicalExpression(tok, expr),\n )\n : new FilterSelector(\n this.environment,\n tok,\n new LogicalExpression(tok, expr),\n );\n }\n\n protected parseBoolean(stream: TokenStream): BooleanLiteral {\n if (stream.current.kind === TokenKind.FALSE)\n return new BooleanLiteral(stream.current, false);\n return new BooleanLiteral(stream.current, true);\n }\n\n protected parseNull(stream: TokenStream): NullLiteral {\n return new NullLiteral(stream.current);\n }\n\n protected parseString(stream: TokenStream): StringLiteral {\n return new StringLiteral(stream.current, this.decodeString(stream.current));\n }\n\n protected parseNumber(stream: TokenStream): NumberLiteral {\n const value = stream.current.value;\n if (value.startsWith(\"0\") && value.length > 1) {\n throw new JSONPathSyntaxError(\n `invalid number literal '${value}'`,\n stream.current,\n );\n }\n\n const num = Number(stream.current.value);\n\n if (isNaN(num)) {\n throw new JSONPathSyntaxError(\n `invalid number literal '${value}'`,\n stream.current,\n );\n }\n return new NumberLiteral(stream.current, num);\n }\n\n protected parsePrefixExpression(stream: TokenStream): PrefixExpression {\n stream.expect(TokenKind.NOT);\n stream.next();\n return new PrefixExpression(\n stream.current,\n \"!\",\n this.parseFilterExpression(stream, PRECEDENCE_PREFIX),\n );\n }\n\n protected parseInfixExpression(\n stream: TokenStream,\n left: FilterExpression,\n ): InfixExpression {\n const tok = stream.next();\n const precedence = PRECEDENCES.get(tok.kind) || PRECEDENCE_LOWEST;\n const right = this.parseFilterExpression(stream, precedence);\n const operator = BINARY_OPERATORS.get(tok.kind);\n\n if (!operator) {\n throw new JSONPathSyntaxError(`unknown operator '${tok.kind}'`, tok);\n }\n\n if (COMPARISON_OPERATORS.has(operator)) {\n this.throwForNonComparable(left);\n this.throwForNonComparable(right);\n } else {\n this.throwForLiteral(left);\n this.throwForLiteral(right);\n }\n\n return new InfixExpression(tok, left, operator, right);\n }\n\n protected parseGroupedExpression(stream: TokenStream): FilterExpression {\n if (stream.peek.kind === TokenKind.RPAREN) {\n throw new JSONPathSyntaxError(`empty paren expression`, stream.current);\n }\n\n stream.next(); // eat open paren\n\n let expr = this.parseFilterExpression(stream);\n stream.next();\n\n while (stream.current.kind !== TokenKind.RPAREN) {\n if (stream.current.kind === TokenKind.EOF) {\n throw new JSONPathSyntaxError(\"unbalanced parentheses\", stream.current);\n }\n\n if (!BINARY_OPERATORS.has(stream.current.kind)) {\n throw new JSONPathSyntaxError(\n `expected an expression, found '${stream.current.value}'`,\n stream.current,\n );\n }\n\n expr = this.parseInfixExpression(stream, expr);\n }\n\n stream.expect(TokenKind.RPAREN);\n return expr;\n }\n\n protected parseRootQuery(stream: TokenStream): RootQuery {\n const tok = stream.next();\n return new RootQuery(\n tok,\n new JSONPathQuery(this.environment, this.parseQuery(stream, true)),\n );\n }\n\n protected parseRelativeQuery(stream: TokenStream): RelativeQuery {\n const tok = stream.next();\n return new RelativeQuery(\n tok,\n new JSONPathQuery(this.environment, this.parseQuery(stream, true)),\n );\n }\n\n protected parseCurrentKey(stream: TokenStream): CurrentKey {\n return new CurrentKey(stream.current);\n }\n\n protected parseFunction(stream: TokenStream): FunctionExtension {\n const args: FilterExpression[] = [];\n const tok = stream.next();\n\n while (stream.current.kind !== TokenKind.RPAREN) {\n const func = this.tokenMap.get(stream.current.kind);\n if (!func) {\n throw new JSONPathSyntaxError(\n `unexpected '${stream.current.value}'`,\n stream.current,\n );\n }\n\n let expr = func.bind(this)(stream);\n\n // Could be a comparison/logical expression\n let peekKind = stream.peek.kind;\n while (BINARY_OPERATORS.has(peekKind)) {\n stream.next();\n expr = this.parseInfixExpression(stream, expr);\n peekKind = stream.peek.kind;\n }\n\n args.push(expr);\n\n if (stream.peek.kind !== TokenKind.RPAREN) {\n if (stream.peek.kind === TokenKind.RBRACKET) break;\n stream.expectPeek(TokenKind.COMMA);\n stream.next();\n }\n\n stream.next();\n }\n\n stream.expect(TokenKind.RPAREN);\n\n return new FunctionExtension(\n tok,\n tok.value,\n this.environment.checkWellTypedness(tok, args),\n );\n }\n\n protected parseFilterExpression(\n stream: TokenStream,\n precedence: number = PRECEDENCE_LOWEST,\n ): FilterExpression {\n const func = this.tokenMap.get(stream.current.kind);\n if (!func) {\n let msg: string;\n switch (stream.current.kind) {\n case TokenKind.EOF:\n case TokenKind.RBRACKET:\n msg = \"end of expression\";\n break;\n default:\n msg = `'${stream.current.value}'`;\n }\n throw new JSONPathSyntaxError(`unexpected ${msg}`, stream.current);\n }\n\n let left = func.bind(this)(stream);\n\n for (;;) {\n const peekKind = stream.peek.kind;\n if (\n peekKind === TokenKind.EOF ||\n peekKind === TokenKind.RBRACKET ||\n (PRECEDENCES.get(peekKind) || PRECEDENCE_LOWEST) < precedence\n ) {\n break;\n }\n\n if (!BINARY_OPERATORS.has(peekKind)) return left;\n stream.next();\n left = this.parseInfixExpression(stream, left);\n }\n\n return left;\n }\n\n protected decodeString(token: Token): string {\n return this.unescapeString(\n token.kind === TokenKind.SINGLE_QUOTE_STRING\n ? token.value.replaceAll('\"', '\\\\\"').replaceAll(\"\\\\'\", \"'\")\n : token.value,\n token,\n );\n }\n\n protected unescapeString(value: string, token: Token): string {\n const rv: string[] = [];\n const length = value.length;\n let index = 0;\n let codepoint: number;\n\n while (index < length) {\n const ch = value[index];\n if (ch === \"\\\\\") {\n // Handle escape sequences\n index += 1; // Move past '\\'\n\n switch (value[index]) {\n case '\"':\n rv.push('\"');\n break;\n case \"\\\\\":\n rv.push(\"\\\\\");\n break;\n case \"/\":\n rv.push(\"/\");\n break;\n case \"b\":\n rv.push(\"\\x08\");\n break;\n case \"f\":\n rv.push(\"\\x0C\");\n break;\n case \"n\":\n rv.push(\"\\n\");\n break;\n case \"r\":\n rv.push(\"\\r\");\n break;\n case \"t\":\n rv.push(\"\\t\");\n break;\n case \"u\":\n [codepoint, index] = this.decodeHexChar(value, index, token);\n rv.push(this.stringFromCodePoint(codepoint, token));\n break;\n default:\n throw new JSONPathSyntaxError(\n `unknown escape sequence at index ${token.index + index - 1}`,\n token,\n );\n }\n } else {\n this.stringFromCodePoint(ch.codePointAt(0), token);\n rv.push(ch);\n }\n\n index += 1;\n }\n\n return rv.join(\"\");\n }\n\n /**\n * Decode a `\\uXXXX` or `\\uXXXX\\uXXXX` escape sequence from _value_ at _index_.\n *\n * @param value - A string value containing the sequence to decode.\n * @param index - The start index of an escape sequence in _value_.\n * @param token - The token for the string value.\n * @returns - A codepoint, new index tuple.\n */\n protected decodeHexChar(\n value: string,\n index: number,\n token: Token,\n ): [number, number] {\n const length = value.length;\n\n if (index + 4 >= length) {\n throw new JSONPathSyntaxError(\n `incomplete escape sequence at index ${token.index + index - 1}`,\n token,\n );\n }\n\n index += 1; // Move past 'u'\n let codepoint = this.parseHexDigits(value.slice(index, index + 4), token);\n\n if (isLowSurrogate(codepoint)) {\n throw new JSONPathSyntaxError(\n `unexpected low surrogate codepoint at index ${token.index + index - 2}`,\n token,\n );\n }\n\n if (isHighSurrogate(codepoint)) {\n // Expect a surrogate pair.\n if (!(\n index + 9 < length &&\n value[index + 4] === \"\\\\\" &&\n value[index + 5] === \"u\"\n )) {\n throw new JSONPathSyntaxError(\n `incomplete escape sequence at index ${token.index + index - 2}`,\n token,\n );\n }\n\n const lowSurrogate = this.parseHexDigits(\n value.slice(index + 6, index + 10),\n token,\n );\n\n if (!isLowSurrogate(lowSurrogate)) {\n throw new JSONPathSyntaxError(\n `unexpected codepoint at index ${token.index + index + 4}`,\n token,\n );\n }\n\n codepoint =\n 0x10000 + (((codepoint & 0x03ff) << 10) | (lowSurrogate & 0x03ff));\n\n return [codepoint, index + 9];\n }\n\n return [codepoint, index + 3];\n }\n\n /**\n * Parse a hexadecimal string as an integer.\n *\n * @param digits - Hexadecimal digit string.\n * @param token - The token for the string value.\n * @returns - The number representation of _digits_.\n *\n * Note that we're not using `parseInt(digits, 16)` because it accepts `+`\n * and `-` and things we don't allow.\n */\n protected parseHexDigits(digits: string, token: Token): number {\n const encoder = new TextEncoder();\n let codepoint = 0;\n for (const digit of encoder.encode(digits)) {\n codepoint <<= 4;\n switch (digit) {\n case 48:\n case 49:\n case 50:\n case 51:\n case 52:\n case 53:\n case 54:\n case 55:\n case 56:\n case 57:\n codepoint |= digit - 48; // '0'\n break;\n case 97:\n case 98:\n case 99:\n case 100:\n case 101:\n case 102:\n codepoint |= digit - 97 + 10; // 'a'\n break;\n case 65:\n case 66:\n case 67:\n case 68:\n case 69:\n case 70:\n codepoint |= digit - 65 + 10; // 'A'\n break;\n default:\n throw new JSONPathSyntaxError(\n \"invalid \\\\uXXXX escape sequence\",\n token,\n );\n }\n }\n return codepoint;\n }\n\n /** Check the codepoint is valid and return its string representation. */\n protected stringFromCodePoint(\n codepoint: number | undefined,\n token: Token,\n ): string {\n if (codepoint === undefined || codepoint <= 0x1f) {\n throw new JSONPathSyntaxError(`invalid character`, token);\n }\n\n try {\n return String.fromCodePoint(codepoint);\n } catch {\n // This should not be reachable.\n throw new JSONPathSyntaxError(\"invalid escape sequence\", token);\n }\n }\n\n protected throwForNonComparable(expr: FilterExpression): void {\n if (\n (expr instanceof RootQuery || expr instanceof RelativeQuery) &&\n !expr.path.singularQuery()\n ) {\n throw new JSONPathTypeError(\n \"non-singular query is not comparable\",\n expr.token,\n );\n }\n\n if (expr instanceof FunctionExtension) {\n const func = this.environment.functionRegister.get(expr.name);\n if (func && func.returnType !== FunctionExpressionType.ValueType) {\n throw new JSONPathTypeError(\n `result of ${expr.name}() is not comparable`,\n expr.token,\n );\n }\n }\n }\n\n protected throwForLiteral(expr: FilterExpression): void {\n if (expr instanceof FilterExpressionLiteral) {\n throw new JSONPathSyntaxError(\n `filter expression literals (${expr.toString()}) must be compared`,\n expr.token,\n );\n }\n }\n}\n\nexport function isHighSurrogate(codepoint: number): boolean {\n return codepoint >= 0xd800 && codepoint <= 0xdbff;\n}\n\nexport function isLowSurrogate(codepoint: number): boolean {\n return codepoint >= 0xdc00 && codepoint <= 0xdfff;\n}\n","import { JSONPathTypeError, UndefinedFilterFunctionError } from \"./errors\";\nimport {\n FilterExpression,\n FilterExpressionLiteral,\n FunctionExtension,\n InfixExpression,\n FilterQuery,\n} from \"./expression\";\nimport { Count as CountFilterFunction } from \"./functions/count\";\nimport { FilterFunction, FunctionExpressionType } from \"./functions/function\";\nimport { Length as LengthFilterFunction } from \"./functions/length\";\nimport { Match as MatchFilterFunction } from \"./functions/match\";\nimport { Search as SearchFilterFunction } from \"./functions/search\";\nimport { Value as ValueFilterFunction } from \"./functions/value\";\nimport { tokenize } from \"./lex\";\nimport { JSONPathNode, JSONPathNodeList } from \"./node\";\nimport { Parser } from \"./parse\";\nimport { JSONPathQuery } from \"./path\";\nimport { Token, TokenStream } from \"./token\";\nimport { JSONValue } from \"../types\";\nimport { CurrentKey } from \"./extra/expression\";\n\n/**\n * JSONPath environment options. The defaults are in compliance with JSONPath\n * standards.\n */\nexport type JSONPathEnvironmentOptions = {\n /**\n * Indicates if the environment should to be strict about its compliance with\n * RFC 9535.\n *\n * Defaults to `true`. Setting `strict` to `false` enables non-standard\n * features. Non-standard features are subject to change if conflicting\n * features are included in a future JSONPath standard or draft standard, or\n * an overwhelming consensus amongst the JSONPath community emerges that\n * differs from this implementation.\n */\n strict?: boolean;\n\n /**\n * The maximum number allowed when indexing or slicing an array. Defaults to\n * 2**53 -1.\n */\n maxIntIndex?: number;\n\n /**\n * The minimum number allowed when indexing or slicing an array. Defaults to\n * -(2**53) -1.\n */\n minIntIndex?: number;\n\n /**\n * The maximum number of objects and/or arrays the recursive descent selector\n * can visit before a `JSONPathRecursionLimitError` is thrown.\n */\n maxRecursionDepth?: number;\n\n /**\n * If `true`, enable nondeterministic ordering when iterating JSON object data.\n *\n * This is mainly useful for validating the JSONPath Compliance Test Suite.\n */\n nondeterministic?: boolean;\n\n /**\n * The pattern to use for the non-standard _keys selector_.\n *\n * The lexer expects the sticky bit to be set. Defaults to `/~/y`.\n */\n keysPattern?: RegExp;\n};\n\n/**\n * A configuration object from which JSONPath queries can be evaluated.\n *\n * An environment is where you'd register custom function extensions or set\n * the maximum recursion depth limit, for example.\n */\nexport class JSONPathEnvironment {\n /**\n * Indicates if the environment should to be strict about its compliance with\n * JSONPath standards.\n *\n * Defaults to `true`. Setting `strict` to `false` currently has no effect.\n * If/when we add non-standard features, the environment's strictness will\n * control their availability.\n */\n readonly strict: boolean;\n\n /**\n * The maximum number allowed when indexing or slicing an array. Defaults to\n * 2**53 -1.\n */\n readonly maxIntIndex: number;\n\n /**\n * The minimum number allowed when indexing or slicing an array. Defaults to\n * -(2**53) -1.\n */\n readonly minIntIndex: number;\n\n /**\n * The maximum number of objects and/or arrays the recursive descent selector\n * can visit before a `JSONPathRecursionLimitError` is thrown.\n */\n readonly maxRecursionDepth: number;\n\n /**\n * If `true`, enable nondeterministic ordering when iterating JSON object data.\n */\n readonly nondeterministic: boolean;\n\n /**\n * The pattern to use for the non-standard _keys selector_.\n */\n readonly keysPattern: RegExp;\n\n /**\n * A map of function names to objects implementing the {@link FilterFunction}\n * interface. You are free to set or delete custom filter functions directly.\n */\n public functionRegister: Map<string, FilterFunction> = new Map();\n\n private parser: Parser;\n\n /**\n * @param options - Environment configuration options.\n */\n constructor(options: JSONPathEnvironmentOptions = {}) {\n this.strict = options.strict ?? true;\n this.maxIntIndex = options.maxIntIndex ?? Math.pow(2, 53) - 1;\n this.minIntIndex = options.maxIntIndex ?? -Math.pow(2, 53) + 1;\n this.maxRecursionDepth = options.maxRecursionDepth ?? 50;\n this.nondeterministic = options.nondeterministic ?? false;\n this.keysPattern = options.keysPattern ?? /~/y;\n\n this.parser = new Parser(this);\n this.setupFilterFunctions();\n }\n\n /**\n * @param path - A JSONPath query to parse.\n * @returns A new {@link JSONPathQuery} object, bound to this environment.\n */\n public compile(path: string): JSONPathQuery {\n return new JSONPathQuery(\n this,\n this.parser.parse(new TokenStream(tokenize(this, path))),\n );\n }\n\n /**\n *\n * @param path - A JSONPath query to parse and evaluate against _value_.\n * @param value - Data to which _path_ will be applied.\n * @returns The {@link JSONPathNodeList} resulting from applying _path_\n * to _value_.\n */\n public query(path: string, value: JSONValue): JSONPathNodeList {\n return this.compile(path).query(value);\n }\n\n /**\n * A lazy version of {@link query} which is faster and more memory\n * efficient when querying some large datasets.\n *\n * @param path - A JSONPath query to parse and evaluate against _value_.\n * @param value - Data to which _path_ will be applied.\n * @returns A sequence of {@link JSONPathNode} objects resulting from\n * applying _path_ to _value_.\n */\n public lazyQuery(\n path: string,\n value: JSONValue,\n ): IterableIterator<JSONPathNode> {\n return this.compile(path).lazyQuery(value);\n }\n\n /**\n * Return a {@link JSONPathNode} instance for the first object found in\n * _value_ matching _path_.\n *\n * @param path - A JSONPath query.\n * @param value - JSON-like data to which the query _path_ will be applied.\n * @returns The first node in _value_ matching _path_, or `undefined` if\n * there are no matches.\n */\n public match(path: string, value: JSONValue): JSONPathNode | undefined {\n return this.compile(path).match(value);\n }\n\n /**\n * A hook for setting up the function register. You are encouraged to\n * override this method in classes extending `JSONPathEnvironment`.\n */\n protected setupFilterFunctions(): void {\n this.functionRegister.set(\"count\", new CountFilterFunction());\n this.functionRegister.set(\"length\", new LengthFilterFunction());\n this.functionRegister.set(\"search\", new SearchFilterFunction());\n this.functionRegister.set(\"match\", new MatchFilterFunction());\n this.functionRegister.set(\"value\", new ValueFilterFunction());\n }\n\n /**\n * Check the well-typedness of a function's arguments at compile-time.\n *\n * This method is called by the parser when parsing function calls.\n * It is expected to throw a {@link JSONPathTypeError} if the function's\n * parameters are not well-typed.\n *\n * Override this if you want to deviate from the JSONPath Spec's function\n * extension type system.\n *\n * @param token - The {@link Token} starting the function call. `Token.value`\n * will contain the name of the function.\n * @param args - One {@link FilterExpression} for each argument.\n */\n // eslint-disable-next-line sonarjs/cognitive-complexity\n public checkWellTypedness(\n token: Token,\n args: FilterExpression[],\n ): FilterExpression[] {\n const func = this.functionRegister.get(token.value);\n if (!func) {\n throw new UndefinedFilterFunctionError(\n `no such function '${token.value}'`,\n token,\n );\n }\n\n // Correct number of arguments\n if (args.length !== func.argTypes.length) {\n throw new JSONPathTypeError(\n `${token.value}() takes ${func.argTypes.length} argument${\n func.argTypes.length === 1 ? \"\" : \"s\"\n }, ${args.length} given`,\n token,\n );\n }\n\n // Argument types\n for (const [typ, arg, idx] of func.argTypes.map(\n (t, i): [FunctionExpressionType, FilterExpression, number] => [\n t,\n args[i],\n i,\n ],\n )) {\n switch (typ) {\n case FunctionExpressionType.ValueType:\n if (!(\n arg instanceof FilterExpressionLiteral ||\n arg instanceof CurrentKey ||\n (arg instanceof FilterQuery && arg.path.singularQuery()) ||\n (arg instanceof FunctionExtension &&\n this.functionRegister.get(arg.name)?.returnType ===\n FunctionExpressionType.ValueType)\n )) {\n throw new JSONPathTypeError(\n `${token.value}() argument ${idx} must be of ValueType`,\n arg.token,\n );\n }\n break;\n case FunctionExpressionType.LogicalType:\n if (!(arg instanceof FilterQuery || arg instanceof InfixExpression)) {\n throw new JSONPathTypeError(\n `${token.value}() argument ${idx} must be of LogicalType`,\n arg.token,\n );\n }\n break;\n case FunctionExpressionType.NodesType:\n if (!(\n arg instanceof FilterQuery ||\n (arg instanceof FunctionExtension &&\n this.functionRegister.get(arg.name)?.returnType ===\n FunctionExpressionType.NodesType)\n )) {\n throw new JSONPathTypeError(\n `${token.value}() argument ${idx} must be of NodesType`,\n arg.token,\n );\n }\n }\n }\n\n return args;\n }\n\n /**\n * Return an array of key/values of the enumerable properties in _obj_.\n *\n * If you want to introduce some nondeterminism to iterating JSON-like\n * objects, do it here. The wildcard selector, descendent segment and\n * filter selector all use `this.environment.entries`.\n *\n * @param obj - A JSON-like object.\n */\n public entries(obj: {\n [key: string]: JSONValue;\n }): Array<[string, JSONValue]> {\n function shuffle(entries: Array<[string, JSONValue]>) {\n for (let i = entries.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [entries[i], entries[j]] = [entries[j], entries[i]];\n }\n return entries;\n }\n\n if (this.nondeterministic) {\n return shuffle(Object.entries(obj));\n }\n\n return Object.entries(obj);\n }\n}\n","import { check } from \"iregexp-check\";\nimport { LRUCache } from \"../lru_cache\";\nimport { FilterFunction, FunctionExpressionType } from \"./function\";\nimport { isObject, isString } from \"../../types\";\nimport { IRegexpError } from \"../errors\";\nimport { mapRegexp, fullMatch } from \"./pattern\";\n\nexport type HasFilterFunctionOptions = {\n /**\n * The maximum number of regular expressions to cache. Defaults\n * to 10.\n */\n cacheSize?: number;\n\n /**\n * If _true_, throw errors from regex construction and matching.\n * The standard and default behavior is to ignore these errors\n * and return _false_.\n */\n throwErrors?: boolean;\n\n /**\n * If _true_, check that regexp patterns are valid according to I-Regexp.\n * The standard and default behavior is to silently return _false_ if a\n * pattern is invalid.\n *\n * If `iRegexpCheck` is _true_ and `throwErrors` is _true_, an `IRegexpError`\n * will be thrown.\n */\n iRegexpCheck?: boolean;\n\n /**\n * if _true_, use regex search semantics when testing patterns against\n * property names. Defaults to _true_.\n */\n search?: boolean;\n};\n\n/**\n * A function extension that returns `true` if the first argument is an object\n * value and it contains a property matching the second argument.\n */\nexport class Has implements FilterFunction {\n readonly argTypes = [\n FunctionExpressionType.ValueType,\n FunctionExpressionType.ValueType,\n ];\n\n readonly returnType = FunctionExpressionType.LogicalType;\n\n readonly cacheSize: number;\n readonly throwErrors: boolean;\n readonly iRegexpCheck: boolean;\n readonly search: boolean;\n #cache: LRUCache<string, RegExp>;\n\n constructor(readonly options: HasFilterFunctionOptions = {}) {\n this.cacheSize = options.cacheSize ?? 10;\n this.throwErrors = options.throwErrors ?? false;\n this.iRegexpCheck = options.iRegexpCheck ?? true;\n this.search = options.search ?? true;\n this.#cache = new LRUCache(this.cacheSize);\n }\n\n // eslint-disable-next-line sonarjs/cognitive-complexity\n public call(value: unknown, pattern: string): boolean {\n if (this.cacheSize > 0) {\n const re = this.#cache.get(pattern);\n if (re) {\n try {\n if (isObject(value)) {\n return Object.keys(value).some((k) => !!k.match(re));\n }\n return false;\n } catch (error) {\n if (this.throwErrors) throw error;\n return false;\n }\n }\n }\n\n if (!isString(pattern)) {\n if (this.throwErrors) {\n throw new IRegexpError(\n `match() expected a string pattern, found ${pattern}`,\n );\n }\n return false;\n }\n\n if (this.iRegexpCheck && !check(pattern)) {\n if (this.throwErrors) {\n throw new IRegexpError(\n `pattern ${pattern} is not a valid I-Regexp pattern`,\n );\n }\n return false;\n }\n\n try {\n const re = this.search\n ? new RegExp(mapRegexp(pattern), \"u\")\n : new RegExp(mapRegexp(fullMatch(pattern)), \"u\");\n\n if (this.cacheSize > 0) this.#cache.set(pattern, re);\n\n if (isObject(value)) {\n return Object.keys(value).some((k) => !!k.match(re));\n }\n\n return false;\n } catch (error) {\n if (this.throwErrors) throw error;\n return false;\n }\n }\n}\n","import { JSONValue } from \"../types\";\nimport { JSONPathEnvironment } from \"./environment\";\nimport { JSONPathNode, JSONPathNodeList } from \"./node\";\nimport { JSONPathQuery } from \"./path\";\n\nexport { JSONPathEnvironment } from \"./environment\";\nexport type { JSONPathEnvironmentOptions } from \"./environment\";\n\nexport { JSONPathSegment } from \"./segments\";\nexport { JSONPathSelector } from \"./selectors\";\nexport { JSONPathQuery } from \"./path\";\nexport { JSONPathNodeList, JSONPathNode } from \"./node\";\nexport { Token, TokenKind } from \"./token\";\n\nexport * as selectors from \"./selectors\";\nexport * as expressions from \"./expression\";\nexport * as functions from \"./functions\";\n\nexport { FunctionExpressionType } from \"./functions\";\nexport type { FilterFunction } from \"./functions\";\n\nexport {\n JSONPathError,\n JSONPathIndexError,\n JSONPathLexerError,\n JSONPathSyntaxError,\n JSONPathTypeError,\n JSONPathRecursionLimitError,\n} from \"./errors\";\n\nexport { Nothing, KEY_MARK } from \"./types\";\nexport type {\n JSONPathValue,\n FilterContext,\n SerializationOptions,\n} from \"./types\";\n\nexport const DEFAULT_ENVIRONMENT = new JSONPathEnvironment();\n\n/**\n * Query JSON value _value_ with JSONPath expression _path_.\n * @param path - A JSONPath expression/query.\n * @param value - The JSON-like value the JSONPath query is applied to.\n * @returns A list of JSONPathNode objects, one for each value matched\n * by _path_ in _value_.\n *\n * @throws {@link JSONPathSyntaxError}\n * If the path does not conform to standard syntax.\n *\n * @throws {@link JSONPathTypeError}\n * If filter function arguments are invalid, or filter expression are\n * used in an invalid way.\n */\nexport function query(path: string, value: JSONValue): JSONPathNodeList {\n return DEFAULT_ENVIRONMENT.query(path, value);\n}\n\n/**\n * Lazily query JSON value _value_ with JSONPath expression _path_.\n * Lazy queries can be faster and more memory efficient when querying\n * large datasets, especially when using recursive decent selectors.\n *\n * @param path - A JSONPath expression/query.\n * @param value - The JSON-like value the JSONPath query is applied to.\n * @returns A sequence of {@link JSONPathNode} objects resulting from\n * applying _path_ to _value_.\n *\n * @throws {@link JSONPathSyntaxError}\n * If the path does not conform to standard syntax.\n *\n * @throws {@link JSONPathTypeError}\n * If filter function arguments are invalid, or filter expression are\n * used in an invalid way.\n */\nexport function lazyQuery(\n path: string,\n value: JSONValue,\n): IterableIterator<JSONPathNode> {\n return DEFAULT_ENVIRONMENT.lazyQuery(path, value);\n}\n\n/**\n * Compile JSONPath _path_ for later use.\n * @param path - A JSONPath expression/query.\n * @returns A path object with a `query()` method.\n *\n * @throws {@link JSONPathSyntaxError}\n * If the path does not conform to standard syntax.\n *\n * @throws {@link JSONPathTypeError}\n * If filter function arguments are invalid, or filter expression are\n * used in an invalid way.\n */\nexport function compile(path: string): JSONPathQuery {\n return DEFAULT_ENVIRONMENT.compile(path);\n}\n\n/**\n * Return a {@link JSONPathNode} instance for the first object found in\n * _value_ matching _path_.\n *\n * @param path - A JSONPath query.\n * @param value - JSON-like data to which the query _path_ will be applied.\n * @returns The first node in _value_ matching _path_, or `undefined` if\n * there are no matches.\n */\nexport function match(\n path: string,\n value: JSONValue,\n): JSONPathNode | undefined {\n return DEFAULT_ENVIRONMENT.match(path, value);\n}\n","/**\n * Base class for all JSON Patch errors.\n */\nexport class JSONPatchError extends Error {\n constructor(readonly message: string) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPatchError\";\n }\n}\n\nexport class JSONPatchTestFailure extends JSONPatchError {\n constructor(readonly message: string) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"JSONPatchTestFailure\";\n }\n}\n","import { deepEquals } from \"../deep_equals\";\nimport { JSONPointer, UNDEFINED } from \"../pointer\";\nimport {\n JSONPointerError,\n JSONPointerResolutionError,\n} from \"../pointer/errors\";\nimport { JSONValue, isArray, isObject, isString } from \"../types\";\nimport { JSONPatchError, JSONPatchTestFailure } from \"./errors\";\n\nexport type OpObject = {\n op: string;\n path: string;\n value?: JSONValue;\n from?: string;\n};\n\n/**\n * A JSON Patch operation.\n */\nexport interface Op {\n /**\n * The patch operation name.\n */\n name: string;\n\n /**\n * Apply the patch operation to _value_.\n * @param value - The target JSON value.\n */\n apply: (value: JSONValue, index: number) => JSONValue;\n\n /**\n * A plain object representation of the patch operation.\n */\n toObject: () => OpObject;\n}\n\n/**\n * The JSON Patch _add_ operation.\n */\nexport class OpAdd implements Op {\n public name: string = \"add\";\n\n constructor(\n readonly path: JSONPointer,\n readonly value: JSONValue,\n ) {}\n\n public apply(value: JSONValue, index: number): JSONValue {\n const [parent, obj] = this.path.resolveWithParent(value);\n if (parent === UNDEFINED) {\n // Replace the root object.\n return this.value;\n }\n\n const target = this.path.tokens.at(-1);\n if (target === undefined) {\n // this should not be possible\n throw new JSONPatchError(\n `unexpected operation on 'undefined' (${this.name}:${index})`,\n );\n } else if (isArray(parent)) {\n if (obj === UNDEFINED) {\n if (target === \"-\") {\n parent.push(this.value);\n } else {\n throw new JSONPatchError(\n `index out of range (${this.name}:${index})`,\n );\n }\n } else {\n parent.splice(Number(target), 0, this.value);\n }\n } else if (isObject(parent)) {\n parent[target] = this.value;\n } else {\n throw new JSONPatchError(\n `unexpected operation on '${typeof parent}' (${this.name}:${index})`,\n );\n }\n\n return value;\n }\n\n public toObject(): OpObject {\n return { op: this.name, path: this.path.toString(), value: this.value };\n }\n}\n\n/**\n * The JSON Patch _remove_ operation.\n */\nexport class OpRemove implements Op {\n public name: string = \"remove\";\n\n constructor(readonly path: JSONPointer) {}\n\n public apply(value: JSONValue, index: number): JSONValue {\n const [parent, obj] = this.path.resolveWithParent(value);\n if (parent === UNDEFINED) {\n throw new JSONPatchError(`can't remove root (${this.name}:${index})`);\n }\n\n const target = this.path.tokens.at(-1);\n if (target === undefined) {\n // this should not be possible\n throw new JSONPatchError(\n `unexpected operation on 'undefined' (${this.name}:${index})`,\n );\n } else if (isArray(parent)) {\n if (obj === UNDEFINED) {\n throw new JSONPatchError(\n `can't remove nonexistent item (${this.name}:${index})`,\n );\n }\n parent.splice(Number(target), 1);\n } else if (isObject(parent)) {\n if (obj === UNDEFINED) {\n throw new JSONPatchError(\n `can't remove nonexistent property (${this.name}:${index})`,\n );\n }\n delete parent[target];\n } else {\n throw new JSONPatchError(\n `unexpected operation on '${typeof parent}' (${this.name}:${index})`,\n );\n }\n\n return value;\n }\n\n public toObject(): OpObject {\n return { op: this.name, path: this.path.toString() };\n }\n}\n\n/**\n * The JSON Patch _replace_ operation.\n */\nexport class OpReplace implements Op {\n name: string = \"replace\";\n\n constructor(\n readonly path: JSONPointer,\n readonly value: JSONValue,\n ) {}\n\n public apply(value: JSONValue, index: number): JSONValue {\n const [parent, obj] = this.path.resolveWithParent(value);\n if (parent === UNDEFINED) {\n // Replace the root object.\n return this.value;\n }\n\n const target = this.path.tokens.at(-1);\n if (target === undefined) {\n // this should not be possible\n throw new JSONPatchError(\n `unexpected operation on 'undefined' (${this.name}:${index})`,\n );\n }\n\n if (isArray(parent)) {\n if (obj === UNDEFINED) {\n throw new JSONPatchError(\n `can't replace nonexistent item (${this.name}:${index})`,\n );\n }\n parent.splice(Number(target), 1, this.value);\n } else if (isObject(parent)) {\n if (obj === UNDEFINED) {\n throw new JSONPatchError(\n `can't replace nonexistent property (${this.name}:${index})`,\n );\n }\n parent[target] = this.value;\n } else {\n throw new JSONPatchError(\n `unexpected operation on '${typeof parent}' (${this.name}:${index})`,\n );\n }\n\n return value;\n }\n\n public toObject(): OpObject {\n return { op: this.name, path: this.path.toString(), value: this.value };\n }\n}\n\n/**\n * The JSON Patch _move_ operation.\n */\nexport class OpMove implements Op {\n name: string = \"move\";\n\n constructor(\n readonly from: JSONPointer,\n readonly path: JSONPointer,\n ) {}\n\n public apply(value: JSONValue, index: number): JSONValue {\n if (this.path.isRelativeTo(this.from)) {\n throw new JSONPatchError(\n `can't move object to one of its own children (${this.name}:${index})`,\n );\n }\n\n const [sourceParent, sourceObj] = this.from.resolveWithParent(value);\n if (sourceObj === UNDEFINED) {\n throw new JSONPatchError(\n `source object does not exist (${this.name}:${index})`,\n );\n }\n\n const sourceTarget = this.from.tokens.at(-1);\n if (sourceTarget === undefined) {\n // this should not be possible\n throw new JSONPatchError(\n `unexpected operation on 'undefined' (${this.name}:${index})`,\n );\n }\n\n if (isArray(sourceParent)) {\n sourceParent.splice(Number(sourceTarget), 1);\n } else if (isObject(sourceParent)) {\n delete sourceParent[sourceTarget];\n }\n\n const [destParent, _] = this.path.resolveWithParent(value);\n if (destParent === UNDEFINED) {\n // move source to root\n return sourceObj;\n }\n\n const destTarget = this.path.tokens.at(-1);\n if (destTarget === undefined) {\n // this should not be possible\n throw new JSONPatchError(\n `unexpected operation on 'undefined' (${this.name}:${index})`,\n );\n }\n\n if (isArray(destParent)) {\n if (destTarget === \"-\") {\n destParent.push(sourceObj);\n } else {\n destParent.splice(Number(destTarget), 0, sourceObj);\n }\n } else if (isObject(destParent)) {\n destParent[destTarget] = sourceObj;\n } else {\n throw new JSONPatchError(\n `unexpected operation on '${typeof parent}' (${this.name}:${index})`,\n );\n }\n\n return value;\n }\n\n public toObject(): OpObject {\n return {\n op: this.name,\n from: this.from.toString(),\n path: this.path.toString(),\n };\n }\n}\n\n/**\n * The JSON Patch _copy_ operation.\n */\nexport class OpCopy implements Op {\n name = \"copy\";\n\n constructor(\n readonly from: JSONPointer,\n readonly path: JSONPointer,\n ) {}\n\n public apply(value: JSONValue, index: number): JSONValue {\n const [_, sourceObj] = this.from.resolveWithParent(value);\n if (sourceObj === UNDEFINED) {\n throw new JSONPatchError(\n `source object does not exist (${this.name}:${index})`,\n );\n }\n\n const [destParent] = this.path.resolveWithParent(value);\n if (destParent === UNDEFINED) {\n // copy source to root\n return this.deepCopy(sourceObj);\n }\n\n const destTarget = this.path.tokens.at(-1);\n if (destTarget === undefined) {\n // this should not be possible\n throw new JSONPatchError(\n `unexpected operation on 'undefined' (${this.name}:${index})`,\n );\n }\n\n if (isArray(destParent)) {\n if (destTarget === \"-\") {\n destParent.push(this.deepCopy(sourceObj));\n } else {\n destParent.splice(Number(destTarget), 0, this.deepCopy(sourceObj));\n }\n } else if (isObject(destParent)) {\n destParent[destTarget] = this.deepCopy(sourceObj);\n } else {\n throw new JSONPatchError(\n `unexpected operation on '${typeof destParent}' (${this.name}:${index})`,\n );\n }\n\n return value;\n }\n\n // eslint-disable-next-line sonarjs/no-identical-functions\n public toObject(): OpObject {\n return {\n op: this.name,\n from: this.from.toString(),\n path: this.path.toString(),\n };\n }\n\n protected deepCopy(value: JSONValue): JSONValue {\n return JSON.parse(JSON.stringify(value));\n }\n}\n\n/**\n * The JSON Patch _test_ operation.\n */\nexport class OpTest implements Op {\n public name: string = \"test\";\n\n constructor(\n readonly path: JSONPointer,\n readonly value: JSONValue,\n ) {}\n\n public apply(value: JSONValue, index: number): JSONValue {\n const [_, obj] = this.path.resolveWithParent(value);\n if (!deepEquals(obj, this.value)) {\n throw new JSONPatchTestFailure(`test failed (${this.name}:${index})`);\n }\n return value;\n }\n\n public toObject(): OpObject {\n return { op: this.name, path: this.path.toString(), value: this.value };\n }\n}\n\n/**\n *\n */\nexport class JSONPatch {\n private ops: Op[] = [];\n\n /**\n *\n * @param ops -\n */\n constructor(ops?: OpObject[]) {\n if (ops) {\n this.build(ops);\n }\n }\n\n /**\n * @returns an iterator over ops in this patch.\n */\n *[Symbol.iterator](): Iterator<OpObject> {\n for (const op of this.ops) {\n yield op.toObject();\n }\n }\n\n /**\n *\n * @param path -\n * @param value -\n * @returns\n */\n public add(path: string | JSONPointer, value: JSONValue): this {\n this.ops.push(\n new OpAdd(this.ensurePointer(path, \"add\", this.ops.length), value),\n );\n return this;\n }\n\n /**\n *\n * @param path -\n */\n public remove(path: string | JSONPointer): this {\n this.ops.push(\n new OpRemove(this.ensurePointer(path, \"remove\", this.ops.length)),\n );\n return this;\n }\n\n /**\n *\n * @param path -\n * @param value -\n * @returns\n */\n public replace(path: string | JSONPointer, value: JSONValue): this {\n this.ops.push(\n new OpReplace(\n this.ensurePointer(path, \"replace\", this.ops.length),\n value,\n ),\n );\n return this;\n }\n\n /**\n *\n * @param from -\n * @param path -\n * @returns\n */\n public move(from: string | JSONPointer, path: string | JSONPointer): this {\n this.ops.push(\n new OpMove(\n this.ensurePointer(from, \"move\", this.ops.length),\n this.ensurePointer(path, \"move\", this.ops.length),\n ),\n );\n return this;\n }\n /**\n *\n * @param from -\n * @param path -\n * @returns\n */\n public copy(from: string | JSONPointer, path: string | JSONPointer): this {\n this.ops.push(\n new OpCopy(\n this.ensurePointer(from, \"copy\", this.ops.length),\n this.ensurePointer(path, \"copy\", this.ops.length),\n ),\n );\n return this;\n }\n\n /**\n *\n * @param path -\n * @param value -\n * @returns\n */\n public test(path: string | JSONPointer, value: JSONValue): this {\n this.ops.push(\n new OpTest(this.ensurePointer(path, \"test\", this.ops.length), value),\n );\n return this;\n }\n\n /**\n *\n * @param value -\n */\n public apply(value: JSONValue): JSONValue {\n let _value = value;\n for (let i = 0; i < this.ops.length; i++) {\n const op = this.ops[i];\n try {\n _value = op.apply(_value, i);\n } catch (error) {\n if (error instanceof JSONPointerResolutionError) {\n throw new JSONPatchError(`${error.message} (${op.name}:${i})`);\n }\n throw error;\n }\n }\n return _value;\n }\n\n /**\n *\n * @returns\n */\n public toArray(): OpObject[] {\n return this.ops.map((op) => op.toObject());\n }\n\n protected build(ops: OpObject[]): void {\n for (let i = 0; i < ops.length; i++) {\n const operation = ops[i];\n switch (operation.op) {\n case \"add\":\n this.add(\n this.opPointer(operation, \"path\", \"add\", i),\n this.opValue(operation, \"value\", \"add\", i),\n );\n break;\n case \"remove\":\n this.remove(this.opPointer(operation, \"path\", \"remove\", i));\n break;\n case \"replace\":\n this.replace(\n this.opPointer(operation, \"path\", \"replace\", i),\n this.opValue(operation, \"value\", \"replace\", i),\n );\n break;\n case \"move\":\n this.move(\n this.opPointer(operation, \"from\", \"move\", i),\n this.opPointer(operation, \"path\", \"move\", i),\n );\n break;\n case \"copy\":\n this.copy(\n this.opPointer(operation, \"from\", \"copy\", i),\n this.opPointer(operation, \"path\", \"copy\", i),\n );\n break;\n case \"test\":\n this.test(\n this.opPointer(operation, \"path\", \"test\", i),\n this.opValue(operation, \"value\", \"test\", i),\n );\n break;\n default:\n throw new JSONPatchError(\n `expected 'op' to be one of 'add', 'remove', 'replace', 'move', 'copy' or 'test' (${operation.op}:${i})`,\n );\n }\n }\n }\n\n protected opPointer(\n opObj: OpObject,\n key: keyof OpObject,\n op: string,\n index: number,\n ): JSONPointer {\n if (!Object.hasOwn(opObj, key)) {\n throw new JSONPatchError(`missing property '${key}' (${op}:${index})`);\n }\n\n const p = opObj[key];\n\n if (!isString(p)) {\n throw new JSONPatchError(\n `expected a JSON Pointer string for '${key}', found ${typeof p} (${op}:${index})`,\n );\n }\n\n try {\n return new JSONPointer(p);\n } catch (error) {\n if (error instanceof JSONPointerError) {\n throw new JSONPatchError(`${error.message} (${op}:${index})`);\n }\n throw error;\n }\n }\n\n protected opValue(\n opObj: OpObject,\n key: keyof OpObject,\n op: string,\n index: number,\n ): JSONValue {\n if (!Object.hasOwn(opObj, key)) {\n throw new JSONPatchError(`missing property '${key}' (${op}:${index})`);\n }\n\n return opObj[key];\n }\n\n protected ensurePointer(\n p: JSONPointer | string,\n op: string,\n index: number,\n ): JSONPointer {\n if (p instanceof JSONPointer) {\n return p;\n }\n\n if (!isString(p)) {\n throw new JSONPatchError(\n `expected a JSON Pointer string, found ${typeof p} (${op}:${index})`,\n );\n }\n\n try {\n return new JSONPointer(p);\n } catch (error) {\n if (error instanceof JSONPointerError) {\n throw new JSONPatchError(`${error.message} (${op}:${index})`);\n }\n throw error;\n }\n }\n}\n","import { JSONValue } from \"../types\";\nimport { JSONPatch, OpObject } from \"./patch\";\n\nexport { JSONPatch } from \"./patch\";\nexport { JSONPatchError, JSONPatchTestFailure } from \"./errors\";\nexport type { OpObject } from \"./patch\";\n\n/**\n * Apply the JSON Patch _patch_ to JSON-like data _value_.\n * @param ops - JSON Patch operations following RFC 6902.\n * @param value - The target JSON-like document to patch.\n */\nexport function apply(ops: OpObject[], value: JSONValue): JSONValue {\n return new JSONPatch(ops).apply(value);\n}\n","export const version = \"__VERSION__\";\n\nexport * as jsonpath from \"./path\";\nexport {\n DEFAULT_ENVIRONMENT,\n FunctionExpressionType,\n JSONPathQuery,\n JSONPathEnvironment,\n JSONPathError,\n JSONPathIndexError,\n JSONPathLexerError,\n JSONPathNode,\n JSONPathNodeList,\n JSONPathSyntaxError,\n JSONPathTypeError,\n JSONPathRecursionLimitError,\n Token,\n TokenKind,\n Nothing,\n lazyQuery,\n query,\n compile,\n} from \"./path\";\nexport type { JSONPathEnvironmentOptions, FilterFunction } from \"./path\";\n\nexport * as jsonpointer from \"./pointer\";\nexport {\n JSONPointer,\n RelativeJSONPointer,\n resolve,\n UNDEFINED,\n} from \"./pointer\";\n\nexport * as jsonpatch from \"./patch\";\nexport {\n JSONPatch,\n JSONPatchError,\n JSONPatchTestFailure,\n apply,\n} from \"./patch\";\nexport type { OpObject } from \"./patch\";\n\nexport type { JSONValue } from \"./types\";\n"],"names":["JSONPathError","Error","constructor","message","token","super","this","Object","setPrototypeOf","prototype","name","withErrorContext","input","length","index","slice","JSONPathLexerError","JSONPathTypeError","JSONPathIndexError","UndefinedFilterFunctionError","JSONPathSyntaxError","JSONPathRecursionLimitError","IRegexpError","isArray","value","Array","isObject","_type","isString","isNumber","deepEquals","a","b","i","keysA","keys","keysB","key","FunctionExpressionType","JSONPointerError","JSONPointerResolutionError","JSONPointerIndexError","JSONPointerKeyError","JSONPointerSyntaxError","JSONPointerTypeError","UNDEFINED","Symbol","for","JSONPointer","pointer","tokens","parse","encode","map","replaceAll","join","resolve","fallback","reduce","getItem","bind","error","resolveWithParent","parent","toString","isRelativeTo","every","t","startsWith","split","val","idx","hasOwn","Number","maybeIndex","RE_INT","test","_join","concat","tok","exists","to","rel","RelativeJSONPointer","RE_RELATIVE_POINTER","origin","sign","p","isIntLike","at","newIndex","String","push","match","exec","groups","parseInt","ORIGIN","INDEX","SIGN","POINTER","s","undefined","SHORTHAND_COMPATIBLE_IDENTIFIER","toQuoted","includes","JSON","stringify","toCanonical","toShorthand","Nothing","hasStringKey","KEY_MARK","defaultSerializationOptions","form","JSONPathNode","location","root","path","getPath","options","opts","decodeNameLocation","toPointer","normalized","serialize","hasKeyMark","shorthand","JSONPathNodeList","nodes","iterator","empty","values","node","valuesOrSingular","locations","paths","pointers","FilterExpression","FilterExpressionLiteral","NullLiteral","evaluate","BooleanLiteral","StringLiteral","NumberLiteral","PrefixExpression","operator","right","context","isTruthy","InfixExpression","left","logical","compare","LogicalExpression","expression","_toString","parentPrecedence","precedence","op","expr","FilterQuery","RelativeQuery","lazy","from","lazyQuery","currentValue","query","RootQuery","rootValue","FunctionExtension","args","func","environment","functionRegister","get","arg","argTypes","NodesType","unpack_node_list","call","e","eq","lt","Count","returnType","ValueType","Length","LRUCache","Map","maxSize","entries","has","delete","set","size","first","next","mapRegexp","pattern","escaped","charClass","parts","ch","fullMatch","explicitCaret","explicitDollar","endsWith","peg$SyntaxError","expected","found","self","peg$padEnd","str","targetLength","padString","repeat","child","C","peg$subclass","format","sources","k","src","source","text","start","offset_s","offset","loc","line","column","end","filler","hatLen","buildMessage","DESCRIBE_EXPECTATION_FNS","literal","expectation","literalEscape","class","escapedParts","part","classEscape","inverted","any","other","description","hex","charCodeAt","toUpperCase","replace","describeExpectation","type","j","descriptions","sort","describeExpected","describeFound","iregexp","StartRules","SyntaxError","peg$result","peg$FAILED","peg$source","grammarSource","peg$startRuleFunctions","peg$parsestart","peg$startRuleFunction","peg$c0","peg$c1","peg$c2","peg$c3","peg$c4","peg$c5","peg$c6","peg$c7","peg$c8","peg$c9","peg$c10","peg$c11","peg$c12","peg$c13","peg$c14","peg$c15","peg$c16","peg$c17","peg$c18","peg$c19","peg$c20","peg$r0","peg$r1","peg$r2","peg$r3","peg$r4","peg$r5","peg$r6","peg$r7","peg$r8","peg$r9","peg$e0","peg$literalExpectation","peg$e1","peg$classExpectation","peg$e2","peg$e3","peg$e4","peg$e5","peg$e6","peg$e7","peg$e8","peg$e9","peg$e10","peg$e11","peg$e12","peg$e13","peg$e14","peg$e15","peg$e16","peg$e17","peg$e18","peg$e19","peg$e20","peg$e21","peg$e22","peg$e23","peg$e24","peg$e25","peg$e26","peg$e27","peg$e28","peg$e29","peg$e30","peg$e31","peg$f0","c","isNormalChar","peg$f1","isCCChar","peg$currPos","peg$posDetailsCache","peg$maxFailPos","peg$maxFailExpected","peg$silentFails","startRule","ignoreCase","peg$computePosDetails","pos","details","peg$computeLocation","startPos","endPos","startPosDetails","endPosDetails","peg$fail","peg$parseiregexp","s1","s2","s3","s4","peg$parsebranch","s0","peg$parsepiece","charAt","peg$parsenormal_char","peg$parsesingle_char_esc","peg$parsechar_class_esc","s5","s6","peg$parsecce1","peg$parsechar_class_expr","peg$parsechar_class","peg$parseatom","peg$parserange_quantifier","peg$parsequantifier","substr","peg$parseis_category","peg$parsecat_esc","peg$parsecompl_esc","peg$parsecc_char","peg$parseletters","peg$parsemarks","peg$parsenumbers","peg$parsepunctuation","peg$parseseparators","peg$parsesymbols","peg$parseothers","peg$library","check$1","Match","LogicalType","cache","cacheSize","throwErrors","iRegexpCheck","re","check","RegExp","Search","Value","TokenKind","Token","kind","EOF","TokenStream","current","peek","backup","expect","expectPeek","peeked","expectPeekNot","exponentPattern","functionNamePattern","indexPattern","intPattern","namePattern","whitespace","Set","nameFirstPattern","Lexer","filterLevel","funcCallStack","bracketStack","run","state","lexRoot","emit","ignore","msg","ERROR","peekMatch","accept","valid","acceptMatch","acceptRun","acceptMatchRun","lastIndex","ignoreWhitespace","tokenize","lexer","lex","l","ROOT","lexSegment","DDOT","lexDescendantSelection","lexDotSelector","LBRACKET","lexInsideBracketedSelection","lexInsideFilter","NAME","strict","keysPattern","KEY","KEYS","WILD","lexSingleQuoteKeyString","lexDoubleQuoteKeyString","KEYS_FILTER","pop","RBRACKET","FILTER","COMMA","COLON","lexSingleQuoteStringInsideBracketSelection","lexDoubleQuoteStringInsideBracketSelection","lexSingleQuoteStringInsideFilterExpression","lexDoubleQuoteStringInsideFilterExpression","LPAREN","RPAREN","CURRENT","CURRENT_KEY","NE","NOT","EQ","LE","LT","GE","GT","NUMBER","AND","OR","TRUE","FALSE","NULL","FUNCTION","makeLexString","quote","token_kind","SINGLE_QUOTE_STRING","DOUBLE_QUOTE_STRING","la","KEY_SINGLE_QUOTE_STRING","KEY_DOUBLE_QUOTE_STRING","JSONPathSelector","NameSelector","rv","lazyResolve","IndexSelector","minIntIndex","maxIntIndex","normIndex","normalizedIndex","Math","abs","SliceSelector","stop","step","checkRange","lazySlice","indices","arr","max","min","slicedArray","WildcardSelector","FilterSelector","filterContext","currentKey","JSONPathSegment","selectors","ChildSegment","selector","DescendantSegment","visitor","nondeterministic","nondeterministicVisit","visit","_node","depth","maxRecursionDepth","queue","nondeterministicChildren","_depth","shift","visitChildren","random","interleave","n","arrayA","arrayB","iterators","itA","itB","floor","shuffle","it","JSONPathQuery","segments","segment","done","singularQuery","CurrentKey","KeySelector","KeysSelector","_","KeysFilterSelector","PRECEDENCES","BINARY_OPERATORS","COMPARISON_OPERATORS","Parser","tokenMap","parseBoolean","parseNumber","parseGroupedExpression","parsePrefixExpression","parseNull","parseRootQuery","parseRelativeQuery","parseString","parseFunction","parseCurrentKey","stream","parseQuery","inFilter","loop","parseSelectors","parseBracketedSelection","parseIndex","parseSlice","decodeString","parseFilter","parseFilterExpression","throwForLiteral","num","isNaN","parseInfixExpression","throwForNonComparable","peekKind","checkWellTypedness","unescapeString","codepoint","decodeHexChar","stringFromCodePoint","codePointAt","parseHexDigits","isLowSurrogate","isHighSurrogate","lowSurrogate","digits","encoder","TextEncoder","digit","fromCodePoint","JSONPathEnvironment","pow","parser","setupFilterFunctions","compile","CountFilterFunction","LengthFilterFunction","SearchFilterFunction","MatchFilterFunction","ValueFilterFunction","typ","obj","search","some","DEFAULT_ENVIRONMENT","JSONPatchError","JSONPatchTestFailure","OpAdd","apply","target","splice","toObject","OpRemove","OpReplace","OpMove","sourceParent","sourceObj","sourceTarget","destParent","destTarget","OpCopy","deepCopy","OpTest","JSONPatch","ops","build","add","ensurePointer","remove","move","copy","_value","toArray","operation","opPointer","opValue","opObj","version"],"mappings":"AAKO,MAAMA,UAAsBC,MACjCC,WAAAA,CACWC,EACAC,GAETC,MAAMF,GAASG,KAHNH,QAAAA,EAAeG,KACfF,MAAAA,EAGTG,OAAOC,eAAeF,gBAAiBG,WACvCH,KAAKI,KAAO,gBACZJ,KAAKH,QAAUQ,EAAiBR,EAASC,EAC3C,EAGF,SAASO,EAAiBR,EAAiBC,GACzC,OAAIA,EAAMQ,MAAMC,QAAU,EACjB,GAAGV,OAAaC,EAAMQ,UAAUR,EAAMU,SAG3CV,EAAMU,MAAQV,EAAMQ,MAAMC,OAAS,EAC9B,GAAGV,OAAaC,EAAMQ,MAAMG,MAAMX,EAAMQ,MAAMC,OAAS,OAC5DT,EAAMU,SAINV,EAAMU,MAAQ,EAAI,EACb,GAAGX,OAAaC,EAAMQ,MAAMG,MAAM,EAAG,OAAOX,EAAMU,SAGpD,GAAGX,OAAaC,EAAMQ,MAAMG,MACjCX,EAAMU,MAAQ,EACdV,EAAMU,MAAQ,OACVV,EAAMU,QACd,CAKO,MAAME,UAA2BhB,EACtCE,WAAAA,CACWC,EACAC,GAETC,MAAMF,EAASC,GAAOE,KAHbH,QAAAA,EAAeG,KACfF,MAAAA,EAGTG,OAAOC,eAAeF,gBAAiBG,WACvCH,KAAKI,KAAO,qBACZJ,KAAKH,QAAUQ,EAAiBR,EAASC,EAC3C,EAMK,MAAMa,UAA0BjB,EACrCE,WAAAA,CACWC,EACAC,GAETC,MAAMF,EAASC,GAAOE,KAHbH,QAAAA,EAAeG,KACfF,MAAAA,EAGTG,OAAOC,eAAeF,gBAAiBG,WACvCH,KAAKI,KAAO,oBACZJ,KAAKH,QAAUQ,EAAiBR,EAASC,EAC3C,EAMK,MAAMc,U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