@mlightcad/geometry-engine 3.3.4 → 3.4.1

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.
Files changed (35) hide show
  1. package/README.md +3 -0
  2. package/dist/geometry-engine.umd.cjs +1 -1
  3. package/lib/geometry/AcGeArea2d.d.ts +0 -4
  4. package/lib/geometry/AcGeArea2d.d.ts.map +1 -1
  5. package/lib/geometry/AcGeArea2d.js +2 -16
  6. package/lib/geometry/AcGeArea2d.js.map +1 -1
  7. package/lib/geometry/AcGeCircArc3d.d.ts +1 -1
  8. package/lib/geometry/AcGeCircArc3d.d.ts.map +1 -1
  9. package/lib/geometry/AcGeCircArc3d.js +4 -4
  10. package/lib/geometry/AcGeCircArc3d.js.map +1 -1
  11. package/lib/geometry/AcGeEllipseArc3d.d.ts +1 -3
  12. package/lib/geometry/AcGeEllipseArc3d.d.ts.map +1 -1
  13. package/lib/geometry/AcGeEllipseArc3d.js +4 -15
  14. package/lib/geometry/AcGeEllipseArc3d.js.map +1 -1
  15. package/lib/geometry/AcGePolyline2d.d.ts +4 -0
  16. package/lib/geometry/AcGePolyline2d.d.ts.map +1 -1
  17. package/lib/geometry/AcGePolyline2d.js +14 -0
  18. package/lib/geometry/AcGePolyline2d.js.map +1 -1
  19. package/lib/geometry/AcGeSpline3d.d.ts +4 -0
  20. package/lib/geometry/AcGeSpline3d.d.ts.map +1 -1
  21. package/lib/geometry/AcGeSpline3d.js +14 -0
  22. package/lib/geometry/AcGeSpline3d.js.map +1 -1
  23. package/lib/index.d.ts +1 -1
  24. package/lib/index.d.ts.map +1 -1
  25. package/lib/index.js +1 -1
  26. package/lib/index.js.map +1 -1
  27. package/lib/util/AcGePolygonAreaUtil.d.ts +25 -0
  28. package/lib/util/AcGePolygonAreaUtil.d.ts.map +1 -0
  29. package/lib/util/AcGePolygonAreaUtil.js +66 -0
  30. package/lib/util/AcGePolygonAreaUtil.js.map +1 -0
  31. package/lib/util/index.d.ts +1 -0
  32. package/lib/util/index.d.ts.map +1 -1
  33. package/lib/util/index.js +1 -0
  34. package/lib/util/index.js.map +1 -1
  35. package/package.json +2 -2
package/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # @mlightcad/geometry-engine
2
2
 
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![npm version](https://img.shields.io/npm/v/@mlightcad/geometry-engine.svg)](https://www.npmjs.com/package/@mlightcad/geometry-engine)
5
+
3
6
  The geometry-engine package provides comprehensive geometric entities, mathematical operations, and transformations for 2D and 3D space. This package mimics AutoCAD ObjectARX's AcGe (Geometry) classes and provides the mathematical foundation for CAD operations.
4
7
 
5
8
  ## Overview
@@ -1 +1 @@
1
- (function(A,V){typeof exports=="object"&&typeof module<"u"?V(exports,require("@mlightcad/common")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/common"],V):(A=typeof globalThis<"u"?globalThis:A||self,V(A["geometry-engine"]={},A.common))})(this,function(A,V){"use strict";const L=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let sn=1234567;const jt=Math.PI/180,qt=180/Math.PI;function rn(){const h=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,e=Math.random()*4294967295|0;return(L[h&255]+L[h>>8&255]+L[h>>16&255]+L[h>>24&255]+"-"+L[t&255]+L[t>>8&255]+"-"+L[t>>16&15|64]+L[t>>24&255]+"-"+L[n&63|128]+L[n>>8&255]+"-"+L[n>>16&255]+L[n>>24&255]+L[e&255]+L[e>>8&255]+L[e>>16&255]+L[e>>24&255]).toLowerCase()}function Q(h,t,n){return Math.max(t,Math.min(n,h))}function Vt(h,t){return(h%t+t)%t}function on(h,t,n,e,s){return e+(h-t)*(s-e)/(n-t)}function hn(h,t,n){return h!==t?(n-h)/(t-h):0}function Lt(h,t,n){return(1-n)*h+n*t}function an(h,t,n,e){return Lt(h,t,1-Math.exp(-n*e))}function cn(h,t=1){return t-Math.abs(Vt(h,t*2)-t)}function ln(h,t,n){return h<=t?0:h>=n?1:(h=(h-t)/(n-t),h*h*(3-2*h))}function un(h,t,n){return h<=t?0:h>=n?1:(h=(h-t)/(n-t),h*h*h*(h*(h*6-15)+10))}function dn(h,t){return h+Math.floor(Math.random()*(t-h+1))}function mn(h,t){return h+Math.random()*(t-h)}function gn(h){return h*(.5-Math.random())}function yn(h){h!==void 0&&(sn=h);let t=sn+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function xn(h){return h*jt}function _n(h){return h*qt}function fn(h){return(h&h-1)===0&&h!==0}function An(h){return Math.pow(2,Math.ceil(Math.log(h)/Math.LN2))}function Pn(h){return Math.pow(2,Math.floor(Math.log(h)/Math.LN2))}function ut(h){const t=Math.PI*2;return(h%t+t)%t}function pn(h,t,n){return h>t&&h<n||h>n&&h<t}function wn(h,t,n,e=!1){return h=ut(h),t=ut(t),n=ut(n),e?t>n?h<=t&&h>=n:h<=t||h>=n:t<n?h>=t&&h<=n:h>=t||h<=n}function vt(h){return h=Math.abs(h),h<1?0:Math.ceil(Math.log10(Math.abs(h)+1))}function Mn(h,t=1e-7){const n=vt(h);return Math.max(Math.pow(10,n)*t,t)}const w={DEG2RAD:jt,RAD2DEG:qt,generateUUID:rn,clamp:Q,euclideanModulo:Vt,mapLinear:on,inverseLerp:hn,lerp:Lt,damp:an,pingpong:cn,smoothstep:ln,smootherstep:un,randInt:dn,randFloat:mn,randFloatSpread:gn,seededRandom:yn,degToRad:xn,radToDeg:_n,isPowerOfTwo:fn,ceilPowerOfTwo:An,floorPowerOfTwo:Pn,normalizeAngle:ut,isBetween:pn,isBetweenAngle:wn,intPartLength:vt,relativeEps:Mn},_t=class _t{constructor(t,n){this.x=0,this.y=0;const e=+(t!==void 0)+ +(n!==void 0);if(e!==0){if(e===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(e===1){const{x:s,y:i}=t;this.x=s,this.y=i;return}if(e===2){this.x=t,this.y=n;return}throw V.AcCmErrors.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,n){return this.x=t,this.y=n,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new _t(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const n=this.x,e=this.y,s=t.elements;return this.x=s[0]*n+s[3]*e+s[6],this.y=s[1]*n+s[4]*e+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this}clampScalar(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this}clampLength(t,n){const e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(n,e)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const n=Math.sqrt(this.lengthSq()*t.lengthSq());if(n===0)return Math.PI/2;const e=this.dot(t)/n;return Math.acos(Math.max(-1,Math.min(1,e)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const n=this.x-t.x,e=this.y-t.y;return n*n+e*e}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this}lerpVectors(t,n,e){return this.x=t.x+(n.x-t.x)*e,this.y=t.y+(n.y-t.y)*e,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t}rotateAround(t,n){const e=Math.cos(n),s=Math.sin(n),i=this.x-t.x,r=this.y-t.y;return this.x=i*e-r*s+t.x,this.y=i*s+r*e+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(w.relativeEps(this.x,t),w.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};_t.EMPTY=Object.freeze(new _t(0,0));let R=_t;const ft=class ft{constructor(t,n,e,s,i,r,o,a,c){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&n!=null&&e!=null&&s!=null&&i!=null&&r!=null&&o!=null&&a!=null&&c!=null&&this.set(t,n,e,s,i,r,o,a,c)}set(t,n,e,s,i,r,o,a,c){const l=this.elements;return l[0]=t,l[1]=s,l[2]=o,l[3]=n,l[4]=i,l[5]=a,l[6]=e,l[7]=r,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const n=this.elements,e=t.elements;return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],this}extractBasis(t,n,e){return t.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),e.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const n=t.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const e=t.elements,s=n.elements,i=this.elements,r=e[0],o=e[3],a=e[6],c=e[1],l=e[4],u=e[7],d=e[2],m=e[5],g=e[8],y=s[0],x=s[3],_=s[6],b=s[1],p=s[4],C=s[7],S=s[2],T=s[5],z=s[8];return i[0]=r*y+o*b+a*S,i[3]=r*x+o*p+a*T,i[6]=r*_+o*C+a*z,i[1]=c*y+l*b+u*S,i[4]=c*x+l*p+u*T,i[7]=c*_+l*C+u*z,i[2]=d*y+m*b+g*S,i[5]=d*x+m*p+g*T,i[8]=d*_+m*C+g*z,this}multiplyScalar(t){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=t,n[4]*=t,n[7]*=t,n[2]*=t,n[5]*=t,n[8]*=t,this}determinant(){const t=this.elements,n=t[0],e=t[1],s=t[2],i=t[3],r=t[4],o=t[5],a=t[6],c=t[7],l=t[8];return n*r*l-n*o*c-e*i*l+e*o*a+s*i*c-s*r*a}invert(){const t=this.elements,n=t[0],e=t[1],s=t[2],i=t[3],r=t[4],o=t[5],a=t[6],c=t[7],l=t[8],u=l*r-o*c,d=o*a-l*i,m=c*i-r*a,g=n*u+e*d+s*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/g;return t[0]=u*y,t[1]=(s*c-l*e)*y,t[2]=(o*e-s*r)*y,t[3]=d*y,t[4]=(l*n-s*a)*y,t[5]=(s*i-o*n)*y,t[6]=m*y,t[7]=(e*a-c*n)*y,t[8]=(r*n-e*i)*y,this}transpose(){let t;const n=this.elements;return t=n[1],n[1]=n[3],n[3]=t,t=n[2],n[2]=n[6],n[6]=t,t=n[5],n[5]=n[7],n[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const n=this.elements;return t.elements[0]=n[0],t.elements[1]=n[3],t.elements[2]=n[6],t.elements[3]=n[1],t.elements[4]=n[4],t.elements[5]=n[7],t.elements[6]=n[2],t.elements[7]=n[5],t.elements[8]=n[8],this}setUvTransform(t,n,e,s,i,r,o){const a=Math.cos(i),c=Math.sin(i);return this.set(e*a,e*c,-e*(a*r+c*o)+r+t,-s*c,s*a,-s*(-c*r+a*o)+o+n,0,0,1),this}scale(t,n){return this.premultiply(Ut.makeScale(t,n)),this}rotate(t){return this.premultiply(Ut.makeRotation(-t)),this}translate(t,n){return this.premultiply(Ut.makeTranslation(t,n)),this}makeTranslation(t,n){return t instanceof R?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,n,0,0,1),this}makeRotation(t){const n=Math.cos(t),e=Math.sin(t);return this.set(n,-e,0,e,n,0,0,0,1),this}makeScale(t,n){return this.set(t,0,0,0,n,0,0,0,1),this}equals(t){const n=this.elements,e=t.elements;for(let s=0;s<9;s++)if(n[s]!==e[s])return!1;return!0}fromArray(t,n=0){for(let e=0;e<9;e++)this.elements[e]=t[e+n];return this}toArray(t=[],n=0){const e=this.elements;return t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3],t[n+4]=e[4],t[n+5]=e[5],t[n+6]=e[6],t[n+7]=e[7],t[n+8]=e[8],t}clone(){return new ft().fromArray(this.elements)}};ft.IDENTITY=Object.freeze(new ft);let rt=ft;const Ut=new rt,K=1e-6,I=2*Math.PI,Hn={x:0,y:0},Ft={x:0,y:0,z:0};class B{constructor(){this.equalPointTol=K,this.equalVectorTol=K}clone(){const t=new B;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t}equalPoint2d(t,n){return new R(t).sub(n).length()<this.equalPointTol}equalPoint3d(t,n){return new f(t).sub(n).length()<this.equalPointTol}static equalToZero(t,n=K){return t<n&&t>-n}static equal(t,n,e=K){return Math.abs(t-n)<e}static great(t,n,e=K){return t-n>e}static less(t,n,e=K){return t-n<e}static isPositive(t,n=K){return t>n}static isNonPositive(t,n=K){return t<=n}}const pt=new B;class dt{constructor(t=0,n=0,e=0,s=1){this._x=t,this._y=n,this._z=e,this._w=s}static slerpFlat(t,n,e,s,i,r,o){let a=e[s+0],c=e[s+1],l=e[s+2],u=e[s+3];const d=i[r+0],m=i[r+1],g=i[r+2],y=i[r+3];if(o===0){t[n+0]=a,t[n+1]=c,t[n+2]=l,t[n+3]=u;return}if(o===1){t[n+0]=d,t[n+1]=m,t[n+2]=g,t[n+3]=y;return}if(u!==y||a!==d||c!==m||l!==g){let x=1-o;const _=a*d+c*m+l*g+u*y,b=_>=0?1:-1,p=1-_*_;if(p>Number.EPSILON){const S=Math.sqrt(p),T=Math.atan2(S,_*b);x=Math.sin(x*T)/S,o=Math.sin(o*T)/S}const C=o*b;if(a=a*x+d*C,c=c*x+m*C,l=l*x+g*C,u=u*x+y*C,x===1-o){const S=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=S,c*=S,l*=S,u*=S}}t[n]=a,t[n+1]=c,t[n+2]=l,t[n+3]=u}static multiplyQuaternionsFlat(t,n,e,s,i,r){const o=e[s],a=e[s+1],c=e[s+2],l=e[s+3],u=i[r],d=i[r+1],m=i[r+2],g=i[r+3];return t[n]=o*g+l*u+a*m-c*d,t[n+1]=a*g+l*d+c*u-o*m,t[n+2]=c*g+l*m+o*d-a*u,t[n+3]=l*g-o*u-a*d-c*m,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,n,e,s){return this._x=t,this._y=n,this._z=e,this._w=s,this._onChangeCallback(),this}clone(){return new dt(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,n=!0){const e=t.x,s=t.y,i=t.z,r=t.order,o=Math.cos,a=Math.sin,c=o(e/2),l=o(s/2),u=o(i/2),d=a(e/2),m=a(s/2),g=a(i/2);switch(r){case"XYZ":this._x=d*l*u+c*m*g,this._y=c*m*u-d*l*g,this._z=c*l*g+d*m*u,this._w=c*l*u-d*m*g;break;case"YXZ":this._x=d*l*u+c*m*g,this._y=c*m*u-d*l*g,this._z=c*l*g-d*m*u,this._w=c*l*u+d*m*g;break;case"ZXY":this._x=d*l*u-c*m*g,this._y=c*m*u+d*l*g,this._z=c*l*g+d*m*u,this._w=c*l*u-d*m*g;break;case"ZYX":this._x=d*l*u-c*m*g,this._y=c*m*u+d*l*g,this._z=c*l*g-d*m*u,this._w=c*l*u+d*m*g;break;case"YZX":this._x=d*l*u+c*m*g,this._y=c*m*u+d*l*g,this._z=c*l*g-d*m*u,this._w=c*l*u-d*m*g;break;case"XZY":this._x=d*l*u-c*m*g,this._y=c*m*u-d*l*g,this._z=c*l*g+d*m*u,this._w=c*l*u+d*m*g;break}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,n){const e=n/2,s=Math.sin(e);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(t){const n=t.elements,e=n[0],s=n[4],i=n[8],r=n[1],o=n[5],a=n[9],c=n[2],l=n[6],u=n[10],d=e+o+u;if(d>0){const m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(l-a)*m,this._y=(i-c)*m,this._z=(r-s)*m}else if(e>o&&e>u){const m=2*Math.sqrt(1+e-o-u);this._w=(l-a)/m,this._x=.25*m,this._y=(s+r)/m,this._z=(i+c)/m}else if(o>u){const m=2*Math.sqrt(1+o-e-u);this._w=(i-c)/m,this._x=(s+r)/m,this._y=.25*m,this._z=(a+l)/m}else{const m=2*Math.sqrt(1+u-e-o);this._w=(r-s)/m,this._x=(i+c)/m,this._y=(a+l)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(t,n){let e=t.dot(n)+1;return e<Number.EPSILON?(e=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=e):(this._x=0,this._y=-t.z,this._z=t.y,this._w=e)):(this._x=t.y*n.z-t.z*n.y,this._y=t.z*n.x-t.x*n.z,this._z=t.x*n.y-t.y*n.x,this._w=e),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Q(this.dot(t),-1,1)))}rotateTowards(t,n){const e=this.angleTo(t);if(e===0)return this;const s=Math.min(1,n/e);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,n){const e=t._x,s=t._y,i=t._z,r=t._w,o=n._x,a=n._y,c=n._z,l=n._w;return this._x=e*l+r*o+s*c-i*a,this._y=s*l+r*a+i*o-e*c,this._z=i*l+r*c+e*a-s*o,this._w=r*l-e*o-s*a-i*c,this._onChangeCallback(),this}slerp(t,n){if(n===0)return this;if(n===1)return this.copy(t);const e=this._x,s=this._y,i=this._z,r=this._w;let o=r*t._w+e*t._x+s*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=r,this._x=e,this._y=s,this._z=i,this;const a=1-o*o;if(a<=Number.EPSILON){const m=1-n;return this._w=m*r+n*this._w,this._x=m*e+n*this._x,this._y=m*s+n*this._y,this._z=m*i+n*this._z,this.normalize(),this}const c=Math.sqrt(a),l=Math.atan2(c,o),u=Math.sin((1-n)*l)/c,d=Math.sin(n*l)/c;return this._w=r*u+this._w*d,this._x=e*u+this._x*d,this._y=s*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,n,e){return this.copy(t).slerp(n,e)}random(){const t=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),e=Math.random(),s=Math.sqrt(1-e),i=Math.sqrt(e);return this.set(s*Math.sin(t),s*Math.cos(t),i*Math.sin(n),i*Math.cos(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,n=0){return this._x=t[n],this._y=t[n+1],this._z=t[n+2],this._w=t[n+3],this._onChangeCallback(),this}toArray(t=[],n=0){return t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const j=class j{constructor(t,n,e){this.x=0,this.y=0,this.z=0;const s=+(t!==void 0)+ +(n!==void 0)+ +(e!==void 0);if(s!==0){if(s===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(s===1){const{x:i,y:r,z:o}=t;this.x=i,this.y=r,this.z=o||0;return}if(s===3){this.x=t,this.y=n,this.z=e;return}throw V.AcCmErrors.ILLEGAL_PARAMETERS}}set(t,n,e){return e===void 0&&(e=this.z),this.x=t,this.y=n,this.z=e,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new j(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,n){return this.x=t.x*n.x,this.y=t.y*n.y,this.z=t.z*n.z,this}applyEuler(t){return this.applyQuaternion(zn.setFromEuler(t))}applyAxisAngle(t,n){return this.applyQuaternion(zn.setFromAxisAngle(t,n))}applyMatrix3(t){const n=this.x,e=this.y,s=this.z,i=t.elements;return this.x=i[0]*n+i[3]*e+i[6]*s,this.y=i[1]*n+i[4]*e+i[7]*s,this.z=i[2]*n+i[5]*e+i[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const n=this.x,e=this.y,s=this.z,i=t.elements,r=1/(i[3]*n+i[7]*e+i[11]*s+i[15]);return this.x=(i[0]*n+i[4]*e+i[8]*s+i[12])*r,this.y=(i[1]*n+i[5]*e+i[9]*s+i[13])*r,this.z=(i[2]*n+i[6]*e+i[10]*s+i[14])*r,this}applyQuaternion(t){const n=this.x,e=this.y,s=this.z,i=t.x,r=t.y,o=t.z,a=t.w,c=2*(r*s-o*e),l=2*(o*n-i*s),u=2*(i*e-r*n);return this.x=n+a*c+r*u-o*l,this.y=e+a*l+o*c-i*u,this.z=s+a*u+i*l-r*c,this}transformDirection(t){const n=this.x,e=this.y,s=this.z,i=t.elements;return this.x=i[0]*n+i[4]*e+i[8]*s,this.y=i[1]*n+i[5]*e+i[9]*s,this.z=i[2]*n+i[6]*e+i[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this.z=Math.max(t.z,Math.min(n.z,this.z)),this}clampScalar(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this.z=Math.max(t,Math.min(n,this.z)),this}clampLength(t,n){const e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(n,e)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const n=this.dot(t),e=this.length(),s=t.length();return Math.abs(n)===e*s}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this}lerpVectors(t,n,e){return this.x=t.x+(n.x-t.x)*e,this.y=t.y+(n.y-t.y)*e,this.z=t.z+(n.z-t.z)*e,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,n){const e=t.x,s=t.y,i=t.z,r=n.x,o=n.y,a=n.z;return this.x=s*a-i*o,this.y=i*r-e*a,this.z=e*o-s*r,this}projectOnVector(t){const n=t.lengthSq();if(n===0)return this.set(0,0,0);const e=t.dot(this)/n;return this.copy(t).multiplyScalar(e)}projectOnPlane(t){return Ot.copy(this).projectOnVector(t),this.sub(Ot)}reflect(t){return this.sub(Ot.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const n=Math.sqrt(this.lengthSq()*t.lengthSq());if(n===0)return Math.PI/2;const e=this.dot(t)/n;return Math.acos(Math.max(-1,Math.min(1,e)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const n=this.x-t.x,e=this.y-t.y,s=this.z-t.z;return n*n+e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromMatrixPosition(t){const n=t.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(t){const n=this.setFromMatrixColumn(t,0).length(),e=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=n,this.y=e,this.z=s,this}setFromMatrixColumn(t,n){return this.fromArray(t.elements,n*4)}setFromMatrix3Column(t,n){return this.fromArray(t.elements,n*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this.z=t[n+2],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t[n+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,n=Math.random()*2-1,e=Math.sqrt(1-n*n);return this.x=e*Math.cos(t),this.y=n,this.z=e*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};j.ORIGIN=Object.freeze(new j(0,0,0)),j.X_AXIS=Object.freeze(new j(1,0,0)),j.NEGATIVE_X_AXIS=Object.freeze(new j(-1,0,0)),j.Y_AXIS=Object.freeze(new j(0,1,0)),j.NEGATIVE_Y_AXIS=Object.freeze(new j(0,-1,0)),j.Z_AXIS=Object.freeze(new j(0,0,1)),j.NEGATIVE_Z_AXIS=Object.freeze(new j(0,0,-1));let f=j;const Ot=new f,zn=new dt,At=class At{constructor(t,n,e,s,i,r,o,a,c,l,u,d,m,g,y,x){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&n!=null&&e!=null&&s!=null&&i!=null&&r!=null&&o!=null&&a!=null&&c!=null&&l!=null&&u!=null&&d!=null&&m!=null&&g!=null&&y!=null&&x!=null&&this.set(t,n,e,s,i,r,o,a,c,l,u,d,m,g,y,x)}set(t,n,e,s,i,r,o,a,c,l,u,d,m,g,y,x){const _=this.elements;return _[0]=t,_[4]=n,_[8]=e,_[12]=s,_[1]=i,_[5]=r,_[9]=o,_[13]=a,_[2]=c,_[6]=l,_[10]=u,_[14]=d,_[3]=m,_[7]=g,_[11]=y,_[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new At().fromArray(this.elements)}copy(t){const n=this.elements,e=t.elements;return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],this}copyPosition(t){const n=this.elements,e=t.elements;return n[12]=e[12],n[13]=e[13],n[14]=e[14],this}setFromMatrix3(t){const n=t.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}setFromExtrusionDirection(t){if(pt.equalPoint3d(t,f.Z_AXIS))this.identity();else{const n=new f(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?n.crossVectors(f.Y_AXIS,t).normalize():n.crossVectors(f.Z_AXIS,t).normalize();const e=t.clone().cross(n).normalize();this.set(n.x,n.y,n.z,0,e.x,e.y,e.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,n,e){return t.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),e.setFromMatrixColumn(this,2),this}makeBasis(t,n,e){return this.set(t.x,n.x,e.x,0,t.y,n.y,e.y,0,t.z,n.z,e.z,0,0,0,0,1),this}extractRotation(t){const n=this.elements,e=t.elements,s=1/ot.setFromMatrixColumn(t,0).length(),i=1/ot.setFromMatrixColumn(t,1).length(),r=1/ot.setFromMatrixColumn(t,2).length();return n[0]=e[0]*s,n[1]=e[1]*s,n[2]=e[2]*s,n[3]=0,n[4]=e[4]*i,n[5]=e[5]*i,n[6]=e[6]*i,n[7]=0,n[8]=e[8]*r,n[9]=e[9]*r,n[10]=e[10]*r,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(t){return this.compose(te,t,ne)}lookAt(t,n,e){const s=this.elements;return F.subVectors(t,n),F.lengthSq()===0&&(F.z=1),F.normalize(),H.crossVectors(e,F),H.lengthSq()===0&&(Math.abs(e.z)===1?F.x+=1e-4:F.z+=1e-4,F.normalize(),H.crossVectors(e,F)),H.normalize(),wt.crossVectors(F,H),s[0]=H.x,s[4]=wt.x,s[8]=F.x,s[1]=H.y,s[5]=wt.y,s[9]=F.y,s[2]=H.z,s[6]=wt.z,s[10]=F.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const e=t.elements,s=n.elements,i=this.elements,r=e[0],o=e[4],a=e[8],c=e[12],l=e[1],u=e[5],d=e[9],m=e[13],g=e[2],y=e[6],x=e[10],_=e[14],b=e[3],p=e[7],C=e[11],S=e[15],T=s[0],z=s[4],k=s[8],E=s[12],N=s[1],q=s[5],Y=s[9],J=s[13],U=s[2],Et=s[6],It=s[10],Tt=s[14],Bt=s[3],Rt=s[7],kt=s[11],Nt=s[15];return i[0]=r*T+o*N+a*U+c*Bt,i[4]=r*z+o*q+a*Et+c*Rt,i[8]=r*k+o*Y+a*It+c*kt,i[12]=r*E+o*J+a*Tt+c*Nt,i[1]=l*T+u*N+d*U+m*Bt,i[5]=l*z+u*q+d*Et+m*Rt,i[9]=l*k+u*Y+d*It+m*kt,i[13]=l*E+u*J+d*Tt+m*Nt,i[2]=g*T+y*N+x*U+_*Bt,i[6]=g*z+y*q+x*Et+_*Rt,i[10]=g*k+y*Y+x*It+_*kt,i[14]=g*E+y*J+x*Tt+_*Nt,i[3]=b*T+p*N+C*U+S*Bt,i[7]=b*z+p*q+C*Et+S*Rt,i[11]=b*k+p*Y+C*It+S*kt,i[15]=b*E+p*J+C*Tt+S*Nt,this}multiplyScalar(t){const n=this.elements;return n[0]*=t,n[4]*=t,n[8]*=t,n[12]*=t,n[1]*=t,n[5]*=t,n[9]*=t,n[13]*=t,n[2]*=t,n[6]*=t,n[10]*=t,n[14]*=t,n[3]*=t,n[7]*=t,n[11]*=t,n[15]*=t,this}determinant(){const t=this.elements,n=t[0],e=t[4],s=t[8],i=t[12],r=t[1],o=t[5],a=t[9],c=t[13],l=t[2],u=t[6],d=t[10],m=t[14],g=t[3],y=t[7],x=t[11],_=t[15];return g*(+i*a*u-s*c*u-i*o*d+e*c*d+s*o*m-e*a*m)+y*(+n*a*m-n*c*d+i*r*d-s*r*m+s*c*l-i*a*l)+x*(+n*c*u-n*o*m-i*r*u+e*r*m+i*o*l-e*c*l)+_*(-s*o*l-n*a*u+n*o*d+s*r*u-e*r*d+e*a*l)}transpose(){const t=this.elements;let n;return n=t[1],t[1]=t[4],t[4]=n,n=t[2],t[2]=t[8],t[8]=n,n=t[6],t[6]=t[9],t[9]=n,n=t[3],t[3]=t[12],t[12]=n,n=t[7],t[7]=t[13],t[13]=n,n=t[11],t[11]=t[14],t[14]=n,this}setPosition(t,n,e){const s=this.elements;return t instanceof f?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=n,s[14]=e),this}invert(){const t=this.elements,n=t[0],e=t[1],s=t[2],i=t[3],r=t[4],o=t[5],a=t[6],c=t[7],l=t[8],u=t[9],d=t[10],m=t[11],g=t[12],y=t[13],x=t[14],_=t[15],b=u*x*c-y*d*c+y*a*m-o*x*m-u*a*_+o*d*_,p=g*d*c-l*x*c-g*a*m+r*x*m+l*a*_-r*d*_,C=l*y*c-g*u*c+g*o*m-r*y*m-l*o*_+r*u*_,S=g*u*a-l*y*a-g*o*d+r*y*d+l*o*x-r*u*x,T=n*b+e*p+s*C+i*S;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const z=1/T;return t[0]=b*z,t[1]=(y*d*i-u*x*i-y*s*m+e*x*m+u*s*_-e*d*_)*z,t[2]=(o*x*i-y*a*i+y*s*c-e*x*c-o*s*_+e*a*_)*z,t[3]=(u*a*i-o*d*i-u*s*c+e*d*c+o*s*m-e*a*m)*z,t[4]=p*z,t[5]=(l*x*i-g*d*i+g*s*m-n*x*m-l*s*_+n*d*_)*z,t[6]=(g*a*i-r*x*i-g*s*c+n*x*c+r*s*_-n*a*_)*z,t[7]=(r*d*i-l*a*i+l*s*c-n*d*c-r*s*m+n*a*m)*z,t[8]=C*z,t[9]=(g*u*i-l*y*i-g*e*m+n*y*m+l*e*_-n*u*_)*z,t[10]=(r*y*i-g*o*i+g*e*c-n*y*c-r*e*_+n*o*_)*z,t[11]=(l*o*i-r*u*i-l*e*c+n*u*c+r*e*m-n*o*m)*z,t[12]=S*z,t[13]=(l*y*s-g*u*s+g*e*d-n*y*d-l*e*x+n*u*x)*z,t[14]=(g*o*s-r*y*s-g*e*a+n*y*a+r*e*x-n*o*x)*z,t[15]=(r*u*s-l*o*s+l*e*a-n*u*a-r*e*d+n*o*d)*z,this}scale(t){const n=this.elements,e=t.x,s=t.y,i=t.z;return n[0]*=e,n[4]*=s,n[8]*=i,n[1]*=e,n[5]*=s,n[9]*=i,n[2]*=e,n[6]*=s,n[10]*=i,n[3]*=e,n[7]*=s,n[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,n=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],e=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(n,e,s))}makeTranslation(t,n,e){return t instanceof f?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,n,0,0,1,e,0,0,0,1),this}makeRotationX(t){const n=Math.cos(t),e=Math.sin(t);return this.set(1,0,0,0,0,n,-e,0,0,e,n,0,0,0,0,1),this}makeRotationY(t){const n=Math.cos(t),e=Math.sin(t);return this.set(n,0,e,0,0,1,0,0,-e,0,n,0,0,0,0,1),this}makeRotationZ(t){const n=Math.cos(t),e=Math.sin(t);return this.set(n,-e,0,0,e,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,n){const e=Math.cos(n),s=Math.sin(n),i=1-e,r=t.x,o=t.y,a=t.z,c=i*r,l=i*o;return this.set(c*r+e,c*o-s*a,c*a+s*o,0,c*o+s*a,l*o+e,l*a-s*r,0,c*a-s*o,l*a+s*r,i*a*a+e,0,0,0,0,1),this}makeScale(t,n,e){return this.set(t,0,0,0,0,n,0,0,0,0,e,0,0,0,0,1),this}makeShear(t,n,e,s,i,r){return this.set(1,e,i,0,t,1,r,0,n,s,1,0,0,0,0,1),this}compose(t,n,e){const s=this.elements,i=n.x,r=n.y,o=n.z,a=n.w,c=i+i,l=r+r,u=o+o,d=i*c,m=i*l,g=i*u,y=r*l,x=r*u,_=o*u,b=a*c,p=a*l,C=a*u,S=e.x,T=e.y,z=e.z;return s[0]=(1-(y+_))*S,s[1]=(m+C)*S,s[2]=(g-p)*S,s[3]=0,s[4]=(m-C)*T,s[5]=(1-(d+_))*T,s[6]=(x+b)*T,s[7]=0,s[8]=(g+p)*z,s[9]=(x-b)*z,s[10]=(1-(d+y))*z,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,n,e){const s=this.elements;let i=ot.set(s[0],s[1],s[2]).length();const r=ot.set(s[4],s[5],s[6]).length(),o=ot.set(s[8],s[9],s[10]).length();this.determinant()<0&&(i=-i),t.x=s[12],t.y=s[13],t.z=s[14],D.copy(this);const c=1/i,l=1/r,u=1/o;return D.elements[0]*=c,D.elements[1]*=c,D.elements[2]*=c,D.elements[4]*=l,D.elements[5]*=l,D.elements[6]*=l,D.elements[8]*=u,D.elements[9]*=u,D.elements[10]*=u,n.setFromRotationMatrix(D),e.x=i,e.y=r,e.z=o,this}equals(t){const n=this.elements,e=t.elements;for(let s=0;s<16;s++)if(n[s]!==e[s])return!1;return!0}fromArray(t,n=0){for(let e=0;e<16;e++)this.elements[e]=t[e+n];return this}toArray(t=[],n=0){const e=this.elements;return t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3],t[n+4]=e[4],t[n+5]=e[5],t[n+6]=e[6],t[n+7]=e[7],t[n+8]=e[8],t[n+9]=e[9],t[n+10]=e[10],t[n+11]=e[11],t[n+12]=e[12],t[n+13]=e[13],t[n+14]=e[14],t[n+15]=e[15],t}};At.IDENTITY=Object.freeze(new At);let W=At;const ot=new f,D=new W,te=new f(0,0,0),ne=new f(1,1,1),H=new f,wt=new f,F=new f;class Z{constructor(t=void 0,n=void 0){this.min=t==null?new f(1/0,1/0,1/0):new f(t.x,t.y,t.z),this.max=n==null?new f(-1/0,-1/0,-1/0):new f(n.x,n.y,n.z)}set(t,n){return this.min.copy(t),this.max.copy(n),this}setFromArray(t){this.makeEmpty();for(let n=0,e=t.length;n<e;n+=3)this.expandByPoint(Xt.fromArray(t,n));return this}setFromPoints(t){this.makeEmpty();for(let n=0,e=t.length;n<e;n++)this.expandByPoint(t[n]);return this}setFromCenterAndSize(t,n){const e=Xt.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new Z().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new f(0,0,0):new f(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new f(0,0,0):new f(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,n){return n.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsPlane(t){let n,e;return t.normal.x>0?(n=t.normal.x*this.min.x,e=t.normal.x*this.max.x):(n=t.normal.x*this.max.x,e=t.normal.x*this.min.x),t.normal.y>0?(n+=t.normal.y*this.min.y,e+=t.normal.y*this.max.y):(n+=t.normal.y*this.max.y,e+=t.normal.y*this.min.y),t.normal.z>0?(n+=t.normal.z*this.min.z,e+=t.normal.z*this.max.z):(n+=t.normal.z*this.max.z,e+=t.normal.z*this.min.z),n<=-t.constant&&e>=-t.constant}clampPoint(t,n){return n.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Xt).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:($[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),$[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),$[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),$[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),$[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),$[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),$[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),$[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints($),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const $=[new f,new f,new f,new f,new f,new f,new f,new f],Xt=new f,bn=new R;class O{constructor(t=void 0,n=void 0){this.min=t==null?new R(1/0,1/0):new R(t.x,t.y),this.max=n==null?new R(-1/0,-1/0):new R(n.x,n.y)}set(t,n){return this.min.copy(t),this.max.copy(n),this}setFromPoints(t){this.makeEmpty();for(let n=0,e=t.length;n<e;n++)this.expandByPoint(t[n]);return this}setFromCenterAndSize(t,n){const e=bn.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new O().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new R(0,0):new R(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new R(0,0):new R(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,n){return n.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,n){return n.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,bn).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Sn=new f,ee=new f,se=new rt;class mt{constructor(t=new f(1,0,0),n=0){this.normal=t,this.constant=n}set(t,n){return this.normal.copy(t),this.constant=n,this}setComponents(t,n,e,s){return this.normal.set(t,n,e),this.constant=s,this}setFromNormalAndCoplanarPoint(t,n){return this.normal.copy(t),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(t,n,e){const s=Sn.subVectors(e,n).cross(ee.subVectors(t,n)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}projectPoint(t,n){return n.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectsBox(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,n){const e=n||se.getNormalMatrix(t),s=this.coplanarPoint(Sn).applyMatrix4(t),i=this.normal.applyMatrix3(e).normalize();return this.constant=-s.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new mt().copy(this)}}class P extends R{clone(){return new P(this.x,this.y)}static pointArrayToNumberArray(t){const n=new Array(t.length*2);return t.forEach((e,s)=>{e.toArray(n,s*2)}),n}}class M extends f{clone(){return new M(this.x,this.y,this.z)}static pointArrayToNumberArray(t,n=!0){const e=n?3:2,s=new Array(t.length*e);return t.forEach((i,r)=>{i.toArray(s,r*e)}),s}}const Cn=new W,En=new dt,Pt=class Pt{constructor(t=0,n=0,e=0,s=Pt.DEFAULT_ORDER){this._x=t,this._y=n,this._z=e,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,n,e,s=this._order){return this._x=t,this._y=n,this._z=e,this._order=s,this._onChangeCallback(),this}clone(){return new Pt(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,n=this._order,e=!0){const s=t.elements,i=s[0],r=s[4],o=s[8],a=s[1],c=s[5],l=s[9],u=s[2],d=s[6],m=s[10];switch(n){case"XYZ":this._y=Math.asin(Q(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,m),this._z=Math.atan2(-r,i)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Q(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(Q(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,m),this._z=Math.atan2(-r,c)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-Q(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-r,c));break;case"YZX":this._z=Math.asin(Q(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-Q(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,m),this._y=0);break}return this._order=n,e===!0&&this._onChangeCallback(),this}setFromQuaternion(t,n,e=!0){return Cn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Cn,n,e)}setFromVector3(t,n=this._order){return this.set(t.x,t.y,t.z,n)}reorder(t){return En.setFromEuler(this),this.setFromQuaternion(En,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],n=0){return t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Pt.DEFAULT_ORDER="XYZ";let Dt=Pt;function Yt(h,t,n=!1){const e=h.x,s=h.y;let i=!1;const r=t.length;for(let o=0,a=r-1;o<r;a=o++){const c=t[o].x,l=t[o].y,u=t[a].x,d=t[a].y;let m=l>s!=d>s;n&&(m=l>=s!=d>=s),m&&e<(u-c)*(s-l)/(d-l)+c&&(i=!i)}return i}function In(h,t){if(h.length===0||t.length===0)return!1;const n=new O().setFromPoints(h),e=new O().setFromPoints(t);if(!n.intersectsBox(e))return!1;for(let s=0;s<h.length;){if(Yt(h[s],t,!0))return!0;s<h.length-1&&pt.equalPoint2d(h[s+1],h[s])&&++s,++s}return!1}const Tn={isPointInPolygon:Yt,isPolygonIntersect:In};function ie(h,t){const n=[],e=t-1,s=h;for(let i=0;i<=s;i++)n.push(0);for(let i=1;i<=e-s;i++)n.push(i);for(let i=0;i<=s;i++)n.push(e-s+1);return n}function re(h,t){const n=t.length-1,e=h,s=[0];let i=0;for(let o=1;o<=n;o++){const a=t[o][0]-t[o-1][0],c=t[o][1]-t[o-1][1],l=t[o][2]-t[o-1][2],u=Math.sqrt(a*a+c*c+l*l);i+=u,s.push(i)}const r=[];for(let o=0;o<=e;o++)r.push(0);for(let o=1;o<=n-e;o++){const a=s[o]/i;r.push(a*(n-e+1))}for(let o=0;o<=e;o++)r.push(n-e+1);return r}function Bn(h,t="Uniform"){const n=h.length;if(n===0)return[];if(n===1)return[0];const e=n-1;if(t==="Uniform")return new Array(n).fill(0).map((r,o)=>o/e);const s=[0];let i=0;for(let r=1;r<=e;r++){const o=h[r][0]-h[r-1][0],a=h[r][1]-h[r-1][1],c=h[r][2]-h[r-1][2],l=Math.sqrt(o*o+a*a+c*c),u=t==="SqrtChord"?Math.sqrt(l):l;i+=u,s.push(i)}return i<1e-12?new Array(n).fill(0).map((r,o)=>o/e):s.map(r=>r/i)}function Rn(h,t){const n=t.length-1,e=h,s=n+e+1,i=new Array(s+1).fill(0),r=t[t.length-1];for(let o=s-e;o<=s;o++)i[o]=r;for(let o=1;o<=n-e;o++){let a=0;for(let c=o;c<o+e;c++)a+=t[c];i[o+e]=a/e}return i}function oe(h,t){const n=t.length-1,e=h,s=[0];let i=0;for(let o=1;o<=n;o++){const a=t[o][0]-t[o-1][0],c=t[o][1]-t[o-1][1],l=t[o][2]-t[o-1][2],u=Math.sqrt(a*a+c*c+l*l),d=Math.sqrt(u);i+=d,s.push(i)}const r=[];for(let o=0;o<=e;o++)r.push(0);for(let o=1;o<=n-e;o++){const a=s[o]/i;r.push(a*(n-e+1))}for(let o=0;o<=e;o++)r.push(n-e+1);return r}function Zt(h,t){const n=h.length,e=h.map(r=>r.slice()),s=t.slice();for(let r=0;r<n;r++){let o=r,a=Math.abs(e[r][r]);for(let c=r+1;c<n;c++){const l=Math.abs(e[c][r]);l>a&&(a=l,o=c)}if(a<1e-12)throw new Error("Interpolation matrix is singular.");if(o!==r){const c=e[r];e[r]=e[o],e[o]=c;const l=s[r];s[r]=s[o],s[o]=l}for(let c=r+1;c<n;c++){const l=e[c][r]/e[r][r];if(!(Math.abs(l)<1e-14)){for(let u=r;u<n;u++)e[c][u]-=l*e[r][u];s[c]-=l*s[r]}}}const i=new Array(n).fill(0);for(let r=n-1;r>=0;r--){let o=s[r];for(let a=r+1;a<n;a++)o-=e[r][a]*i[a];i[r]=o/e[r][r]}return i}function Gt(h,t,n="Uniform",e,s){if(h.length===0)return{controlPoints:[],knots:[],weights:[]};const i=h.map(E=>[E[0],E[1],E[2]??0]),r=!!e,o=!!s,a=(r?1:0)+(o?1:0),c=i.length-1,l=c+a;if(l<t)throw new Error("Not enough points to interpolate a curve of this degree.");const u=Bn(i,n),d=u.slice();r&&d.unshift(u[0]),o&&d.push(u[u.length-1]);const m=Rn(t,d),g=l+1,y=new Array(g),x=new Array(g),_=new Array(g),b=new Array(g);let p=0;y[p]=new Array(g).fill(0),y[p][0]=1,x[p]=i[0][0],_[p]=i[0][1],b[p]=i[0][2],p++;for(let E=1;E<=c-1;E++){const N=u[E];y[p]=new Array(g).fill(0);for(let q=0;q<=l;q++)y[p][q]=tt(q,t,N,m);x[p]=i[E][0],_[p]=i[E][1],b[p]=i[E][2],p++}if(y[p]=new Array(g).fill(0),y[p][l]=1,x[p]=i[c][0],_[p]=i[c][1],b[p]=i[c][2],p++,r){const E=m[t+1]-m[0],N=E!==0?t/E:0;y[p]=new Array(g).fill(0),y[p][0]=-N,y[p][1]=N,x[p]=(e==null?void 0:e[0])??0,_[p]=(e==null?void 0:e[1])??0,b[p]=(e==null?void 0:e[2])??0,p++}if(o){const E=m[l+t+1]-m[l],N=E!==0?t/E:0;y[p]=new Array(g).fill(0),y[p][l-1]=-N,y[p][l]=N,x[p]=(s==null?void 0:s[0])??0,_[p]=(s==null?void 0:s[1])??0,b[p]=(s==null?void 0:s[2])??0,p++}const C=Zt(y,x),S=Zt(y,_),T=Zt(y,b),z=new Array(g);for(let E=0;E<g;E++)z[E]=[C[E],S[E],T[E]];const k=new Array(g).fill(1);return{controlPoints:z,knots:m,weights:k}}function tt(h,t,n,e){if(t===0)return n>=e[h]&&n<e[h+1]?1:0;const s=e[h+t]-e[h],i=e[h+t+1]-e[h+1],r=s>1e-10?(n-e[h])/s:0,o=i>1e-10?(e[h+t+1]-n)/i:0;return r*tt(h,t-1,n,e)+o*tt(h+1,t-1,n,e)}function gt(h,t,n,e,s){const i=e.length-1,r=t;if(h=Math.max(n[r],Math.min(n[i+1],h)),Math.abs(h-n[i+1])<1e-8)return[...e[i]];if(Math.abs(h-n[r])<1e-8)return[...e[0]];const o=[0,0,0];let a=0;for(let c=0;c<=i;c++){const l=tt(c,r,h,n),u=s[c]*l;o[0]+=e[c][0]*u,o[1]+=e[c][1]*u,o[2]+=e[c][2]*u,a+=u}if(Math.abs(a)<1e-10){const c=n[n.length-r-1];if(Math.abs(h-c)<1e-8)return[...e[i]];if(Math.abs(h-n[r])<1e-8)return[...e[0]]}return Math.abs(a)>=1e-10&&(o[0]/=a,o[1]/=a,o[2]/=a),o}function Qt(h,t,n,e){if(t===0)return 0;const s=e[h+t]-e[h],i=e[h+t+1]-e[h+1];let r=0;return s>1e-10&&(r+=t/s*tt(h,t-1,n,e)),i>1e-10&&(r-=t/i*tt(h+1,t-1,n,e)),r}function he(h,t,n,e){if(t<=1)return 0;const s=e[h+t]-e[h],i=e[h+t+1]-e[h+1];let r=0;return s>1e-10&&(r+=t/s*Qt(h,t-1,n,e)),i>1e-10&&(r-=t/i*Qt(h+1,t-1,n,e)),r}function kn(h,t,n,e,s){const i=e.length-1,r=t,o=n[r],a=n[i+1];h=Math.max(o,Math.min(a,h));const c=[0,0,0],l=[0,0,0],u=[0,0,0];let d=0,m=0,g=0;for(let T=0;T<=i;T++){const z=tt(T,r,h,n),k=Qt(T,r,h,n),E=he(T,r,h,n),N=s[T],q=N*z,Y=N*k,J=N*E,U=e[T];c[0]+=q*U[0],c[1]+=q*U[1],c[2]+=q*U[2],l[0]+=Y*U[0],l[1]+=Y*U[1],l[2]+=Y*U[2],u[0]+=J*U[0],u[1]+=J*U[1],u[2]+=J*U[2],d+=q,m+=Y,g+=J}if(Math.abs(d)<1e-10)return{point:gt(h,t,n,e,s),deriv1:[0,0,0],deriv2:[0,0,0]};const y=d*d,x=[c[0]/d,c[1]/d,c[2]/d],_=[(l[0]*d-c[0]*m)/y,(l[1]*d-c[1]*m)/y,(l[2]*d-c[2]*m)/y],b=u[0]*d-c[0]*g,p=u[1]*d-c[1]*g,C=u[2]*d-c[2]*g,S=[b/y-2*m*_[0]/d,p/y-2*m*_[1]/d,C/y-2*m*_[2]/d];return{point:x,deriv1:_,deriv2:S}}function Nn(h,t){const n=h[0],e=h[1],s=t[0],i=t[1],r=n*n+e*e;return r<1e-20?0:(n*i-e*s)/Math.pow(r,1.5)}function jn(h,t,n,e){const s=h,i=t[s],r=t[t.length-s-1];let o=0;const a=1e3,c=(r-i)/a;let l=gt(i,h,t,n,e);for(let y=1;y<=a;y++){const x=i+y*c,_=gt(x,h,t,n,e),b=_[0]-l[0],p=_[1]-l[1],C=_[2]-l[2];o+=Math.sqrt(b*b+p*p+C*C),l=_}const u=gt(r,h,t,n,e),d=u[0]-l[0],m=u[1]-l[1],g=u[2]-l[2];return o+=Math.sqrt(d*d+m*m+g*g),o}function ae(h,t=3,n="Uniform",e,s){return h.length===0?[]:Gt(h,t,n,e,s).controlPoints}const qn=new W,Vn=new f,ce=new f,le=new f,Kt=new M;function Ln(h){return new W().setFromExtrusionDirection(new f(h.x,h.y,h.z))}function ue(h){return qn.setFromExtrusionDirection(new f(h.x,h.y,h.z)),qn.extractBasis(Vn,ce,le),Vn.clone()}function de(h,t){return new M(h.x,h.y,h.z??0).applyMatrix4(Ln(t))}function Wt(h,t){return new M(h.x,h.y,h.z??0).applyMatrix4(Ln(t).invert())}function me(h,t,n){const e=Wt(h,n),s=Wt(t,n);return Kt.set(s.x-e.x,s.y-e.y,(s.z??0)-(e.z??0)),w.normalizeAngle(Math.atan2(Kt.y,Kt.x))}class vn{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class $t extends vn{translate(t){return this.transform(new rt().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class ht extends $t{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const n=this.getUtoTmapping(t);return this.getPoint(n)}getPoints(t=5){const n=[];for(let e=0;e<=t;e++)n.push(this.getPoint(e/t));return n}getSpacedPoints(t=5){const n=[];for(let e=0;e<=t;e++)n.push(this.getPointAt(e/t));return n}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const n=[];let e,s=this.getPoint(0),i=0;n.push(0);for(let r=1;r<=t;r++)e=this.getPoint(r/t),i+=e.distanceTo(s),n.push(i),s=e;return n}getUtoTmapping(t,n){const e=this.getLengths();let s=0;const i=e.length;let r;n?r=n:r=t*e[i-1];let o=0,a=i-1,c;for(;o<=a;)if(s=Math.floor(o+(a-o)/2),c=e[s]-r,c<0)o=s+1;else if(c>0)a=s-1;else{a=s;break}if(s=a,e[s]===r)return s/(i-1);const l=e[s],d=e[s+1]-l,m=(r-l)/d;return(s+m)/(i-1)}getTangent(t){let e=t-1e-4,s=t+1e-4;e<0&&(e=0),s>1&&(s=1);const i=this.getPoint(e),r=this.getPoint(s),o=new P;return o.copy(r).sub(i).normalize(),o}getTangentAt(t){const n=this.getUtoTmapping(t);return this.getTangent(n)}}class G extends ht{constructor(t,n,e,s,i){super();const r=+(t!==void 0)+ +(n!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(i!==void 0);if(r==3)typeof t=="object"&&typeof n=="object"&&typeof e=="object"?this.createByThreePoints(t,n,e):this.createByStartEndPointsAndBulge(t,n,e);else if(r==5){const o=t;this.center=new P(o.x,o.y),this.radius=n,this._clockwise=i,this._startAngle=this._clockwise?this._mirrorAngle(w.normalizeAngle(e)):w.normalizeAngle(e),this._endAngle=this._clockwise?this._mirrorAngle(w.normalizeAngle(s)):w.normalizeAngle(s)}else throw V.AcCmErrors.ILLEGAL_PARAMETERS}createByThreePoints(t,n,e){const s=(z,k)=>({x:(z.x+k.x)/2,y:(z.y+k.y)/2}),i=(z,k)=>(k.y-z.y)/(k.x-z.x),r=z=>-1/z,o=s(t,n),a=s(n,e),c=i(t,n),l=i(n,e),u=r(c),d=r(l),m=(z,k,E,N)=>{const q=(N-k)/(z-E),Y=z*q+k;return{x:q,y:Y}},g=o.y-u*o.x,y=a.y-d*a.x,x=m(u,g,d,y),_=Math.sqrt(Math.pow(t.x-x.x,2)+Math.pow(t.y-x.y,2)),b=(z,k)=>Math.atan2(z.y-k.y,z.x-k.x),p=b(t,x),C=b(n,x),S=b(e,x),T=S>p&&S<C||p>S&&p<C||C>S&&C<p;this.center=x,this.radius=_,this._clockwise=!T,this._startAngle=p,this._endAngle=S}createByStartEndPointsAndBulge(t,n,e){let s,i,r;e<0?(s=Math.atan(-e)*4,i=new R(t),r=new R(n)):(s=Math.atan(e)*4,i=new R(n),r=new R(t));const o=new R().subVectors(r,i),a=o.length(),c=new R().addVectors(i,o.multiplyScalar(.5)),l=Math.abs(a/2/Math.tan(s/2)),u=o.normalize(),d=e<0?-Math.PI/2:Math.PI/2,m=new R(u.x*Math.cos(d)-u.y*Math.sin(d),u.y*Math.cos(d)+u.x*Math.sin(d));let g;s<Math.PI?e<0?g=c.add(m.multiplyScalar(l)):g=c.add(m.multiplyScalar(-l)):e<0?g=c.add(m.multiplyScalar(-l)):g=c.add(m.multiplyScalar(l)),e<0?(this._startAngle=Math.atan2(i.y-g.y,i.x-g.x),this._endAngle=Math.atan2(r.y-g.y,r.x-g.x)):(this._startAngle=Math.atan2(r.y-g.y,r.x-g.x),this._endAngle=Math.atan2(i.y-g.y,i.x-g.x)),this._clockwise=e<0,this.center=g,this.radius=r.sub(g).length()}get center(){return this._center}set center(t){this._center=new P(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(t){this._startAngle=this._clockwise?this._mirrorAngle(w.normalizeAngle(t)):w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(t){const n=this.startAngle==0&&t==I?t:w.normalizeAngle(t);this._endAngle=this._clockwise?this._mirrorAngle(n):n,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(t){return(360-t*180/Math.PI)%360*Math.PI/180}_getInternalAngle(t){return this._clockwise?this._mirrorAngle(t):t}get deltaAngle(){const t=this._getInternalAngle(this.startAngle),n=this._getInternalAngle(this.endAngle);return this.clockwise?w.normalizeAngle(t-n):w.normalizeAngle(n-t)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=this._getInternalAngle(this.startAngle),n=this._clockwise?w.normalizeAngle(t-this.deltaAngle/2):w.normalizeAngle(t+this.deltaAngle/2),e=this._clockwise?this._mirrorAngle(n):n;return this.getPointAtAngle(e)}get closed(){const t=this._getInternalAngle(this.startAngle),n=this._getInternalAngle(this.endAngle);return Math.abs(n-t)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],n=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const i of n){const r=this._getInternalAngle(i);w.isBetweenAngle(r,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(i))}const e=t.map(i=>i.x),s=t.map(i=>i.y);return new O(new P(Math.min(...e),Math.min(...s)),new P(Math.max(...e),Math.max(...s)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){const n=t,e=this.center.clone().applyMatrix2d(n),s=this.startPoint.clone().applyMatrix2d(n);if(this.closed)return this.center=e,this.radius=e.distanceTo(s),this._startAngle=Math.atan2(s.y-e.y,s.x-e.x),this._endAngle=this._startAngle,this._clockwise=n.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;const i=this.midPoint.clone().applyMatrix2d(n),r=this.endPoint.clone().applyMatrix2d(n),o=new G(s,i,r),a=n.determinant()<0?!this.clockwise:this.clockwise,c=l=>{const u=w.normalizeAngle(l);return a?this._mirrorAngle(u):u};return this.center=o.center,this.radius=o.radius,this.clockwise=a,this.startAngle=c(Math.atan2(s.y-o.center.y,s.x-o.center.x)),this.endAngle=c(Math.atan2(r.y-o.center.y,r.x-o.center.x)),this._boundingBoxNeedsUpdate=!0,this}clone(){return new G(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const n=this._getInternalAngle(t),e=this.center.x+this.radius*Math.cos(n),s=this.center.y+this.radius*Math.sin(n);return new P(e,s)}getQuadrantPoints(){const t=[],n=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle),s=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const i of s){const r=this._getInternalAngle(i);w.isBetweenAngle(r,n,e,this.clockwise)&&t.push(this.getPointAtAngle(i))}return t}nearestPoint(t){const n=new P(t.x,t.y),e=n.x-this.center.x,s=n.y-this.center.y;if(Math.hypot(e,s)<1e-12)return this.startPoint.clone();const r=Math.atan2(s,e),o=this.clockwise?this._mirrorAngle(w.normalizeAngle(r)):w.normalizeAngle(r),a=this._getInternalAngle(o),c=this._getInternalAngle(this.startAngle),l=this._getInternalAngle(this.endAngle);if(w.isBetweenAngle(a,c,l,this.clockwise))return this.getPointAtAngle(o);const u=n.distanceToSquared(this.startPoint),d=n.distanceToSquared(this.endPoint);return u<=d?this.startPoint.clone():this.endPoint.clone()}perpendicularPoints(t){const n=new P(t.x,t.y),e=n.x-this.center.x,s=n.y-this.center.y,i=Math.hypot(e,s);if(i<1e-12)return[];const r=e/i,o=s/i,a=[new P(this.center.x+r*this.radius,this.center.y+o*this.radius),new P(this.center.x-r*this.radius,this.center.y-o*this.radius)],c=[],l=this._getInternalAngle(this.startAngle),u=this._getInternalAngle(this.endAngle);for(const d of a){const m=Math.atan2(d.y-this.center.y,d.x-this.center.x),g=this.clockwise?this._mirrorAngle(w.normalizeAngle(m)):w.normalizeAngle(m),y=this._getInternalAngle(g);(this.closed||w.isBetweenAngle(y,l,u,this.clockwise))&&c.push(d)}return c}tangentPoints(t){const n=[],e=t.x-this.center.x,s=t.y-this.center.y,i=Math.hypot(e,s),r=this.radius;if(i<r)return n;const o=Math.acos(r/i),a=Math.atan2(s,e),c=[a+o,a-o],l=this._getInternalAngle(this.startAngle),u=this._getInternalAngle(this.endAngle);for(const d of c){const m=this.clockwise?this._mirrorAngle(w.normalizeAngle(d)):w.normalizeAngle(d),g=this._getInternalAngle(m);(this.closed||w.isBetweenAngle(g,l,u,this.clockwise))&&n.push(this.getPointAtAngle(m))}return n}getPoints(t=100){const n=[];let e=this.deltaAngle,s=this._getInternalAngle(this.startAngle);if(this.closed&&(e=I,s=0),this.clockwise)for(let i=0;i<=t;i++){const r=s-e*(i/t),o=this._clockwise?this._mirrorAngle(r):r,a=this.getPointAtAngle(o);n.push(new P(a.x,a.y))}else for(let i=0;i<=t;i++){const r=s+e*(i/t),o=this._clockwise?this._mirrorAngle(r):r,a=this.getPointAtAngle(o);n.push(new P(a.x,a.y))}return n}}const Mt=1e-6;function Un(h,t){if(je(h)){const i=ye(h,t);return i?[i]:[]}const n=Zn(h);if(n.numberOfVertices<2)return[];const s=Ve(n,t);return s?[s]:[]}function ge(h){return Zn(h)}function ye(h,t){const n=xe(h);if(n.length===0)return null;const e=[];for(const o of n){const a=fe(o,t);if(!a)return null;e.push(a)}const s=_e(h),i=we(e,s,h.closed,t);if(i.length<2)return null;const r=new nt;return i.forEach((o,a)=>{r.addVertexAt(a,{x:o.x,y:o.y})}),r.closed=h.closed,r}function xe(h){const t=[],n=h.numberOfVertices,e=h.closed?n:n-1;for(let s=0;s<e;s++){const i=h.vertices[s],r=h.vertices[(s+1)%n];B.isPositive(Math.abs(i.bulge??0))?t.push({kind:"arc",arc:new G(i,r,i.bulge)}):t.push({kind:"line",start:new P(i.x,i.y),end:new P(r.x,r.y)})}return t}function _e(h){const t=[];for(let n=0;n<h.numberOfVertices;n++)t.push(h.getPointAt(n));return t}function fe(h,t){if(h.kind==="line"){const e=pe(h.start,h.end,t);return e?{kind:"line",...e}:null}const n=Ae(h.arc,h.arc.startPoint,h.arc.endPoint,t);return n?{kind:"arc",arc:n}:null}function Ae(h,t,n,e){const s=Pe(h,t,n,e),i=h.radius+s;return B.isNonPositive(i)?null:new G(h.center,i,h.startAngle,h.endAngle,h.clockwise)}function Pe(h,t,n,e){const s=n.x-t.x,i=n.y-t.y,r=Math.hypot(s,i);if(B.isNonPositive(r))return h.clockwise?-e:e;const o=-i/r,a=s/r,c=h.center.x-(t.x+n.x)/2,l=h.center.y-(t.y+n.y)/2;return c*o+l*a>0?-e:e}function pe(h,t,n){const e=t.x-h.x,s=t.y-h.y,i=Math.hypot(e,s);if(B.isNonPositive(i))return null;const r=-s/i*n,o=e/i*n;return{start:new P(h.x+r,h.y+o),end:new P(t.x+r,t.y+o),dx:e,dy:s}}function we(h,t,n,e){var o;const s=h.length;if(s===0)return[];const i=Me(h,t,n,e),r=[((o=i[0].nextSegmentStart)==null?void 0:o.clone())??i[0].point.clone()];for(let a=0;a<s;a++){const c=h[a],l=a===s-1&&!n?{point:Ee(c)}:i[(a+1)%s];if(a>0&&i[a].filletPoints&&i[a].filletPoints.forEach(u=>r.push(u.clone())),c.kind==="arc"){const u=i[a].nextSegmentStart??i[a].point,d=l.point,m=ze(c.arc,u,d,Math.max(16,32));for(let g=1;g<m.length;g++)r.push(m[g])}else r.push(l.point.clone())}return Gn(r)}function Me(h,t,n,e){const s=h.length,i=[];for(let r=0;r<s;r++)r===0?i.push(n?Fn(h[s-1],h[0],t[0],e):{point:Ce(h[0])}):i.push(Fn(h[r-1],h[r],t[r],e));return i}function ze(h,t,n,e){const s=h.nearestPoint(t),i=h.nearestPoint(n),r=Jt(h,s),o=Jt(h,i),a=Se(h,r,o),c=[];for(let l=0;l<=e;l++){const u=l/e,d=h.clockwise?r-a*u:r+a*u;c.push(h.getPointAtAngle(be(h,d)))}return c}function Jt(h,t){return Math.atan2(t.y-h.center.y,t.x-h.center.x)}function be(h,t){const n=w.normalizeAngle(t);return h.clockwise?Ht(n):n}function Ht(h){return(360-h*180/Math.PI)%360*(Math.PI/180)}function Se(h,t,n){if(h.clockwise){let s=t-n;return B.isNonPositive(s)&&(s+=I),s}let e=n-t;return B.isNonPositive(e)&&(e+=I),e}function Ce(h){return h.kind==="line"?h.start.clone():h.arc.startPoint.clone()}function Ee(h){return h.kind==="line"?h.end.clone():h.arc.endPoint.clone()}function Fn(h,t,n,e){return h.kind==="line"&&t.kind==="line"?{point:tn({start:h.start,end:h.end,dx:h.dx,dy:h.dy},{start:t.start,end:t.end,dx:t.dx,dy:t.dy})}:h.kind==="line"&&t.kind==="arc"?On(h,t.arc,n,e,!0):h.kind==="arc"&&t.kind==="line"?On(t,h.arc,n,e,!1):h.kind==="arc"&&t.kind==="arc"?Ie(h.arc,t.arc,n,e):{point:n.clone()}}function Ie(h,t,n,e){const s=Yn(h.endPoint,t.startPoint),r=Ne(h,t).filter(l=>zt(h,l)&&zt(t,l));if(r.length>0)return{point:Dn(r,s)};const o=h.endPoint.clone(),a=t.startPoint.clone(),c=Xn(n,Math.abs(e),o,a);return{point:o,filletPoints:c,nextSegmentStart:a}}function On(h,t,n,e,s){const i=Yn(s?h.end:h.start,s?t.startPoint:t.endPoint),r=ke(h,t,i);if(Be(h,r)&&zt(t,r))return{point:r};const o=Te(h,n,e),a=s?t.startPoint.clone():t.endPoint.clone(),c=Xn(n,Math.abs(e),s?o:a,s?a:o);return s?{point:o,filletPoints:c,nextSegmentStart:a}:{point:a,filletPoints:c,nextSegmentStart:o}}function Te(h,t,n){const e=Math.hypot(h.dx,h.dy),s=-h.dy/e*n,i=h.dx/e*n;return new P(t.x+s,t.y+i)}function Be(h,t){const n=Math.hypot(h.dx,h.dy);if(B.isNonPositive(n))return!1;const e=h.dx/n,s=h.dy/n,i=t.x-h.start.x,r=t.y-h.start.y,o=Math.abs(i*s-r*e);return B.equalToZero(o)}function Xn(h,t,n,e){const s=Math.atan2(n.y-h.y,n.x-h.x),i=Math.atan2(e.y-h.y,e.x-h.x),r=Re(s,i);if(B.equalToZero(Math.abs(r)))return[];const o=[],a=Math.max(2,Math.ceil(Math.abs(r)/Math.PI*16));for(let c=1;c<a;c++){const l=c/a,u=s+r*l;o.push(new P(h.x+t*Math.cos(u),h.y+t*Math.sin(u)))}return o}function Re(h,t){let n=t-h;for(;n>Math.PI;)n-=I;for(;n<=-Math.PI;)n+=I;return n}function ke(h,t,n){const e=Math.hypot(h.dx,h.dy);if(B.isNonPositive(e))return n.clone();const s=h.dx/e,i=h.dy/e,r=h.start.x-t.center.x,o=h.start.y-t.center.y,a=2*(r*s+o*i),c=r*r+o*o-t.radius*t.radius,l=a*a-4*c;if(l<0)return n.clone();const u=Math.sqrt(l),d=[(-a-u)/2,(-a+u)/2].map(g=>new P(h.start.x+s*g,h.start.y+i*g)),m=d.filter(g=>zt(t,g));return Dn(m.length>0?m:d,n)}function zt(h,t){const n=Math.abs(Math.hypot(t.x-h.center.x,t.y-h.center.y)-h.radius);if(B.isPositive(n))return!1;const e=Jt(h,t),s=h.clockwise?Ht(w.normalizeAngle(h.startAngle)):w.normalizeAngle(h.startAngle),i=h.clockwise?Ht(w.normalizeAngle(h.endAngle)):w.normalizeAngle(h.endAngle);return w.isBetweenAngle(e,s,i,h.clockwise)}function Ne(h,t){const n=t.center.x-h.center.x,e=t.center.y-h.center.y,s=Math.hypot(n,e);if(B.isNonPositive(s))return[];const i=h.radius+t.radius,r=Math.abs(h.radius-t.radius);if(s>i+Mt)return[];if(s<r-Mt)return[];const o=(h.radius*h.radius-t.radius*t.radius+s*s)/(2*s),a=h.radius*h.radius-o*o;if(a<-Mt)return[];const c=h.center.x+o*n/s,l=h.center.y+o*e/s;if(a<=Mt)return[new P(c,l)];const u=Math.sqrt(a),d=-e*u/s,m=n*u/s;return[new P(c+d,l+m),new P(c-d,l-m)]}function Dn(h,t){let n=h[0],e=n.distanceToSquared(t);for(let s=1;s<h.length;s++){const i=h[s].distanceToSquared(t);i<e&&(n=h[s],e=i)}return n.clone()}function Yn(h,t){return new P((h.x+t.x)/2,(h.y+t.y)/2)}function je(h){const t=h.numberOfVertices,n=h.closed?t:t-1;for(let e=0;e<n;e++){const s=h.vertices[e];if(B.isPositive(Math.abs(s.bulge??0)))return!0}return!1}function Zn(h){const t=qe(h.vertices.map(n=>new P(n.x,n.y)),h.closed);return t.length===h.numberOfVertices?h:new nt(t.map(n=>({x:n.x,y:n.y})),h.closed)}function qe(h,t){const n=Gn(h);if(!t||n.length<2)return n;const e=n[0],s=n[n.length-1];return B.isNonPositive(Math.hypot(e.x-s.x,e.y-s.y))&&n.pop(),n}function Gn(h){const t=[];return h.forEach(n=>{const e=t[t.length-1];(!e||B.isPositive(Math.hypot(e.x-n.x,e.y-n.y)))&&t.push(new P(n.x,n.y))}),t}function Ve(h,t){const n=[];for(let r=0;r<h.numberOfVertices;r++)n.push(h.getPointAt(r));const e=Le(n,h.closed,t);if(e.length===0)return null;const s=[];if(h.closed){if(e.length<2)return null;const r=e.length;for(let o=0;o<r;o++){const a=e[(o-1+r)%r],c=e[o];s.push(tn(a,c))}}else{s.push(e[0].start);for(let r=1;r<e.length;r++)s.push(tn(e[r-1],e[r]));s.push(e[e.length-1].end)}const i=new nt;return s.forEach((r,o)=>{i.addVertexAt(o,{x:r.x,y:r.y})}),i.closed=h.closed,i}function Le(h,t,n){const e=[],s=t?h.length:h.length-1;for(let i=0;i<s;i++){const r=h[i],o=h[t?(i+1)%h.length:i+1],a=o.x-r.x,c=o.y-r.y,l=Math.hypot(a,c);if(B.isNonPositive(l))continue;const u=-c/l*n,d=a/l*n;e.push({start:new P(r.x+u,r.y+d),end:new P(o.x+u,o.y+d),dx:a,dy:c})}return e}function tn(h,t){const n=h.dx*t.dy-h.dy*t.dx;if(B.equalToZero(n))return new P((h.end.x+t.start.x)/2,(h.end.y+t.start.y)/2);const e=t.start.x-h.start.x,s=t.start.y-h.start.y,i=(e*t.dy-s*t.dx)/n;return new P(h.start.x+i*h.dx,h.start.y+i*h.dy)}class nt extends ht{constructor(t=null,n=!1){super(),this._vertices=t||new Array,this._closed=n}get vertices(){return this._vertices}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new P(t.x,t.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const t=this.numberOfVertices;if(t>0)if(this.closed){const n=this._vertices[0];return new P(n.x,n.y)}else{const n=this._vertices[t-1];return new P(n.x,n.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let t=0;const n=this._vertices.length;for(let e=0;e<n;++e){const s=this._vertices[e];let i=null;if(e<n-1?i=this._vertices[e+1]:e==n-1&&this.closed&&(i=this._vertices[0]),i)if(s.bulge){const r=new G(s,i,s.bulge);t+=r.length}else t+=new P(s.x,s.y).distanceTo(i)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,n){t<=0?this._vertices.unshift(n):this._vertices.splice(t,0,n),this._boundingBoxNeedsUpdate=!0}removeVertexAt(t){if(t<0||t>=this._vertices.length)throw new Error(`Index ${t} is out of bounds. Valid range is 0 to ${this._vertices.length-1}.`);this._vertices.splice(t,1),this._boundingBoxNeedsUpdate=!0}reset(t,n){t?n!==void 0&&n>=0&&n<this._vertices.length&&(this._vertices=this._vertices.slice(0,n),this._boundingBoxNeedsUpdate=!0):(this._vertices=new Array,this._boundingBoxNeedsUpdate=!0)}getPointAt(t){const n=this._vertices[t];return new P(n.x,n.y)}calculateBoundingBox(){const t=this.getPoints(100);return new O().setFromPoints(t)}transform(t){const n=t.determinant()<0;return this._vertices.forEach(e=>{const s=new P(e).applyMatrix2d(t);e.x=s.x,e.y=s.y,n&&e.bulge!=null&&(e.bulge=-e.bulge)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new nt(this._vertices.map(t=>({...t})),this._closed)}getPoints3d(t,n){const e=[];return this.getPoints(t).forEach(i=>e.push(new M().set(i.x,i.y,n))),e}getPoints(t){const n=[],e=this._vertices.length;for(let s=0;s<e;++s){const i=this._vertices[s];if(i.bulge){let r=null;if(s<e-1?r=this._vertices[s+1]:s==e-1&&this.closed&&(r=this._vertices[0]),r){const a=new G(i,r,i.bulge).getPoints(t),c=a.length;for(let l=0;l<c;++l){const u=a[l];n.push(new P(u.x,u.y))}}}else n.push(new P(i.x,i.y)),s==e-1&&this.closed&&n.push(n[0])}return n}offset(t){return Un(this,t)}}function ve(h,t,n){const e=Math.hypot(t.x,t.y);if(B.isNonPositive(e))return null;const s=-t.y/e*n,i=t.x/e*n;return new M(h.x+s,h.y+i,h.z)}function Ue(h,t,n){if(h.length<2)return null;const e=ge(new nt(h.map(i=>({x:i.x,y:i.y})),t));return Un(e,n)[0]??null}function Fe(h,t,n,e){if(h.length<2||B.equalToZero(n))return null;const{points:s,tangents:i}=Kn(h,e);if(s.length<2)return null;const r=i??Oe(s,t),o=Xe(s,r,n),a=t?Ye(o):De(o);if(a.length<2)return null;const c=new nt;return a.forEach((l,u)=>{c.addVertexAt(u,{x:l.x,y:l.y})}),c.closed=t,c}function Oe(h,t){const n=h.length,e=new Array(n);for(let s=0;s<n;s++){let i=0,r=0;if(t){const a=h[(s-1+n)%n],c=h[(s+1)%n];i=c.x-a.x,r=c.y-a.y}else s===0?(i=h[1].x-h[0].x,r=h[1].y-h[0].y):s===n-1?(i=h[n-1].x-h[n-2].x,r=h[n-1].y-h[n-2].y):(i=h[s+1].x-h[s-1].x,r=h[s+1].y-h[s-1].y);const o=Math.hypot(i,r);B.isNonPositive(o)?e[s]=new P(1,0):e[s]=new P(i/o,r/o)}return e}function Xe(h,t,n){return h.map((e,s)=>{const i=t[s],r=-i.y*n,o=i.x*n;return new P(e.x+r,e.y+o)})}function De(h){let t=bt(h);if(t.length<3)return t;for(;;){const n=Qn(t,!1);if(!n||(t=bt([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<2))break}return t}function Ye(h){let t=bt(h);if(t.length<4)return t;for(;;){const n=Qn(t,!0);if(!n||(t=bt([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<3))break}return t}function Qn(h,t){const n=t?h.length:h.length-1;if(n<2)return null;for(let e=0;e<n;e++){const s=h[e],i=h[(e+1)%h.length];for(let r=e+1;r<n;r++){if(Ze(e,r,n,t))continue;const o=h[r],a=h[(r+1)%h.length],c=Ge(s,i,o,a);if(c)return{point:c,segmentA:e,segmentB:r}}}return null}function Ze(h,t,n,e){return!!(t===h||t===h+1||e&&h===0&&t===n-1)}function Ge(h,t,n,e){const s=t.x-h.x,i=t.y-h.y,r=e.x-n.x,o=e.y-n.y,a=s*o-i*r;if(B.equalToZero(a))return null;const c=n.x-h.x,l=n.y-h.y,u=(c*o-l*r)/a,d=(c*i-l*s)/a,m=pt.equalPointTol;return u<-m||u>1+m||d<-m||d>1+m?null:new P(h.x+u*s,h.y+u*i)}function Kn(h,t){const n=[],e=[],s=t!=null&&t.length===h.length;return h.forEach((i,r)=>{const o=n[n.length-1];if((!o||B.isPositive(Math.hypot(o.x-i.x,o.y-i.y)))&&(n.push(new P(i.x,i.y)),s)){const a=t[r];e.push(new P(a.x,a.y))}}),{points:n,tangents:s?e:void 0}}function bt(h){return Kn(h).points}class nn extends $t{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new O}transform(t){return this._loops.forEach(n=>{n.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){const t=new nn;return this._loops.forEach(n=>{t.add(n.clone())}),t}getPoints(t){const n=[];for(let e=0;e<this.loops.length;++e){const i=this.loops[e].getPoints(t);n.push(i)}return n}buildHierarchy(){var o;const t=this.getPoints(100),n=this.calculateBoundaryBoxes(t),e=this.sortBoundaryBoxesByAreas(n),s=new Map,i=e.length;for(let a=0;a<i;a++)s.set(e[a],{index:e[a],children:[]});const r={index:-1,children:[]};for(let a=0;a<i;a++){const c=e[a],l=t[c],u=n[c];let d=a+1;for(;d<i;d++){const m=e[d],g=t[m];if(n[m].containsBox(u)&&Tn.isPointInPolygon(l[w.randInt(0,l.length-1)],g)){(o=s.get(m))==null||o.children.push(s.get(c));break}}d===i&&r.children.push(s.get(c))}return r}get area(){if(this._loops.length===0)return 0;let t=0;for(let n=0;n<this._loops.length;n++){const s=this._loops[n].getPoints(128),i=this.polygonArea(s);n===0?t+=Math.abs(i):t-=Math.abs(i)}return t}polygonArea(t){const n=t.length;if(n<3)return 0;let e=0;for(let s=0,i=n-1;s<n;i=s++){const r=t[i],o=t[s];e+=r.x*o.y-o.x*r.y}return e*.5}calculateBoundaryBoxes(t){const n=[];return t.forEach(e=>{n.push(new O().setFromPoints(e))}),n}sortBoundaryBoxesByAreas(t){const n=[];t.forEach((s,i)=>{const r=s.size,o=r.width*r.height;n.push({area:o,index:i})}),n.sort((s,i)=>s.area-i.area);const e=[];return n.forEach(s=>{e.push(s.index)}),e}}class Qe extends vn{translate(t){return this.transform(new W().makeTranslation(t.x,t.y,t.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class yt extends Qe{}class at extends yt{constructor(t,n){super(),this._start=new M(t),this._end=new M(n)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}get direction(){return new f().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new M((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}nearestPoint(t){return this.project(t)}get length(){return this.startPoint.distanceTo(this.endPoint)}isPointOnLine(t){return this.project(t).distanceTo(t)<1e-6}at(t,n){return this.delta(n).multiplyScalar(t).add(this._start)}atLength(t,n=!1){if(n){const e=this.delta(st).normalize();return new M(this._start).addScaledVector(e,t)}else{const e=this.delta(st).normalize();return new M(this._end).addScaledVector(e,t)}}extend(t,n=!1){if(n){const e=st.subVectors(this._start,this._end).normalize();this._start=new M(this._start).addScaledVector(e,t)}else{const e=this.delta(st).normalize();this._end=new M(this._end).addScaledVector(e,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,n){Wn.subVectors(t,this._start),St.subVectors(this.endPoint,this.startPoint);const e=St.dot(St);let i=St.dot(Wn)/e;return n&&(i=w.clamp(i,0,1)),i}closestPointToPoint(t,n,e){const s=this.closestPointToPointParameter(t,n);return this.delta(e).multiplyScalar(s).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const n=this.direction,s=st.subVectors(t,this.startPoint).dot(n);return new M().copy(n).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const n=this.direction,e=this.startPoint,i=st.subVectors(t,e).dot(n),r=st.copy(n).multiplyScalar(i);return new M().addVectors(e,r)}calculateBoundingBox(){const t=new M(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),n=new M(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y),Math.max(this._start.z,this._end.z));return new Z(t,n)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new at(this._start.clone(),this._end.clone())}offset(t){const n=this.startPoint,e=this.endPoint;if(Math.hypot(e.x-n.x,e.y-n.y)===0)return this.clone();const i=new f(e.x-n.x,e.y-n.y,0).normalize(),r=new f(-i.y,i.x,0);return new at(new M(n.x+r.x*t,n.y+r.y*t,n.z),new M(e.x+r.x*t,e.y+r.y*t,e.z))}}const st=new f,Wn=new f,St=new f;class ct extends yt{static computeCenterPoint(t,n,e){const s=new f().addVectors(t,n).multiplyScalar(.5),i=new f().addVectors(t,e).multiplyScalar(.5),r=new f().subVectors(n,t),o=new f().subVectors(e,t),a=new f().crossVectors(r,o).normalize();if(a.lengthSq()===0)return null;const c=new f().crossVectors(r,a).normalize(),l=new f().crossVectors(o,a).normalize(),u=c.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),d=l.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),m=new at(s,s.clone().add(u)),g=new at(i,i.clone().add(d)),y=new f;return m.closestPointToPoint(g.startPoint,!0,y)?y:null}static createByThreePoints(t,n,e){const s=ct.computeCenterPoint(t,n,e);if(s){const i=s.distanceTo(t),r=new f().subVectors(t,s),o=new f().subVectors(n,s),a=Math.atan2(r.y,r.x),c=Math.atan2(o.y,o.x);return new ct(s,i,a,c,f.Z_AXIS)}}constructor(t,n,e,s,i,r=f.X_AXIS){super(),this.center=t,this.radius=n,this.startAngle=e,this.endAngle=s,this.normal=i,this.refVec=r,(s-e)%I==0?(this.startAngle=0,this.endAngle=I):(this.startAngle=e,this.endAngle=s)}get center(){return this._center}set center(t){this._center=new M(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==I?t:w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return w.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new f(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new f(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,n=this.deltaAngle;this.closed&&(t=0,n=I);const e=t+n*.5;return this.getPointAtAngle(e)}get length(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)}get area(){return this.closed?Math.PI*this.radius*this.radius:Math.abs(this.deltaAngle*this.radius*this.radius)}nearestPoint(t){const n=new f(t.x,t.y,t.z||0),e=this.center,s=this.normal,r=n.clone().sub(e).dot(s),a=n.clone().sub(s.clone().multiplyScalar(r)).clone().sub(e);if(a.lengthSq()===0)return this.startPoint.clone();a.normalize().multiplyScalar(this.radius);const c=e.clone().add(a),l=this.getAngle(c.clone()),u=this.startAngle,d=this.deltaAngle;let m=w.normalizeAngle(l-u);m<0&&(m=0),m>d&&(m=d);const g=this.getPointAtAngle(u+m),y=g.distanceTo(n),x=this.startPoint.distanceTo(n),_=this.endPoint.distanceTo(n);return x<y&&x<=_?this.startPoint.clone():_<y&&_<x?this.endPoint.clone():g}tangentPoints(t){const n=[],e=new f(t.x,t.y,t.z||0),s=this.center,i=this.normal,r=this.radius,a=e.clone().sub(s).dot(i),c=e.clone().sub(i.clone().multiplyScalar(a)),l=s.clone(),d=c.clone().sub(l).length();if(d<r)return n;const m=Math.acos(r/d),g=this.getAngle(c.clone()),y=[g+m,g-m];for(const x of y){const _=w.normalizeAngle(x-this.startAngle);_>=0&&_<=this.deltaAngle&&n.push(this.getPointAtAngle(this.startAngle+_))}return n}perpendicularPoints(t){const n=[],e=new f(t.x,t.y,t.z||0),s=this.center,i=this.normal,r=this.radius,a=e.clone().sub(s).dot(i),l=e.clone().sub(i.clone().multiplyScalar(a)).clone().sub(s);if(l.lengthSq()<1e-24)return n;l.normalize();const u=[s.clone().add(l.clone().multiplyScalar(r)),s.clone().sub(l.clone().multiplyScalar(r))];for(const d of u){const m=this.getAngle(d.clone()),g=w.normalizeAngle(m-this.startAngle);g>=0&&g<=this.deltaAngle&&n.push(new M(d.x,d.y,d.z||0))}return n}nearestTangentPoint(t){const n=this.tangentPoints(t);if(n.length===0)return null;const e=new M(t.x,t.y,t.z||0);return n.length===1||n[0].distanceTo(e)<n[1].distanceTo(e)?n[0]:n[1]}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let a=0;a<2*Math.PI;a+=Math.PI/2)w.isBetweenAngle(a,this.startAngle,this.endAngle)&&t.push(a);let n=1/0,e=1/0,s=1/0,i=-1/0,r=-1/0,o=-1/0;for(const a of t){const c=this.getPointAtAngle(a);c.x<n&&(n=c.x),c.y<e&&(e=c.y),c.z<s&&(s=c.z),c.x>i&&(i=c.x),c.y>r&&(r=c.y),c.z>o&&(o=c.z)}return new Z({x:n,y:e,z:s},{x:i,y:r,z:o})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const n=[];let e=this.deltaAngle,s=this.startAngle;this.closed&&(e=I,s=0);for(let i=0;i<=t;i++){const r=s+e*(i/t),o=this.getPointAtAngle(r);n.push(o)}return n}transform(t){const n=this.center.clone().applyMatrix4(t),e=this.startPoint.clone().applyMatrix4(t),s=this.endPoint.clone().applyMatrix4(t),i=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(t),r=new f(e).sub(n).normalize(),o=n.distanceTo(e);let a=new f().crossVectors(new f(e).sub(n),new f(i).sub(n)).normalize();a.lengthSq()===0&&(a=this.normal.clone().transformDirection(t));const c=l=>{const u=new f(l).sub(n);return Math.atan2(u.dot($n.crossVectors(a,r)),u.dot(r))};return this.center=n,this.radius=o,this.normal=a,this.refVec=r,this.startAngle=0,this.endAngle=this.closed?I:c(s),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new ct(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot($n.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const n=this.normal,e=this.refVec,s={x:n.y*e.z-n.z*e.y,y:n.z*e.x-n.x*e.z,z:n.x*e.y-n.y*e.x},i=this.center,r=this.radius;return new M(i.x+r*(e.x*Math.cos(t)+s.x*Math.sin(t)),i.y+r*(e.y*Math.cos(t)+s.y*Math.sin(t)),i.z+r*(e.z*Math.cos(t)+s.z*Math.sin(t)))}get plane(){const t=new f(this.center).distanceTo(Ft);return new mt(this.normal,t)}offset(t){const n=this.radius+t;return n<=0?null:new ct(this.center,n,this.startAngle,this.endAngle,this.normal,this.refVec)}}const $n=new f;class it extends ht{constructor(t,n,e,s=0,i=I,r=!1,o=0){super(),this.center=t,this.majorAxisRadius=n,this.minorAxisRadius=e,(i-s)%I==0?(this.startAngle=0,this.endAngle=I):(this.startAngle=s,this.endAngle=i),this.clockwise=r,this.rotation=o}get center(){return this._center}set center(t){this._center=new M(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==I?t:w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return w.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let n=1/0,e=1/0,s=-1/0,i=-1/0;for(let r=0;r<=100;r++){const o=this.getPoint(r/100);n=Math.min(n,o.x),e=Math.min(e,o.y),s=Math.max(s,o.x),i=Math.max(i,o.y)}return new O({x:n,y:e},{x:s,y:i})}get closed(){return this.deltaAngle==0}getPoint(t){const n=Math.PI*2;let e=this.endAngle-this.startAngle;const s=Math.abs(e)<Number.EPSILON;for(;e<0;)e+=n;for(;e>n;)e-=n;e<Number.EPSILON&&(s?e=0:e=n),this.clockwise===!0&&!s&&(e===n?e=-n:e=e-n);const i=this.startAngle+t*e;let r=this.center.x+this.majorAxisRadius*Math.cos(i),o=this.center.y+this.minorAxisRadius*Math.sin(i);if(this.rotation!==0){const a=Math.cos(this.rotation),c=Math.sin(this.rotation),l=r-this.center.x,u=o-this.center.y;r=l*a-u*c+this.center.x,o=l*c+u*a+this.center.y}return new P(r,o)}transform(t){const n=t,e=new P(this.center).applyMatrix2d(n),s=new M(e.x,e.y,this.center.z),i=this.getPointAtAngle(0).clone().applyMatrix2d(n),r=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(n),o=new P(i).sub(e),a=new P(r).sub(e),c=o.length(),l=a.length(),u=Math.atan2(o.y,o.x),d=o.clone().normalize(),m=a.clone().normalize(),g=_=>{const b=new P(_).sub(e),p=b.dot(d),C=b.dot(m);return w.normalizeAngle(Math.atan2(C/l,p/c))},y=n.determinant()<0?!this.clockwise:this.clockwise,x=this.closed?new it(s,c,l,0,I,y,u):new it(s,c,l,g(this.startPoint.clone().applyMatrix2d(n)),g(this.endPoint.clone().applyMatrix2d(n)),y,u);return this.center=x.center,this.majorAxisRadius=x.majorAxisRadius,this.minorAxisRadius=x.minorAxisRadius,this._startAngle=x._startAngle,this._endAngle=x._endAngle,this._clockwise=x._clockwise,this.rotation=x.rotation,this._boundingBoxNeedsUpdate=!0,this}getPointAtAngle(t){return this.getPoint(this.closed?t/I:w.normalizeAngle(t-this.startAngle)/this.deltaAngle)}copy(t){return this.center=t.center,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}clone(){return new it(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}getFocusPoints(){const t=Math.max(this.majorAxisRadius,this.minorAxisRadius),n=Math.min(this.majorAxisRadius,this.minorAxisRadius);if(t-n<1e-9)return[];const e=Math.sqrt(t*t-n*n),s=Math.cos(this.rotation),i=Math.sin(this.rotation),r=this.majorAxisRadius>=this.minorAxisRadius,o=r?s:-i,a=r?i:s;return[new P(this.center.x-e*o,this.center.y-e*a),new P(this.center.x+e*o,this.center.y+e*a)]}getQuadrantPoints(){return this.closed?[this.getPoint(0),this.getPoint(.25),this.getPoint(.5),this.getPoint(.75)]:[]}nearestPoint(t){const n=new P(t.x,t.y);let e=this.getPoint(0),s=n.distanceToSquared(e);const i=72;for(let r=1;r<=i;r++){const o=this.getPoint(r/i),a=n.distanceToSquared(o);a<s&&(s=a,e=o)}return e}tangentPoints(t){const n=this._projectPointToLocal(t);return this._findSnapAngles(n,(s,i,r,o)=>{const a=-this.majorAxisRadius*o,c=this.minorAxisRadius*r;return(s-n.x)*c-(i-n.y)*a}).map(s=>this.getPointAtAngle(s))}perpendicularPoints(t){const n=this._projectPointToLocal(t);return this._findSnapAngles(n,(s,i,r,o)=>{const a=this.minorAxisRadius*r,c=this.majorAxisRadius*o;return(s-n.x)*c-(i-n.y)*a}).map(s=>this.getPointAtAngle(s))}_projectPointToLocal(t){const n=t.x-this.center.x,e=t.y-this.center.y,s=Math.cos(-this.rotation),i=Math.sin(-this.rotation);return{x:n*s-e*i,y:n*i+e*s}}_findSnapAngles(t,n,e=144){const s=this.majorAxisRadius,i=this.minorAxisRadius,r=this.startAngle,o=this.deltaAngle,a=[],c=d=>{const m=Math.cos(d),g=Math.sin(d);return n(s*m,i*g,m,g)};let l=r,u=c(l);for(let d=1;d<=e;d++){const m=r+o*d/e,g=c(m);if(Math.abs(u)<1e-10&&a.push(l),u*g<0){let y=l,x=m;for(let _=0;_<32;_++){const b=(y+x)/2;c(y)*c(b)<=0?x=b:y=b}a.push((y+x)/2)}l=m,u=g}return a}}class lt extends yt{constructor(t,n,e,s,i,r=0,o=I){super(),this.center=t,this.normal=n,this.majorAxis=e,this.majorAxisRadius=s,this.minorAxisRadius=i;const a=Math.abs(o-r);Math.abs(a-I)<1e-10||Math.abs(a-2*I)<1e-10?(this.startAngle=0,this.endAngle=I):(this.startAngle=r,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new M(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==I?t:w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-I)<1e-10?I:w.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new f(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new f(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new f().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,n=this.deltaAngle;(this.closed||Math.abs(n-I)<1e-10)&&(t=0,n=I);const e=t+n/2;return this.getPointAtAngle(e)}get isCircular(){return B.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const t=1e3,n=this.deltaAngle/t;let e=0,s=this.getPointAtAngle(this.startAngle);for(let i=1;i<=t;i++){const r=this.startAngle+i*n,o=this.getPointAtAngle(r),a=o.x-s.x,c=o.y-s.y,l=o.z-s.z;e+=Math.sqrt(a*a+c*c+l*l),s=o}return e}get area(){const t=this.majorAxisRadius,n=this.minorAxisRadius,e=this.startAngle,s=e+this.deltaAngle;if(Math.abs(this.deltaAngle-I)<1e-10)return Math.PI*t*n;const i=t*n/2*(s-e-(Math.sin(s)*Math.cos(s)-Math.sin(e)*Math.cos(e)));return Math.abs(i)}calculateBoundingBox(){if(this.majorAxis.equals(f.X_AXIS)||this.majorAxis.equals(f.Y_AXIS)||this.majorAxis.isParallelTo(f.X_AXIS)||this.majorAxis.isParallelTo(f.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let a=0;a<2*Math.PI;a+=Math.PI/2)w.isBetweenAngle(a,this.startAngle,this.endAngle)&&t.push(a);let n=1/0,e=1/0,s=1/0,i=-1/0,r=-1/0,o=-1/0;for(const a of t){const c=this.getPointAtAngle(a);c.x<n&&(n=c.x),c.y<e&&(e=c.y),c.z<s&&(s=c.z),c.x>i&&(i=c.x),c.y>r&&(r=c.y),c.z>o&&(o=c.z)}return new Z({x:n,y:e,z:s},{x:i,y:r,z:o})}else{let n=1/0,e=1/0,s=1/0,i=-1/0,r=-1/0,o=-1/0;for(let a=0;a<=100;a++){const c=this.startAngle+this.deltaAngle*(a/100),l=this.getPointAtAngle(c);n=Math.min(n,l.x),e=Math.min(e,l.y),s=Math.min(s,l.z),i=Math.max(i,l.x),r=Math.max(r,l.y),o=Math.max(o,l.z)}return new Z({x:n,y:e,z:s},{x:i,y:r,z:o})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const n=[];let e=this.deltaAngle,s=this.startAngle;this.closed&&(e=I,s=0);for(let i=0;i<=t;i++){const r=s+e*(i/t),o=this.getPointAtAngle(r);n.push(o)}return n}getPointAtAngle(t){const n=Math.cos(t),e=Math.sin(t),s=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(e),i=this.majorAxis.clone().multiplyScalar(n*this.majorAxisRadius).add(s);return new M(this.center.x+i.x,this.center.y+i.y,this.center.z+i.z)}nearestPoint(t,n=72){const e=new M(t.x,t.y,t.z||0);let s=this.getPointAtAngle(this.startAngle),i=e.distanceToSquared(s);for(let a=1;a<=n;a++){const c=this.startAngle+this.deltaAngle*a/n,l=this.getPointAtAngle(c),u=e.distanceToSquared(l);u<i&&(i=u,s=l)}const r=e.distanceToSquared(this.startPoint),o=e.distanceToSquared(this.endPoint);return r<i&&r<=o?this.startPoint.clone():o<i&&o<r?this.endPoint.clone():s.clone()}tangentPoints(t){const n=this._projectPointToLocalPlane(t);return this._findSnapParameterAngles((s,i,r,o)=>{const a=-this.majorAxisRadius*o,c=this.minorAxisRadius*r;return(s-n.x)*c-(i-n.y)*a}).map(s=>this.getPointAtAngle(s))}perpendicularPoints(t){const n=this._projectPointToLocalPlane(t);return this._findSnapParameterAngles((s,i,r,o)=>{const a=this.minorAxisRadius*r,c=this.majorAxisRadius*o;return(s-n.x)*c-(i-n.y)*a}).map(s=>this.getPointAtAngle(s))}_projectPointToLocalPlane(t){const n=new M(t.x,t.y,t.z||0),e=new f(n).sub(this.center),s=e.dot(this.normal);return e.sub(this.normal.clone().multiplyScalar(s)),{x:e.dot(this.majorAxis),y:e.dot(this.minorAxis)}}_findSnapParameterAngles(t,n=144){const e=this.majorAxisRadius,s=this.minorAxisRadius,i=this.startAngle,r=this.deltaAngle,o=[],a=u=>{const d=Math.cos(u),m=Math.sin(u);return t(e*d,s*m,d,m)};let c=i,l=a(c);for(let u=1;u<=n;u++){const d=i+r*u/n,m=a(d);if(Math.abs(l)<1e-10&&o.push(c),l*m<0){let g=c,y=d;for(let x=0;x<32;x++){const _=(g+y)/2;a(g)*a(_)<=0?y=_:g=_}o.push((g+y)/2)}c=d,l=m}return o}contains(t){const n=new f(t).sub(this.center),e=n.dot(this.majorAxis),s=n.dot(this.minorAxis),i=e/this.majorAxisRadius,r=s/this.minorAxisRadius;return i*i+r*r<=1}transform(t){const n=t,e=this.center.clone().applyMatrix4(n),s=this.getPointAtAngle(0).clone().applyMatrix4(n),i=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(n),r=new f(s).sub(e),o=new f(i).sub(e),a=r.length(),c=o.length(),l=r.clone().normalize(),u=new f().crossVectors(r,o).normalize();let d=new f().crossVectors(u,l).normalize();d.dot(o)<0&&(u.negate(),d=new f().crossVectors(u,l).normalize());const m=y=>{const x=new f(y).sub(e),_=x.dot(l),b=x.dot(d);return w.normalizeAngle(Math.atan2(b/c,_/a))},g=this.closed?new lt(e,u,l,a,c,0,I):new lt(e,u,l,a,c,m(this.startPoint.clone().applyMatrix4(n)),m(this.endPoint.clone().applyMatrix4(n)));return this.center=g.center,this.normal=g.normal,this.majorAxis=g.majorAxis,this.majorAxisRadius=g.majorAxisRadius,this.minorAxisRadius=g.minorAxisRadius,this._startAngle=g._startAngle,this._endAngle=g._endAngle,this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new lt(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new f(this.center).distanceTo(Ft);return new mt(this.normal,t)}offset(t){const n=this.majorAxisRadius+t,e=this.minorAxisRadius+t;return n<=0||e<=0?null:new lt(this.center,this.normal,this.majorAxis,n,e,this.startAngle,this.endAngle)}}class xt extends ht{constructor(t,n){super(),this._start=new P(t),this._end=new P(n)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const t=new P(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),n=new P(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new O(t,n)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new xt(this._start.clone(),this._end.clone())}project(t){const n=this._end.x-this._start.x,e=this._end.y-this._start.y,s=n*n+e*e;if(s<1e-18)return this._start.clone();let i=((t.x-this._start.x)*n+(t.y-this._start.y)*e)/s;return i=Math.max(0,Math.min(1,i)),new P(this._start.x+i*n,this._start.y+i*e)}nearestPoint(t){return this.project(t)}}class X extends ht{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}static buildFromEdges(t,n=.001){if(t.length===0)return[];const e=[...t],s=[],i=n*n,r=(o,a)=>{const c=o.x-a.x,l=o.y-a.y;return c*c+l*l<=i};for(;e.length>0;){const o=[],a=e.shift();o.push(a);const c=X.getEdgeStartPoint(a);let l=X.getEdgeEndPoint(a);if(!r(c,l))for(;e.length>0;){const u=X.findConnectingEdge(e,l,i);if(u.index<0)break;let d=e.splice(u.index,1)[0];if(u.reverse&&(d=X.reverseEdge(d)),o.push(d),l=X.getEdgeEndPoint(d),r(l,c))break}s.push(new X(o))}return s}add(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const t=this._curves[0].startPoint;return new P(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let t=0;return this._curves.forEach(n=>{t+=n.length}),t}calculateBoundingBox(){const t=this.getPoints(100),n=new O;return n.setFromPoints(t),n}transform(t){const n=new W().set(t.elements[0],t.elements[3],0,t.elements[6],t.elements[1],t.elements[4],0,t.elements[7],0,0,1,0,0,0,0,1);return this._curves.forEach(e=>{e instanceof et?e.transform(n):e.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new X(this._curves.map(t=>t.clone()))}get closed(){return!0}getPoints(t){const n=[];return this.curves.forEach(e=>{e.getPoints(t).forEach(s=>{n.push(new P(s.x,s.y))})}),n}static findConnectingEdge(t,n,e){let s=-1,i=!1,r=Number.POSITIVE_INFINITY;for(let o=0;o<t.length;o++){const a=t[o],c=X.getEdgeStartPoint(a),l=X.getEdgeEndPoint(a),u=n.x-c.x,d=n.y-c.y,m=u*u+d*d;m<r&&(r=m,s=o,i=!1);const g=n.x-l.x,y=n.y-l.y,x=g*g+y*y;x<r&&(r=x,s=o,i=!0)}return r>e?{index:-1,reverse:!1}:{index:s,reverse:i}}static getEdgeStartPoint(t){const n=t.startPoint;return new P(n.x,n.y)}static getEdgeEndPoint(t){const n=t.endPoint;return new P(n.x,n.y)}static reverseEdge(t){return t instanceof xt?new xt(t.endPoint,t.startPoint):t instanceof G?new G(t.center,t.radius,t.endAngle,t.startAngle,!t.clockwise):t instanceof it?new it(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof et?X.reverseSplineEdge(t):t}static reverseSplineEdge(t){const n=[...t.controlPoints].reverse(),e=t.knots,s=e[0],i=e[e.length-1],r=e.map(c=>s+i-c).reverse(),o=t.weights,a=o.length>0?[...o].reverse():void 0;return new et(n,r,a,t.degree,t.closed)}}class en{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,n,e,s){this.c0=t,this.c1=e,this.c2=-3*t+3*n-2*e-s,this.c3=2*t-2*n+e+s}initCatmullRom(t,n,e,s,i){this.init(n,e,i*(e-t),i*(s-n))}initNonuniformCatmullRom(t,n,e,s,i,r,o){let a=(n-t)/i-(e-t)/(i+r)+(e-n)/r,c=(e-n)/r-(s-n)/(r+o)+(s-e)/o;a*=r,c*=r,this.init(n,e,a,c)}calc(t){const n=t*t,e=n*t;return this.c0+this.c1*t+this.c2*n+this.c3*e}}class Ct extends yt{constructor(t=[],n=!1,e="centripetal",s=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new f,this._px=new en,this._py=new en,this._pz=new en,this._points=t.map(i=>new M(i)),this._closed=n,this._curveType=e,this._tension=s}get points(){return this._points}get closed(){return this._closed}get curveType(){return this._curveType}get tension(){return this._tension}get startPoint(){return this._points.length>0?this._points[0]:new M}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new M}get length(){if(this._points.length<2)return 0;let t=0;for(let n=1;n<this._points.length;n++)t+=this._points[n-1].distanceTo(this._points[n]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,n=new M){const e=n,s=this._points,i=s.length;if(i===0)return e.set(0,0,0);if(i===1)return e.copy(s[0]);const r=(i-(this._closed?0:1))*t;let o=Math.floor(r),a=r-o;this._closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:a===0&&o===i-1&&(o=i-2,a=1);let c,l;this._closed||o>0?c=s[(o-1)%i]:(this._tmp.subVectors(s[0],s[1]).add(s[0]),c=new M(this._tmp.x,this._tmp.y,this._tmp.z));const u=s[o%i],d=s[(o+1)%i];if(this._closed||o+2<i?l=s[(o+2)%i]:(this._tmp.subVectors(s[i-1],s[i-2]).add(s[i-1]),l=new M(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const m=this._curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(u),m),y=Math.pow(u.distanceToSquared(d),m),x=Math.pow(d.distanceToSquared(l),m);y<1e-4&&(y=1),g<1e-4&&(g=y),x<1e-4&&(x=y),this._px.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,g,y,x),this._py.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,g,y,x),this._pz.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,g,y,x)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(c.x,u.x,d.x,l.x,this._tension),this._py.initCatmullRom(c.y,u.y,d.y,l.y,this._tension),this._pz.initCatmullRom(c.z,u.z,d.z,l.z,this._tension));return e.set(this._px.calc(a),this._py.calc(a),this._pz.calc(a)),e}getPoints(t){const n=[];for(let e=0;e<=t;e++)n.push(this.getPoint(e/t));return n}setPoints(t){this._points=t.map(n=>new M(n)),this._boundingBoxNeedsUpdate=!0}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)}setCurveType(t){this._curveType=t}setTension(t){this._tension=t}clone(){return new Ct(this._points.map(t=>t.clone()),this._closed,this._curveType,this._tension)}transform(t){return this._points=this._points.map(n=>{const e=new M;return e.copy(n),e.applyMatrix4(t),e}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Z;const t=new Z;return this._points.forEach(n=>{t.expandByPoint(n)}),t}}function Jn(h,t){const n=h.x-t[0],e=h.y-t[1],s=(h.z??0)-(t[2]??0);return n*n+e*e+s*s}class v{constructor(t,n,e,s){this._degree=t,this._knots=[...n],this._controlPoints=e.map(i=>({x:i.x,y:i.y,z:i.z})),this._weights=s?[...s]:new Array(e.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z}))}weights(){return[...this._weights]}clone(){return new v(this._degree,this._knots,this._controlPoints,this._weights)}point(t){return this.evaluate(t).point}evaluate(t){const n=this._controlPoints.map(e=>[e.x,e.y,e.z]);return kn(t,this._degree,this._knots,n,this._weights)}signedPlanarCurvatureAt(t){const n=this.evaluate(t);return Nn(n.deriv1,n.deriv2)}getOffsetSamplePath2d(t,n=512){const e=Math.abs(t),{start:s,end:i}=this.getParameterRange(),r=this.length(),o=Math.max(64,Math.ceil(r/Math.max(e*.2,1e-6)));let a=Ke(s,i,Math.min(o,n));for(let u=0;u<8&&a.length<n;u++){const d=[];for(let m=0;m<a.length-1;m++){const g=a[m],y=a[m+1],x=(g+y)/2,_=Math.max(Math.abs(this.signedPlanarCurvatureAt(g)),Math.abs(this.signedPlanarCurvatureAt(y)),Math.abs(this.signedPlanarCurvatureAt(x)));e*_>.85&&d.push(x)}if(d.length===0)break;if(a=We(a,d),a.length>n){a=a.slice(0,n);break}}const c=[],l=[];return a.forEach(u=>{const d=this.evaluate(u);c.push(new P(d.point[0],d.point[1]));const m=d.deriv1[0],g=d.deriv1[1],y=Math.hypot(m,g);l.push(y>1e-10?new P(m/y,g/y):new P(1,0))}),{points:c,tangents:l}}length(){const t=this._controlPoints.map(n=>[n.x,n.y,n.z]);return jn(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,n,e,s){return new v(t,n,e,s)}static byPoints(t,n,e="Uniform",s,i){const r=Gt(t,n,e,s,i),o=r.controlPoints.map(a=>({x:a[0],y:a[1],z:a[2]}));return new v(n,r.knots,o,r.weights)}getParameterRange(){const t=this._knots[this._degree],n=this._knots[this._knots.length-this._degree-1];return{start:t,end:n}}getPoints(t){const n=[],{start:e,end:s}=this.getParameterRange();for(let i=0;i<=t;i++){const r=e+(s-e)*(i/t);n.push(this.point(r))}return n}isClosed(t=1e-6){const{start:n,end:e}=this.getParameterRange(),s=this.point(n),i=this.point(e),r=s[0]-i[0],o=s[1]-i[1],a=s[2]-i[2];return Math.sqrt(r*r+o*o+a*a)<t}static createFitPointsForClosedCurve(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const n=new Ct(t,!0,"centripetal"),e=Math.max(50,t.length*2);return n.getPoints(e)}nearestPoint(t,n=64){const{start:e,end:s}=this.getParameterRange();let i=this.point(e),r=Jn(t,i);for(let o=0;o<=n;o++){const a=e+(s-e)*o/n,c=this.point(a),l=Jn(t,c);l<r&&(r=l,i=c)}return{x:i[0],y:i[1],z:i[2]??0}}static createClosedCurve(t,n,e="Chord"){const i=this.createFitPointsForClosedCurve(t).map(r=>[r.x,r.y,r.z]);return v.byPoints(i,n,e)}}function Ke(h,t,n){if(n<2)return[h,t];const e=[];for(let s=0;s<n;s++)e.push(s===n-1?t:h+(t-h)*s/(n-1));return e}function We(h,t){const n=[...h,...t].sort((s,i)=>s-i),e=[];return n.forEach(s=>{const i=e[e.length-1];(i===void 0||Math.abs(i-s)>1e-10)&&e.push(s)}),e}class et extends yt{constructor(t,n,e,s,i,r){super();const o=arguments.length;if(this._degree=3,this._closed=!1,Array.isArray(n)){if(o<2||o>5)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._controlPoints=t;let a,c=3,l=!1;if(o>=3&&(Array.isArray(e)?(a=e,o>=4&&(c=s||3),o>=5&&(l=i)):e!==void 0&&(c=e||3,o>=4&&(l=s))),e===void 0&&o>=4&&(c=s||3,o>=5&&(l=i)),this._degree=c,this._closed=l,this._controlPoints.length<this._degree+1)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._nurbsCurve=v.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,a)}else{if(o<2||o>6)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._fitPoints=t,this._knotParameterization=n,o>=3&&(this._degree=e||3);const a=typeof s=="boolean";o>=4&&a&&(this._closed=s),a?(o>=5&&(this._startTangent=i),o>=6&&(this._endTangent=r)):(o>=4&&(this._startTangent=s),o>=5&&(this._endTangent=i)),this._closed&&(this._startTangent=void 0,this._endTangent=void 0);const c=(this._startTangent?1:0)+(this._endTangent?1:0);if(this._fitPoints.length+c<this._degree+1)throw V.AcCmErrors.ILLEGAL_PARAMETERS;if(this._closed)this._nurbsCurve=v.createClosedCurve(this._fitPoints,this._degree,this._knotParameterization);else{const l=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=v.byPoints(l,this._degree,this._knotParameterization,this._startTangent?this.toNurbsPoint(this._startTangent):void 0,this._endTangent?this.toNurbsPoint(this._endTangent):void 0)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(l=>[l.x,l.y,l.z||0]))}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=v.createFitPointsForClosedCurve(this._fitPoints),n=this.toNurbsPoints(t);this._nurbsCurve=v.byPoints(n,this._degree,this._knotParameterization)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=v.byPoints(t,this._degree,this._knotParameterization,this._startTangent?this.toNurbsPoint(this._startTangent):void 0,this._endTangent?this.toNurbsPoint(this._endTangent):void 0)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(t=>[t.x,t.y,t.z||0]))}else if(this._controlPoints)if(this._closed){const t=v.createFitPointsForClosedCurve(this._controlPoints),n=this.toNurbsPoints(t);this._nurbsCurve=v.byPoints(n,this._degree,this._knotParameterization),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(e=>[e.x,e.y,e.z||0]))}else{const t=this._nurbsCurve.knots(),n=this._nurbsCurve.weights();this._nurbsCurve=v.byKnotsControlPointsWeights(this._degree,t,this._controlPoints,n)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z||0}))}get fitPoints(){var t;return(t=this._fitPoints)==null?void 0:t.map(n=>({x:n.x,y:n.y,z:n.z||0}))}get knots(){return[...this._nurbsCurve.knots()]}get weights(){return[...this._nurbsCurve.weights()]}get startPoint(){const t=this._nurbsCurve.knots(),n=this._nurbsCurve.degree(),e=t[n],s=this._nurbsCurve.point(e);return new M(s[0],s[1],s[2])}get endPoint(){const t=this._nurbsCurve.knots(),n=this._nurbsCurve.degree(),e=t[t.length-n-1],s=this._nurbsCurve.point(e);return new M(s[0],s[1],s[2])}get length(){return this._nurbsCurve.length()}nearestPoint(t,n=64){const e=this._nurbsCurve.nearestPoint(t,n);return new M(e.x,e.y,e.z||0)}evaluateAt(t){const n=this._nurbsCurve.point(t);return new M(n[0],n[1],n[2])}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const n=this._fitPoints.length,e=t<0||t>=n?n-1:t,s=this._fitPoints[e];return{x:s.x,y:s.y,z:s.z||0}}getControlPointAt(t){const n=this._controlPoints.length,e=t<0||t>=n?n-1:t;return this._controlPoints[e]}getOffsetSamplePath2d(t){return this._nurbsCurve.getOffsetSamplePath2d(t)}getPoints(t=100){const n=this._nurbsCurve,e=[],s=n.knots(),i=this._nurbsCurve.degree(),r=s[i],o=s[s.length-i-1],a=(o-r)/(t-1);for(let c=0;c<t;c++){const l=c===t-1?o:r+c*a,u=n.point(l);e.push(new M(u[0],u[1],u[2]))}return e}getCurvePoints(t,n){const e=[],s=t.knots(),i=t.degree(),r=s[i],a=(s[s.length-i-1]-r)/(n-1);for(let c=0;c<n;c++){const l=r+c*a;e.push(t.point(l))}return e}calculateBoundingBox(){const t=this.getPoints(100);return new Z().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(n=>new M(n).applyMatrix4(t)),this._startTangent&&(this._startTangent=new M(this._startTangent).transformDirection(t)),this._endTangent&&(this._endTangent=new M(this._endTangent).transformDirection(t)),this.buildCurve();else{const n=this._nurbsCurve.knots(),e=this._nurbsCurve.weights();this._controlPoints=this._controlPoints.map(s=>new M(s).applyMatrix4(t)),this._nurbsCurve=v.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,e.length>0?e:void 0)}return this._boundingBoxNeedsUpdate=!0,this}clone(){return this._fitPoints&&this._knotParameterization?new et(this._fitPoints.map(t=>({x:t.x,y:t.y,z:t.z||0})),this._knotParameterization,this._degree,this._closed,this._startTangent?{x:this._startTangent.x,y:this._startTangent.y,z:this._startTangent.z||0}:void 0,this._endTangent?{x:this._endTangent.x,y:this._endTangent.y,z:this._endTangent.z||0}:void 0):new et(this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z||0})),this._nurbsCurve.knots(),this._nurbsCurve.weights(),this._degree,this._closed)}toNurbsPoints(t){const n=new Array(t.length);return t.forEach((e,s)=>{n[s]=[e.x,e.y,e.z||0]}),n}toGePoints(t){const n=new Array(t.length);return t.forEach((e,s)=>{n[s]={x:e[0],y:e[1],z:e[2]}}),n}toNurbsPoint(t){return[t.x,t.y,t.z||0]}static createClosedSpline(t,n="Uniform",e=3){if(t.length<e+1)throw new Error(`At least ${e+1} points are required for a degree ${e} closed spline`);return new et(t,n,e,!0)}}A.AcGeArea2d=nn,A.AcGeBox2d=O,A.AcGeBox3d=Z,A.AcGeCatmullRomCurve3d=Ct,A.AcGeCircArc2d=G,A.AcGeCircArc3d=ct,A.AcGeCurve2d=ht,A.AcGeEllipseArc2d=it,A.AcGeEllipseArc3d=lt,A.AcGeEuler=Dt,A.AcGeGeometryUtil=Tn,A.AcGeLine2d=xt,A.AcGeLine3d=at,A.AcGeLoop2d=X,A.AcGeMathUtil=w,A.AcGeMatrix2d=rt,A.AcGeMatrix3d=W,A.AcGeNurbsCurve=v,A.AcGePlane=mt,A.AcGePoint2d=P,A.AcGePoint3d=M,A.AcGePolyline2d=nt,A.AcGeQuaternion=dt,A.AcGeShape2d=$t,A.AcGeSpline3d=et,A.AcGeTol=B,A.AcGeVector2d=R,A.AcGeVector3d=f,A.DEFAULT_TOL=pt,A.DEG2RAD=jt,A.FLOAT_TOL=K,A.ORIGIN_POINT_2D=Hn,A.ORIGIN_POINT_3D=Ft,A.RAD2DEG=qt,A.TAU=I,A.basisFunction=tt,A.calculateCurveLength=jn,A.ceilPowerOfTwo=An,A.clamp=Q,A.computeParameterValues=Bn,A.damp=an,A.degToRad=xn,A.euclideanModulo=Vt,A.evaluateNurbsDerivatives=kn,A.evaluateNurbsPoint=gt,A.floorPowerOfTwo=Pn,A.generateAveragedKnots=Rn,A.generateChordKnots=re,A.generateSqrtChordKnots=oe,A.generateUUID=rn,A.generateUniformKnots=ie,A.getOcsAngle=me,A.getOcsReferenceVector=ue,A.intPartLength=vt,A.interpolateControlPoints=ae,A.interpolateNurbsCurve=Gt,A.inverseLerp=hn,A.isBetween=pn,A.isBetweenAngle=wn,A.isPointInPolygon=Yt,A.isPolygonIntersect=In,A.isPowerOfTwo=fn,A.lerp=Lt,A.mapLinear=on,A.normalizeAngle=ut,A.offsetPointByDirectionInXY=ve,A.offsetSmoothedSampledPath=Fe,A.offsetVertexPath=Ue,A.pingpong=cn,A.radToDeg=_n,A.randFloat=mn,A.randFloatSpread=gn,A.randInt=dn,A.relativeEps=Mn,A.seededRandom=yn,A.signedPlanarCurvature=Nn,A.smootherstep=un,A.smoothstep=ln,A.transformOcsPointToWcs=de,A.transformWcsPointToOcs=Wt,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
1
+ (function(f,V){typeof exports=="object"&&typeof module<"u"?V(exports,require("@mlightcad/common")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/common"],V):(f=typeof globalThis<"u"?globalThis:f||self,V(f["geometry-engine"]={},f.common))})(this,function(f,V){"use strict";const L=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let rn=1234567;const jt=Math.PI/180,qt=180/Math.PI;function on(){const o=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,e=Math.random()*4294967295|0;return(L[o&255]+L[o>>8&255]+L[o>>16&255]+L[o>>24&255]+"-"+L[t&255]+L[t>>8&255]+"-"+L[t>>16&15|64]+L[t>>24&255]+"-"+L[n&63|128]+L[n>>8&255]+"-"+L[n>>16&255]+L[n>>24&255]+L[e&255]+L[e>>8&255]+L[e>>16&255]+L[e>>24&255]).toLowerCase()}function Q(o,t,n){return Math.max(t,Math.min(n,o))}function Vt(o,t){return(o%t+t)%t}function hn(o,t,n,e,s){return e+(o-t)*(s-e)/(n-t)}function an(o,t,n){return o!==t?(n-o)/(t-o):0}function Lt(o,t,n){return(1-n)*o+n*t}function cn(o,t,n,e){return Lt(o,t,1-Math.exp(-n*e))}function ln(o,t=1){return t-Math.abs(Vt(o,t*2)-t)}function un(o,t,n){return o<=t?0:o>=n?1:(o=(o-t)/(n-t),o*o*(3-2*o))}function dn(o,t,n){return o<=t?0:o>=n?1:(o=(o-t)/(n-t),o*o*o*(o*(o*6-15)+10))}function mn(o,t){return o+Math.floor(Math.random()*(t-o+1))}function gn(o,t){return o+Math.random()*(t-o)}function yn(o){return o*(.5-Math.random())}function xn(o){o!==void 0&&(rn=o);let t=rn+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function _n(o){return o*jt}function fn(o){return o*qt}function An(o){return(o&o-1)===0&&o!==0}function Pn(o){return Math.pow(2,Math.ceil(Math.log(o)/Math.LN2))}function pn(o){return Math.pow(2,Math.floor(Math.log(o)/Math.LN2))}function ut(o){const t=Math.PI*2;return(o%t+t)%t}function wn(o,t,n){return o>t&&o<n||o>n&&o<t}function Mn(o,t,n,e=!1){return o=ut(o),t=ut(t),n=ut(n),e?t>n?o<=t&&o>=n:o<=t||o>=n:t<n?o>=t&&o<=n:o>=t||o<=n}function vt(o){return o=Math.abs(o),o<1?0:Math.ceil(Math.log10(Math.abs(o)+1))}function zn(o,t=1e-7){const n=vt(o);return Math.max(Math.pow(10,n)*t,t)}const w={DEG2RAD:jt,RAD2DEG:qt,generateUUID:on,clamp:Q,euclideanModulo:Vt,mapLinear:hn,inverseLerp:an,lerp:Lt,damp:cn,pingpong:ln,smoothstep:un,smootherstep:dn,randInt:mn,randFloat:gn,randFloatSpread:yn,seededRandom:xn,degToRad:_n,radToDeg:fn,isPowerOfTwo:An,ceilPowerOfTwo:Pn,floorPowerOfTwo:pn,normalizeAngle:ut,isBetween:wn,isBetweenAngle:Mn,intPartLength:vt,relativeEps:zn},_t=class _t{constructor(t,n){this.x=0,this.y=0;const e=+(t!==void 0)+ +(n!==void 0);if(e!==0){if(e===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(e===1){const{x:s,y:i}=t;this.x=s,this.y=i;return}if(e===2){this.x=t,this.y=n;return}throw V.AcCmErrors.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,n){return this.x=t,this.y=n,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new _t(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const n=this.x,e=this.y,s=t.elements;return this.x=s[0]*n+s[3]*e+s[6],this.y=s[1]*n+s[4]*e+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this}clampScalar(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this}clampLength(t,n){const e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(n,e)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const n=Math.sqrt(this.lengthSq()*t.lengthSq());if(n===0)return Math.PI/2;const e=this.dot(t)/n;return Math.acos(Math.max(-1,Math.min(1,e)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const n=this.x-t.x,e=this.y-t.y;return n*n+e*e}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this}lerpVectors(t,n,e){return this.x=t.x+(n.x-t.x)*e,this.y=t.y+(n.y-t.y)*e,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t}rotateAround(t,n){const e=Math.cos(n),s=Math.sin(n),i=this.x-t.x,r=this.y-t.y;return this.x=i*e-r*s+t.x,this.y=i*s+r*e+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(w.relativeEps(this.x,t),w.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};_t.EMPTY=Object.freeze(new _t(0,0));let R=_t;const ft=class ft{constructor(t,n,e,s,i,r,h,a,c){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&n!=null&&e!=null&&s!=null&&i!=null&&r!=null&&h!=null&&a!=null&&c!=null&&this.set(t,n,e,s,i,r,h,a,c)}set(t,n,e,s,i,r,h,a,c){const l=this.elements;return l[0]=t,l[1]=s,l[2]=h,l[3]=n,l[4]=i,l[5]=a,l[6]=e,l[7]=r,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const n=this.elements,e=t.elements;return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],this}extractBasis(t,n,e){return t.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),e.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const n=t.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const e=t.elements,s=n.elements,i=this.elements,r=e[0],h=e[3],a=e[6],c=e[1],l=e[4],u=e[7],d=e[2],m=e[5],g=e[8],y=s[0],x=s[3],_=s[6],b=s[1],p=s[4],C=s[7],S=s[2],T=s[5],z=s[8];return i[0]=r*y+h*b+a*S,i[3]=r*x+h*p+a*T,i[6]=r*_+h*C+a*z,i[1]=c*y+l*b+u*S,i[4]=c*x+l*p+u*T,i[7]=c*_+l*C+u*z,i[2]=d*y+m*b+g*S,i[5]=d*x+m*p+g*T,i[8]=d*_+m*C+g*z,this}multiplyScalar(t){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=t,n[4]*=t,n[7]*=t,n[2]*=t,n[5]*=t,n[8]*=t,this}determinant(){const t=this.elements,n=t[0],e=t[1],s=t[2],i=t[3],r=t[4],h=t[5],a=t[6],c=t[7],l=t[8];return n*r*l-n*h*c-e*i*l+e*h*a+s*i*c-s*r*a}invert(){const t=this.elements,n=t[0],e=t[1],s=t[2],i=t[3],r=t[4],h=t[5],a=t[6],c=t[7],l=t[8],u=l*r-h*c,d=h*a-l*i,m=c*i-r*a,g=n*u+e*d+s*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/g;return t[0]=u*y,t[1]=(s*c-l*e)*y,t[2]=(h*e-s*r)*y,t[3]=d*y,t[4]=(l*n-s*a)*y,t[5]=(s*i-h*n)*y,t[6]=m*y,t[7]=(e*a-c*n)*y,t[8]=(r*n-e*i)*y,this}transpose(){let t;const n=this.elements;return t=n[1],n[1]=n[3],n[3]=t,t=n[2],n[2]=n[6],n[6]=t,t=n[5],n[5]=n[7],n[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const n=this.elements;return t.elements[0]=n[0],t.elements[1]=n[3],t.elements[2]=n[6],t.elements[3]=n[1],t.elements[4]=n[4],t.elements[5]=n[7],t.elements[6]=n[2],t.elements[7]=n[5],t.elements[8]=n[8],this}setUvTransform(t,n,e,s,i,r,h){const a=Math.cos(i),c=Math.sin(i);return this.set(e*a,e*c,-e*(a*r+c*h)+r+t,-s*c,s*a,-s*(-c*r+a*h)+h+n,0,0,1),this}scale(t,n){return this.premultiply(Ut.makeScale(t,n)),this}rotate(t){return this.premultiply(Ut.makeRotation(-t)),this}translate(t,n){return this.premultiply(Ut.makeTranslation(t,n)),this}makeTranslation(t,n){return t instanceof R?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,n,0,0,1),this}makeRotation(t){const n=Math.cos(t),e=Math.sin(t);return this.set(n,-e,0,e,n,0,0,0,1),this}makeScale(t,n){return this.set(t,0,0,0,n,0,0,0,1),this}equals(t){const n=this.elements,e=t.elements;for(let s=0;s<9;s++)if(n[s]!==e[s])return!1;return!0}fromArray(t,n=0){for(let e=0;e<9;e++)this.elements[e]=t[e+n];return this}toArray(t=[],n=0){const e=this.elements;return t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3],t[n+4]=e[4],t[n+5]=e[5],t[n+6]=e[6],t[n+7]=e[7],t[n+8]=e[8],t}clone(){return new ft().fromArray(this.elements)}};ft.IDENTITY=Object.freeze(new ft);let rt=ft;const Ut=new rt,K=1e-6,I=2*Math.PI,ie={x:0,y:0},Ft={x:0,y:0,z:0};class B{constructor(){this.equalPointTol=K,this.equalVectorTol=K}clone(){const t=new B;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t}equalPoint2d(t,n){return new R(t).sub(n).length()<this.equalPointTol}equalPoint3d(t,n){return new A(t).sub(n).length()<this.equalPointTol}static equalToZero(t,n=K){return t<n&&t>-n}static equal(t,n,e=K){return Math.abs(t-n)<e}static great(t,n,e=K){return t-n>e}static less(t,n,e=K){return t-n<e}static isPositive(t,n=K){return t>n}static isNonPositive(t,n=K){return t<=n}}const pt=new B;class dt{constructor(t=0,n=0,e=0,s=1){this._x=t,this._y=n,this._z=e,this._w=s}static slerpFlat(t,n,e,s,i,r,h){let a=e[s+0],c=e[s+1],l=e[s+2],u=e[s+3];const d=i[r+0],m=i[r+1],g=i[r+2],y=i[r+3];if(h===0){t[n+0]=a,t[n+1]=c,t[n+2]=l,t[n+3]=u;return}if(h===1){t[n+0]=d,t[n+1]=m,t[n+2]=g,t[n+3]=y;return}if(u!==y||a!==d||c!==m||l!==g){let x=1-h;const _=a*d+c*m+l*g+u*y,b=_>=0?1:-1,p=1-_*_;if(p>Number.EPSILON){const S=Math.sqrt(p),T=Math.atan2(S,_*b);x=Math.sin(x*T)/S,h=Math.sin(h*T)/S}const C=h*b;if(a=a*x+d*C,c=c*x+m*C,l=l*x+g*C,u=u*x+y*C,x===1-h){const S=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=S,c*=S,l*=S,u*=S}}t[n]=a,t[n+1]=c,t[n+2]=l,t[n+3]=u}static multiplyQuaternionsFlat(t,n,e,s,i,r){const h=e[s],a=e[s+1],c=e[s+2],l=e[s+3],u=i[r],d=i[r+1],m=i[r+2],g=i[r+3];return t[n]=h*g+l*u+a*m-c*d,t[n+1]=a*g+l*d+c*u-h*m,t[n+2]=c*g+l*m+h*d-a*u,t[n+3]=l*g-h*u-a*d-c*m,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,n,e,s){return this._x=t,this._y=n,this._z=e,this._w=s,this._onChangeCallback(),this}clone(){return new dt(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,n=!0){const e=t.x,s=t.y,i=t.z,r=t.order,h=Math.cos,a=Math.sin,c=h(e/2),l=h(s/2),u=h(i/2),d=a(e/2),m=a(s/2),g=a(i/2);switch(r){case"XYZ":this._x=d*l*u+c*m*g,this._y=c*m*u-d*l*g,this._z=c*l*g+d*m*u,this._w=c*l*u-d*m*g;break;case"YXZ":this._x=d*l*u+c*m*g,this._y=c*m*u-d*l*g,this._z=c*l*g-d*m*u,this._w=c*l*u+d*m*g;break;case"ZXY":this._x=d*l*u-c*m*g,this._y=c*m*u+d*l*g,this._z=c*l*g+d*m*u,this._w=c*l*u-d*m*g;break;case"ZYX":this._x=d*l*u-c*m*g,this._y=c*m*u+d*l*g,this._z=c*l*g-d*m*u,this._w=c*l*u+d*m*g;break;case"YZX":this._x=d*l*u+c*m*g,this._y=c*m*u+d*l*g,this._z=c*l*g-d*m*u,this._w=c*l*u-d*m*g;break;case"XZY":this._x=d*l*u-c*m*g,this._y=c*m*u-d*l*g,this._z=c*l*g+d*m*u,this._w=c*l*u+d*m*g;break}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,n){const e=n/2,s=Math.sin(e);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(t){const n=t.elements,e=n[0],s=n[4],i=n[8],r=n[1],h=n[5],a=n[9],c=n[2],l=n[6],u=n[10],d=e+h+u;if(d>0){const m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(l-a)*m,this._y=(i-c)*m,this._z=(r-s)*m}else if(e>h&&e>u){const m=2*Math.sqrt(1+e-h-u);this._w=(l-a)/m,this._x=.25*m,this._y=(s+r)/m,this._z=(i+c)/m}else if(h>u){const m=2*Math.sqrt(1+h-e-u);this._w=(i-c)/m,this._x=(s+r)/m,this._y=.25*m,this._z=(a+l)/m}else{const m=2*Math.sqrt(1+u-e-h);this._w=(r-s)/m,this._x=(i+c)/m,this._y=(a+l)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(t,n){let e=t.dot(n)+1;return e<Number.EPSILON?(e=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=e):(this._x=0,this._y=-t.z,this._z=t.y,this._w=e)):(this._x=t.y*n.z-t.z*n.y,this._y=t.z*n.x-t.x*n.z,this._z=t.x*n.y-t.y*n.x,this._w=e),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Q(this.dot(t),-1,1)))}rotateTowards(t,n){const e=this.angleTo(t);if(e===0)return this;const s=Math.min(1,n/e);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,n){const e=t._x,s=t._y,i=t._z,r=t._w,h=n._x,a=n._y,c=n._z,l=n._w;return this._x=e*l+r*h+s*c-i*a,this._y=s*l+r*a+i*h-e*c,this._z=i*l+r*c+e*a-s*h,this._w=r*l-e*h-s*a-i*c,this._onChangeCallback(),this}slerp(t,n){if(n===0)return this;if(n===1)return this.copy(t);const e=this._x,s=this._y,i=this._z,r=this._w;let h=r*t._w+e*t._x+s*t._y+i*t._z;if(h<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,h=-h):this.copy(t),h>=1)return this._w=r,this._x=e,this._y=s,this._z=i,this;const a=1-h*h;if(a<=Number.EPSILON){const m=1-n;return this._w=m*r+n*this._w,this._x=m*e+n*this._x,this._y=m*s+n*this._y,this._z=m*i+n*this._z,this.normalize(),this}const c=Math.sqrt(a),l=Math.atan2(c,h),u=Math.sin((1-n)*l)/c,d=Math.sin(n*l)/c;return this._w=r*u+this._w*d,this._x=e*u+this._x*d,this._y=s*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,n,e){return this.copy(t).slerp(n,e)}random(){const t=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),e=Math.random(),s=Math.sqrt(1-e),i=Math.sqrt(e);return this.set(s*Math.sin(t),s*Math.cos(t),i*Math.sin(n),i*Math.cos(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,n=0){return this._x=t[n],this._y=t[n+1],this._z=t[n+2],this._w=t[n+3],this._onChangeCallback(),this}toArray(t=[],n=0){return t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const j=class j{constructor(t,n,e){this.x=0,this.y=0,this.z=0;const s=+(t!==void 0)+ +(n!==void 0)+ +(e!==void 0);if(s!==0){if(s===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(s===1){const{x:i,y:r,z:h}=t;this.x=i,this.y=r,this.z=h||0;return}if(s===3){this.x=t,this.y=n,this.z=e;return}throw V.AcCmErrors.ILLEGAL_PARAMETERS}}set(t,n,e){return e===void 0&&(e=this.z),this.x=t,this.y=n,this.z=e,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new j(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,n){return this.x=t.x*n.x,this.y=t.y*n.y,this.z=t.z*n.z,this}applyEuler(t){return this.applyQuaternion(bn.setFromEuler(t))}applyAxisAngle(t,n){return this.applyQuaternion(bn.setFromAxisAngle(t,n))}applyMatrix3(t){const n=this.x,e=this.y,s=this.z,i=t.elements;return this.x=i[0]*n+i[3]*e+i[6]*s,this.y=i[1]*n+i[4]*e+i[7]*s,this.z=i[2]*n+i[5]*e+i[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const n=this.x,e=this.y,s=this.z,i=t.elements,r=1/(i[3]*n+i[7]*e+i[11]*s+i[15]);return this.x=(i[0]*n+i[4]*e+i[8]*s+i[12])*r,this.y=(i[1]*n+i[5]*e+i[9]*s+i[13])*r,this.z=(i[2]*n+i[6]*e+i[10]*s+i[14])*r,this}applyQuaternion(t){const n=this.x,e=this.y,s=this.z,i=t.x,r=t.y,h=t.z,a=t.w,c=2*(r*s-h*e),l=2*(h*n-i*s),u=2*(i*e-r*n);return this.x=n+a*c+r*u-h*l,this.y=e+a*l+h*c-i*u,this.z=s+a*u+i*l-r*c,this}transformDirection(t){const n=this.x,e=this.y,s=this.z,i=t.elements;return this.x=i[0]*n+i[4]*e+i[8]*s,this.y=i[1]*n+i[5]*e+i[9]*s,this.z=i[2]*n+i[6]*e+i[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this.z=Math.max(t.z,Math.min(n.z,this.z)),this}clampScalar(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this.z=Math.max(t,Math.min(n,this.z)),this}clampLength(t,n){const e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(n,e)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const n=this.dot(t),e=this.length(),s=t.length();return Math.abs(n)===e*s}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this}lerpVectors(t,n,e){return this.x=t.x+(n.x-t.x)*e,this.y=t.y+(n.y-t.y)*e,this.z=t.z+(n.z-t.z)*e,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,n){const e=t.x,s=t.y,i=t.z,r=n.x,h=n.y,a=n.z;return this.x=s*a-i*h,this.y=i*r-e*a,this.z=e*h-s*r,this}projectOnVector(t){const n=t.lengthSq();if(n===0)return this.set(0,0,0);const e=t.dot(this)/n;return this.copy(t).multiplyScalar(e)}projectOnPlane(t){return Ot.copy(this).projectOnVector(t),this.sub(Ot)}reflect(t){return this.sub(Ot.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const n=Math.sqrt(this.lengthSq()*t.lengthSq());if(n===0)return Math.PI/2;const e=this.dot(t)/n;return Math.acos(Math.max(-1,Math.min(1,e)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const n=this.x-t.x,e=this.y-t.y,s=this.z-t.z;return n*n+e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromMatrixPosition(t){const n=t.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(t){const n=this.setFromMatrixColumn(t,0).length(),e=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=n,this.y=e,this.z=s,this}setFromMatrixColumn(t,n){return this.fromArray(t.elements,n*4)}setFromMatrix3Column(t,n){return this.fromArray(t.elements,n*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this.z=t[n+2],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t[n+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,n=Math.random()*2-1,e=Math.sqrt(1-n*n);return this.x=e*Math.cos(t),this.y=n,this.z=e*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};j.ORIGIN=Object.freeze(new j(0,0,0)),j.X_AXIS=Object.freeze(new j(1,0,0)),j.NEGATIVE_X_AXIS=Object.freeze(new j(-1,0,0)),j.Y_AXIS=Object.freeze(new j(0,1,0)),j.NEGATIVE_Y_AXIS=Object.freeze(new j(0,-1,0)),j.Z_AXIS=Object.freeze(new j(0,0,1)),j.NEGATIVE_Z_AXIS=Object.freeze(new j(0,0,-1));let A=j;const Ot=new A,bn=new dt,At=class At{constructor(t,n,e,s,i,r,h,a,c,l,u,d,m,g,y,x){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&n!=null&&e!=null&&s!=null&&i!=null&&r!=null&&h!=null&&a!=null&&c!=null&&l!=null&&u!=null&&d!=null&&m!=null&&g!=null&&y!=null&&x!=null&&this.set(t,n,e,s,i,r,h,a,c,l,u,d,m,g,y,x)}set(t,n,e,s,i,r,h,a,c,l,u,d,m,g,y,x){const _=this.elements;return _[0]=t,_[4]=n,_[8]=e,_[12]=s,_[1]=i,_[5]=r,_[9]=h,_[13]=a,_[2]=c,_[6]=l,_[10]=u,_[14]=d,_[3]=m,_[7]=g,_[11]=y,_[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new At().fromArray(this.elements)}copy(t){const n=this.elements,e=t.elements;return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],this}copyPosition(t){const n=this.elements,e=t.elements;return n[12]=e[12],n[13]=e[13],n[14]=e[14],this}setFromMatrix3(t){const n=t.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}setFromExtrusionDirection(t){if(pt.equalPoint3d(t,A.Z_AXIS))this.identity();else{const n=new A(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?n.crossVectors(A.Y_AXIS,t).normalize():n.crossVectors(A.Z_AXIS,t).normalize();const e=t.clone().cross(n).normalize();this.set(n.x,n.y,n.z,0,e.x,e.y,e.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,n,e){return t.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),e.setFromMatrixColumn(this,2),this}makeBasis(t,n,e){return this.set(t.x,n.x,e.x,0,t.y,n.y,e.y,0,t.z,n.z,e.z,0,0,0,0,1),this}extractRotation(t){const n=this.elements,e=t.elements,s=1/ot.setFromMatrixColumn(t,0).length(),i=1/ot.setFromMatrixColumn(t,1).length(),r=1/ot.setFromMatrixColumn(t,2).length();return n[0]=e[0]*s,n[1]=e[1]*s,n[2]=e[2]*s,n[3]=0,n[4]=e[4]*i,n[5]=e[5]*i,n[6]=e[6]*i,n[7]=0,n[8]=e[8]*r,n[9]=e[9]*r,n[10]=e[10]*r,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(t){return this.compose(re,t,oe)}lookAt(t,n,e){const s=this.elements;return F.subVectors(t,n),F.lengthSq()===0&&(F.z=1),F.normalize(),H.crossVectors(e,F),H.lengthSq()===0&&(Math.abs(e.z)===1?F.x+=1e-4:F.z+=1e-4,F.normalize(),H.crossVectors(e,F)),H.normalize(),wt.crossVectors(F,H),s[0]=H.x,s[4]=wt.x,s[8]=F.x,s[1]=H.y,s[5]=wt.y,s[9]=F.y,s[2]=H.z,s[6]=wt.z,s[10]=F.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const e=t.elements,s=n.elements,i=this.elements,r=e[0],h=e[4],a=e[8],c=e[12],l=e[1],u=e[5],d=e[9],m=e[13],g=e[2],y=e[6],x=e[10],_=e[14],b=e[3],p=e[7],C=e[11],S=e[15],T=s[0],z=s[4],k=s[8],E=s[12],N=s[1],q=s[5],Y=s[9],J=s[13],U=s[2],Et=s[6],It=s[10],Tt=s[14],Bt=s[3],Rt=s[7],kt=s[11],Nt=s[15];return i[0]=r*T+h*N+a*U+c*Bt,i[4]=r*z+h*q+a*Et+c*Rt,i[8]=r*k+h*Y+a*It+c*kt,i[12]=r*E+h*J+a*Tt+c*Nt,i[1]=l*T+u*N+d*U+m*Bt,i[5]=l*z+u*q+d*Et+m*Rt,i[9]=l*k+u*Y+d*It+m*kt,i[13]=l*E+u*J+d*Tt+m*Nt,i[2]=g*T+y*N+x*U+_*Bt,i[6]=g*z+y*q+x*Et+_*Rt,i[10]=g*k+y*Y+x*It+_*kt,i[14]=g*E+y*J+x*Tt+_*Nt,i[3]=b*T+p*N+C*U+S*Bt,i[7]=b*z+p*q+C*Et+S*Rt,i[11]=b*k+p*Y+C*It+S*kt,i[15]=b*E+p*J+C*Tt+S*Nt,this}multiplyScalar(t){const n=this.elements;return n[0]*=t,n[4]*=t,n[8]*=t,n[12]*=t,n[1]*=t,n[5]*=t,n[9]*=t,n[13]*=t,n[2]*=t,n[6]*=t,n[10]*=t,n[14]*=t,n[3]*=t,n[7]*=t,n[11]*=t,n[15]*=t,this}determinant(){const t=this.elements,n=t[0],e=t[4],s=t[8],i=t[12],r=t[1],h=t[5],a=t[9],c=t[13],l=t[2],u=t[6],d=t[10],m=t[14],g=t[3],y=t[7],x=t[11],_=t[15];return g*(+i*a*u-s*c*u-i*h*d+e*c*d+s*h*m-e*a*m)+y*(+n*a*m-n*c*d+i*r*d-s*r*m+s*c*l-i*a*l)+x*(+n*c*u-n*h*m-i*r*u+e*r*m+i*h*l-e*c*l)+_*(-s*h*l-n*a*u+n*h*d+s*r*u-e*r*d+e*a*l)}transpose(){const t=this.elements;let n;return n=t[1],t[1]=t[4],t[4]=n,n=t[2],t[2]=t[8],t[8]=n,n=t[6],t[6]=t[9],t[9]=n,n=t[3],t[3]=t[12],t[12]=n,n=t[7],t[7]=t[13],t[13]=n,n=t[11],t[11]=t[14],t[14]=n,this}setPosition(t,n,e){const s=this.elements;return t instanceof A?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=n,s[14]=e),this}invert(){const t=this.elements,n=t[0],e=t[1],s=t[2],i=t[3],r=t[4],h=t[5],a=t[6],c=t[7],l=t[8],u=t[9],d=t[10],m=t[11],g=t[12],y=t[13],x=t[14],_=t[15],b=u*x*c-y*d*c+y*a*m-h*x*m-u*a*_+h*d*_,p=g*d*c-l*x*c-g*a*m+r*x*m+l*a*_-r*d*_,C=l*y*c-g*u*c+g*h*m-r*y*m-l*h*_+r*u*_,S=g*u*a-l*y*a-g*h*d+r*y*d+l*h*x-r*u*x,T=n*b+e*p+s*C+i*S;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const z=1/T;return t[0]=b*z,t[1]=(y*d*i-u*x*i-y*s*m+e*x*m+u*s*_-e*d*_)*z,t[2]=(h*x*i-y*a*i+y*s*c-e*x*c-h*s*_+e*a*_)*z,t[3]=(u*a*i-h*d*i-u*s*c+e*d*c+h*s*m-e*a*m)*z,t[4]=p*z,t[5]=(l*x*i-g*d*i+g*s*m-n*x*m-l*s*_+n*d*_)*z,t[6]=(g*a*i-r*x*i-g*s*c+n*x*c+r*s*_-n*a*_)*z,t[7]=(r*d*i-l*a*i+l*s*c-n*d*c-r*s*m+n*a*m)*z,t[8]=C*z,t[9]=(g*u*i-l*y*i-g*e*m+n*y*m+l*e*_-n*u*_)*z,t[10]=(r*y*i-g*h*i+g*e*c-n*y*c-r*e*_+n*h*_)*z,t[11]=(l*h*i-r*u*i-l*e*c+n*u*c+r*e*m-n*h*m)*z,t[12]=S*z,t[13]=(l*y*s-g*u*s+g*e*d-n*y*d-l*e*x+n*u*x)*z,t[14]=(g*h*s-r*y*s-g*e*a+n*y*a+r*e*x-n*h*x)*z,t[15]=(r*u*s-l*h*s+l*e*a-n*u*a-r*e*d+n*h*d)*z,this}scale(t){const n=this.elements,e=t.x,s=t.y,i=t.z;return n[0]*=e,n[4]*=s,n[8]*=i,n[1]*=e,n[5]*=s,n[9]*=i,n[2]*=e,n[6]*=s,n[10]*=i,n[3]*=e,n[7]*=s,n[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,n=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],e=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(n,e,s))}makeTranslation(t,n,e){return t instanceof A?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,n,0,0,1,e,0,0,0,1),this}makeRotationX(t){const n=Math.cos(t),e=Math.sin(t);return this.set(1,0,0,0,0,n,-e,0,0,e,n,0,0,0,0,1),this}makeRotationY(t){const n=Math.cos(t),e=Math.sin(t);return this.set(n,0,e,0,0,1,0,0,-e,0,n,0,0,0,0,1),this}makeRotationZ(t){const n=Math.cos(t),e=Math.sin(t);return this.set(n,-e,0,0,e,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,n){const e=Math.cos(n),s=Math.sin(n),i=1-e,r=t.x,h=t.y,a=t.z,c=i*r,l=i*h;return this.set(c*r+e,c*h-s*a,c*a+s*h,0,c*h+s*a,l*h+e,l*a-s*r,0,c*a-s*h,l*a+s*r,i*a*a+e,0,0,0,0,1),this}makeScale(t,n,e){return this.set(t,0,0,0,0,n,0,0,0,0,e,0,0,0,0,1),this}makeShear(t,n,e,s,i,r){return this.set(1,e,i,0,t,1,r,0,n,s,1,0,0,0,0,1),this}compose(t,n,e){const s=this.elements,i=n.x,r=n.y,h=n.z,a=n.w,c=i+i,l=r+r,u=h+h,d=i*c,m=i*l,g=i*u,y=r*l,x=r*u,_=h*u,b=a*c,p=a*l,C=a*u,S=e.x,T=e.y,z=e.z;return s[0]=(1-(y+_))*S,s[1]=(m+C)*S,s[2]=(g-p)*S,s[3]=0,s[4]=(m-C)*T,s[5]=(1-(d+_))*T,s[6]=(x+b)*T,s[7]=0,s[8]=(g+p)*z,s[9]=(x-b)*z,s[10]=(1-(d+y))*z,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,n,e){const s=this.elements;let i=ot.set(s[0],s[1],s[2]).length();const r=ot.set(s[4],s[5],s[6]).length(),h=ot.set(s[8],s[9],s[10]).length();this.determinant()<0&&(i=-i),t.x=s[12],t.y=s[13],t.z=s[14],D.copy(this);const c=1/i,l=1/r,u=1/h;return D.elements[0]*=c,D.elements[1]*=c,D.elements[2]*=c,D.elements[4]*=l,D.elements[5]*=l,D.elements[6]*=l,D.elements[8]*=u,D.elements[9]*=u,D.elements[10]*=u,n.setFromRotationMatrix(D),e.x=i,e.y=r,e.z=h,this}equals(t){const n=this.elements,e=t.elements;for(let s=0;s<16;s++)if(n[s]!==e[s])return!1;return!0}fromArray(t,n=0){for(let e=0;e<16;e++)this.elements[e]=t[e+n];return this}toArray(t=[],n=0){const e=this.elements;return t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3],t[n+4]=e[4],t[n+5]=e[5],t[n+6]=e[6],t[n+7]=e[7],t[n+8]=e[8],t[n+9]=e[9],t[n+10]=e[10],t[n+11]=e[11],t[n+12]=e[12],t[n+13]=e[13],t[n+14]=e[14],t[n+15]=e[15],t}};At.IDENTITY=Object.freeze(new At);let W=At;const ot=new A,D=new W,re=new A(0,0,0),oe=new A(1,1,1),H=new A,wt=new A,F=new A;class Z{constructor(t=void 0,n=void 0){this.min=t==null?new A(1/0,1/0,1/0):new A(t.x,t.y,t.z),this.max=n==null?new A(-1/0,-1/0,-1/0):new A(n.x,n.y,n.z)}set(t,n){return this.min.copy(t),this.max.copy(n),this}setFromArray(t){this.makeEmpty();for(let n=0,e=t.length;n<e;n+=3)this.expandByPoint(Xt.fromArray(t,n));return this}setFromPoints(t){this.makeEmpty();for(let n=0,e=t.length;n<e;n++)this.expandByPoint(t[n]);return this}setFromCenterAndSize(t,n){const e=Xt.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new Z().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new A(0,0,0):new A(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new A(0,0,0):new A(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,n){return n.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsPlane(t){let n,e;return t.normal.x>0?(n=t.normal.x*this.min.x,e=t.normal.x*this.max.x):(n=t.normal.x*this.max.x,e=t.normal.x*this.min.x),t.normal.y>0?(n+=t.normal.y*this.min.y,e+=t.normal.y*this.max.y):(n+=t.normal.y*this.max.y,e+=t.normal.y*this.min.y),t.normal.z>0?(n+=t.normal.z*this.min.z,e+=t.normal.z*this.max.z):(n+=t.normal.z*this.max.z,e+=t.normal.z*this.min.z),n<=-t.constant&&e>=-t.constant}clampPoint(t,n){return n.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Xt).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:($[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),$[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),$[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),$[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),$[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),$[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),$[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),$[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints($),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const $=[new A,new A,new A,new A,new A,new A,new A,new A],Xt=new A,Sn=new R;class O{constructor(t=void 0,n=void 0){this.min=t==null?new R(1/0,1/0):new R(t.x,t.y),this.max=n==null?new R(-1/0,-1/0):new R(n.x,n.y)}set(t,n){return this.min.copy(t),this.max.copy(n),this}setFromPoints(t){this.makeEmpty();for(let n=0,e=t.length;n<e;n++)this.expandByPoint(t[n]);return this}setFromCenterAndSize(t,n){const e=Sn.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new O().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new R(0,0):new R(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new R(0,0):new R(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,n){return n.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,n){return n.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Sn).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Cn=new A,he=new A,ae=new rt;class mt{constructor(t=new A(1,0,0),n=0){this.normal=t,this.constant=n}set(t,n){return this.normal.copy(t),this.constant=n,this}setComponents(t,n,e,s){return this.normal.set(t,n,e),this.constant=s,this}setFromNormalAndCoplanarPoint(t,n){return this.normal.copy(t),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(t,n,e){const s=Cn.subVectors(e,n).cross(he.subVectors(t,n)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}projectPoint(t,n){return n.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectsBox(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,n){const e=n||ae.getNormalMatrix(t),s=this.coplanarPoint(Cn).applyMatrix4(t),i=this.normal.applyMatrix3(e).normalize();return this.constant=-s.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new mt().copy(this)}}class P extends R{clone(){return new P(this.x,this.y)}static pointArrayToNumberArray(t){const n=new Array(t.length*2);return t.forEach((e,s)=>{e.toArray(n,s*2)}),n}}class M extends A{clone(){return new M(this.x,this.y,this.z)}static pointArrayToNumberArray(t,n=!0){const e=n?3:2,s=new Array(t.length*e);return t.forEach((i,r)=>{i.toArray(s,r*e)}),s}}const En=new W,In=new dt,Pt=class Pt{constructor(t=0,n=0,e=0,s=Pt.DEFAULT_ORDER){this._x=t,this._y=n,this._z=e,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,n,e,s=this._order){return this._x=t,this._y=n,this._z=e,this._order=s,this._onChangeCallback(),this}clone(){return new Pt(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,n=this._order,e=!0){const s=t.elements,i=s[0],r=s[4],h=s[8],a=s[1],c=s[5],l=s[9],u=s[2],d=s[6],m=s[10];switch(n){case"XYZ":this._y=Math.asin(Q(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-l,m),this._z=Math.atan2(-r,i)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Q(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(h,m),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(Q(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,m),this._z=Math.atan2(-r,c)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-Q(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-r,c));break;case"YZX":this._z=Math.asin(Q(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(h,m));break;case"XZY":this._z=Math.asin(-Q(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(h,i)):(this._x=Math.atan2(-l,m),this._y=0);break}return this._order=n,e===!0&&this._onChangeCallback(),this}setFromQuaternion(t,n,e=!0){return En.makeRotationFromQuaternion(t),this.setFromRotationMatrix(En,n,e)}setFromVector3(t,n=this._order){return this.set(t.x,t.y,t.z,n)}reorder(t){return In.setFromEuler(this),this.setFromQuaternion(In,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],n=0){return t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Pt.DEFAULT_ORDER="XYZ";let Dt=Pt;function Yt(o,t,n=!1){const e=o.x,s=o.y;let i=!1;const r=t.length;for(let h=0,a=r-1;h<r;a=h++){const c=t[h].x,l=t[h].y,u=t[a].x,d=t[a].y;let m=l>s!=d>s;n&&(m=l>=s!=d>=s),m&&e<(u-c)*(s-l)/(d-l)+c&&(i=!i)}return i}function Tn(o,t){if(o.length===0||t.length===0)return!1;const n=new O().setFromPoints(o),e=new O().setFromPoints(t);if(!n.intersectsBox(e))return!1;for(let s=0;s<o.length;){if(Yt(o[s],t,!0))return!0;s<o.length-1&&pt.equalPoint2d(o[s+1],o[s])&&++s,++s}return!1}const Bn={isPointInPolygon:Yt,isPolygonIntersect:Tn};function ce(o,t){const n=[],e=t-1,s=o;for(let i=0;i<=s;i++)n.push(0);for(let i=1;i<=e-s;i++)n.push(i);for(let i=0;i<=s;i++)n.push(e-s+1);return n}function le(o,t){const n=t.length-1,e=o,s=[0];let i=0;for(let h=1;h<=n;h++){const a=t[h][0]-t[h-1][0],c=t[h][1]-t[h-1][1],l=t[h][2]-t[h-1][2],u=Math.sqrt(a*a+c*c+l*l);i+=u,s.push(i)}const r=[];for(let h=0;h<=e;h++)r.push(0);for(let h=1;h<=n-e;h++){const a=s[h]/i;r.push(a*(n-e+1))}for(let h=0;h<=e;h++)r.push(n-e+1);return r}function Rn(o,t="Uniform"){const n=o.length;if(n===0)return[];if(n===1)return[0];const e=n-1;if(t==="Uniform")return new Array(n).fill(0).map((r,h)=>h/e);const s=[0];let i=0;for(let r=1;r<=e;r++){const h=o[r][0]-o[r-1][0],a=o[r][1]-o[r-1][1],c=o[r][2]-o[r-1][2],l=Math.sqrt(h*h+a*a+c*c),u=t==="SqrtChord"?Math.sqrt(l):l;i+=u,s.push(i)}return i<1e-12?new Array(n).fill(0).map((r,h)=>h/e):s.map(r=>r/i)}function kn(o,t){const n=t.length-1,e=o,s=n+e+1,i=new Array(s+1).fill(0),r=t[t.length-1];for(let h=s-e;h<=s;h++)i[h]=r;for(let h=1;h<=n-e;h++){let a=0;for(let c=h;c<h+e;c++)a+=t[c];i[h+e]=a/e}return i}function ue(o,t){const n=t.length-1,e=o,s=[0];let i=0;for(let h=1;h<=n;h++){const a=t[h][0]-t[h-1][0],c=t[h][1]-t[h-1][1],l=t[h][2]-t[h-1][2],u=Math.sqrt(a*a+c*c+l*l),d=Math.sqrt(u);i+=d,s.push(i)}const r=[];for(let h=0;h<=e;h++)r.push(0);for(let h=1;h<=n-e;h++){const a=s[h]/i;r.push(a*(n-e+1))}for(let h=0;h<=e;h++)r.push(n-e+1);return r}function Zt(o,t){const n=o.length,e=o.map(r=>r.slice()),s=t.slice();for(let r=0;r<n;r++){let h=r,a=Math.abs(e[r][r]);for(let c=r+1;c<n;c++){const l=Math.abs(e[c][r]);l>a&&(a=l,h=c)}if(a<1e-12)throw new Error("Interpolation matrix is singular.");if(h!==r){const c=e[r];e[r]=e[h],e[h]=c;const l=s[r];s[r]=s[h],s[h]=l}for(let c=r+1;c<n;c++){const l=e[c][r]/e[r][r];if(!(Math.abs(l)<1e-14)){for(let u=r;u<n;u++)e[c][u]-=l*e[r][u];s[c]-=l*s[r]}}}const i=new Array(n).fill(0);for(let r=n-1;r>=0;r--){let h=s[r];for(let a=r+1;a<n;a++)h-=e[r][a]*i[a];i[r]=h/e[r][r]}return i}function Gt(o,t,n="Uniform",e,s){if(o.length===0)return{controlPoints:[],knots:[],weights:[]};const i=o.map(E=>[E[0],E[1],E[2]??0]),r=!!e,h=!!s,a=(r?1:0)+(h?1:0),c=i.length-1,l=c+a;if(l<t)throw new Error("Not enough points to interpolate a curve of this degree.");const u=Rn(i,n),d=u.slice();r&&d.unshift(u[0]),h&&d.push(u[u.length-1]);const m=kn(t,d),g=l+1,y=new Array(g),x=new Array(g),_=new Array(g),b=new Array(g);let p=0;y[p]=new Array(g).fill(0),y[p][0]=1,x[p]=i[0][0],_[p]=i[0][1],b[p]=i[0][2],p++;for(let E=1;E<=c-1;E++){const N=u[E];y[p]=new Array(g).fill(0);for(let q=0;q<=l;q++)y[p][q]=tt(q,t,N,m);x[p]=i[E][0],_[p]=i[E][1],b[p]=i[E][2],p++}if(y[p]=new Array(g).fill(0),y[p][l]=1,x[p]=i[c][0],_[p]=i[c][1],b[p]=i[c][2],p++,r){const E=m[t+1]-m[0],N=E!==0?t/E:0;y[p]=new Array(g).fill(0),y[p][0]=-N,y[p][1]=N,x[p]=(e==null?void 0:e[0])??0,_[p]=(e==null?void 0:e[1])??0,b[p]=(e==null?void 0:e[2])??0,p++}if(h){const E=m[l+t+1]-m[l],N=E!==0?t/E:0;y[p]=new Array(g).fill(0),y[p][l-1]=-N,y[p][l]=N,x[p]=(s==null?void 0:s[0])??0,_[p]=(s==null?void 0:s[1])??0,b[p]=(s==null?void 0:s[2])??0,p++}const C=Zt(y,x),S=Zt(y,_),T=Zt(y,b),z=new Array(g);for(let E=0;E<g;E++)z[E]=[C[E],S[E],T[E]];const k=new Array(g).fill(1);return{controlPoints:z,knots:m,weights:k}}function tt(o,t,n,e){if(t===0)return n>=e[o]&&n<e[o+1]?1:0;const s=e[o+t]-e[o],i=e[o+t+1]-e[o+1],r=s>1e-10?(n-e[o])/s:0,h=i>1e-10?(e[o+t+1]-n)/i:0;return r*tt(o,t-1,n,e)+h*tt(o+1,t-1,n,e)}function gt(o,t,n,e,s){const i=e.length-1,r=t;if(o=Math.max(n[r],Math.min(n[i+1],o)),Math.abs(o-n[i+1])<1e-8)return[...e[i]];if(Math.abs(o-n[r])<1e-8)return[...e[0]];const h=[0,0,0];let a=0;for(let c=0;c<=i;c++){const l=tt(c,r,o,n),u=s[c]*l;h[0]+=e[c][0]*u,h[1]+=e[c][1]*u,h[2]+=e[c][2]*u,a+=u}if(Math.abs(a)<1e-10){const c=n[n.length-r-1];if(Math.abs(o-c)<1e-8)return[...e[i]];if(Math.abs(o-n[r])<1e-8)return[...e[0]]}return Math.abs(a)>=1e-10&&(h[0]/=a,h[1]/=a,h[2]/=a),h}function Qt(o,t,n,e){if(t===0)return 0;const s=e[o+t]-e[o],i=e[o+t+1]-e[o+1];let r=0;return s>1e-10&&(r+=t/s*tt(o,t-1,n,e)),i>1e-10&&(r-=t/i*tt(o+1,t-1,n,e)),r}function de(o,t,n,e){if(t<=1)return 0;const s=e[o+t]-e[o],i=e[o+t+1]-e[o+1];let r=0;return s>1e-10&&(r+=t/s*Qt(o,t-1,n,e)),i>1e-10&&(r-=t/i*Qt(o+1,t-1,n,e)),r}function Nn(o,t,n,e,s){const i=e.length-1,r=t,h=n[r],a=n[i+1];o=Math.max(h,Math.min(a,o));const c=[0,0,0],l=[0,0,0],u=[0,0,0];let d=0,m=0,g=0;for(let T=0;T<=i;T++){const z=tt(T,r,o,n),k=Qt(T,r,o,n),E=de(T,r,o,n),N=s[T],q=N*z,Y=N*k,J=N*E,U=e[T];c[0]+=q*U[0],c[1]+=q*U[1],c[2]+=q*U[2],l[0]+=Y*U[0],l[1]+=Y*U[1],l[2]+=Y*U[2],u[0]+=J*U[0],u[1]+=J*U[1],u[2]+=J*U[2],d+=q,m+=Y,g+=J}if(Math.abs(d)<1e-10)return{point:gt(o,t,n,e,s),deriv1:[0,0,0],deriv2:[0,0,0]};const y=d*d,x=[c[0]/d,c[1]/d,c[2]/d],_=[(l[0]*d-c[0]*m)/y,(l[1]*d-c[1]*m)/y,(l[2]*d-c[2]*m)/y],b=u[0]*d-c[0]*g,p=u[1]*d-c[1]*g,C=u[2]*d-c[2]*g,S=[b/y-2*m*_[0]/d,p/y-2*m*_[1]/d,C/y-2*m*_[2]/d];return{point:x,deriv1:_,deriv2:S}}function jn(o,t){const n=o[0],e=o[1],s=t[0],i=t[1],r=n*n+e*e;return r<1e-20?0:(n*i-e*s)/Math.pow(r,1.5)}function qn(o,t,n,e){const s=o,i=t[s],r=t[t.length-s-1];let h=0;const a=1e3,c=(r-i)/a;let l=gt(i,o,t,n,e);for(let y=1;y<=a;y++){const x=i+y*c,_=gt(x,o,t,n,e),b=_[0]-l[0],p=_[1]-l[1],C=_[2]-l[2];h+=Math.sqrt(b*b+p*p+C*C),l=_}const u=gt(r,o,t,n,e),d=u[0]-l[0],m=u[1]-l[1],g=u[2]-l[2];return h+=Math.sqrt(d*d+m*m+g*g),h}function me(o,t=3,n="Uniform",e,s){return o.length===0?[]:Gt(o,t,n,e,s).controlPoints}const Vn=new W,Ln=new A,ge=new A,ye=new A,Kt=new M;function vn(o){return new W().setFromExtrusionDirection(new A(o.x,o.y,o.z))}function xe(o){return Vn.setFromExtrusionDirection(new A(o.x,o.y,o.z)),Vn.extractBasis(Ln,ge,ye),Ln.clone()}function _e(o,t){return new M(o.x,o.y,o.z??0).applyMatrix4(vn(t))}function Wt(o,t){return new M(o.x,o.y,o.z??0).applyMatrix4(vn(t).invert())}function fe(o,t,n){const e=Wt(o,n),s=Wt(t,n);return Kt.set(s.x-e.x,s.y-e.y,(s.z??0)-(e.z??0)),w.normalizeAngle(Math.atan2(Kt.y,Kt.x))}function $t(o){const t=o.length;if(t<3)return 0;let n=0;for(let e=0,s=t-1;e<t;s=e++){const i=o[s],r=o[e];n+=i.x*r.y-r.x*i.y}return n*.5}function Un(o){return Math.abs($t(o))}function Fn(o){const t=o.length;if(t<3)return 0;let n=0,e=0,s=0;for(let i=0,r=t-1;i<t;r=i++){const h=o[r],a=o[i],c=h.x,l=h.y,u=h.z??0,d=a.x,m=a.y,g=a.z??0;n+=(u+g)*(l-m),e+=(c+d)*(u-g),s+=(l+m)*(c-d)}return .5*Math.hypot(n,e,s)}function On(o){return o.length<3?0:Un(o)}function Xn(o){return o.length<3?0:Fn(o)}class Dn{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Jt extends Dn{translate(t){return this.transform(new rt().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class ht extends Jt{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const n=this.getUtoTmapping(t);return this.getPoint(n)}getPoints(t=5){const n=[];for(let e=0;e<=t;e++)n.push(this.getPoint(e/t));return n}getSpacedPoints(t=5){const n=[];for(let e=0;e<=t;e++)n.push(this.getPointAt(e/t));return n}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const n=[];let e,s=this.getPoint(0),i=0;n.push(0);for(let r=1;r<=t;r++)e=this.getPoint(r/t),i+=e.distanceTo(s),n.push(i),s=e;return n}getUtoTmapping(t,n){const e=this.getLengths();let s=0;const i=e.length;let r;n?r=n:r=t*e[i-1];let h=0,a=i-1,c;for(;h<=a;)if(s=Math.floor(h+(a-h)/2),c=e[s]-r,c<0)h=s+1;else if(c>0)a=s-1;else{a=s;break}if(s=a,e[s]===r)return s/(i-1);const l=e[s],d=e[s+1]-l,m=(r-l)/d;return(s+m)/(i-1)}getTangent(t){let e=t-1e-4,s=t+1e-4;e<0&&(e=0),s>1&&(s=1);const i=this.getPoint(e),r=this.getPoint(s),h=new P;return h.copy(r).sub(i).normalize(),h}getTangentAt(t){const n=this.getUtoTmapping(t);return this.getTangent(n)}}class G extends ht{constructor(t,n,e,s,i){super();const r=+(t!==void 0)+ +(n!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(i!==void 0);if(r==3)typeof t=="object"&&typeof n=="object"&&typeof e=="object"?this.createByThreePoints(t,n,e):this.createByStartEndPointsAndBulge(t,n,e);else if(r==5){const h=t;this.center=new P(h.x,h.y),this.radius=n,this._clockwise=i,this._startAngle=this._clockwise?this._mirrorAngle(w.normalizeAngle(e)):w.normalizeAngle(e),this._endAngle=this._clockwise?this._mirrorAngle(w.normalizeAngle(s)):w.normalizeAngle(s)}else throw V.AcCmErrors.ILLEGAL_PARAMETERS}createByThreePoints(t,n,e){const s=(z,k)=>({x:(z.x+k.x)/2,y:(z.y+k.y)/2}),i=(z,k)=>(k.y-z.y)/(k.x-z.x),r=z=>-1/z,h=s(t,n),a=s(n,e),c=i(t,n),l=i(n,e),u=r(c),d=r(l),m=(z,k,E,N)=>{const q=(N-k)/(z-E),Y=z*q+k;return{x:q,y:Y}},g=h.y-u*h.x,y=a.y-d*a.x,x=m(u,g,d,y),_=Math.sqrt(Math.pow(t.x-x.x,2)+Math.pow(t.y-x.y,2)),b=(z,k)=>Math.atan2(z.y-k.y,z.x-k.x),p=b(t,x),C=b(n,x),S=b(e,x),T=S>p&&S<C||p>S&&p<C||C>S&&C<p;this.center=x,this.radius=_,this._clockwise=!T,this._startAngle=p,this._endAngle=S}createByStartEndPointsAndBulge(t,n,e){let s,i,r;e<0?(s=Math.atan(-e)*4,i=new R(t),r=new R(n)):(s=Math.atan(e)*4,i=new R(n),r=new R(t));const h=new R().subVectors(r,i),a=h.length(),c=new R().addVectors(i,h.multiplyScalar(.5)),l=Math.abs(a/2/Math.tan(s/2)),u=h.normalize(),d=e<0?-Math.PI/2:Math.PI/2,m=new R(u.x*Math.cos(d)-u.y*Math.sin(d),u.y*Math.cos(d)+u.x*Math.sin(d));let g;s<Math.PI?e<0?g=c.add(m.multiplyScalar(l)):g=c.add(m.multiplyScalar(-l)):e<0?g=c.add(m.multiplyScalar(-l)):g=c.add(m.multiplyScalar(l)),e<0?(this._startAngle=Math.atan2(i.y-g.y,i.x-g.x),this._endAngle=Math.atan2(r.y-g.y,r.x-g.x)):(this._startAngle=Math.atan2(r.y-g.y,r.x-g.x),this._endAngle=Math.atan2(i.y-g.y,i.x-g.x)),this._clockwise=e<0,this.center=g,this.radius=r.sub(g).length()}get center(){return this._center}set center(t){this._center=new P(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(t){this._startAngle=this._clockwise?this._mirrorAngle(w.normalizeAngle(t)):w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(t){const n=this.startAngle==0&&t==I?t:w.normalizeAngle(t);this._endAngle=this._clockwise?this._mirrorAngle(n):n,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(t){return(360-t*180/Math.PI)%360*Math.PI/180}_getInternalAngle(t){return this._clockwise?this._mirrorAngle(t):t}get deltaAngle(){const t=this._getInternalAngle(this.startAngle),n=this._getInternalAngle(this.endAngle);return this.clockwise?w.normalizeAngle(t-n):w.normalizeAngle(n-t)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=this._getInternalAngle(this.startAngle),n=this._clockwise?w.normalizeAngle(t-this.deltaAngle/2):w.normalizeAngle(t+this.deltaAngle/2),e=this._clockwise?this._mirrorAngle(n):n;return this.getPointAtAngle(e)}get closed(){const t=this._getInternalAngle(this.startAngle),n=this._getInternalAngle(this.endAngle);return Math.abs(n-t)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],n=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const i of n){const r=this._getInternalAngle(i);w.isBetweenAngle(r,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(i))}const e=t.map(i=>i.x),s=t.map(i=>i.y);return new O(new P(Math.min(...e),Math.min(...s)),new P(Math.max(...e),Math.max(...s)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){const n=t,e=this.center.clone().applyMatrix2d(n),s=this.startPoint.clone().applyMatrix2d(n);if(this.closed)return this.center=e,this.radius=e.distanceTo(s),this._startAngle=Math.atan2(s.y-e.y,s.x-e.x),this._endAngle=this._startAngle,this._clockwise=n.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;const i=this.midPoint.clone().applyMatrix2d(n),r=this.endPoint.clone().applyMatrix2d(n),h=new G(s,i,r),a=n.determinant()<0?!this.clockwise:this.clockwise,c=l=>{const u=w.normalizeAngle(l);return a?this._mirrorAngle(u):u};return this.center=h.center,this.radius=h.radius,this.clockwise=a,this.startAngle=c(Math.atan2(s.y-h.center.y,s.x-h.center.x)),this.endAngle=c(Math.atan2(r.y-h.center.y,r.x-h.center.x)),this._boundingBoxNeedsUpdate=!0,this}clone(){return new G(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const n=this._getInternalAngle(t),e=this.center.x+this.radius*Math.cos(n),s=this.center.y+this.radius*Math.sin(n);return new P(e,s)}getQuadrantPoints(){const t=[],n=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle),s=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const i of s){const r=this._getInternalAngle(i);w.isBetweenAngle(r,n,e,this.clockwise)&&t.push(this.getPointAtAngle(i))}return t}nearestPoint(t){const n=new P(t.x,t.y),e=n.x-this.center.x,s=n.y-this.center.y;if(Math.hypot(e,s)<1e-12)return this.startPoint.clone();const r=Math.atan2(s,e),h=this.clockwise?this._mirrorAngle(w.normalizeAngle(r)):w.normalizeAngle(r),a=this._getInternalAngle(h),c=this._getInternalAngle(this.startAngle),l=this._getInternalAngle(this.endAngle);if(w.isBetweenAngle(a,c,l,this.clockwise))return this.getPointAtAngle(h);const u=n.distanceToSquared(this.startPoint),d=n.distanceToSquared(this.endPoint);return u<=d?this.startPoint.clone():this.endPoint.clone()}perpendicularPoints(t){const n=new P(t.x,t.y),e=n.x-this.center.x,s=n.y-this.center.y,i=Math.hypot(e,s);if(i<1e-12)return[];const r=e/i,h=s/i,a=[new P(this.center.x+r*this.radius,this.center.y+h*this.radius),new P(this.center.x-r*this.radius,this.center.y-h*this.radius)],c=[],l=this._getInternalAngle(this.startAngle),u=this._getInternalAngle(this.endAngle);for(const d of a){const m=Math.atan2(d.y-this.center.y,d.x-this.center.x),g=this.clockwise?this._mirrorAngle(w.normalizeAngle(m)):w.normalizeAngle(m),y=this._getInternalAngle(g);(this.closed||w.isBetweenAngle(y,l,u,this.clockwise))&&c.push(d)}return c}tangentPoints(t){const n=[],e=t.x-this.center.x,s=t.y-this.center.y,i=Math.hypot(e,s),r=this.radius;if(i<r)return n;const h=Math.acos(r/i),a=Math.atan2(s,e),c=[a+h,a-h],l=this._getInternalAngle(this.startAngle),u=this._getInternalAngle(this.endAngle);for(const d of c){const m=this.clockwise?this._mirrorAngle(w.normalizeAngle(d)):w.normalizeAngle(d),g=this._getInternalAngle(m);(this.closed||w.isBetweenAngle(g,l,u,this.clockwise))&&n.push(this.getPointAtAngle(m))}return n}getPoints(t=100){const n=[];let e=this.deltaAngle,s=this._getInternalAngle(this.startAngle);if(this.closed&&(e=I,s=0),this.clockwise)for(let i=0;i<=t;i++){const r=s-e*(i/t),h=this._clockwise?this._mirrorAngle(r):r,a=this.getPointAtAngle(h);n.push(new P(a.x,a.y))}else for(let i=0;i<=t;i++){const r=s+e*(i/t),h=this._clockwise?this._mirrorAngle(r):r,a=this.getPointAtAngle(h);n.push(new P(a.x,a.y))}return n}}const Mt=1e-6;function Yn(o,t){if(Ue(o)){const i=Pe(o,t);return i?[i]:[]}const n=$n(o);if(n.numberOfVertices<2)return[];const s=Oe(n,t);return s?[s]:[]}function Ae(o){return $n(o)}function Pe(o,t){const n=pe(o);if(n.length===0)return null;const e=[];for(const h of n){const a=Me(h,t);if(!a)return null;e.push(a)}const s=we(o),i=Ce(e,s,o.closed,t);if(i.length<2)return null;const r=new nt;return i.forEach((h,a)=>{r.addVertexAt(a,{x:h.x,y:h.y})}),r.closed=o.closed,r}function pe(o){const t=[],n=o.numberOfVertices,e=o.closed?n:n-1;for(let s=0;s<e;s++){const i=o.vertices[s],r=o.vertices[(s+1)%n];B.isPositive(Math.abs(i.bulge??0))?t.push({kind:"arc",arc:new G(i,r,i.bulge)}):t.push({kind:"line",start:new P(i.x,i.y),end:new P(r.x,r.y)})}return t}function we(o){const t=[];for(let n=0;n<o.numberOfVertices;n++)t.push(o.getPointAt(n));return t}function Me(o,t){if(o.kind==="line"){const e=Se(o.start,o.end,t);return e?{kind:"line",...e}:null}const n=ze(o.arc,o.arc.startPoint,o.arc.endPoint,t);return n?{kind:"arc",arc:n}:null}function ze(o,t,n,e){const s=be(o,t,n,e),i=o.radius+s;return B.isNonPositive(i)?null:new G(o.center,i,o.startAngle,o.endAngle,o.clockwise)}function be(o,t,n,e){const s=n.x-t.x,i=n.y-t.y,r=Math.hypot(s,i);if(B.isNonPositive(r))return o.clockwise?-e:e;const h=-i/r,a=s/r,c=o.center.x-(t.x+n.x)/2,l=o.center.y-(t.y+n.y)/2;return c*h+l*a>0?-e:e}function Se(o,t,n){const e=t.x-o.x,s=t.y-o.y,i=Math.hypot(e,s);if(B.isNonPositive(i))return null;const r=-s/i*n,h=e/i*n;return{start:new P(o.x+r,o.y+h),end:new P(t.x+r,t.y+h),dx:e,dy:s}}function Ce(o,t,n,e){var h;const s=o.length;if(s===0)return[];const i=Ee(o,t,n,e),r=[((h=i[0].nextSegmentStart)==null?void 0:h.clone())??i[0].point.clone()];for(let a=0;a<s;a++){const c=o[a],l=a===s-1&&!n?{point:ke(c)}:i[(a+1)%s];if(a>0&&i[a].filletPoints&&i[a].filletPoints.forEach(u=>r.push(u.clone())),c.kind==="arc"){const u=i[a].nextSegmentStart??i[a].point,d=l.point,m=Ie(c.arc,u,d,Math.max(16,32));for(let g=1;g<m.length;g++)r.push(m[g])}else r.push(l.point.clone())}return Jn(r)}function Ee(o,t,n,e){const s=o.length,i=[];for(let r=0;r<s;r++)r===0?i.push(n?Zn(o[s-1],o[0],t[0],e):{point:Re(o[0])}):i.push(Zn(o[r-1],o[r],t[r],e));return i}function Ie(o,t,n,e){const s=o.nearestPoint(t),i=o.nearestPoint(n),r=Ht(o,s),h=Ht(o,i),a=Be(o,r,h),c=[];for(let l=0;l<=e;l++){const u=l/e,d=o.clockwise?r-a*u:r+a*u;c.push(o.getPointAtAngle(Te(o,d)))}return c}function Ht(o,t){return Math.atan2(t.y-o.center.y,t.x-o.center.x)}function Te(o,t){const n=w.normalizeAngle(t);return o.clockwise?tn(n):n}function tn(o){return(360-o*180/Math.PI)%360*(Math.PI/180)}function Be(o,t,n){if(o.clockwise){let s=t-n;return B.isNonPositive(s)&&(s+=I),s}let e=n-t;return B.isNonPositive(e)&&(e+=I),e}function Re(o){return o.kind==="line"?o.start.clone():o.arc.startPoint.clone()}function ke(o){return o.kind==="line"?o.end.clone():o.arc.endPoint.clone()}function Zn(o,t,n,e){return o.kind==="line"&&t.kind==="line"?{point:nn({start:o.start,end:o.end,dx:o.dx,dy:o.dy},{start:t.start,end:t.end,dx:t.dx,dy:t.dy})}:o.kind==="line"&&t.kind==="arc"?Gn(o,t.arc,n,e,!0):o.kind==="arc"&&t.kind==="line"?Gn(t,o.arc,n,e,!1):o.kind==="arc"&&t.kind==="arc"?Ne(o.arc,t.arc,n,e):{point:n.clone()}}function Ne(o,t,n,e){const s=Wn(o.endPoint,t.startPoint),r=ve(o,t).filter(l=>zt(o,l)&&zt(t,l));if(r.length>0)return{point:Kn(r,s)};const h=o.endPoint.clone(),a=t.startPoint.clone(),c=Qn(n,Math.abs(e),h,a);return{point:h,filletPoints:c,nextSegmentStart:a}}function Gn(o,t,n,e,s){const i=Wn(s?o.end:o.start,s?t.startPoint:t.endPoint),r=Le(o,t,i);if(qe(o,r)&&zt(t,r))return{point:r};const h=je(o,n,e),a=s?t.startPoint.clone():t.endPoint.clone(),c=Qn(n,Math.abs(e),s?h:a,s?a:h);return s?{point:h,filletPoints:c,nextSegmentStart:a}:{point:a,filletPoints:c,nextSegmentStart:h}}function je(o,t,n){const e=Math.hypot(o.dx,o.dy),s=-o.dy/e*n,i=o.dx/e*n;return new P(t.x+s,t.y+i)}function qe(o,t){const n=Math.hypot(o.dx,o.dy);if(B.isNonPositive(n))return!1;const e=o.dx/n,s=o.dy/n,i=t.x-o.start.x,r=t.y-o.start.y,h=Math.abs(i*s-r*e);return B.equalToZero(h)}function Qn(o,t,n,e){const s=Math.atan2(n.y-o.y,n.x-o.x),i=Math.atan2(e.y-o.y,e.x-o.x),r=Ve(s,i);if(B.equalToZero(Math.abs(r)))return[];const h=[],a=Math.max(2,Math.ceil(Math.abs(r)/Math.PI*16));for(let c=1;c<a;c++){const l=c/a,u=s+r*l;h.push(new P(o.x+t*Math.cos(u),o.y+t*Math.sin(u)))}return h}function Ve(o,t){let n=t-o;for(;n>Math.PI;)n-=I;for(;n<=-Math.PI;)n+=I;return n}function Le(o,t,n){const e=Math.hypot(o.dx,o.dy);if(B.isNonPositive(e))return n.clone();const s=o.dx/e,i=o.dy/e,r=o.start.x-t.center.x,h=o.start.y-t.center.y,a=2*(r*s+h*i),c=r*r+h*h-t.radius*t.radius,l=a*a-4*c;if(l<0)return n.clone();const u=Math.sqrt(l),d=[(-a-u)/2,(-a+u)/2].map(g=>new P(o.start.x+s*g,o.start.y+i*g)),m=d.filter(g=>zt(t,g));return Kn(m.length>0?m:d,n)}function zt(o,t){const n=Math.abs(Math.hypot(t.x-o.center.x,t.y-o.center.y)-o.radius);if(B.isPositive(n))return!1;const e=Ht(o,t),s=o.clockwise?tn(w.normalizeAngle(o.startAngle)):w.normalizeAngle(o.startAngle),i=o.clockwise?tn(w.normalizeAngle(o.endAngle)):w.normalizeAngle(o.endAngle);return w.isBetweenAngle(e,s,i,o.clockwise)}function ve(o,t){const n=t.center.x-o.center.x,e=t.center.y-o.center.y,s=Math.hypot(n,e);if(B.isNonPositive(s))return[];const i=o.radius+t.radius,r=Math.abs(o.radius-t.radius);if(s>i+Mt)return[];if(s<r-Mt)return[];const h=(o.radius*o.radius-t.radius*t.radius+s*s)/(2*s),a=o.radius*o.radius-h*h;if(a<-Mt)return[];const c=o.center.x+h*n/s,l=o.center.y+h*e/s;if(a<=Mt)return[new P(c,l)];const u=Math.sqrt(a),d=-e*u/s,m=n*u/s;return[new P(c+d,l+m),new P(c-d,l-m)]}function Kn(o,t){let n=o[0],e=n.distanceToSquared(t);for(let s=1;s<o.length;s++){const i=o[s].distanceToSquared(t);i<e&&(n=o[s],e=i)}return n.clone()}function Wn(o,t){return new P((o.x+t.x)/2,(o.y+t.y)/2)}function Ue(o){const t=o.numberOfVertices,n=o.closed?t:t-1;for(let e=0;e<n;e++){const s=o.vertices[e];if(B.isPositive(Math.abs(s.bulge??0)))return!0}return!1}function $n(o){const t=Fe(o.vertices.map(n=>new P(n.x,n.y)),o.closed);return t.length===o.numberOfVertices?o:new nt(t.map(n=>({x:n.x,y:n.y})),o.closed)}function Fe(o,t){const n=Jn(o);if(!t||n.length<2)return n;const e=n[0],s=n[n.length-1];return B.isNonPositive(Math.hypot(e.x-s.x,e.y-s.y))&&n.pop(),n}function Jn(o){const t=[];return o.forEach(n=>{const e=t[t.length-1];(!e||B.isPositive(Math.hypot(e.x-n.x,e.y-n.y)))&&t.push(new P(n.x,n.y))}),t}function Oe(o,t){const n=[];for(let r=0;r<o.numberOfVertices;r++)n.push(o.getPointAt(r));const e=Xe(n,o.closed,t);if(e.length===0)return null;const s=[];if(o.closed){if(e.length<2)return null;const r=e.length;for(let h=0;h<r;h++){const a=e[(h-1+r)%r],c=e[h];s.push(nn(a,c))}}else{s.push(e[0].start);for(let r=1;r<e.length;r++)s.push(nn(e[r-1],e[r]));s.push(e[e.length-1].end)}const i=new nt;return s.forEach((r,h)=>{i.addVertexAt(h,{x:r.x,y:r.y})}),i.closed=o.closed,i}function Xe(o,t,n){const e=[],s=t?o.length:o.length-1;for(let i=0;i<s;i++){const r=o[i],h=o[t?(i+1)%o.length:i+1],a=h.x-r.x,c=h.y-r.y,l=Math.hypot(a,c);if(B.isNonPositive(l))continue;const u=-c/l*n,d=a/l*n;e.push({start:new P(r.x+u,r.y+d),end:new P(h.x+u,h.y+d),dx:a,dy:c})}return e}function nn(o,t){const n=o.dx*t.dy-o.dy*t.dx;if(B.equalToZero(n))return new P((o.end.x+t.start.x)/2,(o.end.y+t.start.y)/2);const e=t.start.x-o.start.x,s=t.start.y-o.start.y,i=(e*t.dy-s*t.dx)/n;return new P(o.start.x+i*o.dx,o.start.y+i*o.dy)}class nt extends ht{constructor(t=null,n=!1){super(),this._vertices=t||new Array,this._closed=n}get vertices(){return this._vertices}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new P(t.x,t.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const t=this.numberOfVertices;if(t>0)if(this.closed){const n=this._vertices[0];return new P(n.x,n.y)}else{const n=this._vertices[t-1];return new P(n.x,n.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let t=0;const n=this._vertices.length;for(let e=0;e<n;++e){const s=this._vertices[e];let i=null;if(e<n-1?i=this._vertices[e+1]:e==n-1&&this.closed&&(i=this._vertices[0]),i)if(s.bulge){const r=new G(s,i,s.bulge);t+=r.length}else t+=new P(s.x,s.y).distanceTo(i)}return t}get area(){if(!this._closed||this._vertices.length<3)return 0;const t=this.getPoints(128);return On(t)}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,n){t<=0?this._vertices.unshift(n):this._vertices.splice(t,0,n),this._boundingBoxNeedsUpdate=!0}removeVertexAt(t){if(t<0||t>=this._vertices.length)throw new Error(`Index ${t} is out of bounds. Valid range is 0 to ${this._vertices.length-1}.`);this._vertices.splice(t,1),this._boundingBoxNeedsUpdate=!0}reset(t,n){t?n!==void 0&&n>=0&&n<this._vertices.length&&(this._vertices=this._vertices.slice(0,n),this._boundingBoxNeedsUpdate=!0):(this._vertices=new Array,this._boundingBoxNeedsUpdate=!0)}getPointAt(t){const n=this._vertices[t];return new P(n.x,n.y)}calculateBoundingBox(){const t=this.getPoints(100);return new O().setFromPoints(t)}transform(t){const n=t.determinant()<0;return this._vertices.forEach(e=>{const s=new P(e).applyMatrix2d(t);e.x=s.x,e.y=s.y,n&&e.bulge!=null&&(e.bulge=-e.bulge)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new nt(this._vertices.map(t=>({...t})),this._closed)}getPoints3d(t,n){const e=[];return this.getPoints(t).forEach(i=>e.push(new M().set(i.x,i.y,n))),e}getPoints(t){const n=[],e=this._vertices.length;for(let s=0;s<e;++s){const i=this._vertices[s];if(i.bulge){let r=null;if(s<e-1?r=this._vertices[s+1]:s==e-1&&this.closed&&(r=this._vertices[0]),r){const a=new G(i,r,i.bulge).getPoints(t),c=a.length;for(let l=0;l<c;++l){const u=a[l];n.push(new P(u.x,u.y))}}}else n.push(new P(i.x,i.y)),s==e-1&&this.closed&&n.push(n[0])}return n}offset(t){return Yn(this,t)}}function De(o,t,n){const e=Math.hypot(t.x,t.y);if(B.isNonPositive(e))return null;const s=-t.y/e*n,i=t.x/e*n;return new M(o.x+s,o.y+i,o.z)}function Ye(o,t,n){if(o.length<2)return null;const e=Ae(new nt(o.map(i=>({x:i.x,y:i.y})),t));return Yn(e,n)[0]??null}function Ze(o,t,n,e){if(o.length<2||B.equalToZero(n))return null;const{points:s,tangents:i}=te(o,e);if(s.length<2)return null;const r=i??Ge(s,t),h=Qe(s,r,n),a=t?We(h):Ke(h);if(a.length<2)return null;const c=new nt;return a.forEach((l,u)=>{c.addVertexAt(u,{x:l.x,y:l.y})}),c.closed=t,c}function Ge(o,t){const n=o.length,e=new Array(n);for(let s=0;s<n;s++){let i=0,r=0;if(t){const a=o[(s-1+n)%n],c=o[(s+1)%n];i=c.x-a.x,r=c.y-a.y}else s===0?(i=o[1].x-o[0].x,r=o[1].y-o[0].y):s===n-1?(i=o[n-1].x-o[n-2].x,r=o[n-1].y-o[n-2].y):(i=o[s+1].x-o[s-1].x,r=o[s+1].y-o[s-1].y);const h=Math.hypot(i,r);B.isNonPositive(h)?e[s]=new P(1,0):e[s]=new P(i/h,r/h)}return e}function Qe(o,t,n){return o.map((e,s)=>{const i=t[s],r=-i.y*n,h=i.x*n;return new P(e.x+r,e.y+h)})}function Ke(o){let t=bt(o);if(t.length<3)return t;for(;;){const n=Hn(t,!1);if(!n||(t=bt([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<2))break}return t}function We(o){let t=bt(o);if(t.length<4)return t;for(;;){const n=Hn(t,!0);if(!n||(t=bt([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<3))break}return t}function Hn(o,t){const n=t?o.length:o.length-1;if(n<2)return null;for(let e=0;e<n;e++){const s=o[e],i=o[(e+1)%o.length];for(let r=e+1;r<n;r++){if($e(e,r,n,t))continue;const h=o[r],a=o[(r+1)%o.length],c=Je(s,i,h,a);if(c)return{point:c,segmentA:e,segmentB:r}}}return null}function $e(o,t,n,e){return!!(t===o||t===o+1||e&&o===0&&t===n-1)}function Je(o,t,n,e){const s=t.x-o.x,i=t.y-o.y,r=e.x-n.x,h=e.y-n.y,a=s*h-i*r;if(B.equalToZero(a))return null;const c=n.x-o.x,l=n.y-o.y,u=(c*h-l*r)/a,d=(c*i-l*s)/a,m=pt.equalPointTol;return u<-m||u>1+m||d<-m||d>1+m?null:new P(o.x+u*s,o.y+u*i)}function te(o,t){const n=[],e=[],s=t!=null&&t.length===o.length;return o.forEach((i,r)=>{const h=n[n.length-1];if((!h||B.isPositive(Math.hypot(h.x-i.x,h.y-i.y)))&&(n.push(new P(i.x,i.y)),s)){const a=t[r];e.push(new P(a.x,a.y))}}),{points:n,tangents:s?e:void 0}}function bt(o){return te(o).points}class en extends Jt{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new O}transform(t){return this._loops.forEach(n=>{n.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){const t=new en;return this._loops.forEach(n=>{t.add(n.clone())}),t}getPoints(t){const n=[];for(let e=0;e<this.loops.length;++e){const i=this.loops[e].getPoints(t);n.push(i)}return n}buildHierarchy(){var h;const t=this.getPoints(100),n=this.calculateBoundaryBoxes(t),e=this.sortBoundaryBoxesByAreas(n),s=new Map,i=e.length;for(let a=0;a<i;a++)s.set(e[a],{index:e[a],children:[]});const r={index:-1,children:[]};for(let a=0;a<i;a++){const c=e[a],l=t[c],u=n[c];let d=a+1;for(;d<i;d++){const m=e[d],g=t[m];if(n[m].containsBox(u)&&Bn.isPointInPolygon(l[w.randInt(0,l.length-1)],g)){(h=s.get(m))==null||h.children.push(s.get(c));break}}d===i&&r.children.push(s.get(c))}return r}get area(){if(this._loops.length===0)return 0;let t=0;for(let n=0;n<this._loops.length;n++){const s=this._loops[n].getPoints(128),i=$t(s);n===0?t+=Math.abs(i):t-=Math.abs(i)}return t}calculateBoundaryBoxes(t){const n=[];return t.forEach(e=>{n.push(new O().setFromPoints(e))}),n}sortBoundaryBoxesByAreas(t){const n=[];t.forEach((s,i)=>{const r=s.size,h=r.width*r.height;n.push({area:h,index:i})}),n.sort((s,i)=>s.area-i.area);const e=[];return n.forEach(s=>{e.push(s.index)}),e}}class He extends Dn{translate(t){return this.transform(new W().makeTranslation(t.x,t.y,t.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class yt extends He{}class at extends yt{constructor(t,n){super(),this._start=new M(t),this._end=new M(n)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}get direction(){return new A().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new M((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}nearestPoint(t){return this.project(t)}get length(){return this.startPoint.distanceTo(this.endPoint)}isPointOnLine(t){return this.project(t).distanceTo(t)<1e-6}at(t,n){return this.delta(n).multiplyScalar(t).add(this._start)}atLength(t,n=!1){if(n){const e=this.delta(st).normalize();return new M(this._start).addScaledVector(e,t)}else{const e=this.delta(st).normalize();return new M(this._end).addScaledVector(e,t)}}extend(t,n=!1){if(n){const e=st.subVectors(this._start,this._end).normalize();this._start=new M(this._start).addScaledVector(e,t)}else{const e=this.delta(st).normalize();this._end=new M(this._end).addScaledVector(e,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,n){ne.subVectors(t,this._start),St.subVectors(this.endPoint,this.startPoint);const e=St.dot(St);let i=St.dot(ne)/e;return n&&(i=w.clamp(i,0,1)),i}closestPointToPoint(t,n,e){const s=this.closestPointToPointParameter(t,n);return this.delta(e).multiplyScalar(s).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const n=this.direction,s=st.subVectors(t,this.startPoint).dot(n);return new M().copy(n).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const n=this.direction,e=this.startPoint,i=st.subVectors(t,e).dot(n),r=st.copy(n).multiplyScalar(i);return new M().addVectors(e,r)}calculateBoundingBox(){const t=new M(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),n=new M(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y),Math.max(this._start.z,this._end.z));return new Z(t,n)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new at(this._start.clone(),this._end.clone())}offset(t){const n=this.startPoint,e=this.endPoint;if(Math.hypot(e.x-n.x,e.y-n.y)===0)return this.clone();const i=new A(e.x-n.x,e.y-n.y,0).normalize(),r=new A(-i.y,i.x,0);return new at(new M(n.x+r.x*t,n.y+r.y*t,n.z),new M(e.x+r.x*t,e.y+r.y*t,e.z))}}const st=new A,ne=new A,St=new A;class ct extends yt{static computeCenterPoint(t,n,e){const s=new A().addVectors(t,n).multiplyScalar(.5),i=new A().addVectors(t,e).multiplyScalar(.5),r=new A().subVectors(n,t),h=new A().subVectors(e,t),a=new A().crossVectors(r,h).normalize();if(a.lengthSq()===0)return null;const c=new A().crossVectors(r,a).normalize(),l=new A().crossVectors(h,a).normalize(),u=c.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),d=l.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),m=new at(s,s.clone().add(u)),g=new at(i,i.clone().add(d)),y=new A;return m.closestPointToPoint(g.startPoint,!0,y)?y:null}static createByThreePoints(t,n,e){const s=ct.computeCenterPoint(t,n,e);if(s){const i=s.distanceTo(t),r=new A().subVectors(t,s),h=new A().subVectors(n,s),a=Math.atan2(r.y,r.x),c=Math.atan2(h.y,h.x);return new ct(s,i,a,c,A.Z_AXIS)}}constructor(t,n,e,s,i,r=A.X_AXIS){super(),this.center=t,this.radius=n,this.startAngle=e,this.endAngle=s,this.normal=i,this.refVec=r,(s-e)%I==0?(this.startAngle=0,this.endAngle=I):(this.startAngle=e,this.endAngle=s)}get center(){return this._center}set center(t){this._center=new M(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==I?t:w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return w.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new A(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new A(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,n=this.deltaAngle;this.closed&&(t=0,n=I);const e=t+n*.5;return this.getPointAtAngle(e)}get length(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)}get area(){return this.closed?Math.PI*this.radius*this.radius:0}nearestPoint(t){const n=new A(t.x,t.y,t.z||0),e=this.center,s=this.normal,r=n.clone().sub(e).dot(s),a=n.clone().sub(s.clone().multiplyScalar(r)).clone().sub(e);if(a.lengthSq()===0)return this.startPoint.clone();a.normalize().multiplyScalar(this.radius);const c=e.clone().add(a),l=this.getAngle(c.clone()),u=this.startAngle,d=this.deltaAngle;let m=w.normalizeAngle(l-u);m<0&&(m=0),m>d&&(m=d);const g=this.getPointAtAngle(u+m),y=g.distanceTo(n),x=this.startPoint.distanceTo(n),_=this.endPoint.distanceTo(n);return x<y&&x<=_?this.startPoint.clone():_<y&&_<x?this.endPoint.clone():g}tangentPoints(t){const n=[],e=new A(t.x,t.y,t.z||0),s=this.center,i=this.normal,r=this.radius,a=e.clone().sub(s).dot(i),c=e.clone().sub(i.clone().multiplyScalar(a)),l=s.clone(),d=c.clone().sub(l).length();if(d<r)return n;const m=Math.acos(r/d),g=this.getAngle(c.clone()),y=[g+m,g-m];for(const x of y){const _=w.normalizeAngle(x-this.startAngle);_>=0&&_<=this.deltaAngle&&n.push(this.getPointAtAngle(this.startAngle+_))}return n}perpendicularPoints(t){const n=[],e=new A(t.x,t.y,t.z||0),s=this.center,i=this.normal,r=this.radius,a=e.clone().sub(s).dot(i),l=e.clone().sub(i.clone().multiplyScalar(a)).clone().sub(s);if(l.lengthSq()<1e-24)return n;l.normalize();const u=[s.clone().add(l.clone().multiplyScalar(r)),s.clone().sub(l.clone().multiplyScalar(r))];for(const d of u){const m=this.getAngle(d.clone()),g=w.normalizeAngle(m-this.startAngle);g>=0&&g<=this.deltaAngle&&n.push(new M(d.x,d.y,d.z||0))}return n}nearestTangentPoint(t){const n=this.tangentPoints(t);if(n.length===0)return null;const e=new M(t.x,t.y,t.z||0);return n.length===1||n[0].distanceTo(e)<n[1].distanceTo(e)?n[0]:n[1]}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let a=0;a<2*Math.PI;a+=Math.PI/2)w.isBetweenAngle(a,this.startAngle,this.endAngle)&&t.push(a);let n=1/0,e=1/0,s=1/0,i=-1/0,r=-1/0,h=-1/0;for(const a of t){const c=this.getPointAtAngle(a);c.x<n&&(n=c.x),c.y<e&&(e=c.y),c.z<s&&(s=c.z),c.x>i&&(i=c.x),c.y>r&&(r=c.y),c.z>h&&(h=c.z)}return new Z({x:n,y:e,z:s},{x:i,y:r,z:h})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const n=[];let e=this.deltaAngle,s=this.startAngle;this.closed&&(e=I,s=0);for(let i=0;i<=t;i++){const r=s+e*(i/t),h=this.getPointAtAngle(r);n.push(h)}return n}transform(t){const n=this.center.clone().applyMatrix4(t),e=this.startPoint.clone().applyMatrix4(t),s=this.endPoint.clone().applyMatrix4(t),i=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(t),r=new A(e).sub(n).normalize(),h=n.distanceTo(e);let a=new A().crossVectors(new A(e).sub(n),new A(i).sub(n)).normalize();a.lengthSq()===0&&(a=this.normal.clone().transformDirection(t));const c=l=>{const u=new A(l).sub(n);return Math.atan2(u.dot(ee.crossVectors(a,r)),u.dot(r))};return this.center=n,this.radius=h,this.normal=a,this.refVec=r,this.startAngle=0,this.endAngle=this.closed?I:c(s),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new ct(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(ee.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const n=this.normal,e=this.refVec,s={x:n.y*e.z-n.z*e.y,y:n.z*e.x-n.x*e.z,z:n.x*e.y-n.y*e.x},i=this.center,r=this.radius;return new M(i.x+r*(e.x*Math.cos(t)+s.x*Math.sin(t)),i.y+r*(e.y*Math.cos(t)+s.y*Math.sin(t)),i.z+r*(e.z*Math.cos(t)+s.z*Math.sin(t)))}get plane(){const t=new A(this.center).distanceTo(Ft);return new mt(this.normal,t)}offset(t){const n=this.radius+t;return n<=0?null:new ct(this.center,n,this.startAngle,this.endAngle,this.normal,this.refVec)}}const ee=new A;class it extends ht{constructor(t,n,e,s=0,i=I,r=!1,h=0){super(),this.center=t,this.majorAxisRadius=n,this.minorAxisRadius=e,(i-s)%I==0?(this.startAngle=0,this.endAngle=I):(this.startAngle=s,this.endAngle=i),this.clockwise=r,this.rotation=h}get center(){return this._center}set center(t){this._center=new M(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==I?t:w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return w.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let n=1/0,e=1/0,s=-1/0,i=-1/0;for(let r=0;r<=100;r++){const h=this.getPoint(r/100);n=Math.min(n,h.x),e=Math.min(e,h.y),s=Math.max(s,h.x),i=Math.max(i,h.y)}return new O({x:n,y:e},{x:s,y:i})}get closed(){return this.deltaAngle==0}getPoint(t){const n=Math.PI*2;let e=this.endAngle-this.startAngle;const s=Math.abs(e)<Number.EPSILON;for(;e<0;)e+=n;for(;e>n;)e-=n;e<Number.EPSILON&&(s?e=0:e=n),this.clockwise===!0&&!s&&(e===n?e=-n:e=e-n);const i=this.startAngle+t*e;let r=this.center.x+this.majorAxisRadius*Math.cos(i),h=this.center.y+this.minorAxisRadius*Math.sin(i);if(this.rotation!==0){const a=Math.cos(this.rotation),c=Math.sin(this.rotation),l=r-this.center.x,u=h-this.center.y;r=l*a-u*c+this.center.x,h=l*c+u*a+this.center.y}return new P(r,h)}transform(t){const n=t,e=new P(this.center).applyMatrix2d(n),s=new M(e.x,e.y,this.center.z),i=this.getPointAtAngle(0).clone().applyMatrix2d(n),r=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(n),h=new P(i).sub(e),a=new P(r).sub(e),c=h.length(),l=a.length(),u=Math.atan2(h.y,h.x),d=h.clone().normalize(),m=a.clone().normalize(),g=_=>{const b=new P(_).sub(e),p=b.dot(d),C=b.dot(m);return w.normalizeAngle(Math.atan2(C/l,p/c))},y=n.determinant()<0?!this.clockwise:this.clockwise,x=this.closed?new it(s,c,l,0,I,y,u):new it(s,c,l,g(this.startPoint.clone().applyMatrix2d(n)),g(this.endPoint.clone().applyMatrix2d(n)),y,u);return this.center=x.center,this.majorAxisRadius=x.majorAxisRadius,this.minorAxisRadius=x.minorAxisRadius,this._startAngle=x._startAngle,this._endAngle=x._endAngle,this._clockwise=x._clockwise,this.rotation=x.rotation,this._boundingBoxNeedsUpdate=!0,this}getPointAtAngle(t){return this.getPoint(this.closed?t/I:w.normalizeAngle(t-this.startAngle)/this.deltaAngle)}copy(t){return this.center=t.center,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}clone(){return new it(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}getFocusPoints(){const t=Math.max(this.majorAxisRadius,this.minorAxisRadius),n=Math.min(this.majorAxisRadius,this.minorAxisRadius);if(t-n<1e-9)return[];const e=Math.sqrt(t*t-n*n),s=Math.cos(this.rotation),i=Math.sin(this.rotation),r=this.majorAxisRadius>=this.minorAxisRadius,h=r?s:-i,a=r?i:s;return[new P(this.center.x-e*h,this.center.y-e*a),new P(this.center.x+e*h,this.center.y+e*a)]}getQuadrantPoints(){return this.closed?[this.getPoint(0),this.getPoint(.25),this.getPoint(.5),this.getPoint(.75)]:[]}nearestPoint(t){const n=new P(t.x,t.y);let e=this.getPoint(0),s=n.distanceToSquared(e);const i=72;for(let r=1;r<=i;r++){const h=this.getPoint(r/i),a=n.distanceToSquared(h);a<s&&(s=a,e=h)}return e}tangentPoints(t){const n=this._projectPointToLocal(t);return this._findSnapAngles(n,(s,i,r,h)=>{const a=-this.majorAxisRadius*h,c=this.minorAxisRadius*r;return(s-n.x)*c-(i-n.y)*a}).map(s=>this.getPointAtAngle(s))}perpendicularPoints(t){const n=this._projectPointToLocal(t);return this._findSnapAngles(n,(s,i,r,h)=>{const a=this.minorAxisRadius*r,c=this.majorAxisRadius*h;return(s-n.x)*c-(i-n.y)*a}).map(s=>this.getPointAtAngle(s))}_projectPointToLocal(t){const n=t.x-this.center.x,e=t.y-this.center.y,s=Math.cos(-this.rotation),i=Math.sin(-this.rotation);return{x:n*s-e*i,y:n*i+e*s}}_findSnapAngles(t,n,e=144){const s=this.majorAxisRadius,i=this.minorAxisRadius,r=this.startAngle,h=this.deltaAngle,a=[],c=d=>{const m=Math.cos(d),g=Math.sin(d);return n(s*m,i*g,m,g)};let l=r,u=c(l);for(let d=1;d<=e;d++){const m=r+h*d/e,g=c(m);if(Math.abs(u)<1e-10&&a.push(l),u*g<0){let y=l,x=m;for(let _=0;_<32;_++){const b=(y+x)/2;c(y)*c(b)<=0?x=b:y=b}a.push((y+x)/2)}l=m,u=g}return a}}class lt extends yt{constructor(t,n,e,s,i,r=0,h=I){super(),this.center=t,this.normal=n,this.majorAxis=e,this.majorAxisRadius=s,this.minorAxisRadius=i;const a=Math.abs(h-r);Math.abs(a-I)<1e-10||Math.abs(a-2*I)<1e-10?(this.startAngle=0,this.endAngle=I):(this.startAngle=r,this.endAngle=h)}get center(){return this._center}set center(t){this._center=new M(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==I?t:w.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-I)<1e-10?I:w.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new A(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new A(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new A().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,n=this.deltaAngle;(this.closed||Math.abs(n-I)<1e-10)&&(t=0,n=I);const e=t+n/2;return this.getPointAtAngle(e)}get isCircular(){return B.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const t=1e3,n=this.deltaAngle/t;let e=0,s=this.getPointAtAngle(this.startAngle);for(let i=1;i<=t;i++){const r=this.startAngle+i*n,h=this.getPointAtAngle(r),a=h.x-s.x,c=h.y-s.y,l=h.z-s.z;e+=Math.sqrt(a*a+c*c+l*l),s=h}return e}get area(){return Math.abs(this.deltaAngle-I)>=1e-10?0:Math.PI*this.majorAxisRadius*this.minorAxisRadius}calculateBoundingBox(){if(this.majorAxis.equals(A.X_AXIS)||this.majorAxis.equals(A.Y_AXIS)||this.majorAxis.isParallelTo(A.X_AXIS)||this.majorAxis.isParallelTo(A.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let a=0;a<2*Math.PI;a+=Math.PI/2)w.isBetweenAngle(a,this.startAngle,this.endAngle)&&t.push(a);let n=1/0,e=1/0,s=1/0,i=-1/0,r=-1/0,h=-1/0;for(const a of t){const c=this.getPointAtAngle(a);c.x<n&&(n=c.x),c.y<e&&(e=c.y),c.z<s&&(s=c.z),c.x>i&&(i=c.x),c.y>r&&(r=c.y),c.z>h&&(h=c.z)}return new Z({x:n,y:e,z:s},{x:i,y:r,z:h})}else{let n=1/0,e=1/0,s=1/0,i=-1/0,r=-1/0,h=-1/0;for(let a=0;a<=100;a++){const c=this.startAngle+this.deltaAngle*(a/100),l=this.getPointAtAngle(c);n=Math.min(n,l.x),e=Math.min(e,l.y),s=Math.min(s,l.z),i=Math.max(i,l.x),r=Math.max(r,l.y),h=Math.max(h,l.z)}return new Z({x:n,y:e,z:s},{x:i,y:r,z:h})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const n=[];let e=this.deltaAngle,s=this.startAngle;this.closed&&(e=I,s=0);for(let i=0;i<=t;i++){const r=s+e*(i/t),h=this.getPointAtAngle(r);n.push(h)}return n}getPointAtAngle(t){const n=Math.cos(t),e=Math.sin(t),s=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(e),i=this.majorAxis.clone().multiplyScalar(n*this.majorAxisRadius).add(s);return new M(this.center.x+i.x,this.center.y+i.y,this.center.z+i.z)}nearestPoint(t,n=72){const e=new M(t.x,t.y,t.z||0);let s=this.getPointAtAngle(this.startAngle),i=e.distanceToSquared(s);for(let a=1;a<=n;a++){const c=this.startAngle+this.deltaAngle*a/n,l=this.getPointAtAngle(c),u=e.distanceToSquared(l);u<i&&(i=u,s=l)}const r=e.distanceToSquared(this.startPoint),h=e.distanceToSquared(this.endPoint);return r<i&&r<=h?this.startPoint.clone():h<i&&h<r?this.endPoint.clone():s.clone()}tangentPoints(t){const n=this._projectPointToLocalPlane(t);return this._findSnapParameterAngles((s,i,r,h)=>{const a=-this.majorAxisRadius*h,c=this.minorAxisRadius*r;return(s-n.x)*c-(i-n.y)*a}).map(s=>this.getPointAtAngle(s))}perpendicularPoints(t){const n=this._projectPointToLocalPlane(t);return this._findSnapParameterAngles((s,i,r,h)=>{const a=this.minorAxisRadius*r,c=this.majorAxisRadius*h;return(s-n.x)*c-(i-n.y)*a}).map(s=>this.getPointAtAngle(s))}_projectPointToLocalPlane(t){const n=new M(t.x,t.y,t.z||0),e=new A(n).sub(this.center),s=e.dot(this.normal);return e.sub(this.normal.clone().multiplyScalar(s)),{x:e.dot(this.majorAxis),y:e.dot(this.minorAxis)}}_findSnapParameterAngles(t,n=144){const e=this.majorAxisRadius,s=this.minorAxisRadius,i=this.startAngle,r=this.deltaAngle,h=[],a=u=>{const d=Math.cos(u),m=Math.sin(u);return t(e*d,s*m,d,m)};let c=i,l=a(c);for(let u=1;u<=n;u++){const d=i+r*u/n,m=a(d);if(Math.abs(l)<1e-10&&h.push(c),l*m<0){let g=c,y=d;for(let x=0;x<32;x++){const _=(g+y)/2;a(g)*a(_)<=0?y=_:g=_}h.push((g+y)/2)}c=d,l=m}return h}contains(t){const n=new A(t).sub(this.center),e=n.dot(this.majorAxis),s=n.dot(this.minorAxis),i=e/this.majorAxisRadius,r=s/this.minorAxisRadius;return i*i+r*r<=1}transform(t){const n=t,e=this.center.clone().applyMatrix4(n),s=this.getPointAtAngle(0).clone().applyMatrix4(n),i=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(n),r=new A(s).sub(e),h=new A(i).sub(e),a=r.length(),c=h.length(),l=r.clone().normalize(),u=new A().crossVectors(r,h).normalize();let d=new A().crossVectors(u,l).normalize();d.dot(h)<0&&(u.negate(),d=new A().crossVectors(u,l).normalize());const m=y=>{const x=new A(y).sub(e),_=x.dot(l),b=x.dot(d);return w.normalizeAngle(Math.atan2(b/c,_/a))},g=this.closed?new lt(e,u,l,a,c,0,I):new lt(e,u,l,a,c,m(this.startPoint.clone().applyMatrix4(n)),m(this.endPoint.clone().applyMatrix4(n)));return this.center=g.center,this.normal=g.normal,this.majorAxis=g.majorAxis,this.majorAxisRadius=g.majorAxisRadius,this.minorAxisRadius=g.minorAxisRadius,this._startAngle=g._startAngle,this._endAngle=g._endAngle,this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new lt(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new A(this.center).distanceTo(Ft);return new mt(this.normal,t)}offset(t){const n=this.majorAxisRadius+t,e=this.minorAxisRadius+t;return n<=0||e<=0?null:new lt(this.center,this.normal,this.majorAxis,n,e,this.startAngle,this.endAngle)}}class xt extends ht{constructor(t,n){super(),this._start=new P(t),this._end=new P(n)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const t=new P(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),n=new P(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new O(t,n)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new xt(this._start.clone(),this._end.clone())}project(t){const n=this._end.x-this._start.x,e=this._end.y-this._start.y,s=n*n+e*e;if(s<1e-18)return this._start.clone();let i=((t.x-this._start.x)*n+(t.y-this._start.y)*e)/s;return i=Math.max(0,Math.min(1,i)),new P(this._start.x+i*n,this._start.y+i*e)}nearestPoint(t){return this.project(t)}}class X extends ht{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}static buildFromEdges(t,n=.001){if(t.length===0)return[];const e=[...t],s=[],i=n*n,r=(h,a)=>{const c=h.x-a.x,l=h.y-a.y;return c*c+l*l<=i};for(;e.length>0;){const h=[],a=e.shift();h.push(a);const c=X.getEdgeStartPoint(a);let l=X.getEdgeEndPoint(a);if(!r(c,l))for(;e.length>0;){const u=X.findConnectingEdge(e,l,i);if(u.index<0)break;let d=e.splice(u.index,1)[0];if(u.reverse&&(d=X.reverseEdge(d)),h.push(d),l=X.getEdgeEndPoint(d),r(l,c))break}s.push(new X(h))}return s}add(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const t=this._curves[0].startPoint;return new P(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let t=0;return this._curves.forEach(n=>{t+=n.length}),t}calculateBoundingBox(){const t=this.getPoints(100),n=new O;return n.setFromPoints(t),n}transform(t){const n=new W().set(t.elements[0],t.elements[3],0,t.elements[6],t.elements[1],t.elements[4],0,t.elements[7],0,0,1,0,0,0,0,1);return this._curves.forEach(e=>{e instanceof et?e.transform(n):e.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new X(this._curves.map(t=>t.clone()))}get closed(){return!0}getPoints(t){const n=[];return this.curves.forEach(e=>{e.getPoints(t).forEach(s=>{n.push(new P(s.x,s.y))})}),n}static findConnectingEdge(t,n,e){let s=-1,i=!1,r=Number.POSITIVE_INFINITY;for(let h=0;h<t.length;h++){const a=t[h],c=X.getEdgeStartPoint(a),l=X.getEdgeEndPoint(a),u=n.x-c.x,d=n.y-c.y,m=u*u+d*d;m<r&&(r=m,s=h,i=!1);const g=n.x-l.x,y=n.y-l.y,x=g*g+y*y;x<r&&(r=x,s=h,i=!0)}return r>e?{index:-1,reverse:!1}:{index:s,reverse:i}}static getEdgeStartPoint(t){const n=t.startPoint;return new P(n.x,n.y)}static getEdgeEndPoint(t){const n=t.endPoint;return new P(n.x,n.y)}static reverseEdge(t){return t instanceof xt?new xt(t.endPoint,t.startPoint):t instanceof G?new G(t.center,t.radius,t.endAngle,t.startAngle,!t.clockwise):t instanceof it?new it(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof et?X.reverseSplineEdge(t):t}static reverseSplineEdge(t){const n=[...t.controlPoints].reverse(),e=t.knots,s=e[0],i=e[e.length-1],r=e.map(c=>s+i-c).reverse(),h=t.weights,a=h.length>0?[...h].reverse():void 0;return new et(n,r,a,t.degree,t.closed)}}class sn{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,n,e,s){this.c0=t,this.c1=e,this.c2=-3*t+3*n-2*e-s,this.c3=2*t-2*n+e+s}initCatmullRom(t,n,e,s,i){this.init(n,e,i*(e-t),i*(s-n))}initNonuniformCatmullRom(t,n,e,s,i,r,h){let a=(n-t)/i-(e-t)/(i+r)+(e-n)/r,c=(e-n)/r-(s-n)/(r+h)+(s-e)/h;a*=r,c*=r,this.init(n,e,a,c)}calc(t){const n=t*t,e=n*t;return this.c0+this.c1*t+this.c2*n+this.c3*e}}class Ct extends yt{constructor(t=[],n=!1,e="centripetal",s=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new A,this._px=new sn,this._py=new sn,this._pz=new sn,this._points=t.map(i=>new M(i)),this._closed=n,this._curveType=e,this._tension=s}get points(){return this._points}get closed(){return this._closed}get curveType(){return this._curveType}get tension(){return this._tension}get startPoint(){return this._points.length>0?this._points[0]:new M}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new M}get length(){if(this._points.length<2)return 0;let t=0;for(let n=1;n<this._points.length;n++)t+=this._points[n-1].distanceTo(this._points[n]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,n=new M){const e=n,s=this._points,i=s.length;if(i===0)return e.set(0,0,0);if(i===1)return e.copy(s[0]);const r=(i-(this._closed?0:1))*t;let h=Math.floor(r),a=r-h;this._closed?h+=h>0?0:(Math.floor(Math.abs(h)/i)+1)*i:a===0&&h===i-1&&(h=i-2,a=1);let c,l;this._closed||h>0?c=s[(h-1)%i]:(this._tmp.subVectors(s[0],s[1]).add(s[0]),c=new M(this._tmp.x,this._tmp.y,this._tmp.z));const u=s[h%i],d=s[(h+1)%i];if(this._closed||h+2<i?l=s[(h+2)%i]:(this._tmp.subVectors(s[i-1],s[i-2]).add(s[i-1]),l=new M(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const m=this._curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(u),m),y=Math.pow(u.distanceToSquared(d),m),x=Math.pow(d.distanceToSquared(l),m);y<1e-4&&(y=1),g<1e-4&&(g=y),x<1e-4&&(x=y),this._px.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,g,y,x),this._py.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,g,y,x),this._pz.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,g,y,x)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(c.x,u.x,d.x,l.x,this._tension),this._py.initCatmullRom(c.y,u.y,d.y,l.y,this._tension),this._pz.initCatmullRom(c.z,u.z,d.z,l.z,this._tension));return e.set(this._px.calc(a),this._py.calc(a),this._pz.calc(a)),e}getPoints(t){const n=[];for(let e=0;e<=t;e++)n.push(this.getPoint(e/t));return n}setPoints(t){this._points=t.map(n=>new M(n)),this._boundingBoxNeedsUpdate=!0}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)}setCurveType(t){this._curveType=t}setTension(t){this._tension=t}clone(){return new Ct(this._points.map(t=>t.clone()),this._closed,this._curveType,this._tension)}transform(t){return this._points=this._points.map(n=>{const e=new M;return e.copy(n),e.applyMatrix4(t),e}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Z;const t=new Z;return this._points.forEach(n=>{t.expandByPoint(n)}),t}}function se(o,t){const n=o.x-t[0],e=o.y-t[1],s=(o.z??0)-(t[2]??0);return n*n+e*e+s*s}class v{constructor(t,n,e,s){this._degree=t,this._knots=[...n],this._controlPoints=e.map(i=>({x:i.x,y:i.y,z:i.z})),this._weights=s?[...s]:new Array(e.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z}))}weights(){return[...this._weights]}clone(){return new v(this._degree,this._knots,this._controlPoints,this._weights)}point(t){return this.evaluate(t).point}evaluate(t){const n=this._controlPoints.map(e=>[e.x,e.y,e.z]);return Nn(t,this._degree,this._knots,n,this._weights)}signedPlanarCurvatureAt(t){const n=this.evaluate(t);return jn(n.deriv1,n.deriv2)}getOffsetSamplePath2d(t,n=512){const e=Math.abs(t),{start:s,end:i}=this.getParameterRange(),r=this.length(),h=Math.max(64,Math.ceil(r/Math.max(e*.2,1e-6)));let a=ts(s,i,Math.min(h,n));for(let u=0;u<8&&a.length<n;u++){const d=[];for(let m=0;m<a.length-1;m++){const g=a[m],y=a[m+1],x=(g+y)/2,_=Math.max(Math.abs(this.signedPlanarCurvatureAt(g)),Math.abs(this.signedPlanarCurvatureAt(y)),Math.abs(this.signedPlanarCurvatureAt(x)));e*_>.85&&d.push(x)}if(d.length===0)break;if(a=ns(a,d),a.length>n){a=a.slice(0,n);break}}const c=[],l=[];return a.forEach(u=>{const d=this.evaluate(u);c.push(new P(d.point[0],d.point[1]));const m=d.deriv1[0],g=d.deriv1[1],y=Math.hypot(m,g);l.push(y>1e-10?new P(m/y,g/y):new P(1,0))}),{points:c,tangents:l}}length(){const t=this._controlPoints.map(n=>[n.x,n.y,n.z]);return qn(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,n,e,s){return new v(t,n,e,s)}static byPoints(t,n,e="Uniform",s,i){const r=Gt(t,n,e,s,i),h=r.controlPoints.map(a=>({x:a[0],y:a[1],z:a[2]}));return new v(n,r.knots,h,r.weights)}getParameterRange(){const t=this._knots[this._degree],n=this._knots[this._knots.length-this._degree-1];return{start:t,end:n}}getPoints(t){const n=[],{start:e,end:s}=this.getParameterRange();for(let i=0;i<=t;i++){const r=e+(s-e)*(i/t);n.push(this.point(r))}return n}isClosed(t=1e-6){const{start:n,end:e}=this.getParameterRange(),s=this.point(n),i=this.point(e),r=s[0]-i[0],h=s[1]-i[1],a=s[2]-i[2];return Math.sqrt(r*r+h*h+a*a)<t}static createFitPointsForClosedCurve(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const n=new Ct(t,!0,"centripetal"),e=Math.max(50,t.length*2);return n.getPoints(e)}nearestPoint(t,n=64){const{start:e,end:s}=this.getParameterRange();let i=this.point(e),r=se(t,i);for(let h=0;h<=n;h++){const a=e+(s-e)*h/n,c=this.point(a),l=se(t,c);l<r&&(r=l,i=c)}return{x:i[0],y:i[1],z:i[2]??0}}static createClosedCurve(t,n,e="Chord"){const i=this.createFitPointsForClosedCurve(t).map(r=>[r.x,r.y,r.z]);return v.byPoints(i,n,e)}}function ts(o,t,n){if(n<2)return[o,t];const e=[];for(let s=0;s<n;s++)e.push(s===n-1?t:o+(t-o)*s/(n-1));return e}function ns(o,t){const n=[...o,...t].sort((s,i)=>s-i),e=[];return n.forEach(s=>{const i=e[e.length-1];(i===void 0||Math.abs(i-s)>1e-10)&&e.push(s)}),e}class et extends yt{constructor(t,n,e,s,i,r){super();const h=arguments.length;if(this._degree=3,this._closed=!1,Array.isArray(n)){if(h<2||h>5)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._controlPoints=t;let a,c=3,l=!1;if(h>=3&&(Array.isArray(e)?(a=e,h>=4&&(c=s||3),h>=5&&(l=i)):e!==void 0&&(c=e||3,h>=4&&(l=s))),e===void 0&&h>=4&&(c=s||3,h>=5&&(l=i)),this._degree=c,this._closed=l,this._controlPoints.length<this._degree+1)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._nurbsCurve=v.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,a)}else{if(h<2||h>6)throw V.AcCmErrors.ILLEGAL_PARAMETERS;this._fitPoints=t,this._knotParameterization=n,h>=3&&(this._degree=e||3);const a=typeof s=="boolean";h>=4&&a&&(this._closed=s),a?(h>=5&&(this._startTangent=i),h>=6&&(this._endTangent=r)):(h>=4&&(this._startTangent=s),h>=5&&(this._endTangent=i)),this._closed&&(this._startTangent=void 0,this._endTangent=void 0);const c=(this._startTangent?1:0)+(this._endTangent?1:0);if(this._fitPoints.length+c<this._degree+1)throw V.AcCmErrors.ILLEGAL_PARAMETERS;if(this._closed)this._nurbsCurve=v.createClosedCurve(this._fitPoints,this._degree,this._knotParameterization);else{const l=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=v.byPoints(l,this._degree,this._knotParameterization,this._startTangent?this.toNurbsPoint(this._startTangent):void 0,this._endTangent?this.toNurbsPoint(this._endTangent):void 0)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(l=>[l.x,l.y,l.z||0]))}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=v.createFitPointsForClosedCurve(this._fitPoints),n=this.toNurbsPoints(t);this._nurbsCurve=v.byPoints(n,this._degree,this._knotParameterization)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=v.byPoints(t,this._degree,this._knotParameterization,this._startTangent?this.toNurbsPoint(this._startTangent):void 0,this._endTangent?this.toNurbsPoint(this._endTangent):void 0)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(t=>[t.x,t.y,t.z||0]))}else if(this._controlPoints)if(this._closed){const t=v.createFitPointsForClosedCurve(this._controlPoints),n=this.toNurbsPoints(t);this._nurbsCurve=v.byPoints(n,this._degree,this._knotParameterization),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(e=>[e.x,e.y,e.z||0]))}else{const t=this._nurbsCurve.knots(),n=this._nurbsCurve.weights();this._nurbsCurve=v.byKnotsControlPointsWeights(this._degree,t,this._controlPoints,n)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z||0}))}get fitPoints(){var t;return(t=this._fitPoints)==null?void 0:t.map(n=>({x:n.x,y:n.y,z:n.z||0}))}get knots(){return[...this._nurbsCurve.knots()]}get weights(){return[...this._nurbsCurve.weights()]}get startPoint(){const t=this._nurbsCurve.knots(),n=this._nurbsCurve.degree(),e=t[n],s=this._nurbsCurve.point(e);return new M(s[0],s[1],s[2])}get endPoint(){const t=this._nurbsCurve.knots(),n=this._nurbsCurve.degree(),e=t[t.length-n-1],s=this._nurbsCurve.point(e);return new M(s[0],s[1],s[2])}get length(){return this._nurbsCurve.length()}nearestPoint(t,n=64){const e=this._nurbsCurve.nearestPoint(t,n);return new M(e.x,e.y,e.z||0)}evaluateAt(t){const n=this._nurbsCurve.point(t);return new M(n[0],n[1],n[2])}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const n=this._fitPoints.length,e=t<0||t>=n?n-1:t,s=this._fitPoints[e];return{x:s.x,y:s.y,z:s.z||0}}getControlPointAt(t){const n=this._controlPoints.length,e=t<0||t>=n?n-1:t;return this._controlPoints[e]}getOffsetSamplePath2d(t){return this._nurbsCurve.getOffsetSamplePath2d(t)}getPoints(t=100){const n=this._nurbsCurve,e=[],s=n.knots(),i=this._nurbsCurve.degree(),r=s[i],h=s[s.length-i-1],a=(h-r)/(t-1);for(let c=0;c<t;c++){const l=c===t-1?h:r+c*a,u=n.point(l);e.push(new M(u[0],u[1],u[2]))}return e}getCurvePoints(t,n){const e=[],s=t.knots(),i=t.degree(),r=s[i],a=(s[s.length-i-1]-r)/(n-1);for(let c=0;c<n;c++){const l=r+c*a;e.push(t.point(l))}return e}calculateBoundingBox(){const t=this.getPoints(100);return new Z().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}get area(){if(!this._closed)return 0;const t=this.getPoints(128);return Xn(t)}transform(t){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(n=>new M(n).applyMatrix4(t)),this._startTangent&&(this._startTangent=new M(this._startTangent).transformDirection(t)),this._endTangent&&(this._endTangent=new M(this._endTangent).transformDirection(t)),this.buildCurve();else{const n=this._nurbsCurve.knots(),e=this._nurbsCurve.weights();this._controlPoints=this._controlPoints.map(s=>new M(s).applyMatrix4(t)),this._nurbsCurve=v.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,e.length>0?e:void 0)}return this._boundingBoxNeedsUpdate=!0,this}clone(){return this._fitPoints&&this._knotParameterization?new et(this._fitPoints.map(t=>({x:t.x,y:t.y,z:t.z||0})),this._knotParameterization,this._degree,this._closed,this._startTangent?{x:this._startTangent.x,y:this._startTangent.y,z:this._startTangent.z||0}:void 0,this._endTangent?{x:this._endTangent.x,y:this._endTangent.y,z:this._endTangent.z||0}:void 0):new et(this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z||0})),this._nurbsCurve.knots(),this._nurbsCurve.weights(),this._degree,this._closed)}toNurbsPoints(t){const n=new Array(t.length);return t.forEach((e,s)=>{n[s]=[e.x,e.y,e.z||0]}),n}toGePoints(t){const n=new Array(t.length);return t.forEach((e,s)=>{n[s]={x:e[0],y:e[1],z:e[2]}}),n}toNurbsPoint(t){return[t.x,t.y,t.z||0]}static createClosedSpline(t,n="Uniform",e=3){if(t.length<e+1)throw new Error(`At least ${e+1} points are required for a degree ${e} closed spline`);return new et(t,n,e,!0)}}f.AcGeArea2d=en,f.AcGeBox2d=O,f.AcGeBox3d=Z,f.AcGeCatmullRomCurve3d=Ct,f.AcGeCircArc2d=G,f.AcGeCircArc3d=ct,f.AcGeCurve2d=ht,f.AcGeEllipseArc2d=it,f.AcGeEllipseArc3d=lt,f.AcGeEuler=Dt,f.AcGeGeometryUtil=Bn,f.AcGeLine2d=xt,f.AcGeLine3d=at,f.AcGeLoop2d=X,f.AcGeMathUtil=w,f.AcGeMatrix2d=rt,f.AcGeMatrix3d=W,f.AcGeNurbsCurve=v,f.AcGePlane=mt,f.AcGePoint2d=P,f.AcGePoint3d=M,f.AcGePolyline2d=nt,f.AcGeQuaternion=dt,f.AcGeShape2d=Jt,f.AcGeSpline3d=et,f.AcGeTol=B,f.AcGeVector2d=R,f.AcGeVector3d=A,f.DEFAULT_TOL=pt,f.DEG2RAD=jt,f.FLOAT_TOL=K,f.ORIGIN_POINT_2D=ie,f.ORIGIN_POINT_3D=Ft,f.RAD2DEG=qt,f.TAU=I,f.acGeClosedPolygonArea2d=On,f.acGeClosedPolygonArea3d=Xn,f.acGePolygonArea2d=Un,f.acGePolygonArea3d=Fn,f.acGeSignedPolygonArea2d=$t,f.basisFunction=tt,f.calculateCurveLength=qn,f.ceilPowerOfTwo=Pn,f.clamp=Q,f.computeParameterValues=Rn,f.damp=cn,f.degToRad=_n,f.euclideanModulo=Vt,f.evaluateNurbsDerivatives=Nn,f.evaluateNurbsPoint=gt,f.floorPowerOfTwo=pn,f.generateAveragedKnots=kn,f.generateChordKnots=le,f.generateSqrtChordKnots=ue,f.generateUUID=on,f.generateUniformKnots=ce,f.getOcsAngle=fe,f.getOcsReferenceVector=xe,f.intPartLength=vt,f.interpolateControlPoints=me,f.interpolateNurbsCurve=Gt,f.inverseLerp=an,f.isBetween=wn,f.isBetweenAngle=Mn,f.isPointInPolygon=Yt,f.isPolygonIntersect=Tn,f.isPowerOfTwo=An,f.lerp=Lt,f.mapLinear=hn,f.normalizeAngle=ut,f.offsetPointByDirectionInXY=De,f.offsetSmoothedSampledPath=Ze,f.offsetVertexPath=Ye,f.pingpong=ln,f.radToDeg=fn,f.randFloat=gn,f.randFloatSpread=yn,f.randInt=mn,f.relativeEps=zn,f.seededRandom=xn,f.signedPlanarCurvature=jn,f.smootherstep=dn,f.smoothstep=un,f.transformOcsPointToWcs=_e,f.transformWcsPointToOcs=Wt,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
@@ -54,10 +54,6 @@ export declare class AcGeArea2d extends AcGeShape2d {
54
54
  * Outter loop area minus inner loop areas (holes).
55
55
  */
56
56
  get area(): number;
57
- /**
58
- * Calculate signed area of a polygon using Shoelace formula
59
- */
60
- private polygonArea;
61
57
  /**
62
58
  * Calcuate bounding box of each loop in this area and return an array of their bounding box
63
59
  * @param pointBoundaries An array of loop consisted by points
@@ -1 +1 @@
1
- {"version":3,"file":"AcGeArea2d.d.ts","sourceRoot":"","sources":["../../src/geometry/AcGeArea2d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAmB,MAAM,SAAS,CAAA;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,aAAa,EAAE,CAAA;CAC1B;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,cAAc,CAAA;AAExD;;GAEG;AACH,qBAAa,UAAW,SAAQ,WAAW;IACzC,OAAO,CAAC,MAAM,CAAuB;IAErC;;OAEG;;IAMH;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,cAAc;IAKxB;;OAEG;IACH,IAAI,KAAK,IACe,aAAa,CAAC,cAAc,CAAC,CACpD;IAED;;OAEG;IACH,IAAI,MAAM,+BAKT;IAED;;OAEG;IACH,oBAAoB,IAAI,SAAS;IASjC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,YAAY;IAQ9B;;OAEG;IACH,KAAK;IAQL;;;;OAIG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE,EAAE;IAU7C,cAAc;IA8Cd;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAsBjB;IAED;;OAEG;IACH,OAAO,CAAC,WAAW;IAcnB;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAQ9B;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;CAmBjC"}
1
+ {"version":3,"file":"AcGeArea2d.d.ts","sourceRoot":"","sources":["../../src/geometry/AcGeArea2d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAmB,MAAM,SAAS,CAAA;AAG/E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,aAAa,EAAE,CAAA;CAC1B;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,cAAc,CAAA;AAExD;;GAEG;AACH,qBAAa,UAAW,SAAQ,WAAW;IACzC,OAAO,CAAC,MAAM,CAAuB;IAErC;;OAEG;;IAMH;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,cAAc;IAKxB;;OAEG;IACH,IAAI,KAAK,IACe,aAAa,CAAC,cAAc,CAAC,CACpD;IAED;;OAEG;IACH,IAAI,MAAM,+BAKT;IAED;;OAEG;IACH,oBAAoB,IAAI,SAAS;IASjC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,YAAY;IAQ9B;;OAEG;IACH,KAAK;IAQL;;;;OAIG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE,EAAE;IAU7C,cAAc;IA8Cd;;;OAGG;IACH,IAAI,IAAI,IAAI,MAAM,CAsBjB;IAED;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAQ9B;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;CAmBjC"}