ov-configurator 1.0.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.
- package/README.md +170 -0
- package/dist/calculator.d.ts +60 -0
- package/dist/configurator.d.ts +11 -0
- package/dist/index.d.ts +3 -0
- package/dist/ov-configurator.cjs +30 -0
- package/dist/ov-configurator.iife.js +30 -0
- package/dist/ov-configurator.js +1784 -0
- package/dist/types.d.ts +63 -0
- package/package.json +40 -0
|
@@ -0,0 +1,1784 @@
|
|
|
1
|
+
//#region \0rollupPluginBabelHelpers.js
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
this.v = e, this.k = t;
|
|
4
|
+
}
|
|
5
|
+
function t(e, t) {
|
|
6
|
+
(t == null || t > e.length) && (t = e.length);
|
|
7
|
+
for (var n = 0, r = Array(t); n < t; n++) r[n] = e[n];
|
|
8
|
+
return r;
|
|
9
|
+
}
|
|
10
|
+
function n(e) {
|
|
11
|
+
if (Array.isArray(e)) return t(e);
|
|
12
|
+
}
|
|
13
|
+
function r(e) {
|
|
14
|
+
if (e === void 0) throw ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
15
|
+
return e;
|
|
16
|
+
}
|
|
17
|
+
function i(e, t, n) {
|
|
18
|
+
return t = d(t), y(e, m() ? Reflect.construct(t, n || [], d(e).constructor) : t.apply(e, n));
|
|
19
|
+
}
|
|
20
|
+
function a(e, t) {
|
|
21
|
+
if (!(e instanceof t)) throw TypeError("Cannot call a class as a function");
|
|
22
|
+
}
|
|
23
|
+
function o(e, t, n) {
|
|
24
|
+
if (m()) return Reflect.construct.apply(null, arguments);
|
|
25
|
+
var r = [null];
|
|
26
|
+
r.push.apply(r, t);
|
|
27
|
+
var i = new (e.bind.apply(e, r))();
|
|
28
|
+
return n && b(i, n.prototype), i;
|
|
29
|
+
}
|
|
30
|
+
function s(e, t) {
|
|
31
|
+
for (var n = 0; n < t.length; n++) {
|
|
32
|
+
var r = t[n];
|
|
33
|
+
r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, C(r.key), r);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function c(e, t, n) {
|
|
37
|
+
return t && s(e.prototype, t), n && s(e, n), Object.defineProperty(e, "prototype", { writable: !1 }), e;
|
|
38
|
+
}
|
|
39
|
+
function l(e, t) {
|
|
40
|
+
var n = typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
|
|
41
|
+
if (!n) {
|
|
42
|
+
if (Array.isArray(e) || (n = T(e)) || t && e && typeof e.length == "number") {
|
|
43
|
+
n && (e = n);
|
|
44
|
+
var r = 0, i = function() {};
|
|
45
|
+
return {
|
|
46
|
+
s: i,
|
|
47
|
+
n: function() {
|
|
48
|
+
return r >= e.length ? { done: !0 } : {
|
|
49
|
+
done: !1,
|
|
50
|
+
value: e[r++]
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
e: function(e) {
|
|
54
|
+
throw e;
|
|
55
|
+
},
|
|
56
|
+
f: i
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
60
|
+
}
|
|
61
|
+
var a, o = !0, s = !1;
|
|
62
|
+
return {
|
|
63
|
+
s: function() {
|
|
64
|
+
n = n.call(e);
|
|
65
|
+
},
|
|
66
|
+
n: function() {
|
|
67
|
+
var e = n.next();
|
|
68
|
+
return o = e.done, e;
|
|
69
|
+
},
|
|
70
|
+
e: function(e) {
|
|
71
|
+
s = !0, a = e;
|
|
72
|
+
},
|
|
73
|
+
f: function() {
|
|
74
|
+
try {
|
|
75
|
+
o || n.return == null || n.return();
|
|
76
|
+
} finally {
|
|
77
|
+
if (s) throw a;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function u(e, t, n) {
|
|
83
|
+
return (t = C(t)) in e ? Object.defineProperty(e, t, {
|
|
84
|
+
value: n,
|
|
85
|
+
enumerable: !0,
|
|
86
|
+
configurable: !0,
|
|
87
|
+
writable: !0
|
|
88
|
+
}) : e[t] = n, e;
|
|
89
|
+
}
|
|
90
|
+
function d(e) {
|
|
91
|
+
return d = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
|
|
92
|
+
return e.__proto__ || Object.getPrototypeOf(e);
|
|
93
|
+
}, d(e);
|
|
94
|
+
}
|
|
95
|
+
function f(e, t) {
|
|
96
|
+
if (typeof t != "function" && t !== null) throw TypeError("Super expression must either be null or a function");
|
|
97
|
+
e.prototype = Object.create(t && t.prototype, { constructor: {
|
|
98
|
+
value: e,
|
|
99
|
+
writable: !0,
|
|
100
|
+
configurable: !0
|
|
101
|
+
} }), Object.defineProperty(e, "prototype", { writable: !1 }), t && b(e, t);
|
|
102
|
+
}
|
|
103
|
+
function p(e) {
|
|
104
|
+
try {
|
|
105
|
+
return Function.toString.call(e).indexOf("[native code]") !== -1;
|
|
106
|
+
} catch (t) {
|
|
107
|
+
return typeof e == "function";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function m() {
|
|
111
|
+
try {
|
|
112
|
+
var e = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
113
|
+
} catch (e) {}
|
|
114
|
+
return (m = function() {
|
|
115
|
+
return !!e;
|
|
116
|
+
})();
|
|
117
|
+
}
|
|
118
|
+
function h(e) {
|
|
119
|
+
if (typeof Symbol < "u" && e[Symbol.iterator] != null || e["@@iterator"] != null) return Array.from(e);
|
|
120
|
+
}
|
|
121
|
+
function g() {
|
|
122
|
+
throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
123
|
+
}
|
|
124
|
+
function _(e, t) {
|
|
125
|
+
var n = Object.keys(e);
|
|
126
|
+
if (Object.getOwnPropertySymbols) {
|
|
127
|
+
var r = Object.getOwnPropertySymbols(e);
|
|
128
|
+
t && (r = r.filter(function(t) {
|
|
129
|
+
return Object.getOwnPropertyDescriptor(e, t).enumerable;
|
|
130
|
+
})), n.push.apply(n, r);
|
|
131
|
+
}
|
|
132
|
+
return n;
|
|
133
|
+
}
|
|
134
|
+
function v(e) {
|
|
135
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
136
|
+
var n = arguments[t] == null ? {} : arguments[t];
|
|
137
|
+
t % 2 ? _(Object(n), !0).forEach(function(t) {
|
|
138
|
+
u(e, t, n[t]);
|
|
139
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : _(Object(n)).forEach(function(t) {
|
|
140
|
+
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return e;
|
|
144
|
+
}
|
|
145
|
+
function y(e, t) {
|
|
146
|
+
if (t && (typeof t == "object" || typeof t == "function")) return t;
|
|
147
|
+
if (t !== void 0) throw TypeError("Derived constructors may only return object or undefined");
|
|
148
|
+
return r(e);
|
|
149
|
+
}
|
|
150
|
+
function b(e, t) {
|
|
151
|
+
return b = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
|
|
152
|
+
return e.__proto__ = t, e;
|
|
153
|
+
}, b(e, t);
|
|
154
|
+
}
|
|
155
|
+
function x(e) {
|
|
156
|
+
return n(e) || h(e) || T(e) || g();
|
|
157
|
+
}
|
|
158
|
+
function S(e, t) {
|
|
159
|
+
if (typeof e != "object" || !e) return e;
|
|
160
|
+
var n = e[Symbol.toPrimitive];
|
|
161
|
+
if (n !== void 0) {
|
|
162
|
+
var r = n.call(e, t || "default");
|
|
163
|
+
if (typeof r != "object") return r;
|
|
164
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
165
|
+
}
|
|
166
|
+
return (t === "string" ? String : Number)(e);
|
|
167
|
+
}
|
|
168
|
+
function C(e) {
|
|
169
|
+
var t = S(e, "string");
|
|
170
|
+
return typeof t == "symbol" ? t : t + "";
|
|
171
|
+
}
|
|
172
|
+
function w(e) {
|
|
173
|
+
"@babel/helpers - typeof";
|
|
174
|
+
return w = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
175
|
+
return typeof e;
|
|
176
|
+
} : function(e) {
|
|
177
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
178
|
+
}, w(e);
|
|
179
|
+
}
|
|
180
|
+
function T(e, n) {
|
|
181
|
+
if (e) {
|
|
182
|
+
if (typeof e == "string") return t(e, n);
|
|
183
|
+
var r = {}.toString.call(e).slice(8, -1);
|
|
184
|
+
return r === "Object" && e.constructor && (r = e.constructor.name), r === "Map" || r === "Set" ? Array.from(e) : r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? t(e, n) : void 0;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function E(t) {
|
|
188
|
+
var n, r;
|
|
189
|
+
function i(n, r) {
|
|
190
|
+
try {
|
|
191
|
+
var o = t[n](r), s = o.value, c = s instanceof e;
|
|
192
|
+
Promise.resolve(c ? s.v : s).then(function(e) {
|
|
193
|
+
if (c) {
|
|
194
|
+
var r = n === "return" && s.k ? n : "next";
|
|
195
|
+
if (!s.k || e.done) return i(r, e);
|
|
196
|
+
e = t[r](e).value;
|
|
197
|
+
}
|
|
198
|
+
a(!!o.done, e);
|
|
199
|
+
}, function(e) {
|
|
200
|
+
i("throw", e);
|
|
201
|
+
});
|
|
202
|
+
} catch (e) {
|
|
203
|
+
a(2, e);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function a(e, t) {
|
|
207
|
+
e === 2 ? n.reject(t) : n.resolve({
|
|
208
|
+
value: t,
|
|
209
|
+
done: e
|
|
210
|
+
}), (n = n.next) ? i(n.key, n.arg) : r = null;
|
|
211
|
+
}
|
|
212
|
+
this._invoke = function(e, t) {
|
|
213
|
+
return new Promise(function(a, o) {
|
|
214
|
+
var s = {
|
|
215
|
+
key: e,
|
|
216
|
+
arg: t,
|
|
217
|
+
resolve: a,
|
|
218
|
+
reject: o,
|
|
219
|
+
next: null
|
|
220
|
+
};
|
|
221
|
+
r ? r = r.next = s : (n = r = s, i(e, t));
|
|
222
|
+
});
|
|
223
|
+
}, typeof t.return != "function" && (this.return = void 0);
|
|
224
|
+
}
|
|
225
|
+
E.prototype[typeof Symbol == "function" && Symbol.asyncIterator || "@@asyncIterator"] = function() {
|
|
226
|
+
return this;
|
|
227
|
+
}, E.prototype.next = function(e) {
|
|
228
|
+
return this._invoke("next", e);
|
|
229
|
+
}, E.prototype.throw = function(e) {
|
|
230
|
+
return this._invoke("throw", e);
|
|
231
|
+
}, E.prototype.return = function(e) {
|
|
232
|
+
return this._invoke("return", e);
|
|
233
|
+
};
|
|
234
|
+
function D(e) {
|
|
235
|
+
var t = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
236
|
+
return D = function(e) {
|
|
237
|
+
if (e === null || !p(e)) return e;
|
|
238
|
+
if (typeof e != "function") throw TypeError("Super expression must either be null or a function");
|
|
239
|
+
if (t !== void 0) {
|
|
240
|
+
if (t.has(e)) return t.get(e);
|
|
241
|
+
t.set(e, n);
|
|
242
|
+
}
|
|
243
|
+
function n() {
|
|
244
|
+
return o(e, arguments, d(this).constructor);
|
|
245
|
+
}
|
|
246
|
+
return n.prototype = Object.create(e.prototype, { constructor: {
|
|
247
|
+
value: n,
|
|
248
|
+
enumerable: !1,
|
|
249
|
+
writable: !0,
|
|
250
|
+
configurable: !0
|
|
251
|
+
} }), b(n, e);
|
|
252
|
+
}, D(e);
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/calculator.ts
|
|
256
|
+
var O;
|
|
257
|
+
(function() {
|
|
258
|
+
var e = Number;
|
|
259
|
+
e.isNaN || (e.isNaN = function(e) {
|
|
260
|
+
return typeof e == "number" && isNaN(e);
|
|
261
|
+
}), Array.prototype.find || (Array.prototype.find = function(e, t) {
|
|
262
|
+
if (this == null) throw TypeError("Array.prototype.find called on null or undefined");
|
|
263
|
+
if (typeof e != "function") throw TypeError("predicate must be a function");
|
|
264
|
+
for (var n = Object(this), r = n.length >>> 0, i = 0; i < r; i++) {
|
|
265
|
+
var a = n[i];
|
|
266
|
+
if (e.call(t, a, i, n)) return a;
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
})();
|
|
270
|
+
var k = {
|
|
271
|
+
DATA_ATTRIBUTE: "data",
|
|
272
|
+
CUSTOM: "custom",
|
|
273
|
+
DEFAULT: "default"
|
|
274
|
+
}, A = {
|
|
275
|
+
PARENT: "parent",
|
|
276
|
+
SELF: "self",
|
|
277
|
+
CLOSEST: "closest"
|
|
278
|
+
}, j = /* @__PURE__ */ function() {
|
|
279
|
+
function e(t) {
|
|
280
|
+
a(this, e), this.node = null, this.animationId = 0, this.prevValue = void 0;
|
|
281
|
+
var n = t.selector;
|
|
282
|
+
this.selector = n, this.options = v({
|
|
283
|
+
animated: !1,
|
|
284
|
+
duration: 800,
|
|
285
|
+
dots: 0,
|
|
286
|
+
dataKey: n,
|
|
287
|
+
calculateFunction: function() {
|
|
288
|
+
return null;
|
|
289
|
+
},
|
|
290
|
+
attribute: !1,
|
|
291
|
+
animation: ["animate__faster", "animate__pulse"],
|
|
292
|
+
animatedNode: A.PARENT,
|
|
293
|
+
animatedNodeSelector: ""
|
|
294
|
+
}, t);
|
|
295
|
+
}
|
|
296
|
+
return c(e, [
|
|
297
|
+
{
|
|
298
|
+
key: "getNode",
|
|
299
|
+
value: function(e) {
|
|
300
|
+
var t = e.prefix, n = e.parentNode, r = e.type;
|
|
301
|
+
return (r === void 0 ? k.DEFAULT : r) === k.CUSTOM ? this.node = n.querySelector(this.options.selector) : (this.node = n.querySelector(`[data-${t}="${this.options.selector}"]`), !this.node && this.options.attribute && n.getAttribute(`data-${t}`) === this.options.selector && (this.node = n)), this.node;
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
key: "changeValue",
|
|
306
|
+
value: function(e) {
|
|
307
|
+
if (this.node) {
|
|
308
|
+
if (this.animateBlock(e), this.options.attribute) {
|
|
309
|
+
var t = this.node.dataset.calcAttribute;
|
|
310
|
+
t && this.node.setAttribute(t, String(e));
|
|
311
|
+
} else {
|
|
312
|
+
if (Number.isNaN(Number(e))) {
|
|
313
|
+
this.node.innerHTML = String(e);
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
this.animateNumber(Number(e));
|
|
317
|
+
}
|
|
318
|
+
this.prevValue = e;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
key: "animateBlock",
|
|
324
|
+
value: function(e) {
|
|
325
|
+
var t, n, r;
|
|
326
|
+
if (e !== this.prevValue) {
|
|
327
|
+
var i = this.options, a = i.animated, o = i.animation, s = i.animatedNode, c = i.animatedNodeSelector, l = null;
|
|
328
|
+
switch (s) {
|
|
329
|
+
case A.SELF:
|
|
330
|
+
l = this.node;
|
|
331
|
+
break;
|
|
332
|
+
case A.PARENT:
|
|
333
|
+
l = (t = this.node) == null ? void 0 : t.parentNode;
|
|
334
|
+
break;
|
|
335
|
+
case A.CLOSEST:
|
|
336
|
+
l = (n = (r = this.node) == null ? void 0 : r.closest(c)) == null ? null : n;
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
if (a && l) {
|
|
340
|
+
var u, d = ["animate__animated"].concat(x(o)), f = function() {
|
|
341
|
+
var e;
|
|
342
|
+
(e = l.classList).remove.apply(e, x(d));
|
|
343
|
+
};
|
|
344
|
+
(u = l.classList).add.apply(u, x(d)), l.addEventListener("webkitAnimationEnd", f), l.addEventListener("mozAnimationEnd", f), l.addEventListener("MSAnimationEnd", f), l.addEventListener("oanimationend", f), l.addEventListener("animationend", f);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
key: "animateNumber",
|
|
351
|
+
value: function(e) {
|
|
352
|
+
var t = this, n = this.options, r = n.duration, i = r === void 0 ? 800 : r, a = n.dots, o = a === void 0 ? 0 : a, s = this.node;
|
|
353
|
+
window.cancelAnimationFrame(this.animationId);
|
|
354
|
+
var c = Number(s.textContent);
|
|
355
|
+
c = Number.isNaN(c) ? 0 : c;
|
|
356
|
+
var l = e - c, u = l > 0, d = null, f = function(n) {
|
|
357
|
+
d === null && (d = n);
|
|
358
|
+
var r = n - d;
|
|
359
|
+
s.textContent = p(r).toFixed(o), r < i ? t.animationId = window.requestAnimationFrame(f) : (s.textContent = e.toFixed(m(e)), window.cancelAnimationFrame(t.animationId));
|
|
360
|
+
};
|
|
361
|
+
function p(t) {
|
|
362
|
+
var n = c + t * l / i;
|
|
363
|
+
if (u) {
|
|
364
|
+
if (n > e) return e;
|
|
365
|
+
} else if (n < e) return e;
|
|
366
|
+
return n;
|
|
367
|
+
}
|
|
368
|
+
function m(e) {
|
|
369
|
+
var t = String(e);
|
|
370
|
+
return t.includes(".") ? t.length - 1 > o ? o : t.length - 1 : 0;
|
|
371
|
+
}
|
|
372
|
+
this.animationId = window.requestAnimationFrame(f);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
]);
|
|
376
|
+
}(), M = /* @__PURE__ */ function() {
|
|
377
|
+
function e(t) {
|
|
378
|
+
a(this, e), this.savedValues = {}, this.values = {}, this.node = null;
|
|
379
|
+
var n = t.editableFields, r = n === void 0 ? [] : n, i = t.data, o = i === void 0 ? null : i;
|
|
380
|
+
this.options = v({
|
|
381
|
+
editableFields: [],
|
|
382
|
+
prefix: "card",
|
|
383
|
+
data: null,
|
|
384
|
+
stylePrefix: "calculator",
|
|
385
|
+
dataAttributePrefix: "calc"
|
|
386
|
+
}, t), this.data = o, this.fields = r.map(function(e) {
|
|
387
|
+
return new j(e);
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
return c(e, [
|
|
391
|
+
{
|
|
392
|
+
key: "addField",
|
|
393
|
+
value: function(e) {
|
|
394
|
+
this.fields.push(new j(e));
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
key: "addSection",
|
|
399
|
+
value: function(e) {
|
|
400
|
+
var t, n = ((t = this.options.sectionsOptions) == null ? [] : t).concat([e]);
|
|
401
|
+
this.options.sectionsOptions = n;
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
key: "init",
|
|
406
|
+
value: function() {
|
|
407
|
+
var e = this;
|
|
408
|
+
if (this.data) {
|
|
409
|
+
var t = this.options, n = t.parentSelector, r = t.dataAttributePrefix, i = t.stylePrefix, a = document.querySelector(n);
|
|
410
|
+
this.fields.forEach(function(e) {
|
|
411
|
+
return e.getNode({
|
|
412
|
+
prefix: r,
|
|
413
|
+
parentNode: a
|
|
414
|
+
});
|
|
415
|
+
}), this.form = a.querySelector(`.${i}`), this.form.addEventListener("change", function() {
|
|
416
|
+
return e.changeHandler(e.form);
|
|
417
|
+
}), this.changeHandler(this.form);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
key: "getValues",
|
|
423
|
+
value: function() {
|
|
424
|
+
return this.values;
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
key: "changeHandler",
|
|
429
|
+
value: function(e) {
|
|
430
|
+
var t = this, n = Array.from(e.querySelectorAll("input")).filter(function(e) {
|
|
431
|
+
return e.checked;
|
|
432
|
+
}).reduce(function(e, t) {
|
|
433
|
+
var n = t.name.split("-");
|
|
434
|
+
return v(v({}, e), {}, u({}, n[n.length - 1], t.value));
|
|
435
|
+
}, {});
|
|
436
|
+
this.fields.forEach(function(e) {
|
|
437
|
+
try {
|
|
438
|
+
var r = e.options.calculateFunction(n, t.data);
|
|
439
|
+
if (r === null) return;
|
|
440
|
+
t.saveValue(e.selector, r), e.changeValue(r == null ? "--" : r);
|
|
441
|
+
} catch (e) {
|
|
442
|
+
console.warn(e);
|
|
443
|
+
}
|
|
444
|
+
}), this.values = n;
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
key: "saveValue",
|
|
449
|
+
value: function(e, t) {
|
|
450
|
+
this.savedValues[e] = t;
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
key: "getValue",
|
|
455
|
+
value: function(e) {
|
|
456
|
+
return this.savedValues[e];
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
key: "getHTML",
|
|
461
|
+
value: function() {
|
|
462
|
+
var e = this;
|
|
463
|
+
if (!this.data) return "";
|
|
464
|
+
var t = this.options, n = t.stylePrefix, r = t.sectionsOptions;
|
|
465
|
+
return `
|
|
466
|
+
<form action="/" class="${n}">
|
|
467
|
+
${(r == null ? [] : r).map(function(t) {
|
|
468
|
+
return e.getSectionHTML(t);
|
|
469
|
+
}).join("")}
|
|
470
|
+
</form>
|
|
471
|
+
`;
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
key: "getSectionHTML",
|
|
476
|
+
value: function(e) {
|
|
477
|
+
var t, n = this.options, r = n.stylePrefix, i = n.prefix, a = n.id, o = e.title, s = o === void 0 ? "" : o, c = e.type, l = e.inputs, u = e.className, d = u === void 0 ? "" : u, f = e.checked, p = f === void 0 ? !0 : f, m = e.inputType, h = m === void 0 ? "radio" : m;
|
|
478
|
+
if (typeof l == "function" && (l = l(this.data)), !l.length) return "";
|
|
479
|
+
var g = l[0].value, _ = (t = this.getValues()[c]) == null ? g : t;
|
|
480
|
+
return l.find(function(e) {
|
|
481
|
+
return e.value === _;
|
|
482
|
+
}) || (_ = g), `
|
|
483
|
+
<div class="${r}__section">
|
|
484
|
+
${s && `<h4 class="${r}__section-title">${s}:</h4>`}
|
|
485
|
+
<div class="${r}__section-row">
|
|
486
|
+
${l.map(function(e, t) {
|
|
487
|
+
var n = _ === e.value ? "checked" : "";
|
|
488
|
+
return `
|
|
489
|
+
<div class="${r}__section-col ${d}">
|
|
490
|
+
<input
|
|
491
|
+
${p ? n : ""}
|
|
492
|
+
name="${i}-${a}-${c}"
|
|
493
|
+
id="${i}-${a}-${c}-${t}"
|
|
494
|
+
type="${h}"
|
|
495
|
+
value="${e.value}"
|
|
496
|
+
/>
|
|
497
|
+
<label
|
|
498
|
+
for="${i}-${a}-${c}-${t}"
|
|
499
|
+
>${e.label}</label
|
|
500
|
+
>
|
|
501
|
+
</div>
|
|
502
|
+
`;
|
|
503
|
+
}).join("")}
|
|
504
|
+
</div>
|
|
505
|
+
</div>
|
|
506
|
+
`;
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
key: "renderInNode",
|
|
511
|
+
value: function(e) {
|
|
512
|
+
e.innerHTML = this.getHTML(), this.node = e;
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
key: "refresh",
|
|
517
|
+
value: function() {
|
|
518
|
+
this.node && (this.renderInNode(this.node), this.init());
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
]);
|
|
522
|
+
}();
|
|
523
|
+
O = M, O.fieldTypes = k, O.animatedNodeTypes = A;
|
|
524
|
+
//#endregion
|
|
525
|
+
//#region node_modules/jsonpath-plus/dist/index-browser-esm.js
|
|
526
|
+
var N = /* @__PURE__ */ function() {
|
|
527
|
+
function e() {
|
|
528
|
+
a(this, e);
|
|
529
|
+
}
|
|
530
|
+
return c(e, [{
|
|
531
|
+
key: "add",
|
|
532
|
+
value: function(e, t, n) {
|
|
533
|
+
if (typeof arguments[0] != "string") for (var r in arguments[0]) this.add(r, arguments[0][r], arguments[1]);
|
|
534
|
+
else (Array.isArray(e) ? e : [e]).forEach(function(e) {
|
|
535
|
+
this[e] = this[e] || [], t && this[e][n ? "unshift" : "push"](t);
|
|
536
|
+
}, this);
|
|
537
|
+
}
|
|
538
|
+
}, {
|
|
539
|
+
key: "run",
|
|
540
|
+
value: function(e, t) {
|
|
541
|
+
this[e] = this[e] || [], this[e].forEach(function(e) {
|
|
542
|
+
e.call(t && t.context ? t.context : t, t);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
}]);
|
|
546
|
+
}(), P = /* @__PURE__ */ function() {
|
|
547
|
+
function e(t) {
|
|
548
|
+
a(this, e), this.jsep = t, this.registered = {};
|
|
549
|
+
}
|
|
550
|
+
return c(e, [{
|
|
551
|
+
key: "register",
|
|
552
|
+
value: function() {
|
|
553
|
+
var e = this;
|
|
554
|
+
[...arguments].forEach(function(t) {
|
|
555
|
+
if (w(t) !== "object" || !t.name || !t.init) throw Error("Invalid JSEP plugin format");
|
|
556
|
+
e.registered[t.name] || (t.init(e.jsep), e.registered[t.name] = t);
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
}]);
|
|
560
|
+
}(), F = /* @__PURE__ */ function() {
|
|
561
|
+
function e(t) {
|
|
562
|
+
a(this, e), this.expr = t, this.index = 0;
|
|
563
|
+
}
|
|
564
|
+
return c(e, [
|
|
565
|
+
{
|
|
566
|
+
key: "char",
|
|
567
|
+
get: function() {
|
|
568
|
+
return this.expr.charAt(this.index);
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
key: "code",
|
|
573
|
+
get: function() {
|
|
574
|
+
return this.expr.charCodeAt(this.index);
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
key: "throwError",
|
|
579
|
+
value: function(e) {
|
|
580
|
+
var t = /* @__PURE__ */ Error(e + " at character " + this.index);
|
|
581
|
+
throw t.index = this.index, t.description = e, t;
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
key: "runHook",
|
|
586
|
+
value: function(t, n) {
|
|
587
|
+
if (e.hooks[t]) {
|
|
588
|
+
var r = {
|
|
589
|
+
context: this,
|
|
590
|
+
node: n
|
|
591
|
+
};
|
|
592
|
+
return e.hooks.run(t, r), r.node;
|
|
593
|
+
}
|
|
594
|
+
return n;
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
key: "searchHook",
|
|
599
|
+
value: function(t) {
|
|
600
|
+
if (e.hooks[t]) {
|
|
601
|
+
var n = { context: this };
|
|
602
|
+
return e.hooks[t].find(function(e) {
|
|
603
|
+
return e.call(n.context, n), n.node;
|
|
604
|
+
}), n.node;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
key: "gobbleSpaces",
|
|
610
|
+
value: function() {
|
|
611
|
+
for (var t = this.code; t === e.SPACE_CODE || t === e.TAB_CODE || t === e.LF_CODE || t === e.CR_CODE;) t = this.expr.charCodeAt(++this.index);
|
|
612
|
+
this.runHook("gobble-spaces");
|
|
613
|
+
}
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
key: "parse",
|
|
617
|
+
value: function() {
|
|
618
|
+
this.runHook("before-all");
|
|
619
|
+
var t = this.gobbleExpressions(), n = t.length === 1 ? t[0] : {
|
|
620
|
+
type: e.COMPOUND,
|
|
621
|
+
body: t
|
|
622
|
+
};
|
|
623
|
+
return this.runHook("after-all", n);
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
key: "gobbleExpressions",
|
|
628
|
+
value: function(t) {
|
|
629
|
+
for (var n = [], r, i; this.index < this.expr.length;) if (r = this.code, r === e.SEMCOL_CODE || r === e.COMMA_CODE) this.index++;
|
|
630
|
+
else if (i = this.gobbleExpression()) n.push(i);
|
|
631
|
+
else if (this.index < this.expr.length) {
|
|
632
|
+
if (r === t) break;
|
|
633
|
+
this.throwError("Unexpected \"" + this.char + "\"");
|
|
634
|
+
}
|
|
635
|
+
return n;
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
{
|
|
639
|
+
key: "gobbleExpression",
|
|
640
|
+
value: function() {
|
|
641
|
+
var e = this.searchHook("gobble-expression") || this.gobbleBinaryExpression();
|
|
642
|
+
return this.gobbleSpaces(), this.runHook("after-expression", e);
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
key: "gobbleBinaryOp",
|
|
647
|
+
value: function() {
|
|
648
|
+
this.gobbleSpaces();
|
|
649
|
+
for (var t = this.expr.substr(this.index, e.max_binop_len), n = t.length; n > 0;) {
|
|
650
|
+
if (e.binary_ops.hasOwnProperty(t) && (!e.isIdentifierStart(this.code) || this.index + t.length < this.expr.length && !e.isIdentifierPart(this.expr.charCodeAt(this.index + t.length)))) return this.index += n, t;
|
|
651
|
+
t = t.substr(0, --n);
|
|
652
|
+
}
|
|
653
|
+
return !1;
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
key: "gobbleBinaryExpression",
|
|
658
|
+
value: function() {
|
|
659
|
+
var t, n, r, i, a, o = this.gobbleToken(), s, c, l;
|
|
660
|
+
if (!o || (n = this.gobbleBinaryOp(), !n)) return o;
|
|
661
|
+
for (a = {
|
|
662
|
+
value: n,
|
|
663
|
+
prec: e.binaryPrecedence(n),
|
|
664
|
+
right_a: e.right_associative.has(n)
|
|
665
|
+
}, s = this.gobbleToken(), s || this.throwError("Expected expression after " + n), i = [
|
|
666
|
+
o,
|
|
667
|
+
a,
|
|
668
|
+
s
|
|
669
|
+
]; n = this.gobbleBinaryOp();) {
|
|
670
|
+
if (r = e.binaryPrecedence(n), r === 0) {
|
|
671
|
+
this.index -= n.length;
|
|
672
|
+
break;
|
|
673
|
+
}
|
|
674
|
+
a = {
|
|
675
|
+
value: n,
|
|
676
|
+
prec: r,
|
|
677
|
+
right_a: e.right_associative.has(n)
|
|
678
|
+
}, l = n;
|
|
679
|
+
for (var u = function(e) {
|
|
680
|
+
return a.right_a && e.right_a ? r > e.prec : r <= e.prec;
|
|
681
|
+
}; i.length > 2 && u(i[i.length - 2]);) s = i.pop(), n = i.pop().value, o = i.pop(), t = {
|
|
682
|
+
type: e.BINARY_EXP,
|
|
683
|
+
operator: n,
|
|
684
|
+
left: o,
|
|
685
|
+
right: s
|
|
686
|
+
}, i.push(t);
|
|
687
|
+
t = this.gobbleToken(), t || this.throwError("Expected expression after " + l), i.push(a, t);
|
|
688
|
+
}
|
|
689
|
+
for (c = i.length - 1, t = i[c]; c > 1;) t = {
|
|
690
|
+
type: e.BINARY_EXP,
|
|
691
|
+
operator: i[c - 1].value,
|
|
692
|
+
left: i[c - 2],
|
|
693
|
+
right: t
|
|
694
|
+
}, c -= 2;
|
|
695
|
+
return t;
|
|
696
|
+
}
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
key: "gobbleToken",
|
|
700
|
+
value: function() {
|
|
701
|
+
var t, n, r, i;
|
|
702
|
+
if (this.gobbleSpaces(), i = this.searchHook("gobble-token"), i) return this.runHook("after-token", i);
|
|
703
|
+
if (t = this.code, e.isDecimalDigit(t) || t === e.PERIOD_CODE) return this.gobbleNumericLiteral();
|
|
704
|
+
if (t === e.SQUOTE_CODE || t === e.DQUOTE_CODE) i = this.gobbleStringLiteral();
|
|
705
|
+
else if (t === e.OBRACK_CODE) i = this.gobbleArray();
|
|
706
|
+
else {
|
|
707
|
+
for (n = this.expr.substr(this.index, e.max_unop_len), r = n.length; r > 0;) {
|
|
708
|
+
if (e.unary_ops.hasOwnProperty(n) && (!e.isIdentifierStart(this.code) || this.index + n.length < this.expr.length && !e.isIdentifierPart(this.expr.charCodeAt(this.index + n.length)))) {
|
|
709
|
+
this.index += r;
|
|
710
|
+
var a = this.gobbleToken();
|
|
711
|
+
return a || this.throwError("missing unaryOp argument"), this.runHook("after-token", {
|
|
712
|
+
type: e.UNARY_EXP,
|
|
713
|
+
operator: n,
|
|
714
|
+
argument: a,
|
|
715
|
+
prefix: !0
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
n = n.substr(0, --r);
|
|
719
|
+
}
|
|
720
|
+
e.isIdentifierStart(t) ? (i = this.gobbleIdentifier(), e.literals.hasOwnProperty(i.name) ? i = {
|
|
721
|
+
type: e.LITERAL,
|
|
722
|
+
value: e.literals[i.name],
|
|
723
|
+
raw: i.name
|
|
724
|
+
} : i.name === e.this_str && (i = { type: e.THIS_EXP })) : t === e.OPAREN_CODE && (i = this.gobbleGroup());
|
|
725
|
+
}
|
|
726
|
+
return i ? (i = this.gobbleTokenProperty(i), this.runHook("after-token", i)) : this.runHook("after-token", !1);
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
key: "gobbleTokenProperty",
|
|
731
|
+
value: function(t) {
|
|
732
|
+
this.gobbleSpaces();
|
|
733
|
+
for (var n = this.code; n === e.PERIOD_CODE || n === e.OBRACK_CODE || n === e.OPAREN_CODE || n === e.QUMARK_CODE;) {
|
|
734
|
+
var r = void 0;
|
|
735
|
+
if (n === e.QUMARK_CODE) {
|
|
736
|
+
if (this.expr.charCodeAt(this.index + 1) !== e.PERIOD_CODE) break;
|
|
737
|
+
r = !0, this.index += 2, this.gobbleSpaces(), n = this.code;
|
|
738
|
+
}
|
|
739
|
+
this.index++, n === e.OBRACK_CODE ? (t = {
|
|
740
|
+
type: e.MEMBER_EXP,
|
|
741
|
+
computed: !0,
|
|
742
|
+
object: t,
|
|
743
|
+
property: this.gobbleExpression()
|
|
744
|
+
}, t.property || this.throwError("Unexpected \"" + this.char + "\""), this.gobbleSpaces(), n = this.code, n !== e.CBRACK_CODE && this.throwError("Unclosed ["), this.index++) : n === e.OPAREN_CODE ? t = {
|
|
745
|
+
type: e.CALL_EXP,
|
|
746
|
+
arguments: this.gobbleArguments(e.CPAREN_CODE),
|
|
747
|
+
callee: t
|
|
748
|
+
} : (n === e.PERIOD_CODE || r) && (r && this.index--, this.gobbleSpaces(), t = {
|
|
749
|
+
type: e.MEMBER_EXP,
|
|
750
|
+
computed: !1,
|
|
751
|
+
object: t,
|
|
752
|
+
property: this.gobbleIdentifier()
|
|
753
|
+
}), r && (t.optional = !0), this.gobbleSpaces(), n = this.code;
|
|
754
|
+
}
|
|
755
|
+
return t;
|
|
756
|
+
}
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
key: "gobbleNumericLiteral",
|
|
760
|
+
value: function() {
|
|
761
|
+
for (var t = "", n, r; e.isDecimalDigit(this.code);) t += this.expr.charAt(this.index++);
|
|
762
|
+
if (this.code === e.PERIOD_CODE) for (t += this.expr.charAt(this.index++); e.isDecimalDigit(this.code);) t += this.expr.charAt(this.index++);
|
|
763
|
+
if (n = this.char, n === "e" || n === "E") {
|
|
764
|
+
for (t += this.expr.charAt(this.index++), n = this.char, (n === "+" || n === "-") && (t += this.expr.charAt(this.index++)); e.isDecimalDigit(this.code);) t += this.expr.charAt(this.index++);
|
|
765
|
+
e.isDecimalDigit(this.expr.charCodeAt(this.index - 1)) || this.throwError("Expected exponent (" + t + this.char + ")");
|
|
766
|
+
}
|
|
767
|
+
return r = this.code, e.isIdentifierStart(r) ? this.throwError("Variable names cannot start with a number (" + t + this.char + ")") : (r === e.PERIOD_CODE || t.length === 1 && t.charCodeAt(0) === e.PERIOD_CODE) && this.throwError("Unexpected period"), {
|
|
768
|
+
type: e.LITERAL,
|
|
769
|
+
value: parseFloat(t),
|
|
770
|
+
raw: t
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
key: "gobbleStringLiteral",
|
|
776
|
+
value: function() {
|
|
777
|
+
for (var t = "", n = this.index, r = this.expr.charAt(this.index++), i = !1; this.index < this.expr.length;) {
|
|
778
|
+
var a = this.expr.charAt(this.index++);
|
|
779
|
+
if (a === r) {
|
|
780
|
+
i = !0;
|
|
781
|
+
break;
|
|
782
|
+
} else if (a === "\\") switch (a = this.expr.charAt(this.index++), a) {
|
|
783
|
+
case "n":
|
|
784
|
+
t += "\n";
|
|
785
|
+
break;
|
|
786
|
+
case "r":
|
|
787
|
+
t += "\r";
|
|
788
|
+
break;
|
|
789
|
+
case "t":
|
|
790
|
+
t += " ";
|
|
791
|
+
break;
|
|
792
|
+
case "b":
|
|
793
|
+
t += "\b";
|
|
794
|
+
break;
|
|
795
|
+
case "f":
|
|
796
|
+
t += "\f";
|
|
797
|
+
break;
|
|
798
|
+
case "v":
|
|
799
|
+
t += "\v";
|
|
800
|
+
break;
|
|
801
|
+
default: t += a;
|
|
802
|
+
}
|
|
803
|
+
else t += a;
|
|
804
|
+
}
|
|
805
|
+
return i || this.throwError("Unclosed quote after \"" + t + "\""), {
|
|
806
|
+
type: e.LITERAL,
|
|
807
|
+
value: t,
|
|
808
|
+
raw: this.expr.substring(n, this.index)
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
key: "gobbleIdentifier",
|
|
814
|
+
value: function() {
|
|
815
|
+
var t = this.code, n = this.index;
|
|
816
|
+
for (e.isIdentifierStart(t) ? this.index++ : this.throwError("Unexpected " + this.char); this.index < this.expr.length && (t = this.code, e.isIdentifierPart(t));) this.index++;
|
|
817
|
+
return {
|
|
818
|
+
type: e.IDENTIFIER,
|
|
819
|
+
name: this.expr.slice(n, this.index)
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
key: "gobbleArguments",
|
|
825
|
+
value: function(t) {
|
|
826
|
+
for (var n = [], r = !1, i = 0; this.index < this.expr.length;) {
|
|
827
|
+
this.gobbleSpaces();
|
|
828
|
+
var a = this.code;
|
|
829
|
+
if (a === t) {
|
|
830
|
+
r = !0, this.index++, t === e.CPAREN_CODE && i && i >= n.length && this.throwError("Unexpected token " + String.fromCharCode(t));
|
|
831
|
+
break;
|
|
832
|
+
} else if (a === e.COMMA_CODE) {
|
|
833
|
+
if (this.index++, i++, i !== n.length) {
|
|
834
|
+
if (t === e.CPAREN_CODE) this.throwError("Unexpected token ,");
|
|
835
|
+
else if (t === e.CBRACK_CODE) for (var o = n.length; o < i; o++) n.push(null);
|
|
836
|
+
}
|
|
837
|
+
} else if (n.length !== i && i !== 0) this.throwError("Expected comma");
|
|
838
|
+
else {
|
|
839
|
+
var s = this.gobbleExpression();
|
|
840
|
+
(!s || s.type === e.COMPOUND) && this.throwError("Expected comma"), n.push(s);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
return r || this.throwError("Expected " + String.fromCharCode(t)), n;
|
|
844
|
+
}
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
key: "gobbleGroup",
|
|
848
|
+
value: function() {
|
|
849
|
+
this.index++;
|
|
850
|
+
var t = this.gobbleExpressions(e.CPAREN_CODE);
|
|
851
|
+
if (this.code === e.CPAREN_CODE) return this.index++, t.length === 1 ? t[0] : t.length ? {
|
|
852
|
+
type: e.SEQUENCE_EXP,
|
|
853
|
+
expressions: t
|
|
854
|
+
} : !1;
|
|
855
|
+
this.throwError("Unclosed (");
|
|
856
|
+
}
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
key: "gobbleArray",
|
|
860
|
+
value: function() {
|
|
861
|
+
return this.index++, {
|
|
862
|
+
type: e.ARRAY_EXP,
|
|
863
|
+
elements: this.gobbleArguments(e.CBRACK_CODE)
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
], [
|
|
868
|
+
{
|
|
869
|
+
key: "version",
|
|
870
|
+
get: function() {
|
|
871
|
+
return "1.4.0";
|
|
872
|
+
}
|
|
873
|
+
},
|
|
874
|
+
{
|
|
875
|
+
key: "toString",
|
|
876
|
+
value: function() {
|
|
877
|
+
return "JavaScript Expression Parser (JSEP) v" + e.version;
|
|
878
|
+
}
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
key: "addUnaryOp",
|
|
882
|
+
value: function(t) {
|
|
883
|
+
return e.max_unop_len = Math.max(t.length, e.max_unop_len), e.unary_ops[t] = 1, e;
|
|
884
|
+
}
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
key: "addBinaryOp",
|
|
888
|
+
value: function(t, n, r) {
|
|
889
|
+
return e.max_binop_len = Math.max(t.length, e.max_binop_len), e.binary_ops[t] = n, r ? e.right_associative.add(t) : e.right_associative.delete(t), e;
|
|
890
|
+
}
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
key: "addIdentifierChar",
|
|
894
|
+
value: function(t) {
|
|
895
|
+
return e.additional_identifier_chars.add(t), e;
|
|
896
|
+
}
|
|
897
|
+
},
|
|
898
|
+
{
|
|
899
|
+
key: "addLiteral",
|
|
900
|
+
value: function(t, n) {
|
|
901
|
+
return e.literals[t] = n, e;
|
|
902
|
+
}
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
key: "removeUnaryOp",
|
|
906
|
+
value: function(t) {
|
|
907
|
+
return delete e.unary_ops[t], t.length === e.max_unop_len && (e.max_unop_len = e.getMaxKeyLen(e.unary_ops)), e;
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
key: "removeAllUnaryOps",
|
|
912
|
+
value: function() {
|
|
913
|
+
return e.unary_ops = {}, e.max_unop_len = 0, e;
|
|
914
|
+
}
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
key: "removeIdentifierChar",
|
|
918
|
+
value: function(t) {
|
|
919
|
+
return e.additional_identifier_chars.delete(t), e;
|
|
920
|
+
}
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
key: "removeBinaryOp",
|
|
924
|
+
value: function(t) {
|
|
925
|
+
return delete e.binary_ops[t], t.length === e.max_binop_len && (e.max_binop_len = e.getMaxKeyLen(e.binary_ops)), e.right_associative.delete(t), e;
|
|
926
|
+
}
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
key: "removeAllBinaryOps",
|
|
930
|
+
value: function() {
|
|
931
|
+
return e.binary_ops = {}, e.max_binop_len = 0, e;
|
|
932
|
+
}
|
|
933
|
+
},
|
|
934
|
+
{
|
|
935
|
+
key: "removeLiteral",
|
|
936
|
+
value: function(t) {
|
|
937
|
+
return delete e.literals[t], e;
|
|
938
|
+
}
|
|
939
|
+
},
|
|
940
|
+
{
|
|
941
|
+
key: "removeAllLiterals",
|
|
942
|
+
value: function() {
|
|
943
|
+
return e.literals = {}, e;
|
|
944
|
+
}
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
key: "parse",
|
|
948
|
+
value: function(t) {
|
|
949
|
+
return new e(t).parse();
|
|
950
|
+
}
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
key: "getMaxKeyLen",
|
|
954
|
+
value: function(e) {
|
|
955
|
+
return Math.max.apply(Math, [0].concat(x(Object.keys(e).map(function(e) {
|
|
956
|
+
return e.length;
|
|
957
|
+
}))));
|
|
958
|
+
}
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
key: "isDecimalDigit",
|
|
962
|
+
value: function(e) {
|
|
963
|
+
return e >= 48 && e <= 57;
|
|
964
|
+
}
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
key: "binaryPrecedence",
|
|
968
|
+
value: function(t) {
|
|
969
|
+
return e.binary_ops[t] || 0;
|
|
970
|
+
}
|
|
971
|
+
},
|
|
972
|
+
{
|
|
973
|
+
key: "isIdentifierStart",
|
|
974
|
+
value: function(t) {
|
|
975
|
+
return t >= 65 && t <= 90 || t >= 97 && t <= 122 || t >= 128 && !e.binary_ops[String.fromCharCode(t)] || e.additional_identifier_chars.has(String.fromCharCode(t));
|
|
976
|
+
}
|
|
977
|
+
},
|
|
978
|
+
{
|
|
979
|
+
key: "isIdentifierPart",
|
|
980
|
+
value: function(t) {
|
|
981
|
+
return e.isIdentifierStart(t) || e.isDecimalDigit(t);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
]);
|
|
985
|
+
}(), I = new N();
|
|
986
|
+
Object.assign(F, {
|
|
987
|
+
hooks: I,
|
|
988
|
+
plugins: new P(F),
|
|
989
|
+
COMPOUND: "Compound",
|
|
990
|
+
SEQUENCE_EXP: "SequenceExpression",
|
|
991
|
+
IDENTIFIER: "Identifier",
|
|
992
|
+
MEMBER_EXP: "MemberExpression",
|
|
993
|
+
LITERAL: "Literal",
|
|
994
|
+
THIS_EXP: "ThisExpression",
|
|
995
|
+
CALL_EXP: "CallExpression",
|
|
996
|
+
UNARY_EXP: "UnaryExpression",
|
|
997
|
+
BINARY_EXP: "BinaryExpression",
|
|
998
|
+
ARRAY_EXP: "ArrayExpression",
|
|
999
|
+
TAB_CODE: 9,
|
|
1000
|
+
LF_CODE: 10,
|
|
1001
|
+
CR_CODE: 13,
|
|
1002
|
+
SPACE_CODE: 32,
|
|
1003
|
+
PERIOD_CODE: 46,
|
|
1004
|
+
COMMA_CODE: 44,
|
|
1005
|
+
SQUOTE_CODE: 39,
|
|
1006
|
+
DQUOTE_CODE: 34,
|
|
1007
|
+
OPAREN_CODE: 40,
|
|
1008
|
+
CPAREN_CODE: 41,
|
|
1009
|
+
OBRACK_CODE: 91,
|
|
1010
|
+
CBRACK_CODE: 93,
|
|
1011
|
+
QUMARK_CODE: 63,
|
|
1012
|
+
SEMCOL_CODE: 59,
|
|
1013
|
+
COLON_CODE: 58,
|
|
1014
|
+
unary_ops: {
|
|
1015
|
+
"-": 1,
|
|
1016
|
+
"!": 1,
|
|
1017
|
+
"~": 1,
|
|
1018
|
+
"+": 1
|
|
1019
|
+
},
|
|
1020
|
+
binary_ops: {
|
|
1021
|
+
"||": 1,
|
|
1022
|
+
"??": 1,
|
|
1023
|
+
"&&": 2,
|
|
1024
|
+
"|": 3,
|
|
1025
|
+
"^": 4,
|
|
1026
|
+
"&": 5,
|
|
1027
|
+
"==": 6,
|
|
1028
|
+
"!=": 6,
|
|
1029
|
+
"===": 6,
|
|
1030
|
+
"!==": 6,
|
|
1031
|
+
"<": 7,
|
|
1032
|
+
">": 7,
|
|
1033
|
+
"<=": 7,
|
|
1034
|
+
">=": 7,
|
|
1035
|
+
"<<": 8,
|
|
1036
|
+
">>": 8,
|
|
1037
|
+
">>>": 8,
|
|
1038
|
+
"+": 9,
|
|
1039
|
+
"-": 9,
|
|
1040
|
+
"*": 10,
|
|
1041
|
+
"/": 10,
|
|
1042
|
+
"%": 10,
|
|
1043
|
+
"**": 11
|
|
1044
|
+
},
|
|
1045
|
+
right_associative: new Set(["**"]),
|
|
1046
|
+
additional_identifier_chars: new Set(["$", "_"]),
|
|
1047
|
+
literals: {
|
|
1048
|
+
true: !0,
|
|
1049
|
+
false: !1,
|
|
1050
|
+
null: null
|
|
1051
|
+
},
|
|
1052
|
+
this_str: "this"
|
|
1053
|
+
}), F.max_unop_len = F.getMaxKeyLen(F.unary_ops), F.max_binop_len = F.getMaxKeyLen(F.binary_ops);
|
|
1054
|
+
var L = function(e) {
|
|
1055
|
+
return new F(e).parse();
|
|
1056
|
+
}, R = Object.getOwnPropertyNames(/* @__PURE__ */ c(function e() {
|
|
1057
|
+
a(this, e);
|
|
1058
|
+
}));
|
|
1059
|
+
Object.getOwnPropertyNames(F).filter(function(e) {
|
|
1060
|
+
return !R.includes(e) && L[e] === void 0;
|
|
1061
|
+
}).forEach(function(e) {
|
|
1062
|
+
L[e] = F[e];
|
|
1063
|
+
}), L.Jsep = F;
|
|
1064
|
+
var z = "ConditionalExpression";
|
|
1065
|
+
L.plugins.register({
|
|
1066
|
+
name: "ternary",
|
|
1067
|
+
init: function(e) {
|
|
1068
|
+
e.hooks.add("after-expression", function(t) {
|
|
1069
|
+
if (t.node && this.code === e.QUMARK_CODE) {
|
|
1070
|
+
this.index++;
|
|
1071
|
+
var n = t.node, r = this.gobbleExpression();
|
|
1072
|
+
if (r || this.throwError("Expected expression"), this.gobbleSpaces(), this.code === e.COLON_CODE) {
|
|
1073
|
+
this.index++;
|
|
1074
|
+
var i = this.gobbleExpression();
|
|
1075
|
+
if (i || this.throwError("Expected expression"), t.node = {
|
|
1076
|
+
type: z,
|
|
1077
|
+
test: n,
|
|
1078
|
+
consequent: r,
|
|
1079
|
+
alternate: i
|
|
1080
|
+
}, n.operator && e.binary_ops[n.operator] <= .9) {
|
|
1081
|
+
for (var a = n; a.right.operator && e.binary_ops[a.right.operator] <= .9;) a = a.right;
|
|
1082
|
+
t.node.test = a.right, a.right = t.node, t.node = n;
|
|
1083
|
+
}
|
|
1084
|
+
} else this.throwError("Expected :");
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
});
|
|
1089
|
+
var B = 47, V = 92, H = {
|
|
1090
|
+
name: "regex",
|
|
1091
|
+
init: function(e) {
|
|
1092
|
+
e.hooks.add("gobble-token", function(t) {
|
|
1093
|
+
if (this.code === B) {
|
|
1094
|
+
for (var n = ++this.index, r = !1; this.index < this.expr.length;) {
|
|
1095
|
+
if (this.code === B && !r) {
|
|
1096
|
+
for (var i = this.expr.slice(n, this.index), a = ""; ++this.index < this.expr.length;) {
|
|
1097
|
+
var o = this.code;
|
|
1098
|
+
if (o >= 97 && o <= 122 || o >= 65 && o <= 90 || o >= 48 && o <= 57) a += this.char;
|
|
1099
|
+
else break;
|
|
1100
|
+
}
|
|
1101
|
+
var s = void 0;
|
|
1102
|
+
try {
|
|
1103
|
+
s = new RegExp(i, a);
|
|
1104
|
+
} catch (e) {
|
|
1105
|
+
this.throwError(e.message);
|
|
1106
|
+
}
|
|
1107
|
+
return t.node = {
|
|
1108
|
+
type: e.LITERAL,
|
|
1109
|
+
value: s,
|
|
1110
|
+
raw: this.expr.slice(n - 1, this.index)
|
|
1111
|
+
}, t.node = this.gobbleTokenProperty(t.node), t.node;
|
|
1112
|
+
}
|
|
1113
|
+
this.code === e.OBRACK_CODE ? r = !0 : r && this.code === e.CBRACK_CODE && (r = !1), this.index += this.code === V ? 2 : 1;
|
|
1114
|
+
}
|
|
1115
|
+
this.throwError("Unclosed Regex");
|
|
1116
|
+
}
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
}, U = 43, W = {
|
|
1120
|
+
name: "assignment",
|
|
1121
|
+
assignmentOperators: new Set([
|
|
1122
|
+
"=",
|
|
1123
|
+
"*=",
|
|
1124
|
+
"**=",
|
|
1125
|
+
"/=",
|
|
1126
|
+
"%=",
|
|
1127
|
+
"+=",
|
|
1128
|
+
"-=",
|
|
1129
|
+
"<<=",
|
|
1130
|
+
">>=",
|
|
1131
|
+
">>>=",
|
|
1132
|
+
"&=",
|
|
1133
|
+
"^=",
|
|
1134
|
+
"|=",
|
|
1135
|
+
"||=",
|
|
1136
|
+
"&&=",
|
|
1137
|
+
"??="
|
|
1138
|
+
]),
|
|
1139
|
+
updateOperators: [U, 45],
|
|
1140
|
+
assignmentPrecedence: .9,
|
|
1141
|
+
init: function(e) {
|
|
1142
|
+
var t = [e.IDENTIFIER, e.MEMBER_EXP];
|
|
1143
|
+
W.assignmentOperators.forEach(function(t) {
|
|
1144
|
+
return e.addBinaryOp(t, W.assignmentPrecedence, !0);
|
|
1145
|
+
}), e.hooks.add("gobble-token", function(e) {
|
|
1146
|
+
var n = this, r = this.code;
|
|
1147
|
+
W.updateOperators.some(function(e) {
|
|
1148
|
+
return e === r && e === n.expr.charCodeAt(n.index + 1);
|
|
1149
|
+
}) && (this.index += 2, e.node = {
|
|
1150
|
+
type: "UpdateExpression",
|
|
1151
|
+
operator: r === U ? "++" : "--",
|
|
1152
|
+
argument: this.gobbleTokenProperty(this.gobbleIdentifier()),
|
|
1153
|
+
prefix: !0
|
|
1154
|
+
}, (!e.node.argument || !t.includes(e.node.argument.type)) && this.throwError(`Unexpected ${e.node.operator}`));
|
|
1155
|
+
}), e.hooks.add("after-token", function(e) {
|
|
1156
|
+
var n = this;
|
|
1157
|
+
if (e.node) {
|
|
1158
|
+
var r = this.code;
|
|
1159
|
+
W.updateOperators.some(function(e) {
|
|
1160
|
+
return e === r && e === n.expr.charCodeAt(n.index + 1);
|
|
1161
|
+
}) && (t.includes(e.node.type) || this.throwError(`Unexpected ${e.node.operator}`), this.index += 2, e.node = {
|
|
1162
|
+
type: "UpdateExpression",
|
|
1163
|
+
operator: r === U ? "++" : "--",
|
|
1164
|
+
argument: e.node,
|
|
1165
|
+
prefix: !1
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
}), e.hooks.add("after-expression", function(e) {
|
|
1169
|
+
e.node && n(e.node);
|
|
1170
|
+
});
|
|
1171
|
+
function n(e) {
|
|
1172
|
+
W.assignmentOperators.has(e.operator) ? (e.type = "AssignmentExpression", n(e.left), n(e.right)) : e.operator || Object.values(e).forEach(function(e) {
|
|
1173
|
+
e && w(e) === "object" && n(e);
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
};
|
|
1178
|
+
L.plugins.register(H, W), L.addUnaryOp("typeof"), L.addUnaryOp("void"), L.addLiteral("null", null), L.addLiteral("undefined", void 0);
|
|
1179
|
+
var G = new Set([
|
|
1180
|
+
"constructor",
|
|
1181
|
+
"__proto__",
|
|
1182
|
+
"__defineGetter__",
|
|
1183
|
+
"__defineSetter__",
|
|
1184
|
+
"__lookupGetter__",
|
|
1185
|
+
"__lookupSetter__"
|
|
1186
|
+
]), K = {
|
|
1187
|
+
evalAst: function(e, t) {
|
|
1188
|
+
switch (e.type) {
|
|
1189
|
+
case "BinaryExpression":
|
|
1190
|
+
case "LogicalExpression": return K.evalBinaryExpression(e, t);
|
|
1191
|
+
case "Compound": return K.evalCompound(e, t);
|
|
1192
|
+
case "ConditionalExpression": return K.evalConditionalExpression(e, t);
|
|
1193
|
+
case "Identifier": return K.evalIdentifier(e, t);
|
|
1194
|
+
case "Literal": return K.evalLiteral(e, t);
|
|
1195
|
+
case "MemberExpression": return K.evalMemberExpression(e, t);
|
|
1196
|
+
case "UnaryExpression": return K.evalUnaryExpression(e, t);
|
|
1197
|
+
case "ArrayExpression": return K.evalArrayExpression(e, t);
|
|
1198
|
+
case "CallExpression": return K.evalCallExpression(e, t);
|
|
1199
|
+
case "AssignmentExpression": return K.evalAssignmentExpression(e, t);
|
|
1200
|
+
default: throw SyntaxError("Unexpected expression", e);
|
|
1201
|
+
}
|
|
1202
|
+
},
|
|
1203
|
+
evalBinaryExpression: function(e, t) {
|
|
1204
|
+
return {
|
|
1205
|
+
"||": function(e, t) {
|
|
1206
|
+
return e || t();
|
|
1207
|
+
},
|
|
1208
|
+
"&&": function(e, t) {
|
|
1209
|
+
return e && t();
|
|
1210
|
+
},
|
|
1211
|
+
"|": function(e, t) {
|
|
1212
|
+
return e | t();
|
|
1213
|
+
},
|
|
1214
|
+
"^": function(e, t) {
|
|
1215
|
+
return e ^ t();
|
|
1216
|
+
},
|
|
1217
|
+
"&": function(e, t) {
|
|
1218
|
+
return e & t();
|
|
1219
|
+
},
|
|
1220
|
+
"==": function(e, t) {
|
|
1221
|
+
return e == t();
|
|
1222
|
+
},
|
|
1223
|
+
"!=": function(e, t) {
|
|
1224
|
+
return e != t();
|
|
1225
|
+
},
|
|
1226
|
+
"===": function(e, t) {
|
|
1227
|
+
return e === t();
|
|
1228
|
+
},
|
|
1229
|
+
"!==": function(e, t) {
|
|
1230
|
+
return e !== t();
|
|
1231
|
+
},
|
|
1232
|
+
"<": function(e, t) {
|
|
1233
|
+
return e < t();
|
|
1234
|
+
},
|
|
1235
|
+
">": function(e, t) {
|
|
1236
|
+
return e > t();
|
|
1237
|
+
},
|
|
1238
|
+
"<=": function(e, t) {
|
|
1239
|
+
return e <= t();
|
|
1240
|
+
},
|
|
1241
|
+
">=": function(e, t) {
|
|
1242
|
+
return e >= t();
|
|
1243
|
+
},
|
|
1244
|
+
"<<": function(e, t) {
|
|
1245
|
+
return e << t();
|
|
1246
|
+
},
|
|
1247
|
+
">>": function(e, t) {
|
|
1248
|
+
return e >> t();
|
|
1249
|
+
},
|
|
1250
|
+
">>>": function(e, t) {
|
|
1251
|
+
return e >>> t();
|
|
1252
|
+
},
|
|
1253
|
+
"+": function(e, t) {
|
|
1254
|
+
return e + t();
|
|
1255
|
+
},
|
|
1256
|
+
"-": function(e, t) {
|
|
1257
|
+
return e - t();
|
|
1258
|
+
},
|
|
1259
|
+
"*": function(e, t) {
|
|
1260
|
+
return e * t();
|
|
1261
|
+
},
|
|
1262
|
+
"/": function(e, t) {
|
|
1263
|
+
return e / t();
|
|
1264
|
+
},
|
|
1265
|
+
"%": function(e, t) {
|
|
1266
|
+
return e % t();
|
|
1267
|
+
}
|
|
1268
|
+
}[e.operator](K.evalAst(e.left, t), function() {
|
|
1269
|
+
return K.evalAst(e.right, t);
|
|
1270
|
+
});
|
|
1271
|
+
},
|
|
1272
|
+
evalCompound: function(e, t) {
|
|
1273
|
+
for (var n, r = 0; r < e.body.length; r++) {
|
|
1274
|
+
e.body[r].type === "Identifier" && [
|
|
1275
|
+
"var",
|
|
1276
|
+
"let",
|
|
1277
|
+
"const"
|
|
1278
|
+
].includes(e.body[r].name) && e.body[r + 1] && e.body[r + 1].type === "AssignmentExpression" && (r += 1);
|
|
1279
|
+
var i = e.body[r];
|
|
1280
|
+
n = K.evalAst(i, t);
|
|
1281
|
+
}
|
|
1282
|
+
return n;
|
|
1283
|
+
},
|
|
1284
|
+
evalConditionalExpression: function(e, t) {
|
|
1285
|
+
return K.evalAst(e.test, t) ? K.evalAst(e.consequent, t) : K.evalAst(e.alternate, t);
|
|
1286
|
+
},
|
|
1287
|
+
evalIdentifier: function(e, t) {
|
|
1288
|
+
if (Object.hasOwn(t, e.name)) return t[e.name];
|
|
1289
|
+
throw ReferenceError(`${e.name} is not defined`);
|
|
1290
|
+
},
|
|
1291
|
+
evalLiteral: function(e) {
|
|
1292
|
+
return e.value;
|
|
1293
|
+
},
|
|
1294
|
+
evalMemberExpression: function(e, t) {
|
|
1295
|
+
var n = String(e.computed ? K.evalAst(e.property) : e.property.name), r = K.evalAst(e.object, t);
|
|
1296
|
+
if (r == null || !Object.hasOwn(r, n) && G.has(n)) throw TypeError(`Cannot read properties of ${r} (reading '${n}')`);
|
|
1297
|
+
var i = r[n];
|
|
1298
|
+
return typeof i == "function" ? i.bind(r) : i;
|
|
1299
|
+
},
|
|
1300
|
+
evalUnaryExpression: function(e, t) {
|
|
1301
|
+
return {
|
|
1302
|
+
"-": function(e) {
|
|
1303
|
+
return -K.evalAst(e, t);
|
|
1304
|
+
},
|
|
1305
|
+
"!": function(e) {
|
|
1306
|
+
return !K.evalAst(e, t);
|
|
1307
|
+
},
|
|
1308
|
+
"~": function(e) {
|
|
1309
|
+
return ~K.evalAst(e, t);
|
|
1310
|
+
},
|
|
1311
|
+
"+": function(e) {
|
|
1312
|
+
return +K.evalAst(e, t);
|
|
1313
|
+
},
|
|
1314
|
+
typeof: function e(n) {
|
|
1315
|
+
return e(K.evalAst(n, t));
|
|
1316
|
+
},
|
|
1317
|
+
void: function(e) {
|
|
1318
|
+
K.evalAst(e, t);
|
|
1319
|
+
}
|
|
1320
|
+
}[e.operator](e.argument);
|
|
1321
|
+
},
|
|
1322
|
+
evalArrayExpression: function(e, t) {
|
|
1323
|
+
return e.elements.map(function(e) {
|
|
1324
|
+
return K.evalAst(e, t);
|
|
1325
|
+
});
|
|
1326
|
+
},
|
|
1327
|
+
evalCallExpression: function(e, t) {
|
|
1328
|
+
var n = e.arguments.map(function(e) {
|
|
1329
|
+
return K.evalAst(e, t);
|
|
1330
|
+
}), r = K.evalAst(e.callee, t);
|
|
1331
|
+
/* c8 ignore start */
|
|
1332
|
+
if (r === Function) throw Error("Function constructor is disabled");
|
|
1333
|
+
/* c8 ignore end */
|
|
1334
|
+
return r.apply(void 0, x(n));
|
|
1335
|
+
},
|
|
1336
|
+
evalAssignmentExpression: function(e, t) {
|
|
1337
|
+
if (e.left.type !== "Identifier") throw SyntaxError("Invalid left-hand side in assignment");
|
|
1338
|
+
var n = e.left.name;
|
|
1339
|
+
return t[n] = K.evalAst(e.right, t), t[n];
|
|
1340
|
+
}
|
|
1341
|
+
}, q = /* @__PURE__ */ function() {
|
|
1342
|
+
function e(t) {
|
|
1343
|
+
a(this, e), this.code = t, this.ast = L(this.code);
|
|
1344
|
+
}
|
|
1345
|
+
return c(e, [{
|
|
1346
|
+
key: "runInNewContext",
|
|
1347
|
+
value: function(e) {
|
|
1348
|
+
var t = Object.assign(Object.create(null), e);
|
|
1349
|
+
return K.evalAst(this.ast, t);
|
|
1350
|
+
}
|
|
1351
|
+
}]);
|
|
1352
|
+
}();
|
|
1353
|
+
function J(e, t) {
|
|
1354
|
+
return e = e.slice(), e.push(t), e;
|
|
1355
|
+
}
|
|
1356
|
+
function Y(e, t) {
|
|
1357
|
+
return t = t.slice(), t.unshift(e), t;
|
|
1358
|
+
}
|
|
1359
|
+
var X = /* @__PURE__ */ function(e) {
|
|
1360
|
+
function t(e) {
|
|
1361
|
+
var n;
|
|
1362
|
+
return a(this, t), n = i(this, t, ["JSONPath should not be called with \"new\" (it prevents return of (unwrapped) scalar values)"]), n.avoidNew = !0, n.value = e, n.name = "NewError", n;
|
|
1363
|
+
}
|
|
1364
|
+
return f(t, e), c(t);
|
|
1365
|
+
}(/* @__PURE__ */ D(Error));
|
|
1366
|
+
function Z(e, t, n, r, i) {
|
|
1367
|
+
if (!(this instanceof Z)) try {
|
|
1368
|
+
return new Z(e, t, n, r, i);
|
|
1369
|
+
} catch (e) {
|
|
1370
|
+
if (!e.avoidNew) throw e;
|
|
1371
|
+
return e.value;
|
|
1372
|
+
}
|
|
1373
|
+
typeof e == "string" && (i = r, r = n, n = t, t = e, e = null);
|
|
1374
|
+
var a = e && w(e) === "object";
|
|
1375
|
+
if (e = e || {}, this.json = e.json || n, this.path = e.path || t, this.resultType = e.resultType || "value", this.flatten = e.flatten || !1, this.wrap = Object.hasOwn(e, "wrap") ? e.wrap : !0, this.sandbox = e.sandbox || {}, this.eval = e.eval === void 0 ? "safe" : e.eval, this.ignoreEvalErrors = e.ignoreEvalErrors === void 0 ? !1 : e.ignoreEvalErrors, this.parent = e.parent || null, this.parentProperty = e.parentProperty || null, this.callback = e.callback || r || null, this.otherTypeCallback = e.otherTypeCallback || i || function() {
|
|
1376
|
+
throw TypeError("You must supply an otherTypeCallback callback option with the @other() operator.");
|
|
1377
|
+
}, e.autostart !== !1) {
|
|
1378
|
+
var o = { path: a ? e.path : t };
|
|
1379
|
+
a ? "json" in e && (o.json = e.json) : o.json = n;
|
|
1380
|
+
var s = this.evaluate(o);
|
|
1381
|
+
if (!s || w(s) !== "object") throw new X(s);
|
|
1382
|
+
return s;
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
Z.prototype.evaluate = function(e, t, n, r) {
|
|
1386
|
+
var i = this, a = this.parent, o = this.parentProperty, s = this.flatten, c = this.wrap;
|
|
1387
|
+
if (this.currResultType = this.resultType, this.currEval = this.eval, this.currSandbox = this.sandbox, n = n || this.callback, this.currOtherTypeCallback = r || this.otherTypeCallback, t = t || this.json, e = e || this.path, e && w(e) === "object" && !Array.isArray(e)) {
|
|
1388
|
+
if (!e.path && e.path !== "") throw TypeError("You must supply a \"path\" property when providing an object argument to JSONPath.evaluate().");
|
|
1389
|
+
if (!Object.hasOwn(e, "json")) throw TypeError("You must supply a \"json\" property when providing an object argument to JSONPath.evaluate().");
|
|
1390
|
+
t = e.json, s = Object.hasOwn(e, "flatten") ? e.flatten : s, this.currResultType = Object.hasOwn(e, "resultType") ? e.resultType : this.currResultType, this.currSandbox = Object.hasOwn(e, "sandbox") ? e.sandbox : this.currSandbox, c = Object.hasOwn(e, "wrap") ? e.wrap : c, this.currEval = Object.hasOwn(e, "eval") ? e.eval : this.currEval, n = Object.hasOwn(e, "callback") ? e.callback : n, this.currOtherTypeCallback = Object.hasOwn(e, "otherTypeCallback") ? e.otherTypeCallback : this.currOtherTypeCallback, a = Object.hasOwn(e, "parent") ? e.parent : a, o = Object.hasOwn(e, "parentProperty") ? e.parentProperty : o, e = e.path;
|
|
1391
|
+
}
|
|
1392
|
+
if (a = a || null, o = o || null, Array.isArray(e) && (e = Z.toPathString(e)), !(!e && e !== "" || !t)) {
|
|
1393
|
+
var l = Z.toPathArray(e);
|
|
1394
|
+
l[0] === "$" && l.length > 1 && l.shift(), this._hasParentSelector = null;
|
|
1395
|
+
var u = this._trace(l, t, ["$"], a, o, n).filter(function(e) {
|
|
1396
|
+
return e && !e.isParentSelector;
|
|
1397
|
+
});
|
|
1398
|
+
return u.length ? !c && u.length === 1 && !u[0].hasArrExpr ? this._getPreferredOutput(u[0]) : u.reduce(function(e, t) {
|
|
1399
|
+
var n = i._getPreferredOutput(t);
|
|
1400
|
+
return s && Array.isArray(n) ? e = e.concat(n) : e.push(n), e;
|
|
1401
|
+
}, []) : c ? [] : void 0;
|
|
1402
|
+
}
|
|
1403
|
+
}, Z.prototype._getPreferredOutput = function(e) {
|
|
1404
|
+
var t = this.currResultType;
|
|
1405
|
+
switch (t) {
|
|
1406
|
+
case "all":
|
|
1407
|
+
var n = Array.isArray(e.path) ? e.path : Z.toPathArray(e.path);
|
|
1408
|
+
return e.pointer = Z.toPointer(n), e.path = typeof e.path == "string" ? e.path : Z.toPathString(e.path), e;
|
|
1409
|
+
case "value":
|
|
1410
|
+
case "parent":
|
|
1411
|
+
case "parentProperty": return e[t];
|
|
1412
|
+
case "path": return Z.toPathString(e[t]);
|
|
1413
|
+
case "pointer": return Z.toPointer(e.path);
|
|
1414
|
+
default: throw TypeError("Unknown result type");
|
|
1415
|
+
}
|
|
1416
|
+
}, Z.prototype._handleCallback = function(e, t, n) {
|
|
1417
|
+
if (t) {
|
|
1418
|
+
var r = this._getPreferredOutput(e);
|
|
1419
|
+
e.path = typeof e.path == "string" ? e.path : Z.toPathString(e.path), t(r, n, e);
|
|
1420
|
+
}
|
|
1421
|
+
}, Z.prototype._trace = function(e, t, n, r, i, a, o, s) {
|
|
1422
|
+
var c = this, u;
|
|
1423
|
+
if (!e.length) return u = {
|
|
1424
|
+
path: n,
|
|
1425
|
+
value: t,
|
|
1426
|
+
parent: r,
|
|
1427
|
+
parentProperty: i,
|
|
1428
|
+
hasArrExpr: o
|
|
1429
|
+
}, this._handleCallback(u, a, "value"), u;
|
|
1430
|
+
var d = e[0], f = e.slice(1), p = [];
|
|
1431
|
+
function m(e) {
|
|
1432
|
+
Array.isArray(e) ? e.forEach(function(e) {
|
|
1433
|
+
p.push(e);
|
|
1434
|
+
}) : p.push(e);
|
|
1435
|
+
}
|
|
1436
|
+
if ((typeof d != "string" || s) && t && Object.hasOwn(t, d)) m(this._trace(f, t[d], J(n, d), t, d, a, o));
|
|
1437
|
+
else if (d === "*") this._walk(t, function(e) {
|
|
1438
|
+
m(c._trace(f, t[e], J(n, e), t, e, a, !0, !0));
|
|
1439
|
+
});
|
|
1440
|
+
else if (d === "..") m(this._trace(f, t, n, r, i, a, o)), this._walk(t, function(r) {
|
|
1441
|
+
w(t[r]) === "object" && m(c._trace(e.slice(), t[r], J(n, r), t, r, a, !0));
|
|
1442
|
+
});
|
|
1443
|
+
else if (d === "^") return this._hasParentSelector = !0, {
|
|
1444
|
+
path: n.slice(0, -1),
|
|
1445
|
+
expr: f,
|
|
1446
|
+
isParentSelector: !0
|
|
1447
|
+
};
|
|
1448
|
+
else if (d === "~") return u = {
|
|
1449
|
+
path: J(n, d),
|
|
1450
|
+
value: i,
|
|
1451
|
+
parent: r,
|
|
1452
|
+
parentProperty: null
|
|
1453
|
+
}, this._handleCallback(u, a, "property"), u;
|
|
1454
|
+
else if (d === "$") m(this._trace(f, t, n, null, null, a, o));
|
|
1455
|
+
else if (/^(-?[0-9]*):(-?[0-9]*):?([0-9]*)$/.test(d)) m(this._slice(d, f, t, n, r, i, a));
|
|
1456
|
+
else if (d.indexOf("?(") === 0) {
|
|
1457
|
+
if (this.currEval === !1) throw Error("Eval [?(expr)] prevented in JSONPath expression.");
|
|
1458
|
+
var h = d.replace(/^\?\(((?:[\0-\t\x0B\f\x0E-\u2027\u202A-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*?)\)$/, "$1"), g = /@(?:[\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(h);
|
|
1459
|
+
g ? this._walk(t, function(e) {
|
|
1460
|
+
var o = [g[2]], s = g[1] ? t[e][g[1]] : t[e];
|
|
1461
|
+
c._trace(o, s, n, r, i, a, !0).length > 0 && m(c._trace(f, t[e], J(n, e), t, e, a, !0));
|
|
1462
|
+
}) : this._walk(t, function(e) {
|
|
1463
|
+
c._eval(h, t[e], e, n, r, i) && m(c._trace(f, t[e], J(n, e), t, e, a, !0));
|
|
1464
|
+
});
|
|
1465
|
+
} else if (d[0] === "(") {
|
|
1466
|
+
if (this.currEval === !1) throw Error("Eval [(expr)] prevented in JSONPath expression.");
|
|
1467
|
+
m(this._trace(Y(this._eval(d, t, n.at(-1), n.slice(0, -1), r, i), f), t, n, r, i, a, o));
|
|
1468
|
+
} else if (d[0] === "@") {
|
|
1469
|
+
var _ = !1, v = d.slice(1, -2);
|
|
1470
|
+
switch (v) {
|
|
1471
|
+
case "scalar":
|
|
1472
|
+
(!t || !["object", "function"].includes(w(t))) && (_ = !0);
|
|
1473
|
+
break;
|
|
1474
|
+
case "boolean":
|
|
1475
|
+
case "string":
|
|
1476
|
+
case "undefined":
|
|
1477
|
+
case "function":
|
|
1478
|
+
w(t) === v && (_ = !0);
|
|
1479
|
+
break;
|
|
1480
|
+
case "integer":
|
|
1481
|
+
Number.isFinite(t) && !(t % 1) && (_ = !0);
|
|
1482
|
+
break;
|
|
1483
|
+
case "number":
|
|
1484
|
+
Number.isFinite(t) && (_ = !0);
|
|
1485
|
+
break;
|
|
1486
|
+
case "nonFinite":
|
|
1487
|
+
typeof t == "number" && !Number.isFinite(t) && (_ = !0);
|
|
1488
|
+
break;
|
|
1489
|
+
case "object":
|
|
1490
|
+
t && w(t) === v && (_ = !0);
|
|
1491
|
+
break;
|
|
1492
|
+
case "array":
|
|
1493
|
+
Array.isArray(t) && (_ = !0);
|
|
1494
|
+
break;
|
|
1495
|
+
case "other":
|
|
1496
|
+
_ = this.currOtherTypeCallback(t, n, r, i);
|
|
1497
|
+
break;
|
|
1498
|
+
case "null":
|
|
1499
|
+
t === null && (_ = !0);
|
|
1500
|
+
break;
|
|
1501
|
+
/* c8 ignore next 2 */
|
|
1502
|
+
default: throw TypeError("Unknown value type " + v);
|
|
1503
|
+
}
|
|
1504
|
+
if (_) return u = {
|
|
1505
|
+
path: n,
|
|
1506
|
+
value: t,
|
|
1507
|
+
parent: r,
|
|
1508
|
+
parentProperty: i
|
|
1509
|
+
}, this._handleCallback(u, a, "value"), u;
|
|
1510
|
+
} else if (d[0] === "`" && t && Object.hasOwn(t, d.slice(1))) {
|
|
1511
|
+
var y = d.slice(1);
|
|
1512
|
+
m(this._trace(f, t[y], J(n, y), t, y, a, o, !0));
|
|
1513
|
+
} else if (d.includes(",")) {
|
|
1514
|
+
var b = l(d.split(",")), x;
|
|
1515
|
+
try {
|
|
1516
|
+
for (b.s(); !(x = b.n()).done;) {
|
|
1517
|
+
var S = x.value;
|
|
1518
|
+
m(this._trace(Y(S, f), t, n, r, i, a, !0));
|
|
1519
|
+
}
|
|
1520
|
+
} catch (e) {
|
|
1521
|
+
b.e(e);
|
|
1522
|
+
} finally {
|
|
1523
|
+
b.f();
|
|
1524
|
+
}
|
|
1525
|
+
} else !s && t && Object.hasOwn(t, d) && m(this._trace(f, t[d], J(n, d), t, d, a, o, !0));
|
|
1526
|
+
if (this._hasParentSelector) for (var C = 0; C < p.length; C++) {
|
|
1527
|
+
var T = p[C];
|
|
1528
|
+
if (T && T.isParentSelector) {
|
|
1529
|
+
var E = this._trace(T.expr, t, T.path, r, i, a, o);
|
|
1530
|
+
if (Array.isArray(E)) {
|
|
1531
|
+
p[C] = E[0];
|
|
1532
|
+
for (var D = E.length, O = 1; O < D; O++) C++, p.splice(C, 0, E[O]);
|
|
1533
|
+
} else p[C] = E;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
return p;
|
|
1537
|
+
}, Z.prototype._walk = function(e, t) {
|
|
1538
|
+
if (Array.isArray(e)) for (var n = e.length, r = 0; r < n; r++) t(r);
|
|
1539
|
+
else e && w(e) === "object" && Object.keys(e).forEach(function(e) {
|
|
1540
|
+
t(e);
|
|
1541
|
+
});
|
|
1542
|
+
}, Z.prototype._slice = function(e, t, n, r, i, a, o) {
|
|
1543
|
+
if (Array.isArray(n)) {
|
|
1544
|
+
var s = n.length, c = e.split(":"), l = c[2] && Number.parseInt(c[2]) || 1, u = c[0] && Number.parseInt(c[0]) || 0, d = c[1] && Number.parseInt(c[1]) || s;
|
|
1545
|
+
u = u < 0 ? Math.max(0, u + s) : Math.min(s, u), d = d < 0 ? Math.max(0, d + s) : Math.min(s, d);
|
|
1546
|
+
for (var f = [], p = u; p < d; p += l) this._trace(Y(p, t), n, r, i, a, o, !0).forEach(function(e) {
|
|
1547
|
+
f.push(e);
|
|
1548
|
+
});
|
|
1549
|
+
return f;
|
|
1550
|
+
}
|
|
1551
|
+
}, Z.prototype._eval = function(e, t, n, r, i, a) {
|
|
1552
|
+
var o = this;
|
|
1553
|
+
this.currSandbox._$_parentProperty = a, this.currSandbox._$_parent = i, this.currSandbox._$_property = n, this.currSandbox._$_root = this.json, this.currSandbox._$_v = t;
|
|
1554
|
+
var s = e.includes("@path");
|
|
1555
|
+
s && (this.currSandbox._$_path = Z.toPathString(r.concat([n])));
|
|
1556
|
+
var c = this.currEval + "Script:" + e;
|
|
1557
|
+
if (!Z.cache[c]) {
|
|
1558
|
+
var l = e.replaceAll("@parentProperty", "_$_parentProperty").replaceAll("@parent", "_$_parent").replaceAll("@property", "_$_property").replaceAll("@root", "_$_root").replaceAll(/@([\t-\r \)\.\[\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])/g, "_$_v$1");
|
|
1559
|
+
if (s && (l = l.replaceAll("@path", "_$_path")), this.currEval === "safe" || this.currEval === !0 || this.currEval === void 0) Z.cache[c] = new this.safeVm.Script(l);
|
|
1560
|
+
else if (this.currEval === "native") Z.cache[c] = new this.vm.Script(l);
|
|
1561
|
+
else if (typeof this.currEval == "function" && this.currEval.prototype && Object.hasOwn(this.currEval.prototype, "runInNewContext")) {
|
|
1562
|
+
var u = this.currEval;
|
|
1563
|
+
Z.cache[c] = new u(l);
|
|
1564
|
+
} else if (typeof this.currEval == "function") Z.cache[c] = { runInNewContext: function(e) {
|
|
1565
|
+
return o.currEval(l, e);
|
|
1566
|
+
} };
|
|
1567
|
+
else throw TypeError(`Unknown "eval" property "${this.currEval}"`);
|
|
1568
|
+
}
|
|
1569
|
+
try {
|
|
1570
|
+
return Z.cache[c].runInNewContext(this.currSandbox);
|
|
1571
|
+
} catch (t) {
|
|
1572
|
+
if (this.ignoreEvalErrors) return !1;
|
|
1573
|
+
throw Error("jsonPath: " + t.message + ": " + e);
|
|
1574
|
+
}
|
|
1575
|
+
}, Z.cache = {}, Z.toPathString = function(e) {
|
|
1576
|
+
for (var t = e, n = t.length, r = "$", i = 1; i < n; 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]) || (r += /^[\*0-9]+$/.test(t[i]) ? "[" + t[i] + "]" : "['" + t[i] + "']");
|
|
1577
|
+
return r;
|
|
1578
|
+
}, Z.toPointer = function(e) {
|
|
1579
|
+
for (var t = e, n = t.length, r = "", i = 1; i < n; 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]) || (r += "/" + t[i].toString().replaceAll("~", "~0").replaceAll("/", "~1"));
|
|
1580
|
+
return r;
|
|
1581
|
+
}, Z.toPathArray = function(e) {
|
|
1582
|
+
var t = Z.cache;
|
|
1583
|
+
if (t[e]) return t[e].concat();
|
|
1584
|
+
var n = [];
|
|
1585
|
+
return t[e] = e.replaceAll(/@(?:null|boolean|number|string|integer|undefined|nonFinite|scalar|array|object|function|other)\(\)/g, ";$&;").replaceAll(/['\[](\??\((?:[\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) {
|
|
1586
|
+
return "[#" + (n.push(t) - 1) + "]";
|
|
1587
|
+
}).replaceAll(/\[["']((?:[\0-&\(-\\\^-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)["']\]/g, function(e, t) {
|
|
1588
|
+
return "['" + t.replaceAll(".", "%@%").replaceAll("~", "%%@@%%") + "']";
|
|
1589
|
+
}).replaceAll("~", ";~;").replaceAll(/["']?\.["']?(?!(?:[\0-Z\\-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*\])|\[["']?/g, ";").replaceAll("%@%", ".").replaceAll("%%@@%%", "~").replaceAll(/(?:;)?(\^+)(?:;)?/g, function(e, t) {
|
|
1590
|
+
return ";" + t.split("").join(";") + ";";
|
|
1591
|
+
}).replaceAll(/;;;|;;/g, ";..;").replaceAll(/;$|'?\]|'$/g, "").split(";").map(function(e) {
|
|
1592
|
+
var t = e.match(/#([0-9]+)/);
|
|
1593
|
+
return !t || !t[1] ? e : n[t[1]];
|
|
1594
|
+
}), t[e].concat();
|
|
1595
|
+
}, Z.prototype.safeVm = { Script: q };
|
|
1596
|
+
var ee = function(e, t, n) {
|
|
1597
|
+
for (var r = e.length, i = 0; i < r; i++) {
|
|
1598
|
+
var a = e[i];
|
|
1599
|
+
n(a) && t.push(e.splice(i--, 1)[0]);
|
|
1600
|
+
}
|
|
1601
|
+
}, te = /* @__PURE__ */ function() {
|
|
1602
|
+
function e(t) {
|
|
1603
|
+
a(this, e), this.code = t;
|
|
1604
|
+
}
|
|
1605
|
+
return c(e, [{
|
|
1606
|
+
key: "runInNewContext",
|
|
1607
|
+
value: function(e) {
|
|
1608
|
+
var t = this.code, n = Object.keys(e), r = [];
|
|
1609
|
+
ee(n, r, function(t) {
|
|
1610
|
+
return typeof e[t] == "function";
|
|
1611
|
+
});
|
|
1612
|
+
var i = n.map(function(t) {
|
|
1613
|
+
return e[t];
|
|
1614
|
+
});
|
|
1615
|
+
t = r.reduce(function(t, n) {
|
|
1616
|
+
var r = e[n].toString();
|
|
1617
|
+
return /function/.test(r) || (r = "function " + r), "var " + n + "=" + r + ";" + t;
|
|
1618
|
+
}, "") + t, !/(["'])use strict\1/.test(t) && !n.includes("arguments") && (t = "var arguments = undefined;" + t), t = t.replace(/;[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*$/, "");
|
|
1619
|
+
var a = t.lastIndexOf(";"), s = a === -1 ? " return " + t : t.slice(0, a + 1) + " return " + t.slice(a + 1);
|
|
1620
|
+
return o(Function, n.concat([s])).apply(void 0, x(i));
|
|
1621
|
+
}
|
|
1622
|
+
}]);
|
|
1623
|
+
}();
|
|
1624
|
+
Z.prototype.vm = { Script: te };
|
|
1625
|
+
//#endregion
|
|
1626
|
+
//#region src/configurator.ts
|
|
1627
|
+
function ne(e) {
|
|
1628
|
+
if (!e) return null;
|
|
1629
|
+
try {
|
|
1630
|
+
var t, n, r = (t = (n = e.textContent) == null ? void 0 : n.trim()) == null ? "" : t;
|
|
1631
|
+
return r.startsWith("{") || (r = "{" + r + "}"), Function(`return (${r})`)();
|
|
1632
|
+
} catch (e) {
|
|
1633
|
+
return console.warn(e), null;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
function Q(e, t) {
|
|
1637
|
+
var n = t.getAttribute("data-calc-id");
|
|
1638
|
+
if (!n) return null;
|
|
1639
|
+
var r = t.querySelector(`[data-calc-place="${n}"]`);
|
|
1640
|
+
return !r || e === void 0 || !e[n] ? null : {
|
|
1641
|
+
data: e[n],
|
|
1642
|
+
uniqId: n + "-" + Math.random().toString(36).slice(2, 7),
|
|
1643
|
+
id: n,
|
|
1644
|
+
placeNode: r
|
|
1645
|
+
};
|
|
1646
|
+
}
|
|
1647
|
+
function $(e, t) {
|
|
1648
|
+
var n = v({}, arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {});
|
|
1649
|
+
function r(t, r) {
|
|
1650
|
+
var i = t.replace(/\$get:([a-zA-Z0-9_.-]+)/g, function(e, t) {
|
|
1651
|
+
return String(n[t]);
|
|
1652
|
+
});
|
|
1653
|
+
if (i.startsWith("$save:")) {
|
|
1654
|
+
var a = i.replace("$save:", "");
|
|
1655
|
+
return n[a] = r, r;
|
|
1656
|
+
}
|
|
1657
|
+
switch (i) {
|
|
1658
|
+
case "$root": return e;
|
|
1659
|
+
case "$first": return r[0];
|
|
1660
|
+
case "$last":
|
|
1661
|
+
var o = r;
|
|
1662
|
+
return o[o.length - 1];
|
|
1663
|
+
default: return Z({
|
|
1664
|
+
path: i,
|
|
1665
|
+
json: r
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
var i = t.split("||").map(function(e) {
|
|
1670
|
+
return e.trim();
|
|
1671
|
+
}), a = null;
|
|
1672
|
+
do {
|
|
1673
|
+
a = e;
|
|
1674
|
+
for (var o = i.shift().split(">").map(function(e) {
|
|
1675
|
+
return e.trim();
|
|
1676
|
+
}); o.length;) if (a = r(o.shift(), a), a == null || Array.isArray(a) && !a.length) {
|
|
1677
|
+
a = null;
|
|
1678
|
+
break;
|
|
1679
|
+
}
|
|
1680
|
+
if (a !== null) break;
|
|
1681
|
+
} while (i.length);
|
|
1682
|
+
return a;
|
|
1683
|
+
}
|
|
1684
|
+
function re(e, t) {
|
|
1685
|
+
var n = Q(e, t);
|
|
1686
|
+
if (n) {
|
|
1687
|
+
var r = n.id, i = n.uniqId, a = n.data, o = n.placeNode, s = ne(t.querySelector("[data-configurator-options]"));
|
|
1688
|
+
if (s) {
|
|
1689
|
+
var c = s.oldPricePercent, l = s.getPrice, u = s.sections, d = s.fields;
|
|
1690
|
+
t.setAttribute("data-calc-id", i);
|
|
1691
|
+
var f = new M({
|
|
1692
|
+
id: i,
|
|
1693
|
+
parentSelector: `[data-calc-id="${i}"]`,
|
|
1694
|
+
data: a,
|
|
1695
|
+
editableFields: [],
|
|
1696
|
+
sectionsOptions: []
|
|
1697
|
+
});
|
|
1698
|
+
f.addField({
|
|
1699
|
+
selector: "price",
|
|
1700
|
+
calculateFunction: function(e, t) {
|
|
1701
|
+
var n = l(e, t, r), i = f.getValues();
|
|
1702
|
+
return Object.keys(i).length !== Object.keys(e).length && setTimeout(function() {
|
|
1703
|
+
f.refresh();
|
|
1704
|
+
}), n;
|
|
1705
|
+
}
|
|
1706
|
+
}), f.addField({
|
|
1707
|
+
selector: "old-price",
|
|
1708
|
+
calculateFunction: function() {
|
|
1709
|
+
return f.getValue("price") / ((100 - c) / 100);
|
|
1710
|
+
}
|
|
1711
|
+
});
|
|
1712
|
+
var p = { calculateFunction: function(e) {
|
|
1713
|
+
return u.map(function(t) {
|
|
1714
|
+
var n;
|
|
1715
|
+
return e[t.key] + ((n = t.postfix) == null ? "" : n);
|
|
1716
|
+
}).join(" ");
|
|
1717
|
+
} };
|
|
1718
|
+
f.addField(v({ selector: "params" }, p)), f.addField(v({
|
|
1719
|
+
selector: "params-attr",
|
|
1720
|
+
attribute: !0
|
|
1721
|
+
}, p));
|
|
1722
|
+
var m = { calculateFunction: function(e) {
|
|
1723
|
+
return u.map(function(t) {
|
|
1724
|
+
var n;
|
|
1725
|
+
return `${t.title}: ${e[t.key]}${(n = t.postfix) == null ? "" : n}`;
|
|
1726
|
+
}).join("\n");
|
|
1727
|
+
} };
|
|
1728
|
+
f.addField(v({ selector: "params-view" }, m)), f.addField(v({
|
|
1729
|
+
selector: "params-view-attr",
|
|
1730
|
+
attribute: !0
|
|
1731
|
+
}, m));
|
|
1732
|
+
var h = ["price", "old-price"];
|
|
1733
|
+
u.forEach(function(e) {
|
|
1734
|
+
f.addField({
|
|
1735
|
+
selector: e.key,
|
|
1736
|
+
calculateFunction: function(t) {
|
|
1737
|
+
return t[e.key];
|
|
1738
|
+
}
|
|
1739
|
+
}), h.push(e.key), f.addField({
|
|
1740
|
+
selector: `${e.key}-view`,
|
|
1741
|
+
calculateFunction: function(t) {
|
|
1742
|
+
var n = t[e.key], r = $(a, e.path, t);
|
|
1743
|
+
return typeof e.selectorDisplay == "function" ? e.selectorDisplay(n, r) : n;
|
|
1744
|
+
}
|
|
1745
|
+
});
|
|
1746
|
+
function t(t) {
|
|
1747
|
+
var n, r, i;
|
|
1748
|
+
return (r = ((n = e.labelMapping) == null ? {} : n)[t]) == null ? t + ((i = e.postfix) == null ? "" : i) : r;
|
|
1749
|
+
}
|
|
1750
|
+
f.addSection({
|
|
1751
|
+
title: e.title,
|
|
1752
|
+
type: e.key,
|
|
1753
|
+
inputs: Array.isArray(e.inputs) ? e.inputs : function() {
|
|
1754
|
+
var n = f.getValues(), r = $(a, e.path, n);
|
|
1755
|
+
return r ? r.map(function(e) {
|
|
1756
|
+
return {
|
|
1757
|
+
label: t(e),
|
|
1758
|
+
value: e
|
|
1759
|
+
};
|
|
1760
|
+
}) : [];
|
|
1761
|
+
}
|
|
1762
|
+
});
|
|
1763
|
+
}), Array.isArray(d) && d.forEach(function(e) {
|
|
1764
|
+
f.addField({
|
|
1765
|
+
selector: e.selector,
|
|
1766
|
+
attribute: !!e.attribute,
|
|
1767
|
+
calculateFunction: function(t, n) {
|
|
1768
|
+
return e.get(t, n, r, f);
|
|
1769
|
+
}
|
|
1770
|
+
});
|
|
1771
|
+
}), h.forEach(function(e) {
|
|
1772
|
+
f.addField({
|
|
1773
|
+
selector: e,
|
|
1774
|
+
attribute: !0,
|
|
1775
|
+
calculateFunction: function() {
|
|
1776
|
+
return f.getValue(e);
|
|
1777
|
+
}
|
|
1778
|
+
});
|
|
1779
|
+
}), f.renderInNode(o), f.init();
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
//#endregion
|
|
1784
|
+
export { M as Calculator, Q as getOptions, re as initConfigurator, $ as queryByPath };
|