UNPKG

dielines

Version:

Create dielines with pantograph APIs

1 lines 540 kB
{"version":3,"file":"dielines.umd.cjs","sources":["../../pantograph/dist/QuadraticBezier-BeY2TXKH.js","../../pantograph/dist/models-BHeLX0dj.js","../../pantograph/dist/draw-B3EaXatz.js","../../pantograph/dist/svg-BTO7h1ix.js","../../pantograph/dist/pantograph.js","../src/Dieline.ts","../src/drawFlaps.ts","../src/FoldLockBump.ts","../src/linearDistribution.ts"],"sourcesContent":["var Xe = Object.defineProperty;\nvar ye = (r) => {\n throw TypeError(r);\n};\nvar Ze = (r, s, t) => s in r ? Xe(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;\nvar q = (r, s, t) => Ze(r, typeof s != \"symbol\" ? s + \"\" : s, t), oe = (r, s, t) => s.has(r) || ye(\"Cannot \" + t);\nvar ht = (r, s, t) => (oe(r, s, \"read from private field\"), t ? t.call(r) : s.get(r)), le = (r, s, t) => s.has(r) ? ye(\"Cannot add the same private member more than once\") : s instanceof WeakSet ? s.add(r) : s.set(r, t), Dt = (r, s, t, e) => (oe(r, s, \"write to private field\"), e ? e.call(r, t) : s.set(r, t), t), he = (r, s, t) => (oe(r, s, \"access private method\"), t);\nconst Me = Symbol.for(\"pantograph:BoundingBox\");\nfunction Ot(r, s, t, e) {\n return r <= e && s >= t;\n}\nclass mt {\n constructor(s = 1 / 0, t = 1 / 0, e = -1 / 0, n = -1 / 0) {\n q(this, \"xMin\");\n q(this, \"yMin\");\n q(this, \"xMax\");\n q(this, \"yMax\");\n Object.defineProperty(this, Me, { value: !0 }), this.xMin = s, this.yMin = t, this.xMax = e, this.yMax = n;\n }\n static isInstance(s) {\n return !!s && s[Me] === !0;\n }\n get width() {\n return this.xMax - this.xMin;\n }\n get height() {\n return this.yMax - this.yMin;\n }\n get center() {\n return [(this.xMin + this.xMax) / 2, (this.yMin + this.yMax) / 2];\n }\n grow(s) {\n return new mt(\n this.xMin - s,\n this.yMin - s,\n this.xMax + s,\n this.yMax + s\n );\n }\n contains(s) {\n const [t, e] = s;\n return Ot(this.xMin, this.xMax, t, t) && Ot(this.yMin, this.yMax, e, e);\n }\n overlaps(s) {\n return Ot(this.xMin, this.xMax, s.xMin, s.xMax) && Ot(this.yMin, this.yMax, s.yMin, s.yMax);\n }\n addPoint(s) {\n const [t, e] = s;\n return new mt(\n Math.min(this.xMin, t),\n Math.min(this.yMin, e),\n Math.max(this.xMax, t),\n Math.max(this.yMax, e)\n );\n }\n merge(s) {\n return new mt(\n Math.min(this.xMin, s.xMin),\n Math.min(this.yMin, s.yMin),\n Math.max(this.xMax, s.xMax),\n Math.max(this.yMax, s.yMax)\n );\n }\n intersection(s) {\n return new mt(\n Math.max(this.xMin, s.xMin),\n Math.max(this.yMin, s.yMin),\n Math.min(this.xMax, s.xMax),\n Math.min(this.yMax, s.yMax)\n );\n }\n}\nfunction ce(r) {\n return r.reduce((s, t) => s.addPoint(t), new mt());\n}\nconst Pe = (r, s = 1e-9) => {\n let t = r;\n return Math.abs(r) < s && (t = 0), t.toFixed(-Math.log10(s));\n};\nfunction Ne(r, s = 1e-9) {\n return Array.from(\n new Map(\n r.map(([t, e]) => [\n `[${Pe(t, s)},${Pe(e, s)}]`,\n [t, e]\n ])\n ).values()\n );\n}\nconst fe = Math.PI / 180, Je = 180 / Math.PI, Z = (r) => `[${r[0]}, ${r[1]}]`, Y = ([r, s], [t, e], n = 1e-9) => Math.abs(r - t) <= n && Math.abs(s - e) <= n, it = ([r, s], [t, e]) => [r + t, s + e], Q = ([r, s], [t, e]) => [r - t, s - e], Tt = ([r, s]) => r * r + s * s, pn = ([r, s]) => Math.sqrt(Tt([r, s])), nt = ([r, s], t) => [r * t, s * t], Rt = ([r, s], [t, e] = [0, 0]) => (r - t) ** 2 + (s - e) ** 2, J = (r, s = [0, 0]) => Math.sqrt(Rt(r, s));\nfunction St([r, s], [t, e]) {\n return r * e - s * t;\n}\nfunction be([r, s], [t, e]) {\n return r * t + s * e;\n}\nfunction dn([r, s], [t, e] = [0, 0]) {\n return Math.atan2(e * r - s * t, r * t + s * e);\n}\nfunction H([r, s]) {\n const t = J([r, s]);\n return [r / t, s / t];\n}\nfunction It(r, s) {\n const t = Math.cos(s) * r, e = Math.sin(s) * r;\n return [t, e];\n}\nfunction Ke([r, s]) {\n return Math.atan2(s, r);\n}\nfunction He(r) {\n const s = J(r), t = Ke(r);\n return [s, t];\n}\nfunction Ve(r, s, t = 1e-9) {\n const e = St(r, s), n = Tt(r), i = Tt(s);\n return e * e < n * i * t * t;\n}\nfunction tt(r) {\n return [-r[1], r[0]];\n}\nfunction Qt(r) {\n return [r[1], -r[0]];\n}\nfunction ts(r, s, t) {\n return Y(t, r) || Ve(Q(t, r), s);\n}\nconst Ee = Symbol.for(\n \"pantograph:TransformationMatrix\"\n), yt = (r, s) => {\n const [t, e, n, i, o, l, h, a, u] = r, [c, g, d, w, p, P, f, y, E] = s;\n return [\n t * c + e * w + n * f,\n t * g + e * p + n * y,\n t * d + e * P + n * E,\n i * c + o * w + l * f,\n i * g + o * p + l * y,\n i * d + o * P + l * E,\n h * c + a * w + u * f,\n h * g + a * p + u * y,\n h * d + a * P + u * E\n ];\n}, es = (r) => {\n const [s, t, e, n, i, o, l, h, a] = r, u = s * (i * a - o * h) - t * (n * a - o * l) + e * (n * h - i * l);\n return [\n (i * a - o * h) / u,\n (e * h - t * a) / u,\n (t * o - e * i) / u,\n (o * l - n * a) / u,\n (s * a - e * l) / u,\n (e * n - s * o) / u,\n (n * h - i * l) / u,\n (t * l - s * h) / u,\n (s * i - t * n) / u\n ];\n}, ss = (r) => {\n const [s, t, e, n, i, o, l, h, a] = r;\n return [s, n, l, t, i, h, e, o, a];\n};\nclass et {\n constructor(s) {\n q(this, \"_matrix\", [1, 0, 0, 0, 1, 0, 0, 0, 1]);\n Object.defineProperty(this, Ee, {\n value: !0\n }), s && (this._matrix = [...s]);\n }\n static isInstance(s) {\n return !!s && s[Ee] === !0;\n }\n clone() {\n return new et(this._matrix);\n }\n transpose() {\n return this._matrix = ss(this._matrix), this;\n }\n inverse() {\n return this._matrix = es(this._matrix), this;\n }\n translate(s, t) {\n return this._matrix = yt([1, 0, s, 0, 1, t, 0, 0, 1], this._matrix), this;\n }\n rotate(s, t) {\n const e = Math.cos(s), n = Math.sin(s), i = [e, -n, 0, n, e, 0, 0, 0, 1];\n return t && this.translate(-t[0], -t[1]), this._matrix = yt(i, this._matrix), t && this.translate(t[0], t[1]), this;\n }\n mirrorX() {\n return this._matrix = yt([1, 0, 0, 0, -1, 0, 0, 0, 1], this._matrix), this;\n }\n mirrorY() {\n return this._matrix = yt([-1, 0, 0, 0, 1, 0, 0, 0, 1], this._matrix), this;\n }\n mirrorLine(s, t) {\n const [e, n] = s, i = Math.atan2(n, e);\n return t && this.translate(-t[0], -t[1]), this.rotate(-i), this.mirrorX(), this.rotate(i), t && this.translate(t[0], t[1]), this;\n }\n mirrorCenter(s) {\n return s && this.translate(-s[0], -s[1]), this._matrix = yt([-1, 0, 0, 0, -1, 0, 0, 0, 1], this._matrix), s && this.translate(s[0], s[1]), this;\n }\n scale(s, t) {\n return t && this.translate(-t[0], -t[1]), this._matrix = yt([s, 0, 0, 0, s, 0, 0, 0, 1], this._matrix), t && this.translate(t[0], t[1]), this;\n }\n transform(s) {\n const [t, e] = s, [n, i, o, l, h, a] = this._matrix;\n return [n * t + i * e + o, l * t + h * e + a];\n }\n transformAngle(s) {\n const [t, e] = this.transform([Math.cos(s), Math.sin(s)]), [n, i] = this.transform([0, 0]);\n return Math.atan2(e - i, t - n);\n }\n keepsOrientation() {\n const [s, , , , t] = this._matrix;\n return s * t > 0;\n }\n scaleFactor() {\n const [s, , , t] = this._matrix;\n return Math.sqrt(s * s + t * t);\n }\n}\nclass ns {\n translateX(s) {\n const t = new et().translate(s, 0);\n return this.transform(t);\n }\n translateY(s) {\n const t = new et().translate(0, s);\n return this.transform(t);\n }\n translate(s, t) {\n const e = new et().translate(s, t);\n return this.transform(e);\n }\n translateTo([s, t]) {\n const e = new et().translate(s, t);\n return this.transform(e);\n }\n rotate(s, t) {\n const e = new et().rotate(\n s * fe,\n t\n );\n return this.transform(e);\n }\n scale(s, t) {\n const e = new et().scale(s, t);\n return this.transform(e);\n }\n mirrorCenter(s) {\n const t = new et().mirrorCenter(s);\n return this.transform(t);\n }\n mirror(s = \"x\", t) {\n const e = new et();\n return s === \"x\" ? e.mirrorX() : s === \"y\" ? e.mirrorY() : e.mirrorLine(s, t), this.transform(e);\n }\n}\nclass Ft extends ns {\n constructor(t, e) {\n super();\n q(this, \"precision\", 1e-9);\n this.firstPoint = t, this.lastPoint = e, this.firstPoint = t, this.lastPoint = e;\n }\n get repr() {\n return `${this.segmentType} ${Z(this.firstPoint)} - ${Z(\n this.lastPoint\n )}`;\n }\n get info() {\n return this.repr;\n }\n [Symbol.for(\"nodejs.util.inspect.custom\")]() {\n return this.repr;\n }\n}\nconst _e = Symbol.for(\"pantograph:Line\");\nclass at extends Ft {\n constructor(t, e) {\n super(t, e);\n q(this, \"segmentType\", \"LINE\");\n q(this, \"_V\", null);\n q(this, \"_slope\", null);\n q(this, \"_yIntercept\", null);\n q(this, \"_boundingBox\", null);\n Object.defineProperty(this, _e, { value: !0 });\n }\n static isInstance(t) {\n return !!t && t[_e] === !0;\n }\n isValidParameter(t) {\n const e = this.length * this.precision;\n return t >= -e && 1 - t >= -e;\n }\n paramPoint(t) {\n return it(this.firstPoint, nt(this.V, t));\n }\n get length() {\n return J(this.firstPoint, this.lastPoint);\n }\n get squareLength() {\n return Rt(this.firstPoint, this.lastPoint);\n }\n get V() {\n return this._V === null && (this._V = Q(this.lastPoint, this.firstPoint)), this._V;\n }\n get slope() {\n if (this._slope === null) {\n const [t, e] = this.V;\n this._slope = e / t;\n }\n return this._slope;\n }\n get yIntercept() {\n return this._yIntercept === null && (this._yIntercept = this.firstPoint[1] - this.slope * this.firstPoint[0]), this._yIntercept;\n }\n get midPoint() {\n return it(this.firstPoint, nt(this.V, 0.5));\n }\n isSame(t) {\n return at.isInstance(t) ? Y(this.firstPoint, t.firstPoint) && Y(this.lastPoint, t.lastPoint) || Y(this.lastPoint, t.firstPoint) && Y(this.firstPoint, t.lastPoint) : !1;\n }\n clone() {\n return new at(this.firstPoint, this.lastPoint);\n }\n reverse() {\n return new at(this.lastPoint, this.firstPoint);\n }\n get boundingBox() {\n return this._boundingBox === null && (this._boundingBox = new mt(\n Math.min(this.firstPoint[0], this.lastPoint[0]) - this.precision,\n Math.min(this.firstPoint[1], this.lastPoint[1]) - this.precision,\n Math.max(this.firstPoint[0], this.lastPoint[0]) + this.precision,\n Math.max(this.firstPoint[1], this.lastPoint[1]) + this.precision\n )), this._boundingBox;\n }\n distanceFrom(t) {\n const e = Q(t, this.firstPoint), n = be(e, this.V) / this.squareLength;\n if (n < 0)\n return J(t, this.firstPoint);\n if (n > 1)\n return J(t, this.lastPoint);\n const i = this.paramPoint(n);\n return J(t, i);\n }\n isOnSegment(t) {\n if (Y(t, this.firstPoint, this.precision)) return !0;\n const e = Q(t, this.firstPoint);\n if (!Ve(this.V, e)) return !1;\n const n = be(e, this.V) / this.squareLength;\n return this.isValidParameter(n);\n }\n gradientAt(t) {\n return this.V;\n }\n tangentAt(t) {\n if (!this.isOnSegment(t)) throw new Error(\"Point is not on segment\");\n return H(this.V);\n }\n get normalVector() {\n return tt(H(this.V));\n }\n get tangentAtFirstPoint() {\n return H(this.V);\n }\n get tangentAtLastPoint() {\n return H(this.V);\n }\n splitAt(t) {\n let e;\n if (Array.isArray(t) && t.length === 0)\n return [this];\n Array.isArray(t[0]) ? e = t : e = [t], e.forEach((a) => {\n if (!this.isOnSegment(a))\n throw new Error(\n `Point ${Z(a)} is not on segment ${this.repr}`\n );\n });\n const n = [this.firstPoint, ...e, this.lastPoint], i = Ne(n), o = this.lastPoint[0] - this.firstPoint[0];\n let l = Math.sign(o), h = 0;\n return Math.abs(o) < this.precision && (l = Math.sign(this.lastPoint[1] - this.firstPoint[1]), h = 1), i.sort(\n (a, u) => l * (a[h] - u[h])\n ), i.flatMap((a, u) => u === i.length - 1 ? [] : new at(a, i[u + 1]));\n }\n transform(t) {\n return new at(\n t.transform(this.firstPoint),\n t.transform(this.lastPoint)\n );\n }\n}\nfunction is(r) {\n return Array.from(Array(r).keys());\n}\nfunction Kt(r) {\n const s = Math.min(...r.map((t) => t.length));\n return is(s).map((t) => r.map((e) => e[t]));\n}\nfunction wt(r, s = 1e-9) {\n return r < 0 ? r + 2 * Math.PI : r >= 2 * Math.PI ? r % (2 * Math.PI) : r > 2 * Math.PI - s ? 0 : r;\n}\nfunction Zt(r, s, t, e = 1e-9) {\n let n = s - r;\n return t && (n = -n), n < 0 && (n += 2 * Math.PI), n > 2 * Math.PI - e ? 0 : n;\n}\nconst me = (r, s, t) => {\n const e = St(r.V, s.V), n = Tt(r.V), i = Tt(s.V), o = t ? t * t : r.precision * s.precision;\n if (e * e < n * i * o)\n return \"parallel\";\n const l = Q(s.firstPoint, r.firstPoint), h = St(l, s.V) / e, a = St(l, r.V) / e;\n return {\n intersectionParam1: h,\n intersectionParam2: a\n };\n};\nfunction yn(r, s, t = !1, e) {\n const n = me(r, s, e);\n if (n === \"parallel\") {\n if (!t) return null;\n if (r.isSame(s)) return r;\n const l = Ne(\n [\n s.isOnSegment(r.firstPoint) ? r.firstPoint : null,\n s.isOnSegment(r.lastPoint) ? r.lastPoint : null,\n r.isOnSegment(s.firstPoint) ? s.firstPoint : null,\n r.isOnSegment(s.lastPoint) ? s.lastPoint : null\n ].filter((h) => h !== null)\n ).sort((h, a) => h[0] - a[0]);\n if (l.length === 0) return null;\n if (l.length === 1) return null;\n if (l.length === 2) return new at(l[0], l[1]);\n throw console.error(l), new Error(\n \"Unexpected number of points while intersecting parallel lines\"\n );\n }\n const { intersectionParam1: i, intersectionParam2: o } = n;\n return !r.isValidParameter(i) || !s.isValidParameter(o) ? null : r.paramPoint(i);\n}\nconst Bt = (r, s) => {\n const t = Q(r, s);\n return He(t);\n}, je = Symbol.for(\"pantograph:Arc\");\nclass ct extends Ft {\n constructor(t, e, n, i = !1, { ignoreChecks: o = !1 } = {}) {\n super(t, e);\n q(this, \"segmentType\", \"ARC\");\n q(this, \"center\");\n q(this, \"clockwise\");\n q(this, \"_coefficients\", null);\n q(this, \"_angularLength\", null);\n q(this, \"_radius\", null);\n q(this, \"_firstAngle\", null);\n q(this, \"_lastAngle\", null);\n q(this, \"_boundingBox\", null);\n if (Object.defineProperty(this, je, { value: !0 }), this.center = n, this.clockwise = i, !o) {\n if (Y(t, e))\n throw new Error(\"Invalid arc, cannot be a full circle\");\n if (Math.abs(this.radius - J(this.lastPoint, this.center)) > this.precision)\n throw new Error(\n `Invalid arc, radius does not match between ${Z(\n t\n )} and ${Z(e)}} (center ${Z(n)})`\n );\n }\n }\n static isInstance(t) {\n return !!t && t[je] === !0;\n }\n get info() {\n return `ARC(${Z(this.firstPoint)}, ${Z(\n this.lastPoint\n )}, ${Z(this.center)}, ${this.clockwise ? \"CW\" : \"CCW\"})`;\n }\n get coefficients() {\n if (this._coefficients === null) {\n const [t, e] = this.center, n = this.radius * this.radius;\n this._coefficients = {\n x2: 1 / n,\n xy: 0,\n y2: 1 / n,\n x: -(2 * t) / n,\n y: -(2 * e) / n,\n c: (t * t + e * e - n) / n\n };\n }\n return this._coefficients;\n }\n isValidParameter(t) {\n return 1 - t >= -this.precision && t >= -this.precision;\n }\n angleToParam(t) {\n return Zt(this.firstAngle, wt(t), this.clockwise) / this.angularLength;\n }\n get angularLength() {\n return this._angularLength || (this._angularLength = Zt(\n this.firstAngle,\n this.lastAngle,\n this.clockwise\n )), this._angularLength;\n }\n paramPoint(t) {\n return it(\n this.center,\n It(\n this.radius,\n this.firstAngle + t * this.angularLength * (this.clockwise ? -1 : 1)\n )\n );\n }\n pointToParam(t) {\n const [e, n] = Bt(t, this.center);\n if (Math.abs(e - this.radius) > this.precision)\n throw new Error(\n `Point ${Z(t)} is not on segment ${this.repr}`\n );\n const i = this.angleToParam(n);\n if (!this.isValidParameter(i))\n throw new Error(\n `Point ${Z(t)} is not on segment ${this.repr}`\n );\n return i;\n }\n get radius() {\n return this._radius === null && (this._radius = J(this.firstPoint, this.center)), this._radius;\n }\n get firstAngle() {\n if (this._firstAngle === null) {\n const [t, e] = Q(this.firstPoint, this.center);\n this._firstAngle = wt(Math.atan2(e, t));\n }\n return this._firstAngle;\n }\n get lastAngle() {\n if (this._lastAngle === null) {\n const [t, e] = Q(this.lastPoint, this.center);\n this._lastAngle = wt(Math.atan2(e, t));\n }\n return this._lastAngle;\n }\n get length() {\n return this.radius * this.angularLength;\n }\n get squareLength() {\n return this.length * this.length;\n }\n get midPoint() {\n return this.paramPoint(0.5);\n }\n isSame(t) {\n return !ct.isInstance(t) || !Y(this.center, t.center) ? !1 : Y(this.firstPoint, t.firstPoint) && Y(this.lastPoint, t.lastPoint) && this.clockwise === t.clockwise || Y(this.lastPoint, t.firstPoint) && Y(this.firstPoint, t.lastPoint) && this.clockwise === !t.clockwise;\n }\n clone() {\n return new ct(\n this.firstPoint,\n this.lastPoint,\n this.center,\n this.clockwise\n );\n }\n reverse() {\n return new ct(\n this.lastPoint,\n this.firstPoint,\n this.center,\n !this.clockwise\n );\n }\n get boundingBox() {\n if (this._boundingBox === null) {\n const t = this.radius + this.precision, e = (n) => this.isValidParameter(this.angleToParam(n));\n this._boundingBox = new mt(\n e(Math.PI) ? this.center[0] - t : Math.min(this.firstPoint[0], this.lastPoint[0]) - this.precision,\n e(Math.PI * 1.5) ? this.center[1] - t : Math.min(this.firstPoint[1], this.lastPoint[1]) - this.precision,\n e(0) ? this.center[0] + t : Math.max(this.firstPoint[0], this.lastPoint[0]) + this.precision,\n e(Math.PI / 2) ? this.center[1] + t : Math.max(this.firstPoint[1], this.lastPoint[1]) + this.precision\n );\n }\n return this._boundingBox;\n }\n distanceFrom(t) {\n const [e, n] = Bt(t, this.center);\n return this.isValidParameter(this.angleToParam(n)) ? Math.abs(e - this.radius) : Math.sqrt(\n Math.min(\n Rt(t, this.firstPoint),\n Rt(t, this.lastPoint)\n )\n );\n }\n isOnSegment(t) {\n if (Y(t, this.firstPoint) || Y(t, this.lastPoint))\n return !0;\n const [e, n] = Bt(t, this.center);\n if (Math.abs(e - this.radius) > this.precision) return !1;\n const i = this.angleToParam(n);\n return this.isValidParameter(i);\n }\n gradientAt(t) {\n const e = this.firstAngle + t * this.angularLength * (this.clockwise ? -1 : 1), n = this.radius * this.angularLength, i = -n * Math.sin(e), o = n * Math.cos(e);\n return this.clockwise ? [-i, -o] : [i, o];\n }\n tangentAt(t) {\n const [e, n] = Bt(t, this.center);\n if (Math.abs(e - this.radius) > this.precision)\n throw new Error(\"Point is not on the arc\");\n const i = this.angleToParam(n);\n if (!this.isValidParameter(i))\n throw new Error(\"Point is not on the arc\");\n const o = It(1, n);\n return (this.clockwise ? Qt : tt)(H(o));\n }\n get tangentAtFirstPoint() {\n const t = It(1, this.firstAngle);\n return (this.clockwise ? Qt : tt)(H(t));\n }\n get tangentAtLastPoint() {\n const t = It(1, this.lastAngle);\n return (this.clockwise ? Qt : tt)(H(t));\n }\n splitAt(t) {\n let e;\n if (Array.isArray(t) && t.length === 0)\n return [this];\n Array.isArray(t[0]) ? e = t : e = [t];\n const i = [0, 1, ...e.map((h) => this.pointToParam(h))], o = new Map(\n Kt([i, [this.firstPoint, this.lastPoint, ...e]])\n );\n i.sort((h, a) => h - a);\n let l = null;\n return i.flatMap((h, a) => {\n if (a === i.length - 1) return [];\n const u = i[a + 1];\n if (u - h < this.precision)\n return l === null && (l = h), [];\n const c = l === null ? h : l, g = new ct(\n o.get(c) || this.paramPoint(c),\n o.get(u) || this.paramPoint(u),\n this.center,\n this.clockwise\n );\n return l = null, g;\n });\n }\n transform(t) {\n return new ct(\n t.transform(this.firstPoint),\n t.transform(this.lastPoint),\n t.transform(this.center),\n t.keepsOrientation() ? this.clockwise : !this.clockwise\n );\n }\n}\nfunction Mn(r, s, t) {\n const e = new at(s, r), n = new at(s, t), i = tt(e.tangentAtFirstPoint), o = tt(n.tangentAtLastPoint), l = me(\n { firstPoint: e.midPoint, V: i, precision: 1e-9 },\n { firstPoint: n.midPoint, V: o, precision: 1e-9 }\n );\n if (l === \"parallel\")\n throw new Error(\"Cannot create an arc from three colinear points\");\n const h = St(\n Q(r, s),\n Q(t, s)\n ) > 0;\n return new ct(\n r,\n t,\n it(e.midPoint, nt(i, l.intersectionParam1)),\n h,\n { ignoreChecks: !0 }\n );\n}\nfunction Pn(r, s, t) {\n const e = new at(r, s), n = tt(e.tangentAtFirstPoint), i = me(\n { firstPoint: e.midPoint, V: n, precision: 1e-9 },\n {\n firstPoint: r,\n V: tt(t),\n precision: 1e-9\n }\n );\n if (i === \"parallel\")\n throw new Error(\"Cannot create an arc from three colinear points\");\n const o = it(\n e.midPoint,\n nt(n, i.intersectionParam1)\n ), l = St(\n Q(o, r),\n Q(o, it(r, t))\n ) < 0;\n return new ct(r, s, o, l, {\n ignoreChecks: !0\n });\n}\nconst Se = 1e-21, zt = 1.618034;\nfunction ke(r, s = 0, t = 1, e = 110, n = 1e3) {\n let i, o, l, h, a, u, c, g, d, w, p, P, f;\n for (o = r(s), l = r(t), o < l && ([s, t] = [t, s], [o, l] = [l, o]), f = t + zt * (t - s), h = r(f), a = 3, c = 0; h < l; ) {\n if (g = (t - s) * (l - h), d = (t - f) * (l - o), w = d - g, Math.abs(w) < Se ? i = 2 * Se : i = 2 * w, p = t - ((t - f) * d - (t - s) * g) / i, P = t + e * (f - t), c > n)\n throw new Error(\"Too many iterations.\");\n if (c += 1, (p - f) * (t - p) > 0) {\n if (u = r(p), a += 1, u < h)\n return s = t, t = p, o = l, l = u, [s, t, f, o, l, h, a];\n if (u > l)\n return f = p, h = u, [s, t, f, o, l, h, a];\n p = f + zt * (f - t), u = r(p), a += 1;\n } else\n (p - P) * (P - f) >= 0 ? (p = P, u = r(p), a += 1) : (p - P) * (f - p) > 0 ? (u = r(p), a += 1, u < h && (t = f, f = p, p = f + zt * (f - t), l = h, h = u, u = r(p), a += 1)) : (p = f + zt * (f - t), u = r(p), a += 1);\n s = t, t = f, f = p, o = l, l = h, h = u;\n }\n return [s, t, f, o, l, h, a];\n}\nconst Re = 0.381966, rs = 1e-11;\nclass os {\n constructor(s, t = 148e-10, e = 500) {\n q(this, \"xmin\");\n q(this, \"fval\");\n q(this, \"iter\");\n q(this, \"funcalls\");\n q(this, \"brack\");\n this.func = s, this.tol = t, this.maxiter = e, this.func = s, this.tol = t, this.maxiter = e, this.xmin = 1 / 0, this.fval = 1 / 0, this.iter = 0, this.funcalls = 0, this.brack = null;\n }\n setBracket(s = null) {\n this.brack = s;\n }\n getBracketInfo() {\n let s, t, e, n, i, o, l;\n const h = this.func, a = this.brack;\n if (a === null)\n [i, o, l, s, t, e, n] = ke(h);\n else if (a.length === 2)\n [i, o, l, s, t, e, n] = ke(h, a[0], a[1]);\n else if (a.length === 3) {\n if ([i, o, l] = a, i > l && ([l, i] = [i, l]), !(i < o && o < l))\n throw new Error(\"Not a bracketing interval.\");\n if (s = h(i), t = h(o), e = h(l), !(t < s && t < e))\n throw new Error(\"Not a bracketing interval.\");\n n = 3;\n } else\n throw new Error(\n \"Bracketing interval must be length 2 or 3 sequence.\"\n );\n return [i, o, l, s, t, e, n];\n }\n optimize() {\n const s = this.func;\n let [t, e, n, , , , i] = this.getBracketInfo(), o = e, l = e, h = e, a = s(o), u = a, c = a, g, d;\n t < n ? (g = t, d = n) : (g = n, d = t);\n let w = 0;\n i = 1;\n let p = 0, P = 0, f;\n for (; p < this.maxiter; ) {\n const y = this.tol * Math.abs(o) + rs, E = 2 * y, R = 0.5 * (g + d);\n if (Math.abs(o - R) < E - 0.5 * (d - g))\n break;\n if (Math.abs(w) <= y)\n o >= R ? w = g - o : w = d - o, P = Re * w;\n else {\n const L = (o - l) * (c - u);\n let S = (o - h) * (c - a), k = (o - h) * S - (o - l) * L;\n S = 2 * (S - L), S > 0 && (k = -k), S = Math.abs(S);\n const D = w;\n w = P, k > S * (g - o) && k < S * (d - o) && Math.abs(k) < Math.abs(0.5 * S * D) ? (P = k * 1 / S, f = o + P, (f - g < E || d - f < E) && (R - o >= 0 ? P = y : P = -y)) : (o >= R ? w = g - o : w = d - o, P = Re * w);\n }\n Math.abs(P) < y ? P >= 0 ? f = o + y : f = o - y : f = o + P;\n const v = s(f);\n i += 1, v > c ? (f < o ? g = f : d = f, v <= a || l === o ? (h = l, l = f, u = a, a = v) : (v <= u || h === o || h === l) && (h = f, u = v)) : (f >= o ? g = o : d = o, h = l, l = o, o = f, u = a, a = c, c = v), p += 1;\n }\n this.xmin = o, this.fval = c, this.iter = p, this.funcalls = i;\n }\n results() {\n return {\n argMin: this.xmin,\n fMin: this.fval,\n iterations: this.iter,\n funcCalls: this.funcalls\n };\n }\n run() {\n return this.optimize(), this.results();\n }\n}\nfunction $e(r, s = 1e-8, t = 1e3) {\n const e = new os(r, s, t);\n return e.setBracket([0, 1]), e.run();\n}\nfunction Le(r) {\n if (r.__esModule) return r;\n var s = r.default;\n if (typeof s == \"function\") {\n var t = function e() {\n return this instanceof e ? Reflect.construct(s, arguments, this.constructor) : s.apply(this, arguments);\n };\n t.prototype = s.prototype;\n } else t = {};\n return Object.defineProperty(t, \"__esModule\", { value: !0 }), Object.keys(r).forEach(function(e) {\n var n = Object.getOwnPropertyDescriptor(r, e);\n Object.defineProperty(t, e, n.get ? n : {\n enumerable: !0,\n get: function() {\n return r[e];\n }\n });\n }), t;\n}\nvar $ = {};\nconst ls = Object.prototype.toString;\nfunction Ct(r) {\n const s = ls.call(r);\n return s.endsWith(\"Array]\") && !s.includes(\"Big\");\n}\nconst hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n isAnyArray: Ct\n}, Symbol.toStringTag, { value: \"Module\" })), as = /* @__PURE__ */ Le(hs);\nfunction us(r) {\n var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n if (!Ct(r))\n throw new TypeError(\"input must be an array\");\n if (r.length === 0)\n throw new TypeError(\"input must not be empty\");\n var t = s.fromIndex, e = t === void 0 ? 0 : t, n = s.toIndex, i = n === void 0 ? r.length : n;\n if (e < 0 || e >= r.length || !Number.isInteger(e))\n throw new Error(\"fromIndex must be a positive integer smaller than length\");\n if (i <= e || i > r.length || !Number.isInteger(i))\n throw new Error(\"toIndex must be an integer greater than fromIndex and at most equal to length\");\n for (var o = r[e], l = e + 1; l < i; l++)\n r[l] > o && (o = r[l]);\n return o;\n}\nfunction cs(r) {\n var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n if (!Ct(r))\n throw new TypeError(\"input must be an array\");\n if (r.length === 0)\n throw new TypeError(\"input must not be empty\");\n var t = s.fromIndex, e = t === void 0 ? 0 : t, n = s.toIndex, i = n === void 0 ? r.length : n;\n if (e < 0 || e >= r.length || !Number.isInteger(e))\n throw new Error(\"fromIndex must be a positive integer smaller than length\");\n if (i <= e || i > r.length || !Number.isInteger(i))\n throw new Error(\"toIndex must be an integer greater than fromIndex and at most equal to length\");\n for (var o = r[e], l = e + 1; l < i; l++)\n r[l] < o && (o = r[l]);\n return o;\n}\nfunction fs(r) {\n var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n if (Ct(r)) {\n if (r.length === 0)\n throw new TypeError(\"input must not be empty\");\n } else throw new TypeError(\"input must be an array\");\n var t;\n if (s.output !== void 0) {\n if (!Ct(s.output))\n throw new TypeError(\"output option must be an array if specified\");\n t = s.output;\n } else\n t = new Array(r.length);\n var e = cs(r), n = us(r);\n if (e === n)\n throw new RangeError(\"minimum and maximum input values are equal. Cannot rescale a constant array\");\n var i = s.min, o = i === void 0 ? s.autoMinMax ? e : 0 : i, l = s.max, h = l === void 0 ? s.autoMinMax ? n : 1 : l;\n if (o >= h)\n throw new RangeError(\"min option must be smaller than max option\");\n for (var a = (h - o) / (n - e), u = 0; u < r.length; u++)\n t[u] = (r[u] - e) * a + o;\n return t;\n}\nconst ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({\n __proto__: null,\n default: fs\n}, Symbol.toStringTag, { value: \"Module\" })), gs = /* @__PURE__ */ Le(ms);\nObject.defineProperty($, \"__esModule\", { value: !0 });\nvar st = as, ve = gs;\nconst Ut = \" \".repeat(2), De = \" \".repeat(4);\nfunction ws() {\n return Oe(this);\n}\nfunction Oe(r, s = {}) {\n const {\n maxRows: t = 15,\n maxColumns: e = 10,\n maxNumSize: n = 8,\n padMinus: i = \"auto\"\n } = s;\n return `${r.constructor.name} {\n${Ut}[\n${De}${ps(r, t, e, n, i)}\n${Ut}]\n${Ut}rows: ${r.rows}\n${Ut}columns: ${r.columns}\n}`;\n}\nfunction ps(r, s, t, e, n) {\n const { rows: i, columns: o } = r, l = Math.min(i, s), h = Math.min(o, t), a = [];\n if (n === \"auto\") {\n n = !1;\n t: for (let u = 0; u < l; u++)\n for (let c = 0; c < h; c++)\n if (r.get(u, c) < 0) {\n n = !0;\n break t;\n }\n }\n for (let u = 0; u < l; u++) {\n let c = [];\n for (let g = 0; g < h; g++)\n c.push(ds(r.get(u, g), e, n));\n a.push(`${c.join(\" \")}`);\n }\n return h !== o && (a[a.length - 1] += ` ... ${o - t} more columns`), l !== i && a.push(`... ${i - s} more rows`), a.join(`\n${De}`);\n}\nfunction ds(r, s, t) {\n return (r >= 0 && t ? ` ${Ie(r, s - 1)}` : Ie(r, s)).padEnd(s);\n}\nfunction Ie(r, s) {\n let t = r.toString();\n if (t.length <= s) return t;\n let e = r.toFixed(s);\n if (e.length > s && (e = r.toFixed(Math.max(0, s - (e.length - s)))), e.length <= s && !e.startsWith(\"0.000\") && !e.startsWith(\"-0.000\"))\n return e;\n let n = r.toExponential(s);\n return n.length > s && (n = r.toExponential(Math.max(0, s - (n.length - s)))), n.slice(0);\n}\nfunction ys(r, s) {\n r.prototype.add = function(e) {\n return typeof e == \"number\" ? this.addS(e) : this.addM(e);\n }, r.prototype.addS = function(e) {\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) + e);\n return this;\n }, r.prototype.addM = function(e) {\n if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)\n throw new RangeError(\"Matrices dimensions must be equal\");\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) + e.get(n, i));\n return this;\n }, r.add = function(e, n) {\n return new s(e).add(n);\n }, r.prototype.sub = function(e) {\n return typeof e == \"number\" ? this.subS(e) : this.subM(e);\n }, r.prototype.subS = function(e) {\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) - e);\n return this;\n }, r.prototype.subM = function(e) {\n if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)\n throw new RangeError(\"Matrices dimensions must be equal\");\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) - e.get(n, i));\n return this;\n }, r.sub = function(e, n) {\n return new s(e).sub(n);\n }, r.prototype.subtract = r.prototype.sub, r.prototype.subtractS = r.prototype.subS, r.prototype.subtractM = r.prototype.subM, r.subtract = r.sub, r.prototype.mul = function(e) {\n return typeof e == \"number\" ? this.mulS(e) : this.mulM(e);\n }, r.prototype.mulS = function(e) {\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) * e);\n return this;\n }, r.prototype.mulM = function(e) {\n if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)\n throw new RangeError(\"Matrices dimensions must be equal\");\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) * e.get(n, i));\n return this;\n }, r.mul = function(e, n) {\n return new s(e).mul(n);\n }, r.prototype.multiply = r.prototype.mul, r.prototype.multiplyS = r.prototype.mulS, r.prototype.multiplyM = r.prototype.mulM, r.multiply = r.mul, r.prototype.div = function(e) {\n return typeof e == \"number\" ? this.divS(e) : this.divM(e);\n }, r.prototype.divS = function(e) {\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) / e);\n return this;\n }, r.prototype.divM = function(e) {\n if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)\n throw new RangeError(\"Matrices dimensions must be equal\");\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) / e.get(n, i));\n return this;\n }, r.div = function(e, n) {\n return new s(e).div(n);\n }, r.prototype.divide = r.prototype.div, r.prototype.divideS = r.prototype.divS, r.prototype.divideM = r.prototype.divM, r.divide = r.div, r.prototype.mod = function(e) {\n return typeof e == \"number\" ? this.modS(e) : this.modM(e);\n }, r.prototype.modS = function(e) {\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) % e);\n return this;\n }, r.prototype.modM = function(e) {\n if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)\n throw new RangeError(\"Matrices dimensions must be equal\");\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) % e.get(n, i));\n return this;\n }, r.mod = function(e, n) {\n return new s(e).mod(n);\n }, r.prototype.modulus = r.prototype.mod, r.prototype.modulusS = r.prototype.modS, r.prototype.modulusM = r.prototype.modM, r.modulus = r.mod, r.prototype.and = function(e) {\n return typeof e == \"number\" ? this.andS(e) : this.andM(e);\n }, r.prototype.andS = function(e) {\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) & e);\n return this;\n }, r.prototype.andM = function(e) {\n if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)\n throw new RangeError(\"Matrices dimensions must be equal\");\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) & e.get(n, i));\n return this;\n }, r.and = function(e, n) {\n return new s(e).and(n);\n }, r.prototype.or = function(e) {\n return typeof e == \"number\" ? this.orS(e) : this.orM(e);\n }, r.prototype.orS = function(e) {\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) | e);\n return this;\n }, r.prototype.orM = function(e) {\n if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)\n throw new RangeError(\"Matrices dimensions must be equal\");\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) | e.get(n, i));\n return this;\n }, r.or = function(e, n) {\n return new s(e).or(n);\n }, r.prototype.xor = function(e) {\n return typeof e == \"number\" ? this.xorS(e) : this.xorM(e);\n }, r.prototype.xorS = function(e) {\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) ^ e);\n return this;\n }, r.prototype.xorM = function(e) {\n if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)\n throw new RangeError(\"Matrices dimensions must be equal\");\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) ^ e.get(n, i));\n return this;\n }, r.xor = function(e, n) {\n return new s(e).xor(n);\n }, r.prototype.leftShift = function(e) {\n return typeof e == \"number\" ? this.leftShiftS(e) : this.leftShiftM(e);\n }, r.prototype.leftShiftS = function(e) {\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) << e);\n return this;\n }, r.prototype.leftShiftM = function(e) {\n if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)\n throw new RangeError(\"Matrices dimensions must be equal\");\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) << e.get(n, i));\n return this;\n }, r.leftShift = function(e, n) {\n return new s(e).leftShift(n);\n }, r.prototype.signPropagatingRightShift = function(e) {\n return typeof e == \"number\" ? this.signPropagatingRightShiftS(e) : this.signPropagatingRightShiftM(e);\n }, r.prototype.signPropagatingRightShiftS = function(e) {\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) >> e);\n return this;\n }, r.prototype.signPropagatingRightShiftM = function(e) {\n if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)\n throw new RangeError(\"Matrices dimensions must be equal\");\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) >> e.get(n, i));\n return this;\n }, r.signPropagatingRightShift = function(e, n) {\n return new s(e).signPropagatingRightShift(n);\n }, r.prototype.rightShift = function(e) {\n return typeof e == \"number\" ? this.rightShiftS(e) : this.rightShiftM(e);\n }, r.prototype.rightShiftS = function(e) {\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) >>> e);\n return this;\n }, r.prototype.rightShiftM = function(e) {\n if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)\n throw new RangeError(\"Matrices dimensions must be equal\");\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) >>> e.get(n, i));\n return this;\n }, r.rightShift = function(e, n) {\n return new s(e).rightShift(n);\n }, r.prototype.zeroFillRightShift = r.prototype.rightShift, r.prototype.zeroFillRightShiftS = r.prototype.rightShiftS, r.prototype.zeroFillRightShiftM = r.prototype.rightShiftM, r.zeroFillRightShift = r.rightShift, r.prototype.not = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, ~this.get(e, n));\n return this;\n }, r.not = function(e) {\n return new s(e).not();\n }, r.prototype.abs = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.abs(this.get(e, n)));\n return this;\n }, r.abs = function(e) {\n return new s(e).abs();\n }, r.prototype.acos = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.acos(this.get(e, n)));\n return this;\n }, r.acos = function(e) {\n return new s(e).acos();\n }, r.prototype.acosh = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.acosh(this.get(e, n)));\n return this;\n }, r.acosh = function(e) {\n return new s(e).acosh();\n }, r.prototype.asin = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.asin(this.get(e, n)));\n return this;\n }, r.asin = function(e) {\n return new s(e).asin();\n }, r.prototype.asinh = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.asinh(this.get(e, n)));\n return this;\n }, r.asinh = function(e) {\n return new s(e).asinh();\n }, r.prototype.atan = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.atan(this.get(e, n)));\n return this;\n }, r.atan = function(e) {\n return new s(e).atan();\n }, r.prototype.atanh = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.atanh(this.get(e, n)));\n return this;\n }, r.atanh = function(e) {\n return new s(e).atanh();\n }, r.prototype.cbrt = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.cbrt(this.get(e, n)));\n return this;\n }, r.cbrt = function(e) {\n return new s(e).cbrt();\n }, r.prototype.ceil = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.ceil(this.get(e, n)));\n return this;\n }, r.ceil = function(e) {\n return new s(e).ceil();\n }, r.prototype.clz32 = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.clz32(this.get(e, n)));\n return this;\n }, r.clz32 = function(e) {\n return new s(e).clz32();\n }, r.prototype.cos = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.cos(this.get(e, n)));\n return this;\n }, r.cos = function(e) {\n return new s(e).cos();\n }, r.prototype.cosh = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.cosh(this.get(e, n)));\n return this;\n }, r.cosh = function(e) {\n return new s(e).cosh();\n }, r.prototype.exp = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.exp(this.get(e, n)));\n return this;\n }, r.exp = function(e) {\n return new s(e).exp();\n }, r.prototype.expm1 = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.expm1(this.get(e, n)));\n return this;\n }, r.expm1 = function(e) {\n return new s(e).expm1();\n }, r.prototype.floor = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.floor(this.get(e, n)));\n return this;\n }, r.floor = function(e) {\n return new s(e).floor();\n }, r.prototype.fround = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.fround(this.get(e, n)));\n return this;\n }, r.fround = function(e) {\n return new s(e).fround();\n }, r.prototype.log = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.log(this.get(e, n)));\n return this;\n }, r.log = function(e) {\n return new s(e).log();\n }, r.prototype.log1p = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.log1p(this.get(e, n)));\n return this;\n }, r.log1p = function(e) {\n return new s(e).log1p();\n }, r.prototype.log10 = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.log10(this.get(e, n)));\n return this;\n }, r.log10 = function(e) {\n return new s(e).log10();\n }, r.prototype.log2 = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.log2(this.get(e, n)));\n return this;\n }, r.log2 = function(e) {\n return new s(e).log2();\n }, r.prototype.round = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.round(this.get(e, n)));\n return this;\n }, r.round = function(e) {\n return new s(e).round();\n }, r.prototype.sign = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.sign(this.get(e, n)));\n return this;\n }, r.sign = function(e) {\n return new s(e).sign();\n }, r.prototype.sin = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.sin(this.get(e, n)));\n return this;\n }, r.sin = function(e) {\n return new s(e).sin();\n }, r.prototype.sinh = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.sinh(this.get(e, n)));\n return this;\n }, r.sinh = function(e) {\n return new s(e).sinh();\n }, r.prototype.sqrt = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.sqrt(this.get(e, n)));\n return this;\n }, r.sqrt = function(e) {\n return new s(e).sqrt();\n }, r.prototype.tan = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.tan(this.get(e, n)));\n return this;\n }, r.tan = function(e) {\n return new s(e).tan();\n }, r.prototype.tanh = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.tanh(this.get(e, n)));\n return this;\n }, r.tanh = function(e) {\n return new s(e).tanh();\n }, r.prototype.trunc = function() {\n for (let e = 0; e < this.rows; e++)\n for (let n = 0; n < this.columns; n++)\n this.set(e, n, Math.trunc(this.get(e, n)));\n return this;\n }, r.trunc = function(e) {\n return new s(e).trunc();\n }, r.pow = function(e, n) {\n return new s(e).pow(n);\n }, r.prototype.pow = function(e) {\n return typeof e == \"number\" ? this.powS(e) : this.powM(e);\n }, r.prototype.powS = function(e) {\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) ** e);\n return this;\n }, r.prototype.powM = function(e) {\n if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)\n throw new RangeError(\"Matrices dimensions must be equal\");\n for (let n = 0; n < this.rows; n++)\n for (let i = 0; i < this.columns; i++)\n this.set(n, i, this.get(n, i) ** e.get(n, i));\n return this;\n };\n}\nfunction ot(r, s, t) {\n let e = t ? r.rows : r.rows - 1;\n if (s < 0 || s > e)\n throw new RangeError(\"Row index out of range\");\n}\nfunction lt(r, s, t) {\n let e = t ? r.columns : r.columns - 1;\n if (s < 0 || s > e)\n throw new RangeError(\"Column index out of range\");\n}\nfunction Pt(r, s) {\n if (s.to1DArray && (s = s.to1DArray()), s.length !== r.columns)\n throw new RangeError(\n \"vector size must be the same as the number of columns\"\n );\n return s;\n}\nfunction bt(r, s) {\n if (s.to1DArray && (s = s.to1DArray()), s.length !== r.rows)\n throw new RangeError(\"vector size must be the same as the number of rows\");\n return s;\n}\nfunction ge(r, s) {\n if (!st.isAnyArray(s))\n throw new TypeError(\"row indices must be an array\");\n for (let t = 0; t < s.length; t++)\n if (s[t] < 0 || s[t] >= r.rows)\n throw new RangeError(\"row indices are out of range\");\n}\nfunction we(r, s) {\n if (!st.isAnyArray(s))\n throw new TypeError(\"column indices must be an array\");\n for (let t = 0; t < s.length; t++)\n if (s[t] < 0 || s[t] >= r.columns)\n throw new RangeError(\"column indices are out of range\");\n}\nfunction ae(r, s, t, e, n) {\n if (arguments.length !== 5)\n throw new RangeError(\"expected 4 arguments\");\n if (Yt(\"startRow\", s), Yt(\"endRow\", t), Yt(\"startColumn\", e), Yt(\"endColumn\", n), s > t || e > n || s < 0 || s >= r.rows || t < 0 || t >= r.rows || e < 0 || e >= r.columns || n < 0 || n >= r.columns)\n throw new RangeError(\"Submatrix indices are out of range\");\n}\nfunction Ht(r, s = 0) {\n let t = [];\n for (let e = 0; e < r; e++)\n t.push(s);\n return t;\n}\nfunction Yt(r, s) {\n if (typeof s != \"number\")\n throw new TypeError(`${r} must be a number`);\n}\nfunction Mt(r) {\n if (r.isEmpty())\n throw new Error(\"Empty matrix has no elements to index\");\n}\nfunction Ms(r) {\n let s = Ht(r.rows);\n for (let t = 0; t < r.rows; ++t)\n for (let e = 0; e < r.columns; ++e)\n s[t] += r.get(t, e);\n return s;\n}\nfunction Ps(r) {\n let s = Ht(r.columns);\n for (let t = 0; t < r.rows; ++t)\n for (let e = 0; e < r.columns; ++e)\n s[e] += r.get(t, e);\n return s;\n}\nfunction bs(r) {\n let s = 0;\n for (let t = 0; t < r.rows; t++)\n for (let e = 0; e < r.columns; e++)\n s += r.get(t, e);\n return s;\n}\nfunction Es(r) {\n let s = Ht(r.rows, 1);\n for (let t = 0; t < r