@nebula-spatial/viewer 0.4.3 → 0.4.5

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.
@@ -0,0 +1,1537 @@
1
+ import { n as bt } from "./session-DNyPmQOW.js";
2
+ function _t(t) {
3
+ const e = t.split(/[\\/]/g);
4
+ return e.pop(), e.length === 0 ? "./" : e.join("/") + "/";
5
+ }
6
+ function K(t, e, r = []) {
7
+ t.tagName === e && r.push(t);
8
+ for (let n = 0, s = t.children.length; n < s; n++) {
9
+ const o = t.children[n];
10
+ K(o, e, r);
11
+ }
12
+ return r;
13
+ }
14
+ function ft(t, e) {
15
+ const r = t.cloneNode(), n = t.childNodes;
16
+ for (let s = 0, o = n.length; s < o; s++) {
17
+ const a = n[s], u = a.tagName;
18
+ (!e || u !== "xacro:property" && u !== "xacro:macro") && r.appendChild(ft(a, e));
19
+ }
20
+ return r;
21
+ }
22
+ function rt(t) {
23
+ for (; t.length > 0; ) {
24
+ const e = t[t.length - 1];
25
+ if (e.nodeType !== e.ELEMENT_NODE)
26
+ t.pop();
27
+ else
28
+ break;
29
+ }
30
+ }
31
+ function Zt(t) {
32
+ return /^[()/*+\-%|&=[\]]+$/.test(t);
33
+ }
34
+ function jt(t) {
35
+ return /^(('[^']*?')|("[^"]*?")|(`[^`]*?`))$/.test(t);
36
+ }
37
+ function gt(t) {
38
+ return !isNaN(Number(t)) && !isNaN(parseFloat(t));
39
+ }
40
+ function Jt(t) {
41
+ const e = /(('[^']*?')|("[^"]*?")|(`[^`]*?`)|([()/*+\-%|!&=]+?))/g;
42
+ return t.replace(e, (r) => ` ${r} `).trim().split(/\s+/g);
43
+ }
44
+ function Qt(t) {
45
+ return t.replace(/[-+]{2,}/, (e) => {
46
+ let r = !0;
47
+ for (let n = 0, s = e.length; n < s; n++)
48
+ e[n] === "-" && (r = !r);
49
+ return r ? "+" : "-";
50
+ });
51
+ }
52
+ const st = Symbol("parent");
53
+ function Tt(...t) {
54
+ const e = {};
55
+ for (let r = 0, n = t.length; r < n; r++) {
56
+ const s = t[r];
57
+ for (const o in s)
58
+ e[o] = s[o];
59
+ st in s && (e[st] = s[st]);
60
+ }
61
+ return e;
62
+ }
63
+ function te(t) {
64
+ const e = Tt(t);
65
+ return e[st] = t, e;
66
+ }
67
+ var X = "INUMBER", ut = "IOP1", ht = "IOP2", ct = "IOP3", z = "IVAR", H = "IVARNAME", at = "IFUNCALL", yt = "IFUNDEF", F = "IEXPR", Nt = "IEXPREVAL", Z = "IMEMBER", xt = "IENDSTATEMENT", ot = "IARRAY";
68
+ function x(t, e) {
69
+ this.type = t, this.value = e ?? 0;
70
+ }
71
+ x.prototype.toString = function() {
72
+ switch (this.type) {
73
+ case X:
74
+ case ut:
75
+ case ht:
76
+ case ct:
77
+ case z:
78
+ case H:
79
+ case xt:
80
+ return this.value;
81
+ case at:
82
+ return "CALL " + this.value;
83
+ case yt:
84
+ return "DEF " + this.value;
85
+ case ot:
86
+ return "ARRAY " + this.value;
87
+ case Z:
88
+ return "." + this.value;
89
+ default:
90
+ return "Invalid Instruction";
91
+ }
92
+ };
93
+ function Mt(t) {
94
+ return new x(ut, t);
95
+ }
96
+ function G(t) {
97
+ return new x(ht, t);
98
+ }
99
+ function Wt(t) {
100
+ return new x(ct, t);
101
+ }
102
+ function Pt(t, e, r, n, s) {
103
+ for (var o = [], a = [], u, y, M, E, N = 0; N < t.length; N++) {
104
+ var c = t[N], b = c.type;
105
+ if (b === X || b === H)
106
+ Array.isArray(c.value) ? o.push.apply(o, Pt(c.value.map(function(R) {
107
+ return new x(X, R);
108
+ }).concat(new x(ot, c.value.length)), e, r, n, s)) : o.push(c);
109
+ else if (b === z && Object.hasOwn(s, c.value))
110
+ c = new x(X, s[c.value]), o.push(c);
111
+ else if (b === ht && o.length > 1)
112
+ y = o.pop(), u = o.pop(), E = r[c.value], c = new x(X, E(u.value, y.value)), o.push(c);
113
+ else if (b === ct && o.length > 2)
114
+ M = o.pop(), y = o.pop(), u = o.pop(), c.value === "?" ? o.push(u.value ? y.value : M.value) : (E = n[c.value], c = new x(X, E(u.value, y.value, M.value)), o.push(c));
115
+ else if (b === ut && o.length > 0)
116
+ u = o.pop(), E = e[c.value], c = new x(X, E(u.value)), o.push(c);
117
+ else if (b === F) {
118
+ for (; o.length > 0; )
119
+ a.push(o.shift());
120
+ a.push(new x(F, Pt(c.value, e, r, n, s)));
121
+ } else if (b === Z && o.length > 0)
122
+ u = o.pop(), o.push(new x(X, u.value[c.value]));
123
+ else {
124
+ for (; o.length > 0; )
125
+ a.push(o.shift());
126
+ a.push(c);
127
+ }
128
+ }
129
+ for (; o.length > 0; )
130
+ a.push(o.shift());
131
+ return a;
132
+ }
133
+ function Gt(t, e, r) {
134
+ for (var n = [], s = 0; s < t.length; s++) {
135
+ var o = t[s], a = o.type;
136
+ if (a === z && o.value === e)
137
+ for (var u = 0; u < r.tokens.length; u++) {
138
+ var y = r.tokens[u], M;
139
+ y.type === ut ? M = Mt(y.value) : y.type === ht ? M = G(y.value) : y.type === ct ? M = Wt(y.value) : M = new x(y.type, y.value), n.push(M);
140
+ }
141
+ else a === F ? n.push(new x(F, Gt(o.value, e, r))) : n.push(o);
142
+ }
143
+ return n;
144
+ }
145
+ function Ot(t, e, r) {
146
+ if (Object.values(e.functions).includes(t)) return !0;
147
+ for (const s of Object.values(r))
148
+ if (typeof s == "object" && s !== null) {
149
+ for (const o of Object.values(s))
150
+ if (o === t) {
151
+ const a = Object.freeze({
152
+ abs: Math.abs,
153
+ acos: Math.acos,
154
+ asin: Math.asin,
155
+ atan: Math.atan,
156
+ atan2: Math.atan2,
157
+ ceil: Math.ceil,
158
+ clz32: Math.clz32,
159
+ cos: Math.cos,
160
+ exp: Math.exp,
161
+ floor: Math.floor,
162
+ imul: Math.imul,
163
+ fround: Math.fround,
164
+ f16round: Math.f16round,
165
+ log: Math.log,
166
+ max: Math.max,
167
+ min: Math.min,
168
+ pow: Math.pow,
169
+ random: Math.random,
170
+ round: Math.round,
171
+ sin: Math.sin,
172
+ sqrt: Math.sqrt,
173
+ tan: Math.tan,
174
+ log10: Math.log10,
175
+ log2: Math.log2,
176
+ log1p: Math.log1p,
177
+ expm1: Math.expm1,
178
+ cosh: Math.cosh,
179
+ sinh: Math.sinh,
180
+ tanh: Math.tanh,
181
+ acosh: Math.acosh,
182
+ asinh: Math.asinh,
183
+ atanh: Math.atanh,
184
+ hypot: Math.hypot,
185
+ trunc: Math.trunc,
186
+ sign: Math.sign,
187
+ cbrt: Math.cbrt
188
+ });
189
+ for (var n of Object.getOwnPropertyNames(a))
190
+ if (a[n] === o) return !0;
191
+ return Object.values(e.functions).includes(o);
192
+ }
193
+ }
194
+ return !1;
195
+ }
196
+ function Y(t, e, r) {
197
+ var n = [], s, o, a, u, y, M;
198
+ if (Ct(t))
199
+ return V(t, r);
200
+ for (var E = t.length, N = 0; N < E; N++) {
201
+ var c = t[N], b = c.type;
202
+ if (b === X || b === H)
203
+ n.push(c.value);
204
+ else if (b === ht)
205
+ o = n.pop(), s = n.pop(), c.value === "and" ? n.push(s ? !!Y(o, e, r) : !1) : c.value === "or" ? n.push(s ? !0 : !!Y(o, e, r)) : c.value === "=" ? (u = e.binaryOps[c.value], n.push(u(s, Y(o, e, r), r))) : (u = e.binaryOps[c.value], n.push(u(V(s, r), V(o, r))));
206
+ else if (b === ct)
207
+ a = n.pop(), o = n.pop(), s = n.pop(), c.value === "?" ? n.push(Y(s ? o : a, e, r)) : (u = e.ternaryOps[c.value], n.push(u(V(s, r), V(o, r), V(a, r))));
208
+ else if (b === z) {
209
+ if (/^__proto__|prototype|constructor$/.test(c.value))
210
+ throw new Error("prototype access detected");
211
+ if (c.value in e.functions)
212
+ n.push(e.functions[c.value]);
213
+ else if (c.value in e.unaryOps && e.parser.isOperatorEnabled(c.value))
214
+ n.push(e.unaryOps[c.value]);
215
+ else {
216
+ var R = r[c.value];
217
+ if (R !== void 0) {
218
+ if (typeof R == "function" && !Ot(R, e, r))
219
+ throw new Error("Variable references an unallowed function: " + c.value);
220
+ n.push(R);
221
+ } else
222
+ throw new Error("undefined variable: " + c.value);
223
+ }
224
+ } else if (b === ut)
225
+ s = n.pop(), u = e.unaryOps[c.value], n.push(u(V(s, r)));
226
+ else if (b === at) {
227
+ for (M = c.value, y = []; M-- > 0; )
228
+ y.unshift(V(n.pop(), r));
229
+ if (u = n.pop(), !Ot(u, e, r))
230
+ throw new Error("Is not an allowed function.");
231
+ if (u.apply && u.call)
232
+ n.push(u.apply(void 0, y));
233
+ else
234
+ throw new Error(u + " is not a function");
235
+ } else if (b === yt)
236
+ n.push(function() {
237
+ for (var D = n.pop(), d = [], g = c.value; g-- > 0; )
238
+ d.unshift(n.pop());
239
+ var S = n.pop(), k = function() {
240
+ for (var wt = Object.assign({}, r), Q = 0, pt = d.length; Q < pt; Q++)
241
+ wt[d[Q]] = arguments[Q];
242
+ return Y(D, e, wt);
243
+ };
244
+ return e.functions["lambda_" + e.functions.__counter++] = k, r[S] = k, k;
245
+ }());
246
+ else if (b === F)
247
+ n.push(ee(c, e));
248
+ else if (b === Nt)
249
+ n.push(c);
250
+ else if (b === Z) {
251
+ if (s = n.pop(), /^__proto__|prototype|constructor$/.test(c.value))
252
+ throw new Error("prototype access detected in MEMBER");
253
+ if (typeof s == "object" && typeof s[c.value] == "function" && !Ot(s[c.value], e, r))
254
+ throw new Error("Is not an allowed function in MEMBER.");
255
+ n.push(s[c.value]);
256
+ } else if (b === xt)
257
+ n.pop();
258
+ else if (b === ot) {
259
+ for (M = c.value, y = []; M-- > 0; )
260
+ y.unshift(n.pop());
261
+ n.push(y);
262
+ } else
263
+ throw new Error("invalid Expression");
264
+ }
265
+ if (n.length > 1)
266
+ throw new Error("invalid Expression (parity)");
267
+ return n[0] === 0 ? 0 : V(n[0], r);
268
+ }
269
+ function ee(t, e, r) {
270
+ return Ct(t) ? t : {
271
+ type: Nt,
272
+ value: function(n) {
273
+ return Y(t.value, e, n);
274
+ }
275
+ };
276
+ }
277
+ function Ct(t) {
278
+ return t && t.type === Nt;
279
+ }
280
+ function V(t, e) {
281
+ return Ct(t) ? t.value(e) : t;
282
+ }
283
+ function It(t, e) {
284
+ for (var r = [], n, s, o, a, u, y, M = 0; M < t.length; M++) {
285
+ var E = t[M], N = E.type;
286
+ if (N === X)
287
+ typeof E.value == "number" && E.value < 0 ? r.push("(" + E.value + ")") : Array.isArray(E.value) ? r.push("[" + E.value.map(Xt).join(", ") + "]") : r.push(Xt(E.value));
288
+ else if (N === ht)
289
+ s = r.pop(), n = r.pop(), a = E.value, e ? a === "^" ? r.push("Math.pow(" + n + ", " + s + ")") : a === "and" ? r.push("(!!" + n + " && !!" + s + ")") : a === "or" ? r.push("(!!" + n + " || !!" + s + ")") : a === "||" ? r.push("(function(a,b){ return Array.isArray(a) && Array.isArray(b) ? a.concat(b) : String(a) + String(b); }((" + n + "),(" + s + ")))") : a === "==" ? r.push("(" + n + " === " + s + ")") : a === "!=" ? r.push("(" + n + " !== " + s + ")") : a === "[" ? r.push(n + "[(" + s + ") | 0]") : r.push("(" + n + " " + a + " " + s + ")") : a === "[" ? r.push(n + "[" + s + "]") : r.push("(" + n + " " + a + " " + s + ")");
290
+ else if (N === ct)
291
+ if (o = r.pop(), s = r.pop(), n = r.pop(), a = E.value, a === "?")
292
+ r.push("(" + n + " ? " + s + " : " + o + ")");
293
+ else
294
+ throw new Error("invalid Expression");
295
+ else if (N === z || N === H)
296
+ r.push(E.value);
297
+ else if (N === ut)
298
+ n = r.pop(), a = E.value, a === "-" || a === "+" ? r.push("(" + a + n + ")") : e ? a === "not" ? r.push("(!" + n + ")") : a === "!" ? r.push("fac(" + n + ")") : r.push(a + "(" + n + ")") : a === "!" ? r.push("(" + n + "!)") : r.push("(" + a + " " + n + ")");
299
+ else if (N === at) {
300
+ for (y = E.value, u = []; y-- > 0; )
301
+ u.unshift(r.pop());
302
+ a = r.pop(), r.push(a + "(" + u.join(", ") + ")");
303
+ } else if (N === yt) {
304
+ for (s = r.pop(), y = E.value, u = []; y-- > 0; )
305
+ u.unshift(r.pop());
306
+ n = r.pop(), e ? r.push("(" + n + " = function(" + u.join(", ") + ") { return " + s + " })") : r.push("(" + n + "(" + u.join(", ") + ") = " + s + ")");
307
+ } else if (N === Z)
308
+ n = r.pop(), r.push(n + "." + E.value);
309
+ else if (N === ot) {
310
+ for (y = E.value, u = []; y-- > 0; )
311
+ u.unshift(r.pop());
312
+ r.push("[" + u.join(", ") + "]");
313
+ } else if (N === F)
314
+ r.push("(" + It(E.value, e) + ")");
315
+ else if (N !== xt) throw new Error("invalid Expression");
316
+ }
317
+ return r.length > 1 && (e ? r = [r.join(",")] : r = [r.join(";")]), String(r[0]);
318
+ }
319
+ function Xt(t) {
320
+ return typeof t == "string" ? JSON.stringify(t).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029") : t;
321
+ }
322
+ function nt(t, e) {
323
+ for (var r = 0; r < t.length; r++)
324
+ if (t[r] === e)
325
+ return !0;
326
+ return !1;
327
+ }
328
+ function St(t, e, r) {
329
+ r = r || {};
330
+ for (var n = !!r.withMembers, s = null, o = 0; o < t.length; o++) {
331
+ var a = t[o];
332
+ a.type === z || a.type === H ? !n && !nt(e, a.value) ? e.push(a.value) : (s !== null && (nt(e, s) || e.push(s)), s = a.value) : a.type === Z && n && s !== null ? s += "." + a.value : a.type === F ? St(a.value, e, r) : s !== null && (nt(e, s) || e.push(s), s = null);
333
+ }
334
+ s !== null && !nt(e, s) && e.push(s);
335
+ }
336
+ function U(t, e) {
337
+ this.tokens = t, this.parser = e, this.unaryOps = e.unaryOps, this.binaryOps = e.binaryOps, this.ternaryOps = e.ternaryOps, this.functions = e.functions;
338
+ }
339
+ U.prototype.simplify = function(t) {
340
+ return t = t || {}, new U(Pt(this.tokens, this.unaryOps, this.binaryOps, this.ternaryOps, t), this.parser);
341
+ };
342
+ U.prototype.substitute = function(t, e) {
343
+ return e instanceof U || (e = this.parser.parse(String(e))), new U(Gt(this.tokens, t, e), this.parser);
344
+ };
345
+ U.prototype.evaluate = function(t) {
346
+ return t = t || {}, Y(this.tokens, this, t);
347
+ };
348
+ U.prototype.toString = function() {
349
+ return It(this.tokens, !1);
350
+ };
351
+ U.prototype.symbols = function(t) {
352
+ t = t || {};
353
+ var e = [];
354
+ return St(this.tokens, e, t), e;
355
+ };
356
+ U.prototype.variables = function(t) {
357
+ t = t || {};
358
+ var e = [];
359
+ St(this.tokens, e, t);
360
+ var r = this.functions;
361
+ return e.filter(function(n) {
362
+ return !(n in r);
363
+ });
364
+ };
365
+ U.prototype.toJSFunction = function(t, e) {
366
+ var r = this, n = new Function(t, "with(this.functions) with (this.ternaryOps) with (this.binaryOps) with (this.unaryOps) { return " + It(this.simplify(e).tokens, !0) + "; }");
367
+ return function() {
368
+ return n.apply(r, arguments);
369
+ };
370
+ };
371
+ var dt = "TEOF", O = "TOP", Et = "TNUMBER", Kt = "TSTRING", W = "TPAREN", it = "TBRACKET", At = "TCOMMA", $t = "TNAME", Rt = "TSEMICOLON";
372
+ function Yt(t, e, r) {
373
+ this.type = t, this.value = e, this.index = r;
374
+ }
375
+ Yt.prototype.toString = function() {
376
+ return this.type + ": " + this.value;
377
+ };
378
+ function C(t, e) {
379
+ this.pos = 0, this.current = null, this.unaryOps = t.unaryOps, this.binaryOps = t.binaryOps, this.ternaryOps = t.ternaryOps, this.consts = t.consts, this.expression = e, this.savedPosition = 0, this.savedCurrent = null, this.options = t.options, this.parser = t;
380
+ }
381
+ C.prototype.newToken = function(t, e, r) {
382
+ return new Yt(t, e, r ?? this.pos);
383
+ };
384
+ C.prototype.save = function() {
385
+ this.savedPosition = this.pos, this.savedCurrent = this.current;
386
+ };
387
+ C.prototype.restore = function() {
388
+ this.pos = this.savedPosition, this.current = this.savedCurrent;
389
+ };
390
+ C.prototype.next = function() {
391
+ if (this.pos >= this.expression.length)
392
+ return this.newToken(dt, "EOF");
393
+ if (this.isWhitespace() || this.isComment())
394
+ return this.next();
395
+ if (this.isRadixInteger() || this.isNumber() || this.isOperator() || this.isString() || this.isParen() || this.isBracket() || this.isComma() || this.isSemicolon() || this.isNamedOp() || this.isConst() || this.isName())
396
+ return this.current;
397
+ this.parseError('Unknown character "' + this.expression.charAt(this.pos) + '"');
398
+ };
399
+ C.prototype.isString = function() {
400
+ var t = !1, e = this.pos, r = this.expression.charAt(e);
401
+ if (r === "'" || r === '"')
402
+ for (var n = this.expression.indexOf(r, e + 1); n >= 0 && this.pos < this.expression.length; ) {
403
+ if (this.pos = n + 1, this.expression.charAt(n - 1) !== "\\") {
404
+ var s = this.expression.substring(e + 1, n);
405
+ this.current = this.newToken(Kt, this.unescape(s), e), t = !0;
406
+ break;
407
+ }
408
+ n = this.expression.indexOf(r, n + 1);
409
+ }
410
+ return t;
411
+ };
412
+ C.prototype.isParen = function() {
413
+ var t = this.expression.charAt(this.pos);
414
+ return t === "(" || t === ")" ? (this.current = this.newToken(W, t), this.pos++, !0) : !1;
415
+ };
416
+ C.prototype.isBracket = function() {
417
+ var t = this.expression.charAt(this.pos);
418
+ return (t === "[" || t === "]") && this.isOperatorEnabled("[") ? (this.current = this.newToken(it, t), this.pos++, !0) : !1;
419
+ };
420
+ C.prototype.isComma = function() {
421
+ var t = this.expression.charAt(this.pos);
422
+ return t === "," ? (this.current = this.newToken(At, ","), this.pos++, !0) : !1;
423
+ };
424
+ C.prototype.isSemicolon = function() {
425
+ var t = this.expression.charAt(this.pos);
426
+ return t === ";" ? (this.current = this.newToken(Rt, ";"), this.pos++, !0) : !1;
427
+ };
428
+ C.prototype.isConst = function() {
429
+ for (var t = this.pos, e = t; e < this.expression.length; e++) {
430
+ var r = this.expression.charAt(e);
431
+ if (r.toUpperCase() === r.toLowerCase() && (e === this.pos || r !== "_" && r !== "." && (r < "0" || r > "9")))
432
+ break;
433
+ }
434
+ if (e > t) {
435
+ var n = this.expression.substring(t, e);
436
+ if (n in this.consts)
437
+ return this.current = this.newToken(Et, this.consts[n]), this.pos += n.length, !0;
438
+ }
439
+ return !1;
440
+ };
441
+ C.prototype.isNamedOp = function() {
442
+ for (var t = this.pos, e = t; e < this.expression.length; e++) {
443
+ var r = this.expression.charAt(e);
444
+ if (r.toUpperCase() === r.toLowerCase() && (e === this.pos || r !== "_" && (r < "0" || r > "9")))
445
+ break;
446
+ }
447
+ if (e > t) {
448
+ var n = this.expression.substring(t, e);
449
+ if (this.isOperatorEnabled(n) && (n in this.binaryOps || n in this.unaryOps || n in this.ternaryOps))
450
+ return this.current = this.newToken(O, n), this.pos += n.length, !0;
451
+ }
452
+ return !1;
453
+ };
454
+ C.prototype.isName = function() {
455
+ for (var t = this.pos, e = t, r = !1; e < this.expression.length; e++) {
456
+ var n = this.expression.charAt(e);
457
+ if (n.toUpperCase() === n.toLowerCase()) {
458
+ if (e === this.pos && (n === "$" || n === "_")) {
459
+ n === "_" && (r = !0);
460
+ continue;
461
+ } else if (e === this.pos || !r || n !== "_" && (n < "0" || n > "9"))
462
+ break;
463
+ } else
464
+ r = !0;
465
+ }
466
+ if (r) {
467
+ var s = this.expression.substring(t, e);
468
+ return this.current = this.newToken($t, s), this.pos += s.length, !0;
469
+ }
470
+ return !1;
471
+ };
472
+ C.prototype.isWhitespace = function() {
473
+ for (var t = !1, e = this.expression.charAt(this.pos); (e === " " || e === " " || e === `
474
+ ` || e === "\r") && (t = !0, this.pos++, !(this.pos >= this.expression.length)); )
475
+ e = this.expression.charAt(this.pos);
476
+ return t;
477
+ };
478
+ var re = /^[0-9a-f]{4}$/i;
479
+ C.prototype.unescape = function(t) {
480
+ var e = t.indexOf("\\");
481
+ if (e < 0)
482
+ return t;
483
+ for (var r = t.substring(0, e); e >= 0; ) {
484
+ var n = t.charAt(++e);
485
+ switch (n) {
486
+ case "'":
487
+ r += "'";
488
+ break;
489
+ case '"':
490
+ r += '"';
491
+ break;
492
+ case "\\":
493
+ r += "\\";
494
+ break;
495
+ case "/":
496
+ r += "/";
497
+ break;
498
+ case "b":
499
+ r += "\b";
500
+ break;
501
+ case "f":
502
+ r += "\f";
503
+ break;
504
+ case "n":
505
+ r += `
506
+ `;
507
+ break;
508
+ case "r":
509
+ r += "\r";
510
+ break;
511
+ case "t":
512
+ r += " ";
513
+ break;
514
+ case "u":
515
+ var s = t.substring(e + 1, e + 5);
516
+ re.test(s) || this.parseError("Illegal escape sequence: \\u" + s), r += String.fromCharCode(parseInt(s, 16)), e += 4;
517
+ break;
518
+ default:
519
+ throw this.parseError('Illegal escape sequence: "\\' + n + '"');
520
+ }
521
+ ++e;
522
+ var o = t.indexOf("\\", e);
523
+ r += t.substring(e, o < 0 ? t.length : o), e = o;
524
+ }
525
+ return r;
526
+ };
527
+ C.prototype.isComment = function() {
528
+ var t = this.expression.charAt(this.pos);
529
+ return t === "/" && this.expression.charAt(this.pos + 1) === "*" ? (this.pos = this.expression.indexOf("*/", this.pos) + 2, this.pos === 1 && (this.pos = this.expression.length), !0) : !1;
530
+ };
531
+ C.prototype.isRadixInteger = function() {
532
+ var t = this.pos;
533
+ if (t >= this.expression.length - 2 || this.expression.charAt(t) !== "0")
534
+ return !1;
535
+ ++t;
536
+ var e, r;
537
+ if (this.expression.charAt(t) === "x")
538
+ e = 16, r = /^[0-9a-f]$/i, ++t;
539
+ else if (this.expression.charAt(t) === "b")
540
+ e = 2, r = /^[01]$/i, ++t;
541
+ else
542
+ return !1;
543
+ for (var n = !1, s = t; t < this.expression.length; ) {
544
+ var o = this.expression.charAt(t);
545
+ if (r.test(o))
546
+ t++, n = !0;
547
+ else
548
+ break;
549
+ }
550
+ return n && (this.current = this.newToken(Et, parseInt(this.expression.substring(s, t), e)), this.pos = t), n;
551
+ };
552
+ C.prototype.isNumber = function() {
553
+ for (var t = !1, e = this.pos, r = e, n = e, s = !1, o = !1, a; e < this.expression.length && (a = this.expression.charAt(e), a >= "0" && a <= "9" || !s && a === "."); )
554
+ a === "." ? s = !0 : o = !0, e++, t = o;
555
+ if (t && (n = e), a === "e" || a === "E") {
556
+ e++;
557
+ for (var u = !0, y = !1; e < this.expression.length; ) {
558
+ if (a = this.expression.charAt(e), u && (a === "+" || a === "-"))
559
+ u = !1;
560
+ else if (a >= "0" && a <= "9")
561
+ y = !0, u = !1;
562
+ else
563
+ break;
564
+ e++;
565
+ }
566
+ y || (e = n);
567
+ }
568
+ return t ? (this.current = this.newToken(Et, parseFloat(this.expression.substring(r, e))), this.pos = e) : this.pos = n, t;
569
+ };
570
+ C.prototype.isOperator = function() {
571
+ var t = this.pos, e = this.expression.charAt(this.pos);
572
+ if (e === "+" || e === "-" || e === "*" || e === "/" || e === "%" || e === "^" || e === "?" || e === ":" || e === ".")
573
+ this.current = this.newToken(O, e);
574
+ else if (e === "∙" || e === "•")
575
+ this.current = this.newToken(O, "*");
576
+ else if (e === ">")
577
+ this.expression.charAt(this.pos + 1) === "=" ? (this.current = this.newToken(O, ">="), this.pos++) : this.current = this.newToken(O, ">");
578
+ else if (e === "<")
579
+ this.expression.charAt(this.pos + 1) === "=" ? (this.current = this.newToken(O, "<="), this.pos++) : this.current = this.newToken(O, "<");
580
+ else if (e === "|")
581
+ if (this.expression.charAt(this.pos + 1) === "|")
582
+ this.current = this.newToken(O, "||"), this.pos++;
583
+ else
584
+ return !1;
585
+ else if (e === "=")
586
+ this.expression.charAt(this.pos + 1) === "=" ? (this.current = this.newToken(O, "=="), this.pos++) : this.current = this.newToken(O, e);
587
+ else if (e === "!")
588
+ this.expression.charAt(this.pos + 1) === "=" ? (this.current = this.newToken(O, "!="), this.pos++) : this.current = this.newToken(O, e);
589
+ else
590
+ return !1;
591
+ return this.pos++, this.isOperatorEnabled(this.current.value) ? !0 : (this.pos = t, !1);
592
+ };
593
+ C.prototype.isOperatorEnabled = function(t) {
594
+ return this.parser.isOperatorEnabled(t);
595
+ };
596
+ C.prototype.getCoordinates = function() {
597
+ var t = 0, e, r = -1;
598
+ do
599
+ t++, e = this.pos - r, r = this.expression.indexOf(`
600
+ `, r + 1);
601
+ while (r >= 0 && r < this.pos);
602
+ return {
603
+ line: t,
604
+ column: e
605
+ };
606
+ };
607
+ C.prototype.parseError = function(t) {
608
+ var e = this.getCoordinates();
609
+ throw new Error("parse error [" + e.line + ":" + e.column + "]: " + t);
610
+ };
611
+ function P(t, e, r) {
612
+ this.parser = t, this.tokens = e, this.current = null, this.nextToken = null, this.next(), this.savedCurrent = null, this.savedNextToken = null, this.allowMemberAccess = r.allowMemberAccess !== !1;
613
+ }
614
+ P.prototype.next = function() {
615
+ return this.current = this.nextToken, this.nextToken = this.tokens.next();
616
+ };
617
+ P.prototype.tokenMatches = function(t, e) {
618
+ return typeof e > "u" ? !0 : Array.isArray(e) ? nt(e, t.value) : typeof e == "function" ? e(t) : t.value === e;
619
+ };
620
+ P.prototype.save = function() {
621
+ this.savedCurrent = this.current, this.savedNextToken = this.nextToken, this.tokens.save();
622
+ };
623
+ P.prototype.restore = function() {
624
+ this.tokens.restore(), this.current = this.savedCurrent, this.nextToken = this.savedNextToken;
625
+ };
626
+ P.prototype.accept = function(t, e) {
627
+ return this.nextToken.type === t && this.tokenMatches(this.nextToken, e) ? (this.next(), !0) : !1;
628
+ };
629
+ P.prototype.expect = function(t, e) {
630
+ if (!this.accept(t, e)) {
631
+ var r = this.tokens.getCoordinates();
632
+ throw new Error("parse error [" + r.line + ":" + r.column + "]: Expected " + (e || t));
633
+ }
634
+ };
635
+ P.prototype.parseAtom = function(t) {
636
+ var e = this.tokens.unaryOps;
637
+ function r(s) {
638
+ return s.value in e;
639
+ }
640
+ if (this.accept($t) || this.accept(O, r))
641
+ t.push(new x(z, this.current.value));
642
+ else if (this.accept(Et))
643
+ t.push(new x(X, this.current.value));
644
+ else if (this.accept(Kt))
645
+ t.push(new x(X, this.current.value));
646
+ else if (this.accept(W, "("))
647
+ this.parseExpression(t), this.expect(W, ")");
648
+ else if (this.accept(it, "["))
649
+ if (this.accept(it, "]"))
650
+ t.push(new x(ot, 0));
651
+ else {
652
+ var n = this.parseArrayList(t);
653
+ t.push(new x(ot, n));
654
+ }
655
+ else
656
+ throw new Error("unexpected " + this.nextToken);
657
+ };
658
+ P.prototype.parseExpression = function(t) {
659
+ var e = [];
660
+ this.parseUntilEndStatement(t, e) || (this.parseVariableAssignmentExpression(e), !this.parseUntilEndStatement(t, e) && this.pushExpression(t, e));
661
+ };
662
+ P.prototype.pushExpression = function(t, e) {
663
+ for (var r = 0, n = e.length; r < n; r++)
664
+ t.push(e[r]);
665
+ };
666
+ P.prototype.parseUntilEndStatement = function(t, e) {
667
+ return this.accept(Rt) ? (this.nextToken && this.nextToken.type !== dt && !(this.nextToken.type === W && this.nextToken.value === ")") && e.push(new x(xt)), this.nextToken.type !== dt && this.parseExpression(e), t.push(new x(F, e)), !0) : !1;
668
+ };
669
+ P.prototype.parseArrayList = function(t) {
670
+ for (var e = 0; !this.accept(it, "]"); )
671
+ for (this.parseExpression(t), ++e; this.accept(At); )
672
+ this.parseExpression(t), ++e;
673
+ return e;
674
+ };
675
+ P.prototype.parseVariableAssignmentExpression = function(t) {
676
+ for (this.parseConditionalExpression(t); this.accept(O, "="); ) {
677
+ var e = t.pop(), r = [], n = t.length - 1;
678
+ if (e.type === at) {
679
+ if (!this.tokens.isOperatorEnabled("()="))
680
+ throw new Error("function definition is not permitted");
681
+ for (var s = 0, o = e.value + 1; s < o; s++) {
682
+ var a = n - s;
683
+ t[a].type === z && (t[a] = new x(H, t[a].value));
684
+ }
685
+ this.parseVariableAssignmentExpression(r), t.push(new x(F, r)), t.push(new x(yt, e.value));
686
+ continue;
687
+ }
688
+ if (e.type !== z && e.type !== Z)
689
+ throw new Error("expected variable for assignment");
690
+ this.parseVariableAssignmentExpression(r), t.push(new x(H, e.value)), t.push(new x(F, r)), t.push(G("="));
691
+ }
692
+ };
693
+ P.prototype.parseConditionalExpression = function(t) {
694
+ for (this.parseOrExpression(t); this.accept(O, "?"); ) {
695
+ var e = [], r = [];
696
+ this.parseConditionalExpression(e), this.expect(O, ":"), this.parseConditionalExpression(r), t.push(new x(F, e)), t.push(new x(F, r)), t.push(Wt("?"));
697
+ }
698
+ };
699
+ P.prototype.parseOrExpression = function(t) {
700
+ for (this.parseAndExpression(t); this.accept(O, "or"); ) {
701
+ var e = [];
702
+ this.parseAndExpression(e), t.push(new x(F, e)), t.push(G("or"));
703
+ }
704
+ };
705
+ P.prototype.parseAndExpression = function(t) {
706
+ for (this.parseComparison(t); this.accept(O, "and"); ) {
707
+ var e = [];
708
+ this.parseComparison(e), t.push(new x(F, e)), t.push(G("and"));
709
+ }
710
+ };
711
+ var ne = ["==", "!=", "<", "<=", ">=", ">", "in"];
712
+ P.prototype.parseComparison = function(t) {
713
+ for (this.parseAddSub(t); this.accept(O, ne); ) {
714
+ var e = this.current;
715
+ this.parseAddSub(t), t.push(G(e.value));
716
+ }
717
+ };
718
+ var se = ["+", "-", "||"];
719
+ P.prototype.parseAddSub = function(t) {
720
+ for (this.parseTerm(t); this.accept(O, se); ) {
721
+ var e = this.current;
722
+ this.parseTerm(t), t.push(G(e.value));
723
+ }
724
+ };
725
+ var ae = ["*", "/", "%"];
726
+ P.prototype.parseTerm = function(t) {
727
+ for (this.parseFactor(t); this.accept(O, ae); ) {
728
+ var e = this.current;
729
+ this.parseFactor(t), t.push(G(e.value));
730
+ }
731
+ };
732
+ P.prototype.parseFactor = function(t) {
733
+ var e = this.tokens.unaryOps;
734
+ function r(s) {
735
+ return s.value in e;
736
+ }
737
+ if (this.save(), this.accept(O, r)) {
738
+ if (this.current.value !== "-" && this.current.value !== "+") {
739
+ if (this.nextToken.type === W && this.nextToken.value === "(") {
740
+ this.restore(), this.parseExponential(t);
741
+ return;
742
+ } else if (this.nextToken.type === Rt || this.nextToken.type === At || this.nextToken.type === dt || this.nextToken.type === W && this.nextToken.value === ")") {
743
+ this.restore(), this.parseAtom(t);
744
+ return;
745
+ }
746
+ }
747
+ var n = this.current;
748
+ this.parseFactor(t), t.push(Mt(n.value));
749
+ } else
750
+ this.parseExponential(t);
751
+ };
752
+ P.prototype.parseExponential = function(t) {
753
+ for (this.parsePostfixExpression(t); this.accept(O, "^"); )
754
+ this.parseFactor(t), t.push(G("^"));
755
+ };
756
+ P.prototype.parsePostfixExpression = function(t) {
757
+ for (this.parseFunctionCall(t); this.accept(O, "!"); )
758
+ t.push(Mt("!"));
759
+ };
760
+ P.prototype.parseFunctionCall = function(t) {
761
+ var e = this.tokens.unaryOps;
762
+ function r(o) {
763
+ return o.value in e;
764
+ }
765
+ if (this.accept(O, r)) {
766
+ var n = this.current;
767
+ this.parseAtom(t), t.push(Mt(n.value));
768
+ } else
769
+ for (this.parseMemberExpression(t); this.accept(W, "("); )
770
+ if (this.accept(W, ")"))
771
+ t.push(new x(at, 0));
772
+ else {
773
+ var s = this.parseArgumentList(t);
774
+ t.push(new x(at, s));
775
+ }
776
+ };
777
+ P.prototype.parseArgumentList = function(t) {
778
+ for (var e = 0; !this.accept(W, ")"); )
779
+ for (this.parseExpression(t), ++e; this.accept(At); )
780
+ this.parseExpression(t), ++e;
781
+ return e;
782
+ };
783
+ P.prototype.parseMemberExpression = function(t) {
784
+ for (this.parseAtom(t); this.accept(O, ".") || this.accept(it, "["); ) {
785
+ var e = this.current;
786
+ if (e.value === ".") {
787
+ if (!this.allowMemberAccess)
788
+ throw new Error('unexpected ".", member access is not permitted');
789
+ this.expect($t), t.push(new x(Z, this.current.value));
790
+ } else if (e.value === "[") {
791
+ if (!this.tokens.isOperatorEnabled("["))
792
+ throw new Error('unexpected "[]", arrays are disabled');
793
+ this.parseExpression(t), this.expect(it, "]"), t.push(G("["));
794
+ } else
795
+ throw new Error("unexpected symbol: " + e.value);
796
+ }
797
+ };
798
+ function oe(t, e) {
799
+ return Number(t) + Number(e);
800
+ }
801
+ function ie(t, e) {
802
+ return t - e;
803
+ }
804
+ function ue(t, e) {
805
+ return t * e;
806
+ }
807
+ function he(t, e) {
808
+ return t / e;
809
+ }
810
+ function ce(t, e) {
811
+ return t % e;
812
+ }
813
+ function pe(t, e) {
814
+ return Array.isArray(t) && Array.isArray(e) ? t.concat(e) : "" + t + e;
815
+ }
816
+ function le(t, e) {
817
+ return t === e;
818
+ }
819
+ function fe(t, e) {
820
+ return t !== e;
821
+ }
822
+ function ge(t, e) {
823
+ return t > e;
824
+ }
825
+ function de(t, e) {
826
+ return t < e;
827
+ }
828
+ function we(t, e) {
829
+ return t >= e;
830
+ }
831
+ function ve(t, e) {
832
+ return t <= e;
833
+ }
834
+ function ye(t, e) {
835
+ return !!(t && e);
836
+ }
837
+ function xe(t, e) {
838
+ return !!(t || e);
839
+ }
840
+ function Me(t, e) {
841
+ return nt(e, t);
842
+ }
843
+ function Ee(t) {
844
+ return (Math.exp(t) - Math.exp(-t)) / 2;
845
+ }
846
+ function Ae(t) {
847
+ return (Math.exp(t) + Math.exp(-t)) / 2;
848
+ }
849
+ function me(t) {
850
+ return t === 1 / 0 ? 1 : t === -1 / 0 ? -1 : (Math.exp(t) - Math.exp(-t)) / (Math.exp(t) + Math.exp(-t));
851
+ }
852
+ function be(t) {
853
+ return t === -1 / 0 ? t : Math.log(t + Math.sqrt(t * t + 1));
854
+ }
855
+ function Oe(t) {
856
+ return Math.log(t + Math.sqrt(t * t - 1));
857
+ }
858
+ function ke(t) {
859
+ return Math.log((1 + t) / (1 - t)) / 2;
860
+ }
861
+ function Ut(t) {
862
+ return Math.log(t) * Math.LOG10E;
863
+ }
864
+ function Te(t) {
865
+ return -t;
866
+ }
867
+ function Pe(t) {
868
+ return !t;
869
+ }
870
+ function Ne(t) {
871
+ return t < 0 ? Math.ceil(t) : Math.floor(t);
872
+ }
873
+ function Ce(t) {
874
+ return Math.random() * (t || 1);
875
+ }
876
+ function Dt(t) {
877
+ return Ft(t + 1);
878
+ }
879
+ function Ie(t) {
880
+ return isFinite(t) && t === Math.round(t);
881
+ }
882
+ var Se = 4.7421875, kt = [
883
+ 0.9999999999999971,
884
+ 57.15623566586292,
885
+ -59.59796035547549,
886
+ 14.136097974741746,
887
+ -0.4919138160976202,
888
+ 3399464998481189e-20,
889
+ 4652362892704858e-20,
890
+ -9837447530487956e-20,
891
+ 1580887032249125e-19,
892
+ -21026444172410488e-20,
893
+ 21743961811521265e-20,
894
+ -1643181065367639e-19,
895
+ 8441822398385275e-20,
896
+ -26190838401581408e-21,
897
+ 36899182659531625e-22
898
+ ];
899
+ function Ft(t) {
900
+ var e, r;
901
+ if (Ie(t)) {
902
+ if (t <= 0)
903
+ return isFinite(t) ? 1 / 0 : NaN;
904
+ if (t > 171)
905
+ return 1 / 0;
906
+ for (var n = t - 2, s = t - 1; n > 1; )
907
+ s *= n, n--;
908
+ return s === 0 && (s = 1), s;
909
+ }
910
+ if (t < 0.5)
911
+ return Math.PI / (Math.sin(Math.PI * t) * Ft(1 - t));
912
+ if (t >= 171.35)
913
+ return 1 / 0;
914
+ if (t > 85) {
915
+ var o = t * t, a = o * t, u = a * t, y = u * t;
916
+ return Math.sqrt(2 * Math.PI / t) * Math.pow(t / Math.E, t) * (1 + 1 / (12 * t) + 1 / (288 * o) - 139 / (51840 * a) - 571 / (2488320 * u) + 163879 / (209018880 * y) + 5246819 / (75246796800 * y * t));
917
+ }
918
+ --t, r = kt[0];
919
+ for (var M = 1; M < kt.length; ++M)
920
+ r += kt[M] / (t + M);
921
+ return e = t + Se + 0.5, Math.sqrt(2 * Math.PI) * Math.pow(e, t + 0.5) * Math.exp(-e) * r;
922
+ }
923
+ function $e(t) {
924
+ return Array.isArray(t) ? t.length : String(t).length;
925
+ }
926
+ function qt() {
927
+ for (var t = 0, e = 0, r = 0; r < arguments.length; r++) {
928
+ var n = Math.abs(arguments[r]), s;
929
+ e < n ? (s = e / n, t = t * s * s + 1, e = n) : n > 0 ? (s = n / e, t += s * s) : t += n;
930
+ }
931
+ return e === 1 / 0 ? 1 / 0 : e * Math.sqrt(t);
932
+ }
933
+ function Lt(t, e, r) {
934
+ return t ? e : r;
935
+ }
936
+ function Re(t, e) {
937
+ return typeof e > "u" || +e == 0 ? Math.round(t) : (t = +t, e = -+e, isNaN(t) || !(typeof e == "number" && e % 1 === 0) ? NaN : (t = t.toString().split("e"), t = Math.round(+(t[0] + "e" + (t[1] ? +t[1] - e : -e))), t = t.toString().split("e"), +(t[0] + "e" + (t[1] ? +t[1] + e : e))));
938
+ }
939
+ function Fe(t, e, r) {
940
+ return r && (r[t] = e), e;
941
+ }
942
+ function _e(t, e) {
943
+ return t[e | 0];
944
+ }
945
+ function je(t) {
946
+ return arguments.length === 1 && Array.isArray(t) ? Math.max.apply(Math, t) : Math.max.apply(Math, arguments);
947
+ }
948
+ function Xe(t) {
949
+ return arguments.length === 1 && Array.isArray(t) ? Math.min.apply(Math, t) : Math.min.apply(Math, arguments);
950
+ }
951
+ function Ue(t, e) {
952
+ if (typeof t != "function")
953
+ throw new Error("First argument to map is not a function");
954
+ if (!Array.isArray(e))
955
+ throw new Error("Second argument to map is not an array");
956
+ return e.map(function(r, n) {
957
+ return t(r, n);
958
+ });
959
+ }
960
+ function De(t, e, r) {
961
+ if (typeof t != "function")
962
+ throw new Error("First argument to fold is not a function");
963
+ if (!Array.isArray(r))
964
+ throw new Error("Second argument to fold is not an array");
965
+ return r.reduce(function(n, s, o) {
966
+ return t(n, s, o);
967
+ }, e);
968
+ }
969
+ function qe(t, e) {
970
+ if (typeof t != "function")
971
+ throw new Error("First argument to filter is not a function");
972
+ if (!Array.isArray(e))
973
+ throw new Error("Second argument to filter is not an array");
974
+ return e.filter(function(r, n) {
975
+ return t(r, n);
976
+ });
977
+ }
978
+ function Le(t, e) {
979
+ if (!(Array.isArray(e) || typeof e == "string"))
980
+ throw new Error("Second argument to indexOf is not a string or array");
981
+ return e.indexOf(t);
982
+ }
983
+ function Be(t, e) {
984
+ if (!Array.isArray(e))
985
+ throw new Error("Second argument to join is not an array");
986
+ return e.join(t);
987
+ }
988
+ function Ve(t) {
989
+ return (t > 0) - (t < 0) || +t;
990
+ }
991
+ var Bt = 1 / 3;
992
+ function ze(t) {
993
+ return t < 0 ? -Math.pow(-t, Bt) : Math.pow(t, Bt);
994
+ }
995
+ function We(t) {
996
+ return Math.exp(t) - 1;
997
+ }
998
+ function Ge(t) {
999
+ return Math.log(1 + t);
1000
+ }
1001
+ function Ke(t) {
1002
+ return Math.log(t) / Math.LN2;
1003
+ }
1004
+ function Ye(t) {
1005
+ if (!Array.isArray(t))
1006
+ throw new Error("Sum argument is not an array");
1007
+ return t.reduce(function(e, r) {
1008
+ return e + Number(r);
1009
+ }, 0);
1010
+ }
1011
+ function J(t) {
1012
+ this.options = t || {}, this.unaryOps = {
1013
+ sin: Math.sin,
1014
+ cos: Math.cos,
1015
+ tan: Math.tan,
1016
+ asin: Math.asin,
1017
+ acos: Math.acos,
1018
+ atan: Math.atan,
1019
+ sinh: Math.sinh || Ee,
1020
+ cosh: Math.cosh || Ae,
1021
+ tanh: Math.tanh || me,
1022
+ asinh: Math.asinh || be,
1023
+ acosh: Math.acosh || Oe,
1024
+ atanh: Math.atanh || ke,
1025
+ sqrt: Math.sqrt,
1026
+ cbrt: Math.cbrt || ze,
1027
+ log: Math.log,
1028
+ log2: Math.log2 || Ke,
1029
+ ln: Math.log,
1030
+ lg: Math.log10 || Ut,
1031
+ log10: Math.log10 || Ut,
1032
+ expm1: Math.expm1 || We,
1033
+ log1p: Math.log1p || Ge,
1034
+ abs: Math.abs,
1035
+ ceil: Math.ceil,
1036
+ floor: Math.floor,
1037
+ round: Math.round,
1038
+ trunc: Math.trunc || Ne,
1039
+ "-": Te,
1040
+ "+": Number,
1041
+ exp: Math.exp,
1042
+ not: Pe,
1043
+ length: $e,
1044
+ "!": Dt,
1045
+ sign: Math.sign || Ve
1046
+ }, this.binaryOps = {
1047
+ "+": oe,
1048
+ "-": ie,
1049
+ "*": ue,
1050
+ "/": he,
1051
+ "%": ce,
1052
+ "^": Math.pow,
1053
+ "||": pe,
1054
+ "==": le,
1055
+ "!=": fe,
1056
+ ">": ge,
1057
+ "<": de,
1058
+ ">=": we,
1059
+ "<=": ve,
1060
+ and: ye,
1061
+ or: xe,
1062
+ in: Me,
1063
+ "=": Fe,
1064
+ "[": _e
1065
+ }, this.ternaryOps = {
1066
+ "?": Lt
1067
+ }, this.functions = {
1068
+ random: Ce,
1069
+ fac: Dt,
1070
+ min: Xe,
1071
+ max: je,
1072
+ hypot: Math.hypot || qt,
1073
+ pyt: Math.hypot || qt,
1074
+ // backward compat
1075
+ pow: Math.pow,
1076
+ atan2: Math.atan2,
1077
+ if: Lt,
1078
+ gamma: Ft,
1079
+ roundTo: Re,
1080
+ map: Ue,
1081
+ fold: De,
1082
+ filter: qe,
1083
+ indexOf: Le,
1084
+ join: Be,
1085
+ sum: Ye
1086
+ }, this.consts = {
1087
+ E: Math.E,
1088
+ PI: Math.PI,
1089
+ true: !0,
1090
+ false: !1
1091
+ };
1092
+ }
1093
+ J.prototype.parse = function(t) {
1094
+ var e = [], r = new P(
1095
+ this,
1096
+ new C(this, t),
1097
+ { allowMemberAccess: this.options.allowMemberAccess }
1098
+ );
1099
+ return r.parseExpression(e), r.expect(dt, "EOF"), new U(e, this);
1100
+ };
1101
+ J.prototype.evaluate = function(t, e) {
1102
+ return this.parse(t).evaluate(e);
1103
+ };
1104
+ var Ht = new J();
1105
+ J.parse = function(t) {
1106
+ return Ht.parse(t);
1107
+ };
1108
+ J.evaluate = function(t, e) {
1109
+ return Ht.parse(t).evaluate(e);
1110
+ };
1111
+ var Vt = {
1112
+ "+": "add",
1113
+ "-": "subtract",
1114
+ "*": "multiply",
1115
+ "/": "divide",
1116
+ "%": "remainder",
1117
+ "^": "power",
1118
+ "!": "factorial",
1119
+ "<": "comparison",
1120
+ ">": "comparison",
1121
+ "<=": "comparison",
1122
+ ">=": "comparison",
1123
+ "==": "comparison",
1124
+ "!=": "comparison",
1125
+ "||": "concatenate",
1126
+ and: "logical",
1127
+ or: "logical",
1128
+ not: "logical",
1129
+ "?": "conditional",
1130
+ ":": "conditional",
1131
+ "=": "assignment",
1132
+ "[": "array",
1133
+ "()=": "fndef"
1134
+ };
1135
+ function He(t) {
1136
+ return Object.hasOwn(Vt, t) ? Vt[t] : t;
1137
+ }
1138
+ J.prototype.isOperatorEnabled = function(t) {
1139
+ var e = He(t), r = this.options.operators || {};
1140
+ return !(e in r) || !!r[e];
1141
+ };
1142
+ class Ze extends J {
1143
+ constructor(...e) {
1144
+ super(...e);
1145
+ const r = this;
1146
+ r.unaryOps = {
1147
+ "-": r.unaryOps["-"],
1148
+ "+": r.unaryOps["+"],
1149
+ "!": r.unaryOps.not,
1150
+ not: r.unaryOps.not
1151
+ }, r.functions = {
1152
+ sin: Math.sin,
1153
+ cos: Math.cos,
1154
+ tan: Math.tan,
1155
+ asin: Math.asin,
1156
+ acos: Math.acos,
1157
+ atan: Math.atan,
1158
+ log: Math.log,
1159
+ atan2: Math.atan2,
1160
+ pow: Math.pow,
1161
+ radians: (n) => n * (Math.PI / 180),
1162
+ degrees: (n) => n * (180 / Math.PI),
1163
+ __read_property__: (n, ...s) => {
1164
+ let o = n;
1165
+ for (let a = 0, u = s.length; a < u; a++)
1166
+ o = o[s[a]];
1167
+ return o;
1168
+ }
1169
+ }, r.binaryOps = {
1170
+ ...r.binaryOps,
1171
+ "+": (n, s) => (gt(n) && (n = Number(n)), gt(s) && (s = Number(s)), n + s),
1172
+ in: (n, s) => Array.isArray(s) || typeof s == "string" ? s.includes(n) : n in s,
1173
+ "||": (n, s) => !!(n || s)
1174
+ // binary AND is not supported by expr-eval. See expr-eval issue #253.
1175
+ // '&&': (a, b) => Boolean(a || b),
1176
+ }, r.consts = {
1177
+ ...r.consts,
1178
+ pi: Math.PI,
1179
+ tau: 2 * Math.PI,
1180
+ e: Math.E
1181
+ };
1182
+ }
1183
+ }
1184
+ class Je {
1185
+ constructor() {
1186
+ this.inOrder = !0, this.requirePrefix = !0, this.localProperties = !0, this.rospackCommands = {}, this.arguments = {}, this.expressionParser = new Ze(), this.workingPath = "";
1187
+ }
1188
+ async getFileContents(e) {
1189
+ throw new Error("XacroParser: getFileContents() not implemented.");
1190
+ }
1191
+ async parse(e) {
1192
+ function r(i, h, w = !1) {
1193
+ function l(f, m) {
1194
+ if (typeof f != "string")
1195
+ return f;
1196
+ const $ = f.split(/(\$?\$\([^)]+\))|(\$?\${[^}]+})/g).filter((v) => !!v).map((v) => {
1197
+ if (!/^\$[{(].+/.test(v) || /^\$\$/.test(v))
1198
+ return v;
1199
+ const B = /^\$\(/.test(v);
1200
+ let _ = v.substring(2, v.length - 1);
1201
+ if (_ = l(_, m), /\[.+\]$/.test(_) && (_ = _.replace(/([^[\s]+)(\[[^[]+\])+/g, (tt, ...L) => {
1202
+ const I = tt.split(/[[\]]+/g);
1203
+ return I.pop(), `__read_property__( ${I.join(",")} )`;
1204
+ })), B) {
1205
+ const L = l(_, m).split(/\s+/g), I = L.shift();
1206
+ try {
1207
+ return wt(I, ...L);
1208
+ } catch (et) {
1209
+ throw new Error(`XacroParser: Cannot run rospack command "${_}".
1210
+ ` + et.message);
1211
+ }
1212
+ } else {
1213
+ if (A.includes(_))
1214
+ throw new Error(
1215
+ `XacroParser: Cannot evaluate infinitely recursive expression: ${A.join(" > ")} > ${_}`
1216
+ );
1217
+ A.push(_);
1218
+ const tt = /([()/*+!\-%|&=])+/g, L = Jt(_).map((I) => {
1219
+ if (tt.lastIndex = 0, Zt(I) || gt(I) || jt(I)) return I;
1220
+ if (I in m) {
1221
+ const et = l(m[I], m);
1222
+ return !gt(et) && typeof et != "object" ? `"${et.toString().replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"` : et;
1223
+ } else
1224
+ return I;
1225
+ }).map((I) => (tt.lastIndex = 0, /^[^0-9.]/.test(I) && !tt.test(I) ? ` ${I} ` : I)).join("");
1226
+ if (A.pop(), jt(L))
1227
+ return L.substring(1, L.length - 1);
1228
+ if (gt(L))
1229
+ return L;
1230
+ {
1231
+ const I = Qt(L);
1232
+ return Q.evaluate(I, m);
1233
+ }
1234
+ }
1235
+ }), q = $.filter((v) => (typeof v == "string" && (v = v.trim()), v !== "" && v !== null && v !== void 0));
1236
+ return q.length === 1 ? q[0] : $.join("");
1237
+ }
1238
+ const A = [], p = Tt(k, h);
1239
+ try {
1240
+ let f = l(i, p);
1241
+ return w && typeof f == "string" && (f = f.replace(/\${2}([({])/g, (m, T) => `$${T}`)), f;
1242
+ } catch (f) {
1243
+ throw new Error(`XacroParser: Failed to process expression "${i}".
1244
+ ` + f.message);
1245
+ }
1246
+ }
1247
+ async function n(i, h, w, l) {
1248
+ const A = i.tagName.replace(/^xacro:/, ""), p = w[A];
1249
+ if (!p)
1250
+ throw new Error(`XacroParser: Cannot find macro "${A}"`);
1251
+ const f = h, m = w;
1252
+ h = te(h), w = Tt(w);
1253
+ let T = [];
1254
+ for (const v of i.children)
1255
+ await a(v, f, m, T);
1256
+ T = T.filter((v) => v.nodeType === v.ELEMENT_NODE);
1257
+ let $ = 0;
1258
+ for (const v in p.params) {
1259
+ const B = p.params[v];
1260
+ i.hasAttribute(v) ? h[v] = r(i.getAttribute(v), f) : B.type === "BLOCK" ? (h[v] = [T[$]], $++) : B.type === "MULTI_BLOCK" ? h[v] = [...T.filter((_) => _.tagName === v)[0].childNodes] : h[v] = r(p.params[v].def, f);
1261
+ }
1262
+ const q = [...p.node.childNodes];
1263
+ for (const v of q) {
1264
+ const B = [];
1265
+ await a(v, h, w, B), l.push(...B);
1266
+ }
1267
+ }
1268
+ function s(i) {
1269
+ const h = {};
1270
+ if (/^\*\*/.test(i) ? h.type = "MULTI_BLOCK" : /^\*/.test(i) ? h.type = "BLOCK" : h.type = "PARAM", i = i.replace(/^\*{1,2}/g, ""), /:?=/.test(i)) {
1271
+ const [w, l] = i.split(/:?=/);
1272
+ if (/^\^/.test(l) || /\|/.test(l))
1273
+ throw new Error(`XacroParser: ROS Jade pass-through notation not supported in macro defaults: ${l}`);
1274
+ h.name = w, l.startsWith("'") && l.endsWith("'") ? h.def = l.substring(1, l.length - 1) : h.def = l;
1275
+ } else
1276
+ h.name = i, h.def = null;
1277
+ return h;
1278
+ }
1279
+ function o(i) {
1280
+ const h = i.getAttribute("name").replace(/^xacro:/, ""), w = i.getAttribute("params"), l = {};
1281
+ return w && w.trim().match(/[^\s']+('[^']*')?/g).map((p) => s(p)).forEach((p) => {
1282
+ l[p.name] = p;
1283
+ }), {
1284
+ name: h,
1285
+ node: ft(i, !1),
1286
+ params: l
1287
+ };
1288
+ }
1289
+ async function a(i, h, w, l = []) {
1290
+ if (i.nodeType === i.TEXT_NODE) {
1291
+ const p = i.cloneNode();
1292
+ p.textContent = r(p.textContent, h, !0), l.push(p);
1293
+ return;
1294
+ } else if (i.nodeType !== i.ELEMENT_NODE) {
1295
+ l.push(i.cloneNode());
1296
+ return;
1297
+ }
1298
+ let A = i.tagName.toLowerCase();
1299
+ if (!R)
1300
+ switch (A) {
1301
+ case "arg":
1302
+ case "property":
1303
+ case "macro":
1304
+ case "insert_block":
1305
+ case "if":
1306
+ case "unless":
1307
+ case "include":
1308
+ case "element":
1309
+ case "attribute":
1310
+ A = `xacro:${A}`;
1311
+ break;
1312
+ default:
1313
+ A in w && (A = `xacro:${A}`);
1314
+ break;
1315
+ }
1316
+ switch (A) {
1317
+ case "xacro:property": {
1318
+ rt(l);
1319
+ const p = i.getAttribute("name");
1320
+ let f;
1321
+ if (i.hasAttribute("value"))
1322
+ f = i.getAttribute("value");
1323
+ else if (i.hasAttribute("default"))
1324
+ f = i.getAttribute("default");
1325
+ else {
1326
+ const T = [...i.childNodes];
1327
+ f = [];
1328
+ for (const $ of T)
1329
+ f.push(ft($, !1));
1330
+ }
1331
+ let m = "global";
1332
+ pt && (m = i.getAttribute("scope") || "local"), m !== "local" && (f = r(f, h)), m === "global" ? k[p] = f : m === "parent" ? h[st][p] = f : h[p] = f;
1333
+ break;
1334
+ }
1335
+ case "xacro:macro": {
1336
+ rt(l);
1337
+ const p = o(i);
1338
+ w[p.name] = p;
1339
+ break;
1340
+ }
1341
+ case "xacro:insert_block": {
1342
+ rt(l);
1343
+ const p = i.getAttribute("name"), f = h[p];
1344
+ for (const m of f)
1345
+ await a(m, h, w, l);
1346
+ return;
1347
+ }
1348
+ case "xacro:if":
1349
+ case "xacro:unless": {
1350
+ rt(l);
1351
+ const p = r(i.getAttribute("value"), h, !0);
1352
+ let f = null;
1353
+ if (isNaN(parseFloat(p)) ? p === "true" || p === "false" ? f = p === "true" : f = p : f = !!parseFloat(p), A === "xacro:unless" && (f = !f), f) {
1354
+ const m = [...i.childNodes];
1355
+ for (const T of m)
1356
+ await a(T, h, w, l);
1357
+ }
1358
+ return;
1359
+ }
1360
+ case "xacro:include": {
1361
+ if (rt(l), i.hasAttribute("ns"))
1362
+ throw new Error("XacroParser: xacro:include name spaces not supported.");
1363
+ const p = r(i.getAttribute("filename"), h, !0), m = /^[/\\]/.test(p) || /^[a-zA-Z]+:[/\\]/.test(p) ? p : vt + p, T = vt;
1364
+ vt = _t(m);
1365
+ const q = [...(await M(m)).children[0].childNodes];
1366
+ for (const v of q)
1367
+ await a(v, h, w, l);
1368
+ vt = T;
1369
+ return;
1370
+ }
1371
+ case "xacro:arg": {
1372
+ const p = i.getAttribute("name");
1373
+ S[p] = r(i.getAttribute("default"), h, !0);
1374
+ return;
1375
+ }
1376
+ case "xacro:attribute":
1377
+ case "xacro:element":
1378
+ throw new Error(`XacroParser: ${A} tags not supported.`);
1379
+ default: {
1380
+ if (/^xacro:/.test(A) || A in w)
1381
+ return rt(l), n(i, h, w, l);
1382
+ {
1383
+ const p = i.cloneNode();
1384
+ for (let T = 0, $ = p.attributes.length; T < $; T++) {
1385
+ const q = p.attributes[T], v = r(q.value, h, !0);
1386
+ p.setAttribute(q.name, v);
1387
+ }
1388
+ const f = [...i.childNodes], m = [];
1389
+ for (let T = 0, $ = f.length; T < $; T++)
1390
+ await a(f[T], h, w, m);
1391
+ m.forEach((T) => p.appendChild(T)), l.push(p);
1392
+ }
1393
+ }
1394
+ }
1395
+ }
1396
+ async function u(i, h, w) {
1397
+ const l = K(i, "xacro:property");
1398
+ R || l.push(...K(i, "property"));
1399
+ for (const p of l)
1400
+ await a(p, h, w);
1401
+ const A = K(i, "xacro:macro");
1402
+ R || A.push(...K(i, "macro"));
1403
+ for (const p of A)
1404
+ await a(p, h, w);
1405
+ }
1406
+ async function y(i, h, w) {
1407
+ const l = i.cloneNode();
1408
+ for (let A = 0, p = i.children.length; A < p; A++) {
1409
+ const f = [];
1410
+ await a(i.children[A], h, w, f);
1411
+ const m = f[0];
1412
+ m.removeAttribute("xmlns:xacro"), l.appendChild(m);
1413
+ }
1414
+ return l;
1415
+ }
1416
+ async function M(i) {
1417
+ try {
1418
+ const h = await N.getFileContents(i);
1419
+ return new DOMParser().parseFromString(h, "text/xml");
1420
+ } catch {
1421
+ throw new Error(`XacroParser: Could not load included file: ${i}`);
1422
+ }
1423
+ }
1424
+ async function E(i, h, w = []) {
1425
+ const l = K(i, "xacro:include");
1426
+ R || l.push(...K(i, "include"));
1427
+ const A = l.map((p) => {
1428
+ if (p.hasAttribute("ns"))
1429
+ throw new Error("XacroParser: xacro:include name spaces not supported.");
1430
+ const f = p.getAttribute("filename"), m = p.getAttribute("ns") || null, $ = /^[/\\]/.test(f) || /^[a-zA-Z]+:[/\\]/.test(f) ? f : h + f;
1431
+ return M($).then((v) => {
1432
+ w.push({ filename: f, namespace: m, content: v });
1433
+ const B = _t($);
1434
+ return E(v, B, w);
1435
+ });
1436
+ });
1437
+ return await Promise.all(A), w;
1438
+ }
1439
+ const N = this, c = this.inOrder, b = this.workingPath + (this.workingPath && !/[\\/]$/.test(this.workingPath) ? "/" : ""), R = this.requirePrefix, D = this.rospackCommands, d = {}, g = {}, S = {}, k = { True: 1, False: 0 };
1440
+ k[st] = k;
1441
+ const wt = (i, ...h) => {
1442
+ let w;
1443
+ if (D instanceof Function && (w = D(i, ...h)), w == null && D != null && typeof D[i] == "function" && (w = D[i](...h)), w == null && i === "arg") {
1444
+ const l = h[0];
1445
+ if (l === void 0)
1446
+ throw new Error("XacroParser: $(arg) must specify a variable name");
1447
+ if (w = this.arguments[l], w == null && (w = S[l]), w == null)
1448
+ throw new Error(`XacroParser: Undefined substitution argument ${l}`);
1449
+ }
1450
+ return w;
1451
+ }, Q = this.expressionParser;
1452
+ let pt = this.localProperties, vt = b, lt = new DOMParser().parseFromString(e, "text/xml");
1453
+ pt && !c && (console.warn('XacroParser: Implicitly setting "localProperties" option to false because "inOrder" is false.'), pt = !1);
1454
+ let mt = null;
1455
+ return c ? mt = Promise.resolve() : mt = async function() {
1456
+ return await u(lt, k, d), lt = ft(lt, !0), E(lt, b).then((i) => {
1457
+ i.forEach((h) => {
1458
+ u(h.content, k, d), h.content = ft(h.content, !0), g[h.filename] = h.content;
1459
+ });
1460
+ });
1461
+ }(), await mt, y(lt, k, d);
1462
+ }
1463
+ }
1464
+ const zt = "http://wiki.ros.org/xacro", j = (t) => Object.assign(new Error(t), { code: "E_XACRO_EXPAND" });
1465
+ async function er(t, e, r, n, s) {
1466
+ var R, D;
1467
+ s.throwIfAborted();
1468
+ const o = new Map(Object.entries((n == null ? void 0 : n.packages) ?? {})), a = /* @__PURE__ */ new Map();
1469
+ for (const d of r.paths().filter((g) => /(^|\/)package\.xml$/.test(g))) {
1470
+ const S = (D = (R = new DOMParser().parseFromString(await r.text(d), "text/xml").querySelector("package > name")) == null ? void 0 : R.textContent) == null ? void 0 : D.trim();
1471
+ S && a.set(S, [...a.get(S) ?? [], d.slice(0, -11)]);
1472
+ }
1473
+ for (const [d, g] of a)
1474
+ if (!o.has(d)) {
1475
+ if (g.length !== 1) throw j(`Ambiguous ROS package: ${d}. Set xacro.packages explicitly.`);
1476
+ o.set(d, g[0]);
1477
+ }
1478
+ const u = (d) => {
1479
+ if (!o.has(d)) throw j(`Unknown ROS package: ${d}. Upload package.xml or set xacro.packages.`);
1480
+ return "/" + bt(o.get(d));
1481
+ }, y = (d, g) => {
1482
+ if (d.length > 4 * 1024 * 1024) throw j(`Xacro input exceeds 4 MiB: ${g}`);
1483
+ const S = new DOMParser().parseFromString(d, "text/xml");
1484
+ if (S.querySelector("parsererror") || S.doctype) throw j(`Invalid XML or unsupported DOCTYPE: ${g}`);
1485
+ for (const k of Array.from(S.getElementsByTagName("*"))) {
1486
+ if (k.namespaceURI === zt && k.prefix !== "xacro") throw j(`Use the xacro: namespace prefix: ${g}`);
1487
+ if (k.tagName === "xacro:call" || k.tagName === "xacro:include" && k.hasAttribute("ns") || k.tagName === "xacro:macro" && /:=\^/.test(k.getAttribute("params") ?? ""))
1488
+ throw j(`Unsupported Xacro feature ${k.tagName}: ${g}`);
1489
+ }
1490
+ };
1491
+ y(t, e);
1492
+ const M = new Je(), E = /* @__PURE__ */ Object.create(null), N = new DOMParser().parseFromString(t, "text/xml");
1493
+ for (const d of Array.from(N.documentElement.children))
1494
+ if (d.tagName === "xacro:arg" && d.hasAttribute("name") && d.hasAttribute("default")) {
1495
+ const g = d.getAttribute("name");
1496
+ g in E || (E[g] = d.getAttribute("default"));
1497
+ }
1498
+ M.arguments = Object.assign(/* @__PURE__ */ Object.create(null), E, n == null ? void 0 : n.arguments), M.workingPath = "/" + e.replaceAll("\\", "/").split("/").slice(0, -1).join("/");
1499
+ let c = 0, b;
1500
+ M.getFileContents = async (d) => {
1501
+ try {
1502
+ if (s.throwIfAborted(), ++c > 128) throw j("Xacro include limit exceeded (128); check for include cycles.");
1503
+ const g = bt(d);
1504
+ if (g === ".." || g.startsWith("../") || /^[a-z]+:/i.test(g)) throw j(`Unsupported include path: ${d}`);
1505
+ const S = await r.text(g);
1506
+ return s.throwIfAborted(), y(S, g), S;
1507
+ } catch (g) {
1508
+ throw b = g, g;
1509
+ }
1510
+ }, M.rospackCommands = (d, ...g) => {
1511
+ if (d !== "arg") {
1512
+ if (d === "find" && g.length === 1) return u(g[0]);
1513
+ throw j(`Unsupported Xacro substitution: $(${d} ${g.join(" ")})`);
1514
+ }
1515
+ };
1516
+ try {
1517
+ const d = await M.parse(t);
1518
+ if (s.throwIfAborted(), d.documentElement.tagName !== "robot") throw j("Expanded Xacro must have a robot root.");
1519
+ for (const g of Array.from(d.getElementsByTagName("*"))) {
1520
+ if (g.prefix === "xacro" || g.namespaceURI === zt) throw j(`Unexpanded Xacro element: ${g.tagName}`);
1521
+ for (const S of Array.from(g.attributes))
1522
+ if (/\$\{|\$\(/.test(S.value)) throw j(`Unexpanded Xacro expression: ${S.value}`);
1523
+ if (g.tagName === "mesh" || g.tagName === "texture") {
1524
+ const S = g.getAttribute("filename") ?? "", k = /^package:\/\/([^/]+)\/(.+)$/.exec(S);
1525
+ k && o.has(k[1]) && g.setAttribute("filename", bt(`${u(k[1])}/${k[2]}`));
1526
+ }
1527
+ }
1528
+ return d.documentElement.outerHTML;
1529
+ } catch (d) {
1530
+ s.throwIfAborted();
1531
+ const g = b ?? d;
1532
+ throw Object.assign(j(`Xacro expansion failed (${e}): ${g instanceof Error ? g.message : String(g)}`), { cause: g });
1533
+ }
1534
+ }
1535
+ export {
1536
+ er as expandXacro
1537
+ };