curvy 2.0.0-alpha.0 → 2.0.0-alpha.2
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/characteristic/index.d.mts +3 -3
- package/dist/characteristic/index.mjs +1 -1
- package/dist/curve/index.d.mts +1 -1
- package/dist/curve/index.mjs +1 -1
- package/dist/interval/index.d.mts +3 -2
- package/dist/interval/index.mjs +3 -2
- package/dist/matrix/index.d.mts +1 -1
- package/dist/number.mjs.map +1 -1
- package/dist/path/index.d.mts +26 -6
- package/dist/path/index.mjs +36 -3
- package/dist/path/index.mjs.map +1 -1
- package/dist/polynomial/index.d.mts +1 -1
- package/dist/polynomial/index.mjs +2 -2
- package/dist/shared/{characteristic-BGRxcxUH.mjs → characteristic-B9nCh_cx.mjs} +2 -2
- package/dist/shared/{characteristic-BGRxcxUH.mjs.map → characteristic-B9nCh_cx.mjs.map} +1 -1
- package/dist/shared/{cubic-Dfn6DB02.d.mts → cubic-BajUY0JT.d.mts} +12 -11
- package/dist/shared/{cubic-CYYEUHNm.mjs → cubic-CpHAx8cC.mjs} +5 -5
- package/dist/shared/cubic-CpHAx8cC.mjs.map +1 -0
- package/dist/shared/{interval-CCEqzPgA.mjs → interval-05CR6eBf.mjs} +47 -2
- package/dist/shared/interval-05CR6eBf.mjs.map +1 -0
- package/dist/shared/{interval-hQDiKqj0.d.mts → interval-Dy-RMEE3.d.mts} +43 -4
- package/dist/shared/interval2d-8IBZnUOq.mjs +108 -0
- package/dist/shared/interval2d-8IBZnUOq.mjs.map +1 -0
- package/dist/shared/interval2d-C2id9u31.d.mts +172 -0
- package/dist/shared/{matrix4x4-Bt_DBlP0.d.mts → matrix4x4-Dm_tSiH1.d.mts} +4 -3
- package/dist/shared/{quadratic-DEhuAKuE.mjs → quadratic-CamozcFc.mjs} +3 -3
- package/dist/shared/quadratic-CamozcFc.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-D_-XWxcm.d.mts → rationalCubic2d-B6g97ryJ.d.mts} +16 -5
- package/dist/shared/{rationalCubic2d-CXa7Yren.mjs → rationalCubic2d-BEgUGSFf.mjs} +20 -3
- package/dist/shared/rationalCubic2d-BEgUGSFf.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-CP4oGpnk.mjs → rationalCubic2d-Bys2Uory.mjs} +44 -7
- package/dist/shared/rationalCubic2d-Bys2Uory.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-BPLohNuI.d.mts → rationalCubic2d-DlQfBURs.d.mts} +40 -9
- package/dist/shared/{solution-CbSWzXCn.mjs → solution-CrtLfqEq.mjs} +2 -2
- package/dist/shared/{solution-CbSWzXCn.mjs.map → solution-CrtLfqEq.mjs.map} +1 -1
- package/dist/shared/{solution-BjoW7ov4.d.mts → solution-sNQ-ZVhN.d.mts} +3 -3
- package/dist/shared/{utils-DqTGyXrP.d.mts → utils-MCckigYk.d.mts} +1 -1
- package/dist/shared/vector2-DPUY3_eA.d.mts +470 -0
- package/dist/shared/{vector2-TV0UnlxY.d.mts → vector3-DqeOZtOB.d.mts} +43 -508
- package/dist/solution/index.d.mts +1 -1
- package/dist/solution/index.mjs +1 -1
- package/dist/splines/index.d.mts +4 -4
- package/dist/splines/index.mjs +4 -4
- package/dist/utils.d.mts +1 -1
- package/dist/vector/index.d.mts +2 -1
- package/package.json +1 -1
- package/dist/shared/cubic-CYYEUHNm.mjs.map +0 -1
- package/dist/shared/interval-CCEqzPgA.mjs.map +0 -1
- package/dist/shared/quadratic-DEhuAKuE.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-CP4oGpnk.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-CXa7Yren.mjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as solution_d_exports } from "../shared/solution-
|
|
1
|
+
import { a as solution_d_exports } from "../shared/solution-sNQ-ZVhN.mjs";
|
|
2
2
|
export { solution_d_exports as Solution };
|
package/dist/solution/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as solution_exports } from "../shared/solution-
|
|
1
|
+
import { c as solution_exports } from "../shared/solution-CrtLfqEq.mjs";
|
|
2
2
|
export { solution_exports as Solution };
|
package/dist/splines/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as Weighted, t as Vector2 } from "../shared/vector2-
|
|
2
|
-
import { t as Pipeable } from "../shared/utils-
|
|
3
|
-
import { t as AtMostOne } from "../shared/solution-
|
|
4
|
-
import { r as CubicPath2d, t as RationalCubicPath2d } from "../shared/rationalCubic2d-
|
|
1
|
+
import { n as Weighted, t as Vector2 } from "../shared/vector2-DPUY3_eA.mjs";
|
|
2
|
+
import { t as Pipeable } from "../shared/utils-MCckigYk.mjs";
|
|
3
|
+
import { t as AtMostOne } from "../shared/solution-sNQ-ZVhN.mjs";
|
|
4
|
+
import { r as CubicPath2d, t as RationalCubicPath2d } from "../shared/rationalCubic2d-B6g97ryJ.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/splines/rationalBezier2d.internal.d.ts
|
|
7
7
|
declare const RationalBezier2dTypeId: unique symbol;
|
package/dist/splines/index.mjs
CHANGED
|
@@ -5,10 +5,10 @@ import { a as makeWeighted, i as make$10, o as scale, s as subtract, t as add }
|
|
|
5
5
|
import { t as make$11 } from "../shared/vector3-D-tv_aKL.mjs";
|
|
6
6
|
import { n as transpose, t as make$12 } from "../shared/vector4-5KbjoHVj.mjs";
|
|
7
7
|
import { a as vectorProductLeft, i as multiply, t as inverse } from "../shared/matrix4x4-Ck2WROK-.mjs";
|
|
8
|
-
import { o as none, s as one } from "../shared/solution-
|
|
9
|
-
import { n as fromBezierPoints,
|
|
10
|
-
import { a as cubicCardinal, i as cubicBezier, o as cubicHermite, r as cubicBasisSpline, t as apply } from "../shared/characteristic-
|
|
11
|
-
import { i as make$13, t as fromArray$10 } from "../shared/rationalCubic2d-
|
|
8
|
+
import { o as none, s as one } from "../shared/solution-CrtLfqEq.mjs";
|
|
9
|
+
import { n as fromBezierPoints, s as fromPolynomials } from "../shared/rationalCubic2d-Bys2Uory.mjs";
|
|
10
|
+
import { a as cubicCardinal, i as cubicBezier, o as cubicHermite, r as cubicBasisSpline, t as apply } from "../shared/characteristic-B9nCh_cx.mjs";
|
|
11
|
+
import { i as make$13, t as fromArray$10 } from "../shared/rationalCubic2d-BEgUGSFf.mjs";
|
|
12
12
|
//#region src/splines/rationalBezier2d.internal.ts
|
|
13
13
|
const RationalBezier2dTypeId = Symbol("curvy/splines/rationalBezier2d");
|
|
14
14
|
var RationalBezier2dImpl = class extends Pipeable {
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as pipe, n as dual, r as invariant, t as Pipeable } from "./shared/utils-
|
|
1
|
+
import { i as pipe, n as dual, r as invariant, t as Pipeable } from "./shared/utils-MCckigYk.mjs";
|
|
2
2
|
export { Pipeable, dual, invariant, pipe };
|
package/dist/vector/index.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as vector2_d_exports } from "../shared/vector2-DPUY3_eA.mjs";
|
|
2
|
+
import { i as vector4_d_exports, n as vector3_d_exports } from "../shared/vector3-DqeOZtOB.mjs";
|
|
2
3
|
export { vector2_d_exports as Vector2, vector3_d_exports as Vector3, vector4_d_exports as Vector4 };
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cubic-CYYEUHNm.mjs","names":["equals","make","fromVector","fromPoints","solve","toSolver","solveInverse","Solution.none","Solution.one","toInverseSolver","monotonicity","isMonotonic","isIncreasing","isDecreasing","asMonotonic","asIncreasing","asDecreasing","derivative","antiderivative","domain","Interval.make","Solution.isNone","range","length","Interval.size","fromPoints","make","equals","fromVector","solve","toSolver","solveInverse","Linear.solveInverse","Linear.make","Solution.none","Solution.one","Solution.two","toInverseSolver","derivative","roots","Solution.match","Vector2.make","monotonicity","Interval.size","Linear.monotonicity","Interval.contains","Interval.toOpen","isMonotonic","isIncreasing","isDecreasing","asMonotonic","asIncreasing","asDecreasing","domain","Interval.fromMinMax","range","Linear.range","length","Linear.length","Linear.solve","curvature","make","isCubicPolynomial","equals","fromVector","fromPoints","solve","toSolver","solveInverse","Quadratic.solveInverse","Quadratic.make","Solution.fromArray","toInverseSolver","derivative","subdivide","roots","extrema","Quadratic.roots","monotonicity","Interval.size","Linear.monotonicity","Linear.make","Quadratic.monotonicity","Interval.filter","Interval.toOpen","isMonotonic","isIncreasing","isDecreasing","asMonotonic","asIncreasing","asDecreasing","domain","Interval.fromMinMax","range","length","Linear.length","Quadratic.length","Interval.scaleShift","Interval.biunit","Quadratic.solve","curvature","Quadratic.derivative","Linear.solve","internal.isCubicPolynomial","internal.equals","internal.make","internal.fromVector","internal.fromPoints","internal.solve","internal.toSolver","internal.solveInverse","internal.toInverseSolver","internal.derivative","internal.subdivide","internal.roots","internal.extrema","internal.monotonicity","internal.isMonotonic","internal.isIncreasing","internal.isDecreasing","internal.asMonotonic","internal.asIncreasing","internal.asDecreasing","internal.domain","internal.range","internal.length","internal.curvature"],"sources":["../../src/polynomial/quadratic.internal.circular.ts","../../src/polynomial/linear.internal.ts","../../src/polynomial/cubic.internal.circular.ts","../../src/polynomial/monotonicity.ts","../../src/polynomial/quadratic.internal.ts","../../src/length.ts","../../src/polynomial/cubic.internal.ts","../../src/polynomial/cubic.ts"],"sourcesContent":["import { Pipeable } from '../utils'\nimport type { QuadraticPolynomial } from './quadratic'\nimport { PolynomialTraits } from './traits'\n\nexport const QuadraticPolynomialTypeId: unique symbol = Symbol.for('curvy/polynomial/quadratic')\nexport type QuadraticPolynomialTypeId = typeof QuadraticPolynomialTypeId\n\nexport class QuadraticPolynomialImpl extends Pipeable implements QuadraticPolynomial<unknown> {\n readonly [QuadraticPolynomialTypeId]: QuadraticPolynomialTypeId = QuadraticPolynomialTypeId\n declare readonly [PolynomialTraits]: unknown\n\n readonly c0: number\n readonly c1: number\n readonly c2: number\n\n constructor(c0 = 0, c1 = 0, c2 = 0) {\n super()\n\n this.c0 = c0\n this.c1 = c1\n this.c2 = c2\n }\n}\n","import * as Interval from '../interval/interval'\nimport { dual, Pipeable } from '../utils'\nimport * as Solution from '../solution/solution'\nimport { invariant } from '../utils'\nimport { epsEquals } from '../number'\nimport type { Vector2 } from '../vector/vector2'\nimport type { LinearPolynomial } from './linear'\nimport type { Decreasing, Increasing, Monotonic } from './traits'\nimport { PolynomialTraits } from './traits'\nimport type { QuadraticPolynomial } from './quadratic'\nimport { QuadraticPolynomialImpl } from './quadratic.internal.circular'\n\nexport const LinearPolynomialTypeId: unique symbol = Symbol.for('curvy/linear')\nexport type LinearPolynomialTypeId = typeof LinearPolynomialTypeId\n\nclass LinearPolynomialImpl extends Pipeable implements LinearPolynomial<unknown> {\n readonly [LinearPolynomialTypeId]: LinearPolynomialTypeId = LinearPolynomialTypeId\n declare readonly [PolynomialTraits]: unknown\n\n readonly c0: number\n readonly c1: number\n\n constructor(c0 = 0, c1 = 0) {\n super()\n\n this.c0 = c0\n this.c1 = c1\n }\n}\n\nexport const isLinearPolynomial = (v: unknown): v is LinearPolynomial =>\n typeof v === 'object' && v !== null && LinearPolynomialTypeId in v\n\nexport const equals = dual<\n (b: LinearPolynomial) => (a: LinearPolynomial) => boolean,\n (a: LinearPolynomial, b: LinearPolynomial) => boolean\n>(2, (a: LinearPolynomial, b: LinearPolynomial) => epsEquals(a.c0, b.c0) && epsEquals(a.c1, b.c1))\n\nexport const make = (c0 = 0, c1 = 0): LinearPolynomial => new LinearPolynomialImpl(c0, c1)\n\nexport const fromVector = (v: Vector2) => new LinearPolynomialImpl(v.x, v.y)\n\nexport const fromPointSlope = (p: Vector2, slope: number) =>\n new LinearPolynomialImpl(p.y - slope * p.x, slope)\n\nexport const fromPoints = (p1: Vector2, p2: Vector2) =>\n fromPointSlope(p1, (p2.y - p1.y) / (p2.x - p1.x))\n\nexport const solve = dual<\n (x: number) => (p: LinearPolynomial) => number,\n (p: LinearPolynomial, x: number) => number\n>(2, (p: LinearPolynomial, x: number) => p.c0 + x * p.c1)\n\nexport const toSolver = (p: LinearPolynomial) => (x: number) => solve(p, x)\n\nexport const solveInverse = dual<\n (y: number) => (p: LinearPolynomial) => Solution.AtMostOne<number>,\n (p: LinearPolynomial, y: number) => Solution.AtMostOne<number>\n>(2, (p: LinearPolynomial, y: number) => {\n if (p.c1 === 0) {\n return Solution.none\n }\n return Solution.one((y - p.c0) / p.c1)\n})\n\nexport const toInverseSolver = (p: LinearPolynomial) => (y: number) => solveInverse(p, y)\n\nexport const monotonicity = (p: LinearPolynomial) =>\n p.c1 === 0 ? 'constant' : p.c1 > 0 ? 'increasing' : 'decreasing'\n\nexport const isMonotonic = <T>(p: LinearPolynomial<T>): p is LinearPolynomial<T & Monotonic> =>\n p.c1 !== 0\n\nexport const isIncreasing = <T>(p: LinearPolynomial<T>): p is LinearPolynomial<T & Increasing> =>\n p.c1 > 0\n\nexport const isDecreasing = <T>(p: LinearPolynomial<T>): p is LinearPolynomial<T & Decreasing> =>\n p.c1 < 0\n\nexport const asMonotonic = <T>(p: LinearPolynomial<T>): LinearPolynomial<T & Monotonic> => {\n invariant(isMonotonic(p), 'linear polynomial is not monotonic')\n return p\n}\n\nexport const asIncreasing = <T>(p: LinearPolynomial<T>): LinearPolynomial<T & Increasing> => {\n invariant(isIncreasing(p), 'linear polynomial is not increasing')\n return p\n}\n\nexport const asDecreasing = <T>(p: LinearPolynomial<T>): LinearPolynomial<T & Decreasing> => {\n invariant(isDecreasing(p), 'linear polynomial is not decreasing')\n return p\n}\n\nexport const derivative = (p: LinearPolynomial) => p.c1\n\nexport const antiderivative = dual<\n (integrationConstant: number) => (p: LinearPolynomial) => QuadraticPolynomial,\n (p: LinearPolynomial, integrationConstant?: number) => QuadraticPolynomial\n>(\n (args) => isLinearPolynomial(args[0]),\n (p: LinearPolynomial, integrationConstant = 0) =>\n new QuadraticPolynomialImpl(integrationConstant, p.c0, p.c1 / 2),\n)\n\nexport const domain = dual<\n (range: Interval.Interval) => (p: LinearPolynomial) => Solution.AtMostOne<Interval.Interval>,\n (p: LinearPolynomial, range: Interval.Interval) => Solution.AtMostOne<Interval.Interval>\n>(2, (p: LinearPolynomial, r: Interval.Interval) => {\n if (p.c1 === 0) {\n if (r.start === p.c0 && r.end === p.c0) {\n return Solution.one(Interval.make(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY))\n }\n return Solution.none\n }\n\n const start = solveInverse(p, r.start)\n const end = solveInverse(p, r.end)\n\n if (Solution.isNone(start) || Solution.isNone(end)) {\n return Solution.none\n }\n\n return Solution.one(Interval.make(start.value, end.value))\n})\n\nexport const range = dual<\n (domain: Interval.Interval) => (p: LinearPolynomial) => Interval.Interval,\n (p: LinearPolynomial, domain: Interval.Interval) => Interval.Interval\n>(2, (p: LinearPolynomial, d: Interval.Interval) =>\n Interval.make(solve(p, d.start), solve(p, d.end)),\n)\n\nexport const length = dual<\n (domain: Interval.Interval) => (p: LinearPolynomial) => number,\n (p: LinearPolynomial, domain: Interval.Interval) => number\n>(2, (p: LinearPolynomial, d: Interval.Interval) => {\n if (Interval.size(d) === 0) {\n return 0\n }\n\n if (p.c1 === 0) {\n return Interval.size(d)\n }\n\n return Math.sqrt(1 + p.c1 ** 2) * Interval.size(d)\n})\n","import { Pipeable } from '../utils'\nimport type { CubicPolynomial } from './cubic'\nimport { PolynomialTraits } from './traits'\n\nexport const CubicPolynomialTypeId: unique symbol = Symbol.for('curvy/polynomial/cubic')\nexport type CubicPolynomialTypeId = typeof CubicPolynomialTypeId\n\nexport class CubicPolynomialImpl extends Pipeable implements CubicPolynomial<unknown> {\n readonly [CubicPolynomialTypeId]: CubicPolynomialTypeId = CubicPolynomialTypeId\n declare readonly [PolynomialTraits]: unknown\n\n readonly c0: number\n readonly c1: number\n readonly c2: number\n readonly c3: number\n\n constructor(c0 = 0, c1 = 0, c2 = 0, c3 = 0) {\n super()\n\n this.c0 = c0\n this.c1 = c1\n this.c2 = c2\n this.c3 = c3\n }\n}\n","export type Monotonicity = 'none' | 'increasing' | 'decreasing' | 'constant'\nexport type GuaranteedMonotonicity = 'increasing' | 'decreasing' | 'constant'\n\nexport function guaranteedMonotonicityFromComparison(\n s0: number,\n s1: number,\n): GuaranteedMonotonicity {\n if (s0 < s1) {\n return 'increasing'\n }\n\n if (s0 > s1) {\n return 'decreasing'\n }\n\n return 'constant'\n}\n","import * as Interval from '../interval/interval'\nimport { dual } from '../utils'\nimport * as Solution from '../solution/solution'\nimport { invariant } from '../utils'\nimport { epsEquals } from '../number'\nimport * as Vector2 from '../vector/vector2'\nimport type { Vector3 } from '../vector/vector3'\nimport type { CubicPolynomial } from './cubic'\nimport { CubicPolynomialImpl } from './cubic.internal.circular'\nimport * as Linear from './linear.internal'\nimport { guaranteedMonotonicityFromComparison, type Monotonicity } from './monotonicity'\nimport type { QuadraticPolynomial } from './quadratic'\nimport { QuadraticPolynomialImpl, QuadraticPolynomialTypeId } from './quadratic.internal.circular'\nimport type { Decreasing, Increasing, Monotonic } from './traits'\n\nexport const fromPoints = (\n p0: Vector2.Vector2,\n p1: Vector2.Vector2,\n p2: Vector2.Vector2,\n): QuadraticPolynomial => {\n // Newton's divided differences, then collected to monomial form.\n const f01 = (p1.y - p0.y) / (p1.x - p0.x)\n const f12 = (p2.y - p1.y) / (p2.x - p1.x)\n const f012 = (f12 - f01) / (p2.x - p0.x)\n\n return new QuadraticPolynomialImpl(\n p0.y - f01 * p0.x + f012 * p0.x * p1.x,\n f01 - f012 * (p0.x + p1.x),\n f012,\n )\n}\n\nexport const make = (c0 = 0, c1 = 0, c2 = 0): QuadraticPolynomial =>\n new QuadraticPolynomialImpl(c0, c1, c2)\n\nexport const isQuadraticPolynomial = (v: unknown): v is QuadraticPolynomial =>\n typeof v === 'object' && v !== null && QuadraticPolynomialTypeId in v\n\nexport const equals = dual<\n (b: QuadraticPolynomial) => (a: QuadraticPolynomial) => boolean,\n (a: QuadraticPolynomial, b: QuadraticPolynomial) => boolean\n>(\n 2,\n (a: QuadraticPolynomial, b: QuadraticPolynomial) =>\n epsEquals(a.c0, b.c0) && epsEquals(a.c1, b.c1) && epsEquals(a.c2, b.c2),\n)\n\nexport const fromVector = (v: Vector3) => new QuadraticPolynomialImpl(v.x, v.y, v.z)\n\nexport const solve = dual<\n (x: number) => (p: QuadraticPolynomial) => number,\n (p: QuadraticPolynomial, x: number) => number\n>(2, (p: QuadraticPolynomial, x: number) => p.c0 + x * p.c1 + x ** 2 * p.c2)\n\nexport const toSolver = (p: QuadraticPolynomial) => (x: number) => solve(p, x)\n\nexport const solveInverse: {\n (p: QuadraticPolynomial, y: number): Solution.AtMostTwo<number>\n (y: number): (p: QuadraticPolynomial) => Solution.AtMostTwo<number>\n} = dual<\n (y: number) => (p: QuadraticPolynomial) => Solution.AtMostTwo<number>,\n (p: QuadraticPolynomial, y: number) => Solution.AtMostTwo<number>\n>(2, (p: QuadraticPolynomial, y: number) => {\n // c2 = 0: the polynomial is actually linear in disguise. Defer rather than\n // dividing by zero in the quadratic formula.\n if (p.c2 === 0) {\n return Linear.solveInverse(Linear.make(p.c0, p.c1), y)\n }\n\n const discriminant = p.c1 ** 2 - 4 * p.c2 * (p.c0 - y)\n\n if (discriminant < 0) {\n return Solution.none\n }\n\n if (discriminant === 0) {\n return Solution.one(-p.c1 / (2 * p.c2))\n }\n\n const sqrtDiscriminant = Math.sqrt(discriminant)\n const a = (-p.c1 + sqrtDiscriminant) / (2 * p.c2)\n const b = (-p.c1 - sqrtDiscriminant) / (2 * p.c2)\n return a < b ? Solution.two(a, b) : Solution.two(b, a)\n})\n\nexport const toInverseSolver =\n (p: QuadraticPolynomial) =>\n (y: number): Solution.AtMostTwo<number> =>\n solveInverse(p, y)\n\nexport const derivative = (p: QuadraticPolynomial) => Linear.make(p.c1, p.c2 * 2)\n\nexport const roots = (p: QuadraticPolynomial) => solveInverse(p, 0)\n\nexport const extreme = (p: QuadraticPolynomial) =>\n derivative(p).pipe(\n Linear.solveInverse(0),\n Solution.match({\n onNone: () => null,\n onSome: ({ value: t }) => Vector2.make(t, solve(p, t)),\n }),\n )\n\nexport const monotonicity = dual<\n (i: Interval.Interval) => (p: QuadraticPolynomial) => Monotonicity,\n (p: QuadraticPolynomial, i?: Interval.Interval) => Monotonicity\n>(\n (args) => isQuadraticPolynomial(args[0]),\n (p: QuadraticPolynomial, i?: Interval.Interval) => {\n invariant(\n i === undefined || Interval.size(i) > 0,\n 'monotonicity is undefined over a zero-width interval',\n )\n\n if (p.c2 === 0 && p.c1 === 0) {\n return 'constant'\n }\n\n if (p.c2 === 0) {\n return Linear.monotonicity(Linear.make(p.c0, p.c1))\n }\n\n // c2 is non-zero, so the extreme is guaranteed to be non-null\n const e = extreme(p) as Vector2.Vector2\n\n // if there is no interval, or the extreme is within the interval,\n // the monotonicity is none\n if (i === undefined || Interval.contains(Interval.toOpen(i), e.x)) {\n return 'none'\n }\n\n return guaranteedMonotonicityFromComparison(solve(p, i.start), solve(p, i.end))\n },\n)\n\nexport const isMonotonic = dual<\n (\n i: Interval.Interval,\n ) => <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Monotonic>,\n <T>(p: QuadraticPolynomial<T>, i?: Interval.Interval) => p is QuadraticPolynomial<T & Monotonic>\n>((args) => isQuadraticPolynomial(args[0]), ((p: QuadraticPolynomial, i?: Interval.Interval) => {\n const m = monotonicity(p, i as Interval.Interval)\n return m === 'increasing' || m === 'decreasing'\n}) as never)\n\nexport const isIncreasing = dual<\n (\n i: Interval.Interval,\n ) => <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Increasing>,\n <T>(p: QuadraticPolynomial<T>, i?: Interval.Interval) => p is QuadraticPolynomial<T & Increasing>\n>(\n (args) => isQuadraticPolynomial(args[0]),\n ((p: QuadraticPolynomial, i?: Interval.Interval) =>\n monotonicity(p, i as Interval.Interval) === 'increasing') as never,\n)\n\nexport const isDecreasing = dual<\n (\n i: Interval.Interval,\n ) => <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Decreasing>,\n <T>(p: QuadraticPolynomial<T>, i?: Interval.Interval) => p is QuadraticPolynomial<T & Decreasing>\n>(\n (args) => isQuadraticPolynomial(args[0]),\n ((p: QuadraticPolynomial, i?: Interval.Interval) =>\n monotonicity(p, i as Interval.Interval) === 'decreasing') as never,\n)\n\nexport const asMonotonic = <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval.Interval,\n): QuadraticPolynomial<T & Monotonic> => {\n invariant(isMonotonic(p, i as Interval.Interval), 'quadratic polynomial is not monotonic')\n return p\n}\n\nexport const asIncreasing = <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval.Interval,\n): QuadraticPolynomial<T & Increasing> => {\n invariant(isIncreasing(p, i as Interval.Interval), 'quadratic polynomial is not increasing')\n return p\n}\n\nexport const asDecreasing = <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval.Interval,\n): QuadraticPolynomial<T & Decreasing> => {\n invariant(isDecreasing(p, i as Interval.Interval), 'quadratic polynomial is not decreasing')\n return p\n}\n\nexport const antiderivative = dual<\n (integrationConstant: number) => (p: QuadraticPolynomial) => CubicPolynomial,\n (p: QuadraticPolynomial, integrationConstant?: number) => CubicPolynomial\n>(\n 2,\n (p: QuadraticPolynomial, integrationConstant = 0) =>\n new CubicPolynomialImpl(integrationConstant, p.c0, p.c1 / 2, p.c2 / 3),\n)\n\nexport const domain = dual<\n (range: Interval.Interval) => (p: QuadraticPolynomial) => Solution.AtMostOne<Interval.Interval>,\n (p: QuadraticPolynomial, range: Interval.Interval) => Solution.AtMostOne<Interval.Interval>\n>(2, (p: QuadraticPolynomial, r: Interval.Interval) => {\n const start = solveInverse(p, r.start)\n const end = solveInverse(p, r.end)\n\n if (start.length === 0 && end.length === 0) {\n return Solution.none\n }\n\n return Solution.one(Interval.fromMinMax(...start, ...end))\n})\n\nexport const range = dual<\n (domain: Interval.Interval) => (p: QuadraticPolynomial) => Interval.Interval,\n (p: QuadraticPolynomial, domain: Interval.Interval) => Interval.Interval\n>(2, (p: QuadraticPolynomial, d: Interval.Interval) => {\n if (p.c2 === 0) {\n return Linear.range(Linear.make(p.c0, p.c1), d)\n }\n\n const e = extreme(p)\n\n return e !== null && Interval.contains(d, e.x)\n ? Interval.fromMinMax(solve(p, d.start), solve(p, d.end), e.y)\n : Interval.fromMinMax(solve(p, d.start), solve(p, d.end))\n})\n\nexport const length = dual<\n (domain: Interval.Interval) => (p: QuadraticPolynomial) => number,\n (p: QuadraticPolynomial, domain: Interval.Interval) => number\n>(2, (p: QuadraticPolynomial, dom: Interval.Interval) => {\n if (Interval.size(dom) === 0) {\n return 0\n }\n\n if (p.c2 === 0) {\n return Linear.length(Linear.make(p.c0, p.c1), dom)\n }\n\n const dp = derivative(p)\n\n const derivativeStart = Linear.solve(dp, dom.start)\n const sqrtStart = Math.sqrt(1 + derivativeStart ** 2)\n const evalStart =\n (derivativeStart * sqrtStart + Math.log(Math.abs(derivativeStart + sqrtStart))) / (4 * p.c2)\n\n const derivativeEnd = Linear.solve(dp, dom.end)\n const sqrtEnd = Math.sqrt(1 + derivativeEnd ** 2)\n const evalEnd =\n (derivativeEnd * sqrtEnd + Math.log(Math.abs(derivativeEnd + sqrtEnd))) / (4 * p.c2)\n\n return evalEnd - evalStart\n})\n\nexport const curvature = dual<\n (x: number) => (p: QuadraticPolynomial) => number,\n (p: QuadraticPolynomial, x: number) => number\n>(\n 2,\n (p: QuadraticPolynomial, x: number) =>\n Math.abs(2 * p.c2) / (1 + (Linear.solve(derivative(p), x) ** 2) ** 1.5),\n)\n","export const GL32_X0 = 0.9972638618494816\nexport const GL32_X1 = 0.9856115115452684\nexport const GL32_X2 = 0.9647622555875064\nexport const GL32_X3 = 0.9349060759377397\nexport const GL32_X4 = 0.8963211557660521\nexport const GL32_X5 = 0.84936761373257\nexport const GL32_X6 = 0.7944837959679424\nexport const GL32_X7 = 0.7321821187402897\nexport const GL32_X8 = 0.6630442669302152\nexport const GL32_X9 = 0.5877157572407623\nexport const GL32_X10 = 0.5068999089322294\nexport const GL32_X11 = 0.42135127613063533\nexport const GL32_X12 = 0.33186860228212767\nexport const GL32_X13 = 0.23928736225213706\nexport const GL32_X14 = 0.1444719615827965\nexport const GL32_X15 = 0.04830766568773831\nexport const GL32_W0 = 0.007018610009470136\nexport const GL32_W1 = 0.01627439473090571\nexport const GL32_W2 = 0.02539206530926214\nexport const GL32_W3 = 0.03427386291302141\nexport const GL32_W4 = 0.042835898022226704\nexport const GL32_W5 = 0.050998059262376154\nexport const GL32_W6 = 0.05868409347853558\nexport const GL32_W7 = 0.06582222277636195\nexport const GL32_W8 = 0.07234579410884862\nexport const GL32_W9 = 0.07819389578707044\nexport const GL32_W10 = 0.08331192422694672\nexport const GL32_W11 = 0.08765209300440374\nexport const GL32_W12 = 0.0911738786957639\nexport const GL32_W13 = 0.09384439908080454\nexport const GL32_W14 = 0.09563872007927485\nexport const GL32_W15 = 0.09654008851472785\n","import * as Interval from '../interval/interval'\nimport {\n GL32_W0,\n GL32_W1,\n GL32_W2,\n GL32_W3,\n GL32_W4,\n GL32_W5,\n GL32_W6,\n GL32_W7,\n GL32_W8,\n GL32_W9,\n GL32_W10,\n GL32_W11,\n GL32_W12,\n GL32_W13,\n GL32_W14,\n GL32_W15,\n GL32_X0,\n GL32_X1,\n GL32_X2,\n GL32_X3,\n GL32_X4,\n GL32_X5,\n GL32_X6,\n GL32_X7,\n GL32_X8,\n GL32_X9,\n GL32_X10,\n GL32_X11,\n GL32_X12,\n GL32_X13,\n GL32_X14,\n GL32_X15,\n} from '../length'\nimport { dual } from '../utils'\nimport * as Solution from '../solution/solution'\nimport { invariant } from '../utils'\nimport { clampToZero, epsEquals } from '../number'\nimport type * as Vector2 from '../vector/vector2'\nimport type { Vector4 } from '../vector/vector4'\nimport type { CubicPolynomial } from './cubic'\nimport { CubicPolynomialImpl, CubicPolynomialTypeId } from './cubic.internal.circular'\nimport type { Decreasing, Increasing, Monotonic } from './traits'\nimport * as Linear from './linear.internal'\nimport { guaranteedMonotonicityFromComparison, type Monotonicity } from './monotonicity'\nimport * as Quadratic from './quadratic.internal'\n\nexport const make = (c0 = 0, c1 = 0, c2 = 0, c3 = 0): CubicPolynomial =>\n new CubicPolynomialImpl(c0, c1, c2, c3)\n\nexport const isCubicPolynomial = (v: unknown): v is CubicPolynomial =>\n typeof v === 'object' && v !== null && CubicPolynomialTypeId in v\n\nexport const equals = dual<\n (b: CubicPolynomial) => (a: CubicPolynomial) => boolean,\n (a: CubicPolynomial, b: CubicPolynomial) => boolean\n>(\n 2,\n (a: CubicPolynomial, b: CubicPolynomial) =>\n epsEquals(a.c0, b.c0) &&\n epsEquals(a.c1, b.c1) &&\n epsEquals(a.c2, b.c2) &&\n epsEquals(a.c3, b.c3),\n)\n\nexport const fromVector = (v: Vector4) => new CubicPolynomialImpl(v.x, v.y, v.z, v.w)\n\nexport const fromPoints = (\n p0: Vector2.Vector2,\n p1: Vector2.Vector2,\n p2: Vector2.Vector2,\n p3: Vector2.Vector2,\n): CubicPolynomial => {\n // Newton's divided differences, then collected to monomial form.\n const f01 = (p1.y - p0.y) / (p1.x - p0.x)\n const f12 = (p2.y - p1.y) / (p2.x - p1.x)\n const f23 = (p3.y - p2.y) / (p3.x - p2.x)\n const f012 = (f12 - f01) / (p2.x - p0.x)\n const f123 = (f23 - f12) / (p3.x - p1.x)\n const f0123 = (f123 - f012) / (p3.x - p0.x)\n\n return new CubicPolynomialImpl(\n p0.y - f01 * p0.x + f012 * p0.x * p1.x - f0123 * p0.x * p1.x * p2.x,\n f01 - f012 * (p0.x + p1.x) + f0123 * (p0.x * p1.x + p0.x * p2.x + p1.x * p2.x),\n f012 - f0123 * (p0.x + p1.x + p2.x),\n f0123,\n )\n}\n\nexport const solve = dual<\n (x: number) => (p: CubicPolynomial) => number,\n (p: CubicPolynomial, x: number) => number\n>(2, (p: CubicPolynomial, x: number) => p.c0 + x * p.c1 + x ** 2 * p.c2 + x ** 3 * p.c3)\n\nexport const toSolver = (p: CubicPolynomial) => (x: number) => solve(p, x)\n\nexport const solveInverse = dual<\n (y: number) => (p: CubicPolynomial) => Solution.AtMostThree<number>,\n (p: CubicPolynomial, y: number) => Solution.AtMostThree<number>\n>(2, (self: CubicPolynomial, y: number) => {\n // c3 = 0: the polynomial is actually quadratic-or-less in disguise. Defer to\n // the quadratic solver (which itself handles c2 = 0 by deferring to linear).\n if (self.c3 === 0) {\n return Quadratic.solveInverse(Quadratic.make(self.c0, self.c1, self.c2), y)\n }\n\n const shift = self.c2 / (3 * self.c3)\n\n const d0 = self.c2 ** 2 - 3 * self.c3 * self.c1\n const d1 = 2 * self.c2 ** 3 - 9 * self.c3 * self.c2 * self.c1 + 27 * self.c3 ** 2 * (self.c0 - y)\n\n const p = -d0 / (3 * self.c3 ** 2)\n const q = d1 / (27 * self.c3 ** 3)\n\n const discriminant = clampToZero(-(4 * p ** 3 + 27 * q ** 2), 1e-12)\n\n const roots = new Set<number>()\n\n if (discriminant > 0) {\n const r = 2 * Math.sqrt(-p / 3)\n const theta = Math.acos(((3 * q) / (2 * p)) * Math.sqrt(-3 / p)) / 3\n const offset = (2 * Math.PI) / 3\n\n roots.add(r * Math.cos(theta + offset) - shift)\n roots.add(r * Math.cos(theta) - shift)\n roots.add(r * Math.cos(theta - offset) - shift)\n } else if (discriminant < 0) {\n const u = Math.sqrt(q ** 2 / 4 + p ** 3 / 27)\n\n const u1 = Math.cbrt(-q / 2 + u)\n const u2 = Math.cbrt(-q / 2 - u)\n\n roots.add(u1 + u2 - shift)\n } else if (d0 === 0) {\n roots.add(-shift)\n } else {\n roots.add((9 * self.c3 * (self.c0 - y) - self.c2 * self.c1) / (2 * d0))\n roots.add(\n (4 * self.c3 * self.c2 * self.c1 - 9 * self.c3 ** 2 * (self.c0 - y) - self.c2 ** 3) /\n (self.c3 * d0),\n )\n }\n\n return Solution.fromArray(Array.from(roots).toSorted((a, b) => a - b))\n})\n\nexport const toInverseSolver = (p: CubicPolynomial) => (y: number) => solveInverse(p, y)\n\nexport const derivative = (p: CubicPolynomial) => Quadratic.make(p.c1, p.c2 * 2, p.c3 * 3)\n\n// Subdivides a cubic polynomial at parameter `t ∈ (0, 1)` into two new cubic\n// polynomials. The first polynomial's evaluation on `[0, 1]` matches the\n// original's evaluation on `[0, t]`; the second matches the original's\n// evaluation on `[t, 1]`. Concretely: `left(u) = p(t·u)` and\n// `right(u) = p(t + (1-t)·u)`. The left half is a uniform scale of the input\n// parameter by powers of `t`; the right half is a binomial expansion in\n// `(s + r·u)` with `s = t` and `r = 1 - t`.\nexport const subdivide = dual<\n (t: number) => (p: CubicPolynomial) => [CubicPolynomial, CubicPolynomial],\n (p: CubicPolynomial, t: number) => [CubicPolynomial, CubicPolynomial]\n>(2, (p: CubicPolynomial, t: number): [CubicPolynomial, CubicPolynomial] => {\n invariant(t > 0 && t < 1, 'subdivide parameter t must be in the open interval (0, 1)')\n\n const r = 1 - t\n const left = make(p.c0, p.c1 * t, p.c2 * t * t, p.c3 * t * t * t)\n const right = make(\n p.c0 + p.c1 * t + p.c2 * t * t + p.c3 * t * t * t,\n p.c1 * r + 2 * p.c2 * t * r + 3 * p.c3 * t * t * r,\n p.c2 * r * r + 3 * p.c3 * t * r * r,\n p.c3 * r * r * r,\n )\n return [left, right]\n})\n\nexport const roots = (p: CubicPolynomial): Solution.AtMostThree<number> => solveInverse(p, 0)\n\nexport const extrema = (p: CubicPolynomial): Solution.AtMostTwo<number> =>\n Quadratic.roots(derivative(p))\n\nexport const monotonicity = dual<\n (i: Interval.Interval) => (p: CubicPolynomial) => Monotonicity,\n (p: CubicPolynomial, i?: Interval.Interval) => Monotonicity\n>(\n (args) => isCubicPolynomial(args[0]),\n (p: CubicPolynomial, i?: Interval.Interval) => {\n invariant(\n i === undefined || Interval.size(i) > 0,\n 'monotonicity is undefined over a zero-width interval',\n )\n\n // shortcut to check for a horizontal line\n if (p.c3 === 0 && p.c2 === 0 && p.c1 === 0) {\n return 'constant'\n }\n\n // shortcut to check for a non-horizontal line\n if (p.c3 === 0 && p.c2 === 0) {\n return Linear.monotonicity(Linear.make(p.c0, p.c1))\n }\n\n // without an interval, the monotonicity will be none if c3 or c2 are nonzero\n if (i === undefined) {\n return 'none'\n }\n\n if (p.c3 === 0) {\n return Quadratic.monotonicity(Quadratic.make(p.c0, p.c1, p.c2), i)\n }\n\n const e = Interval.filter(Interval.toOpen(i), [...extrema(p)])\n\n if (e.length > 0) {\n return 'none'\n }\n\n return guaranteedMonotonicityFromComparison(solve(p, i.start), solve(p, i.end))\n },\n)\n\nexport const isMonotonic = dual<\n (i: Interval.Interval) => <T>(p: CubicPolynomial<T>) => p is CubicPolynomial<T & Monotonic>,\n <T>(p: CubicPolynomial<T>, i?: Interval.Interval) => p is CubicPolynomial<T & Monotonic>\n>((args) => isCubicPolynomial(args[0]), ((p: CubicPolynomial, i?: Interval.Interval) => {\n const m = monotonicity(p, i as Interval.Interval)\n return m === 'increasing' || m === 'decreasing'\n}) as never)\n\nexport const isIncreasing = dual<\n (i: Interval.Interval) => <T>(p: CubicPolynomial<T>) => p is CubicPolynomial<T & Increasing>,\n <T>(p: CubicPolynomial<T>, i?: Interval.Interval) => p is CubicPolynomial<T & Increasing>\n>(\n (args) => isCubicPolynomial(args[0]),\n ((p: CubicPolynomial, i?: Interval.Interval) =>\n monotonicity(p, i as Interval.Interval) === 'increasing') as never,\n)\n\nexport const isDecreasing = dual<\n (i: Interval.Interval) => <T>(p: CubicPolynomial<T>) => p is CubicPolynomial<T & Decreasing>,\n <T>(p: CubicPolynomial<T>, i?: Interval.Interval) => p is CubicPolynomial<T & Decreasing>\n>(\n (args) => isCubicPolynomial(args[0]),\n ((p: CubicPolynomial, i?: Interval.Interval) =>\n monotonicity(p, i as Interval.Interval) === 'decreasing') as never,\n)\n\nexport const asMonotonic = <T>(\n p: CubicPolynomial<T>,\n i?: Interval.Interval,\n): CubicPolynomial<T & Monotonic> => {\n invariant(isMonotonic(p, i as Interval.Interval), 'cubic polynomial is not monotonic')\n return p\n}\n\nexport const asIncreasing = <T>(\n p: CubicPolynomial<T>,\n i?: Interval.Interval,\n): CubicPolynomial<T & Increasing> => {\n invariant(isIncreasing(p, i as Interval.Interval), 'cubic polynomial is not increasing')\n return p\n}\n\nexport const asDecreasing = <T>(\n p: CubicPolynomial<T>,\n i?: Interval.Interval,\n): CubicPolynomial<T & Decreasing> => {\n invariant(isDecreasing(p, i as Interval.Interval), 'cubic polynomial is not decreasing')\n return p\n}\n\nexport const domain = dual<\n (range: Interval.Interval) => (p: CubicPolynomial) => Interval.Interval,\n (p: CubicPolynomial, range: Interval.Interval) => Interval.Interval\n>(2, (p: CubicPolynomial, r: Interval.Interval) =>\n Interval.fromMinMax(...solveInverse(p, r.start), ...solveInverse(p, r.end)),\n)\n\nexport const range = dual<\n (domain: Interval.Interval) => (p: CubicPolynomial) => Interval.Interval,\n (p: CubicPolynomial, domain: Interval.Interval) => Interval.Interval\n>(2, (p: CubicPolynomial, d: Interval.Interval) =>\n Interval.fromMinMax(\n solve(p, d.start),\n solve(p, d.end),\n ...Interval.filter(d, [...extrema(p)]).map((e) => solve(p, e)),\n ),\n)\n\nexport const length = dual<\n (domain: Interval.Interval) => (p: CubicPolynomial) => number,\n (p: CubicPolynomial, domain: Interval.Interval) => number\n>(2, (p: CubicPolynomial, dom: Interval.Interval) => {\n if (Interval.size(dom) === 0) {\n return 0\n }\n\n if (p.c3 === 0) {\n if (p.c2 === 0) {\n return Linear.length(Linear.make(p.c0, p.c1), dom)\n }\n\n return Quadratic.length(Quadratic.make(p.c0, p.c1, p.c2), dom)\n }\n\n const d = derivative(p)\n\n const { scale, shift } = Interval.scaleShift(Interval.biunit, dom)\n\n return (\n (GL32_W0 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X0) ** 2) +\n GL32_W0 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X0) ** 2) +\n GL32_W1 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X1) ** 2) +\n GL32_W1 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X1) ** 2) +\n GL32_W2 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X2) ** 2) +\n GL32_W2 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X2) ** 2) +\n GL32_W3 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X3) ** 2) +\n GL32_W3 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X3) ** 2) +\n GL32_W4 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X4) ** 2) +\n GL32_W4 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X4) ** 2) +\n GL32_W5 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X5) ** 2) +\n GL32_W5 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X5) ** 2) +\n GL32_W6 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X6) ** 2) +\n GL32_W6 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X6) ** 2) +\n GL32_W7 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X7) ** 2) +\n GL32_W7 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X7) ** 2) +\n GL32_W8 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X8) ** 2) +\n GL32_W8 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X8) ** 2) +\n GL32_W9 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X9) ** 2) +\n GL32_W9 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X9) ** 2) +\n GL32_W10 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X10) ** 2) +\n GL32_W10 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X10) ** 2) +\n GL32_W11 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X11) ** 2) +\n GL32_W11 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X11) ** 2) +\n GL32_W12 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X12) ** 2) +\n GL32_W12 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X12) ** 2) +\n GL32_W13 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X13) ** 2) +\n GL32_W13 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X13) ** 2) +\n GL32_W14 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X14) ** 2) +\n GL32_W14 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X14) ** 2) +\n GL32_W15 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X15) ** 2) +\n GL32_W15 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X15) ** 2)) *\n scale\n )\n})\n\nexport const curvature = dual(2, (p: CubicPolynomial, x: number) => {\n const d = derivative(p)\n const dd = Quadratic.derivative(d)\n\n return Math.abs(Linear.solve(dd, x)) / (1 + Quadratic.solve(d, x) ** 2) ** 1.5\n})\n","import type { Interval } from '../interval/interval'\nimport type { Pipeable } from '../utils'\nimport type * as Solution from '../solution/solution'\nimport type { Vector2 } from '../vector/vector2'\nimport type { Vector4 } from '../vector/vector4'\nimport * as internal from './cubic.internal'\nimport type { CubicPolynomialTypeId } from './cubic.internal.circular'\nimport type { Monotonicity } from './monotonicity'\nimport type { QuadraticPolynomial } from './quadratic'\nimport type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits'\n\nexport type { Monotonic, Increasing, Decreasing } from './traits'\n\n/**\n * A cubic polynomial.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Traits` type parameter is a phantom marker that accumulates trait\n * brands as the polynomial is refined via `isMonotonic` / `asMonotonic` and\n * friends. A cubic is monotonic only over an interval that avoids both of its\n * extrema (or globally, when c2 = c3 = 0 and c1 ≠ 0).\n *\n * @since 1.0.0\n */\nexport interface CubicPolynomial<out Traits = unknown> extends Pipeable {\n readonly [CubicPolynomialTypeId]: CubicPolynomialTypeId\n readonly [PolynomialTraits]: Traits\n\n /**\n * The coefficient of the x^0 term.\n */\n readonly c0: number\n /**\n * The coefficient of the x^1 term.\n */\n readonly c1: number\n /**\n * The coefficient of the x^2 term.\n */\n readonly c2: number\n /**\n * The coefficient of the x^3 term.\n */\n readonly c3: number\n}\n\n/**\n * Checks if a value is a `CubicPolynomial`.\n *\n * @param value - The value to check.\n * @returns `true` if the value is a `CubicPolynomial`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isCubicPolynomial: (value: unknown) => value is CubicPolynomial =\n internal.isCubicPolynomial\n\nexport const equals: {\n /**\n * Checks if two `CubicPolynomial` instances are approximately equal within\n * the default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first polynomial.\n * @param b - The second polynomial.\n * @returns `true` when each pair of coefficients is within tolerance.\n * @since 1.1.0\n */\n (a: CubicPolynomial, b: CubicPolynomial): boolean\n /**\n * Checks if two `CubicPolynomial` instances are approximately equal within\n * the default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second polynomial.\n * @returns A function that takes the first polynomial and returns the comparison result.\n * @since 1.1.0\n */\n (b: CubicPolynomial): (a: CubicPolynomial) => boolean\n} = internal.equals\n\n/**\n * Creates a new `CubicPolynomial` instance.\n *\n * @param c0 - The coefficient of the x^0 term.\n * @param c1 - The coefficient of the x^1 term.\n * @param c2 - The coefficient of the x^2 term.\n * @param c3 - The coefficient of the x^3 term.\n */\nexport const make: (c0: number, c1: number, c2: number, c3: number) => CubicPolynomial =\n internal.make\n\n/**\n * Creates a new `CubicPolynomial` instance from a vector.\n *\n * @param v - The vector to convert.\n * @returns A new `CubicPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromVector: (v: Vector4) => CubicPolynomial = internal.fromVector\n\n/**\n * Creates a new `CubicPolynomial` that interpolates the four given points,\n * treating each `Vector2` as an `(x, y)` pair. The four input `x` values must\n * be distinct.\n *\n * @param p0 - The first point.\n * @param p1 - The second point.\n * @param p2 - The third point.\n * @param p3 - The fourth point.\n * @returns The unique cubic polynomial passing through the four points.\n * @since 2.0.0\n */\nexport const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => CubicPolynomial =\n internal.fromPoints\n\nexport const solve: {\n /**\n * Solves a cubic polynomial for a given value of x.\n *\n * @param p - The cubic polynomial to solve.\n * @param x - The value of x to solve for.\n * @returns The result of the polynomial evaluation at x.\n * @since 1.0.0\n */\n (p: CubicPolynomial, x: number): number\n /**\n * Solves a cubic polynomial for a given value of x.\n *\n * @param x - The value of x to solve for.\n * @returns A function that takes a cubic polynomial and returns the result of the polynomial evaluation at x.\n * @since 1.0.0\n */\n (x: number): (p: CubicPolynomial) => number\n} = internal.solve\n\n/**\n * Converts a cubic polynomial to a solver function.\n *\n * @param p - The cubic polynomial to convert.\n * @returns A function that takes a value of x and returns the result of the polynomial evaluation at x.\n * @since 1.0.0\n */\nexport const toSolver: (p: CubicPolynomial) => (x: number) => number = internal.toSolver\n\nexport const solveInverse: {\n /**\n * Solves a monotonic cubic polynomial for a given value of y. Because the\n * polynomial is strictly monotonic, the inverse has at most one solution.\n *\n * @param p - The monotonic cubic polynomial.\n * @param y - The value of y to solve for.\n * @returns Zero or one solutions.\n * @since 2.0.0\n */\n <T extends Monotonic>(p: CubicPolynomial<T>, y: number): Solution.AtMostOne<number>\n /**\n * Solves a cubic polynomial for a given value of y.\n *\n * @param p - The cubic polynomial to solve.\n * @param y - The value of y to solve for.\n * @returns The roots of the polynomial equation p(x) = y.\n * @since 1.0.0\n */\n <T>(p: CubicPolynomial<T>, y: number): Solution.AtMostThree<number>\n /**\n * Solves a cubic polynomial for a given value of y.\n *\n * @param y - The value of y to solve for.\n * @returns A function that takes a cubic polynomial and returns the roots\n * of the polynomial equation p(x) = y. Tightens to `Solution.AtMostOne<number>` for\n * monotonic inputs.\n * @since 1.0.0\n */\n (y: number): {\n <T extends Monotonic>(p: CubicPolynomial<T>): Solution.AtMostOne<number>\n <T>(p: CubicPolynomial<T>): Solution.AtMostThree<number>\n }\n} = internal.solveInverse as never\n\n/**\n * Converts a cubic polynomial to an inverse solver function.\n *\n * @param p - The cubic polynomial to convert.\n * @returns A function that takes a value of y and returns the roots of the polynomial equation p(x) = y.\n * @since 1.0.0\n */\nexport const toInverseSolver: (p: CubicPolynomial) => (y: number) => Solution.AtMostThree<number> =\n internal.toInverseSolver\n\n/**\n * Calculates the derivative of a cubic polynomial.\n *\n * @param p - The cubic polynomial to differentiate.\n * @returns The derivative of the cubic polynomial.\n * @since 1.0.0\n */\nexport const derivative: (p: CubicPolynomial) => QuadraticPolynomial = internal.derivative\n\nexport const subdivide: {\n /**\n * Subdivides a cubic polynomial at parameter `t ∈ (0, 1)` into two new\n * cubic polynomials. The first polynomial's evaluation on `[0, 1]` matches\n * the original's on `[0, t]`; the second matches the original's on\n * `[t, 1]`. Equivalent to de Casteljau subdivision in Bernstein form,\n * performed directly in monomial form.\n *\n * @param p - The cubic polynomial to subdivide.\n * @param t - The split parameter; must be in the open interval `(0, 1)`.\n * @returns A `[left, right]` tuple of cubic polynomials.\n * @since 2.1.0\n */\n (p: CubicPolynomial, t: number): [CubicPolynomial, CubicPolynomial]\n /**\n * Subdivides a cubic polynomial at parameter `t ∈ (0, 1)`.\n *\n * @param t - The split parameter; must be in the open interval `(0, 1)`.\n * @returns A function that takes a polynomial and returns its `[left, right]` halves.\n * @since 2.1.0\n */\n (t: number): (p: CubicPolynomial) => [CubicPolynomial, CubicPolynomial]\n} = internal.subdivide\n\n/**\n * Calculates the roots of a cubic polynomial.\n *\n * @param p - The cubic polynomial to find the roots of.\n * @returns The roots of the cubic polynomial.\n * @since 1.0.0\n */\nexport const roots: (p: CubicPolynomial) => Solution.AtMostThree<number> = internal.roots\n\n/**\n * Calculates the extrema of a cubic polynomial.\n *\n * @param p - The cubic polynomial to find the extrema of.\n * @returns The extrema of the cubic polynomial.\n * @since 1.0.0\n */\nexport const extrema: (p: CubicPolynomial) => Solution.AtMostTwo<number> = internal.extrema\n\nexport const monotonicity: {\n /**\n * Calculates the monotonicity of a cubic polynomial. Throws when the\n * interval has zero width — the question is undefined at a single point.\n *\n * @param p - The cubic polynomial to analyze.\n * @param i - The interval to restrict the analysis to.\n * @returns The monotonicity of the cubic polynomial in the specified interval.\n * @since 1.0.0\n */\n (p: CubicPolynomial, i?: Interval): Monotonicity\n /**\n * Calculates the monotonicity of a cubic polynomial. Throws when the\n * interval has zero width.\n *\n * @param i - The interval to restrict the analysis to.\n * @returns A function that takes a cubic polynomial and returns the\n * monotonicity of the cubic polynomial in the specified interval.\n * @since 1.0.0\n */\n (i: Interval): (p: CubicPolynomial) => Monotonicity\n} = internal.monotonicity\n\n/**\n * Type-narrowing predicate: refines a `CubicPolynomial<T>` to\n * `CubicPolynomial<T & Monotonic>` when the polynomial is strictly monotonic\n * over the given interval (or globally, when no interval is given).\n *\n * @param p - The cubic polynomial to check.\n * @param i - Optional interval over which to check monotonicity.\n * @returns `true` when monotonicity is `'increasing'` or `'decreasing'`.\n * @since 2.0.0\n */\nexport const isMonotonic: {\n <T>(p: CubicPolynomial<T>, i?: Interval): p is CubicPolynomial<T & Monotonic>\n (i: Interval): <T>(p: CubicPolynomial<T>) => p is CubicPolynomial<T & Monotonic>\n} = internal.isMonotonic\n\n/**\n * Type-narrowing predicate: refines to `CubicPolynomial<T & Increasing>`.\n *\n * @since 2.0.0\n */\nexport const isIncreasing: {\n <T>(p: CubicPolynomial<T>, i?: Interval): p is CubicPolynomial<T & Increasing>\n (i: Interval): <T>(p: CubicPolynomial<T>) => p is CubicPolynomial<T & Increasing>\n} = internal.isIncreasing\n\n/**\n * Type-narrowing predicate: refines to `CubicPolynomial<T & Decreasing>`.\n *\n * @since 2.0.0\n */\nexport const isDecreasing: {\n <T>(p: CubicPolynomial<T>, i?: Interval): p is CubicPolynomial<T & Decreasing>\n (i: Interval): <T>(p: CubicPolynomial<T>) => p is CubicPolynomial<T & Decreasing>\n} = internal.isDecreasing\n\n/**\n * Asserts that the cubic polynomial is monotonic, throwing on failure.\n *\n * @param p - The cubic polynomial to assert against.\n * @param i - Optional interval over which to check monotonicity.\n * @returns The same polynomial, typed with the `Monotonic` brand.\n * @throws When the polynomial is not monotonic over the given (or global) interval.\n * @since 2.0.0\n */\nexport const asMonotonic: <T>(\n p: CubicPolynomial<T>,\n i?: Interval,\n) => CubicPolynomial<T & Monotonic> = internal.asMonotonic\n\n/**\n * Asserts that the cubic polynomial is increasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasing: <T>(\n p: CubicPolynomial<T>,\n i?: Interval,\n) => CubicPolynomial<T & Increasing> = internal.asIncreasing\n\n/**\n * Asserts that the cubic polynomial is decreasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasing: <T>(\n p: CubicPolynomial<T>,\n i?: Interval,\n) => CubicPolynomial<T & Decreasing> = internal.asDecreasing\n\nexport const domain: {\n /**\n * Calculates the domain of a cubic polynomial.\n *\n * @param p - The cubic polynomial to analyze.\n * @param range - The range to restrict the analysis to.\n * @returns The domain of the cubic polynomial in the specified range.\n * @since 1.0.0\n */\n (p: CubicPolynomial, range: Interval): Interval\n /**\n * Calculates the domain of a cubic polynomial.\n *\n * @param range - The range to restrict the analysis to.\n * @returns A function that takes a cubic polynomial and returns the domain of the cubic polynomial in the specified range.\n * @since 1.0.0\n */\n (range: Interval): (p: CubicPolynomial) => Interval\n} = internal.domain\n\nexport const range: {\n /**\n * Calculates the range of a cubic polynomial.\n *\n * @param p - The cubic polynomial to analyze.\n * @param domain - The domain to restrict the analysis to.\n * @returns The range of the cubic polynomial in the specified domain.\n * @since 1.0.0\n */\n (p: CubicPolynomial, domain: Interval): Interval\n /**\n * Calculates the range of a cubic polynomial.\n *\n * @param domain - The domain to restrict the analysis to.\n * @returns A function that takes a cubic polynomial and returns the range of the cubic polynomial in the specified domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: CubicPolynomial) => Interval\n} = internal.range\n\nexport const length: {\n /**\n * Calculates the length of a cubic polynomial.\n *\n * @param p - The cubic polynomial to analyze.\n * @param domain - The domain to restrict the analysis to.\n * @returns The length of the cubic polynomial in the specified domain.\n * @since 1.0.0\n */\n (p: CubicPolynomial, domain: Interval): number\n /**\n * Calculates the length of a cubic polynomial.\n *\n * @param domain - The domain to restrict the analysis to.\n * @returns A function that takes a cubic polynomial and returns the length of the cubic polynomial in the specified domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: CubicPolynomial) => number\n} = internal.length\n\nexport const curvature: {\n /**\n * Calculates the curvature of a cubic polynomial.\n *\n * @param p - The cubic polynomial to analyze.\n * @param x - The value of x to calculate the curvature at.\n * @returns The curvature of the cubic polynomial at the specified value of x.\n * @since 1.0.0\n */\n (p: CubicPolynomial, x: number): number\n /**\n * Calculates the curvature of a cubic polynomial.\n *\n * @param x - The value of x to calculate the curvature at.\n * @returns A function that takes a cubic polynomial and returns the curvature of the cubic polynomial at the specified value of x.\n * @since 1.0.0\n */\n (x: number): (p: CubicPolynomial) => number\n} = internal.curvature\n"],"mappings":";;;;;;;AAIA,MAAa,4BAA2C,OAAO,IAAI,6BAA6B;AAGhG,IAAa,0BAAb,cAA6C,SAAiD;CAC5F,CAAU,6BAAwD;CAGlE;CACA;CACA;CAEA,YAAY,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;EAClC,OAAO;EAEP,KAAK,KAAK;EACV,KAAK,KAAK;EACV,KAAK,KAAK;;;;;ACRd,MAAa,yBAAwC,OAAO,IAAI,eAAe;AAG/E,IAAM,uBAAN,cAAmC,SAA8C;CAC/E,CAAU,0BAAkD;CAG5D;CACA;CAEA,YAAY,KAAK,GAAG,KAAK,GAAG;EAC1B,OAAO;EAEP,KAAK,KAAK;EACV,KAAK,KAAK;;;AAId,MAAa,sBAAsB,MACjC,OAAO,MAAM,YAAY,MAAM,QAAQ,0BAA0B;AAEnE,MAAaA,WAAS,KAGpB,IAAI,GAAqB,MAAwB,UAAU,EAAE,IAAI,EAAE,GAAG,I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a,aACXC;AAEF,MAAa,QAkBTC;;;;;;;;AASJ,MAAa,WAA0DC;AAEvE,MAAa,eAiCTC;;;;;;;;AASJ,MAAa,kBACXC;;;;;;;;AASF,MAAa,aAA0DC;AAEvE,MAAa,YAsBTC;;;;;;;;AASJ,MAAa,QAA8DC;;;;;;;;AAS3E,MAAa,UAA8DC;AAE3E,MAAa,eAqBTC;;;;;;;;;;;AAYJ,MAAa,cAGTC;;;;;;AAOJ,MAAa,eAGTC;;;;;;AAOJ,MAAa,eAGTC;;;;;;;;;;AAWJ,MAAa,cAGyBC;;;;;;AAOtC,MAAa,eAG0BC;;;;;;AAOvC,MAAa,eAG0BC;AAEvC,MAAa,SAkBTC;AAEJ,MAAa,QAkBTC;AAEJ,MAAa,SAkBTC;AAEJ,MAAa,YAkBTC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interval-CCEqzPgA.mjs","names":["isInterval","equals","aligned","make","makeOpenStart","makeOpenEnd","makeOpen","fromSize","fromMinMax","size","contains","filter","clamp","toStartOpen","toStartClosed","toEndOpen","toEndClosed","toClosed","toOpen","isClosed","isOpen","isOpenStart","isOpenEnd","isOpenAtStart","isOpenAtEnd","isClosedAtStart","isClosedAtEnd","unit","unitOpen","biunit","lerp","toLerpFn","normalize","toNormalizeFn","remap","toRemapFn","scaleShift","internal.isInterval","internal.equals","internal.aligned","internal.make","internal.makeOpenStart","internal.makeOpenEnd","internal.makeOpen","internal.fromSize","internal.fromMinMax","internal.size","internal.contains","internal.filter","internal.clamp","internal.toStartOpen","internal.toStartClosed","internal.toEndOpen","internal.toEndClosed","internal.toClosed","internal.toOpen","internal.isClosed","internal.isOpen","internal.isOpenStart","internal.isOpenEnd","internal.isOpenAtStart","internal.isOpenAtEnd","internal.isClosedAtStart","internal.isClosedAtEnd","internal.unit","internal.unitOpen","internal.biunit","internal.lerp","internal.toLerpFn","internal.normalize","internal.toNormalizeFn","internal.remap","internal.toRemapFn","internal.scaleShift"],"sources":["../../src/interval/interval.internal.ts","../../src/interval/interval.ts"],"sourcesContent":["import type { Bounds, Closed, Interval, Open, OpenEnd, OpenStart } from './interval'\nimport { dual, Pipeable } from '../utils'\nimport { epsEquals } from '../number'\n\nconst TypeId: unique symbol = Symbol.for('curvy/interval')\ntype TypeId = typeof TypeId\n\nabstract class IntervalImpl extends Pipeable {\n readonly [TypeId]: TypeId = TypeId\n\n abstract readonly kind: 'closed' | 'open-start' | 'open-end' | 'open'\n\n readonly start: number\n readonly end: number\n\n constructor(start: number, end: number) {\n super()\n\n if (end < start) {\n throw new Error('Interval end must be greater than or equal to start')\n }\n\n this.start = start\n this.end = end\n }\n\n get [Symbol.toStringTag]() {\n const open = this.kind === 'open-start' || this.kind === 'open' ? '(' : '['\n const close = this.kind === 'open-end' || this.kind === 'open' ? ')' : ']'\n return `Interval ${open}${this.start}, ${this.end}${close}`\n }\n\n get [Symbol.for('nodejs.util.inspect.custom')]() {\n return this[Symbol.toStringTag]\n }\n}\n\nclass ClosedImpl extends IntervalImpl implements Closed {\n readonly kind = 'closed' as const\n}\n\nclass OpenStartImpl extends IntervalImpl implements OpenStart {\n readonly kind = 'open-start' as const\n}\n\nclass OpenEndImpl extends IntervalImpl implements OpenEnd {\n readonly kind = 'open-end' as const\n}\n\nclass OpenImpl extends IntervalImpl implements Open {\n readonly kind = 'open' as const\n}\n\nexport const isInterval = (v: unknown): v is Interval =>\n typeof v === 'object' && v !== null && TypeId in v\n\nexport const equals = dual<\n (b: Interval) => (a: Interval) => boolean,\n (a: Interval, b: Interval) => boolean\n>(\n 2,\n (a: Interval, b: Interval) =>\n a.kind === b.kind && epsEquals(a.start, b.start) && epsEquals(a.end, b.end),\n)\n\nexport const aligned = dual<\n (b: Bounds) => (a: Bounds) => boolean,\n (a: Bounds, b: Bounds) => boolean\n>(2, (a: Bounds, b: Bounds) => epsEquals(a.start, b.start) && epsEquals(a.end, b.end))\n\nexport const make = (start: number, end?: number): Closed => new ClosedImpl(start, end ?? start)\n\nexport const makeOpenStart = (start: number, end?: number): OpenStart =>\n new OpenStartImpl(start, end ?? start)\n\nexport const makeOpenEnd = (start: number, end?: number): OpenEnd =>\n new OpenEndImpl(start, end ?? start)\n\nexport const makeOpen = (start: number, end?: number): Open => new OpenImpl(start, end ?? start)\n\nexport const fromSize = (a: number, b?: number): Closed => {\n if (b === undefined) {\n return new ClosedImpl(0, a)\n }\n return new ClosedImpl(a, a + b)\n}\n\nexport const fromMinMax = (...values: ReadonlyArray<number>): Closed =>\n new ClosedImpl(Math.min(...values), Math.max(...values))\n\nexport const size = (i: Bounds): number => Math.abs(i.end - i.start)\n\nexport const contains = dual<\n (value: number) => (interval: Interval) => boolean,\n (interval: Interval, value: number) => boolean\n>(2, (interval: Interval, value: number): boolean => {\n switch (interval.kind) {\n case 'closed':\n return value >= interval.start && value <= interval.end\n case 'open-start':\n return value > interval.start && value <= interval.end\n case 'open-end':\n return value >= interval.start && value < interval.end\n case 'open':\n return value > interval.start && value < interval.end\n }\n})\n\nexport const filter = dual<\n <V extends ReadonlyArray<number>>(value: V) => (interval: Interval) => V,\n <V extends ReadonlyArray<number>>(interval: Interval, value: V) => V\n>(\n 2,\n <V extends ReadonlyArray<number>>(interval: Interval, value: V): V =>\n value.filter((v) => contains(interval, v)) as unknown as V,\n)\n\nexport const clamp = dual<\n <V extends number | ReadonlyArray<number>>(value: V) => (interval: Bounds) => V,\n <V extends number | ReadonlyArray<number>>(interval: Bounds, value: V) => V\n>(2, <V extends number | ReadonlyArray<number>>(interval: Bounds, value: V): V => {\n if (Array.isArray(value)) {\n return value.map((v) => clamp(interval, v)) as unknown as V\n }\n const v = value as number\n if (v < interval.start) {\n return interval.start as V\n }\n if (v > interval.end) {\n return interval.end as V\n }\n return v as V\n})\n\nexport const toStartOpen = ((i: Interval): OpenStart | Open => {\n switch (i.kind) {\n case 'closed':\n return new OpenStartImpl(i.start, i.end)\n case 'open-end':\n return new OpenImpl(i.start, i.end)\n case 'open-start':\n case 'open':\n return i\n }\n}) as {\n (i: Closed | OpenStart): OpenStart\n (i: OpenEnd | Open): Open\n}\n\nexport const toStartClosed = ((i: Interval): Closed | OpenEnd => {\n switch (i.kind) {\n case 'open-start':\n return new ClosedImpl(i.start, i.end)\n case 'open':\n return new OpenEndImpl(i.start, i.end)\n case 'closed':\n case 'open-end':\n return i\n }\n}) as {\n (i: Closed | OpenEnd): Closed\n (i: OpenStart | Open): OpenEnd\n}\n\nexport const toEndOpen = ((i: Interval): OpenEnd | Open => {\n switch (i.kind) {\n case 'closed':\n return new OpenEndImpl(i.start, i.end)\n case 'open-start':\n return new OpenImpl(i.start, i.end)\n case 'open-end':\n case 'open':\n return i\n }\n}) as {\n (i: Closed | OpenEnd): OpenEnd\n (i: OpenStart | Open): Open\n}\n\nexport const toEndClosed = ((i: Interval): Closed | OpenStart => {\n switch (i.kind) {\n case 'open-end':\n return new ClosedImpl(i.start, i.end)\n case 'open':\n return new OpenStartImpl(i.start, i.end)\n case 'closed':\n case 'open-start':\n return i\n }\n}) as {\n (i: Closed | OpenEnd): Closed\n (i: OpenStart | Open): OpenStart\n}\n\nexport const toClosed = (i: Interval): Closed => {\n if (i.kind === 'closed') {\n return i\n }\n return new ClosedImpl(i.start, i.end)\n}\n\nexport const toOpen = (i: Interval): Open => {\n if (i.kind === 'open') {\n return i\n }\n return new OpenImpl(i.start, i.end)\n}\n\nexport const isClosed = (i: Interval): i is Closed => i.kind === 'closed'\nexport const isOpen = (i: Interval): i is Open => i.kind === 'open'\nexport const isOpenStart = (i: Interval): i is OpenStart => i.kind === 'open-start'\nexport const isOpenEnd = (i: Interval): i is OpenEnd => i.kind === 'open-end'\n\nexport const isOpenAtStart = (i: Interval): i is OpenStart | Open =>\n i.kind === 'open-start' || i.kind === 'open'\nexport const isOpenAtEnd = (i: Interval): i is OpenEnd | Open =>\n i.kind === 'open-end' || i.kind === 'open'\nexport const isClosedAtStart = (i: Interval): i is Closed | OpenEnd =>\n i.kind === 'closed' || i.kind === 'open-end'\nexport const isClosedAtEnd = (i: Interval): i is Closed | OpenStart =>\n i.kind === 'closed' || i.kind === 'open-start'\n\nexport const unit: Closed = make(0, 1)\n\nexport const unitOpen: Open = new OpenImpl(0, 1)\n\nexport const biunit: Closed = make(-1, 1)\n\nexport const lerp = (interval: Bounds, t: number): number =>\n (1 - t) * interval.start + t * interval.end\n\nexport const toLerpFn =\n (interval: Bounds) =>\n (t: number): number =>\n lerp(interval, t)\n\nexport const normalize = (interval: Bounds, x: number): number =>\n (x - interval.start) / size(interval)\n\nexport const toNormalizeFn =\n (interval: Bounds) =>\n (x: number): number =>\n normalize(interval, x)\n\nexport const remap = (source: Bounds, target: Bounds, x: number): number =>\n target.start + ((x - source.start) * size(target)) / size(source)\n\nexport const toRemapFn =\n (source: Bounds, target: Bounds) =>\n (x: number): number =>\n remap(source, target, x)\n\nexport const scaleShift = (source: Bounds, target: Bounds) => {\n const scale = size(target) / size(source)\n\n return {\n scale,\n shift: target.start - source.start * scale,\n }\n}\n","import * as internal from './interval.internal'\nimport type { Pipeable } from '../utils'\n\n/**\n * The structural minimum: any value with numeric `start` and `end` fields.\n *\n * Operations that don't read endpoint inclusivity (e.g. `lerp`, `normalize`,\n * `remap`, `size`) accept `Bounds` so the signature itself documents what\n * the operation depends on.\n *\n * @since 2.0.0\n */\nexport interface Bounds {\n readonly start: number\n readonly end: number\n}\n\n/**\n * A mathematical interval. Discriminated union of four variants by endpoint\n * inclusivity: `Closed`, `OpenStart`, `OpenEnd`, `Open`. Operations that\n * depend on inclusivity (e.g. `contains`, `filter`, `equals`) dispatch on\n * the `kind` field; operations that don't accept the broader `Bounds` type.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport type Interval = Closed | OpenStart | OpenEnd | Open\n\n/**\n * `[start, end]` — both endpoints included.\n *\n * @since 2.0.0\n */\nexport interface Closed extends Pipeable, Bounds {\n readonly kind: 'closed'\n}\n\n/**\n * `(start, end]` — start excluded, end included.\n *\n * @since 2.0.0\n */\nexport interface OpenStart extends Pipeable, Bounds {\n readonly kind: 'open-start'\n}\n\n/**\n * `[start, end)` — start included, end excluded.\n *\n * @since 2.0.0\n */\nexport interface OpenEnd extends Pipeable, Bounds {\n readonly kind: 'open-end'\n}\n\n/**\n * `(start, end)` — both endpoints excluded.\n *\n * @since 2.0.0\n */\nexport interface Open extends Pipeable, Bounds {\n readonly kind: 'open'\n}\n\n/**\n * Checks if a value is an `Interval`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is an `Interval`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isInterval: (v: unknown) => v is Interval = internal.isInterval\n\nexport const equals: {\n /**\n * Checks if two `Interval` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * Both endpoints AND the kind must match — a `Closed` and an `OpenStart` with\n * the same numeric endpoints are not equal. Use `aligned` for the looser\n * \"same numeric range\" check.\n *\n * @param a - The first interval.\n * @param b - The second interval.\n * @returns `true` when both intervals share a kind and both endpoints are within tolerance.\n * @since 1.1.0\n */\n (a: Interval, b: Interval): boolean\n /**\n * Checks if two `Interval` instances are approximately equal within the\n * default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second interval.\n * @returns A function that takes the first interval and returns the comparison result.\n * @since 1.1.0\n */\n (b: Interval): (a: Interval) => boolean\n} = internal.equals\n\nexport const aligned: {\n /**\n * Checks if two values share the same numeric range, ignoring endpoint\n * inclusivity. Accepts any `Bounds`-shaped value.\n *\n * @param a - The first bounds.\n * @param b - The second bounds.\n * @returns `true` when both endpoints are within the default tolerance ({@link EPSILON}).\n * @since 2.0.0\n */\n (a: Bounds, b: Bounds): boolean\n /**\n * @param b - The second bounds.\n * @returns A function that takes the first bounds and returns the comparison result.\n * @since 2.0.0\n */\n (b: Bounds): (a: Bounds) => boolean\n} = internal.aligned\n\nexport const make: {\n /**\n * Creates a new closed `Interval` instance.\n *\n * @param point - The point of the interval.\n * @returns A new `Closed` interval `[point, point]`.\n * @since 1.0.0\n */\n (point: number): Closed\n /**\n * Creates a new closed `Interval` instance.\n *\n * @param start - The start of the interval.\n * @param end - The end of the interval.\n * @returns A new `Closed` interval `[start, end]`.\n * @since 1.0.0\n */\n (start: number, end: number): Closed\n} = internal.make\n\nexport const makeOpenStart: {\n /**\n * Creates a new left-open `Interval` instance.\n *\n * @param point - The point of the interval.\n * @returns A new `OpenStart` interval `(point, point]` (degenerate, empty).\n * @since 2.0.0\n */\n (point: number): OpenStart\n /**\n * Creates a new left-open `Interval` instance.\n *\n * @param start - The start of the interval (excluded).\n * @param end - The end of the interval (included).\n * @returns A new `OpenStart` interval `(start, end]`.\n * @since 2.0.0\n */\n (start: number, end: number): OpenStart\n} = internal.makeOpenStart\n\nexport const makeOpenEnd: {\n /**\n * Creates a new right-open `Interval` instance.\n *\n * @param point - The point of the interval.\n * @returns A new `OpenEnd` interval `[point, point)` (degenerate, empty).\n * @since 2.0.0\n */\n (point: number): OpenEnd\n /**\n * Creates a new right-open `Interval` instance.\n *\n * @param start - The start of the interval (included).\n * @param end - The end of the interval (excluded).\n * @returns A new `OpenEnd` interval `[start, end)`.\n * @since 2.0.0\n */\n (start: number, end: number): OpenEnd\n} = internal.makeOpenEnd\n\nexport const makeOpen: {\n /**\n * Creates a new fully open `Interval` instance.\n *\n * @param point - The point of the interval.\n * @returns A new `Open` interval `(point, point)` (degenerate, empty).\n * @since 2.0.0\n */\n (point: number): Open\n /**\n * Creates a new fully open `Interval` instance.\n *\n * @param start - The start of the interval (excluded).\n * @param end - The end of the interval (excluded).\n * @returns A new `Open` interval `(start, end)`.\n * @since 2.0.0\n */\n (start: number, end: number): Open\n} = internal.makeOpen\n\nexport const fromSize: {\n /**\n * Creates a new closed `Interval` instance from a size.\n *\n * @param size - The size of the interval.\n * @returns A new `Closed` interval `[0, size]`.\n * @since 1.0.0\n */\n (size: number): Closed\n /**\n * Creates a new closed `Interval` instance from a size.\n *\n * @param start - The start of the interval.\n * @param size - The size of the interval.\n * @returns A new `Closed` interval `[start, start + size]`.\n * @since 1.0.0\n */\n (start: number, size: number): Closed\n} = internal.fromSize\n\n/**\n * Creates a new closed `Interval` from a minimum and maximum value, in any order.\n *\n * @param values - The values to take the min and max of.\n * @returns A new `Closed` interval `[min(values), max(values)]`.\n * @since 1.0.0\n */\nexport const fromMinMax: (...values: ReadonlyArray<number>) => Closed = internal.fromMinMax\n\n/**\n * Calculates the size of an interval.\n *\n * Kind-agnostic — `size` of `[0, 1]` and `(0, 1)` are both `1`.\n *\n * @param i - The bounds to calculate the size of.\n * @returns The size of the bounds.\n * @since 1.0.0\n */\nexport const size: (i: Bounds) => number = internal.size\n\nexport const contains: {\n /**\n * Checks if a value is contained within an interval. Endpoint inclusivity\n * follows the interval's `kind`.\n *\n * @param interval - The interval to check.\n * @param value - The value to check.\n * @returns `true` if the value is contained within the interval, `false` otherwise.\n * @since 1.0.0\n */\n (interval: Interval, value: number): boolean\n /**\n * Checks if a value is contained within an interval. Endpoint inclusivity\n * follows the interval's `kind`.\n *\n * @param value - The value to check.\n * @returns A function that takes an interval and returns `true` if the value is contained within the interval, `false` otherwise.\n * @since 1.0.0\n */\n (value: number): (interval: Interval) => boolean\n} = internal.contains\n\nexport const filter: {\n /**\n * Filters an array of values to those contained within an interval.\n * Endpoint inclusivity follows the interval's `kind`.\n *\n * @param interval - The interval to filter the values to.\n * @param value - The values to filter.\n * @returns The filtered values.\n * @since 1.0.0\n */\n <V extends ReadonlyArray<number>>(interval: Interval, value: V): V\n /**\n * Filters an array of values to those contained within an interval.\n *\n * @param value - The values to filter.\n * @returns A function that takes an interval and returns the filtered values.\n * @since 1.0.0\n */\n <V extends ReadonlyArray<number>>(value: V): (interval: Interval) => V\n} = internal.filter\n\nexport const clamp: {\n /**\n * Clamps a value to be within bounds. Kind-agnostic — clamps to the numeric\n * range regardless of endpoint inclusivity.\n *\n * @param interval - The bounds to clamp the value to.\n * @param value - The value to clamp.\n * @returns The clamped value.\n * @since 1.0.0\n */\n (interval: Bounds, value: number): number\n /**\n * Clamps a value to be within bounds. Kind-agnostic.\n *\n * @param value - The value to clamp.\n * @returns A function that takes bounds and returns the clamped value.\n * @since 1.0.0\n */\n (value: number): (interval: Bounds) => number\n /**\n * Clamps an array of values to be within bounds. Kind-agnostic.\n *\n * @param interval - The bounds to clamp the values to.\n * @param value - The values to clamp.\n * @returns The clamped values.\n * @since 1.0.0\n */\n (interval: Bounds, value: ReadonlyArray<number>): ReadonlyArray<number>\n /**\n * Clamps an array of values to be within bounds. Kind-agnostic.\n *\n * @param value - The values to clamp.\n * @returns A function that takes bounds and returns the clamped values.\n * @since 1.0.0\n */\n (value: ReadonlyArray<number>): (interval: Bounds) => ReadonlyArray<number>\n} = internal.clamp\n\n/**\n * Returns an interval with the start endpoint open. Preserves the end endpoint's inclusivity.\n *\n * @since 2.0.0\n */\nexport const toStartOpen: {\n (i: Closed | OpenStart): OpenStart\n (i: OpenEnd | Open): Open\n} = internal.toStartOpen\n\n/**\n * Returns an interval with the start endpoint closed. Preserves the end endpoint's inclusivity.\n *\n * @since 2.0.0\n */\nexport const toStartClosed: {\n (i: Closed | OpenEnd): Closed\n (i: OpenStart | Open): OpenEnd\n} = internal.toStartClosed\n\n/**\n * Returns an interval with the end endpoint open. Preserves the start endpoint's inclusivity.\n *\n * @since 2.0.0\n */\nexport const toEndOpen: {\n (i: Closed | OpenEnd): OpenEnd\n (i: OpenStart | Open): Open\n} = internal.toEndOpen\n\n/**\n * Returns an interval with the end endpoint closed. Preserves the start endpoint's inclusivity.\n *\n * @since 2.0.0\n */\nexport const toEndClosed: {\n (i: Closed | OpenEnd): Closed\n (i: OpenStart | Open): OpenStart\n} = internal.toEndClosed\n\n/**\n * Returns a closed interval over the same numeric range.\n *\n * @since 2.0.0\n */\nexport const toClosed: (i: Interval) => Closed = internal.toClosed\n\n/**\n * Returns a fully open interval over the same numeric range.\n *\n * @since 2.0.0\n */\nexport const toOpen: (i: Interval) => Open = internal.toOpen\n\n/**\n * Type-narrowing predicate: refines `Interval` to `Closed`.\n *\n * @since 2.0.0\n */\nexport const isClosed: (i: Interval) => i is Closed = internal.isClosed\n\n/**\n * Type-narrowing predicate: refines `Interval` to `Open`.\n *\n * @since 2.0.0\n */\nexport const isOpen: (i: Interval) => i is Open = internal.isOpen\n\n/**\n * Type-narrowing predicate: refines `Interval` to `OpenStart`.\n *\n * @since 2.0.0\n */\nexport const isOpenStart: (i: Interval) => i is OpenStart = internal.isOpenStart\n\n/**\n * Type-narrowing predicate: refines `Interval` to `OpenEnd`.\n *\n * @since 2.0.0\n */\nexport const isOpenEnd: (i: Interval) => i is OpenEnd = internal.isOpenEnd\n\n/**\n * Type-narrowing predicate: refines `Interval` to those with an open start endpoint.\n *\n * @since 2.0.0\n */\nexport const isOpenAtStart: (i: Interval) => i is OpenStart | Open = internal.isOpenAtStart\n\n/**\n * Type-narrowing predicate: refines `Interval` to those with an open end endpoint.\n *\n * @since 2.0.0\n */\nexport const isOpenAtEnd: (i: Interval) => i is OpenEnd | Open = internal.isOpenAtEnd\n\n/**\n * Type-narrowing predicate: refines `Interval` to those with a closed start endpoint.\n *\n * @since 2.0.0\n */\nexport const isClosedAtStart: (i: Interval) => i is Closed | OpenEnd = internal.isClosedAtStart\n\n/**\n * Type-narrowing predicate: refines `Interval` to those with a closed end endpoint.\n *\n * @since 2.0.0\n */\nexport const isClosedAtEnd: (i: Interval) => i is Closed | OpenStart = internal.isClosedAtEnd\n\n/**\n * The unit interval, `[0, 1]`.\n *\n * @since 1.0.0\n */\nexport const unit: Closed = internal.unit\n\n/**\n * The open unit interval, `(0, 1)`. The symmetric open analog of {@link unit};\n * convenient for \"strict interior\" use cases such as filtering roots that\n * must lie strictly inside the unit parameter range.\n *\n * @since 2.1.0\n */\nexport const unitOpen: Open = internal.unitOpen\n\n/**\n * The biunit interval, `[-1, 1]`.\n *\n * @since 1.0.0\n */\nexport const biunit: Closed = internal.biunit\n\n/**\n * Linearly interpolates a value within bounds.\n *\n * @param interval - The bounds to interpolate within.\n * @param t - The interpolation factor, typically between 0 and 1.\n * @returns The interpolated value.\n * @since 1.0.0\n */\nexport const lerp: (interval: Bounds, t: number) => number = internal.lerp\n\n/**\n * Creates a linear interpolation function for given bounds.\n *\n * @param interval - The bounds to create the interpolation function for.\n * @returns A function that takes a factor `t` and returns the interpolated value.\n * @since 1.0.0\n */\nexport const toLerpFn: (interval: Bounds) => (t: number) => number = internal.toLerpFn\n\n/**\n * Normalizes a value within bounds.\n *\n * @param interval - The bounds to normalize within.\n * @param x - The value to normalize.\n * @returns The normalized value.\n * @since 1.0.0\n */\nexport const normalize: (interval: Bounds, x: number) => number = internal.normalize\n\n/**\n * Creates a normalization function for given bounds.\n *\n * @param interval - The bounds to create the normalization function for.\n * @returns A function that takes a value `x` and returns the normalized value.\n * @since 1.0.0\n */\nexport const toNormalizeFn: (interval: Bounds) => (x: number) => number = internal.toNormalizeFn\n\n/**\n * Remaps a value from one bounds to another.\n *\n * @param source - The source bounds.\n * @param target - The target bounds.\n * @param x - The value to remap.\n * @returns The remapped value.\n * @since 1.0.0\n */\nexport const remap: (source: Bounds, target: Bounds, x: number) => number = internal.remap\n\n/**\n * Creates a remapping function for given bounds.\n *\n * @param source - The source bounds.\n * @param target - The target bounds.\n * @returns A function that takes a value `x` and returns the remapped value.\n * @since 1.0.0\n */\nexport const toRemapFn: (source: Bounds, target: Bounds) => (x: number) => number =\n internal.toRemapFn\n\n/**\n * Calculates the scale and shift needed to map a source bounds to a target bounds.\n *\n * @param source - The source bounds.\n * @param target - The target bounds.\n * @returns An object containing the scale and shift values.\n * @since 1.0.0\n */\nexport const scaleShift: (source: Bounds, target: Bounds) => ScaleShift = internal.scaleShift\n\n/**\n * The scale and shift needed to map a source bounds to a target bounds.\n *\n * @since 1.0.0\n */\nexport interface ScaleShift {\n readonly scale: number\n readonly shift: number\n}\n"],"mappings":";;;;AAIA,MAAM,SAAwB,OAAO,IAAI,iBAAiB;AAG1D,IAAe,eAAf,cAAoC,SAAS;CAC3C,CAAU,UAAkB;CAI5B;CACA;CAEA,YAAY,OAAe,KAAa;EACt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;;AAOjE,MAAa,kBAA0DC;;;;;;AAOvE,MAAa,gBAA0DC;;;;;;AAOvE,MAAa,OAAeC;;;;;;;;AAS5B,MAAa,WAAiBC;;;;;;AAO9B,MAAa,SAAiBC;;;;;;;;;AAU9B,MAAa,OAAgDC;;;;;;;;AAS7D,MAAa,WAAwDC;;;;;;;;;AAUrE,MAAa,YAAqDC;;;;;;;;AASlE,MAAa,gBAA6DC;;;;;;;;;;AAW1E,MAAa,QAA+DC;;;;;;;;;AAU5E,MAAa,YACXC;;;;;;;;;AAUF,MAAa,aAA6DC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quadratic-DEhuAKuE.mjs","names":["internal.isLinearPolynomial","equals","internal.equals","make","internal.make","fromVector","internal.fromVector","internal.fromPointSlope","fromPoints","internal.fromPoints","solve","internal.solve","toSolver","internal.toSolver","solveInverse","internal.solveInverse","toInverseSolver","internal.toInverseSolver","monotonicity","internal.monotonicity","isMonotonic","internal.isMonotonic","isIncreasing","internal.isIncreasing","isDecreasing","internal.isDecreasing","asMonotonic","internal.asMonotonic","asIncreasing","internal.asIncreasing","asDecreasing","internal.asDecreasing","derivative","internal.derivative","antiderivative","internal.antiderivative","domain","internal.domain","range","internal.range","length","internal.length","internal.isQuadraticPolynomial","internal.equals","internal.make","internal.fromVector","internal.fromPoints","internal.solve","internal.toSolver","internal.solveInverse","internal.toInverseSolver","internal.derivative","internal.roots","internal.extreme","internal.monotonicity","internal.isMonotonic","internal.isIncreasing","internal.isDecreasing","internal.asMonotonic","internal.asIncreasing","internal.asDecreasing","internal.antiderivative","internal.domain","internal.range","internal.length","internal.curvature"],"sources":["../../src/polynomial/linear.ts","../../src/polynomial/quadratic.ts"],"sourcesContent":["import type { Interval } from '../interval/interval'\nimport type { Pipeable } from '../utils'\nimport type * as Solution from '../solution/solution'\nimport type { Vector2 } from '../vector/vector2'\nimport type { LinearPolynomialTypeId } from './linear.internal'\nimport * as internal from './linear.internal'\nimport type { GuaranteedMonotonicity } from './monotonicity'\nimport type { QuadraticPolynomial } from './quadratic'\nimport type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits'\n\nexport type { Monotonic, Increasing, Decreasing } from './traits'\n\n/**\n * A linear polynomial.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Traits` type parameter is a phantom marker that accumulates trait\n * brands as the polynomial is refined via `isMonotonic` / `asMonotonic` and\n * friends. The runtime value carries no trait data — `Traits` only flows\n * through the type system to enable tighter return types on operations like\n * `solveInverse`.\n *\n * @since 1.0.0\n */\nexport interface LinearPolynomial<out Traits = unknown> extends Pipeable {\n readonly [LinearPolynomialTypeId]: LinearPolynomialTypeId\n readonly [PolynomialTraits]: Traits\n\n /**\n * The coefficient of the x^0 term.\n */\n readonly c0: number\n\n /**\n * The coefficient of the x^1 term.\n */\n readonly c1: number\n}\n\n/**\n * Checks if a value is a `LinearPolynomial`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is a `LinearPolynomial`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isLinearPolynomial: (v: unknown) => v is LinearPolynomial = internal.isLinearPolynomial\n\nexport const equals: {\n /**\n * Checks if two `LinearPolynomial` instances are approximately equal within\n * the default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first polynomial.\n * @param b - The second polynomial.\n * @returns `true` when each pair of coefficients is within tolerance.\n * @since 1.1.0\n */\n (a: LinearPolynomial, b: LinearPolynomial): boolean\n /**\n * Checks if two `LinearPolynomial` instances are approximately equal within\n * the default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second polynomial.\n * @returns A function that takes the first polynomial and returns the comparison result.\n * @since 1.1.0\n */\n (b: LinearPolynomial): (a: LinearPolynomial) => boolean\n} = internal.equals\n\n/**\n * Creates a new `LinearPolynomial` instance.\n *\n * @param c0 - The coefficient of the x^0 term. Defaults to 0.\n * @param c1 - The coefficient of the x^1 term. Defaults to 0.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const make: (c0?: number, c1?: number) => LinearPolynomial = internal.make\n\n/**\n * Creates a new `LinearPolynomial` instance from a vector.\n *\n * @param v - The vector to create the polynomial from.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromVector: (v: Vector2) => LinearPolynomial = internal.fromVector\n\n/**\n * Creates a new `LinearPolynomial` instance from a point and slope.\n *\n * @param p - The point on the line.\n * @param slope - The slope of the line.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromPointSlope: (p: Vector2, slope: number) => LinearPolynomial =\n internal.fromPointSlope\n\n/**\n * Creates a new `LinearPolynomial` instance from two points.\n *\n * @param p1 - The first point.\n * @param p2 - The second point.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromPoints: (p1: Vector2, p2: Vector2) => LinearPolynomial = internal.fromPoints\n\nexport const solve: {\n /**\n * Solves a linear polynomial for a given value of x.\n *\n * @param p - The linear polynomial to solve.\n * @param x - The value of x to solve for.\n * @returns The result of the polynomial evaluated at x.\n * @since 1.0.0\n */\n (p: LinearPolynomial, x: number): number\n /**\n * Solves a linear polynomial for a given value of x.\n *\n * @param x - The value of x to solve for.\n * @returns A function that takes a `LinearPolynomial` and returns the result of the polynomial evaluated at x.\n * @since 1.0.0\n */\n (x: number): (p: LinearPolynomial) => number\n} = internal.solve\n\n/**\n * Converts a linear polynomial to a solver function.\n *\n * @param p - The linear polynomial to convert.\n * @returns A function that takes a value of x and returns the result of the polynomial evaluated at x.\n * @since 1.0.0\n */\nexport const toSolver: (p: LinearPolynomial) => (x: number) => number = internal.toSolver\n\n// The implementation always runs the same `c1 === 0 ? Solution.none : ...`\n// branch. For `Monotonic`-branded polynomials the empty branch is provably\n// unreachable, but TS can't see that — the cast pairs the type-level promise\n// with the runtime brand check.\nexport const solveInverse: {\n /**\n * Solves a monotonic linear polynomial for a given value of y. Because the\n * polynomial is strictly monotonic, the inverse always has exactly one\n * solution — wrapped in `Solution.One`.\n *\n * @param p - The monotonic linear polynomial to solve.\n * @param y - The value of y to solve for.\n * @since 2.0.0\n */\n <T extends Monotonic>(p: LinearPolynomial<T>, y: number): Solution.One<number>\n /**\n * Solves a linear polynomial for a given value of y. Returns `Solution.none`\n * for constant polynomials (no inverse).\n *\n * @param p - The linear polynomial to solve.\n * @param y - The value of y to solve for.\n * @since 1.0.0\n */\n <T>(p: LinearPolynomial<T>, y: number): Solution.AtMostOne<number>\n /** @since 1.0.0 */\n (y: number): {\n <T extends Monotonic>(p: LinearPolynomial<T>): Solution.One<number>\n <T>(p: LinearPolynomial<T>): Solution.AtMostOne<number>\n }\n} = internal.solveInverse as never\n\n/**\n * Converts a linear polynomial to an inverse solver function.\n *\n * @param p - The linear polynomial to convert.\n * @since 1.0.0\n */\nexport const toInverseSolver: (p: LinearPolynomial) => (y: number) => Solution.AtMostOne<number> =\n internal.toInverseSolver\n\n/**\n * Finds the roots of a linear polynomial.\n *\n * @param p - The linear polynomial to find the roots of.\n * @since 1.0.0\n */\nexport const root: (p: LinearPolynomial) => Solution.AtMostOne<number> = (p) =>\n internal.solveInverse(p, 0)\n\n/**\n * Calculates the monotonicity of a linear polynomial.\n *\n * @param p - The linear polynomial to check.\n * @returns The guaranteed monotonicity of the polynomial.\n * @since 1.0.0\n */\nexport const monotonicity: (p: LinearPolynomial) => GuaranteedMonotonicity = internal.monotonicity\n\n/**\n * Type-narrowing predicate: refines a `LinearPolynomial<T>` to\n * `LinearPolynomial<T & Monotonic>` when the polynomial is strictly monotonic.\n *\n * @param p - The linear polynomial to check.\n * @returns `true` when `monotonicity(p)` is `'increasing'` or `'decreasing'`.\n * @since 2.0.0\n */\nexport const isMonotonic: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Monotonic> =\n internal.isMonotonic\n\n/**\n * Type-narrowing predicate: refines to `LinearPolynomial<T & Increasing>`.\n *\n * @param p - The linear polynomial to check.\n * @returns `true` when `monotonicity(p)` is `'increasing'`.\n * @since 2.0.0\n */\nexport const isIncreasing: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Increasing> =\n internal.isIncreasing\n\n/**\n * Type-narrowing predicate: refines to `LinearPolynomial<T & Decreasing>`.\n *\n * @param p - The linear polynomial to check.\n * @returns `true` when `monotonicity(p)` is `'decreasing'`.\n * @since 2.0.0\n */\nexport const isDecreasing: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Decreasing> =\n internal.isDecreasing\n\n/**\n * Asserts that the linear polynomial is monotonic, throwing on failure.\n *\n * @param p - The linear polynomial to assert against.\n * @returns The same polynomial, typed with the `Monotonic` brand.\n * @throws When `monotonicity(p)` is `'constant'`.\n * @since 2.0.0\n */\nexport const asMonotonic: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Monotonic> =\n internal.asMonotonic\n\n/**\n * Asserts that the linear polynomial is increasing, throwing on failure.\n *\n * @param p - The linear polynomial to assert against.\n * @returns The same polynomial, typed with the `Increasing` brand.\n * @throws When `monotonicity(p)` is not `'increasing'`.\n * @since 2.0.0\n */\nexport const asIncreasing: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Increasing> =\n internal.asIncreasing\n\n/**\n * Asserts that the linear polynomial is decreasing, throwing on failure.\n *\n * @param p - The linear polynomial to assert against.\n * @returns The same polynomial, typed with the `Decreasing` brand.\n * @throws When `monotonicity(p)` is not `'decreasing'`.\n * @since 2.0.0\n */\nexport const asDecreasing: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Decreasing> =\n internal.asDecreasing\n\n/**\n * Calculates the derivative of a linear polynomial.\n *\n * @param p - The linear polynomial to differentiate.\n * @returns The derivative of the linear polynomial.\n * @since 1.0.0\n */\nexport const derivative: (p: LinearPolynomial) => number = internal.derivative\n\nexport const antiderivative: {\n /**\n * Calculates the antiderivative of a linear polynomial.\n *\n * @param p - The linear polynomial to integrate.\n * @param constant - The constant of integration. Defaults to 0.\n * @returns The antiderivative of the linear polynomial.\n * @since 1.0.0\n */\n (p: LinearPolynomial, constant?: number): QuadraticPolynomial\n /**\n * Calculates the antiderivative of a linear polynomial.\n *\n * @param constant - The constant of integration. Defaults to 0.\n * @returns A function that takes a `LinearPolynomial` and returns the antiderivative of the polynomial.\n * @since 1.0.0\n */\n (constant: number): (p: LinearPolynomial) => QuadraticPolynomial\n} = internal.antiderivative\n\nexport const domain: {\n /**\n * Calculates the domain of a linear polynomial.\n *\n * @param p - The linear polynomial to check.\n * @param range - The range to check against.\n * @returns The domain of the polynomial within the given range.\n * @since 1.0.0\n */\n (p: LinearPolynomial, range: Interval): Solution.AtMostOne<Interval>\n /**\n * Calculates the domain of a linear polynomial.\n *\n * @param range - The range to check against.\n * @returns A function that takes a `LinearPolynomial` and returns the domain of the polynomial within the given range.\n * @since 1.0.0\n */\n (range: Interval): (p: LinearPolynomial) => Solution.AtMostOne<Interval>\n} = internal.domain\n\nexport const range: {\n /**\n * Calculates the range of a linear polynomial.\n *\n * @param p - The linear polynomial to check.\n * @param domain - The domain to check against.\n * @returns The range of the polynomial within the given domain.\n * @since 1.0.0\n */\n (p: LinearPolynomial, domain: Interval): Interval\n /**\n * Calculates the range of a linear polynomial.\n *\n * @param domain - The domain to check against.\n * @returns A function that takes a `LinearPolynomial` and returns the range of the polynomial within the given domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: LinearPolynomial) => Interval\n} = internal.range\n\nexport const length: {\n /**\n * Calculates the length of a linear polynomial within a particular domain `Interval`.\n *\n * @param p - The linear polynomial to analyze.\n * @param domain - The domain to restrict the analysis to.\n * @returns The length of the linear polynomial in the specified domain.\n * @since 1.0.0\n */\n (p: LinearPolynomial, domain: Interval): number\n /**\n * Calculates the length of a linear polynomial within a particular domain `Interval`.\n *\n * @param domain - The domain to restrict the analysis to.\n * @returns A function that takes a `LinearPolynomial` and returns the length of the polynomial in the specified domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: LinearPolynomial) => number\n} = internal.length\n","import type { Interval } from '../interval/interval'\nimport type { Pipeable } from '../utils'\nimport type * as Solution from '../solution/solution'\nimport type { Vector2 } from '../vector/vector2'\nimport type { Vector3 } from '../vector/vector3'\nimport type { CubicPolynomial } from './cubic'\nimport type { LinearPolynomial } from './linear'\nimport type { Monotonicity } from './monotonicity'\nimport * as internal from './quadratic.internal'\nimport type { QuadraticPolynomialTypeId } from './quadratic.internal.circular'\nimport type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits'\n\nexport type { Monotonic, Increasing, Decreasing } from './traits'\n\n/**\n * A quadratic polynomial.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Traits` type parameter is a phantom marker that accumulates trait\n * brands as the polynomial is refined via `isMonotonic` / `asMonotonic` and\n * friends. Refinements may be parameterized by an `Interval` — a quadratic is\n * monotonic on an interval that avoids its extremum, even though it is not\n * monotonic globally.\n *\n * @since 1.0.0\n */\nexport interface QuadraticPolynomial<out Traits = unknown> extends Pipeable {\n readonly [QuadraticPolynomialTypeId]: QuadraticPolynomialTypeId\n readonly [PolynomialTraits]: Traits\n\n /**\n * The coefficient of the x^0 term.\n */\n readonly c0: number\n /**\n * The coefficient of the x^1 term.\n */\n readonly c1: number\n /**\n * The coefficient of the x^2 term.\n */\n readonly c2: number\n}\n\n/**\n * Checks if a value is a `QuadraticPolynomial`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is a `QuadraticPolynomial`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isQuadraticPolynomial: (v: unknown) => v is QuadraticPolynomial =\n internal.isQuadraticPolynomial\n\nexport const equals: {\n /**\n * Checks if two `QuadraticPolynomial` instances are approximately equal\n * within the default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first polynomial.\n * @param b - The second polynomial.\n * @returns `true` when each pair of coefficients is within tolerance.\n * @since 1.1.0\n */\n (a: QuadraticPolynomial, b: QuadraticPolynomial): boolean\n /**\n * Checks if two `QuadraticPolynomial` instances are approximately equal\n * within the default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second polynomial.\n * @returns A function that takes the first polynomial and returns the comparison result.\n * @since 1.1.0\n */\n (b: QuadraticPolynomial): (a: QuadraticPolynomial) => boolean\n} = internal.equals\n\n/**\n * Creates a new `QuadraticPolynomial` instance.\n *\n * @param c0 - The coefficient of the x^0 term. Defaults to 0.\n * @param c1 - The coefficient of the x^1 term. Defaults to 0.\n * @param c2 - The coefficient of the x^2 term. Defaults to 1.\n * @returns A new `QuadraticPolynomial` instance.\n * @since 1.0.0\n */\nexport const make: (c0?: number, c1?: number, c2?: number) => QuadraticPolynomial = internal.make\n\n/**\n * Creates a new `QuadraticPolynomial` instance from a vector.\n *\n * @param v - The vector to create the polynomial from.\n * @returns A new `QuadraticPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromVector: (v: Vector3) => QuadraticPolynomial = internal.fromVector\n\n/**\n * Creates a new `QuadraticPolynomial` that interpolates the three given\n * points, treating each `Vector2` as an `(x, y)` pair. The three input `x`\n * values must be distinct.\n *\n * @param p0 - The first point.\n * @param p1 - The second point.\n * @param p2 - The third point.\n * @returns The unique quadratic polynomial passing through the three points.\n * @since 2.0.0\n */\nexport const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2) => QuadraticPolynomial =\n internal.fromPoints\n\nexport const solve: {\n /**\n * Solves the quadratic polynomial for a given x value.\n *\n * @param p - The quadratic polynomial.\n * @param x - The x value to solve for.\n * @returns The result of the polynomial at the given x value.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, x: number): number\n /**\n * Solves the quadratic polynomial for a given x value.\n *\n * @param x - The x value to solve for.\n * @returns A function that takes a quadratic polynomial and returns the result of the polynomial at the given x value.\n * @since 1.0.0\n */\n (x: number): (p: QuadraticPolynomial) => number\n} = internal.solve\n\n/**\n * Creates a solver function for the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns A function that takes an x value and returns the result of the polynomial at that x value.\n */\nexport const toSolver: (p: QuadraticPolynomial) => (x: number) => number = internal.toSolver\n\nexport const solveInverse: {\n /**\n * Solves a monotonic quadratic polynomial for a given y value. Because the\n * polynomial is strictly monotonic (either globally, or over the interval\n * the `Monotonic` brand was attached for), the inverse has at most one\n * solution.\n *\n * @param p - The monotonic quadratic polynomial.\n * @param y - The y value to solve for.\n * @returns Zero or one solutions.\n * @since 2.0.0\n */\n <T extends Monotonic>(p: QuadraticPolynomial<T>, y: number): Solution.AtMostOne<number>\n /**\n * Solves the quadratic polynomial for a given y value.\n *\n * @param p - The quadratic polynomial.\n * @param y - The y value to solve for.\n * @returns The solutions to the polynomial at the given y value.\n * @since 1.0.0\n */\n <T>(p: QuadraticPolynomial<T>, y: number): Solution.AtMostTwo<number>\n /**\n * Solves the quadratic polynomial for a given y value.\n *\n * @param y - The y value to solve for.\n * @returns A function that takes a quadratic polynomial and returns the\n * solutions. Tightens to `Solution.AtMostOne<number>` for monotonic inputs.\n * @since 1.0.0\n */\n (y: number): {\n <T extends Monotonic>(p: QuadraticPolynomial<T>): Solution.AtMostOne<number>\n <T>(p: QuadraticPolynomial<T>): Solution.AtMostTwo<number>\n }\n} = internal.solveInverse as never\n\n/**\n * Creates an inverse solver function for the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns A function that takes a y value and returns the solutions to the polynomial at that y value.\n */\nexport const toInverseSolver: (\n p: QuadraticPolynomial,\n) => (y: number) => Solution.AtMostTwo<number> = internal.toInverseSolver\n\n/**\n * Computes the derivative of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns The derivative of the polynomial as a linear polynomial.\n * @since 1.0.0\n */\nexport const derivative: (p: QuadraticPolynomial) => LinearPolynomial = internal.derivative\n\n/**\n * Finds the roots of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns The roots of the polynomial as a tuple of solutions.\n * @since 1.0.0\n */\nexport const roots: (p: QuadraticPolynomial) => Solution.AtMostTwo<number> = internal.roots\n\n/**\n * Finds the extreme point of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns The extreme point of the polynomial as a solution.\n * @since 1.0.0\n */\nexport const extreme: (p: QuadraticPolynomial) => Vector2 | null = internal.extreme\n\nexport const monotonicity: {\n /**\n * Computes the monotonicity of the quadratic polynomial over a given\n * interval. Throws when the interval has zero width — the question is\n * undefined at a single point.\n *\n * @param p - The quadratic polynomial.\n * @param i - The interval to compute the monotonicity over.\n * @returns The monotonicity of the polynomial over the interval.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, i?: Interval): Monotonicity\n /**\n * Computes the monotonicity of the quadratic polynomial over a given\n * interval. Throws when the interval has zero width.\n *\n * @param i - The interval to compute the monotonicity over.\n * @returns A function that takes a quadratic polynomial and returns the\n * monotonicity of the polynomial over the interval.\n * @since 1.0.0\n */\n (i: Interval): (p: QuadraticPolynomial) => Monotonicity\n} = internal.monotonicity\n\n/**\n * Type-narrowing predicate: refines a `QuadraticPolynomial<T>` to\n * `QuadraticPolynomial<T & Monotonic>` when the polynomial is strictly\n * monotonic over the given interval (or globally, when no interval is given).\n *\n * @param p - The quadratic polynomial to check.\n * @param i - Optional interval over which to check monotonicity.\n * @returns `true` when monotonicity is `'increasing'` or `'decreasing'`.\n * @since 2.0.0\n */\nexport const isMonotonic: {\n <T>(p: QuadraticPolynomial<T>, i?: Interval): p is QuadraticPolynomial<T & Monotonic>\n (i: Interval): <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Monotonic>\n} = internal.isMonotonic\n\n/**\n * Type-narrowing predicate: refines to `QuadraticPolynomial<T & Increasing>`.\n *\n * @since 2.0.0\n */\nexport const isIncreasing: {\n <T>(p: QuadraticPolynomial<T>, i?: Interval): p is QuadraticPolynomial<T & Increasing>\n (i: Interval): <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Increasing>\n} = internal.isIncreasing\n\n/**\n * Type-narrowing predicate: refines to `QuadraticPolynomial<T & Decreasing>`.\n *\n * @since 2.0.0\n */\nexport const isDecreasing: {\n <T>(p: QuadraticPolynomial<T>, i?: Interval): p is QuadraticPolynomial<T & Decreasing>\n (i: Interval): <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Decreasing>\n} = internal.isDecreasing\n\n/**\n * Asserts that the quadratic polynomial is monotonic, throwing on failure.\n *\n * @param p - The quadratic polynomial to assert against.\n * @param i - Optional interval over which to check monotonicity.\n * @returns The same polynomial, typed with the `Monotonic` brand.\n * @throws When the polynomial is not monotonic over the given (or global) interval.\n * @since 2.0.0\n */\nexport const asMonotonic: <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval,\n) => QuadraticPolynomial<T & Monotonic> = internal.asMonotonic\n\n/**\n * Asserts that the quadratic polynomial is increasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasing: <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval,\n) => QuadraticPolynomial<T & Increasing> = internal.asIncreasing\n\n/**\n * Asserts that the quadratic polynomial is decreasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasing: <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval,\n) => QuadraticPolynomial<T & Decreasing> = internal.asDecreasing\n\nexport const antiderivative: {\n /**\n * Computes the antiderivative of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @param constant - The constant of integration. Defaults to 0.\n * @returns The antiderivative of the polynomial as a cubic polynomial.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, constant?: number): CubicPolynomial\n /**\n * Computes the antiderivative of the quadratic polynomial.\n *\n * @param constant - The constant of integration. Defaults to 0.\n * @returns A function that takes a quadratic polynomial and returns the antiderivative of the polynomial as a cubic polynomial.\n * @since 1.0.0\n */\n (constant: number): (p: QuadraticPolynomial) => CubicPolynomial\n} = internal.antiderivative\n\nexport const domain: {\n /**\n * Computes the domain of the quadratic polynomial over a given range.\n *\n * @param p - The quadratic polynomial.\n * @param range - The range to compute the domain over.\n * @returns The domain of the polynomial over the range.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, range: Interval): Solution.AtMostOne<Interval>\n /**\n * Computes the domain of the quadratic polynomial over a given range.\n *\n * @param range - The range to compute the domain over.\n * @returns A function that takes a quadratic polynomial and returns the domain of the polynomial over the range.\n * @since 1.0.0\n */\n (range: Interval): (p: QuadraticPolynomial) => Solution.AtMostOne<Interval>\n} = internal.domain\n\nexport const range: {\n /**\n * Computes the range of the quadratic polynomial over a given domain.\n *\n * @param p - The quadratic polynomial.\n * @param domain - The domain to compute the range over.\n * @returns The range of the polynomial over the domain.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, domain: Interval): Interval\n /**\n * Computes the range of the quadratic polynomial over a given domain.\n *\n * @param domain - The domain to compute the range over.\n * @returns A function that takes a quadratic polynomial and returns the range of the polynomial over the domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: QuadraticPolynomial) => Interval\n} = internal.range\n\nexport const length: {\n /**\n * Computes the length of the quadratic polynomial over a given interval.\n *\n * @param p - The quadratic polynomial.\n * @param i - The interval to compute the length over.\n * @returns The length of the polynomial over the interval.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, i: Interval): number\n /**\n * Computes the length of the quadratic polynomial over a given interval.\n *\n * @param i - The interval to compute the length over.\n * @returns A function that takes a quadratic polynomial and returns the length of the polynomial over the interval.\n * @since 1.0.0\n */\n (i: Interval): (p: QuadraticPolynomial) => number\n} = internal.length\n\nexport const curvature: {\n /**\n * Computes the curvature of the quadratic polynomial at a given x value.\n *\n * @param p - The quadratic polynomial.\n * @param x - The x value to compute the curvature at.\n * @returns The curvature of the polynomial at the given x value.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, x: number): number\n /**\n * Computes the curvature of the quadratic polynomial at a given x value.\n *\n * @param x - The x value to compute the curvature at.\n * @returns A function that takes a quadratic polynomial and returns the curvature of the polynomial at the given x value.\n * @since 1.0.0\n */\n (x: number): (p: QuadraticPolynomial) => number\n} = internal.curvature\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,qBAA4DA;AAEzE,MAAaC,WAoBTC;;;;;;;;;AAUJ,MAAaC,SAAuDC;;;;;;;;AASpE,MAAaC,e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