@cortex-js/compute-engine 0.35.3 → 0.35.4
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/dist/compute-engine.esm.js +29 -14
- package/dist/compute-engine.min.esm.js +24 -9
- package/dist/compute-engine.min.umd.js +24 -9
- package/dist/compute-engine.umd.js +29 -14
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.umd.js +2 -2
- package/dist/math-json.umd.js +2 -2
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/configuration-change.d.ts +1 -1
- package/dist/types/common/fuzzy-string-match.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/interruptible.d.ts +1 -1
- package/dist/types/common/one-of.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/type/ast-nodes.d.ts +1 -1
- package/dist/types/common/type/boxed-type.d.ts +1 -1
- package/dist/types/common/type/lexer.d.ts +1 -1
- package/dist/types/common/type/parse.d.ts +1 -1
- package/dist/types/common/type/parser.d.ts +1 -1
- package/dist/types/common/type/primitive.d.ts +1 -1
- package/dist/types/common/type/reduce.d.ts +1 -1
- package/dist/types/common/type/serialize.d.ts +1 -1
- package/dist/types/common/type/subtype.d.ts +1 -1
- package/dist/types/common/type/type-builder.d.ts +1 -1
- package/dist/types/common/type/types.d.ts +1 -1
- package/dist/types/common/type/utils.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/types.d.ts +1 -1
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/function-utils.d.ts +1 -1
- package/dist/types/compute-engine/global-types.d.ts +1 -1
- package/dist/types/compute-engine/index.d.ts +1 -1
- package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
- package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
- package/dist/types/compute-engine/interval/index.d.ts +1 -1
- package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
- package/dist/types/compute-engine/interval/types.d.ts +2 -1
- package/dist/types/compute-engine/interval/util.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/invisible-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
- package/dist/types/compute-engine/library/logic-utils.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/statistics.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
- package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
- package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
- package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
- package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
- package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
- package/dist/types/compute-engine/numerics/types.d.ts +1 -1
- package/dist/types/compute-engine/oeis.d.ts +1 -1
- package/dist/types/compute-engine/sequence.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
- package/dist/types/compute-engine/types.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +1 -1
- package/dist/types/math-json/symbols.d.ts +1 -1
- package/dist/types/math-json/types.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.35.
|
|
1
|
+
/** Compute Engine 0.35.4 */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -52555,7 +52555,7 @@ function floor2(x) {
|
|
|
52555
52555
|
const flo = Math.floor(xVal.lo);
|
|
52556
52556
|
const fhi = Math.floor(xVal.hi);
|
|
52557
52557
|
if (flo === fhi) return ok({ lo: flo, hi: fhi });
|
|
52558
|
-
return { kind: "singular", at: flo + 1 };
|
|
52558
|
+
return { kind: "singular", at: flo + 1, continuity: "right" };
|
|
52559
52559
|
}
|
|
52560
52560
|
function ceil2(x) {
|
|
52561
52561
|
const unwrapped = unwrapOrPropagate(x);
|
|
@@ -52564,7 +52564,7 @@ function ceil2(x) {
|
|
|
52564
52564
|
const clo = Math.ceil(xVal.lo);
|
|
52565
52565
|
const chi = Math.ceil(xVal.hi);
|
|
52566
52566
|
if (clo === chi) return ok({ lo: clo, hi: chi });
|
|
52567
|
-
return { kind: "singular", at: clo };
|
|
52567
|
+
return { kind: "singular", at: clo, continuity: "left" };
|
|
52568
52568
|
}
|
|
52569
52569
|
function round2(x) {
|
|
52570
52570
|
const unwrapped = unwrapOrPropagate(x);
|
|
@@ -52573,7 +52573,7 @@ function round2(x) {
|
|
|
52573
52573
|
const rlo = Math.round(xVal.lo);
|
|
52574
52574
|
const rhi = Math.round(xVal.hi);
|
|
52575
52575
|
if (rlo === rhi) return ok({ lo: rlo, hi: rhi });
|
|
52576
|
-
return { kind: "singular", at: rlo + 0.5 };
|
|
52576
|
+
return { kind: "singular", at: rlo + 0.5, continuity: "right" };
|
|
52577
52577
|
}
|
|
52578
52578
|
function fract(x) {
|
|
52579
52579
|
const unwrapped = unwrapOrPropagate(x);
|
|
@@ -52584,7 +52584,7 @@ function fract(x) {
|
|
|
52584
52584
|
if (flo === fhi) {
|
|
52585
52585
|
return ok({ lo: xVal.lo - flo, hi: xVal.hi - flo });
|
|
52586
52586
|
}
|
|
52587
|
-
return { kind: "singular", at: flo + 1 };
|
|
52587
|
+
return { kind: "singular", at: flo + 1, continuity: "right" };
|
|
52588
52588
|
}
|
|
52589
52589
|
function min2(a, b) {
|
|
52590
52590
|
const unwrapped = unwrapOrPropagate(a, b);
|
|
@@ -52615,7 +52615,7 @@ function mod2(a, b) {
|
|
|
52615
52615
|
const flo = Math.floor(aVal.lo / period);
|
|
52616
52616
|
const fhi = Math.floor(aVal.hi / period);
|
|
52617
52617
|
if (flo !== fhi) {
|
|
52618
|
-
return { kind: "singular", at: (flo + 1) * period };
|
|
52618
|
+
return { kind: "singular", at: (flo + 1) * period, continuity: "right" };
|
|
52619
52619
|
}
|
|
52620
52620
|
const modLo = aVal.lo - period * flo;
|
|
52621
52621
|
const modHi = aVal.hi - period * flo;
|
|
@@ -53468,6 +53468,8 @@ const float IA_SINGULAR = 3.0;
|
|
|
53468
53468
|
const float IA_PARTIAL_LO = 4.0;
|
|
53469
53469
|
const float IA_PARTIAL_HI = 5.0;
|
|
53470
53470
|
const float IA_PARTIAL_BOTH = 6.0;
|
|
53471
|
+
const float IA_SINGULAR_RIGHT = 7.0;
|
|
53472
|
+
const float IA_SINGULAR_LEFT = 8.0;
|
|
53471
53473
|
|
|
53472
53474
|
// Interval result struct
|
|
53473
53475
|
struct IntervalResult {
|
|
@@ -53501,12 +53503,20 @@ IntervalResult ia_singular(float at) {
|
|
|
53501
53503
|
return IntervalResult(vec2(at, at), IA_SINGULAR);
|
|
53502
53504
|
}
|
|
53503
53505
|
|
|
53506
|
+
IntervalResult ia_singular_right(float at) {
|
|
53507
|
+
return IntervalResult(vec2(at, at), IA_SINGULAR_RIGHT);
|
|
53508
|
+
}
|
|
53509
|
+
|
|
53510
|
+
IntervalResult ia_singular_left(float at) {
|
|
53511
|
+
return IntervalResult(vec2(at, at), IA_SINGULAR_LEFT);
|
|
53512
|
+
}
|
|
53513
|
+
|
|
53504
53514
|
IntervalResult ia_partial(vec2 v, float clip) {
|
|
53505
53515
|
return IntervalResult(v, clip);
|
|
53506
53516
|
}
|
|
53507
53517
|
|
|
53508
53518
|
bool ia_is_error(float status) {
|
|
53509
|
-
return status == IA_EMPTY || status == IA_ENTIRE || status == IA_SINGULAR;
|
|
53519
|
+
return status == IA_EMPTY || status == IA_ENTIRE || status == IA_SINGULAR || status == IA_SINGULAR_RIGHT || status == IA_SINGULAR_LEFT;
|
|
53510
53520
|
}
|
|
53511
53521
|
|
|
53512
53522
|
// Addition
|
|
@@ -53646,7 +53656,8 @@ IntervalResult ia_floor(vec2 x) {
|
|
|
53646
53656
|
return ia_ok(vec2(flo, fhi));
|
|
53647
53657
|
}
|
|
53648
53658
|
// Interval spans an integer boundary - discontinuity at first integer > x.x
|
|
53649
|
-
|
|
53659
|
+
// floor is right-continuous
|
|
53660
|
+
return ia_singular_right(flo + 1.0);
|
|
53650
53661
|
}
|
|
53651
53662
|
|
|
53652
53663
|
// Ceiling - has jump discontinuities at every integer
|
|
@@ -53657,7 +53668,8 @@ IntervalResult ia_ceil(vec2 x) {
|
|
|
53657
53668
|
return ia_ok(vec2(clo, chi));
|
|
53658
53669
|
}
|
|
53659
53670
|
// Interval spans an integer boundary - discontinuity at ceil(x.x)
|
|
53660
|
-
|
|
53671
|
+
// ceil is left-continuous
|
|
53672
|
+
return ia_singular_left(clo);
|
|
53661
53673
|
}
|
|
53662
53674
|
|
|
53663
53675
|
// Round - has jump discontinuities at every half-integer
|
|
@@ -53671,7 +53683,8 @@ IntervalResult ia_round(vec2 x) {
|
|
|
53671
53683
|
return ia_ok(vec2(rlo, rhi));
|
|
53672
53684
|
}
|
|
53673
53685
|
// Interval spans a half-integer boundary - discontinuity
|
|
53674
|
-
|
|
53686
|
+
// round is right-continuous (with round-half-up convention)
|
|
53687
|
+
return ia_singular_right(rlo + 0.5);
|
|
53675
53688
|
}
|
|
53676
53689
|
|
|
53677
53690
|
// Fract - sawtooth discontinuities at every integer
|
|
@@ -53684,7 +53697,8 @@ IntervalResult ia_fract(vec2 x) {
|
|
|
53684
53697
|
return ia_ok(vec2(fract(x.x) - IA_EPS, fract(x.y) + IA_EPS));
|
|
53685
53698
|
}
|
|
53686
53699
|
// Interval spans an integer - sawtooth discontinuity
|
|
53687
|
-
|
|
53700
|
+
// fract is right-continuous (inherits from floor)
|
|
53701
|
+
return ia_singular_right(flo + 1.0);
|
|
53688
53702
|
}
|
|
53689
53703
|
|
|
53690
53704
|
// Mod - periodic discontinuities at multiples of the modulus
|
|
@@ -53707,7 +53721,8 @@ IntervalResult ia_mod(vec2 x, vec2 y) {
|
|
|
53707
53721
|
return ia_ok(vec2(min(mlo, mhi) - IA_EPS, max(mlo, mhi) + IA_EPS));
|
|
53708
53722
|
}
|
|
53709
53723
|
// Discontinuity at first multiple of period in the interval
|
|
53710
|
-
|
|
53724
|
+
// mod has sawtooth discontinuities, right-continuous
|
|
53725
|
+
return ia_singular_right((flo + 1.0) * period);
|
|
53711
53726
|
}
|
|
53712
53727
|
|
|
53713
53728
|
// General case: compose from existing operations
|
|
@@ -56397,10 +56412,10 @@ function defToString(name, def, v) {
|
|
|
56397
56412
|
// src/compute-engine.ts
|
|
56398
56413
|
init_types6();
|
|
56399
56414
|
init_base_compiler();
|
|
56400
|
-
var version = "0.35.
|
|
56415
|
+
var version = "0.35.4";
|
|
56401
56416
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
56402
56417
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
56403
|
-
version: "0.35.
|
|
56418
|
+
version: "0.35.4"
|
|
56404
56419
|
};
|
|
56405
56420
|
export {
|
|
56406
56421
|
BaseCompiler,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.35.
|
|
1
|
+
/** Compute Engine 0.35.4 */
|
|
2
2
|
var xu=Object.defineProperty;var Ny=Object.getOwnPropertyDescriptor;var Ty=Object.getOwnPropertyNames;var Sy=Object.prototype.hasOwnProperty;var k=(n,e)=>()=>(n&&(e=n(n=0)),e);var No=(n,e)=>{for(var t in e)xu(n,t,{get:e[t],enumerable:!0})},Iy=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ty(e))!Sy.call(n,r)&&r!==t&&xu(n,r,{get:()=>e[r],enumerable:!(i=Ny(e,r))||i.enumerable});return n};var bt=n=>Iy(xu({},"__esModule",{value:!0}),n);function yu(n,e){var t=Math.abs(n),i=Math.abs(e);return n===0?Math.log(i):e===0?Math.log(t):t<3e3&&i<3e3?Math.log(n*n+e*e)*.5:(n=n/2,e=e/2,.5*Math.log(n*n+e*e)+Math.LN2)}var on,jn,By,Ay,br,wy,ie,$i=k(()=>{on=Math.cosh||function(n){return Math.abs(n)<1e-9?1-n:(Math.exp(n)+Math.exp(-n))*.5},jn=Math.sinh||function(n){return Math.abs(n)<1e-9?n:(Math.exp(n)-Math.exp(-n))*.5},By=function(n){var e=Math.PI/4;if(-e>n||n>e)return Math.cos(n)-1;var t=n*n;return t*(t*(t*(t*(t*(t*(t*(t/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},Ay=function(n,e){var t=Math.abs(n),i=Math.abs(e);return t<3e3&&i<3e3?Math.sqrt(t*t+i*i):(t<i?(t=i,i=n/e):i=e/n,t*Math.sqrt(1+i*i))},br=function(){throw SyntaxError("Invalid Param")};wy=function(n,e){var t={re:0,im:0};if(n==null)t.re=t.im=0;else if(e!==void 0)t.re=n,t.im=e;else switch(typeof n){case"object":if("im"in n&&"re"in n)t.re=n.re,t.im=n.im;else if("abs"in n&&"arg"in n){if(!Number.isFinite(n.abs)&&Number.isFinite(n.arg))return ie.INFINITY;t.re=n.abs*Math.cos(n.arg),t.im=n.abs*Math.sin(n.arg)}else if("r"in n&&"phi"in n){if(!Number.isFinite(n.r)&&Number.isFinite(n.phi))return ie.INFINITY;t.re=n.r*Math.cos(n.phi),t.im=n.r*Math.sin(n.phi)}else n.length===2?(t.re=n[0],t.im=n[1]):br();break;case"string":t.im=t.re=0;var i=n.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),r=1,o=0;i===null&&br();for(var s=0;s<i.length;s++){var a=i[s];a===" "||a===" "||a===`
|
|
3
3
|
`||(a==="+"?r++:a==="-"?o++:a==="i"||a==="I"?(r+o===0&&br(),i[s+1]!==" "&&!isNaN(Number(i[s+1]))?(t.im+=parseFloat((o%2?"-":"")+i[s+1]),s++):t.im+=parseFloat((o%2?"-":"")+"1"),r=o=0):((r+o===0||isNaN(Number(a)))&&br(),i[s+1]==="i"||i[s+1]==="I"?(t.im+=parseFloat((o%2?"-":"")+a),s++):t.re+=parseFloat((o%2?"-":"")+a),r=o=0))}r+o>0&&br();break;case"number":t.im=0,t.re=n;break;default:br()}return isNaN(t.re)||isNaN(t.im),t},ie=class n{constructor(e,t){this.re=0,this.im=0;var i=wy(e,t);this.re=i.re,this.im=i.im}sign(){var e=this.abs();return new n(this.re/e,this.im/e)}add(e,t){var i=new n(e,t);return this.isInfinite()&&i.isInfinite()?n.NAN:this.isInfinite()||i.isInfinite()?n.INFINITY:new n(this.re+i.re,this.im+i.im)}sub(e,t){var i=new n(e,t);return this.isInfinite()&&i.isInfinite()?n.NAN:this.isInfinite()||i.isInfinite()?n.INFINITY:new n(this.re-i.re,this.im-i.im)}mul(e,t){var i=new n(e,t);return this.isInfinite()&&i.isZero()||this.isZero()&&i.isInfinite()?n.NAN:this.isInfinite()||i.isInfinite()?n.INFINITY:i.im===0&&this.im===0?new n(this.re*i.re,0):new n(this.re*i.re-this.im*i.im,this.re*i.im+this.im*i.re)}div(e,t){var i=new n(e,t);if(this.isZero()&&i.isZero()||this.isInfinite()&&i.isInfinite())return n.NAN;if(this.isInfinite()||i.isZero())return n.INFINITY;if(this.isZero()||i.isInfinite())return n.ZERO;e=this.re,t=this.im;var r=i.re,o=i.im,s,a;return o===0?new n(e/r,t/r):Math.abs(r)<Math.abs(o)?(a=r/o,s=r*a+o,new n((e*a+t)/s,(t*a-e)/s)):(a=o/r,s=o*a+r,new n((e+t*a)/s,(t-e*a)/s))}pow(e,t){var i=new n(e,t);if(e=this.re,t=this.im,i.isZero())return n.ONE;if(i.im===0){if(t===0&&e>0)return new n(Math.pow(e,i.re),0);if(e===0)switch((i.re%4+4)%4){case 0:return new n(Math.pow(t,i.re),0);case 1:return new n(0,Math.pow(t,i.re));case 2:return new n(-Math.pow(t,i.re),0);case 3:return new n(0,-Math.pow(t,i.re))}}if(e===0&&t===0&&i.re>0&&i.im>=0)return n.ZERO;var r=Math.atan2(t,e),o=yu(e,t);return e=Math.exp(i.re*o-i.im*r),t=i.im*o+i.re*r,new n(e*Math.cos(t),e*Math.sin(t))}sqrt(){var e=this.re,t=this.im,i=this.abs(),r,o;if(e>=0){if(t===0)return new n(Math.sqrt(e),0);r=.5*Math.sqrt(2*(i+e))}else r=Math.abs(t)/Math.sqrt(2*(i-e));return e<=0?o=.5*Math.sqrt(2*(i-e)):o=Math.abs(t)/Math.sqrt(2*(i+e)),new n(r,t<0?-o:o)}exp(){var e=Math.exp(this.re);return this.im,new n(e*Math.cos(this.im),e*Math.sin(this.im))}expm1(){var e=this.re,t=this.im;return new n(Math.expm1(e)*Math.cos(t)+By(t),Math.exp(e)*Math.sin(t))}log(){var e=this.re,t=this.im;return t===0&&e>0,new n(yu(e,t),Math.atan2(t,e))}abs(){return Ay(this.re,this.im)}arg(){return Math.atan2(this.im,this.re)}sin(){var e=this.re,t=this.im;return new n(Math.sin(e)*on(t),Math.cos(e)*jn(t))}cos(){var e=this.re,t=this.im;return new n(Math.cos(e)*on(t),-Math.sin(e)*jn(t))}tan(){var e=2*this.re,t=2*this.im,i=Math.cos(e)+on(t);return new n(Math.sin(e)/i,jn(t)/i)}cot(){var e=2*this.re,t=2*this.im,i=Math.cos(e)-on(t);return new n(-Math.sin(e)/i,jn(t)/i)}sec(){var e=this.re,t=this.im,i=.5*on(2*t)+.5*Math.cos(2*e);return new n(Math.cos(e)*on(t)/i,Math.sin(e)*jn(t)/i)}csc(){var e=this.re,t=this.im,i=.5*on(2*t)-.5*Math.cos(2*e);return new n(Math.sin(e)*on(t)/i,-Math.cos(e)*jn(t)/i)}asin(){var e=this.re,t=this.im,i=new n(t*t-e*e+1,-2*e*t).sqrt(),r=new n(i.re-t,i.im+e).log();return new n(r.im,-r.re)}acos(){var e=this.re,t=this.im,i=new n(t*t-e*e+1,-2*e*t).sqrt(),r=new n(i.re-t,i.im+e).log();return new n(Math.PI/2-r.im,r.re)}atan(){var e=this.re,t=this.im;if(e===0){if(t===1)return new n(0,1/0);if(t===-1)return new n(0,-1/0)}var i=e*e+(1-t)*(1-t),r=new n((1-t*t-e*e)/i,-2*e/i).log();return new n(-.5*r.im,.5*r.re)}acot(){var e=this.re,t=this.im;if(t===0)return new n(Math.atan2(1,e),0);var i=e*e+t*t;return i!==0?new n(e/i,-t/i).atan():new n(e!==0?e/0:0,t!==0?-t/0:0).atan()}asec(){var e=this.re,t=this.im;if(e===0&&t===0)return new n(0,1/0);var i=e*e+t*t;return i!==0?new n(e/i,-t/i).acos():new n(e!==0?e/0:0,t!==0?-t/0:0).acos()}acsc(){var e=this.re,t=this.im;if(e===0&&t===0)return new n(Math.PI/2,1/0);var i=e*e+t*t;return i!==0?new n(e/i,-t/i).asin():new n(e!==0?e/0:0,t!==0?-t/0:0).asin()}sinh(){var e=this.re,t=this.im;return new n(jn(e)*Math.cos(t),on(e)*Math.sin(t))}cosh(){var e=this.re,t=this.im;return new n(on(e)*Math.cos(t),jn(e)*Math.sin(t))}tanh(){var e=2*this.re,t=2*this.im,i=on(e)+Math.cos(t);return new n(jn(e)/i,Math.sin(t)/i)}coth(){var e=2*this.re,t=2*this.im,i=on(e)-Math.cos(t);return new n(jn(e)/i,-Math.sin(t)/i)}csch(){var e=this.re,t=this.im,i=Math.cos(2*t)-on(2*e);return new n(-2*jn(e)*Math.cos(t)/i,2*on(e)*Math.sin(t)/i)}sech(){var e=this.re,t=this.im,i=Math.cos(2*t)+on(2*e);return new n(2*on(e)*Math.cos(t)/i,-2*jn(e)*Math.sin(t)/i)}asinh(){var e=this.im;this.im=-this.re,this.re=e;var t=this.asin();return this.re=-this.im,this.im=e,e=t.re,t.re=-t.im,t.im=e,t}acosh(){var e=this.acos();if(e.im<=0){var t=e.re;e.re=-e.im,e.im=t}else{var t=e.im;e.im=-e.re,e.re=t}return e}atanh(){var e=this.re,t=this.im,i=e>1&&t===0,r=1-e,o=1+e,s=r*r+t*t,a=s!==0?new n((o*r-t*t)/s,(t*r+o*t)/s):new n(e!==-1?e/0:0,t!==0?t/0:0),u=a.re;return a.re=yu(a.re,a.im)/2,a.im=Math.atan2(a.im,u)/2,i&&(a.im=-a.im),a}acoth(){var e=this.re,t=this.im;if(e===0&&t===0)return new n(0,Math.PI/2);var i=e*e+t*t;return i!==0?new n(e/i,-t/i).atanh():new n(e!==0?e/0:0,t!==0?-t/0:0).atanh()}acsch(){var e=this.re,t=this.im;if(t===0)return new n(e!==0?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var i=e*e+t*t;return i!==0?new n(e/i,-t/i).asinh():new n(e!==0?e/0:0,t!==0?-t/0:0).asinh()}asech(){var e=this.re,t=this.im;if(this.isZero())return n.INFINITY;var i=e*e+t*t;return i!==0?new n(e/i,-t/i).acosh():new n(e!==0?e/0:0,t!==0?-t/0:0).acosh()}inverse(){if(this.isZero())return n.INFINITY;if(this.isInfinite())return n.ZERO;var e=this.re,t=this.im,i=e*e+t*t;return new n(e/i,-t/i)}conjugate(){return new n(this.re,-this.im)}neg(){return new n(-this.re,-this.im)}ceil(e){return e=Math.pow(10,e||0),new n(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)}floor(e){return e=Math.pow(10,e||0),new n(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)}round(e){return e=Math.pow(10,e||0),new n(Math.round(this.re*e)/e,Math.round(this.im*e)/e)}equals(e,t){var i=new n(e,t);return Math.abs(i.re-this.re)<=n.EPSILON&&Math.abs(i.im-this.im)<=n.EPSILON}clone(){return new n(this.re,this.im)}toString(){var e=this.re,t=this.im,i="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<n.EPSILON&&(e=0),Math.abs(t)<n.EPSILON&&(t=0),t===0?i+e:(e!==0?(i+=e,i+=" ",t<0?(t=-t,i+="-"):i+="+",i+=" "):t<0&&(t=-t,i+="-"),t!==1&&(i+=t),i+"i"))}toVector(){return[this.re,this.im]}valueOf(){return this.im===0?this.re:null}isNaN(){return isNaN(this.re)||isNaN(this.im)}isZero(){return this.im===0&&this.re===0}isFinite(){return isFinite(this.re)&&isFinite(this.im)}isInfinite(){return!(this.isNaN()||this.isFinite())}};ie.ZERO=new ie(0,0);ie.ONE=new ie(1,0);ie.I=new ie(0,1);ie.PI=new ie(Math.PI,0);ie.E=new ie(Math.E,0);ie.INFINITY=new ie(1/0,1/0);ie.NAN=new ie(NaN,NaN);ie.EPSILON=1e-15});function Ke(n){var e,t,i,r=n.length-1,o="",s=n[0];if(r>0){for(o+=s,e=1;e<r;e++)i=n[e]+"",t=$-i.length,t&&(o+=fi(t)),o+=i;s=n[e],i=s+"",t=$-i.length,t&&(o+=fi(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function _n(n,e,t){if(n!==~~n||n<e||n>t)throw Error(di+n)}function To(n,e,t,i){var r,o,s,a;for(o=n[0];o>=10;o/=10)--e;return--e<0?(e+=$,r=0):(r=Math.ceil((e+1)/$),e%=$),o=Ge(10,$-e),a=n[r]%o|0,i==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):s=(t<4&&a+1==o||t>3&&a+1==o/2)&&(n[r+1]/o/100|0)==Ge(10,e-2)-1||(a==o/2||a==0)&&(n[r+1]/o/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(i||t<4)&&a==9999||!i&&t>3&&a==4999):s=((i||t<4)&&a+1==o||!i&&t>3&&a+1==o/2)&&(n[r+1]/o/1e3|0)==Ge(10,e-3)-1,s}function Os(n,e,t){for(var i,r=[0],o,s=0,a=n.length;s<a;){for(o=r.length;o--;)r[o]*=e;for(r[0]+=bu.indexOf(n.charAt(s++)),i=0;i<r.length;i++)r[i]>t-1&&(r[i+1]===void 0&&(r[i+1]=0),r[i+1]+=r[i]/t|0,r[i]%=t)}return r.reverse()}function Py(n,e){var t,i,r;if(e.isZero())return e;i=e.d.length,i<32?(t=Math.ceil(i/3),r=(1/js(4,t)).toString()):(t=16,r="2.3283064365386962890625e-10"),n.precision+=t,e=Er(n,1,e.times(r),new n(1));for(var o=t;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return n.precision-=t,e}function F(n,e,t,i){var r,o,s,a,u,l,c,f,p,d=n.constructor;e:if(e!=null){if(f=n.d,!f)return n;for(r=1,a=f[0];a>=10;a/=10)r++;if(o=e-r,o<0)o+=$,s=e,c=f[p=0],u=c/Ge(10,r-s-1)%10|0;else if(p=Math.ceil((o+1)/$),a=f.length,p>=a)if(i){for(;a++<=p;)f.push(0);c=u=0,r=1,o%=$,s=o-$+1}else break e;else{for(c=a=f[p],r=1;a>=10;a/=10)r++;o%=$,s=o-$+r,u=s<0?0:c/Ge(10,r-s-1)%10|0}if(i=i||e<0||f[p+1]!==void 0||(s<0?c:c%Ge(10,r-s-1)),l=t<4?(u||i)&&(t==0||t==(n.s<0?3:2)):u>5||u==5&&(t==4||i||t==6&&(o>0?s>0?c/Ge(10,r-s):0:f[p-1])%10&1||t==(n.s<0?8:7)),e<1||!f[0])return f.length=0,l?(e-=n.e+1,f[0]=Ge(10,($-e%$)%$),n.e=-e||0):f[0]=n.e=0,n;if(o==0?(f.length=p,a=1,p--):(f.length=p+1,a=Ge(10,$-o),f[p]=s>0?(c/Ge(10,r-s)%Ge(10,s)|0)*a:0),l)for(;;)if(p==0){for(o=1,s=f[0];s>=10;s/=10)o++;for(s=f[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(n.e++,f[0]==ot&&(f[0]=1));break}else{if(f[p]+=a,f[p]!=ot)break;f[p--]=0,a=1}for(o=f.length;f[--o]===0;)f.pop()}return U&&(n.e>d.maxE?(n.d=null,n.e=NaN):n.e<d.minE&&(n.e=0,n.d=[0])),n}function Et(n,e,t){if(!n.isFinite())return kp(n);var i,r=n.e,o=Ke(n.d),s=o.length;return e?(t&&(i=t-s)>0?o=o.charAt(0)+"."+o.slice(1)+fi(i):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(n.e<0?"e":"e+")+n.e):r<0?(o="0."+fi(-r-1)+o,t&&(i=t-s)>0&&(o+=fi(i))):r>=s?(o+=fi(r+1-s),t&&(i=t-r-1)>0&&(o=o+"."+fi(i))):((i=r+1)<s&&(o=o.slice(0,i)+"."+o.slice(i)),t&&(i=t-s)>0&&(r+1===s&&(o+="."),o+=fi(i))),o}function Us(n,e){var t=n[0];for(e*=$;t>=10;t/=10)e++;return e}function Vs(n,e,t){if(e>Dy)throw U=!0,t&&(n.precision=t),Error(Np);return F(new n(qs),e,1,!0)}function vt(n,e,t){if(e>Eu)throw Error(Np);return F(new n(Fs),e,t,!0)}function Bp(n){var e=n.length-1,t=e*$+1;if(e=n[e],e){for(;e%10==0;e/=10)t--;for(e=n[0];e>=10;e/=10)t++}return t}function fi(n){for(var e="";n--;)e+="0";return e}function Ap(n,e,t,i){var r,o=new n(1),s=Math.ceil(i/$+4);for(U=!1;;){if(t%2&&(o=o.times(e),vp(o.d,s)&&(r=!0)),t=sn(t/2),t===0){t=o.d.length-1,r&&o.d[t]===0&&++o.d[t];break}e=e.times(e),vp(e.d,s)}return U=!0,o}function bp(n){return n.d[n.d.length-1]&1}function wp(n,e,t){for(var i,r,o=new n(e[0]),s=0;++s<e.length;){if(r=new n(e[s]),!r.s){o=r;break}i=o.cmp(r),(i===t||i===0&&o.s===t)&&(o=r)}return o}function _u(n,e){var t,i,r,o,s,a,u,l=0,c=0,f=0,p=n.constructor,d=p.rounding,m=p.precision;if(!n.d||!n.d[0]||n.e>17)return new p(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(e==null?(U=!1,u=m):u=e,a=new p(.03125);n.e>-2;)n=n.times(a),f+=5;for(i=Math.log(Ge(2,f))/Math.LN10*2+5|0,u+=i,t=o=s=new p(1),p.precision=u;;){if(o=F(o.times(n),u,1),t=t.times(++c),a=s.plus(xe(o,t,u,1)),Ke(a.d).slice(0,u)===Ke(s.d).slice(0,u)){for(r=f;r--;)s=F(s.times(s),u,1);if(e==null)if(l<3&&To(s.d,u-i,d,l))p.precision=u+=10,t=o=a=new p(1),c=0,l++;else return F(s,p.precision=m,d,U=!0);else return p.precision=m,s}s=a}}function pi(n,e){var t,i,r,o,s,a,u,l,c,f,p,d=1,m=10,g=n,h=g.d,x=g.constructor,y=x.rounding,E=x.precision;if(g.s<0||!h||!h[0]||!g.e&&h[0]==1&&h.length==1)return new x(h&&!h[0]?-1/0:g.s!=1?NaN:h?0:g);if(e==null?(U=!1,c=E):c=e,x.precision=c+=m,t=Ke(h),i=t.charAt(0),Math.abs(o=g.e)<15e14){for(;i<7&&i!=1||i==1&&t.charAt(1)>3;)g=g.times(n),t=Ke(g.d),i=t.charAt(0),d++;o=g.e,i>1?(g=new x("0."+t),o++):g=new x(i+"."+t.slice(1))}else return l=Vs(x,c+2,E).times(o+""),g=pi(new x(i+"."+t.slice(1)),c-m).plus(l),x.precision=E,e==null?F(g,E,y,U=!0):g;for(f=g,u=s=g=xe(g.minus(1),g.plus(1),c,1),p=F(g.times(g),c,1),r=3;;){if(s=F(s.times(p),c,1),l=u.plus(xe(s,new x(r),c,1)),Ke(l.d).slice(0,c)===Ke(u.d).slice(0,c))if(u=u.times(2),o!==0&&(u=u.plus(Vs(x,c+2,E).times(o+""))),u=xe(u,new x(d),c,1),e==null)if(To(u.d,c-m,y,a))x.precision=c+=m,l=s=g=xe(f.minus(1),f.plus(1),c,1),p=F(g.times(g),c,1),r=a=1;else return F(u,x.precision=E,y,U=!0);else return x.precision=E,u;u=l,r+=2}}function kp(n){return String(n.s*n.s/0)}function Ls(n,e){var t,i,r;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(t<0&&(t=i),t+=+e.slice(i+1),e=e.substring(0,i)):t<0&&(t=e.length),i=0;e.charCodeAt(i)===48;i++);for(r=e.length;e.charCodeAt(r-1)===48;--r);if(e=e.slice(i,r),e){if(r-=i,n.e=t=t-i-1,n.d=[],i=(t+1)%$,t<0&&(i+=$),i<r){for(i&&n.d.push(+e.slice(0,i)),r-=$;i<r;)n.d.push(+e.slice(i,i+=$));e=e.slice(i),i=$-e.length}else i-=r;for(;i--;)e+="0";n.d.push(+e),U&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function Oy(n,e){var t,i,r,o,s,a,u,l,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),Ip.test(e))return Ls(n,e)}else if(e==="Infinity"||e==="NaN")return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(Cy.test(e))t=16,e=e.toLowerCase();else if(ky.test(e))t=2;else if(Ry.test(e))t=8;else throw Error(di+e);for(o=e.search(/p/i),o>0?(u=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,i=n.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,r=Ap(i,new i(t),o,o*2)),l=Os(e,t,ot),c=l.length-1,o=c;l[o]===0;--o)l.pop();return o<0?new i(n.s*0):(n.e=Us(l,c),n.d=l,U=!1,s&&(n=xe(n,r,a*4)),u&&(n=n.times(Math.abs(u)<54?Ge(2,u):j.pow(2,u))),U=!0,n)}function Ly(n,e){var t,i=e.d.length;if(i<3)return e.isZero()?e:Er(n,2,e,e);t=1.4*Math.sqrt(i),t=t>16?16:t|0,e=e.times(1/js(5,t)),e=Er(n,2,e,e);for(var r,o=new n(5),s=new n(16),a=new n(20);t--;)r=e.times(e),e=e.times(o.plus(r.times(s.times(r).minus(a))));return e}function Er(n,e,t,i,r){var o,s,a,u,l=1,c=n.precision,f=Math.ceil(c/$);for(U=!1,u=t.times(t),a=new n(i);;){if(s=xe(a.times(u),new n(e++*e++),c,1),a=r?i.plus(s):i.minus(s),i=xe(s.times(u),new n(e++*e++),c,1),s=a.plus(i),s.d[f]!==void 0){for(o=f;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=i,i=s,s=o,l++}return U=!0,s.d.length=f+1,s}function js(n,e){for(var t=n;--e;)t*=n;return t}function Cp(n,e){var t,i=e.s<0,r=vt(n,n.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return $t=i?4:1,e;if(t=e.divToInt(r),t.isZero())$t=i?3:2;else{if(e=e.minus(t.times(r)),e.lte(o))return $t=bp(t)?i?2:3:i?4:1,e;$t=bp(t)?i?1:4:i?3:2}return e.minus(r).abs()}function Nu(n,e,t,i){var r,o,s,a,u,l,c,f,p,d=n.constructor,m=t!==void 0;if(m?(_n(t,1,mi),i===void 0?i=d.rounding:_n(i,0,8)):(t=d.precision,i=d.rounding),!n.isFinite())c=kp(n);else{for(c=Et(n),s=c.indexOf("."),m?(r=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):r=e,s>=0&&(c=c.replace(".",""),p=new d(1),p.e=c.length-s,p.d=Os(Et(p),10,r),p.e=p.d.length),f=Os(c,10,r),o=u=f.length;f[--u]==0;)f.pop();if(!f[0])c=m?"0p+0":"0";else{if(s<0?o--:(n=new d(n),n.d=f,n.e=o,n=xe(n,p,t,i,0,r),f=n.d,o=n.e,l=_p),s=f[t],a=r/2,l=l||f[t+1]!==void 0,l=i<4?(s!==void 0||l)&&(i===0||i===(n.s<0?3:2)):s>a||s===a&&(i===4||l||i===6&&f[t-1]&1||i===(n.s<0?8:7)),f.length=t,l)for(;++f[--t]>r-1;)f[t]=0,t||(++o,f.unshift(1));for(u=f.length;!f[u-1];--u);for(s=0,c="";s<u;s++)c+=bu.charAt(f[s]);if(m){if(u>1)if(e==16||e==8){for(s=e==16?4:3,--u;u%s;u++)c+="0";for(f=Os(c,r,e),u=f.length;!f[u-1];--u);for(s=1,c="1.";s<u;s++)c+=bu.charAt(f[s])}else c=c.charAt(0)+"."+c.slice(1);c=c+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)c="0"+c;c="0."+c}else if(++o>u)for(o-=u;o--;)c+="0";else o<u&&(c=c.slice(0,o)+"."+c.slice(o))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return n.s<0?"-"+c:c}function vp(n,e){if(n.length>e)return n.length=e,!0}function qy(n){return new this(n).abs()}function Fy(n){return new this(n).acos()}function Vy(n){return new this(n).acosh()}function $y(n,e){return new this(n).plus(e)}function Uy(n){return new this(n).asin()}function jy(n){return new this(n).asinh()}function Gy(n){return new this(n).atan()}function zy(n){return new this(n).atanh()}function Zy(n,e){n=new this(n),e=new this(e);var t,i=this.precision,r=this.rounding,o=i+4;return!n.s||!e.s?t=new this(NaN):!n.d&&!e.d?(t=vt(this,o,1).times(e.s>0?.25:.75),t.s=n.s):!e.d||n.isZero()?(t=e.s<0?vt(this,i,r):new this(0),t.s=n.s):!n.d||e.isZero()?(t=vt(this,o,1).times(.5),t.s=n.s):e.s<0?(this.precision=o,this.rounding=1,t=this.atan(xe(n,e,o,1)),e=vt(this,o,1),this.precision=i,this.rounding=r,t=n.s<0?t.minus(e):t.plus(e)):t=this.atan(xe(n,e,o,1)),t}function Hy(n){return new this(n).cbrt()}function Wy(n){return F(n=new this(n),n.e+1,2)}function Jy(n,e,t){return new this(n).clamp(e,t)}function Yy(n){if(!n||typeof n!="object")throw Error($s+"Object expected");var e,t,i,r=n.defaults===!0,o=["precision",1,mi,"rounding",0,8,"toExpNeg",-vr,0,"toExpPos",0,vr,"maxE",0,vr,"minE",-vr,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(t=o[e],r&&(this[t]=vu[t]),(i=n[t])!==void 0)if(sn(i)===i&&i>=o[e+1]&&i<=o[e+2])this[t]=i;else throw Error(di+t+": "+i);if(t="crypto",r&&(this[t]=vu[t]),(i=n[t])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Tp);else this[t]=!1;else throw Error(di+t+": "+i);return this}function Qy(n){return new this(n).cos()}function Xy(n){return new this(n).cosh()}function Rp(n){var e,t,i;function r(o){var s,a,u,l=this;if(!(l instanceof r))return new r(o);if(l.constructor=r,Ep(o)){l.s=o.s,U?!o.d||o.e>r.maxE?(l.e=NaN,l.d=null):o.e<r.minE?(l.e=0,l.d=[0]):(l.e=o.e,l.d=o.d.slice()):(l.e=o.e,l.d=o.d?o.d.slice():o.d);return}if(u=typeof o,u==="number"){if(o===0){l.s=1/o<0?-1:1,l.e=0,l.d=[0];return}if(o<0?(o=-o,l.s=-1):l.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;U?s>r.maxE?(l.e=NaN,l.d=null):s<r.minE?(l.e=0,l.d=[0]):(l.e=s,l.d=[o]):(l.e=s,l.d=[o]);return}if(o*0!==0){o||(l.s=NaN),l.e=NaN,l.d=null;return}return Ls(l,o.toString())}if(u==="string")return(a=o.charCodeAt(0))===45?(o=o.slice(1),l.s=-1):(a===43&&(o=o.slice(1)),l.s=1),Ip.test(o)?Ls(l,o):Oy(l,o);if(u==="bigint")return o<0?(o=-o,l.s=-1):l.s=1,Ls(l,o.toString());throw Error(di+o)}if(r.prototype=I,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=Yy,r.clone=Rp,r.isDecimal=Ep,r.abs=qy,r.acos=Fy,r.acosh=Vy,r.add=$y,r.asin=Uy,r.asinh=jy,r.atan=Gy,r.atanh=zy,r.atan2=Zy,r.cbrt=Hy,r.ceil=Wy,r.clamp=Jy,r.cos=Qy,r.cosh=Xy,r.div=Ky,r.exp=eb,r.floor=nb,r.hypot=tb,r.ln=ib,r.log=rb,r.log10=sb,r.log2=ob,r.max=ab,r.min=ub,r.mod=lb,r.mul=cb,r.pow=fb,r.random=pb,r.round=db,r.sign=mb,r.sin=gb,r.sinh=hb,r.sqrt=xb,r.sub=yb,r.sum=bb,r.tan=vb,r.tanh=Eb,r.trunc=_b,n===void 0&&(n={}),n&&n.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<i.length;)n.hasOwnProperty(t=i[e++])||(n[t]=this[t]);return r.config(n),r}function Ky(n,e){return new this(n).div(e)}function eb(n){return new this(n).exp()}function nb(n){return F(n=new this(n),n.e+1,3)}function tb(){var n,e,t=new this(0);for(U=!1,n=0;n<arguments.length;)if(e=new this(arguments[n++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return U=!0,new this(1/0);t=e}return U=!0,t.sqrt()}function Ep(n){return n instanceof j||n&&n.toStringTag===Sp||!1}function ib(n){return new this(n).ln()}function rb(n,e){return new this(n).log(e)}function ob(n){return new this(n).log(2)}function sb(n){return new this(n).log(10)}function ab(){return wp(this,arguments,-1)}function ub(){return wp(this,arguments,1)}function lb(n,e){return new this(n).mod(e)}function cb(n,e){return new this(n).mul(e)}function fb(n,e){return new this(n).pow(e)}function pb(n){var e,t,i,r,o=0,s=new this(1),a=[];if(n===void 0?n=this.precision:_n(n,1,mi),i=Math.ceil(n/$),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(i));o<i;)r=e[o],r>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=r%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(i*=4);o<i;)r=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(e,o):(a.push(r%1e7),o+=4);o=i/4}else throw Error(Tp);else for(;o<i;)a[o++]=Math.random()*1e7|0;for(i=a[--o],n%=$,i&&n&&(r=Ge(10,$-n),a[o]=(i/r|0)*r);a[o]===0;o--)a.pop();if(o<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=$)a.shift();for(i=1,r=a[0];r>=10;r/=10)i++;i<$&&(t-=$-i)}return s.e=t,s.d=a,s}function db(n){return F(n=new this(n),n.e+1,this.rounding)}function mb(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function gb(n){return new this(n).sin()}function hb(n){return new this(n).sinh()}function xb(n){return new this(n).sqrt()}function yb(n,e){return new this(n).sub(e)}function bb(){var n=0,e=arguments,t=new this(e[n]);for(U=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return U=!0,F(t,this.precision,this.rounding)}function vb(n){return new this(n).tan()}function Eb(n){return new this(n).tanh()}function _b(n){return F(n=new this(n),n.e+1,1)}var vr,mi,bu,qs,Fs,vu,_p,$t,U,$s,di,Np,Tp,Sp,sn,Ge,ky,Cy,Ry,Ip,ot,$,My,Dy,Eu,I,xe,j,So,Nn=k(()=>{vr=9e15,mi=1e9,bu="0123456789abcdef",qs="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Fs="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",vu={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-vr,maxE:vr,crypto:!1},U=!0,$s="[DecimalError] ",di=$s+"Invalid argument: ",Np=$s+"Precision limit exceeded",Tp=$s+"crypto unavailable",Sp="[object Decimal]",sn=Math.floor,Ge=Math.pow,ky=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Cy=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ry=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ip=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ot=1e7,$=7,My=9007199254740991,Dy=qs.length-1,Eu=Fs.length-1,I={toStringTag:Sp};I.absoluteValue=I.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),F(n)};I.ceil=function(){return F(new this.constructor(this),this.e+1,2)};I.clampedTo=I.clamp=function(n,e){var t,i=this,r=i.constructor;if(n=new r(n),e=new r(e),!n.s||!e.s)return new r(NaN);if(n.gt(e))throw Error(di+e);return t=i.cmp(n),t<0?n:i.cmp(e)>0?e:new r(i)};I.comparedTo=I.cmp=function(n){var e,t,i,r,o=this,s=o.d,a=(n=new o.constructor(n)).d,u=o.s,l=n.s;if(!s||!a)return!u||!l?NaN:u!==l?u:s===a?0:!s^u<0?1:-1;if(!s[0]||!a[0])return s[0]?u:a[0]?-l:0;if(u!==l)return u;if(o.e!==n.e)return o.e>n.e^u<0?1:-1;for(i=s.length,r=a.length,e=0,t=i<r?i:r;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^u<0?1:-1;return i===r?0:i>r^u<0?1:-1};I.cosine=I.cos=function(){var n,e,t=this,i=t.constructor;return t.d?t.d[0]?(n=i.precision,e=i.rounding,i.precision=n+Math.max(t.e,t.sd())+$,i.rounding=1,t=Py(i,Cp(i,t)),i.precision=n,i.rounding=e,F($t==2||$t==3?t.neg():t,n,e,!0)):new i(1):new i(NaN)};I.cubeRoot=I.cbrt=function(){var n,e,t,i,r,o,s,a,u,l,c=this,f=c.constructor;if(!c.isFinite()||c.isZero())return new f(c);for(U=!1,o=c.s*Ge(c.s*c,1/3),!o||Math.abs(o)==1/0?(t=Ke(c.d),n=c.e,(o=(n-t.length+1)%3)&&(t+=o==1||o==-2?"0":"00"),o=Ge(t,1/3),n=sn((n+1)/3)-(n%3==(n<0?-1:2)),o==1/0?t="5e"+n:(t=o.toExponential(),t=t.slice(0,t.indexOf("e")+1)+n),i=new f(t),i.s=c.s):i=new f(o.toString()),s=(n=f.precision)+3;;)if(a=i,u=a.times(a).times(a),l=u.plus(c),i=xe(l.plus(c).times(a),l.plus(u),s+2,1),Ke(a.d).slice(0,s)===(t=Ke(i.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!r&&t=="4999"){if(!r&&(F(a,n+1,0),a.times(a).times(a).eq(c))){i=a;break}s+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(F(i,n+1,1),e=!i.times(i).times(i).eq(c));break}return U=!0,F(i,n,f.rounding,e)};I.decimalPlaces=I.dp=function(){var n,e=this.d,t=NaN;if(e){if(n=e.length-1,t=(n-sn(this.e/$))*$,n=e[n],n)for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t};I.dividedBy=I.div=function(n){return xe(this,new this.constructor(n))};I.dividedToIntegerBy=I.divToInt=function(n){var e=this,t=e.constructor;return F(xe(e,new t(n),0,1,1),t.precision,t.rounding)};I.equals=I.eq=function(n){return this.cmp(n)===0};I.floor=function(){return F(new this.constructor(this),this.e+1,3)};I.greaterThan=I.gt=function(n){return this.cmp(n)>0};I.greaterThanOrEqualTo=I.gte=function(n){var e=this.cmp(n);return e==1||e===0};I.hyperbolicCosine=I.cosh=function(){var n,e,t,i,r,o=this,s=o.constructor,a=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return a;t=s.precision,i=s.rounding,s.precision=t+Math.max(o.e,o.sd())+4,s.rounding=1,r=o.d.length,r<32?(n=Math.ceil(r/3),e=(1/js(4,n)).toString()):(n=16,e="2.3283064365386962890625e-10"),o=Er(s,1,o.times(e),new s(1),!0);for(var u,l=n,c=new s(8);l--;)u=o.times(o),o=a.minus(u.times(c.minus(u.times(c))));return F(o,s.precision=t,s.rounding=i,!0)};I.hyperbolicSine=I.sinh=function(){var n,e,t,i,r=this,o=r.constructor;if(!r.isFinite()||r.isZero())return new o(r);if(e=o.precision,t=o.rounding,o.precision=e+Math.max(r.e,r.sd())+4,o.rounding=1,i=r.d.length,i<3)r=Er(o,2,r,r,!0);else{n=1.4*Math.sqrt(i),n=n>16?16:n|0,r=r.times(1/js(5,n)),r=Er(o,2,r,r,!0);for(var s,a=new o(5),u=new o(16),l=new o(20);n--;)s=r.times(r),r=r.times(a.plus(s.times(u.times(s).plus(l))))}return o.precision=e,o.rounding=t,F(r,e,t,!0)};I.hyperbolicTangent=I.tanh=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+7,i.rounding=1,xe(t.sinh(),t.cosh(),i.precision=n,i.rounding=e)):new i(t.s)};I.inverseCosine=I.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),i=e.precision,r=e.rounding;return t!==-1?t===0?n.isNeg()?vt(e,i,r):new e(0):new e(NaN):n.isZero()?vt(e,i+4,r).times(.5):(e.precision=i+6,e.rounding=1,n=new e(1).minus(n).div(n.plus(1)).sqrt().atan(),e.precision=i,e.rounding=r,n.times(2))};I.inverseHyperbolicCosine=I.acosh=function(){var n,e,t=this,i=t.constructor;return t.lte(1)?new i(t.eq(1)?0:NaN):t.isFinite()?(n=i.precision,e=i.rounding,i.precision=n+Math.max(Math.abs(t.e),t.sd())+4,i.rounding=1,U=!1,t=t.times(t).minus(1).sqrt().plus(t),U=!0,i.precision=n,i.rounding=e,t.ln()):new i(t)};I.inverseHyperbolicSine=I.asinh=function(){var n,e,t=this,i=t.constructor;return!t.isFinite()||t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,i.rounding=1,U=!1,t=t.times(t).plus(1).sqrt().plus(t),U=!0,i.precision=n,i.rounding=e,t.ln())};I.inverseHyperbolicTangent=I.atanh=function(){var n,e,t,i,r=this,o=r.constructor;return r.isFinite()?r.e>=0?new o(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=o.precision,e=o.rounding,i=r.sd(),Math.max(i,n)<2*-r.e-1?F(new o(r),n,e,!0):(o.precision=t=i-r.e,r=xe(r.plus(1),new o(1).minus(r),t+n,1),o.precision=n+4,o.rounding=1,r=r.ln(),o.precision=n,o.rounding=e,r.times(.5))):new o(NaN)};I.inverseSine=I.asin=function(){var n,e,t,i,r=this,o=r.constructor;return r.isZero()?new o(r):(e=r.abs().cmp(1),t=o.precision,i=o.rounding,e!==-1?e===0?(n=vt(o,t+4,i).times(.5),n.s=r.s,n):new o(NaN):(o.precision=t+6,o.rounding=1,r=r.div(new o(1).minus(r.times(r)).sqrt().plus(1)).atan(),o.precision=t,o.rounding=i,r.times(2)))};I.inverseTangent=I.atan=function(){var n,e,t,i,r,o,s,a,u,l=this,c=l.constructor,f=c.precision,p=c.rounding;if(l.isFinite()){if(l.isZero())return new c(l);if(l.abs().eq(1)&&f+4<=Eu)return s=vt(c,f+4,p).times(.25),s.s=l.s,s}else{if(!l.s)return new c(NaN);if(f+4<=Eu)return s=vt(c,f+4,p).times(.5),s.s=l.s,s}for(c.precision=a=f+10,c.rounding=1,t=Math.min(28,a/$+2|0),n=t;n;--n)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(U=!1,e=Math.ceil(a/$),i=1,u=l.times(l),s=new c(l),r=l;n!==-1;)if(r=r.times(u),o=s.minus(r.div(i+=2)),r=r.times(u),s=o.plus(r.div(i+=2)),s.d[e]!==void 0)for(n=e;s.d[n]===o.d[n]&&n--;);return t&&(s=s.times(2<<t-1)),U=!0,F(s,c.precision=f,c.rounding=p,!0)};I.isFinite=function(){return!!this.d};I.isInteger=I.isInt=function(){return!!this.d&&sn(this.e/$)>this.d.length-2};I.isNaN=function(){return!this.s};I.isNegative=I.isNeg=function(){return this.s<0};I.isPositive=I.isPos=function(){return this.s>0};I.isZero=function(){return!!this.d&&this.d[0]===0};I.lessThan=I.lt=function(n){return this.cmp(n)<0};I.lessThanOrEqualTo=I.lte=function(n){return this.cmp(n)<1};I.logarithm=I.log=function(n){var e,t,i,r,o,s,a,u,l=this,c=l.constructor,f=c.precision,p=c.rounding,d=5;if(n==null)n=new c(10),e=!0;else{if(n=new c(n),t=n.d,n.s<0||!t||!t[0]||n.eq(1))return new c(NaN);e=n.eq(10)}if(t=l.d,l.s<0||!t||!t[0]||l.eq(1))return new c(t&&!t[0]?-1/0:l.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)o=!0;else{for(r=t[0];r%10===0;)r/=10;o=r!==1}if(U=!1,a=f+d,s=pi(l,a),i=e?Vs(c,a+10):pi(n,a),u=xe(s,i,a,1),To(u.d,r=f,p))do if(a+=10,s=pi(l,a),i=e?Vs(c,a+10):pi(n,a),u=xe(s,i,a,1),!o){+Ke(u.d).slice(r+1,r+15)+1==1e14&&(u=F(u,f+1,0));break}while(To(u.d,r+=10,p));return U=!0,F(u,f,p)};I.minus=I.sub=function(n){var e,t,i,r,o,s,a,u,l,c,f,p,d=this,m=d.constructor;if(n=new m(n),!d.d||!n.d)return!d.s||!n.s?n=new m(NaN):d.d?n.s=-n.s:n=new m(n.d||d.s!==n.s?d:NaN),n;if(d.s!=n.s)return n.s=-n.s,d.plus(n);if(l=d.d,p=n.d,a=m.precision,u=m.rounding,!l[0]||!p[0]){if(p[0])n.s=-n.s;else if(l[0])n=new m(d);else return new m(u===3?-0:0);return U?F(n,a,u):n}if(t=sn(n.e/$),c=sn(d.e/$),l=l.slice(),o=c-t,o){for(f=o<0,f?(e=l,o=-o,s=p.length):(e=p,t=c,s=l.length),i=Math.max(Math.ceil(a/$),s)+2,o>i&&(o=i,e.length=1),e.reverse(),i=o;i--;)e.push(0);e.reverse()}else{for(i=l.length,s=p.length,f=i<s,f&&(s=i),i=0;i<s;i++)if(l[i]!=p[i]){f=l[i]<p[i];break}o=0}for(f&&(e=l,l=p,p=e,n.s=-n.s),s=l.length,i=p.length-s;i>0;--i)l[s++]=0;for(i=p.length;i>o;){if(l[--i]<p[i]){for(r=i;r&&l[--r]===0;)l[r]=ot-1;--l[r],l[i]+=ot}l[i]-=p[i]}for(;l[--s]===0;)l.pop();for(;l[0]===0;l.shift())--t;return l[0]?(n.d=l,n.e=Us(l,t),U?F(n,a,u):n):new m(u===3?-0:0)};I.modulo=I.mod=function(n){var e,t=this,i=t.constructor;return n=new i(n),!t.d||!n.s||n.d&&!n.d[0]?new i(NaN):!n.d||t.d&&!t.d[0]?F(new i(t),i.precision,i.rounding):(U=!1,i.modulo==9?(e=xe(t,n.abs(),0,3,1),e.s*=n.s):e=xe(t,n,0,i.modulo,1),e=e.times(n),U=!0,t.minus(e))};I.naturalExponential=I.exp=function(){return _u(this)};I.naturalLogarithm=I.ln=function(){return pi(this)};I.negated=I.neg=function(){var n=new this.constructor(this);return n.s=-n.s,F(n)};I.plus=I.add=function(n){var e,t,i,r,o,s,a,u,l,c,f=this,p=f.constructor;if(n=new p(n),!f.d||!n.d)return!f.s||!n.s?n=new p(NaN):f.d||(n=new p(n.d||f.s===n.s?f:NaN)),n;if(f.s!=n.s)return n.s=-n.s,f.minus(n);if(l=f.d,c=n.d,a=p.precision,u=p.rounding,!l[0]||!c[0])return c[0]||(n=new p(f)),U?F(n,a,u):n;if(o=sn(f.e/$),i=sn(n.e/$),l=l.slice(),r=o-i,r){for(r<0?(t=l,r=-r,s=c.length):(t=c,i=o,s=l.length),o=Math.ceil(a/$),s=o>s?o+1:s+1,r>s&&(r=s,t.length=1),t.reverse();r--;)t.push(0);t.reverse()}for(s=l.length,r=c.length,s-r<0&&(r=s,t=c,c=l,l=t),e=0;r;)e=(l[--r]=l[r]+c[r]+e)/ot|0,l[r]%=ot;for(e&&(l.unshift(e),++i),s=l.length;l[--s]==0;)l.pop();return n.d=l,n.e=Us(l,i),U?F(n,a,u):n};I.precision=I.sd=function(n){var e,t=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(di+n);return t.d?(e=Bp(t.d),n&&t.e+1>e&&(e=t.e+1)):e=NaN,e};I.round=function(){var n=this,e=n.constructor;return F(new e(n),n.e+1,e.rounding)};I.sine=I.sin=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+Math.max(t.e,t.sd())+$,i.rounding=1,t=Ly(i,Cp(i,t)),i.precision=n,i.rounding=e,F($t>2?t.neg():t,n,e,!0)):new i(NaN)};I.squareRoot=I.sqrt=function(){var n,e,t,i,r,o,s=this,a=s.d,u=s.e,l=s.s,c=s.constructor;if(l!==1||!a||!a[0])return new c(!l||l<0&&(!a||a[0])?NaN:a?s:1/0);for(U=!1,l=Math.sqrt(+s),l==0||l==1/0?(e=Ke(a),(e.length+u)%2==0&&(e+="0"),l=Math.sqrt(e),u=sn((u+1)/2)-(u<0||u%2),l==1/0?e="5e"+u:(e=l.toExponential(),e=e.slice(0,e.indexOf("e")+1)+u),i=new c(e)):i=new c(l.toString()),t=(u=c.precision)+3;;)if(o=i,i=o.plus(xe(s,o,t+2,1)).times(.5),Ke(o.d).slice(0,t)===(e=Ke(i.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!r&&e=="4999"){if(!r&&(F(o,u+1,0),o.times(o).eq(s))){i=o;break}t+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(F(i,u+1,1),n=!i.times(i).eq(s));break}return U=!0,F(i,u,c.rounding,n)};I.tangent=I.tan=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+10,i.rounding=1,t=t.sin(),t.s=1,t=xe(t,new i(1).minus(t.times(t)).sqrt(),n+10,0),i.precision=n,i.rounding=e,F($t==2||$t==4?t.neg():t,n,e,!0)):new i(NaN)};I.times=I.mul=function(n){var e,t,i,r,o,s,a,u,l,c=this,f=c.constructor,p=c.d,d=(n=new f(n)).d;if(n.s*=c.s,!p||!p[0]||!d||!d[0])return new f(!n.s||p&&!p[0]&&!d||d&&!d[0]&&!p?NaN:!p||!d?n.s/0:n.s*0);for(t=sn(c.e/$)+sn(n.e/$),u=p.length,l=d.length,u<l&&(o=p,p=d,d=o,s=u,u=l,l=s),o=[],s=u+l,i=s;i--;)o.push(0);for(i=l;--i>=0;){for(e=0,r=u+i;r>i;)a=o[r]+d[i]*p[r-i-1]+e,o[r--]=a%ot|0,e=a/ot|0;o[r]=(o[r]+e)%ot|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),n.d=o,n.e=Us(o,t),U?F(n,f.precision,f.rounding):n};I.toBinary=function(n,e){return Nu(this,2,n,e)};I.toDecimalPlaces=I.toDP=function(n,e){var t=this,i=t.constructor;return t=new i(t),n===void 0?t:(_n(n,0,mi),e===void 0?e=i.rounding:_n(e,0,8),F(t,n+t.e+1,e))};I.toExponential=function(n,e){var t,i=this,r=i.constructor;return n===void 0?t=Et(i,!0):(_n(n,0,mi),e===void 0?e=r.rounding:_n(e,0,8),i=F(new r(i),n+1,e),t=Et(i,!0,n+1)),i.isNeg()&&!i.isZero()?"-"+t:t};I.toFixed=function(n,e){var t,i,r=this,o=r.constructor;return n===void 0?t=Et(r):(_n(n,0,mi),e===void 0?e=o.rounding:_n(e,0,8),i=F(new o(r),n+r.e+1,e),t=Et(i,!1,n+i.e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};I.toFraction=function(n){var e,t,i,r,o,s,a,u,l,c,f,p,d=this,m=d.d,g=d.constructor;if(!m)return new g(d);if(l=t=new g(1),i=u=new g(0),e=new g(i),o=e.e=Bp(m)-d.e-1,s=o%$,e.d[0]=Ge(10,s<0?$+s:s),n==null)n=o>0?e:l;else{if(a=new g(n),!a.isInt()||a.lt(l))throw Error(di+a);n=a.gt(e)?o>0?e:l:a}for(U=!1,a=new g(Ke(m)),c=g.precision,g.precision=o=m.length*$*2;f=xe(a,e,0,1,1),r=t.plus(f.times(i)),r.cmp(n)!=1;)t=i,i=r,r=l,l=u.plus(f.times(r)),u=r,r=e,e=a.minus(f.times(r)),a=r;return r=xe(n.minus(t),i,0,1,1),u=u.plus(r.times(l)),t=t.plus(r.times(i)),u.s=l.s=d.s,p=xe(l,i,o,1).minus(d).abs().cmp(xe(u,t,o,1).minus(d).abs())<1?[l,i]:[u,t],g.precision=c,U=!0,p};I.toHexadecimal=I.toHex=function(n,e){return Nu(this,16,n,e)};I.toNearest=function(n,e){var t=this,i=t.constructor;if(t=new i(t),n==null){if(!t.d)return t;n=new i(1),e=i.rounding}else{if(n=new i(n),e===void 0?e=i.rounding:_n(e,0,8),!t.d)return n.s?t:n;if(!n.d)return n.s&&(n.s=t.s),n}return n.d[0]?(U=!1,t=xe(t,n,0,e,1).times(n),U=!0,F(t)):(n.s=t.s,t=n),t};I.toNumber=function(){return+this};I.toOctal=function(n,e){return Nu(this,8,n,e)};I.toPower=I.pow=function(n){var e,t,i,r,o,s,a=this,u=a.constructor,l=+(n=new u(n));if(!a.d||!n.d||!a.d[0]||!n.d[0])return new u(Ge(+a,l));if(a=new u(a),a.eq(1))return a;if(i=u.precision,o=u.rounding,n.eq(1))return F(a,i,o);if(e=sn(n.e/$),e>=n.d.length-1&&(t=l<0?-l:l)<=My)return r=Ap(u,a,t,i),n.s<0?new u(1).div(r):F(r,i,o);if(s=a.s,s<0){if(e<n.d.length-1)return new u(NaN);if((n.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=Ge(+a,l),e=t==0||!isFinite(t)?sn(l*(Math.log("0."+Ke(a.d))/Math.LN10+a.e+1)):new u(t+"").e,e>u.maxE+1||e<u.minE-1?new u(e>0?s/0:0):(U=!1,u.rounding=a.s=1,t=Math.min(12,(e+"").length),r=_u(n.times(pi(a,i+t)),i),r.d&&(r=F(r,i+5,1),To(r.d,i,o)&&(e=i+10,r=F(_u(n.times(pi(a,e+t)),e),e+5,1),+Ke(r.d).slice(i+1,i+15)+1==1e14&&(r=F(r,i+1,0)))),r.s=s,U=!0,u.rounding=o,F(r,i,o))};I.toPrecision=function(n,e){var t,i=this,r=i.constructor;return n===void 0?t=Et(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(_n(n,1,mi),e===void 0?e=r.rounding:_n(e,0,8),i=F(new r(i),n,e),t=Et(i,n<=i.e||i.e<=r.toExpNeg,n)),i.isNeg()&&!i.isZero()?"-"+t:t};I.toSignificantDigits=I.toSD=function(n,e){var t=this,i=t.constructor;return n===void 0?(n=i.precision,e=i.rounding):(_n(n,1,mi),e===void 0?e=i.rounding:_n(e,0,8)),F(new i(t),n,e)};I.toString=function(){var n=this,e=n.constructor,t=Et(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+t:t};I.truncated=I.trunc=function(){return F(new this.constructor(this),this.e+1,1)};I.valueOf=I.toJSON=function(){var n=this,e=n.constructor,t=Et(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+t:t};xe=(function(){function n(i,r,o){var s,a=0,u=i.length;for(i=i.slice();u--;)s=i[u]*r+a,i[u]=s%o|0,a=s/o|0;return a&&i.unshift(a),i}function e(i,r,o,s){var a,u;if(o!=s)u=o>s?1:-1;else for(a=u=0;a<o;a++)if(i[a]!=r[a]){u=i[a]>r[a]?1:-1;break}return u}function t(i,r,o,s){for(var a=0;o--;)i[o]-=a,a=i[o]<r[o]?1:0,i[o]=a*s+i[o]-r[o];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,o,s,a,u){var l,c,f,p,d,m,g,h,x,y,E,v,_,N,T,B,L,Y,H,Ae,qe=i.constructor,Fe=i.s==r.s?1:-1,ce=i.d,oe=r.d;if(!ce||!ce[0]||!oe||!oe[0])return new qe(!i.s||!r.s||(ce?oe&&ce[0]==oe[0]:!oe)?NaN:ce&&ce[0]==0||!oe?Fe*0:Fe/0);for(u?(d=1,c=i.e-r.e):(u=ot,d=$,c=sn(i.e/d)-sn(r.e/d)),H=oe.length,L=ce.length,x=new qe(Fe),y=x.d=[],f=0;oe[f]==(ce[f]||0);f++);if(oe[f]>(ce[f]||0)&&c--,o==null?(N=o=qe.precision,s=qe.rounding):a?N=o+(i.e-r.e)+1:N=o,N<0)y.push(1),m=!0;else{if(N=N/d+2|0,f=0,H==1){for(p=0,oe=oe[0],N++;(f<L||p)&&N--;f++)T=p*u+(ce[f]||0),y[f]=T/oe|0,p=T%oe|0;m=p||f<L}else{for(p=u/(oe[0]+1)|0,p>1&&(oe=n(oe,p,u),ce=n(ce,p,u),H=oe.length,L=ce.length),B=H,E=ce.slice(0,H),v=E.length;v<H;)E[v++]=0;Ae=oe.slice(),Ae.unshift(0),Y=oe[0],oe[1]>=u/2&&++Y;do p=0,l=e(oe,E,H,v),l<0?(_=E[0],H!=v&&(_=_*u+(E[1]||0)),p=_/Y|0,p>1?(p>=u&&(p=u-1),g=n(oe,p,u),h=g.length,v=E.length,l=e(g,E,h,v),l==1&&(p--,t(g,H<h?Ae:oe,h,u))):(p==0&&(l=p=1),g=oe.slice()),h=g.length,h<v&&g.unshift(0),t(E,g,v,u),l==-1&&(v=E.length,l=e(oe,E,H,v),l<1&&(p++,t(E,H<v?Ae:oe,v,u))),v=E.length):l===0&&(p++,E=[0]),y[f++]=p,l&&E[0]?E[v++]=ce[B]||0:(E=[ce[B]],v=1);while((B++<L||E[0]!==void 0)&&N--);m=E[0]!==void 0}y[0]||y.shift()}if(d==1)x.e=c,_p=m;else{for(f=1,p=y[0];p>=10;p/=10)f++;x.e=f+c*d-1,F(x,a?o+x.e+1:o,s,m)}return x}})();I[Symbol.for("nodejs.util.inspect.custom")]=I.toString;I[Symbol.toStringTag]="Decimal";j=I.constructor=Rp(vu);qs=new j(qs);Fs=new j(Fs);So=j});function Lp(n){if(!Su){let t=`^[${["Zyyy","Zinh","Arab","Armn","Beng","Bopo","Cyrl","Deva","Ethi","Geor","Grek","Gujr","Guru","Hang","Hani","Hebr","Hira","Kana","Knda","Khmr","Laoo","Latn","Mlym","Mymr","Orya","Sinh","Taml","Telu","Thaa","Thai","Tibt"].map(i=>`\\p{Script=${i}}`).join("")}]*$`;Su=new RegExp(t,"u")}return Su.test(n)}function ze(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||Nr.test(n)?!0:Lp(n)?/^[\p{XIDS}_]\p{XIDC}*$/u.test(n):!1}function Gn(n){return typeof n!="string"?"not-a-string":n===""?"empty-string":n.normalize()!==n?"expected-nfc":/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(n)?"unexpected-bidi-marker":Nr.test(n)?"valid":/\p{XIDC}/u.test(n)&&wb.test(n)?"unexpected-mixed-emoji":Lp(n)?ze(n)?"valid":ze(n[0])?"invalid-char":"invalid-first-char":"unexpected-script"}var Su,Nb,Tb,Sb,Ib,Bb,Pp,Ab,Op,qp,wb,Nr,gi=k(()=>{Nb="\\u{FE0F}",Tb="\\u{20E3}",Sb="\\u{200D}",Ib="\\p{RI}\\p{RI}",Bb="(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})",Pp=`(?:\\p{EMod}|${Nb}${Tb}?|${Bb})`,Ab="(?:(?=\\P{XIDC})\\p{Emoji})",Op=`(?:${Ab}${Pp}*|\\p{Emoji}${Pp}+|${Ib})`,qp=`(?:${Op})(${Sb}${Op})*`,wb=new RegExp(`(?:${qp})+`,"u"),Nr=new RegExp(`^(?:${qp})+$`,"u")});function Fp(n){return typeof n!="string"?!1:hi.includes(n)}var zs,Iu,Zs,Hs,Bu,Au,hi,Tr=k(()=>{zs=["number","finite_number","complex","finite_complex","imaginary","real","finite_real","rational","finite_rational","integer","finite_integer","non_finite_number"],Iu=["indexed_collection","list","tuple"],Zs=[...Iu,"collection","set","record","dictionary"],Hs=["scalar",...zs,"boolean","string"],Bu=["value",...Zs,...Hs],Au=["expression","symbol","function",...Bu],hi=["any","unknown","nothing","never","error",...Au]});function Bo(n,e){return e==="any"||n==="never"?!0:n==="unknown"||e==="unknown"?!1:n===e?!0:kb[e].includes(n)}function A(n,e){if(typeof n=="string"&&(n=V(n)),typeof e=="string"&&(e=V(e)),e==="any")return!0;if(e==="never")return!1;if(e==="error")return n==="error";if(e==="nothing")return n==="nothing";if(n==="nothing")return!1;if(e==="unknown")return!0;if(n==="unknown")return!1;if(typeof e=="string")return typeof n=="string"?Bo(n,e):n.kind==="value"?typeof n.value=="boolean"?e==="boolean":typeof n.value=="number"?Number.isInteger(n.value)?Bo("integer",e):Bo("number",e):typeof n.value=="boolean"?Bo("boolean",e):typeof n.value=="string"?Bo("string",e):!1:n.kind==="union"?n.types.every(t=>A(t,e)):n.kind==="intersection"?n.types.some(t=>A(t,e)):n.kind==="negation"?!A(n.type,e):n.kind==="numeric"?!!A(n.type,e):e==="number"?Vp(n):e==="symbol"?wu(n):e==="expression"?Cb(n):e==="function"?zp(n):e==="scalar"?$p(n):e==="value"?Gp(n):e==="indexed_collection"?jp(n):e==="collection"?Up(n):e==="tuple"?n.kind==="tuple":e==="list"?n.kind==="list":e==="set"?n.kind==="set":e==="record"?n.kind==="record":e==="dictionary"?n.kind==="dictionary":!1;if(e.kind==="union")return typeof n!="string"&&n.kind==="union"?n.types.every(t=>e.types.some(i=>A(t,i))):e.types.some(t=>A(n,t));if(e.kind==="expression"){if(n==="symbol")return!0;if(typeof n=="string")return!1;if(n.kind==="expression")return e.operator==="Symbol"?wu(n):n.operator===e.operator;if(n.kind==="symbol")return!0}if(typeof n=="string")return!1;if(e.kind==="reference"){if(n.kind==="reference")return n.name===e.name;if(e.alias===!0&&e.def)return A(n,e.def)}if(n.kind==="union")return n.types.some(t=>A(t,e));if(n.kind==="intersection"&&e.kind==="intersection")return e.types.every(t=>n.types.some(i=>A(i,t)));if(n.kind==="intersection")return n.types.every(t=>A(t,e));if(e.kind==="intersection")return e.types.every(t=>A(n,t));if(n.kind==="signature"&&e.kind==="signature"){if(!A(n.result,e.result))return!1;if(n.optArgs||n.variadicArg){if(e.args){if(!n.args||n.args.length!==e.args.length)return!1;for(let t=0;t<e.args.length;t++)if(!A(e.args[t].type,n.args[t].type))return!1}else if(n.args)return!1;if(e.optArgs){if(!n.optArgs||n.optArgs.length!==e.optArgs.length)return!1;for(let t=0;t<n.optArgs.length;t++)if(!A(e.optArgs[t].type,n.optArgs[t].type))return!1}else if(n.optArgs)return!1;if(e.variadicArg){if(!n.variadicArg||n.variadicMin!=e.variadicMin||!A(e.variadicArg.type,n.variadicArg.type))return!1}else if(n.variadicArg)return!1}else{if(e.args&&!n.args)return!1;let t=0;if(e.args){if(n.args.length<e.args.length)return!1;for(;t<e.args.length;){if(!A(e.args[t].type,n.args[t].type))return!1;t+=1}}if(e.optArgs){if(t>=n.args.length)return!0;for(let i=0;i<e.optArgs.length;i++){if(!A(e.optArgs[i].type,n.args[t].type))return!1;if(t+=1,t>=n.args.length)return!0}}if(e.variadicArg){if(t>=n.args.length&&e.variadicMin===0)return!0;if(e.variadicMin>0&&t+e.variadicMin>n.args.length)return!1;for(;t<n.args.length;){if(!A(e.variadicArg.type,n.args[t].type))return!1;t+=1}}}return!0}if(n.kind==="record"&&e.kind==="record"){for(let t of Object.keys(e.elements))if(!(t in n.elements)||!A(n.elements[t],e.elements[t]))return!1;return!0}if(n.kind==="dictionary"&&e.kind==="dictionary")return A(n.values,e.values);if(e.kind==="indexed_collection")return n.kind==="indexed_collection"||n.kind==="list"?A(n.elements,e.elements):n.kind==="tuple"?n.elements.every(t=>A(t.type,e.elements)):!1;if(e.kind==="collection"){if(n.kind==="collection"||n.kind==="indexed_collection"||n.kind==="list")return A(n.elements,e.elements);if(n.kind==="tuple")return n.elements.every(t=>A(t.type,e.elements));if(n.kind==="set")return A(n.elements,e.elements);if(n.kind==="dictionary")return A(V(`tuple<string, ${te(n.values)}>`),e.elements);if(n.kind==="record")return A(V(`tuple<$string, ${te(ve(...Object.values(n.elements)))}>`),e.elements)}if(n.kind==="tuple"&&e.kind==="tuple"){if(n.elements.length!==e.elements.length)return!1;for(let t=0;t<n.elements.length;t++){let i=n.elements[t],r=e.elements[t];if(!A(i.type,r.type)||i.name!==r.name)return!1}return!0}if(e.kind==="list"&&n.kind==="list"){if(!A(n.elements,e.elements))return!1;if(e.dimensions){if(!n.dimensions||n.dimensions.length!==e.dimensions.length)return!1;for(let t=0;t<n.dimensions.length;t++)if(e.dimensions[t]!==-1&&n.dimensions[t]!==e.dimensions[t])return!1}return!0}if(n.kind==="symbol"&&e.kind==="symbol")return n.name===e.name;if(n.kind==="numeric"&&e.kind==="numeric")return!(!A(n.type,e.type)||(n.lower??-1/0)<(e.lower??-1/0)||(n.upper??1/0)>(e.upper??1/0));if(e.kind==="set"&&n.kind==="set")return!!A(n.elements,e.elements);if(n.kind==="negation"&&e.kind==="negation")return A(n.type,e.type);if(e.kind==="negation")return!A(n,e.type);if(e.kind==="value"&&n.kind==="value")return e.value===n.value;if(n.kind==="value"){if(typeof n.value=="boolean")return A("boolean",e);if(typeof n.value=="number")return Number.isInteger(n.value)?A("integer",e):A("real",e);if(typeof n.value=="string")return A("string",e)}return!1}function Vp(n){return typeof n=="string"?zs.includes(n):n.kind==="value"?typeof n.value=="number":n.kind==="numeric"}function $p(n){return Vp(n)?!0:typeof n=="string"?Hs.includes(n):n.kind==="value"?["string","boolean","number"].includes(typeof n.value):!1}function Up(n){return jp(n)?!0:typeof n=="string"?Zs.includes(n):["collection","set","record","dictionary"].includes(n.kind)}function jp(n){return typeof n=="string"?!1:["indexed_collection","list","tuple"].includes(n.kind)}function Gp(n){return $p(n)||Up(n)}function zp(n){return n==="function"||typeof n!="string"&&n.kind==="signature"}function Cb(n){return typeof n=="string"&&["expression","symbol","function"].includes(n)||Gp(n)||zp(n)||wu(n)?!0:typeof n=="string"?!1:n.kind==="expression"}function wu(n){return n==="symbol"?!0:typeof n=="string"?!1:n.kind==="symbol"?!0:n.kind==="expression"?n.operator==="Symbol":!1}var kb,Tn=k(()=>{Sn();Tr();xi();an();kb={number:zs,non_finite_number:[],finite_number:["finite_complex","finite_real","finite_integer","finite_rational"],complex:["finite_complex","imaginary","finite_real","finite_rational","finite_integer","non_finite_number"],finite_complex:["imaginary","finite_real","finite_rational","finite_integer"],imaginary:[],real:["rational","integer","finite_real","finite_rational","finite_integer","non_finite_number"],finite_real:["finite_rational","finite_integer"],rational:["finite_rational","finite_integer","integer","non_finite_number"],finite_rational:["finite_integer"],integer:["finite_integer","non_finite_number"],finite_integer:[],any:hi,unknown:[],nothing:[],never:[],error:[],value:Bu,scalar:Hs,collection:Zs,indexed_collection:Iu,list:[],set:[],tuple:[],record:[],dictionary:[],function:[],symbol:[],boolean:[],string:[],expression:Au}});function te(n,e=0){if(typeof n=="string")return n;let t="";switch(n.kind){case"value":typeof n.value=="string"?t=`"${n.value}"`:typeof n.value=="boolean"?t=n.value?"true":"false":t=n.value.toString();break;case"reference":t=n.name;break;case"negation":t=`!${te(n.type,Hp)}`;break;case"union":t=n.types.map(u=>te(u,Wp)).join(" | ");break;case"intersection":t=n.types.map(u=>te(u,Jp)).join(" & ");break;case"expression":t=`expression<${Zp(n.operator)}>`;break;case"symbol":t=`symbol<${Zp(n.name)}>`;break;case"numeric":Number.isFinite(n.lower)&&Number.isFinite(n.upper)?t=`${n.type}<${n.lower}..${n.upper}>`:Number.isFinite(n.lower)?t=`${n.type}<${n.lower}..>`:Number.isFinite(n.upper)?t=`${n.type}<..${n.upper}>`:t=`${n.type}`;break;case"list":if(n.dimensions&&A(n.elements,"number")){if(n.dimensions===void 0)n.elements==="number"&&(t="tensor");else if(n.dimensions.length===1)n.elements==="number"?n.dimensions[0]<0?t="vector":t=`vector<${n.dimensions[0]}>`:n.dimensions[0]<0?t=`vector<${te(n.elements)}>`:t=`vector<${te(n.elements)}^${n.dimensions[0]}>`;else if(n.dimensions.length===2){let u=n.dimensions;n.elements==="number"?u[0]<0&&u[1]<0?t="matrix":t=`matrix<${u[0]}x${u[1]}>`:u[0]<0&&u[1]<0?t=`matrix<${te(n.elements)}>`:t=`matrix<${te(n.elements)}^(${u[0]}x${u[1]})>`}}if(!t){let u=n.dimensions?n.dimensions.length===1?`^${n.dimensions[0].toString()}`:`^(${n.dimensions.join("x")})`:"";t=`list<${te(n.elements)}${u}>`}break;case"record":t=`record<${Object.entries(n.elements).map(([u,l])=>`${u}: ${te(l)}`).join(", ")}>`;break;case"dictionary":t=`dictionary<${te(n.values)}>`;break;case"set":t=`set<${te(n.elements)}>`;break;case"collection":t=`collection<${te(n.elements)}>`;break;case"indexed_collection":t=`indexed_collection<${te(n.elements)}>`;break;case"tuple":if(n.elements.length===0)t="tuple";else if(n.elements.length===1){let[u]=n.elements;t=`tuple<${Sr(u)}>`}else t="tuple<"+n.elements.map(u=>Sr(u)).join(", ")+">";break;case"signature":let r=n.args?n.args.map(u=>Sr(u)).join(", "):"",o=n.optArgs?n.optArgs.map(u=>Sr(u)+"?").join(", "):"",s=n.variadicArg?n.variadicMin===0?`${Sr(n.variadicArg)}*`:`${Sr(n.variadicArg)}+`:"";t=`(${[r,o,s].filter(u=>u).join(", ")}) -> ${te(n.result)}`;break;default:t="error"}return e>0&&e>Vb(n.kind)?`(${t})`:t}function Sr(n){return n.name?`${n.name}: ${te(n.type)}`:te(n.type)}function Zp(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)?n:`\`${n}\``}function Vb(n){switch(n){case"negation":return Hp;case"union":return Wp;case"intersection":return Jp;case"list":return Rb;case"record":return Mb;case"dictionary":return Db;case"set":return Pb;case"collection":case"indexed_collection":return Ob;case"tuple":return Lb;case"signature":return qb;case"value":return Fb;default:return 0}}var Hp,Wp,Jp,Rb,Mb,Db,Pb,Ob,Lb,qb,Fb,xi=k(()=>{Tn();Hp=3,Wp=1,Jp=2,Rb=4,Mb=5,Db=6,Pb=7,Ob=8,Lb=9,qb=10,Fb=11});function $b(n,e){if(n===e)return 0;if(n.length===0)return e.length;if(e.length===0)return n.length;let t=Array.from({length:n.length+1},(r,o)=>o),i=new Array(n.length+1);for(let r=1;r<=e.length;r++){i[0]=r;for(let o=1;o<=n.length;o++){let s=n[o-1]===e[r-1]?0:1;i[o]=Math.min(t[o]+1,i[o-1]+1,t[o-1]+s)}[t,i]=[i,t]}return t[n.length]}function Ws(n,e){let i=null,r=1/0,o=n.length;for(let s of e){if(Math.abs(o-s.length)>7)continue;let a=$b(n,s);if(a===0)return s;a<=7&&a<r&&(r=a,i=s)}return i}var ku=k(()=>{});var Js,Yp=k(()=>{Js=class{input;pos=0;line=1;column=1;tokens=[];constructor(e){this.input=e}saveState(){return{pos:this.pos,line:this.line,column:this.column,tokens:[...this.tokens]}}restoreState(e){this.pos=e.pos,this.line=e.line,this.column=e.column,this.tokens=e.tokens}error(e){throw new Error(`Lexer error at line ${this.line}, column ${this.column}: ${e}`)}peek(e=0){let t=this.pos+e;return t<this.input.length?this.input[t]:""}advance(){let e=this.input[this.pos++];return e===`
|
|
4
4
|
`?(this.line++,this.column=1):this.column++,e}match(e){if(this.input.slice(this.pos,this.pos+e.length)===e){for(let t=0;t<e.length;t++)this.advance();return!0}return!1}isEOF(){return this.pos>=this.input.length}skipWhitespace(){for(;!this.isEOF()&&/\s/.test(this.peek());)this.advance()}readIdentifier(){let e="";for(;!this.isEOF()&&/[a-zA-Z0-9_]/.test(this.peek());)e+=this.advance();return e}readVerbatimString(){if(!this.match("`"))return"";let e="";for(;!this.isEOF()&&this.peek()!=="`";)this.match("\\`")?e+="`":this.match("\\\\")?e+="\\":e+=this.advance();return this.isEOF()&&this.error("Unterminated verbatim string"),this.advance(),e}readStringLiteral(){let e=this.advance(),t="";for(;!this.isEOF()&&this.peek()!==e;)this.match("\\"+e)?t+=e:this.match("\\\\")?t+="\\":t+=this.advance();return this.isEOF()&&this.error("Unterminated string literal"),this.advance(),t}readNumber(){let e="";if((this.peek()==="-"||this.peek()==="+")&&(e+=this.advance()),this.match("0x")||this.match("0X")){for(e+="x";!this.isEOF()&&/[0-9a-fA-F]/.test(this.peek());)e+=this.advance();return"0"+e}if(this.match("0b")||this.match("0B")){for(e+="b";!this.isEOF()&&/[01]/.test(this.peek());)e+=this.advance();return"0"+e}for(;!this.isEOF()&&/[0-9]/.test(this.peek());)e+=this.advance();if(this.peek()==="."&&/[0-9]/.test(this.peek(1)))for(e+=this.advance();!this.isEOF()&&/[0-9]/.test(this.peek());)e+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(e+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(e+=this.advance());!this.isEOF()&&/[0-9]/.test(this.peek());)e+=this.advance();return e}createToken(e,t){return{type:e,value:t,position:this.pos-t.length,line:this.line,column:this.column-t.length}}nextToken(){if(this.skipWhitespace(),this.isEOF())return this.createToken("EOF","");let e=this.pos,t=this.peek();if(this.match("->"))return this.createToken("->","->");if(this.match(".."))return this.createToken("..","..");if(this.match("+\u221E")||this.match("+oo"))return this.createToken("PLUS_INFINITY",this.input.slice(e,this.pos));if(this.match("-\u221E")||this.match("-oo"))return this.createToken("MINUS_INFINITY",this.input.slice(e,this.pos));if(this.match("+infinity"))return this.createToken("PLUS_INFINITY","+infinity");if(this.match("-infinity"))return this.createToken("MINUS_INFINITY","-infinity");if(/[a-zA-Z_]/.test(t)){let i=this.readIdentifier();switch(i){case"true":return this.createToken("TRUE",i);case"false":return this.createToken("FALSE",i);case"nan":return this.createToken("NAN",i);case"infinity":return this.createToken("INFINITY",i);case"oo":return this.createToken("INFINITY",i);default:return this.createToken("IDENTIFIER",i)}}switch(t){case"|":return this.advance(),this.createToken("|","|");case"&":return this.advance(),this.createToken("&","&");case"!":return this.advance(),this.createToken("!","!");case"^":return this.advance(),this.createToken("^","^");case"(":return this.advance(),this.createToken("(","(");case")":return this.advance(),this.createToken(")",")");case"<":return this.advance(),this.createToken("<","<");case">":return this.advance(),this.createToken(">",">");case"[":return this.advance(),this.createToken("[","[");case"]":return this.advance(),this.createToken("]","]");case",":return this.advance(),this.createToken(",",",");case":":return this.advance(),this.createToken(":",":");case"?":return this.advance(),this.createToken("?","?");case"*":return this.advance(),this.createToken("*","*");case"+":return/[0-9]/.test(this.peek(1))?this.createToken("NUMBER_LITERAL",this.readNumber()):(this.advance(),this.createToken("+","+"));case"x":return/[0-9]/.test(this.peek(1))?(this.advance(),this.createToken("x","x")):(this.advance(),this.createToken("x","x"))}if(t==='"'||t==="'")return this.createToken("STRING_LITERAL",this.readStringLiteral());if(t==="`")return this.createToken("VERBATIM_STRING",this.readVerbatimString());if(/[0-9]/.test(t)||t==="-"&&/[0-9]/.test(this.peek(1))){let i=this.readNumber();return this.peek()==="x"&&/[0-9]/.test(this.peek(1)),this.createToken("NUMBER_LITERAL",i)}if(t==="\u221E")return this.advance(),this.createToken("INFINITY","\u221E");this.error(`Unexpected character: ${t}`)}tokenize(){let e=[];for(;!this.isEOF();){let t=this.nextToken();if(t&&(e.push(t),t.type==="EOF"))break}return e}peekToken(){if(this.tokens.length===0){let e=this.nextToken();e&&this.tokens.push(e)}return this.tokens[0]||this.createToken("EOF","")}consumeToken(){if(this.tokens.length===0){let e=this.nextToken();if(e)return e}return this.tokens.shift()||this.createToken("EOF","")}matchToken(e){return this.peekToken().type===e?(this.consumeToken(),!0):!1}expectToken(e){let t=this.consumeToken();return t.type!==e&&this.error(`Expected ${e}, got ${t.type}`),t}}});var Ys,Qp=k(()=>{Yp();Tr();Ys=class{lexer;typeResolver;current;constructor(e,t){this.lexer=new Js(e),this.typeResolver=t?.typeResolver??{forward:()=>{},resolve:()=>{},get names(){return[]}},this.current=this.lexer.consumeToken()}error(e,t){this.errorAtToken(this.current,e,t)}errorAtToken(e,t,i){let r=this.lexer.input,s=r.split(`
|
|
@@ -121,7 +121,7 @@ Error in definition of "${i}"`,"",JSON.stringify(r,void 0,4),"",o.message].join(
|
|
|
121
121
|
`),u+=`void main() {
|
|
122
122
|
`;for(let f of a){let p=this.compile(f.expression);u+=` ${f.variable} = ${p};
|
|
123
123
|
`}return u+=`}
|
|
124
|
-
`,u}};Mt();function M(n){return{kind:"interval",value:n}}function ff(n){return{lo:n,hi:n}}function dn(n,e,t){let i=Math.ceil((n.lo-e)/t),r=e+i*t,o=1e-15;return r>=n.lo-o&&r<=n.hi+o}function _o(n,e){if(n.kind==="empty")return e;if(e.kind==="empty")return n;if(n.kind==="singular"||e.kind==="singular")return{kind:"singular"};if(n.kind==="entire"||e.kind==="entire")return{kind:"entire"};let t=n.value,i=e.value,r=n.kind==="partial"?n.domainClipped:null,o=e.kind==="partial"?e.domainClipped:null,s={lo:Math.min(t.lo,i.lo),hi:Math.max(t.hi,i.hi)};if(r||o){let a=au(r,o);return{kind:"partial",value:s,domainClipped:a}}return{kind:"interval",value:s}}function au(n,e){return n==="both"||e==="both"?"both":n===null?e:e===null||n===e?n:"both"}function pf(n){return n.lo===n.hi}function En(n){return n.lo<=0&&n.hi>=0}function df(n){return n.lo>0}function ks(n){return n.hi<0}function mf(n){return n.lo>=0}function gf(n){return n.hi<=0}function hf(n){return n.hi-n.lo}function xf(n){return(n.lo+n.hi)/2}function yf(n){if(n.kind==="interval"||n.kind==="partial")return n.value}function bf(n){return"kind"in n?n.kind==="interval"||n.kind==="partial"?n.value:void 0:n}function P(...n){let e=[];for(let t of n)if("kind"in t){if(t.kind==="empty")return{kind:"empty"};if(t.kind==="entire")return{kind:"entire"};if(t.kind==="singular")return t;e.push(t.value)}else e.push(t);return e}function vf(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;return M({lo:i.lo+r.lo,hi:i.hi+r.hi})}function Ef(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;return M({lo:i.lo-r.hi,hi:i.hi-r.lo})}function _f(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return M({lo:-t.hi,hi:-t.lo})}function Nf(n,e){let t=[n.lo*e.lo,n.lo*e.hi,n.hi*e.lo,n.hi*e.hi];return{lo:Math.min(...t),hi:Math.max(...t)}}function Tf(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;return M(Nf(i,r))}function Un(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;return A_(i,r)}function A_(n,e){return e.lo>0||e.hi<0?M(Nf(n,{lo:1/e.hi,hi:1/e.lo})):e.lo<0&&e.hi>0?{kind:"singular"}:e.lo===0&&e.hi>0?n.lo>=0?{kind:"partial",value:{lo:n.lo/e.hi,hi:1/0},domainClipped:"hi"}:n.hi<=0?{kind:"partial",value:{lo:-1/0,hi:n.hi/e.hi},domainClipped:"lo"}:{kind:"entire"}:e.hi===0&&e.lo<0?n.lo>=0?{kind:"partial",value:{lo:-1/0,hi:n.lo/e.lo},domainClipped:"lo"}:n.hi<=0?{kind:"partial",value:{lo:n.hi/e.lo,hi:1/0},domainClipped:"hi"}:{kind:"entire"}:{kind:"empty"}}function Sf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return w_(t)}function w_(n){return n.hi<0?{kind:"empty"}:n.lo>=0?M({lo:Math.sqrt(n.lo),hi:Math.sqrt(n.hi)}):{kind:"partial",value:{lo:0,hi:Math.sqrt(n.hi)},domainClipped:"lo"}}function If(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.lo>=0?M({lo:t.lo*t.lo,hi:t.hi*t.hi}):t.hi<=0?M({lo:t.hi*t.hi,hi:t.lo*t.lo}):M({lo:0,hi:Math.max(t.lo*t.lo,t.hi*t.hi)})}function gy(n,e){return e===0?{lo:1,hi:1}:e===1?n:e%2===0?n.lo>=0?{lo:Math.pow(n.lo,e),hi:Math.pow(n.hi,e)}:n.hi<=0?{lo:Math.pow(n.hi,e),hi:Math.pow(n.lo,e)}:{lo:0,hi:Math.max(Math.pow(n.lo,e),Math.pow(n.hi,e))}:{lo:Math.pow(n.lo,e),hi:Math.pow(n.hi,e)}}function Bf(n,e){let t=P(n);if(!Array.isArray(t))return t;let[i]=t;if(Number.isInteger(e)){if(e>=0)return M(gy(i,e));{if(En(i))return{kind:"singular"};let r=gy(i,-e);return M({lo:1/r.hi,hi:1/r.lo})}}else return ks(i)?{kind:"empty"}:i.lo<0?{kind:"partial",value:e>0?{lo:0,hi:Math.pow(i.hi,e)}:{lo:Math.pow(i.hi,e),hi:1/0},domainClipped:"lo"}:e>0?M({lo:Math.pow(i.lo,e),hi:Math.pow(i.hi,e)}):i.lo===0?{kind:"partial",value:{lo:Math.pow(i.hi,e),hi:1/0},domainClipped:"hi"}:M({lo:Math.pow(i.hi,e),hi:Math.pow(i.lo,e)})}function Af(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;if(i.hi<=0)return{kind:"empty"};if(i.lo<=0){let s={lo:Math.max(i.lo,Number.EPSILON),hi:i.hi},a=[Math.pow(s.lo,r.lo),Math.pow(s.lo,r.hi),Math.pow(s.hi,r.lo),Math.pow(s.hi,r.hi)];return{kind:"partial",value:{lo:Math.min(...a),hi:Math.max(...a)},domainClipped:"lo"}}let o=[Math.pow(i.lo,r.lo),Math.pow(i.lo,r.hi),Math.pow(i.hi,r.lo),Math.pow(i.hi,r.hi)];return M({lo:Math.min(...o),hi:Math.max(...o)})}function wf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return M({lo:Math.exp(t.lo),hi:Math.exp(t.hi)})}function kf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.hi<=0?{kind:"empty"}:t.lo>0?M({lo:Math.log(t.lo),hi:Math.log(t.hi)}):{kind:"partial",value:{lo:-1/0,hi:Math.log(t.hi)},domainClipped:"lo"}}function Cf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.hi<=0?{kind:"empty"}:t.lo>0?M({lo:Math.log10(t.lo),hi:Math.log10(t.hi)}):{kind:"partial",value:{lo:-1/0,hi:Math.log10(t.hi)},domainClipped:"lo"}}function Rf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.hi<=0?{kind:"empty"}:t.lo>0?M({lo:Math.log2(t.lo),hi:Math.log2(t.hi)}):{kind:"partial",value:{lo:-1/0,hi:Math.log2(t.hi)},domainClipped:"lo"}}function Mf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.lo>=0?M(t):t.hi<=0?M({lo:-t.hi,hi:-t.lo}):M({lo:0,hi:Math.max(-t.lo,t.hi)})}function Df(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e,i=Math.floor(t.lo),r=Math.floor(t.hi);return i===r?M({lo:i,hi:r}):{kind:"singular",at:i+1}}function Pf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e,i=Math.ceil(t.lo),r=Math.ceil(t.hi);return i===r?M({lo:i,hi:r}):{kind:"singular",at:i}}function Of(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e,i=Math.round(t.lo),r=Math.round(t.hi);return i===r?M({lo:i,hi:r}):{kind:"singular",at:i+.5}}function Lf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e,i=Math.floor(t.lo),r=Math.floor(t.hi);return i===r?M({lo:t.lo-i,hi:t.hi-i}):{kind:"singular",at:i+1}}function qf(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;return M({lo:Math.min(i.lo,r.lo),hi:Math.min(i.hi,r.hi)})}function Ff(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;return M({lo:Math.max(i.lo,r.lo),hi:Math.max(i.hi,r.hi)})}function Vf(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;if(En(r))return{kind:"singular"};let o=Math.abs(r.lo===r.hi?r.lo:Math.max(Math.abs(r.lo),Math.abs(r.hi))),s=Math.floor(i.lo/o),a=Math.floor(i.hi/o);if(s!==a)return{kind:"singular",at:(s+1)*o};let u=i.lo-o*s,l=i.hi-o*s;return M({lo:Math.min(u,l),hi:Math.max(u,l)})}function $f(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.lo>0?M({lo:1,hi:1}):t.hi<0?M({lo:-1,hi:-1}):t.lo===0&&t.hi===0?M({lo:0,hi:0}):{kind:"singular",at:0}}var qt=2*Math.PI,je=Math.PI,Vi=Math.PI/2,hy=3*Math.PI/2;function Uf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.hi-t.lo>=qt)return M({lo:-1,hi:1});let i=Math.sin(t.lo),r=Math.sin(t.hi),o=Math.min(i,r),s=Math.max(i,r);return dn(t,Vi,qt)&&(s=1),dn(t,hy,qt)&&(o=-1),M({lo:o,hi:s})}function jf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.hi-t.lo>=qt)return M({lo:-1,hi:1});let i=Math.cos(t.lo),r=Math.cos(t.hi),o=Math.min(i,r),s=Math.max(i,r);return dn(t,0,qt)&&(s=1),dn(t,je,qt)&&(o=-1),M({lo:o,hi:s})}function Gf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.hi-t.lo>=je)return{kind:"singular"};if(dn(t,Vi,je)){let o=Math.ceil((t.lo-Vi)/je);return{kind:"singular",at:Vi+o*je}}let i=Math.tan(t.lo),r=Math.tan(t.hi);return i>1e10&&r<-1e10||i<-1e10&&r>1e10?{kind:"singular"}:M({lo:i,hi:r})}function zf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.hi-t.lo>=je)return{kind:"singular"};if(dn(t,0,je))return{kind:"singular",at:Math.ceil(t.lo/je)*je};let i=1/Math.tan(t.lo),r=1/Math.tan(t.hi);return M({lo:Math.min(i,r),hi:Math.max(i,r)})}function Zf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.hi-t.lo>=je)return{kind:"singular"};if(dn(t,Vi,je)){let a=Math.ceil((t.lo-Vi)/je);return{kind:"singular",at:Vi+a*je}}let i=1/Math.cos(t.lo),r=1/Math.cos(t.hi),o=Math.min(i,r),s=Math.max(i,r);return dn(t,0,qt)&&(o=Math.min(o,1),s=Math.max(s,1)),dn(t,je,qt)&&(o=Math.min(o,-1),s=Math.max(s,-1)),M({lo:o,hi:s})}function Hf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.hi-t.lo>=je)return{kind:"singular"};if(dn(t,0,je))return{kind:"singular",at:Math.ceil(t.lo/je)*je};let i=1/Math.sin(t.lo),r=1/Math.sin(t.hi),o=Math.min(i,r),s=Math.max(i,r);return dn(t,Vi,qt)&&(o=Math.min(o,1),s=Math.max(s,1)),dn(t,hy,qt)&&(o=Math.min(o,-1),s=Math.max(s,-1)),M({lo:o,hi:s})}function uu(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.lo>1||t.hi<-1)return{kind:"empty"};if(t.lo<-1||t.hi>1){let i=Math.max(t.lo,-1),r=Math.min(t.hi,1);return{kind:"partial",value:{lo:Math.asin(i),hi:Math.asin(r)},domainClipped:t.lo<-1&&t.hi>1?"both":t.lo<-1?"lo":"hi"}}return M({lo:Math.asin(t.lo),hi:Math.asin(t.hi)})}function lu(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.lo>1||t.hi<-1)return{kind:"empty"};if(t.lo<-1||t.hi>1){let i=Math.max(t.lo,-1),r=Math.min(t.hi,1);return{kind:"partial",value:{lo:Math.acos(r),hi:Math.acos(i)},domainClipped:t.lo<-1&&t.hi>1?"both":t.lo<-1?"lo":"hi"}}return M({lo:Math.acos(t.hi),hi:Math.acos(t.lo)})}function cu(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return M({lo:Math.atan(t.lo),hi:Math.atan(t.hi)})}function Wf(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;if(i.lo===i.hi&&r.lo===r.hi){let s=Math.atan2(i.lo,r.lo);return M({lo:s,hi:s})}let o=[];return o.push(Math.atan2(i.lo,r.lo)),o.push(Math.atan2(i.lo,r.hi)),o.push(Math.atan2(i.hi,r.lo)),o.push(Math.atan2(i.hi,r.hi)),r.lo<0&&i.lo<0&&i.hi>0?M({lo:-je,hi:je}):M({lo:Math.min(...o),hi:Math.max(...o)})}function Cs(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return M({lo:Math.sinh(t.lo),hi:Math.sinh(t.hi)})}function Rs(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.lo>=0?M({lo:Math.cosh(t.lo),hi:Math.cosh(t.hi)}):t.hi<=0?M({lo:Math.cosh(t.hi),hi:Math.cosh(t.lo)}):M({lo:1,hi:Math.max(Math.cosh(t.lo),Math.cosh(t.hi))})}function Jf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return M({lo:Math.tanh(t.lo),hi:Math.tanh(t.hi)})}function fu(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return M({lo:Math.asinh(t.lo),hi:Math.asinh(t.hi)})}function pu(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.hi<1?{kind:"empty"}:t.lo<1?{kind:"partial",value:{lo:0,hi:Math.acosh(t.hi)},domainClipped:"lo"}:M({lo:Math.acosh(t.lo),hi:Math.acosh(t.hi)})}function du(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.lo>=1||t.hi<=-1)return{kind:"empty"};if(t.lo<=-1||t.hi>=1){let i=Math.max(t.lo,-1+Number.EPSILON),r=Math.min(t.hi,1-Number.EPSILON);return{kind:"partial",value:{lo:Math.atanh(i),hi:Math.atanh(r)},domainClipped:t.lo<=-1&&t.hi>=1?"both":t.lo<=-1?"lo":"hi"}}return M({lo:Math.atanh(t.lo),hi:Math.atanh(t.hi)})}function Yf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:cu(Un(M({lo:1,hi:1}),M(t)))}function Qf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:uu(Un(M({lo:1,hi:1}),M(t)))}function Xf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:lu(Un(M({lo:1,hi:1}),M(t)))}function Kf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:Un(Rs(t),Cs(t))}function ep(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:Un(M({lo:1,hi:1}),Cs(t))}function np(n){return Un(M({lo:1,hi:1}),Rs(n))}function tp(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:du(Un(M({lo:1,hi:1}),M(t)))}function ip(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:fu(Un(M({lo:1,hi:1}),M(t)))}function rp(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:pu(Un(M({lo:1,hi:1}),M(t)))}function op(n,e){let t=P(n,e);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.hi<r.lo?"true":i.lo>=r.hi?"false":"maybe"}function sp(n,e){let t=P(n,e);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.hi<=r.lo?"true":i.lo>r.hi?"false":"maybe"}function ap(n,e){let t=P(n,e);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.lo>r.hi?"true":i.hi<=r.lo?"false":"maybe"}function up(n,e){let t=P(n,e);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.lo>=r.hi?"true":i.hi<r.lo?"false":"maybe"}function mu(n,e){let t=P(n,e);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.lo===i.hi&&r.lo===r.hi&&i.lo===r.lo?"true":i.hi<r.lo||r.hi<i.lo?"false":"maybe"}function lp(n,e){let t=mu(n,e);return t==="true"?"false":t==="false"?"true":"maybe"}function cp(n,e){return n==="false"||e==="false"?"false":n==="true"&&e==="true"?"true":"maybe"}function fp(n,e){return n==="true"||e==="true"?"true":n==="false"&&e==="false"?"false":"maybe"}function pp(n){return n==="true"?"false":n==="false"?"true":"maybe"}function dp(n,e,t,i){if(n==="true"||n==="false"||n==="maybe"){let f=n,p=e,d=t;switch(f){case"true":return p();case"false":return d();case"maybe":return _o(p(),d())}}let r=n,o=e,s=t,a=i,u=P(r);if(!Array.isArray(u))return u;let[l]=u;switch(o(l)){case"true":return s(l);case"false":return a(l);case"maybe":let f=s(l),p=a(l);return _o(f,p)}}function mp(n,e,t){let i=P(n,e,t);if(!Array.isArray(i))return i;let[r,o,s]=i,a=Math.max(r.lo,o.lo),u=Math.min(r.hi,s.hi);return a>u?{kind:"empty"}:{kind:"interval",value:{lo:a,hi:u}}}var xy={ok:M,point:ff,containsExtremum:dn,unionResults:_o,mergeDomainClip:au,isPoint:pf,containsZero:En,isPositive:df,isNegative:ks,isNonNegative:mf,isNonPositive:gf,width:hf,midpoint:xf,getValue:yf,unwrap:bf,unwrapOrPropagate:P,add:vf,sub:Ef,mul:Tf,div:Un,negate:_f,sqrt:Sf,square:If,pow:Bf,powInterval:Af,exp:wf,ln:kf,log10:Cf,log2:Rf,abs:Mf,floor:Df,ceil:Pf,round:Of,fract:Lf,min:qf,max:Ff,mod:Vf,sign:$f,sin:Uf,cos:jf,tan:Gf,cot:zf,sec:Zf,csc:Hf,asin:uu,acos:lu,atan:cu,atan2:Wf,sinh:Cs,cosh:Rs,tanh:Jf,asinh:fu,acosh:pu,atanh:du,acot:Yf,acsc:Qf,asec:Xf,coth:Kf,csch:ep,sech:np,acoth:tp,acsch:ip,asech:rp,less:op,lessEqual:sp,greater:ap,greaterEqual:up,equal:mu,notEqual:lp,and:cp,or:fp,not:pp,piecewise:dp,clamp:mp};var k_={Add:["_IA.add",20],Negate:["_IA.negate",20],Subtract:["_IA.sub",20],Multiply:["_IA.mul",20],Divide:["_IA.div",20],Equal:["_IA.equal",20],NotEqual:["_IA.notEqual",20],LessEqual:["_IA.lessEqual",20],GreaterEqual:["_IA.greaterEqual",20],Less:["_IA.less",20],Greater:["_IA.greater",20],And:["_IA.and",20],Or:["_IA.or",20],Not:["_IA.not",20]},gp={Add:(n,e)=>{if(n.length===0)return"_IA.point(0)";if(n.length===1)return e(n[0]);let t=e(n[0]);for(let i=1;i<n.length;i++)t=`_IA.add(${t}, ${e(n[i])})`;return t},Subtract:(n,e)=>{if(n.length===0)return"_IA.point(0)";if(n.length===1)return`_IA.negate(${e(n[0])})`;if(n.length===2)return`_IA.sub(${e(n[0])}, ${e(n[1])})`;let t=e(n[0]);for(let i=1;i<n.length;i++)t=`_IA.sub(${t}, ${e(n[i])})`;return t},Multiply:(n,e)=>{if(n.length===0)return"_IA.point(1)";if(n.length===1)return e(n[0]);let t=e(n[0]);for(let i=1;i<n.length;i++)t=`_IA.mul(${t}, ${e(n[i])})`;return t},Divide:(n,e)=>{if(n.length===0)return"_IA.point(1)";if(n.length===1)return e(n[0]);if(n.length===2)return`_IA.div(${e(n[0])}, ${e(n[1])})`;let t=e(n[0]);for(let i=1;i<n.length;i++)t=`_IA.div(${t}, ${e(n[i])})`;return t},Negate:(n,e)=>`_IA.negate(${e(n[0])})`,Abs:(n,e)=>`_IA.abs(${e(n[0])})`,Ceiling:(n,e)=>`_IA.ceil(${e(n[0])})`,Exp:(n,e)=>`_IA.exp(${e(n[0])})`,Floor:(n,e)=>`_IA.floor(${e(n[0])})`,Ln:(n,e)=>`_IA.ln(${e(n[0])})`,Log:(n,e)=>n.length===1?`_IA.log10(${e(n[0])})`:`_IA.div(_IA.ln(${e(n[0])}), _IA.ln(${e(n[1])}))`,Lb:(n,e)=>`_IA.log2(${e(n[0])})`,Max:(n,e)=>{if(n.length===0)return"_IA.point(-Infinity)";if(n.length===1)return e(n[0]);let t=e(n[0]);for(let i=1;i<n.length;i++)t=`_IA.max(${t}, ${e(n[i])})`;return t},Min:(n,e)=>{if(n.length===0)return"_IA.point(Infinity)";if(n.length===1)return e(n[0]);let t=e(n[0]);for(let i=1;i<n.length;i++)t=`_IA.min(${t}, ${e(n[i])})`;return t},Power:(n,e)=>{let t=n[0],i=n[1];if(t===null)throw new Error("Power: no argument");if(t.symbol==="ExponentialE")return`_IA.exp(${e(i)})`;if(i?.isNumberLiteral&&i.im===0){let r=i.re;return r===.5?`_IA.sqrt(${e(t)})`:r===2?`_IA.square(${e(t)})`:`_IA.pow(${e(t)}, ${r})`}return`_IA.powInterval(${e(t)}, ${e(i)})`},Root:(n,e)=>{let[t,i]=n;if(t===null)throw new Error("Root: no argument");return i===null?`_IA.sqrt(${e(t)})`:i?.re===2?`_IA.sqrt(${e(t)})`:i?.isNumberLiteral&&i.im===0?`_IA.pow(${e(t)}, ${1/i.re})`:`_IA.powInterval(${e(t)}, _IA.div(_IA.point(1), ${e(i)}))`},Round:(n,e)=>`_IA.round(${e(n[0])})`,Sgn:(n,e)=>`_IA.sign(${e(n[0])})`,Sqrt:(n,e)=>`_IA.sqrt(${e(n[0])})`,Square:(n,e)=>`_IA.square(${e(n[0])})`,Sin:(n,e)=>`_IA.sin(${e(n[0])})`,Cos:(n,e)=>`_IA.cos(${e(n[0])})`,Tan:(n,e)=>`_IA.tan(${e(n[0])})`,Cot:(n,e)=>`_IA.cot(${e(n[0])})`,Sec:(n,e)=>`_IA.sec(${e(n[0])})`,Csc:(n,e)=>`_IA.csc(${e(n[0])})`,Arcsin:(n,e)=>`_IA.asin(${e(n[0])})`,Arccos:(n,e)=>`_IA.acos(${e(n[0])})`,Arctan:(n,e)=>`_IA.atan(${e(n[0])})`,Arccot:(n,e)=>`_IA.acot(${e(n[0])})`,Arccsc:(n,e)=>`_IA.acsc(${e(n[0])})`,Arcsec:(n,e)=>`_IA.asec(${e(n[0])})`,Sinh:(n,e)=>`_IA.sinh(${e(n[0])})`,Cosh:(n,e)=>`_IA.cosh(${e(n[0])})`,Tanh:(n,e)=>`_IA.tanh(${e(n[0])})`,Coth:(n,e)=>`_IA.coth(${e(n[0])})`,Csch:(n,e)=>`_IA.csch(${e(n[0])})`,Sech:(n,e)=>`_IA.sech(${e(n[0])})`,Arsinh:(n,e)=>`_IA.asinh(${e(n[0])})`,Arcosh:(n,e)=>`_IA.acosh(${e(n[0])})`,Artanh:(n,e)=>`_IA.atanh(${e(n[0])})`,Arcoth:(n,e)=>`_IA.acoth(${e(n[0])})`,Arcsch:(n,e)=>`_IA.acsch(${e(n[0])})`,Arsech:(n,e)=>`_IA.asech(${e(n[0])})`,Asin:(n,e)=>`_IA.asin(${e(n[0])})`,Acos:(n,e)=>`_IA.acos(${e(n[0])})`,Atan:(n,e)=>`_IA.atan(${e(n[0])})`,Fract:(n,e)=>`_IA.fract(${e(n[0])})`,Mod:(n,e)=>`_IA.mod(${e(n[0])}, ${e(n[1])})`,If:(n,e)=>{if(n.length!==3)throw new Error("If: wrong number of arguments");return`_IA.piecewise(
|
|
124
|
+
`,u}};Mt();function M(n){return{kind:"interval",value:n}}function ff(n){return{lo:n,hi:n}}function dn(n,e,t){let i=Math.ceil((n.lo-e)/t),r=e+i*t,o=1e-15;return r>=n.lo-o&&r<=n.hi+o}function _o(n,e){if(n.kind==="empty")return e;if(e.kind==="empty")return n;if(n.kind==="singular"||e.kind==="singular")return{kind:"singular"};if(n.kind==="entire"||e.kind==="entire")return{kind:"entire"};let t=n.value,i=e.value,r=n.kind==="partial"?n.domainClipped:null,o=e.kind==="partial"?e.domainClipped:null,s={lo:Math.min(t.lo,i.lo),hi:Math.max(t.hi,i.hi)};if(r||o){let a=au(r,o);return{kind:"partial",value:s,domainClipped:a}}return{kind:"interval",value:s}}function au(n,e){return n==="both"||e==="both"?"both":n===null?e:e===null||n===e?n:"both"}function pf(n){return n.lo===n.hi}function En(n){return n.lo<=0&&n.hi>=0}function df(n){return n.lo>0}function ks(n){return n.hi<0}function mf(n){return n.lo>=0}function gf(n){return n.hi<=0}function hf(n){return n.hi-n.lo}function xf(n){return(n.lo+n.hi)/2}function yf(n){if(n.kind==="interval"||n.kind==="partial")return n.value}function bf(n){return"kind"in n?n.kind==="interval"||n.kind==="partial"?n.value:void 0:n}function P(...n){let e=[];for(let t of n)if("kind"in t){if(t.kind==="empty")return{kind:"empty"};if(t.kind==="entire")return{kind:"entire"};if(t.kind==="singular")return t;e.push(t.value)}else e.push(t);return e}function vf(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;return M({lo:i.lo+r.lo,hi:i.hi+r.hi})}function Ef(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;return M({lo:i.lo-r.hi,hi:i.hi-r.lo})}function _f(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return M({lo:-t.hi,hi:-t.lo})}function Nf(n,e){let t=[n.lo*e.lo,n.lo*e.hi,n.hi*e.lo,n.hi*e.hi];return{lo:Math.min(...t),hi:Math.max(...t)}}function Tf(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;return M(Nf(i,r))}function Un(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;return A_(i,r)}function A_(n,e){return e.lo>0||e.hi<0?M(Nf(n,{lo:1/e.hi,hi:1/e.lo})):e.lo<0&&e.hi>0?{kind:"singular"}:e.lo===0&&e.hi>0?n.lo>=0?{kind:"partial",value:{lo:n.lo/e.hi,hi:1/0},domainClipped:"hi"}:n.hi<=0?{kind:"partial",value:{lo:-1/0,hi:n.hi/e.hi},domainClipped:"lo"}:{kind:"entire"}:e.hi===0&&e.lo<0?n.lo>=0?{kind:"partial",value:{lo:-1/0,hi:n.lo/e.lo},domainClipped:"lo"}:n.hi<=0?{kind:"partial",value:{lo:n.hi/e.lo,hi:1/0},domainClipped:"hi"}:{kind:"entire"}:{kind:"empty"}}function Sf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return w_(t)}function w_(n){return n.hi<0?{kind:"empty"}:n.lo>=0?M({lo:Math.sqrt(n.lo),hi:Math.sqrt(n.hi)}):{kind:"partial",value:{lo:0,hi:Math.sqrt(n.hi)},domainClipped:"lo"}}function If(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.lo>=0?M({lo:t.lo*t.lo,hi:t.hi*t.hi}):t.hi<=0?M({lo:t.hi*t.hi,hi:t.lo*t.lo}):M({lo:0,hi:Math.max(t.lo*t.lo,t.hi*t.hi)})}function gy(n,e){return e===0?{lo:1,hi:1}:e===1?n:e%2===0?n.lo>=0?{lo:Math.pow(n.lo,e),hi:Math.pow(n.hi,e)}:n.hi<=0?{lo:Math.pow(n.hi,e),hi:Math.pow(n.lo,e)}:{lo:0,hi:Math.max(Math.pow(n.lo,e),Math.pow(n.hi,e))}:{lo:Math.pow(n.lo,e),hi:Math.pow(n.hi,e)}}function Bf(n,e){let t=P(n);if(!Array.isArray(t))return t;let[i]=t;if(Number.isInteger(e)){if(e>=0)return M(gy(i,e));{if(En(i))return{kind:"singular"};let r=gy(i,-e);return M({lo:1/r.hi,hi:1/r.lo})}}else return ks(i)?{kind:"empty"}:i.lo<0?{kind:"partial",value:e>0?{lo:0,hi:Math.pow(i.hi,e)}:{lo:Math.pow(i.hi,e),hi:1/0},domainClipped:"lo"}:e>0?M({lo:Math.pow(i.lo,e),hi:Math.pow(i.hi,e)}):i.lo===0?{kind:"partial",value:{lo:Math.pow(i.hi,e),hi:1/0},domainClipped:"hi"}:M({lo:Math.pow(i.hi,e),hi:Math.pow(i.lo,e)})}function Af(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;if(i.hi<=0)return{kind:"empty"};if(i.lo<=0){let s={lo:Math.max(i.lo,Number.EPSILON),hi:i.hi},a=[Math.pow(s.lo,r.lo),Math.pow(s.lo,r.hi),Math.pow(s.hi,r.lo),Math.pow(s.hi,r.hi)];return{kind:"partial",value:{lo:Math.min(...a),hi:Math.max(...a)},domainClipped:"lo"}}let o=[Math.pow(i.lo,r.lo),Math.pow(i.lo,r.hi),Math.pow(i.hi,r.lo),Math.pow(i.hi,r.hi)];return M({lo:Math.min(...o),hi:Math.max(...o)})}function wf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return M({lo:Math.exp(t.lo),hi:Math.exp(t.hi)})}function kf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.hi<=0?{kind:"empty"}:t.lo>0?M({lo:Math.log(t.lo),hi:Math.log(t.hi)}):{kind:"partial",value:{lo:-1/0,hi:Math.log(t.hi)},domainClipped:"lo"}}function Cf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.hi<=0?{kind:"empty"}:t.lo>0?M({lo:Math.log10(t.lo),hi:Math.log10(t.hi)}):{kind:"partial",value:{lo:-1/0,hi:Math.log10(t.hi)},domainClipped:"lo"}}function Rf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.hi<=0?{kind:"empty"}:t.lo>0?M({lo:Math.log2(t.lo),hi:Math.log2(t.hi)}):{kind:"partial",value:{lo:-1/0,hi:Math.log2(t.hi)},domainClipped:"lo"}}function Mf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.lo>=0?M(t):t.hi<=0?M({lo:-t.hi,hi:-t.lo}):M({lo:0,hi:Math.max(-t.lo,t.hi)})}function Df(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e,i=Math.floor(t.lo),r=Math.floor(t.hi);return i===r?M({lo:i,hi:r}):{kind:"singular",at:i+1,continuity:"right"}}function Pf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e,i=Math.ceil(t.lo),r=Math.ceil(t.hi);return i===r?M({lo:i,hi:r}):{kind:"singular",at:i,continuity:"left"}}function Of(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e,i=Math.round(t.lo),r=Math.round(t.hi);return i===r?M({lo:i,hi:r}):{kind:"singular",at:i+.5,continuity:"right"}}function Lf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e,i=Math.floor(t.lo),r=Math.floor(t.hi);return i===r?M({lo:t.lo-i,hi:t.hi-i}):{kind:"singular",at:i+1,continuity:"right"}}function qf(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;return M({lo:Math.min(i.lo,r.lo),hi:Math.min(i.hi,r.hi)})}function Ff(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;return M({lo:Math.max(i.lo,r.lo),hi:Math.max(i.hi,r.hi)})}function Vf(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;if(En(r))return{kind:"singular"};let o=Math.abs(r.lo===r.hi?r.lo:Math.max(Math.abs(r.lo),Math.abs(r.hi))),s=Math.floor(i.lo/o),a=Math.floor(i.hi/o);if(s!==a)return{kind:"singular",at:(s+1)*o,continuity:"right"};let u=i.lo-o*s,l=i.hi-o*s;return M({lo:Math.min(u,l),hi:Math.max(u,l)})}function $f(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.lo>0?M({lo:1,hi:1}):t.hi<0?M({lo:-1,hi:-1}):t.lo===0&&t.hi===0?M({lo:0,hi:0}):{kind:"singular",at:0}}var qt=2*Math.PI,je=Math.PI,Vi=Math.PI/2,hy=3*Math.PI/2;function Uf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.hi-t.lo>=qt)return M({lo:-1,hi:1});let i=Math.sin(t.lo),r=Math.sin(t.hi),o=Math.min(i,r),s=Math.max(i,r);return dn(t,Vi,qt)&&(s=1),dn(t,hy,qt)&&(o=-1),M({lo:o,hi:s})}function jf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.hi-t.lo>=qt)return M({lo:-1,hi:1});let i=Math.cos(t.lo),r=Math.cos(t.hi),o=Math.min(i,r),s=Math.max(i,r);return dn(t,0,qt)&&(s=1),dn(t,je,qt)&&(o=-1),M({lo:o,hi:s})}function Gf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.hi-t.lo>=je)return{kind:"singular"};if(dn(t,Vi,je)){let o=Math.ceil((t.lo-Vi)/je);return{kind:"singular",at:Vi+o*je}}let i=Math.tan(t.lo),r=Math.tan(t.hi);return i>1e10&&r<-1e10||i<-1e10&&r>1e10?{kind:"singular"}:M({lo:i,hi:r})}function zf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.hi-t.lo>=je)return{kind:"singular"};if(dn(t,0,je))return{kind:"singular",at:Math.ceil(t.lo/je)*je};let i=1/Math.tan(t.lo),r=1/Math.tan(t.hi);return M({lo:Math.min(i,r),hi:Math.max(i,r)})}function Zf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.hi-t.lo>=je)return{kind:"singular"};if(dn(t,Vi,je)){let a=Math.ceil((t.lo-Vi)/je);return{kind:"singular",at:Vi+a*je}}let i=1/Math.cos(t.lo),r=1/Math.cos(t.hi),o=Math.min(i,r),s=Math.max(i,r);return dn(t,0,qt)&&(o=Math.min(o,1),s=Math.max(s,1)),dn(t,je,qt)&&(o=Math.min(o,-1),s=Math.max(s,-1)),M({lo:o,hi:s})}function Hf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.hi-t.lo>=je)return{kind:"singular"};if(dn(t,0,je))return{kind:"singular",at:Math.ceil(t.lo/je)*je};let i=1/Math.sin(t.lo),r=1/Math.sin(t.hi),o=Math.min(i,r),s=Math.max(i,r);return dn(t,Vi,qt)&&(o=Math.min(o,1),s=Math.max(s,1)),dn(t,hy,qt)&&(o=Math.min(o,-1),s=Math.max(s,-1)),M({lo:o,hi:s})}function uu(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.lo>1||t.hi<-1)return{kind:"empty"};if(t.lo<-1||t.hi>1){let i=Math.max(t.lo,-1),r=Math.min(t.hi,1);return{kind:"partial",value:{lo:Math.asin(i),hi:Math.asin(r)},domainClipped:t.lo<-1&&t.hi>1?"both":t.lo<-1?"lo":"hi"}}return M({lo:Math.asin(t.lo),hi:Math.asin(t.hi)})}function lu(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.lo>1||t.hi<-1)return{kind:"empty"};if(t.lo<-1||t.hi>1){let i=Math.max(t.lo,-1),r=Math.min(t.hi,1);return{kind:"partial",value:{lo:Math.acos(r),hi:Math.acos(i)},domainClipped:t.lo<-1&&t.hi>1?"both":t.lo<-1?"lo":"hi"}}return M({lo:Math.acos(t.hi),hi:Math.acos(t.lo)})}function cu(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return M({lo:Math.atan(t.lo),hi:Math.atan(t.hi)})}function Wf(n,e){let t=P(n,e);if(!Array.isArray(t))return t;let[i,r]=t;if(i.lo===i.hi&&r.lo===r.hi){let s=Math.atan2(i.lo,r.lo);return M({lo:s,hi:s})}let o=[];return o.push(Math.atan2(i.lo,r.lo)),o.push(Math.atan2(i.lo,r.hi)),o.push(Math.atan2(i.hi,r.lo)),o.push(Math.atan2(i.hi,r.hi)),r.lo<0&&i.lo<0&&i.hi>0?M({lo:-je,hi:je}):M({lo:Math.min(...o),hi:Math.max(...o)})}function Cs(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return M({lo:Math.sinh(t.lo),hi:Math.sinh(t.hi)})}function Rs(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.lo>=0?M({lo:Math.cosh(t.lo),hi:Math.cosh(t.hi)}):t.hi<=0?M({lo:Math.cosh(t.hi),hi:Math.cosh(t.lo)}):M({lo:1,hi:Math.max(Math.cosh(t.lo),Math.cosh(t.hi))})}function Jf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return M({lo:Math.tanh(t.lo),hi:Math.tanh(t.hi)})}function fu(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return M({lo:Math.asinh(t.lo),hi:Math.asinh(t.hi)})}function pu(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return t.hi<1?{kind:"empty"}:t.lo<1?{kind:"partial",value:{lo:0,hi:Math.acosh(t.hi)},domainClipped:"lo"}:M({lo:Math.acosh(t.lo),hi:Math.acosh(t.hi)})}function du(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;if(t.lo>=1||t.hi<=-1)return{kind:"empty"};if(t.lo<=-1||t.hi>=1){let i=Math.max(t.lo,-1+Number.EPSILON),r=Math.min(t.hi,1-Number.EPSILON);return{kind:"partial",value:{lo:Math.atanh(i),hi:Math.atanh(r)},domainClipped:t.lo<=-1&&t.hi>=1?"both":t.lo<=-1?"lo":"hi"}}return M({lo:Math.atanh(t.lo),hi:Math.atanh(t.hi)})}function Yf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:cu(Un(M({lo:1,hi:1}),M(t)))}function Qf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:uu(Un(M({lo:1,hi:1}),M(t)))}function Xf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:lu(Un(M({lo:1,hi:1}),M(t)))}function Kf(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:Un(Rs(t),Cs(t))}function ep(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:Un(M({lo:1,hi:1}),Cs(t))}function np(n){return Un(M({lo:1,hi:1}),Rs(n))}function tp(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:du(Un(M({lo:1,hi:1}),M(t)))}function ip(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:fu(Un(M({lo:1,hi:1}),M(t)))}function rp(n){let e=P(n);if(!Array.isArray(e))return e;let[t]=e;return En(t)?{kind:"singular",at:0}:pu(Un(M({lo:1,hi:1}),M(t)))}function op(n,e){let t=P(n,e);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.hi<r.lo?"true":i.lo>=r.hi?"false":"maybe"}function sp(n,e){let t=P(n,e);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.hi<=r.lo?"true":i.lo>r.hi?"false":"maybe"}function ap(n,e){let t=P(n,e);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.lo>r.hi?"true":i.hi<=r.lo?"false":"maybe"}function up(n,e){let t=P(n,e);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.lo>=r.hi?"true":i.hi<r.lo?"false":"maybe"}function mu(n,e){let t=P(n,e);if(!Array.isArray(t))return"maybe";let[i,r]=t;return i.lo===i.hi&&r.lo===r.hi&&i.lo===r.lo?"true":i.hi<r.lo||r.hi<i.lo?"false":"maybe"}function lp(n,e){let t=mu(n,e);return t==="true"?"false":t==="false"?"true":"maybe"}function cp(n,e){return n==="false"||e==="false"?"false":n==="true"&&e==="true"?"true":"maybe"}function fp(n,e){return n==="true"||e==="true"?"true":n==="false"&&e==="false"?"false":"maybe"}function pp(n){return n==="true"?"false":n==="false"?"true":"maybe"}function dp(n,e,t,i){if(n==="true"||n==="false"||n==="maybe"){let f=n,p=e,d=t;switch(f){case"true":return p();case"false":return d();case"maybe":return _o(p(),d())}}let r=n,o=e,s=t,a=i,u=P(r);if(!Array.isArray(u))return u;let[l]=u;switch(o(l)){case"true":return s(l);case"false":return a(l);case"maybe":let f=s(l),p=a(l);return _o(f,p)}}function mp(n,e,t){let i=P(n,e,t);if(!Array.isArray(i))return i;let[r,o,s]=i,a=Math.max(r.lo,o.lo),u=Math.min(r.hi,s.hi);return a>u?{kind:"empty"}:{kind:"interval",value:{lo:a,hi:u}}}var xy={ok:M,point:ff,containsExtremum:dn,unionResults:_o,mergeDomainClip:au,isPoint:pf,containsZero:En,isPositive:df,isNegative:ks,isNonNegative:mf,isNonPositive:gf,width:hf,midpoint:xf,getValue:yf,unwrap:bf,unwrapOrPropagate:P,add:vf,sub:Ef,mul:Tf,div:Un,negate:_f,sqrt:Sf,square:If,pow:Bf,powInterval:Af,exp:wf,ln:kf,log10:Cf,log2:Rf,abs:Mf,floor:Df,ceil:Pf,round:Of,fract:Lf,min:qf,max:Ff,mod:Vf,sign:$f,sin:Uf,cos:jf,tan:Gf,cot:zf,sec:Zf,csc:Hf,asin:uu,acos:lu,atan:cu,atan2:Wf,sinh:Cs,cosh:Rs,tanh:Jf,asinh:fu,acosh:pu,atanh:du,acot:Yf,acsc:Qf,asec:Xf,coth:Kf,csch:ep,sech:np,acoth:tp,acsch:ip,asech:rp,less:op,lessEqual:sp,greater:ap,greaterEqual:up,equal:mu,notEqual:lp,and:cp,or:fp,not:pp,piecewise:dp,clamp:mp};var k_={Add:["_IA.add",20],Negate:["_IA.negate",20],Subtract:["_IA.sub",20],Multiply:["_IA.mul",20],Divide:["_IA.div",20],Equal:["_IA.equal",20],NotEqual:["_IA.notEqual",20],LessEqual:["_IA.lessEqual",20],GreaterEqual:["_IA.greaterEqual",20],Less:["_IA.less",20],Greater:["_IA.greater",20],And:["_IA.and",20],Or:["_IA.or",20],Not:["_IA.not",20]},gp={Add:(n,e)=>{if(n.length===0)return"_IA.point(0)";if(n.length===1)return e(n[0]);let t=e(n[0]);for(let i=1;i<n.length;i++)t=`_IA.add(${t}, ${e(n[i])})`;return t},Subtract:(n,e)=>{if(n.length===0)return"_IA.point(0)";if(n.length===1)return`_IA.negate(${e(n[0])})`;if(n.length===2)return`_IA.sub(${e(n[0])}, ${e(n[1])})`;let t=e(n[0]);for(let i=1;i<n.length;i++)t=`_IA.sub(${t}, ${e(n[i])})`;return t},Multiply:(n,e)=>{if(n.length===0)return"_IA.point(1)";if(n.length===1)return e(n[0]);let t=e(n[0]);for(let i=1;i<n.length;i++)t=`_IA.mul(${t}, ${e(n[i])})`;return t},Divide:(n,e)=>{if(n.length===0)return"_IA.point(1)";if(n.length===1)return e(n[0]);if(n.length===2)return`_IA.div(${e(n[0])}, ${e(n[1])})`;let t=e(n[0]);for(let i=1;i<n.length;i++)t=`_IA.div(${t}, ${e(n[i])})`;return t},Negate:(n,e)=>`_IA.negate(${e(n[0])})`,Abs:(n,e)=>`_IA.abs(${e(n[0])})`,Ceiling:(n,e)=>`_IA.ceil(${e(n[0])})`,Exp:(n,e)=>`_IA.exp(${e(n[0])})`,Floor:(n,e)=>`_IA.floor(${e(n[0])})`,Ln:(n,e)=>`_IA.ln(${e(n[0])})`,Log:(n,e)=>n.length===1?`_IA.log10(${e(n[0])})`:`_IA.div(_IA.ln(${e(n[0])}), _IA.ln(${e(n[1])}))`,Lb:(n,e)=>`_IA.log2(${e(n[0])})`,Max:(n,e)=>{if(n.length===0)return"_IA.point(-Infinity)";if(n.length===1)return e(n[0]);let t=e(n[0]);for(let i=1;i<n.length;i++)t=`_IA.max(${t}, ${e(n[i])})`;return t},Min:(n,e)=>{if(n.length===0)return"_IA.point(Infinity)";if(n.length===1)return e(n[0]);let t=e(n[0]);for(let i=1;i<n.length;i++)t=`_IA.min(${t}, ${e(n[i])})`;return t},Power:(n,e)=>{let t=n[0],i=n[1];if(t===null)throw new Error("Power: no argument");if(t.symbol==="ExponentialE")return`_IA.exp(${e(i)})`;if(i?.isNumberLiteral&&i.im===0){let r=i.re;return r===.5?`_IA.sqrt(${e(t)})`:r===2?`_IA.square(${e(t)})`:`_IA.pow(${e(t)}, ${r})`}return`_IA.powInterval(${e(t)}, ${e(i)})`},Root:(n,e)=>{let[t,i]=n;if(t===null)throw new Error("Root: no argument");return i===null?`_IA.sqrt(${e(t)})`:i?.re===2?`_IA.sqrt(${e(t)})`:i?.isNumberLiteral&&i.im===0?`_IA.pow(${e(t)}, ${1/i.re})`:`_IA.powInterval(${e(t)}, _IA.div(_IA.point(1), ${e(i)}))`},Round:(n,e)=>`_IA.round(${e(n[0])})`,Sgn:(n,e)=>`_IA.sign(${e(n[0])})`,Sqrt:(n,e)=>`_IA.sqrt(${e(n[0])})`,Square:(n,e)=>`_IA.square(${e(n[0])})`,Sin:(n,e)=>`_IA.sin(${e(n[0])})`,Cos:(n,e)=>`_IA.cos(${e(n[0])})`,Tan:(n,e)=>`_IA.tan(${e(n[0])})`,Cot:(n,e)=>`_IA.cot(${e(n[0])})`,Sec:(n,e)=>`_IA.sec(${e(n[0])})`,Csc:(n,e)=>`_IA.csc(${e(n[0])})`,Arcsin:(n,e)=>`_IA.asin(${e(n[0])})`,Arccos:(n,e)=>`_IA.acos(${e(n[0])})`,Arctan:(n,e)=>`_IA.atan(${e(n[0])})`,Arccot:(n,e)=>`_IA.acot(${e(n[0])})`,Arccsc:(n,e)=>`_IA.acsc(${e(n[0])})`,Arcsec:(n,e)=>`_IA.asec(${e(n[0])})`,Sinh:(n,e)=>`_IA.sinh(${e(n[0])})`,Cosh:(n,e)=>`_IA.cosh(${e(n[0])})`,Tanh:(n,e)=>`_IA.tanh(${e(n[0])})`,Coth:(n,e)=>`_IA.coth(${e(n[0])})`,Csch:(n,e)=>`_IA.csch(${e(n[0])})`,Sech:(n,e)=>`_IA.sech(${e(n[0])})`,Arsinh:(n,e)=>`_IA.asinh(${e(n[0])})`,Arcosh:(n,e)=>`_IA.acosh(${e(n[0])})`,Artanh:(n,e)=>`_IA.atanh(${e(n[0])})`,Arcoth:(n,e)=>`_IA.acoth(${e(n[0])})`,Arcsch:(n,e)=>`_IA.acsch(${e(n[0])})`,Arsech:(n,e)=>`_IA.asech(${e(n[0])})`,Asin:(n,e)=>`_IA.asin(${e(n[0])})`,Acos:(n,e)=>`_IA.acos(${e(n[0])})`,Atan:(n,e)=>`_IA.atan(${e(n[0])})`,Fract:(n,e)=>`_IA.fract(${e(n[0])})`,Mod:(n,e)=>`_IA.mod(${e(n[0])}, ${e(n[1])})`,If:(n,e)=>{if(n.length!==3)throw new Error("If: wrong number of arguments");return`_IA.piecewise(
|
|
125
125
|
${e(n[0])},
|
|
126
126
|
() => ${e(n[1])},
|
|
127
127
|
() => ${e(n[2])}
|
|
@@ -139,6 +139,8 @@ const float IA_SINGULAR = 3.0;
|
|
|
139
139
|
const float IA_PARTIAL_LO = 4.0;
|
|
140
140
|
const float IA_PARTIAL_HI = 5.0;
|
|
141
141
|
const float IA_PARTIAL_BOTH = 6.0;
|
|
142
|
+
const float IA_SINGULAR_RIGHT = 7.0;
|
|
143
|
+
const float IA_SINGULAR_LEFT = 8.0;
|
|
142
144
|
|
|
143
145
|
// Interval result struct
|
|
144
146
|
struct IntervalResult {
|
|
@@ -172,12 +174,20 @@ IntervalResult ia_singular(float at) {
|
|
|
172
174
|
return IntervalResult(vec2(at, at), IA_SINGULAR);
|
|
173
175
|
}
|
|
174
176
|
|
|
177
|
+
IntervalResult ia_singular_right(float at) {
|
|
178
|
+
return IntervalResult(vec2(at, at), IA_SINGULAR_RIGHT);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
IntervalResult ia_singular_left(float at) {
|
|
182
|
+
return IntervalResult(vec2(at, at), IA_SINGULAR_LEFT);
|
|
183
|
+
}
|
|
184
|
+
|
|
175
185
|
IntervalResult ia_partial(vec2 v, float clip) {
|
|
176
186
|
return IntervalResult(v, clip);
|
|
177
187
|
}
|
|
178
188
|
|
|
179
189
|
bool ia_is_error(float status) {
|
|
180
|
-
return status == IA_EMPTY || status == IA_ENTIRE || status == IA_SINGULAR;
|
|
190
|
+
return status == IA_EMPTY || status == IA_ENTIRE || status == IA_SINGULAR || status == IA_SINGULAR_RIGHT || status == IA_SINGULAR_LEFT;
|
|
181
191
|
}
|
|
182
192
|
|
|
183
193
|
// Addition
|
|
@@ -317,7 +327,8 @@ IntervalResult ia_floor(vec2 x) {
|
|
|
317
327
|
return ia_ok(vec2(flo, fhi));
|
|
318
328
|
}
|
|
319
329
|
// Interval spans an integer boundary - discontinuity at first integer > x.x
|
|
320
|
-
|
|
330
|
+
// floor is right-continuous
|
|
331
|
+
return ia_singular_right(flo + 1.0);
|
|
321
332
|
}
|
|
322
333
|
|
|
323
334
|
// Ceiling - has jump discontinuities at every integer
|
|
@@ -328,7 +339,8 @@ IntervalResult ia_ceil(vec2 x) {
|
|
|
328
339
|
return ia_ok(vec2(clo, chi));
|
|
329
340
|
}
|
|
330
341
|
// Interval spans an integer boundary - discontinuity at ceil(x.x)
|
|
331
|
-
|
|
342
|
+
// ceil is left-continuous
|
|
343
|
+
return ia_singular_left(clo);
|
|
332
344
|
}
|
|
333
345
|
|
|
334
346
|
// Round - has jump discontinuities at every half-integer
|
|
@@ -342,7 +354,8 @@ IntervalResult ia_round(vec2 x) {
|
|
|
342
354
|
return ia_ok(vec2(rlo, rhi));
|
|
343
355
|
}
|
|
344
356
|
// Interval spans a half-integer boundary - discontinuity
|
|
345
|
-
|
|
357
|
+
// round is right-continuous (with round-half-up convention)
|
|
358
|
+
return ia_singular_right(rlo + 0.5);
|
|
346
359
|
}
|
|
347
360
|
|
|
348
361
|
// Fract - sawtooth discontinuities at every integer
|
|
@@ -355,7 +368,8 @@ IntervalResult ia_fract(vec2 x) {
|
|
|
355
368
|
return ia_ok(vec2(fract(x.x) - IA_EPS, fract(x.y) + IA_EPS));
|
|
356
369
|
}
|
|
357
370
|
// Interval spans an integer - sawtooth discontinuity
|
|
358
|
-
|
|
371
|
+
// fract is right-continuous (inherits from floor)
|
|
372
|
+
return ia_singular_right(flo + 1.0);
|
|
359
373
|
}
|
|
360
374
|
|
|
361
375
|
// Mod - periodic discontinuities at multiples of the modulus
|
|
@@ -378,7 +392,8 @@ IntervalResult ia_mod(vec2 x, vec2 y) {
|
|
|
378
392
|
return ia_ok(vec2(min(mlo, mhi) - IA_EPS, max(mlo, mhi) + IA_EPS));
|
|
379
393
|
}
|
|
380
394
|
// Discontinuity at first multiple of period in the interval
|
|
381
|
-
|
|
395
|
+
// mod has sawtooth discontinuities, right-continuous
|
|
396
|
+
return ia_singular_right((flo + 1.0) * period);
|
|
382
397
|
}
|
|
383
398
|
|
|
384
399
|
// General case: compose from existing operations
|
|
@@ -1053,7 +1068,7 @@ IntervalResult ${i}(${u}) {
|
|
|
1053
1068
|
`}};Mt();var Ps=class n{True;False;Pi;E;Nothing;Zero;One;Half;NegativeOne;Two;I;NaN;PositiveInfinity;NegativeInfinity;ComplexInfinity;decimalSeparator=".";_BIGNUM_NAN;_BIGNUM_ZERO;_BIGNUM_ONE;_BIGNUM_TWO;_BIGNUM_HALF;_BIGNUM_PI;_BIGNUM_NEGATIVE_ONE;_precision;_angularUnit;_tolerance;_bignumTolerance;_negBignumTolerance;__cache={};_configurationChangeTracker=new Xs;_cost;_compilationTargets=new Map;_commonSymbols={Pi:null,True:null,False:null,All:null,Nothing:null,None:null,Undefined:null,ImaginaryUnit:null,ExponentialE:null};_commonNumbers={"-5":null,"-4":null,"-3":null,"-2":null,2:null,3:null,4:null,5:null,6:null,7:null,8:null,9:null,10:null,11:null,12:null,36:null};_evalContextStack=[];get context(){return this._evalContextStack[this._evalContextStack.length-1]}get contextStack(){return[...this._evalContextStack]}set contextStack(e){this._evalContextStack=[...e]}get _typeResolver(){let e=this;return{get names(){let t=[],i=e.context.lexicalScope;for(;i;)i.types&&t.push(...Object.keys(i.types)),i=i.parent;return t},resolve:t=>{let i=e.context.lexicalScope;for(;i;){if(i.types?.[t])return i.types[t];i=i.parent}},forward:t=>{let i={kind:"reference",name:t,alias:!1,def:void 0};return e.context.lexicalScope.types??={},e.context.lexicalScope.types[t]=i,i}}}declareType(e,t,{alias:i}={}){if(!td(e))throw Error(`The type name "${e}" is invalid`);let r=this.context.lexicalScope;if(r.types?.[e])throw Error(`The type "${e}" is already defined in the current scope`);r.types??={},i??=!1,r.types[e]={kind:"reference",name:e,alias:i,def:void 0};let o=t instanceof R?t.type:typeof t=="string"?V(t,this._typeResolver):t;r.types[e].def=o}get trace(){return this._evalContextStack.map(e=>e.name).filter(e=>e!==void 0).reverse()}_generation=0;strict;deadline;_latexDictionaryInput;__indexedLatexDictionary;_bignum;static getStandardLibrary(e="all"){return Uc(e)}static getLatexDictionary(e="all"){return um(e)}constructor(e){if(e!==void 0&&typeof e!="object")throw Error("Unexpected argument");this.strict=!0;let t=e?.precision??Ou;t==="machine"&&(t=Math.floor(_t)),this._bignum=j.clone({precision:t}),this._precision=t,this.tolerance=e?.tolerance??"auto",this._angularUnit="rad",this.Zero=new vn(this,0),this.One=new vn(this,1),this.Half=new vn(this,{rational:[1,2]}),this.NegativeOne=new vn(this,-1),this.Two=new vn(this,2),this.NaN=new vn(this,Number.NaN),this.PositiveInfinity=new vn(this,Number.POSITIVE_INFINITY),this.NegativeInfinity=new vn(this,Number.NEGATIVE_INFINITY),this.I=new vn(this,{im:1}),this.ComplexInfinity=new vn(this,{re:1/0,im:1/0}),this._reset(),this.pushScope(void 0,"system"),this.declareType("limits","expression<Limits>");for(let r of n.getStandardLibrary("domains"))jc(this,r);let i=e?.ids??n.getStandardLibrary();for(let r of i)jc(this,r);for(let r of Object.keys(this._commonSymbols))this._commonSymbols[r]=new xr(this,r,{def:this.lookupDefinition(r)});this.True=this._commonSymbols.True,this.False=this._commonSymbols.False,this.Pi=this._commonSymbols.Pi,this.E=this._commonSymbols.ExponentialE,this.Nothing=this._commonSymbols.Nothing,this.pushScope(void 0,"global"),this._compilationTargets.set("javascript",new vo),this._compilationTargets.set("glsl",new Eo),this._compilationTargets.set("interval-js",new Ms),this._compilationTargets.set("interval-glsl",new Ds),od(this)}toJSON(){return"[ComputeEngine]"}[Symbol.toStringTag]="ComputeEngine";get latexDictionary(){return this._latexDictionaryInput??n.getLatexDictionary()}set latexDictionary(e){this._latexDictionaryInput=e,this.__indexedLatexDictionary=ol(e,t=>{throw Error(typeof t.message=="string"?t.message:t.message.join(","))})}get _indexedLatexDictionary(){return this.__indexedLatexDictionary??=ol(this.latexDictionary,e=>console.error(e)),this.__indexedLatexDictionary}_reset(){this._bignum,this._generation+=1,this._BIGNUM_NEGATIVE_ONE=this.bignum(-1),this._BIGNUM_NAN=this.bignum(NaN),this._BIGNUM_ZERO=this.bignum(0),this._BIGNUM_ONE=this.bignum(1),this._BIGNUM_TWO=this.bignum(2),this._BIGNUM_HALF=this._BIGNUM_ONE.div(this._BIGNUM_TWO),this._BIGNUM_PI=this._BIGNUM_NEGATIVE_ONE.acos();for(let e of Object.values(this._commonSymbols))e?.reset();for(let e of Object.keys(this.__cache))this.__cache[e].value&&(this.__cache[e].purge?this.__cache[e].value=this.__cache[e].purge(this.__cache[e].value):delete this.__cache[e]);this._configurationChangeTracker.notifyNow()}listenToConfigurationChange(e){return this._configurationChangeTracker.listen(e)}registerCompilationTarget(e,t){this._compilationTargets.set(e,t)}_getCompilationTarget(e){return this._compilationTargets.get(e)}get precision(){return this._precision}set precision(e){e==="machine"&&(e=_t),e==="auto"&&(e=Ou);let t=this._precision;if(e!==t){if(typeof e!="number"||e<=0)throw Error('Expected "machine" or a positive number');this._precision=Math.max(e,_t),this._bignum=this._bignum.config({precision:this._precision}),this.tolerance="auto",this._reset()}}get angularUnit(){return this._angularUnit}set angularUnit(e){if(e!==this._angularUnit){if(typeof e!="string")throw Error("Expected a string");this._angularUnit=e,this._reset()}}get timeLimit(){return this._timeLimit}set timeLimit(e){e<=0&&(e=Number.POSITIVE_INFINITY),this._timeLimit=e}_timeLimit=2e3;_deadline=void 0;get _timeRemaining(){return this.deadline===void 0?Number.POSITIVE_INFINITY:this.deadline-Date.now()}get iterationLimit(){return this._iterationLimit}set iterationLimit(e){e<=0&&(e=Number.POSITIVE_INFINITY),this._iterationLimit=e}_iterationLimit=1024;get recursionLimit(){return this._recursionLimit}set recursionLimit(e){e<=0&&(e=Number.POSITIVE_INFINITY),this._recursionLimit=e}_recursionLimit=1024;_isVerifying=!1;get isVerifying(){return this._isVerifying}get tolerance(){return this._tolerance}set tolerance(e){e==="auto"&&(e=Lu),(!Number.isFinite(e)||e<0)&&(e=Math.pow(10,-this._precision+2)),this._tolerance=e,this._bignumTolerance=this.bignum(e),this._negBignumTolerance=this.bignum(-e)}chop(e){return typeof e=="number"?Math.abs(e)<=this._tolerance?0:e:e instanceof j?e.isPositive()&&e.lte(this._bignumTolerance)||e.isNegative()&&e.gte(this._negBignumTolerance)||e.isZero()?0:e:e instanceof ie&&Math.abs(e.re)<=this._tolerance&&Math.abs(e.im)<=this._tolerance?0:e}bignum(e){if(typeof e=="bigint")return new this._bignum(e.toString());try{return new this._bignum(e)}catch(t){console.error(t.message)}return this._BIGNUM_NAN}complex(e,t){return e instanceof j&&(e=e.toNumber()),t instanceof j&&(t=t.toNumber()),new ie(e,t)}_numericValue(e){if(e instanceof le)return e.asExact??e;let t=r=>this.bignum(r),i=this._precision>_t?r=>new Ki(r,t):r=>new er(r,t);if(typeof e=="number")return Number.isInteger(e)?new ye(e,i,t):i(e);if(typeof e=="bigint")return new ye(e,i,t);if(Kt(e))return new ye({rational:e},i,t);if(e instanceof j){if(e.isInteger()&&e.e<=fd){let r=Ee(e.toString());if(r!==null)return new ye(r,i,t)}return i(e)}if(e instanceof ie)return e.im===0?this._numericValue(e.re):i({re:e.re,im:e.im});if("im"in e||"re"in e)return e.im!==void 0&&e.im!==0?i(e):e.re instanceof j&&e.re.isInteger()?new ye({rational:[Ee(e.re.toString()),BigInt(1)]},i,t):typeof e.re=="number"&&Number.isInteger(e.re)?new ye({rational:[e.re,1]},i,t):i(e);if("radical"in e||"rational"in e){if(e.radical!==void 0&&(!Number.isInteger(e.radical)||e.radical>=K))throw Error("Unexpected value for radical part:"+e.radical);return e.rational&&Ne(e.rational)&&(!Number.isInteger(e.rational[0])||!Number.isInteger(e.rational[1]))?i(e):new ye(e,i,t)}throw Error("Unexpected value")}get costFunction(){return this._cost??Gc}set costFunction(e){typeof e!="function"&&(this._cost=Gc),this._cost=e}lookupDefinition(e){return as(e,this.context.lexicalScope)}_declareSymbolValue(e,t,i){i??=this.context.lexicalScope,i.bindings.set(e,{value:new ft(this,e,{type:"unknown",inferred:!0})});let r=i.bindings.get(e);return ur(this,e,r,t),i===this.context.lexicalScope&&re(r)&&r.value.value&&!r.value.isConstant&&(this.context.values[e]=r.value.value),this._generation+=1,r}_declareSymbolOperator(e,t,i){i??=this.context.lexicalScope,i.bindings.set(e,{value:new ft(this,e,{type:"function"})});let r=i.bindings.get(e);return ur(this,e,r,t),this._generation+=1,r}pushScope(e,t){this._pushEvalContext(e??{parent:this.context?.lexicalScope,bindings:new Map},t)}popScope(){this._popEvalContext()}_pushEvalContext(e,t){if(!t){let r=this._evalContextStack.length;r===0&&(t="system"),r===1&&(t="global"),t??=`anonymous_${r-1}`}let i={};for(let[r,o]of e.bindings.entries())re(o)&&!o.value.isConstant&&(i[r]=o.value.value);this._evalContextStack.push({lexicalScope:e,name:t,assumptions:new ws(this.context?.assumptions??[]),values:i})}_popEvalContext(){this._evalContextStack.pop()}_inScope(e,t){if(!e)return t();this._evalContextStack.push({lexicalScope:e,name:"",assumptions:new ws([]),values:{}});try{return t()}finally{this._evalContextStack.pop()}}_printStack(e){e?(e={...e},e.maxDepth??=1,e.details??=!1):e={details:!1,maxDepth:-2},e.maxDepth!==void 0&&e.maxDepth<0&&(e.maxDepth=this._evalContextStack.length+e.maxDepth),e.maxDepth=Math.min(this._evalContextStack.length-1,e.maxDepth);let t=0;for(;t<=e.maxDepth;){let i=this._evalContextStack[this._evalContextStack.length-1-t];t===0?console.group(`${Gs}${Tu}${i.name}${mn}`):console.groupCollapsed(`${Gs}${Tu}${i.name}${mn} ${_r}(${t})${mn}`);let r=[...i.assumptions.entries()].map(([s,a])=>`${s}: ${a}`);if(r.length>0){console.groupCollapsed(`${Gs}${r.length} assumptions${mn}`);for(let s of r)console.info(s);console.groupEnd()}let o=Object.entries(i.values);if(o.length+i.lexicalScope.bindings.size===0){console.groupEnd(),t+=1;continue}for(let[s,a]of o)i.lexicalScope.bindings.has(s)?console.info(_y(s,i.lexicalScope.bindings.get(s),a)):console.info(a===void 0?`${Io}${s}${mn}: ${_r}undefined${mn}`:`${Io}${s}${mn}: ${_r}${a.toString()}${mn}`);for(let[s,a]of i.lexicalScope.bindings)s in i.values||console.info(_y(s,a));console.groupEnd(),t+=1}}_getSymbolValue(e){let t=this._evalContextStack.length-1;if(!(t<0))for(let i=t;i>=0;i--){let r=this._evalContextStack[i].values;if(e in r)return r[e]}}_setSymbolValue(e,t){let i=this._evalContextStack.length-1;if(i<0)throw new Error(`Unknown symbol "${e}"`);typeof t=="number"?t=this.number(t):typeof t=="boolean"&&(t=t?this.True:this.False);for(let o=i;o>=0;o--){let s=this._evalContextStack[o].values;if(e in s){s[e]=t,this._generation+=1;return}}let r=this.lookupContext(e);if(!r)throw new Error(`Unknown symbol "${e}"`);r.values[e]=t}_setCurrentContextValue(e,t){let i=this._evalContextStack.length-1;if(i<0)throw new Error("No evaluation context");typeof t=="number"?t=this.number(t):typeof t=="boolean"&&(t=t?this.True:this.False),this._evalContextStack[i].values[e]=t,this._generation+=1}declare(e,t,i){if(typeof e!="string"){for(let[a,u]of Object.entries(e))this.declare(a,u);return this}let r=e;if(r==="Nothing")return this;if(t==null)throw Error(`Expected a definition or type for "${r}"`);if(typeof r!="string"||r.length===0||!ze(r))throw new Error(`Invalid symbol "${r}": ${Gn(r)}`);if(i??=this.context.lexicalScope,i.bindings.has(r))throw new Error(`The symbol "${r}" is already declared in this scope`);let s=t;if(fs(s))return this._declareSymbolValue(r,s,i),this;if(cs(s))return this._declareSymbolOperator(r,s,i),this;{let a=V(s,this._typeResolver);if(!yi(a))throw Error([`Invalid argument for "${r}"`,JSON.stringify(s,void 0,4),"Use a type, a `OperatorDefinition` or a `ValueDefinition`"].join(`
|
|
1054
1069
|
| `));this._declareSymbolValue(r,{type:a},i)}return this}declareSequence(e,t){if(!t.base||Object.keys(t.base).length===0)throw new Error(`Sequence "${e}" requires at least one base case`);if(!t.recurrence)throw new Error(`Sequence "${e}" requires a recurrence relation`);this.declare(e,{subscriptEvaluate:()=>{}});let i=Ic(this,e,t);if(!i.valid)throw new Error(i.error);let r=Sc(this,e,t),o=this.lookupDefinition(e);return o&&re(o)&&(o.value.subscriptEvaluate=r),this}getSequenceStatus(e){return wh(this,e)}getSequence(e){return kh(this,e)}listSequences(){return Ch(this)}isSequence(e){return kc(this,e)}clearSequenceCache(e){Rh(this,e)}getSequenceCache(e){return Mh(this,e)}getSequenceTerms(e,t,i,r){return Dh(this,e,t,i,r)}lookupOEIS(e,t){return py(this,e,t)}checkSequenceOEIS(e,t,i){return dy(this,e,t,i)}lookupContext(e){if(e.length===0||!ze(e))throw Error(`Invalid symbol "${e}": ${Gn(e)}}`);let t=this._evalContextStack.length-1;if(!(t<0))for(let i=t;i>=0;i--){let r=this._evalContextStack[i];if(r.lexicalScope.bindings.has(e))return r}}_swapContext(e){for(;this._evalContextStack.length>0&&this._evalContextStack[this._evalContextStack.length-1]!==e;)this._evalContextStack.pop();this._evalContextStack.length===0&&(this._evalContextStack=[e])}assign(e,t){if(typeof e=="object"){for(let[a,u]of Object.entries(e))this.assign(a,u);return this}let i=e;if(i==="Nothing")return this;let r=this.lookupDefinition(i);if(ue(r)){if(vy(this,t))throw Error(`Cannot change the operator "${i}" to a value`);let u=Ey(this,t);if(!u)throw Error(`Cannot change the operator "${i}" to a value`);return ur(this,i,r,u),this}let o=vy(this,t);if(o!==void 0){if(!r)return this._declareSymbolValue(i,{value:o}),this;if(r.value.isConstant)throw Error(`Cannot assign a value to the constant "${i}"`);return r.value.inferredType&&(r.value.type=this.type(ve(r.value.type.type,o.type.type))),this._setSymbolValue(i,o),this}let s=Ey(this,t);if(s===void 0)throw Error(`Invalid definition for symbol "${i}"`);return r?(re(r),ur(this,i,r,s),this._setSymbolValue(i,void 0)):this.declare(i,s),this}_shouldContinueExecution(){return this.deadline===void 0||this.deadline>=Date.now()}_checkContinueExecution(){if(!this._shouldContinueExecution())throw new Error("timeout")}_cache(e,t,i){if(this.__cache[e]===void 0)try{this.__cache[e]={build:t,purge:i,value:t()}}catch(r){console.error(`Fatal error building cache "${e}":
|
|
1055
1070
|
${r.toString()}`)}return this.__cache[e]?.value}box(e,t){return xt(this,e,t)}function(e,t,i){return ru(this,e,t,i)}error(e,t){let i;typeof e=="string"?i=this.string(e):i=this.function("ErrorCode",e.map(s=>this.string(s)));let r;t&&Rr(t)?r=this.function("LatexString",[this.string(Ni(t))]):typeof t=="string"&&t.length>0&&(r=this.string(t));let o=[this.box(i)];return r&&o.push(r),this.function("Error",o)}typeError(e,t,i){return t?this.error(["incompatible-type",te(e),t.toString()],i):this.error(["incompatible-type",te(e)],i)}hold(e){return this._fn("Hold",[this.box(e,{canonical:!1})])}tuple(...e){return new Me(this,"Tuple",e.map(t=>typeof t=="number"?this.number(t):t.canonical),{canonical:!0})}type(e){return e instanceof R?e:new R(e,this._typeResolver)}string(e,t){return new Fi(this,e,t)}symbol(e,t){let i=t?.canonical??!0,r=t?.metadata;e=e.normalize();let o=e.toLowerCase();if(o==="infinity"||o==="+infinity")return this.PositiveInfinity;if(o==="-infinity")return this.NegativeInfinity;if(this.strict&&!ze(e))return this.error(["invalid-symbol",Gn(e)],e);if(!i)return new xr(this,e,{metadata:r});let s=this._commonSymbols[e];if(s)return s;let a=this.lookupDefinition(e);return re(a)&&a.value.holdUntil==="never"?a.value.value??this.Nothing:a?new xr(this,e,{metadata:r,def:a}):(a=this._declareSymbolValue(e,{type:"unknown",inferred:!0}),new xr(this,e,{metadata:r,def:a}))}number(e,t){let i=t?.metadata,r=!1;if((!t||t.canonical===void 0||t.canonical==="Number"||t.canonical===!0||Array.isArray(t.canonical)&&t.canonical.includes("Number"))&&(r=!0),!r&&Kt(e))return this._fn("Rational",[this.number(e[0]),this.number(e[1])],{...i,canonical:!1});if(e=ou(this,e),i===void 0){if(typeof e=="number"){let o=e;if(o===1)return this.One;if(o===0)return this.Zero;if(o===-1)return this.NegativeOne;if(o===2)return this.Two;if(Number.isInteger(o)&&this._commonNumbers[o]!==void 0)return this._commonNumbers[o]??=new vn(this,e),this._commonNumbers[o];if(Number.isNaN(o))return this.NaN;if(!Number.isFinite(o))return o<0?this.NegativeInfinity:this.PositiveInfinity}else if(e instanceof le){if(e.isZero)return this.Zero;if(e.isOne)return this.One;if(e.isNegativeOne)return this.NegativeOne;if(e.isNaN)return this.NaN;if(e.isNegativeInfinity)return this.NegativeInfinity;if(e.isPositiveInfinity)return this.PositiveInfinity}}return new vn(this,e,{metadata:i})}rules(e,t){return os(this,e,t)}getRuleSet(e){if(e??="standard-simplification",e==="standard-simplification")return this._cache("standard-simplification-rules",()=>os(this,ly,{canonical:!0}));if(e==="solve-univariate")return this._cache("univariate-roots-rules",()=>os(this,Zg));if(e==="harmonization")return this._cache("harmonization-rules",()=>os(this,Hg))}_fn(e,t,i){let r=i?.canonical??!0;return new Me(this,e,t,{...i,canonical:r})}parse(e,t){if(e==null)return null;if(typeof e!="string")throw Error("ce.parse(): expected a LaTeX string");let i={imaginaryUnit:"\\imaginaryI",positiveInfinity:"\\infty",negativeInfinity:"-\\infty",notANumber:"\\operatorname{NaN}",decimalSeparator:this.decimalSeparator,digitGroup:3,digitGroupSeparator:"\\,",exponentProduct:"\\cdot",beginExponentMarker:"10^{",endExponentMarker:"}",truncationMarker:"\\ldots",repeatingDecimal:"auto",strict:!0,skipSpace:!0,parseNumbers:"auto",getSymbolType:o=>{let s=this.lookupDefinition(o);return s?ue(s)?s.operator.signature:re(s)?s.value.type:R.unknown:R.unknown},hasSubscriptEvaluate:o=>{let s=this.lookupDefinition(o);return!!(re(s)&&s.value.subscriptEvaluate)},parseUnexpectedToken:(o,s)=>null,preserveLatex:!1,quantifierScope:"tight",timeDerivativeVariable:"t"},r=pm(Ni(e)??e,this._indexedLatexDictionary,{...i,...t});if(r===null)throw Error("Failed to parse LaTeX string");return this.box(r,{canonical:t?.canonical??!0})}ask(e){let t=this.box(e,{canonical:!1}),i=[],r=c=>c.operator?.startsWith("_")||He(c)?!0:c.ops?c.ops.some(r):!1,o=c=>{let f=Object.keys(c).sort();for(let p of i){let d=Object.keys(p).sort();if(d.length!==f.length)continue;let m=!0;for(let g=0;g<f.length;g++){if(d[g]!==f[g]){m=!1;break}let h=f[g];if(!c[h].isSame(p[h])){m=!1;break}}if(m)return}i.push(c)},s=this.context.assumptions,a=()=>{let c=new Set;for(let[f,p]of s)if(p===!0)for(let d of f.symbols)c.add(d);return[...c]},u=c=>{let f=c.operator;if(f!=="Less"&&f!=="LessEqual"&&f!=="Greater"&&f!=="GreaterEqual")return[{pattern:c}];let p=f==="Greater"||f==="GreaterEqual"?c.op2:c.op1,d=f==="Greater"||f==="GreaterEqual"?c.op1:c.op2,m=f==="Less"||f==="Greater"?"Less":"LessEqual",g=this.box(["Add",p,["Negate",d]],{canonical:!1});return[{pattern:c},{pattern:this.box([m,g,0],{canonical:!1}),matchPermutations:!1}]};if(t.operator==="Element"&&t.op1?.symbol&&He(t.op2)){let c=pn(t.op2);if(c&&!c.startsWith("__")){let f=this.box(t.op1.symbol).type;f.isUnknown||o({[c]:this.box(f.toString(),{canonical:!1})})}}if((t.operator==="Greater"||t.operator==="GreaterEqual"||t.operator==="Less"||t.operator==="LessEqual")&&He(t.op2)){let c=pn(t.op2);if(c&&!c.startsWith("__")){let f=t.operator==="Greater"||t.operator==="GreaterEqual",p=t.operator==="Greater"||t.operator==="Less";if(t.op1?.symbol){let d=ss(this,t.op1.symbol),m=f?d.lowerBound:d.upperBound,g=f?d.lowerStrict:d.upperStrict;m!==void 0&&(!p||g===!0)&&o({[c]:m})}if(He(t.op1)){let d=pn(t.op1);if(d&&!d.startsWith("__"))for(let m of a()){let g=ss(this,m),h=f?g.lowerBound:g.upperBound,x=f?g.lowerStrict:g.upperStrict;h===void 0||p&&x!==!0||o({[d]:this.box(m,{canonical:!0}),[c]:h})}}}}let l=u(t);for(let[c,f]of s)if(f===!0)for(let{pattern:p,matchPermutations:d}of l){let m=c.match(p,{useVariations:!0,matchPermutations:d});m!==null&&o(m)}return i.length===0&&!r(t)&&!this._isVerifying&&this.verify(this.box(e,{canonical:!0}))===!0&&o({}),i}verify(e){if(!this._isVerifying){this._isVerifying=!0;try{let i=(Rr(e)?this.parse(e,{canonical:!1}):this.box(e,{canonical:!1})).evaluate();if(i.symbol==="True")return!0;if(i.symbol==="False")return!1;let r=i.operator;if(r==="Not"){let o=this.verify(i.op1);return o===void 0?void 0:!o}if(r==="And"){let o=!1;for(let s of i.ops??[]){let a=this.verify(s);if(a===!1)return!1;a===void 0&&(o=!0)}return o?void 0:!0}if(r==="Or"){let o=!1;for(let s of i.ops??[]){let a=this.verify(s);if(a===!0)return!0;a===void 0&&(o=!0)}return o?void 0:!1}return}finally{this._isVerifying=!1}}}assume(e){try{let t=Rr(e)?this.parse(e,{canonical:!1}):this.box(e,{canonical:!1});return this._generation+=1,gc(t)}catch(t){throw console.error(t.message.toString()),t}}forget(e){if(e===void 0){this.context.assumptions?.clear(),this._generation+=1;return}if(Array.isArray(e)){for(let t of e)this.forget(t);return}if(typeof e=="string"){for(let[t,i]of this.context.assumptions)t.has(e)&&this.context.assumptions.delete(t);for(let t of this._evalContextStack)e in t.values&&delete t.values[e]}this._generation+=1}};function vy(n,e){if(e==null||typeof e=="function")return;if(typeof e=="boolean")return e?n.True:n.False;if(typeof e=="number"||typeof e=="bigint")return n.number(e);let t=n.box(e);if(t.operator!=="Function"&&!t.unknowns.some(i=>i.startsWith("_")))return t}function Ey(n,e){if(typeof e=="function")return{evaluate:e,signature:"function"};if(e==null||typeof e=="boolean")return;let t=Le(n.box(e));if(t!==void 0)return{evaluate:t}}function _y(n,e,t){let i="";if(re(e)){let r=[];e.value.holdUntil==="never"&&r.push("(hold never)"),e.value.holdUntil==="N"&&r.push("(hold until N)"),e.value.inferredType&&r.push("inferred");let o=r.length>0?` ${r.join(" ")}`:"";i=`${Io}${n}${mn}:${o}`,e.value.isConstant?(i+=` const ${e.value.type.toString()}`,e.value.value!==void 0&&(i+=` = ${e.value.value?.toString()}`)):i+=` ${e.value.type.toString()}`}else if(ue(e)){let r=[];e.operator.inferredSignature&&r.push("(inferred)");let o=r.length>0?` (${r.join(" ")})`:"";i=`${Io}${n}${mn}:${o} ${e.operator.signature.toString()}`;let s=[];e.operator.lazy&&s.push("lazy"),e.operator.scoped&&s.push("scoped"),e.operator.broadcastable&&s.push("broadcastable"),e.operator.associative&&s.push("associative"),e.operator.commutative&&s.push("commutative"),e.operator.idempotent&&s.push("idempotent"),e.operator.involution&&s.push("involution"),e.operator.pure||s.push("not pure");let a=s.map(u=>`${_r}${u}${mn}`).join(" ");a.length>0&&(i+=`
|
|
1056
|
-
\u2514 ${a}`)}else i="unknown";return t&&(t.isValid?t.isCanonical?i+=` = ${_r}${t.toString()}${mn}`:i+=` = ${Mp}${t.toString()}${mn} (not canonical)`:i+=` = ${Dp}${t.toString()}${mn} (not valid)`),i}Zl();Mt();var vL="0.35.
|
|
1071
|
+
\u2514 ${a}`)}else i="unknown";return t&&(t.isValid?t.isCanonical?i+=` = ${_r}${t.toString()}${mn}`:i+=` = ${Mp}${t.toString()}${mn} (not canonical)`:i+=` = ${Dp}${t.toString()}${mn} (not valid)`),i}Zl();Mt();var vL="0.35.4";globalThis[Symbol.for("io.cortexjs.compute-engine")]={ComputeEngine:Ps.prototype.constructor,version:"0.35.4"};export{Je as BaseCompiler,R as BoxedType,Ps as ComputeEngine,Eo as GLSLTarget,vo as JavaScriptTarget,le as NumericValue,vL as version};
|
|
1057
1072
|
/*! Bundled license information:
|
|
1058
1073
|
|
|
1059
1074
|
complex-esm/dist/src/complex.js:
|