jsonpathplus.min.js 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  1. ! function(e, t) {
  2. "object" == typeof exports && "undefined" != typeof module ? t(exports) : "function" == typeof define && define.amd ? define(["exports"], t) : t((e = "undefined" != typeof globalThis ? globalThis : e || self).JSONPath = {})
  3. }(this, function(e) {
  4. "use strict";
  5. function n(e, t, r) {
  6. return t = l(t),
  7. function(e, t) {
  8. {
  9. if (t && ("object" == typeof t || "function" == typeof t)) return t;
  10. if (void 0 !== t) throw new TypeError("Derived constructors may only return object or undefined")
  11. }
  12. return function(e) {
  13. if (void 0 !== e) return e;
  14. throw new ReferenceError("this hasn't been initialised - super() hasn't been called")
  15. }(e)
  16. }(e, i() ? Reflect.construct(t, r || [], l(e).constructor) : t.apply(e, r))
  17. }
  18. function o(e, t, r) {
  19. if (i()) return Reflect.construct.apply(null, arguments);
  20. var n = [null];
  21. n.push.apply(n, t);
  22. n = new(e.bind.apply(e, n));
  23. return r && h(n, r.prototype), n
  24. }
  25. function i() {
  26. try {
  27. var e = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}))
  28. } catch (e) {}
  29. return (i = function() {
  30. return !!e
  31. })()
  32. }
  33. function t(t, e) {
  34. var r, n = Object.keys(t);
  35. return Object.getOwnPropertySymbols && (r = Object.getOwnPropertySymbols(t), e && (r = r.filter(function(e) {
  36. return Object.getOwnPropertyDescriptor(t, e).enumerable
  37. })), n.push.apply(n, r)), n
  38. }
  39. function r(n) {
  40. for (var e = 1; e < arguments.length; e++) {
  41. var i = null != arguments[e] ? arguments[e] : {};
  42. e % 2 ? t(Object(i), !0).forEach(function(e) {
  43. var t, r;
  44. t = n, e = i[r = e], (r = a(r)) in t ? Object.defineProperty(t, r, {
  45. value: e,
  46. enumerable: !0,
  47. configurable: !0,
  48. writable: !0
  49. }) : t[r] = e
  50. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(n, Object.getOwnPropertyDescriptors(i)) : t(Object(i)).forEach(function(e) {
  51. Object.defineProperty(n, e, Object.getOwnPropertyDescriptor(i, e))
  52. })
  53. }
  54. return n
  55. }
  56. function a(e) {
  57. e = function(e, t) {
  58. if ("object" != typeof e || !e) return e;
  59. var r = e[Symbol.toPrimitive];
  60. if (void 0 === r) return ("string" === t ? String : Number)(e);
  61. if ("object" != typeof(t = r.call(e, t || "default"))) return t;
  62. throw new TypeError("@@toPrimitive must return a primitive value.")
  63. }(e, "string");
  64. return "symbol" == typeof e ? e : e + ""
  65. }
  66. function C(e) {
  67. return (C = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
  68. return typeof e
  69. } : function(e) {
  70. return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
  71. })(e)
  72. }
  73. function s(e, t) {
  74. if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
  75. }
  76. function u(e, t) {
  77. for (var r = 0; r < t.length; r++) {
  78. var n = t[r];
  79. n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, a(n.key), n)
  80. }
  81. }
  82. function c(e, t, r) {
  83. return t && u(e.prototype, t), r && u(e, r), Object.defineProperty(e, "prototype", {
  84. writable: !1
  85. }), e
  86. }
  87. function l(e) {
  88. return (l = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
  89. return e.__proto__ || Object.getPrototypeOf(e)
  90. })(e)
  91. }
  92. function h(e, t) {
  93. return (h = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
  94. return e.__proto__ = t, e
  95. })(e, t)
  96. }
  97. function p(e) {
  98. var r = "function" == typeof Map ? new Map : void 0;
  99. return (p = function(e) {
  100. if (null === e || ! function(t) {
  101. try {
  102. return -1 !== Function.toString.call(t).indexOf("[native code]")
  103. } catch (e) {
  104. return "function" == typeof t
  105. }
  106. }(e)) return e;
  107. if ("function" != typeof e) throw new TypeError("Super expression must either be null or a function");
  108. if (void 0 !== r) {
  109. if (r.has(e)) return r.get(e);
  110. r.set(e, t)
  111. }
  112. function t() {
  113. return o(e, arguments, l(this).constructor)
  114. }
  115. return t.prototype = Object.create(e.prototype, {
  116. constructor: {
  117. value: t,
  118. enumerable: !1,
  119. writable: !0,
  120. configurable: !0
  121. }
  122. }), h(t, e)
  123. })(e)
  124. }
  125. function f(e) {
  126. return function(e) {
  127. if (Array.isArray(e)) return d(e)
  128. }(e) || function(e) {
  129. if ("undefined" != typeof Symbol && null != e[Symbol.iterator] || null != e["@@iterator"]) return Array.from(e)
  130. }(e) || O(e) || function() {
  131. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
  132. }()
  133. }
  134. function O(e, t) {
  135. if (e) {
  136. if ("string" == typeof e) return d(e, t);
  137. var r = Object.prototype.toString.call(e).slice(8, -1);
  138. return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? d(e, t) : void 0
  139. }
  140. }
  141. function d(e, t) {
  142. (null == t || t > e.length) && (t = e.length);
  143. for (var r = 0, n = new Array(t); r < t; r++) n[r] = e[r];
  144. return n
  145. }
  146. var y = function() {
  147. return c(function e() {
  148. s(this, e)
  149. }, [{
  150. key: "add",
  151. value: function(e, t, r) {
  152. if ("string" != typeof e)
  153. for (var n in e) this.add(n, e[n], t);
  154. else(Array.isArray(e) ? e : [e]).forEach(function(e) {
  155. this[e] = this[e] || [], t && this[e][r ? "unshift" : "push"](t)
  156. }, this)
  157. }
  158. }, {
  159. key: "run",
  160. value: function(e, t) {
  161. this[e] = this[e] || [], this[e].forEach(function(e) {
  162. e.call(t && t.context ? t.context : t, t)
  163. })
  164. }
  165. }])
  166. }(),
  167. b = function() {
  168. return c(function e(t) {
  169. s(this, e), this.jsep = t, this.registered = {}
  170. }, [{
  171. key: "register",
  172. value: function() {
  173. for (var t = this, e = arguments.length, r = new Array(e), n = 0; n < e; n++) r[n] = arguments[n];
  174. r.forEach(function(e) {
  175. if ("object" !== C(e) || !e.name || !e.init) throw new Error("Invalid JSEP plugin format");
  176. t.registered[e.name] || (e.init(t.jsep), t.registered[e.name] = e)
  177. })
  178. }
  179. }])
  180. }(),
  181. v = function() {
  182. function l(e) {
  183. s(this, l), this.expr = e, this.index = 0
  184. }
  185. return c(l, [{
  186. key: "char",
  187. get: function() {
  188. return this.expr.charAt(this.index)
  189. }
  190. }, {
  191. key: "code",
  192. get: function() {
  193. return this.expr.charCodeAt(this.index)
  194. }
  195. }, {
  196. key: "throwError",
  197. value: function(e) {
  198. var t = new Error(e + " at character " + this.index);
  199. throw t.index = this.index, t.description = e, t
  200. }
  201. }, {
  202. key: "runHook",
  203. value: function(e, t) {
  204. if (l.hooks[e]) {
  205. var r = {
  206. context: this,
  207. node: t
  208. };
  209. return l.hooks.run(e, r), r.node
  210. }
  211. return t
  212. }
  213. }, {
  214. key: "searchHook",
  215. value: function(e) {
  216. if (l.hooks[e]) {
  217. var t = {
  218. context: this
  219. };
  220. return l.hooks[e].find(function(e) {
  221. return e.call(t.context, t), t.node
  222. }), t.node
  223. }
  224. }
  225. }, {
  226. key: "gobbleSpaces",
  227. value: function() {
  228. for (var e = this.code; e === l.SPACE_CODE || e === l.TAB_CODE || e === l.LF_CODE || e === l.CR_CODE;) e = this.expr.charCodeAt(++this.index);
  229. this.runHook("gobble-spaces")
  230. }
  231. }, {
  232. key: "parse",
  233. value: function() {
  234. this.runHook("before-all");
  235. var e = this.gobbleExpressions(),
  236. e = 1 === e.length ? e[0] : {
  237. type: l.COMPOUND,
  238. body: e
  239. };
  240. return this.runHook("after-all", e)
  241. }
  242. }, {
  243. key: "gobbleExpressions",
  244. value: function(e) {
  245. for (var t, r, n = []; this.index < this.expr.length;)
  246. if ((t = this.code) === l.SEMCOL_CODE || t === l.COMMA_CODE) this.index++;
  247. else if (r = this.gobbleExpression()) n.push(r);
  248. else if (this.index < this.expr.length) {
  249. if (t === e) break;
  250. this.throwError('Unexpected "' + this.char + '"')
  251. }
  252. return n
  253. }
  254. }, {
  255. key: "gobbleExpression",
  256. value: function() {
  257. var e = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
  258. return this.gobbleSpaces(), this.runHook("after-expression", e)
  259. }
  260. }, {
  261. key: "gobbleBinaryOp",
  262. value: function() {
  263. this.gobbleSpaces();
  264. for (var e = this.expr.substr(this.index, l.max_binop_len), t = e.length; 0 < t;) {
  265. if (l.binary_ops.hasOwnProperty(e) && (!l.isIdentifierStart(this.code) || this.index + e.length < this.expr.length && !l.isIdentifierPart(this.expr.charCodeAt(this.index + e.length)))) return this.index += t, e;
  266. e = e.substr(0, --t)
  267. }
  268. return !1
  269. }
  270. }, {
  271. key: "gobbleBinaryExpression",
  272. value: function() {
  273. var e, t, r, n, i, o, a, s, u, c = this.gobbleToken();
  274. if (!c) return c;
  275. if (!(t = this.gobbleBinaryOp())) return c;
  276. for (i = {
  277. value: t,
  278. prec: l.binaryPrecedence(t),
  279. right_a: l.right_associative.has(t)
  280. }, (o = this.gobbleToken()) || this.throwError("Expected expression after " + t), n = [c, i, o]; t = this.gobbleBinaryOp();) {
  281. if (0 === (r = l.binaryPrecedence(t))) {
  282. this.index -= t.length;
  283. break
  284. }
  285. i = {
  286. value: t,
  287. prec: r,
  288. right_a: l.right_associative.has(t)
  289. }, s = t;
  290. for (; 2 < n.length && (u = n[n.length - 2], i.right_a && u.right_a ? r > u.prec : r <= u.prec);) o = n.pop(), t = n.pop().value, c = n.pop(), e = {
  291. type: l.BINARY_EXP,
  292. operator: t,
  293. left: c,
  294. right: o
  295. }, n.push(e);
  296. (e = this.gobbleToken()) || this.throwError("Expected expression after " + s), n.push(i, e)
  297. }
  298. for (e = n[a = n.length - 1]; 1 < a;) e = {
  299. type: l.BINARY_EXP,
  300. operator: n[a - 1].value,
  301. left: n[a - 2],
  302. right: e
  303. }, a -= 2;
  304. return e
  305. }
  306. }, {
  307. key: "gobbleToken",
  308. value: function() {
  309. var e, t, r, n;
  310. if (this.gobbleSpaces(), n = this.searchHook("gobble-token")) return this.runHook("after-token", n);
  311. if (e = this.code, l.isDecimalDigit(e) || e === l.PERIOD_CODE) return this.gobbleNumericLiteral();
  312. if (e === l.SQUOTE_CODE || e === l.DQUOTE_CODE) n = this.gobbleStringLiteral();
  313. else if (e === l.OBRACK_CODE) n = this.gobbleArray();
  314. else {
  315. for (r = (t = this.expr.substr(this.index, l.max_unop_len)).length; 0 < r;) {
  316. if (l.unary_ops.hasOwnProperty(t) && (!l.isIdentifierStart(this.code) || this.index + t.length < this.expr.length && !l.isIdentifierPart(this.expr.charCodeAt(this.index + t.length)))) {
  317. this.index += r;
  318. var i = this.gobbleToken();
  319. return i || this.throwError("missing unaryOp argument"), this.runHook("after-token", {
  320. type: l.UNARY_EXP,
  321. operator: t,
  322. argument: i,
  323. prefix: !0
  324. })
  325. }
  326. t = t.substr(0, --r)
  327. }
  328. l.isIdentifierStart(e) ? (n = this.gobbleIdentifier(), l.literals.hasOwnProperty(n.name) ? n = {
  329. type: l.LITERAL,
  330. value: l.literals[n.name],
  331. raw: n.name
  332. } : n.name === l.this_str && (n = {
  333. type: l.THIS_EXP
  334. })) : e === l.OPAREN_CODE && (n = this.gobbleGroup())
  335. }
  336. return n ? (n = this.gobbleTokenProperty(n), this.runHook("after-token", n)) : this.runHook("after-token", !1)
  337. }
  338. }, {
  339. key: "gobbleTokenProperty",
  340. value: function(e) {
  341. this.gobbleSpaces();
  342. for (var t = this.code; t === l.PERIOD_CODE || t === l.OBRACK_CODE || t === l.OPAREN_CODE || t === l.QUMARK_CODE;) {
  343. var r = void 0;
  344. if (t === l.QUMARK_CODE) {
  345. if (this.expr.charCodeAt(this.index + 1) !== l.PERIOD_CODE) break;
  346. r = !0, this.index += 2, this.gobbleSpaces(), t = this.code
  347. }
  348. this.index++, t === l.OBRACK_CODE ? (e = {
  349. type: l.MEMBER_EXP,
  350. computed: !0,
  351. object: e,
  352. property: this.gobbleExpression()
  353. }, this.gobbleSpaces(), (t = this.code) !== l.CBRACK_CODE && this.throwError("Unclosed ["), this.index++) : t === l.OPAREN_CODE ? e = {
  354. type: l.CALL_EXP,
  355. arguments: this.gobbleArguments(l.CPAREN_CODE),
  356. callee: e
  357. } : t !== l.PERIOD_CODE && !r || (r && this.index--, this.gobbleSpaces(), e = {
  358. type: l.MEMBER_EXP,
  359. computed: !1,
  360. object: e,
  361. property: this.gobbleIdentifier()
  362. }), r && (e.optional = !0), this.gobbleSpaces(), t = this.code
  363. }
  364. return e
  365. }
  366. }, {
  367. key: "gobbleNumericLiteral",
  368. value: function() {
  369. for (var e, t = ""; l.isDecimalDigit(this.code);) t += this.expr.charAt(this.index++);
  370. if (this.code === l.PERIOD_CODE)
  371. for (t += this.expr.charAt(this.index++); l.isDecimalDigit(this.code);) t += this.expr.charAt(this.index++);
  372. if ("e" === (e = this.char) || "E" === e) {
  373. for (t += this.expr.charAt(this.index++), "+" !== (e = this.char) && "-" !== e || (t += this.expr.charAt(this.index++)); l.isDecimalDigit(this.code);) t += this.expr.charAt(this.index++);
  374. l.isDecimalDigit(this.expr.charCodeAt(this.index - 1)) || this.throwError("Expected exponent (" + t + this.char + ")")
  375. }
  376. return e = this.code, l.isIdentifierStart(e) ? this.throwError("Variable names cannot start with a number (" + t + this.char + ")") : (e === l.PERIOD_CODE || 1 === t.length && t.charCodeAt(0) === l.PERIOD_CODE) && this.throwError("Unexpected period"), {
  377. type: l.LITERAL,
  378. value: parseFloat(t),
  379. raw: t
  380. }
  381. }
  382. }, {
  383. key: "gobbleStringLiteral",
  384. value: function() {
  385. for (var e = "", t = this.index, r = this.expr.charAt(this.index++), n = !1; this.index < this.expr.length;) {
  386. var i = this.expr.charAt(this.index++);
  387. if (i === r) {
  388. n = !0;
  389. break
  390. }
  391. if ("\\" === i) switch (i = this.expr.charAt(this.index++)) {
  392. case "n":
  393. e += "\n";
  394. break;
  395. case "r":
  396. e += "\r";
  397. break;
  398. case "t":
  399. e += "\t";
  400. break;
  401. case "b":
  402. e += "\b";
  403. break;
  404. case "f":
  405. e += "\f";
  406. break;
  407. case "v":
  408. e += "\v";
  409. break;
  410. default:
  411. e += i
  412. } else e += i
  413. }
  414. return n || this.throwError('Unclosed quote after "' + e + '"'), {
  415. type: l.LITERAL,
  416. value: e,
  417. raw: this.expr.substring(t, this.index)
  418. }
  419. }
  420. }, {
  421. key: "gobbleIdentifier",
  422. value: function() {
  423. var e = this.code,
  424. t = this.index;
  425. for (l.isIdentifierStart(e) ? this.index++ : this.throwError("Unexpected " + this.char); this.index < this.expr.length && (e = this.code, l.isIdentifierPart(e));) this.index++;
  426. return {
  427. type: l.IDENTIFIER,
  428. name: this.expr.slice(t, this.index)
  429. }
  430. }
  431. }, {
  432. key: "gobbleArguments",
  433. value: function(e) {
  434. for (var t = [], r = !1, n = 0; this.index < this.expr.length;) {
  435. this.gobbleSpaces();
  436. var i = this.code;
  437. if (i === e) {
  438. r = !0, this.index++, e === l.CPAREN_CODE && n && n >= t.length && this.throwError("Unexpected token " + String.fromCharCode(e));
  439. break
  440. }
  441. if (i === l.COMMA_CODE) {
  442. if (this.index++, ++n !== t.length)
  443. if (e === l.CPAREN_CODE) this.throwError("Unexpected token ,");
  444. else if (e === l.CBRACK_CODE)
  445. for (var o = t.length; o < n; o++) t.push(null)
  446. } else t.length !== n && 0 !== n ? this.throwError("Expected comma") : ((i = this.gobbleExpression()) && i.type !== l.COMPOUND || this.throwError("Expected comma"), t.push(i))
  447. }
  448. return r || this.throwError("Expected " + String.fromCharCode(e)), t
  449. }
  450. }, {
  451. key: "gobbleGroup",
  452. value: function() {
  453. this.index++;
  454. var e = this.gobbleExpressions(l.CPAREN_CODE);
  455. if (this.code === l.CPAREN_CODE) return this.index++, 1 === e.length ? e[0] : !!e.length && {
  456. type: l.SEQUENCE_EXP,
  457. expressions: e
  458. };
  459. this.throwError("Unclosed (")
  460. }
  461. }, {
  462. key: "gobbleArray",
  463. value: function() {
  464. return this.index++, {
  465. type: l.ARRAY_EXP,
  466. elements: this.gobbleArguments(l.CBRACK_CODE)
  467. }
  468. }
  469. }], [{
  470. key: "version",
  471. get: function() {
  472. return "1.3.8"
  473. }
  474. }, {
  475. key: "toString",
  476. value: function() {
  477. return "JavaScript Expression Parser (JSEP) v" + l.version
  478. }
  479. }, {
  480. key: "addUnaryOp",
  481. value: function(e) {
  482. return l.max_unop_len = Math.max(e.length, l.max_unop_len), l.unary_ops[e] = 1, l
  483. }
  484. }, {
  485. key: "addBinaryOp",
  486. value: function(e, t, r) {
  487. return l.max_binop_len = Math.max(e.length, l.max_binop_len), l.binary_ops[e] = t, r ? l.right_associative.add(e) : l.right_associative.delete(e), l
  488. }
  489. }, {
  490. key: "addIdentifierChar",
  491. value: function(e) {
  492. return l.additional_identifier_chars.add(e), l
  493. }
  494. }, {
  495. key: "addLiteral",
  496. value: function(e, t) {
  497. return l.literals[e] = t, l
  498. }
  499. }, {
  500. key: "removeUnaryOp",
  501. value: function(e) {
  502. return delete l.unary_ops[e], e.length === l.max_unop_len && (l.max_unop_len = l.getMaxKeyLen(l.unary_ops)), l
  503. }
  504. }, {
  505. key: "removeAllUnaryOps",
  506. value: function() {
  507. return l.unary_ops = {}, l.max_unop_len = 0, l
  508. }
  509. }, {
  510. key: "removeIdentifierChar",
  511. value: function(e) {
  512. return l.additional_identifier_chars.delete(e), l
  513. }
  514. }, {
  515. key: "removeBinaryOp",
  516. value: function(e) {
  517. return delete l.binary_ops[e], e.length === l.max_binop_len && (l.max_binop_len = l.getMaxKeyLen(l.binary_ops)), l.right_associative.delete(e), l
  518. }
  519. }, {
  520. key: "removeAllBinaryOps",
  521. value: function() {
  522. return l.binary_ops = {}, l.max_binop_len = 0, l
  523. }
  524. }, {
  525. key: "removeLiteral",
  526. value: function(e) {
  527. return delete l.literals[e], l
  528. }
  529. }, {
  530. key: "removeAllLiterals",
  531. value: function() {
  532. return l.literals = {}, l
  533. }
  534. }, {
  535. key: "parse",
  536. value: function(e) {
  537. return new l(e).parse()
  538. }
  539. }, {
  540. key: "getMaxKeyLen",
  541. value: function(e) {
  542. return Math.max.apply(Math, [0].concat(f(Object.keys(e).map(function(e) {
  543. return e.length
  544. }))))
  545. }
  546. }, {
  547. key: "isDecimalDigit",
  548. value: function(e) {
  549. return 48 <= e && e <= 57
  550. }
  551. }, {
  552. key: "binaryPrecedence",
  553. value: function(e) {
  554. return l.binary_ops[e] || 0
  555. }
  556. }, {
  557. key: "isIdentifierStart",
  558. value: function(e) {
  559. return 65 <= e && e <= 90 || 97 <= e && e <= 122 || 128 <= e && !l.binary_ops[String.fromCharCode(e)] || l.additional_identifier_chars.has(String.fromCharCode(e))
  560. }
  561. }, {
  562. key: "isIdentifierPart",
  563. value: function(e) {
  564. return l.isIdentifierStart(e) || l.isDecimalDigit(e)
  565. }
  566. }])
  567. }(),
  568. y = new y;
  569. Object.assign(v, {
  570. hooks: y,
  571. plugins: new b(v),
  572. COMPOUND: "Compound",
  573. SEQUENCE_EXP: "SequenceExpression",
  574. IDENTIFIER: "Identifier",
  575. MEMBER_EXP: "MemberExpression",
  576. LITERAL: "Literal",
  577. THIS_EXP: "ThisExpression",
  578. CALL_EXP: "CallExpression",
  579. UNARY_EXP: "UnaryExpression",
  580. BINARY_EXP: "BinaryExpression",
  581. ARRAY_EXP: "ArrayExpression",
  582. TAB_CODE: 9,
  583. LF_CODE: 10,
  584. CR_CODE: 13,
  585. SPACE_CODE: 32,
  586. PERIOD_CODE: 46,
  587. COMMA_CODE: 44,
  588. SQUOTE_CODE: 39,
  589. DQUOTE_CODE: 34,
  590. OPAREN_CODE: 40,
  591. CPAREN_CODE: 41,
  592. OBRACK_CODE: 91,
  593. CBRACK_CODE: 93,
  594. QUMARK_CODE: 63,
  595. SEMCOL_CODE: 59,
  596. COLON_CODE: 58,
  597. unary_ops: {
  598. "-": 1,
  599. "!": 1,
  600. "~": 1,
  601. "+": 1
  602. },
  603. binary_ops: {
  604. "||": 1,
  605. "&&": 2,
  606. "|": 3,
  607. "^": 4,
  608. "&": 5,
  609. "==": 6,
  610. "!=": 6,
  611. "===": 6,
  612. "!==": 6,
  613. "<": 7,
  614. ">": 7,
  615. "<=": 7,
  616. ">=": 7,
  617. "<<": 8,
  618. ">>": 8,
  619. ">>>": 8,
  620. "+": 9,
  621. "-": 9,
  622. "*": 10,
  623. "/": 10,
  624. "%": 10
  625. },
  626. right_associative: new Set,
  627. additional_identifier_chars: new Set(["$", "_"]),
  628. literals: {
  629. true: !0,
  630. false: !1,
  631. null: null
  632. },
  633. this_str: "this"
  634. }), v.max_unop_len = v.getMaxKeyLen(v.unary_ops), v.max_binop_len = v.getMaxKeyLen(v.binary_ops);
  635. var E = function(e) {
  636. return new v(e).parse()
  637. };
  638. Object.getOwnPropertyNames(v).forEach(function(e) {
  639. void 0 === E[e] && "prototype" !== e && (E[e] = v[e])
  640. }), E.Jsep = v;
  641. b = {
  642. name: "ternary",
  643. init: function(o) {
  644. o.hooks.add("after-expression", function(e) {
  645. if (e.node && this.code === o.QUMARK_CODE) {
  646. this.index++;
  647. var t = e.node,
  648. r = this.gobbleExpression();
  649. if (r || this.throwError("Expected expression"), this.gobbleSpaces(), this.code === o.COLON_CODE) {
  650. this.index++;
  651. var n = this.gobbleExpression();
  652. if (n || this.throwError("Expected expression"), e.node = {
  653. type: "ConditionalExpression",
  654. test: t,
  655. consequent: r,
  656. alternate: n
  657. }, t.operator && o.binary_ops[t.operator] <= .9) {
  658. for (var i = t; i.right.operator && o.binary_ops[i.right.operator] <= .9;) i = i.right;
  659. e.node.test = i.right, i.right = e.node, e.node = t
  660. }
  661. } else this.throwError("Expected :")
  662. }
  663. })
  664. }
  665. };
  666. E.plugins.register(b);
  667. var b = {
  668. name: "regex",
  669. init: function(s) {
  670. s.hooks.add("gobble-token", function(e) {
  671. if (47 === this.code) {
  672. for (var t = ++this.index, r = !1; this.index < this.expr.length;) {
  673. if (47 === this.code && !r) {
  674. for (var n = this.expr.slice(t, this.index), i = ""; ++this.index < this.expr.length;) {
  675. var o = this.code;
  676. if (!(97 <= o && o <= 122 || 65 <= o && o <= 90 || 48 <= o && o <= 57)) break;
  677. i += this.char
  678. }
  679. var a = void 0;
  680. try {
  681. a = new RegExp(n, i)
  682. } catch (e) {
  683. this.throwError(e.message)
  684. }
  685. return e.node = {
  686. type: s.LITERAL,
  687. value: a,
  688. raw: this.expr.slice(t - 1, this.index)
  689. }, e.node = this.gobbleTokenProperty(e.node), e.node
  690. }
  691. this.code === s.OBRACK_CODE ? r = !0 : r && this.code === s.CBRACK_CODE && (r = !1), this.index += 92 === this.code ? 2 : 1
  692. }
  693. this.throwError("Unclosed Regex")
  694. }
  695. })
  696. }
  697. },
  698. g = {
  699. name: "assignment",
  700. assignmentOperators: new Set(["=", "*=", "**=", "/=", "%=", "+=", "-=", "<<=", ">>=", ">>>=", "&=", "^=", "|="]),
  701. updateOperators: [43, 45],
  702. assignmentPrecedence: .9,
  703. init: function(t) {
  704. var n = [t.IDENTIFIER, t.MEMBER_EXP];
  705. g.assignmentOperators.forEach(function(e) {
  706. return t.addBinaryOp(e, g.assignmentPrecedence, !0)
  707. }), t.hooks.add("gobble-token", function(e) {
  708. var t = this,
  709. r = this.code;
  710. g.updateOperators.some(function(e) {
  711. return e === r && e === t.expr.charCodeAt(t.index + 1)
  712. }) && (this.index += 2, e.node = {
  713. type: "UpdateExpression",
  714. operator: 43 === r ? "++" : "--",
  715. argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
  716. prefix: !0
  717. }, e.node.argument && n.includes(e.node.argument.type) || this.throwError("Unexpected ".concat(e.node.operator)))
  718. }), t.hooks.add("after-token", function(e) {
  719. var t, r = this;
  720. e.node && (t = this.code, g.updateOperators.some(function(e) {
  721. return e === t && e === r.expr.charCodeAt(r.index + 1)
  722. }) && (n.includes(e.node.type) || this.throwError("Unexpected ".concat(e.node.operator)), this.index += 2, e.node = {
  723. type: "UpdateExpression",
  724. operator: 43 === t ? "++" : "--",
  725. argument: e.node,
  726. prefix: !1
  727. }))
  728. }), t.hooks.add("after-expression", function(e) {
  729. e.node && ! function t(e) {
  730. g.assignmentOperators.has(e.operator) ? (e.type = "AssignmentExpression", t(e.left), t(e.right)) : e.operator || Object.values(e).forEach(function(e) {
  731. e && "object" === C(e) && t(e)
  732. })
  733. }(e.node)
  734. })
  735. }
  736. },
  737. A = Object.prototype.hasOwnProperty;
  738. function w(e, t) {
  739. return (e = e.slice()).push(t), e
  740. }
  741. function k(e, t) {
  742. return (t = t.slice()).unshift(e), t
  743. }
  744. var x = function() {
  745. function r(e) {
  746. var t;
  747. return s(this, r), (t = n(this, r, ['JSONPath should not be called with "new" (it prevents return of (unwrapped) scalar values)'])).avoidNew = !0, t.value = e, t.name = "NewError", t
  748. }
  749. return function(e, t) {
  750. if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
  751. e.prototype = Object.create(t && t.prototype, {
  752. constructor: {
  753. value: e,
  754. writable: !0,
  755. configurable: !0
  756. }
  757. }), Object.defineProperty(e, "prototype", {
  758. writable: !1
  759. }), t && h(e, t)
  760. }(r, p(Error)), c(r)
  761. }();
  762. function F(e, t, r, n, i) {
  763. if (!(this instanceof F)) try {
  764. return new F(e, t, r, n, i)
  765. } catch (e) {
  766. if (!e.avoidNew) throw e;
  767. return e.value
  768. }
  769. "string" == typeof e && (i = n, n = r, r = t, t = e, e = null);
  770. var o = e && "object" === C(e);
  771. if (e = e || {}, this.json = e.json || r, this.path = e.path || t, this.resultType = e.resultType || "value", this.flatten = e.flatten || !1, this.wrap = !A.call(e, "wrap") || e.wrap, this.sandbox = e.sandbox || {}, this.eval = void 0 === e.eval ? "safe" : e.eval, this.ignoreEvalErrors = void 0 !== e.ignoreEvalErrors && e.ignoreEvalErrors, this.parent = e.parent || null, this.parentProperty = e.parentProperty || null, this.callback = e.callback || n || null, this.otherTypeCallback = e.otherTypeCallback || i || function() {
  772. throw new TypeError("You must supply an otherTypeCallback callback option with the @other() operator.")
  773. }, !1 !== e.autostart) {
  774. var a = {
  775. path: o ? e.path : t
  776. };
  777. o ? "json" in e && (a.json = e.json) : a.json = r;
  778. a = this.evaluate(a);
  779. if (!a || "object" !== C(a)) throw new x(a);
  780. return a
  781. }
  782. }
  783. F.prototype.evaluate = function(e, t, r, n) {
  784. var i = this,
  785. o = this.parent,
  786. a = this.parentProperty,
  787. s = this.flatten,
  788. u = this.wrap;
  789. if (this.currResultType = this.resultType, this.currEval = this.eval, this.currSandbox = this.sandbox, r = r || this.callback, this.currOtherTypeCallback = n || this.otherTypeCallback, t = t || this.json, (e = e || this.path) && "object" === C(e) && !Array.isArray(e)) {
  790. if (!e.path && "" !== e.path) throw new TypeError('You must supply a "path" property when providing an object argument to JSONPath.evaluate().');
  791. if (!A.call(e, "json")) throw new TypeError('You must supply a "json" property when providing an object argument to JSONPath.evaluate().');
  792. t = e.json, s = A.call(e, "flatten") ? e.flatten : s, this.currResultType = A.call(e, "resultType") ? e.resultType : this.currResultType, this.currSandbox = A.call(e, "sandbox") ? e.sandbox : this.currSandbox, u = A.call(e, "wrap") ? e.wrap : u, this.currEval = A.call(e, "eval") ? e.eval : this.currEval, r = A.call(e, "callback") ? e.callback : r, this.currOtherTypeCallback = A.call(e, "otherTypeCallback") ? e.otherTypeCallback : this.currOtherTypeCallback, o = A.call(e, "parent") ? e.parent : o, a = A.call(e, "parentProperty") ? e.parentProperty : a, e = e.path
  793. }
  794. if (o = o || null, a = a || null, Array.isArray(e) && (e = F.toPathString(e)), (e || "" === e) && t) {
  795. e = F.toPathArray(e);
  796. "$" === e[0] && 1 < e.length && e.shift(), this._hasParentSelector = null;
  797. r = this._trace(e, t, ["$"], o, a, r).filter(function(e) {
  798. return e && !e.isParentSelector
  799. });
  800. return r.length ? u || 1 !== r.length || r[0].hasArrExpr ? r.reduce(function(e, t) {
  801. t = i._getPreferredOutput(t);
  802. return s && Array.isArray(t) ? e = e.concat(t) : e.push(t), e
  803. }, []) : this._getPreferredOutput(r[0]) : u ? [] : void 0
  804. }
  805. }, F.prototype._getPreferredOutput = function(e) {
  806. var t = this.currResultType;
  807. switch (t) {
  808. case "all":
  809. var r = Array.isArray(e.path) ? e.path : F.toPathArray(e.path);
  810. return e.pointer = F.toPointer(r), e.path = "string" == typeof e.path ? e.path : F.toPathString(e.path), e;
  811. case "value":
  812. case "parent":
  813. case "parentProperty":
  814. return e[t];
  815. case "path":
  816. return F.toPathString(e[t]);
  817. case "pointer":
  818. return F.toPointer(e.path);
  819. default:
  820. throw new TypeError("Unknown result type")
  821. }
  822. }, F.prototype._handleCallback = function(e, t, r) {
  823. var n;
  824. t && (n = this._getPreferredOutput(e), e.path = "string" == typeof e.path ? e.path : F.toPathString(e.path), t(n, r, e))
  825. }, F.prototype._trace = function(t, n, i, o, a, s, e, r) {
  826. var u = this;
  827. if (!t.length) return v = {
  828. path: i,
  829. value: n,
  830. parent: o,
  831. parentProperty: a,
  832. hasArrExpr: e
  833. }, this._handleCallback(v, s, "value"), v;
  834. var c = t[0],
  835. l = t.slice(1),
  836. h = [];
  837. function p(e) {
  838. Array.isArray(e) ? e.forEach(function(e) {
  839. h.push(e)
  840. }) : h.push(e)
  841. }
  842. if (("string" != typeof c || r) && n && A.call(n, c)) p(this._trace(l, n[c], w(i, c), n, c, s, e));
  843. else if ("*" === c) this._walk(n, function(e) {
  844. p(u._trace(l, n[e], w(i, e), n, e, s, !0, !0))
  845. });
  846. else if (".." === c) p(this._trace(l, n, i, o, a, s, e)), this._walk(n, function(e) {
  847. "object" === C(n[e]) && p(u._trace(t.slice(), n[e], w(i, e), n, e, s, !0))
  848. });
  849. else {
  850. if ("^" === c) return this._hasParentSelector = !0, {
  851. path: i.slice(0, -1),
  852. expr: l,
  853. isParentSelector: !0
  854. };
  855. if ("~" === c) return v = {
  856. path: w(i, c),
  857. value: a,
  858. parent: o,
  859. parentProperty: null
  860. }, this._handleCallback(v, s, "property"), v;
  861. if ("$" === c) p(this._trace(l, n, i, null, null, s, e));
  862. else if (/^(\x2D?[0-9]*):(\x2D?[0-9]*):?([0-9]*)$/.test(c)) p(this._slice(c, l, n, i, o, a, s));
  863. else if (0 === c.indexOf("?(")) {
  864. if (!1 === this.currEval) throw new Error("Eval [?(expr)] prevented in JSONPath expression.");
  865. var f = c.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/, "$1"),
  866. d = /@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])?((?:[\0->@-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))(?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\)\])['\]]/g.exec(f);
  867. d ? this._walk(n, function(e) {
  868. var t = [d[2]],
  869. r = d[1] ? n[e][d[1]] : n[e];
  870. 0 < u._trace(t, r, i, o, a, s, !0).length && p(u._trace(l, n[e], w(i, e), n, e, s, !0))
  871. }) : this._walk(n, function(e) {
  872. u._eval(f, n[e], e, i, o, a) && p(u._trace(l, n[e], w(i, e), n, e, s, !0))
  873. })
  874. } else if ("(" === c[0]) {
  875. if (!1 === this.currEval) throw new Error("Eval [(expr)] prevented in JSONPath expression.");
  876. p(this._trace(k(this._eval(c, n, i[i.length - 1], i.slice(0, -1), o, a), l), n, i, o, a, s, e))
  877. } else if ("@" === c[0]) {
  878. var y = !1,
  879. b = c.slice(1, -2);
  880. switch (b) {
  881. case "scalar":
  882. n && ["object", "function"].includes(C(n)) || (y = !0);
  883. break;
  884. case "boolean":
  885. case "string":
  886. case "undefined":
  887. case "function":
  888. C(n) === b && (y = !0);
  889. break;
  890. case "integer":
  891. !Number.isFinite(n) || n % 1 || (y = !0);
  892. break;
  893. case "number":
  894. Number.isFinite(n) && (y = !0);
  895. break;
  896. case "nonFinite":
  897. "number" != typeof n || Number.isFinite(n) || (y = !0);
  898. break;
  899. case "object":
  900. n && C(n) === b && (y = !0);
  901. break;
  902. case "array":
  903. Array.isArray(n) && (y = !0);
  904. break;
  905. case "other":
  906. y = this.currOtherTypeCallback(n, i, o, a);
  907. break;
  908. case "null":
  909. null === n && (y = !0);
  910. break;
  911. default:
  912. throw new TypeError("Unknown value type " + b)
  913. }
  914. if (y) return v = {
  915. path: i,
  916. value: n,
  917. parent: o,
  918. parentProperty: a
  919. }, this._handleCallback(v, s, "value"), v
  920. } else if ("`" === c[0] && n && A.call(n, c.slice(1))) {
  921. var v = c.slice(1);
  922. p(this._trace(l, n[v], w(i, v), n, v, s, e, !0))
  923. } else if (c.includes(",")) {
  924. var E = function(e, t) {
  925. var r = "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
  926. if (!r) {
  927. if (Array.isArray(e) || (r = O(e)) || t && e && "number" == typeof e.length) {
  928. r && (e = r);
  929. var n = 0,
  930. t = function() {};
  931. return {
  932. s: t,
  933. n: function() {
  934. return n >= e.length ? {
  935. done: !0
  936. } : {
  937. done: !1,
  938. value: e[n++]
  939. }
  940. },
  941. e: function(e) {
  942. throw e
  943. },
  944. f: t
  945. }
  946. }
  947. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
  948. }
  949. var i, o = !0,
  950. a = !1;
  951. return {
  952. s: function() {
  953. r = r.call(e)
  954. },
  955. n: function() {
  956. var e = r.next();
  957. return o = e.done, e
  958. },
  959. e: function(e) {
  960. a = !0, i = e
  961. },
  962. f: function() {
  963. try {
  964. o || null == r.return || r.return()
  965. } finally {
  966. if (a) throw i
  967. }
  968. }
  969. }
  970. }(c.split(","));
  971. try {
  972. for (E.s(); !(g = E.n()).done;) {
  973. var g = g.value;
  974. p(this._trace(k(g, l), n, i, o, a, s, !0))
  975. }
  976. } catch (e) {
  977. E.e(e)
  978. } finally {
  979. E.f()
  980. }
  981. } else !r && n && A.call(n, c) && p(this._trace(l, n[c], w(i, c), n, c, s, e, !0))
  982. }
  983. if (this._hasParentSelector)
  984. for (var x = 0; x < h.length; x++) {
  985. var F = h[x];
  986. if (F && F.isParentSelector) {
  987. var D = this._trace(F.expr, n, F.path, o, a, s, e);
  988. if (Array.isArray(D)) {
  989. h[x] = D[0];
  990. for (var _ = D.length, m = 1; m < _; m++) x++, h.splice(x, 0, D[m])
  991. } else h[x] = D
  992. }
  993. }
  994. return h
  995. }, F.prototype._walk = function(e, t) {
  996. if (Array.isArray(e))
  997. for (var r = e.length, n = 0; n < r; n++) t(n);
  998. else e && "object" === C(e) && Object.keys(e).forEach(function(e) {
  999. t(e)
  1000. })
  1001. }, F.prototype._slice = function(e, t, r, n, i, o, a) {
  1002. if (Array.isArray(r)) {
  1003. for (var s = r.length, u = e.split(":"), c = u[2] && Number.parseInt(u[2]) || 1, e = u[0] && Number.parseInt(u[0]) || 0, l = u[1] && Number.parseInt(u[1]) || s, e = e < 0 ? Math.max(0, e + s) : Math.min(s, e), l = l < 0 ? Math.max(0, l + s) : Math.min(s, l), h = [], p = e; p < l; p += c) this._trace(k(p, t), r, n, i, o, a, !0).forEach(function(e) {
  1004. h.push(e)
  1005. });
  1006. return h
  1007. }
  1008. }, F.prototype._eval = function(t, e, r, n, i, o) {
  1009. var a = this;
  1010. this.currSandbox._$_parentProperty = o, this.currSandbox._$_parent = i, this.currSandbox._$_property = r, this.currSandbox._$_root = this.json, this.currSandbox._$_v = e;
  1011. e = t.includes("@path");
  1012. e && (this.currSandbox._$_path = F.toPathString(n.concat([r])));
  1013. var s = this.currEval + "Script:" + t;
  1014. if (!F.cache[s]) {
  1015. var u = t.replace(/@parentProperty/g, "_$_parentProperty").replace(/@parent/g, "_$_parent").replace(/@property/g, "_$_property").replace(/@root/g, "_$_root").replace(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g, "_$_v$1");
  1016. if (e && (u = u.replace(/@path/g, "_$_path")), "safe" === this.currEval || !0 === this.currEval || void 0 === this.currEval) F.cache[s] = new this.safeVm.Script(u);
  1017. else if ("native" === this.currEval) F.cache[s] = new this.vm.Script(u);
  1018. else if ("function" == typeof this.currEval && this.currEval.prototype && A.call(this.currEval.prototype, "runInNewContext")) {
  1019. e = this.currEval;
  1020. F.cache[s] = new e(u)
  1021. } else {
  1022. if ("function" != typeof this.currEval) throw new TypeError('Unknown "eval" property "'.concat(this.currEval, '"'));
  1023. F.cache[s] = {
  1024. runInNewContext: function(e) {
  1025. return a.currEval(u, e)
  1026. }
  1027. }
  1028. }
  1029. }
  1030. try {
  1031. return F.cache[s].runInNewContext(this.currSandbox)
  1032. } catch (e) {
  1033. if (this.ignoreEvalErrors) return !1;
  1034. throw new Error("jsonPath: " + e.message + ": " + t)
  1035. }
  1036. }, F.cache = {}, F.toPathString = function(e) {
  1037. for (var t = e, r = t.length, n = "$", i = 1; i < r; i++) /^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i]) || (n += /^[\*0-9]+$/.test(t[i]) ? "[" + t[i] + "]" : "['" + t[i] + "']");
  1038. return n
  1039. }, F.toPointer = function(e) {
  1040. for (var t = e, r = t.length, n = "", i = 1; i < r; i++) /^(~|\^|@(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\(\))$/.test(t[i]) || (n += "/" + t[i].toString().replace(/~/g, "~0").replace(/\//g, "~1"));
  1041. return n
  1042. }, F.toPathArray = function(e) {
  1043. var t = F.cache;
  1044. if (t[e]) return t[e].concat();
  1045. var r = [],
  1046. n = e.replace(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g, ";$&;").replace(/['\[](\??\((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?\))['\]](?!(?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])\])/g, function(e, t) {
  1047. return "[#" + (r.push(t) - 1) + "]"
  1048. }).replace(/\[["']((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)["']\]/g, function(e, t) {
  1049. return "['" + t.replace(/\./g, "%@%").replace(/~/g, "%%@@%%") + "']"
  1050. }).replace(/~/g, ";~;").replace(/["']?\.["']?(?!(?:[\0-Z\\-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*\])|\[["']?/g, ";").replace(/%@%/g, ".").replace(/%%@@%%/g, "~").replace(/(?:;)?(\^+)(?:;)?/g, function(e, t) {
  1051. return ";" + t.split("").join(";") + ";"
  1052. }).replace(/;;;|;;/g, ";..;").replace(/;$|'?\]|'$/g, "").split(";").map(function(e) {
  1053. var t = e.match(/#([0-9]+)/);
  1054. return t && t[1] ? r[t[1]] : e
  1055. });
  1056. return t[e] = n, t[e].concat()
  1057. };
  1058. E.plugins.register(b, g);
  1059. var D = {
  1060. evalAst: function(e, t) {
  1061. switch (e.type) {
  1062. case "BinaryExpression":
  1063. case "LogicalExpression":
  1064. return D.evalBinaryExpression(e, t);
  1065. case "Compound":
  1066. return D.evalCompound(e, t);
  1067. case "ConditionalExpression":
  1068. return D.evalConditionalExpression(e, t);
  1069. case "Identifier":
  1070. return D.evalIdentifier(e, t);
  1071. case "Literal":
  1072. return D.evalLiteral(e, t);
  1073. case "MemberExpression":
  1074. return D.evalMemberExpression(e, t);
  1075. case "UnaryExpression":
  1076. return D.evalUnaryExpression(e, t);
  1077. case "ArrayExpression":
  1078. return D.evalArrayExpression(e, t);
  1079. case "CallExpression":
  1080. return D.evalCallExpression(e, t);
  1081. case "AssignmentExpression":
  1082. return D.evalAssignmentExpression(e, t);
  1083. default:
  1084. throw SyntaxError("Unexpected expression", e)
  1085. }
  1086. },
  1087. evalBinaryExpression: function(e, t) {
  1088. return {
  1089. "||": function(e, t) {
  1090. return e || t()
  1091. },
  1092. "&&": function(e, t) {
  1093. return e && t()
  1094. },
  1095. "|": function(e, t) {
  1096. return e | t()
  1097. },
  1098. "^": function(e, t) {
  1099. return e ^ t()
  1100. },
  1101. "&": function(e, t) {
  1102. return e & t()
  1103. },
  1104. "==": function(e, t) {
  1105. return e == t()
  1106. },
  1107. "!=": function(e, t) {
  1108. return e != t()
  1109. },
  1110. "===": function(e, t) {
  1111. return e === t()
  1112. },
  1113. "!==": function(e, t) {
  1114. return e !== t()
  1115. },
  1116. "<": function(e, t) {
  1117. return e < t()
  1118. },
  1119. ">": function(e, t) {
  1120. return e > t()
  1121. },
  1122. "<=": function(e, t) {
  1123. return e <= t()
  1124. },
  1125. ">=": function(e, t) {
  1126. return e >= t()
  1127. },
  1128. "<<": function(e, t) {
  1129. return e << t()
  1130. },
  1131. ">>": function(e, t) {
  1132. return e >> t()
  1133. },
  1134. ">>>": function(e, t) {
  1135. return e >>> t()
  1136. },
  1137. "+": function(e, t) {
  1138. return e + t()
  1139. },
  1140. "-": function(e, t) {
  1141. return e - t()
  1142. },
  1143. "*": function(e, t) {
  1144. return e * t()
  1145. },
  1146. "/": function(e, t) {
  1147. return e / t()
  1148. },
  1149. "%": function(e, t) {
  1150. return e % t()
  1151. }
  1152. } [e.operator](D.evalAst(e.left, t), function() {
  1153. return D.evalAst(e.right, t)
  1154. })
  1155. },
  1156. evalCompound: function(e, t) {
  1157. for (var r = 0; r < e.body.length; r++) {
  1158. "Identifier" === e.body[r].type && ["var", "let", "const"].includes(e.body[r].name) && e.body[r + 1] && "AssignmentExpression" === e.body[r + 1].type && (r += 1);
  1159. var n = e.body[r],
  1160. i = D.evalAst(n, t)
  1161. }
  1162. return i
  1163. },
  1164. evalConditionalExpression: function(e, t) {
  1165. return D.evalAst(e.test, t) ? D.evalAst(e.consequent, t) : D.evalAst(e.alternate, t)
  1166. },
  1167. evalIdentifier: function(e, t) {
  1168. if (e.name in t) return t[e.name];
  1169. throw ReferenceError("".concat(e.name, " is not defined"))
  1170. },
  1171. evalLiteral: function(e) {
  1172. return e.value
  1173. },
  1174. evalMemberExpression: function(e, t) {
  1175. var r = e.computed ? D.evalAst(e.property) : e.property.name,
  1176. t = D.evalAst(e.object, t),
  1177. r = t[r];
  1178. return "function" == typeof r ? r.bind(t) : r
  1179. },
  1180. evalUnaryExpression: function(e, t) {
  1181. return {
  1182. "-": function(e) {
  1183. return -D.evalAst(e, t)
  1184. },
  1185. "!": function(e) {
  1186. return !D.evalAst(e, t)
  1187. },
  1188. "~": function(e) {
  1189. return ~D.evalAst(e, t)
  1190. },
  1191. "+": function(e) {
  1192. return +D.evalAst(e, t)
  1193. }
  1194. } [e.operator](e.argument)
  1195. },
  1196. evalArrayExpression: function(e, t) {
  1197. return e.elements.map(function(e) {
  1198. return D.evalAst(e, t)
  1199. })
  1200. },
  1201. evalCallExpression: function(e, t) {
  1202. var r = e.arguments.map(function(e) {
  1203. return D.evalAst(e, t)
  1204. });
  1205. return D.evalAst(e.callee, t).apply(void 0, f(r))
  1206. },
  1207. evalAssignmentExpression: function(e, t) {
  1208. if ("Identifier" !== e.left.type) throw SyntaxError("Invalid left-hand side in assignment");
  1209. var r = e.left.name,
  1210. e = D.evalAst(e.right, t);
  1211. return t[r] = e, t[r]
  1212. }
  1213. },
  1214. b = function() {
  1215. return c(function e(t) {
  1216. s(this, e), this.code = t, this.ast = E(this.code)
  1217. }, [{
  1218. key: "runInNewContext",
  1219. value: function(e) {
  1220. e = r({}, e);
  1221. return D.evalAst(this.ast, e)
  1222. }
  1223. }])
  1224. }();
  1225. F.prototype.vm = {
  1226. Script: function() {
  1227. return c(function e(t) {
  1228. s(this, e), this.code = t
  1229. }, [{
  1230. key: "runInNewContext",
  1231. value: function(n) {
  1232. var e = this.code,
  1233. t = Object.keys(n),
  1234. r = [];
  1235. ! function(e, t, r) {
  1236. for (var n = e.length, i = 0; i < n; i++) r(e[i]) && t.push(e.splice(i--, 1)[0])
  1237. }(t, r, function(e) {
  1238. return "function" == typeof n[e]
  1239. });
  1240. var i = t.map(function(e) {
  1241. return n[e]
  1242. }),
  1243. r = r.reduce(function(e, t) {
  1244. var r = n[t].toString();
  1245. return /function/.test(r) || (r = "function " + r), "var " + t + "=" + r + ";" + e
  1246. }, "");
  1247. /(["'])use strict\1/.test(e = r + e) || t.includes("arguments") || (e = "var arguments = undefined;" + e);
  1248. r = (e = e.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/, "")).lastIndexOf(";"), e = -1 < r ? e.slice(0, r + 1) + " return " + e.slice(r + 1) : " return " + e;
  1249. return o(Function, t.concat([e])).apply(void 0, f(i))
  1250. }
  1251. }])
  1252. }()
  1253. }, F.prototype.safeVm = {
  1254. Script: b
  1255. }, e.JSONPath = F, e.SafeScript = b
  1256. });