@mlightcad/geometry-engine 3.13.1 → 3.14.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.
- package/dist/geometry-engine.umd.cjs +1 -1
- package/lib/geometry/AcGeCircArc2d.d.ts +24 -0
- package/lib/geometry/AcGeCircArc2d.d.ts.map +1 -1
- package/lib/geometry/AcGeCircArc2d.js +52 -1
- package/lib/geometry/AcGeCircArc2d.js.map +1 -1
- package/lib/geometry/AcGeCircArcUtil.d.ts +18 -0
- package/lib/geometry/AcGeCircArcUtil.d.ts.map +1 -1
- package/lib/geometry/AcGeCircArcUtil.js +37 -0
- package/lib/geometry/AcGeCircArcUtil.js.map +1 -1
- package/lib/geometry/AcGeCurveIntersect.d.ts +64 -0
- package/lib/geometry/AcGeCurveIntersect.d.ts.map +1 -0
- package/lib/geometry/AcGeCurveIntersect.js +941 -0
- package/lib/geometry/AcGeCurveIntersect.js.map +1 -0
- package/lib/geometry/index.d.ts +3 -0
- package/lib/geometry/index.d.ts.map +1 -1
- package/lib/geometry/index.js +2 -0
- package/lib/geometry/index.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(_,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("@mlightcad/common")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/common"],R):(_=typeof globalThis<"u"?globalThis:_||self,R(_["geometry-engine"]={},_.common))})(this,(function(_,R){"use strict";const q=["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 ln=1234567;const Vt=Math.PI/180,Ut=180/Math.PI;function un(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,e=Math.random()*4294967295|0;return(q[r&255]+q[r>>8&255]+q[r>>16&255]+q[r>>24&255]+"-"+q[t&255]+q[t>>8&255]+"-"+q[t>>16&15|64]+q[t>>24&255]+"-"+q[n&63|128]+q[n>>8&255]+"-"+q[n>>16&255]+q[n>>24&255]+q[e&255]+q[e>>8&255]+q[e>>16&255]+q[e>>24&255]).toLowerCase()}function K(r,t,n){return Math.max(t,Math.min(n,r))}function Ft(r,t){return(r%t+t)%t}function dn(r,t,n,e,s){return e+(r-t)*(s-e)/(n-t)}function gn(r,t,n){return r!==t?(n-r)/(t-r):0}function Ot(r,t,n){return(1-n)*r+n*t}function mn(r,t,n,e){return Ot(r,t,1-Math.exp(-n*e))}function yn(r,t=1){return t-Math.abs(Ft(r,t*2)-t)}function xn(r,t,n){return r<=t?0:r>=n?1:(r=(r-t)/(n-t),r*r*(3-2*r))}function fn(r,t,n){return r<=t?0:r>=n?1:(r=(r-t)/(n-t),r*r*r*(r*(r*6-15)+10))}function _n(r,t){return r+Math.floor(Math.random()*(t-r+1))}function An(r,t){return r+Math.random()*(t-r)}function Pn(r){return r*(.5-Math.random())}function pn(r){r!==void 0&&(ln=r);let t=ln+=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 wn(r){return r*Vt}function Mn(r){return r*Ut}function zn(r){return(r&r-1)===0&&r!==0}function bn(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function Sn(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function ot(r){const t=Math.PI*2;return(r%t+t)%t}function Cn(r,t,n){return r>t&&r<n||r>n&&r<t}function En(r,t,n,e=!1){return r=ot(r),t=ot(t),n=ot(n),e?t>n?r<=t&&r>=n:r<=t||r>=n:t<n?r>=t&&r<=n:r>=t||r<=n}function Tn(r,t,n){const e=ot(n-r);return ot(t-r)<=e+1e-7}function Dt(r){return r=Math.abs(r),r<1?0:Math.ceil(Math.log10(Math.abs(r)+1))}function In(r,t=1e-7){const n=Dt(r);return Math.max(Math.pow(10,n)*t,t)}const p={DEG2RAD:Vt,RAD2DEG:Ut,generateUUID:un,clamp:K,euclideanModulo:Ft,mapLinear:dn,inverseLerp:gn,lerp:Ot,damp:mn,pingpong:yn,smoothstep:xn,smootherstep:fn,randInt:_n,randFloat:An,randFloatSpread:Pn,seededRandom:pn,degToRad:wn,radToDeg:Mn,isPowerOfTwo:zn,ceilPowerOfTwo:bn,floorPowerOfTwo:Sn,normalizeAngle:ot,isBetween:Cn,isBetweenAngle:En,isAngleOnCcwSweep:Tn,intPartLength:Dt,relativeEps:In},pt=class pt{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 R.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 pt(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,o=this.y-t.y;return this.x=i*e-o*s+t.x,this.y=i*s+o*e+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(p.relativeEps(this.x,t),p.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};pt.EMPTY=Object.freeze(new pt(0,0));let N=pt;const wt=class wt{constructor(t,n,e,s,i,o,h,a,c){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&n!=null&&e!=null&&s!=null&&i!=null&&o!=null&&h!=null&&a!=null&&c!=null&&this.set(t,n,e,s,i,o,h,a,c)}set(t,n,e,s,i,o,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]=o,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,o=e[0],h=e[3],a=e[6],c=e[1],l=e[4],u=e[7],d=e[2],g=e[5],m=e[8],y=s[0],f=s[3],x=s[6],b=s[1],w=s[4],I=s[7],B=s[2],T=s[5],C=s[8];return i[0]=o*y+h*b+a*B,i[3]=o*f+h*w+a*T,i[6]=o*x+h*I+a*C,i[1]=c*y+l*b+u*B,i[4]=c*f+l*w+u*T,i[7]=c*x+l*I+u*C,i[2]=d*y+g*b+m*B,i[5]=d*f+g*w+m*T,i[8]=d*x+g*I+m*C,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],o=t[4],h=t[5],a=t[6],c=t[7],l=t[8];return n*o*l-n*h*c-e*i*l+e*h*a+s*i*c-s*o*a}invert(){const t=this.elements,n=t[0],e=t[1],s=t[2],i=t[3],o=t[4],h=t[5],a=t[6],c=t[7],l=t[8],u=l*o-h*c,d=h*a-l*i,g=c*i-o*a,m=n*u+e*d+s*g;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/m;return t[0]=u*y,t[1]=(s*c-l*e)*y,t[2]=(h*e-s*o)*y,t[3]=d*y,t[4]=(l*n-s*a)*y,t[5]=(s*i-h*n)*y,t[6]=g*y,t[7]=(e*a-c*n)*y,t[8]=(o*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,o,h){const a=Math.cos(i),c=Math.sin(i);return this.set(e*a,e*c,-e*(a*o+c*h)+o+t,-s*c,s*a,-s*(-c*o+a*h)+h+n,0,0,1),this}scale(t,n){return this.premultiply(Xt.makeScale(t,n)),this}rotate(t){return this.premultiply(Xt.makeRotation(-t)),this}translate(t,n){return this.premultiply(Xt.makeTranslation(t,n)),this}makeTranslation(t,n){return t instanceof N?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 wt().fromArray(this.elements)}};wt.IDENTITY=Object.freeze(new wt);let ct=wt;const Xt=new ct,O=1e-6,S=2*Math.PI,ge={x:0,y:0},Yt={x:0,y:0,z:0};class M{constructor(){this.equalPointTol=O,this.equalVectorTol=O}clone(){const t=new M;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t}equalPoint2d(t,n){return new N(t).sub(n).length()<this.equalPointTol}equalPoint3d(t,n){return new A(t).sub(n).length()<this.equalPointTol}static equalToZero(t,n=O){return t<n&&t>-n}static equal(t,n,e=O){return Math.abs(t-n)<e}static great(t,n,e=O){return t-n>e}static less(t,n,e=O){return t-n<e}static isPositive(t,n=O){return t>n}static isNonPositive(t,n=O){return t<=n}}const zt=new M;class yt{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,o,h){let a=e[s+0],c=e[s+1],l=e[s+2],u=e[s+3];const d=i[o+0],g=i[o+1],m=i[o+2],y=i[o+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]=g,t[n+2]=m,t[n+3]=y;return}if(u!==y||a!==d||c!==g||l!==m){let f=1-h;const x=a*d+c*g+l*m+u*y,b=x>=0?1:-1,w=1-x*x;if(w>Number.EPSILON){const B=Math.sqrt(w),T=Math.atan2(B,x*b);f=Math.sin(f*T)/B,h=Math.sin(h*T)/B}const I=h*b;if(a=a*f+d*I,c=c*f+g*I,l=l*f+m*I,u=u*f+y*I,f===1-h){const B=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=B,c*=B,l*=B,u*=B}}t[n]=a,t[n+1]=c,t[n+2]=l,t[n+3]=u}static multiplyQuaternionsFlat(t,n,e,s,i,o){const h=e[s],a=e[s+1],c=e[s+2],l=e[s+3],u=i[o],d=i[o+1],g=i[o+2],m=i[o+3];return t[n]=h*m+l*u+a*g-c*d,t[n+1]=a*m+l*d+c*u-h*g,t[n+2]=c*m+l*g+h*d-a*u,t[n+3]=l*m-h*u-a*d-c*g,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 yt(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,o=t.order,h=Math.cos,a=Math.sin,c=h(e/2),l=h(s/2),u=h(i/2),d=a(e/2),g=a(s/2),m=a(i/2);switch(o){case"XYZ":this._x=d*l*u+c*g*m,this._y=c*g*u-d*l*m,this._z=c*l*m+d*g*u,this._w=c*l*u-d*g*m;break;case"YXZ":this._x=d*l*u+c*g*m,this._y=c*g*u-d*l*m,this._z=c*l*m-d*g*u,this._w=c*l*u+d*g*m;break;case"ZXY":this._x=d*l*u-c*g*m,this._y=c*g*u+d*l*m,this._z=c*l*m+d*g*u,this._w=c*l*u-d*g*m;break;case"ZYX":this._x=d*l*u-c*g*m,this._y=c*g*u+d*l*m,this._z=c*l*m-d*g*u,this._w=c*l*u+d*g*m;break;case"YZX":this._x=d*l*u+c*g*m,this._y=c*g*u+d*l*m,this._z=c*l*m-d*g*u,this._w=c*l*u-d*g*m;break;case"XZY":this._x=d*l*u-c*g*m,this._y=c*g*u-d*l*m,this._z=c*l*m+d*g*u,this._w=c*l*u+d*g*m;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],o=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 g=.5/Math.sqrt(d+1);this._w=.25/g,this._x=(l-a)*g,this._y=(i-c)*g,this._z=(o-s)*g}else if(e>h&&e>u){const g=2*Math.sqrt(1+e-h-u);this._w=(l-a)/g,this._x=.25*g,this._y=(s+o)/g,this._z=(i+c)/g}else if(h>u){const g=2*Math.sqrt(1+h-e-u);this._w=(i-c)/g,this._x=(s+o)/g,this._y=.25*g,this._z=(a+l)/g}else{const g=2*Math.sqrt(1+u-e-h);this._w=(o-s)/g,this._x=(i+c)/g,this._y=(a+l)/g,this._z=.25*g}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(K(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,o=t._w,h=n._x,a=n._y,c=n._z,l=n._w;return this._x=e*l+o*h+s*c-i*a,this._y=s*l+o*a+i*h-e*c,this._z=i*l+o*c+e*a-s*h,this._w=o*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,o=this._w;let h=o*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=o,this._x=e,this._y=s,this._z=i,this;const a=1-h*h;if(a<=Number.EPSILON){const g=1-n;return this._w=g*o+n*this._w,this._x=g*e+n*this._x,this._y=g*s+n*this._y,this._z=g*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=o*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 v=class v{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:o,z:h}=t;this.x=i,this.y=o,this.z=h||0;return}if(s===3){this.x=t,this.y=n,this.z=e;return}throw R.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 v(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,o=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])*o,this.y=(i[1]*n+i[5]*e+i[9]*s+i[13])*o,this.z=(i[2]*n+i[6]*e+i[10]*s+i[14])*o,this}applyQuaternion(t){const n=this.x,e=this.y,s=this.z,i=t.x,o=t.y,h=t.z,a=t.w,c=2*(o*s-h*e),l=2*(h*n-i*s),u=2*(i*e-o*n);return this.x=n+a*c+o*u-h*l,this.y=e+a*l+h*c-i*u,this.z=s+a*u+i*l-o*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,o=n.x,h=n.y,a=n.z;return this.x=s*a-i*h,this.y=i*o-e*a,this.z=e*h-s*o,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 Zt.copy(this).projectOnVector(t),this.sub(Zt)}reflect(t){return this.sub(Zt.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}};v.ORIGIN=Object.freeze(new v(0,0,0)),v.X_AXIS=Object.freeze(new v(1,0,0)),v.NEGATIVE_X_AXIS=Object.freeze(new v(-1,0,0)),v.Y_AXIS=Object.freeze(new v(0,1,0)),v.NEGATIVE_Y_AXIS=Object.freeze(new v(0,-1,0)),v.Z_AXIS=Object.freeze(new v(0,0,1)),v.NEGATIVE_Z_AXIS=Object.freeze(new v(0,0,-1));let A=v;const Zt=new A,Bn=new yt,mt=class mt{static makeTranslation(t,n,e){return new mt().makeTranslation(t,n,e)}constructor(t,n,e,s,i,o,h,a,c,l,u,d,g,m,y,f){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&&o!=null&&h!=null&&a!=null&&c!=null&&l!=null&&u!=null&&d!=null&&g!=null&&m!=null&&y!=null&&f!=null&&this.set(t,n,e,s,i,o,h,a,c,l,u,d,g,m,y,f)}set(t,n,e,s,i,o,h,a,c,l,u,d,g,m,y,f){const x=this.elements;return x[0]=t,x[4]=n,x[8]=e,x[12]=s,x[1]=i,x[5]=o,x[9]=h,x[13]=a,x[2]=c,x[6]=l,x[10]=u,x[14]=d,x[3]=g,x[7]=m,x[11]=y,x[15]=f,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 mt().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){const n=Math.hypot(t.x,t.y,t.z);if(!Number.isFinite(n)||n<1e-12)return this.identity(),this;const e=Math.abs(n-1)>1e-6?t.clone().multiplyScalar(1/n):t;if(zt.equalPoint3d(e,A.Z_AXIS))this.identity();else{const s=new A(1,0,0);Math.abs(e.x)<1/64&&Math.abs(e.y)<1/64?s.crossVectors(A.Y_AXIS,e).normalize():s.crossVectors(A.Z_AXIS,e).normalize();const i=e.clone().cross(s).normalize();this.makeBasis(s,i,e)}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/lt.setFromMatrixColumn(t,0).length(),i=1/lt.setFromMatrixColumn(t,1).length(),o=1/lt.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]*o,n[9]=e[9]*o,n[10]=e[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(t){return this.compose(me,t,ye)}lookAt(t,n,e){const s=this.elements;return D.subVectors(t,n),D.lengthSq()===0&&(D.z=1),D.normalize(),nt.crossVectors(e,D),nt.lengthSq()===0&&(Math.abs(e.z)===1?D.x+=1e-4:D.z+=1e-4,D.normalize(),nt.crossVectors(e,D)),nt.normalize(),bt.crossVectors(D,nt),s[0]=nt.x,s[4]=bt.x,s[8]=D.x,s[1]=nt.y,s[5]=bt.y,s[9]=D.y,s[2]=nt.z,s[6]=bt.z,s[10]=D.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,o=e[0],h=e[4],a=e[8],c=e[12],l=e[1],u=e[5],d=e[9],g=e[13],m=e[2],y=e[6],f=e[10],x=e[14],b=e[3],w=e[7],I=e[11],B=e[15],T=s[0],C=s[4],rt=s[8],E=s[12],V=s[1],U=s[5],H=s[9],tt=s[13],F=s[2],Nt=s[6],Rt=s[10],kt=s[14],vt=s[3],qt=s[7],jt=s[11],Lt=s[15];return i[0]=o*T+h*V+a*F+c*vt,i[4]=o*C+h*U+a*Nt+c*qt,i[8]=o*rt+h*H+a*Rt+c*jt,i[12]=o*E+h*tt+a*kt+c*Lt,i[1]=l*T+u*V+d*F+g*vt,i[5]=l*C+u*U+d*Nt+g*qt,i[9]=l*rt+u*H+d*Rt+g*jt,i[13]=l*E+u*tt+d*kt+g*Lt,i[2]=m*T+y*V+f*F+x*vt,i[6]=m*C+y*U+f*Nt+x*qt,i[10]=m*rt+y*H+f*Rt+x*jt,i[14]=m*E+y*tt+f*kt+x*Lt,i[3]=b*T+w*V+I*F+B*vt,i[7]=b*C+w*U+I*Nt+B*qt,i[11]=b*rt+w*H+I*Rt+B*jt,i[15]=b*E+w*tt+I*kt+B*Lt,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],o=t[1],h=t[5],a=t[9],c=t[13],l=t[2],u=t[6],d=t[10],g=t[14],m=t[3],y=t[7],f=t[11],x=t[15];return m*(+i*a*u-s*c*u-i*h*d+e*c*d+s*h*g-e*a*g)+y*(+n*a*g-n*c*d+i*o*d-s*o*g+s*c*l-i*a*l)+f*(+n*c*u-n*h*g-i*o*u+e*o*g+i*h*l-e*c*l)+x*(-s*h*l-n*a*u+n*h*d+s*o*u-e*o*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],o=t[4],h=t[5],a=t[6],c=t[7],l=t[8],u=t[9],d=t[10],g=t[11],m=t[12],y=t[13],f=t[14],x=t[15],b=u*f*c-y*d*c+y*a*g-h*f*g-u*a*x+h*d*x,w=m*d*c-l*f*c-m*a*g+o*f*g+l*a*x-o*d*x,I=l*y*c-m*u*c+m*h*g-o*y*g-l*h*x+o*u*x,B=m*u*a-l*y*a-m*h*d+o*y*d+l*h*f-o*u*f,T=n*b+e*w+s*I+i*B;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/T;return t[0]=b*C,t[1]=(y*d*i-u*f*i-y*s*g+e*f*g+u*s*x-e*d*x)*C,t[2]=(h*f*i-y*a*i+y*s*c-e*f*c-h*s*x+e*a*x)*C,t[3]=(u*a*i-h*d*i-u*s*c+e*d*c+h*s*g-e*a*g)*C,t[4]=w*C,t[5]=(l*f*i-m*d*i+m*s*g-n*f*g-l*s*x+n*d*x)*C,t[6]=(m*a*i-o*f*i-m*s*c+n*f*c+o*s*x-n*a*x)*C,t[7]=(o*d*i-l*a*i+l*s*c-n*d*c-o*s*g+n*a*g)*C,t[8]=I*C,t[9]=(m*u*i-l*y*i-m*e*g+n*y*g+l*e*x-n*u*x)*C,t[10]=(o*y*i-m*h*i+m*e*c-n*y*c-o*e*x+n*h*x)*C,t[11]=(l*h*i-o*u*i-l*e*c+n*u*c+o*e*g-n*h*g)*C,t[12]=B*C,t[13]=(l*y*s-m*u*s+m*e*d-n*y*d-l*e*f+n*u*f)*C,t[14]=(m*h*s-o*y*s-m*e*a+n*y*a+o*e*f-n*h*f)*C,t[15]=(o*u*s-l*h*s+l*e*a-n*u*a-o*e*d+n*h*d)*C,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 typeof t=="object"?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z??0,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,o=t.x,h=t.y,a=t.z,c=i*o,l=i*h;return this.set(c*o+e,c*h-s*a,c*a+s*h,0,c*h+s*a,l*h+e,l*a-s*o,0,c*a-s*h,l*a+s*o,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,o){return this.set(1,e,i,0,t,1,o,0,n,s,1,0,0,0,0,1),this}compose(t,n,e){const s=this.elements,i=n.x,o=n.y,h=n.z,a=n.w,c=i+i,l=o+o,u=h+h,d=i*c,g=i*l,m=i*u,y=o*l,f=o*u,x=h*u,b=a*c,w=a*l,I=a*u,B=e.x,T=e.y,C=e.z;return s[0]=(1-(y+x))*B,s[1]=(g+I)*B,s[2]=(m-w)*B,s[3]=0,s[4]=(g-I)*T,s[5]=(1-(d+x))*T,s[6]=(f+b)*T,s[7]=0,s[8]=(m+w)*C,s[9]=(f-b)*C,s[10]=(1-(d+y))*C,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=lt.set(s[0],s[1],s[2]).length();const o=lt.set(s[4],s[5],s[6]).length(),h=lt.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],G.copy(this);const c=1/i,l=1/o,u=1/h;return G.elements[0]*=c,G.elements[1]*=c,G.elements[2]*=c,G.elements[4]*=l,G.elements[5]*=l,G.elements[6]*=l,G.elements[8]*=u,G.elements[9]*=u,G.elements[10]*=u,n.setFromRotationMatrix(G),e.x=i,e.y=o,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}};mt.IDENTITY=Object.freeze(new mt);let Q=mt;const lt=new A,G=new Q,me=new A(0,0,0),ye=new A(1,1,1),nt=new A,bt=new A,D=new A;class W{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(Gt.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=Gt.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new W().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,Gt).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],Gt=new A,Nn=new N;class Z{constructor(t=void 0,n=void 0){this.min=t==null?new N(1/0,1/0):new N(t.x,t.y),this.max=n==null?new N(-1/0,-1/0):new N(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=Nn.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=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 N(0,0):new N(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new N(0,0):new N(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,Nn).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 Rn=new A,xe=new A,fe=new ct;class xt{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=Rn.subVectors(e,n).cross(xe.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||fe.getNormalMatrix(t),s=this.coplanarPoint(Rn).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 xt().copy(this)}}class P extends N{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 z extends A{clone(){return new z(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,o)=>{i.toArray(s,o*e)}),s}}const kn=new Q,vn=new yt,Mt=class Mt{constructor(t=0,n=0,e=0,s=Mt.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 Mt(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],o=s[4],h=s[8],a=s[1],c=s[5],l=s[9],u=s[2],d=s[6],g=s[10];switch(n){case"XYZ":this._y=Math.asin(K(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-l,g),this._z=Math.atan2(-o,i)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-K(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(h,g),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(K(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,g),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-K(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,g),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(K(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,g));break;case"XZY":this._z=Math.asin(-K(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(h,i)):(this._x=Math.atan2(-l,g),this._y=0);break}return this._order=n,e===!0&&this._onChangeCallback(),this}setFromQuaternion(t,n,e=!0){return kn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(kn,n,e)}setFromVector3(t,n=this._order){return this.set(t.x,t.y,t.z,n)}reorder(t){return vn.setFromEuler(this),this.setFromQuaternion(vn,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}};Mt.DEFAULT_ORDER="XYZ";let Wt=Mt;function _e(r){const t=r;return{x:r.x,y:r.y,z:t.z??0}}function Ae(r,t){r.x+=t.x,r.y+=t.y,r.z=(r.z??0)+(t.z??0)}function Pe(r,t,n=!1){const e=r.x,s=r.y;let i=!1;const o=t.length;for(let h=0,a=o-1;h<o;a=h++){const c=t[h].x,l=t[h].y,u=t[a].x,d=t[a].y;let g=l>s!=d>s;n&&(g=l>=s!=d>=s),g&&e<(u-c)*(s-l)/(d-l)+c&&(i=!i)}return i}function pe(r,t){if(r.length===0||t.length===0)return!1;const n=new Z().setFromPoints(r),e=new Z().setFromPoints(t);if(!n.intersectsBox(e))return!1;for(let s=0;s<r.length;){if(j.isPointInPolygon(r[s],t,!0))return!0;s<r.length-1&&zt.equalPoint2d(r[s+1],r[s])&&++s,++s}return!1}const j={applyOffsetToPoint3d:Ae,isPointInPolygon:Pe,isPolygonIntersect:pe,point2dToPoint3d:_e};function we(r,t){const n=[],e=t-1,s=r;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 Me(r,t){const n=t.length-1,e=r,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 o=[];for(let h=0;h<=e;h++)o.push(0);for(let h=1;h<=n-e;h++){const a=s[h]/i;o.push(a*(n-e+1))}for(let h=0;h<=e;h++)o.push(n-e+1);return o}function qn(r,t="Uniform"){const n=r.length;if(n===0)return[];if(n===1)return[0];const e=n-1;if(t==="Uniform")return new Array(n).fill(0).map((o,h)=>h/e);const s=[0];let i=0;for(let o=1;o<=e;o++){const h=r[o][0]-r[o-1][0],a=r[o][1]-r[o-1][1],c=r[o][2]-r[o-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((o,h)=>h/e):s.map(o=>o/i)}function jn(r,t){const n=t.length-1,e=r,s=n+e+1,i=new Array(s+1).fill(0),o=t[t.length-1];for(let h=s-e;h<=s;h++)i[h]=o;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 ze(r,t){const n=t.length-1,e=r,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 o=[];for(let h=0;h<=e;h++)o.push(0);for(let h=1;h<=n-e;h++){const a=s[h]/i;o.push(a*(n-e+1))}for(let h=0;h<=e;h++)o.push(n-e+1);return o}function Kt(r,t){const n=r.length,e=r.map(o=>o.slice()),s=t.slice();for(let o=0;o<n;o++){let h=o,a=Math.abs(e[o][o]);for(let c=o+1;c<n;c++){const l=Math.abs(e[c][o]);l>a&&(a=l,h=c)}if(a<1e-12)throw new Error("Interpolation matrix is singular.");if(h!==o){const c=e[o];e[o]=e[h],e[h]=c;const l=s[o];s[o]=s[h],s[h]=l}for(let c=o+1;c<n;c++){const l=e[c][o]/e[o][o];if(!(Math.abs(l)<1e-14)){for(let u=o;u<n;u++)e[c][u]-=l*e[o][u];s[c]-=l*s[o]}}}const i=new Array(n).fill(0);for(let o=n-1;o>=0;o--){let h=s[o];for(let a=o+1;a<n;a++)h-=e[o][a]*i[a];i[o]=h/e[o][o]}return i}function Qt(r,t,n="Uniform",e,s){if(r.length===0)return{controlPoints:[],knots:[],weights:[]};const i=r.map(E=>[E[0],E[1],E[2]??0]),o=!!e,h=!!s,a=(o?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=qn(i,n),d=u.slice();o&&d.unshift(u[0]),h&&d.push(u[u.length-1]);const g=jn(t,d),m=l+1,y=new Array(m),f=new Array(m),x=new Array(m),b=new Array(m);let w=0;y[w]=new Array(m).fill(0),y[w][0]=1,f[w]=i[0][0],x[w]=i[0][1],b[w]=i[0][2],w++;for(let E=1;E<=c-1;E++){const V=u[E];y[w]=new Array(m).fill(0);for(let U=0;U<=l;U++)y[w][U]=et(U,t,V,g);f[w]=i[E][0],x[w]=i[E][1],b[w]=i[E][2],w++}if(y[w]=new Array(m).fill(0),y[w][l]=1,f[w]=i[c][0],x[w]=i[c][1],b[w]=i[c][2],w++,o){const E=g[t+1]-g[0],V=E!==0?t/E:0;y[w]=new Array(m).fill(0),y[w][0]=-V,y[w][1]=V,f[w]=(e==null?void 0:e[0])??0,x[w]=(e==null?void 0:e[1])??0,b[w]=(e==null?void 0:e[2])??0,w++}if(h){const E=g[l+t+1]-g[l],V=E!==0?t/E:0;y[w]=new Array(m).fill(0),y[w][l-1]=-V,y[w][l]=V,f[w]=(s==null?void 0:s[0])??0,x[w]=(s==null?void 0:s[1])??0,b[w]=(s==null?void 0:s[2])??0,w++}const I=Kt(y,f),B=Kt(y,x),T=Kt(y,b),C=new Array(m);for(let E=0;E<m;E++)C[E]=[I[E],B[E],T[E]];const rt=new Array(m).fill(1);return{controlPoints:C,knots:g,weights:rt}}function et(r,t,n,e){if(t===0)return n>=e[r]&&n<e[r+1]?1:0;const s=e[r+t]-e[r],i=e[r+t+1]-e[r+1],o=s>1e-10?(n-e[r])/s:0,h=i>1e-10?(e[r+t+1]-n)/i:0;return o*et(r,t-1,n,e)+h*et(r+1,t-1,n,e)}function ft(r,t,n,e,s){const i=e.length-1,o=t;if(r=Math.max(n[o],Math.min(n[i+1],r)),Math.abs(r-n[i+1])<1e-8)return[...e[i]];if(Math.abs(r-n[o])<1e-8)return[...e[0]];const h=[0,0,0];let a=0;for(let c=0;c<=i;c++){const l=et(c,o,r,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-o-1];if(Math.abs(r-c)<1e-8)return[...e[i]];if(Math.abs(r-n[o])<1e-8)return[...e[0]]}return Math.abs(a)>=1e-10&&(h[0]/=a,h[1]/=a,h[2]/=a),h}function $t(r,t,n,e){if(t===0)return 0;const s=e[r+t]-e[r],i=e[r+t+1]-e[r+1];let o=0;return s>1e-10&&(o+=t/s*et(r,t-1,n,e)),i>1e-10&&(o-=t/i*et(r+1,t-1,n,e)),o}function be(r,t,n,e){if(t<=1)return 0;const s=e[r+t]-e[r],i=e[r+t+1]-e[r+1];let o=0;return s>1e-10&&(o+=t/s*$t(r,t-1,n,e)),i>1e-10&&(o-=t/i*$t(r+1,t-1,n,e)),o}function Ln(r,t,n,e,s){const i=e.length-1,o=t,h=n[o],a=n[i+1];r=Math.max(h,Math.min(a,r));const c=[0,0,0],l=[0,0,0],u=[0,0,0];let d=0,g=0,m=0;for(let T=0;T<=i;T++){const C=et(T,o,r,n),rt=$t(T,o,r,n),E=be(T,o,r,n),V=s[T],U=V*C,H=V*rt,tt=V*E,F=e[T];c[0]+=U*F[0],c[1]+=U*F[1],c[2]+=U*F[2],l[0]+=H*F[0],l[1]+=H*F[1],l[2]+=H*F[2],u[0]+=tt*F[0],u[1]+=tt*F[1],u[2]+=tt*F[2],d+=U,g+=H,m+=tt}if(Math.abs(d)<1e-10)return{point:ft(r,t,n,e,s),deriv1:[0,0,0],deriv2:[0,0,0]};const y=d*d,f=[c[0]/d,c[1]/d,c[2]/d],x=[(l[0]*d-c[0]*g)/y,(l[1]*d-c[1]*g)/y,(l[2]*d-c[2]*g)/y],b=u[0]*d-c[0]*m,w=u[1]*d-c[1]*m,I=u[2]*d-c[2]*m,B=[b/y-2*g*x[0]/d,w/y-2*g*x[1]/d,I/y-2*g*x[2]/d];return{point:f,deriv1:x,deriv2:B}}function Vn(r,t){const n=r[0],e=r[1],s=t[0],i=t[1],o=n*n+e*e;return o<1e-20?0:(n*i-e*s)/Math.pow(o,1.5)}function Un(r,t,n,e){const s=r,i=t[s],o=t[t.length-s-1];let h=0;const a=1e3,c=(o-i)/a;let l=ft(i,r,t,n,e);for(let y=1;y<=a;y++){const f=i+y*c,x=ft(f,r,t,n,e),b=x[0]-l[0],w=x[1]-l[1],I=x[2]-l[2];h+=Math.sqrt(b*b+w*w+I*I),l=x}const u=ft(o,r,t,n,e),d=u[0]-l[0],g=u[1]-l[1],m=u[2]-l[2];return h+=Math.sqrt(d*d+g*g+m*m),h}function Se(r,t=3,n="Uniform",e,s){return r.length===0?[]:Qt(r,t,n,e,s).controlPoints}const Fn=new Q,On=new A,Ce=new A,Ee=new A,Jt=new z;function Dn(r){return new Q().setFromExtrusionDirection(new A(r.x,r.y,r.z))}function Te(r){return Fn.setFromExtrusionDirection(new A(r.x,r.y,r.z)),Fn.extractBasis(On,Ce,Ee),On.clone()}function Ie(r,t){return new z(r.x,r.y,r.z??0).applyMatrix4(Dn(t))}function Ht(r,t){return new z(r.x,r.y,r.z??0).applyMatrix4(Dn(t).invert())}function Be(r,t,n){const e=Ht(r,n),s=Ht(t,n);return Jt.set(s.x-e.x,s.y-e.y,(s.z??0)-(e.z??0)),p.normalizeAngle(Math.atan2(Jt.y,Jt.x))}function tn(r){const t=r.length;if(t<3)return 0;let n=0;for(let e=0,s=t-1;e<t;s=e++){const i=r[s],o=r[e];n+=i.x*o.y-o.x*i.y}return n*.5}function Xn(r){return Math.abs(tn(r))}function Yn(r){const t=r.length;if(t<3)return 0;let n=0,e=0,s=0;for(let i=0,o=t-1;i<t;o=i++){const h=r[o],a=r[i],c=h.x,l=h.y,u=h.z??0,d=a.x,g=a.y,m=a.z??0;n+=(u+m)*(l-g),e+=(c+d)*(u-m),s+=(l+g)*(c-d)}return .5*Math.hypot(n,e,s)}function Zn(r){return r.length<3?0:Xn(r)}function Gn(r){return r.length<3?0:Yn(r)}function nn(r,t,n){const e=r.x,s=r.y,i=t.x,o=t.y,h=n.x,a=n.y,c=2*(e*(o-a)+i*(a-s)+h*(s-o));if(M.equalToZero(c))return null;const l=((e*e+s*s)*(o-a)+(i*i+o*o)*(a-s)+(h*h+a*a)*(s-o))/c,u=((e*e+s*s)*(h-i)+(i*i+o*o)*(e-h)+(h*h+a*a)*(i-e))/c,d=Math.hypot(l-e,u-s);return!Number.isFinite(d)||M.isNonPositive(d)?null:{center:new P(l,u),radius:d}}function Wn(r,t,n){const e=r.x,s=r.y,i=r.z??0,o=new A(t.x-e,t.y-s,(t.z??0)-i),h=new A(n.x-e,n.y-s,(n.z??0)-i),a=new A().crossVectors(o,h),c=a.lengthSq();if(c<O*O)return null;const l=o.lengthSq(),u=h.lengthSq(),d=new A().crossVectors(a,o).multiplyScalar(u).add(new A().crossVectors(h,a).multiplyScalar(l)).multiplyScalar(1/(2*c)),g=new z(e+d.x,s+d.y,i+d.z),m=Math.hypot(g.x-e,g.y-s,g.z-i);return!Number.isFinite(m)||M.isNonPositive(m)?null:{center:g,radius:m}}function st(r,t){return Math.atan2(t.y-r.y,t.x-r.x)}function J(r,t){return Math.hypot(t.x-r.x,t.y-r.y)}function Kn(r,t,n){if(M.isNonPositive(t))return null;const e=n.x-r.x,s=n.y-r.y,i=Math.hypot(e,s);if(M.isNonPositive(i))return null;const o=t/i;return new P(r.x+e*o,r.y+s*o)}function Qn(r,t,n,e=!1){const s=nn(r,t,n);if(!s)return null;const i=st(s.center,r),o=st(s.center,t),h=st(s.center,n);let a=!p.isAngleOnCcwSweep(i,o,h);return e&&(a=!a),L.fromMathAngles(s.center,s.radius,i,h,a)}function en(r,t){return!Number.isFinite(t)||M.isNonPositive(t)?null:new L(r,t,0,S,!1)}function Ne(r,t){const n=J(r,t);return M.isNonPositive(n)?null:en({x:(r.x+t.x)/2,y:(r.y+t.y)/2},n/2)}function Re(r,t,n){const e=nn(r,t,n);return e?en(e.center,e.radius):null}function ke(r,t,n){const e=J(n,r);if(M.isNonPositive(e))return null;const s=st(n,r),i=st(n,t),o=p.normalizeAngle(i-s);return L.fromMathAngles(n,e,s,i,o>Math.PI)}function _t(r,t,n,e){const s=J(r,t),i=J(r,n);if(M.isNonPositive(s)||M.isNonPositive(i))return null;const o=Math.max(O,s*O);return Math.abs(s-i)>o?null:L.fromMathAngles(r,s,st(r,t),st(r,n),e)}function ve(r,t,n,e){const s=J(r,t);if(M.isNonPositive(s))return null;const i=Kn(r,s,n);return i?_t(r,t,i,e):null}function $n(r,t,n){const e=J(r,t),s=Math.abs(n);if(M.isNonPositive(e)||M.isNonPositive(s)||!M.great(S-s,0))return null;const i=n<0,o=st(r,t),h=i?o-s:o+s;return L.fromMathAngles(r,e,o,h,i)}function qe(r,t,n){const e=J(r,t),s=Math.abs(n);if(M.isNonPositive(e)||M.isNonPositive(s)||M.great(s,2*e))return null;const i=Math.max(-1,Math.min(1,s/(2*e))),o=2*Math.asin(i);return $n(r,t,n>=0?o:-o)}function je(r,t,n){const e=J(r,t),s=Math.abs(n);if(M.isNonPositive(e)||M.isNonPositive(s)||!M.great(S-s,0))return null;const i=Math.sin(s/2);if(M.equalToZero(i))return null;const o=e/(2*i),h=o*o-e*e/4;if(M.less(h,0))return null;const a=Math.sqrt(Math.max(0,h)),c=(r.x+t.x)/2,l=(r.y+t.y)/2,u=t.x-r.x,g=-(t.y-r.y)/e,m=u/e,y=n>=0,x=y&&s<=Math.PI||!y&&s>Math.PI?1:-1,b={x:c+g*a*x,y:l+m*a*x};return _t(b,r,t,!y)}function Le(r,t,n){const e=Math.cos(n),s=Math.sin(n),i=t.x-r.x,o=t.y-r.y,h=-s,a=e,c=2*(i*h+o*a);if(M.equalToZero(c))return null;const l=(i*i+o*o)/c;if(!Number.isFinite(l))return null;const u={x:r.x+h*l,y:r.y+a*l},d=r.x-u.x,g=r.y-u.y,m=d*s-g*e;return M.equalToZero(m)?null:_t(u,r,t,m<0)}function Ve(r,t,n){const e=Math.abs(n),s=J(r,t);if(M.isNonPositive(e)||M.isNonPositive(s)||M.great(s,2*e))return null;const i=(r.x+t.x)/2,o=(r.y+t.y)/2,h=t.x-r.x,c=-(t.y-r.y)/s,l=h/s,u=Math.sqrt(Math.max(0,e*e-s*s/4)),d=n>=0?1:-1,g={x:i+c*u*d,y:o+l*u*d};return _t(g,r,t,n<0)}class Jn{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class sn extends Jn{translate(t){return this.transform(new ct().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class ut extends sn{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 o=1;o<=t;o++)e=this.getPoint(o/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 o;n?o=n:o=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]-o,c<0)h=s+1;else if(c>0)a=s-1;else{a=s;break}if(s=a,e[s]===o)return s/(i-1);const l=e[s],d=e[s+1]-l,g=(o-l)/d;return(s+g)/(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),o=this.getPoint(s),h=new P;return h.copy(o).sub(i).normalize(),h}getTangentAt(t){const n=this.getUtoTmapping(t);return this.getTangent(n)}}class L extends ut{constructor(t,n,e,s,i){super();const o=+(t!==void 0)+ +(n!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(i!==void 0);if(o==3)typeof t=="object"&&typeof n=="object"&&typeof e=="object"?this.createByThreePoints(t,n,e):this.createByStartEndPointsAndBulge(t,n,e);else if(o==5){const h=t;this.center=new P(h.x,h.y),this.radius=n,this._clockwise=i,this._startAngle=this._clockwise?this._mirrorAngle(p.normalizeAngle(e)):p.normalizeAngle(e),this._endAngle=this._clockwise?this._mirrorAngle(p.normalizeAngle(s)):p.normalizeAngle(s)}else throw R.AcCmErrors.ILLEGAL_PARAMETERS}static fromMathAngles(t,n,e,s,i){const o=new L(t,n,p.normalizeAngle(e),p.normalizeAngle(s),!1);return o._clockwise=i,o._boundingBoxNeedsUpdate=!0,o}static computeCircumcircle(t,n,e){return nn(t,n,e)}static projectPoint(t,n,e){return Kn(t,n,e)}static tryCreateByThreePoints(t,n,e,s=!1){return Qn(t,n,e,s)}static tryCreateCircle(t,n){return en(t,n)}static tryCreateCircleByDiameter(t,n){return Ne(t,n)}static tryCreateCircleByThreePoints(t,n,e){return Re(t,n,e)}static tryCreateShorterArc(t,n,e){return ke(t,n,e)}static tryCreateByCenterStartEnd(t,n,e,s){return _t(t,n,e,s)}static tryCreateByCenterStartProjectedEnd(t,n,e,s){return ve(t,n,e,s)}static tryCreateByCenterStartSweep(t,n,e){return $n(t,n,e)}static tryCreateByCenterStartChord(t,n,e){return qe(t,n,e)}static tryCreateByStartEndAngle(t,n,e){return je(t,n,e)}static tryCreateByStartEndDirection(t,n,e){return Le(t,n,e)}static tryCreateByStartEndRadius(t,n,e){return Ve(t,n,e)}createByThreePoints(t,n,e){const s=Qn(t,n,e);if(!s)throw R.AcCmErrors.ILLEGAL_PARAMETERS;this.center=s.center,this.radius=s.radius,this._clockwise=s._clockwise,this._startAngle=s._startAngle,this._endAngle=s._endAngle,this._boundingBoxNeedsUpdate=!0}createByStartEndPointsAndBulge(t,n,e){let s,i,o;e<0?(s=Math.atan(-e)*4,i=new N(t),o=new N(n)):(s=Math.atan(e)*4,i=new N(n),o=new N(t));const h=new N().subVectors(o,i),a=h.length(),c=new N().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,g=new N(u.x*Math.cos(d)-u.y*Math.sin(d),u.y*Math.cos(d)+u.x*Math.sin(d));let m;s<Math.PI?e<0?m=c.add(g.multiplyScalar(l)):m=c.add(g.multiplyScalar(-l)):e<0?m=c.add(g.multiplyScalar(-l)):m=c.add(g.multiplyScalar(l)),e<0?(this._startAngle=Math.atan2(i.y-m.y,i.x-m.x),this._endAngle=Math.atan2(o.y-m.y,o.x-m.x)):(this._startAngle=Math.atan2(o.y-m.y,o.x-m.x),this._endAngle=Math.atan2(i.y-m.y,i.x-m.x)),this._clockwise=e<0,this.center=m,this.radius=o.sub(m).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(p.normalizeAngle(t)):p.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==S?t:p.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?p.normalizeAngle(t-n):p.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?p.normalizeAngle(t-this.deltaAngle/2):p.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 o=this._getInternalAngle(i);p.isBetweenAngle(o,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 Z(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),o=this.endPoint.clone().applyMatrix2d(n),h=new L(s,i,o),a=n.determinant()<0?!this.clockwise:this.clockwise,c=l=>{const u=p.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(o.y-h.center.y,o.x-h.center.x)),this._boundingBoxNeedsUpdate=!0,this}clone(){return new L(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 o=this._getInternalAngle(i);p.isBetweenAngle(o,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 o=Math.atan2(s,e),h=this.clockwise?this._mirrorAngle(p.normalizeAngle(o)):p.normalizeAngle(o),a=this._getInternalAngle(h),c=this._getInternalAngle(this.startAngle),l=this._getInternalAngle(this.endAngle);if(p.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 o=e/i,h=s/i,a=[new P(this.center.x+o*this.radius,this.center.y+h*this.radius),new P(this.center.x-o*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 g=Math.atan2(d.y-this.center.y,d.x-this.center.x),m=this.clockwise?this._mirrorAngle(p.normalizeAngle(g)):p.normalizeAngle(g),y=this._getInternalAngle(m);(this.closed||p.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),o=this.radius;if(i<o)return n;const h=Math.acos(o/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 g=this.clockwise?this._mirrorAngle(p.normalizeAngle(d)):p.normalizeAngle(d),m=this._getInternalAngle(g);(this.closed||p.isBetweenAngle(m,l,u,this.clockwise))&&n.push(this.getPointAtAngle(g))}return n}getPoints(t=100){const n=[];let e=this.deltaAngle,s=this._getInternalAngle(this.startAngle);if(this.closed&&(e=S,s=0),this.clockwise)for(let i=0;i<=t;i++){const o=s-e*(i/t),h=this._clockwise?this._mirrorAngle(o):o,a=this.getPointAtAngle(h);n.push(new P(a.x,a.y))}else for(let i=0;i<=t;i++){const o=s+e*(i/t),h=this._clockwise?this._mirrorAngle(o):o,a=this.getPointAtAngle(h);n.push(new P(a.x,a.y))}return n}}const St=1e-6;function Hn(r,t){if(hs(r)){const i=Fe(r,t);return i?[i]:[]}const n=re(r);if(n.numberOfVertices<2)return[];const s=cs(n,t);return s?[s]:[]}function Ue(r){return re(r)}function Fe(r,t){const n=Oe(r);if(n.length===0)return null;const e=[];for(const h of n){const a=Xe(h,t);if(!a)return null;e.push(a)}const s=De(r),i=We(e,s,r.closed,t);if(i.length<2)return null;const o=new it;return i.forEach((h,a)=>{o.addVertexAt(a,{x:h.x,y:h.y})}),o.closed=r.closed,o}function Oe(r){const t=[],n=r.numberOfVertices,e=r.closed?n:n-1;for(let s=0;s<e;s++){const i=r.vertices[s],o=r.vertices[(s+1)%n];M.isPositive(Math.abs(i.bulge??0))?t.push({kind:"arc",arc:new L(i,o,i.bulge)}):t.push({kind:"line",start:new P(i.x,i.y),end:new P(o.x,o.y)})}return t}function De(r){const t=[];for(let n=0;n<r.numberOfVertices;n++)t.push(r.getPointAt(n));return t}function Xe(r,t){if(r.kind==="line"){const e=Ge(r.start,r.end,t);return e?{kind:"line",...e}:null}const n=Ye(r.arc,r.arc.startPoint,r.arc.endPoint,t);return n?{kind:"arc",arc:n}:null}function Ye(r,t,n,e){const s=Ze(r,t,n,e),i=r.radius+s;return M.isNonPositive(i)?null:new L(r.center,i,r.startAngle,r.endAngle,r.clockwise)}function Ze(r,t,n,e){const s=n.x-t.x,i=n.y-t.y,o=Math.hypot(s,i);if(M.isNonPositive(o))return r.clockwise?-e:e;const h=-i/o,a=s/o,c=r.center.x-(t.x+n.x)/2,l=r.center.y-(t.y+n.y)/2;return c*h+l*a>0?-e:e}function Ge(r,t,n){const e=t.x-r.x,s=t.y-r.y,i=Math.hypot(e,s);if(M.isNonPositive(i))return null;const o=-s/i*n,h=e/i*n;return{start:new P(r.x+o,r.y+h),end:new P(t.x+o,t.y+h),dx:e,dy:s}}function We(r,t,n,e){var h;const s=r.length;if(s===0)return[];const i=Ke(r,t,n,e),o=[((h=i[0].nextSegmentStart)==null?void 0:h.clone())??i[0].point.clone()];for(let a=0;a<s;a++){const c=r[a],l=a===s-1&&!n?{point:ts(c)}:i[(a+1)%s];if(a>0&&i[a].filletPoints&&i[a].filletPoints.forEach(u=>o.push(u.clone())),c.kind==="arc"){const u=i[a].nextSegmentStart??i[a].point,d=l.point,g=Qe(c.arc,u,d,Math.max(16,32));for(let m=1;m<g.length;m++)o.push(g[m])}else o.push(l.point.clone())}return oe(o)}function Ke(r,t,n,e){const s=r.length,i=[];for(let o=0;o<s;o++)o===0?i.push(n?te(r[s-1],r[0],t[0],e):{point:He(r[0])}):i.push(te(r[o-1],r[o],t[o],e));return i}function Qe(r,t,n,e){const s=r.nearestPoint(t),i=r.nearestPoint(n),o=rn(r,s),h=rn(r,i),a=Je(r,o,h),c=[];for(let l=0;l<=e;l++){const u=l/e,d=r.clockwise?o-a*u:o+a*u;c.push(r.getPointAtAngle($e(r,d)))}return c}function rn(r,t){return Math.atan2(t.y-r.center.y,t.x-r.center.x)}function $e(r,t){const n=p.normalizeAngle(t);return r.clockwise?on(n):n}function on(r){return(360-r*180/Math.PI)%360*(Math.PI/180)}function Je(r,t,n){if(r.clockwise){let s=t-n;return M.isNonPositive(s)&&(s+=S),s}let e=n-t;return M.isNonPositive(e)&&(e+=S),e}function He(r){return r.kind==="line"?r.start.clone():r.arc.startPoint.clone()}function ts(r){return r.kind==="line"?r.end.clone():r.arc.endPoint.clone()}function te(r,t,n,e){return r.kind==="line"&&t.kind==="line"?{point:hn({start:r.start,end:r.end,dx:r.dx,dy:r.dy},{start:t.start,end:t.end,dx:t.dx,dy:t.dy})}:r.kind==="line"&&t.kind==="arc"?ne(r,t.arc,n,e,!0):r.kind==="arc"&&t.kind==="line"?ne(t,r.arc,n,e,!1):r.kind==="arc"&&t.kind==="arc"?ns(r.arc,t.arc,n,e):{point:n.clone()}}function ns(r,t,n,e){const s=ie(r.endPoint,t.startPoint),o=os(r,t).filter(l=>Ct(r,l)&&Ct(t,l));if(o.length>0)return{point:se(o,s)};const h=r.endPoint.clone(),a=t.startPoint.clone(),c=ee(n,Math.abs(e),h,a);return{point:h,filletPoints:c,nextSegmentStart:a}}function ne(r,t,n,e,s){const i=ie(s?r.end:r.start,s?t.startPoint:t.endPoint),o=rs(r,t,i);if(ss(r,o)&&Ct(t,o))return{point:o};const h=es(r,n,e),a=s?t.startPoint.clone():t.endPoint.clone(),c=ee(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 es(r,t,n){const e=Math.hypot(r.dx,r.dy),s=-r.dy/e*n,i=r.dx/e*n;return new P(t.x+s,t.y+i)}function ss(r,t){const n=Math.hypot(r.dx,r.dy);if(M.isNonPositive(n))return!1;const e=r.dx/n,s=r.dy/n,i=t.x-r.start.x,o=t.y-r.start.y,h=Math.abs(i*s-o*e);return M.equalToZero(h)}function ee(r,t,n,e){const s=Math.atan2(n.y-r.y,n.x-r.x),i=Math.atan2(e.y-r.y,e.x-r.x),o=is(s,i);if(M.equalToZero(Math.abs(o)))return[];const h=[],a=Math.max(2,Math.ceil(Math.abs(o)/Math.PI*16));for(let c=1;c<a;c++){const l=c/a,u=s+o*l;h.push(new P(r.x+t*Math.cos(u),r.y+t*Math.sin(u)))}return h}function is(r,t){let n=t-r;for(;n>Math.PI;)n-=S;for(;n<=-Math.PI;)n+=S;return n}function rs(r,t,n){const e=Math.hypot(r.dx,r.dy);if(M.isNonPositive(e))return n.clone();const s=r.dx/e,i=r.dy/e,o=r.start.x-t.center.x,h=r.start.y-t.center.y,a=2*(o*s+h*i),c=o*o+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(m=>new P(r.start.x+s*m,r.start.y+i*m)),g=d.filter(m=>Ct(t,m));return se(g.length>0?g:d,n)}function Ct(r,t){const n=Math.abs(Math.hypot(t.x-r.center.x,t.y-r.center.y)-r.radius);if(M.isPositive(n))return!1;const e=rn(r,t),s=r.clockwise?on(p.normalizeAngle(r.startAngle)):p.normalizeAngle(r.startAngle),i=r.clockwise?on(p.normalizeAngle(r.endAngle)):p.normalizeAngle(r.endAngle);return p.isBetweenAngle(e,s,i,r.clockwise)}function os(r,t){const n=t.center.x-r.center.x,e=t.center.y-r.center.y,s=Math.hypot(n,e);if(M.isNonPositive(s))return[];const i=r.radius+t.radius,o=Math.abs(r.radius-t.radius);if(s>i+St)return[];if(s<o-St)return[];const h=(r.radius*r.radius-t.radius*t.radius+s*s)/(2*s),a=r.radius*r.radius-h*h;if(a<-St)return[];const c=r.center.x+h*n/s,l=r.center.y+h*e/s;if(a<=St)return[new P(c,l)];const u=Math.sqrt(a),d=-e*u/s,g=n*u/s;return[new P(c+d,l+g),new P(c-d,l-g)]}function se(r,t){let n=r[0],e=n.distanceToSquared(t);for(let s=1;s<r.length;s++){const i=r[s].distanceToSquared(t);i<e&&(n=r[s],e=i)}return n.clone()}function ie(r,t){return new P((r.x+t.x)/2,(r.y+t.y)/2)}function hs(r){const t=r.numberOfVertices,n=r.closed?t:t-1;for(let e=0;e<n;e++){const s=r.vertices[e];if(M.isPositive(Math.abs(s.bulge??0)))return!0}return!1}function re(r){const t=as(r.vertices.map(n=>new P(n.x,n.y)),r.closed);return t.length===r.numberOfVertices?r:new it(t.map(n=>({x:n.x,y:n.y})),r.closed)}function as(r,t){const n=oe(r);if(!t||n.length<2)return n;const e=n[0],s=n[n.length-1];return M.isNonPositive(Math.hypot(e.x-s.x,e.y-s.y))&&n.pop(),n}function oe(r){const t=[];return r.forEach(n=>{const e=t[t.length-1];(!e||M.isPositive(Math.hypot(e.x-n.x,e.y-n.y)))&&t.push(new P(n.x,n.y))}),t}function cs(r,t){const n=[];for(let o=0;o<r.numberOfVertices;o++)n.push(r.getPointAt(o));const e=ls(n,r.closed,t);if(e.length===0)return null;const s=[];if(r.closed){if(e.length<2)return null;const o=e.length;for(let h=0;h<o;h++){const a=e[(h-1+o)%o],c=e[h];s.push(hn(a,c))}}else{s.push(e[0].start);for(let o=1;o<e.length;o++)s.push(hn(e[o-1],e[o]));s.push(e[e.length-1].end)}const i=new it;return s.forEach((o,h)=>{i.addVertexAt(h,{x:o.x,y:o.y})}),i.closed=r.closed,i}function ls(r,t,n){const e=[],s=t?r.length:r.length-1;for(let i=0;i<s;i++){const o=r[i],h=r[t?(i+1)%r.length:i+1],a=h.x-o.x,c=h.y-o.y,l=Math.hypot(a,c);if(M.isNonPositive(l))continue;const u=-c/l*n,d=a/l*n;e.push({start:new P(o.x+u,o.y+d),end:new P(h.x+u,h.y+d),dx:a,dy:c})}return e}function hn(r,t){const n=r.dx*t.dy-r.dy*t.dx;if(M.equalToZero(n))return new P((r.end.x+t.start.x)/2,(r.end.y+t.start.y)/2);const e=t.start.x-r.start.x,s=t.start.y-r.start.y,i=(e*t.dy-s*t.dx)/n;return new P(r.start.x+i*r.dx,r.start.y+i*r.dy)}class it extends ut{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 o=new L(s,i,s.bulge);t+=o.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 Zn(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 Z().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 it(this._vertices.map(t=>({...t})),this._closed)}getPoints3d(t,n){const e=[];return this.getPoints(t).forEach(i=>e.push(new z().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 o=null;if(s<e-1?o=this._vertices[s+1]:s==e-1&&this.closed&&(o=this._vertices[0]),o){const a=new L(i,o,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 Hn(this,t)}}function us(r,t,n){const e=Math.hypot(t.x,t.y);if(M.isNonPositive(e))return null;const s=-t.y/e*n,i=t.x/e*n;return new z(r.x+s,r.y+i,r.z)}function ds(r,t,n){if(r.length<2)return null;const e=Ue(new it(r.map(i=>({x:i.x,y:i.y})),t));return Hn(e,n)[0]??null}function gs(r,t,n,e){if(r.length<2||M.equalToZero(n))return null;const{points:s,tangents:i}=ae(r,e);if(s.length<2)return null;const o=i??ms(s,t),h=ys(s,o,n),a=t?fs(h):xs(h);if(a.length<2)return null;const c=new it;return a.forEach((l,u)=>{c.addVertexAt(u,{x:l.x,y:l.y})}),c.closed=t,c}function ms(r,t){const n=r.length,e=new Array(n);for(let s=0;s<n;s++){let i=0,o=0;if(t){const a=r[(s-1+n)%n],c=r[(s+1)%n];i=c.x-a.x,o=c.y-a.y}else s===0?(i=r[1].x-r[0].x,o=r[1].y-r[0].y):s===n-1?(i=r[n-1].x-r[n-2].x,o=r[n-1].y-r[n-2].y):(i=r[s+1].x-r[s-1].x,o=r[s+1].y-r[s-1].y);const h=Math.hypot(i,o);M.isNonPositive(h)?e[s]=new P(1,0):e[s]=new P(i/h,o/h)}return e}function ys(r,t,n){return r.map((e,s)=>{const i=t[s],o=-i.y*n,h=i.x*n;return new P(e.x+o,e.y+h)})}function xs(r){let t=Et(r);if(t.length<3)return t;for(;;){const n=he(t,!1);if(!n||(t=Et([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<2))break}return t}function fs(r){let t=Et(r);if(t.length<4)return t;for(;;){const n=he(t,!0);if(!n||(t=Et([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<3))break}return t}function he(r,t){const n=t?r.length:r.length-1;if(n<2)return null;for(let e=0;e<n;e++){const s=r[e],i=r[(e+1)%r.length];for(let o=e+1;o<n;o++){if(_s(e,o,n,t))continue;const h=r[o],a=r[(o+1)%r.length],c=As(s,i,h,a);if(c)return{point:c,segmentA:e,segmentB:o}}}return null}function _s(r,t,n,e){return!!(t===r||t===r+1||e&&r===0&&t===n-1)}function As(r,t,n,e){const s=t.x-r.x,i=t.y-r.y,o=e.x-n.x,h=e.y-n.y,a=s*h-i*o;if(M.equalToZero(a))return null;const c=n.x-r.x,l=n.y-r.y,u=(c*h-l*o)/a,d=(c*i-l*s)/a,g=zt.equalPointTol;return u<-g||u>1+g||d<-g||d>1+g?null:new P(r.x+u*s,r.y+u*i)}function ae(r,t){const n=[],e=[],s=t!=null&&t.length===r.length;return r.forEach((i,o)=>{const h=n[n.length-1];if((!h||M.isPositive(Math.hypot(h.x-i.x,h.y-i.y)))&&(n.push(new P(i.x,i.y)),s)){const a=t[o];e.push(new P(a.x,a.y))}}),{points:n,tangents:s?e:void 0}}function Et(r){return ae(r).points}class an extends sn{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 Z}transform(t){return this._loops.forEach(n=>{n.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){const t=new an;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 o={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 g=e[d],m=t[g];if(n[g].containsBox(u)&&j.isPointInPolygon(l[p.randInt(0,l.length-1)],m)){(h=s.get(g))==null||h.children.push(s.get(c));break}}d===i&&o.children.push(s.get(c))}return o}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=tn(s);n===0?t+=Math.abs(i):t-=Math.abs(i)}return t}calculateBoundaryBoxes(t){const n=[];return t.forEach(e=>{n.push(new Z().setFromPoints(e))}),n}sortBoundaryBoxesByAreas(t){const n=[];t.forEach((s,i)=>{const o=s.size,h=o.width*o.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 Ps extends Jn{translate(t){return this.transform(new Q().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 At extends Ps{}class dt extends At{static computeCenterPoint(t,n,e){var s;return((s=Wn(t,e,n))==null?void 0:s.center)??null}static tryCreateByThreePoints(t,n,e){const s=Wn(t,e,n);if(!s)return null;const{center:i,radius:o}=s,h=new A(t.x-i.x,t.y-i.y,(t.z??0)-i.z),a=new A(e.x-i.x,e.y-i.y,(e.z??0)-i.z),c=new A(n.x-i.x,n.y-i.y,(n.z??0)-i.z);if(h.lengthSq()===0||c.lengthSq()===0)return null;const l=new A().crossVectors(h,c);if(l.lengthSq()===0&&(l.crossVectors(h,a),l.lengthSq()===0))return null;l.normalize();const u=h.clone().normalize(),d=new A().crossVectors(l,u),g=y=>p.normalizeAngle(Math.atan2(y.dot(d),y.dot(u)));p.isAngleOnCcwSweep(0,g(a),g(c))||(l.negate(),d.negate());let m=g(c);return M.equalToZero(m)&&(m=S),new dt(i,o,0,m,l,u)}static createByThreePoints(t,n,e){return dt.tryCreateByThreePoints(t,n,e)}constructor(t,n,e,s,i,o=A.X_AXIS){super(),this.center=t,this.radius=n,this.startAngle=e,this.endAngle=s,this.normal=i,this.refVec=o,(s-e)%S==0?(this.startAngle=0,this.endAngle=S):(this.startAngle=e,this.endAngle=s)}get center(){return this._center}set center(t){this._center=new z(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw R.AcCmErrors.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=p.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==S?t:p.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return p.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=S);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,o=n.clone().sub(e).dot(s),a=n.clone().sub(s.clone().multiplyScalar(o)).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 g=p.normalizeAngle(l-u);g<0&&(g=0),g>d&&(g=d);const m=this.getPointAtAngle(u+g),y=m.distanceTo(n),f=this.startPoint.distanceTo(n),x=this.endPoint.distanceTo(n);return f<y&&f<=x?this.startPoint.clone():x<y&&x<f?this.endPoint.clone():m}tangentPoints(t){const n=[],e=new A(t.x,t.y,t.z||0),s=this.center,i=this.normal,o=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<o)return n;const g=Math.acos(o/d),m=this.getAngle(c.clone()),y=[m+g,m-g];for(const f of y){const x=p.normalizeAngle(f-this.startAngle);x>=0&&x<=this.deltaAngle&&n.push(this.getPointAtAngle(this.startAngle+x))}return n}perpendicularPoints(t){const n=[],e=new A(t.x,t.y,t.z||0),s=this.center,i=this.normal,o=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(o)),s.clone().sub(l.clone().multiplyScalar(o))];for(const d of u){const g=this.getAngle(d.clone()),m=p.normalizeAngle(g-this.startAngle);m>=0&&m<=this.deltaAngle&&n.push(new z(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 z(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)p.isBetweenAngle(a,this.startAngle,this.endAngle)&&t.push(a);let n=1/0,e=1/0,s=1/0,i=-1/0,o=-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>o&&(o=c.y),c.z>h&&(h=c.z)}return new W({x:n,y:e,z:s},{x:i,y:o,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=S,s=0);for(let i=0;i<=t;i++){const o=s+e*(i/t),h=this.getPointAtAngle(o);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),o=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(ce.crossVectors(a,o)),u.dot(o))};return this.center=n,this.radius=h,this.normal=a,this.refVec=o,this.startAngle=0,this.endAngle=this.closed?S: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 dt(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(ce.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,o=this.radius;return new z(i.x+o*(e.x*Math.cos(t)+s.x*Math.sin(t)),i.y+o*(e.y*Math.cos(t)+s.y*Math.sin(t)),i.z+o*(e.z*Math.cos(t)+s.z*Math.sin(t)))}get plane(){const t=new A(this.center).distanceTo(Yt);return new xt(this.normal,t)}offset(t){const n=this.radius+t;return n<=0?null:new dt(this.center,n,this.startAngle,this.endAngle,this.normal,this.refVec)}}const ce=new A;class ht extends ut{constructor(t,n,e,s=0,i=S,o=!1,h=0){super(),this.center=t,this.majorAxisRadius=n,this.minorAxisRadius=e,(i-s)%S==0?(this.startAngle=0,this.endAngle=S):(this.startAngle=s,this.endAngle=i),this.clockwise=o,this.rotation=h}get center(){return this._center}set center(t){this._center=new z(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw R.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw R.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=p.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==S?t:p.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 p.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 o=0;o<=100;o++){const h=this.getPoint(o/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 Z({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 o=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=o-this.center.x,u=h-this.center.y;o=l*a-u*c+this.center.x,h=l*c+u*a+this.center.y}return new P(o,h)}transform(t){const n=t,e=new P(this.center).applyMatrix2d(n),s=new z(e.x,e.y,this.center.z),i=this.getPointAtAngle(0).clone().applyMatrix2d(n),o=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(n),h=new P(i).sub(e),a=new P(o).sub(e),c=h.length(),l=a.length(),u=Math.atan2(h.y,h.x),d=h.clone().normalize(),g=a.clone().normalize(),m=x=>{const b=new P(x).sub(e),w=b.dot(d),I=b.dot(g);return p.normalizeAngle(Math.atan2(I/l,w/c))},y=n.determinant()<0?!this.clockwise:this.clockwise,f=this.closed?new ht(s,c,l,0,S,y,u):new ht(s,c,l,m(this.startPoint.clone().applyMatrix2d(n)),m(this.endPoint.clone().applyMatrix2d(n)),y,u);return this.center=f.center,this.majorAxisRadius=f.majorAxisRadius,this.minorAxisRadius=f.minorAxisRadius,this._startAngle=f._startAngle,this._endAngle=f._endAngle,this._clockwise=f._clockwise,this.rotation=f.rotation,this._boundingBoxNeedsUpdate=!0,this}getPointAtAngle(t){return this.getPoint(this.closed?t/S:p.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 ht(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),o=this.majorAxisRadius>=this.minorAxisRadius,h=o?s:-i,a=o?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 o=1;o<=i;o++){const h=this.getPoint(o/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,o,h)=>{const a=-this.majorAxisRadius*h,c=this.minorAxisRadius*o;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,o,h)=>{const a=this.minorAxisRadius*o,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,o=this.startAngle,h=this.deltaAngle,a=[],c=d=>{const g=Math.cos(d),m=Math.sin(d);return n(s*g,i*m,g,m)};let l=o,u=c(l);for(let d=1;d<=e;d++){const g=o+h*d/e,m=c(g);if(Math.abs(u)<1e-10&&a.push(l),u*m<0){let y=l,f=g;for(let x=0;x<32;x++){const b=(y+f)/2;c(y)*c(b)<=0?f=b:y=b}a.push((y+f)/2)}l=g,u=m}return a}}class gt extends At{constructor(t,n,e,s,i,o=0,h=S){super(),this.center=t,this.normal=n,this.majorAxis=e,this.majorAxisRadius=s,this.minorAxisRadius=i;const a=Math.abs(h-o);Math.abs(a-S)<1e-10||Math.abs(a-2*S)<1e-10?(this.startAngle=0,this.endAngle=S):(this.startAngle=o,this.endAngle=h)}get center(){return this._center}set center(t){this._center=new z(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw R.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw R.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=p.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==S?t:p.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-S)<1e-10?S:p.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-S)<1e-10)&&(t=0,n=S);const e=t+n/2;return this.getPointAtAngle(e)}get isCircular(){return M.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 o=this.startAngle+i*n,h=this.getPointAtAngle(o),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-S)>=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)p.isBetweenAngle(a,this.startAngle,this.endAngle)&&t.push(a);let n=1/0,e=1/0,s=1/0,i=-1/0,o=-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>o&&(o=c.y),c.z>h&&(h=c.z)}return new W({x:n,y:e,z:s},{x:i,y:o,z:h})}else{let n=1/0,e=1/0,s=1/0,i=-1/0,o=-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),o=Math.max(o,l.y),h=Math.max(h,l.z)}return new W({x:n,y:e,z:s},{x:i,y:o,z:h})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const n=[];let e=this.deltaAngle,s=this.startAngle;this.closed&&(e=S,s=0);for(let i=0;i<=t;i++){const o=s+e*(i/t),h=this.getPointAtAngle(o);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 z(this.center.x+i.x,this.center.y+i.y,this.center.z+i.z)}nearestPoint(t,n=72){const e=new z(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 o=e.distanceToSquared(this.startPoint),h=e.distanceToSquared(this.endPoint);return o<i&&o<=h?this.startPoint.clone():h<i&&h<o?this.endPoint.clone():s.clone()}tangentPoints(t){const n=this._projectPointToLocalPlane(t);return this._findSnapParameterAngles((s,i,o,h)=>{const a=-this.majorAxisRadius*h,c=this.minorAxisRadius*o;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,o,h)=>{const a=this.minorAxisRadius*o,c=this.majorAxisRadius*h;return(s-n.x)*c-(i-n.y)*a}).map(s=>this.getPointAtAngle(s))}_projectPointToLocalPlane(t){const n=new z(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,o=this.deltaAngle,h=[],a=u=>{const d=Math.cos(u),g=Math.sin(u);return t(e*d,s*g,d,g)};let c=i,l=a(c);for(let u=1;u<=n;u++){const d=i+o*u/n,g=a(d);if(Math.abs(l)<1e-10&&h.push(c),l*g<0){let m=c,y=d;for(let f=0;f<32;f++){const x=(m+y)/2;a(m)*a(x)<=0?y=x:m=x}h.push((m+y)/2)}c=d,l=g}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,o=s/this.minorAxisRadius;return i*i+o*o<=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),o=new A(s).sub(e),h=new A(i).sub(e),a=o.length(),c=h.length(),l=o.clone().normalize(),u=new A().crossVectors(o,h).normalize();let d=new A().crossVectors(u,l).normalize();d.dot(h)<0&&(u.negate(),d=new A().crossVectors(u,l).normalize());const g=y=>{const f=new A(y).sub(e),x=f.dot(l),b=f.dot(d);return p.normalizeAngle(Math.atan2(b/c,x/a))},m=this.closed?new gt(e,u,l,a,c,0,S):new gt(e,u,l,a,c,g(this.startPoint.clone().applyMatrix4(n)),g(this.endPoint.clone().applyMatrix4(n)));return this.center=m.center,this.normal=m.normal,this.majorAxis=m.majorAxis,this.majorAxisRadius=m.majorAxisRadius,this.minorAxisRadius=m.minorAxisRadius,this._startAngle=m._startAngle,this._endAngle=m._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 gt(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new A(this.center).distanceTo(Yt);return new xt(this.normal,t)}offset(t){const n=this.majorAxisRadius+t,e=this.minorAxisRadius+t;return n<=0||e<=0?null:new gt(this.center,this.normal,this.majorAxis,n,e,this.startAngle,this.endAngle)}}class Pt extends ut{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 Z(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 Pt(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 Tt extends At{constructor(t,n){super(),this._start=new z(t),this._end=new z(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 z((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(at).normalize();return new z(this._start).addScaledVector(e,t)}else{const e=this.delta(at).normalize();return new z(this._end).addScaledVector(e,t)}}extend(t,n=!1){if(n){const e=at.subVectors(this._start,this._end).normalize();this._start=new z(this._start).addScaledVector(e,t)}else{const e=this.delta(at).normalize();this._end=new z(this._end).addScaledVector(e,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,n){le.subVectors(t,this._start),It.subVectors(this.endPoint,this.startPoint);const e=It.dot(It);let i=It.dot(le)/e;return n&&(i=p.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=at.subVectors(t,this.startPoint).dot(n);return new z().copy(n).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const n=this.direction,e=this.startPoint,i=at.subVectors(t,e).dot(n),o=at.copy(n).multiplyScalar(i);return new z().addVectors(e,o)}calculateBoundingBox(){const t=new z(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 z(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 W(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 Tt(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(),o=new A(-i.y,i.x,0);return new Tt(new z(n.x+o.x*t,n.y+o.y*t,n.z),new z(e.x+o.x*t,e.y+o.y*t,e.z))}}const at=new A,le=new A,It=new A;class cn{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,o,h){let a=(n-t)/i-(e-t)/(i+o)+(e-n)/o,c=(e-n)/o-(s-n)/(o+h)+(s-e)/h;a*=o,c*=o,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 Bt extends At{constructor(t=[],n=!1,e="centripetal",s=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new A,this._px=new cn,this._py=new cn,this._pz=new cn,this._points=t.map(i=>new z(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 z}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new z}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 z){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 o=(i-(this._closed?0:1))*t;let h=Math.floor(o),a=o-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 z(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 z(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const g=this._curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(u),g),y=Math.pow(u.distanceToSquared(d),g),f=Math.pow(d.distanceToSquared(l),g);y<1e-4&&(y=1),m<1e-4&&(m=y),f<1e-4&&(f=y),this._px.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,m,y,f),this._py.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,m,y,f),this._pz.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,m,y,f)}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 z(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 Bt(this._points.map(t=>t.clone()),this._closed,this._curveType,this._tension)}transform(t){return this._points=this._points.map(n=>{const e=new z;return e.copy(n),e.applyMatrix4(t),e}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new W;const t=new W;return this._points.forEach(n=>{t.expandByPoint(n)}),t}}function ue(r,t){const n=r.x-t[0],e=r.y-t[1],s=(r.z??0)-(t[2]??0);return n*n+e*e+s*s}class k{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 k(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 Ln(t,this._degree,this._knots,n,this._weights)}signedPlanarCurvatureAt(t){const n=this.evaluate(t);return Vn(n.deriv1,n.deriv2)}getOffsetSamplePath2d(t,n=512){const e=Math.abs(t),{start:s,end:i}=this.getParameterRange(),o=this.length(),h=Math.max(64,Math.ceil(o/Math.max(e*.2,1e-6)));let a=ps(s,i,Math.min(h,n));for(let u=0;u<8&&a.length<n;u++){const d=[];for(let g=0;g<a.length-1;g++){const m=a[g],y=a[g+1],f=(m+y)/2,x=Math.max(Math.abs(this.signedPlanarCurvatureAt(m)),Math.abs(this.signedPlanarCurvatureAt(y)),Math.abs(this.signedPlanarCurvatureAt(f)));e*x>.85&&d.push(f)}if(d.length===0)break;if(a=ws(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 g=d.deriv1[0],m=d.deriv1[1],y=Math.hypot(g,m);l.push(y>1e-10?new P(g/y,m/y):new P(1,0))}),{points:c,tangents:l}}length(){const t=this._controlPoints.map(n=>[n.x,n.y,n.z]);return Un(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,n,e,s){return new k(t,n,e,s)}static byPoints(t,n,e="Uniform",s,i){const o=Qt(t,n,e,s,i),h=o.controlPoints.map(a=>({x:a[0],y:a[1],z:a[2]}));return new k(n,o.knots,h,o.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 o=e+(s-e)*(i/t);n.push(this.point(o))}return n}isClosed(t=1e-6){const{start:n,end:e}=this.getParameterRange(),s=this.point(n),i=this.point(e),o=s[0]-i[0],h=s[1]-i[1],a=s[2]-i[2];return Math.sqrt(o*o+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 Bt(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),o=ue(t,i);for(let h=0;h<=n;h++){const a=e+(s-e)*h/n,c=this.point(a),l=ue(t,c);l<o&&(o=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(o=>[o.x,o.y,o.z]);return k.byPoints(i,n,e)}}function ps(r,t,n){if(n<2)return[r,t];const e=[];for(let s=0;s<n;s++)e.push(s===n-1?t:r+(t-r)*s/(n-1));return e}function ws(r,t){const n=[...r,...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}function de(r){if(!r)return!1;const t=r.x??0,n=r.y??0,e=r.z??0;return t*t+n*n+e*e>1e-20}function Ms(r,t,n){let e=r??0;return e<1&&n>0&&t>0&&(e=n-t-1),e<1&&(e=3),e=Math.min(e,t-1),Math.max(1,e)}function zs(r,t,n){let e=r??0;e<1&&(e=3);const s=t+n-1;return e=Math.min(e,s),Math.max(1,e)}function bs(r,t){if(!(!r||r.length!==t))return r}class X extends At{constructor(t,n,e,s,i,o){super();const h=arguments.length;if(this._degree=3,this._closed=!1,Array.isArray(n)){if(h<2||h>5)throw R.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 R.AcCmErrors.ILLEGAL_PARAMETERS;this._nurbsCurve=k.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,a)}else{if(h<2||h>6)throw R.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=o)):(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 R.AcCmErrors.ILLEGAL_PARAMETERS;if(this._closed)this._nurbsCurve=k.createClosedCurve(this._fitPoints,this._degree,this._knotParameterization);else{const l=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=k.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=k.createFitPointsForClosedCurve(this._fitPoints),n=this.toNurbsPoints(t);this._nurbsCurve=k.byPoints(n,this._degree,this._knotParameterization)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=k.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=k.createFitPointsForClosedCurve(this._controlPoints),n=this.toNurbsPoints(t);this._nurbsCurve=k.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=k.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(j.point2dToPoint3d)}get fitPoints(){var t;return(t=this._fitPoints)==null?void 0:t.map(j.point2dToPoint3d)}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 z(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 z(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 z(e.x,e.y,e.z||0)}evaluateAt(t){const n=this._nurbsCurve.point(t);return new z(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 j.point2dToPoint3d(s)}getControlPointAt(t){const n=this._controlPoints.length,e=t<0||t>=n?n-1:t;return this._controlPoints[e]}get isFitPointSpline(){return!!(this._fitPoints&&this._fitPoints.length>0&&this._knotParameterization)}get isControlPointSpline(){return!this.isFitPointSpline}getGripPoints(){return this.isFitPointSpline?this._fitPoints.map(t=>new z(t.x,t.y,t.z??0)):this._controlPoints.map(t=>new z(t.x,t.y,t.z??0))}moveGripPointsAt(t,n){return this.isFitPointSpline?(this.moveFitPointsAt(t,n),this):(this.moveControlPointsAt(t,n),this)}moveFitPointsAt(t,n){if(this._fitPoints){for(const e of t){if(!Number.isInteger(e)||e<0)continue;const s=this._fitPoints[e];s&&j.applyOffsetToPoint3d(s,n)}this._boundingBoxNeedsUpdate=!0,this.buildCurve()}}moveControlPointsAt(t,n){for(const e of t){if(!Number.isInteger(e)||e<0)continue;const s=this.getControlPointAt(e);s&&j.applyOffsetToPoint3d(s,n)}this.rebuildAfterControlPointMutation()}rebuildAfterControlPointMutation(){const t=this._nurbsCurve.knots(),n=this._nurbsCurve.weights();this.isFitPointSpline&&(this._fitPoints=void 0,this._knotParameterization=void 0,this._startTangent=void 0,this._endTangent=void 0),this._nurbsCurve=k.byKnotsControlPointsWeights(this._degree,t,this._controlPoints,n.length>0?n:void 0),this._boundingBoxNeedsUpdate=!0}getOffsetSamplePath2d(t){return this._nurbsCurve.getOffsetSamplePath2d(t)}getPoints(t=100){const n=this._nurbsCurve,e=[],s=n.knots(),i=this._nurbsCurve.degree(),o=s[i],h=s[s.length-i-1],a=(h-o)/(t-1);for(let c=0;c<t;c++){const l=c===t-1?h:o+c*a,u=n.point(l);e.push(new z(u[0],u[1],u[2]))}return e}getCurvePoints(t,n){const e=[],s=t.knots(),i=t.degree(),o=s[i],a=(s[s.length-i-1]-o)/(n-1);for(let c=0;c<n;c++){const l=o+c*a;e.push(t.point(l))}return e}calculateBoundingBox(){const t=this.getPoints(100);return new W().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 Gn(t)}transform(t){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(n=>new z(n).applyMatrix4(t)),this._startTangent&&(this._startTangent=new z(this._startTangent).transformDirection(t)),this._endTangent&&(this._endTangent=new z(this._endTangent).transformDirection(t)),this.buildCurve();else{const n=this._nurbsCurve.knots(),e=this._nurbsCurve.weights();this._controlPoints=this._controlPoints.map(s=>new z(s).applyMatrix4(t)),this._nurbsCurve=k.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,e.length>0?e:void 0)}return this._boundingBoxNeedsUpdate=!0,this}clone(){return this._fitPoints&&this._knotParameterization?new X(this._fitPoints.map(j.point2dToPoint3d),this._knotParameterization,this._degree,this._closed,this._startTangent?j.point2dToPoint3d(this._startTangent):void 0,this._endTangent?j.point2dToPoint3d(this._endTangent):void 0):new X(this._controlPoints.map(j.point2dToPoint3d),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 X(t,n,e,!0)}static fromControlPoints(t,n,e,s,i){if(t.length<2||n.length<2)return null;const o=Ms(s,t.length,n.length);if(t.length<o+1)return null;try{return new X(t,n,bs(e,t.length),o,i)}catch{return null}}static fromFitPoints(t,n,e,s,i,o){if(t.length<2)return null;const h=de(i),a=de(o),c=(h?1:0)+(a?1:0),l=zs(e,t.length,c);if(t.length+c<l+1)return null;try{return h||a?new X(t,n,l,s,h?i:void 0,a?o:void 0):new X(t,n,l,s)}catch{return null}}static fromDwgSplineEdge(t){if(t.numberOfControlPoints>0&&t.numberOfKnots>0){const n=t.controlPoints.map(j.point2dToPoint3d);let e=!0;const s=t.controlPoints.map(i=>(i.weight==null&&(e=!1),i.weight||1));return X.fromControlPoints(n,t.knots,e?s:void 0,t.degree,!1)}if(t.numberOfFitData>0){const n=t.fitDatum.map(j.point2dToPoint3d);return X.fromFitPoints(n,"Uniform",t.degree,!1,t.startTangent?j.point2dToPoint3d(t.startTangent):void 0,t.endTangent?j.point2dToPoint3d(t.endTangent):void 0)}return null}}class Y extends ut{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,o=(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=Y.getEdgeStartPoint(a);let l=Y.getEdgeEndPoint(a);if(!o(c,l))for(;e.length>0;){const u=Y.findConnectingEdge(e,l,i);if(u.index<0)break;let d=e.splice(u.index,1)[0];if(u.reverse&&(d=Y.reverseEdge(d)),h.push(d),l=Y.getEdgeEndPoint(d),o(l,c))break}s.push(new Y(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 Z;return n.setFromPoints(t),n}transform(t){const n=new Q().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 X?e.transform(n):e.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new Y(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,o=Number.POSITIVE_INFINITY;for(let h=0;h<t.length;h++){const a=t[h],c=Y.getEdgeStartPoint(a),l=Y.getEdgeEndPoint(a),u=n.x-c.x,d=n.y-c.y,g=u*u+d*d;g<o&&(o=g,s=h,i=!1);const m=n.x-l.x,y=n.y-l.y,f=m*m+y*y;f<o&&(o=f,s=h,i=!0)}return o>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 Pt?new Pt(t.endPoint,t.startPoint):t instanceof L?Y.reverseCircArcEdge(t):t instanceof ht?new ht(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof X?Y.reverseSplineEdge(t):t}static reverseCircArcEdge(t){const n=t.startPoint,e=t.endPoint,s=!t.clockwise,i=Math.atan2(e.y-t.center.y,e.x-t.center.x),o=Math.atan2(n.y-t.center.y,n.x-t.center.x),h=a=>{const c=p.normalizeAngle(a);return s?p.normalizeAngle(-c):c};return new L(t.center,t.radius,h(i),h(o),s)}static reverseSplineEdge(t){const n=[...t.controlPoints].reverse(),e=t.knots,s=e[0],i=e[e.length-1],o=e.map(c=>s+i-c).reverse(),h=t.weights,a=h.length>0?[...h].reverse():void 0;return new X(n,o,a,t.degree,t.closed)}}_.AcGeArea2d=an,_.AcGeBox2d=Z,_.AcGeBox3d=W,_.AcGeCatmullRomCurve3d=Bt,_.AcGeCircArc2d=L,_.AcGeCircArc3d=dt,_.AcGeCurve2d=ut,_.AcGeEllipseArc2d=ht,_.AcGeEllipseArc3d=gt,_.AcGeEuler=Wt,_.AcGeGeometryUtil=j,_.AcGeLine2d=Pt,_.AcGeLine3d=Tt,_.AcGeLoop2d=Y,_.AcGeMathUtil=p,_.AcGeMatrix2d=ct,_.AcGeMatrix3d=Q,_.AcGeNurbsCurve=k,_.AcGePlane=xt,_.AcGePoint2d=P,_.AcGePoint3d=z,_.AcGePolyline2d=it,_.AcGeQuaternion=yt,_.AcGeShape2d=sn,_.AcGeSpline3d=X,_.AcGeTol=M,_.AcGeVector2d=N,_.AcGeVector3d=A,_.DEFAULT_TOL=zt,_.DEG2RAD=Vt,_.FLOAT_TOL=O,_.ORIGIN_POINT_2D=ge,_.ORIGIN_POINT_3D=Yt,_.RAD2DEG=Ut,_.TAU=S,_.acgeBasisFunction=et,_.acgeCalculateCurveLength=Un,_.acgeCeilPowerOfTwo=bn,_.acgeClamp=K,_.acgeClosedPolygonArea2d=Zn,_.acgeClosedPolygonArea3d=Gn,_.acgeComputeParameterValues=qn,_.acgeDamp=mn,_.acgeDegToRad=wn,_.acgeEuclideanModulo=Ft,_.acgeEvaluateNurbsDerivatives=Ln,_.acgeEvaluateNurbsPoint=ft,_.acgeFloorPowerOfTwo=Sn,_.acgeGenerateAveragedKnots=jn,_.acgeGenerateChordKnots=Me,_.acgeGenerateSqrtChordKnots=ze,_.acgeGenerateUUID=un,_.acgeGenerateUniformKnots=we,_.acgeGetOcsAngle=Be,_.acgeGetOcsReferenceVector=Te,_.acgeIntPartLength=Dt,_.acgeInterpolateControlPoints=Se,_.acgeInterpolateNurbsCurve=Qt,_.acgeInverseLerp=gn,_.acgeIsAngleOnCcwSweep=Tn,_.acgeIsBetween=Cn,_.acgeIsBetweenAngle=En,_.acgeIsPowerOfTwo=zn,_.acgeLerp=Ot,_.acgeMapLinear=dn,_.acgeNormalizeAngle=ot,_.acgeOffsetPointByDirectionInXY=us,_.acgeOffsetSmoothedSampledPath=gs,_.acgeOffsetVertexPath=ds,_.acgePingpong=yn,_.acgePolygonArea2d=Xn,_.acgePolygonArea3d=Yn,_.acgeRadToDeg=Mn,_.acgeRandFloat=An,_.acgeRandFloatSpread=Pn,_.acgeRandInt=_n,_.acgeRelativeEps=In,_.acgeSeededRandom=pn,_.acgeSignedPlanarCurvature=Vn,_.acgeSignedPolygonArea2d=tn,_.acgeSmootherstep=fn,_.acgeSmoothstep=xn,_.acgeTransformOcsPointToWcs=Ie,_.acgeTransformWcsPointToOcs=Ht,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(A,q){typeof exports=="object"&&typeof module<"u"?q(exports,require("@mlightcad/common")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/common"],q):(A=typeof globalThis<"u"?globalThis:A||self,q(A["geometry-engine"]={},A.common))})(this,(function(A,q){"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 Vn=1234567;const en=Math.PI/180,sn=180/Math.PI;function jn(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,e=Math.random()*4294967295|0;return(L[i&255]+L[i>>8&255]+L[i>>16&255]+L[i>>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 nt(i,t,n){return Math.max(t,Math.min(n,i))}function rn(i,t){return(i%t+t)%t}function Ln(i,t,n,e,s){return e+(i-t)*(s-e)/(n-t)}function vn(i,t,n){return i!==t?(n-i)/(t-i):0}function on(i,t,n){return(1-n)*i+n*t}function On(i,t,n,e){return on(i,t,1-Math.exp(-n*e))}function Fn(i,t=1){return t-Math.abs(rn(i,t*2)-t)}function Un(i,t,n){return i<=t?0:i>=n?1:(i=(i-t)/(n-t),i*i*(3-2*i))}function Dn(i,t,n){return i<=t?0:i>=n?1:(i=(i-t)/(n-t),i*i*i*(i*(i*6-15)+10))}function Xn(i,t){return i+Math.floor(Math.random()*(t-i+1))}function Yn(i,t){return i+Math.random()*(t-i)}function Zn(i){return i*(.5-Math.random())}function Gn(i){i!==void 0&&(Vn=i);let t=Vn+=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 Wn(i){return i*en}function Qn(i){return i*sn}function Kn(i){return(i&i-1)===0&&i!==0}function $n(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Hn(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function gt(i){const t=Math.PI*2;return(i%t+t)%t}function Jn(i,t,n){return i>t&&i<n||i>n&&i<t}function te(i,t,n,e=!1){return i=gt(i),t=gt(t),n=gt(n),e?t>n?i<=t&&i>=n:i<=t||i>=n:t<n?i>=t&&i<=n:i>=t||i<=n}function ne(i,t,n){const e=gt(n-i);return gt(t-i)<=e+1e-7}function an(i){return i=Math.abs(i),i<1?0:Math.ceil(Math.log10(Math.abs(i)+1))}function ee(i,t=1e-7){const n=an(i);return Math.max(Math.pow(10,n)*t,t)}const p={DEG2RAD:en,RAD2DEG:sn,generateUUID:jn,clamp:nt,euclideanModulo:rn,mapLinear:Ln,inverseLerp:vn,lerp:on,damp:On,pingpong:Fn,smoothstep:Un,smootherstep:Dn,randInt:Xn,randFloat:Yn,randFloatSpread:Zn,seededRandom:Gn,degToRad:Wn,radToDeg:Qn,isPowerOfTwo:Kn,ceilPowerOfTwo:$n,floorPowerOfTwo:Hn,normalizeAngle:gt,isBetween:Jn,isBetweenAngle:te,isAngleOnCcwSweep:ne,intPartLength:an,relativeEps:ee},Vt=class Vt{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:r}=t;this.x=s,this.y=r;return}if(e===2){this.x=t,this.y=n;return}throw q.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 Vt(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),r=this.x-t.x,o=this.y-t.y;return this.x=r*e-o*s+t.x,this.y=r*s+o*e+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(p.relativeEps(this.x,t),p.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};Vt.EMPTY=Object.freeze(new Vt(0,0));let N=Vt;const jt=class jt{constructor(t,n,e,s,r,o,a,h,c){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&n!=null&&e!=null&&s!=null&&r!=null&&o!=null&&a!=null&&h!=null&&c!=null&&this.set(t,n,e,s,r,o,a,h,c)}set(t,n,e,s,r,o,a,h,c){const l=this.elements;return l[0]=t,l[1]=s,l[2]=a,l[3]=n,l[4]=r,l[5]=h,l[6]=e,l[7]=o,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,r=this.elements,o=e[0],a=e[3],h=e[6],c=e[1],l=e[4],u=e[7],d=e[2],g=e[5],m=e[8],f=s[0],y=s[3],_=s[6],C=s[1],b=s[4],k=s[7],B=s[2],T=s[5],E=s[8];return r[0]=o*f+a*C+h*B,r[3]=o*y+a*b+h*T,r[6]=o*_+a*k+h*E,r[1]=c*f+l*C+u*B,r[4]=c*y+l*b+u*T,r[7]=c*_+l*k+u*E,r[2]=d*f+g*C+m*B,r[5]=d*y+g*b+m*T,r[8]=d*_+g*k+m*E,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],r=t[3],o=t[4],a=t[5],h=t[6],c=t[7],l=t[8];return n*o*l-n*a*c-e*r*l+e*a*h+s*r*c-s*o*h}invert(){const t=this.elements,n=t[0],e=t[1],s=t[2],r=t[3],o=t[4],a=t[5],h=t[6],c=t[7],l=t[8],u=l*o-a*c,d=a*h-l*r,g=c*r-o*h,m=n*u+e*d+s*g;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const f=1/m;return t[0]=u*f,t[1]=(s*c-l*e)*f,t[2]=(a*e-s*o)*f,t[3]=d*f,t[4]=(l*n-s*h)*f,t[5]=(s*r-a*n)*f,t[6]=g*f,t[7]=(e*h-c*n)*f,t[8]=(o*n-e*r)*f,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,r,o,a){const h=Math.cos(r),c=Math.sin(r);return this.set(e*h,e*c,-e*(h*o+c*a)+o+t,-s*c,s*h,-s*(-c*o+h*a)+a+n,0,0,1),this}scale(t,n){return this.premultiply(hn.makeScale(t,n)),this}rotate(t){return this.premultiply(hn.makeRotation(-t)),this}translate(t,n){return this.premultiply(hn.makeTranslation(t,n)),this}makeTranslation(t,n){return t instanceof N?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 jt().fromArray(this.elements)}};jt.IDENTITY=Object.freeze(new jt);let _t=jt;const hn=new _t,R=1e-6,S=2*Math.PI,es={x:0,y:0},cn={x:0,y:0,z:0};class M{constructor(){this.equalPointTol=R,this.equalVectorTol=R}clone(){const t=new M;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t}equalPoint2d(t,n){return new N(t).sub(n).length()<this.equalPointTol}equalPoint3d(t,n){return new x(t).sub(n).length()<this.equalPointTol}static equalToZero(t,n=R){return t<n&&t>-n}static equal(t,n,e=R){return Math.abs(t-n)<e}static great(t,n,e=R){return t-n>e}static less(t,n,e=R){return t-n<e}static isPositive(t,n=R){return t>n}static isNonPositive(t,n=R){return t<=n}}const Et=new M;class It{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,r,o,a){let h=e[s+0],c=e[s+1],l=e[s+2],u=e[s+3];const d=r[o+0],g=r[o+1],m=r[o+2],f=r[o+3];if(a===0){t[n+0]=h,t[n+1]=c,t[n+2]=l,t[n+3]=u;return}if(a===1){t[n+0]=d,t[n+1]=g,t[n+2]=m,t[n+3]=f;return}if(u!==f||h!==d||c!==g||l!==m){let y=1-a;const _=h*d+c*g+l*m+u*f,C=_>=0?1:-1,b=1-_*_;if(b>Number.EPSILON){const B=Math.sqrt(b),T=Math.atan2(B,_*C);y=Math.sin(y*T)/B,a=Math.sin(a*T)/B}const k=a*C;if(h=h*y+d*k,c=c*y+g*k,l=l*y+m*k,u=u*y+f*k,y===1-a){const B=1/Math.sqrt(h*h+c*c+l*l+u*u);h*=B,c*=B,l*=B,u*=B}}t[n]=h,t[n+1]=c,t[n+2]=l,t[n+3]=u}static multiplyQuaternionsFlat(t,n,e,s,r,o){const a=e[s],h=e[s+1],c=e[s+2],l=e[s+3],u=r[o],d=r[o+1],g=r[o+2],m=r[o+3];return t[n]=a*m+l*u+h*g-c*d,t[n+1]=h*m+l*d+c*u-a*g,t[n+2]=c*m+l*g+a*d-h*u,t[n+3]=l*m-a*u-h*d-c*g,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 It(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,r=t.z,o=t.order,a=Math.cos,h=Math.sin,c=a(e/2),l=a(s/2),u=a(r/2),d=h(e/2),g=h(s/2),m=h(r/2);switch(o){case"XYZ":this._x=d*l*u+c*g*m,this._y=c*g*u-d*l*m,this._z=c*l*m+d*g*u,this._w=c*l*u-d*g*m;break;case"YXZ":this._x=d*l*u+c*g*m,this._y=c*g*u-d*l*m,this._z=c*l*m-d*g*u,this._w=c*l*u+d*g*m;break;case"ZXY":this._x=d*l*u-c*g*m,this._y=c*g*u+d*l*m,this._z=c*l*m+d*g*u,this._w=c*l*u-d*g*m;break;case"ZYX":this._x=d*l*u-c*g*m,this._y=c*g*u+d*l*m,this._z=c*l*m-d*g*u,this._w=c*l*u+d*g*m;break;case"YZX":this._x=d*l*u+c*g*m,this._y=c*g*u+d*l*m,this._z=c*l*m-d*g*u,this._w=c*l*u-d*g*m;break;case"XZY":this._x=d*l*u-c*g*m,this._y=c*g*u-d*l*m,this._z=c*l*m+d*g*u,this._w=c*l*u+d*g*m;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],r=n[8],o=n[1],a=n[5],h=n[9],c=n[2],l=n[6],u=n[10],d=e+a+u;if(d>0){const g=.5/Math.sqrt(d+1);this._w=.25/g,this._x=(l-h)*g,this._y=(r-c)*g,this._z=(o-s)*g}else if(e>a&&e>u){const g=2*Math.sqrt(1+e-a-u);this._w=(l-h)/g,this._x=.25*g,this._y=(s+o)/g,this._z=(r+c)/g}else if(a>u){const g=2*Math.sqrt(1+a-e-u);this._w=(r-c)/g,this._x=(s+o)/g,this._y=.25*g,this._z=(h+l)/g}else{const g=2*Math.sqrt(1+u-e-a);this._w=(o-s)/g,this._x=(r+c)/g,this._y=(h+l)/g,this._z=.25*g}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(nt(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,r=t._z,o=t._w,a=n._x,h=n._y,c=n._z,l=n._w;return this._x=e*l+o*a+s*c-r*h,this._y=s*l+o*h+r*a-e*c,this._z=r*l+o*c+e*h-s*a,this._w=o*l-e*a-s*h-r*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,r=this._z,o=this._w;let a=o*t._w+e*t._x+s*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=e,this._y=s,this._z=r,this;const h=1-a*a;if(h<=Number.EPSILON){const g=1-n;return this._w=g*o+n*this._w,this._x=g*e+n*this._x,this._y=g*s+n*this._y,this._z=g*r+n*this._z,this.normalize(),this}const c=Math.sqrt(h),l=Math.atan2(c,a),u=Math.sin((1-n)*l)/c,d=Math.sin(n*l)/c;return this._w=o*u+this._w*d,this._x=e*u+this._x*d,this._y=s*u+this._y*d,this._z=r*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),r=Math.sqrt(e);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(n),r*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:r,y:o,z:a}=t;this.x=r,this.y=o,this.z=a||0;return}if(s===3){this.x=t,this.y=n,this.z=e;return}throw q.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(se.setFromEuler(t))}applyAxisAngle(t,n){return this.applyQuaternion(se.setFromAxisAngle(t,n))}applyMatrix3(t){const n=this.x,e=this.y,s=this.z,r=t.elements;return this.x=r[0]*n+r[3]*e+r[6]*s,this.y=r[1]*n+r[4]*e+r[7]*s,this.z=r[2]*n+r[5]*e+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const n=this.x,e=this.y,s=this.z,r=t.elements,o=1/(r[3]*n+r[7]*e+r[11]*s+r[15]);return this.x=(r[0]*n+r[4]*e+r[8]*s+r[12])*o,this.y=(r[1]*n+r[5]*e+r[9]*s+r[13])*o,this.z=(r[2]*n+r[6]*e+r[10]*s+r[14])*o,this}applyQuaternion(t){const n=this.x,e=this.y,s=this.z,r=t.x,o=t.y,a=t.z,h=t.w,c=2*(o*s-a*e),l=2*(a*n-r*s),u=2*(r*e-o*n);return this.x=n+h*c+o*u-a*l,this.y=e+h*l+a*c-r*u,this.z=s+h*u+r*l-o*c,this}transformDirection(t){const n=this.x,e=this.y,s=this.z,r=t.elements;return this.x=r[0]*n+r[4]*e+r[8]*s,this.y=r[1]*n+r[5]*e+r[9]*s,this.z=r[2]*n+r[6]*e+r[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,r=t.z,o=n.x,a=n.y,h=n.z;return this.x=s*h-r*a,this.y=r*o-e*h,this.z=e*a-s*o,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 ln.copy(this).projectOnVector(t),this.sub(ln)}reflect(t){return this.sub(ln.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 x=j;const ln=new x,se=new It,Ct=class Ct{static makeTranslation(t,n,e){return new Ct().makeTranslation(t,n,e)}constructor(t,n,e,s,r,o,a,h,c,l,u,d,g,m,f,y){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&&r!=null&&o!=null&&a!=null&&h!=null&&c!=null&&l!=null&&u!=null&&d!=null&&g!=null&&m!=null&&f!=null&&y!=null&&this.set(t,n,e,s,r,o,a,h,c,l,u,d,g,m,f,y)}set(t,n,e,s,r,o,a,h,c,l,u,d,g,m,f,y){const _=this.elements;return _[0]=t,_[4]=n,_[8]=e,_[12]=s,_[1]=r,_[5]=o,_[9]=a,_[13]=h,_[2]=c,_[6]=l,_[10]=u,_[14]=d,_[3]=g,_[7]=m,_[11]=f,_[15]=y,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 Ct().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){const n=Math.hypot(t.x,t.y,t.z);if(!Number.isFinite(n)||n<1e-12)return this.identity(),this;const e=Math.abs(n-1)>1e-6?t.clone().multiplyScalar(1/n):t;if(Et.equalPoint3d(e,x.Z_AXIS))this.identity();else{const s=new x(1,0,0);Math.abs(e.x)<1/64&&Math.abs(e.y)<1/64?s.crossVectors(x.Y_AXIS,e).normalize():s.crossVectors(x.Z_AXIS,e).normalize();const r=e.clone().cross(s).normalize();this.makeBasis(s,r,e)}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/At.setFromMatrixColumn(t,0).length(),r=1/At.setFromMatrixColumn(t,1).length(),o=1/At.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]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=0,n[8]=e[8]*o,n[9]=e[9]*o,n[10]=e[10]*o,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ss,t,is)}lookAt(t,n,e){const s=this.elements;return X.subVectors(t,n),X.lengthSq()===0&&(X.z=1),X.normalize(),ht.crossVectors(e,X),ht.lengthSq()===0&&(Math.abs(e.z)===1?X.x+=1e-4:X.z+=1e-4,X.normalize(),ht.crossVectors(e,X)),ht.normalize(),vt.crossVectors(X,ht),s[0]=ht.x,s[4]=vt.x,s[8]=X.x,s[1]=ht.y,s[5]=vt.y,s[9]=X.y,s[2]=ht.z,s[6]=vt.z,s[10]=X.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,r=this.elements,o=e[0],a=e[4],h=e[8],c=e[12],l=e[1],u=e[5],d=e[9],g=e[13],m=e[2],f=e[6],y=e[10],_=e[14],C=e[3],b=e[7],k=e[11],B=e[15],T=s[0],E=s[4],dt=s[8],I=s[12],F=s[1],U=s[5],ot=s[9],at=s[13],D=s[2],Qt=s[6],Kt=s[10],$t=s[14],Ht=s[3],Jt=s[7],tn=s[11],nn=s[15];return r[0]=o*T+a*F+h*D+c*Ht,r[4]=o*E+a*U+h*Qt+c*Jt,r[8]=o*dt+a*ot+h*Kt+c*tn,r[12]=o*I+a*at+h*$t+c*nn,r[1]=l*T+u*F+d*D+g*Ht,r[5]=l*E+u*U+d*Qt+g*Jt,r[9]=l*dt+u*ot+d*Kt+g*tn,r[13]=l*I+u*at+d*$t+g*nn,r[2]=m*T+f*F+y*D+_*Ht,r[6]=m*E+f*U+y*Qt+_*Jt,r[10]=m*dt+f*ot+y*Kt+_*tn,r[14]=m*I+f*at+y*$t+_*nn,r[3]=C*T+b*F+k*D+B*Ht,r[7]=C*E+b*U+k*Qt+B*Jt,r[11]=C*dt+b*ot+k*Kt+B*tn,r[15]=C*I+b*at+k*$t+B*nn,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],r=t[12],o=t[1],a=t[5],h=t[9],c=t[13],l=t[2],u=t[6],d=t[10],g=t[14],m=t[3],f=t[7],y=t[11],_=t[15];return m*(+r*h*u-s*c*u-r*a*d+e*c*d+s*a*g-e*h*g)+f*(+n*h*g-n*c*d+r*o*d-s*o*g+s*c*l-r*h*l)+y*(+n*c*u-n*a*g-r*o*u+e*o*g+r*a*l-e*c*l)+_*(-s*a*l-n*h*u+n*a*d+s*o*u-e*o*d+e*h*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 x?(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],r=t[3],o=t[4],a=t[5],h=t[6],c=t[7],l=t[8],u=t[9],d=t[10],g=t[11],m=t[12],f=t[13],y=t[14],_=t[15],C=u*y*c-f*d*c+f*h*g-a*y*g-u*h*_+a*d*_,b=m*d*c-l*y*c-m*h*g+o*y*g+l*h*_-o*d*_,k=l*f*c-m*u*c+m*a*g-o*f*g-l*a*_+o*u*_,B=m*u*h-l*f*h-m*a*d+o*f*d+l*a*y-o*u*y,T=n*C+e*b+s*k+r*B;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/T;return t[0]=C*E,t[1]=(f*d*r-u*y*r-f*s*g+e*y*g+u*s*_-e*d*_)*E,t[2]=(a*y*r-f*h*r+f*s*c-e*y*c-a*s*_+e*h*_)*E,t[3]=(u*h*r-a*d*r-u*s*c+e*d*c+a*s*g-e*h*g)*E,t[4]=b*E,t[5]=(l*y*r-m*d*r+m*s*g-n*y*g-l*s*_+n*d*_)*E,t[6]=(m*h*r-o*y*r-m*s*c+n*y*c+o*s*_-n*h*_)*E,t[7]=(o*d*r-l*h*r+l*s*c-n*d*c-o*s*g+n*h*g)*E,t[8]=k*E,t[9]=(m*u*r-l*f*r-m*e*g+n*f*g+l*e*_-n*u*_)*E,t[10]=(o*f*r-m*a*r+m*e*c-n*f*c-o*e*_+n*a*_)*E,t[11]=(l*a*r-o*u*r-l*e*c+n*u*c+o*e*g-n*a*g)*E,t[12]=B*E,t[13]=(l*f*s-m*u*s+m*e*d-n*f*d-l*e*y+n*u*y)*E,t[14]=(m*a*s-o*f*s-m*e*h+n*f*h+o*e*y-n*a*y)*E,t[15]=(o*u*s-l*a*s+l*e*h-n*u*h-o*e*d+n*a*d)*E,this}scale(t){const n=this.elements,e=t.x,s=t.y,r=t.z;return n[0]*=e,n[4]*=s,n[8]*=r,n[1]*=e,n[5]*=s,n[9]*=r,n[2]*=e,n[6]*=s,n[10]*=r,n[3]*=e,n[7]*=s,n[11]*=r,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 typeof t=="object"?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z??0,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),r=1-e,o=t.x,a=t.y,h=t.z,c=r*o,l=r*a;return this.set(c*o+e,c*a-s*h,c*h+s*a,0,c*a+s*h,l*a+e,l*h-s*o,0,c*h-s*a,l*h+s*o,r*h*h+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,r,o){return this.set(1,e,r,0,t,1,o,0,n,s,1,0,0,0,0,1),this}compose(t,n,e){const s=this.elements,r=n.x,o=n.y,a=n.z,h=n.w,c=r+r,l=o+o,u=a+a,d=r*c,g=r*l,m=r*u,f=o*l,y=o*u,_=a*u,C=h*c,b=h*l,k=h*u,B=e.x,T=e.y,E=e.z;return s[0]=(1-(f+_))*B,s[1]=(g+k)*B,s[2]=(m-b)*B,s[3]=0,s[4]=(g-k)*T,s[5]=(1-(d+_))*T,s[6]=(y+C)*T,s[7]=0,s[8]=(m+b)*E,s[9]=(y-C)*E,s[10]=(1-(d+f))*E,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 r=At.set(s[0],s[1],s[2]).length();const o=At.set(s[4],s[5],s[6]).length(),a=At.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],K.copy(this);const c=1/r,l=1/o,u=1/a;return K.elements[0]*=c,K.elements[1]*=c,K.elements[2]*=c,K.elements[4]*=l,K.elements[5]*=l,K.elements[6]*=l,K.elements[8]*=u,K.elements[9]*=u,K.elements[10]*=u,n.setFromRotationMatrix(K),e.x=r,e.y=o,e.z=a,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}};Ct.IDENTITY=Object.freeze(new Ct);let et=Ct;const At=new x,K=new et,ss=new x(0,0,0),is=new x(1,1,1),ht=new x,vt=new x,X=new x;class G{constructor(t=void 0,n=void 0){this.min=t==null?new x(1/0,1/0,1/0):new x(t.x,t.y,t.z),this.max=n==null?new x(-1/0,-1/0,-1/0):new x(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(un.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=un.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new G().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 x(0,0,0):new x(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new x(0,0,0):new x(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,un).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:(st[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),st[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),st[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),st[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),st[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),st[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),st[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),st[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(st),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 st=[new x,new x,new x,new x,new x,new x,new x,new x],un=new x,ie=new N;class W{constructor(t=void 0,n=void 0){this.min=t==null?new N(1/0,1/0):new N(t.x,t.y),this.max=n==null?new N(-1/0,-1/0):new N(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=ie.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new W().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 N(0,0):new N(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new N(0,0):new N(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,ie).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 re=new x,rs=new x,os=new _t;class Pt{constructor(t=new x(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=re.subVectors(e,n).cross(rs.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||os.getNormalMatrix(t),s=this.coplanarPoint(re).applyMatrix4(t),r=this.normal.applyMatrix3(e).normalize();return this.constant=-s.dot(r),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 Pt().copy(this)}}class P extends N{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 w extends x{clone(){return new w(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((r,o)=>{r.toArray(s,o*e)}),s}}const oe=new et,ae=new It,Lt=class Lt{constructor(t=0,n=0,e=0,s=Lt.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 Lt(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,r=s[0],o=s[4],a=s[8],h=s[1],c=s[5],l=s[9],u=s[2],d=s[6],g=s[10];switch(n){case"XYZ":this._y=Math.asin(nt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,g),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-nt(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,g),this._z=Math.atan2(h,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(nt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,g),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(h,r));break;case"ZYX":this._y=Math.asin(-nt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,g),this._z=Math.atan2(h,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(nt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,g));break;case"XZY":this._z=Math.asin(-nt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-l,g),this._y=0);break}return this._order=n,e===!0&&this._onChangeCallback(),this}setFromQuaternion(t,n,e=!0){return oe.makeRotationFromQuaternion(t),this.setFromRotationMatrix(oe,n,e)}setFromVector3(t,n=this._order){return this.set(t.x,t.y,t.z,n)}reorder(t){return ae.setFromEuler(this),this.setFromQuaternion(ae,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}};Lt.DEFAULT_ORDER="XYZ";let dn=Lt;function as(i){const t=i;return{x:i.x,y:i.y,z:t.z??0}}function hs(i,t){i.x+=t.x,i.y+=t.y,i.z=(i.z??0)+(t.z??0)}function cs(i,t,n=!1){const e=i.x,s=i.y;let r=!1;const o=t.length;for(let a=0,h=o-1;a<o;h=a++){const c=t[a].x,l=t[a].y,u=t[h].x,d=t[h].y;let g=l>s!=d>s;n&&(g=l>=s!=d>=s),g&&e<(u-c)*(s-l)/(d-l)+c&&(r=!r)}return r}function ls(i,t){if(i.length===0||t.length===0)return!1;const n=new W().setFromPoints(i),e=new W().setFromPoints(t);if(!n.intersectsBox(e))return!1;for(let s=0;s<i.length;){if(v.isPointInPolygon(i[s],t,!0))return!0;s<i.length-1&&Et.equalPoint2d(i[s+1],i[s])&&++s,++s}return!1}const v={applyOffsetToPoint3d:hs,isPointInPolygon:cs,isPolygonIntersect:ls,point2dToPoint3d:as};function us(i,t){const n=[],e=t-1,s=i;for(let r=0;r<=s;r++)n.push(0);for(let r=1;r<=e-s;r++)n.push(r);for(let r=0;r<=s;r++)n.push(e-s+1);return n}function ds(i,t){const n=t.length-1,e=i,s=[0];let r=0;for(let a=1;a<=n;a++){const h=t[a][0]-t[a-1][0],c=t[a][1]-t[a-1][1],l=t[a][2]-t[a-1][2],u=Math.sqrt(h*h+c*c+l*l);r+=u,s.push(r)}const o=[];for(let a=0;a<=e;a++)o.push(0);for(let a=1;a<=n-e;a++){const h=s[a]/r;o.push(h*(n-e+1))}for(let a=0;a<=e;a++)o.push(n-e+1);return o}function he(i,t="Uniform"){const n=i.length;if(n===0)return[];if(n===1)return[0];const e=n-1;if(t==="Uniform")return new Array(n).fill(0).map((o,a)=>a/e);const s=[0];let r=0;for(let o=1;o<=e;o++){const a=i[o][0]-i[o-1][0],h=i[o][1]-i[o-1][1],c=i[o][2]-i[o-1][2],l=Math.sqrt(a*a+h*h+c*c),u=t==="SqrtChord"?Math.sqrt(l):l;r+=u,s.push(r)}return r<1e-12?new Array(n).fill(0).map((o,a)=>a/e):s.map(o=>o/r)}function ce(i,t){const n=t.length-1,e=i,s=n+e+1,r=new Array(s+1).fill(0),o=t[t.length-1];for(let a=s-e;a<=s;a++)r[a]=o;for(let a=1;a<=n-e;a++){let h=0;for(let c=a;c<a+e;c++)h+=t[c];r[a+e]=h/e}return r}function gs(i,t){const n=t.length-1,e=i,s=[0];let r=0;for(let a=1;a<=n;a++){const h=t[a][0]-t[a-1][0],c=t[a][1]-t[a-1][1],l=t[a][2]-t[a-1][2],u=Math.sqrt(h*h+c*c+l*l),d=Math.sqrt(u);r+=d,s.push(r)}const o=[];for(let a=0;a<=e;a++)o.push(0);for(let a=1;a<=n-e;a++){const h=s[a]/r;o.push(h*(n-e+1))}for(let a=0;a<=e;a++)o.push(n-e+1);return o}function gn(i,t){const n=i.length,e=i.map(o=>o.slice()),s=t.slice();for(let o=0;o<n;o++){let a=o,h=Math.abs(e[o][o]);for(let c=o+1;c<n;c++){const l=Math.abs(e[c][o]);l>h&&(h=l,a=c)}if(h<1e-12)throw new Error("Interpolation matrix is singular.");if(a!==o){const c=e[o];e[o]=e[a],e[a]=c;const l=s[o];s[o]=s[a],s[a]=l}for(let c=o+1;c<n;c++){const l=e[c][o]/e[o][o];if(!(Math.abs(l)<1e-14)){for(let u=o;u<n;u++)e[c][u]-=l*e[o][u];s[c]-=l*s[o]}}}const r=new Array(n).fill(0);for(let o=n-1;o>=0;o--){let a=s[o];for(let h=o+1;h<n;h++)a-=e[o][h]*r[h];r[o]=a/e[o][o]}return r}function mn(i,t,n="Uniform",e,s){if(i.length===0)return{controlPoints:[],knots:[],weights:[]};const r=i.map(I=>[I[0],I[1],I[2]??0]),o=!!e,a=!!s,h=(o?1:0)+(a?1:0),c=r.length-1,l=c+h;if(l<t)throw new Error("Not enough points to interpolate a curve of this degree.");const u=he(r,n),d=u.slice();o&&d.unshift(u[0]),a&&d.push(u[u.length-1]);const g=ce(t,d),m=l+1,f=new Array(m),y=new Array(m),_=new Array(m),C=new Array(m);let b=0;f[b]=new Array(m).fill(0),f[b][0]=1,y[b]=r[0][0],_[b]=r[0][1],C[b]=r[0][2],b++;for(let I=1;I<=c-1;I++){const F=u[I];f[b]=new Array(m).fill(0);for(let U=0;U<=l;U++)f[b][U]=ct(U,t,F,g);y[b]=r[I][0],_[b]=r[I][1],C[b]=r[I][2],b++}if(f[b]=new Array(m).fill(0),f[b][l]=1,y[b]=r[c][0],_[b]=r[c][1],C[b]=r[c][2],b++,o){const I=g[t+1]-g[0],F=I!==0?t/I:0;f[b]=new Array(m).fill(0),f[b][0]=-F,f[b][1]=F,y[b]=(e==null?void 0:e[0])??0,_[b]=(e==null?void 0:e[1])??0,C[b]=(e==null?void 0:e[2])??0,b++}if(a){const I=g[l+t+1]-g[l],F=I!==0?t/I:0;f[b]=new Array(m).fill(0),f[b][l-1]=-F,f[b][l]=F,y[b]=(s==null?void 0:s[0])??0,_[b]=(s==null?void 0:s[1])??0,C[b]=(s==null?void 0:s[2])??0,b++}const k=gn(f,y),B=gn(f,_),T=gn(f,C),E=new Array(m);for(let I=0;I<m;I++)E[I]=[k[I],B[I],T[I]];const dt=new Array(m).fill(1);return{controlPoints:E,knots:g,weights:dt}}function ct(i,t,n,e){if(t===0)return n>=e[i]&&n<e[i+1]?1:0;const s=e[i+t]-e[i],r=e[i+t+1]-e[i+1],o=s>1e-10?(n-e[i])/s:0,a=r>1e-10?(e[i+t+1]-n)/r:0;return o*ct(i,t-1,n,e)+a*ct(i+1,t-1,n,e)}function Tt(i,t,n,e,s){const r=e.length-1,o=t;if(i=Math.max(n[o],Math.min(n[r+1],i)),Math.abs(i-n[r+1])<1e-8)return[...e[r]];if(Math.abs(i-n[o])<1e-8)return[...e[0]];const a=[0,0,0];let h=0;for(let c=0;c<=r;c++){const l=ct(c,o,i,n),u=s[c]*l;a[0]+=e[c][0]*u,a[1]+=e[c][1]*u,a[2]+=e[c][2]*u,h+=u}if(Math.abs(h)<1e-10){const c=n[n.length-o-1];if(Math.abs(i-c)<1e-8)return[...e[r]];if(Math.abs(i-n[o])<1e-8)return[...e[0]]}return Math.abs(h)>=1e-10&&(a[0]/=h,a[1]/=h,a[2]/=h),a}function fn(i,t,n,e){if(t===0)return 0;const s=e[i+t]-e[i],r=e[i+t+1]-e[i+1];let o=0;return s>1e-10&&(o+=t/s*ct(i,t-1,n,e)),r>1e-10&&(o-=t/r*ct(i+1,t-1,n,e)),o}function ms(i,t,n,e){if(t<=1)return 0;const s=e[i+t]-e[i],r=e[i+t+1]-e[i+1];let o=0;return s>1e-10&&(o+=t/s*fn(i,t-1,n,e)),r>1e-10&&(o-=t/r*fn(i+1,t-1,n,e)),o}function le(i,t,n,e,s){const r=e.length-1,o=t,a=n[o],h=n[r+1];i=Math.max(a,Math.min(h,i));const c=[0,0,0],l=[0,0,0],u=[0,0,0];let d=0,g=0,m=0;for(let T=0;T<=r;T++){const E=ct(T,o,i,n),dt=fn(T,o,i,n),I=ms(T,o,i,n),F=s[T],U=F*E,ot=F*dt,at=F*I,D=e[T];c[0]+=U*D[0],c[1]+=U*D[1],c[2]+=U*D[2],l[0]+=ot*D[0],l[1]+=ot*D[1],l[2]+=ot*D[2],u[0]+=at*D[0],u[1]+=at*D[1],u[2]+=at*D[2],d+=U,g+=ot,m+=at}if(Math.abs(d)<1e-10)return{point:Tt(i,t,n,e,s),deriv1:[0,0,0],deriv2:[0,0,0]};const f=d*d,y=[c[0]/d,c[1]/d,c[2]/d],_=[(l[0]*d-c[0]*g)/f,(l[1]*d-c[1]*g)/f,(l[2]*d-c[2]*g)/f],C=u[0]*d-c[0]*m,b=u[1]*d-c[1]*m,k=u[2]*d-c[2]*m,B=[C/f-2*g*_[0]/d,b/f-2*g*_[1]/d,k/f-2*g*_[2]/d];return{point:y,deriv1:_,deriv2:B}}function ue(i,t){const n=i[0],e=i[1],s=t[0],r=t[1],o=n*n+e*e;return o<1e-20?0:(n*r-e*s)/Math.pow(o,1.5)}function de(i,t,n,e){const s=i,r=t[s],o=t[t.length-s-1];let a=0;const h=1e3,c=(o-r)/h;let l=Tt(r,i,t,n,e);for(let f=1;f<=h;f++){const y=r+f*c,_=Tt(y,i,t,n,e),C=_[0]-l[0],b=_[1]-l[1],k=_[2]-l[2];a+=Math.sqrt(C*C+b*b+k*k),l=_}const u=Tt(o,i,t,n,e),d=u[0]-l[0],g=u[1]-l[1],m=u[2]-l[2];return a+=Math.sqrt(d*d+g*g+m*m),a}function fs(i,t=3,n="Uniform",e,s){return i.length===0?[]:mn(i,t,n,e,s).controlPoints}const ge=new et,me=new x,ys=new x,xs=new x,yn=new w;function fe(i){return new et().setFromExtrusionDirection(new x(i.x,i.y,i.z))}function _s(i){return ge.setFromExtrusionDirection(new x(i.x,i.y,i.z)),ge.extractBasis(me,ys,xs),me.clone()}function As(i,t){return new w(i.x,i.y,i.z??0).applyMatrix4(fe(t))}function xn(i,t){return new w(i.x,i.y,i.z??0).applyMatrix4(fe(t).invert())}function Ps(i,t,n){const e=xn(i,n),s=xn(t,n);return yn.set(s.x-e.x,s.y-e.y,(s.z??0)-(e.z??0)),p.normalizeAngle(Math.atan2(yn.y,yn.x))}function _n(i){const t=i.length;if(t<3)return 0;let n=0;for(let e=0,s=t-1;e<t;s=e++){const r=i[s],o=i[e];n+=r.x*o.y-o.x*r.y}return n*.5}function ye(i){return Math.abs(_n(i))}function xe(i){const t=i.length;if(t<3)return 0;let n=0,e=0,s=0;for(let r=0,o=t-1;r<t;o=r++){const a=i[o],h=i[r],c=a.x,l=a.y,u=a.z??0,d=h.x,g=h.y,m=h.z??0;n+=(u+m)*(l-g),e+=(c+d)*(u-m),s+=(l+g)*(c-d)}return .5*Math.hypot(n,e,s)}function _e(i){return i.length<3?0:ye(i)}function Ae(i){return i.length<3?0:xe(i)}function An(i,t,n){const e=i.x,s=i.y,r=t.x,o=t.y,a=n.x,h=n.y,c=2*(e*(o-h)+r*(h-s)+a*(s-o));if(M.equalToZero(c))return null;const l=((e*e+s*s)*(o-h)+(r*r+o*o)*(h-s)+(a*a+h*h)*(s-o))/c,u=((e*e+s*s)*(a-r)+(r*r+o*o)*(e-a)+(a*a+h*h)*(r-e))/c,d=Math.hypot(l-e,u-s);return!Number.isFinite(d)||M.isNonPositive(d)?null:{center:new P(l,u),radius:d}}function Pe(i,t,n){const e=i.x,s=i.y,r=i.z??0,o=new x(t.x-e,t.y-s,(t.z??0)-r),a=new x(n.x-e,n.y-s,(n.z??0)-r),h=new x().crossVectors(o,a),c=h.lengthSq();if(c<R*R)return null;const l=o.lengthSq(),u=a.lengthSq(),d=new x().crossVectors(h,o).multiplyScalar(u).add(new x().crossVectors(a,h).multiplyScalar(l)).multiplyScalar(1/(2*c)),g=new w(e+d.x,s+d.y,r+d.z),m=Math.hypot(g.x-e,g.y-s,g.z-r);return!Number.isFinite(m)||M.isNonPositive(m)?null:{center:g,radius:m}}function lt(i,t){return Math.atan2(t.y-i.y,t.x-i.x)}function H(i,t){return Math.hypot(t.x-i.x,t.y-i.y)}function pe(i,t,n){if(M.isNonPositive(t))return null;const e=n.x-i.x,s=n.y-i.y,r=Math.hypot(e,s);if(M.isNonPositive(r))return null;const o=t/r;return new P(i.x+e*o,i.y+s*o)}const ps=1e-8;function we(i,t,n,e){return Math.abs(H(i,t)-n)<=(e??Math.max(R,n*1e-5))}function Me(i,t,n,e,s=ps){return Math.abs(i.x-n.x)<=s&&Math.abs(i.y-n.y)<=s&&Math.abs(t-e)<=s}function ze(i,t,n,e){const s=Math.max(1e-18,Math.abs(n)*1e-9);return i<n-s?!0:i>n+s?!1:t>e}function be(i,t,n,e=!1){const s=An(i,t,n);if(!s)return null;const r=lt(s.center,i),o=lt(s.center,t),a=lt(s.center,n);let h=!p.isAngleOnCcwSweep(r,o,a);return e&&(h=!h),O.fromMathAngles(s.center,s.radius,r,a,h)}function Pn(i,t){return!Number.isFinite(t)||M.isNonPositive(t)?null:new O(i,t,0,S,!1)}function ws(i,t){const n=H(i,t);return M.isNonPositive(n)?null:Pn({x:(i.x+t.x)/2,y:(i.y+t.y)/2},n/2)}function Ms(i,t,n){const e=An(i,t,n);return e?Pn(e.center,e.radius):null}function zs(i,t,n){const e=H(n,i);if(M.isNonPositive(e))return null;const s=lt(n,i),r=lt(n,t),o=p.normalizeAngle(r-s);return O.fromMathAngles(n,e,s,r,o>Math.PI)}function kt(i,t,n,e){const s=H(i,t),r=H(i,n);if(M.isNonPositive(s)||M.isNonPositive(r))return null;const o=Math.max(R,s*R);return Math.abs(s-r)>o?null:O.fromMathAngles(i,s,lt(i,t),lt(i,n),e)}function bs(i,t,n,e){const s=H(i,t);if(M.isNonPositive(s))return null;const r=pe(i,s,n);return r?kt(i,t,r,e):null}function Se(i,t,n){const e=H(i,t),s=Math.abs(n);if(M.isNonPositive(e)||M.isNonPositive(s)||!M.great(S-s,0))return null;const r=n<0,o=lt(i,t),a=r?o-s:o+s;return O.fromMathAngles(i,e,o,a,r)}function Ss(i,t,n){const e=H(i,t),s=Math.abs(n);if(M.isNonPositive(e)||M.isNonPositive(s)||M.great(s,2*e))return null;const r=Math.max(-1,Math.min(1,s/(2*e))),o=2*Math.asin(r);return Se(i,t,n>=0?o:-o)}function Cs(i,t,n){const e=H(i,t),s=Math.abs(n);if(M.isNonPositive(e)||M.isNonPositive(s)||!M.great(S-s,0))return null;const r=Math.sin(s/2);if(M.equalToZero(r))return null;const o=e/(2*r),a=o*o-e*e/4;if(M.less(a,0))return null;const h=Math.sqrt(Math.max(0,a)),c=(i.x+t.x)/2,l=(i.y+t.y)/2,u=t.x-i.x,g=-(t.y-i.y)/e,m=u/e,f=n>=0,_=f&&s<=Math.PI||!f&&s>Math.PI?1:-1,C={x:c+g*h*_,y:l+m*h*_};return kt(C,i,t,!f)}function Es(i,t,n){const e=Math.cos(n),s=Math.sin(n),r=t.x-i.x,o=t.y-i.y,a=-s,h=e,c=2*(r*a+o*h);if(M.equalToZero(c))return null;const l=(r*r+o*o)/c;if(!Number.isFinite(l))return null;const u={x:i.x+a*l,y:i.y+h*l},d=i.x-u.x,g=i.y-u.y,m=d*s-g*e;return M.equalToZero(m)?null:kt(u,i,t,m<0)}function Is(i,t,n){const e=Math.abs(n),s=H(i,t);if(M.isNonPositive(e)||M.isNonPositive(s)||M.great(s,2*e))return null;const r=(i.x+t.x)/2,o=(i.y+t.y)/2,a=t.x-i.x,c=-(t.y-i.y)/s,l=a/s,u=Math.sqrt(Math.max(0,e*e-s*s/4)),d=n>=0?1:-1,g={x:r+c*u*d,y:o+l*u*d};return kt(g,i,t,n<0)}class Ce{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class pn extends Ce{translate(t){return this.transform(new _t().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class pt extends pn{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),r=0;n.push(0);for(let o=1;o<=t;o++)e=this.getPoint(o/t),r+=e.distanceTo(s),n.push(r),s=e;return n}getUtoTmapping(t,n){const e=this.getLengths();let s=0;const r=e.length;let o;n?o=n:o=t*e[r-1];let a=0,h=r-1,c;for(;a<=h;)if(s=Math.floor(a+(h-a)/2),c=e[s]-o,c<0)a=s+1;else if(c>0)h=s-1;else{h=s;break}if(s=h,e[s]===o)return s/(r-1);const l=e[s],d=e[s+1]-l,g=(o-l)/d;return(s+g)/(r-1)}getTangent(t){let e=t-1e-4,s=t+1e-4;e<0&&(e=0),s>1&&(s=1);const r=this.getPoint(e),o=this.getPoint(s),a=new P;return a.copy(o).sub(r).normalize(),a}getTangentAt(t){const n=this.getUtoTmapping(t);return this.getTangent(n)}}class O extends pt{constructor(t,n,e,s,r){super();const o=+(t!==void 0)+ +(n!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(r!==void 0);if(o==3)typeof t=="object"&&typeof n=="object"&&typeof e=="object"?this.createByThreePoints(t,n,e):this.createByStartEndPointsAndBulge(t,n,e);else if(o==5){const a=t;this.center=new P(a.x,a.y),this.radius=n,this._clockwise=r,this._startAngle=this._clockwise?this._mirrorAngle(p.normalizeAngle(e)):p.normalizeAngle(e),this._endAngle=this._clockwise?this._mirrorAngle(p.normalizeAngle(s)):p.normalizeAngle(s)}else throw q.AcCmErrors.ILLEGAL_PARAMETERS}static fromMathAngles(t,n,e,s,r){const o=new O(t,n,p.normalizeAngle(e),p.normalizeAngle(s),!1);return o._clockwise=r,o._boundingBoxNeedsUpdate=!0,o}static computeCircumcircle(t,n,e){return An(t,n,e)}static projectPoint(t,n,e){return pe(t,n,e)}static pointLiesOnCircle(t,n,e,s){return we(t,n,e,s)}static sameCircle(t,n,e,s,r){return Me(t,n,e,s,r)}static isBetterDistanceAlign(t,n,e,s){return ze(t,n,e,s)}static tryCreateByThreePoints(t,n,e,s=!1){return be(t,n,e,s)}static tryCreateCircle(t,n){return Pn(t,n)}static tryCreateCircleByDiameter(t,n){return ws(t,n)}static tryCreateCircleByThreePoints(t,n,e){return Ms(t,n,e)}static tryCreateShorterArc(t,n,e){return zs(t,n,e)}static tryCreateByCenterStartEnd(t,n,e,s){return kt(t,n,e,s)}static tryCreateByCenterStartProjectedEnd(t,n,e,s){return bs(t,n,e,s)}static tryCreateByCenterStartSweep(t,n,e){return Se(t,n,e)}static tryCreateByCenterStartChord(t,n,e){return Ss(t,n,e)}static tryCreateByStartEndAngle(t,n,e){return Cs(t,n,e)}static tryCreateByStartEndDirection(t,n,e){return Es(t,n,e)}static tryCreateByStartEndRadius(t,n,e){return Is(t,n,e)}createByThreePoints(t,n,e){const s=be(t,n,e);if(!s)throw q.AcCmErrors.ILLEGAL_PARAMETERS;this.center=s.center,this.radius=s.radius,this._clockwise=s._clockwise,this._startAngle=s._startAngle,this._endAngle=s._endAngle,this._boundingBoxNeedsUpdate=!0}createByStartEndPointsAndBulge(t,n,e){let s,r,o;e<0?(s=Math.atan(-e)*4,r=new N(t),o=new N(n)):(s=Math.atan(e)*4,r=new N(n),o=new N(t));const a=new N().subVectors(o,r),h=a.length(),c=new N().addVectors(r,a.multiplyScalar(.5)),l=Math.abs(h/2/Math.tan(s/2)),u=a.normalize(),d=e<0?-Math.PI/2:Math.PI/2,g=new N(u.x*Math.cos(d)-u.y*Math.sin(d),u.y*Math.cos(d)+u.x*Math.sin(d));let m;s<Math.PI?e<0?m=c.add(g.multiplyScalar(l)):m=c.add(g.multiplyScalar(-l)):e<0?m=c.add(g.multiplyScalar(-l)):m=c.add(g.multiplyScalar(l)),e<0?(this._startAngle=Math.atan2(r.y-m.y,r.x-m.x),this._endAngle=Math.atan2(o.y-m.y,o.x-m.x)):(this._startAngle=Math.atan2(o.y-m.y,o.x-m.x),this._endAngle=Math.atan2(r.y-m.y,r.x-m.x)),this._clockwise=e<0,this.center=m,this.radius=o.sub(m).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(p.normalizeAngle(t)):p.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==S?t:p.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?p.normalizeAngle(t-n):p.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?p.normalizeAngle(t-this.deltaAngle/2):p.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 r of n){const o=this._getInternalAngle(r);p.isBetweenAngle(o,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(r))}const e=t.map(r=>r.x),s=t.map(r=>r.y);return new W(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 r=this.midPoint.clone().applyMatrix2d(n),o=this.endPoint.clone().applyMatrix2d(n),a=new O(s,r,o),h=n.determinant()<0?!this.clockwise:this.clockwise,c=l=>{const u=p.normalizeAngle(l);return h?this._mirrorAngle(u):u};return this.center=a.center,this.radius=a.radius,this.clockwise=h,this.startAngle=c(Math.atan2(s.y-a.center.y,s.x-a.center.x)),this.endAngle=c(Math.atan2(o.y-a.center.y,o.x-a.center.x)),this._boundingBoxNeedsUpdate=!0,this}clone(){return new O(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 r of s){const o=this._getInternalAngle(r);p.isBetweenAngle(o,n,e,this.clockwise)&&t.push(this.getPointAtAngle(r))}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 o=Math.atan2(s,e),a=this.clockwise?this._mirrorAngle(p.normalizeAngle(o)):p.normalizeAngle(o),h=this._getInternalAngle(a),c=this._getInternalAngle(this.startAngle),l=this._getInternalAngle(this.endAngle);if(p.isBetweenAngle(h,c,l,this.clockwise))return this.getPointAtAngle(a);const u=n.distanceToSquared(this.startPoint),d=n.distanceToSquared(this.endPoint);return u<=d?this.startPoint.clone():this.endPoint.clone()}inwardAlignment(t,n){const e=n.x-t.x,s=n.y-t.y;if(e*e+s*s<1e-24)return 0;const r=this.radius>0?this.radius:1,o=Math.max(1e-16,1e-12*r*r),a=this.startPoint.distanceToSquared(t)<=o,h=this.endPoint.distanceToSquared(t)<=o;if(!a&&!h)return 0;const c=this.getPoints(8);if(c.length<3)return 0;const l=a&&!h?c[1]:c[c.length-2],u=l.x-t.x,d=l.y-t.y,g=Math.hypot(u,d);return g>1e-18?(e*u+s*d)/g:0}perpendicularPoints(t){const n=new P(t.x,t.y),e=n.x-this.center.x,s=n.y-this.center.y,r=Math.hypot(e,s);if(r<1e-12)return[];const o=e/r,a=s/r,h=[new P(this.center.x+o*this.radius,this.center.y+a*this.radius),new P(this.center.x-o*this.radius,this.center.y-a*this.radius)],c=[],l=this._getInternalAngle(this.startAngle),u=this._getInternalAngle(this.endAngle);for(const d of h){const g=Math.atan2(d.y-this.center.y,d.x-this.center.x),m=this.clockwise?this._mirrorAngle(p.normalizeAngle(g)):p.normalizeAngle(g),f=this._getInternalAngle(m);(this.closed||p.isBetweenAngle(f,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,r=Math.hypot(e,s),o=this.radius;if(r<o)return n;const a=Math.acos(o/r),h=Math.atan2(s,e),c=[h+a,h-a],l=this._getInternalAngle(this.startAngle),u=this._getInternalAngle(this.endAngle);for(const d of c){const g=this.clockwise?this._mirrorAngle(p.normalizeAngle(d)):p.normalizeAngle(d),m=this._getInternalAngle(g);(this.closed||p.isBetweenAngle(m,l,u,this.clockwise))&&n.push(this.getPointAtAngle(g))}return n}getPoints(t=100){const n=[];let e=this.deltaAngle,s=this._getInternalAngle(this.startAngle);if(this.closed&&(e=S,s=0),this.clockwise)for(let r=0;r<=t;r++){const o=s-e*(r/t),a=this._clockwise?this._mirrorAngle(o):o,h=this.getPointAtAngle(a);n.push(new P(h.x,h.y))}else for(let r=0;r<=t;r++){const o=s+e*(r/t),a=this._clockwise?this._mirrorAngle(o):o,h=this.getPointAtAngle(a);n.push(new P(h.x,h.y))}return n}}const Ot=1e-6;function Ee(i,t){if($s(i)){const r=ks(i,t);return r?[r]:[]}const n=Re(i);if(n.numberOfVertices<2)return[];const s=Js(n,t);return s?[s]:[]}function Ts(i){return Re(i)}function ks(i,t){const n=Bs(i);if(n.length===0)return null;const e=[];for(const a of n){const h=Rs(a,t);if(!h)return null;e.push(h)}const s=Ns(i),r=Ls(e,s,i.closed,t);if(r.length<2)return null;const o=new ut;return r.forEach((a,h)=>{o.addVertexAt(h,{x:a.x,y:a.y})}),o.closed=i.closed,o}function Bs(i){const t=[],n=i.numberOfVertices,e=i.closed?n:n-1;for(let s=0;s<e;s++){const r=i.vertices[s],o=i.vertices[(s+1)%n];M.isPositive(Math.abs(r.bulge??0))?t.push({kind:"arc",arc:new O(r,o,r.bulge)}):t.push({kind:"line",start:new P(r.x,r.y),end:new P(o.x,o.y)})}return t}function Ns(i){const t=[];for(let n=0;n<i.numberOfVertices;n++)t.push(i.getPointAt(n));return t}function Rs(i,t){if(i.kind==="line"){const e=js(i.start,i.end,t);return e?{kind:"line",...e}:null}const n=qs(i.arc,i.arc.startPoint,i.arc.endPoint,t);return n?{kind:"arc",arc:n}:null}function qs(i,t,n,e){const s=Vs(i,t,n,e),r=i.radius+s;return M.isNonPositive(r)?null:new O(i.center,r,i.startAngle,i.endAngle,i.clockwise)}function Vs(i,t,n,e){const s=n.x-t.x,r=n.y-t.y,o=Math.hypot(s,r);if(M.isNonPositive(o))return i.clockwise?-e:e;const a=-r/o,h=s/o,c=i.center.x-(t.x+n.x)/2,l=i.center.y-(t.y+n.y)/2;return c*a+l*h>0?-e:e}function js(i,t,n){const e=t.x-i.x,s=t.y-i.y,r=Math.hypot(e,s);if(M.isNonPositive(r))return null;const o=-s/r*n,a=e/r*n;return{start:new P(i.x+o,i.y+a),end:new P(t.x+o,t.y+a),dx:e,dy:s}}function Ls(i,t,n,e){var a;const s=i.length;if(s===0)return[];const r=vs(i,t,n,e),o=[((a=r[0].nextSegmentStart)==null?void 0:a.clone())??r[0].point.clone()];for(let h=0;h<s;h++){const c=i[h],l=h===s-1&&!n?{point:Xs(c)}:r[(h+1)%s];if(h>0&&r[h].filletPoints&&r[h].filletPoints.forEach(u=>o.push(u.clone())),c.kind==="arc"){const u=r[h].nextSegmentStart??r[h].point,d=l.point,g=Os(c.arc,u,d,Math.max(16,32));for(let m=1;m<g.length;m++)o.push(g[m])}else o.push(l.point.clone())}return qe(o)}function vs(i,t,n,e){const s=i.length,r=[];for(let o=0;o<s;o++)o===0?r.push(n?Ie(i[s-1],i[0],t[0],e):{point:Ds(i[0])}):r.push(Ie(i[o-1],i[o],t[o],e));return r}function Os(i,t,n,e){const s=i.nearestPoint(t),r=i.nearestPoint(n),o=wn(i,s),a=wn(i,r),h=Us(i,o,a),c=[];for(let l=0;l<=e;l++){const u=l/e,d=i.clockwise?o-h*u:o+h*u;c.push(i.getPointAtAngle(Fs(i,d)))}return c}function wn(i,t){return Math.atan2(t.y-i.center.y,t.x-i.center.x)}function Fs(i,t){const n=p.normalizeAngle(t);return i.clockwise?Mn(n):n}function Mn(i){return(360-i*180/Math.PI)%360*(Math.PI/180)}function Us(i,t,n){if(i.clockwise){let s=t-n;return M.isNonPositive(s)&&(s+=S),s}let e=n-t;return M.isNonPositive(e)&&(e+=S),e}function Ds(i){return i.kind==="line"?i.start.clone():i.arc.startPoint.clone()}function Xs(i){return i.kind==="line"?i.end.clone():i.arc.endPoint.clone()}function Ie(i,t,n,e){return i.kind==="line"&&t.kind==="line"?{point:zn({start:i.start,end:i.end,dx:i.dx,dy:i.dy},{start:t.start,end:t.end,dx:t.dx,dy:t.dy})}:i.kind==="line"&&t.kind==="arc"?Te(i,t.arc,n,e,!0):i.kind==="arc"&&t.kind==="line"?Te(t,i.arc,n,e,!1):i.kind==="arc"&&t.kind==="arc"?Ys(i.arc,t.arc,n,e):{point:n.clone()}}function Ys(i,t,n,e){const s=Ne(i.endPoint,t.startPoint),o=Ks(i,t).filter(l=>Ft(i,l)&&Ft(t,l));if(o.length>0)return{point:Be(o,s)};const a=i.endPoint.clone(),h=t.startPoint.clone(),c=ke(n,Math.abs(e),a,h);return{point:a,filletPoints:c,nextSegmentStart:h}}function Te(i,t,n,e,s){const r=Ne(s?i.end:i.start,s?t.startPoint:t.endPoint),o=Qs(i,t,r);if(Gs(i,o)&&Ft(t,o))return{point:o};const a=Zs(i,n,e),h=s?t.startPoint.clone():t.endPoint.clone(),c=ke(n,Math.abs(e),s?a:h,s?h:a);return s?{point:a,filletPoints:c,nextSegmentStart:h}:{point:h,filletPoints:c,nextSegmentStart:a}}function Zs(i,t,n){const e=Math.hypot(i.dx,i.dy),s=-i.dy/e*n,r=i.dx/e*n;return new P(t.x+s,t.y+r)}function Gs(i,t){const n=Math.hypot(i.dx,i.dy);if(M.isNonPositive(n))return!1;const e=i.dx/n,s=i.dy/n,r=t.x-i.start.x,o=t.y-i.start.y,a=Math.abs(r*s-o*e);return M.equalToZero(a)}function ke(i,t,n,e){const s=Math.atan2(n.y-i.y,n.x-i.x),r=Math.atan2(e.y-i.y,e.x-i.x),o=Ws(s,r);if(M.equalToZero(Math.abs(o)))return[];const a=[],h=Math.max(2,Math.ceil(Math.abs(o)/Math.PI*16));for(let c=1;c<h;c++){const l=c/h,u=s+o*l;a.push(new P(i.x+t*Math.cos(u),i.y+t*Math.sin(u)))}return a}function Ws(i,t){let n=t-i;for(;n>Math.PI;)n-=S;for(;n<=-Math.PI;)n+=S;return n}function Qs(i,t,n){const e=Math.hypot(i.dx,i.dy);if(M.isNonPositive(e))return n.clone();const s=i.dx/e,r=i.dy/e,o=i.start.x-t.center.x,a=i.start.y-t.center.y,h=2*(o*s+a*r),c=o*o+a*a-t.radius*t.radius,l=h*h-4*c;if(l<0)return n.clone();const u=Math.sqrt(l),d=[(-h-u)/2,(-h+u)/2].map(m=>new P(i.start.x+s*m,i.start.y+r*m)),g=d.filter(m=>Ft(t,m));return Be(g.length>0?g:d,n)}function Ft(i,t){const n=Math.abs(Math.hypot(t.x-i.center.x,t.y-i.center.y)-i.radius);if(M.isPositive(n))return!1;const e=wn(i,t),s=i.clockwise?Mn(p.normalizeAngle(i.startAngle)):p.normalizeAngle(i.startAngle),r=i.clockwise?Mn(p.normalizeAngle(i.endAngle)):p.normalizeAngle(i.endAngle);return p.isBetweenAngle(e,s,r,i.clockwise)}function Ks(i,t){const n=t.center.x-i.center.x,e=t.center.y-i.center.y,s=Math.hypot(n,e);if(M.isNonPositive(s))return[];const r=i.radius+t.radius,o=Math.abs(i.radius-t.radius);if(s>r+Ot)return[];if(s<o-Ot)return[];const a=(i.radius*i.radius-t.radius*t.radius+s*s)/(2*s),h=i.radius*i.radius-a*a;if(h<-Ot)return[];const c=i.center.x+a*n/s,l=i.center.y+a*e/s;if(h<=Ot)return[new P(c,l)];const u=Math.sqrt(h),d=-e*u/s,g=n*u/s;return[new P(c+d,l+g),new P(c-d,l-g)]}function Be(i,t){let n=i[0],e=n.distanceToSquared(t);for(let s=1;s<i.length;s++){const r=i[s].distanceToSquared(t);r<e&&(n=i[s],e=r)}return n.clone()}function Ne(i,t){return new P((i.x+t.x)/2,(i.y+t.y)/2)}function $s(i){const t=i.numberOfVertices,n=i.closed?t:t-1;for(let e=0;e<n;e++){const s=i.vertices[e];if(M.isPositive(Math.abs(s.bulge??0)))return!0}return!1}function Re(i){const t=Hs(i.vertices.map(n=>new P(n.x,n.y)),i.closed);return t.length===i.numberOfVertices?i:new ut(t.map(n=>({x:n.x,y:n.y})),i.closed)}function Hs(i,t){const n=qe(i);if(!t||n.length<2)return n;const e=n[0],s=n[n.length-1];return M.isNonPositive(Math.hypot(e.x-s.x,e.y-s.y))&&n.pop(),n}function qe(i){const t=[];return i.forEach(n=>{const e=t[t.length-1];(!e||M.isPositive(Math.hypot(e.x-n.x,e.y-n.y)))&&t.push(new P(n.x,n.y))}),t}function Js(i,t){const n=[];for(let o=0;o<i.numberOfVertices;o++)n.push(i.getPointAt(o));const e=ti(n,i.closed,t);if(e.length===0)return null;const s=[];if(i.closed){if(e.length<2)return null;const o=e.length;for(let a=0;a<o;a++){const h=e[(a-1+o)%o],c=e[a];s.push(zn(h,c))}}else{s.push(e[0].start);for(let o=1;o<e.length;o++)s.push(zn(e[o-1],e[o]));s.push(e[e.length-1].end)}const r=new ut;return s.forEach((o,a)=>{r.addVertexAt(a,{x:o.x,y:o.y})}),r.closed=i.closed,r}function ti(i,t,n){const e=[],s=t?i.length:i.length-1;for(let r=0;r<s;r++){const o=i[r],a=i[t?(r+1)%i.length:r+1],h=a.x-o.x,c=a.y-o.y,l=Math.hypot(h,c);if(M.isNonPositive(l))continue;const u=-c/l*n,d=h/l*n;e.push({start:new P(o.x+u,o.y+d),end:new P(a.x+u,a.y+d),dx:h,dy:c})}return e}function zn(i,t){const n=i.dx*t.dy-i.dy*t.dx;if(M.equalToZero(n))return new P((i.end.x+t.start.x)/2,(i.end.y+t.start.y)/2);const e=t.start.x-i.start.x,s=t.start.y-i.start.y,r=(e*t.dy-s*t.dx)/n;return new P(i.start.x+r*i.dx,i.start.y+r*i.dy)}class ut extends pt{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 r=null;if(e<n-1?r=this._vertices[e+1]:e==n-1&&this.closed&&(r=this._vertices[0]),r)if(s.bulge){const o=new O(s,r,s.bulge);t+=o.length}else t+=new P(s.x,s.y).distanceTo(r)}return t}get area(){if(!this._closed||this._vertices.length<3)return 0;const t=this.getPoints(128);return _e(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 W().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 ut(this._vertices.map(t=>({...t})),this._closed)}getPoints3d(t,n){const e=[];return this.getPoints(t).forEach(r=>e.push(new w().set(r.x,r.y,n))),e}getPoints(t){const n=[],e=this._vertices.length;for(let s=0;s<e;++s){const r=this._vertices[s];if(r.bulge){let o=null;if(s<e-1?o=this._vertices[s+1]:s==e-1&&this.closed&&(o=this._vertices[0]),o){const h=new O(r,o,r.bulge).getPoints(t),c=h.length;for(let l=0;l<c;++l){const u=h[l];n.push(new P(u.x,u.y))}}}else n.push(new P(r.x,r.y)),s==e-1&&this.closed&&n.push(n[0])}return n}offset(t){return Ee(this,t)}}function ni(i,t,n){const e=Math.hypot(t.x,t.y);if(M.isNonPositive(e))return null;const s=-t.y/e*n,r=t.x/e*n;return new w(i.x+s,i.y+r,i.z)}function ei(i,t,n){if(i.length<2)return null;const e=Ts(new ut(i.map(r=>({x:r.x,y:r.y})),t));return Ee(e,n)[0]??null}function si(i,t,n,e){if(i.length<2||M.equalToZero(n))return null;const{points:s,tangents:r}=je(i,e);if(s.length<2)return null;const o=r??ii(s,t),a=ri(s,o,n),h=t?ai(a):oi(a);if(h.length<2)return null;const c=new ut;return h.forEach((l,u)=>{c.addVertexAt(u,{x:l.x,y:l.y})}),c.closed=t,c}function ii(i,t){const n=i.length,e=new Array(n);for(let s=0;s<n;s++){let r=0,o=0;if(t){const h=i[(s-1+n)%n],c=i[(s+1)%n];r=c.x-h.x,o=c.y-h.y}else s===0?(r=i[1].x-i[0].x,o=i[1].y-i[0].y):s===n-1?(r=i[n-1].x-i[n-2].x,o=i[n-1].y-i[n-2].y):(r=i[s+1].x-i[s-1].x,o=i[s+1].y-i[s-1].y);const a=Math.hypot(r,o);M.isNonPositive(a)?e[s]=new P(1,0):e[s]=new P(r/a,o/a)}return e}function ri(i,t,n){return i.map((e,s)=>{const r=t[s],o=-r.y*n,a=r.x*n;return new P(e.x+o,e.y+a)})}function oi(i){let t=Ut(i);if(t.length<3)return t;for(;;){const n=Ve(t,!1);if(!n||(t=Ut([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<2))break}return t}function ai(i){let t=Ut(i);if(t.length<4)return t;for(;;){const n=Ve(t,!0);if(!n||(t=Ut([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<3))break}return t}function Ve(i,t){const n=t?i.length:i.length-1;if(n<2)return null;for(let e=0;e<n;e++){const s=i[e],r=i[(e+1)%i.length];for(let o=e+1;o<n;o++){if(hi(e,o,n,t))continue;const a=i[o],h=i[(o+1)%i.length],c=ci(s,r,a,h);if(c)return{point:c,segmentA:e,segmentB:o}}}return null}function hi(i,t,n,e){return!!(t===i||t===i+1||e&&i===0&&t===n-1)}function ci(i,t,n,e){const s=t.x-i.x,r=t.y-i.y,o=e.x-n.x,a=e.y-n.y,h=s*a-r*o;if(M.equalToZero(h))return null;const c=n.x-i.x,l=n.y-i.y,u=(c*a-l*o)/h,d=(c*r-l*s)/h,g=Et.equalPointTol;return u<-g||u>1+g||d<-g||d>1+g?null:new P(i.x+u*s,i.y+u*r)}function je(i,t){const n=[],e=[],s=t!=null&&t.length===i.length;return i.forEach((r,o)=>{const a=n[n.length-1];if((!a||M.isPositive(Math.hypot(a.x-r.x,a.y-r.y)))&&(n.push(new P(r.x,r.y)),s)){const h=t[o];e.push(new P(h.x,h.y))}}),{points:n,tangents:s?e:void 0}}function Ut(i){return je(i).points}class bn extends pn{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 W}transform(t){return this._loops.forEach(n=>{n.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){const t=new bn;return this._loops.forEach(n=>{t.add(n.clone())}),t}getPoints(t){const n=[];for(let e=0;e<this.loops.length;++e){const r=this.loops[e].getPoints(t);n.push(r)}return n}buildHierarchy(){var a;const t=this.getPoints(100),n=this.calculateBoundaryBoxes(t),e=this.sortBoundaryBoxesByAreas(n),s=new Map,r=e.length;for(let h=0;h<r;h++)s.set(e[h],{index:e[h],children:[]});const o={index:-1,children:[]};for(let h=0;h<r;h++){const c=e[h],l=t[c],u=n[c];let d=h+1;for(;d<r;d++){const g=e[d],m=t[g];if(n[g].containsBox(u)&&v.isPointInPolygon(l[p.randInt(0,l.length-1)],m)){(a=s.get(g))==null||a.children.push(s.get(c));break}}d===r&&o.children.push(s.get(c))}return o}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),r=_n(s);n===0?t+=Math.abs(r):t-=Math.abs(r)}return t}calculateBoundaryBoxes(t){const n=[];return t.forEach(e=>{n.push(new W().setFromPoints(e))}),n}sortBoundaryBoxesByAreas(t){const n=[];t.forEach((s,r)=>{const o=s.size,a=o.width*o.height;n.push({area:a,index:r})}),n.sort((s,r)=>s.area-r.area);const e=[];return n.forEach(s=>{e.push(s.index)}),e}}class li extends Ce{translate(t){return this.transform(new et().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 Bt extends li{}class J extends Bt{static computeCenterPoint(t,n,e){var s;return((s=Pe(t,e,n))==null?void 0:s.center)??null}static tryCreateByThreePoints(t,n,e){const s=Pe(t,e,n);if(!s)return null;const{center:r,radius:o}=s,a=new x(t.x-r.x,t.y-r.y,(t.z??0)-r.z),h=new x(e.x-r.x,e.y-r.y,(e.z??0)-r.z),c=new x(n.x-r.x,n.y-r.y,(n.z??0)-r.z);if(a.lengthSq()===0||c.lengthSq()===0)return null;const l=new x().crossVectors(a,c);if(l.lengthSq()===0&&(l.crossVectors(a,h),l.lengthSq()===0))return null;l.normalize();const u=a.clone().normalize(),d=new x().crossVectors(l,u),g=f=>p.normalizeAngle(Math.atan2(f.dot(d),f.dot(u)));p.isAngleOnCcwSweep(0,g(h),g(c))||(l.negate(),d.negate());let m=g(c);return M.equalToZero(m)&&(m=S),new J(r,o,0,m,l,u)}static createByThreePoints(t,n,e){return J.tryCreateByThreePoints(t,n,e)}constructor(t,n,e,s,r,o=x.X_AXIS){super(),this.center=t,this.radius=n,this.startAngle=e,this.endAngle=s,this.normal=r,this.refVec=o,(s-e)%S==0?(this.startAngle=0,this.endAngle=S):(this.startAngle=e,this.endAngle=s)}get center(){return this._center}set center(t){this._center=new w(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw q.AcCmErrors.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=p.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==S?t:p.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return p.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 x(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new x(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=S);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 x(t.x,t.y,t.z||0),e=this.center,s=this.normal,o=n.clone().sub(e).dot(s),h=n.clone().sub(s.clone().multiplyScalar(o)).clone().sub(e);if(h.lengthSq()===0)return this.startPoint.clone();h.normalize().multiplyScalar(this.radius);const c=e.clone().add(h),l=this.getAngle(c.clone()),u=this.startAngle,d=this.deltaAngle;let g=p.normalizeAngle(l-u);g<0&&(g=0),g>d&&(g=d);const m=this.getPointAtAngle(u+g),f=m.distanceTo(n),y=this.startPoint.distanceTo(n),_=this.endPoint.distanceTo(n);return y<f&&y<=_?this.startPoint.clone():_<f&&_<y?this.endPoint.clone():m}tangentPoints(t){const n=[],e=new x(t.x,t.y,t.z||0),s=this.center,r=this.normal,o=this.radius,h=e.clone().sub(s).dot(r),c=e.clone().sub(r.clone().multiplyScalar(h)),l=s.clone(),d=c.clone().sub(l).length();if(d<o)return n;const g=Math.acos(o/d),m=this.getAngle(c.clone()),f=[m+g,m-g];for(const y of f){const _=p.normalizeAngle(y-this.startAngle);_>=0&&_<=this.deltaAngle&&n.push(this.getPointAtAngle(this.startAngle+_))}return n}perpendicularPoints(t){const n=[],e=new x(t.x,t.y,t.z||0),s=this.center,r=this.normal,o=this.radius,h=e.clone().sub(s).dot(r),l=e.clone().sub(r.clone().multiplyScalar(h)).clone().sub(s);if(l.lengthSq()<1e-24)return n;l.normalize();const u=[s.clone().add(l.clone().multiplyScalar(o)),s.clone().sub(l.clone().multiplyScalar(o))];for(const d of u){const g=this.getAngle(d.clone()),m=p.normalizeAngle(g-this.startAngle);m>=0&&m<=this.deltaAngle&&n.push(new w(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 w(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 h=0;h<2*Math.PI;h+=Math.PI/2)p.isBetweenAngle(h,this.startAngle,this.endAngle)&&t.push(h);let n=1/0,e=1/0,s=1/0,r=-1/0,o=-1/0,a=-1/0;for(const h of t){const c=this.getPointAtAngle(h);c.x<n&&(n=c.x),c.y<e&&(e=c.y),c.z<s&&(s=c.z),c.x>r&&(r=c.x),c.y>o&&(o=c.y),c.z>a&&(a=c.z)}return new G({x:n,y:e,z:s},{x:r,y:o,z:a})}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=S,s=0);for(let r=0;r<=t;r++){const o=s+e*(r/t),a=this.getPointAtAngle(o);n.push(a)}return n}transform(t){const n=this.center.clone().applyMatrix4(t),e=this.startPoint.clone().applyMatrix4(t),s=this.endPoint.clone().applyMatrix4(t),r=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(t),o=new x(e).sub(n).normalize(),a=n.distanceTo(e);let h=new x().crossVectors(new x(e).sub(n),new x(r).sub(n)).normalize();h.lengthSq()===0&&(h=this.normal.clone().transformDirection(t));const c=l=>{const u=new x(l).sub(n);return Math.atan2(u.dot(Le.crossVectors(h,o)),u.dot(o))};return this.center=n,this.radius=a,this.normal=h,this.refVec=o,this.startAngle=0,this.endAngle=this.closed?S: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 J(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(Le.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},r=this.center,o=this.radius;return new w(r.x+o*(e.x*Math.cos(t)+s.x*Math.sin(t)),r.y+o*(e.y*Math.cos(t)+s.y*Math.sin(t)),r.z+o*(e.z*Math.cos(t)+s.z*Math.sin(t)))}get plane(){const t=new x(this.center).distanceTo(cn);return new Pt(this.normal,t)}offset(t){const n=this.radius+t;return n<=0?null:new J(this.center,n,this.startAngle,this.endAngle,this.normal,this.refVec)}}const Le=new x;class mt extends pt{constructor(t,n,e,s=0,r=S,o=!1,a=0){super(),this.center=t,this.majorAxisRadius=n,this.minorAxisRadius=e,(r-s)%S==0?(this.startAngle=0,this.endAngle=S):(this.startAngle=s,this.endAngle=r),this.clockwise=o,this.rotation=a}get center(){return this._center}set center(t){this._center=new w(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw q.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw q.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=p.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==S?t:p.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 p.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,r=-1/0;for(let o=0;o<=100;o++){const a=this.getPoint(o/100);n=Math.min(n,a.x),e=Math.min(e,a.y),s=Math.max(s,a.x),r=Math.max(r,a.y)}return new W({x:n,y:e},{x:s,y:r})}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 r=this.startAngle+t*e;let o=this.center.x+this.majorAxisRadius*Math.cos(r),a=this.center.y+this.minorAxisRadius*Math.sin(r);if(this.rotation!==0){const h=Math.cos(this.rotation),c=Math.sin(this.rotation),l=o-this.center.x,u=a-this.center.y;o=l*h-u*c+this.center.x,a=l*c+u*h+this.center.y}return new P(o,a)}transform(t){const n=t,e=new P(this.center).applyMatrix2d(n),s=new w(e.x,e.y,this.center.z),r=this.getPointAtAngle(0).clone().applyMatrix2d(n),o=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(n),a=new P(r).sub(e),h=new P(o).sub(e),c=a.length(),l=h.length(),u=Math.atan2(a.y,a.x),d=a.clone().normalize(),g=h.clone().normalize(),m=_=>{const C=new P(_).sub(e),b=C.dot(d),k=C.dot(g);return p.normalizeAngle(Math.atan2(k/l,b/c))},f=n.determinant()<0?!this.clockwise:this.clockwise,y=this.closed?new mt(s,c,l,0,S,f,u):new mt(s,c,l,m(this.startPoint.clone().applyMatrix2d(n)),m(this.endPoint.clone().applyMatrix2d(n)),f,u);return this.center=y.center,this.majorAxisRadius=y.majorAxisRadius,this.minorAxisRadius=y.minorAxisRadius,this._startAngle=y._startAngle,this._endAngle=y._endAngle,this._clockwise=y._clockwise,this.rotation=y.rotation,this._boundingBoxNeedsUpdate=!0,this}getPointAtAngle(t){return this.getPoint(this.closed?t/S:p.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 mt(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),r=Math.sin(this.rotation),o=this.majorAxisRadius>=this.minorAxisRadius,a=o?s:-r,h=o?r:s;return[new P(this.center.x-e*a,this.center.y-e*h),new P(this.center.x+e*a,this.center.y+e*h)]}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 r=72;for(let o=1;o<=r;o++){const a=this.getPoint(o/r),h=n.distanceToSquared(a);h<s&&(s=h,e=a)}return e}tangentPoints(t){const n=this._projectPointToLocal(t);return this._findSnapAngles(n,(s,r,o,a)=>{const h=-this.majorAxisRadius*a,c=this.minorAxisRadius*o;return(s-n.x)*c-(r-n.y)*h}).map(s=>this.getPointAtAngle(s))}perpendicularPoints(t){const n=this._projectPointToLocal(t);return this._findSnapAngles(n,(s,r,o,a)=>{const h=this.minorAxisRadius*o,c=this.majorAxisRadius*a;return(s-n.x)*c-(r-n.y)*h}).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),r=Math.sin(-this.rotation);return{x:n*s-e*r,y:n*r+e*s}}_findSnapAngles(t,n,e=144){const s=this.majorAxisRadius,r=this.minorAxisRadius,o=this.startAngle,a=this.deltaAngle,h=[],c=d=>{const g=Math.cos(d),m=Math.sin(d);return n(s*g,r*m,g,m)};let l=o,u=c(l);for(let d=1;d<=e;d++){const g=o+a*d/e,m=c(g);if(Math.abs(u)<1e-10&&h.push(l),u*m<0){let f=l,y=g;for(let _=0;_<32;_++){const C=(f+y)/2;c(f)*c(C)<=0?y=C:f=C}h.push((f+y)/2)}l=g,u=m}return h}}class $ extends Bt{constructor(t,n,e,s,r,o=0,a=S){super(),this.center=t,this.normal=n,this.majorAxis=e,this.majorAxisRadius=s,this.minorAxisRadius=r;const h=Math.abs(a-o);Math.abs(h-S)<1e-10||Math.abs(h-2*S)<1e-10?(this.startAngle=0,this.endAngle=S):(this.startAngle=o,this.endAngle=a)}get center(){return this._center}set center(t){this._center=new w(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw q.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw q.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=p.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==S?t:p.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-S)<1e-10?S:p.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 x(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new x(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new x().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-S)<1e-10)&&(t=0,n=S);const e=t+n/2;return this.getPointAtAngle(e)}get isCircular(){return M.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 r=1;r<=t;r++){const o=this.startAngle+r*n,a=this.getPointAtAngle(o),h=a.x-s.x,c=a.y-s.y,l=a.z-s.z;e+=Math.sqrt(h*h+c*c+l*l),s=a}return e}get area(){return Math.abs(this.deltaAngle-S)>=1e-10?0:Math.PI*this.majorAxisRadius*this.minorAxisRadius}calculateBoundingBox(){if(this.majorAxis.equals(x.X_AXIS)||this.majorAxis.equals(x.Y_AXIS)||this.majorAxis.isParallelTo(x.X_AXIS)||this.majorAxis.isParallelTo(x.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let h=0;h<2*Math.PI;h+=Math.PI/2)p.isBetweenAngle(h,this.startAngle,this.endAngle)&&t.push(h);let n=1/0,e=1/0,s=1/0,r=-1/0,o=-1/0,a=-1/0;for(const h of t){const c=this.getPointAtAngle(h);c.x<n&&(n=c.x),c.y<e&&(e=c.y),c.z<s&&(s=c.z),c.x>r&&(r=c.x),c.y>o&&(o=c.y),c.z>a&&(a=c.z)}return new G({x:n,y:e,z:s},{x:r,y:o,z:a})}else{let n=1/0,e=1/0,s=1/0,r=-1/0,o=-1/0,a=-1/0;for(let h=0;h<=100;h++){const c=this.startAngle+this.deltaAngle*(h/100),l=this.getPointAtAngle(c);n=Math.min(n,l.x),e=Math.min(e,l.y),s=Math.min(s,l.z),r=Math.max(r,l.x),o=Math.max(o,l.y),a=Math.max(a,l.z)}return new G({x:n,y:e,z:s},{x:r,y:o,z:a})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const n=[];let e=this.deltaAngle,s=this.startAngle;this.closed&&(e=S,s=0);for(let r=0;r<=t;r++){const o=s+e*(r/t),a=this.getPointAtAngle(o);n.push(a)}return n}getPointAtAngle(t){const n=Math.cos(t),e=Math.sin(t),s=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(e),r=this.majorAxis.clone().multiplyScalar(n*this.majorAxisRadius).add(s);return new w(this.center.x+r.x,this.center.y+r.y,this.center.z+r.z)}nearestPoint(t,n=72){const e=new w(t.x,t.y,t.z||0);let s=this.getPointAtAngle(this.startAngle),r=e.distanceToSquared(s);for(let h=1;h<=n;h++){const c=this.startAngle+this.deltaAngle*h/n,l=this.getPointAtAngle(c),u=e.distanceToSquared(l);u<r&&(r=u,s=l)}const o=e.distanceToSquared(this.startPoint),a=e.distanceToSquared(this.endPoint);return o<r&&o<=a?this.startPoint.clone():a<r&&a<o?this.endPoint.clone():s.clone()}tangentPoints(t){const n=this._projectPointToLocalPlane(t);return this._findSnapParameterAngles((s,r,o,a)=>{const h=-this.majorAxisRadius*a,c=this.minorAxisRadius*o;return(s-n.x)*c-(r-n.y)*h}).map(s=>this.getPointAtAngle(s))}perpendicularPoints(t){const n=this._projectPointToLocalPlane(t);return this._findSnapParameterAngles((s,r,o,a)=>{const h=this.minorAxisRadius*o,c=this.majorAxisRadius*a;return(s-n.x)*c-(r-n.y)*h}).map(s=>this.getPointAtAngle(s))}_projectPointToLocalPlane(t){const n=new w(t.x,t.y,t.z||0),e=new x(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,r=this.startAngle,o=this.deltaAngle,a=[],h=u=>{const d=Math.cos(u),g=Math.sin(u);return t(e*d,s*g,d,g)};let c=r,l=h(c);for(let u=1;u<=n;u++){const d=r+o*u/n,g=h(d);if(Math.abs(l)<1e-10&&a.push(c),l*g<0){let m=c,f=d;for(let y=0;y<32;y++){const _=(m+f)/2;h(m)*h(_)<=0?f=_:m=_}a.push((m+f)/2)}c=d,l=g}return a}contains(t){const n=new x(t).sub(this.center),e=n.dot(this.majorAxis),s=n.dot(this.minorAxis),r=e/this.majorAxisRadius,o=s/this.minorAxisRadius;return r*r+o*o<=1}transform(t){const n=t,e=this.center.clone().applyMatrix4(n),s=this.getPointAtAngle(0).clone().applyMatrix4(n),r=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(n),o=new x(s).sub(e),a=new x(r).sub(e),h=o.length(),c=a.length(),l=o.clone().normalize(),u=new x().crossVectors(o,a).normalize();let d=new x().crossVectors(u,l).normalize();d.dot(a)<0&&(u.negate(),d=new x().crossVectors(u,l).normalize());const g=f=>{const y=new x(f).sub(e),_=y.dot(l),C=y.dot(d);return p.normalizeAngle(Math.atan2(C/c,_/h))},m=this.closed?new $(e,u,l,h,c,0,S):new $(e,u,l,h,c,g(this.startPoint.clone().applyMatrix4(n)),g(this.endPoint.clone().applyMatrix4(n)));return this.center=m.center,this.normal=m.normal,this.majorAxis=m.majorAxis,this.majorAxisRadius=m.majorAxisRadius,this.minorAxisRadius=m.minorAxisRadius,this._startAngle=m._startAngle,this._endAngle=m._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 $(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new x(this.center).distanceTo(cn);return new Pt(this.normal,t)}offset(t){const n=this.majorAxisRadius+t,e=this.minorAxisRadius+t;return n<=0||e<=0?null:new $(this.center,this.normal,this.majorAxis,n,e,this.startAngle,this.endAngle)}}class Nt extends pt{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 W(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 Nt(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 r=((t.x-this._start.x)*n+(t.y-this._start.y)*e)/s;return r=Math.max(0,Math.min(1,r)),new P(this._start.x+r*n,this._start.y+r*e)}nearestPoint(t){return this.project(t)}}class Dt extends Bt{constructor(t,n){super(),this._start=new w(t),this._end=new w(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 x().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new w((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(ft).normalize();return new w(this._start).addScaledVector(e,t)}else{const e=this.delta(ft).normalize();return new w(this._end).addScaledVector(e,t)}}extend(t,n=!1){if(n){const e=ft.subVectors(this._start,this._end).normalize();this._start=new w(this._start).addScaledVector(e,t)}else{const e=this.delta(ft).normalize();this._end=new w(this._end).addScaledVector(e,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,n){ve.subVectors(t,this._start),Xt.subVectors(this.endPoint,this.startPoint);const e=Xt.dot(Xt);let r=Xt.dot(ve)/e;return n&&(r=p.clamp(r,0,1)),r}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=ft.subVectors(t,this.startPoint).dot(n);return new w().copy(n).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const n=this.direction,e=this.startPoint,r=ft.subVectors(t,e).dot(n),o=ft.copy(n).multiplyScalar(r);return new w().addVectors(e,o)}calculateBoundingBox(){const t=new w(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 w(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 G(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 Dt(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 r=new x(e.x-n.x,e.y-n.y,0).normalize(),o=new x(-r.y,r.x,0);return new Dt(new w(n.x+o.x*t,n.y+o.y*t,n.z),new w(e.x+o.x*t,e.y+o.y*t,e.z))}}const ft=new x,ve=new x,Xt=new x;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,r){this.init(n,e,r*(e-t),r*(s-n))}initNonuniformCatmullRom(t,n,e,s,r,o,a){let h=(n-t)/r-(e-t)/(r+o)+(e-n)/o,c=(e-n)/o-(s-n)/(o+a)+(s-e)/a;h*=o,c*=o,this.init(n,e,h,c)}calc(t){const n=t*t,e=n*t;return this.c0+this.c1*t+this.c2*n+this.c3*e}}class Yt extends Bt{constructor(t=[],n=!1,e="centripetal",s=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new x,this._px=new Sn,this._py=new Sn,this._pz=new Sn,this._points=t.map(r=>new w(r)),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 w}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new w}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 w){const e=n,s=this._points,r=s.length;if(r===0)return e.set(0,0,0);if(r===1)return e.copy(s[0]);const o=(r-(this._closed?0:1))*t;let a=Math.floor(o),h=o-a;this._closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:h===0&&a===r-1&&(a=r-2,h=1);let c,l;this._closed||a>0?c=s[(a-1)%r]:(this._tmp.subVectors(s[0],s[1]).add(s[0]),c=new w(this._tmp.x,this._tmp.y,this._tmp.z));const u=s[a%r],d=s[(a+1)%r];if(this._closed||a+2<r?l=s[(a+2)%r]:(this._tmp.subVectors(s[r-1],s[r-2]).add(s[r-1]),l=new w(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const g=this._curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(u),g),f=Math.pow(u.distanceToSquared(d),g),y=Math.pow(d.distanceToSquared(l),g);f<1e-4&&(f=1),m<1e-4&&(m=f),y<1e-4&&(y=f),this._px.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,m,f,y),this._py.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,m,f,y),this._pz.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,m,f,y)}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(h),this._py.calc(h),this._pz.calc(h)),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 w(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 Yt(this._points.map(t=>t.clone()),this._closed,this._curveType,this._tension)}transform(t){return this._points=this._points.map(n=>{const e=new w;return e.copy(n),e.applyMatrix4(t),e}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new G;const t=new G;return this._points.forEach(n=>{t.expandByPoint(n)}),t}}function Oe(i,t){const n=i.x-t[0],e=i.y-t[1],s=(i.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(r=>({x:r.x,y:r.y,z:r.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 le(t,this._degree,this._knots,n,this._weights)}signedPlanarCurvatureAt(t){const n=this.evaluate(t);return ue(n.deriv1,n.deriv2)}getOffsetSamplePath2d(t,n=512){const e=Math.abs(t),{start:s,end:r}=this.getParameterRange(),o=this.length(),a=Math.max(64,Math.ceil(o/Math.max(e*.2,1e-6)));let h=ui(s,r,Math.min(a,n));for(let u=0;u<8&&h.length<n;u++){const d=[];for(let g=0;g<h.length-1;g++){const m=h[g],f=h[g+1],y=(m+f)/2,_=Math.max(Math.abs(this.signedPlanarCurvatureAt(m)),Math.abs(this.signedPlanarCurvatureAt(f)),Math.abs(this.signedPlanarCurvatureAt(y)));e*_>.85&&d.push(y)}if(d.length===0)break;if(h=di(h,d),h.length>n){h=h.slice(0,n);break}}const c=[],l=[];return h.forEach(u=>{const d=this.evaluate(u);c.push(new P(d.point[0],d.point[1]));const g=d.deriv1[0],m=d.deriv1[1],f=Math.hypot(g,m);l.push(f>1e-10?new P(g/f,m/f):new P(1,0))}),{points:c,tangents:l}}length(){const t=this._controlPoints.map(n=>[n.x,n.y,n.z]);return de(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,r){const o=mn(t,n,e,s,r),a=o.controlPoints.map(h=>({x:h[0],y:h[1],z:h[2]}));return new V(n,o.knots,a,o.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 r=0;r<=t;r++){const o=e+(s-e)*(r/t);n.push(this.point(o))}return n}isClosed(t=1e-6){const{start:n,end:e}=this.getParameterRange(),s=this.point(n),r=this.point(e),o=s[0]-r[0],a=s[1]-r[1],h=s[2]-r[2];return Math.sqrt(o*o+a*a+h*h)<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 Yt(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 r=this.point(e),o=Oe(t,r);for(let a=0;a<=n;a++){const h=e+(s-e)*a/n,c=this.point(h),l=Oe(t,c);l<o&&(o=l,r=c)}return{x:r[0],y:r[1],z:r[2]??0}}static createClosedCurve(t,n,e="Chord"){const r=this.createFitPointsForClosedCurve(t).map(o=>[o.x,o.y,o.z]);return V.byPoints(r,n,e)}}function ui(i,t,n){if(n<2)return[i,t];const e=[];for(let s=0;s<n;s++)e.push(s===n-1?t:i+(t-i)*s/(n-1));return e}function di(i,t){const n=[...i,...t].sort((s,r)=>s-r),e=[];return n.forEach(s=>{const r=e[e.length-1];(r===void 0||Math.abs(r-s)>1e-10)&&e.push(s)}),e}function Fe(i){if(!i)return!1;const t=i.x??0,n=i.y??0,e=i.z??0;return t*t+n*n+e*e>1e-20}function gi(i,t,n){let e=i??0;return e<1&&n>0&&t>0&&(e=n-t-1),e<1&&(e=3),e=Math.min(e,t-1),Math.max(1,e)}function mi(i,t,n){let e=i??0;e<1&&(e=3);const s=t+n-1;return e=Math.min(e,s),Math.max(1,e)}function fi(i,t){if(!(!i||i.length!==t))return i}class Y extends Bt{constructor(t,n,e,s,r,o){super();const a=arguments.length;if(this._degree=3,this._closed=!1,Array.isArray(n)){if(a<2||a>5)throw q.AcCmErrors.ILLEGAL_PARAMETERS;this._controlPoints=t;let h,c=3,l=!1;if(a>=3&&(Array.isArray(e)?(h=e,a>=4&&(c=s||3),a>=5&&(l=r)):e!==void 0&&(c=e||3,a>=4&&(l=s))),e===void 0&&a>=4&&(c=s||3,a>=5&&(l=r)),this._degree=c,this._closed=l,this._controlPoints.length<this._degree+1)throw q.AcCmErrors.ILLEGAL_PARAMETERS;this._nurbsCurve=V.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,h)}else{if(a<2||a>6)throw q.AcCmErrors.ILLEGAL_PARAMETERS;this._fitPoints=t,this._knotParameterization=n,a>=3&&(this._degree=e||3);const h=typeof s=="boolean";a>=4&&h&&(this._closed=s),h?(a>=5&&(this._startTangent=r),a>=6&&(this._endTangent=o)):(a>=4&&(this._startTangent=s),a>=5&&(this._endTangent=r)),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 q.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(v.point2dToPoint3d)}get fitPoints(){var t;return(t=this._fitPoints)==null?void 0:t.map(v.point2dToPoint3d)}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 w(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 w(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 w(e.x,e.y,e.z||0)}evaluateAt(t){const n=this._nurbsCurve.point(t);return new w(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 v.point2dToPoint3d(s)}getControlPointAt(t){const n=this._controlPoints.length,e=t<0||t>=n?n-1:t;return this._controlPoints[e]}get isFitPointSpline(){return!!(this._fitPoints&&this._fitPoints.length>0&&this._knotParameterization)}get isControlPointSpline(){return!this.isFitPointSpline}getGripPoints(){return this.isFitPointSpline?this._fitPoints.map(t=>new w(t.x,t.y,t.z??0)):this._controlPoints.map(t=>new w(t.x,t.y,t.z??0))}moveGripPointsAt(t,n){return this.isFitPointSpline?(this.moveFitPointsAt(t,n),this):(this.moveControlPointsAt(t,n),this)}moveFitPointsAt(t,n){if(this._fitPoints){for(const e of t){if(!Number.isInteger(e)||e<0)continue;const s=this._fitPoints[e];s&&v.applyOffsetToPoint3d(s,n)}this._boundingBoxNeedsUpdate=!0,this.buildCurve()}}moveControlPointsAt(t,n){for(const e of t){if(!Number.isInteger(e)||e<0)continue;const s=this.getControlPointAt(e);s&&v.applyOffsetToPoint3d(s,n)}this.rebuildAfterControlPointMutation()}rebuildAfterControlPointMutation(){const t=this._nurbsCurve.knots(),n=this._nurbsCurve.weights();this.isFitPointSpline&&(this._fitPoints=void 0,this._knotParameterization=void 0,this._startTangent=void 0,this._endTangent=void 0),this._nurbsCurve=V.byKnotsControlPointsWeights(this._degree,t,this._controlPoints,n.length>0?n:void 0),this._boundingBoxNeedsUpdate=!0}getOffsetSamplePath2d(t){return this._nurbsCurve.getOffsetSamplePath2d(t)}getPoints(t=100){const n=this._nurbsCurve,e=[],s=n.knots(),r=this._nurbsCurve.degree(),o=s[r],a=s[s.length-r-1],h=(a-o)/(t-1);for(let c=0;c<t;c++){const l=c===t-1?a:o+c*h,u=n.point(l);e.push(new w(u[0],u[1],u[2]))}return e}getCurvePoints(t,n){const e=[],s=t.knots(),r=t.degree(),o=s[r],h=(s[s.length-r-1]-o)/(n-1);for(let c=0;c<n;c++){const l=o+c*h;e.push(t.point(l))}return e}calculateBoundingBox(){const t=this.getPoints(100);return new G().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 Ae(t)}transform(t){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(n=>new w(n).applyMatrix4(t)),this._startTangent&&(this._startTangent=new w(this._startTangent).transformDirection(t)),this._endTangent&&(this._endTangent=new w(this._endTangent).transformDirection(t)),this.buildCurve();else{const n=this._nurbsCurve.knots(),e=this._nurbsCurve.weights();this._controlPoints=this._controlPoints.map(s=>new w(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 Y(this._fitPoints.map(v.point2dToPoint3d),this._knotParameterization,this._degree,this._closed,this._startTangent?v.point2dToPoint3d(this._startTangent):void 0,this._endTangent?v.point2dToPoint3d(this._endTangent):void 0):new Y(this._controlPoints.map(v.point2dToPoint3d),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 Y(t,n,e,!0)}static fromControlPoints(t,n,e,s,r){if(t.length<2||n.length<2)return null;const o=gi(s,t.length,n.length);if(t.length<o+1)return null;try{return new Y(t,n,fi(e,t.length),o,r)}catch{return null}}static fromFitPoints(t,n,e,s,r,o){if(t.length<2)return null;const a=Fe(r),h=Fe(o),c=(a?1:0)+(h?1:0),l=mi(e,t.length,c);if(t.length+c<l+1)return null;try{return a||h?new Y(t,n,l,s,a?r:void 0,h?o:void 0):new Y(t,n,l,s)}catch{return null}}static fromDwgSplineEdge(t){if(t.numberOfControlPoints>0&&t.numberOfKnots>0){const n=t.controlPoints.map(v.point2dToPoint3d);let e=!0;const s=t.controlPoints.map(r=>(r.weight==null&&(e=!1),r.weight||1));return Y.fromControlPoints(n,t.knots,e?s:void 0,t.degree,!1)}if(t.numberOfFitData>0){const n=t.fitDatum.map(v.point2dToPoint3d);return Y.fromFitPoints(n,"Uniform",t.degree,!1,t.startTangent?v.point2dToPoint3d(t.startTangent):void 0,t.endTangent?v.point2dToPoint3d(t.endTangent):void 0)}return null}}class Z extends pt{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=[],r=n*n,o=(a,h)=>{const c=a.x-h.x,l=a.y-h.y;return c*c+l*l<=r};for(;e.length>0;){const a=[],h=e.shift();a.push(h);const c=Z.getEdgeStartPoint(h);let l=Z.getEdgeEndPoint(h);if(!o(c,l))for(;e.length>0;){const u=Z.findConnectingEdge(e,l,r);if(u.index<0)break;let d=e.splice(u.index,1)[0];if(u.reverse&&(d=Z.reverseEdge(d)),a.push(d),l=Z.getEdgeEndPoint(d),o(l,c))break}s.push(new Z(a))}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 W;return n.setFromPoints(t),n}transform(t){const n=new et().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 Y?e.transform(n):e.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new Z(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,r=!1,o=Number.POSITIVE_INFINITY;for(let a=0;a<t.length;a++){const h=t[a],c=Z.getEdgeStartPoint(h),l=Z.getEdgeEndPoint(h),u=n.x-c.x,d=n.y-c.y,g=u*u+d*d;g<o&&(o=g,s=a,r=!1);const m=n.x-l.x,f=n.y-l.y,y=m*m+f*f;y<o&&(o=y,s=a,r=!0)}return o>e?{index:-1,reverse:!1}:{index:s,reverse:r}}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 Nt?new Nt(t.endPoint,t.startPoint):t instanceof O?Z.reverseCircArcEdge(t):t instanceof mt?new mt(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof Y?Z.reverseSplineEdge(t):t}static reverseCircArcEdge(t){const n=t.startPoint,e=t.endPoint,s=!t.clockwise,r=Math.atan2(e.y-t.center.y,e.x-t.center.x),o=Math.atan2(n.y-t.center.y,n.x-t.center.x),a=h=>{const c=p.normalizeAngle(h);return s?p.normalizeAngle(-c):c};return new O(t.center,t.radius,a(r),a(o),s)}static reverseSplineEdge(t){const n=[...t.controlPoints].reverse(),e=t.knots,s=e[0],r=e[e.length-1],o=e.map(c=>s+r-c).reverse(),a=t.weights,h=a.length>0?[...a].reverse():void 0;return new Y(n,o,h,t.degree,t.closed)}}const Rt=128,Zt=96,z=Et.equalPointTol,Cn=z*8;function yi(i,t,n=!1,e=!1,s){const r=De(i,n,s),o=De(t,e,s),a=[];for(const h of r)for(const c of o)In(h,c)&&qn(a,We(h,c));return Ri(a)}function xi(i,t){const n=Ue(i);switch(n.kind){case"line":return n.line.transform(t),n;case"circArc":return n.arc.transform(t),n;case"ellipseArc":return n.arc.transform(t),n;case"spline":return n.spline.transform(t),n}}function Ue(i){switch(i.kind){case"line":return{kind:"line",line:i.line.clone(),extent:i.extent,extendable:i.extendable};case"circArc":return{kind:"circArc",arc:i.arc.clone(),extendable:i.extendable};case"ellipseArc":return{kind:"ellipseArc",arc:i.arc.clone(),extendable:i.extendable};case"spline":return{kind:"spline",spline:i.spline.clone(),extendable:i.extendable}}}function De(i,t,n){const e=[];for(const s of i){const r=t&&s.extendable!==!1;switch(s.kind){case"line":{const o=pi(s.line,n);if(!o)break;const a=r?"unbounded":s.extent;e.push(wt(o.start,o.end,a));break}case"circArc":{const o=Ai(s.arc,r);if(n&&!qt(o.normal,n.normal)){const a=Mi(o,n);(a==null?void 0:a.kind)==="circArc"?e.push(Xe(a.arc,tt(a.arc))):(a==null?void 0:a.kind)==="ellipseArc"?e.push(Ye(a.arc,rt(a.arc))):En(e,Ze(o,tt(o)),tt(o),n)}else{const a=wi(o,n);a&&e.push(Xe(a,tt(a)))}break}case"ellipseArc":{const o=Pi(s.arc,r);if(n&&!qt(o.normal,n.normal))En(e,Ge(o,rt(o)),rt(o),n);else{const a=zi(o,n);a&&e.push(Ye(a,rt(a)))}break}case"spline":{n?En(e,s.spline.getPoints(Rt),s.spline.closed,n):e.push(_i(s.spline));break}}}return e}function wt(i,t,n){const e=new x().subVectors(t,i);return{kind:"line",start:i,dir:e,extent:n,box:n==="bounded"?new G().setFromPoints([i,t]):void 0}}function Xe(i,t){return{kind:"circArc",arc:i,full:t||tt(i),box:i.box}}function Ye(i,t){return{kind:"ellipseArc",arc:i,full:t||rt(i),box:i.box}}function _i(i){const t=[],n=i.getPoints(Rt);if(n.length>=2){const s=i.closed?n.length:n.length-1;for(let r=0;r<s;r++){const o=n[r],a=n[(r+1)%n.length];o.distanceToSquared(a)<z*z||t.push(wt(o.clone(),a.clone(),"bounded"))}}const e=new G;for(const s of t)s.box&&e.union(s.box);return{kind:"spline",spline:i,samples:t,box:t.length>0?e:void 0}}function Ai(i,t){return!t||tt(i)?i:new J(i.center,i.radius,0,S,i.normal,i.refVec)}function Pi(i,t){return!t||rt(i)?i:new $(i.center,i.normal,i.majorAxis,i.majorAxisRadius,i.minorAxisRadius,0,S)}function pi(i,t){if(!t)return{start:i.startPoint.clone(),end:i.endPoint.clone()};const n=it(i.startPoint,t),e=it(i.endPoint,t);return n.distanceToSquared(e)<z*z?null:{start:n,end:e}}function wi(i,t){if(!t)return i;const n=it(i.center,t);return new J(n,i.radius,i.startAngle,i.endAngle,t.normal.clone(),Bn(i.refVec,t.normal))}function Mi(i,t){const n=it(i.center,t),e=i.normal.clone();if(e.lengthSq()<z*z)return null;e.normalize();const s=t.normal.clone();if(s.lengthSq()<z*z)return null;s.normalize();const r=e.dot(s),o=Math.abs(r);if(o>1-1e-8)return{kind:"circArc",arc:new J(n,i.radius,i.startAngle,i.endAngle,s,Bn(i.refVec,s))};if(o<1e-8)return null;const a=new x().crossVectors(e,s);if(a.lengthSq()<z*z)return null;a.normalize();const h=new $(n,s,a,i.radius,i.radius*o,0,S);if(tt(i))return{kind:"ellipseArc",arc:h};const c=it(i.startPoint,t),l=it(i.endPoint,t),u=it(i.midPoint,t),d=bt(h,c),g=bt(h,l),m=bt(h,u),f=p.normalizeAngle(m-d),y=p.normalizeAngle(g-d),_=f<=y||y<1e-8?d+y:d+y+S;return{kind:"ellipseArc",arc:new $(n,s,a,i.radius,i.radius*o,d,_)}}function zi(i,t){if(!t)return i;const n=it(i.center,t),e=Bn(i.majorAxis,t.normal);return e.lengthSq()<z*z?null:new $(n,t.normal.clone(),e,i.majorAxisRadius,i.minorAxisRadius,i.startAngle,i.endAngle)}function En(i,t,n,e){if(t.length<2)return;const s=e?t.map(o=>it(o,e)):t,r=n?s.length:s.length-1;for(let o=0;o<r;o++){const a=s[o],h=s[(o+1)%s.length];a.distanceToSquared(h)<z*z||i.push(wt(a.clone(),h.clone(),"bounded"))}}function Ze(i,t){return t||tt(i)?new J(i.center,i.radius,0,S,i.normal,i.refVec).getPoints(Zt):i.getPoints(Zt)}function Ge(i,t){return t||rt(i)?new $(i.center,i.normal,i.majorAxis,i.majorAxisRadius,i.minorAxisRadius,0,S).getPoints(Zt):i.getPoints(Zt)}function In(i,t){return!i.box||!t.box?!0:i.box.intersectsBox(t.box)}function We(i,t){return i.kind==="spline"&&t.kind==="spline"?bi(i,t):i.kind==="spline"?Qe(i,t):t.kind==="spline"?Qe(t,i):i.kind==="line"&&t.kind==="line"?Ke(i,t):i.kind==="line"&&t.kind==="circArc"?Gt(i,t.arc,t.full):t.kind==="line"&&i.kind==="circArc"?Gt(t,i.arc,i.full):i.kind==="line"&&t.kind==="ellipseArc"?Tn(i,t.arc,t.full):t.kind==="line"&&i.kind==="ellipseArc"?Tn(t,i.arc,i.full):i.kind==="circArc"&&t.kind==="circArc"?Ti(i.arc,i.full,t.arc,t.full):i.kind==="circArc"&&t.kind==="ellipseArc"?$e(i.arc,i.full,t.arc,t.full):i.kind==="ellipseArc"&&t.kind==="circArc"?$e(t.arc,t.full,i.arc,i.full):i.kind==="ellipseArc"&&t.kind==="ellipseArc"?Bi(i.arc,i.full,t.arc,t.full):[]}function Qe(i,t){const n=[];for(const e of i.samples)In(e,t)&&qn(n,We(e,t));return Si(i.spline,n,t)}function bi(i,t){const n=[];for(const s of i.samples)for(const r of t.samples)In(s,r)&&qn(n,Ke(s,r));const e=[];for(const s of n){const r=i.spline.nearestPoint(s,Rt),o=t.spline.nearestPoint(s,Rt);r.distanceTo(o)<=Cn&&e.push(r)}return e}function Si(i,t,n){const e=[];for(const s of t){const r=i.nearestPoint(s,Rt);Ci(n,r)<=Cn&&e.push(r)}return e}function Ci(i,t){if(i.kind==="line"){const n=i.dir.lengthSq();if(n<z*z)return Number.POSITIVE_INFINITY;const e=new x().subVectors(t,i.start).dot(i.dir)/n;return Mt(e,i.extent)?zt(i.start,i.dir,e).distanceTo(t):Number.POSITIVE_INFINITY}if(i.kind==="circArc"){if(!Rn(t,i.arc)){const n=Q(i.arc.normal,i.arc.center),e=Math.abs(n.distanceToPoint(t)),s=Math.abs(t.distanceTo(i.arc.center)-i.arc.radius),r=Math.hypot(e,s);if(r>Cn)return r}return xt(i.arc,yt(i.arc,t),i.full)?0:Number.POSITIVE_INFINITY}return i.kind==="ellipseArc"?St(t,i.arc,i.full)?0:Math.abs(Wt(i.arc,t)):Number.POSITIVE_INFINITY}function Ke(i,t){const n=i.dir,e=t.dir,s=n.lengthSq(),r=e.lengthSq();if(s<z*z||r<z*z)return[];const o=new x().subVectors(i.start,t.start),a=n.dot(n),h=n.dot(e),c=e.dot(e),l=n.dot(o),u=e.dot(o),d=a*c-h*h;if(Math.abs(d)<R*R*a*c)return[];const g=(h*u-c*l)/d,m=(a*u-h*l)/d;if(!Mt(g,i.extent)||!Mt(m,t.extent))return[];const f=zt(i.start,n,g),y=zt(t.start,e,m);return f.distanceTo(y)>z?[]:[f]}function Gt(i,t,n){const e=Q(t.normal,t.center),s=Je(i,e);return s==="coplanar"?Ei(i,t,n):s?Rn(s,t)?xt(t,yt(t,s),n)?[s]:[]:[]:[]}function Ei(i,t,n){const e=new x().subVectors(i.start,t.center),s=i.dir.dot(i.dir);if(s<z*z)return[];const r=2*i.dir.dot(e),o=e.dot(e)-t.radius*t.radius,a=[];for(const h of ns(s,r,o)){if(!Mt(h,i.extent))continue;const c=zt(i.start,i.dir,h);xt(t,yt(t,c),n)&&a.push(c)}return a}function Tn(i,t,n){const e=Q(t.normal,t.center),s=Je(i,e);return s==="coplanar"?Ii(i,t,n):s?St(s,t,n)?[s]:[]:[]}function Ii(i,t,n){const e=t.majorAxis,s=t.minorAxis,r=t.majorAxisRadius,o=t.minorAxisRadius;if(r<z||o<z)return[];const a=new x().subVectors(i.start,t.center),h=a.dot(e),c=a.dot(s),l=i.dir.dot(e),u=i.dir.dot(s),d=l*l/(r*r)+u*u/(o*o),g=2*h*l/(r*r)+2*c*u/(o*o),m=h*h/(r*r)+c*c/(o*o)-1,f=[];for(const y of ns(d,g,m)){if(!Mt(y,i.extent))continue;const _=zt(i.start,i.dir,y);Nn(t,bt(t,_),n)&&f.push(_)}return f}function Ti(i,t,n,e){if(qt(i.normal,n.normal)){const a=Q(i.normal,i.center);return Math.abs(a.distanceToPoint(n.center))>z?[]:Ni(ki(i,n),i,t,n,e)}const s=kn(Q(i.normal,i.center),Q(n.normal,n.center));if(!s)return[];const r=wt(s.point.clone(),new w().addVectors(s.point,s.dir),"unbounded");return Gt(r,i,t).filter(a=>Rn(a,n)?xt(n,yt(n,a),e):!1)}function ki(i,t){const n=new x().subVectors(t.center,i.center),e=n.length(),s=i.radius,r=t.radius;if(e<z&&M.equal(s,r,z))return[];if(e>s+r+z)return[];if(e+Math.min(s,r)+z<Math.max(s,r))return[];const o=e<z?ts(i.normal):n.clone().normalize(),a=(s*s-r*r+e*e)/(2*Math.max(e,z)),h=s*s-a*a,c=new w().copy(i.center).addScaledVector(o,a);if(h<-z*z)return[];if(h<z*z)return[c];const l=Math.sqrt(Math.max(0,h)),u=new x().crossVectors(i.normal,o).normalize();return[new w().copy(c).addScaledVector(u,l),new w().copy(c).addScaledVector(u,-l)]}function $e(i,t,n,e){if(!qt(i.normal,n.normal)){const s=kn(Q(i.normal,i.center),Q(n.normal,n.center));if(!s)return[];const r=wt(s.point.clone(),new w().addVectors(s.point,s.dir),"unbounded");return Gt(r,i,t).filter(o=>St(o,n,e))}return He(Ze(i,t),tt(i)||t,s=>Wt(n,s),s=>xt(i,yt(i,s),t)&&St(s,n,e))}function Bi(i,t,n,e){if(!qt(i.normal,n.normal)){const s=kn(Q(i.normal,i.center),Q(n.normal,n.center));if(!s)return[];const r=wt(s.point.clone(),new w().addVectors(s.point,s.dir),"unbounded");return Tn(r,i,t).filter(o=>St(o,n,e))}return He(Ge(i,t),rt(i)||t,s=>Wt(n,s),s=>Nn(i,bt(i,s),t)&&St(s,n,e))}function He(i,t,n,e){const s=[],r=t?i.length:i.length-1;for(let o=0;o<r;o++){const a=i[o],h=i[(o+1)%i.length],c=n(a),l=n(h);if(Math.abs(c)<=z){e(a)&&s.push(a.clone());continue}if(c*l>0)continue;let u=0,d=1,g=c;for(let f=0;f<40;f++){const y=(u+d)/2,_=new w().lerpVectors(a,h,y),C=n(_);g*C<=0?d=y:(u=y,g=C)}const m=new w().lerpVectors(a,h,(u+d)/2);e(m)&&s.push(m)}return s}function Je(i,t){const n=t.normal.dot(i.dir),e=t.distanceToPoint(i.start);if(M.equalToZero(n,z*Math.max(1,i.dir.length())))return M.equalToZero(e,z)?"coplanar":null;const s=-e/n;return Mt(s,i.extent)?zt(i.start,i.dir,s):null}function kn(i,t){const n=new x().crossVectors(i.normal,t.normal);if(n.lengthSq()<z*z)return null;n.normalize();const e=i.normal,s=t.normal,r=e.dot(e)*s.dot(s)-e.dot(s)**2;if(Math.abs(r)<R)return null;const o=-i.constant,a=-t.constant,h=(s.dot(s)*o-e.dot(s)*a)/r,c=(e.dot(e)*a-e.dot(s)*o)/r;return{point:new w().addScaledVector(e,h).addScaledVector(s,c),dir:n}}function Mt(i,t){return t==="unbounded"?!0:t==="ray"?i>=-z:i>=-z&&i<=1+z}function zt(i,t,n){return new w().copy(i).addScaledVector(t,n)}function it(i,t){const n=new w;return t.projectPoint(i,n),n}function Bn(i,t){const n=i.clone().addScaledVector(t,-i.dot(t));return n.lengthSq()<z*z?ts(t):n.normalize()}function Q(i,t){return new Pt().setFromNormalAndCoplanarPoint(i,t)}function qt(i,t){return new x().crossVectors(i,t).lengthSq()<z*z}function yt(i,t){const n=new x().subVectors(t,i.center),e=new x().crossVectors(i.normal,i.refVec);return Math.atan2(n.dot(e),n.dot(i.refVec))}function bt(i,t){const n=new x().subVectors(t,i.center),e=n.dot(i.majorAxis)/i.majorAxisRadius,s=n.dot(i.minorAxis)/i.minorAxisRadius;return Math.atan2(s,e)}function tt(i){return i.closed||Math.abs(i.deltaAngle-S)<1e-10}function rt(i){return i.closed||Math.abs(i.endAngle-i.startAngle)<1e-10||Math.abs(i.deltaAngle-S)<1e-10}function xt(i,t,n){return n||tt(i)?!0:p.normalizeAngle(t-i.startAngle)<=i.deltaAngle+1e-8}function Nn(i,t,n){return n||rt(i)?!0:p.normalizeAngle(t-i.startAngle)<=i.deltaAngle+1e-8}function Rn(i,t){const n=Q(t.normal,t.center);return Math.abs(n.distanceToPoint(i))>z?!1:Math.abs(i.distanceTo(t.center)-t.radius)<=z}function Wt(i,t){const n=new x().subVectors(t,i.center),e=n.dot(i.majorAxis)/i.majorAxisRadius,s=n.dot(i.minorAxis)/i.minorAxisRadius;return e*e+s*s-1}function St(i,t,n){const e=Q(t.normal,t.center);return Math.abs(e.distanceToPoint(i))>z||Math.abs(Wt(t,i))>1e-4?!1:Nn(t,bt(t,i),n)}function Ni(i,t,n,e,s){return i.filter(r=>xt(t,yt(t,r),n)&&xt(e,yt(e,r),s))}function ts(i){const t=Math.abs(i.x)<.9?x.X_AXIS:x.Y_AXIS,n=new x().crossVectors(i,t);return n.lengthSq()<z*z&&n.crossVectors(i,x.Z_AXIS),n.normalize()}function ns(i,t,n){if(Math.abs(i)<R)return Math.abs(t)<R?[]:[-n/t];const e=t*t-4*i*n;if(e<-z)return[];if(e<z)return[-t/(2*i)];const s=Math.sqrt(Math.max(0,e));return[(-t-s)/(2*i),(-t+s)/(2*i)]}function qn(i,t){for(const n of t)i.push(n)}function Ri(i){const t=[];for(const n of i)t.some(e=>e.distanceTo(n)<=z)||t.push(n);return t}A.AcGeArea2d=bn,A.AcGeBox2d=W,A.AcGeBox3d=G,A.AcGeCatmullRomCurve3d=Yt,A.AcGeCircArc2d=O,A.AcGeCircArc3d=J,A.AcGeCurve2d=pt,A.AcGeEllipseArc2d=mt,A.AcGeEllipseArc3d=$,A.AcGeEuler=dn,A.AcGeGeometryUtil=v,A.AcGeLine2d=Nt,A.AcGeLine3d=Dt,A.AcGeLoop2d=Z,A.AcGeMathUtil=p,A.AcGeMatrix2d=_t,A.AcGeMatrix3d=et,A.AcGeNurbsCurve=V,A.AcGePlane=Pt,A.AcGePoint2d=P,A.AcGePoint3d=w,A.AcGePolyline2d=ut,A.AcGeQuaternion=It,A.AcGeShape2d=pn,A.AcGeSpline3d=Y,A.AcGeTol=M,A.AcGeVector2d=N,A.AcGeVector3d=x,A.DEFAULT_TOL=Et,A.DEG2RAD=en,A.FLOAT_TOL=R,A.ORIGIN_POINT_2D=es,A.ORIGIN_POINT_3D=cn,A.RAD2DEG=sn,A.TAU=S,A.acgeBasisFunction=ct,A.acgeCalculateCurveLength=de,A.acgeCeilPowerOfTwo=$n,A.acgeClamp=nt,A.acgeCloneIntersectPrimitive=Ue,A.acgeClosedPolygonArea2d=_e,A.acgeClosedPolygonArea3d=Ae,A.acgeComputeParameterValues=he,A.acgeDamp=On,A.acgeDegToRad=Wn,A.acgeEuclideanModulo=rn,A.acgeEvaluateNurbsDerivatives=le,A.acgeEvaluateNurbsPoint=Tt,A.acgeFloorPowerOfTwo=Hn,A.acgeGenerateAveragedKnots=ce,A.acgeGenerateChordKnots=ds,A.acgeGenerateSqrtChordKnots=gs,A.acgeGenerateUUID=jn,A.acgeGenerateUniformKnots=us,A.acgeGetOcsAngle=Ps,A.acgeGetOcsReferenceVector=_s,A.acgeIntPartLength=an,A.acgeInterpolateControlPoints=fs,A.acgeInterpolateNurbsCurve=mn,A.acgeIntersectCurves=yi,A.acgeInverseLerp=vn,A.acgeIsAngleOnCcwSweep=ne,A.acgeIsBetterDistanceAlign=ze,A.acgeIsBetween=Jn,A.acgeIsBetweenAngle=te,A.acgeIsPowerOfTwo=Kn,A.acgeLerp=on,A.acgeMapLinear=Ln,A.acgeNormalizeAngle=gt,A.acgeOffsetPointByDirectionInXY=ni,A.acgeOffsetSmoothedSampledPath=si,A.acgeOffsetVertexPath=ei,A.acgePingpong=Fn,A.acgePointLiesOnCircle2d=we,A.acgePolygonArea2d=ye,A.acgePolygonArea3d=xe,A.acgeRadToDeg=Qn,A.acgeRandFloat=Yn,A.acgeRandFloatSpread=Zn,A.acgeRandInt=Xn,A.acgeRelativeEps=ee,A.acgeSameCircle2d=Me,A.acgeSeededRandom=Gn,A.acgeSignedPlanarCurvature=ue,A.acgeSignedPolygonArea2d=_n,A.acgeSmootherstep=Dn,A.acgeSmoothstep=Un,A.acgeTransformIntersectPrimitive=xi,A.acgeTransformOcsPointToWcs=As,A.acgeTransformWcsPointToOcs=xn,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
|