@mlightcad/geometry-engine 3.16.6 → 3.16.8

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.
@@ -1 +1 @@
1
- (function(A,j){typeof exports=="object"&&typeof module<"u"?j(exports,require("@mlightcad/common")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/common"],j):(A=typeof globalThis<"u"?globalThis:A||self,j(A["geometry-engine"]={},A.common))})(this,(function(A,j){"use strict";const Z=["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 ie=1234567;const mn=Math.PI/180,fn=180/Math.PI;function re(){const s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,e=Math.random()*4294967295|0;return(Z[s&255]+Z[s>>8&255]+Z[s>>16&255]+Z[s>>24&255]+"-"+Z[t&255]+Z[t>>8&255]+"-"+Z[t>>16&15|64]+Z[t>>24&255]+"-"+Z[n&63|128]+Z[n>>8&255]+"-"+Z[n>>16&255]+Z[n>>24&255]+Z[e&255]+Z[e>>8&255]+Z[e>>16&255]+Z[e>>24&255]).toLowerCase()}function J(s,t,n){return Math.max(t,Math.min(n,s))}function yn(s,t){return(s%t+t)%t}function oe(s,t,n,e,i){return e+(s-t)*(i-e)/(n-t)}function ce(s,t,n){return s!==t?(n-s)/(t-s):0}function xn(s,t,n){return(1-n)*s+n*t}function ae(s,t,n,e){return xn(s,t,1-Math.exp(-n*e))}function he(s,t=1){return t-Math.abs(yn(s,t*2)-t)}function le(s,t,n){return s<=t?0:s>=n?1:(s=(s-t)/(n-t),s*s*(3-2*s))}function ue(s,t,n){return s<=t?0:s>=n?1:(s=(s-t)/(n-t),s*s*s*(s*(s*6-15)+10))}function de(s,t){return s+Math.floor(Math.random()*(t-s+1))}function ge(s,t){return s+Math.random()*(t-s)}function me(s){return s*(.5-Math.random())}function fe(s){s!==void 0&&(ie=s);let t=ie+=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 ye(s){return s*mn}function xe(s){return s*fn}function Ae(s){return(s&s-1)===0&&s!==0}function _e(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function Pe(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function ft(s){const t=Math.PI*2;return(s%t+t)%t}function we(s,t,n){return s>t&&s<n||s>n&&s<t}function pe(s,t,n,e=!1){return s=ft(s),t=ft(t),n=ft(n),e?t>n?s<=t&&s>=n:s<=t||s>=n:t<n?s>=t&&s<=n:s>=t||s<=n}function Me(s,t,n){const e=ft(n-s);return ft(t-s)<=e+1e-7}function An(s){return s=Math.abs(s),s<1?0:Math.ceil(Math.log10(Math.abs(s)+1))}function ze(s,t=1e-7){const n=An(s);return Math.max(Math.pow(10,n)*t,t)}const M={DEG2RAD:mn,RAD2DEG:fn,generateUUID:re,clamp:J,euclideanModulo:yn,mapLinear:oe,inverseLerp:ce,lerp:xn,damp:ae,pingpong:he,smoothstep:le,smootherstep:ue,randInt:de,randFloat:ge,randFloatSpread:me,seededRandom:fe,degToRad:ye,radToDeg:xe,isPowerOfTwo:Ae,ceilPowerOfTwo:_e,floorPowerOfTwo:Pe,normalizeAngle:ft,isBetween:we,isBetweenAngle:pe,isAngleOnCcwSweep:Me,intPartLength:An,relativeEps:ze},jt=class jt{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:i,y:r}=t;this.x=i,this.y=r;return}if(e===2){this.x=t,this.y=n;return}throw j.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 jt(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,i=t.elements;return this.x=i[0]*n+i[3]*e+i[6],this.y=i[1]*n+i[4]*e+i[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),i=Math.sin(n),r=this.x-t.x,o=this.y-t.y;return this.x=r*e-o*i+t.x,this.y=r*i+o*e+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(M.relativeEps(this.x,t),M.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};jt.EMPTY=Object.freeze(new jt(0,0));let q=jt;const Ot=class Ot{constructor(t,n,e,i,r,o,c,a,h){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&n!=null&&e!=null&&i!=null&&r!=null&&o!=null&&c!=null&&a!=null&&h!=null&&this.set(t,n,e,i,r,o,c,a,h)}set(t,n,e,i,r,o,c,a,h){const l=this.elements;return l[0]=t,l[1]=i,l[2]=c,l[3]=n,l[4]=r,l[5]=a,l[6]=e,l[7]=o,l[8]=h,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,i=n.elements,r=this.elements,o=e[0],c=e[3],a=e[6],h=e[1],l=e[4],u=e[7],d=e[2],g=e[5],m=e[8],y=i[0],f=i[3],x=i[6],w=i[1],k=i[4],E=i[7],N=i[2],B=i[5],T=i[8];return r[0]=o*y+c*w+a*N,r[3]=o*f+c*k+a*B,r[6]=o*x+c*E+a*T,r[1]=h*y+l*w+u*N,r[4]=h*f+l*k+u*B,r[7]=h*x+l*E+u*T,r[2]=d*y+g*w+m*N,r[5]=d*f+g*k+m*B,r[8]=d*x+g*E+m*T,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],i=t[2],r=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8];return n*o*l-n*c*h-e*r*l+e*c*a+i*r*h-i*o*a}invert(){const t=this.elements,n=t[0],e=t[1],i=t[2],r=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],u=l*o-c*h,d=c*a-l*r,g=h*r-o*a,m=n*u+e*d+i*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]=(i*h-l*e)*y,t[2]=(c*e-i*o)*y,t[3]=d*y,t[4]=(l*n-i*a)*y,t[5]=(i*r-c*n)*y,t[6]=g*y,t[7]=(e*a-h*n)*y,t[8]=(o*n-e*r)*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,i,r,o,c){const a=Math.cos(r),h=Math.sin(r);return this.set(e*a,e*h,-e*(a*o+h*c)+o+t,-i*h,i*a,-i*(-h*o+a*c)+c+n,0,0,1),this}scale(t,n){return this.premultiply(_n.makeScale(t,n)),this}rotate(t){return this.premultiply(_n.makeRotation(-t)),this}translate(t,n){return this.premultiply(_n.makeTranslation(t,n)),this}makeTranslation(t,n){return t instanceof q?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 i=0;i<9;i++)if(n[i]!==e[i])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 Ot().fromArray(this.elements)}};Ot.IDENTITY=Object.freeze(new Ot);let Mt=Ot;const _n=new Mt,S=1e-6,C=2*Math.PI,qs={x:0,y:0},Pn={x:0,y:0,z:0};class p{constructor(){this.equalPointTol=S,this.equalVectorTol=S}clone(){const t=new p;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t}equalPoint2d(t,n){return new q(t).sub(n).length()<this.equalPointTol}equalPoint3d(t,n){return new P(t).sub(n).length()<this.equalPointTol}static equalToZero(t,n=S){return t<n&&t>-n}static equal(t,n,e=S){return Math.abs(t-n)<e}static great(t,n,e=S){return t-n>e}static less(t,n,e=S){return t-n<e}static isPositive(t,n=S){return t>n}static isNonPositive(t,n=S){return t<=n}}const yt=new p;class Rt{constructor(t=0,n=0,e=0,i=1){this._x=t,this._y=n,this._z=e,this._w=i}static slerpFlat(t,n,e,i,r,o,c){let a=e[i+0],h=e[i+1],l=e[i+2],u=e[i+3];const d=r[o+0],g=r[o+1],m=r[o+2],y=r[o+3];if(c===0){t[n+0]=a,t[n+1]=h,t[n+2]=l,t[n+3]=u;return}if(c===1){t[n+0]=d,t[n+1]=g,t[n+2]=m,t[n+3]=y;return}if(u!==y||a!==d||h!==g||l!==m){let f=1-c;const x=a*d+h*g+l*m+u*y,w=x>=0?1:-1,k=1-x*x;if(k>Number.EPSILON){const N=Math.sqrt(k),B=Math.atan2(N,x*w);f=Math.sin(f*B)/N,c=Math.sin(c*B)/N}const E=c*w;if(a=a*f+d*E,h=h*f+g*E,l=l*f+m*E,u=u*f+y*E,f===1-c){const N=1/Math.sqrt(a*a+h*h+l*l+u*u);a*=N,h*=N,l*=N,u*=N}}t[n]=a,t[n+1]=h,t[n+2]=l,t[n+3]=u}static multiplyQuaternionsFlat(t,n,e,i,r,o){const c=e[i],a=e[i+1],h=e[i+2],l=e[i+3],u=r[o],d=r[o+1],g=r[o+2],m=r[o+3];return t[n]=c*m+l*u+a*g-h*d,t[n+1]=a*m+l*d+h*u-c*g,t[n+2]=h*m+l*g+c*d-a*u,t[n+3]=l*m-c*u-a*d-h*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,i){return this._x=t,this._y=n,this._z=e,this._w=i,this._onChangeCallback(),this}clone(){return new Rt(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,i=t.y,r=t.z,o=t.order,c=Math.cos,a=Math.sin,h=c(e/2),l=c(i/2),u=c(r/2),d=a(e/2),g=a(i/2),m=a(r/2);switch(o){case"XYZ":this._x=d*l*u+h*g*m,this._y=h*g*u-d*l*m,this._z=h*l*m+d*g*u,this._w=h*l*u-d*g*m;break;case"YXZ":this._x=d*l*u+h*g*m,this._y=h*g*u-d*l*m,this._z=h*l*m-d*g*u,this._w=h*l*u+d*g*m;break;case"ZXY":this._x=d*l*u-h*g*m,this._y=h*g*u+d*l*m,this._z=h*l*m+d*g*u,this._w=h*l*u-d*g*m;break;case"ZYX":this._x=d*l*u-h*g*m,this._y=h*g*u+d*l*m,this._z=h*l*m-d*g*u,this._w=h*l*u+d*g*m;break;case"YZX":this._x=d*l*u+h*g*m,this._y=h*g*u+d*l*m,this._z=h*l*m-d*g*u,this._w=h*l*u-d*g*m;break;case"XZY":this._x=d*l*u-h*g*m,this._y=h*g*u-d*l*m,this._z=h*l*m+d*g*u,this._w=h*l*u+d*g*m;break}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,n){const e=n/2,i=Math.sin(e);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(t){const n=t.elements,e=n[0],i=n[4],r=n[8],o=n[1],c=n[5],a=n[9],h=n[2],l=n[6],u=n[10],d=e+c+u;if(d>0){const g=.5/Math.sqrt(d+1);this._w=.25/g,this._x=(l-a)*g,this._y=(r-h)*g,this._z=(o-i)*g}else if(e>c&&e>u){const g=2*Math.sqrt(1+e-c-u);this._w=(l-a)/g,this._x=.25*g,this._y=(i+o)/g,this._z=(r+h)/g}else if(c>u){const g=2*Math.sqrt(1+c-e-u);this._w=(r-h)/g,this._x=(i+o)/g,this._y=.25*g,this._z=(a+l)/g}else{const g=2*Math.sqrt(1+u-e-c);this._w=(o-i)/g,this._x=(r+h)/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(J(this.dot(t),-1,1)))}rotateTowards(t,n){const e=this.angleTo(t);if(e===0)return this;const i=Math.min(1,n/e);return this.slerp(t,i),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,i=t._y,r=t._z,o=t._w,c=n._x,a=n._y,h=n._z,l=n._w;return this._x=e*l+o*c+i*h-r*a,this._y=i*l+o*a+r*c-e*h,this._z=r*l+o*h+e*a-i*c,this._w=o*l-e*c-i*a-r*h,this._onChangeCallback(),this}slerp(t,n){if(n===0)return this;if(n===1)return this.copy(t);const e=this._x,i=this._y,r=this._z,o=this._w;let c=o*t._w+e*t._x+i*t._y+r*t._z;if(c<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,c=-c):this.copy(t),c>=1)return this._w=o,this._x=e,this._y=i,this._z=r,this;const a=1-c*c;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*i+n*this._y,this._z=g*r+n*this._z,this.normalize(),this}const h=Math.sqrt(a),l=Math.atan2(h,c),u=Math.sin((1-n)*l)/h,d=Math.sin(n*l)/h;return this._w=o*u+this._w*d,this._x=e*u+this._x*d,this._y=i*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(),i=Math.sqrt(1-e),r=Math.sqrt(e);return this.set(i*Math.sin(t),i*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 D=class D{constructor(t,n,e){this.x=0,this.y=0,this.z=0;const i=+(t!==void 0)+ +(n!==void 0)+ +(e!==void 0);if(i!==0){if(i===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(i===1){const{x:r,y:o,z:c}=t;this.x=r,this.y=o,this.z=c||0;return}if(i===3){this.x=t,this.y=n,this.z=e;return}throw j.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 D(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(be.setFromEuler(t))}applyAxisAngle(t,n){return this.applyQuaternion(be.setFromAxisAngle(t,n))}applyMatrix3(t){const n=this.x,e=this.y,i=this.z,r=t.elements;return this.x=r[0]*n+r[3]*e+r[6]*i,this.y=r[1]*n+r[4]*e+r[7]*i,this.z=r[2]*n+r[5]*e+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const n=this.x,e=this.y,i=this.z,r=t.elements,o=1/(r[3]*n+r[7]*e+r[11]*i+r[15]);return this.x=(r[0]*n+r[4]*e+r[8]*i+r[12])*o,this.y=(r[1]*n+r[5]*e+r[9]*i+r[13])*o,this.z=(r[2]*n+r[6]*e+r[10]*i+r[14])*o,this}applyQuaternion(t){const n=this.x,e=this.y,i=this.z,r=t.x,o=t.y,c=t.z,a=t.w,h=2*(o*i-c*e),l=2*(c*n-r*i),u=2*(r*e-o*n);return this.x=n+a*h+o*u-c*l,this.y=e+a*l+c*h-r*u,this.z=i+a*u+r*l-o*h,this}transformDirection(t){const n=this.x,e=this.y,i=this.z,r=t.elements;return this.x=r[0]*n+r[4]*e+r[8]*i,this.y=r[1]*n+r[5]*e+r[9]*i,this.z=r[2]*n+r[6]*e+r[10]*i,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(),i=t.length();return Math.abs(n)===e*i}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,i=t.y,r=t.z,o=n.x,c=n.y,a=n.z;return this.x=i*a-r*c,this.y=r*o-e*a,this.z=e*c-i*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 wn.copy(this).projectOnVector(t),this.sub(wn)}reflect(t){return this.sub(wn.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,i=this.z-t.z;return n*n+e*e+i*i}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(),i=this.setFromMatrixColumn(t,2).length();return this.x=n,this.y=e,this.z=i,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}};D.ORIGIN=Object.freeze(new D(0,0,0)),D.X_AXIS=Object.freeze(new D(1,0,0)),D.NEGATIVE_X_AXIS=Object.freeze(new D(-1,0,0)),D.Y_AXIS=Object.freeze(new D(0,1,0)),D.NEGATIVE_Y_AXIS=Object.freeze(new D(0,-1,0)),D.Z_AXIS=Object.freeze(new D(0,0,1)),D.NEGATIVE_Z_AXIS=Object.freeze(new D(0,0,-1));let P=D;const wn=new P,be=new Rt,Bt=class Bt{static makeTranslation(t,n,e){return new Bt().makeTranslation(t,n,e)}constructor(t,n,e,i,r,o,c,a,h,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&&i!=null&&r!=null&&o!=null&&c!=null&&a!=null&&h!=null&&l!=null&&u!=null&&d!=null&&g!=null&&m!=null&&y!=null&&f!=null&&this.set(t,n,e,i,r,o,c,a,h,l,u,d,g,m,y,f)}set(t,n,e,i,r,o,c,a,h,l,u,d,g,m,y,f){const x=this.elements;return x[0]=t,x[4]=n,x[8]=e,x[12]=i,x[1]=r,x[5]=o,x[9]=c,x[13]=a,x[2]=h,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 Bt().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(yt.equalPoint3d(e,P.Z_AXIS))this.identity();else{const i=new P(1,0,0);Math.abs(e.x)<1/64&&Math.abs(e.y)<1/64?i.crossVectors(P.Y_AXIS,e).normalize():i.crossVectors(P.Z_AXIS,e).normalize();const r=e.clone().cross(i).normalize();this.makeBasis(i,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,i=1/zt.setFromMatrixColumn(t,0).length(),r=1/zt.setFromMatrixColumn(t,1).length(),o=1/zt.setFromMatrixColumn(t,2).length();return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,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(Vs,t,js)}lookAt(t,n,e){const i=this.elements;return Q.subVectors(t,n),Q.lengthSq()===0&&(Q.z=1),Q.normalize(),dt.crossVectors(e,Q),dt.lengthSq()===0&&(Math.abs(e.z)===1?Q.x+=1e-4:Q.z+=1e-4,Q.normalize(),dt.crossVectors(e,Q)),dt.normalize(),Dt.crossVectors(Q,dt),i[0]=dt.x,i[4]=Dt.x,i[8]=Q.x,i[1]=dt.y,i[5]=Dt.y,i[9]=Q.y,i[2]=dt.z,i[6]=Dt.z,i[10]=Q.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const e=t.elements,i=n.elements,r=this.elements,o=e[0],c=e[4],a=e[8],h=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],w=e[3],k=e[7],E=e[11],N=e[15],B=i[0],T=i[4],I=i[8],R=i[12],G=i[1],V=i[5],$=i[9],K=i[13],L=i[2],at=i[6],an=i[10],hn=i[14],ln=i[3],un=i[7],dn=i[11],gn=i[15];return r[0]=o*B+c*G+a*L+h*ln,r[4]=o*T+c*V+a*at+h*un,r[8]=o*I+c*$+a*an+h*dn,r[12]=o*R+c*K+a*hn+h*gn,r[1]=l*B+u*G+d*L+g*ln,r[5]=l*T+u*V+d*at+g*un,r[9]=l*I+u*$+d*an+g*dn,r[13]=l*R+u*K+d*hn+g*gn,r[2]=m*B+y*G+f*L+x*ln,r[6]=m*T+y*V+f*at+x*un,r[10]=m*I+y*$+f*an+x*dn,r[14]=m*R+y*K+f*hn+x*gn,r[3]=w*B+k*G+E*L+N*ln,r[7]=w*T+k*V+E*at+N*un,r[11]=w*I+k*$+E*an+N*dn,r[15]=w*R+k*K+E*hn+N*gn,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],i=t[8],r=t[12],o=t[1],c=t[5],a=t[9],h=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*(+r*a*u-i*h*u-r*c*d+e*h*d+i*c*g-e*a*g)+y*(+n*a*g-n*h*d+r*o*d-i*o*g+i*h*l-r*a*l)+f*(+n*h*u-n*c*g-r*o*u+e*o*g+r*c*l-e*h*l)+x*(-i*c*l-n*a*u+n*c*d+i*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 i=this.elements;return t instanceof P?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=n,i[14]=e),this}invert(){const t=this.elements,n=t[0],e=t[1],i=t[2],r=t[3],o=t[4],c=t[5],a=t[6],h=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],w=u*f*h-y*d*h+y*a*g-c*f*g-u*a*x+c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(n,e,i))}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),i=Math.sin(n),r=1-e,o=t.x,c=t.y,a=t.z,h=r*o,l=r*c;return this.set(h*o+e,h*c-i*a,h*a+i*c,0,h*c+i*a,l*c+e,l*a-i*o,0,h*a-i*c,l*a+i*o,r*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}setToMirroring(t,n,e="line"){return e==="plane"?Fs(this,t,n):Ls(this,t,n),this}makeShear(t,n,e,i,r,o){return this.set(1,e,r,0,t,1,o,0,n,i,1,0,0,0,0,1),this}compose(t,n,e){const i=this.elements,r=n.x,o=n.y,c=n.z,a=n.w,h=r+r,l=o+o,u=c+c,d=r*h,g=r*l,m=r*u,y=o*l,f=o*u,x=c*u,w=a*h,k=a*l,E=a*u,N=e.x,B=e.y,T=e.z;return i[0]=(1-(y+x))*N,i[1]=(g+E)*N,i[2]=(m-k)*N,i[3]=0,i[4]=(g-E)*B,i[5]=(1-(d+x))*B,i[6]=(f+w)*B,i[7]=0,i[8]=(m+k)*T,i[9]=(f-w)*T,i[10]=(1-(d+y))*T,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,n,e){const i=this.elements;let r=zt.set(i[0],i[1],i[2]).length();const o=zt.set(i[4],i[5],i[6]).length(),c=zt.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],it.copy(this);const h=1/r,l=1/o,u=1/c;return it.elements[0]*=h,it.elements[1]*=h,it.elements[2]*=h,it.elements[4]*=l,it.elements[5]*=l,it.elements[6]*=l,it.elements[8]*=u,it.elements[9]*=u,it.elements[10]*=u,n.setFromRotationMatrix(it),e.x=r,e.y=o,e.z=c,this}equals(t){const n=this.elements,e=t.elements;for(let i=0;i<16;i++)if(n[i]!==e[i])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}};Bt.IDENTITY=Object.freeze(new Bt);let O=Bt;function Ls(s,t,n){const e=n.x-t.x,i=n.y-t.y,r=e*e+i*i;if(p.equalToZero(Math.sqrt(r)))return s.copy(new O().makeTranslation(t.x,t.y,t.z??0).multiply(new O().makeScale(-1,1,1)).multiply(new O().makeTranslation(-t.x,-t.y,-(t.z??0))));const o=Math.atan2(i,e),c=t.z??0;return s.copy(new O().makeTranslation(t.x,t.y,c).multiply(new O().makeRotationZ(o)).multiply(new O().makeScale(1,-1,1)).multiply(new O().makeRotationZ(-o)).multiply(new O().makeTranslation(-t.x,-t.y,-c)))}function Fs(s,t,n){const e=n.x,i=n.y,r=n.z??0,o=Math.hypot(e,i,r);if(p.equalToZero(o))return s.identity();const c=e/o,a=i/o,h=r/o,l=t.x,u=t.y,d=t.z??0,g=c*l+a*u+h*d;return s.set(1-2*c*c,-2*c*a,-2*c*h,2*g*c,-2*a*c,1-2*a*a,-2*a*h,2*g*a,-2*h*c,-2*h*a,1-2*h*h,2*g*h,0,0,0,1)}const zt=new P,it=new O,Vs=new P(0,0,0),js=new P(1,1,1),dt=new P,Dt=new P,Q=new P;class rt{constructor(t=void 0,n=void 0){this.min=t==null?new P(1/0,1/0,1/0):new P(t.x,t.y,t.z),this.max=n==null?new P(-1/0,-1/0,-1/0):new P(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(pn.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=pn.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new rt().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 P(0,0,0):new P(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new P(0,0,0):new P(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.z)?this:(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,pn).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:(ht[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ht[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ht[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ht[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ht[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ht[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ht[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ht[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ht),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 ht=[new P,new P,new P,new P,new P,new P,new P,new P],pn=new P,Se=new q;class tt{constructor(t=void 0,n=void 0){this.min=t==null?new q(1/0,1/0):new q(t.x,t.y),this.max=n==null?new q(-1/0,-1/0):new q(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=Se.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new tt().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 q(0,0):new q(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new q(0,0):new q(0,0).subVectors(this.max,this.min)}expandByPoint(t){return!Number.isFinite(t.x)||!Number.isFinite(t.y)?this:(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,Se).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 Ce=new P,Os=new P,Us=new Mt;class bt{constructor(t=new P(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,i){return this.normal.set(t,n,e),this.constant=i,this}setFromNormalAndCoplanarPoint(t,n){return this.normal.copy(t),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(t,n,e){const i=Ce.subVectors(e,n).cross(Os.subVectors(t,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,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||Us.getNormalMatrix(t),i=this.coplanarPoint(Ce).applyMatrix4(t),r=this.normal.applyMatrix3(e).normalize();return this.constant=-i.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 bt().copy(this)}}class _ extends q{clone(){return new _(this.x,this.y)}static pointArrayToNumberArray(t){const n=new Array(t.length*2);return t.forEach((e,i)=>{e.toArray(n,i*2)}),n}}class z extends P{clone(){return new z(this.x,this.y,this.z)}static pointArrayToNumberArray(t,n=!0){const e=n?3:2,i=new Array(t.length*e);return t.forEach((r,o)=>{r.toArray(i,o*e)}),i}}const Te=new O,ke=new Rt,Ut=class Ut{constructor(t=0,n=0,e=0,i=Ut.DEFAULT_ORDER){this._x=t,this._y=n,this._z=e,this._order=i}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,i=this._order){return this._x=t,this._y=n,this._z=e,this._order=i,this._onChangeCallback(),this}clone(){return new Ut(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 i=t.elements,r=i[0],o=i[4],c=i[8],a=i[1],h=i[5],l=i[9],u=i[2],d=i[6],g=i[10];switch(n){case"XYZ":this._y=Math.asin(J(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-l,g),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-J(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(c,g),this._z=Math.atan2(a,h)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(J(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,g),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-J(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,g),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-o,h));break;case"YZX":this._z=Math.asin(J(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(c,g));break;case"XZY":this._z=Math.asin(-J(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(c,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 Te.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Te,n,e)}setFromVector3(t,n=this._order){return this.set(t.x,t.y,t.z,n)}reorder(t){return ke.setFromEuler(this),this.setFromQuaternion(ke,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}};Ut.DEFAULT_ORDER="XYZ";let Mn=Ut;function zn(s){const t=s.length;if(t<3)return 0;let n=0;for(let e=0,i=t-1;e<t;i=e++){const r=s[i],o=s[e];n+=r.x*o.y-o.x*r.y}return n*.5}function Ee(s){return Math.abs(zn(s))}function Ie(s){const t=s.length;if(t<3)return 0;let n=0,e=0,i=0;for(let r=0,o=t-1;r<t;o=r++){const c=s[o],a=s[r],h=c.x,l=c.y,u=c.z??0,d=a.x,g=a.y,m=a.z??0;n+=(u+m)*(l-g),e+=(h+d)*(u-m),i+=(l+g)*(h-d)}return .5*Math.hypot(n,e,i)}function Ds(s){return s.length<3?0:Ee(s)}function Ne(s){return s.length<3?0:Ie(s)}function Xs(s){const t=s;return{x:s.x,y:s.y,z:t.z??0}}function Zs(s,t){s.x+=t.x,s.y+=t.y,s.z=(s.z??0)+(t.z??0)}function Ys(s,t,n=!1){const e=s.x,i=s.y;let r=!1;const o=t.length;for(let c=0,a=o-1;c<o;a=c++){const h=t[c].x,l=t[c].y,u=t[a].x,d=t[a].y;let g=l>i!=d>i;n&&(g=l>=i!=d>=i),g&&e<(u-h)*(i-l)/(d-l)+h&&(r=!r)}return r}function Gs(s,t){if(s.length===0||t.length===0)return!1;const n=new tt().setFromPoints(s),e=new tt().setFromPoints(t);if(!n.intersectsBox(e))return!1;for(let i=0;i<s.length;){if(Y.isPointInPolygon(s[i],t,!0))return!0;i<s.length-1&&yt.equalPoint2d(s[i+1],s[i])&&++i,++i}return!1}const Y={applyOffsetToPoint3d:Zs,isPointInPolygon:Ys,isPolygonIntersect:Gs,point2dToPoint3d:Xs};function Ws(s,t){const n=[],e=t-1,i=s;for(let r=0;r<=i;r++)n.push(0);for(let r=1;r<=e-i;r++)n.push(r);for(let r=0;r<=i;r++)n.push(e-i+1);return n}function Ks(s,t){const n=t.length-1,e=s,i=[0];let r=0;for(let c=1;c<=n;c++){const a=t[c][0]-t[c-1][0],h=t[c][1]-t[c-1][1],l=t[c][2]-t[c-1][2],u=Math.sqrt(a*a+h*h+l*l);r+=u,i.push(r)}const o=[];for(let c=0;c<=e;c++)o.push(0);for(let c=1;c<=n-e;c++){const a=i[c]/r;o.push(a*(n-e+1))}for(let c=0;c<=e;c++)o.push(n-e+1);return o}function Be(s,t="Uniform"){const n=s.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,c)=>c/e);const i=[0];let r=0;for(let o=1;o<=e;o++){const c=s[o][0]-s[o-1][0],a=s[o][1]-s[o-1][1],h=s[o][2]-s[o-1][2],l=Math.sqrt(c*c+a*a+h*h),u=t==="SqrtChord"?Math.sqrt(l):l;r+=u,i.push(r)}return r<1e-12?new Array(n).fill(0).map((o,c)=>c/e):i.map(o=>o/r)}function Re(s,t){const n=t.length-1,e=s,i=n+e+1,r=new Array(i+1).fill(0),o=t[t.length-1];for(let c=i-e;c<=i;c++)r[c]=o;for(let c=1;c<=n-e;c++){let a=0;for(let h=c;h<c+e;h++)a+=t[h];r[c+e]=a/e}return r}function Qs(s,t){const n=t.length-1,e=s,i=[0];let r=0;for(let c=1;c<=n;c++){const a=t[c][0]-t[c-1][0],h=t[c][1]-t[c-1][1],l=t[c][2]-t[c-1][2],u=Math.sqrt(a*a+h*h+l*l),d=Math.sqrt(u);r+=d,i.push(r)}const o=[];for(let c=0;c<=e;c++)o.push(0);for(let c=1;c<=n-e;c++){const a=i[c]/r;o.push(a*(n-e+1))}for(let c=0;c<=e;c++)o.push(n-e+1);return o}function Xt(s,t){for(const n of s)if(n.col===t)return n.value;return 0}function ve(s,t){for(let n=0;n<s.length;n++)if(s[n].col===t)return n;return-1}function Hs(s,t){const n=s.length,e=s.map(o=>o.map(c=>({col:c.col,value:c.value}))),i=t.map(o=>o.slice());for(let o=0;o<n;o++){let c=-1,a=1e-12;for(let l=o;l<n;l++){const u=Math.abs(Xt(e[l],o));u>a&&(a=u,c=l)}if(c<0)throw new Error("Interpolation matrix is singular.");if(c!==o){const l=e[o];e[o]=e[c],e[c]=l;for(const u of i){const d=u[o];u[o]=u[c],u[c]=d}}const h=Xt(e[o],o);for(let l=o+1;l<n;l++){const u=ve(e[l],o);if(u<0)continue;const d=e[l][u].value/h;if(!(Math.abs(d)<1e-14)){for(const g of e[l])g.col>o&&(g.value-=d*Xt(e[o],g.col));for(const g of e[o])g.col<=o||g.value===0||ve(e[l],g.col)<0&&e[l].push({col:g.col,value:-d*g.value});e[l][u].value=0;for(const g of i)g[l]-=d*g[o]}}}const r=i.map(()=>new Array(n).fill(0));for(let o=n-1;o>=0;o--){const c=Xt(e[o],o);for(let a=0;a<i.length;a++){let h=i[a][o];for(const l of e[o])l.col>o&&(h-=l.value*r[a][l.col]);r[a][o]=h/c}}return r}function $s(s,t,n){const e=n.length-t-2;if(s>=n[e+1])return e;let i=t,r=n.length-t-2;for(;i<=r;){const o=i+r>>1;if(s<n[o])r=o-1;else if(s>=n[o+1])i=o+1;else return o}return t}function bn(s,t,n="Uniform",e,i){if(s.length===0)return{controlPoints:[],knots:[],weights:[]};const r=s.map(I=>[I[0],I[1],I[2]??0]),o=!!e,c=!!i,a=(o?1:0)+(c?1:0),h=r.length-1,l=h+a;if(l<t)throw new Error("Not enough points to interpolate a curve of this degree.");const u=Be(r,n),d=u.slice();o&&d.unshift(u[0]),c&&d.push(u[u.length-1]);const g=Re(t,d),m=l+1,y=[],f=[],x=[],w=[];if(o){const I=g[t+1]-g[0],R=I!==0?t/I:0;y.push([{col:0,value:-R},{col:1,value:R}]),f.push((e==null?void 0:e[0])??0),x.push((e==null?void 0:e[1])??0),w.push((e==null?void 0:e[2])??0)}y.push([{col:0,value:1}]),f.push(r[0][0]),x.push(r[0][1]),w.push(r[0][2]);for(let I=1;I<=h-1;I++){const R=u[I],G=[],V=$s(R,t,g),$=Math.max(0,V-t),K=Math.min(l,V);for(let L=$;L<=K;L++){const at=gt(L,t,R,g);at!==0&&G.push({col:L,value:at})}y.push(G),f.push(r[I][0]),x.push(r[I][1]),w.push(r[I][2])}if(y.push([{col:l,value:1}]),f.push(r[h][0]),x.push(r[h][1]),w.push(r[h][2]),c){const I=g[l+t+1]-g[l],R=I!==0?t/I:0;y.push([{col:l-1,value:-R},{col:l,value:R}]),f.push((i==null?void 0:i[0])??0),x.push((i==null?void 0:i[1])??0),w.push((i==null?void 0:i[2])??0)}const[k,E,N]=Hs(y,[f,x,w]),B=new Array(m);for(let I=0;I<m;I++)B[I]=[k[I],E[I],N[I]];const T=new Array(m).fill(1);return{controlPoints:B,knots:g,weights:T}}function gt(s,t,n,e){if(t===0)return n>=e[s]&&n<e[s+1]?1:0;const i=e[s+t]-e[s],r=e[s+t+1]-e[s+1],o=i>1e-10?(n-e[s])/i:0,c=r>1e-10?(e[s+t+1]-n)/r:0;return o*gt(s,t-1,n,e)+c*gt(s+1,t-1,n,e)}function vt(s,t,n,e,i){const r=e.length-1,o=t;if(s=Math.max(n[o],Math.min(n[r+1],s)),Math.abs(s-n[r+1])<1e-8)return[...e[r]];if(Math.abs(s-n[o])<1e-8)return[...e[0]];const c=[0,0,0];let a=0;for(let h=0;h<=r;h++){const l=gt(h,o,s,n),u=i[h]*l;c[0]+=e[h][0]*u,c[1]+=e[h][1]*u,c[2]+=e[h][2]*u,a+=u}if(Math.abs(a)<1e-10){const h=n[n.length-o-1];if(Math.abs(s-h)<1e-8)return[...e[r]];if(Math.abs(s-n[o])<1e-8)return[...e[0]]}return Math.abs(a)>=1e-10&&(c[0]/=a,c[1]/=a,c[2]/=a),c}function Sn(s,t,n,e){if(t===0)return 0;const i=e[s+t]-e[s],r=e[s+t+1]-e[s+1];let o=0;return i>1e-10&&(o+=t/i*gt(s,t-1,n,e)),r>1e-10&&(o-=t/r*gt(s+1,t-1,n,e)),o}function Js(s,t,n,e){if(t<=1)return 0;const i=e[s+t]-e[s],r=e[s+t+1]-e[s+1];let o=0;return i>1e-10&&(o+=t/i*Sn(s,t-1,n,e)),r>1e-10&&(o-=t/r*Sn(s+1,t-1,n,e)),o}function Zt(s,t,n,e,i){const r=e.length-1,o=t,c=n[o],a=n[r+1];s=Math.max(c,Math.min(a,s));const h=[0,0,0],l=[0,0,0],u=[0,0,0];let d=0,g=0,m=0;for(let B=0;B<=r;B++){const T=gt(B,o,s,n),I=Sn(B,o,s,n),R=Js(B,o,s,n),G=i[B],V=G*T,$=G*I,K=G*R,L=e[B];h[0]+=V*L[0],h[1]+=V*L[1],h[2]+=V*L[2],l[0]+=$*L[0],l[1]+=$*L[1],l[2]+=$*L[2],u[0]+=K*L[0],u[1]+=K*L[1],u[2]+=K*L[2],d+=V,g+=$,m+=K}if(Math.abs(d)<1e-10)return{point:vt(s,t,n,e,i),deriv1:[0,0,0],deriv2:[0,0,0]};const y=d*d,f=[h[0]/d,h[1]/d,h[2]/d],x=[(l[0]*d-h[0]*g)/y,(l[1]*d-h[1]*g)/y,(l[2]*d-h[2]*g)/y],w=u[0]*d-h[0]*m,k=u[1]*d-h[1]*m,E=u[2]*d-h[2]*m,N=[w/y-2*g*x[0]/d,k/y-2*g*x[1]/d,E/y-2*g*x[2]/d];return{point:f,deriv1:x,deriv2:N}}function qe(s,t){const n=s[0],e=s[1],i=t[0],r=t[1],o=n*n+e*e;return o<1e-20?0:(n*r-e*i)/Math.pow(o,1.5)}function Cn(s,t,n,e){const i=s,r=t[i],o=t[t.length-i-1];let c=0;const a=1e3,h=(o-r)/a;let l=vt(r,s,t,n,e);for(let y=1;y<=a;y++){const f=r+y*h,x=vt(f,s,t,n,e),w=x[0]-l[0],k=x[1]-l[1],E=x[2]-l[2];c+=Math.sqrt(w*w+k*k+E*E),l=x}const u=vt(o,s,t,n,e),d=u[0]-l[0],g=u[1]-l[1],m=u[2]-l[2];return c+=Math.sqrt(d*d+g*g+m*m),c}function ti(s,t=3,n="Uniform",e,i){return s.length===0?[]:bn(s,t,n,e,i).controlPoints}const Tn=1e-10;function ni(s){return s.controlPoints.map((t,n)=>{const e=s.weights[n]??1;return[t.x*e,t.y*e,(t.z??0)*e,e]})}function ei(s,t,n){const e=[],i=[];for(const[r,o,c,a]of n){const h=a===0?1:a;e.push({x:r/h,y:o/h,z:c/h}),i.push(a)}return{degree:s,knots:t,controlPoints:e,weights:i}}function qt(s){const{degree:t,knots:n}=s;return{start:n[t],end:n[n.length-t-1]}}function kn(s,t,n,e=Tn){const i=s.degree,r=s.knots,o=r.length-1,c=s.controlPoints.length-1;for(const f of r)if(Math.abs(f-t)<=e){t=f;break}let a=-1,h=0;for(let f=0;f<=o;f++)r[f]<=t&&(a=f),r[f]===t&&h++;const l=Math.min(n,i-h);if(l<=0||a<i||a>=o)return{degree:i,knots:[...r],controlPoints:s.controlPoints.map(f=>({x:f.x,y:f.y,z:f.z??0})),weights:[...s.weights]};const u=ni(s),d=new Array(o+l+1),g=new Array(c+l+1),m=new Array(i+1);for(let f=0;f<=a;f++)d[f]=r[f];for(let f=1;f<=l;f++)d[a+f]=t;for(let f=a+1;f<=o;f++)d[f+l]=r[f];for(let f=0;f<=a-i;f++)g[f]=[...u[f]];for(let f=a-h;f<=c;f++)g[f+l]=[...u[f]];for(let f=0;f<=i-h;f++)m[f]=[...u[a-i+f]];let y=a-i;for(let f=1;f<=l;f++){y=a-i+f;for(let x=0;x<=i-f-h;x++){const w=(t-r[y+x])/(r[x+a+1]-r[y+x]),k=m[x+1],E=m[x];m[x]=[w*k[0]+(1-w)*E[0],w*k[1]+(1-w)*E[1],w*k[2]+(1-w)*E[2],w*k[3]+(1-w)*E[3]]}g[y]=[...m[0]],g[a+l-f-h]=[...m[i-f-h]]}for(let f=y+1;f<a-h;f++)g[f]=[...m[f-y]];return ei(i,d,g)}function Yt(s,t,n,e=Tn){const i=s.degree,r=qt(s);if(t=Math.max(r.start,Math.min(r.end,t)),n=Math.max(r.start,Math.min(r.end,n)),n-t<=e)return;let o=kn(s,t,i,e);o=kn(o,n,i,e);const c=o.knots,a=f=>{for(const x of c)if(Math.abs(x-f)<=e)return x;return f},h=a(t),l=a(n);let u=-1,d=-1;for(let f=0;f<c.length;f++)c[f]===h&&(u=f),d<0&&c[f]===l&&(d=f);if(u<0||d<0)return;const g=u-i,m=d-1;if(g<0||m>=o.controlPoints.length||m<g)return;const y=[];for(let f=0;f<=i;f++)y.push(h);for(let f=u+1;f<d;f++)y.push(c[f]);for(let f=0;f<=i;f++)y.push(l);return{degree:i,knots:y,controlPoints:o.controlPoints.slice(g,m+1),weights:o.weights.slice(g,m+1)}}function si(s,t,n=Tn){const e=qt(s);if(t<=e.start+n||t>=e.end-n)return;const i=Yt(s,e.start,t,n),r=Yt(s,t,e.end,n);return i&&r?[i,r]:void 0}function ii(s,t){const n=s.degree;if(t.degree!==n)return;const e=s.knots[s.knots.length-1],i=t.knots[0],r=e-i,o=s.knots.slice(0,s.knots.length-1);for(let d=n+1;d<t.knots.length;d++)o.push(t.knots[d]+r);const c=s.weights[s.weights.length-1]??1,a=t.weights[0]??1,h=a===0?1:c/a,l=[...s.controlPoints.map(d=>({x:d.x,y:d.y,z:d.z??0})),...t.controlPoints.slice(1).map(d=>({x:d.x,y:d.y,z:d.z??0}))],u=[...s.weights,...t.weights.slice(1).map(d=>d*h)];return{degree:n,knots:o,controlPoints:l,weights:u}}function ri(s,t){return Zt(t,s.degree,s.knots,s.controlPoints.map(n=>[n.x,n.y,n.z??0]),s.weights)}function oi(s,t){const n=s[0]-t.x,e=s[1]-t.y,i=s[2]-(t.z??0);return n*n+e*e+i*i}function ci(s,t,n=128){const{start:e,end:i}=qt(s);if(!(i>e))return e;const r=Math.max(n,s.controlPoints.length*16),o=s.controlPoints.map(T=>[T.x,T.y,T.z??0]),c=T=>Zt(T,s.degree,s.knots,o,s.weights),a=T=>oi(c(T).point,t);let h=0,l=1/0;const u=(i-e)/r;for(let T=0;T<=r;T++){const I=a(e+T*u);I<l&&(l=I,h=T)}let d=e+Math.max(0,h-1)*u,g=e+Math.min(r,h+1)*u;const m=(Math.sqrt(5)-1)/2;let y=g-m*(g-d),f=d+m*(g-d),x=a(y),w=a(f);for(let T=0;T<60&&g-d>1e-14*(i-e);T++)x<w?(g=f,f=y,w=x,y=g-m*(g-d),x=a(y)):(d=y,y=f,x=w,f=d+m*(g-d),w=a(f));let k=(d+g)/2,E=a(k);for(let T=0;T<8;T++){const{point:I,deriv1:R,deriv2:G}=c(k),V=[I[0]-t.x,I[1]-t.y,I[2]-(t.z??0)],$=R[0]*V[0]+R[1]*V[1]+R[2]*V[2],K=G[0]*V[0]+G[1]*V[1]+G[2]*V[2]+R[0]*R[0]+R[1]*R[1]+R[2]*R[2];if(!(Math.abs(K)>1e-30))break;const L=Math.max(e,Math.min(i,k-$/K)),at=a(L);if(!(at<E))break;k=L,E=at}const N=a(e),B=a(i);return N<E&&N<=B?e:B<E?i:k}function ai(s,t){const{start:n}=qt(s),e=Yt(s,n,t);return e?Cn(e.degree,e.knots,e.controlPoints.map(i=>[i.x,i.y,i.z??0]),e.weights):0}const Gt=new O,Le=new P,hi=new P,li=new P,En=new z,Fe=new P;function ui(s){return new O().setFromExtrusionDirection(new P(s.x,s.y,s.z))}function di(s){return Ve(new P,s)}function Ve(s,t){return Gt.setFromExtrusionDirection(Fe.set(t.x,t.y,t.z)),Gt.extractBasis(Le,hi,li),s.copy(Le),s}function gi(s,t){return je(new z,s,t)}function je(s,t,n){return n.x===0&&n.y===0&&n.z===1?(s.set(t.x,t.y,t.z??0),s):(Gt.setFromExtrusionDirection(Fe.set(n.x,n.y,n.z)),s.set(t.x,t.y,t.z??0),s.applyMatrix4(Gt),s)}function In(s,t){return new z(s.x,s.y,s.z??0).applyMatrix4(ui(t).invert())}function mi(s,t,n){const e=In(s,n),i=In(t,n);return En.set(i.x-e.x,i.y-e.y,(i.z??0)-(e.z??0)),M.normalizeAngle(Math.atan2(En.y,En.x))}function Nn(s,t,n){const e=s.x,i=s.y,r=t.x,o=t.y,c=n.x,a=n.y,h=2*(e*(o-a)+r*(a-i)+c*(i-o));if(p.equalToZero(h))return null;const l=((e*e+i*i)*(o-a)+(r*r+o*o)*(a-i)+(c*c+a*a)*(i-o))/h,u=((e*e+i*i)*(c-r)+(r*r+o*o)*(e-c)+(c*c+a*a)*(r-e))/h,d=Math.hypot(l-e,u-i);return!Number.isFinite(d)||p.isNonPositive(d)?null:{center:new _(l,u),radius:d}}function Oe(s,t,n){const e=s.x,i=s.y,r=s.z??0,o=new P(t.x-e,t.y-i,(t.z??0)-r),c=new P(n.x-e,n.y-i,(n.z??0)-r),a=new P().crossVectors(o,c),h=a.lengthSq();if(h<S*S)return null;const l=o.lengthSq(),u=c.lengthSq(),d=new P().crossVectors(a,o).multiplyScalar(u).add(new P().crossVectors(c,a).multiplyScalar(l)).multiplyScalar(1/(2*h)),g=new z(e+d.x,i+d.y,r+d.z),m=Math.hypot(g.x-e,g.y-i,g.z-r);return!Number.isFinite(m)||p.isNonPositive(m)?null:{center:g,radius:m}}function nt(s,t){return Math.atan2(t.y-s.y,t.x-s.x)}function F(s,t){return Math.hypot(t.x-s.x,t.y-s.y)}function Ue(s,t,n){if(p.isNonPositive(t))return null;const e=n.x-s.x,i=n.y-s.y,r=Math.hypot(e,i);if(p.isNonPositive(r))return null;const o=t/r;return new _(s.x+e*o,s.y+i*o)}const fi=1e-8;function De(s,t,n,e){return Math.abs(F(s,t)-n)<=(e??Math.max(S,n*1e-5))}function Xe(s,t,n,e,i=fi){return Math.abs(s.x-n.x)<=i&&Math.abs(s.y-n.y)<=i&&Math.abs(t-e)<=i}function Ze(s,t,n,e){const i=Math.max(1e-18,Math.abs(n)*1e-9);return s<n-i?!0:s>n+i?!1:t>e}function Bn(s,t,n,e=!1){const i=Nn(s,t,n);if(!i)return null;const r=nt(i.center,s),o=nt(i.center,t),c=nt(i.center,n);let a=!M.isAngleOnCcwSweep(r,o,c);return e&&(a=!a),v.fromMathAngles(i.center,i.radius,r,c,a)}function Rn(s,t){return!Number.isFinite(t)||p.isNonPositive(t)?null:new v(s,t,0,C,!1)}function yi(s,t){const n=F(s,t);return p.isNonPositive(n)?null:Rn({x:(s.x+t.x)/2,y:(s.y+t.y)/2},n/2)}function xi(s,t,n){const e=Nn(s,t,n);return e?Rn(e.center,e.radius):null}function Ai(s,t,n){const e=F(n,s);if(p.isNonPositive(e))return null;const i=nt(n,s),r=nt(n,t),o=M.normalizeAngle(r-i);return v.fromMathAngles(n,e,i,r,o>Math.PI)}function Lt(s,t,n,e){const i=F(s,t),r=F(s,n);if(p.isNonPositive(i)||p.isNonPositive(r))return null;const o=Math.max(S,i*S);return Math.abs(i-r)>o?null:v.fromMathAngles(s,i,nt(s,t),nt(s,n),e)}function _i(s,t,n,e){const i=F(s,t);if(p.isNonPositive(i))return null;const r=Ue(s,i,n);return r?Lt(s,t,r,e):null}function Ye(s,t,n){const e=F(s,t),i=Math.abs(n);if(p.isNonPositive(e)||p.isNonPositive(i)||!p.great(C-i,0))return null;const r=n<0,o=nt(s,t),c=r?o-i:o+i;return v.fromMathAngles(s,e,o,c,r)}function Pi(s,t,n){const e=F(s,t),i=Math.abs(n);if(p.isNonPositive(e)||p.isNonPositive(i)||p.great(i,2*e))return null;const r=Math.max(-1,Math.min(1,i/(2*e))),o=2*Math.asin(r);return Ye(s,t,n>=0?o:-o)}function wi(s,t,n){const e=F(s,t),i=Math.abs(n);if(p.isNonPositive(e)||p.isNonPositive(i)||!p.great(C-i,0))return null;const r=Math.sin(i/2);if(p.equalToZero(r))return null;const o=e/(2*r),c=o*o-e*e/4;if(p.less(c,0))return null;const a=Math.sqrt(Math.max(0,c)),h=(s.x+t.x)/2,l=(s.y+t.y)/2,u=t.x-s.x,g=-(t.y-s.y)/e,m=u/e,y=n>=0,x=y&&i<=Math.PI||!y&&i>Math.PI?1:-1,w={x:h+g*a*x,y:l+m*a*x};return Lt(w,s,t,!y)}function Ge(s,t,n){const e=Math.cos(n),i=Math.sin(n),r=t.x-s.x,o=t.y-s.y,c=-i,a=e,h=2*(r*c+o*a);if(p.equalToZero(h))return null;const l=(r*r+o*o)/h;if(!Number.isFinite(l))return null;const u={x:s.x+c*l,y:s.y+a*l},d=s.x-u.x,g=s.y-u.y,m=d*i-g*e;return p.equalToZero(m)?null:Lt(u,s,t,m<0)}function We(s,t,n){const e=Math.abs(n),i=F(s,t);if(p.isNonPositive(e)||p.isNonPositive(i)||p.great(i,2*e))return null;const r=(s.x+t.x)/2,o=(s.y+t.y)/2,c=t.x-s.x,h=-(t.y-s.y)/i,l=c/i,u=Math.sqrt(Math.max(0,e*e-i*i/4)),d=n>=0?1:-1,g={x:r+h*u*d,y:o+l*u*d};return Lt(g,s,t,n<0)}class Ke{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class vn extends Ke{translate(t){return this.transform(new Mt().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class St extends vn{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,i=this.getPoint(0),r=0;n.push(0);for(let o=1;o<=t;o++)e=this.getPoint(o/t),r+=e.distanceTo(i),n.push(r),i=e;return n}getUtoTmapping(t,n){const e=this.getLengths();let i=0;const r=e.length;let o;n?o=n:o=t*e[r-1];let c=0,a=r-1,h;for(;c<=a;)if(i=Math.floor(c+(a-c)/2),h=e[i]-o,h<0)c=i+1;else if(h>0)a=i-1;else{a=i;break}if(i=a,e[i]===o)return i/(r-1);const l=e[i],d=e[i+1]-l,g=(o-l)/d;return(i+g)/(r-1)}getTangent(t){let e=t-1e-4,i=t+1e-4;e<0&&(e=0),i>1&&(i=1);const r=this.getPoint(e),o=this.getPoint(i),c=new _;return c.copy(o).sub(r).normalize(),c}getTangentAt(t){const n=this.getUtoTmapping(t);return this.getTangent(n)}}const X=class X extends St{constructor(t,n,e,i,r){super();const o=+(t!==void 0)+ +(n!==void 0)+ +(e!==void 0)+ +(i!==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 c=t;this.center=new _(c.x,c.y),this.radius=n,this._clockwise=r,this._startAngle=this._clockwise?this._mirrorAngle(M.normalizeAngle(e)):M.normalizeAngle(e),this._endAngle=this._clockwise?this._mirrorAngle(M.normalizeAngle(i)):M.normalizeAngle(i)}else throw j.AcCmErrors.ILLEGAL_PARAMETERS}static fromMathAngles(t,n,e,i,r){const o=new X(t,n,M.normalizeAngle(e),M.normalizeAngle(i),!1);return o._clockwise=r,o._boundingBoxNeedsUpdate=!0,o}static computeCircumcircle(t,n,e){return Nn(t,n,e)}static projectPoint(t,n,e){return Ue(t,n,e)}static pointLiesOnCircle(t,n,e,i){return De(t,n,e,i)}static sameCircle(t,n,e,i,r){return Xe(t,n,e,i,r)}static isBetterDistanceAlign(t,n,e,i){return Ze(t,n,e,i)}static tryCreateByThreePoints(t,n,e,i=!1){return Bn(t,n,e,i)}static tryCreateCircle(t,n){return Rn(t,n)}static tryCreateCircleByDiameter(t,n){return yi(t,n)}static tryCreateCircleByThreePoints(t,n,e){return xi(t,n,e)}static tryCreateShorterArc(t,n,e){return Ai(t,n,e)}static tryCreateByCenterStartEnd(t,n,e,i){return Lt(t,n,e,i)}static tryCreateByCenterStartProjectedEnd(t,n,e,i){return _i(t,n,e,i)}static tryCreateByCenterStartSweep(t,n,e){return Ye(t,n,e)}static tryCreateByCenterStartChord(t,n,e){return Pi(t,n,e)}static tryCreateByStartEndAngle(t,n,e){return wi(t,n,e)}static tryCreateByStartEndDirection(t,n,e){return Ge(t,n,e)}static tryCreateByStartEndRadius(t,n,e){return We(t,n,e)}createByThreePoints(t,n,e){const i=Bn(t,n,e);if(!i)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this.center=i.center,this.radius=i.radius,this._clockwise=i._clockwise,this._startAngle=i._startAngle,this._endAngle=i._endAngle,this._boundingBoxNeedsUpdate=!0}createByStartEndPointsAndBulge(t,n,e){let i,r,o;e<0?(i=Math.atan(-e)*4,r=new q(t),o=new q(n)):(i=Math.atan(e)*4,r=new q(n),o=new q(t));const c=new q().subVectors(o,r),a=c.length(),h=new q().addVectors(r,c.multiplyScalar(.5)),l=Math.abs(a/2/Math.tan(i/2)),u=c.normalize(),d=e<0?-Math.PI/2:Math.PI/2,g=new q(u.x*Math.cos(d)-u.y*Math.sin(d),u.y*Math.cos(d)+u.x*Math.sin(d));let m;i<Math.PI?e<0?m=h.add(g.multiplyScalar(l)):m=h.add(g.multiplyScalar(-l)):e<0?m=h.add(g.multiplyScalar(-l)):m=h.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 _(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(M.normalizeAngle(t)):M.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==C?t:M.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?M.normalizeAngle(t-n):M.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?M.normalizeAngle(t-this.deltaAngle/2):M.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);M.isBetweenAngle(o,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(r))}const e=t.map(r=>r.x),i=t.map(r=>r.y);return new tt(new _(Math.min(...e),Math.min(...i)),new _(Math.max(...e),Math.max(...i)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){const n=t,e=this.center.clone().applyMatrix2d(n),i=this.startPoint.clone().applyMatrix2d(n);if(this.closed)return this.center=e,this.radius=e.distanceTo(i),this._startAngle=Math.atan2(i.y-e.y,i.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),c=new X(i,r,o),a=n.determinant()<0?!this.clockwise:this.clockwise,h=l=>{const u=M.normalizeAngle(l);return a?this._mirrorAngle(u):u};return this.center=c.center,this.radius=c.radius,this.clockwise=a,this.startAngle=h(Math.atan2(i.y-c.center.y,i.x-c.center.x)),this.endAngle=h(Math.atan2(o.y-c.center.y,o.x-c.center.x)),this._boundingBoxNeedsUpdate=!0,this}clone(){return new X(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),i=this.center.y+this.radius*Math.sin(n);return new _(e,i)}getQuadrantPoints(){const t=[],n=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle),i=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const r of i){const o=this._getInternalAngle(r);M.isBetweenAngle(o,n,e,this.clockwise)&&t.push(this.getPointAtAngle(r))}return t}nearestPoint(t){const n=new _(t.x,t.y),e=n.x-this.center.x,i=n.y-this.center.y;if(Math.hypot(e,i)<1e-12)return this.startPoint.clone();const o=Math.atan2(i,e),c=this.clockwise?this._mirrorAngle(M.normalizeAngle(o)):M.normalizeAngle(o),a=this._getInternalAngle(c),h=this._getInternalAngle(this.startAngle),l=this._getInternalAngle(this.endAngle);if(M.isBetweenAngle(a,h,l,this.clockwise))return this.getPointAtAngle(c);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,i=n.y-t.y;if(e*e+i*i<1e-24)return 0;const r=this.radius>0?this.radius:1,o=Math.max(1e-16,1e-12*r*r),c=this.startPoint.distanceToSquared(t)<=o,a=this.endPoint.distanceToSquared(t)<=o;if(!c&&!a)return 0;const h=this.getPoints(8);if(h.length<3)return 0;const l=c&&!a?h[1]:h[h.length-2],u=l.x-t.x,d=l.y-t.y,g=Math.hypot(u,d);return g>1e-18?(e*u+i*d)/g:0}perpendicularPoints(t){const n=new _(t.x,t.y),e=n.x-this.center.x,i=n.y-this.center.y,r=Math.hypot(e,i);if(r<1e-12)return[];const o=e/r,c=i/r,a=[new _(this.center.x+o*this.radius,this.center.y+c*this.radius),new _(this.center.x-o*this.radius,this.center.y-c*this.radius)],h=[],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(M.normalizeAngle(g)):M.normalizeAngle(g),y=this._getInternalAngle(m);(this.closed||M.isBetweenAngle(y,l,u,this.clockwise))&&h.push(d)}return h}tangentPoints(t){const n=[],e=t.x-this.center.x,i=t.y-this.center.y,r=Math.hypot(e,i),o=this.radius;if(r<o)return n;const c=Math.acos(o/r),a=Math.atan2(i,e),h=[a+c,a-c],l=this._getInternalAngle(this.startAngle),u=this._getInternalAngle(this.endAngle);for(const d of h){const g=this.clockwise?this._mirrorAngle(M.normalizeAngle(d)):M.normalizeAngle(d),m=this._getInternalAngle(g);(this.closed||M.isBetweenAngle(m,l,u,this.clockwise))&&n.push(this.getPointAtAngle(g))}return n}getPoints(t=100){const n=[];let e=this.deltaAngle,i=this._getInternalAngle(this.startAngle);if(this.closed&&(e=C,i=0),this.clockwise)for(let r=0;r<=t;r++){const o=i-e*(r/t),c=this._clockwise?this._mirrorAngle(o):o,a=this.getPointAtAngle(c);n.push(new _(a.x,a.y))}else for(let r=0;r<=t;r++){const o=i+e*(r/t),c=this._clockwise?this._mirrorAngle(o):o,a=this.getPointAtAngle(c);n.push(new _(a.x,a.y))}return n}tessellate(t){const n=this.closed?C:this.deltaAngle,e=X.segmentCount(this.radius,n,{...t,minSegments:(t==null?void 0:t.minSegments)??(this.closed?8:3)});return this.getPoints(e)}static resolveCircleSides(t){return t==null||!Number.isFinite(t)?X.DEFAULT_CIRCLE_SIDES:J(Math.round(t),X.MIN_CIRCLE_SIDES,X.MAX_CIRCLE_SIDES)}static resolveTessellateOptions(t){const n=X.resolveCircleSides(t==null?void 0:t.circleSides),e=Math.max(1,Math.round((t==null?void 0:t.maxSegments)??n));return{deviation:t==null?void 0:t.deviation,circleSides:n,minSegments:t==null?void 0:t.minSegments,maxSegments:e}}static chordDeviationFromRadius(t,n=X.DEFAULT_CIRCLE_SIDES){const e=Math.abs(t),i=X.resolveCircleSides(n);return e<=S?S:Math.max(S,e*(1-Math.cos(Math.PI/i)))}static segmentCount(t,n,e){const i=X.resolveTessellateOptions(e),r=Math.abs(n),o=r>=C-1e-8,c=Math.max(1,Math.round(i.minSegments??(o?8:3))),a=Math.max(c,i.maxSegments),h=Math.abs(t);if(h<=S||r<=S)return c;const u=1-(i.deviation??X.chordDeviationFromRadius(h,i.circleSides))/h;if(!Number.isFinite(u)||u>=1)return a;if(u<=-1)return c;const d=2*Math.acos(u);return d<=S?a:J(Math.ceil(r/d),c,a)}};X.DEFAULT_CIRCLE_SIDES=100,X.MIN_CIRCLE_SIDES=8,X.MAX_CIRCLE_SIDES=2e4;let v=X;function pi(s){const t=Math.abs(s);if(t<.1){const n=t*t,e=1-n/20*(1-n/42*(1-n/72*(1-n/110))),i=t*n/6*e;return s<0?-i:i}return s-Math.sin(s)}function Mi(s,t){const n=s.length;if(!t||n<2)return 0;const e=s[0].x,i=s[0].y;let r=0;for(let o=0;o<n;++o){const c=s[o],a=s[(o+1)%n],h=c.x-e,l=c.y-i,u=a.x-e,d=a.y-i;r+=.5*(h*d-u*l);const g=c.bulge??0,m=u-h,y=d-l,f=m*m+y*y;if(g===0||!(f>0))continue;const x=4*Math.atan(g),w=Math.sin(x/2),k=f/(4*w*w);r+=.5*k*pi(x)}return Math.abs(r)}const Wt=1e-6;function Qe(s,t){if(Zi(s)){const r=bi(s,t);return r?[r]:[]}const n=es(s);if(n.numberOfVertices<2)return[];const i=Gi(n,t);return i?[i]:[]}function zi(s){return es(s)}function bi(s,t){const n=Si(s);if(n.length===0)return null;const e=[];for(const c of n){const a=Ti(c,t);if(!a)return null;e.push(a)}const i=Ci(s),r=Ni(e,i,s.closed,t);if(r.length<2)return null;const o=new mt;return r.forEach((c,a)=>{o.addVertexAt(a,{x:c.x,y:c.y})}),o.closed=s.closed,o}function Si(s){const t=[],n=s.numberOfVertices,e=s.closed?n:n-1;for(let i=0;i<e;i++){const r=s.vertices[i],o=s.vertices[(i+1)%n];p.isPositive(Math.abs(r.bulge??0))?t.push({kind:"arc",arc:new v(r,o,r.bulge)}):t.push({kind:"line",start:new _(r.x,r.y),end:new _(o.x,o.y)})}return t}function Ci(s){const t=[];for(let n=0;n<s.numberOfVertices;n++)t.push(s.getPointAt(n));return t}function Ti(s,t){if(s.kind==="line"){const e=Ii(s.start,s.end,t);return e?{kind:"line",...e}:null}const n=ki(s.arc,s.arc.startPoint,s.arc.endPoint,t);return n?{kind:"arc",arc:n}:null}function ki(s,t,n,e){const i=Ei(s,t,n,e),r=s.radius+i;return p.isNonPositive(r)?null:new v(s.center,r,s.startAngle,s.endAngle,s.clockwise)}function Ei(s,t,n,e){const i=n.x-t.x,r=n.y-t.y,o=Math.hypot(i,r);if(p.isNonPositive(o))return s.clockwise?-e:e;const c=-r/o,a=i/o,h=s.center.x-(t.x+n.x)/2,l=s.center.y-(t.y+n.y)/2;return h*c+l*a>0?-e:e}function Ii(s,t,n){const e=t.x-s.x,i=t.y-s.y,r=Math.hypot(e,i);if(p.isNonPositive(r))return null;const o=-i/r*n,c=e/r*n;return{start:new _(s.x+o,s.y+c),end:new _(t.x+o,t.y+c),dx:e,dy:i}}function Ni(s,t,n,e){var c;const i=s.length;if(i===0)return[];const r=Bi(s,t,n,e),o=[((c=r[0].nextSegmentStart)==null?void 0:c.clone())??r[0].point.clone()];for(let a=0;a<i;a++){const h=s[a],l=a===i-1&&!n?{point:Fi(h)}:r[(a+1)%i];if(a>0&&r[a].filletPoints&&r[a].filletPoints.forEach(u=>o.push(u.clone())),h.kind==="arc"){const u=r[a].nextSegmentStart??r[a].point,d=l.point,g=Ri(h.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 ss(o)}function Bi(s,t,n,e){const i=s.length,r=[];for(let o=0;o<i;o++)o===0?r.push(n?He(s[i-1],s[0],t[0],e):{point:Li(s[0])}):r.push(He(s[o-1],s[o],t[o],e));return r}function Ri(s,t,n,e){const i=s.nearestPoint(t),r=s.nearestPoint(n),o=qn(s,i),c=qn(s,r),a=qi(s,o,c),h=[];for(let l=0;l<=e;l++){const u=l/e,d=s.clockwise?o-a*u:o+a*u;h.push(s.getPointAtAngle(vi(s,d)))}return h}function qn(s,t){return Math.atan2(t.y-s.center.y,t.x-s.center.x)}function vi(s,t){const n=M.normalizeAngle(t);return s.clockwise?Ln(n):n}function Ln(s){return(360-s*180/Math.PI)%360*(Math.PI/180)}function qi(s,t,n){if(s.clockwise){let i=t-n;return p.isNonPositive(i)&&(i+=C),i}let e=n-t;return p.isNonPositive(e)&&(e+=C),e}function Li(s){return s.kind==="line"?s.start.clone():s.arc.startPoint.clone()}function Fi(s){return s.kind==="line"?s.end.clone():s.arc.endPoint.clone()}function He(s,t,n,e){return s.kind==="line"&&t.kind==="line"?{point:Fn({start:s.start,end:s.end,dx:s.dx,dy:s.dy},{start:t.start,end:t.end,dx:t.dx,dy:t.dy})}:s.kind==="line"&&t.kind==="arc"?$e(s,t.arc,n,e,!0):s.kind==="arc"&&t.kind==="line"?$e(t,s.arc,n,e,!1):s.kind==="arc"&&t.kind==="arc"?Vi(s.arc,t.arc,n,e):{point:n.clone()}}function Vi(s,t,n,e){const i=ns(s.endPoint,t.startPoint),o=Xi(s,t).filter(l=>Kt(s,l)&&Kt(t,l));if(o.length>0)return{point:ts(o,i)};const c=s.endPoint.clone(),a=t.startPoint.clone(),h=Je(n,Math.abs(e),c,a);return{point:c,filletPoints:h,nextSegmentStart:a}}function $e(s,t,n,e,i){const r=ns(i?s.end:s.start,i?t.startPoint:t.endPoint),o=Di(s,t,r);if(Oi(s,o)&&Kt(t,o))return{point:o};const c=ji(s,n,e),a=i?t.startPoint.clone():t.endPoint.clone(),h=Je(n,Math.abs(e),i?c:a,i?a:c);return i?{point:c,filletPoints:h,nextSegmentStart:a}:{point:a,filletPoints:h,nextSegmentStart:c}}function ji(s,t,n){const e=Math.hypot(s.dx,s.dy),i=-s.dy/e*n,r=s.dx/e*n;return new _(t.x+i,t.y+r)}function Oi(s,t){const n=Math.hypot(s.dx,s.dy);if(p.isNonPositive(n))return!1;const e=s.dx/n,i=s.dy/n,r=t.x-s.start.x,o=t.y-s.start.y,c=Math.abs(r*i-o*e);return p.equalToZero(c)}function Je(s,t,n,e){const i=Math.atan2(n.y-s.y,n.x-s.x),r=Math.atan2(e.y-s.y,e.x-s.x),o=Ui(i,r);if(p.equalToZero(Math.abs(o)))return[];const c=[],a=Math.max(2,Math.ceil(Math.abs(o)/Math.PI*16));for(let h=1;h<a;h++){const l=h/a,u=i+o*l;c.push(new _(s.x+t*Math.cos(u),s.y+t*Math.sin(u)))}return c}function Ui(s,t){let n=t-s;for(;n>Math.PI;)n-=C;for(;n<=-Math.PI;)n+=C;return n}function Di(s,t,n){const e=Math.hypot(s.dx,s.dy);if(p.isNonPositive(e))return n.clone();const i=s.dx/e,r=s.dy/e,o=s.start.x-t.center.x,c=s.start.y-t.center.y,a=2*(o*i+c*r),h=o*o+c*c-t.radius*t.radius,l=a*a-4*h;if(l<0)return n.clone();const u=Math.sqrt(l),d=[(-a-u)/2,(-a+u)/2].map(m=>new _(s.start.x+i*m,s.start.y+r*m)),g=d.filter(m=>Kt(t,m));return ts(g.length>0?g:d,n)}function Kt(s,t){const n=Math.abs(Math.hypot(t.x-s.center.x,t.y-s.center.y)-s.radius);if(p.isPositive(n))return!1;const e=qn(s,t),i=s.clockwise?Ln(M.normalizeAngle(s.startAngle)):M.normalizeAngle(s.startAngle),r=s.clockwise?Ln(M.normalizeAngle(s.endAngle)):M.normalizeAngle(s.endAngle);return M.isBetweenAngle(e,i,r,s.clockwise)}function Xi(s,t){const n=t.center.x-s.center.x,e=t.center.y-s.center.y,i=Math.hypot(n,e);if(p.isNonPositive(i))return[];const r=s.radius+t.radius,o=Math.abs(s.radius-t.radius);if(i>r+Wt)return[];if(i<o-Wt)return[];const c=(s.radius*s.radius-t.radius*t.radius+i*i)/(2*i),a=s.radius*s.radius-c*c;if(a<-Wt)return[];const h=s.center.x+c*n/i,l=s.center.y+c*e/i;if(a<=Wt)return[new _(h,l)];const u=Math.sqrt(a),d=-e*u/i,g=n*u/i;return[new _(h+d,l+g),new _(h-d,l-g)]}function ts(s,t){let n=s[0],e=n.distanceToSquared(t);for(let i=1;i<s.length;i++){const r=s[i].distanceToSquared(t);r<e&&(n=s[i],e=r)}return n.clone()}function ns(s,t){return new _((s.x+t.x)/2,(s.y+t.y)/2)}function Zi(s){const t=s.numberOfVertices,n=s.closed?t:t-1;for(let e=0;e<n;e++){const i=s.vertices[e];if(p.isPositive(Math.abs(i.bulge??0)))return!0}return!1}function es(s){const t=Yi(s.vertices.map(n=>new _(n.x,n.y)),s.closed);return t.length===s.numberOfVertices?s:new mt(t.map(n=>({x:n.x,y:n.y})),s.closed)}function Yi(s,t){const n=ss(s);if(!t||n.length<2)return n;const e=n[0],i=n[n.length-1];return p.isNonPositive(Math.hypot(e.x-i.x,e.y-i.y))&&n.pop(),n}function ss(s){const t=[];return s.forEach(n=>{const e=t[t.length-1];(!e||p.isPositive(Math.hypot(e.x-n.x,e.y-n.y)))&&t.push(new _(n.x,n.y))}),t}function Gi(s,t){const n=[];for(let o=0;o<s.numberOfVertices;o++)n.push(s.getPointAt(o));const e=Wi(n,s.closed,t);if(e.length===0)return null;const i=[];if(s.closed){if(e.length<2)return null;const o=e.length;for(let c=0;c<o;c++){const a=e[(c-1+o)%o],h=e[c];i.push(Fn(a,h))}}else{i.push(e[0].start);for(let o=1;o<e.length;o++)i.push(Fn(e[o-1],e[o]));i.push(e[e.length-1].end)}const r=new mt;return i.forEach((o,c)=>{r.addVertexAt(c,{x:o.x,y:o.y})}),r.closed=s.closed,r}function Wi(s,t,n){const e=[],i=t?s.length:s.length-1;for(let r=0;r<i;r++){const o=s[r],c=s[t?(r+1)%s.length:r+1],a=c.x-o.x,h=c.y-o.y,l=Math.hypot(a,h);if(p.isNonPositive(l))continue;const u=-h/l*n,d=a/l*n;e.push({start:new _(o.x+u,o.y+d),end:new _(c.x+u,c.y+d),dx:a,dy:h})}return e}function Fn(s,t){const n=s.dx*t.dy-s.dy*t.dx;if(p.equalToZero(n))return new _((s.end.x+t.start.x)/2,(s.end.y+t.start.y)/2);const e=t.start.x-s.start.x,i=t.start.y-s.start.y,r=(e*t.dy-i*t.dx)/n;return new _(s.start.x+r*s.dx,s.start.y+r*s.dy)}class mt extends St{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 _(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 _(n.x,n.y)}else{const n=this._vertices[t-1];return new _(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 i=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(i.bulge){const o=new v(i,r,i.bulge);t+=o.length}else t+=new _(i.x,i.y).distanceTo(r)}return t}get area(){return Mi(this._vertices,this._closed)}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 _(n.x,n.y)}calculateBoundingBox(){const t=this.getPoints(100);return new tt().setFromPoints(t)}transform(t){const n=t.determinant()<0;return this._vertices.forEach(e=>{const i=new _(e).applyMatrix2d(t);e.x=i.x,e.y=i.y,n&&e.bulge!=null&&(e.bulge=-e.bulge)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new mt(this._vertices.map(t=>({...t})),this._closed)}getPoints3d(t,n){const e=[];return this.getPoints(t).forEach(r=>e.push(new z().set(r.x,r.y,n))),e}getPoints(t){const n=[],e=this._vertices.length;for(let i=0;i<e;++i){const r=this._vertices[i];if(r.bulge){let o=null;if(i<e-1?o=this._vertices[i+1]:i==e-1&&this.closed&&(o=this._vertices[0]),o){const a=new v(r,o,r.bulge).getPoints(t),h=a.length;for(let l=0;l<h;++l){const u=a[l];n.push(new _(u.x,u.y))}}}else n.push(new _(r.x,r.y)),i==e-1&&this.closed&&n.push(n[0])}return n}tessellate(t){const n=[],e=this._vertices.length;for(let i=0;i<e;++i){const r=this._vertices[i];if(r.bulge){let o=null;if(i<e-1?o=this._vertices[i+1]:i===e-1&&this.closed&&(o=this._vertices[0]),o){const a=new v(r,o,r.bulge).tessellate(t);for(let h=0;h<a.length;++h)is(n,a[h])}}else is(n,r),i===e-1&&this.closed&&n.length>0&&n.push(n[0].clone())}return n}offset(t){return Qe(this,t)}}function is(s,t){const n=s[s.length-1];if(n){const e=n.x-t.x,i=n.y-t.y;if(e*e+i*i<=S*S)return}s.push(new _(t.x,t.y))}function Ki(s,t,n){const e=Math.hypot(t.x,t.y);if(p.isNonPositive(e))return null;const i=-t.y/e*n,r=t.x/e*n;return new z(s.x+i,s.y+r,s.z)}function Qi(s,t,n){if(s.length<2)return null;const e=zi(new mt(s.map(r=>({x:r.x,y:r.y})),t));return Qe(e,n)[0]??null}function Hi(s,t,n,e){if(s.length<2||p.equalToZero(n))return null;const{points:i,tangents:r}=os(s,e);if(i.length<2)return null;const o=r??$i(i,t),c=Ji(i,o,n),a=t?nr(c):tr(c);if(a.length<2)return null;const h=new mt;return a.forEach((l,u)=>{h.addVertexAt(u,{x:l.x,y:l.y})}),h.closed=t,h}function $i(s,t){const n=s.length,e=new Array(n);for(let i=0;i<n;i++){let r=0,o=0;if(t){const a=s[(i-1+n)%n],h=s[(i+1)%n];r=h.x-a.x,o=h.y-a.y}else i===0?(r=s[1].x-s[0].x,o=s[1].y-s[0].y):i===n-1?(r=s[n-1].x-s[n-2].x,o=s[n-1].y-s[n-2].y):(r=s[i+1].x-s[i-1].x,o=s[i+1].y-s[i-1].y);const c=Math.hypot(r,o);p.isNonPositive(c)?e[i]=new _(1,0):e[i]=new _(r/c,o/c)}return e}function Ji(s,t,n){return s.map((e,i)=>{const r=t[i],o=-r.y*n,c=r.x*n;return new _(e.x+o,e.y+c)})}function tr(s){let t=Qt(s);if(t.length<3)return t;for(;;){const n=rs(t,!1);if(!n||(t=Qt([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<2))break}return t}function nr(s){let t=Qt(s);if(t.length<4)return t;for(;;){const n=rs(t,!0);if(!n||(t=Qt([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<3))break}return t}function rs(s,t){const n=t?s.length:s.length-1;if(n<2)return null;for(let e=0;e<n;e++){const i=s[e],r=s[(e+1)%s.length];for(let o=e+1;o<n;o++){if(er(e,o,n,t))continue;const c=s[o],a=s[(o+1)%s.length],h=sr(i,r,c,a);if(h)return{point:h,segmentA:e,segmentB:o}}}return null}function er(s,t,n,e){return!!(t===s||t===s+1||e&&s===0&&t===n-1)}function sr(s,t,n,e){const i=t.x-s.x,r=t.y-s.y,o=e.x-n.x,c=e.y-n.y,a=i*c-r*o;if(p.equalToZero(a))return null;const h=n.x-s.x,l=n.y-s.y,u=(h*c-l*o)/a,d=(h*r-l*i)/a,g=yt.equalPointTol;return u<-g||u>1+g||d<-g||d>1+g?null:new _(s.x+u*i,s.y+u*r)}function os(s,t){const n=[],e=[],i=t!=null&&t.length===s.length;return s.forEach((r,o)=>{const c=n[n.length-1];if((!c||p.isPositive(Math.hypot(c.x-r.x,c.y-r.y)))&&(n.push(new _(r.x,r.y)),i)){const a=t[o];e.push(new _(a.x,a.y))}}),{points:n,tangents:i?e:void 0}}function Qt(s){return os(s).points}class Vn extends vn{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}clear(){this._loops.length=0,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 tt}transform(t){return this._loops.forEach(n=>{n.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){const t=new Vn;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}tessellate(t){return this.loops.map(n=>n.tessellate(t))}buildHierarchy(t){var a;const n=this.tessellate(t),e=this.calculateBoundaryBoxes(n),i=this.sortBoundaryBoxesByAreas(e),r=new Map,o=i.length;for(let h=0;h<o;h++)r.set(i[h],{index:i[h],children:[]});const c={index:-1,children:[]};for(let h=0;h<o;h++){const l=i[h],u=n[l],d=e[l];let g=h+1;for(;g<o;g++){const m=i[g],y=n[m],f=e[m];if(f.containsBox(d)&&ir(u,y,f)){(a=r.get(m))==null||a.children.push(r.get(l));break}}g===o&&c.children.push(r.get(l))}return c}get area(){if(this._loops.length===0)return 0;let t=0;for(let n=0;n<this._loops.length;n++){const i=this._loops[n].getPoints(128),r=zn(i);n===0?t+=Math.abs(r):t-=Math.abs(r)}return t}calculateBoundaryBoxes(t){const n=[];return t.forEach(e=>{n.push(new tt().setFromPoints(e))}),n}sortBoundaryBoxesByAreas(t){const n=[];t.forEach((i,r)=>{const o=i.size,c=o.width*o.height;n.push({area:c,index:r})}),n.sort((i,r)=>i.area-r.area);const e=[];return n.forEach(i=>{e.push(i.index)}),e}}function ir(s,t,n){const e=n.size,i=Math.max(Math.max(e.width,e.height)*1e-9,S);for(const r of s)if(rr(r,t)>i)return Y.isPointInPolygon(r,t);return!1}function rr(s,t){let n=1/0;for(let e=0,i=t.length-1;e<t.length;i=e++){const r=t[i],o=t[e],c=o.x-r.x,a=o.y-r.y,h=c*c+a*a;let l=h>0?((s.x-r.x)*c+(s.y-r.y)*a)/h:0;l=Math.max(0,Math.min(1,l)),n=Math.min(n,Math.hypot(s.x-(r.x+c*l),s.y-(r.y+a*l)))}return n}class or extends Ke{translate(t){return this.transform(new O().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 xt extends or{static tessellateParametricCurve(t,n,e,i){const r=Math.max(2,Math.round(i.maxSegments)),o=Math.max(1,Math.round(i.minSegments)),c=Math.max(0,i.deviation)*Math.max(0,i.deviation);if(!Number.isFinite(t)||!Number.isFinite(n))return[e(0)];if(Math.abs(n-t)<=S)return[e(t)];const a=Math.min(r,Math.max(2,o+1)),h=Math.min(r,Math.max(a,8));let l=ar(t,n,h);const u=[];for(let g=0;g<l.length;g++)u.push(e(l[g]));let d=u.length;for(let g=0;g<8&&d<r;g++){const m=[];for(let f=0;f<l.length-1&&!(d>=r);f++){const x=(l[f]+l[f+1])/2,w=e(x);d++,cr(w,u[f],u[f+1])>c&&m.push({index:f,t:x,point:w})}if(m.length===0)break;const y=hr(l,u,m);l=y.params,u.length=0;for(let f=0;f<y.points.length;f++)u.push(y.points[f])}return u}}function cr(s,t,n){const e=n.x-t.x,i=n.y-t.y,r=n.z-t.z,o=s.x-t.x,c=s.y-t.y,a=s.z-t.z,h=e*e+i*i+r*r;if(h<=S*S)return o*o+c*c+a*a;const l=J((o*e+c*i+a*r)/h,0,1),u=o-e*l,d=c-i*l,g=a-r*l;return u*u+d*d+g*g}function ar(s,t,n){if(n<=1)return[s];const e=[];for(let i=0;i<n;i++)e.push(i===n-1?t:s+(t-s)*i/(n-1));return e}function hr(s,t,n){const e=[],i=[];let r=0;for(let o=0;o<s.length;o++)for(e.push(s[o]),i.push(t[o]);r<n.length&&n[r].index===o;)e.push(n[r].t),i.push(n[r].point),r++;return{params:e,points:i}}class et extends xt{static computeCenterPoint(t,n,e){var i;return((i=Oe(t,e,n))==null?void 0:i.center)??null}static tryCreateByThreePoints(t,n,e){const i=Oe(t,e,n);if(!i)return null;const{center:r,radius:o}=i,c=new P(t.x-r.x,t.y-r.y,(t.z??0)-r.z),a=new P(e.x-r.x,e.y-r.y,(e.z??0)-r.z),h=new P(n.x-r.x,n.y-r.y,(n.z??0)-r.z);if(c.lengthSq()===0||h.lengthSq()===0)return null;const l=new P().crossVectors(c,h);if(l.lengthSq()===0&&(l.crossVectors(c,a),l.lengthSq()===0))return null;l.normalize();const u=c.clone().normalize(),d=new P().crossVectors(l,u),g=y=>M.normalizeAngle(Math.atan2(y.dot(d),y.dot(u)));M.isAngleOnCcwSweep(0,g(a),g(h))||(l.negate(),d.negate());let m=g(h);return p.equalToZero(m)&&(m=C),new et(r,o,0,m,l,u)}static createByThreePoints(t,n,e){return et.tryCreateByThreePoints(t,n,e)}constructor(t,n,e,i,r,o=P.X_AXIS){super(),this.center=t,this.radius=n,this.startAngle=e,this.endAngle=i,this.normal=r,this.refVec=o,(i-e)%C==0?(this.startAngle=0,this.endAngle=C):(this.startAngle=e,this.endAngle=i)}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 j.AcCmErrors.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=M.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==C?t:M.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return M.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 P(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new P(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=C);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 P(t.x,t.y,t.z||0),e=this.center,i=this.normal,o=n.clone().sub(e).dot(i),a=n.clone().sub(i.clone().multiplyScalar(o)).clone().sub(e);if(a.lengthSq()===0)return this.startPoint.clone();a.normalize().multiplyScalar(this.radius);const h=e.clone().add(a),l=this.getAngle(h.clone()),u=this.startAngle,d=this.deltaAngle;let g=M.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 P(t.x,t.y,t.z||0),i=this.center,r=this.normal,o=this.radius,a=e.clone().sub(i).dot(r),h=e.clone().sub(r.clone().multiplyScalar(a)),l=i.clone(),d=h.clone().sub(l).length();if(d<o)return n;const g=Math.acos(o/d),m=this.getAngle(h.clone()),y=[m+g,m-g];for(const f of y){const x=M.normalizeAngle(f-this.startAngle);x>=0&&x<=this.deltaAngle&&n.push(this.getPointAtAngle(this.startAngle+x))}return n}perpendicularPoints(t){const n=[],e=new P(t.x,t.y,t.z||0),i=this.center,r=this.normal,o=this.radius,a=e.clone().sub(i).dot(r),l=e.clone().sub(r.clone().multiplyScalar(a)).clone().sub(i);if(l.lengthSq()<1e-24)return n;l.normalize();const u=[i.clone().add(l.clone().multiplyScalar(o)),i.clone().sub(l.clone().multiplyScalar(o))];for(const d of u){const g=this.getAngle(d.clone()),m=M.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)M.isBetweenAngle(a,this.startAngle,this.endAngle)&&t.push(a);let n=1/0,e=1/0,i=1/0,r=-1/0,o=-1/0,c=-1/0;for(const a of t){const h=this.getPointAtAngle(a);h.x<n&&(n=h.x),h.y<e&&(e=h.y),h.z<i&&(i=h.z),h.x>r&&(r=h.x),h.y>o&&(o=h.y),h.z>c&&(c=h.z)}return new rt({x:n,y:e,z:i},{x:r,y:o,z:c})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const n=[];let e=this.deltaAngle,i=this.startAngle;this.closed&&(e=C,i=0);for(let r=0;r<=t;r++){const o=i+e*(r/t),c=this.getPointAtAngle(o);n.push(c)}return n}tessellate(t){const n=this.closed?C:this.deltaAngle,e=et.segmentCount(this.radius,n,{...t,minSegments:(t==null?void 0:t.minSegments)??(this.closed?8:3)});return this.getPoints(e)}static segmentCount(t,n,e){return v.segmentCount(t,n,e)}transform(t){const n=this.center.clone().applyMatrix4(t),e=this.startPoint.clone().applyMatrix4(t),i=this.endPoint.clone().applyMatrix4(t),r=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(t),o=new P(e).sub(n).normalize(),c=n.distanceTo(e);let a=new P().crossVectors(new P(e).sub(n),new P(r).sub(n)).normalize();a.lengthSq()===0&&(a=this.normal.clone().transformDirection(t));const h=l=>{const u=new P(l).sub(n);return Math.atan2(u.dot(cs.crossVectors(a,o)),u.dot(o))};return this.center=n,this.radius=c,this.normal=a,this.refVec=o,this.startAngle=0,this.endAngle=this.closed?C:h(i),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 et(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(cs.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const n=this.normal,e=this.refVec,i={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 z(r.x+o*(e.x*Math.cos(t)+i.x*Math.sin(t)),r.y+o*(e.y*Math.cos(t)+i.y*Math.sin(t)),r.z+o*(e.z*Math.cos(t)+i.z*Math.sin(t)))}get plane(){const t=new P(this.center).distanceTo(Pn);return new bt(this.normal,t)}offset(t){const n=this.radius+t;return n<=0?null:new et(this.center,n,this.startAngle,this.endAngle,this.normal,this.refVec)}}const cs=new P;function Ht(s){const t=s.clockwise?-s.deltaAngle:s.deltaAngle;if(!Number.isFinite(t)||p.equalToZero(t)||!p.great(C-Math.abs(t),0))return;const n=Math.tan(t/4);return Number.isFinite(n)?n:void 0}function lr(s){if(p.equalToZero(s))return s;const t=4*Math.atan(s),n=C-Math.abs(t);return p.equalToZero(n)?s:-Math.sign(s)*Math.tan(n/4)}function jn(s,t,n){const e=t.x-s.x,i=t.y-s.y,r=Math.hypot(e,i);if(p.isNonPositive(r)||p.equalToZero(n))return;const o=(s.x+t.x)/2,c=(s.y+t.y)/2,a=r/2*((1-n*n)/(2*n));return new _(o-i/r*a,c+e/r*a)}function On(s,t,n){const e=s.x-t.x,i=s.y-t.y;return n?Math.atan2(e,-i):Math.atan2(-e,i)}function ur(s,t,n){const e=jn(s,t,n);if(e)return On(s,e,n>=0)}function dr(s,t,n){const e=jn(s,t,n);if(e)return On(t,e,n>=0)}function gr(s,t,n){const e=s.x-n.x,i=s.y-n.y,r=t.x-n.x,o=t.y-n.y,c=e*o-i*r,a=e*r+i*o,h=Math.atan2(c,a);if(Number.isFinite(h))return Math.tan(h/4)}function mr(s,t,n,e){const i=s.x-n.x,r=s.y-n.y,o=t.x-n.x,c=t.y-n.y,a=Math.cos(e),h=Math.sin(e),l=t.x-s.x,u=t.y-s.y,d=i*h-r*a;let g;p.isPositive(Math.abs(d))?g=d>0:g=l*h-u*a>=0;const m=Math.atan2(r,i),y=Math.atan2(c,o);let f;if(g?(f=y-m,p.isNonPositive(f)&&(f+=Math.PI*2)):(f=m-y,p.isNonPositive(f)&&(f+=Math.PI*2)),!!p.great(C-f,0))return g?Math.tan(f/4):-Math.tan(f/4)}function fr(s,t,n){const e=Ge(s,t,n);if(e)return Ht(e)}function yr(s,t,n,e=!1){const i=Bn(s,t,n,e);if(i)return Ht(i)}function xr(s,t,n){const e=We(s,t,n);if(e)return Ht(e)}class At extends St{constructor(t,n,e,i=0,r=C,o=!1,c=0){super(),this.center=t,this.majorAxisRadius=n,this.minorAxisRadius=e,(r-i)%C==0?(this.startAngle=0,this.endAngle=C):(this.startAngle=i,this.endAngle=r),this.clockwise=o,this.rotation=c}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 j.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=M.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==C?t:M.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 M.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let n=1/0,e=1/0,i=-1/0,r=-1/0;for(let o=0;o<=100;o++){const c=this.getPoint(o/100);n=Math.min(n,c.x),e=Math.min(e,c.y),i=Math.max(i,c.x),r=Math.max(r,c.y)}return new tt({x:n,y:e},{x:i,y:r})}get closed(){return this.deltaAngle==0}getPoint(t){const n=Math.PI*2;let e=this.endAngle-this.startAngle;const i=Math.abs(e)<Number.EPSILON;for(;e<0;)e+=n;for(;e>n;)e-=n;e<Number.EPSILON&&(i?e=0:e=n),this.clockwise===!0&&!i&&(e===n?e=-n:e=e-n);const r=this.startAngle+t*e;let o=this.center.x+this.majorAxisRadius*Math.cos(r),c=this.center.y+this.minorAxisRadius*Math.sin(r);if(this.rotation!==0){const a=Math.cos(this.rotation),h=Math.sin(this.rotation),l=o-this.center.x,u=c-this.center.y;o=l*a-u*h+this.center.x,c=l*h+u*a+this.center.y}return new _(o,c)}transform(t){const n=t,e=new _(this.center).applyMatrix2d(n),i=new z(e.x,e.y,this.center.z),r=this.getPointAtAngle(0).clone().applyMatrix2d(n),o=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(n),c=new _(r).sub(e),a=new _(o).sub(e),h=c.length(),l=a.length(),u=Math.atan2(c.y,c.x),d=c.clone().normalize(),g=a.clone().normalize(),m=x=>{const w=new _(x).sub(e),k=w.dot(d),E=w.dot(g);return M.normalizeAngle(Math.atan2(E/l,k/h))},y=n.determinant()<0?!this.clockwise:this.clockwise,f=this.closed?new At(i,h,l,0,C,y,u):new At(i,h,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/C:M.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 At(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),i=Math.cos(this.rotation),r=Math.sin(this.rotation),o=this.majorAxisRadius>=this.minorAxisRadius,c=o?i:-r,a=o?r:i;return[new _(this.center.x-e*c,this.center.y-e*a),new _(this.center.x+e*c,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 _(t.x,t.y);let e=this.getPoint(0),i=n.distanceToSquared(e);const r=72;for(let o=1;o<=r;o++){const c=this.getPoint(o/r),a=n.distanceToSquared(c);a<i&&(i=a,e=c)}return e}tangentPoints(t){const n=this._projectPointToLocal(t);return this._findSnapAngles(n,(i,r,o,c)=>{const a=-this.majorAxisRadius*c,h=this.minorAxisRadius*o;return(i-n.x)*h-(r-n.y)*a}).map(i=>this.getPointAtAngle(i))}perpendicularPoints(t){const n=this._projectPointToLocal(t);return this._findSnapAngles(n,(i,r,o,c)=>{const a=this.minorAxisRadius*o,h=this.majorAxisRadius*c;return(i-n.x)*h-(r-n.y)*a}).map(i=>this.getPointAtAngle(i))}_projectPointToLocal(t){const n=t.x-this.center.x,e=t.y-this.center.y,i=Math.cos(-this.rotation),r=Math.sin(-this.rotation);return{x:n*i-e*r,y:n*r+e*i}}_findSnapAngles(t,n,e=144){const i=this.majorAxisRadius,r=this.minorAxisRadius,o=this.startAngle,c=this.deltaAngle,a=[],h=d=>{const g=Math.cos(d),m=Math.sin(d);return n(i*g,r*m,g,m)};let l=o,u=h(l);for(let d=1;d<=e;d++){const g=o+c*d/e,m=h(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 w=(y+f)/2;h(y)*h(w)<=0?f=w:y=w}a.push((y+f)/2)}l=g,u=m}return a}}class ot extends xt{constructor(t,n,e,i,r,o=0,c=C){super(),this.center=t,this.normal=n,this.majorAxis=e,this.majorAxisRadius=i,this.minorAxisRadius=r;const a=Math.abs(c-o);Math.abs(a-C)<1e-10||Math.abs(a-2*C)<1e-10?(this.startAngle=0,this.endAngle=C):(this.startAngle=o,this.endAngle=c)}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 j.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=M.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==C?t:M.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-C)<1e-10?C:M.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 P(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new P(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new P().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-C)<1e-10)&&(t=0,n=C);const e=t+n/2;return this.getPointAtAngle(e)}get isCircular(){return p.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,i=this.getPointAtAngle(this.startAngle);for(let r=1;r<=t;r++){const o=this.startAngle+r*n,c=this.getPointAtAngle(o),a=c.x-i.x,h=c.y-i.y,l=c.z-i.z;e+=Math.sqrt(a*a+h*h+l*l),i=c}return e}get area(){return Math.abs(this.deltaAngle-C)>=1e-10?0:Math.PI*this.majorAxisRadius*this.minorAxisRadius}calculateBoundingBox(){const t=this.closed||Math.abs(this.deltaAngle-C)<1e-10,n=this.majorAxisRadius,e=this.minorAxisRadius,i=this.majorAxis,r=this.minorAxis,o=t?[]:[this.startAngle,this.endAngle];for(const[a,h]of[[i.x,r.x],[i.y,r.y],[i.z,r.z]]){const l=Math.atan2(e*h,n*a);for(const u of[l,l+Math.PI])(t||M.isAngleOnCcwSweep(this.startAngle,u,this.endAngle))&&o.push(u)}o.length===0&&o.push(this.startAngle);const c=new rt;for(const a of o)c.expandByPoint(this.getPointAtAngle(a));return c}get closed(){return this.deltaAngle==0}getPoints(t=100){const n=[];let e=this.deltaAngle,i=this.startAngle;this.closed&&(e=C,i=0);for(let r=0;r<=t;r++){const o=i+e*(r/t),c=this.getPointAtAngle(o);n.push(c)}return n}tessellate(t){const n=v.resolveTessellateOptions(t),e=this.closed?C:this.deltaAngle,i=Math.max(this.majorAxisRadius,this.minorAxisRadius),r=Math.abs(e)>=C-1e-8,o=n.minSegments??(r?8:3);if(this.isCircular){const h=et.segmentCount(i,e,{...t,minSegments:o});return this.getPoints(h)}const c=n.deviation??v.chordDeviationFromRadius(i,n.circleSides),a=this.closed?0:this.startAngle;return xt.tessellateParametricCurve(a,a+e,h=>this.getPointAtAngle(h),{deviation:Math.max(S,c),minSegments:o,maxSegments:n.maxSegments})}getPointAtAngle(t){const n=Math.cos(t),e=Math.sin(t),i=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(e),r=this.majorAxis.clone().multiplyScalar(n*this.majorAxisRadius).add(i);return new z(this.center.x+r.x,this.center.y+r.y,this.center.z+r.z)}nearestPoint(t,n=72){const e=new z(t.x,t.y,t.z||0);let i=this.getPointAtAngle(this.startAngle),r=e.distanceToSquared(i);for(let a=1;a<=n;a++){const h=this.startAngle+this.deltaAngle*a/n,l=this.getPointAtAngle(h),u=e.distanceToSquared(l);u<r&&(r=u,i=l)}const o=e.distanceToSquared(this.startPoint),c=e.distanceToSquared(this.endPoint);return o<r&&o<=c?this.startPoint.clone():c<r&&c<o?this.endPoint.clone():i.clone()}tangentPoints(t){const n=this._projectPointToLocalPlane(t);return this._findSnapParameterAngles((i,r,o,c)=>{const a=-this.majorAxisRadius*c,h=this.minorAxisRadius*o;return(i-n.x)*h-(r-n.y)*a}).map(i=>this.getPointAtAngle(i))}perpendicularPoints(t){const n=this._projectPointToLocalPlane(t);return this._findSnapParameterAngles((i,r,o,c)=>{const a=this.minorAxisRadius*o,h=this.majorAxisRadius*c;return(i-n.x)*h-(r-n.y)*a}).map(i=>this.getPointAtAngle(i))}_projectPointToLocalPlane(t){const n=new z(t.x,t.y,t.z||0),e=new P(n).sub(this.center),i=e.dot(this.normal);return e.sub(this.normal.clone().multiplyScalar(i)),{x:e.dot(this.majorAxis),y:e.dot(this.minorAxis)}}_findSnapParameterAngles(t,n=144){const e=this.majorAxisRadius,i=this.minorAxisRadius,r=this.startAngle,o=this.deltaAngle,c=[],a=u=>{const d=Math.cos(u),g=Math.sin(u);return t(e*d,i*g,d,g)};let h=r,l=a(h);for(let u=1;u<=n;u++){const d=r+o*u/n,g=a(d);if(Math.abs(l)<1e-10&&c.push(h),l*g<0){let m=h,y=d;for(let f=0;f<32;f++){const x=(m+y)/2;a(m)*a(x)<=0?y=x:m=x}c.push((m+y)/2)}h=d,l=g}return c}contains(t){const n=new P(t).sub(this.center),e=n.dot(this.majorAxis),i=n.dot(this.minorAxis),r=e/this.majorAxisRadius,o=i/this.minorAxisRadius;return r*r+o*o<=1}transform(t){const n=t,e=this.center.clone().applyMatrix4(n),i=this.getPointAtAngle(0).clone().applyMatrix4(n),r=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(n),o=new P(i).sub(e),c=new P(r).sub(e),a=o.length(),h=c.length(),l=o.clone().normalize(),u=new P().crossVectors(o,c).normalize();let d=new P().crossVectors(u,l).normalize();d.dot(c)<0&&(u.negate(),d=new P().crossVectors(u,l).normalize());const g=y=>{const f=new P(y).sub(e),x=f.dot(l),w=f.dot(d);return M.normalizeAngle(Math.atan2(w/h,x/a))},m=this.closed?new ot(e,u,l,a,h,0,C):new ot(e,u,l,a,h,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 ot(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new P(this.center).distanceTo(Pn);return new bt(this.normal,t)}offset(t){const n=this.majorAxisRadius+t,e=this.minorAxisRadius+t;return n<=0||e<=0?null:new ot(this.center,this.normal,this.majorAxis,n,e,this.startAngle,this.endAngle)}}class Ct extends St{constructor(t,n){super(),this._start=new _(t),this._end=new _(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 _(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),n=new _(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new tt(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 Ct(this._start.clone(),this._end.clone())}project(t){const n=this._end.x-this._start.x,e=this._end.y-this._start.y,i=n*n+e*e;if(i<1e-18)return this._start.clone();let r=((t.x-this._start.x)*n+(t.y-this._start.y)*e)/i;return r=Math.max(0,Math.min(1,r)),new _(this._start.x+r*n,this._start.y+r*e)}nearestPoint(t){return this.project(t)}}class $t extends xt{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 P().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(_t).normalize();return new z(this._start).addScaledVector(e,t)}else{const e=this.delta(_t).normalize();return new z(this._end).addScaledVector(e,t)}}extend(t,n=!1){if(n){const e=_t.subVectors(this._start,this._end).normalize();this._start=new z(this._start).addScaledVector(e,t)}else{const e=this.delta(_t).normalize();this._end=new z(this._end).addScaledVector(e,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,n){as.subVectors(t,this._start),Jt.subVectors(this.endPoint,this.startPoint);const e=Jt.dot(Jt);let r=Jt.dot(as)/e;return n&&(r=M.clamp(r,0,1)),r}closestPointToPoint(t,n,e){const i=this.closestPointToPointParameter(t,n);return this.delta(e).multiplyScalar(i).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,i=_t.subVectors(t,this.startPoint).dot(n);return new z().copy(n).multiplyScalar(i).add(this.startPoint)}perpPoint(t){const n=this.direction,e=this.startPoint,r=_t.subVectors(t,e).dot(n),o=_t.copy(n).multiplyScalar(r);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 rt(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 $t(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 P(e.x-n.x,e.y-n.y,0).normalize(),o=new P(-r.y,r.x,0);return new $t(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 _t=new P,as=new P,Jt=new P;class Un{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,n,e,i){this.c0=t,this.c1=e,this.c2=-3*t+3*n-2*e-i,this.c3=2*t-2*n+e+i}initCatmullRom(t,n,e,i,r){this.init(n,e,r*(e-t),r*(i-n))}initNonuniformCatmullRom(t,n,e,i,r,o,c){let a=(n-t)/r-(e-t)/(r+o)+(e-n)/o,h=(e-n)/o-(i-n)/(o+c)+(i-e)/c;a*=o,h*=o,this.init(n,e,a,h)}calc(t){const n=t*t,e=n*t;return this.c0+this.c1*t+this.c2*n+this.c3*e}}class tn extends xt{constructor(t=[],n=!1,e="centripetal",i=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new P,this._px=new Un,this._py=new Un,this._pz=new Un,this._points=t.map(r=>new z(r)),this._closed=n,this._curveType=e,this._tension=i}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,i=this._points,r=i.length;if(r===0)return e.set(0,0,0);if(r===1)return e.copy(i[0]);const o=(r-(this._closed?0:1))*t;let c=Math.floor(o),a=o-c;this._closed?c+=c>0?0:(Math.floor(Math.abs(c)/r)+1)*r:a===0&&c===r-1&&(c=r-2,a=1);let h,l;this._closed||c>0?h=i[(c-1)%r]:(this._tmp.subVectors(i[0],i[1]).add(i[0]),h=new z(this._tmp.x,this._tmp.y,this._tmp.z));const u=i[c%r],d=i[(c+1)%r];if(this._closed||c+2<r?l=i[(c+2)%r]:(this._tmp.subVectors(i[r-1],i[r-2]).add(i[r-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(h.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(h.x,u.x,d.x,l.x,m,y,f),this._py.initNonuniformCatmullRom(h.y,u.y,d.y,l.y,m,y,f),this._pz.initNonuniformCatmullRom(h.z,u.z,d.z,l.z,m,y,f)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(h.x,u.x,d.x,l.x,this._tension),this._py.initCatmullRom(h.y,u.y,d.y,l.y,this._tension),this._pz.initCatmullRom(h.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 tn(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 rt;const t=new rt;return this._points.forEach(n=>{t.expandByPoint(n)}),t}}function hs(s,t){const n=s.x-t[0],e=s.y-t[1],i=(s.z??0)-(t[2]??0);return n*n+e*e+i*i}class U{constructor(t,n,e,i){this._degree=t,this._knots=[...n],this._controlPoints=e.map(r=>({x:r.x,y:r.y,z:r.z})),this._weights=i?[...i]: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 U(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 Zt(t,this._degree,this._knots,n,this._weights)}signedPlanarCurvatureAt(t){const n=this.evaluate(t);return qe(n.deriv1,n.deriv2)}getOffsetSamplePath2d(t,n=512){const e=Math.abs(t),{start:i,end:r}=this.getParameterRange(),o=this.length(),c=Math.max(64,Math.ceil(o/Math.max(e*.2,1e-6)));let a=Ar(i,r,Math.min(c,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=_r(a,d),a.length>n){a=a.slice(0,n);break}}const h=[],l=[];return a.forEach(u=>{const d=this.evaluate(u);h.push(new _(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 _(g/y,m/y):new _(1,0))}),{points:h,tangents:l}}length(){const t=this._controlPoints.map(n=>[n.x,n.y,n.z]);return Cn(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,n,e,i){return new U(t,n,e,i)}static byPoints(t,n,e="Uniform",i,r){const o=bn(t,n,e,i,r),c=o.controlPoints.map(a=>({x:a[0],y:a[1],z:a[2]}));return new U(n,o.knots,c,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:i}=this.getParameterRange();for(let r=0;r<=t;r++){const o=e+(i-e)*(r/t);n.push(this.point(o))}return n}isClosed(t=1e-6){const{start:n,end:e}=this.getParameterRange(),i=this.point(n),r=this.point(e),o=i[0]-r[0],c=i[1]-r[1],a=i[2]-r[2];return Math.sqrt(o*o+c*c+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 tn(t,!0,"centripetal"),e=Math.max(50,t.length*2);return n.getPoints(e)}nearestPoint(t,n=64){const{start:e,end:i}=this.getParameterRange();let r=this.point(e),o=hs(t,r);for(let c=0;c<=n;c++){const a=e+(i-e)*c/n,h=this.point(a),l=hs(t,h);l<o&&(o=l,r=h)}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 U.byPoints(r,n,e)}}function Ar(s,t,n){if(n<2)return[s,t];const e=[];for(let i=0;i<n;i++)e.push(i===n-1?t:s+(t-s)*i/(n-1));return e}function _r(s,t){const n=[...s,...t].sort((i,r)=>i-r),e=[];return n.forEach(i=>{const r=e[e.length-1];(r===void 0||Math.abs(r-i)>1e-10)&&e.push(i)}),e}function ls(s){if(!s)return!1;const t=s.x??0,n=s.y??0,e=s.z??0;return t*t+n*n+e*e>1e-20}function Pr(s,t,n){let e=s??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 wr(s,t,n){let e=s??0;e<1&&(e=3);const i=t+n-1;return e=Math.min(e,i),Math.max(1,e)}function pr(s,t){if(!(!s||s.length!==t))return s}class W extends xt{constructor(t,n,e,i,r,o){super();const c=arguments.length;if(this._degree=3,this._closed=!1,Array.isArray(n)){if(c<2||c>5)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._controlPoints=t;let a,h=3,l=!1;if(c>=3&&(Array.isArray(e)?(a=e,c>=4&&(h=i||3),c>=5&&(l=r)):e!==void 0&&(h=e||3,c>=4&&(l=i))),e===void 0&&c>=4&&(h=i||3,c>=5&&(l=r)),this._degree=h,this._closed=l,this._controlPoints.length<this._degree+1)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._nurbsCurve=U.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,a)}else{if(c<2||c>6)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._fitPoints=t,this._knotParameterization=n,c>=3&&(this._degree=e||3);const a=typeof i=="boolean";c>=4&&a&&(this._closed=i),a?(c>=5&&(this._startTangent=r),c>=6&&(this._endTangent=o)):(c>=4&&(this._startTangent=i),c>=5&&(this._endTangent=r)),this._closed&&(this._startTangent=void 0,this._endTangent=void 0);const h=(this._startTangent?1:0)+(this._endTangent?1:0);if(this._fitPoints.length+h<this._degree+1)throw j.AcCmErrors.ILLEGAL_PARAMETERS;if(this._closed)this._nurbsCurve=U.createClosedCurve(this._fitPoints,this._degree,this._knotParameterization);else{const l=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=U.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=U.createFitPointsForClosedCurve(this._fitPoints),n=this.toNurbsPoints(t);this._nurbsCurve=U.byPoints(n,this._degree,this._knotParameterization)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=U.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=U.createFitPointsForClosedCurve(this._controlPoints),n=this.toNurbsPoints(t);this._nurbsCurve=U.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=U.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(Y.point2dToPoint3d)}get fitPoints(){var t;return(t=this._fitPoints)==null?void 0:t.map(Y.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],i=this._nurbsCurve.point(e);return new z(i[0],i[1],i[2])}get endPoint(){const t=this._nurbsCurve.knots(),n=this._nurbsCurve.degree(),e=t[t.length-n-1],i=this._nurbsCurve.point(e);return new z(i[0],i[1],i[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,i=this._fitPoints[e];return Y.point2dToPoint3d(i)}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 i=this._fitPoints[e];i&&Y.applyOffsetToPoint3d(i,n)}this._boundingBoxNeedsUpdate=!0,this.buildCurve()}}moveControlPointsAt(t,n){for(const e of t){if(!Number.isInteger(e)||e<0)continue;const i=this.getControlPointAt(e);i&&Y.applyOffsetToPoint3d(i,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=U.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=[],i=n.knots(),r=this._nurbsCurve.degree(),o=i[r],c=i[i.length-r-1],a=(c-o)/(t-1);for(let h=0;h<t;h++){const l=h===t-1?c:o+h*a,u=n.point(l);e.push(new z(u[0],u[1],u[2]))}return e}tessellate(t){const n=v.resolveTessellateOptions(t),e=this._nurbsCurve.knots(),i=this._nurbsCurve.degree();if(e.length<i+2)return[this.startPoint.clone(),this.endPoint.clone()];const r=e[i],o=e[e.length-i-1],c=n.circleSides,a=Math.abs(this.length),h=n.deviation??Math.max(S,a<=S?S:a/(2*c*c));return xt.tessellateParametricCurve(r,o,l=>this.evaluateAt(l),{deviation:h,minSegments:n.minSegments??(this.closed?8:2),maxSegments:n.maxSegments})}getCurvePoints(t,n){const e=[],i=t.knots(),r=t.degree(),o=i[r],a=(i[i.length-r-1]-o)/(n-1);for(let h=0;h<n;h++){const l=o+h*a;e.push(t.point(l))}return e}calculateBoundingBox(){const t=this.getPoints(100);return new rt().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 Ne(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(i=>new z(i).applyMatrix4(t)),this._nurbsCurve=U.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,e.length>0?e:void 0)}return this._boundingBoxNeedsUpdate=!0,this}clone(){return this._fitPoints&&this._knotParameterization?new W(this._fitPoints.map(Y.point2dToPoint3d),this._knotParameterization,this._degree,this._closed,this._startTangent?Y.point2dToPoint3d(this._startTangent):void 0,this._endTangent?Y.point2dToPoint3d(this._endTangent):void 0):new W(this._controlPoints.map(Y.point2dToPoint3d),this._nurbsCurve.knots(),this._nurbsCurve.weights(),this._degree,this._closed)}toNurbsPoints(t){const n=new Array(t.length);return t.forEach((e,i)=>{n[i]=[e.x,e.y,e.z||0]}),n}toGePoints(t){const n=new Array(t.length);return t.forEach((e,i)=>{n[i]={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 W(t,n,e,!0)}static fromControlPoints(t,n,e,i,r){if(t.length<2||n.length<2)return null;const o=Pr(i,t.length,n.length);if(t.length<o+1)return null;try{return new W(t,n,pr(e,t.length),o,r)}catch{return null}}static fromFitPoints(t,n,e,i,r,o){if(t.length<2)return null;const c=ls(r),a=ls(o),h=(c?1:0)+(a?1:0),l=wr(e,t.length,h);if(t.length+h<l+1)return null;try{return c||a?new W(t,n,l,i,c?r:void 0,a?o:void 0):new W(t,n,l,i)}catch{return null}}static fromDwgSplineEdge(t){if(t.numberOfControlPoints>0&&t.numberOfKnots>0){const n=t.controlPoints.map(Y.point2dToPoint3d);let e=!0;const i=t.controlPoints.map(r=>(r.weight==null&&(e=!1),r.weight||1));return W.fromControlPoints(n,t.knots,e?i:void 0,t.degree,!1)}if(t.numberOfFitData>0){const n=t.fitDatum.map(Y.point2dToPoint3d);return W.fromFitPoints(n,"Uniform",t.degree,!1,t.startTangent?Y.point2dToPoint3d(t.startTangent):void 0,t.endTangent?Y.point2dToPoint3d(t.endTangent):void 0)}return null}}class H extends St{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}static buildFromEdges(t,n=.001){if(t.length===0)return[];const e=[...t],i=[],r=n*n,o=(c,a)=>{const h=c.x-a.x,l=c.y-a.y;return h*h+l*l<=r};for(;e.length>0;){const c=[],a=e.shift();c.push(a);const h=H.getEdgeStartPoint(a);let l=H.getEdgeEndPoint(a);if(!o(h,l))for(;e.length>0;){const u=H.findConnectingEdge(e,l,r);if(u.index<0)break;let d=e.splice(u.index,1)[0];if(u.reverse&&(d=H.reverseEdge(d)),c.push(d),l=H.getEdgeEndPoint(d),o(l,h))break}i.push(new H(c))}return i}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 _(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 tt;return n.setFromPoints(t),n}transform(t){const n=new O().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 W?e.transform(n):e.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new H(this._curves.map(t=>t.clone()))}get closed(){return!0}getPoints(t){const n=[];return this.curves.forEach(e=>{e.getPoints(t).forEach(i=>{n.push(new _(i.x,i.y))})}),n}tessellate(t){const n=[];return this._curves.forEach(e=>{Mr(e,t).forEach(i=>{const r=n[n.length-1];r&&(r.x-i.x)**2+(r.y-i.y)**2<=S*S||n.push(new _(i.x,i.y))})}),n}static findConnectingEdge(t,n,e){let i=-1,r=!1,o=Number.POSITIVE_INFINITY;for(let c=0;c<t.length;c++){const a=t[c],h=H.getEdgeStartPoint(a),l=H.getEdgeEndPoint(a),u=n.x-h.x,d=n.y-h.y,g=u*u+d*d;g<o&&(o=g,i=c,r=!1);const m=n.x-l.x,y=n.y-l.y,f=m*m+y*y;f<o&&(o=f,i=c,r=!0)}return o>e?{index:-1,reverse:!1}:{index:i,reverse:r}}static getEdgeStartPoint(t){const n=t.startPoint;return new _(n.x,n.y)}static getEdgeEndPoint(t){const n=t.endPoint;return new _(n.x,n.y)}static reverseEdge(t){return t instanceof Ct?new Ct(t.endPoint,t.startPoint):t instanceof v?H.reverseCircArcEdge(t):t instanceof At?new At(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof W?H.reverseSplineEdge(t):t}static reverseCircArcEdge(t){const n=t.startPoint,e=t.endPoint,i=!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),c=a=>{const h=M.normalizeAngle(a);return i?M.normalizeAngle(-h):h};return new v(t.center,t.radius,c(r),c(o),i)}static reverseSplineEdge(t){const n=[...t.controlPoints].reverse(),e=t.knots,i=e[0],r=e[e.length-1],o=e.map(h=>i+r-h).reverse(),c=t.weights,a=c.length>0?[...c].reverse():void 0;return new W(n,o,a,t.degree,t.closed)}}function Mr(s,t){if(s instanceof Ct)return s.getPoints();if(s instanceof v||s instanceof W)return s.tessellate(t);const n=s.closed?C:s.deltaAngle,e=v.segmentCount(Math.max(s.majorAxisRadius,s.minorAxisRadius),n,t);return s.getPoints(e)}const Ft=128,nn=96,b=yt.equalPointTol,Dn=b*8;function zr(s,t,n=!1,e=!1,i){const r=ds(s,n,i),o=ds(t,e,i),c=[];for(const a of r)for(const h of o)Zn(a,h)&&Hn(c,xs(a,h));return Ur(c)}function br(s,t){const n=us(s);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 us(s){switch(s.kind){case"line":return{kind:"line",line:s.line.clone(),extent:s.extent,extendable:s.extendable};case"circArc":return{kind:"circArc",arc:s.arc.clone(),extendable:s.extendable};case"ellipseArc":return{kind:"ellipseArc",arc:s.arc.clone(),extendable:s.extendable};case"spline":return{kind:"spline",spline:s.spline.clone(),extendable:s.extendable}}}function ds(s,t,n){const e=[];for(const i of s){const r=t&&i.extendable!==!1;switch(i.kind){case"line":{const o=kr(i.line,n);if(!o)break;const c=r?"unbounded":i.extent;e.push(Tt(o.start,o.end,c));break}case"circArc":{const o=Cr(i.arc,r);if(n&&!Vt(o.normal,n.normal)){const c=Ir(o,n);(c==null?void 0:c.kind)==="circArc"?e.push(gs(c.arc,ct(c.arc))):(c==null?void 0:c.kind)==="ellipseArc"?e.push(ms(c.arc,ut(c.arc))):Xn(e,fs(o,ct(o)),ct(o),n)}else{const c=Er(o,n);c&&e.push(gs(c,ct(c)))}break}case"ellipseArc":{const o=Tr(i.arc,r);if(n&&!Vt(o.normal,n.normal))Xn(e,ys(o,ut(o)),ut(o),n);else{const c=Nr(o,n);c&&e.push(ms(c,ut(c)))}break}case"spline":{n?Xn(e,i.spline.getPoints(Ft),i.spline.closed,n):e.push(Sr(i.spline));break}}}return e}function Tt(s,t,n){const e=new P().subVectors(t,s);return{kind:"line",start:s,dir:e,extent:n,box:n==="bounded"?new rt().setFromPoints([s,t]):void 0}}function gs(s,t){return{kind:"circArc",arc:s,full:t||ct(s),box:s.box}}function ms(s,t){return{kind:"ellipseArc",arc:s,full:t||ut(s),box:s.box}}function Sr(s){const t=[],n=s.getPoints(Ft);if(n.length>=2){const i=s.closed?n.length:n.length-1;for(let r=0;r<i;r++){const o=n[r],c=n[(r+1)%n.length];o.distanceToSquared(c)<b*b||t.push(Tt(o.clone(),c.clone(),"bounded"))}}const e=new rt;for(const i of t)i.box&&e.union(i.box);return{kind:"spline",spline:s,samples:t,box:t.length>0?e:void 0}}function Cr(s,t){return!t||ct(s)?s:new et(s.center,s.radius,0,C,s.normal,s.refVec)}function Tr(s,t){return!t||ut(s)?s:new ot(s.center,s.normal,s.majorAxis,s.majorAxisRadius,s.minorAxisRadius,0,C)}function kr(s,t){if(!t)return{start:s.startPoint.clone(),end:s.endPoint.clone()};const n=lt(s.startPoint,t),e=lt(s.endPoint,t);return n.distanceToSquared(e)<b*b?null:{start:n,end:e}}function Er(s,t){if(!t)return s;const n=lt(s.center,t);return new et(n,s.radius,s.startAngle,s.endAngle,t.normal.clone(),Wn(s.refVec,t.normal))}function Ir(s,t){const n=lt(s.center,t),e=s.normal.clone();if(e.lengthSq()<b*b)return null;e.normalize();const i=t.normal.clone();if(i.lengthSq()<b*b)return null;i.normalize();const r=e.dot(i),o=Math.abs(r);if(o>1-1e-8)return{kind:"circArc",arc:new et(n,s.radius,s.startAngle,s.endAngle,i,Wn(s.refVec,i))};if(o<1e-8)return null;const c=new P().crossVectors(e,i);if(c.lengthSq()<b*b)return null;c.normalize();const a=new ot(n,i,c,s.radius,s.radius*o,0,C);if(ct(s))return{kind:"ellipseArc",arc:a};const h=lt(s.startPoint,t),l=lt(s.endPoint,t),u=lt(s.midPoint,t),d=It(a,h),g=It(a,l),m=It(a,u),y=M.normalizeAngle(m-d),f=M.normalizeAngle(g-d),x=y<=f||f<1e-8?d+f:d+f+C;return{kind:"ellipseArc",arc:new ot(n,i,c,s.radius,s.radius*o,d,x)}}function Nr(s,t){if(!t)return s;const n=lt(s.center,t),e=Wn(s.majorAxis,t.normal);return e.lengthSq()<b*b?null:new ot(n,t.normal.clone(),e,s.majorAxisRadius,s.minorAxisRadius,s.startAngle,s.endAngle)}function Xn(s,t,n,e){if(t.length<2)return;const i=e?t.map(o=>lt(o,e)):t,r=n?i.length:i.length-1;for(let o=0;o<r;o++){const c=i[o],a=i[(o+1)%i.length];c.distanceToSquared(a)<b*b||s.push(Tt(c.clone(),a.clone(),"bounded"))}}function fs(s,t){return t||ct(s)?new et(s.center,s.radius,0,C,s.normal,s.refVec).getPoints(nn):s.getPoints(nn)}function ys(s,t){return t||ut(s)?new ot(s.center,s.normal,s.majorAxis,s.majorAxisRadius,s.minorAxisRadius,0,C).getPoints(nn):s.getPoints(nn)}function Zn(s,t){return!s.box||!t.box?!0:s.box.intersectsBox(t.box)}function xs(s,t){return s.kind==="spline"&&t.kind==="spline"?Br(s,t):s.kind==="spline"?As(s,t):t.kind==="spline"?As(t,s):s.kind==="line"&&t.kind==="line"?_s(s,t):s.kind==="line"&&t.kind==="circArc"?en(s,t.arc,t.full):t.kind==="line"&&s.kind==="circArc"?en(t,s.arc,s.full):s.kind==="line"&&t.kind==="ellipseArc"?Yn(s,t.arc,t.full):t.kind==="line"&&s.kind==="ellipseArc"?Yn(t,s.arc,s.full):s.kind==="circArc"&&t.kind==="circArc"?Fr(s.arc,s.full,t.arc,t.full):s.kind==="circArc"&&t.kind==="ellipseArc"?Ps(s.arc,s.full,t.arc,t.full):s.kind==="ellipseArc"&&t.kind==="circArc"?Ps(t.arc,t.full,s.arc,s.full):s.kind==="ellipseArc"&&t.kind==="ellipseArc"?jr(s.arc,s.full,t.arc,t.full):[]}function As(s,t){const n=[];for(const e of s.samples)Zn(e,t)&&Hn(n,xs(e,t));return Rr(s.spline,n,t)}function Br(s,t){const n=[];for(const i of s.samples)for(const r of t.samples)Zn(i,r)&&Hn(n,_s(i,r));const e=[];for(const i of n){const r=s.spline.nearestPoint(i,Ft),o=t.spline.nearestPoint(i,Ft);r.distanceTo(o)<=Dn&&e.push(r)}return e}function Rr(s,t,n){const e=[];for(const i of t){const r=s.nearestPoint(i,Ft);vr(n,r)<=Dn&&e.push(r)}return e}function vr(s,t){if(s.kind==="line"){const n=s.dir.lengthSq();if(n<b*b)return Number.POSITIVE_INFINITY;const e=new P().subVectors(t,s.start).dot(s.dir)/n;return kt(e,s.extent)?Et(s.start,s.dir,e).distanceTo(t):Number.POSITIVE_INFINITY}if(s.kind==="circArc"){if(!Qn(t,s.arc)){const n=st(s.arc.normal,s.arc.center),e=Math.abs(n.distanceToPoint(t)),i=Math.abs(t.distanceTo(s.arc.center)-s.arc.radius),r=Math.hypot(e,i);if(r>Dn)return r}return wt(s.arc,Pt(s.arc,t),s.full)?0:Number.POSITIVE_INFINITY}return s.kind==="ellipseArc"?Nt(t,s.arc,s.full)?0:Math.abs(sn(s.arc,t)):Number.POSITIVE_INFINITY}function _s(s,t){const n=s.dir,e=t.dir,i=n.lengthSq(),r=e.lengthSq();if(i<b*b||r<b*b)return[];const o=new P().subVectors(s.start,t.start),c=n.dot(n),a=n.dot(e),h=e.dot(e),l=n.dot(o),u=e.dot(o),d=c*h-a*a;if(Math.abs(d)<S*S*c*h)return[];const g=(a*u-h*l)/d,m=(c*u-a*l)/d;if(!kt(g,s.extent)||!kt(m,t.extent))return[];const y=Et(s.start,n,g),f=Et(t.start,e,m);return y.distanceTo(f)>b?[]:[y]}function en(s,t,n){const e=st(t.normal,t.center),i=ps(s,e);return i==="coplanar"?qr(s,t,n):i?Qn(i,t)?wt(t,Pt(t,i),n)?[i]:[]:[]:[]}function qr(s,t,n){const e=new P().subVectors(s.start,t.center),i=s.dir.dot(s.dir);if(i<b*b)return[];const r=2*s.dir.dot(e),o=e.dot(e)-t.radius*t.radius,c=[];for(const a of zs(i,r,o,2*t.radius*b)){if(!kt(a,s.extent))continue;const h=Et(s.start,s.dir,a);wt(t,Pt(t,h),n)&&c.push(h)}return c}function Yn(s,t,n){const e=st(t.normal,t.center),i=ps(s,e);return i==="coplanar"?Lr(s,t,n):i?Nt(i,t,n)?[i]:[]:[]}function Lr(s,t,n){const e=t.majorAxis,i=t.minorAxis,r=t.majorAxisRadius,o=t.minorAxisRadius;if(r<b||o<b)return[];const c=new P().subVectors(s.start,t.center),a=c.dot(e),h=c.dot(i),l=s.dir.dot(e),u=s.dir.dot(i),d=l*l/(r*r)+u*u/(o*o),g=2*a*l/(r*r)+2*h*u/(o*o),m=a*a/(r*r)+h*h/(o*o)-1,y=[];for(const f of zs(d,g,m,2*b/o)){if(!kt(f,s.extent))continue;const x=Et(s.start,s.dir,f);Kn(t,It(t,x),n)&&y.push(x)}return y}function Fr(s,t,n,e){if(Vt(s.normal,n.normal)){const c=st(s.normal,s.center);return Math.abs(c.distanceToPoint(n.center))>b?[]:Or(Vr(s,n),s,t,n,e)}const i=Gn(st(s.normal,s.center),st(n.normal,n.center));if(!i)return[];const r=Tt(i.point.clone(),new z().addVectors(i.point,i.dir),"unbounded");return en(r,s,t).filter(c=>Qn(c,n)?wt(n,Pt(n,c),e):!1)}function Vr(s,t){const n=new P().subVectors(t.center,s.center),e=n.length(),i=s.radius,r=t.radius;if(e<b&&p.equal(i,r,b))return[];if(e>i+r+b)return[];if(e+Math.min(i,r)+b<Math.max(i,r))return[];const o=e<b?Ms(s.normal):n.clone().normalize(),c=(i*i-r*r+e*e)/(2*Math.max(e,b)),a=i*i-c*c,h=new z().copy(s.center).addScaledVector(o,c);if(a<-b*b)return[];if(a<b*b)return[h];const l=Math.sqrt(Math.max(0,a)),u=new P().crossVectors(s.normal,o).normalize();return[new z().copy(h).addScaledVector(u,l),new z().copy(h).addScaledVector(u,-l)]}function Ps(s,t,n,e){if(!Vt(s.normal,n.normal)){const i=Gn(st(s.normal,s.center),st(n.normal,n.center));if(!i)return[];const r=Tt(i.point.clone(),new z().addVectors(i.point,i.dir),"unbounded");return en(r,s,t).filter(o=>Nt(o,n,e))}return ws(fs(s,t),ct(s)||t,i=>sn(n,i),i=>wt(s,Pt(s,i),t)&&Nt(i,n,e))}function jr(s,t,n,e){if(!Vt(s.normal,n.normal)){const i=Gn(st(s.normal,s.center),st(n.normal,n.center));if(!i)return[];const r=Tt(i.point.clone(),new z().addVectors(i.point,i.dir),"unbounded");return Yn(r,s,t).filter(o=>Nt(o,n,e))}return ws(ys(s,t),ut(s)||t,i=>sn(n,i),i=>Kn(s,It(s,i),t)&&Nt(i,n,e))}function ws(s,t,n,e){const i=[],r=t?s.length:s.length-1;for(let o=0;o<r;o++){const c=s[o],a=s[(o+1)%s.length],h=n(c),l=n(a);if(Math.abs(h)<=b){e(c)&&i.push(c.clone());continue}if(h*l>0)continue;let u=0,d=1,g=h;for(let y=0;y<40;y++){const f=(u+d)/2,x=new z().lerpVectors(c,a,f),w=n(x);g*w<=0?d=f:(u=f,g=w)}const m=new z().lerpVectors(c,a,(u+d)/2);e(m)&&i.push(m)}return i}function ps(s,t){const n=t.normal.dot(s.dir),e=t.distanceToPoint(s.start);if(p.equalToZero(n,b*Math.max(1,s.dir.length())))return p.equalToZero(e,b)?"coplanar":null;const i=-e/n;return kt(i,s.extent)?Et(s.start,s.dir,i):null}function Gn(s,t){const n=new P().crossVectors(s.normal,t.normal);if(n.lengthSq()<b*b)return null;n.normalize();const e=s.normal,i=t.normal,r=e.dot(e)*i.dot(i)-e.dot(i)**2;if(Math.abs(r)<S)return null;const o=-s.constant,c=-t.constant,a=(i.dot(i)*o-e.dot(i)*c)/r,h=(e.dot(e)*c-e.dot(i)*o)/r;return{point:new z().addScaledVector(e,a).addScaledVector(i,h),dir:n}}function kt(s,t){return t==="unbounded"?!0:t==="ray"?s>=-b:s>=-b&&s<=1+b}function Et(s,t,n){return new z().copy(s).addScaledVector(t,n)}function lt(s,t){const n=new z;return t.projectPoint(s,n),n}function Wn(s,t){const n=s.clone().addScaledVector(t,-s.dot(t));return n.lengthSq()<b*b?Ms(t):n.normalize()}function st(s,t){return new bt().setFromNormalAndCoplanarPoint(s,t)}function Vt(s,t){return new P().crossVectors(s,t).lengthSq()<b*b}function Pt(s,t){const n=new P().subVectors(t,s.center),e=new P().crossVectors(s.normal,s.refVec);return Math.atan2(n.dot(e),n.dot(s.refVec))}function It(s,t){const n=new P().subVectors(t,s.center),e=n.dot(s.majorAxis)/s.majorAxisRadius,i=n.dot(s.minorAxis)/s.minorAxisRadius;return Math.atan2(i,e)}function ct(s){return s.closed||Math.abs(s.deltaAngle-C)<1e-10}function ut(s){return s.closed||Math.abs(s.endAngle-s.startAngle)<1e-10||Math.abs(s.deltaAngle-C)<1e-10}function wt(s,t,n){return n||ct(s)?!0:M.normalizeAngle(t-s.startAngle)<=s.deltaAngle+1e-8}function Kn(s,t,n){return n||ut(s)?!0:M.normalizeAngle(t-s.startAngle)<=s.deltaAngle+1e-8}function Qn(s,t){const n=st(t.normal,t.center);return Math.abs(n.distanceToPoint(s))>b?!1:Math.abs(s.distanceTo(t.center)-t.radius)<=b}function sn(s,t){const n=new P().subVectors(t,s.center),e=n.dot(s.majorAxis)/s.majorAxisRadius,i=n.dot(s.minorAxis)/s.minorAxisRadius;return e*e+i*i-1}function Nt(s,t,n){const e=st(t.normal,t.center);return Math.abs(e.distanceToPoint(s))>b||Math.abs(sn(t,s))>1e-4?!1:Kn(t,It(t,s),n)}function Or(s,t,n,e,i){return s.filter(r=>wt(t,Pt(t,r),n)&&wt(e,Pt(e,r),i))}function Ms(s){const t=Math.abs(s.x)<.9?P.X_AXIS:P.Y_AXIS,n=new P().crossVectors(s,t);return n.lengthSq()<b*b&&n.crossVectors(s,P.Z_AXIS),n.normalize()}function zs(s,t,n,e){if(Math.abs(s)<S)return Math.abs(t)<S?[]:[-n/t];const i=t*t-4*s*n,r=i/(4*Math.abs(s));if(r<-e)return[];if(r<=e)return[-t/(2*s)];const o=Math.sqrt(i);return[(-t-o)/(2*s),(-t+o)/(2*s)]}function Hn(s,t){for(const n of t)s.push(n)}function Ur(s){const t=[];for(const n of s)t.some(e=>e.distanceTo(n)<=b)||t.push(n);return t}function Dr(s,t,n){const e=n.radius;if(!Number.isFinite(e)||e<0)return{ok:!1,error:"invalidRadius"};const i=n.tol??yt;if(s.kind==="line"&&t.kind==="line")return bs(s,t,e,n.hintA,n.hintB,i);if(s.kind==="line"&&t.kind==="circArc")return rn(s,t,e,n.hintA,n.hintB,i);if(s.kind==="circArc"&&t.kind==="line"){const r=rn(t,s,e,n.hintB,n.hintA,i);return Bs(r)}return s.kind==="circArc"&&t.kind==="circArc"?Yr(s,t,e,n.hintA,n.hintB,i):Gr(s,t,e,n.hintA,n.hintB,i)}function bs(s,t,n,e,i,r){const o=$n(s),c=$n(t);if(o.length<S||c.length<S)return{ok:!1,error:"noSolution"};const a=o.dir.x*c.dir.y-o.dir.y*c.dir.x;if(Math.abs(a)<r.equalVectorTol)return Xr(o,c,n,e,i,r);const h=Ts(o,c);if(!h)return{ok:!1,error:"noIntersection"};if(p.isNonPositive(n))return{ok:!0,result:{trimA:h.clone(),trimB:h.clone(),radius:0}};const l=[];for(const d of[1,-1])for(const g of[1,-1]){const m=te(o,d*n),y=te(c,g*n),f=Ts(m,y);if(!f)continue;const x=on(o,f),w=on(c,f),k=F(f,x),E=F(f,w);if(Math.abs(k-n)>r.equalPointTol*10||Math.abs(E-n)>r.equalPointTol*10)continue;const N=ee(f,n,x,w,h);N&&l.push({arc:N,trimA:x,trimB:w,center:f,radius:n})}return l.length===0?{ok:!1,error:"noSolution"}:{ok:!0,result:se(l,e,i,h)}}function Xr(s,t,n,e,i,r){const o=new _(-s.dir.y,s.dir.x),c=(t.origin.x-s.origin.x)*o.x+(t.origin.y-s.origin.y)*o.y,a=Math.abs(c);if(a<r.equalPointTol)return{ok:!1,error:"parallel"};const h=a/2,l=c>0?1:-1,u=new _(s.origin.x+o.x*l*h,s.origin.y+o.y*l*h),d=e&&i?cn(e,i):e?new _(e):i?new _(i):new _((s.origin.x+t.origin.x)/2,(s.origin.y+t.origin.y)/2),g=on({...s,origin:u},d),m=new _(g.x-o.x*l*h,g.y-o.y*l*h),y=new _(g.x+o.x*l*h,g.y+o.y*l*h),f=new _(g.x+s.dir.x*h,g.y+s.dir.y*h),x=new _(g.x-s.dir.x*h,g.y-s.dir.y*h),w=F(f,d)<=F(x,d)?f:x,k=v.tryCreateByThreePoints(m,w,y);return k?{ok:!0,result:{arc:k,trimA:m,trimB:y,center:g,radius:h}}:{ok:!1,error:"noSolution"}}function rn(s,t,n,e,i,r){const o=$n(s),c=Jn(t);if(o.length<S||c.radius<S)return{ok:!1,error:"noSolution"};if(p.isNonPositive(n))return Zr(o,c,e,i,r);const a=[];for(const u of[1,-1])for(const d of[1,-1]){const g=c.radius+d*n;if(g<S)continue;const m=te(o,u*n),y=ks(m,c.center,g,r);for(const f of y){const x=on(o,f),w=new _(f.x-c.center.x,f.y-c.center.y),k=Math.hypot(w.x,w.y);if(k<S)continue;const E=new _(c.center.x+w.x/k*c.radius,c.center.y+w.y/k*c.radius);if(!ne(c,E)&&!c.closed)continue;const N=pt(e,i)??Ns(x,E),B=ee(f,n,x,E,N);B&&a.push({arc:B,trimA:x,trimB:E,center:f,radius:n})}}if(a.length===0)return{ok:!1,error:"noSolution"};const h=pt(e,i);return{ok:!0,result:se(a,e,i,h)}}function Zr(s,t,n,e,i){const r=ks(s,t.center,t.radius,i);if(r.length===0)return{ok:!1,error:"noIntersection"};const o=pt(n,e);let c=r[0],a=1/0;for(const h of r){const l=o?F(h,o):0;l<a&&(a=l,c=h)}return{ok:!0,result:{trimA:c.clone(),trimB:c.clone(),radius:0}}}function Yr(s,t,n,e,i,r){const o=Jn(s),c=Jn(t);if(p.isNonPositive(n)){const l=Es(o.center,o.radius,c.center,c.radius,r);if(l.length===0)return{ok:!1,error:"noIntersection"};const u=pt(e,i);let d=l[0],g=1/0;for(const m of l){const y=u?F(m,u):0;y<g&&(g=y,d=m)}return{ok:!0,result:{trimA:d.clone(),trimB:d.clone(),radius:0}}}const a=[];for(const l of[1,-1])for(const u of[1,-1]){const d=o.radius+l*n,g=c.radius+u*n;if(d<S||g<S)continue;const m=Es(o.center,d,c.center,g,r);for(const y of m){const f=Is(o.center,o.radius,y),x=Is(c.center,c.radius,y);if(!f||!x||!o.closed&&!ne(o,f)||!c.closed&&!ne(c,x))continue;const w=pt(e,i)??Ns(f,x),k=ee(y,n,f,x,w);k&&a.push({arc:k,trimA:f,trimB:x,center:y,radius:n})}}return a.length===0?{ok:!1,error:"noSolution"}:{ok:!0,result:se(a,e,i,pt(e,i))}}function Gr(s,t,n,e,i,r){const o=Ss(s),c=Ss(t);if(o.length<2||c.length<2)return{ok:!1,error:"unsupported"};const a=Cs(o,e??o[0]),h=Cs(c,i??c[0]);if(!a||!h)return{ok:!1,error:"noSolution"};if(s.kind==="circArc"){const l=rn({start:h.p0,end:h.p1,extent:"bounded"},s,n,i,e,r);if(l.ok)return Bs(l)}if(t.kind==="circArc"){const l=rn({start:a.p0,end:a.p1,extent:"bounded"},t,n,e,i,r);if(l.ok)return l}return bs({start:a.p0,end:a.p1,extent:"bounded"},{start:h.p0,end:h.p1,extent:"bounded"},n,e,i,r)}function Ss(s){return s.kind==="line"?[new _(s.start),new _(s.end)]:s.kind==="circArc"?Wr(s,64):s.kind==="ellipseArc"?Kr(s,96):s.samples.map(t=>new _(t))}function Wr(s,t){const n=[],e=M.normalizeAngle(s.startAngle),i=Math.max(8,t);for(let r=0;r<=i;r++){const o=r/i,c=s.closed?e+Math.PI*2*o:s.clockwise?e-M.normalizeAngle(s.startAngle-s.endAngle)*o:e+M.normalizeAngle(s.endAngle-s.startAngle)*o;n.push(new _(s.center.x+s.radius*Math.cos(c),s.center.y+s.radius*Math.sin(c)))}return n}function Kr(s,t){const n=[],e=s.rotation??0,i=Math.cos(e),r=Math.sin(e),o=Math.max(8,t);for(let c=0;c<=o;c++){const a=c/o,h=s.closed?s.startAngle+Math.PI*2*a:s.clockwise?s.startAngle-M.normalizeAngle(s.startAngle-s.endAngle)*a:s.startAngle+M.normalizeAngle(s.endAngle-s.startAngle)*a,l=s.majorRadius*Math.cos(h),u=s.minorRadius*Math.sin(h);n.push(new _(s.center.x+l*i-u*r,s.center.y+l*r+u*i))}return n}function Cs(s,t){let n=null,e=1/0;for(let i=0;i<s.length-1;i++){const r=s[i],o=s[i+1],c=Qr(r,o,t),a=F(c,t);a<e&&(e=a,n={p0:r,p1:o})}return n}function Qr(s,t,n){const e=t.x-s.x,i=t.y-s.y,r=e*e+i*i;if(r<S)return s.clone();let o=((n.x-s.x)*e+(n.y-s.y)*i)/r;return o=Math.max(0,Math.min(1,o)),new _(s.x+o*e,s.y+o*i)}function $n(s){const t=new _(s.start),n=new _(s.end),e=n.x-t.x,i=n.y-t.y,r=Math.hypot(e,i),o=r>S?new _(e/r,i/r):new _(1,0);return{origin:t,dir:o,length:r,extent:s.extent??"bounded"}}function Jn(s){return{center:new _(s.center),radius:s.radius,startAngle:M.normalizeAngle(s.startAngle),endAngle:M.normalizeAngle(s.endAngle),clockwise:!!s.clockwise,closed:!!s.closed}}function te(s,t){const n=new _(-s.dir.y,s.dir.x);return{origin:new _(s.origin.x+n.x*t,s.origin.y+n.y*t),dir:s.dir.clone(),length:s.length,extent:"unbounded"}}function Ts(s,t){const n=s.dir.x*t.dir.y-s.dir.y*t.dir.x;if(Math.abs(n)<S)return null;const e=t.origin.x-s.origin.x,i=t.origin.y-s.origin.y,r=(e*t.dir.y-i*t.dir.x)/n;return new _(s.origin.x+s.dir.x*r,s.origin.y+s.dir.y*r)}function on(s,t){const n=(t.x-s.origin.x)*s.dir.x+(t.y-s.origin.y)*s.dir.y;return new _(s.origin.x+s.dir.x*n,s.origin.y+s.dir.y*n)}function ks(s,t,n,e){const i=new _(s.origin.x-t.x,s.origin.y-t.y),r=1,o=2*(i.x*s.dir.x+i.y*s.dir.y),c=i.x*i.x+i.y*i.y-n*n,a=o*o-4*r*c;if(a<-e.equalPointTol)return[];const h=Math.sqrt(Math.max(0,a)),l=(-o-h)/(2*r),u=(-o+h)/(2*r),d=[new _(s.origin.x+s.dir.x*l,s.origin.y+s.dir.y*l)];return Math.abs(u-l)>e.equalPointTol&&d.push(new _(s.origin.x+s.dir.x*u,s.origin.y+s.dir.y*u)),d}function Es(s,t,n,e,i){const r=n.x-s.x,o=n.y-s.y,c=Math.hypot(r,o);if(c<S)return[];if(c>t+e+i.equalPointTol)return[];if(c<Math.abs(t-e)-i.equalPointTol)return[];const a=(t*t-e*e+c*c)/(2*c),h=t*t-a*a,l=Math.sqrt(Math.max(0,h)),u=s.x+r*a/c,d=s.y+o*a/c;if(l<i.equalPointTol)return[new _(u,d)];const g=-o*l/c,m=r*l/c;return[new _(u+g,d+m),new _(u-g,d-m)]}function Is(s,t,n){const e=n.x-s.x,i=n.y-s.y,r=Math.hypot(e,i);return r<S?null:new _(s.x+e/r*t,s.y+i/r*t)}function ne(s,t,n){if(s.closed)return!0;const e=nt(s.center,t);return s.clockwise?M.isAngleOnCcwSweep(s.endAngle,e,s.startAngle):M.isAngleOnCcwSweep(s.startAngle,e,s.endAngle)}function ee(s,t,n,e,i){const r=nt(s,n),o=nt(s,e),c=nt(s,i),h=!M.isAngleOnCcwSweep(r,c,o);return v.tryCreateByCenterStartEnd(s,n,e,h)}function se(s,t,n,e){const i=pt(t,n)??e;if(!i)return s[0];let r=s[0],o=1/0;for(const c of s){const a=c.center?c.center:cn(c.trimA,c.trimB);let h=F(a,i);t&&(h+=F(c.trimA,t)*.5),n&&(h+=F(c.trimB,n)*.5),c.arc&&(h+=c.arc.deltaAngle*.01),h<o&&(o=h,r=c)}return r}function cn(s,t){return new _((s.x+t.x)/2,(s.y+t.y)/2)}function pt(s,t){if(s&&t)return cn(s,t);if(s)return new _(s);if(t)return new _(t)}function Ns(s,t){return cn(s,t)}function Bs(s){return s.ok?{ok:!0,result:{...s.result,trimA:s.result.trimB,trimB:s.result.trimA}}:s}function Hr(s,t=64){const n=Math.max(2,t);return{kind:"spline",samples:s.getPoints(n).map(i=>({x:i.x,y:i.y}))}}function $r(s){return{kind:"ellipseArc",center:{x:s.center.x,y:s.center.y},majorRadius:s.majorAxisRadius,minorRadius:s.minorAxisRadius,startAngle:s.startAngle,endAngle:s.endAngle,clockwise:s.clockwise,closed:s.closed,rotation:s.rotation}}function Jr(s,t,n){const e=n.tol??yt,i=vs(s),r=vs(t);if(i.length<S||r.length<S)return{ok:!1,error:"noSolution"};const o=i.dir.x*r.dir.y-i.dir.y*r.dir.x;if(Math.abs(o)<e.equalVectorTol)return{ok:!1,error:"parallel"};const c=to(i,r);if(!c)return{ok:!1,error:"noIntersection"};const a=Rs(i,c,n.hintA),h=Rs(r,c,n.hintB);let l,u;if(n.mode.method==="distance")l=n.mode.distance1,u=n.mode.distance2;else{l=n.mode.length;const m=n.mode.angle;if(!Number.isFinite(m)||m<0)return{ok:!1,error:"invalidDistance"};if(Math.abs(Math.sin(m))<S&&m!==0)return{ok:!1,error:"invalidDistance"};u=l*Math.tan(m)}if(!Number.isFinite(l)||!Number.isFinite(u)||l<0||u<0)return{ok:!1,error:"invalidDistance"};if(p.isNonPositive(l)&&p.isNonPositive(u))return{ok:!0,result:{trimA:c.clone(),trimB:c.clone(),corner:c.clone(),isCornerOnly:!0}};const d=new _(c.x+a.x*l,c.y+a.y*l),g=new _(c.x+h.x*u,c.y+h.y*u);return{ok:!0,result:{trimA:d,trimB:g,corner:c.clone(),isCornerOnly:!1}}}function Rs(s,t,n){const e=(t.x-s.origin.x)*s.dir.x+(t.y-s.origin.y)*s.dir.y;let i;return n?i=(n.x-s.origin.x)*s.dir.x+(n.y-s.origin.y)*s.dir.y>=e:i=s.length/2>=e,i?s.dir.clone():new _(-s.dir.x,-s.dir.y)}function vs(s){const t=new _(s.start),n=new _(s.end),e=n.x-t.x,i=n.y-t.y,r=Math.hypot(e,i),o=r>S?new _(e/r,i/r):new _(1,0);return{origin:t,end:n,dir:o,length:r,extent:s.extent??"bounded"}}function to(s,t){const n=s.dir.x*t.dir.y-s.dir.y*t.dir.x;if(Math.abs(n)<S)return null;const e=t.origin.x-s.origin.x,i=t.origin.y-s.origin.y,r=(e*t.dir.y-i*t.dir.x)/n;return new _(s.origin.x+s.dir.x*r,s.origin.y+s.dir.y*r)}A.AcGeArea2d=Vn,A.AcGeBox2d=tt,A.AcGeBox3d=rt,A.AcGeCatmullRomCurve3d=tn,A.AcGeCircArc2d=v,A.AcGeCircArc3d=et,A.AcGeCurve2d=St,A.AcGeEllipseArc2d=At,A.AcGeEllipseArc3d=ot,A.AcGeEuler=Mn,A.AcGeGeometryUtil=Y,A.AcGeLine2d=Ct,A.AcGeLine3d=$t,A.AcGeLoop2d=H,A.AcGeMathUtil=M,A.AcGeMatrix2d=Mt,A.AcGeMatrix3d=O,A.AcGeNurbsCurve=U,A.AcGePlane=bt,A.AcGePoint2d=_,A.AcGePoint3d=z,A.AcGePolyline2d=mt,A.AcGeQuaternion=Rt,A.AcGeShape2d=vn,A.AcGeSpline3d=W,A.AcGeTol=p,A.AcGeVector2d=q,A.AcGeVector3d=P,A.DEFAULT_TOL=yt,A.DEG2RAD=mn,A.FLOAT_TOL=S,A.ORIGIN_POINT_2D=qs,A.ORIGIN_POINT_3D=Pn,A.RAD2DEG=fn,A.TAU=C,A.acgeBasisFunction=gt,A.acgeBulgeArcTangentAtEnd=dr,A.acgeBulgeArcTangentAtStart=ur,A.acgeBulgeFromCenter=gr,A.acgeBulgeFromCenterWithTangent=mr,A.acgeBulgeFromCircArc2d=Ht,A.acgeBulgeFromStartEndDirection=fr,A.acgeBulgeFromStartEndRadius=xr,A.acgeBulgeFromThreePoints=yr,A.acgeCalculateCurveLength=Cn,A.acgeCeilPowerOfTwo=_e,A.acgeCenterFromBulge=jn,A.acgeChamferCurves2d=Jr,A.acgeClamp=J,A.acgeCloneIntersectPrimitive=us,A.acgeClosedPolygonArea2d=Ds,A.acgeClosedPolygonArea3d=Ne,A.acgeComplementBulge=lr,A.acgeComputeParameterValues=Be,A.acgeDamp=ae,A.acgeDegToRad=ye,A.acgeEuclideanModulo=yn,A.acgeEvaluateNurbsDerivatives=Zt,A.acgeEvaluateNurbsPoint=vt,A.acgeFilletCurves2d=Dr,A.acgeFilletPrimitiveFromEllipse2d=$r,A.acgeFilletPrimitiveFromSpline3d=Hr,A.acgeFloorPowerOfTwo=Pe,A.acgeGenerateAveragedKnots=Re,A.acgeGenerateChordKnots=Ks,A.acgeGenerateSqrtChordKnots=Qs,A.acgeGenerateUUID=re,A.acgeGenerateUniformKnots=Ws,A.acgeGeometricTangentAtPoint=On,A.acgeGetOcsAngle=mi,A.acgeGetOcsReferenceVector=di,A.acgeGetOcsReferenceVectorInto=Ve,A.acgeIntPartLength=An,A.acgeInterpolateControlPoints=ti,A.acgeInterpolateNurbsCurve=bn,A.acgeIntersectCurves=zr,A.acgeInverseLerp=ce,A.acgeIsAngleOnCcwSweep=Me,A.acgeIsBetterDistanceAlign=Ze,A.acgeIsBetween=we,A.acgeIsBetweenAngle=pe,A.acgeIsPowerOfTwo=Ae,A.acgeLerp=xn,A.acgeMapLinear=oe,A.acgeNormalizeAngle=ft,A.acgeNurbsClosestParam=ci,A.acgeNurbsEvaluate=ri,A.acgeNurbsExtractSegment=Yt,A.acgeNurbsInsertKnot=kn,A.acgeNurbsJoin=ii,A.acgeNurbsLengthTo=ai,A.acgeNurbsParameterRange=qt,A.acgeNurbsSplitAt=si,A.acgeOffsetPointByDirectionInXY=Ki,A.acgeOffsetSmoothedSampledPath=Hi,A.acgeOffsetVertexPath=Qi,A.acgePingpong=he,A.acgePointLiesOnCircle2d=De,A.acgePolygonArea2d=Ee,A.acgePolygonArea3d=Ie,A.acgeRadToDeg=xe,A.acgeRandFloat=ge,A.acgeRandFloatSpread=me,A.acgeRandInt=de,A.acgeRelativeEps=ze,A.acgeSameCircle2d=Xe,A.acgeSeededRandom=fe,A.acgeSignedPlanarCurvature=qe,A.acgeSignedPolygonArea2d=zn,A.acgeSmootherstep=ue,A.acgeSmoothstep=le,A.acgeTransformIntersectPrimitive=br,A.acgeTransformOcsPointToWcs=gi,A.acgeTransformOcsPointToWcsInto=je,A.acgeTransformWcsPointToOcs=In,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(A,j){typeof exports=="object"&&typeof module<"u"?j(exports,require("@mlightcad/common")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/common"],j):(A=typeof globalThis<"u"?globalThis:A||self,j(A["geometry-engine"]={},A.common))})(this,(function(A,j){"use strict";const X=["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 ie=1234567;const mn=Math.PI/180,fn=180/Math.PI;function re(){const s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,e=Math.random()*4294967295|0;return(X[s&255]+X[s>>8&255]+X[s>>16&255]+X[s>>24&255]+"-"+X[t&255]+X[t>>8&255]+"-"+X[t>>16&15|64]+X[t>>24&255]+"-"+X[n&63|128]+X[n>>8&255]+"-"+X[n>>16&255]+X[n>>24&255]+X[e&255]+X[e>>8&255]+X[e>>16&255]+X[e>>24&255]).toLowerCase()}function J(s,t,n){return Math.max(t,Math.min(n,s))}function yn(s,t){return(s%t+t)%t}function oe(s,t,n,e,i){return e+(s-t)*(i-e)/(n-t)}function ce(s,t,n){return s!==t?(n-s)/(t-s):0}function xn(s,t,n){return(1-n)*s+n*t}function ae(s,t,n,e){return xn(s,t,1-Math.exp(-n*e))}function he(s,t=1){return t-Math.abs(yn(s,t*2)-t)}function le(s,t,n){return s<=t?0:s>=n?1:(s=(s-t)/(n-t),s*s*(3-2*s))}function ue(s,t,n){return s<=t?0:s>=n?1:(s=(s-t)/(n-t),s*s*s*(s*(s*6-15)+10))}function de(s,t){return s+Math.floor(Math.random()*(t-s+1))}function ge(s,t){return s+Math.random()*(t-s)}function me(s){return s*(.5-Math.random())}function fe(s){s!==void 0&&(ie=s);let t=ie+=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 ye(s){return s*mn}function xe(s){return s*fn}function Ae(s){return(s&s-1)===0&&s!==0}function _e(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function Pe(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function ft(s){const t=Math.PI*2;return(s%t+t)%t}function we(s,t,n){return s>t&&s<n||s>n&&s<t}function pe(s,t,n,e=!1){return s=ft(s),t=ft(t),n=ft(n),e?t>n?s<=t&&s>=n:s<=t||s>=n:t<n?s>=t&&s<=n:s>=t||s<=n}function Me(s,t,n){const e=ft(n-s);return ft(t-s)<=e+1e-7}function An(s){return s=Math.abs(s),s<1?0:Math.ceil(Math.log10(Math.abs(s)+1))}function ze(s,t=1e-7){const n=An(s);return Math.max(Math.pow(10,n)*t,t)}const M={DEG2RAD:mn,RAD2DEG:fn,generateUUID:re,clamp:J,euclideanModulo:yn,mapLinear:oe,inverseLerp:ce,lerp:xn,damp:ae,pingpong:he,smoothstep:le,smootherstep:ue,randInt:de,randFloat:ge,randFloatSpread:me,seededRandom:fe,degToRad:ye,radToDeg:xe,isPowerOfTwo:Ae,ceilPowerOfTwo:_e,floorPowerOfTwo:Pe,normalizeAngle:ft,isBetween:we,isBetweenAngle:pe,isAngleOnCcwSweep:Me,intPartLength:An,relativeEps:ze},jt=class jt{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:i,y:r}=t;this.x=i,this.y=r;return}if(e===2){this.x=t,this.y=n;return}throw j.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 jt(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,i=t.elements;return this.x=i[0]*n+i[3]*e+i[6],this.y=i[1]*n+i[4]*e+i[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),i=Math.sin(n),r=this.x-t.x,o=this.y-t.y;return this.x=r*e-o*i+t.x,this.y=r*i+o*e+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(M.relativeEps(this.x,t),M.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};jt.EMPTY=Object.freeze(new jt(0,0));let q=jt;const Ot=class Ot{constructor(t,n,e,i,r,o,c,a,h){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&n!=null&&e!=null&&i!=null&&r!=null&&o!=null&&c!=null&&a!=null&&h!=null&&this.set(t,n,e,i,r,o,c,a,h)}set(t,n,e,i,r,o,c,a,h){const l=this.elements;return l[0]=t,l[1]=i,l[2]=c,l[3]=n,l[4]=r,l[5]=a,l[6]=e,l[7]=o,l[8]=h,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,i=n.elements,r=this.elements,o=e[0],c=e[3],a=e[6],h=e[1],l=e[4],u=e[7],d=e[2],g=e[5],m=e[8],y=i[0],f=i[3],x=i[6],p=i[1],k=i[4],E=i[7],N=i[2],B=i[5],T=i[8];return r[0]=o*y+c*p+a*N,r[3]=o*f+c*k+a*B,r[6]=o*x+c*E+a*T,r[1]=h*y+l*p+u*N,r[4]=h*f+l*k+u*B,r[7]=h*x+l*E+u*T,r[2]=d*y+g*p+m*N,r[5]=d*f+g*k+m*B,r[8]=d*x+g*E+m*T,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],i=t[2],r=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8];return n*o*l-n*c*h-e*r*l+e*c*a+i*r*h-i*o*a}invert(){const t=this.elements,n=t[0],e=t[1],i=t[2],r=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],u=l*o-c*h,d=c*a-l*r,g=h*r-o*a,m=n*u+e*d+i*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]=(i*h-l*e)*y,t[2]=(c*e-i*o)*y,t[3]=d*y,t[4]=(l*n-i*a)*y,t[5]=(i*r-c*n)*y,t[6]=g*y,t[7]=(e*a-h*n)*y,t[8]=(o*n-e*r)*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,i,r,o,c){const a=Math.cos(r),h=Math.sin(r);return this.set(e*a,e*h,-e*(a*o+h*c)+o+t,-i*h,i*a,-i*(-h*o+a*c)+c+n,0,0,1),this}scale(t,n){return this.premultiply(_n.makeScale(t,n)),this}rotate(t){return this.premultiply(_n.makeRotation(-t)),this}translate(t,n){return this.premultiply(_n.makeTranslation(t,n)),this}makeTranslation(t,n){return t instanceof q?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 i=0;i<9;i++)if(n[i]!==e[i])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 Ot().fromArray(this.elements)}};Ot.IDENTITY=Object.freeze(new Ot);let Mt=Ot;const _n=new Mt,S=1e-6,C=2*Math.PI,qs={x:0,y:0},Pn={x:0,y:0,z:0};class w{constructor(){this.equalPointTol=S,this.equalVectorTol=S}clone(){const t=new w;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t}equalPoint2d(t,n){return new q(t).sub(n).length()<this.equalPointTol}equalPoint3d(t,n){return new P(t).sub(n).length()<this.equalPointTol}static equalToZero(t,n=S){return t<n&&t>-n}static equal(t,n,e=S){return Math.abs(t-n)<e}static great(t,n,e=S){return t-n>e}static less(t,n,e=S){return t-n<e}static isPositive(t,n=S){return t>n}static isNonPositive(t,n=S){return t<=n}}const yt=new w;class Rt{constructor(t=0,n=0,e=0,i=1){this._x=t,this._y=n,this._z=e,this._w=i}static slerpFlat(t,n,e,i,r,o,c){let a=e[i+0],h=e[i+1],l=e[i+2],u=e[i+3];const d=r[o+0],g=r[o+1],m=r[o+2],y=r[o+3];if(c===0){t[n+0]=a,t[n+1]=h,t[n+2]=l,t[n+3]=u;return}if(c===1){t[n+0]=d,t[n+1]=g,t[n+2]=m,t[n+3]=y;return}if(u!==y||a!==d||h!==g||l!==m){let f=1-c;const x=a*d+h*g+l*m+u*y,p=x>=0?1:-1,k=1-x*x;if(k>Number.EPSILON){const N=Math.sqrt(k),B=Math.atan2(N,x*p);f=Math.sin(f*B)/N,c=Math.sin(c*B)/N}const E=c*p;if(a=a*f+d*E,h=h*f+g*E,l=l*f+m*E,u=u*f+y*E,f===1-c){const N=1/Math.sqrt(a*a+h*h+l*l+u*u);a*=N,h*=N,l*=N,u*=N}}t[n]=a,t[n+1]=h,t[n+2]=l,t[n+3]=u}static multiplyQuaternionsFlat(t,n,e,i,r,o){const c=e[i],a=e[i+1],h=e[i+2],l=e[i+3],u=r[o],d=r[o+1],g=r[o+2],m=r[o+3];return t[n]=c*m+l*u+a*g-h*d,t[n+1]=a*m+l*d+h*u-c*g,t[n+2]=h*m+l*g+c*d-a*u,t[n+3]=l*m-c*u-a*d-h*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,i){return this._x=t,this._y=n,this._z=e,this._w=i,this._onChangeCallback(),this}clone(){return new Rt(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,i=t.y,r=t.z,o=t.order,c=Math.cos,a=Math.sin,h=c(e/2),l=c(i/2),u=c(r/2),d=a(e/2),g=a(i/2),m=a(r/2);switch(o){case"XYZ":this._x=d*l*u+h*g*m,this._y=h*g*u-d*l*m,this._z=h*l*m+d*g*u,this._w=h*l*u-d*g*m;break;case"YXZ":this._x=d*l*u+h*g*m,this._y=h*g*u-d*l*m,this._z=h*l*m-d*g*u,this._w=h*l*u+d*g*m;break;case"ZXY":this._x=d*l*u-h*g*m,this._y=h*g*u+d*l*m,this._z=h*l*m+d*g*u,this._w=h*l*u-d*g*m;break;case"ZYX":this._x=d*l*u-h*g*m,this._y=h*g*u+d*l*m,this._z=h*l*m-d*g*u,this._w=h*l*u+d*g*m;break;case"YZX":this._x=d*l*u+h*g*m,this._y=h*g*u+d*l*m,this._z=h*l*m-d*g*u,this._w=h*l*u-d*g*m;break;case"XZY":this._x=d*l*u-h*g*m,this._y=h*g*u-d*l*m,this._z=h*l*m+d*g*u,this._w=h*l*u+d*g*m;break}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,n){const e=n/2,i=Math.sin(e);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(t){const n=t.elements,e=n[0],i=n[4],r=n[8],o=n[1],c=n[5],a=n[9],h=n[2],l=n[6],u=n[10],d=e+c+u;if(d>0){const g=.5/Math.sqrt(d+1);this._w=.25/g,this._x=(l-a)*g,this._y=(r-h)*g,this._z=(o-i)*g}else if(e>c&&e>u){const g=2*Math.sqrt(1+e-c-u);this._w=(l-a)/g,this._x=.25*g,this._y=(i+o)/g,this._z=(r+h)/g}else if(c>u){const g=2*Math.sqrt(1+c-e-u);this._w=(r-h)/g,this._x=(i+o)/g,this._y=.25*g,this._z=(a+l)/g}else{const g=2*Math.sqrt(1+u-e-c);this._w=(o-i)/g,this._x=(r+h)/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(J(this.dot(t),-1,1)))}rotateTowards(t,n){const e=this.angleTo(t);if(e===0)return this;const i=Math.min(1,n/e);return this.slerp(t,i),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,i=t._y,r=t._z,o=t._w,c=n._x,a=n._y,h=n._z,l=n._w;return this._x=e*l+o*c+i*h-r*a,this._y=i*l+o*a+r*c-e*h,this._z=r*l+o*h+e*a-i*c,this._w=o*l-e*c-i*a-r*h,this._onChangeCallback(),this}slerp(t,n){if(n===0)return this;if(n===1)return this.copy(t);const e=this._x,i=this._y,r=this._z,o=this._w;let c=o*t._w+e*t._x+i*t._y+r*t._z;if(c<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,c=-c):this.copy(t),c>=1)return this._w=o,this._x=e,this._y=i,this._z=r,this;const a=1-c*c;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*i+n*this._y,this._z=g*r+n*this._z,this.normalize(),this}const h=Math.sqrt(a),l=Math.atan2(h,c),u=Math.sin((1-n)*l)/h,d=Math.sin(n*l)/h;return this._w=o*u+this._w*d,this._x=e*u+this._x*d,this._y=i*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(),i=Math.sqrt(1-e),r=Math.sqrt(e);return this.set(i*Math.sin(t),i*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 D=class D{constructor(t,n,e){this.x=0,this.y=0,this.z=0;const i=+(t!==void 0)+ +(n!==void 0)+ +(e!==void 0);if(i!==0){if(i===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(i===1){const{x:r,y:o,z:c}=t;this.x=r,this.y=o,this.z=c||0;return}if(i===3){this.x=t,this.y=n,this.z=e;return}throw j.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 D(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(be.setFromEuler(t))}applyAxisAngle(t,n){return this.applyQuaternion(be.setFromAxisAngle(t,n))}applyMatrix3(t){const n=this.x,e=this.y,i=this.z,r=t.elements;return this.x=r[0]*n+r[3]*e+r[6]*i,this.y=r[1]*n+r[4]*e+r[7]*i,this.z=r[2]*n+r[5]*e+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const n=this.x,e=this.y,i=this.z,r=t.elements,o=1/(r[3]*n+r[7]*e+r[11]*i+r[15]);return this.x=(r[0]*n+r[4]*e+r[8]*i+r[12])*o,this.y=(r[1]*n+r[5]*e+r[9]*i+r[13])*o,this.z=(r[2]*n+r[6]*e+r[10]*i+r[14])*o,this}applyQuaternion(t){const n=this.x,e=this.y,i=this.z,r=t.x,o=t.y,c=t.z,a=t.w,h=2*(o*i-c*e),l=2*(c*n-r*i),u=2*(r*e-o*n);return this.x=n+a*h+o*u-c*l,this.y=e+a*l+c*h-r*u,this.z=i+a*u+r*l-o*h,this}transformDirection(t){const n=this.x,e=this.y,i=this.z,r=t.elements;return this.x=r[0]*n+r[4]*e+r[8]*i,this.y=r[1]*n+r[5]*e+r[9]*i,this.z=r[2]*n+r[6]*e+r[10]*i,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(),i=t.length();return Math.abs(n)===e*i}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,i=t.y,r=t.z,o=n.x,c=n.y,a=n.z;return this.x=i*a-r*c,this.y=r*o-e*a,this.z=e*c-i*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 wn.copy(this).projectOnVector(t),this.sub(wn)}reflect(t){return this.sub(wn.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,i=this.z-t.z;return n*n+e*e+i*i}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(),i=this.setFromMatrixColumn(t,2).length();return this.x=n,this.y=e,this.z=i,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}};D.ORIGIN=Object.freeze(new D(0,0,0)),D.X_AXIS=Object.freeze(new D(1,0,0)),D.NEGATIVE_X_AXIS=Object.freeze(new D(-1,0,0)),D.Y_AXIS=Object.freeze(new D(0,1,0)),D.NEGATIVE_Y_AXIS=Object.freeze(new D(0,-1,0)),D.Z_AXIS=Object.freeze(new D(0,0,1)),D.NEGATIVE_Z_AXIS=Object.freeze(new D(0,0,-1));let P=D;const wn=new P,be=new Rt,Bt=class Bt{static makeTranslation(t,n,e){return new Bt().makeTranslation(t,n,e)}constructor(t,n,e,i,r,o,c,a,h,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&&i!=null&&r!=null&&o!=null&&c!=null&&a!=null&&h!=null&&l!=null&&u!=null&&d!=null&&g!=null&&m!=null&&y!=null&&f!=null&&this.set(t,n,e,i,r,o,c,a,h,l,u,d,g,m,y,f)}set(t,n,e,i,r,o,c,a,h,l,u,d,g,m,y,f){const x=this.elements;return x[0]=t,x[4]=n,x[8]=e,x[12]=i,x[1]=r,x[5]=o,x[9]=c,x[13]=a,x[2]=h,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 Bt().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(yt.equalPoint3d(e,P.Z_AXIS))this.identity();else{const i=new P(1,0,0);Math.abs(e.x)<1/64&&Math.abs(e.y)<1/64?i.crossVectors(P.Y_AXIS,e).normalize():i.crossVectors(P.Z_AXIS,e).normalize();const r=e.clone().cross(i).normalize();this.makeBasis(i,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,i=1/zt.setFromMatrixColumn(t,0).length(),r=1/zt.setFromMatrixColumn(t,1).length(),o=1/zt.setFromMatrixColumn(t,2).length();return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,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(Vs,t,js)}lookAt(t,n,e){const i=this.elements;return Q.subVectors(t,n),Q.lengthSq()===0&&(Q.z=1),Q.normalize(),dt.crossVectors(e,Q),dt.lengthSq()===0&&(Math.abs(e.z)===1?Q.x+=1e-4:Q.z+=1e-4,Q.normalize(),dt.crossVectors(e,Q)),dt.normalize(),Dt.crossVectors(Q,dt),i[0]=dt.x,i[4]=Dt.x,i[8]=Q.x,i[1]=dt.y,i[5]=Dt.y,i[9]=Q.y,i[2]=dt.z,i[6]=Dt.z,i[10]=Q.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const e=t.elements,i=n.elements,r=this.elements,o=e[0],c=e[4],a=e[8],h=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],p=e[3],k=e[7],E=e[11],N=e[15],B=i[0],T=i[4],I=i[8],R=i[12],G=i[1],V=i[5],$=i[9],K=i[13],L=i[2],at=i[6],an=i[10],hn=i[14],ln=i[3],un=i[7],dn=i[11],gn=i[15];return r[0]=o*B+c*G+a*L+h*ln,r[4]=o*T+c*V+a*at+h*un,r[8]=o*I+c*$+a*an+h*dn,r[12]=o*R+c*K+a*hn+h*gn,r[1]=l*B+u*G+d*L+g*ln,r[5]=l*T+u*V+d*at+g*un,r[9]=l*I+u*$+d*an+g*dn,r[13]=l*R+u*K+d*hn+g*gn,r[2]=m*B+y*G+f*L+x*ln,r[6]=m*T+y*V+f*at+x*un,r[10]=m*I+y*$+f*an+x*dn,r[14]=m*R+y*K+f*hn+x*gn,r[3]=p*B+k*G+E*L+N*ln,r[7]=p*T+k*V+E*at+N*un,r[11]=p*I+k*$+E*an+N*dn,r[15]=p*R+k*K+E*hn+N*gn,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],i=t[8],r=t[12],o=t[1],c=t[5],a=t[9],h=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*(+r*a*u-i*h*u-r*c*d+e*h*d+i*c*g-e*a*g)+y*(+n*a*g-n*h*d+r*o*d-i*o*g+i*h*l-r*a*l)+f*(+n*h*u-n*c*g-r*o*u+e*o*g+r*c*l-e*h*l)+x*(-i*c*l-n*a*u+n*c*d+i*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 i=this.elements;return t instanceof P?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=n,i[14]=e),this}invert(){const t=this.elements,n=t[0],e=t[1],i=t[2],r=t[3],o=t[4],c=t[5],a=t[6],h=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],p=u*f*h-y*d*h+y*a*g-c*f*g-u*a*x+c*d*x,k=m*d*h-l*f*h-m*a*g+o*f*g+l*a*x-o*d*x,E=l*y*h-m*u*h+m*c*g-o*y*g-l*c*x+o*u*x,N=m*u*a-l*y*a-m*c*d+o*y*d+l*c*f-o*u*f,B=n*p+e*k+i*E+r*N;if(B===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/B;return t[0]=p*T,t[1]=(y*d*r-u*f*r-y*i*g+e*f*g+u*i*x-e*d*x)*T,t[2]=(c*f*r-y*a*r+y*i*h-e*f*h-c*i*x+e*a*x)*T,t[3]=(u*a*r-c*d*r-u*i*h+e*d*h+c*i*g-e*a*g)*T,t[4]=k*T,t[5]=(l*f*r-m*d*r+m*i*g-n*f*g-l*i*x+n*d*x)*T,t[6]=(m*a*r-o*f*r-m*i*h+n*f*h+o*i*x-n*a*x)*T,t[7]=(o*d*r-l*a*r+l*i*h-n*d*h-o*i*g+n*a*g)*T,t[8]=E*T,t[9]=(m*u*r-l*y*r-m*e*g+n*y*g+l*e*x-n*u*x)*T,t[10]=(o*y*r-m*c*r+m*e*h-n*y*h-o*e*x+n*c*x)*T,t[11]=(l*c*r-o*u*r-l*e*h+n*u*h+o*e*g-n*c*g)*T,t[12]=N*T,t[13]=(l*y*i-m*u*i+m*e*d-n*y*d-l*e*f+n*u*f)*T,t[14]=(m*c*i-o*y*i-m*e*a+n*y*a+o*e*f-n*c*f)*T,t[15]=(o*u*i-l*c*i+l*e*a-n*u*a-o*e*d+n*c*d)*T,this}scale(t){const n=this.elements,e=t.x,i=t.y,r=t.z;return n[0]*=e,n[4]*=i,n[8]*=r,n[1]*=e,n[5]*=i,n[9]*=r,n[2]*=e,n[6]*=i,n[10]*=r,n[3]*=e,n[7]*=i,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],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(n,e,i))}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),i=Math.sin(n),r=1-e,o=t.x,c=t.y,a=t.z,h=r*o,l=r*c;return this.set(h*o+e,h*c-i*a,h*a+i*c,0,h*c+i*a,l*c+e,l*a-i*o,0,h*a-i*c,l*a+i*o,r*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}setToMirroring(t,n,e="line"){return e==="plane"?Fs(this,t,n):Ls(this,t,n),this}makeShear(t,n,e,i,r,o){return this.set(1,e,r,0,t,1,o,0,n,i,1,0,0,0,0,1),this}compose(t,n,e){const i=this.elements,r=n.x,o=n.y,c=n.z,a=n.w,h=r+r,l=o+o,u=c+c,d=r*h,g=r*l,m=r*u,y=o*l,f=o*u,x=c*u,p=a*h,k=a*l,E=a*u,N=e.x,B=e.y,T=e.z;return i[0]=(1-(y+x))*N,i[1]=(g+E)*N,i[2]=(m-k)*N,i[3]=0,i[4]=(g-E)*B,i[5]=(1-(d+x))*B,i[6]=(f+p)*B,i[7]=0,i[8]=(m+k)*T,i[9]=(f-p)*T,i[10]=(1-(d+y))*T,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,n,e){const i=this.elements;let r=zt.set(i[0],i[1],i[2]).length();const o=zt.set(i[4],i[5],i[6]).length(),c=zt.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],it.copy(this);const h=1/r,l=1/o,u=1/c;return it.elements[0]*=h,it.elements[1]*=h,it.elements[2]*=h,it.elements[4]*=l,it.elements[5]*=l,it.elements[6]*=l,it.elements[8]*=u,it.elements[9]*=u,it.elements[10]*=u,n.setFromRotationMatrix(it),e.x=r,e.y=o,e.z=c,this}equals(t){const n=this.elements,e=t.elements;for(let i=0;i<16;i++)if(n[i]!==e[i])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}};Bt.IDENTITY=Object.freeze(new Bt);let O=Bt;function Ls(s,t,n){const e=n.x-t.x,i=n.y-t.y,r=e*e+i*i;if(w.equalToZero(Math.sqrt(r)))return s.copy(new O().makeTranslation(t.x,t.y,t.z??0).multiply(new O().makeScale(-1,1,1)).multiply(new O().makeTranslation(-t.x,-t.y,-(t.z??0))));const o=Math.atan2(i,e),c=t.z??0;return s.copy(new O().makeTranslation(t.x,t.y,c).multiply(new O().makeRotationZ(o)).multiply(new O().makeScale(1,-1,1)).multiply(new O().makeRotationZ(-o)).multiply(new O().makeTranslation(-t.x,-t.y,-c)))}function Fs(s,t,n){const e=n.x,i=n.y,r=n.z??0,o=Math.hypot(e,i,r);if(w.equalToZero(o))return s.identity();const c=e/o,a=i/o,h=r/o,l=t.x,u=t.y,d=t.z??0,g=c*l+a*u+h*d;return s.set(1-2*c*c,-2*c*a,-2*c*h,2*g*c,-2*a*c,1-2*a*a,-2*a*h,2*g*a,-2*h*c,-2*h*a,1-2*h*h,2*g*h,0,0,0,1)}const zt=new P,it=new O,Vs=new P(0,0,0),js=new P(1,1,1),dt=new P,Dt=new P,Q=new P;class rt{constructor(t=void 0,n=void 0){this.min=t==null?new P(1/0,1/0,1/0):new P(t.x,t.y,t.z),this.max=n==null?new P(-1/0,-1/0,-1/0):new P(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(pn.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=pn.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new rt().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 P(0,0,0):new P(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new P(0,0,0):new P(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.z)?this:(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,pn).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:(ht[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ht[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ht[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ht[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ht[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ht[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ht[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ht[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ht),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 ht=[new P,new P,new P,new P,new P,new P,new P,new P],pn=new P,Se=new q;class tt{constructor(t=void 0,n=void 0){this.min=t==null?new q(1/0,1/0):new q(t.x,t.y),this.max=n==null?new q(-1/0,-1/0):new q(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=Se.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new tt().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 q(0,0):new q(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new q(0,0):new q(0,0).subVectors(this.max,this.min)}expandByPoint(t){return!Number.isFinite(t.x)||!Number.isFinite(t.y)?this:(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,Se).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 Ce=new P,Os=new P,Us=new Mt;class bt{constructor(t=new P(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,i){return this.normal.set(t,n,e),this.constant=i,this}setFromNormalAndCoplanarPoint(t,n){return this.normal.copy(t),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(t,n,e){const i=Ce.subVectors(e,n).cross(Os.subVectors(t,n)).normalize();return this.setFromNormalAndCoplanarPoint(i,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||Us.getNormalMatrix(t),i=this.coplanarPoint(Ce).applyMatrix4(t),r=this.normal.applyMatrix3(e).normalize();return this.constant=-i.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 bt().copy(this)}}class _ extends q{clone(){return new _(this.x,this.y)}static pointArrayToNumberArray(t){const n=new Array(t.length*2);return t.forEach((e,i)=>{e.toArray(n,i*2)}),n}}class z extends P{clone(){return new z(this.x,this.y,this.z)}static pointArrayToNumberArray(t,n=!0){const e=n?3:2,i=new Array(t.length*e);return t.forEach((r,o)=>{r.toArray(i,o*e)}),i}}const Te=new O,ke=new Rt,Ut=class Ut{constructor(t=0,n=0,e=0,i=Ut.DEFAULT_ORDER){this._x=t,this._y=n,this._z=e,this._order=i}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,i=this._order){return this._x=t,this._y=n,this._z=e,this._order=i,this._onChangeCallback(),this}clone(){return new Ut(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 i=t.elements,r=i[0],o=i[4],c=i[8],a=i[1],h=i[5],l=i[9],u=i[2],d=i[6],g=i[10];switch(n){case"XYZ":this._y=Math.asin(J(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-l,g),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-J(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(c,g),this._z=Math.atan2(a,h)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(J(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,g),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-J(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,g),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-o,h));break;case"YZX":this._z=Math.asin(J(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(c,g));break;case"XZY":this._z=Math.asin(-J(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(c,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 Te.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Te,n,e)}setFromVector3(t,n=this._order){return this.set(t.x,t.y,t.z,n)}reorder(t){return ke.setFromEuler(this),this.setFromQuaternion(ke,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}};Ut.DEFAULT_ORDER="XYZ";let Mn=Ut;function zn(s){const t=s.length;if(t<3)return 0;let n=0;for(let e=0,i=t-1;e<t;i=e++){const r=s[i],o=s[e];n+=r.x*o.y-o.x*r.y}return n*.5}function Ee(s){return Math.abs(zn(s))}function Ie(s){const t=s.length;if(t<3)return 0;let n=0,e=0,i=0;for(let r=0,o=t-1;r<t;o=r++){const c=s[o],a=s[r],h=c.x,l=c.y,u=c.z??0,d=a.x,g=a.y,m=a.z??0;n+=(u+m)*(l-g),e+=(h+d)*(u-m),i+=(l+g)*(h-d)}return .5*Math.hypot(n,e,i)}function Ds(s){return s.length<3?0:Ee(s)}function Ne(s){return s.length<3?0:Ie(s)}function Zs(s){const t=s;return{x:s.x,y:s.y,z:t.z??0}}function Xs(s,t){s.x+=t.x,s.y+=t.y,s.z=(s.z??0)+(t.z??0)}function Ys(s,t,n=!1){const e=s.x,i=s.y;let r=!1;const o=t.length;for(let c=0,a=o-1;c<o;a=c++){const h=t[c].x,l=t[c].y,u=t[a].x,d=t[a].y;let g=l>i!=d>i;n&&(g=l>=i!=d>=i),g&&e<(u-h)*(i-l)/(d-l)+h&&(r=!r)}return r}function Gs(s,t){if(s.length===0||t.length===0)return!1;const n=new tt().setFromPoints(s),e=new tt().setFromPoints(t);if(!n.intersectsBox(e))return!1;for(let i=0;i<s.length;){if(Y.isPointInPolygon(s[i],t,!0))return!0;i<s.length-1&&yt.equalPoint2d(s[i+1],s[i])&&++i,++i}return!1}const Y={applyOffsetToPoint3d:Xs,isPointInPolygon:Ys,isPolygonIntersect:Gs,point2dToPoint3d:Zs};function Ws(s,t){const n=[],e=t-1,i=s;for(let r=0;r<=i;r++)n.push(0);for(let r=1;r<=e-i;r++)n.push(r);for(let r=0;r<=i;r++)n.push(e-i+1);return n}function Ks(s,t){const n=t.length-1,e=s,i=[0];let r=0;for(let c=1;c<=n;c++){const a=t[c][0]-t[c-1][0],h=t[c][1]-t[c-1][1],l=t[c][2]-t[c-1][2],u=Math.sqrt(a*a+h*h+l*l);r+=u,i.push(r)}const o=[];for(let c=0;c<=e;c++)o.push(0);for(let c=1;c<=n-e;c++){const a=i[c]/r;o.push(a*(n-e+1))}for(let c=0;c<=e;c++)o.push(n-e+1);return o}function Be(s,t="Uniform"){const n=s.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,c)=>c/e);const i=[0];let r=0;for(let o=1;o<=e;o++){const c=s[o][0]-s[o-1][0],a=s[o][1]-s[o-1][1],h=s[o][2]-s[o-1][2],l=Math.sqrt(c*c+a*a+h*h),u=t==="SqrtChord"?Math.sqrt(l):l;r+=u,i.push(r)}return r<1e-12?new Array(n).fill(0).map((o,c)=>c/e):i.map(o=>o/r)}function Re(s,t){const n=t.length-1,e=s,i=n+e+1,r=new Array(i+1).fill(0),o=t[t.length-1];for(let c=i-e;c<=i;c++)r[c]=o;for(let c=1;c<=n-e;c++){let a=0;for(let h=c;h<c+e;h++)a+=t[h];r[c+e]=a/e}return r}function Qs(s,t){const n=t.length-1,e=s,i=[0];let r=0;for(let c=1;c<=n;c++){const a=t[c][0]-t[c-1][0],h=t[c][1]-t[c-1][1],l=t[c][2]-t[c-1][2],u=Math.sqrt(a*a+h*h+l*l),d=Math.sqrt(u);r+=d,i.push(r)}const o=[];for(let c=0;c<=e;c++)o.push(0);for(let c=1;c<=n-e;c++){const a=i[c]/r;o.push(a*(n-e+1))}for(let c=0;c<=e;c++)o.push(n-e+1);return o}function Zt(s,t){for(const n of s)if(n.col===t)return n.value;return 0}function ve(s,t){for(let n=0;n<s.length;n++)if(s[n].col===t)return n;return-1}function Hs(s,t){const n=s.length,e=s.map(o=>o.map(c=>({col:c.col,value:c.value}))),i=t.map(o=>o.slice());for(let o=0;o<n;o++){let c=-1,a=1e-12;for(let l=o;l<n;l++){const u=Math.abs(Zt(e[l],o));u>a&&(a=u,c=l)}if(c<0)throw new Error("Interpolation matrix is singular.");if(c!==o){const l=e[o];e[o]=e[c],e[c]=l;for(const u of i){const d=u[o];u[o]=u[c],u[c]=d}}const h=Zt(e[o],o);for(let l=o+1;l<n;l++){const u=ve(e[l],o);if(u<0)continue;const d=e[l][u].value/h;if(!(Math.abs(d)<1e-14)){for(const g of e[l])g.col>o&&(g.value-=d*Zt(e[o],g.col));for(const g of e[o])g.col<=o||g.value===0||ve(e[l],g.col)<0&&e[l].push({col:g.col,value:-d*g.value});e[l][u].value=0;for(const g of i)g[l]-=d*g[o]}}}const r=i.map(()=>new Array(n).fill(0));for(let o=n-1;o>=0;o--){const c=Zt(e[o],o);for(let a=0;a<i.length;a++){let h=i[a][o];for(const l of e[o])l.col>o&&(h-=l.value*r[a][l.col]);r[a][o]=h/c}}return r}function $s(s,t,n){const e=n.length-t-2;if(s>=n[e+1])return e;let i=t,r=n.length-t-2;for(;i<=r;){const o=i+r>>1;if(s<n[o])r=o-1;else if(s>=n[o+1])i=o+1;else return o}return t}function bn(s,t,n="Uniform",e,i){if(s.length===0)return{controlPoints:[],knots:[],weights:[]};const r=s.map(I=>[I[0],I[1],I[2]??0]),o=!!e,c=!!i,a=(o?1:0)+(c?1:0),h=r.length-1,l=h+a;if(l<t)throw new Error("Not enough points to interpolate a curve of this degree.");const u=Be(r,n),d=u.slice();o&&d.unshift(u[0]),c&&d.push(u[u.length-1]);const g=Re(t,d),m=l+1,y=[],f=[],x=[],p=[];if(o){const I=g[t+1]-g[0],R=I!==0?t/I:0;y.push([{col:0,value:-R},{col:1,value:R}]),f.push((e==null?void 0:e[0])??0),x.push((e==null?void 0:e[1])??0),p.push((e==null?void 0:e[2])??0)}y.push([{col:0,value:1}]),f.push(r[0][0]),x.push(r[0][1]),p.push(r[0][2]);for(let I=1;I<=h-1;I++){const R=u[I],G=[],V=$s(R,t,g),$=Math.max(0,V-t),K=Math.min(l,V);for(let L=$;L<=K;L++){const at=gt(L,t,R,g);at!==0&&G.push({col:L,value:at})}y.push(G),f.push(r[I][0]),x.push(r[I][1]),p.push(r[I][2])}if(y.push([{col:l,value:1}]),f.push(r[h][0]),x.push(r[h][1]),p.push(r[h][2]),c){const I=g[l+t+1]-g[l],R=I!==0?t/I:0;y.push([{col:l-1,value:-R},{col:l,value:R}]),f.push((i==null?void 0:i[0])??0),x.push((i==null?void 0:i[1])??0),p.push((i==null?void 0:i[2])??0)}const[k,E,N]=Hs(y,[f,x,p]),B=new Array(m);for(let I=0;I<m;I++)B[I]=[k[I],E[I],N[I]];const T=new Array(m).fill(1);return{controlPoints:B,knots:g,weights:T}}function gt(s,t,n,e){if(t===0)return n>=e[s]&&n<e[s+1]?1:0;const i=e[s+t]-e[s],r=e[s+t+1]-e[s+1],o=i>1e-10?(n-e[s])/i:0,c=r>1e-10?(e[s+t+1]-n)/r:0;return o*gt(s,t-1,n,e)+c*gt(s+1,t-1,n,e)}function vt(s,t,n,e,i){const r=e.length-1,o=t;if(s=Math.max(n[o],Math.min(n[r+1],s)),Math.abs(s-n[r+1])<1e-8)return[...e[r]];if(Math.abs(s-n[o])<1e-8)return[...e[0]];const c=[0,0,0];let a=0;for(let h=0;h<=r;h++){const l=gt(h,o,s,n),u=i[h]*l;c[0]+=e[h][0]*u,c[1]+=e[h][1]*u,c[2]+=e[h][2]*u,a+=u}if(Math.abs(a)<1e-10){const h=n[n.length-o-1];if(Math.abs(s-h)<1e-8)return[...e[r]];if(Math.abs(s-n[o])<1e-8)return[...e[0]]}return Math.abs(a)>=1e-10&&(c[0]/=a,c[1]/=a,c[2]/=a),c}function Sn(s,t,n,e){if(t===0)return 0;const i=e[s+t]-e[s],r=e[s+t+1]-e[s+1];let o=0;return i>1e-10&&(o+=t/i*gt(s,t-1,n,e)),r>1e-10&&(o-=t/r*gt(s+1,t-1,n,e)),o}function Js(s,t,n,e){if(t<=1)return 0;const i=e[s+t]-e[s],r=e[s+t+1]-e[s+1];let o=0;return i>1e-10&&(o+=t/i*Sn(s,t-1,n,e)),r>1e-10&&(o-=t/r*Sn(s+1,t-1,n,e)),o}function Xt(s,t,n,e,i){const r=e.length-1,o=t,c=n[o],a=n[r+1];s=Math.max(c,Math.min(a,s));const h=[0,0,0],l=[0,0,0],u=[0,0,0];let d=0,g=0,m=0;for(let B=0;B<=r;B++){const T=gt(B,o,s,n),I=Sn(B,o,s,n),R=Js(B,o,s,n),G=i[B],V=G*T,$=G*I,K=G*R,L=e[B];h[0]+=V*L[0],h[1]+=V*L[1],h[2]+=V*L[2],l[0]+=$*L[0],l[1]+=$*L[1],l[2]+=$*L[2],u[0]+=K*L[0],u[1]+=K*L[1],u[2]+=K*L[2],d+=V,g+=$,m+=K}if(Math.abs(d)<1e-10)return{point:vt(s,t,n,e,i),deriv1:[0,0,0],deriv2:[0,0,0]};const y=d*d,f=[h[0]/d,h[1]/d,h[2]/d],x=[(l[0]*d-h[0]*g)/y,(l[1]*d-h[1]*g)/y,(l[2]*d-h[2]*g)/y],p=u[0]*d-h[0]*m,k=u[1]*d-h[1]*m,E=u[2]*d-h[2]*m,N=[p/y-2*g*x[0]/d,k/y-2*g*x[1]/d,E/y-2*g*x[2]/d];return{point:f,deriv1:x,deriv2:N}}function qe(s,t){const n=s[0],e=s[1],i=t[0],r=t[1],o=n*n+e*e;return o<1e-20?0:(n*r-e*i)/Math.pow(o,1.5)}function Cn(s,t,n,e){const i=s,r=t[i],o=t[t.length-i-1];let c=0;const a=1e3,h=(o-r)/a;let l=vt(r,s,t,n,e);for(let y=1;y<=a;y++){const f=r+y*h,x=vt(f,s,t,n,e),p=x[0]-l[0],k=x[1]-l[1],E=x[2]-l[2];c+=Math.sqrt(p*p+k*k+E*E),l=x}const u=vt(o,s,t,n,e),d=u[0]-l[0],g=u[1]-l[1],m=u[2]-l[2];return c+=Math.sqrt(d*d+g*g+m*m),c}function ti(s,t=3,n="Uniform",e,i){return s.length===0?[]:bn(s,t,n,e,i).controlPoints}const Tn=1e-10;function ni(s){return s.controlPoints.map((t,n)=>{const e=s.weights[n]??1;return[t.x*e,t.y*e,(t.z??0)*e,e]})}function ei(s,t,n){const e=[],i=[];for(const[r,o,c,a]of n){const h=a===0?1:a;e.push({x:r/h,y:o/h,z:c/h}),i.push(a)}return{degree:s,knots:t,controlPoints:e,weights:i}}function qt(s){const{degree:t,knots:n}=s;return{start:n[t],end:n[n.length-t-1]}}function kn(s,t,n,e=Tn){const i=s.degree,r=s.knots,o=r.length-1,c=s.controlPoints.length-1;for(const f of r)if(Math.abs(f-t)<=e){t=f;break}let a=-1,h=0;for(let f=0;f<=o;f++)r[f]<=t&&(a=f),r[f]===t&&h++;const l=Math.min(n,i-h);if(l<=0||a<i||a>=o)return{degree:i,knots:[...r],controlPoints:s.controlPoints.map(f=>({x:f.x,y:f.y,z:f.z??0})),weights:[...s.weights]};const u=ni(s),d=new Array(o+l+1),g=new Array(c+l+1),m=new Array(i+1);for(let f=0;f<=a;f++)d[f]=r[f];for(let f=1;f<=l;f++)d[a+f]=t;for(let f=a+1;f<=o;f++)d[f+l]=r[f];for(let f=0;f<=a-i;f++)g[f]=[...u[f]];for(let f=a-h;f<=c;f++)g[f+l]=[...u[f]];for(let f=0;f<=i-h;f++)m[f]=[...u[a-i+f]];let y=a-i;for(let f=1;f<=l;f++){y=a-i+f;for(let x=0;x<=i-f-h;x++){const p=(t-r[y+x])/(r[x+a+1]-r[y+x]),k=m[x+1],E=m[x];m[x]=[p*k[0]+(1-p)*E[0],p*k[1]+(1-p)*E[1],p*k[2]+(1-p)*E[2],p*k[3]+(1-p)*E[3]]}g[y]=[...m[0]],g[a+l-f-h]=[...m[i-f-h]]}for(let f=y+1;f<a-h;f++)g[f]=[...m[f-y]];return ei(i,d,g)}function Yt(s,t,n,e=Tn){const i=s.degree,r=qt(s);if(t=Math.max(r.start,Math.min(r.end,t)),n=Math.max(r.start,Math.min(r.end,n)),n-t<=e)return;let o=kn(s,t,i,e);o=kn(o,n,i,e);const c=o.knots,a=f=>{for(const x of c)if(Math.abs(x-f)<=e)return x;return f},h=a(t),l=a(n);let u=-1,d=-1;for(let f=0;f<c.length;f++)c[f]===h&&(u=f),d<0&&c[f]===l&&(d=f);if(u<0||d<0)return;const g=u-i,m=d-1;if(g<0||m>=o.controlPoints.length||m<g)return;const y=[];for(let f=0;f<=i;f++)y.push(h);for(let f=u+1;f<d;f++)y.push(c[f]);for(let f=0;f<=i;f++)y.push(l);return{degree:i,knots:y,controlPoints:o.controlPoints.slice(g,m+1),weights:o.weights.slice(g,m+1)}}function si(s,t,n=Tn){const e=qt(s);if(t<=e.start+n||t>=e.end-n)return;const i=Yt(s,e.start,t,n),r=Yt(s,t,e.end,n);return i&&r?[i,r]:void 0}function ii(s,t){const n=s.degree;if(t.degree!==n)return;const e=s.knots[s.knots.length-1],i=t.knots[0],r=e-i,o=s.knots.slice(0,s.knots.length-1);for(let d=n+1;d<t.knots.length;d++)o.push(t.knots[d]+r);const c=s.weights[s.weights.length-1]??1,a=t.weights[0]??1,h=a===0?1:c/a,l=[...s.controlPoints.map(d=>({x:d.x,y:d.y,z:d.z??0})),...t.controlPoints.slice(1).map(d=>({x:d.x,y:d.y,z:d.z??0}))],u=[...s.weights,...t.weights.slice(1).map(d=>d*h)];return{degree:n,knots:o,controlPoints:l,weights:u}}function ri(s,t){return Xt(t,s.degree,s.knots,s.controlPoints.map(n=>[n.x,n.y,n.z??0]),s.weights)}function oi(s,t){const n=s[0]-t.x,e=s[1]-t.y,i=s[2]-(t.z??0);return n*n+e*e+i*i}function ci(s,t,n=128){const{start:e,end:i}=qt(s);if(!(i>e))return e;const r=Math.max(n,s.controlPoints.length*16),o=s.controlPoints.map(T=>[T.x,T.y,T.z??0]),c=T=>Xt(T,s.degree,s.knots,o,s.weights),a=T=>oi(c(T).point,t);let h=0,l=1/0;const u=(i-e)/r;for(let T=0;T<=r;T++){const I=a(e+T*u);I<l&&(l=I,h=T)}let d=e+Math.max(0,h-1)*u,g=e+Math.min(r,h+1)*u;const m=(Math.sqrt(5)-1)/2;let y=g-m*(g-d),f=d+m*(g-d),x=a(y),p=a(f);for(let T=0;T<60&&g-d>1e-14*(i-e);T++)x<p?(g=f,f=y,p=x,y=g-m*(g-d),x=a(y)):(d=y,y=f,x=p,f=d+m*(g-d),p=a(f));let k=(d+g)/2,E=a(k);for(let T=0;T<8;T++){const{point:I,deriv1:R,deriv2:G}=c(k),V=[I[0]-t.x,I[1]-t.y,I[2]-(t.z??0)],$=R[0]*V[0]+R[1]*V[1]+R[2]*V[2],K=G[0]*V[0]+G[1]*V[1]+G[2]*V[2]+R[0]*R[0]+R[1]*R[1]+R[2]*R[2];if(!(Math.abs(K)>1e-30))break;const L=Math.max(e,Math.min(i,k-$/K)),at=a(L);if(!(at<E))break;k=L,E=at}const N=a(e),B=a(i);return N<E&&N<=B?e:B<E?i:k}function ai(s,t){const{start:n}=qt(s),e=Yt(s,n,t);return e?Cn(e.degree,e.knots,e.controlPoints.map(i=>[i.x,i.y,i.z??0]),e.weights):0}const Gt=new O,Le=new P,hi=new P,li=new P,En=new z,Fe=new P;function ui(s){return new O().setFromExtrusionDirection(new P(s.x,s.y,s.z))}function di(s){return Ve(new P,s)}function Ve(s,t){return Gt.setFromExtrusionDirection(Fe.set(t.x,t.y,t.z)),Gt.extractBasis(Le,hi,li),s.copy(Le),s}function gi(s,t){return je(new z,s,t)}function je(s,t,n){return n.x===0&&n.y===0&&n.z===1?(s.set(t.x,t.y,t.z??0),s):(Gt.setFromExtrusionDirection(Fe.set(n.x,n.y,n.z)),s.set(t.x,t.y,t.z??0),s.applyMatrix4(Gt),s)}function In(s,t){return new z(s.x,s.y,s.z??0).applyMatrix4(ui(t).invert())}function mi(s,t,n){const e=In(s,n),i=In(t,n);return En.set(i.x-e.x,i.y-e.y,(i.z??0)-(e.z??0)),M.normalizeAngle(Math.atan2(En.y,En.x))}function Nn(s,t,n){const e=s.x,i=s.y,r=t.x,o=t.y,c=n.x,a=n.y,h=2*(e*(o-a)+r*(a-i)+c*(i-o));if(w.equalToZero(h))return null;const l=((e*e+i*i)*(o-a)+(r*r+o*o)*(a-i)+(c*c+a*a)*(i-o))/h,u=((e*e+i*i)*(c-r)+(r*r+o*o)*(e-c)+(c*c+a*a)*(r-e))/h,d=Math.hypot(l-e,u-i);return!Number.isFinite(d)||w.isNonPositive(d)?null:{center:new _(l,u),radius:d}}function Oe(s,t,n){const e=s.x,i=s.y,r=s.z??0,o=new P(t.x-e,t.y-i,(t.z??0)-r),c=new P(n.x-e,n.y-i,(n.z??0)-r),a=new P().crossVectors(o,c),h=a.lengthSq();if(h<S*S)return null;const l=o.lengthSq(),u=c.lengthSq(),d=new P().crossVectors(a,o).multiplyScalar(u).add(new P().crossVectors(c,a).multiplyScalar(l)).multiplyScalar(1/(2*h)),g=new z(e+d.x,i+d.y,r+d.z),m=Math.hypot(g.x-e,g.y-i,g.z-r);return!Number.isFinite(m)||w.isNonPositive(m)?null:{center:g,radius:m}}function nt(s,t){return Math.atan2(t.y-s.y,t.x-s.x)}function F(s,t){return Math.hypot(t.x-s.x,t.y-s.y)}function Ue(s,t,n){if(w.isNonPositive(t))return null;const e=n.x-s.x,i=n.y-s.y,r=Math.hypot(e,i);if(w.isNonPositive(r))return null;const o=t/r;return new _(s.x+e*o,s.y+i*o)}const fi=1e-8;function De(s,t,n,e){return Math.abs(F(s,t)-n)<=(e??Math.max(S,n*1e-5))}function Ze(s,t,n,e,i=fi){return Math.abs(s.x-n.x)<=i&&Math.abs(s.y-n.y)<=i&&Math.abs(t-e)<=i}function Xe(s,t,n,e){const i=Math.max(1e-18,Math.abs(n)*1e-9);return s<n-i?!0:s>n+i?!1:t>e}function Bn(s,t,n,e=!1){const i=Nn(s,t,n);if(!i)return null;const r=nt(i.center,s),o=nt(i.center,t),c=nt(i.center,n);let a=!M.isAngleOnCcwSweep(r,o,c);return e&&(a=!a),v.fromMathAngles(i.center,i.radius,r,c,a)}function Rn(s,t){return!Number.isFinite(t)||w.isNonPositive(t)?null:new v(s,t,0,C,!1)}function yi(s,t){const n=F(s,t);return w.isNonPositive(n)?null:Rn({x:(s.x+t.x)/2,y:(s.y+t.y)/2},n/2)}function xi(s,t,n){const e=Nn(s,t,n);return e?Rn(e.center,e.radius):null}function Ai(s,t,n){const e=F(n,s);if(w.isNonPositive(e))return null;const i=nt(n,s),r=nt(n,t),o=M.normalizeAngle(r-i);return v.fromMathAngles(n,e,i,r,o>Math.PI)}function Lt(s,t,n,e){const i=F(s,t),r=F(s,n);if(w.isNonPositive(i)||w.isNonPositive(r))return null;const o=Math.max(S,i*S);return Math.abs(i-r)>o?null:v.fromMathAngles(s,i,nt(s,t),nt(s,n),e)}function _i(s,t,n,e){const i=F(s,t);if(w.isNonPositive(i))return null;const r=Ue(s,i,n);return r?Lt(s,t,r,e):null}function Ye(s,t,n){const e=F(s,t),i=Math.abs(n);if(w.isNonPositive(e)||w.isNonPositive(i)||!w.great(C-i,0))return null;const r=n<0,o=nt(s,t),c=r?o-i:o+i;return v.fromMathAngles(s,e,o,c,r)}function Pi(s,t,n){const e=F(s,t),i=Math.abs(n);if(w.isNonPositive(e)||w.isNonPositive(i)||w.great(i,2*e))return null;const r=Math.max(-1,Math.min(1,i/(2*e))),o=2*Math.asin(r);return Ye(s,t,n>=0?o:-o)}function wi(s,t,n){const e=F(s,t),i=Math.abs(n);if(w.isNonPositive(e)||w.isNonPositive(i)||!w.great(C-i,0))return null;const r=Math.sin(i/2);if(w.equalToZero(r))return null;const o=e/(2*r),c=o*o-e*e/4;if(w.less(c,0))return null;const a=Math.sqrt(Math.max(0,c)),h=(s.x+t.x)/2,l=(s.y+t.y)/2,u=t.x-s.x,g=-(t.y-s.y)/e,m=u/e,y=n>=0,x=y&&i<=Math.PI||!y&&i>Math.PI?1:-1,p={x:h+g*a*x,y:l+m*a*x};return Lt(p,s,t,!y)}function Ge(s,t,n){const e=Math.cos(n),i=Math.sin(n),r=t.x-s.x,o=t.y-s.y,c=-i,a=e,h=2*(r*c+o*a);if(w.equalToZero(h))return null;const l=(r*r+o*o)/h;if(!Number.isFinite(l))return null;const u={x:s.x+c*l,y:s.y+a*l},d=s.x-u.x,g=s.y-u.y,m=d*i-g*e;return w.equalToZero(m)?null:Lt(u,s,t,m<0)}function We(s,t,n){const e=Math.abs(n),i=F(s,t);if(w.isNonPositive(e)||w.isNonPositive(i)||w.great(i,2*e))return null;const r=(s.x+t.x)/2,o=(s.y+t.y)/2,c=t.x-s.x,h=-(t.y-s.y)/i,l=c/i,u=Math.sqrt(Math.max(0,e*e-i*i/4)),d=n>=0?1:-1,g={x:r+h*u*d,y:o+l*u*d};return Lt(g,s,t,n<0)}class Ke{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class vn extends Ke{translate(t){return this.transform(new Mt().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class St extends vn{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,i=this.getPoint(0),r=0;n.push(0);for(let o=1;o<=t;o++)e=this.getPoint(o/t),r+=e.distanceTo(i),n.push(r),i=e;return n}getUtoTmapping(t,n){const e=this.getLengths();let i=0;const r=e.length;let o;n?o=n:o=t*e[r-1];let c=0,a=r-1,h;for(;c<=a;)if(i=Math.floor(c+(a-c)/2),h=e[i]-o,h<0)c=i+1;else if(h>0)a=i-1;else{a=i;break}if(i=a,e[i]===o)return i/(r-1);const l=e[i],d=e[i+1]-l,g=(o-l)/d;return(i+g)/(r-1)}getTangent(t){let e=t-1e-4,i=t+1e-4;e<0&&(e=0),i>1&&(i=1);const r=this.getPoint(e),o=this.getPoint(i),c=new _;return c.copy(o).sub(r).normalize(),c}getTangentAt(t){const n=this.getUtoTmapping(t);return this.getTangent(n)}}const Z=class Z extends St{constructor(t,n,e,i,r){super();const o=+(t!==void 0)+ +(n!==void 0)+ +(e!==void 0)+ +(i!==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 c=t;this.center=new _(c.x,c.y),this.radius=n,this._clockwise=r,this._startAngle=this._clockwise?this._mirrorAngle(M.normalizeAngle(e)):M.normalizeAngle(e),this._endAngle=this._clockwise?this._mirrorAngle(M.normalizeAngle(i)):M.normalizeAngle(i)}else throw j.AcCmErrors.ILLEGAL_PARAMETERS}static fromMathAngles(t,n,e,i,r){const o=new Z(t,n,M.normalizeAngle(e),M.normalizeAngle(i),!1);return o._clockwise=r,o._boundingBoxNeedsUpdate=!0,o}static computeCircumcircle(t,n,e){return Nn(t,n,e)}static projectPoint(t,n,e){return Ue(t,n,e)}static pointLiesOnCircle(t,n,e,i){return De(t,n,e,i)}static sameCircle(t,n,e,i,r){return Ze(t,n,e,i,r)}static isBetterDistanceAlign(t,n,e,i){return Xe(t,n,e,i)}static tryCreateByThreePoints(t,n,e,i=!1){return Bn(t,n,e,i)}static tryCreateCircle(t,n){return Rn(t,n)}static tryCreateCircleByDiameter(t,n){return yi(t,n)}static tryCreateCircleByThreePoints(t,n,e){return xi(t,n,e)}static tryCreateShorterArc(t,n,e){return Ai(t,n,e)}static tryCreateByCenterStartEnd(t,n,e,i){return Lt(t,n,e,i)}static tryCreateByCenterStartProjectedEnd(t,n,e,i){return _i(t,n,e,i)}static tryCreateByCenterStartSweep(t,n,e){return Ye(t,n,e)}static tryCreateByCenterStartChord(t,n,e){return Pi(t,n,e)}static tryCreateByStartEndAngle(t,n,e){return wi(t,n,e)}static tryCreateByStartEndDirection(t,n,e){return Ge(t,n,e)}static tryCreateByStartEndRadius(t,n,e){return We(t,n,e)}createByThreePoints(t,n,e){const i=Bn(t,n,e);if(!i)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this.center=i.center,this.radius=i.radius,this._clockwise=i._clockwise,this._startAngle=i._startAngle,this._endAngle=i._endAngle,this._boundingBoxNeedsUpdate=!0}createByStartEndPointsAndBulge(t,n,e){let i,r,o;e<0?(i=Math.atan(-e)*4,r=new q(t),o=new q(n)):(i=Math.atan(e)*4,r=new q(n),o=new q(t));const c=new q().subVectors(o,r),a=c.length(),h=new q().addVectors(r,c.multiplyScalar(.5)),l=Math.abs(a/2/Math.tan(i/2)),u=c.normalize(),d=e<0?-Math.PI/2:Math.PI/2,g=new q(u.x*Math.cos(d)-u.y*Math.sin(d),u.y*Math.cos(d)+u.x*Math.sin(d));let m;i<Math.PI?e<0?m=h.add(g.multiplyScalar(l)):m=h.add(g.multiplyScalar(-l)):e<0?m=h.add(g.multiplyScalar(-l)):m=h.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 _(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(M.normalizeAngle(t)):M.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==C?t:M.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?M.normalizeAngle(t-n):M.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?M.normalizeAngle(t-this.deltaAngle/2):M.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),i=Math.abs(n-t)/Math.PI%2,r=1e-12;return w.equalToZero(i,r)||w.equalToZero(2-i,r)}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);M.isBetweenAngle(o,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(r))}const e=t.map(r=>r.x),i=t.map(r=>r.y);return new tt(new _(Math.min(...e),Math.min(...i)),new _(Math.max(...e),Math.max(...i)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){const n=t,e=this.center.clone().applyMatrix2d(n),i=this.startPoint.clone().applyMatrix2d(n);if(this.closed)return this.center=e,this.radius=e.distanceTo(i),this._startAngle=Math.atan2(i.y-e.y,i.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),c=Z.tryCreateByThreePoints(i,r,o),a=n.determinant()<0?!this.clockwise:this.clockwise,h=l=>{const u=M.normalizeAngle(l);return a?this._mirrorAngle(u):u};if(!c){this.center=e;const l=e.distanceTo(i);return l>S&&(this.radius=l),this.clockwise=a,this.startAngle=h(Math.atan2(i.y-e.y,i.x-e.x)),this.endAngle=h(Math.atan2(o.y-e.y,o.x-e.x)),this._boundingBoxNeedsUpdate=!0,this}return this.center=c.center,this.radius=c.radius,this.clockwise=a,this.startAngle=h(Math.atan2(i.y-c.center.y,i.x-c.center.x)),this.endAngle=h(Math.atan2(o.y-c.center.y,o.x-c.center.x)),this._boundingBoxNeedsUpdate=!0,this}clone(){return new Z(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),i=this.center.y+this.radius*Math.sin(n);return new _(e,i)}getQuadrantPoints(){const t=[],n=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle),i=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const r of i){const o=this._getInternalAngle(r);M.isBetweenAngle(o,n,e,this.clockwise)&&t.push(this.getPointAtAngle(r))}return t}nearestPoint(t){const n=new _(t.x,t.y),e=n.x-this.center.x,i=n.y-this.center.y;if(Math.hypot(e,i)<1e-12)return this.startPoint.clone();const o=Math.atan2(i,e),c=this.clockwise?this._mirrorAngle(M.normalizeAngle(o)):M.normalizeAngle(o),a=this._getInternalAngle(c),h=this._getInternalAngle(this.startAngle),l=this._getInternalAngle(this.endAngle);if(M.isBetweenAngle(a,h,l,this.clockwise))return this.getPointAtAngle(c);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,i=n.y-t.y;if(e*e+i*i<1e-24)return 0;const r=this.radius>0?this.radius:1,o=Math.max(1e-16,1e-12*r*r),c=this.startPoint.distanceToSquared(t)<=o,a=this.endPoint.distanceToSquared(t)<=o;if(!c&&!a)return 0;const h=this.getPoints(8);if(h.length<3)return 0;const l=c&&!a?h[1]:h[h.length-2],u=l.x-t.x,d=l.y-t.y,g=Math.hypot(u,d);return g>1e-18?(e*u+i*d)/g:0}perpendicularPoints(t){const n=new _(t.x,t.y),e=n.x-this.center.x,i=n.y-this.center.y,r=Math.hypot(e,i);if(r<1e-12)return[];const o=e/r,c=i/r,a=[new _(this.center.x+o*this.radius,this.center.y+c*this.radius),new _(this.center.x-o*this.radius,this.center.y-c*this.radius)],h=[],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(M.normalizeAngle(g)):M.normalizeAngle(g),y=this._getInternalAngle(m);(this.closed||M.isBetweenAngle(y,l,u,this.clockwise))&&h.push(d)}return h}tangentPoints(t){const n=[],e=t.x-this.center.x,i=t.y-this.center.y,r=Math.hypot(e,i),o=this.radius;if(r<o)return n;const c=Math.acos(o/r),a=Math.atan2(i,e),h=[a+c,a-c],l=this._getInternalAngle(this.startAngle),u=this._getInternalAngle(this.endAngle);for(const d of h){const g=this.clockwise?this._mirrorAngle(M.normalizeAngle(d)):M.normalizeAngle(d),m=this._getInternalAngle(g);(this.closed||M.isBetweenAngle(m,l,u,this.clockwise))&&n.push(this.getPointAtAngle(g))}return n}getPoints(t=100){const n=[];let e=this.deltaAngle,i=this._getInternalAngle(this.startAngle);if(this.closed&&(e=C,i=0),this.clockwise)for(let r=0;r<=t;r++){const o=i-e*(r/t),c=this._clockwise?this._mirrorAngle(o):o,a=this.getPointAtAngle(c);n.push(new _(a.x,a.y))}else for(let r=0;r<=t;r++){const o=i+e*(r/t),c=this._clockwise?this._mirrorAngle(o):o,a=this.getPointAtAngle(c);n.push(new _(a.x,a.y))}return n}tessellate(t){const n=this.closed?C:this.deltaAngle,e=Z.segmentCount(this.radius,n,{...t,minSegments:(t==null?void 0:t.minSegments)??(this.closed?8:3)});return this.getPoints(e)}static resolveCircleSides(t){return t==null||!Number.isFinite(t)?Z.DEFAULT_CIRCLE_SIDES:J(Math.round(t),Z.MIN_CIRCLE_SIDES,Z.MAX_CIRCLE_SIDES)}static resolveTessellateOptions(t){const n=Z.resolveCircleSides(t==null?void 0:t.circleSides),e=Math.max(1,Math.round((t==null?void 0:t.maxSegments)??n));return{deviation:t==null?void 0:t.deviation,circleSides:n,minSegments:t==null?void 0:t.minSegments,maxSegments:e}}static chordDeviationFromRadius(t,n=Z.DEFAULT_CIRCLE_SIDES){const e=Math.abs(t),i=Z.resolveCircleSides(n);return e<=S?S:Math.max(S,e*(1-Math.cos(Math.PI/i)))}static segmentCount(t,n,e){const i=Z.resolveTessellateOptions(e),r=Math.abs(n),o=r>=C-1e-8,c=Math.max(1,Math.round(i.minSegments??(o?8:3))),a=Math.max(c,i.maxSegments),h=Math.abs(t);if(h<=S||r<=S)return c;const u=1-(i.deviation??Z.chordDeviationFromRadius(h,i.circleSides))/h;if(!Number.isFinite(u)||u>=1)return a;if(u<=-1)return c;const d=2*Math.acos(u);return d<=S?a:J(Math.ceil(r/d),c,a)}};Z.DEFAULT_CIRCLE_SIDES=100,Z.MIN_CIRCLE_SIDES=8,Z.MAX_CIRCLE_SIDES=2e4;let v=Z;function pi(s){const t=Math.abs(s);if(t<.1){const n=t*t,e=1-n/20*(1-n/42*(1-n/72*(1-n/110))),i=t*n/6*e;return s<0?-i:i}return s-Math.sin(s)}function Mi(s,t){const n=s.length;if(!t||n<2)return 0;const e=s[0].x,i=s[0].y;let r=0;for(let o=0;o<n;++o){const c=s[o],a=s[(o+1)%n],h=c.x-e,l=c.y-i,u=a.x-e,d=a.y-i;r+=.5*(h*d-u*l);const g=c.bulge??0,m=u-h,y=d-l,f=m*m+y*y;if(g===0||!(f>0))continue;const x=4*Math.atan(g),p=Math.sin(x/2),k=f/(4*p*p);r+=.5*k*pi(x)}return Math.abs(r)}const Wt=1e-6;function Qe(s,t){if(Xi(s)){const r=bi(s,t);return r?[r]:[]}const n=es(s);if(n.numberOfVertices<2)return[];const i=Gi(n,t);return i?[i]:[]}function zi(s){return es(s)}function bi(s,t){const n=Si(s);if(n.length===0)return null;const e=[];for(const c of n){const a=Ti(c,t);if(!a)return null;e.push(a)}const i=Ci(s),r=Ni(e,i,s.closed,t);if(r.length<2)return null;const o=new mt;return r.forEach((c,a)=>{o.addVertexAt(a,{x:c.x,y:c.y})}),o.closed=s.closed,o}function Si(s){const t=[],n=s.numberOfVertices,e=s.closed?n:n-1;for(let i=0;i<e;i++){const r=s.vertices[i],o=s.vertices[(i+1)%n];w.isPositive(Math.abs(r.bulge??0))?t.push({kind:"arc",arc:new v(r,o,r.bulge)}):t.push({kind:"line",start:new _(r.x,r.y),end:new _(o.x,o.y)})}return t}function Ci(s){const t=[];for(let n=0;n<s.numberOfVertices;n++)t.push(s.getPointAt(n));return t}function Ti(s,t){if(s.kind==="line"){const e=Ii(s.start,s.end,t);return e?{kind:"line",...e}:null}const n=ki(s.arc,s.arc.startPoint,s.arc.endPoint,t);return n?{kind:"arc",arc:n}:null}function ki(s,t,n,e){const i=Ei(s,t,n,e),r=s.radius+i;return w.isNonPositive(r)?null:new v(s.center,r,s.startAngle,s.endAngle,s.clockwise)}function Ei(s,t,n,e){const i=n.x-t.x,r=n.y-t.y,o=Math.hypot(i,r);if(w.isNonPositive(o))return s.clockwise?-e:e;const c=-r/o,a=i/o,h=s.center.x-(t.x+n.x)/2,l=s.center.y-(t.y+n.y)/2;return h*c+l*a>0?-e:e}function Ii(s,t,n){const e=t.x-s.x,i=t.y-s.y,r=Math.hypot(e,i);if(w.isNonPositive(r))return null;const o=-i/r*n,c=e/r*n;return{start:new _(s.x+o,s.y+c),end:new _(t.x+o,t.y+c),dx:e,dy:i}}function Ni(s,t,n,e){var c;const i=s.length;if(i===0)return[];const r=Bi(s,t,n,e),o=[((c=r[0].nextSegmentStart)==null?void 0:c.clone())??r[0].point.clone()];for(let a=0;a<i;a++){const h=s[a],l=a===i-1&&!n?{point:Fi(h)}:r[(a+1)%i];if(a>0&&r[a].filletPoints&&r[a].filletPoints.forEach(u=>o.push(u.clone())),h.kind==="arc"){const u=r[a].nextSegmentStart??r[a].point,d=l.point,g=Ri(h.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 ss(o)}function Bi(s,t,n,e){const i=s.length,r=[];for(let o=0;o<i;o++)o===0?r.push(n?He(s[i-1],s[0],t[0],e):{point:Li(s[0])}):r.push(He(s[o-1],s[o],t[o],e));return r}function Ri(s,t,n,e){const i=s.nearestPoint(t),r=s.nearestPoint(n),o=qn(s,i),c=qn(s,r),a=qi(s,o,c),h=[];for(let l=0;l<=e;l++){const u=l/e,d=s.clockwise?o-a*u:o+a*u;h.push(s.getPointAtAngle(vi(s,d)))}return h}function qn(s,t){return Math.atan2(t.y-s.center.y,t.x-s.center.x)}function vi(s,t){const n=M.normalizeAngle(t);return s.clockwise?Ln(n):n}function Ln(s){return(360-s*180/Math.PI)%360*(Math.PI/180)}function qi(s,t,n){if(s.clockwise){let i=t-n;return w.isNonPositive(i)&&(i+=C),i}let e=n-t;return w.isNonPositive(e)&&(e+=C),e}function Li(s){return s.kind==="line"?s.start.clone():s.arc.startPoint.clone()}function Fi(s){return s.kind==="line"?s.end.clone():s.arc.endPoint.clone()}function He(s,t,n,e){return s.kind==="line"&&t.kind==="line"?{point:Fn({start:s.start,end:s.end,dx:s.dx,dy:s.dy},{start:t.start,end:t.end,dx:t.dx,dy:t.dy})}:s.kind==="line"&&t.kind==="arc"?$e(s,t.arc,n,e,!0):s.kind==="arc"&&t.kind==="line"?$e(t,s.arc,n,e,!1):s.kind==="arc"&&t.kind==="arc"?Vi(s.arc,t.arc,n,e):{point:n.clone()}}function Vi(s,t,n,e){const i=ns(s.endPoint,t.startPoint),o=Zi(s,t).filter(l=>Kt(s,l)&&Kt(t,l));if(o.length>0)return{point:ts(o,i)};const c=s.endPoint.clone(),a=t.startPoint.clone(),h=Je(n,Math.abs(e),c,a);return{point:c,filletPoints:h,nextSegmentStart:a}}function $e(s,t,n,e,i){const r=ns(i?s.end:s.start,i?t.startPoint:t.endPoint),o=Di(s,t,r);if(Oi(s,o)&&Kt(t,o))return{point:o};const c=ji(s,n,e),a=i?t.startPoint.clone():t.endPoint.clone(),h=Je(n,Math.abs(e),i?c:a,i?a:c);return i?{point:c,filletPoints:h,nextSegmentStart:a}:{point:a,filletPoints:h,nextSegmentStart:c}}function ji(s,t,n){const e=Math.hypot(s.dx,s.dy),i=-s.dy/e*n,r=s.dx/e*n;return new _(t.x+i,t.y+r)}function Oi(s,t){const n=Math.hypot(s.dx,s.dy);if(w.isNonPositive(n))return!1;const e=s.dx/n,i=s.dy/n,r=t.x-s.start.x,o=t.y-s.start.y,c=Math.abs(r*i-o*e);return w.equalToZero(c)}function Je(s,t,n,e){const i=Math.atan2(n.y-s.y,n.x-s.x),r=Math.atan2(e.y-s.y,e.x-s.x),o=Ui(i,r);if(w.equalToZero(Math.abs(o)))return[];const c=[],a=Math.max(2,Math.ceil(Math.abs(o)/Math.PI*16));for(let h=1;h<a;h++){const l=h/a,u=i+o*l;c.push(new _(s.x+t*Math.cos(u),s.y+t*Math.sin(u)))}return c}function Ui(s,t){let n=t-s;for(;n>Math.PI;)n-=C;for(;n<=-Math.PI;)n+=C;return n}function Di(s,t,n){const e=Math.hypot(s.dx,s.dy);if(w.isNonPositive(e))return n.clone();const i=s.dx/e,r=s.dy/e,o=s.start.x-t.center.x,c=s.start.y-t.center.y,a=2*(o*i+c*r),h=o*o+c*c-t.radius*t.radius,l=a*a-4*h;if(l<0)return n.clone();const u=Math.sqrt(l),d=[(-a-u)/2,(-a+u)/2].map(m=>new _(s.start.x+i*m,s.start.y+r*m)),g=d.filter(m=>Kt(t,m));return ts(g.length>0?g:d,n)}function Kt(s,t){const n=Math.abs(Math.hypot(t.x-s.center.x,t.y-s.center.y)-s.radius);if(w.isPositive(n))return!1;const e=qn(s,t),i=s.clockwise?Ln(M.normalizeAngle(s.startAngle)):M.normalizeAngle(s.startAngle),r=s.clockwise?Ln(M.normalizeAngle(s.endAngle)):M.normalizeAngle(s.endAngle);return M.isBetweenAngle(e,i,r,s.clockwise)}function Zi(s,t){const n=t.center.x-s.center.x,e=t.center.y-s.center.y,i=Math.hypot(n,e);if(w.isNonPositive(i))return[];const r=s.radius+t.radius,o=Math.abs(s.radius-t.radius);if(i>r+Wt)return[];if(i<o-Wt)return[];const c=(s.radius*s.radius-t.radius*t.radius+i*i)/(2*i),a=s.radius*s.radius-c*c;if(a<-Wt)return[];const h=s.center.x+c*n/i,l=s.center.y+c*e/i;if(a<=Wt)return[new _(h,l)];const u=Math.sqrt(a),d=-e*u/i,g=n*u/i;return[new _(h+d,l+g),new _(h-d,l-g)]}function ts(s,t){let n=s[0],e=n.distanceToSquared(t);for(let i=1;i<s.length;i++){const r=s[i].distanceToSquared(t);r<e&&(n=s[i],e=r)}return n.clone()}function ns(s,t){return new _((s.x+t.x)/2,(s.y+t.y)/2)}function Xi(s){const t=s.numberOfVertices,n=s.closed?t:t-1;for(let e=0;e<n;e++){const i=s.vertices[e];if(w.isPositive(Math.abs(i.bulge??0)))return!0}return!1}function es(s){const t=Yi(s.vertices.map(n=>new _(n.x,n.y)),s.closed);return t.length===s.numberOfVertices?s:new mt(t.map(n=>({x:n.x,y:n.y})),s.closed)}function Yi(s,t){const n=ss(s);if(!t||n.length<2)return n;const e=n[0],i=n[n.length-1];return w.isNonPositive(Math.hypot(e.x-i.x,e.y-i.y))&&n.pop(),n}function ss(s){const t=[];return s.forEach(n=>{const e=t[t.length-1];(!e||w.isPositive(Math.hypot(e.x-n.x,e.y-n.y)))&&t.push(new _(n.x,n.y))}),t}function Gi(s,t){const n=[];for(let o=0;o<s.numberOfVertices;o++)n.push(s.getPointAt(o));const e=Wi(n,s.closed,t);if(e.length===0)return null;const i=[];if(s.closed){if(e.length<2)return null;const o=e.length;for(let c=0;c<o;c++){const a=e[(c-1+o)%o],h=e[c];i.push(Fn(a,h))}}else{i.push(e[0].start);for(let o=1;o<e.length;o++)i.push(Fn(e[o-1],e[o]));i.push(e[e.length-1].end)}const r=new mt;return i.forEach((o,c)=>{r.addVertexAt(c,{x:o.x,y:o.y})}),r.closed=s.closed,r}function Wi(s,t,n){const e=[],i=t?s.length:s.length-1;for(let r=0;r<i;r++){const o=s[r],c=s[t?(r+1)%s.length:r+1],a=c.x-o.x,h=c.y-o.y,l=Math.hypot(a,h);if(w.isNonPositive(l))continue;const u=-h/l*n,d=a/l*n;e.push({start:new _(o.x+u,o.y+d),end:new _(c.x+u,c.y+d),dx:a,dy:h})}return e}function Fn(s,t){const n=s.dx*t.dy-s.dy*t.dx;if(w.equalToZero(n))return new _((s.end.x+t.start.x)/2,(s.end.y+t.start.y)/2);const e=t.start.x-s.start.x,i=t.start.y-s.start.y,r=(e*t.dy-i*t.dx)/n;return new _(s.start.x+r*s.dx,s.start.y+r*s.dy)}class mt extends St{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 _(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 _(n.x,n.y)}else{const n=this._vertices[t-1];return new _(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 i=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(i.bulge){const o=new v(i,r,i.bulge);t+=o.length}else t+=new _(i.x,i.y).distanceTo(r)}return t}get area(){return Mi(this._vertices,this._closed)}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 _(n.x,n.y)}calculateBoundingBox(){const t=this.getPoints(100);return new tt().setFromPoints(t)}transform(t){const n=t.determinant()<0;return this._vertices.forEach(e=>{const i=new _(e).applyMatrix2d(t);e.x=i.x,e.y=i.y,n&&e.bulge!=null&&(e.bulge=-e.bulge)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new mt(this._vertices.map(t=>({...t})),this._closed)}getPoints3d(t,n){const e=[];return this.getPoints(t).forEach(r=>e.push(new z().set(r.x,r.y,n))),e}getPoints(t){const n=[],e=this._vertices.length;for(let i=0;i<e;++i){const r=this._vertices[i];if(r.bulge){let o=null;if(i<e-1?o=this._vertices[i+1]:i==e-1&&this.closed&&(o=this._vertices[0]),o){const a=new v(r,o,r.bulge).getPoints(t),h=a.length;for(let l=0;l<h;++l){const u=a[l];n.push(new _(u.x,u.y))}}}else n.push(new _(r.x,r.y)),i==e-1&&this.closed&&n.push(n[0])}return n}tessellate(t){const n=[],e=this._vertices.length;for(let i=0;i<e;++i){const r=this._vertices[i];if(r.bulge){let o=null;if(i<e-1?o=this._vertices[i+1]:i===e-1&&this.closed&&(o=this._vertices[0]),o){const a=new v(r,o,r.bulge).tessellate(t);for(let h=0;h<a.length;++h)is(n,a[h])}}else is(n,r),i===e-1&&this.closed&&n.length>0&&n.push(n[0].clone())}return n}offset(t){return Qe(this,t)}}function is(s,t){const n=s[s.length-1];if(n){const e=n.x-t.x,i=n.y-t.y;if(e*e+i*i<=S*S)return}s.push(new _(t.x,t.y))}function Ki(s,t,n){const e=Math.hypot(t.x,t.y);if(w.isNonPositive(e))return null;const i=-t.y/e*n,r=t.x/e*n;return new z(s.x+i,s.y+r,s.z)}function Qi(s,t,n){if(s.length<2)return null;const e=zi(new mt(s.map(r=>({x:r.x,y:r.y})),t));return Qe(e,n)[0]??null}function Hi(s,t,n,e){if(s.length<2||w.equalToZero(n))return null;const{points:i,tangents:r}=os(s,e);if(i.length<2)return null;const o=r??$i(i,t),c=Ji(i,o,n),a=t?nr(c):tr(c);if(a.length<2)return null;const h=new mt;return a.forEach((l,u)=>{h.addVertexAt(u,{x:l.x,y:l.y})}),h.closed=t,h}function $i(s,t){const n=s.length,e=new Array(n);for(let i=0;i<n;i++){let r=0,o=0;if(t){const a=s[(i-1+n)%n],h=s[(i+1)%n];r=h.x-a.x,o=h.y-a.y}else i===0?(r=s[1].x-s[0].x,o=s[1].y-s[0].y):i===n-1?(r=s[n-1].x-s[n-2].x,o=s[n-1].y-s[n-2].y):(r=s[i+1].x-s[i-1].x,o=s[i+1].y-s[i-1].y);const c=Math.hypot(r,o);w.isNonPositive(c)?e[i]=new _(1,0):e[i]=new _(r/c,o/c)}return e}function Ji(s,t,n){return s.map((e,i)=>{const r=t[i],o=-r.y*n,c=r.x*n;return new _(e.x+o,e.y+c)})}function tr(s){let t=Qt(s);if(t.length<3)return t;for(;;){const n=rs(t,!1);if(!n||(t=Qt([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<2))break}return t}function nr(s){let t=Qt(s);if(t.length<4)return t;for(;;){const n=rs(t,!0);if(!n||(t=Qt([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<3))break}return t}function rs(s,t){const n=t?s.length:s.length-1;if(n<2)return null;for(let e=0;e<n;e++){const i=s[e],r=s[(e+1)%s.length];for(let o=e+1;o<n;o++){if(er(e,o,n,t))continue;const c=s[o],a=s[(o+1)%s.length],h=sr(i,r,c,a);if(h)return{point:h,segmentA:e,segmentB:o}}}return null}function er(s,t,n,e){return!!(t===s||t===s+1||e&&s===0&&t===n-1)}function sr(s,t,n,e){const i=t.x-s.x,r=t.y-s.y,o=e.x-n.x,c=e.y-n.y,a=i*c-r*o;if(w.equalToZero(a))return null;const h=n.x-s.x,l=n.y-s.y,u=(h*c-l*o)/a,d=(h*r-l*i)/a,g=yt.equalPointTol;return u<-g||u>1+g||d<-g||d>1+g?null:new _(s.x+u*i,s.y+u*r)}function os(s,t){const n=[],e=[],i=t!=null&&t.length===s.length;return s.forEach((r,o)=>{const c=n[n.length-1];if((!c||w.isPositive(Math.hypot(c.x-r.x,c.y-r.y)))&&(n.push(new _(r.x,r.y)),i)){const a=t[o];e.push(new _(a.x,a.y))}}),{points:n,tangents:i?e:void 0}}function Qt(s){return os(s).points}class Vn extends vn{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}clear(){this._loops.length=0,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 tt}transform(t){return this._loops.forEach(n=>{n.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){const t=new Vn;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}tessellate(t){return this.loops.map(n=>n.tessellate(t))}buildHierarchy(t){var a;const n=this.tessellate(t),e=this.calculateBoundaryBoxes(n),i=this.sortBoundaryBoxesByAreas(e),r=new Map,o=i.length;for(let h=0;h<o;h++)r.set(i[h],{index:i[h],children:[]});const c={index:-1,children:[]};for(let h=0;h<o;h++){const l=i[h],u=n[l],d=e[l];let g=h+1;for(;g<o;g++){const m=i[g],y=n[m],f=e[m];if(f.containsBox(d)&&ir(u,y,f)){(a=r.get(m))==null||a.children.push(r.get(l));break}}g===o&&c.children.push(r.get(l))}return c}get area(){if(this._loops.length===0)return 0;let t=0;for(let n=0;n<this._loops.length;n++){const i=this._loops[n].getPoints(128),r=zn(i);n===0?t+=Math.abs(r):t-=Math.abs(r)}return t}calculateBoundaryBoxes(t){const n=[];return t.forEach(e=>{n.push(new tt().setFromPoints(e))}),n}sortBoundaryBoxesByAreas(t){const n=[];t.forEach((i,r)=>{const o=i.size,c=o.width*o.height;n.push({area:c,index:r})}),n.sort((i,r)=>i.area-r.area);const e=[];return n.forEach(i=>{e.push(i.index)}),e}}function ir(s,t,n){const e=n.size,i=Math.max(Math.max(e.width,e.height)*1e-9,S);for(const r of s)if(rr(r,t)>i)return Y.isPointInPolygon(r,t);return!1}function rr(s,t){let n=1/0;for(let e=0,i=t.length-1;e<t.length;i=e++){const r=t[i],o=t[e],c=o.x-r.x,a=o.y-r.y,h=c*c+a*a;let l=h>0?((s.x-r.x)*c+(s.y-r.y)*a)/h:0;l=Math.max(0,Math.min(1,l)),n=Math.min(n,Math.hypot(s.x-(r.x+c*l),s.y-(r.y+a*l)))}return n}class or extends Ke{translate(t){return this.transform(new O().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 xt extends or{static tessellateParametricCurve(t,n,e,i){const r=Math.max(2,Math.round(i.maxSegments)),o=Math.max(1,Math.round(i.minSegments)),c=Math.max(0,i.deviation)*Math.max(0,i.deviation);if(!Number.isFinite(t)||!Number.isFinite(n))return[e(0)];if(Math.abs(n-t)<=S)return[e(t)];const a=Math.min(r,Math.max(2,o+1)),h=Math.min(r,Math.max(a,8));let l=ar(t,n,h);const u=[];for(let g=0;g<l.length;g++)u.push(e(l[g]));let d=u.length;for(let g=0;g<8&&d<r;g++){const m=[];for(let f=0;f<l.length-1&&!(d>=r);f++){const x=(l[f]+l[f+1])/2,p=e(x);d++,cr(p,u[f],u[f+1])>c&&m.push({index:f,t:x,point:p})}if(m.length===0)break;const y=hr(l,u,m);l=y.params,u.length=0;for(let f=0;f<y.points.length;f++)u.push(y.points[f])}return u}}function cr(s,t,n){const e=n.x-t.x,i=n.y-t.y,r=n.z-t.z,o=s.x-t.x,c=s.y-t.y,a=s.z-t.z,h=e*e+i*i+r*r;if(h<=S*S)return o*o+c*c+a*a;const l=J((o*e+c*i+a*r)/h,0,1),u=o-e*l,d=c-i*l,g=a-r*l;return u*u+d*d+g*g}function ar(s,t,n){if(n<=1)return[s];const e=[];for(let i=0;i<n;i++)e.push(i===n-1?t:s+(t-s)*i/(n-1));return e}function hr(s,t,n){const e=[],i=[];let r=0;for(let o=0;o<s.length;o++)for(e.push(s[o]),i.push(t[o]);r<n.length&&n[r].index===o;)e.push(n[r].t),i.push(n[r].point),r++;return{params:e,points:i}}class et extends xt{static computeCenterPoint(t,n,e){var i;return((i=Oe(t,e,n))==null?void 0:i.center)??null}static tryCreateByThreePoints(t,n,e){const i=Oe(t,e,n);if(!i)return null;const{center:r,radius:o}=i,c=new P(t.x-r.x,t.y-r.y,(t.z??0)-r.z),a=new P(e.x-r.x,e.y-r.y,(e.z??0)-r.z),h=new P(n.x-r.x,n.y-r.y,(n.z??0)-r.z);if(c.lengthSq()===0||h.lengthSq()===0)return null;const l=new P().crossVectors(c,h);if(l.lengthSq()===0&&(l.crossVectors(c,a),l.lengthSq()===0))return null;l.normalize();const u=c.clone().normalize(),d=new P().crossVectors(l,u),g=y=>M.normalizeAngle(Math.atan2(y.dot(d),y.dot(u)));M.isAngleOnCcwSweep(0,g(a),g(h))||(l.negate(),d.negate());let m=g(h);return w.equalToZero(m)&&(m=C),new et(r,o,0,m,l,u)}static createByThreePoints(t,n,e){return et.tryCreateByThreePoints(t,n,e)}constructor(t,n,e,i,r,o=P.X_AXIS){super(),this.center=t,this.radius=n,this.startAngle=e,this.endAngle=i,this.normal=r,this.refVec=o,(i-e)%C==0?(this.startAngle=0,this.endAngle=C):(this.startAngle=e,this.endAngle=i)}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 j.AcCmErrors.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=M.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==C?t:M.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return M.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 P(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new P(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=C);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 P(t.x,t.y,t.z||0),e=this.center,i=this.normal,o=n.clone().sub(e).dot(i),a=n.clone().sub(i.clone().multiplyScalar(o)).clone().sub(e);if(a.lengthSq()===0)return this.startPoint.clone();a.normalize().multiplyScalar(this.radius);const h=e.clone().add(a),l=this.getAngle(h.clone()),u=this.startAngle,d=this.deltaAngle;let g=M.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 P(t.x,t.y,t.z||0),i=this.center,r=this.normal,o=this.radius,a=e.clone().sub(i).dot(r),h=e.clone().sub(r.clone().multiplyScalar(a)),l=i.clone(),d=h.clone().sub(l).length();if(d<o)return n;const g=Math.acos(o/d),m=this.getAngle(h.clone()),y=[m+g,m-g];for(const f of y){const x=M.normalizeAngle(f-this.startAngle);x>=0&&x<=this.deltaAngle&&n.push(this.getPointAtAngle(this.startAngle+x))}return n}perpendicularPoints(t){const n=[],e=new P(t.x,t.y,t.z||0),i=this.center,r=this.normal,o=this.radius,a=e.clone().sub(i).dot(r),l=e.clone().sub(r.clone().multiplyScalar(a)).clone().sub(i);if(l.lengthSq()<1e-24)return n;l.normalize();const u=[i.clone().add(l.clone().multiplyScalar(o)),i.clone().sub(l.clone().multiplyScalar(o))];for(const d of u){const g=this.getAngle(d.clone()),m=M.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)M.isBetweenAngle(a,this.startAngle,this.endAngle)&&t.push(a);let n=1/0,e=1/0,i=1/0,r=-1/0,o=-1/0,c=-1/0;for(const a of t){const h=this.getPointAtAngle(a);h.x<n&&(n=h.x),h.y<e&&(e=h.y),h.z<i&&(i=h.z),h.x>r&&(r=h.x),h.y>o&&(o=h.y),h.z>c&&(c=h.z)}return new rt({x:n,y:e,z:i},{x:r,y:o,z:c})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const n=[];let e=this.deltaAngle,i=this.startAngle;this.closed&&(e=C,i=0);for(let r=0;r<=t;r++){const o=i+e*(r/t),c=this.getPointAtAngle(o);n.push(c)}return n}tessellate(t){const n=this.closed?C:this.deltaAngle,e=et.segmentCount(this.radius,n,{...t,minSegments:(t==null?void 0:t.minSegments)??(this.closed?8:3)});return this.getPoints(e)}static segmentCount(t,n,e){return v.segmentCount(t,n,e)}transform(t){const n=this.center.clone().applyMatrix4(t),e=this.startPoint.clone().applyMatrix4(t),i=this.endPoint.clone().applyMatrix4(t),r=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(t),o=new P(e).sub(n).normalize(),c=n.distanceTo(e);let a=new P().crossVectors(new P(e).sub(n),new P(r).sub(n)).normalize();a.lengthSq()===0&&(a=this.normal.clone().transformDirection(t));const h=l=>{const u=new P(l).sub(n);return Math.atan2(u.dot(cs.crossVectors(a,o)),u.dot(o))};return this.center=n,this.radius=c,this.normal=a,this.refVec=o,this.startAngle=0,this.endAngle=this.closed?C:h(i),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 et(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(cs.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const n=this.normal,e=this.refVec,i={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 z(r.x+o*(e.x*Math.cos(t)+i.x*Math.sin(t)),r.y+o*(e.y*Math.cos(t)+i.y*Math.sin(t)),r.z+o*(e.z*Math.cos(t)+i.z*Math.sin(t)))}get plane(){const t=new P(this.center).distanceTo(Pn);return new bt(this.normal,t)}offset(t){const n=this.radius+t;return n<=0?null:new et(this.center,n,this.startAngle,this.endAngle,this.normal,this.refVec)}}const cs=new P;function Ht(s){const t=s.clockwise?-s.deltaAngle:s.deltaAngle;if(!Number.isFinite(t)||w.equalToZero(t)||!w.great(C-Math.abs(t),0))return;const n=Math.tan(t/4);return Number.isFinite(n)?n:void 0}function lr(s){if(w.equalToZero(s))return s;const t=4*Math.atan(s),n=C-Math.abs(t);return w.equalToZero(n)?s:-Math.sign(s)*Math.tan(n/4)}function jn(s,t,n){const e=t.x-s.x,i=t.y-s.y,r=Math.hypot(e,i);if(w.isNonPositive(r)||w.equalToZero(n))return;const o=(s.x+t.x)/2,c=(s.y+t.y)/2,a=r/2*((1-n*n)/(2*n));return new _(o-i/r*a,c+e/r*a)}function On(s,t,n){const e=s.x-t.x,i=s.y-t.y;return n?Math.atan2(e,-i):Math.atan2(-e,i)}function ur(s,t,n){const e=jn(s,t,n);if(e)return On(s,e,n>=0)}function dr(s,t,n){const e=jn(s,t,n);if(e)return On(t,e,n>=0)}function gr(s,t,n){const e=s.x-n.x,i=s.y-n.y,r=t.x-n.x,o=t.y-n.y,c=e*o-i*r,a=e*r+i*o,h=Math.atan2(c,a);if(Number.isFinite(h))return Math.tan(h/4)}function mr(s,t,n,e){const i=s.x-n.x,r=s.y-n.y,o=t.x-n.x,c=t.y-n.y,a=Math.cos(e),h=Math.sin(e),l=t.x-s.x,u=t.y-s.y,d=i*h-r*a;let g;w.isPositive(Math.abs(d))?g=d>0:g=l*h-u*a>=0;const m=Math.atan2(r,i),y=Math.atan2(c,o);let f;if(g?(f=y-m,w.isNonPositive(f)&&(f+=Math.PI*2)):(f=m-y,w.isNonPositive(f)&&(f+=Math.PI*2)),!!w.great(C-f,0))return g?Math.tan(f/4):-Math.tan(f/4)}function fr(s,t,n){const e=Ge(s,t,n);if(e)return Ht(e)}function yr(s,t,n,e=!1){const i=Bn(s,t,n,e);if(i)return Ht(i)}function xr(s,t,n){const e=We(s,t,n);if(e)return Ht(e)}class At extends St{constructor(t,n,e,i=0,r=C,o=!1,c=0){super(),this.center=t,this.majorAxisRadius=n,this.minorAxisRadius=e,(r-i)%C==0?(this.startAngle=0,this.endAngle=C):(this.startAngle=i,this.endAngle=r),this.clockwise=o,this.rotation=c}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 j.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=M.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==C?t:M.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 M.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let n=1/0,e=1/0,i=-1/0,r=-1/0;for(let o=0;o<=100;o++){const c=this.getPoint(o/100);n=Math.min(n,c.x),e=Math.min(e,c.y),i=Math.max(i,c.x),r=Math.max(r,c.y)}return new tt({x:n,y:e},{x:i,y:r})}get closed(){return w.equalToZero(this.deltaAngle,1e-12)||w.equalToZero(C-this.deltaAngle,1e-12)}getPoint(t){const n=Math.PI*2;let e=this.endAngle-this.startAngle;const i=Math.abs(e)<Number.EPSILON;for(;e<0;)e+=n;for(;e>n;)e-=n;e<Number.EPSILON&&(i?e=0:e=n),this.clockwise===!0&&!i&&(e===n?e=-n:e=e-n);const r=this.startAngle+t*e;let o=this.center.x+this.majorAxisRadius*Math.cos(r),c=this.center.y+this.minorAxisRadius*Math.sin(r);if(this.rotation!==0){const a=Math.cos(this.rotation),h=Math.sin(this.rotation),l=o-this.center.x,u=c-this.center.y;o=l*a-u*h+this.center.x,c=l*h+u*a+this.center.y}return new _(o,c)}transform(t){const n=t,e=new _(this.center).applyMatrix2d(n),i=new z(e.x,e.y,this.center.z),r=this.getPointAtAngle(0).clone().applyMatrix2d(n),o=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(n),c=new _(r).sub(e),a=new _(o).sub(e),h=c.length(),l=a.length(),u=Math.atan2(c.y,c.x),d=c.clone().normalize(),g=a.clone().normalize(),m=x=>{const p=new _(x).sub(e),k=p.dot(d),E=p.dot(g);return M.normalizeAngle(Math.atan2(E/l,k/h))},y=n.determinant()<0?!this.clockwise:this.clockwise,f=this.closed?new At(i,h,l,0,C,y,u):new At(i,h,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/C:M.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 At(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),i=Math.cos(this.rotation),r=Math.sin(this.rotation),o=this.majorAxisRadius>=this.minorAxisRadius,c=o?i:-r,a=o?r:i;return[new _(this.center.x-e*c,this.center.y-e*a),new _(this.center.x+e*c,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 _(t.x,t.y);let e=this.getPoint(0),i=n.distanceToSquared(e);const r=72;for(let o=1;o<=r;o++){const c=this.getPoint(o/r),a=n.distanceToSquared(c);a<i&&(i=a,e=c)}return e}tangentPoints(t){const n=this._projectPointToLocal(t);return this._findSnapAngles(n,(i,r,o,c)=>{const a=-this.majorAxisRadius*c,h=this.minorAxisRadius*o;return(i-n.x)*h-(r-n.y)*a}).map(i=>this.getPointAtAngle(i))}perpendicularPoints(t){const n=this._projectPointToLocal(t);return this._findSnapAngles(n,(i,r,o,c)=>{const a=this.minorAxisRadius*o,h=this.majorAxisRadius*c;return(i-n.x)*h-(r-n.y)*a}).map(i=>this.getPointAtAngle(i))}_projectPointToLocal(t){const n=t.x-this.center.x,e=t.y-this.center.y,i=Math.cos(-this.rotation),r=Math.sin(-this.rotation);return{x:n*i-e*r,y:n*r+e*i}}_findSnapAngles(t,n,e=144){const i=this.majorAxisRadius,r=this.minorAxisRadius,o=this.startAngle,c=this.deltaAngle,a=[],h=d=>{const g=Math.cos(d),m=Math.sin(d);return n(i*g,r*m,g,m)};let l=o,u=h(l);for(let d=1;d<=e;d++){const g=o+c*d/e,m=h(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 p=(y+f)/2;h(y)*h(p)<=0?f=p:y=p}a.push((y+f)/2)}l=g,u=m}return a}}class ot extends xt{constructor(t,n,e,i,r,o=0,c=C){super(),this.center=t,this.normal=n,this.majorAxis=e,this.majorAxisRadius=i,this.minorAxisRadius=r;const a=Math.abs(c-o);Math.abs(a-C)<1e-10||Math.abs(a-2*C)<1e-10?(this.startAngle=0,this.endAngle=C):(this.startAngle=o,this.endAngle=c)}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 j.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=M.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==C?t:M.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-C)<1e-10?C:M.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 P(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new P(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new P().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-C)<1e-10)&&(t=0,n=C);const e=t+n/2;return this.getPointAtAngle(e)}get isCircular(){return w.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,i=this.getPointAtAngle(this.startAngle);for(let r=1;r<=t;r++){const o=this.startAngle+r*n,c=this.getPointAtAngle(o),a=c.x-i.x,h=c.y-i.y,l=c.z-i.z;e+=Math.sqrt(a*a+h*h+l*l),i=c}return e}get area(){return Math.abs(this.deltaAngle-C)>=1e-10?0:Math.PI*this.majorAxisRadius*this.minorAxisRadius}calculateBoundingBox(){const t=this.closed||Math.abs(this.deltaAngle-C)<1e-10,n=this.majorAxisRadius,e=this.minorAxisRadius,i=this.majorAxis,r=this.minorAxis,o=t?[]:[this.startAngle,this.endAngle];for(const[a,h]of[[i.x,r.x],[i.y,r.y],[i.z,r.z]]){const l=Math.atan2(e*h,n*a);for(const u of[l,l+Math.PI])(t||M.isAngleOnCcwSweep(this.startAngle,u,this.endAngle))&&o.push(u)}o.length===0&&o.push(this.startAngle);const c=new rt;for(const a of o)c.expandByPoint(this.getPointAtAngle(a));return c}get closed(){return this.deltaAngle==0}getPoints(t=100){const n=[];let e=this.deltaAngle,i=this.startAngle;this.closed&&(e=C,i=0);for(let r=0;r<=t;r++){const o=i+e*(r/t),c=this.getPointAtAngle(o);n.push(c)}return n}tessellate(t){const n=v.resolveTessellateOptions(t),e=this.closed?C:this.deltaAngle,i=Math.max(this.majorAxisRadius,this.minorAxisRadius),r=Math.abs(e)>=C-1e-8,o=n.minSegments??(r?8:3);if(this.isCircular){const h=et.segmentCount(i,e,{...t,minSegments:o});return this.getPoints(h)}const c=n.deviation??v.chordDeviationFromRadius(i,n.circleSides),a=this.closed?0:this.startAngle;return xt.tessellateParametricCurve(a,a+e,h=>this.getPointAtAngle(h),{deviation:Math.max(S,c),minSegments:o,maxSegments:n.maxSegments})}getPointAtAngle(t){const n=Math.cos(t),e=Math.sin(t),i=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(e),r=this.majorAxis.clone().multiplyScalar(n*this.majorAxisRadius).add(i);return new z(this.center.x+r.x,this.center.y+r.y,this.center.z+r.z)}nearestPoint(t,n=72){const e=new z(t.x,t.y,t.z||0);let i=this.getPointAtAngle(this.startAngle),r=e.distanceToSquared(i);for(let a=1;a<=n;a++){const h=this.startAngle+this.deltaAngle*a/n,l=this.getPointAtAngle(h),u=e.distanceToSquared(l);u<r&&(r=u,i=l)}const o=e.distanceToSquared(this.startPoint),c=e.distanceToSquared(this.endPoint);return o<r&&o<=c?this.startPoint.clone():c<r&&c<o?this.endPoint.clone():i.clone()}tangentPoints(t){const n=this._projectPointToLocalPlane(t);return this._findSnapParameterAngles((i,r,o,c)=>{const a=-this.majorAxisRadius*c,h=this.minorAxisRadius*o;return(i-n.x)*h-(r-n.y)*a}).map(i=>this.getPointAtAngle(i))}perpendicularPoints(t){const n=this._projectPointToLocalPlane(t);return this._findSnapParameterAngles((i,r,o,c)=>{const a=this.minorAxisRadius*o,h=this.majorAxisRadius*c;return(i-n.x)*h-(r-n.y)*a}).map(i=>this.getPointAtAngle(i))}_projectPointToLocalPlane(t){const n=new z(t.x,t.y,t.z||0),e=new P(n).sub(this.center),i=e.dot(this.normal);return e.sub(this.normal.clone().multiplyScalar(i)),{x:e.dot(this.majorAxis),y:e.dot(this.minorAxis)}}_findSnapParameterAngles(t,n=144){const e=this.majorAxisRadius,i=this.minorAxisRadius,r=this.startAngle,o=this.deltaAngle,c=[],a=u=>{const d=Math.cos(u),g=Math.sin(u);return t(e*d,i*g,d,g)};let h=r,l=a(h);for(let u=1;u<=n;u++){const d=r+o*u/n,g=a(d);if(Math.abs(l)<1e-10&&c.push(h),l*g<0){let m=h,y=d;for(let f=0;f<32;f++){const x=(m+y)/2;a(m)*a(x)<=0?y=x:m=x}c.push((m+y)/2)}h=d,l=g}return c}contains(t){const n=new P(t).sub(this.center),e=n.dot(this.majorAxis),i=n.dot(this.minorAxis),r=e/this.majorAxisRadius,o=i/this.minorAxisRadius;return r*r+o*o<=1}transform(t){const n=t,e=this.center.clone().applyMatrix4(n),i=this.getPointAtAngle(0).clone().applyMatrix4(n),r=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(n),o=new P(i).sub(e),c=new P(r).sub(e),a=o.length(),h=c.length(),l=o.clone().normalize(),u=new P().crossVectors(o,c).normalize();let d=new P().crossVectors(u,l).normalize();d.dot(c)<0&&(u.negate(),d=new P().crossVectors(u,l).normalize());const g=y=>{const f=new P(y).sub(e),x=f.dot(l),p=f.dot(d);return M.normalizeAngle(Math.atan2(p/h,x/a))},m=this.closed?new ot(e,u,l,a,h,0,C):new ot(e,u,l,a,h,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 ot(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new P(this.center).distanceTo(Pn);return new bt(this.normal,t)}offset(t){const n=this.majorAxisRadius+t,e=this.minorAxisRadius+t;return n<=0||e<=0?null:new ot(this.center,this.normal,this.majorAxis,n,e,this.startAngle,this.endAngle)}}class Ct extends St{constructor(t,n){super(),this._start=new _(t),this._end=new _(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 _(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),n=new _(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new tt(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 Ct(this._start.clone(),this._end.clone())}project(t){const n=this._end.x-this._start.x,e=this._end.y-this._start.y,i=n*n+e*e;if(i<1e-18)return this._start.clone();let r=((t.x-this._start.x)*n+(t.y-this._start.y)*e)/i;return r=Math.max(0,Math.min(1,r)),new _(this._start.x+r*n,this._start.y+r*e)}nearestPoint(t){return this.project(t)}}class $t extends xt{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 P().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(_t).normalize();return new z(this._start).addScaledVector(e,t)}else{const e=this.delta(_t).normalize();return new z(this._end).addScaledVector(e,t)}}extend(t,n=!1){if(n){const e=_t.subVectors(this._start,this._end).normalize();this._start=new z(this._start).addScaledVector(e,t)}else{const e=this.delta(_t).normalize();this._end=new z(this._end).addScaledVector(e,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,n){as.subVectors(t,this._start),Jt.subVectors(this.endPoint,this.startPoint);const e=Jt.dot(Jt);let r=Jt.dot(as)/e;return n&&(r=M.clamp(r,0,1)),r}closestPointToPoint(t,n,e){const i=this.closestPointToPointParameter(t,n);return this.delta(e).multiplyScalar(i).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,i=_t.subVectors(t,this.startPoint).dot(n);return new z().copy(n).multiplyScalar(i).add(this.startPoint)}perpPoint(t){const n=this.direction,e=this.startPoint,r=_t.subVectors(t,e).dot(n),o=_t.copy(n).multiplyScalar(r);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 rt(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 $t(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 P(e.x-n.x,e.y-n.y,0).normalize(),o=new P(-r.y,r.x,0);return new $t(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 _t=new P,as=new P,Jt=new P;class Un{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,n,e,i){this.c0=t,this.c1=e,this.c2=-3*t+3*n-2*e-i,this.c3=2*t-2*n+e+i}initCatmullRom(t,n,e,i,r){this.init(n,e,r*(e-t),r*(i-n))}initNonuniformCatmullRom(t,n,e,i,r,o,c){let a=(n-t)/r-(e-t)/(r+o)+(e-n)/o,h=(e-n)/o-(i-n)/(o+c)+(i-e)/c;a*=o,h*=o,this.init(n,e,a,h)}calc(t){const n=t*t,e=n*t;return this.c0+this.c1*t+this.c2*n+this.c3*e}}class tn extends xt{constructor(t=[],n=!1,e="centripetal",i=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new P,this._px=new Un,this._py=new Un,this._pz=new Un,this._points=t.map(r=>new z(r)),this._closed=n,this._curveType=e,this._tension=i}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,i=this._points,r=i.length;if(r===0)return e.set(0,0,0);if(r===1)return e.copy(i[0]);const o=(r-(this._closed?0:1))*t;let c=Math.floor(o),a=o-c;this._closed?c+=c>0?0:(Math.floor(Math.abs(c)/r)+1)*r:a===0&&c===r-1&&(c=r-2,a=1);let h,l;this._closed||c>0?h=i[(c-1)%r]:(this._tmp.subVectors(i[0],i[1]).add(i[0]),h=new z(this._tmp.x,this._tmp.y,this._tmp.z));const u=i[c%r],d=i[(c+1)%r];if(this._closed||c+2<r?l=i[(c+2)%r]:(this._tmp.subVectors(i[r-1],i[r-2]).add(i[r-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(h.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(h.x,u.x,d.x,l.x,m,y,f),this._py.initNonuniformCatmullRom(h.y,u.y,d.y,l.y,m,y,f),this._pz.initNonuniformCatmullRom(h.z,u.z,d.z,l.z,m,y,f)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(h.x,u.x,d.x,l.x,this._tension),this._py.initCatmullRom(h.y,u.y,d.y,l.y,this._tension),this._pz.initCatmullRom(h.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 tn(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 rt;const t=new rt;return this._points.forEach(n=>{t.expandByPoint(n)}),t}}function hs(s,t){const n=s.x-t[0],e=s.y-t[1],i=(s.z??0)-(t[2]??0);return n*n+e*e+i*i}class U{constructor(t,n,e,i){this._degree=t,this._knots=[...n],this._controlPoints=e.map(r=>({x:r.x,y:r.y,z:r.z})),this._weights=i?[...i]: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 U(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 Xt(t,this._degree,this._knots,n,this._weights)}signedPlanarCurvatureAt(t){const n=this.evaluate(t);return qe(n.deriv1,n.deriv2)}getOffsetSamplePath2d(t,n=512){const e=Math.abs(t),{start:i,end:r}=this.getParameterRange(),o=this.length(),c=Math.max(64,Math.ceil(o/Math.max(e*.2,1e-6)));let a=Ar(i,r,Math.min(c,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=_r(a,d),a.length>n){a=a.slice(0,n);break}}const h=[],l=[];return a.forEach(u=>{const d=this.evaluate(u);h.push(new _(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 _(g/y,m/y):new _(1,0))}),{points:h,tangents:l}}length(){const t=this._controlPoints.map(n=>[n.x,n.y,n.z]);return Cn(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,n,e,i){return new U(t,n,e,i)}static byPoints(t,n,e="Uniform",i,r){const o=bn(t,n,e,i,r),c=o.controlPoints.map(a=>({x:a[0],y:a[1],z:a[2]}));return new U(n,o.knots,c,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:i}=this.getParameterRange();for(let r=0;r<=t;r++){const o=e+(i-e)*(r/t);n.push(this.point(o))}return n}isClosed(t=1e-6){const{start:n,end:e}=this.getParameterRange(),i=this.point(n),r=this.point(e),o=i[0]-r[0],c=i[1]-r[1],a=i[2]-r[2];return Math.sqrt(o*o+c*c+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 tn(t,!0,"centripetal"),e=Math.max(50,t.length*2);return n.getPoints(e)}nearestPoint(t,n=64){const{start:e,end:i}=this.getParameterRange();let r=this.point(e),o=hs(t,r);for(let c=0;c<=n;c++){const a=e+(i-e)*c/n,h=this.point(a),l=hs(t,h);l<o&&(o=l,r=h)}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 U.byPoints(r,n,e)}}function Ar(s,t,n){if(n<2)return[s,t];const e=[];for(let i=0;i<n;i++)e.push(i===n-1?t:s+(t-s)*i/(n-1));return e}function _r(s,t){const n=[...s,...t].sort((i,r)=>i-r),e=[];return n.forEach(i=>{const r=e[e.length-1];(r===void 0||Math.abs(r-i)>1e-10)&&e.push(i)}),e}function ls(s){if(!s)return!1;const t=s.x??0,n=s.y??0,e=s.z??0;return t*t+n*n+e*e>1e-20}function Pr(s,t,n){let e=s??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 wr(s,t,n){let e=s??0;e<1&&(e=3);const i=t+n-1;return e=Math.min(e,i),Math.max(1,e)}function pr(s,t){if(!(!s||s.length!==t))return s}class W extends xt{constructor(t,n,e,i,r,o){super();const c=arguments.length;if(this._degree=3,this._closed=!1,Array.isArray(n)){if(c<2||c>5)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._controlPoints=t;let a,h=3,l=!1;if(c>=3&&(Array.isArray(e)?(a=e,c>=4&&(h=i||3),c>=5&&(l=r)):e!==void 0&&(h=e||3,c>=4&&(l=i))),e===void 0&&c>=4&&(h=i||3,c>=5&&(l=r)),this._degree=h,this._closed=l,this._controlPoints.length<this._degree+1)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._nurbsCurve=U.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,a)}else{if(c<2||c>6)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._fitPoints=t,this._knotParameterization=n,c>=3&&(this._degree=e||3);const a=typeof i=="boolean";c>=4&&a&&(this._closed=i),a?(c>=5&&(this._startTangent=r),c>=6&&(this._endTangent=o)):(c>=4&&(this._startTangent=i),c>=5&&(this._endTangent=r)),this._closed&&(this._startTangent=void 0,this._endTangent=void 0);const h=(this._startTangent?1:0)+(this._endTangent?1:0);if(this._fitPoints.length+h<this._degree+1)throw j.AcCmErrors.ILLEGAL_PARAMETERS;if(this._closed)this._nurbsCurve=U.createClosedCurve(this._fitPoints,this._degree,this._knotParameterization);else{const l=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=U.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=U.createFitPointsForClosedCurve(this._fitPoints),n=this.toNurbsPoints(t);this._nurbsCurve=U.byPoints(n,this._degree,this._knotParameterization)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=U.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=U.createFitPointsForClosedCurve(this._controlPoints),n=this.toNurbsPoints(t);this._nurbsCurve=U.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=U.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(Y.point2dToPoint3d)}get fitPoints(){var t;return(t=this._fitPoints)==null?void 0:t.map(Y.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],i=this._nurbsCurve.point(e);return new z(i[0],i[1],i[2])}get endPoint(){const t=this._nurbsCurve.knots(),n=this._nurbsCurve.degree(),e=t[t.length-n-1],i=this._nurbsCurve.point(e);return new z(i[0],i[1],i[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,i=this._fitPoints[e];return Y.point2dToPoint3d(i)}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 i=this._fitPoints[e];i&&Y.applyOffsetToPoint3d(i,n)}this._boundingBoxNeedsUpdate=!0,this.buildCurve()}}moveControlPointsAt(t,n){for(const e of t){if(!Number.isInteger(e)||e<0)continue;const i=this.getControlPointAt(e);i&&Y.applyOffsetToPoint3d(i,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=U.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=[],i=n.knots(),r=this._nurbsCurve.degree(),o=i[r],c=i[i.length-r-1],a=(c-o)/(t-1);for(let h=0;h<t;h++){const l=h===t-1?c:o+h*a,u=n.point(l);e.push(new z(u[0],u[1],u[2]))}return e}tessellate(t){const n=v.resolveTessellateOptions(t),e=this._nurbsCurve.knots(),i=this._nurbsCurve.degree();if(e.length<i+2)return[this.startPoint.clone(),this.endPoint.clone()];const r=e[i],o=e[e.length-i-1],c=n.circleSides,a=Math.abs(this.length),h=n.deviation??Math.max(S,a<=S?S:a/(2*c*c));return xt.tessellateParametricCurve(r,o,l=>this.evaluateAt(l),{deviation:h,minSegments:n.minSegments??(this.closed?8:2),maxSegments:n.maxSegments})}getCurvePoints(t,n){const e=[],i=t.knots(),r=t.degree(),o=i[r],a=(i[i.length-r-1]-o)/(n-1);for(let h=0;h<n;h++){const l=o+h*a;e.push(t.point(l))}return e}calculateBoundingBox(){const t=this.getPoints(100);return new rt().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 Ne(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(i=>new z(i).applyMatrix4(t)),this._nurbsCurve=U.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,e.length>0?e:void 0)}return this._boundingBoxNeedsUpdate=!0,this}clone(){return this._fitPoints&&this._knotParameterization?new W(this._fitPoints.map(Y.point2dToPoint3d),this._knotParameterization,this._degree,this._closed,this._startTangent?Y.point2dToPoint3d(this._startTangent):void 0,this._endTangent?Y.point2dToPoint3d(this._endTangent):void 0):new W(this._controlPoints.map(Y.point2dToPoint3d),this._nurbsCurve.knots(),this._nurbsCurve.weights(),this._degree,this._closed)}toNurbsPoints(t){const n=new Array(t.length);return t.forEach((e,i)=>{n[i]=[e.x,e.y,e.z||0]}),n}toGePoints(t){const n=new Array(t.length);return t.forEach((e,i)=>{n[i]={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 W(t,n,e,!0)}static fromControlPoints(t,n,e,i,r){if(t.length<2||n.length<2)return null;const o=Pr(i,t.length,n.length);if(t.length<o+1)return null;try{return new W(t,n,pr(e,t.length),o,r)}catch{return null}}static fromFitPoints(t,n,e,i,r,o){if(t.length<2)return null;const c=ls(r),a=ls(o),h=(c?1:0)+(a?1:0),l=wr(e,t.length,h);if(t.length+h<l+1)return null;try{return c||a?new W(t,n,l,i,c?r:void 0,a?o:void 0):new W(t,n,l,i)}catch{return null}}static fromDwgSplineEdge(t){if(t.numberOfControlPoints>0&&t.numberOfKnots>0){const n=t.controlPoints.map(Y.point2dToPoint3d);let e=!0;const i=t.controlPoints.map(r=>(r.weight==null&&(e=!1),r.weight||1));return W.fromControlPoints(n,t.knots,e?i:void 0,t.degree,!1)}if(t.numberOfFitData>0){const n=t.fitDatum.map(Y.point2dToPoint3d);return W.fromFitPoints(n,"Uniform",t.degree,!1,t.startTangent?Y.point2dToPoint3d(t.startTangent):void 0,t.endTangent?Y.point2dToPoint3d(t.endTangent):void 0)}return null}}class H extends St{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}static buildFromEdges(t,n=.001){if(t.length===0)return[];const e=[...t],i=[],r=n*n,o=(c,a)=>{const h=c.x-a.x,l=c.y-a.y;return h*h+l*l<=r};for(;e.length>0;){const c=[],a=e.shift();c.push(a);const h=H.getEdgeStartPoint(a);let l=H.getEdgeEndPoint(a);if(!o(h,l))for(;e.length>0;){const u=H.findConnectingEdge(e,l,r);if(u.index<0)break;let d=e.splice(u.index,1)[0];if(u.reverse&&(d=H.reverseEdge(d)),c.push(d),l=H.getEdgeEndPoint(d),o(l,h))break}i.push(new H(c))}return i}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 _(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 tt;return n.setFromPoints(t),n}transform(t){const n=new O().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 W?e.transform(n):e.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new H(this._curves.map(t=>t.clone()))}get closed(){return!0}getPoints(t){const n=[];return this.curves.forEach(e=>{e.getPoints(t).forEach(i=>{n.push(new _(i.x,i.y))})}),n}tessellate(t){const n=[];return this._curves.forEach(e=>{Mr(e,t).forEach(i=>{const r=n[n.length-1];r&&(r.x-i.x)**2+(r.y-i.y)**2<=S*S||n.push(new _(i.x,i.y))})}),n}static findConnectingEdge(t,n,e){let i=-1,r=!1,o=Number.POSITIVE_INFINITY;for(let c=0;c<t.length;c++){const a=t[c],h=H.getEdgeStartPoint(a),l=H.getEdgeEndPoint(a),u=n.x-h.x,d=n.y-h.y,g=u*u+d*d;g<o&&(o=g,i=c,r=!1);const m=n.x-l.x,y=n.y-l.y,f=m*m+y*y;f<o&&(o=f,i=c,r=!0)}return o>e?{index:-1,reverse:!1}:{index:i,reverse:r}}static getEdgeStartPoint(t){const n=t.startPoint;return new _(n.x,n.y)}static getEdgeEndPoint(t){const n=t.endPoint;return new _(n.x,n.y)}static reverseEdge(t){return t instanceof Ct?new Ct(t.endPoint,t.startPoint):t instanceof v?H.reverseCircArcEdge(t):t instanceof At?new At(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof W?H.reverseSplineEdge(t):t}static reverseCircArcEdge(t){const n=t.startPoint,e=t.endPoint,i=!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),c=a=>{const h=M.normalizeAngle(a);return i?M.normalizeAngle(-h):h};return new v(t.center,t.radius,c(r),c(o),i)}static reverseSplineEdge(t){const n=[...t.controlPoints].reverse(),e=t.knots,i=e[0],r=e[e.length-1],o=e.map(h=>i+r-h).reverse(),c=t.weights,a=c.length>0?[...c].reverse():void 0;return new W(n,o,a,t.degree,t.closed)}}function Mr(s,t){if(s instanceof Ct)return s.getPoints();if(s instanceof v||s instanceof W)return s.tessellate(t);const n=s.closed?C:s.deltaAngle,e=v.segmentCount(Math.max(s.majorAxisRadius,s.minorAxisRadius),n,t);return s.getPoints(e)}const Ft=128,nn=96,b=yt.equalPointTol,Dn=b*8;function zr(s,t,n=!1,e=!1,i){const r=ds(s,n,i),o=ds(t,e,i),c=[];for(const a of r)for(const h of o)Xn(a,h)&&Hn(c,xs(a,h));return Ur(c)}function br(s,t){const n=us(s);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 us(s){switch(s.kind){case"line":return{kind:"line",line:s.line.clone(),extent:s.extent,extendable:s.extendable};case"circArc":return{kind:"circArc",arc:s.arc.clone(),extendable:s.extendable};case"ellipseArc":return{kind:"ellipseArc",arc:s.arc.clone(),extendable:s.extendable};case"spline":return{kind:"spline",spline:s.spline.clone(),extendable:s.extendable}}}function ds(s,t,n){const e=[];for(const i of s){const r=t&&i.extendable!==!1;switch(i.kind){case"line":{const o=kr(i.line,n);if(!o)break;const c=r?"unbounded":i.extent;e.push(Tt(o.start,o.end,c));break}case"circArc":{const o=Cr(i.arc,r);if(n&&!Vt(o.normal,n.normal)){const c=Ir(o,n);(c==null?void 0:c.kind)==="circArc"?e.push(gs(c.arc,ct(c.arc))):(c==null?void 0:c.kind)==="ellipseArc"?e.push(ms(c.arc,ut(c.arc))):Zn(e,fs(o,ct(o)),ct(o),n)}else{const c=Er(o,n);c&&e.push(gs(c,ct(c)))}break}case"ellipseArc":{const o=Tr(i.arc,r);if(n&&!Vt(o.normal,n.normal))Zn(e,ys(o,ut(o)),ut(o),n);else{const c=Nr(o,n);c&&e.push(ms(c,ut(c)))}break}case"spline":{n?Zn(e,i.spline.getPoints(Ft),i.spline.closed,n):e.push(Sr(i.spline));break}}}return e}function Tt(s,t,n){const e=new P().subVectors(t,s);return{kind:"line",start:s,dir:e,extent:n,box:n==="bounded"?new rt().setFromPoints([s,t]):void 0}}function gs(s,t){return{kind:"circArc",arc:s,full:t||ct(s),box:s.box}}function ms(s,t){return{kind:"ellipseArc",arc:s,full:t||ut(s),box:s.box}}function Sr(s){const t=[],n=s.getPoints(Ft);if(n.length>=2){const i=s.closed?n.length:n.length-1;for(let r=0;r<i;r++){const o=n[r],c=n[(r+1)%n.length];o.distanceToSquared(c)<b*b||t.push(Tt(o.clone(),c.clone(),"bounded"))}}const e=new rt;for(const i of t)i.box&&e.union(i.box);return{kind:"spline",spline:s,samples:t,box:t.length>0?e:void 0}}function Cr(s,t){return!t||ct(s)?s:new et(s.center,s.radius,0,C,s.normal,s.refVec)}function Tr(s,t){return!t||ut(s)?s:new ot(s.center,s.normal,s.majorAxis,s.majorAxisRadius,s.minorAxisRadius,0,C)}function kr(s,t){if(!t)return{start:s.startPoint.clone(),end:s.endPoint.clone()};const n=lt(s.startPoint,t),e=lt(s.endPoint,t);return n.distanceToSquared(e)<b*b?null:{start:n,end:e}}function Er(s,t){if(!t)return s;const n=lt(s.center,t);return new et(n,s.radius,s.startAngle,s.endAngle,t.normal.clone(),Wn(s.refVec,t.normal))}function Ir(s,t){const n=lt(s.center,t),e=s.normal.clone();if(e.lengthSq()<b*b)return null;e.normalize();const i=t.normal.clone();if(i.lengthSq()<b*b)return null;i.normalize();const r=e.dot(i),o=Math.abs(r);if(o>1-1e-8)return{kind:"circArc",arc:new et(n,s.radius,s.startAngle,s.endAngle,i,Wn(s.refVec,i))};if(o<1e-8)return null;const c=new P().crossVectors(e,i);if(c.lengthSq()<b*b)return null;c.normalize();const a=new ot(n,i,c,s.radius,s.radius*o,0,C);if(ct(s))return{kind:"ellipseArc",arc:a};const h=lt(s.startPoint,t),l=lt(s.endPoint,t),u=lt(s.midPoint,t),d=It(a,h),g=It(a,l),m=It(a,u),y=M.normalizeAngle(m-d),f=M.normalizeAngle(g-d),x=y<=f||f<1e-8?d+f:d+f+C;return{kind:"ellipseArc",arc:new ot(n,i,c,s.radius,s.radius*o,d,x)}}function Nr(s,t){if(!t)return s;const n=lt(s.center,t),e=Wn(s.majorAxis,t.normal);return e.lengthSq()<b*b?null:new ot(n,t.normal.clone(),e,s.majorAxisRadius,s.minorAxisRadius,s.startAngle,s.endAngle)}function Zn(s,t,n,e){if(t.length<2)return;const i=e?t.map(o=>lt(o,e)):t,r=n?i.length:i.length-1;for(let o=0;o<r;o++){const c=i[o],a=i[(o+1)%i.length];c.distanceToSquared(a)<b*b||s.push(Tt(c.clone(),a.clone(),"bounded"))}}function fs(s,t){return t||ct(s)?new et(s.center,s.radius,0,C,s.normal,s.refVec).getPoints(nn):s.getPoints(nn)}function ys(s,t){return t||ut(s)?new ot(s.center,s.normal,s.majorAxis,s.majorAxisRadius,s.minorAxisRadius,0,C).getPoints(nn):s.getPoints(nn)}function Xn(s,t){return!s.box||!t.box?!0:s.box.intersectsBox(t.box)}function xs(s,t){return s.kind==="spline"&&t.kind==="spline"?Br(s,t):s.kind==="spline"?As(s,t):t.kind==="spline"?As(t,s):s.kind==="line"&&t.kind==="line"?_s(s,t):s.kind==="line"&&t.kind==="circArc"?en(s,t.arc,t.full):t.kind==="line"&&s.kind==="circArc"?en(t,s.arc,s.full):s.kind==="line"&&t.kind==="ellipseArc"?Yn(s,t.arc,t.full):t.kind==="line"&&s.kind==="ellipseArc"?Yn(t,s.arc,s.full):s.kind==="circArc"&&t.kind==="circArc"?Fr(s.arc,s.full,t.arc,t.full):s.kind==="circArc"&&t.kind==="ellipseArc"?Ps(s.arc,s.full,t.arc,t.full):s.kind==="ellipseArc"&&t.kind==="circArc"?Ps(t.arc,t.full,s.arc,s.full):s.kind==="ellipseArc"&&t.kind==="ellipseArc"?jr(s.arc,s.full,t.arc,t.full):[]}function As(s,t){const n=[];for(const e of s.samples)Xn(e,t)&&Hn(n,xs(e,t));return Rr(s.spline,n,t)}function Br(s,t){const n=[];for(const i of s.samples)for(const r of t.samples)Xn(i,r)&&Hn(n,_s(i,r));const e=[];for(const i of n){const r=s.spline.nearestPoint(i,Ft),o=t.spline.nearestPoint(i,Ft);r.distanceTo(o)<=Dn&&e.push(r)}return e}function Rr(s,t,n){const e=[];for(const i of t){const r=s.nearestPoint(i,Ft);vr(n,r)<=Dn&&e.push(r)}return e}function vr(s,t){if(s.kind==="line"){const n=s.dir.lengthSq();if(n<b*b)return Number.POSITIVE_INFINITY;const e=new P().subVectors(t,s.start).dot(s.dir)/n;return kt(e,s.extent)?Et(s.start,s.dir,e).distanceTo(t):Number.POSITIVE_INFINITY}if(s.kind==="circArc"){if(!Qn(t,s.arc)){const n=st(s.arc.normal,s.arc.center),e=Math.abs(n.distanceToPoint(t)),i=Math.abs(t.distanceTo(s.arc.center)-s.arc.radius),r=Math.hypot(e,i);if(r>Dn)return r}return wt(s.arc,Pt(s.arc,t),s.full)?0:Number.POSITIVE_INFINITY}return s.kind==="ellipseArc"?Nt(t,s.arc,s.full)?0:Math.abs(sn(s.arc,t)):Number.POSITIVE_INFINITY}function _s(s,t){const n=s.dir,e=t.dir,i=n.lengthSq(),r=e.lengthSq();if(i<b*b||r<b*b)return[];const o=new P().subVectors(s.start,t.start),c=n.dot(n),a=n.dot(e),h=e.dot(e),l=n.dot(o),u=e.dot(o),d=c*h-a*a;if(Math.abs(d)<S*S*c*h)return[];const g=(a*u-h*l)/d,m=(c*u-a*l)/d;if(!kt(g,s.extent)||!kt(m,t.extent))return[];const y=Et(s.start,n,g),f=Et(t.start,e,m);return y.distanceTo(f)>b?[]:[y]}function en(s,t,n){const e=st(t.normal,t.center),i=ps(s,e);return i==="coplanar"?qr(s,t,n):i?Qn(i,t)?wt(t,Pt(t,i),n)?[i]:[]:[]:[]}function qr(s,t,n){const e=new P().subVectors(s.start,t.center),i=s.dir.dot(s.dir);if(i<b*b)return[];const r=2*s.dir.dot(e),o=e.dot(e)-t.radius*t.radius,c=[];for(const a of zs(i,r,o,2*t.radius*b)){if(!kt(a,s.extent))continue;const h=Et(s.start,s.dir,a);wt(t,Pt(t,h),n)&&c.push(h)}return c}function Yn(s,t,n){const e=st(t.normal,t.center),i=ps(s,e);return i==="coplanar"?Lr(s,t,n):i?Nt(i,t,n)?[i]:[]:[]}function Lr(s,t,n){const e=t.majorAxis,i=t.minorAxis,r=t.majorAxisRadius,o=t.minorAxisRadius;if(r<b||o<b)return[];const c=new P().subVectors(s.start,t.center),a=c.dot(e),h=c.dot(i),l=s.dir.dot(e),u=s.dir.dot(i),d=l*l/(r*r)+u*u/(o*o),g=2*a*l/(r*r)+2*h*u/(o*o),m=a*a/(r*r)+h*h/(o*o)-1,y=[];for(const f of zs(d,g,m,2*b/o)){if(!kt(f,s.extent))continue;const x=Et(s.start,s.dir,f);Kn(t,It(t,x),n)&&y.push(x)}return y}function Fr(s,t,n,e){if(Vt(s.normal,n.normal)){const c=st(s.normal,s.center);return Math.abs(c.distanceToPoint(n.center))>b?[]:Or(Vr(s,n),s,t,n,e)}const i=Gn(st(s.normal,s.center),st(n.normal,n.center));if(!i)return[];const r=Tt(i.point.clone(),new z().addVectors(i.point,i.dir),"unbounded");return en(r,s,t).filter(c=>Qn(c,n)?wt(n,Pt(n,c),e):!1)}function Vr(s,t){const n=new P().subVectors(t.center,s.center),e=n.length(),i=s.radius,r=t.radius;if(e<b&&w.equal(i,r,b))return[];if(e>i+r+b)return[];if(e+Math.min(i,r)+b<Math.max(i,r))return[];const o=e<b?Ms(s.normal):n.clone().normalize(),c=(i*i-r*r+e*e)/(2*Math.max(e,b)),a=i*i-c*c,h=new z().copy(s.center).addScaledVector(o,c);if(a<-b*b)return[];if(a<b*b)return[h];const l=Math.sqrt(Math.max(0,a)),u=new P().crossVectors(s.normal,o).normalize();return[new z().copy(h).addScaledVector(u,l),new z().copy(h).addScaledVector(u,-l)]}function Ps(s,t,n,e){if(!Vt(s.normal,n.normal)){const i=Gn(st(s.normal,s.center),st(n.normal,n.center));if(!i)return[];const r=Tt(i.point.clone(),new z().addVectors(i.point,i.dir),"unbounded");return en(r,s,t).filter(o=>Nt(o,n,e))}return ws(fs(s,t),ct(s)||t,i=>sn(n,i),i=>wt(s,Pt(s,i),t)&&Nt(i,n,e))}function jr(s,t,n,e){if(!Vt(s.normal,n.normal)){const i=Gn(st(s.normal,s.center),st(n.normal,n.center));if(!i)return[];const r=Tt(i.point.clone(),new z().addVectors(i.point,i.dir),"unbounded");return Yn(r,s,t).filter(o=>Nt(o,n,e))}return ws(ys(s,t),ut(s)||t,i=>sn(n,i),i=>Kn(s,It(s,i),t)&&Nt(i,n,e))}function ws(s,t,n,e){const i=[],r=t?s.length:s.length-1;for(let o=0;o<r;o++){const c=s[o],a=s[(o+1)%s.length],h=n(c),l=n(a);if(Math.abs(h)<=b){e(c)&&i.push(c.clone());continue}if(h*l>0)continue;let u=0,d=1,g=h;for(let y=0;y<40;y++){const f=(u+d)/2,x=new z().lerpVectors(c,a,f),p=n(x);g*p<=0?d=f:(u=f,g=p)}const m=new z().lerpVectors(c,a,(u+d)/2);e(m)&&i.push(m)}return i}function ps(s,t){const n=t.normal.dot(s.dir),e=t.distanceToPoint(s.start);if(w.equalToZero(n,b*Math.max(1,s.dir.length())))return w.equalToZero(e,b)?"coplanar":null;const i=-e/n;return kt(i,s.extent)?Et(s.start,s.dir,i):null}function Gn(s,t){const n=new P().crossVectors(s.normal,t.normal);if(n.lengthSq()<b*b)return null;n.normalize();const e=s.normal,i=t.normal,r=e.dot(e)*i.dot(i)-e.dot(i)**2;if(Math.abs(r)<S)return null;const o=-s.constant,c=-t.constant,a=(i.dot(i)*o-e.dot(i)*c)/r,h=(e.dot(e)*c-e.dot(i)*o)/r;return{point:new z().addScaledVector(e,a).addScaledVector(i,h),dir:n}}function kt(s,t){return t==="unbounded"?!0:t==="ray"?s>=-b:s>=-b&&s<=1+b}function Et(s,t,n){return new z().copy(s).addScaledVector(t,n)}function lt(s,t){const n=new z;return t.projectPoint(s,n),n}function Wn(s,t){const n=s.clone().addScaledVector(t,-s.dot(t));return n.lengthSq()<b*b?Ms(t):n.normalize()}function st(s,t){return new bt().setFromNormalAndCoplanarPoint(s,t)}function Vt(s,t){return new P().crossVectors(s,t).lengthSq()<b*b}function Pt(s,t){const n=new P().subVectors(t,s.center),e=new P().crossVectors(s.normal,s.refVec);return Math.atan2(n.dot(e),n.dot(s.refVec))}function It(s,t){const n=new P().subVectors(t,s.center),e=n.dot(s.majorAxis)/s.majorAxisRadius,i=n.dot(s.minorAxis)/s.minorAxisRadius;return Math.atan2(i,e)}function ct(s){return s.closed||Math.abs(s.deltaAngle-C)<1e-10}function ut(s){return s.closed||Math.abs(s.endAngle-s.startAngle)<1e-10||Math.abs(s.deltaAngle-C)<1e-10}function wt(s,t,n){return n||ct(s)?!0:M.normalizeAngle(t-s.startAngle)<=s.deltaAngle+1e-8}function Kn(s,t,n){return n||ut(s)?!0:M.normalizeAngle(t-s.startAngle)<=s.deltaAngle+1e-8}function Qn(s,t){const n=st(t.normal,t.center);return Math.abs(n.distanceToPoint(s))>b?!1:Math.abs(s.distanceTo(t.center)-t.radius)<=b}function sn(s,t){const n=new P().subVectors(t,s.center),e=n.dot(s.majorAxis)/s.majorAxisRadius,i=n.dot(s.minorAxis)/s.minorAxisRadius;return e*e+i*i-1}function Nt(s,t,n){const e=st(t.normal,t.center);return Math.abs(e.distanceToPoint(s))>b||Math.abs(sn(t,s))>1e-4?!1:Kn(t,It(t,s),n)}function Or(s,t,n,e,i){return s.filter(r=>wt(t,Pt(t,r),n)&&wt(e,Pt(e,r),i))}function Ms(s){const t=Math.abs(s.x)<.9?P.X_AXIS:P.Y_AXIS,n=new P().crossVectors(s,t);return n.lengthSq()<b*b&&n.crossVectors(s,P.Z_AXIS),n.normalize()}function zs(s,t,n,e){if(Math.abs(s)<S)return Math.abs(t)<S?[]:[-n/t];const i=t*t-4*s*n,r=i/(4*Math.abs(s));if(r<-e)return[];if(r<=e)return[-t/(2*s)];const o=Math.sqrt(i);return[(-t-o)/(2*s),(-t+o)/(2*s)]}function Hn(s,t){for(const n of t)s.push(n)}function Ur(s){const t=[];for(const n of s)t.some(e=>e.distanceTo(n)<=b)||t.push(n);return t}function Dr(s,t,n){const e=n.radius;if(!Number.isFinite(e)||e<0)return{ok:!1,error:"invalidRadius"};const i=n.tol??yt;if(s.kind==="line"&&t.kind==="line")return bs(s,t,e,n.hintA,n.hintB,i);if(s.kind==="line"&&t.kind==="circArc")return rn(s,t,e,n.hintA,n.hintB,i);if(s.kind==="circArc"&&t.kind==="line"){const r=rn(t,s,e,n.hintB,n.hintA,i);return Bs(r)}return s.kind==="circArc"&&t.kind==="circArc"?Yr(s,t,e,n.hintA,n.hintB,i):Gr(s,t,e,n.hintA,n.hintB,i)}function bs(s,t,n,e,i,r){const o=$n(s),c=$n(t);if(o.length<S||c.length<S)return{ok:!1,error:"noSolution"};const a=o.dir.x*c.dir.y-o.dir.y*c.dir.x;if(Math.abs(a)<r.equalVectorTol)return Zr(o,c,n,e,i,r);const h=Ts(o,c);if(!h)return{ok:!1,error:"noIntersection"};if(w.isNonPositive(n))return{ok:!0,result:{trimA:h.clone(),trimB:h.clone(),radius:0}};const l=[];for(const d of[1,-1])for(const g of[1,-1]){const m=te(o,d*n),y=te(c,g*n),f=Ts(m,y);if(!f)continue;const x=on(o,f),p=on(c,f),k=F(f,x),E=F(f,p);if(Math.abs(k-n)>r.equalPointTol*10||Math.abs(E-n)>r.equalPointTol*10)continue;const N=ee(f,n,x,p,h);N&&l.push({arc:N,trimA:x,trimB:p,center:f,radius:n})}return l.length===0?{ok:!1,error:"noSolution"}:{ok:!0,result:se(l,e,i,h)}}function Zr(s,t,n,e,i,r){const o=new _(-s.dir.y,s.dir.x),c=(t.origin.x-s.origin.x)*o.x+(t.origin.y-s.origin.y)*o.y,a=Math.abs(c);if(a<r.equalPointTol)return{ok:!1,error:"parallel"};const h=a/2,l=c>0?1:-1,u=new _(s.origin.x+o.x*l*h,s.origin.y+o.y*l*h),d=e&&i?cn(e,i):e?new _(e):i?new _(i):new _((s.origin.x+t.origin.x)/2,(s.origin.y+t.origin.y)/2),g=on({...s,origin:u},d),m=new _(g.x-o.x*l*h,g.y-o.y*l*h),y=new _(g.x+o.x*l*h,g.y+o.y*l*h),f=new _(g.x+s.dir.x*h,g.y+s.dir.y*h),x=new _(g.x-s.dir.x*h,g.y-s.dir.y*h),p=F(f,d)<=F(x,d)?f:x,k=v.tryCreateByThreePoints(m,p,y);return k?{ok:!0,result:{arc:k,trimA:m,trimB:y,center:g,radius:h}}:{ok:!1,error:"noSolution"}}function rn(s,t,n,e,i,r){const o=$n(s),c=Jn(t);if(o.length<S||c.radius<S)return{ok:!1,error:"noSolution"};if(w.isNonPositive(n))return Xr(o,c,e,i,r);const a=[];for(const u of[1,-1])for(const d of[1,-1]){const g=c.radius+d*n;if(g<S)continue;const m=te(o,u*n),y=ks(m,c.center,g,r);for(const f of y){const x=on(o,f),p=new _(f.x-c.center.x,f.y-c.center.y),k=Math.hypot(p.x,p.y);if(k<S)continue;const E=new _(c.center.x+p.x/k*c.radius,c.center.y+p.y/k*c.radius);if(!ne(c,E)&&!c.closed)continue;const N=pt(e,i)??Ns(x,E),B=ee(f,n,x,E,N);B&&a.push({arc:B,trimA:x,trimB:E,center:f,radius:n})}}if(a.length===0)return{ok:!1,error:"noSolution"};const h=pt(e,i);return{ok:!0,result:se(a,e,i,h)}}function Xr(s,t,n,e,i){const r=ks(s,t.center,t.radius,i);if(r.length===0)return{ok:!1,error:"noIntersection"};const o=pt(n,e);let c=r[0],a=1/0;for(const h of r){const l=o?F(h,o):0;l<a&&(a=l,c=h)}return{ok:!0,result:{trimA:c.clone(),trimB:c.clone(),radius:0}}}function Yr(s,t,n,e,i,r){const o=Jn(s),c=Jn(t);if(w.isNonPositive(n)){const l=Es(o.center,o.radius,c.center,c.radius,r);if(l.length===0)return{ok:!1,error:"noIntersection"};const u=pt(e,i);let d=l[0],g=1/0;for(const m of l){const y=u?F(m,u):0;y<g&&(g=y,d=m)}return{ok:!0,result:{trimA:d.clone(),trimB:d.clone(),radius:0}}}const a=[];for(const l of[1,-1])for(const u of[1,-1]){const d=o.radius+l*n,g=c.radius+u*n;if(d<S||g<S)continue;const m=Es(o.center,d,c.center,g,r);for(const y of m){const f=Is(o.center,o.radius,y),x=Is(c.center,c.radius,y);if(!f||!x||!o.closed&&!ne(o,f)||!c.closed&&!ne(c,x))continue;const p=pt(e,i)??Ns(f,x),k=ee(y,n,f,x,p);k&&a.push({arc:k,trimA:f,trimB:x,center:y,radius:n})}}return a.length===0?{ok:!1,error:"noSolution"}:{ok:!0,result:se(a,e,i,pt(e,i))}}function Gr(s,t,n,e,i,r){const o=Ss(s),c=Ss(t);if(o.length<2||c.length<2)return{ok:!1,error:"unsupported"};const a=Cs(o,e??o[0]),h=Cs(c,i??c[0]);if(!a||!h)return{ok:!1,error:"noSolution"};if(s.kind==="circArc"){const l=rn({start:h.p0,end:h.p1,extent:"bounded"},s,n,i,e,r);if(l.ok)return Bs(l)}if(t.kind==="circArc"){const l=rn({start:a.p0,end:a.p1,extent:"bounded"},t,n,e,i,r);if(l.ok)return l}return bs({start:a.p0,end:a.p1,extent:"bounded"},{start:h.p0,end:h.p1,extent:"bounded"},n,e,i,r)}function Ss(s){return s.kind==="line"?[new _(s.start),new _(s.end)]:s.kind==="circArc"?Wr(s,64):s.kind==="ellipseArc"?Kr(s,96):s.samples.map(t=>new _(t))}function Wr(s,t){const n=[],e=M.normalizeAngle(s.startAngle),i=Math.max(8,t);for(let r=0;r<=i;r++){const o=r/i,c=s.closed?e+Math.PI*2*o:s.clockwise?e-M.normalizeAngle(s.startAngle-s.endAngle)*o:e+M.normalizeAngle(s.endAngle-s.startAngle)*o;n.push(new _(s.center.x+s.radius*Math.cos(c),s.center.y+s.radius*Math.sin(c)))}return n}function Kr(s,t){const n=[],e=s.rotation??0,i=Math.cos(e),r=Math.sin(e),o=Math.max(8,t);for(let c=0;c<=o;c++){const a=c/o,h=s.closed?s.startAngle+Math.PI*2*a:s.clockwise?s.startAngle-M.normalizeAngle(s.startAngle-s.endAngle)*a:s.startAngle+M.normalizeAngle(s.endAngle-s.startAngle)*a,l=s.majorRadius*Math.cos(h),u=s.minorRadius*Math.sin(h);n.push(new _(s.center.x+l*i-u*r,s.center.y+l*r+u*i))}return n}function Cs(s,t){let n=null,e=1/0;for(let i=0;i<s.length-1;i++){const r=s[i],o=s[i+1],c=Qr(r,o,t),a=F(c,t);a<e&&(e=a,n={p0:r,p1:o})}return n}function Qr(s,t,n){const e=t.x-s.x,i=t.y-s.y,r=e*e+i*i;if(r<S)return s.clone();let o=((n.x-s.x)*e+(n.y-s.y)*i)/r;return o=Math.max(0,Math.min(1,o)),new _(s.x+o*e,s.y+o*i)}function $n(s){const t=new _(s.start),n=new _(s.end),e=n.x-t.x,i=n.y-t.y,r=Math.hypot(e,i),o=r>S?new _(e/r,i/r):new _(1,0);return{origin:t,dir:o,length:r,extent:s.extent??"bounded"}}function Jn(s){return{center:new _(s.center),radius:s.radius,startAngle:M.normalizeAngle(s.startAngle),endAngle:M.normalizeAngle(s.endAngle),clockwise:!!s.clockwise,closed:!!s.closed}}function te(s,t){const n=new _(-s.dir.y,s.dir.x);return{origin:new _(s.origin.x+n.x*t,s.origin.y+n.y*t),dir:s.dir.clone(),length:s.length,extent:"unbounded"}}function Ts(s,t){const n=s.dir.x*t.dir.y-s.dir.y*t.dir.x;if(Math.abs(n)<S)return null;const e=t.origin.x-s.origin.x,i=t.origin.y-s.origin.y,r=(e*t.dir.y-i*t.dir.x)/n;return new _(s.origin.x+s.dir.x*r,s.origin.y+s.dir.y*r)}function on(s,t){const n=(t.x-s.origin.x)*s.dir.x+(t.y-s.origin.y)*s.dir.y;return new _(s.origin.x+s.dir.x*n,s.origin.y+s.dir.y*n)}function ks(s,t,n,e){const i=new _(s.origin.x-t.x,s.origin.y-t.y),r=1,o=2*(i.x*s.dir.x+i.y*s.dir.y),c=i.x*i.x+i.y*i.y-n*n,a=o*o-4*r*c;if(a<-e.equalPointTol)return[];const h=Math.sqrt(Math.max(0,a)),l=(-o-h)/(2*r),u=(-o+h)/(2*r),d=[new _(s.origin.x+s.dir.x*l,s.origin.y+s.dir.y*l)];return Math.abs(u-l)>e.equalPointTol&&d.push(new _(s.origin.x+s.dir.x*u,s.origin.y+s.dir.y*u)),d}function Es(s,t,n,e,i){const r=n.x-s.x,o=n.y-s.y,c=Math.hypot(r,o);if(c<S)return[];if(c>t+e+i.equalPointTol)return[];if(c<Math.abs(t-e)-i.equalPointTol)return[];const a=(t*t-e*e+c*c)/(2*c),h=t*t-a*a,l=Math.sqrt(Math.max(0,h)),u=s.x+r*a/c,d=s.y+o*a/c;if(l<i.equalPointTol)return[new _(u,d)];const g=-o*l/c,m=r*l/c;return[new _(u+g,d+m),new _(u-g,d-m)]}function Is(s,t,n){const e=n.x-s.x,i=n.y-s.y,r=Math.hypot(e,i);return r<S?null:new _(s.x+e/r*t,s.y+i/r*t)}function ne(s,t,n){if(s.closed)return!0;const e=nt(s.center,t);return s.clockwise?M.isAngleOnCcwSweep(s.endAngle,e,s.startAngle):M.isAngleOnCcwSweep(s.startAngle,e,s.endAngle)}function ee(s,t,n,e,i){const r=nt(s,n),o=nt(s,e),c=nt(s,i),h=!M.isAngleOnCcwSweep(r,c,o);return v.tryCreateByCenterStartEnd(s,n,e,h)}function se(s,t,n,e){const i=pt(t,n)??e;if(!i)return s[0];let r=s[0],o=1/0;for(const c of s){const a=c.center?c.center:cn(c.trimA,c.trimB);let h=F(a,i);t&&(h+=F(c.trimA,t)*.5),n&&(h+=F(c.trimB,n)*.5),c.arc&&(h+=c.arc.deltaAngle*.01),h<o&&(o=h,r=c)}return r}function cn(s,t){return new _((s.x+t.x)/2,(s.y+t.y)/2)}function pt(s,t){if(s&&t)return cn(s,t);if(s)return new _(s);if(t)return new _(t)}function Ns(s,t){return cn(s,t)}function Bs(s){return s.ok?{ok:!0,result:{...s.result,trimA:s.result.trimB,trimB:s.result.trimA}}:s}function Hr(s,t=64){const n=Math.max(2,t);return{kind:"spline",samples:s.getPoints(n).map(i=>({x:i.x,y:i.y}))}}function $r(s){return{kind:"ellipseArc",center:{x:s.center.x,y:s.center.y},majorRadius:s.majorAxisRadius,minorRadius:s.minorAxisRadius,startAngle:s.startAngle,endAngle:s.endAngle,clockwise:s.clockwise,closed:s.closed,rotation:s.rotation}}function Jr(s,t,n){const e=n.tol??yt,i=vs(s),r=vs(t);if(i.length<S||r.length<S)return{ok:!1,error:"noSolution"};const o=i.dir.x*r.dir.y-i.dir.y*r.dir.x;if(Math.abs(o)<e.equalVectorTol)return{ok:!1,error:"parallel"};const c=to(i,r);if(!c)return{ok:!1,error:"noIntersection"};const a=Rs(i,c,n.hintA),h=Rs(r,c,n.hintB);let l,u;if(n.mode.method==="distance")l=n.mode.distance1,u=n.mode.distance2;else{l=n.mode.length;const m=n.mode.angle;if(!Number.isFinite(m)||m<0)return{ok:!1,error:"invalidDistance"};if(Math.abs(Math.sin(m))<S&&m!==0)return{ok:!1,error:"invalidDistance"};u=l*Math.tan(m)}if(!Number.isFinite(l)||!Number.isFinite(u)||l<0||u<0)return{ok:!1,error:"invalidDistance"};if(w.isNonPositive(l)&&w.isNonPositive(u))return{ok:!0,result:{trimA:c.clone(),trimB:c.clone(),corner:c.clone(),isCornerOnly:!0}};const d=new _(c.x+a.x*l,c.y+a.y*l),g=new _(c.x+h.x*u,c.y+h.y*u);return{ok:!0,result:{trimA:d,trimB:g,corner:c.clone(),isCornerOnly:!1}}}function Rs(s,t,n){const e=(t.x-s.origin.x)*s.dir.x+(t.y-s.origin.y)*s.dir.y;let i;return n?i=(n.x-s.origin.x)*s.dir.x+(n.y-s.origin.y)*s.dir.y>=e:i=s.length/2>=e,i?s.dir.clone():new _(-s.dir.x,-s.dir.y)}function vs(s){const t=new _(s.start),n=new _(s.end),e=n.x-t.x,i=n.y-t.y,r=Math.hypot(e,i),o=r>S?new _(e/r,i/r):new _(1,0);return{origin:t,end:n,dir:o,length:r,extent:s.extent??"bounded"}}function to(s,t){const n=s.dir.x*t.dir.y-s.dir.y*t.dir.x;if(Math.abs(n)<S)return null;const e=t.origin.x-s.origin.x,i=t.origin.y-s.origin.y,r=(e*t.dir.y-i*t.dir.x)/n;return new _(s.origin.x+s.dir.x*r,s.origin.y+s.dir.y*r)}A.AcGeArea2d=Vn,A.AcGeBox2d=tt,A.AcGeBox3d=rt,A.AcGeCatmullRomCurve3d=tn,A.AcGeCircArc2d=v,A.AcGeCircArc3d=et,A.AcGeCurve2d=St,A.AcGeEllipseArc2d=At,A.AcGeEllipseArc3d=ot,A.AcGeEuler=Mn,A.AcGeGeometryUtil=Y,A.AcGeLine2d=Ct,A.AcGeLine3d=$t,A.AcGeLoop2d=H,A.AcGeMathUtil=M,A.AcGeMatrix2d=Mt,A.AcGeMatrix3d=O,A.AcGeNurbsCurve=U,A.AcGePlane=bt,A.AcGePoint2d=_,A.AcGePoint3d=z,A.AcGePolyline2d=mt,A.AcGeQuaternion=Rt,A.AcGeShape2d=vn,A.AcGeSpline3d=W,A.AcGeTol=w,A.AcGeVector2d=q,A.AcGeVector3d=P,A.DEFAULT_TOL=yt,A.DEG2RAD=mn,A.FLOAT_TOL=S,A.ORIGIN_POINT_2D=qs,A.ORIGIN_POINT_3D=Pn,A.RAD2DEG=fn,A.TAU=C,A.acgeBasisFunction=gt,A.acgeBulgeArcTangentAtEnd=dr,A.acgeBulgeArcTangentAtStart=ur,A.acgeBulgeFromCenter=gr,A.acgeBulgeFromCenterWithTangent=mr,A.acgeBulgeFromCircArc2d=Ht,A.acgeBulgeFromStartEndDirection=fr,A.acgeBulgeFromStartEndRadius=xr,A.acgeBulgeFromThreePoints=yr,A.acgeCalculateCurveLength=Cn,A.acgeCeilPowerOfTwo=_e,A.acgeCenterFromBulge=jn,A.acgeChamferCurves2d=Jr,A.acgeClamp=J,A.acgeCloneIntersectPrimitive=us,A.acgeClosedPolygonArea2d=Ds,A.acgeClosedPolygonArea3d=Ne,A.acgeComplementBulge=lr,A.acgeComputeParameterValues=Be,A.acgeDamp=ae,A.acgeDegToRad=ye,A.acgeEuclideanModulo=yn,A.acgeEvaluateNurbsDerivatives=Xt,A.acgeEvaluateNurbsPoint=vt,A.acgeFilletCurves2d=Dr,A.acgeFilletPrimitiveFromEllipse2d=$r,A.acgeFilletPrimitiveFromSpline3d=Hr,A.acgeFloorPowerOfTwo=Pe,A.acgeGenerateAveragedKnots=Re,A.acgeGenerateChordKnots=Ks,A.acgeGenerateSqrtChordKnots=Qs,A.acgeGenerateUUID=re,A.acgeGenerateUniformKnots=Ws,A.acgeGeometricTangentAtPoint=On,A.acgeGetOcsAngle=mi,A.acgeGetOcsReferenceVector=di,A.acgeGetOcsReferenceVectorInto=Ve,A.acgeIntPartLength=An,A.acgeInterpolateControlPoints=ti,A.acgeInterpolateNurbsCurve=bn,A.acgeIntersectCurves=zr,A.acgeInverseLerp=ce,A.acgeIsAngleOnCcwSweep=Me,A.acgeIsBetterDistanceAlign=Xe,A.acgeIsBetween=we,A.acgeIsBetweenAngle=pe,A.acgeIsPowerOfTwo=Ae,A.acgeLerp=xn,A.acgeMapLinear=oe,A.acgeNormalizeAngle=ft,A.acgeNurbsClosestParam=ci,A.acgeNurbsEvaluate=ri,A.acgeNurbsExtractSegment=Yt,A.acgeNurbsInsertKnot=kn,A.acgeNurbsJoin=ii,A.acgeNurbsLengthTo=ai,A.acgeNurbsParameterRange=qt,A.acgeNurbsSplitAt=si,A.acgeOffsetPointByDirectionInXY=Ki,A.acgeOffsetSmoothedSampledPath=Hi,A.acgeOffsetVertexPath=Qi,A.acgePingpong=he,A.acgePointLiesOnCircle2d=De,A.acgePolygonArea2d=Ee,A.acgePolygonArea3d=Ie,A.acgeRadToDeg=xe,A.acgeRandFloat=ge,A.acgeRandFloatSpread=me,A.acgeRandInt=de,A.acgeRelativeEps=ze,A.acgeSameCircle2d=Ze,A.acgeSeededRandom=fe,A.acgeSignedPlanarCurvature=qe,A.acgeSignedPolygonArea2d=zn,A.acgeSmootherstep=ue,A.acgeSmoothstep=le,A.acgeTransformIntersectPrimitive=br,A.acgeTransformOcsPointToWcs=gi,A.acgeTransformOcsPointToWcsInto=je,A.acgeTransformWcsPointToOcs=In,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
@@ -201,7 +201,8 @@ export declare class AcGeCircArc2d extends AcGeCurve2d {
201
201
  */
202
202
  get midPoint(): AcGePoint2d;
203
203
  /**
204
- * Return true if its start point is identical to its end point. Otherwise, return false.
204
+ * Return true if this arc is a full circle (start angle equals end angle
205
+ * modulo 2π, including float noise from DWG/DXF round-trips).
205
206
  */
206
207
  get closed(): boolean;
207
208
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AcGeCircArc2d.d.ts","sourceRoot":"","sources":["../../src/geometry/AcGeCircArc2d.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,WAAW,EACX,eAAe,EAEhB,MAAM,kBAAkB,CAAA;AAgBzB,OAAO,EACL,KAAK,kBAAkB,EAMxB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EACV,6BAA6B,EAC7B,qBAAqB,EACtB,MAAM,0BAA0B,CAAA;AAEjC;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,oBAAoB,OAAM;IAC1C,iEAAiE;IACjE,MAAM,CAAC,QAAQ,CAAC,gBAAgB,KAAI;IACpC,mFAAmF;IACnF,MAAM,CAAC,QAAQ,CAAC,gBAAgB,SAAQ;IAExC,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAU;gBAEhB,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,eAAe;gBAC7D,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM;gBAErE,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE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AEG;IACH,SAAS,CAAC,OAAO,EAAE,YAAY;IA8E/B;;OAEG;IACH,KAAK;IAUL;;;;OAIG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IAO3C;;;OAGG;IACH,iBAAiB,IAAI,WAAW,EAAE;IAqBlC;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW;IAiCjD;;;;;;;OAOG;IACH,eAAe,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,GAAG,MAAM;IAqBzE;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW,EAAE;IAiD1D;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW,EAAE;IAmCpD;;;;OAIG;IACH,SAAS,CAAC,SAAS,GAAE,MAAY,GAAG,WAAW,EAAE;IA8BjD;;;;;;;OAOG;IACH,UAAU,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,WAAW,EAAE;IAS1D;;;;OAIG;IACH,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM;IAWvD;;;OAGG;IACH,MAAM,CAAC,wBAAwB,CAC7B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,6BAA6B;IAchC;;;;;OAKG;IACH,MAAM,CAAC,wBAAwB,CAC7B,MAAM,EAAE,MAAM,EACd,WAAW,GAAE,MAA2C,GACvD,MAAM;IAST;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,YAAY,CACjB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,qBAAqB,GAC9B,MAAM;CAgCV"}
@@ -62,7 +62,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
62
62
  };
63
63
  import { AcCmErrors } from '@mlightcad/common';
64
64
  import { AcGeBox2d, AcGePoint2d, AcGeVector2d } from '../math/index.js';
65
- import { acgeClamp, AcGeMathUtil, FLOAT_TOL, TAU } from '../util/index.js';
65
+ import { acgeClamp, AcGeMathUtil, AcGeTol, FLOAT_TOL, TAU } from '../util/index.js';
66
66
  import { acgeTryCreateArcByCenterStartChord, acgeTryCreateArcByCenterStartEnd, acgeTryCreateArcByCenterStartProjectedEnd, acgeTryCreateArcByCenterStartSweep, acgeTryCreateArcByStartEndAngle, acgeTryCreateArcByStartEndDirection, acgeTryCreateArcByStartEndRadius, acgeTryCreateArcByThreePoints, acgeTryCreateCircle, acgeTryCreateCircleByDiameter, acgeTryCreateCircleByThreePoints, acgeTryCreateShorterArc } from './AcGeCircArc2dFactory.js';
67
67
  import { acgeComputeCircumcircle2d, acgeIsBetterDistanceAlign, acgePointLiesOnCircle2d, acgeProjectPointOntoCircle2d, acgeSameCircle2d } from './AcGeCircArcUtil.js';
68
68
  import { AcGeCurve2d } from './AcGeCurve2d.js';
@@ -488,12 +488,20 @@ var AcGeCircArc2d = /** @class */ (function (_super) {
488
488
  });
489
489
  Object.defineProperty(AcGeCircArc2d.prototype, "closed", {
490
490
  /**
491
- * Return true if its start point is identical to its end point. Otherwise, return false.
491
+ * Return true if this arc is a full circle (start angle equals end angle
492
+ * modulo 2π, including float noise from DWG/DXF round-trips).
492
493
  */
493
494
  get: function () {
494
495
  var internalStartAngle = this._getInternalAngle(this.startAngle);
495
496
  var internalEndAngle = this._getInternalAngle(this.endAngle);
496
- return (Math.abs(internalEndAngle - internalStartAngle) / Math.PI) % 2 == 0;
497
+ // Half-turns modulo 2: 0, 2, 4, … mean a full-circle span (0, 2π, 4π, …).
498
+ // Use a tight angle epsilon so intentional tiny sweeps stay open, while
499
+ // DWG float noise (e.g. start/end differing by ~1e-15) still counts as closed.
500
+ var halfTurns = Math.abs(internalEndAngle - internalStartAngle) / Math.PI;
501
+ var mod = halfTurns % 2;
502
+ var angleTol = 1e-12;
503
+ return (AcGeTol.equalToZero(mod, angleTol) ||
504
+ AcGeTol.equalToZero(2 - mod, angleTol));
497
505
  },
498
506
  enumerable: false,
499
507
  configurable: true
@@ -555,12 +563,27 @@ var AcGeCircArc2d = /** @class */ (function (_super) {
555
563
  }
556
564
  var transformedMid = this.midPoint.clone().applyMatrix2d(matrix);
557
565
  var transformedEnd = this.endPoint.clone().applyMatrix2d(matrix);
558
- var transformedArc = new AcGeCircArc2d(transformedStart, transformedMid, transformedEnd);
566
+ // Affine maps can make start/mid/end collinear (near-zero sweep, or a
567
+ // near-singular OCS→XY projection). Never throw from transform — fall
568
+ // back to transforming the defining center and polar angles.
569
+ var transformedArc = AcGeCircArc2d.tryCreateByThreePoints(transformedStart, transformedMid, transformedEnd);
559
570
  var clockwise = matrix.determinant() < 0 ? !this.clockwise : this.clockwise;
560
571
  var toPublicAngle = function (angle) {
561
572
  var normalized = AcGeMathUtil.normalizeAngle(angle);
562
573
  return clockwise ? _this._mirrorAngle(normalized) : normalized;
563
574
  };
575
+ if (!transformedArc) {
576
+ this.center = transformedCenter;
577
+ var radius = transformedCenter.distanceTo(transformedStart);
578
+ if (radius > FLOAT_TOL) {
579
+ this.radius = radius;
580
+ }
581
+ this.clockwise = clockwise;
582
+ this.startAngle = toPublicAngle(Math.atan2(transformedStart.y - transformedCenter.y, transformedStart.x - transformedCenter.x));
583
+ this.endAngle = toPublicAngle(Math.atan2(transformedEnd.y - transformedCenter.y, transformedEnd.x - transformedCenter.x));
584
+ this._boundingBoxNeedsUpdate = true;
585
+ return this;
586
+ }
564
587
  this.center = transformedArc.center;
565
588
  this.radius = transformedArc.radius;
566
589
  this.clockwise = clockwise;
@@ -1 +1 @@
1
- {"version":3,"file":"AcGeCircArc2d.js","sourceRoot":"","sources":["../../src/geometry/AcGeCircArc2d.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EACL,SAAS,EAET,WAAW,EAEX,YAAY,EACb,MAAM,kBAAk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ACjD,8BAAgB,GAAG,CAAC,CAAA;IACpC,mFAAmF;IACnE,8BAAgB,GAAG,KAAK,CAAA;IA8/B1C,oBAAC;CAAA,AAvgCD,CAAmC,WAAW,GAugC7C;SAvgCY,aAAa"}
@@ -80,7 +80,8 @@ export declare class AcGeEllipseArc2d extends AcGeCurve2d {
80
80
  */
81
81
  calculateBoundingBox(): AcGeBox2d;
82
82
  /**
83
- * Return true if its start point is identical to its end point. Otherwise, return false.
83
+ * Return true if this arc is a full ellipse (start angle equals end angle
84
+ * modulo 2π, including float noise from DWG/DXF round-trips).
84
85
  */
85
86
  get closed(): boolean;
86
87
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AcGeEllipseArc2d.d.ts","sourceRoot":"","sources":["../../src/geometry/AcGeEllipseArc2d.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,EACX,aAAa,EACd,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;IAE/C,OAAO,CAAC,OAAO,CAAc;IAE7B,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO,CAAC,WAAW,CAAS;IAE5B,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,UAAU,CAAU;IAG5B,OAAO,CAAC,SAAS,CAAS;IAE1B;;;;;;;;;;OAUG;gBAED,MAAM,EAAE,aAAa,EACrB,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,EACvB,UAAU,GAAE,MAAU,EACtB,QAAQ,GAAE,MAAY,EACtB,SAAS,GAAE,OAAe,EAC1B,QAAQ,GAAE,MAAU;IAkBtB;;OAEG;IACH,IAAI,MAAM,IAAI,WAAW,CAExB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,aAAa,EAG9B;IAED;;OAE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,EAAE,MAAM,EAMzB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IACD,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,EAG3B;IAED;;;OAGG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAGzB;IAED;;OAEG;IACH,IAAI,UAAU,WAEb;IAED;;OAEG;IACH,IAAI,UAAU,UAEb;IAED;;;;OAIG;IACH,oBAAoB;IAmBpB;;;OAGG;IACH,IAAI,MAAM,YAUT;IAED;;;;OAIG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW;IA4ChC;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,YAAY;IAyE/B,OAAO,CAAC,eAAe;IAQvB;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,gBAAgB;IAW5B;;OAEG;IACH,KAAK;IAYL;;;;OAIG;IACH,cAAc,IAAI,WAAW,EAAE;IAkB/B;;OAEG;IACH,iBAAiB,IAAI,WAAW,EAAE;IAYlC;;;;;;OAMG;IACH,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW;IAgB/C;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,EAAE;IAUlD;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,WAAW,EAAE;IAUxD,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,eAAe;CAuCxB"}
@@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () {
15
15
  })();
16
16
  import { AcCmErrors } from '@mlightcad/common';
17
17
  import { AcGeBox2d, AcGePoint2d, AcGePoint3d } from '../math/index.js';
18
- import { AcGeMathUtil, TAU } from '../util/index.js';
18
+ import { AcGeMathUtil, AcGeTol, TAU } from '../util/index.js';
19
19
  import { AcGeCurve2d } from './AcGeCurve2d.js';
20
20
  /**
21
21
  * Class representing a 3d ellipse arc defined by center, normal, majorAxis, majorAxisRadius,
@@ -208,10 +208,17 @@ var AcGeEllipseArc2d = /** @class */ (function (_super) {
208
208
  };
209
209
  Object.defineProperty(AcGeEllipseArc2d.prototype, "closed", {
210
210
  /**
211
- * Return true if its start point is identical to its end point. Otherwise, return false.
211
+ * Return true if this arc is a full ellipse (start angle equals end angle
212
+ * modulo 2π, including float noise from DWG/DXF round-trips).
212
213
  */
213
214
  get: function () {
214
- return this.deltaAngle == 0;
215
+ // deltaAngle is already in [0, 2π). Near-0 and near-2π both mean a full
216
+ // span; use a tight angle epsilon so intentional tiny sweeps stay open
217
+ // while DWG float noise (e.g. start/end differing by ~1e-15) still counts
218
+ // as closed — matching AcGeCircArc2d.
219
+ var angleTol = 1e-12;
220
+ return (AcGeTol.equalToZero(this.deltaAngle, angleTol) ||
221
+ AcGeTol.equalToZero(TAU - this.deltaAngle, angleTol));
215
222
  },
216
223
  enumerable: false,
217
224
  configurable: true
@@ -1 +1 @@
1
- {"version":3,"file":"AcGeEllipseArc2d.js","sourceRoot":"","sources":["../../src/geometry/AcGeEllipseArc2d.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EACL,SAAS,EAET,WAAW,EACX,WAAW,EAEZ,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C;;;;;;;;GAQG;AACH;IAAsC,oCAAW;IAiB/C;;;;;;;;;;OAUG;IACH,0BACE,MAAqB,EACrB,eAAuB,EACvB,eAAuB,EACvB,UAAsB,EACtB,QAAsB,EACtB,SAA0B,EAC1B,QAAoB;QAHpB,2BAAA,EAAA,cAAsB;QACtB,yBAAA,EAAA,cAAsB;QACtB,0BAAA,EAAA,iBAA0B;QAC1B,yBAAA,EAAA,YAAoB;QAEpB,YAAA,MAAK,WA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AW,GAyehD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/geometry-engine",
3
- "version": "3.16.6",
3
+ "version": "3.16.8",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "require": "./dist/geometry-engine.umd.cjs"
35
35
  },
36
36
  "peerDependencies": {
37
- "@mlightcad/common": "^1.16.6"
37
+ "@mlightcad/common": "^1.16.8"
38
38
  },
39
39
  "scripts": {
40
40
  "clean": "rimraf dist lib tsconfig.tsbuildinfo",