pantograph2d 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Diagram-ab93c8b7.cjs +11 -0
- package/dist/Diagram-ab93c8b7.cjs.map +1 -0
- package/dist/Diagram-d848c815.js +4252 -0
- package/dist/Diagram-d848c815.js.map +1 -0
- package/dist/draw-0f591ea4.cjs +2 -0
- package/dist/draw-0f591ea4.cjs.map +1 -0
- package/dist/draw-a830827a.js +288 -0
- package/dist/draw-a830827a.js.map +1 -0
- package/dist/pantograph/drawShape.cjs +1 -1
- package/dist/pantograph/drawShape.cjs.map +1 -1
- package/dist/pantograph/drawShape.js +13 -17
- package/dist/pantograph/drawShape.js.map +1 -1
- package/dist/pantograph/models.cjs +1 -1
- package/dist/pantograph/models.js +3 -3
- package/dist/pantograph.cjs +6 -6
- package/dist/pantograph.cjs.map +1 -1
- package/dist/pantograph.js +475 -334
- package/dist/pantograph.js.map +1 -1
- package/dist/types/algorithms/boolean/figureBooleans.d.ts +8 -0
- package/dist/types/algorithms/boolean/loopBooleans.d.ts +14 -0
- package/dist/types/algorithms/boolean/strandBoolean.d.ts +8 -0
- package/dist/types/algorithms/boolean/strandsBetweenIntersections.d.ts +4 -0
- package/dist/types/algorithms/distances/arcArcDistance.d.ts +2 -0
- package/dist/types/algorithms/distances/genericDistance.d.ts +6 -0
- package/dist/types/algorithms/distances/index.d.ts +2 -0
- package/dist/types/algorithms/distances/lineArcDistance.d.ts +3 -0
- package/dist/types/algorithms/distances/lineLineDistance.d.ts +2 -0
- package/dist/types/algorithms/filletSegments.d.ts +3 -0
- package/dist/types/algorithms/intersections/arcArcIntersection.d.ts +3 -0
- package/dist/types/algorithms/intersections/arcEllipseArcIntersection.d.ts +3 -0
- package/dist/types/algorithms/intersections/ellipseArcEllipseArcIntersection.d.ts +3 -0
- package/dist/types/algorithms/intersections/ellipseEllipseIntersection.d.ts +4 -0
- package/dist/types/algorithms/intersections/index.d.ts +8 -0
- package/dist/types/algorithms/intersections/lineArcIntersection.d.ts +4 -0
- package/dist/types/algorithms/intersections/lineEllipseArcIntersection.d.ts +4 -0
- package/dist/types/algorithms/intersections/lineLineIntersection.d.ts +28 -0
- package/dist/types/algorithms/intersections/rayIntersections.d.ts +3 -0
- package/dist/types/algorithms/offsets/offsetFigure.d.ts +4 -0
- package/dist/types/algorithms/offsets/offsetSegment.d.ts +12 -0
- package/dist/types/algorithms/offsets/offsetStroke.d.ts +9 -0
- package/dist/types/algorithms/optimisation/DiRect.d.ts +45 -0
- package/dist/types/algorithms/organiseLoops.d.ts +9 -0
- package/dist/types/algorithms/simplify.d.ts +3 -0
- package/dist/types/algorithms/solvers/solvePolynomials.d.ts +4 -0
- package/dist/types/algorithms/stitchSegments.d.ts +2 -0
- package/dist/types/api/drawShape.d.ts +2 -0
- package/dist/types/api/models.d.ts +1 -0
- package/dist/types/booleanOperations.d.ts +11 -0
- package/dist/types/definitions.d.ts +2 -0
- package/dist/types/draw.d.ts +47 -0
- package/dist/types/drawShape/drawCircle.d.ts +2 -0
- package/dist/types/drawShape/drawRect.d.ts +5 -0
- package/dist/types/export/json/exportJSON.d.ts +196 -0
- package/dist/types/export/json/jsonDiagram.d.ts +69 -0
- package/dist/types/export/json/jsonFigure.d.ts +66 -0
- package/dist/types/export/json/jsonLoop.d.ts +32 -0
- package/dist/types/export/json/jsonSegment.d.ts +29 -0
- package/dist/types/export/svg/exportSVG.d.ts +18 -0
- package/dist/types/export/svg/svgDiagram.d.ts +2 -0
- package/dist/types/export/svg/svgFigure.d.ts +2 -0
- package/dist/types/export/svg/svgLoop.d.ts +2 -0
- package/dist/types/export/svg/svgSegment.d.ts +2 -0
- package/dist/types/export/svg/svgStrand.d.ts +2 -0
- package/dist/types/export/svg/wrapSVG.d.ts +4 -0
- package/dist/types/import/json/importJSON.d.ts +7 -0
- package/dist/types/main.d.ts +12 -0
- package/dist/types/models/BoundingBox.d.ts +15 -0
- package/dist/types/models/Diagram.d.ts +25 -0
- package/dist/types/models/Figure.d.ts +23 -0
- package/dist/types/models/Loop.d.ts +18 -0
- package/dist/types/models/Strand.d.ts +10 -0
- package/dist/types/models/Stroke.d.ts +29 -0
- package/dist/types/models/TransformationMatrix.d.ts +31 -0
- package/dist/types/models/exports.d.ts +11 -0
- package/dist/types/models/segments/Arc.d.ts +52 -0
- package/dist/types/models/segments/EllipseArc.d.ts +70 -0
- package/dist/types/models/segments/Line.d.ts +32 -0
- package/dist/types/models/segments/Segment.d.ts +28 -0
- package/dist/types/models/utils/Transformable.d.ts +14 -0
- package/dist/types/offsetOperations.d.ts +8 -0
- package/dist/types/operations.d.ts +2 -0
- package/dist/types/utils/allCombinations.d.ts +2 -0
- package/dist/types/utils/allPairs.d.ts +1 -0
- package/dist/types/utils/angularDistance.d.ts +1 -0
- package/dist/types/utils/listOfFigures.d.ts +4 -0
- package/dist/types/utils/projectPointOnLine.d.ts +3 -0
- package/dist/types/utils/range.d.ts +1 -0
- package/dist/types/utils/removeDuplicatePoints.d.ts +2 -0
- package/dist/types/utils/unitAngle.d.ts +1 -0
- package/dist/types/utils/zip.d.ts +3 -0
- package/dist/types/vectorOperations.d.ts +23 -0
- package/package.json +29 -10
- package/dist/Diagram-9915ed5e.js +0 -1700
- package/dist/Diagram-9915ed5e.js.map +0 -1
- package/dist/Diagram-c2ca1c3b.cjs +0 -4
- package/dist/Diagram-c2ca1c3b.cjs.map +0 -1
- package/dist/draw-25b9ed64.cjs +0 -2
- package/dist/draw-25b9ed64.cjs.map +0 -1
- package/dist/draw-cd61ec6b.js +0 -256
- package/dist/draw-cd61ec6b.js.map +0 -1
- package/dist/drawShape.d.ts +0 -153
- package/dist/models.d.ts +0 -210
- package/dist/pantograph/drawShape.d.ts +0 -1
- package/dist/pantograph/models.d.ts +0 -1
- package/dist/pantograph.d.ts +0 -397
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";function bt(i,t,n,e){return i<=e&&t>=n}class st{constructor(t=1/0,n=1/0,e=-1/0,s=-1/0){this.xMin=t,this.yMin=n,this.xMax=e,this.yMax=s}get width(){return this.xMax-this.xMin}get height(){return this.yMax-this.yMin}contains(t){const[n,e]=t;return bt(this.xMin,this.xMax,n,n)&&bt(this.yMin,this.yMax,e,e)}overlaps(t){return bt(this.xMin,this.xMax,t.xMin,t.xMax)&&bt(this.yMin,this.yMax,t.yMin,t.yMax)}addPoint(t){const[n,e]=t;return new st(Math.min(this.xMin,n),Math.min(this.yMin,e),Math.max(this.xMax,n),Math.max(this.yMax,e))}merge(t){return new st(Math.min(this.xMin,t.xMin),Math.min(this.yMin,t.yMin),Math.max(this.xMax,t.xMax),Math.max(this.yMax,t.yMax))}}function Ge(i){return i.reduce((t,n)=>t.addPoint(n),new st)}const Ht=(i,t=1e-9)=>{let n=i;return Math.abs(i)<t&&(n=0),n.toFixed(-Math.log10(t))};function ot(i,t=1e-9){return Array.from(new Map(i.map(([n,e])=>[`[${Ht(n,t)},${Ht(e,t)}]`,[n,e]])).values())}const Ct=Math.PI/180,pe=180/Math.PI,T=i=>`[${i[0]}, ${i[1]}]`,E=([i,t],[n,e],s=1e-9)=>Math.abs(i-n)<=s&&Math.abs(t-e)<=s,B=([i,t],[n,e])=>[i+n,t+e],O=([i,t],[n,e])=>[i-n,t-e],xt=([i,t])=>i*i+t*t,L=([i,t],n)=>[i*n,t*n],gt=([i,t],[n,e]=[0,0])=>(i-n)**2+(t-e)**2,$=(i,t=[0,0])=>Math.sqrt(gt(i,t));function rt([i,t],[n,e]){return i*e-t*n}function Bt([i,t],[n,e]){return i*n+t*e}function X([i,t]){const n=$([i,t]);return[i/n,t/n]}function ft(i,t){const n=Math.cos(t)*i,e=Math.sin(t)*i;return[n,e]}function we([i,t]){return Math.atan2(t,i)}function de(i){const t=$(i),n=we(i);return[t,n]}function zt(i,t,n=1e-9){const e=rt(i,t),s=xt(i),r=xt(t);return e*e<s*r*n*n}function G(i){return[-i[1],i[0]]}function wt(i){return[i[1],-i[0]]}function We(i,t,n){return E(n,i)||zt(O(n,i),t)}const lt=(i,t)=>{const[n,e,s,r,o,h,u,l,c]=i,[a,g,w,m,d,P,f,p,y]=t;return[n*a+e*m+s*f,n*g+e*d+s*p,n*w+e*P+s*y,r*a+o*m+h*f,r*g+o*d+h*p,r*w+o*P+h*y,u*a+l*m+c*f,u*g+l*d+c*p,u*w+l*P+c*y]},Je=i=>{const[t,n,e,s,r,o,h,u,l]=i,c=t*(r*l-o*u)-n*(s*l-o*h)+e*(s*u-r*h);return[(r*l-o*u)/c,(e*u-n*l)/c,(n*o-e*r)/c,(o*h-s*l)/c,(t*l-e*h)/c,(e*s-t*o)/c,(s*u-r*h)/c,(n*h-t*u)/c,(t*r-n*s)/c]},Ke=i=>{const[t,n,e,s,r,o,h,u,l]=i;return[t,s,h,n,r,u,e,o,l]};class N{constructor(t){this._matrix=[1,0,0,0,1,0,0,0,1],t&&(this._matrix=[...t])}clone(){return new N(this._matrix)}transpose(){return this._matrix=Ke(this._matrix),this}inverse(){return this._matrix=Je(this._matrix),this}translate(t,n){return this._matrix=lt(this._matrix,[1,0,t,0,1,n,0,0,1]),this}rotate(t,n){const e=Math.cos(t),s=Math.sin(t),r=[e,-s,0,s,e,0,0,0,1];return n&&this.translate(n[0],n[1]),this._matrix=lt(this._matrix,r),n&&this.translate(-n[0],-n[1]),this}mirrorX(){return this._matrix=lt(this._matrix,[1,0,0,0,-1,0,0,0,1]),this}mirrorY(){return this._matrix=lt(this._matrix,[-1,0,0,0,1,0,0,0,1]),this}mirrorLine(t,n){const[e,s]=t,r=Math.atan2(s,e);return n&&this.translate(n[0],n[1]),this.rotate(r),this.mirrorX(),this.rotate(-r),n&&this.translate(-n[0],-n[1]),this}mirrorCenter(t){return t&&this.translate(t[0],t[1]),this._matrix=lt(this._matrix,[-1,0,0,0,-1,0,0,0,1]),t&&this.translate(-t[0],-t[1]),this}scale(t,n){return n&&this.translate(n[0],n[1]),this._matrix=lt(this._matrix,[t,0,0,0,t,0,0,0,1]),n&&this.translate(-n[0],-n[1]),this}transform(t){const[n,e]=t,[s,r,o,h,u,l]=this._matrix;return[s*n+r*e+o,h*n+u*e+l]}transformAngle(t){const[n,e]=this.transform([Math.cos(t),Math.sin(t)]),[s,r]=this.transform([0,0]);return Math.atan2(e-r,n-s)}keepsOrientation(){const[t,,,,n]=this._matrix;return t*n>0}scaleFactor(){const[t,,,n]=this._matrix;return Math.sqrt(t*t+n*n)}}class Mt{translateX(t){const n=new N().translate(t,0);return this.transform(n)}translateY(t){const n=new N().translate(0,t);return this.transform(n)}translate(t,n){const e=new N().translate(t,n);return this.transform(e)}translateTo([t,n]){const e=new N().translate(t,n);return this.transform(e)}rotate(t,n){const e=new N().rotate(t*Ct,n);return this.transform(e)}scale(t,n){const e=new N().scale(t,n);return this.transform(e)}mirrorCenter(t){const n=new N().mirrorCenter(t);return this.transform(n)}mirror(t="x",n){const e=new N;return t==="x"?e.mirrorX():t==="y"?e.mirrorY():e.mirrorLine(t,n),this.transform(e)}}class Ut extends Mt{constructor(t,n){super(),this.firstPoint=t,this.lastPoint=n,this.precision=1e-9,this.firstPoint=t,this.lastPoint=n}get repr(){return`${this.segmentType} ${T(this.firstPoint)} - ${T(this.lastPoint)}`}get info(){return this.repr}[Symbol.for("nodejs.util.inspect.custom")](){return this.repr}}class x extends Ut{constructor(){super(...arguments),this.segmentType="LINE",this._V=null,this._slope=null,this._yIntercept=null,this._boundingBox=null}isValidParameter(t){const n=this.length*this.precision;return t>=-n&&1-t>=-n}paramPoint(t){return B(this.firstPoint,L(this.V,t))}get length(){return $(this.firstPoint,this.lastPoint)}get squareLength(){return gt(this.firstPoint,this.lastPoint)}get V(){return this._V===null&&(this._V=O(this.lastPoint,this.firstPoint)),this._V}get slope(){if(this._slope===null){const[t,n]=this.V;this._slope=n/t}return this._slope}get yIntercept(){return this._yIntercept===null&&(this._yIntercept=this.firstPoint[1]-this.slope*this.firstPoint[0]),this._yIntercept}get midPoint(){return B(this.firstPoint,L(this.V,.5))}isSame(t){return t instanceof x?E(this.firstPoint,t.firstPoint)&&E(this.lastPoint,t.lastPoint)||E(this.lastPoint,t.firstPoint)&&E(this.firstPoint,t.lastPoint):!1}clone(){return new x(this.firstPoint,this.lastPoint)}reverse(){return new x(this.lastPoint,this.firstPoint)}get boundingBox(){return this._boundingBox===null&&(this._boundingBox=new st(Math.min(this.firstPoint[0],this.lastPoint[0])-this.precision,Math.min(this.firstPoint[1],this.lastPoint[1])-this.precision,Math.max(this.firstPoint[0],this.lastPoint[0])+this.precision,Math.max(this.firstPoint[1],this.lastPoint[1])+this.precision)),this._boundingBox}distanceFrom(t){const n=O(t,this.firstPoint),e=Bt(n,this.V)/this.squareLength;if(e<0)return $(t,this.firstPoint);if(e>1)return $(t,this.lastPoint);const s=this.paramPoint(e);return $(t,s)}isOnSegment(t){if(E(t,this.firstPoint,this.precision))return!0;const n=O(t,this.firstPoint);if(!zt(this.V,n))return!1;const e=Bt(n,this.V)/this.squareLength;return this.isValidParameter(e)}gradientAt(t){return this.V}tangentAt(t){if(!this.isOnSegment(t))throw new Error("Point is not on segment");return X(this.V)}get normalVector(){return G(X(this.V))}get tangentAtFirstPoint(){return X(this.V)}get tangentAtLastPoint(){return X(this.V)}splitAt(t){let n;if(Array.isArray(t)&&t.length===0)return[this];Array.isArray(t[0])?n=t:n=[t],n.forEach(u=>{if(!this.isOnSegment(u))throw new Error(`Point ${T(u)} is not on segment ${this.repr}`)});const e=[this.firstPoint,...n,this.lastPoint],s=ot(e),r=this.lastPoint[0]-this.firstPoint[0];let o=Math.sign(r),h=0;return Math.abs(r)<this.precision&&(o=Math.sign(this.lastPoint[1]-this.firstPoint[1]),h=1),s.sort((u,l)=>o*(u[h]-l[h])),s.flatMap((u,l)=>l===s.length-1?[]:new x(u,s[l+1]))}transform(t){return new x(t.transform(this.firstPoint),t.transform(this.lastPoint))}}function Qe(i){return Array.from(Array(i).keys())}function nt(i){const t=Math.min(...i.map(n=>n.length));return Qe(t).map(n=>i.map(e=>e[n]))}function it(i,t=1e-9){return i<0?i+2*Math.PI:i>=2*Math.PI?i%(2*Math.PI):i>2*Math.PI-t?0:i}function Rt(i,t,n,e=1e-9){let s=t-i;return n&&(s=-s),s<0&&(s+=2*Math.PI),s>2*Math.PI-e?0:s}const Et=(i,t,n)=>{const e=rt(i.V,t.V),s=xt(i.V),r=xt(t.V),o=n?n*n:i.precision*t.precision;if(e*e<s*r*o)return"parallel";const h=O(t.firstPoint,i.firstPoint),u=rt(h,t.V)/e,l=rt(h,i.V)/e;return{intersectionParam1:u,intersectionParam2:l}};function ye(i,t,n=!1,e){const s=Et(i,t,e);if(s==="parallel"){if(!n)return null;if(i.isSame(t))return i;const h=ot([t.isOnSegment(i.firstPoint)?i.firstPoint:null,t.isOnSegment(i.lastPoint)?i.lastPoint:null,i.isOnSegment(t.firstPoint)?t.firstPoint:null,i.isOnSegment(t.lastPoint)?t.lastPoint:null].filter(u=>u!==null)).sort((u,l)=>u[0]-l[0]);if(h.length===0)return null;if(h.length===1)return null;if(h.length===2)return new x(h[0],h[1]);throw console.error(h),new Error("Unexpected number of points while intersecting parallel lines")}const{intersectionParam1:r,intersectionParam2:o}=s;return!i.isValidParameter(r)||!t.isValidParameter(o)?null:i.paramPoint(r)}const jt=(i,t)=>{const n=O(i,t);return de(n)};class I extends Ut{constructor(t,n,e,s=!1,{ignoreChecks:r=!1}={}){if(super(t,n),this.segmentType="ARC",this._coefficients=null,this._angularLength=null,this._radius=null,this._firstAngle=null,this._lastAngle=null,this._boundingBox=null,this.center=e,this.clockwise=s,!r){if(E(t,n))throw new Error("Invalid arc, cannot be a full circle");if(Math.abs(this.radius-$(this.lastPoint,this.center))>this.precision)throw new Error(`Invalid arc, radius does not match between ${T(t)} and ${T(n)}} (center ${T(e)})`)}}get info(){return`ARC(${T(this.firstPoint)}, ${T(this.lastPoint)}, ${T(this.center)}, ${this.clockwise?"CW":"CCW"})`}get coefficients(){if(this._coefficients===null){const[t,n]=this.center,e=this.radius*this.radius;this._coefficients={x2:1/e,xy:0,y2:1/e,x:-(2*t)/e,y:-(2*n)/e,c:(t*t+n*n-e)/e}}return this._coefficients}isValidParameter(t){return 1-t>=-this.precision&&t>=-this.precision}angleToParam(t){return Rt(this.firstAngle,it(t),this.clockwise)/this.angularLength}get angularLength(){return this._angularLength||(this._angularLength=Rt(this.firstAngle,this.lastAngle,this.clockwise)),this._angularLength}paramPoint(t){return B(this.center,ft(this.radius,this.firstAngle+t*this.angularLength*(this.clockwise?-1:1)))}pointToParam(t){const[n,e]=jt(t,this.center);if(Math.abs(n-this.radius)>this.precision)throw new Error(`Point ${T(t)} is not on segment ${this.repr}`);const s=this.angleToParam(e);if(!this.isValidParameter(s))throw new Error(`Point ${T(t)} is not on segment ${this.repr}`);return s}get radius(){return this._radius===null&&(this._radius=$(this.firstPoint,this.center)),this._radius}get firstAngle(){if(this._firstAngle===null){const[t,n]=O(this.firstPoint,this.center);this._firstAngle=it(Math.atan2(n,t))}return this._firstAngle}get lastAngle(){if(this._lastAngle===null){const[t,n]=O(this.lastPoint,this.center);this._lastAngle=it(Math.atan2(n,t))}return this._lastAngle}get length(){return this.radius*this.angularLength}get squareLength(){return this.length*this.length}get midPoint(){return this.paramPoint(.5)}isSame(t){return!(t instanceof I)||!E(this.center,t.center)?!1:E(this.firstPoint,t.firstPoint)&&E(this.lastPoint,t.lastPoint)&&this.clockwise===t.clockwise||E(this.lastPoint,t.firstPoint)&&E(this.firstPoint,t.lastPoint)&&this.clockwise===!t.clockwise}clone(){return new I(this.firstPoint,this.lastPoint,this.center,this.clockwise)}reverse(){return new I(this.lastPoint,this.firstPoint,this.center,!this.clockwise)}get boundingBox(){if(this._boundingBox===null){const t=this.radius+this.precision,n=e=>this.isValidParameter(this.angleToParam(e));this._boundingBox=new st(n(Math.PI)?this.center[0]-t:Math.min(this.firstPoint[0],this.lastPoint[0])-this.precision,n(Math.PI*1.5)?this.center[1]-t:Math.min(this.firstPoint[1],this.lastPoint[1])-this.precision,n(0)?this.center[0]+t:Math.max(this.firstPoint[0],this.lastPoint[0])+this.precision,n(Math.PI/2)?this.center[1]+t:Math.max(this.firstPoint[1],this.lastPoint[1])+this.precision)}return this._boundingBox}distanceFrom(t){const[n,e]=jt(t,this.center);return this.isValidParameter(this.angleToParam(e))?Math.abs(n-this.radius):Math.sqrt(Math.min(gt(t,this.firstPoint),gt(t,this.lastPoint)))}isOnSegment(t){if(E(t,this.firstPoint)||E(t,this.lastPoint))return!0;const[n,e]=jt(t,this.center);if(Math.abs(n-this.radius)>this.precision)return!1;const s=this.angleToParam(e);return this.isValidParameter(s)}gradientAt(t){const n=this.firstAngle+t*this.angularLength*(this.clockwise?-1:1),e=this.radius*this.angularLength,s=-e*Math.sin(n),r=e*Math.cos(n);return this.clockwise?[-s,-r]:[s,r]}tangentAt(t){const[n,e]=jt(t,this.center);if(Math.abs(n-this.radius)>this.precision)throw new Error("Point is not on the arc");const s=this.angleToParam(e);if(!this.isValidParameter(s))throw new Error("Point is not on the arc");const r=ft(1,e);return(this.clockwise?wt:G)(X(r))}get tangentAtFirstPoint(){const t=ft(1,this.firstAngle);return(this.clockwise?wt:G)(X(t))}get tangentAtLastPoint(){const t=ft(1,this.lastAngle);return(this.clockwise?wt:G)(X(t))}splitAt(t){let n;if(Array.isArray(t)&&t.length===0)return[this];Array.isArray(t[0])?n=t:n=[t];const s=[0,1,...n.map(h=>this.pointToParam(h))],r=new Map(nt([s,[this.firstPoint,this.lastPoint,...n]]));s.sort((h,u)=>h-u);let o=null;return s.flatMap((h,u)=>{if(u===s.length-1)return[];const l=s[u+1];if(l-h<this.precision)return o===null&&(o=h),[];const c=o===null?h:o,a=new I(r.get(c)||this.paramPoint(c),r.get(l)||this.paramPoint(l),this.center,this.clockwise);return o=null,a})}transform(t){return new I(t.transform(this.firstPoint),t.transform(this.lastPoint),t.transform(this.center),t.keepsOrientation()?this.clockwise:!this.clockwise)}}function Ze(i,t,n){const e=new x(t,i),s=new x(t,n),r=G(e.tangentAtFirstPoint),o=G(s.tangentAtLastPoint),h=Et({firstPoint:e.midPoint,V:r,precision:1e-9},{firstPoint:s.midPoint,V:o,precision:1e-9});if(h==="parallel")throw new Error("Cannot create an arc from three colinear points");const u=rt(O(i,t),O(n,t))>0;return new I(i,n,B(e.midPoint,L(r,h.intersectionParam1)),u,{ignoreChecks:!0})}function He(i,t,n){const e=new x(t,i),s=G(e.tangentAtFirstPoint),r=Et({firstPoint:e.midPoint,V:s,precision:1e-9},{firstPoint:i,V:G(n),precision:1e-9});if(r==="parallel")throw new Error("Cannot create an arc from three colinear points");const o=B(e.midPoint,L(s,r.intersectionParam1)),h=rt(O(o,i),O(o,B(i,n)))<0;return new I(i,t,o,h,{ignoreChecks:!0})}function Pe(i,t){const n=O(t,i.firstPoint),e=Bt(n,i.V)/i.squareLength;return i.paramPoint(e)}function yt(i,t,n){const e=n||i.precision,s=Pe(i,t.center),r=$(s,t.center);if(r>t.radius+e)return[];if(Math.abs(r-t.radius)<e){const a=s;return i.isOnSegment(a)&&t.isOnSegment(a)?[a]:[]}const o=[],h=Math.sqrt(t.radius*t.radius-r*r),u=i.tangentAtFirstPoint,l=B(s,L(u,h));i.isOnSegment(l)&&t.isOnSegment(l)&&o.push(l);const c=B(s,L(u,-h));return i.isOnSegment(c)&&t.isOnSegment(c)&&o.push(c),o}const tn=i=>{const{firstPoint:t,lastPoint:n,center:e,clockwise:s}=i;return new I(n,t,e,s,{ignoreChecks:!0})},en=(i,t)=>{if(i.isSame(t))return[i];const n=ot([t.isOnSegment(i.firstPoint)?i.firstPoint:null,t.isOnSegment(i.lastPoint)?i.lastPoint:null,i.isOnSegment(t.firstPoint)?t.firstPoint:null,i.isOnSegment(t.lastPoint)?t.lastPoint:null].filter(e=>e!==null)).sort((e,s)=>i.pointToParam(e)-i.pointToParam(s));if(n.length===0)return[];if(n.length===1)return[];if(n.length===2)return i.isSame(tn(t))?[]:[new I(n[0],n[1],i.center,i.clockwise)];if(n.length===3){const e=E(n[0],t.lastPoint)||E(n[0],t.firstPoint)?1:0;return[new I(n[0+e],n[1+e],i.center,i.clockwise)]}else if(n.length===4)return[new I(n[0],n[1],i.center,i.clockwise),new I(n[2],n[3],i.center,i.clockwise)];throw new Error("Bug in the arc arc overlap algorithm")};function Yt(i,t,n=!1,e){const s=e||i.precision,r=$(i.center,t.center),o=i.radius+t.radius;if(r>o+s)return[];const h=Math.abs(i.radius-t.radius);if(r<h-s)return[];if(r<s)return h>s?[]:n?en(i,t):[];const u=X(O(t.center,i.center)),l=r>o-s;if(l||Math.abs(r-h)<s){const f=l||i.radius>t.radius?1:-1,p=B(i.center,L(u,f*i.radius));return i.isOnSegment(p)&&t.isOnSegment(p)?[p]:[]}const c=i.radius*i.radius/(2*r)-t.radius*t.radius/(2*r)+r/2,a=B(i.center,L(u,c)),g=Math.sqrt(i.radius*i.radius-c*c),w=G(u),m=B(a,L(w,g)),d=B(a,L(w,-g)),P=[];return i.isOnSegment(m)&&t.isOnSegment(m)&&P.push(m),i.isOnSegment(d)&&t.isOnSegment(d)&&P.push(d),P}class C extends Ut{constructor(t,n,e,s,r,o,h=!1,{ignoreChecks:u=!1,angleUnits:l="deg"}={}){super(t,n),this.segmentType="ELLIPSE_ARC",this.precision=1e-6,this._coefficients=null,this.center=e;const c=s>=r;this.majorRadius=c?s:r,this.minorRadius=c?r:s;const a=l==="deg"?o*Ct:o;if(this.tiltAngle=it(c?a:a+Math.PI/2),this.clockwise=h,!u){if(E(t,n))throw new Error("Invalid arc, cannot be a full circle");if(!this.isPointOnEllipse(t))throw new Error(`First point ${T(t)} not on the ellipse defined by ${this.info}`);if(!this.isPointOnEllipse(n))throw new Error(`Last point ${T(n)} not on the ellipse defined by ${this.info}`);if(Math.abs(this.majorRadius-this.minorRadius)<this.precision)throw new Error("Both radii should be different, create an arc instead")}}get coefficients(){if(this._coefficients===null){const[t,n]=this.center,e=this.majorRadius*this.majorRadius,s=this.minorRadius*this.minorRadius,r=Math.cos(this.tiltAngle),o=Math.sin(this.tiltAngle),h=e*o*o+s*r*r,u=2*(s-e)*o*r,l=e*r*r+s*o*o;this._coefficients={x2:h,xy:u,y2:l,x:-2*h*t-u*n,y:-2*l*n-u*t,c:h*t*t+u*t*n+l*n*n-e*s}}return this._coefficients}get info(){return`ELLIPSE_ARC(${T(this.firstPoint)}, ${T(this.lastPoint)}, ${T(this.center)}, ${this.majorRadius}, ${this.minorRadius}, ${this.tiltAngle*pe}, ${this.clockwise?"CW":"CCW"})`}reverse(){return new C(this.lastPoint,this.firstPoint,this.center,this.majorRadius,this.minorRadius,this.tiltAngle,!this.clockwise,{ignoreChecks:!0,angleUnits:"rad"})}clone(){return new C(this.firstPoint,this.lastPoint,this.center,this.majorRadius,this.minorRadius,this.tiltAngle,this.clockwise,{ignoreChecks:!0,angleUnits:"rad"})}computeEllipseExtrema(){const t=Math.tan(this.tiltAngle),n=this.minorRadius/this.majorRadius,e=-Math.atan(n*t),s=Math.atan(n/t);return[e,Math.PI+e,s,Math.PI+s].map(o=>this.thetaToParam(o)).filter(o=>this.isValidParameter(o)).map(o=>this.paramPoint(o))}get boundingBox(){if(this._boundingBox===void 0){const t=this.computeEllipseExtrema(),n=[this.firstPoint,this.lastPoint,...t];this._boundingBox=Ge(n)}return this._boundingBox}get linearExentricity(){return this._linearExentricity===void 0&&(this._linearExentricity=Math.sqrt(this.majorRadius*this.majorRadius-this.minorRadius*this.minorRadius)),this._linearExentricity}get exentricity(){return this._exentricity===void 0&&(this._exentricity=this.linearExentricity/this.majorRadius),this._exentricity}get focals(){if(this._focals===void 0){const t=this.majorAxis;this._focals=[B(this.center,L(t,this.linearExentricity)),B(this.center,L(t,-this.linearExentricity))]}return this._focals}get majorAxis(){return ft(1,this.tiltAngle)}paramPoint(t){const n=this.firstAngle+t*this.deltaAngle*(this.clockwise?-1:1);return this.reverseEllipseReferenceFrameTransform.transform([this.majorRadius*Math.cos(n),this.minorRadius*Math.sin(n)])}pointToParam(t){if(!this.isPointOnEllipse(t))throw new Error(`Point ${T(t)} not on the ellipse defined by ${this.repr}`);const n=this.thetaToParam(this.pointTheta(t));if(!this.isValidParameter(n))throw new Error(`Point ${T(t)} is not on segment ${this.repr}`);return n}get midPoint(){return this.paramPoint(.5)}isValidParameter(t){return 1-t>=-this.precision&&t>=-this.precision}isSame(t){return E(this.center,t.center)&&Math.abs(this.majorRadius-t.majorRadius)<this.precision&&Math.abs(this.minorRadius-t.minorRadius)<this.precision&&(Math.abs(this.tiltAngle-t.tiltAngle)<this.precision||Math.abs(Math.abs(this.tiltAngle-t.tiltAngle)-Math.PI)<this.precision)&&(E(this.firstPoint,t.firstPoint)&&this.clockwise===t.clockwise||E(this.firstPoint,t.lastPoint)&&this.clockwise!==t.clockwise)}pointTheta(t){const n=this.ellipseReferenceFrameTransform.transform(t),e=Math.atan2(n[1]/this.minorRadius,n[0]/this.majorRadius);return it(e)}thetaToParam(t){return Rt(this.firstAngle,it(t),this.clockwise)/this.deltaAngle}isPointOnEllipse(t){const[n,e]=this.focals,s=$(t,n),r=$(t,e);return Math.abs(2*this.majorRadius-s-r)<this.precision}isOnSegment(t){return this.isPointOnEllipse(t)?this.isValidParameter(this.thetaToParam(this.pointTheta(t))):!1}distanceFrom(t){let n;if(E(t,this.center)?n=B(this.center,L(G(this.majorAxis),this.minorRadius)):n=this.reverseEllipseReferenceFrameTransform.transform(rn(this.majorRadius,this.minorRadius,this.ellipseReferenceFrameTransform.transform(t))),this.isValidParameter(this.thetaToParam(this.pointTheta(t))))return $(t,n);if(We(t,this.majorAxis,this.center)){const e=it(2*Math.PI-this.pointTheta(t)),s=this.thetaToParam(e);if(this.isValidParameter(s))return $(t,this.paramPoint(s))}return Math.min($(t,this.firstPoint),$(t,this.lastPoint))}get ellipseReferenceFrameTransform(){return this._ellipseReferenceFrameTransform===void 0&&(this._ellipseReferenceFrameTransform=new N().rotate(-this.tiltAngle).translate(-this.center[0],-this.center[1])),this._ellipseReferenceFrameTransform}get reverseEllipseReferenceFrameTransform(){return this._reverseEllipseReferenceFrameTransform===void 0&&(this._reverseEllipseReferenceFrameTransform=new N().translate(this.center[0],this.center[1]).rotate(this.tiltAngle)),this._reverseEllipseReferenceFrameTransform}get rotateFromEllipseReferenceFrame(){return this._rotateFromEllipseReferenceFrame===void 0&&(this._rotateFromEllipseReferenceFrame=new N().rotate(this.tiltAngle)),this._rotateFromEllipseReferenceFrame}get firstAngle(){return this._firstAngle===void 0&&(this._firstAngle=this.pointTheta(this.firstPoint)),this._firstAngle}get lastAngle(){return this._lastAngle===void 0&&(this._lastAngle=this.pointTheta(this.lastPoint)),this._lastAngle}get deltaAngle(){return this._deltaAngle===void 0&&(this._deltaAngle=Rt(this.firstAngle,this.lastAngle,this.clockwise)),this._deltaAngle}normalAt(t){const n=this.tangentAt(t);return this.clockwise?G(n):wt(n)}gradientAt(t){const n=this.firstAngle+t*this.deltaAngle*(this.clockwise?-1:1),e=-this.majorRadius*this.deltaAngle*Math.sin(n),s=this.minorRadius*this.deltaAngle*Math.cos(n),r=this.clockwise?[-e,-s]:[e,s];return this.rotateFromEllipseReferenceFrame.transform(r)}tangentAt(t){const n=this.pointTheta(t),e=-this.majorRadius*Math.sin(n),s=this.minorRadius*Math.cos(n),r=this.clockwise?[-e,-s]:[e,s];return X(this.rotateFromEllipseReferenceFrame.transform(r))}get tangentAtFirstPoint(){const t=-this.majorRadius*Math.sin(this.firstAngle),n=this.minorRadius*Math.cos(this.firstAngle),e=this.clockwise?[-t,-n]:[t,n];return X(this.rotateFromEllipseReferenceFrame.transform(e))}get tangentAtLastPoint(){const t=-this.majorRadius*Math.sin(this.lastAngle),n=this.minorRadius*Math.cos(this.lastAngle),e=this.clockwise?[-t,-n]:[t,n];return X(this.rotateFromEllipseReferenceFrame.transform(e))}transform(t){const n=t.transformAngle(this.tiltAngle),e=t.scaleFactor();return new C(t.transform(this.firstPoint),t.transform(this.lastPoint),t.transform(this.center),this.majorRadius*e,this.minorRadius*e,n,t.keepsOrientation()?this.clockwise:!this.clockwise,{angleUnits:"rad"})}splitAt(t){let n;if(Array.isArray(t)&&t.length===0)return[this];Array.isArray(t[0])?n=t:n=[t];const s=[0,1,...n.map(h=>this.pointToParam(h))],r=new Map(nt([s,[this.firstPoint,this.lastPoint,...n]]));s.sort((h,u)=>h-u);let o=null;return s.flatMap((h,u)=>{if(u===s.length-1)return[];const l=s[u+1];if(l-h<this.precision)return o===null&&(o=h),[];const c=o===null?h:o,a=new C(r.get(c)||this.paramPoint(c),r.get(l)||this.paramPoint(l),this.center,this.majorRadius,this.minorRadius,this.tiltAngle,this.clockwise,{angleUnits:"rad"});return o=null,a})}}function nn(i,t,n,e,s,r,o){const{center:h,rx:u,ry:l}=sn(i,t,n,e,s*Ct,!r,o);return Math.abs(u-l)<1e-9?new I(i,t,h,o):new C(i,t,h,u,l,s,o)}function sn([i,t],[n,e],s,r,o,h,u){if(s<0&&(s=-s),r<0&&(r=-r),s==0||r==0)throw Error("rx and ry can not be 0");const l=Math.sin(o),c=Math.cos(o),a=(i-n)/2,g=(t-e)/2,w=(i+n)/2,m=(t+e)/2,d=c*a+l*g,P=c*g-l*a,f=d*d/(s*s)+P*P/(r*r);f>1&&(s=s*Math.sqrt(f),r=r*Math.sqrt(f));const p=s*r,y=s*P,M=r*d,b=y*y+M*M;if(!b)throw Error("start point can not be same as end point");let R=Math.sqrt(Math.abs((p*p-b)/b));h==u&&(R=-R);const k=R*y/r,S=-R*M/s,F=c*k-l*S+w,_=l*k+c*S+m;return{center:[F,_],rx:s,ry:r}}function rn(i,t,n){const e=Math.abs(n[0]),s=Math.abs(n[1]);let r=.707,o=.707;const h=i,u=t;for(let l=0;l<3;l++){const c=h*r,a=u*o,g=(h*h-u*u)*r**3/h,w=(u*u-h*h)*o**3/u,m=c-g,d=a-w,P=e-g,f=s-w,p=Math.hypot(m,d),y=Math.hypot(P,f);r=Math.min(1,Math.max(0,(P*p/y+g)/h)),o=Math.min(1,Math.max(0,(f*p/y+w)/u));const M=Math.hypot(r,o);r/=M,o/=M}return[h*r*Math.sign(n[0]),u*o*Math.sign(n[1])]}function qt(i,t,n=1e-9){const e=i.transform(t.ellipseReferenceFrameTransform),s=e.slope,r=e.yIntercept,o=t.majorRadius*t.majorRadius,h=t.minorRadius*t.minorRadius,u=t.majorRadius*t.minorRadius,l=e.slope*e.slope,c=e.yIntercept*e.yIntercept,a=f=>f.map(p=>t.reverseEllipseReferenceFrameTransform.transform(p)).filter(p=>i.isOnSegment(p)&&t.isOnSegment(p));if(!Number.isFinite(s)){const f=e.firstPoint[0];if(Math.abs(f)-t.majorRadius>n)return[];if(Math.abs(Math.abs(f)-t.majorRadius)<n)return a([[f,0]]);const p=t.minorRadius*Math.sqrt(1-f*f/o),y=[f,p],M=[f,-p];return a([y,M])}const g=o*l+h-c;if(g<-n)return[];const w=o*l+h;if(Math.abs(g)<n){const f=-(o*s*r)/w,p=h*r/w;return a([[f,p]])}const m=Math.sqrt(g),d=[-(o*s*r+u*m)/w,(h*r-u*s*m)/w],P=[-(o*s*r-u*m)/w,(h*r+u*s*m)/w];return a([d,P])}const on=Object.prototype.toString;function z(i){const t=on.call(i);return t.endsWith("Array]")&&!t.includes("Big")}function hn(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!z(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var n=t.fromIndex,e=n===void 0?0:n,s=t.toIndex,r=s===void 0?i.length:s;if(e<0||e>=i.length||!Number.isInteger(e))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=e||r>i.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var o=i[e],h=e+1;h<r;h++)i[h]>o&&(o=i[h]);return o}function ln(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!z(i))throw new TypeError("input must be an array");if(i.length===0)throw new TypeError("input must not be empty");var n=t.fromIndex,e=n===void 0?0:n,s=t.toIndex,r=s===void 0?i.length:s;if(e<0||e>=i.length||!Number.isInteger(e))throw new Error("fromIndex must be a positive integer smaller than length");if(r<=e||r>i.length||!Number.isInteger(r))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var o=i[e],h=e+1;h<r;h++)i[h]<o&&(o=i[h]);return o}function te(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(z(i)){if(i.length===0)throw new TypeError("input must not be empty")}else throw new TypeError("input must be an array");var n;if(t.output!==void 0){if(!z(t.output))throw new TypeError("output option must be an array if specified");n=t.output}else n=new Array(i.length);var e=ln(i),s=hn(i);if(e===s)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var r=t.min,o=r===void 0?t.autoMinMax?e:0:r,h=t.max,u=h===void 0?t.autoMinMax?s:1:h;if(o>=u)throw new RangeError("min option must be smaller than max option");for(var l=(u-o)/(s-e),c=0;c<i.length;c++)n[c]=(i[c]-e)*l+o;return n}const vt=" ".repeat(2),Me=" ".repeat(4);function un(){return Ee(this)}function Ee(i,t={}){const{maxRows:n=15,maxColumns:e=10,maxNumSize:s=8,padMinus:r="auto"}=t;return`${i.constructor.name} {
|
|
2
|
+
${vt}[
|
|
3
|
+
${Me}${an(i,n,e,s,r)}
|
|
4
|
+
${vt}]
|
|
5
|
+
${vt}rows: ${i.rows}
|
|
6
|
+
${vt}columns: ${i.columns}
|
|
7
|
+
}`}function an(i,t,n,e,s){const{rows:r,columns:o}=i,h=Math.min(r,t),u=Math.min(o,n),l=[];if(s==="auto"){s=!1;t:for(let c=0;c<h;c++)for(let a=0;a<u;a++)if(i.get(c,a)<0){s=!0;break t}}for(let c=0;c<h;c++){let a=[];for(let g=0;g<u;g++)a.push(cn(i.get(c,g),e,s));l.push(`${a.join(" ")}`)}return u!==o&&(l[l.length-1]+=` ... ${o-n} more columns`),h!==r&&l.push(`... ${r-t} more rows`),l.join(`
|
|
8
|
+
${Me}`)}function cn(i,t,n){return(i>=0&&n?` ${ee(i,t-1)}`:ee(i,t)).padEnd(t)}function ee(i,t){let n=i.toString();if(n.length<=t)return n;let e=i.toFixed(t);if(e.length>t&&(e=i.toFixed(Math.max(0,t-(e.length-t)))),e.length<=t&&!e.startsWith("0.000")&&!e.startsWith("-0.000"))return e;let s=i.toExponential(t);return s.length>t&&(s=i.toExponential(Math.max(0,t-(s.length-t)))),s.slice(0)}function fn(i,t){i.prototype.add=function(e){return typeof e=="number"?this.addS(e):this.addM(e)},i.prototype.addS=function(e){for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)+e);return this},i.prototype.addM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)+e.get(s,r));return this},i.add=function(e,s){return new t(e).add(s)},i.prototype.sub=function(e){return typeof e=="number"?this.subS(e):this.subM(e)},i.prototype.subS=function(e){for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)-e);return this},i.prototype.subM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)-e.get(s,r));return this},i.sub=function(e,s){return new t(e).sub(s)},i.prototype.subtract=i.prototype.sub,i.prototype.subtractS=i.prototype.subS,i.prototype.subtractM=i.prototype.subM,i.subtract=i.sub,i.prototype.mul=function(e){return typeof e=="number"?this.mulS(e):this.mulM(e)},i.prototype.mulS=function(e){for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)*e);return this},i.prototype.mulM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)*e.get(s,r));return this},i.mul=function(e,s){return new t(e).mul(s)},i.prototype.multiply=i.prototype.mul,i.prototype.multiplyS=i.prototype.mulS,i.prototype.multiplyM=i.prototype.mulM,i.multiply=i.mul,i.prototype.div=function(e){return typeof e=="number"?this.divS(e):this.divM(e)},i.prototype.divS=function(e){for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)/e);return this},i.prototype.divM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)/e.get(s,r));return this},i.div=function(e,s){return new t(e).div(s)},i.prototype.divide=i.prototype.div,i.prototype.divideS=i.prototype.divS,i.prototype.divideM=i.prototype.divM,i.divide=i.div,i.prototype.mod=function(e){return typeof e=="number"?this.modS(e):this.modM(e)},i.prototype.modS=function(e){for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)%e);return this},i.prototype.modM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)%e.get(s,r));return this},i.mod=function(e,s){return new t(e).mod(s)},i.prototype.modulus=i.prototype.mod,i.prototype.modulusS=i.prototype.modS,i.prototype.modulusM=i.prototype.modM,i.modulus=i.mod,i.prototype.and=function(e){return typeof e=="number"?this.andS(e):this.andM(e)},i.prototype.andS=function(e){for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)&e);return this},i.prototype.andM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)&e.get(s,r));return this},i.and=function(e,s){return new t(e).and(s)},i.prototype.or=function(e){return typeof e=="number"?this.orS(e):this.orM(e)},i.prototype.orS=function(e){for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)|e);return this},i.prototype.orM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)|e.get(s,r));return this},i.or=function(e,s){return new t(e).or(s)},i.prototype.xor=function(e){return typeof e=="number"?this.xorS(e):this.xorM(e)},i.prototype.xorS=function(e){for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)^e);return this},i.prototype.xorM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)^e.get(s,r));return this},i.xor=function(e,s){return new t(e).xor(s)},i.prototype.leftShift=function(e){return typeof e=="number"?this.leftShiftS(e):this.leftShiftM(e)},i.prototype.leftShiftS=function(e){for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)<<e);return this},i.prototype.leftShiftM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)<<e.get(s,r));return this},i.leftShift=function(e,s){return new t(e).leftShift(s)},i.prototype.signPropagatingRightShift=function(e){return typeof e=="number"?this.signPropagatingRightShiftS(e):this.signPropagatingRightShiftM(e)},i.prototype.signPropagatingRightShiftS=function(e){for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)>>e);return this},i.prototype.signPropagatingRightShiftM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)>>e.get(s,r));return this},i.signPropagatingRightShift=function(e,s){return new t(e).signPropagatingRightShift(s)},i.prototype.rightShift=function(e){return typeof e=="number"?this.rightShiftS(e):this.rightShiftM(e)},i.prototype.rightShiftS=function(e){for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)>>>e);return this},i.prototype.rightShiftM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,this.get(s,r)>>>e.get(s,r));return this},i.rightShift=function(e,s){return new t(e).rightShift(s)},i.prototype.zeroFillRightShift=i.prototype.rightShift,i.prototype.zeroFillRightShiftS=i.prototype.rightShiftS,i.prototype.zeroFillRightShiftM=i.prototype.rightShiftM,i.zeroFillRightShift=i.rightShift,i.prototype.not=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,~this.get(e,s));return this},i.not=function(e){return new t(e).not()},i.prototype.abs=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.abs(this.get(e,s)));return this},i.abs=function(e){return new t(e).abs()},i.prototype.acos=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.acos(this.get(e,s)));return this},i.acos=function(e){return new t(e).acos()},i.prototype.acosh=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.acosh(this.get(e,s)));return this},i.acosh=function(e){return new t(e).acosh()},i.prototype.asin=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.asin(this.get(e,s)));return this},i.asin=function(e){return new t(e).asin()},i.prototype.asinh=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.asinh(this.get(e,s)));return this},i.asinh=function(e){return new t(e).asinh()},i.prototype.atan=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.atan(this.get(e,s)));return this},i.atan=function(e){return new t(e).atan()},i.prototype.atanh=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.atanh(this.get(e,s)));return this},i.atanh=function(e){return new t(e).atanh()},i.prototype.cbrt=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.cbrt(this.get(e,s)));return this},i.cbrt=function(e){return new t(e).cbrt()},i.prototype.ceil=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.ceil(this.get(e,s)));return this},i.ceil=function(e){return new t(e).ceil()},i.prototype.clz32=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.clz32(this.get(e,s)));return this},i.clz32=function(e){return new t(e).clz32()},i.prototype.cos=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.cos(this.get(e,s)));return this},i.cos=function(e){return new t(e).cos()},i.prototype.cosh=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.cosh(this.get(e,s)));return this},i.cosh=function(e){return new t(e).cosh()},i.prototype.exp=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.exp(this.get(e,s)));return this},i.exp=function(e){return new t(e).exp()},i.prototype.expm1=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.expm1(this.get(e,s)));return this},i.expm1=function(e){return new t(e).expm1()},i.prototype.floor=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.floor(this.get(e,s)));return this},i.floor=function(e){return new t(e).floor()},i.prototype.fround=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.fround(this.get(e,s)));return this},i.fround=function(e){return new t(e).fround()},i.prototype.log=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.log(this.get(e,s)));return this},i.log=function(e){return new t(e).log()},i.prototype.log1p=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.log1p(this.get(e,s)));return this},i.log1p=function(e){return new t(e).log1p()},i.prototype.log10=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.log10(this.get(e,s)));return this},i.log10=function(e){return new t(e).log10()},i.prototype.log2=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.log2(this.get(e,s)));return this},i.log2=function(e){return new t(e).log2()},i.prototype.round=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.round(this.get(e,s)));return this},i.round=function(e){return new t(e).round()},i.prototype.sign=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.sign(this.get(e,s)));return this},i.sign=function(e){return new t(e).sign()},i.prototype.sin=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.sin(this.get(e,s)));return this},i.sin=function(e){return new t(e).sin()},i.prototype.sinh=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.sinh(this.get(e,s)));return this},i.sinh=function(e){return new t(e).sinh()},i.prototype.sqrt=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.sqrt(this.get(e,s)));return this},i.sqrt=function(e){return new t(e).sqrt()},i.prototype.tan=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.tan(this.get(e,s)));return this},i.tan=function(e){return new t(e).tan()},i.prototype.tanh=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.tanh(this.get(e,s)));return this},i.tanh=function(e){return new t(e).tanh()},i.prototype.trunc=function(){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.set(e,s,Math.trunc(this.get(e,s)));return this},i.trunc=function(e){return new t(e).trunc()},i.pow=function(e,s){return new t(e).pow(s)},i.prototype.pow=function(e){return typeof e=="number"?this.powS(e):this.powM(e)},i.prototype.powS=function(e){for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,Math.pow(this.get(s,r),e));return this},i.prototype.powM=function(e){if(e=t.checkMatrix(e),this.rows!==e.rows||this.columns!==e.columns)throw new RangeError("Matrices dimensions must be equal");for(let s=0;s<this.rows;s++)for(let r=0;r<this.columns;r++)this.set(s,r,Math.pow(this.get(s,r),e.get(s,r)));return this}}function W(i,t,n){let e=n?i.rows:i.rows-1;if(t<0||t>e)throw new RangeError("Row index out of range")}function J(i,t,n){let e=n?i.columns:i.columns-1;if(t<0||t>e)throw new RangeError("Column index out of range")}function at(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.columns)throw new RangeError("vector size must be the same as the number of columns");return t}function ct(i,t){if(t.to1DArray&&(t=t.to1DArray()),t.length!==i.rows)throw new RangeError("vector size must be the same as the number of rows");return t}function gn(i,t){if(!z(t))throw new TypeError("row indices must be an array");for(let n=0;n<t.length;n++)if(t[n]<0||t[n]>=i.rows)throw new RangeError("row indices are out of range")}function mn(i,t){if(!z(t))throw new TypeError("column indices must be an array");for(let n=0;n<t.length;n++)if(t[n]<0||t[n]>=i.columns)throw new RangeError("column indices are out of range")}function ne(i,t,n,e,s){if(arguments.length!==5)throw new RangeError("expected 4 arguments");if(kt("startRow",t),kt("endRow",n),kt("startColumn",e),kt("endColumn",s),t>n||e>s||t<0||t>=i.rows||n<0||n>=i.rows||e<0||e>=i.columns||s<0||s>=i.columns)throw new RangeError("Submatrix indices are out of range")}function $t(i,t=0){let n=[];for(let e=0;e<i;e++)n.push(t);return n}function kt(i,t){if(typeof t!="number")throw new TypeError(`${i} must be a number`)}function ut(i){if(i.isEmpty())throw new Error("Empty matrix has no elements to index")}function pn(i){let t=$t(i.rows);for(let n=0;n<i.rows;++n)for(let e=0;e<i.columns;++e)t[n]+=i.get(n,e);return t}function wn(i){let t=$t(i.columns);for(let n=0;n<i.rows;++n)for(let e=0;e<i.columns;++e)t[e]+=i.get(n,e);return t}function dn(i){let t=0;for(let n=0;n<i.rows;n++)for(let e=0;e<i.columns;e++)t+=i.get(n,e);return t}function yn(i){let t=$t(i.rows,1);for(let n=0;n<i.rows;++n)for(let e=0;e<i.columns;++e)t[n]*=i.get(n,e);return t}function Pn(i){let t=$t(i.columns,1);for(let n=0;n<i.rows;++n)for(let e=0;e<i.columns;++e)t[e]*=i.get(n,e);return t}function Mn(i){let t=1;for(let n=0;n<i.rows;n++)for(let e=0;e<i.columns;e++)t*=i.get(n,e);return t}function En(i,t,n){const e=i.rows,s=i.columns,r=[];for(let o=0;o<e;o++){let h=0,u=0,l=0;for(let c=0;c<s;c++)l=i.get(o,c)-n[o],h+=l,u+=l*l;t?r.push((u-h*h/s)/(s-1)):r.push((u-h*h/s)/s)}return r}function Sn(i,t,n){const e=i.rows,s=i.columns,r=[];for(let o=0;o<s;o++){let h=0,u=0,l=0;for(let c=0;c<e;c++)l=i.get(c,o)-n[o],h+=l,u+=l*l;t?r.push((u-h*h/e)/(e-1)):r.push((u-h*h/e)/e)}return r}function bn(i,t,n){const e=i.rows,s=i.columns,r=e*s;let o=0,h=0,u=0;for(let l=0;l<e;l++)for(let c=0;c<s;c++)u=i.get(l,c)-n,o+=u,h+=u*u;return t?(h-o*o/r)/(r-1):(h-o*o/r)/r}function jn(i,t){for(let n=0;n<i.rows;n++)for(let e=0;e<i.columns;e++)i.set(n,e,i.get(n,e)-t[n])}function vn(i,t){for(let n=0;n<i.rows;n++)for(let e=0;e<i.columns;e++)i.set(n,e,i.get(n,e)-t[e])}function kn(i,t){for(let n=0;n<i.rows;n++)for(let e=0;e<i.columns;e++)i.set(n,e,i.get(n,e)-t)}function In(i){const t=[];for(let n=0;n<i.rows;n++){let e=0;for(let s=0;s<i.columns;s++)e+=Math.pow(i.get(n,s),2)/(i.columns-1);t.push(Math.sqrt(e))}return t}function xn(i,t){for(let n=0;n<i.rows;n++)for(let e=0;e<i.columns;e++)i.set(n,e,i.get(n,e)/t[n])}function Rn(i){const t=[];for(let n=0;n<i.columns;n++){let e=0;for(let s=0;s<i.rows;s++)e+=Math.pow(i.get(s,n),2)/(i.rows-1);t.push(Math.sqrt(e))}return t}function Fn(i,t){for(let n=0;n<i.rows;n++)for(let e=0;e<i.columns;e++)i.set(n,e,i.get(n,e)/t[e])}function _n(i){const t=i.size-1;let n=0;for(let e=0;e<i.columns;e++)for(let s=0;s<i.rows;s++)n+=Math.pow(i.get(s,e),2)/t;return Math.sqrt(n)}function Tn(i,t){for(let n=0;n<i.rows;n++)for(let e=0;e<i.columns;e++)i.set(n,e,i.get(n,e)/t)}class v{static from1DArray(t,n,e){if(t*n!==e.length)throw new RangeError("data length does not match given dimensions");let r=new j(t,n);for(let o=0;o<t;o++)for(let h=0;h<n;h++)r.set(o,h,e[o*n+h]);return r}static rowVector(t){let n=new j(1,t.length);for(let e=0;e<t.length;e++)n.set(0,e,t[e]);return n}static columnVector(t){let n=new j(t.length,1);for(let e=0;e<t.length;e++)n.set(e,0,t[e]);return n}static zeros(t,n){return new j(t,n)}static ones(t,n){return new j(t,n).fill(1)}static rand(t,n,e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{random:s=Math.random}=e;let r=new j(t,n);for(let o=0;o<t;o++)for(let h=0;h<n;h++)r.set(o,h,s());return r}static randInt(t,n,e={}){if(typeof e!="object")throw new TypeError("options must be an object");const{min:s=0,max:r=1e3,random:o=Math.random}=e;if(!Number.isInteger(s))throw new TypeError("min must be an integer");if(!Number.isInteger(r))throw new TypeError("max must be an integer");if(s>=r)throw new RangeError("min must be smaller than max");let h=r-s,u=new j(t,n);for(let l=0;l<t;l++)for(let c=0;c<n;c++){let a=s+Math.round(o()*h);u.set(l,c,a)}return u}static eye(t,n,e){n===void 0&&(n=t),e===void 0&&(e=1);let s=Math.min(t,n),r=this.zeros(t,n);for(let o=0;o<s;o++)r.set(o,o,e);return r}static diag(t,n,e){let s=t.length;n===void 0&&(n=s),e===void 0&&(e=n);let r=Math.min(s,n,e),o=this.zeros(n,e);for(let h=0;h<r;h++)o.set(h,h,t[h]);return o}static min(t,n){t=this.checkMatrix(t),n=this.checkMatrix(n);let e=t.rows,s=t.columns,r=new j(e,s);for(let o=0;o<e;o++)for(let h=0;h<s;h++)r.set(o,h,Math.min(t.get(o,h),n.get(o,h)));return r}static max(t,n){t=this.checkMatrix(t),n=this.checkMatrix(n);let e=t.rows,s=t.columns,r=new this(e,s);for(let o=0;o<e;o++)for(let h=0;h<s;h++)r.set(o,h,Math.max(t.get(o,h),n.get(o,h)));return r}static checkMatrix(t){return v.isMatrix(t)?t:new j(t)}static isMatrix(t){return t!=null&&t.klass==="Matrix"}get size(){return this.rows*this.columns}apply(t){if(typeof t!="function")throw new TypeError("callback must be a function");for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)t.call(this,n,e);return this}to1DArray(){let t=[];for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)t.push(this.get(n,e));return t}to2DArray(){let t=[];for(let n=0;n<this.rows;n++){t.push([]);for(let e=0;e<this.columns;e++)t[n].push(this.get(n,e))}return t}toJSON(){return this.to2DArray()}isRowVector(){return this.rows===1}isColumnVector(){return this.columns===1}isVector(){return this.rows===1||this.columns===1}isSquare(){return this.rows===this.columns}isEmpty(){return this.rows===0||this.columns===0}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let n=0;n<=t;n++)if(this.get(t,n)!==this.get(n,t))return!1;return!0}return!1}isEchelonForm(){let t=0,n=0,e=-1,s=!0,r=!1;for(;t<this.rows&&s;){for(n=0,r=!1;n<this.columns&&r===!1;)this.get(t,n)===0?n++:this.get(t,n)===1&&n>e?(r=!0,e=n):(s=!1,r=!0);t++}return s}isReducedEchelonForm(){let t=0,n=0,e=-1,s=!0,r=!1;for(;t<this.rows&&s;){for(n=0,r=!1;n<this.columns&&r===!1;)this.get(t,n)===0?n++:this.get(t,n)===1&&n>e?(r=!0,e=n):(s=!1,r=!0);for(let o=n+1;o<this.rows;o++)this.get(t,o)!==0&&(s=!1);t++}return s}echelonForm(){let t=this.clone(),n=0,e=0;for(;n<t.rows&&e<t.columns;){let s=n;for(let r=n;r<t.rows;r++)t.get(r,e)>t.get(s,e)&&(s=r);if(t.get(s,e)===0)e++;else{t.swapRows(n,s);let r=t.get(n,e);for(let o=e;o<t.columns;o++)t.set(n,o,t.get(n,o)/r);for(let o=n+1;o<t.rows;o++){let h=t.get(o,e)/t.get(n,e);t.set(o,e,0);for(let u=e+1;u<t.columns;u++)t.set(o,u,t.get(o,u)-t.get(n,u)*h)}n++,e++}}return t}reducedEchelonForm(){let t=this.echelonForm(),n=t.columns,e=t.rows,s=e-1;for(;s>=0;)if(t.maxRow(s)===0)s--;else{let r=0,o=!1;for(;r<e&&o===!1;)t.get(s,r)===1?o=!0:r++;for(let h=0;h<s;h++){let u=t.get(h,r);for(let l=r;l<n;l++){let c=t.get(h,l)-u*t.get(s,l);t.set(h,l,c)}}s--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{rows:n=1,columns:e=1}=t;if(!Number.isInteger(n)||n<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(e)||e<=0)throw new TypeError("columns must be a positive integer");let s=new j(this.rows*n,this.columns*e);for(let r=0;r<n;r++)for(let o=0;o<e;o++)s.setSubMatrix(this,this.rows*r,this.columns*o);return s}fill(t){for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)this.set(n,e,t);return this}neg(){return this.mulS(-1)}getRow(t){W(this,t);let n=[];for(let e=0;e<this.columns;e++)n.push(this.get(t,e));return n}getRowVector(t){return j.rowVector(this.getRow(t))}setRow(t,n){W(this,t),n=at(this,n);for(let e=0;e<this.columns;e++)this.set(t,e,n[e]);return this}swapRows(t,n){W(this,t),W(this,n);for(let e=0;e<this.columns;e++){let s=this.get(t,e);this.set(t,e,this.get(n,e)),this.set(n,e,s)}return this}getColumn(t){J(this,t);let n=[];for(let e=0;e<this.rows;e++)n.push(this.get(e,t));return n}getColumnVector(t){return j.columnVector(this.getColumn(t))}setColumn(t,n){J(this,t),n=ct(this,n);for(let e=0;e<this.rows;e++)this.set(e,t,n[e]);return this}swapColumns(t,n){J(this,t),J(this,n);for(let e=0;e<this.rows;e++){let s=this.get(e,t);this.set(e,t,this.get(e,n)),this.set(e,n,s)}return this}addRowVector(t){t=at(this,t);for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)this.set(n,e,this.get(n,e)+t[e]);return this}subRowVector(t){t=at(this,t);for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)this.set(n,e,this.get(n,e)-t[e]);return this}mulRowVector(t){t=at(this,t);for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)this.set(n,e,this.get(n,e)*t[e]);return this}divRowVector(t){t=at(this,t);for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)this.set(n,e,this.get(n,e)/t[e]);return this}addColumnVector(t){t=ct(this,t);for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)this.set(n,e,this.get(n,e)+t[n]);return this}subColumnVector(t){t=ct(this,t);for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)this.set(n,e,this.get(n,e)-t[n]);return this}mulColumnVector(t){t=ct(this,t);for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)this.set(n,e,this.get(n,e)*t[n]);return this}divColumnVector(t){t=ct(this,t);for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)this.set(n,e,this.get(n,e)/t[n]);return this}mulRow(t,n){W(this,t);for(let e=0;e<this.columns;e++)this.set(t,e,this.get(t,e)*n);return this}mulColumn(t,n){J(this,t);for(let e=0;e<this.rows;e++)this.set(e,t,this.get(e,t)*n);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const n=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>n[e]&&(n[e]=this.get(e,s));return n}case"column":{const n=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>n[s]&&(n[s]=this.get(e,s));return n}case void 0:{let n=this.get(0,0);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>n&&(n=this.get(e,s));return n}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){ut(this);let t=this.get(0,0),n=[0,0];for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)>t&&(t=this.get(e,s),n[0]=e,n[1]=s);return n}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const n=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<n[e]&&(n[e]=this.get(e,s));return n}case"column":{const n=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<n[s]&&(n[s]=this.get(e,s));return n}case void 0:{let n=this.get(0,0);for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<n&&(n=this.get(e,s));return n}default:throw new Error(`invalid option: ${t}`)}}minIndex(){ut(this);let t=this.get(0,0),n=[0,0];for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)this.get(e,s)<t&&(t=this.get(e,s),n[0]=e,n[1]=s);return n}maxRow(t){if(W(this,t),this.isEmpty())return NaN;let n=this.get(t,0);for(let e=1;e<this.columns;e++)this.get(t,e)>n&&(n=this.get(t,e));return n}maxRowIndex(t){W(this,t),ut(this);let n=this.get(t,0),e=[t,0];for(let s=1;s<this.columns;s++)this.get(t,s)>n&&(n=this.get(t,s),e[1]=s);return e}minRow(t){if(W(this,t),this.isEmpty())return NaN;let n=this.get(t,0);for(let e=1;e<this.columns;e++)this.get(t,e)<n&&(n=this.get(t,e));return n}minRowIndex(t){W(this,t),ut(this);let n=this.get(t,0),e=[t,0];for(let s=1;s<this.columns;s++)this.get(t,s)<n&&(n=this.get(t,s),e[1]=s);return e}maxColumn(t){if(J(this,t),this.isEmpty())return NaN;let n=this.get(0,t);for(let e=1;e<this.rows;e++)this.get(e,t)>n&&(n=this.get(e,t));return n}maxColumnIndex(t){J(this,t),ut(this);let n=this.get(0,t),e=[0,t];for(let s=1;s<this.rows;s++)this.get(s,t)>n&&(n=this.get(s,t),e[0]=s);return e}minColumn(t){if(J(this,t),this.isEmpty())return NaN;let n=this.get(0,t);for(let e=1;e<this.rows;e++)this.get(e,t)<n&&(n=this.get(e,t));return n}minColumnIndex(t){J(this,t),ut(this);let n=this.get(0,t),e=[0,t];for(let s=1;s<this.rows;s++)this.get(s,t)<n&&(n=this.get(s,t),e[0]=s);return e}diag(){let t=Math.min(this.rows,this.columns),n=[];for(let e=0;e<t;e++)n.push(this.get(e,e));return n}norm(t="frobenius"){let n=0;if(t==="max")return this.max();if(t==="frobenius"){for(let e=0;e<this.rows;e++)for(let s=0;s<this.columns;s++)n=n+this.get(e,s)*this.get(e,s);return Math.sqrt(n)}else throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)t+=this.get(n,e),this.set(n,e,t);return this}dot(t){v.isMatrix(t)&&(t=t.to1DArray());let n=this.to1DArray();if(n.length!==t.length)throw new RangeError("vectors do not have the same size");let e=0;for(let s=0;s<n.length;s++)e+=n[s]*t[s];return e}mmul(t){t=j.checkMatrix(t);let n=this.rows,e=this.columns,s=t.columns,r=new j(n,s),o=new Float64Array(e);for(let h=0;h<s;h++){for(let u=0;u<e;u++)o[u]=t.get(u,h);for(let u=0;u<n;u++){let l=0;for(let c=0;c<e;c++)l+=this.get(u,c)*o[c];r.set(u,h,l)}}return r}strassen2x2(t){t=j.checkMatrix(t);let n=new j(2,2);const e=this.get(0,0),s=t.get(0,0),r=this.get(0,1),o=t.get(0,1),h=this.get(1,0),u=t.get(1,0),l=this.get(1,1),c=t.get(1,1),a=(e+l)*(s+c),g=(h+l)*s,w=e*(o-c),m=l*(u-s),d=(e+r)*c,P=(h-e)*(s+o),f=(r-l)*(u+c),p=a+m-d+f,y=w+d,M=g+m,b=a-g+w+P;return n.set(0,0,p),n.set(0,1,y),n.set(1,0,M),n.set(1,1,b),n}strassen3x3(t){t=j.checkMatrix(t);let n=new j(3,3);const e=this.get(0,0),s=this.get(0,1),r=this.get(0,2),o=this.get(1,0),h=this.get(1,1),u=this.get(1,2),l=this.get(2,0),c=this.get(2,1),a=this.get(2,2),g=t.get(0,0),w=t.get(0,1),m=t.get(0,2),d=t.get(1,0),P=t.get(1,1),f=t.get(1,2),p=t.get(2,0),y=t.get(2,1),M=t.get(2,2),b=(e+s+r-o-h-c-a)*P,R=(e-o)*(-w+P),k=h*(-g+w+d-P-f-p+M),S=(-e+o+h)*(g-w+P),F=(o+h)*(-g+w),_=e*g,q=(-e+l+c)*(g-m+f),K=(-e+l)*(m-f),Q=(l+c)*(-g+m),Z=(e+s+r-h-u-l-c)*f,A=c*(-g+m+d-P-f-p+y),V=(-r+c+a)*(P+p-y),St=(r-a)*(P-y),H=r*p,ht=(c+a)*(-p+y),D=(-r+h+u)*(f+p-M),Qt=(r-u)*(f-M),Zt=(h+u)*(-p+M),Ce=s*d,$e=u*y,Ae=o*m,Be=l*w,qe=a*M,Oe=_+H+Ce,Ne=b+S+F+_+V+H+ht,Le=_+q+Q+Z+H+D+Zt,Ve=R+k+S+_+H+D+Qt,De=R+S+F+_+$e,ze=H+D+Qt+Zt+Ae,Ue=_+q+K+A+V+St+H,Ye=V+St+H+ht+Be,Xe=_+q+K+Q+qe;return n.set(0,0,Oe),n.set(0,1,Ne),n.set(0,2,Le),n.set(1,0,Ve),n.set(1,1,De),n.set(1,2,ze),n.set(2,0,Ue),n.set(2,1,Ye),n.set(2,2,Xe),n}mmulStrassen(t){t=j.checkMatrix(t);let n=this.clone(),e=n.rows,s=n.columns,r=t.rows,o=t.columns;s!==r&&console.warn(`Multiplying ${e} x ${s} and ${r} x ${o} matrix: dimensions do not match.`);function h(a,g,w){let m=a.rows,d=a.columns;if(m===g&&d===w)return a;{let P=v.zeros(g,w);return P=P.setSubMatrix(a,0,0),P}}let u=Math.max(e,r),l=Math.max(s,o);n=h(n,u,l),t=h(t,u,l);function c(a,g,w,m){if(w<=512||m<=512)return a.mmul(g);w%2===1&&m%2===1?(a=h(a,w+1,m+1),g=h(g,w+1,m+1)):w%2===1?(a=h(a,w+1,m),g=h(g,w+1,m)):m%2===1&&(a=h(a,w,m+1),g=h(g,w,m+1));let d=parseInt(a.rows/2,10),P=parseInt(a.columns/2,10),f=a.subMatrix(0,d-1,0,P-1),p=g.subMatrix(0,d-1,0,P-1),y=a.subMatrix(0,d-1,P,a.columns-1),M=g.subMatrix(0,d-1,P,g.columns-1),b=a.subMatrix(d,a.rows-1,0,P-1),R=g.subMatrix(d,g.rows-1,0,P-1),k=a.subMatrix(d,a.rows-1,P,a.columns-1),S=g.subMatrix(d,g.rows-1,P,g.columns-1),F=c(v.add(f,k),v.add(p,S),d,P),_=c(v.add(b,k),p,d,P),q=c(f,v.sub(M,S),d,P),K=c(k,v.sub(R,p),d,P),Q=c(v.add(f,y),S,d,P),Z=c(v.sub(b,f),v.add(p,M),d,P),A=c(v.sub(y,k),v.add(R,S),d,P),V=v.add(F,K);V.sub(Q),V.add(A);let St=v.add(q,Q),H=v.add(_,K),ht=v.sub(F,_);ht.add(q),ht.add(Z);let D=v.zeros(2*V.rows,2*V.columns);return D=D.setSubMatrix(V,0,0),D=D.setSubMatrix(St,V.rows,0),D=D.setSubMatrix(H,0,V.columns),D=D.setSubMatrix(ht,V.rows,V.columns),D.subMatrix(0,w-1,0,m-1)}return c(n,t,u,l)}scaleRows(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:n=0,max:e=1}=t;if(!Number.isFinite(n))throw new TypeError("min must be a number");if(!Number.isFinite(e))throw new TypeError("max must be a number");if(n>=e)throw new RangeError("min must be smaller than max");let s=new j(this.rows,this.columns);for(let r=0;r<this.rows;r++){const o=this.getRow(r);o.length>0&&te(o,{min:n,max:e,output:o}),s.setRow(r,o)}return s}scaleColumns(t={}){if(typeof t!="object")throw new TypeError("options must be an object");const{min:n=0,max:e=1}=t;if(!Number.isFinite(n))throw new TypeError("min must be a number");if(!Number.isFinite(e))throw new TypeError("max must be a number");if(n>=e)throw new RangeError("min must be smaller than max");let s=new j(this.rows,this.columns);for(let r=0;r<this.columns;r++){const o=this.getColumn(r);o.length&&te(o,{min:n,max:e,output:o}),s.setColumn(r,o)}return s}flipRows(){const t=Math.ceil(this.columns/2);for(let n=0;n<this.rows;n++)for(let e=0;e<t;e++){let s=this.get(n,e),r=this.get(n,this.columns-1-e);this.set(n,e,r),this.set(n,this.columns-1-e,s)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let n=0;n<this.columns;n++)for(let e=0;e<t;e++){let s=this.get(e,n),r=this.get(this.rows-1-e,n);this.set(e,n,r),this.set(this.rows-1-e,n,s)}return this}kroneckerProduct(t){t=j.checkMatrix(t);let n=this.rows,e=this.columns,s=t.rows,r=t.columns,o=new j(n*s,e*r);for(let h=0;h<n;h++)for(let u=0;u<e;u++)for(let l=0;l<s;l++)for(let c=0;c<r;c++)o.set(s*h+l,r*u+c,this.get(h,u)*t.get(l,c));return o}kroneckerSum(t){if(t=j.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let n=this.rows,e=t.rows,s=this.kroneckerProduct(j.eye(e,e)),r=j.eye(n,n).kroneckerProduct(t);return s.add(r)}transpose(){let t=new j(this.columns,this.rows);for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)t.set(e,n,this.get(n,e));return t}sortRows(t=se){for(let n=0;n<this.rows;n++)this.setRow(n,this.getRow(n).sort(t));return this}sortColumns(t=se){for(let n=0;n<this.columns;n++)this.setColumn(n,this.getColumn(n).sort(t));return this}subMatrix(t,n,e,s){ne(this,t,n,e,s);let r=new j(n-t+1,s-e+1);for(let o=t;o<=n;o++)for(let h=e;h<=s;h++)r.set(o-t,h-e,this.get(o,h));return r}subMatrixRow(t,n,e){if(n===void 0&&(n=0),e===void 0&&(e=this.columns-1),n>e||n<0||n>=this.columns||e<0||e>=this.columns)throw new RangeError("Argument out of range");let s=new j(t.length,e-n+1);for(let r=0;r<t.length;r++)for(let o=n;o<=e;o++){if(t[r]<0||t[r]>=this.rows)throw new RangeError(`Row index out of range: ${t[r]}`);s.set(r,o-n,this.get(t[r],o))}return s}subMatrixColumn(t,n,e){if(n===void 0&&(n=0),e===void 0&&(e=this.rows-1),n>e||n<0||n>=this.rows||e<0||e>=this.rows)throw new RangeError("Argument out of range");let s=new j(e-n+1,t.length);for(let r=0;r<t.length;r++)for(let o=n;o<=e;o++){if(t[r]<0||t[r]>=this.columns)throw new RangeError(`Column index out of range: ${t[r]}`);s.set(o-n,r,this.get(o,t[r]))}return s}setSubMatrix(t,n,e){if(t=j.checkMatrix(t),t.isEmpty())return this;let s=n+t.rows-1,r=e+t.columns-1;ne(this,n,s,e,r);for(let o=0;o<t.rows;o++)for(let h=0;h<t.columns;h++)this.set(n+o,e+h,t.get(o,h));return this}selection(t,n){gn(this,t),mn(this,n);let e=new j(t.length,n.length);for(let s=0;s<t.length;s++){let r=t[s];for(let o=0;o<n.length;o++){let h=n[o];e.set(s,o,this.get(r,h))}}return e}trace(){let t=Math.min(this.rows,this.columns),n=0;for(let e=0;e<t;e++)n+=this.get(e,e);return n}clone(){let t=new j(this.rows,this.columns);for(let n=0;n<this.rows;n++)for(let e=0;e<this.columns;e++)t.set(n,e,this.get(n,e));return t}sum(t){switch(t){case"row":return pn(this);case"column":return wn(this);case void 0:return dn(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return yn(this);case"column":return Pn(this);case void 0:return Mn(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const n=this.sum(t);switch(t){case"row":{for(let e=0;e<this.rows;e++)n[e]/=this.columns;return n}case"column":{for(let e=0;e<this.columns;e++)n[e]/=this.rows;return n}case void 0:return n/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,n={}){if(typeof t=="object"&&(n=t,t=void 0),typeof n!="object")throw new TypeError("options must be an object");const{unbiased:e=!0,mean:s=this.mean(t)}=n;if(typeof e!="boolean")throw new TypeError("unbiased must be a boolean");switch(t){case"row":{if(!z(s))throw new TypeError("mean must be an array");return En(this,e,s)}case"column":{if(!z(s))throw new TypeError("mean must be an array");return Sn(this,e,s)}case void 0:{if(typeof s!="number")throw new TypeError("mean must be a number");return bn(this,e,s)}default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,n){typeof t=="object"&&(n=t,t=void 0);const e=this.variance(t,n);if(t===void 0)return Math.sqrt(e);for(let s=0;s<e.length;s++)e[s]=Math.sqrt(e[s]);return e}center(t,n={}){if(typeof t=="object"&&(n=t,t=void 0),typeof n!="object")throw new TypeError("options must be an object");const{center:e=this.mean(t)}=n;switch(t){case"row":{if(!z(e))throw new TypeError("center must be an array");return jn(this,e),this}case"column":{if(!z(e))throw new TypeError("center must be an array");return vn(this,e),this}case void 0:{if(typeof e!="number")throw new TypeError("center must be a number");return kn(this,e),this}default:throw new Error(`invalid option: ${t}`)}}scale(t,n={}){if(typeof t=="object"&&(n=t,t=void 0),typeof n!="object")throw new TypeError("options must be an object");let e=n.scale;switch(t){case"row":{if(e===void 0)e=In(this);else if(!z(e))throw new TypeError("scale must be an array");return xn(this,e),this}case"column":{if(e===void 0)e=Rn(this);else if(!z(e))throw new TypeError("scale must be an array");return Fn(this,e),this}case void 0:{if(e===void 0)e=_n(this);else if(typeof e!="number")throw new TypeError("scale must be a number");return Tn(this,e),this}default:throw new Error(`invalid option: ${t}`)}}toString(t){return Ee(this,t)}}v.prototype.klass="Matrix";typeof Symbol<"u"&&(v.prototype[Symbol.for("nodejs.util.inspect.custom")]=un);function se(i,t){return i-t}function Cn(i){return i.every(t=>typeof t=="number")}v.random=v.rand;v.randomInt=v.randInt;v.diagonal=v.diag;v.prototype.diagonal=v.prototype.diag;v.identity=v.eye;v.prototype.negate=v.prototype.neg;v.prototype.tensorProduct=v.prototype.kroneckerProduct;class j extends v{constructor(t,n){if(super(),j.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0)if(this.data=[],Number.isInteger(n)&&n>=0)for(let e=0;e<t;e++)this.data.push(new Float64Array(n));else throw new TypeError("nColumns must be a positive integer");else if(z(t)){const e=t;if(t=e.length,n=t?e[0].length:0,typeof n!="number")throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let s=0;s<t;s++){if(e[s].length!==n)throw new RangeError("Inconsistent array dimensions");if(!Cn(e[s]))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(e[s]))}}else throw new TypeError("First argument must be a positive number or an array");this.rows=t,this.columns=n}set(t,n,e){return this.data[t][n]=e,this}get(t,n){return this.data[t][n]}removeRow(t){return W(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,n){return n===void 0&&(n=t,t=this.rows),W(this,t,!0),n=Float64Array.from(at(this,n)),this.data.splice(t,0,n),this.rows+=1,this}removeColumn(t){J(this,t);for(let n=0;n<this.rows;n++){const e=new Float64Array(this.columns-1);for(let s=0;s<t;s++)e[s]=this.data[n][s];for(let s=t+1;s<this.columns;s++)e[s-1]=this.data[n][s];this.data[n]=e}return this.columns-=1,this}addColumn(t,n){typeof n>"u"&&(n=t,t=this.columns),J(this,t,!0),n=ct(this,n);for(let e=0;e<this.rows;e++){const s=new Float64Array(this.columns+1);let r=0;for(;r<t;r++)s[r]=this.data[e][r];for(s[r++]=n[e];r<this.columns+1;r++)s[r]=this.data[e][r-1];this.data[e]=s}return this.columns+=1,this}}fn(v,j);class $n extends v{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,n,e){return this.data[t][n]=e,this}get(t,n){return this.data[t][n]}}function ie(i,t){let n=0;return Math.abs(i)>Math.abs(t)?(n=t/i,Math.abs(i)*Math.sqrt(1+n*n)):t!==0?(n=i/t,Math.abs(t)*Math.sqrt(1+n*n)):0}class An{constructor(t,n={}){const{assumeSymmetric:e=!1}=n;if(t=$n.checkMatrix(t),!t.isSquare())throw new Error("Matrix is not a square matrix");if(t.isEmpty())throw new Error("Matrix must be non-empty");let s=t.columns,r=new j(s,s),o=new Float64Array(s),h=new Float64Array(s),u=t,l,c,a=!1;if(e?a=!0:a=t.isSymmetric(),a){for(l=0;l<s;l++)for(c=0;c<s;c++)r.set(l,c,u.get(l,c));Bn(s,h,o,r),qn(s,h,o,r)}else{let g=new j(s,s),w=new Float64Array(s);for(c=0;c<s;c++)for(l=0;l<s;l++)g.set(l,c,u.get(l,c));On(s,g,w,r),Nn(s,h,o,r,g)}this.n=s,this.e=h,this.d=o,this.V=r}get realEigenvalues(){return Array.from(this.d)}get imaginaryEigenvalues(){return Array.from(this.e)}get eigenvectorMatrix(){return this.V}get diagonalMatrix(){let t=this.n,n=this.e,e=this.d,s=new j(t,t),r,o;for(r=0;r<t;r++){for(o=0;o<t;o++)s.set(r,o,0);s.set(r,r,e[r]),n[r]>0?s.set(r,r+1,n[r]):n[r]<0&&s.set(r,r-1,n[r])}return s}}function Bn(i,t,n,e){let s,r,o,h,u,l,c,a;for(u=0;u<i;u++)n[u]=e.get(i-1,u);for(h=i-1;h>0;h--){for(a=0,o=0,l=0;l<h;l++)a=a+Math.abs(n[l]);if(a===0)for(t[h]=n[h-1],u=0;u<h;u++)n[u]=e.get(h-1,u),e.set(h,u,0),e.set(u,h,0);else{for(l=0;l<h;l++)n[l]/=a,o+=n[l]*n[l];for(s=n[h-1],r=Math.sqrt(o),s>0&&(r=-r),t[h]=a*r,o=o-s*r,n[h-1]=s-r,u=0;u<h;u++)t[u]=0;for(u=0;u<h;u++){for(s=n[u],e.set(u,h,s),r=t[u]+e.get(u,u)*s,l=u+1;l<=h-1;l++)r+=e.get(l,u)*n[l],t[l]+=e.get(l,u)*s;t[u]=r}for(s=0,u=0;u<h;u++)t[u]/=o,s+=t[u]*n[u];for(c=s/(o+o),u=0;u<h;u++)t[u]-=c*n[u];for(u=0;u<h;u++){for(s=n[u],r=t[u],l=u;l<=h-1;l++)e.set(l,u,e.get(l,u)-(s*t[l]+r*n[l]));n[u]=e.get(h-1,u),e.set(h,u,0)}}n[h]=o}for(h=0;h<i-1;h++){if(e.set(i-1,h,e.get(h,h)),e.set(h,h,1),o=n[h+1],o!==0){for(l=0;l<=h;l++)n[l]=e.get(l,h+1)/o;for(u=0;u<=h;u++){for(r=0,l=0;l<=h;l++)r+=e.get(l,h+1)*e.get(l,u);for(l=0;l<=h;l++)e.set(l,u,e.get(l,u)-r*n[l])}}for(l=0;l<=h;l++)e.set(l,h+1,0)}for(u=0;u<i;u++)n[u]=e.get(i-1,u),e.set(i-1,u,0);e.set(i-1,i-1,1),t[0]=0}function qn(i,t,n,e){let s,r,o,h,u,l,c,a,g,w,m,d,P,f,p,y;for(o=1;o<i;o++)t[o-1]=t[o];t[i-1]=0;let M=0,b=0,R=Number.EPSILON;for(l=0;l<i;l++){for(b=Math.max(b,Math.abs(n[l])+Math.abs(t[l])),c=l;c<i&&!(Math.abs(t[c])<=R*b);)c++;if(c>l)do{for(s=n[l],a=(n[l+1]-s)/(2*t[l]),g=ie(a,1),a<0&&(g=-g),n[l]=t[l]/(a+g),n[l+1]=t[l]*(a+g),w=n[l+1],r=s-n[l],o=l+2;o<i;o++)n[o]-=r;for(M=M+r,a=n[c],m=1,d=m,P=m,f=t[l+1],p=0,y=0,o=c-1;o>=l;o--)for(P=d,d=m,y=p,s=m*t[o],r=m*a,g=ie(a,t[o]),t[o+1]=p*g,p=t[o]/g,m=a/g,a=m*n[o]-p*s,n[o+1]=r+p*(m*s+p*n[o]),u=0;u<i;u++)r=e.get(u,o+1),e.set(u,o+1,p*e.get(u,o)+m*r),e.set(u,o,m*e.get(u,o)-p*r);a=-p*y*P*f*t[l]/w,t[l]=p*a,n[l]=m*a}while(Math.abs(t[l])>R*b);n[l]=n[l]+M,t[l]=0}for(o=0;o<i-1;o++){for(u=o,a=n[o],h=o+1;h<i;h++)n[h]<a&&(u=h,a=n[h]);if(u!==o)for(n[u]=n[o],n[o]=a,h=0;h<i;h++)a=e.get(h,o),e.set(h,o,e.get(h,u)),e.set(h,u,a)}}function On(i,t,n,e){let s=0,r=i-1,o,h,u,l,c,a,g;for(a=s+1;a<=r-1;a++){for(g=0,l=a;l<=r;l++)g=g+Math.abs(t.get(l,a-1));if(g!==0){for(u=0,l=r;l>=a;l--)n[l]=t.get(l,a-1)/g,u+=n[l]*n[l];for(h=Math.sqrt(u),n[a]>0&&(h=-h),u=u-n[a]*h,n[a]=n[a]-h,c=a;c<i;c++){for(o=0,l=r;l>=a;l--)o+=n[l]*t.get(l,c);for(o=o/u,l=a;l<=r;l++)t.set(l,c,t.get(l,c)-o*n[l])}for(l=0;l<=r;l++){for(o=0,c=r;c>=a;c--)o+=n[c]*t.get(l,c);for(o=o/u,c=a;c<=r;c++)t.set(l,c,t.get(l,c)-o*n[c])}n[a]=g*n[a],t.set(a,a-1,g*h)}}for(l=0;l<i;l++)for(c=0;c<i;c++)e.set(l,c,l===c?1:0);for(a=r-1;a>=s+1;a--)if(t.get(a,a-1)!==0){for(l=a+1;l<=r;l++)n[l]=t.get(l,a-1);for(c=a;c<=r;c++){for(h=0,l=a;l<=r;l++)h+=n[l]*e.get(l,c);for(h=h/n[a]/t.get(a,a-1),l=a;l<=r;l++)e.set(l,c,e.get(l,c)+h*n[l])}}}function Nn(i,t,n,e,s){let r=i-1,o=0,h=i-1,u=Number.EPSILON,l=0,c=0,a=0,g=0,w=0,m=0,d=0,P=0,f,p,y,M,b,R,k,S,F,_,q,K,Q,Z,A;for(f=0;f<i;f++)for((f<o||f>h)&&(n[f]=s.get(f,f),t[f]=0),p=Math.max(f-1,0);p<i;p++)c=c+Math.abs(s.get(f,p));for(;r>=o;){for(M=r;M>o&&(m=Math.abs(s.get(M-1,M-1))+Math.abs(s.get(M,M)),m===0&&(m=c),!(Math.abs(s.get(M,M-1))<u*m));)M--;if(M===r)s.set(r,r,s.get(r,r)+l),n[r]=s.get(r,r),t[r]=0,r--,P=0;else if(M===r-1){if(k=s.get(r,r-1)*s.get(r-1,r),a=(s.get(r-1,r-1)-s.get(r,r))/2,g=a*a+k,d=Math.sqrt(Math.abs(g)),s.set(r,r,s.get(r,r)+l),s.set(r-1,r-1,s.get(r-1,r-1)+l),S=s.get(r,r),g>=0){for(d=a>=0?a+d:a-d,n[r-1]=S+d,n[r]=n[r-1],d!==0&&(n[r]=S-k/d),t[r-1]=0,t[r]=0,S=s.get(r,r-1),m=Math.abs(S)+Math.abs(d),a=S/m,g=d/m,w=Math.sqrt(a*a+g*g),a=a/w,g=g/w,p=r-1;p<i;p++)d=s.get(r-1,p),s.set(r-1,p,g*d+a*s.get(r,p)),s.set(r,p,g*s.get(r,p)-a*d);for(f=0;f<=r;f++)d=s.get(f,r-1),s.set(f,r-1,g*d+a*s.get(f,r)),s.set(f,r,g*s.get(f,r)-a*d);for(f=o;f<=h;f++)d=e.get(f,r-1),e.set(f,r-1,g*d+a*e.get(f,r)),e.set(f,r,g*e.get(f,r)-a*d)}else n[r-1]=S+a,n[r]=S+a,t[r-1]=d,t[r]=-d;r=r-2,P=0}else{if(S=s.get(r,r),F=0,k=0,M<r&&(F=s.get(r-1,r-1),k=s.get(r,r-1)*s.get(r-1,r)),P===10){for(l+=S,f=o;f<=r;f++)s.set(f,f,s.get(f,f)-S);m=Math.abs(s.get(r,r-1))+Math.abs(s.get(r-1,r-2)),S=F=.75*m,k=-.4375*m*m}if(P===30&&(m=(F-S)/2,m=m*m+k,m>0)){for(m=Math.sqrt(m),F<S&&(m=-m),m=S-k/((F-S)/2+m),f=o;f<=r;f++)s.set(f,f,s.get(f,f)-m);l+=m,S=F=k=.964}for(P=P+1,b=r-2;b>=M&&(d=s.get(b,b),w=S-d,m=F-d,a=(w*m-k)/s.get(b+1,b)+s.get(b,b+1),g=s.get(b+1,b+1)-d-w-m,w=s.get(b+2,b+1),m=Math.abs(a)+Math.abs(g)+Math.abs(w),a=a/m,g=g/m,w=w/m,!(b===M||Math.abs(s.get(b,b-1))*(Math.abs(g)+Math.abs(w))<u*(Math.abs(a)*(Math.abs(s.get(b-1,b-1))+Math.abs(d)+Math.abs(s.get(b+1,b+1))))));)b--;for(f=b+2;f<=r;f++)s.set(f,f-2,0),f>b+2&&s.set(f,f-3,0);for(y=b;y<=r-1&&(Z=y!==r-1,y!==b&&(a=s.get(y,y-1),g=s.get(y+1,y-1),w=Z?s.get(y+2,y-1):0,S=Math.abs(a)+Math.abs(g)+Math.abs(w),S!==0&&(a=a/S,g=g/S,w=w/S)),S!==0);y++)if(m=Math.sqrt(a*a+g*g+w*w),a<0&&(m=-m),m!==0){for(y!==b?s.set(y,y-1,-m*S):M!==b&&s.set(y,y-1,-s.get(y,y-1)),a=a+m,S=a/m,F=g/m,d=w/m,g=g/a,w=w/a,p=y;p<i;p++)a=s.get(y,p)+g*s.get(y+1,p),Z&&(a=a+w*s.get(y+2,p),s.set(y+2,p,s.get(y+2,p)-a*d)),s.set(y,p,s.get(y,p)-a*S),s.set(y+1,p,s.get(y+1,p)-a*F);for(f=0;f<=Math.min(r,y+3);f++)a=S*s.get(f,y)+F*s.get(f,y+1),Z&&(a=a+d*s.get(f,y+2),s.set(f,y+2,s.get(f,y+2)-a*w)),s.set(f,y,s.get(f,y)-a),s.set(f,y+1,s.get(f,y+1)-a*g);for(f=o;f<=h;f++)a=S*e.get(f,y)+F*e.get(f,y+1),Z&&(a=a+d*e.get(f,y+2),e.set(f,y+2,e.get(f,y+2)-a*w)),e.set(f,y,e.get(f,y)-a),e.set(f,y+1,e.get(f,y+1)-a*g)}}}if(c!==0){for(r=i-1;r>=0;r--)if(a=n[r],g=t[r],g===0)for(M=r,s.set(r,r,1),f=r-1;f>=0;f--){for(k=s.get(f,f)-a,w=0,p=M;p<=r;p++)w=w+s.get(f,p)*s.get(p,r);if(t[f]<0)d=k,m=w;else if(M=f,t[f]===0?s.set(f,r,k!==0?-w/k:-w/(u*c)):(S=s.get(f,f+1),F=s.get(f+1,f),g=(n[f]-a)*(n[f]-a)+t[f]*t[f],R=(S*m-d*w)/g,s.set(f,r,R),s.set(f+1,r,Math.abs(S)>Math.abs(d)?(-w-k*R)/S:(-m-F*R)/d)),R=Math.abs(s.get(f,r)),u*R*R>1)for(p=f;p<=r;p++)s.set(p,r,s.get(p,r)/R)}else if(g<0)for(M=r-1,Math.abs(s.get(r,r-1))>Math.abs(s.get(r-1,r))?(s.set(r-1,r-1,g/s.get(r,r-1)),s.set(r-1,r,-(s.get(r,r)-a)/s.get(r,r-1))):(A=It(0,-s.get(r-1,r),s.get(r-1,r-1)-a,g),s.set(r-1,r-1,A[0]),s.set(r-1,r,A[1])),s.set(r,r-1,0),s.set(r,r,1),f=r-2;f>=0;f--){for(_=0,q=0,p=M;p<=r;p++)_=_+s.get(f,p)*s.get(p,r-1),q=q+s.get(f,p)*s.get(p,r);if(k=s.get(f,f)-a,t[f]<0)d=k,w=_,m=q;else if(M=f,t[f]===0?(A=It(-_,-q,k,g),s.set(f,r-1,A[0]),s.set(f,r,A[1])):(S=s.get(f,f+1),F=s.get(f+1,f),K=(n[f]-a)*(n[f]-a)+t[f]*t[f]-g*g,Q=(n[f]-a)*2*g,K===0&&Q===0&&(K=u*c*(Math.abs(k)+Math.abs(g)+Math.abs(S)+Math.abs(F)+Math.abs(d))),A=It(S*w-d*_+g*q,S*m-d*q-g*_,K,Q),s.set(f,r-1,A[0]),s.set(f,r,A[1]),Math.abs(S)>Math.abs(d)+Math.abs(g)?(s.set(f+1,r-1,(-_-k*s.get(f,r-1)+g*s.get(f,r))/S),s.set(f+1,r,(-q-k*s.get(f,r)-g*s.get(f,r-1))/S)):(A=It(-w-F*s.get(f,r-1),-m-F*s.get(f,r),d,g),s.set(f+1,r-1,A[0]),s.set(f+1,r,A[1]))),R=Math.max(Math.abs(s.get(f,r-1)),Math.abs(s.get(f,r))),u*R*R>1)for(p=f;p<=r;p++)s.set(p,r-1,s.get(p,r-1)/R),s.set(p,r,s.get(p,r)/R)}for(f=0;f<i;f++)if(f<o||f>h)for(p=f;p<i;p++)e.set(f,p,s.get(f,p));for(p=i-1;p>=o;p--)for(f=o;f<=h;f++){for(d=0,y=o;y<=Math.min(p,h);y++)d=d+e.get(f,y)*s.get(y,p);e.set(f,p,d)}}}function It(i,t,n,e){let s,r;return Math.abs(n)>Math.abs(e)?(s=e/n,r=n+s*e,[(i+s*t)/r,(t-s*i)/r]):(s=n/e,r=e+s*n,[(s*i+t)/r,(s*t-i)/r])}function Se(i,t=1e-9){if(i[i.length-1]==0)return Se(i.slice(0,-1),t);const n=new j([i.slice(0,-1).reverse().map(s=>-s/i[i.length-1]),...Array.from({length:i.length-2},(s,r)=>{const o=new Array(i.length-1).fill(0);return o[r]=1,o})]),e=new An(n);return e.realEigenvalues.filter((s,r)=>Math.abs(e.imaginaryEigenvalues[r])<t)}function be(i,t){const n=Math.max(i.precision,t.precision),e=i.coefficients,s=e.x2,r=e.xy,o=e.y2,h=e.x,u=e.y,l=e.c,c=t.coefficients,a=c.x2,g=c.xy,w=c.y2,m=c.x,d=c.y,P=c.c,f={z0:l*s*m*m+s*s*P*P-h*s*m*P+a*a*l*l-2*s*P*a*l-h*m*a*l+a*h*h*P,z1:d*h*h*a-P*m*s*r-2*s*P*a*u-l*a*g*h+2*m*g*s*l+2*d*P*s*s+m*m*s*u-d*m*s*h-2*s*d*a*l-l*a*m*r+2*l*u*a*a-P*g*s*h-u*a*m*h+2*P*r*a*h,z2:d*d*s*s+2*w*P*s*s-u*a*m*r+P*a*r*r-u*a*g*h-P*g*s*r-2*s*d*a*u+2*m*g*s*u-w*m*s*h-2*s*w*a*l+g*g*s*l+2*d*r*a*h+u*u*a*a-o*a*m*h-d*g*s*h+2*l*o*a*a-l*a*g*r+w*h*h*a+m*m*s*o-d*m*s*r-2*s*P*a*o,z3:-2*s*a*o*d+d*a*r*r+2*w*r*a*h-o*a*g*h+g*g*s*u-d*g*s*r-2*s*w*a*u-u*a*g*r-w*g*s*h+2*d*w*s*s+2*u*o*a*a-o*a*m*r+2*m*g*s*o-w*m*s*r,z4:s*s*w*w-2*s*w*a*o+a*a*o*o-r*s*g*w-r*g*a*o+r*r*a*w+o*s*g*g},y=Se([f.z0,f.z1,f.z2,f.z3,f.z4],n).flatMap(M=>{const b=s*g*M+s*m-a*r*M-a*h;if(b)return[[-(s*P+s*w*M*M-a*o*M*M+s*d*M-a*u*M-a*l)/b,M]];const R=r*M+h,k=-R/(2*s),S=o*M*M+u*M+l,F=R*R/(4*s*s)-S/s;if(Math.abs(F)<n)return[[k,M]];if(F>0){const _=Math.sqrt(F);return[[k+_,M],[k-_,M]]}return[]});return ot(y,n)}function re(i,t){return be(i,t).filter(e=>i.isOnSegment(e)&&t.isOnSegment(e))}const Ln=i=>{const{firstPoint:t,lastPoint:n,center:e,majorRadius:s,minorRadius:r,tiltAngle:o,clockwise:h}=i;return new C(n,t,e,s,r,o,h,{ignoreChecks:!0,angleUnits:"rad"})},Vn=(i,t)=>{if(i.isSame(t))return[i];const n=(s,r)=>new C(s,r,i.center,i.majorRadius,i.minorRadius,i.tiltAngle,i.clockwise,{ignoreChecks:!0,angleUnits:"rad"}),e=ot([t.isOnSegment(i.firstPoint)?i.firstPoint:null,t.isOnSegment(i.lastPoint)?i.lastPoint:null,i.isOnSegment(t.firstPoint)?t.firstPoint:null,i.isOnSegment(t.lastPoint)?t.lastPoint:null].filter(s=>s!==null)).sort((s,r)=>i.pointToParam(s)-i.pointToParam(r));if(e.length===0)return[];if(e.length===1)return[];if(e.length===2)return i.isSame(Ln(t))?[]:[n(e[0],e[1])];if(e.length===3){const s=E(e[0],t.lastPoint)||E(e[0],t.firstPoint)?1:0;return[n(e[0+s],e[1+s])]}else if(e.length===4)return[n(e[0],e[1]),n(e[2],e[3])];throw new Error("Bug in the ellipse arc ellipse arc overlap algorithm")};function Dn(i,t,n=!1){const e=Math.max(i.precision,t.precision);return E(i.center,t.center)&&Math.abs(i.majorRadius-t.majorRadius)<e&&Math.abs(i.minorRadius-t.minorRadius)<e&&(Math.abs(i.tiltAngle-t.tiltAngle)<e||Math.abs(Math.abs(i.tiltAngle-t.tiltAngle)-Math.PI)<e)?n?Vn(i,t):[]:be(i,t).filter(o=>i.isOnSegment(o)&&t.isOnSegment(o))}function zn(i,t,n){if(i instanceof x&&t instanceof x){const e=ye(i,t,!1,n);return e===null?[]:[e]}if(i instanceof x&&t instanceof I)return yt(i,t,n);if(i instanceof I&&t instanceof x)return yt(t,i,n);if(i instanceof I&&t instanceof I)return Yt(i,t,!1,n);throw new Error("Not implemented")}function Pt(i,t,n){if(i instanceof x&&t instanceof x){const e=ye(i,t,!0,n);return e===null?{intersections:[],overlaps:[],count:0}:e instanceof x?{intersections:[],overlaps:[e],count:1}:{intersections:[e],overlaps:[],count:1}}if(!i.boundingBox.overlaps(t.boundingBox))return{intersections:[],overlaps:[],count:0};if(i instanceof x&&t instanceof I){const e=yt(i,t,n);return{intersections:e,overlaps:[],count:e.length}}if(i instanceof I&&t instanceof x){const e=yt(t,i,n);return{intersections:e,overlaps:[],count:e.length}}if(i instanceof I&&t instanceof I){const e=Yt(i,t,!0,n);return e.length?e[0]instanceof I?{intersections:[],overlaps:e,count:e.length}:{intersections:e,overlaps:[],count:e.length}:{intersections:[],overlaps:[],count:0}}if(i instanceof x&&t instanceof C){const e=qt(i,t,n);return{intersections:e,overlaps:[],count:e.length}}if(t instanceof x&&i instanceof C){const e=qt(t,i,n);return{intersections:e,overlaps:[],count:e.length}}if(i instanceof I&&t instanceof C){const e=re(i,t);return{intersections:e,overlaps:[],count:e.length}}if(t instanceof I&&i instanceof C){const e=re(t,i);return{intersections:e,overlaps:[],count:e.length}}if(i instanceof C&&t instanceof C){const e=Dn(i,t,!0);return e.length?e[0]instanceof C?{intersections:[],overlaps:e,count:e.length}:{intersections:e,overlaps:[],count:e.length}:{intersections:[],overlaps:[],count:0}}throw new Error("Not implemented")}function je(i){const t=[];for(let n=0;n<i;n++)for(let e=0;e<=n;e++)t.push([n,e]);return t}function*Ot(i){for(const[t,n]of je(i.length))t!==n&&(yield[i[t],i[n]])}class ve extends Mt{constructor(t,{ignoreChecks:n=!1}={}){super(),this._boundingBox=null,n||ke(t),this.segments=t}get repr(){return this.segments.map(t=>t.repr).join(`
|
|
9
|
+
`)+`
|
|
10
|
+
`}get info(){return this.repr}get firstPoint(){return this.segments[0].firstPoint}get lastPoint(){return this.segments[this.segments.length-1].lastPoint}get segmentsCount(){return this.segments.length}onStroke(t){return this.segments.some(n=>n.isOnSegment(t))}intersects(t){return this.boundingBox.overlaps(t.boundingBox)?this.segments.some(n=>t.segments.some(e=>Pt(n,e).count>0)):!1}overlappingSegments(t){return this.segments.flatMap(n=>t.segments.flatMap(e=>n.boundingBox.overlaps(e.boundingBox)?Pt(n,e).overlaps:[]))}get boundingBox(){if(this._boundingBox===null){let t=this.segments[0].boundingBox;this.segments.slice(1).forEach(n=>{t=t.merge(n.boundingBox)}),this._boundingBox=t}return this._boundingBox}[Symbol.for("nodejs.util.inspect.custom")](){return this.repr}}function Un(i,t="Stroke"){je(i.length).forEach(([n,e])=>{if(n===e)return;const s=i[n],r=i[e],o=Pt(s,r),h=Math.max(s.precision,r.precision);if(o.count!==0){if(o.count===1&&!o.overlaps.length){const u=n-e,l=o.intersections[0];if(u===1&&E(s.firstPoint,l,h)||u===-1&&E(s.lastPoint,l,h)||u===i.length-1&&E(s.lastPoint,l,h)&&E(r.firstPoint,l,h)||-u===i.length-1&&E(s.firstPoint,l,h)&&E(r.lastPoint,l,h))return}if(!(o.count===2&&i.length===2&&(E(s.firstPoint,o.intersections[0],h)&&E(s.lastPoint,o.intersections[1],h)||E(s.firstPoint,o.intersections[1],h)&&E(s.lastPoint,o.intersections[0],h))))throw new Error(`${t} segments must not intersect, but segments ${s.info} and ${r.info} do at ${JSON.stringify(o.intersections)}`)}})}function ke(i,t="Stroke"){if(i.length===0)throw new Error(`${t} must have at least one segment`);nt([i.slice(0,-1),i.slice(1)]).forEach(([n,e])=>{if(!E(n.lastPoint,e.firstPoint))throw new Error(`${t} segments must be connected, but ${n.info} and ${e.info} are not`)}),Un(i,t)}function oe(i,t){return!!(i instanceof x&&t instanceof x&&zt(i.V,t.V)||i instanceof I&&t instanceof I&&E(i.center,t.center)&&i.radius-t.radius<i.precision)}function he(i,t){if(i instanceof x&&t instanceof x)return new x(i.firstPoint,t.lastPoint);if(i instanceof I&&t instanceof I)return new I(i.firstPoint,t.lastPoint,i.center,i.clockwise);throw new Error("Not implemented")}function Ie(i){let t=!1;const n=[];for(const e of i.segments){if(n.length===0){n.push(e);continue}const s=n[n.length-1];oe(s,e)?(t=!0,n.pop(),n.push(he(s,e))):n.push(e)}if(E(i.firstPoint,i.lastPoint)&&oe(n[0],n[n.length-1])){t=!0;const e=n.pop();n[0]=he(e,n[0])}return t?n:null}class Y extends ve{constructor(){super(...arguments),this.strokeType="STRAND"}reverse(){const t=this.segments.map(n=>n.reverse());return t.reverse(),new Y(t,{ignoreChecks:!0})}clone(){return new Y(this.segments.map(t=>t.clone()),{ignoreChecks:!0})}extend(t){if(!E(this.lastPoint,t.firstPoint))throw console.error(this.repr,t.repr),new Error("Cannot extend strand: connection point is not the same");return new Y([...this.segments,...t.segments])}simplify(){const t=Ie(this);return t?new Y(t,{ignoreChecks:!0}):this}transform(t){return new Y(this.segments.map(n=>n.transform(t)),{ignoreChecks:!0})}}const Yn=(i,t)=>{const n=Et(t,{V:[1,0],firstPoint:i,precision:t.precision});if(n==="parallel")return 0;const{intersectionParam1:e,intersectionParam2:s}=n;if(!t.isValidParameter(e)||s<=-t.precision)return 0;if(Math.abs(e)<t.precision||Math.abs(e-1)<t.precision){const[,r]=t.midPoint;return i[1]-r<0?1:0}return 1};class xe{constructor(t){this._count=0,this.segment=t}update(t,n=!1){!n&&!this.segment.isOnSegment(t)||(E(t,this.segment.firstPoint)?this._count+=this.segment.tangentAtFirstPoint[1]>0?1:0:E(t,this.segment.lastPoint)?this._count+=this.segment.tangentAtLastPoint[1]>0?0:1:this._count+=1)}get count(){return this._count}}const Xn=(i,t)=>{const n=t.precision,e=Math.abs(i[1]-t.center[1]);if(e>t.radius+n)return 0;const s=gt(i,t.center),r=t.radius*t.radius,o=n*n;if(Math.abs(s-r)<o&&t.isOnSegment(i))return 0;const h=s-r>o;if(h&&t.center[0]<i[0])return 0;const u=Math.sqrt(t.radius*t.radius-e*e),l=new xe(t);return l.update([t.center[0]+u,i[1]]),h&&l.update([t.center[0]-u,i[1]]),l.count},Gn=(i,t)=>{const n=t.boundingBox.xMax+t.boundingBox.width/2,e=new x(i,[n,i[1]]),s=new xe(t);return qt(e,t).forEach(r=>{s.update(r,!0)}),s.count};function Wn(i,t){if(t instanceof x)return Yn(i,t);if(t instanceof I)return Xn(i,t);if(t instanceof C)return Gn(i,t);throw new Error("Not implemented")}class et extends ve{constructor(t,{ignoreChecks:n=!1}={}){super(t,{ignoreChecks:!0}),this.strokeType="LOOP",this._clockwise=null,n||Jn(t)}get clockwise(){if(this._clockwise===null){const t=this.segments.flatMap(e=>e instanceof x?[e.firstPoint]:[e.firstPoint,e.paramPoint(.5)]),n=t.map((e,s)=>{const r=t[(s+1)%t.length];return(r[0]-e[0])*(r[1]+e[1])}).reduce((e,s)=>e+s,0);this._clockwise=n>0}return this._clockwise}clone(){return new et(this.segments.map(t=>t.clone()),{ignoreChecks:!0})}reverse(){const t=this.segments.map(n=>n.reverse());return t.reverse(),new et(t,{ignoreChecks:!0})}transform(t){return new et(this.segments.map(n=>n.transform(t)),{ignoreChecks:!0})}contains(t){return this.onStroke(t)||!this.boundingBox.contains(t)?!1:this.segments.reduce((e,s)=>e+Wn(t,s),0)%2===1}simplify(){const t=Ie(this);return t?new et(t,{ignoreChecks:!0}):this}}function Jn(i){if(ke(i,"Loop"),!E(i[0].firstPoint,i[i.length-1].lastPoint))throw new Error("Loop segment must be closed")}function Re(i){if(i instanceof x)return{type:i.segmentType,firstPoint:i.firstPoint,lastPoint:i.lastPoint};if(i instanceof I)return{type:i.segmentType,firstPoint:i.firstPoint,lastPoint:i.lastPoint,center:i.center,clockwise:i.clockwise};if(i instanceof C)return{type:i.segmentType,firstPoint:i.firstPoint,lastPoint:i.lastPoint,center:i.center,clockwise:i.clockwise,majorRadius:i.majorRadius,minorRadius:i.minorRadius,tiltAngle:i.tiltAngle};throw new Error("Unknown segment type")}function Nt(i){return{type:"LOOP",segments:i.segments.map(Re)}}function Fe(i){return{type:"FIGURE",contour:Nt(i.contour),holes:i.holes.map(Nt)}}function Kn(i){return{type:"DIAGRAM",figures:i.figures.map(Fe)}}function Lt(i){if(i instanceof tt)return Kn(i);if(i instanceof U)return Fe(i);if(i instanceof et)return Nt(i);if(i instanceof I||i instanceof x)return Re(i);throw new Error("Unknown shape type")}class Qn{constructor(){this.ids=[],this.values=[],this.length=0}clear(){this.length=0}push(t,n){let e=this.length++;for(;e>0;){const s=e-1>>1,r=this.values[s];if(n>=r)break;this.ids[e]=this.ids[s],this.values[e]=r,e=s}this.ids[e]=t,this.values[e]=n}pop(){if(this.length===0)return;const t=this.ids[0];if(this.length--,this.length>0){const n=this.ids[0]=this.ids[this.length],e=this.values[0]=this.values[this.length],s=this.length>>1;let r=0;for(;r<s;){let o=(r<<1)+1;const h=o+1;let u=this.ids[o],l=this.values[o];const c=this.values[h];if(h<this.length&&c<l&&(o=h,u=this.ids[h],l=c),l>=e)break;this.ids[r]=u,this.values[r]=l,r=o}this.ids[r]=n,this.values[r]=e}return t}peek(){if(this.length!==0)return this.ids[0]}peekValue(){if(this.length!==0)return this.values[0]}shrink(){this.ids.length=this.values.length=this.length}}const le=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],At=3;class Xt{static from(t){if(!t||t.byteLength===void 0||t.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");const[n,e]=new Uint8Array(t,0,2);if(n!==251)throw new Error("Data does not appear to be in a Flatbush format.");if(e>>4!==At)throw new Error(`Got v${e>>4} data when expected v${At}.`);const[s]=new Uint16Array(t,2,1),[r]=new Uint32Array(t,4,1);return new Xt(r,s,le[e&15],void 0,t)}constructor(t,n=16,e=Float64Array,s=ArrayBuffer,r){if(t===void 0)throw new Error("Missing required argument: numItems.");if(isNaN(t)||t<=0)throw new Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535);let o=t,h=o;this._levelBounds=[o*4];do o=Math.ceil(o/this.nodeSize),h+=o,this._levelBounds.push(h*4);while(o!==1);this.ArrayType=e||Float64Array,this.IndexArrayType=h<16384?Uint16Array:Uint32Array;const u=le.indexOf(this.ArrayType),l=h*4*this.ArrayType.BYTES_PER_ELEMENT;if(u<0)throw new Error(`Unexpected typed array class: ${e}.`);r&&r.byteLength!==void 0&&!r.buffer?(this.data=r,this._boxes=new this.ArrayType(this.data,8,h*4),this._indices=new this.IndexArrayType(this.data,8+l,h),this._pos=h*4,this.minX=this._boxes[this._pos-4],this.minY=this._boxes[this._pos-3],this.maxX=this._boxes[this._pos-2],this.maxY=this._boxes[this._pos-1]):(this.data=new s(8+l+h*this.IndexArrayType.BYTES_PER_ELEMENT),this._boxes=new this.ArrayType(this.data,8,h*4),this._indices=new this.IndexArrayType(this.data,8+l,h),this._pos=0,this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,new Uint8Array(this.data,0,2).set([251,(At<<4)+u]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t),this._queue=new Qn}add(t,n,e,s){const r=this._pos>>2,o=this._boxes;return this._indices[r]=r,o[this._pos++]=t,o[this._pos++]=n,o[this._pos++]=e,o[this._pos++]=s,t<this.minX&&(this.minX=t),n<this.minY&&(this.minY=n),e>this.maxX&&(this.maxX=e),s>this.maxY&&(this.maxY=s),r}finish(){if(this._pos>>2!==this.numItems)throw new Error(`Added ${this._pos>>2} items when expected ${this.numItems}.`);const t=this._boxes;if(this.numItems<=this.nodeSize){t[this._pos++]=this.minX,t[this._pos++]=this.minY,t[this._pos++]=this.maxX,t[this._pos++]=this.maxY;return}const n=this.maxX-this.minX||1,e=this.maxY-this.minY||1,s=new Uint32Array(this.numItems),r=(1<<16)-1;for(let o=0,h=0;o<this.numItems;o++){const u=t[h++],l=t[h++],c=t[h++],a=t[h++],g=Math.floor(r*((u+c)/2-this.minX)/n),w=Math.floor(r*((l+a)/2-this.minY)/e);s[o]=Hn(g,w)}Vt(s,t,this._indices,0,this.numItems-1,this.nodeSize);for(let o=0,h=0;o<this._levelBounds.length-1;o++){const u=this._levelBounds[o];for(;h<u;){const l=h;let c=t[h++],a=t[h++],g=t[h++],w=t[h++];for(let m=1;m<this.nodeSize&&h<u;m++)c=Math.min(c,t[h++]),a=Math.min(a,t[h++]),g=Math.max(g,t[h++]),w=Math.max(w,t[h++]);this._indices[this._pos>>2]=l,t[this._pos++]=c,t[this._pos++]=a,t[this._pos++]=g,t[this._pos++]=w}}}search(t,n,e,s,r){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let o=this._boxes.length-4;const h=[],u=[];for(;o!==void 0;){const l=Math.min(o+this.nodeSize*4,ae(o,this._levelBounds));for(let c=o;c<l;c+=4){if(e<this._boxes[c]||s<this._boxes[c+1]||t>this._boxes[c+2]||n>this._boxes[c+3])continue;const a=this._indices[c>>2]|0;o>=this.numItems*4?h.push(a):(r===void 0||r(a))&&u.push(a)}o=h.pop()}return u}neighbors(t,n,e=1/0,s=1/0,r){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let o=this._boxes.length-4;const h=this._queue,u=[],l=s*s;for(;o!==void 0;){const c=Math.min(o+this.nodeSize*4,ae(o,this._levelBounds));for(let a=o;a<c;a+=4){const g=this._indices[a>>2]|0,w=ue(t,this._boxes[a],this._boxes[a+2]),m=ue(n,this._boxes[a+1],this._boxes[a+3]),d=w*w+m*m;o>=this.numItems*4?h.push(g<<1,d):(r===void 0||r(g))&&h.push((g<<1)+1,d)}for(;h.length&&h.peek()&1;)if(h.peekValue()>l||(u.push(h.pop()>>1),u.length===e))return h.clear(),u;o=h.pop()>>1}return h.clear(),u}}function ue(i,t,n){return i<t?t-i:i<=n?0:i-n}function ae(i,t){let n=0,e=t.length-1;for(;n<e;){const s=n+e>>1;t[s]>i?e=s:n=s+1}return t[n]}function Vt(i,t,n,e,s,r){if(Math.floor(e/r)>=Math.floor(s/r))return;const o=i[e+s>>1];let h=e-1,u=s+1;for(;;){do h++;while(i[h]<o);do u--;while(i[u]>o);if(h>=u)break;Zn(i,t,n,h,u)}Vt(i,t,n,e,u,r),Vt(i,t,n,u+1,s,r)}function Zn(i,t,n,e,s){const r=i[e];i[e]=i[s],i[s]=r;const o=4*e,h=4*s,u=t[o],l=t[o+1],c=t[o+2],a=t[o+3];t[o]=t[h],t[o+1]=t[h+1],t[o+2]=t[h+2],t[o+3]=t[h+3],t[h]=u,t[h+1]=l,t[h+2]=c,t[h+3]=a;const g=n[e];n[e]=n[s],n[s]=g}function Hn(i,t){let n=i^t,e=65535^n,s=65535^(i|t),r=i&(t^65535),o=n|e>>1,h=n>>1^n,u=s>>1^e&r>>1^s,l=n&s>>1^r>>1^r;n=o,e=h,s=u,r=l,o=n&n>>2^e&e>>2,h=n&e>>2^e&(n^e)>>2,u^=n&s>>2^e&r>>2,l^=e&s>>2^(n^e)&r>>2,n=o,e=h,s=u,r=l,o=n&n>>4^e&e>>4,h=n&e>>4^e&(n^e)>>4,u^=n&s>>4^e&r>>4,l^=e&s>>4^(n^e)&r>>4,n=o,e=h,s=u,r=l,u^=n&s>>8^e&r>>8,l^=e&s>>8^(n^e)&r>>8,n=u^u>>1,e=l^l>>1;let c=i^t,a=e|65535^(c|n);return c=(c|c<<8)&16711935,c=(c|c<<4)&252645135,c=(c|c<<2)&858993459,c=(c|c<<1)&1431655765,a=(a|a<<8)&16711935,a=(a|a<<4)&252645135,a=(a|a<<2)&858993459,a=(a|a<<1)&1431655765,(a<<1|c)>>>0}function Gt(i,t=1e-7){if(i.length===0)return[];if(i.length===1)return[i];const n=new Xt(i.length);i.forEach(r=>{const[o,h]=r.firstPoint;n.add(o-t,h-t,o+t,h+t)}),n.finish();const e=[],s=new Set;return i.forEach((r,o)=>{if(s.has(o))return;const h=[r];let u=o;s.add(o);let l=i.length;for(;;){if(l--<0)throw new Error("Infinite loop detected");const c=h[h.length-1].lastPoint,[a,g]=c,w=n.search(a-t,g-t,a+t,g+t),m=p=>Math.abs((u-p)%i.length),d=w.filter(p=>!s.has(p)).map(p=>[i[p],p,m(p)]).sort(([,,p],[,,y])=>m(p)-m(y));if(d.length===0){e.push(h);break}const[P,f]=d[0];h.push(P),s.add(f),u=f}}),e}class U extends Mt{constructor(t,n=[],{ignoreChecks:e=!1}={}){super(),e||ts(t,n),this.contour=t,this.holes=n}get boundingBox(){return this.contour.boundingBox}get isFull(){return this.holes.length===0}get allLoops(){return[this.contour,...this.holes]}clone(){return new U(this.contour.clone(),this.holes.map(t=>t.clone()))}transform(t){return new U(this.contour.transform(t),this.holes.map(n=>n.transform(t)))}contains(t){return this.contour.contains(t)&&!this.holes.some(n=>n.contains(t))}intersects(t){return this.allLoops.some(n=>t.allLoops.some(e=>n.intersects(e)))}overlappingStrands(t){const n=t instanceof U?t.allLoops:[t],e=this.allLoops.flatMap(s=>n.flatMap(r=>s.overlappingSegments(r)));return Gt(e).map(s=>new Y(s))}}function ts(i,t=[]){if(!i)throw new Error("Figure must have a contour");for(const[n,e]of Ot([i,...t]))if(n.intersects(e))throw new Error("Loops in a figure must not intersect");if(t.some(n=>!i.contains(n.firstPoint)&&!i.onStroke(n.firstPoint)))throw new Error("Holes must be inside the contour");for(const[n,e]of Ot(t))if(n.contains(e.firstPoint))throw console.error(Lt(n),Lt(e)),new Error("Holes must not be inside other holes")}const es=i=>{const t=i.map((s,r)=>i.slice(r+1).map((o,h)=>[h+r+1,o]).filter(([,o])=>s.boundingBox.overlaps(o.boundingBox)).map(([o])=>o)),n=[],e=Array(t.length);return t.forEach((s,r)=>{let o=e[r];o||(o=[],n.push(o)),o.push(i[r]),s.length&&s.forEach(h=>{e[h]=o})}),n},_e=i=>i.map((t,n)=>{const s=t.segments[0].midPoint,r=i.filter((o,h)=>n===h?!1:o.contains(s));return{loop:t,isIn:r}}),ns=(i,t)=>i.flatMap(({loop:n})=>Wt(t.filter(({loop:e,isIn:s})=>e===n||s.indexOf(n)!==-1))),ss=(i,t)=>{const n=t.filter(({isIn:s})=>s.length<=1),e=Wt(_e(i.map(({loop:s})=>s)));return[n,...e]},Wt=i=>{if(!i.length)return[];const t=i.filter(({isIn:e})=>!e.length),n=i.filter(({isIn:e})=>e.length>1);return t.length===1&&n.length===0?[i]:t.length>1?ns(t,i):ss(n,i)};function dt(i){return es(i).map(_e).flatMap(Wt).map(n=>{if(n.length===1)return new U(n[0].loop);n.sort((r,o)=>r.isIn.length-o.isIn.length);const[e,...s]=n.map(({loop:r})=>r);return new U(e,s)})}function is(i,t){const n=[];for(const e of i)for(const s of t)n.push([e,s]);return n}function*Dt(i,t,n){const e=o=>t.some(h=>E(h,o.lastPoint)),s=o=>n.some(h=>o.isSame(h));let r=[];for(const o of i)e(o)?(r.push(o),yield new Y(r,{ignoreChecks:!0}),r=[]):s(o)?(r.length&&(yield new Y(r,{ignoreChecks:!0}),r=[]),yield new Y([o],{ignoreChecks:!0})):r.push(o);r.length&&(yield new Y(r,{ignoreChecks:!0}))}const ce=(i,t)=>{const n=i.findIndex(r=>E(t,r.firstPoint)),e=i.slice(0,n);return i.slice(n).concat(e)},fe=(i,t)=>{let n=i;const e=h=>E(h.firstPoint,t.firstPoint)&&E(h.lastPoint,t.lastPoint);let s=i.findIndex(e);if(s===-1){const h=i.map(u=>u.reverse());if(h.reverse(),s=h.findIndex(e),s===-1)throw console.error(h.map(u=>u.repr),t.repr),new Error("Failed to rotate to segment start");n=h}const r=n.slice(0,s);return n.slice(s).concat(r)};function rs(i,t,n){return i.filter(e=>{const s=t.filter(h=>E(h.firstPoint,e)||E(h.lastPoint,e));if(s.length%2)throw new Error("Bug in the intersection algo on non crossing point");const r=s.map(h=>n.contains(h.midPoint));return!(r.every(h=>h)||!r.some(h=>h))})}function os(i,t,n){let e=[];const s=[],r=new Array(i.segments.length).fill(0).map(()=>[]),o=new Array(t.segments.length).fill(0).map(()=>[]);if(i.segments.forEach((g,w)=>{t.segments.forEach((m,d)=>{const{intersections:P,overlaps:f}=Pt(g,m,n);e.push(...P),r[w].push(...P),o[d].push(...P),s.push(...f);const p=f.flatMap(y=>[y.firstPoint,y.lastPoint]);e.push(...p),r[w].push(...p),o[d].push(...p)})}),e=ot(e,n),!e.length||e.length===1)return null;const h=([g,w])=>w.length?g.splitAt(w):[g];let u=nt([i.segments,r]).flatMap(h),l=nt([t.segments,o]).flatMap(h);if(e=rs(e,u,t),!e.length&&!s.length)return null;if(s.length){const g=s[0];u=fe(u,g),l=fe(l,g)}else{const g=e[0];u=ce(u,g),l=ce(l,g)}let c=Array.from(Dt(u,e,s)),a=Array.from(Dt(l,e,s));return(!E(a[0].lastPoint,c[0].lastPoint)||s.length>0&&a[0].segmentsCount!==1)&&(a=a.map(g=>g.reverse()).reverse(),E(a[0].lastPoint,c[0].lastPoint)||(c=c.map(g=>g.reverse()).reverse())),nt([c,a]).map(([g,w])=>g.segmentsCount===1&&s.some(m=>g.segments[0].isSame(m))?[g,"same"]:[g,w])}function ge(i){let t=i[0];for(const n of i.slice(1))t=t.extend(n);if(!E(t.firstPoint,t.lastPoint))throw console.error(T(t.firstPoint),T(t.lastPoint)),new Error("Bug in the intersection algo on non closing strand");return new et(t.segments)}function hs(i,t){const n=nt([t.slice(0,-1),t.slice(1)]).map(([s,r])=>ge(i.slice(s,r)));let e=i.slice(t[t.length-1]);return t[0]!==0&&(e=e.concat(i.slice(0,t[0]))),n.push(ge(e)),n}function ls(i){if(!i.length)return[];const t=i.map(s=>s.firstPoint);let n=i.map(s=>s.lastPoint);n=n.slice(-1).concat(n.slice(0,-1));const e=nt([t,n]).flatMap(([s,r],o)=>E(s,r)?[]:o);try{return hs(i,e)}catch{return Gt(i.flatMap(r=>r.segments)).filter(r=>r.length>1).filter(r=>E(r[0].firstPoint,r.at(-1).lastPoint)).map(r=>new et(r))}}const me=(i,t)=>{if(i.length===0)return[t];const n=i.at(-1);return E(n.lastPoint,t.firstPoint)?i.slice(0,-1).concat([n.extend(t)]):E(n.lastPoint,t.lastPoint)?i.slice(0,-1).concat([n.extend(t.reverse())]):i.concat([t])},us=(i,t)=>i.length===0?[t]:E(i[0].firstPoint,t.lastPoint)?[t.extend(i[0])].concat(i.slice(1)):[t].concat(i);function Jt(i,t,{firstInside:n,secondInside:e}){const s=os(i,t);if(!s){const u=i.segments[0].midPoint,l=t.contains(u),c=t.segments[0].midPoint,a=i.contains(c);return{identical:!1,firstCurveInSecond:l,secondCurveInFirst:a}}if(s.every(([,u])=>u==="same"))return{identical:!0};let r=null,o=null;const h=s.flatMap(([u,l])=>{let c=[],a=0;if(l==="same")return o===1?(o=1,u):o===2||o===0?(o=null,[]):o===null?(r?r=r.extend(u):r=u,[]):(console.error("weird situation"),[]);const g=u.segments[0].midPoint,w=t.contains(g);(n==="keep"&&w||n==="remove"&&!w)&&(a+=1,c=me(c,u));const m=l.segments[0].midPoint,d=i.contains(m);if(e==="keep"&&d||e==="remove"&&!d){const P=l;a+=1,a===2&&c.length?(c=me(c,P),r=null):c=[P]}return o===null&&a===1&&r&&(c=us(c,r)),a===1&&(o=a,r=null),c.length?c:(r=null,[])});return ls(h)}const as=(i,t)=>{const n=Jt(i,t,{firstInside:"remove",secondInside:"remove"});return Array.isArray(n)?n:n.identical?[i]:n.firstCurveInSecond?[t]:n.secondCurveInFirst?[i]:[i,t]},Ft=(i,t)=>{const n=Jt(i,t,{firstInside:"remove",secondInside:"keep"});return Array.isArray(n)?n:n.identical?[]:n.firstCurveInSecond?[]:n.secondCurveInFirst?[i,t]:[i]},Kt=(i,t)=>{const n=Jt(i,t,{firstInside:"keep",secondInside:"keep"});return Array.isArray(n)?n:n.identical?[i]:n.firstCurveInSecond?[i]:n.secondCurveInFirst?[t]:[]};function cs(i){const t=new Map,n=[];return i.forEach((e,s)=>{let r;t.has(s)?r=t.get(s):(r={current:[e],fusedWith:new Set([s])},n.push(r)),i.slice(s+1).forEach((o,h)=>{const u=r.current,l=s+h+1;if(r.fusedWith.has(l))return;let c=[o],a=!1;if(t.has(l)&&(c=t.get(l).current,a=!0),!u.some(m=>c.some(d=>m.intersects(d))))return;let w;u.length>1||c.length>1?w=mt(u,c):w=Te(u[0],c[0]),r.fusedWith.add(l),r.current=w,a||t.set(l,r)})}),n.flatMap(({current:e})=>e)}function Te(i,t){const n=as(i.contour,t.contour),e=t.holes.flatMap(o=>Ft(o,i.contour)),s=i.holes.flatMap(o=>Ft(o,t.contour)),r=is(i.holes,t.holes).flatMap(([o,h])=>Kt(o,h));return dt([...n,...e,...s,...r])}function _t(i,t){if(i.isFull&&t.isFull)return dt(Ft(i.contour,t.contour));if(i.isFull){const e=Ft(i.contour,t.contour),s=t.holes.flatMap(r=>Kt(r,i.contour));return dt([...e,...s])}else if(t.isFull&&!i.contour.intersects(t.contour))if(i.contour.contains(t.contour.firstPoint)){const e=mt(i.holes.map(s=>new U(s)),[t]);return dt([i.contour,...e.flatMap(s=>s.allLoops)])}else return[i];let n=_t(new U(i.contour),t);return i.holes.forEach(e=>{n=n.flatMap(s=>_t(s,new U(e)))}),n}function fs(i,t){const n=Kt(i.contour,t.contour);if(!n.length)return[];let e=dt(n);return e=pt(e,i.holes.map(s=>new U(s))),pt(e,t.holes.map(s=>new U(s)))}function mt(i,t){if(!i.length)return t;if(!t.length)return i;if(i.length===1&&t.length>1||t.length===1&&i.length>1)return cs([...i,...t]);if(i.length>1&&t.length>1){let n=mt([i[0]],t);return i.slice(1).forEach(e=>{n=mt([e],n)}),n}return i.length===1&&t.length===1?Te(i[0],t[0]):[]}function pt(i,t){if(!i.length)return[];if(!t.length)return i;if(i.length===1&&t.length===1)return _t(i[0],t[0]);if(i.length>1)return i.flatMap(e=>pt([e],t));let n=_t(i[0],t[0]);return t.slice(1).forEach(e=>{n=pt(n,[e])}),n}function Tt(i,t){return!i.length||!t.length?[]:i.length===1&&t.length===1?fs(i[0],t[0]):i.length>1?i.flatMap(n=>Tt([n],t)):t.flatMap(n=>Tt(i,[n]))}class tt extends Mt{constructor(t=[],{ignoreChecks:n=!1}={}){super(),this._boundingBox=null,n||gs(t),this.figures=t}get isEmpty(){return this.figures.length===0}get boundingBox(){if(this.isEmpty)return new st;if(this._boundingBox===null){let t=this.figures[0].boundingBox;for(const n of this.figures.slice(1))t=t.merge(n.boundingBox);this._boundingBox=t}return this._boundingBox}clone(){return new tt(this.figures.map(t=>t.clone()))}transform(t){return new tt(this.figures.map(n=>n.transform(t)))}contains(t){return this.figures.some(n=>n.contains(t))}intersects(t){return this.figures.some(n=>t.figures.some(e=>n.intersects(e)))}overlappingStrands(t){return this.figures.flatMap(n=>t instanceof tt?t.figures.flatMap(e=>n.overlappingStrands(e)):n.overlappingStrands(t))}fuse(t){return new tt(mt(this.figures,t.figures))}cut(t){return new tt(pt(this.figures,t.figures))}intersect(t){return new tt(Tt(this.figures,t.figures))}}function gs(i){for(const[t,n]of Ot(i))if(t.intersects(n))throw new Error("Diagram figures must not intersect")}exports.Arc=I;exports.BoundingBox=st;exports.DEG2RAD=Ct;exports.Diagram=tt;exports.EllipseArc=C;exports.Figure=U;exports.Line=x;exports.Loop=et;exports.RAD2DEG=pe;exports.Strand=Y;exports.Transformable=Mt;exports.TransformationMatrix=N;exports.add=B;exports.arcArcIntersection=Yt;exports.cartesianToPolar=de;exports.crossProduct=rt;exports.cutFiguresLists=pt;exports.distance=$;exports.exportJSON=Lt;exports.findIntersections=zn;exports.findIntersectionsAndOverlaps=Pt;exports.fuseFiguresLists=mt;exports.intersectFiguresLists=Tt;exports.lineArcIntersection=yt;exports.lineLineParams=Et;exports.normalize=X;exports.perpendicular=G;exports.perpendicularClockwise=wt;exports.polarAngle=we;exports.polarToCartesian=ft;exports.projectPointOnLine=Pe;exports.removeDuplicatePoints=ot;exports.sameVector=E;exports.scalarMultiply=L;exports.squareDistance=gt;exports.stitchSegments=Gt;exports.strandsBetweenIntersections=Dt;exports.subtract=O;exports.svgEllipse=nn;exports.tangentArc=He;exports.threePointsArc=Ze;exports.zip=nt;
|
|
11
|
+
//# sourceMappingURL=Diagram-ab93c8b7.cjs.map
|