@mlightcad/geometry-engine 3.2.38 → 3.2.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/geometry-engine.umd.cjs +1 -1
  2. package/lib/geometry/AcGeCircArc3d.d.ts +7 -0
  3. package/lib/geometry/AcGeCircArc3d.d.ts.map +1 -1
  4. package/lib/geometry/AcGeCircArc3d.js +12 -0
  5. package/lib/geometry/AcGeCircArc3d.js.map +1 -1
  6. package/lib/geometry/AcGeEllipseArc3d.d.ts +7 -0
  7. package/lib/geometry/AcGeEllipseArc3d.d.ts.map +1 -1
  8. package/lib/geometry/AcGeEllipseArc3d.js +13 -0
  9. package/lib/geometry/AcGeEllipseArc3d.js.map +1 -1
  10. package/lib/geometry/AcGeLine3d.d.ts +7 -0
  11. package/lib/geometry/AcGeLine3d.d.ts.map +1 -1
  12. package/lib/geometry/AcGeLine3d.js +16 -0
  13. package/lib/geometry/AcGeLine3d.js.map +1 -1
  14. package/lib/geometry/AcGeNurbsCurve.d.ts +55 -1
  15. package/lib/geometry/AcGeNurbsCurve.d.ts.map +1 -1
  16. package/lib/geometry/AcGeNurbsCurve.js +146 -4
  17. package/lib/geometry/AcGeNurbsCurve.js.map +1 -1
  18. package/lib/geometry/AcGePolyline2d.d.ts +7 -0
  19. package/lib/geometry/AcGePolyline2d.d.ts.map +1 -1
  20. package/lib/geometry/AcGePolyline2d.js +10 -0
  21. package/lib/geometry/AcGePolyline2d.js.map +1 -1
  22. package/lib/geometry/AcGePolyline2dOffset.d.ts +28 -0
  23. package/lib/geometry/AcGePolyline2dOffset.d.ts.map +1 -0
  24. package/lib/geometry/AcGePolyline2dOffset.js +886 -0
  25. package/lib/geometry/AcGePolyline2dOffset.js.map +1 -0
  26. package/lib/geometry/AcGeSpline3d.d.ts +9 -1
  27. package/lib/geometry/AcGeSpline3d.d.ts.map +1 -1
  28. package/lib/geometry/AcGeSpline3d.js +7 -0
  29. package/lib/geometry/AcGeSpline3d.js.map +1 -1
  30. package/lib/index.d.ts +1 -1
  31. package/lib/index.d.ts.map +1 -1
  32. package/lib/index.js +1 -1
  33. package/lib/index.js.map +1 -1
  34. package/lib/util/AcGeCurveOffsetUtil.d.ts +22 -0
  35. package/lib/util/AcGeCurveOffsetUtil.d.ts.map +1 -0
  36. package/lib/util/AcGeCurveOffsetUtil.js +37 -0
  37. package/lib/util/AcGeCurveOffsetUtil.js.map +1 -0
  38. package/lib/util/AcGeNurbsUtil.d.ts +13 -0
  39. package/lib/util/AcGeNurbsUtil.d.ts.map +1 -1
  40. package/lib/util/AcGeNurbsUtil.js +105 -0
  41. package/lib/util/AcGeNurbsUtil.js.map +1 -1
  42. package/lib/util/AcGeSampledCurveOffsetUtil.d.ts +21 -0
  43. package/lib/util/AcGeSampledCurveOffsetUtil.d.ts.map +1 -0
  44. package/lib/util/AcGeSampledCurveOffsetUtil.js +302 -0
  45. package/lib/util/AcGeSampledCurveOffsetUtil.js.map +1 -0
  46. package/lib/util/AcGeTol.d.ts +8 -0
  47. package/lib/util/AcGeTol.d.ts.map +1 -1
  48. package/lib/util/AcGeTol.js +14 -0
  49. package/lib/util/AcGeTol.js.map +1 -1
  50. package/lib/util/index.d.ts +3 -1
  51. package/lib/util/index.d.ts.map +1 -1
  52. package/lib/util/index.js +3 -1
  53. package/lib/util/index.js.map +1 -1
  54. package/package.json +2 -2
@@ -1 +1 @@
1
- (function(A,N){typeof exports=="object"&&typeof module<"u"?N(exports,require("@mlightcad/common")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/common"],N):(A=typeof globalThis<"u"?globalThis:A||self,N(A["geometry-engine"]={},A.common))})(this,function(A,N){"use strict";const j=["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 Wt=1234567;const Bt=Math.PI/180,kt=180/Math.PI;function $t(){const u=Math.random()*4294967295|0,t=Math.random()*4294967295|0,s=Math.random()*4294967295|0,e=Math.random()*4294967295|0;return(j[u&255]+j[u>>8&255]+j[u>>16&255]+j[u>>24&255]+"-"+j[t&255]+j[t>>8&255]+"-"+j[t>>16&15|64]+j[t>>24&255]+"-"+j[s&63|128]+j[s>>8&255]+"-"+j[s>>16&255]+j[s>>24&255]+j[e&255]+j[e>>8&255]+j[e>>16&255]+j[e>>24&255]).toLowerCase()}function Y(u,t,s){return Math.max(t,Math.min(s,u))}function Rt(u,t){return(u%t+t)%t}function Ht(u,t,s,e,n){return e+(u-t)*(n-e)/(s-t)}function Jt(u,t,s){return u!==t?(s-u)/(t-u):0}function Tt(u,t,s){return(1-s)*u+s*t}function ts(u,t,s,e){return Tt(u,t,1-Math.exp(-s*e))}function ss(u,t=1){return t-Math.abs(Rt(u,t*2)-t)}function es(u,t,s){return u<=t?0:u>=s?1:(u=(u-t)/(s-t),u*u*(3-2*u))}function ns(u,t,s){return u<=t?0:u>=s?1:(u=(u-t)/(s-t),u*u*u*(u*(u*6-15)+10))}function is(u,t){return u+Math.floor(Math.random()*(t-u+1))}function rs(u,t){return u+Math.random()*(t-u)}function os(u){return u*(.5-Math.random())}function hs(u){u!==void 0&&(Wt=u);let t=Wt+=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 as(u){return u*Bt}function cs(u){return u*kt}function ls(u){return(u&u-1)===0&&u!==0}function us(u){return Math.pow(2,Math.ceil(Math.log(u)/Math.LN2))}function ds(u){return Math.pow(2,Math.floor(Math.log(u)/Math.LN2))}function nt(u){const t=Math.PI*2;return(u%t+t)%t}function ms(u,t,s){return u>t&&u<s||u>s&&u<t}function gs(u,t,s,e=!1){return u=nt(u),t=nt(t),s=nt(s),e?t>s?u<=t&&u>=s:u<=t||u>=s:t<s?u>=t&&u<=s:u>=t||u<=s}function Nt(u){return u=Math.abs(u),u<1?0:Math.ceil(Math.log10(Math.abs(u)+1))}function ys(u,t=1e-7){const s=Nt(u);return Math.max(Math.pow(10,s)*t,t)}const P={DEG2RAD:Bt,RAD2DEG:kt,generateUUID:$t,clamp:Y,euclideanModulo:Rt,mapLinear:Ht,inverseLerp:Jt,lerp:Tt,damp:ts,pingpong:ss,smoothstep:es,smootherstep:ns,randInt:is,randFloat:rs,randFloatSpread:os,seededRandom:hs,degToRad:as,radToDeg:cs,isPowerOfTwo:ls,ceilPowerOfTwo:us,floorPowerOfTwo:ds,normalizeAngle:nt,isBetween:ms,isBetweenAngle:gs,intPartLength:Nt,relativeEps:ys},gt=class gt{constructor(t,s){this.x=0,this.y=0;const e=+(t!==void 0)+ +(s!==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:n,y:i}=t;this.x=n,this.y=i;return}if(e===2){this.x=t,this.y=s;return}throw N.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,s){return this.x=t,this.y=s,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,s){switch(t){case 0:this.x=s;break;case 1:this.y=s;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 gt(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,s){return this.x=t.x+s.x,this.y=t.y+s.y,this}addScaledVector(t,s){return this.x+=t.x*s,this.y+=t.y*s,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,s){return this.x=t.x-s.x,this.y=t.y-s.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 s=this.x,e=this.y,n=t.elements;return this.x=n[0]*s+n[3]*e+n[6],this.y=n[1]*s+n[4]*e+n[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,s){return this.x=Math.max(t.x,Math.min(s.x,this.x)),this.y=Math.max(t.y,Math.min(s.y,this.y)),this}clampScalar(t,s){return this.x=Math.max(t,Math.min(s,this.x)),this.y=Math.max(t,Math.min(s,this.y)),this}clampLength(t,s){const e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(s,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 s=Math.sqrt(this.lengthSq()*t.lengthSq());if(s===0)return Math.PI/2;const e=this.dot(t)/s;return Math.acos(Math.max(-1,Math.min(1,e)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const s=this.x-t.x,e=this.y-t.y;return s*s+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,s){return this.x+=(t.x-this.x)*s,this.y+=(t.y-this.y)*s,this}lerpVectors(t,s,e){return this.x=t.x+(s.x-t.x)*e,this.y=t.y+(s.y-t.y)*e,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,s=0){return this.x=t[s],this.y=t[s+1],this}toArray(t=[],s=0){return t[s]=this.x,t[s+1]=this.y,t}rotateAround(t,s){const e=Math.cos(s),n=Math.sin(s),i=this.x-t.x,r=this.y-t.y;return this.x=i*e-r*n+t.x,this.y=i*n+r*e+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(P.relativeEps(this.x,t),P.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};gt.EMPTY=Object.freeze(new gt(0,0));let B=gt;const yt=class yt{constructor(t,s,e,n,i,r,o,a,h){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&s!=null&&e!=null&&n!=null&&i!=null&&r!=null&&o!=null&&a!=null&&h!=null&&this.set(t,s,e,n,i,r,o,a,h)}set(t,s,e,n,i,r,o,a,h){const c=this.elements;return c[0]=t,c[1]=n,c[2]=o,c[3]=s,c[4]=i,c[5]=a,c[6]=e,c[7]=r,c[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const s=this.elements,e=t.elements;return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s[6]=e[6],s[7]=e[7],s[8]=e[8],this}extractBasis(t,s,e){return t.setFromMatrix3Column(this,0),s.setFromMatrix3Column(this,1),e.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const s=t.elements;return this.set(s[0],s[4],s[8],s[1],s[5],s[9],s[2],s[6],s[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,s){const e=t.elements,n=s.elements,i=this.elements,r=e[0],o=e[3],a=e[6],h=e[1],c=e[4],l=e[7],m=e[2],d=e[5],g=e[8],y=n[0],x=n[3],f=n[6],b=n[1],p=n[4],C=n[7],S=n[2],k=n[5],w=n[8];return i[0]=r*y+o*b+a*S,i[3]=r*x+o*p+a*k,i[6]=r*f+o*C+a*w,i[1]=h*y+c*b+l*S,i[4]=h*x+c*p+l*k,i[7]=h*f+c*C+l*w,i[2]=m*y+d*b+g*S,i[5]=m*x+d*p+g*k,i[8]=m*f+d*C+g*w,this}multiplyScalar(t){const s=this.elements;return s[0]*=t,s[3]*=t,s[6]*=t,s[1]*=t,s[4]*=t,s[7]*=t,s[2]*=t,s[5]*=t,s[8]*=t,this}determinant(){const t=this.elements,s=t[0],e=t[1],n=t[2],i=t[3],r=t[4],o=t[5],a=t[6],h=t[7],c=t[8];return s*r*c-s*o*h-e*i*c+e*o*a+n*i*h-n*r*a}invert(){const t=this.elements,s=t[0],e=t[1],n=t[2],i=t[3],r=t[4],o=t[5],a=t[6],h=t[7],c=t[8],l=c*r-o*h,m=o*a-c*i,d=h*i-r*a,g=s*l+e*m+n*d;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/g;return t[0]=l*y,t[1]=(n*h-c*e)*y,t[2]=(o*e-n*r)*y,t[3]=m*y,t[4]=(c*s-n*a)*y,t[5]=(n*i-o*s)*y,t[6]=d*y,t[7]=(e*a-h*s)*y,t[8]=(r*s-e*i)*y,this}transpose(){let t;const s=this.elements;return t=s[1],s[1]=s[3],s[3]=t,t=s[2],s[2]=s[6],s[6]=t,t=s[5],s[5]=s[7],s[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const s=this.elements;return t.elements[0]=s[0],t.elements[1]=s[3],t.elements[2]=s[6],t.elements[3]=s[1],t.elements[4]=s[4],t.elements[5]=s[7],t.elements[6]=s[2],t.elements[7]=s[5],t.elements[8]=s[8],this}setUvTransform(t,s,e,n,i,r,o){const a=Math.cos(i),h=Math.sin(i);return this.set(e*a,e*h,-e*(a*r+h*o)+r+t,-n*h,n*a,-n*(-h*r+a*o)+o+s,0,0,1),this}scale(t,s){return this.premultiply(jt.makeScale(t,s)),this}rotate(t){return this.premultiply(jt.makeRotation(-t)),this}translate(t,s){return this.premultiply(jt.makeTranslation(t,s)),this}makeTranslation(t,s){return t instanceof B?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,s,0,0,1),this}makeRotation(t){const s=Math.cos(t),e=Math.sin(t);return this.set(s,-e,0,e,s,0,0,0,1),this}makeScale(t,s){return this.set(t,0,0,0,s,0,0,0,1),this}equals(t){const s=this.elements,e=t.elements;for(let n=0;n<9;n++)if(s[n]!==e[n])return!1;return!0}fromArray(t,s=0){for(let e=0;e<9;e++)this.elements[e]=t[e+s];return this}toArray(t=[],s=0){const e=this.elements;return t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3],t[s+4]=e[4],t[s+5]=e[5],t[s+6]=e[6],t[s+7]=e[7],t[s+8]=e[8],t}clone(){return new yt().fromArray(this.elements)}};yt.IDENTITY=Object.freeze(new yt);let J=yt;const jt=new J,W=1e-6,I=2*Math.PI,Ts={x:0,y:0},qt={x:0,y:0,z:0};class it{constructor(){this.equalPointTol=W,this.equalVectorTol=W}clone(){const t=new it;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t}equalPoint2d(t,s){return new B(t).sub(s).length()<this.equalPointTol}equalPoint3d(t,s){return new _(t).sub(s).length()<this.equalPointTol}static equalToZero(t,s=W){return t<s&&t>-s}static equal(t,s,e=W){return Math.abs(t-s)<e}static great(t,s,e=W){return t-s>e}static less(t,s,e=W){return t-s<e}}const Vt=new it;class rt{constructor(t=0,s=0,e=0,n=1){this._x=t,this._y=s,this._z=e,this._w=n}static slerpFlat(t,s,e,n,i,r,o){let a=e[n+0],h=e[n+1],c=e[n+2],l=e[n+3];const m=i[r+0],d=i[r+1],g=i[r+2],y=i[r+3];if(o===0){t[s+0]=a,t[s+1]=h,t[s+2]=c,t[s+3]=l;return}if(o===1){t[s+0]=m,t[s+1]=d,t[s+2]=g,t[s+3]=y;return}if(l!==y||a!==m||h!==d||c!==g){let x=1-o;const f=a*m+h*d+c*g+l*y,b=f>=0?1:-1,p=1-f*f;if(p>Number.EPSILON){const S=Math.sqrt(p),k=Math.atan2(S,f*b);x=Math.sin(x*k)/S,o=Math.sin(o*k)/S}const C=o*b;if(a=a*x+m*C,h=h*x+d*C,c=c*x+g*C,l=l*x+y*C,x===1-o){const S=1/Math.sqrt(a*a+h*h+c*c+l*l);a*=S,h*=S,c*=S,l*=S}}t[s]=a,t[s+1]=h,t[s+2]=c,t[s+3]=l}static multiplyQuaternionsFlat(t,s,e,n,i,r){const o=e[n],a=e[n+1],h=e[n+2],c=e[n+3],l=i[r],m=i[r+1],d=i[r+2],g=i[r+3];return t[s]=o*g+c*l+a*d-h*m,t[s+1]=a*g+c*m+h*l-o*d,t[s+2]=h*g+c*d+o*m-a*l,t[s+3]=c*g-o*l-a*m-h*d,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,s,e,n){return this._x=t,this._y=s,this._z=e,this._w=n,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,s=!0){const e=t.x,n=t.y,i=t.z,r=t.order,o=Math.cos,a=Math.sin,h=o(e/2),c=o(n/2),l=o(i/2),m=a(e/2),d=a(n/2),g=a(i/2);switch(r){case"XYZ":this._x=m*c*l+h*d*g,this._y=h*d*l-m*c*g,this._z=h*c*g+m*d*l,this._w=h*c*l-m*d*g;break;case"YXZ":this._x=m*c*l+h*d*g,this._y=h*d*l-m*c*g,this._z=h*c*g-m*d*l,this._w=h*c*l+m*d*g;break;case"ZXY":this._x=m*c*l-h*d*g,this._y=h*d*l+m*c*g,this._z=h*c*g+m*d*l,this._w=h*c*l-m*d*g;break;case"ZYX":this._x=m*c*l-h*d*g,this._y=h*d*l+m*c*g,this._z=h*c*g-m*d*l,this._w=h*c*l+m*d*g;break;case"YZX":this._x=m*c*l+h*d*g,this._y=h*d*l+m*c*g,this._z=h*c*g-m*d*l,this._w=h*c*l-m*d*g;break;case"XZY":this._x=m*c*l-h*d*g,this._y=h*d*l-m*c*g,this._z=h*c*g+m*d*l,this._w=h*c*l+m*d*g;break}return s===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,s){const e=s/2,n=Math.sin(e);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(t){const s=t.elements,e=s[0],n=s[4],i=s[8],r=s[1],o=s[5],a=s[9],h=s[2],c=s[6],l=s[10],m=e+o+l;if(m>0){const d=.5/Math.sqrt(m+1);this._w=.25/d,this._x=(c-a)*d,this._y=(i-h)*d,this._z=(r-n)*d}else if(e>o&&e>l){const d=2*Math.sqrt(1+e-o-l);this._w=(c-a)/d,this._x=.25*d,this._y=(n+r)/d,this._z=(i+h)/d}else if(o>l){const d=2*Math.sqrt(1+o-e-l);this._w=(i-h)/d,this._x=(n+r)/d,this._y=.25*d,this._z=(a+c)/d}else{const d=2*Math.sqrt(1+l-e-o);this._w=(r-n)/d,this._x=(i+h)/d,this._y=(a+c)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(t,s){let e=t.dot(s)+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*s.z-t.z*s.y,this._y=t.z*s.x-t.x*s.z,this._z=t.x*s.y-t.y*s.x,this._w=e),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Y(this.dot(t),-1,1)))}rotateTowards(t,s){const e=this.angleTo(t);if(e===0)return this;const n=Math.min(1,s/e);return this.slerp(t,n),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,s){const e=t._x,n=t._y,i=t._z,r=t._w,o=s._x,a=s._y,h=s._z,c=s._w;return this._x=e*c+r*o+n*h-i*a,this._y=n*c+r*a+i*o-e*h,this._z=i*c+r*h+e*a-n*o,this._w=r*c-e*o-n*a-i*h,this._onChangeCallback(),this}slerp(t,s){if(s===0)return this;if(s===1)return this.copy(t);const e=this._x,n=this._y,i=this._z,r=this._w;let o=r*t._w+e*t._x+n*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=r,this._x=e,this._y=n,this._z=i,this;const a=1-o*o;if(a<=Number.EPSILON){const d=1-s;return this._w=d*r+s*this._w,this._x=d*e+s*this._x,this._y=d*n+s*this._y,this._z=d*i+s*this._z,this.normalize(),this}const h=Math.sqrt(a),c=Math.atan2(h,o),l=Math.sin((1-s)*c)/h,m=Math.sin(s*c)/h;return this._w=r*l+this._w*m,this._x=e*l+this._x*m,this._y=n*l+this._y*m,this._z=i*l+this._z*m,this._onChangeCallback(),this}slerpQuaternions(t,s,e){return this.copy(t).slerp(s,e)}random(){const t=2*Math.PI*Math.random(),s=2*Math.PI*Math.random(),e=Math.random(),n=Math.sqrt(1-e),i=Math.sqrt(e);return this.set(n*Math.sin(t),n*Math.cos(t),i*Math.sin(s),i*Math.cos(s))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,s=0){return this._x=t[s],this._y=t[s+1],this._z=t[s+2],this._w=t[s+3],this._onChangeCallback(),this}toArray(t=[],s=0){return t[s]=this._x,t[s+1]=this._y,t[s+2]=this._z,t[s+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 T=class T{constructor(t,s,e){this.x=0,this.y=0,this.z=0;const n=+(t!==void 0)+ +(s!==void 0)+ +(e!==void 0);if(n!==0){if(n===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(n===1){const{x:i,y:r,z:o}=t;this.x=i,this.y=r,this.z=o||0;return}if(n===3){this.x=t,this.y=s,this.z=e;return}throw N.AcCmErrors.ILLEGAL_PARAMETERS}}set(t,s,e){return e===void 0&&(e=this.z),this.x=t,this.y=s,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,s){switch(t){case 0:this.x=s;break;case 1:this.y=s;break;case 2:this.z=s;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 T(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,s){return this.x=t.x+s.x,this.y=t.y+s.y,this.z=t.z+s.z,this}addScaledVector(t,s){return this.x+=t.x*s,this.y+=t.y*s,this.z+=t.z*s,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,s){return this.x=t.x-s.x,this.y=t.y-s.y,this.z=t.z-s.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,s){return this.x=t.x*s.x,this.y=t.y*s.y,this.z=t.z*s.z,this}applyEuler(t){return this.applyQuaternion(xs.setFromEuler(t))}applyAxisAngle(t,s){return this.applyQuaternion(xs.setFromAxisAngle(t,s))}applyMatrix3(t){const s=this.x,e=this.y,n=this.z,i=t.elements;return this.x=i[0]*s+i[3]*e+i[6]*n,this.y=i[1]*s+i[4]*e+i[7]*n,this.z=i[2]*s+i[5]*e+i[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const s=this.x,e=this.y,n=this.z,i=t.elements,r=1/(i[3]*s+i[7]*e+i[11]*n+i[15]);return this.x=(i[0]*s+i[4]*e+i[8]*n+i[12])*r,this.y=(i[1]*s+i[5]*e+i[9]*n+i[13])*r,this.z=(i[2]*s+i[6]*e+i[10]*n+i[14])*r,this}applyQuaternion(t){const s=this.x,e=this.y,n=this.z,i=t.x,r=t.y,o=t.z,a=t.w,h=2*(r*n-o*e),c=2*(o*s-i*n),l=2*(i*e-r*s);return this.x=s+a*h+r*l-o*c,this.y=e+a*c+o*h-i*l,this.z=n+a*l+i*c-r*h,this}transformDirection(t){const s=this.x,e=this.y,n=this.z,i=t.elements;return this.x=i[0]*s+i[4]*e+i[8]*n,this.y=i[1]*s+i[5]*e+i[9]*n,this.z=i[2]*s+i[6]*e+i[10]*n,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,s){return this.x=Math.max(t.x,Math.min(s.x,this.x)),this.y=Math.max(t.y,Math.min(s.y,this.y)),this.z=Math.max(t.z,Math.min(s.z,this.z)),this}clampScalar(t,s){return this.x=Math.max(t,Math.min(s,this.x)),this.y=Math.max(t,Math.min(s,this.y)),this.z=Math.max(t,Math.min(s,this.z)),this}clampLength(t,s){const e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(s,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 s=this.dot(t),e=this.length(),n=t.length();return Math.abs(s)===e*n}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,s){return this.x+=(t.x-this.x)*s,this.y+=(t.y-this.y)*s,this.z+=(t.z-this.z)*s,this}lerpVectors(t,s,e){return this.x=t.x+(s.x-t.x)*e,this.y=t.y+(s.y-t.y)*e,this.z=t.z+(s.z-t.z)*e,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,s){const e=t.x,n=t.y,i=t.z,r=s.x,o=s.y,a=s.z;return this.x=n*a-i*o,this.y=i*r-e*a,this.z=e*o-n*r,this}projectOnVector(t){const s=t.lengthSq();if(s===0)return this.set(0,0,0);const e=t.dot(this)/s;return this.copy(t).multiplyScalar(e)}projectOnPlane(t){return Lt.copy(this).projectOnVector(t),this.sub(Lt)}reflect(t){return this.sub(Lt.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const s=Math.sqrt(this.lengthSq()*t.lengthSq());if(s===0)return Math.PI/2;const e=this.dot(t)/s;return Math.acos(Math.max(-1,Math.min(1,e)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const s=this.x-t.x,e=this.y-t.y,n=this.z-t.z;return s*s+e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromMatrixPosition(t){const s=t.elements;return this.x=s[12],this.y=s[13],this.z=s[14],this}setFromMatrixScale(t){const s=this.setFromMatrixColumn(t,0).length(),e=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=s,this.y=e,this.z=n,this}setFromMatrixColumn(t,s){return this.fromArray(t.elements,s*4)}setFromMatrix3Column(t,s){return this.fromArray(t.elements,s*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,s=0){return this.x=t[s],this.y=t[s+1],this.z=t[s+2],this}toArray(t=[],s=0){return t[s]=this.x,t[s+1]=this.y,t[s+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,s=Math.random()*2-1,e=Math.sqrt(1-s*s);return this.x=e*Math.cos(t),this.y=s,this.z=e*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};T.ORIGIN=Object.freeze(new T(0,0,0)),T.X_AXIS=Object.freeze(new T(1,0,0)),T.NEGATIVE_X_AXIS=Object.freeze(new T(-1,0,0)),T.Y_AXIS=Object.freeze(new T(0,1,0)),T.NEGATIVE_Y_AXIS=Object.freeze(new T(0,-1,0)),T.Z_AXIS=Object.freeze(new T(0,0,1)),T.NEGATIVE_Z_AXIS=Object.freeze(new T(0,0,-1));let _=T;const Lt=new _,xs=new rt,xt=class xt{constructor(t,s,e,n,i,r,o,a,h,c,l,m,d,g,y,x){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&s!=null&&e!=null&&n!=null&&i!=null&&r!=null&&o!=null&&a!=null&&h!=null&&c!=null&&l!=null&&m!=null&&d!=null&&g!=null&&y!=null&&x!=null&&this.set(t,s,e,n,i,r,o,a,h,c,l,m,d,g,y,x)}set(t,s,e,n,i,r,o,a,h,c,l,m,d,g,y,x){const f=this.elements;return f[0]=t,f[4]=s,f[8]=e,f[12]=n,f[1]=i,f[5]=r,f[9]=o,f[13]=a,f[2]=h,f[6]=c,f[10]=l,f[14]=m,f[3]=d,f[7]=g,f[11]=y,f[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new xt().fromArray(this.elements)}copy(t){const s=this.elements,e=t.elements;return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s[6]=e[6],s[7]=e[7],s[8]=e[8],s[9]=e[9],s[10]=e[10],s[11]=e[11],s[12]=e[12],s[13]=e[13],s[14]=e[14],s[15]=e[15],this}copyPosition(t){const s=this.elements,e=t.elements;return s[12]=e[12],s[13]=e[13],s[14]=e[14],this}setFromMatrix3(t){const s=t.elements;return this.set(s[0],s[3],s[6],0,s[1],s[4],s[7],0,s[2],s[5],s[8],0,0,0,0,1),this}setFromExtrusionDirection(t){if(Vt.equalPoint3d(t,_.Z_AXIS))this.identity();else{const s=new _(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?s.crossVectors(_.Y_AXIS,t).normalize():s.crossVectors(_.Z_AXIS,t).normalize();const e=t.clone().cross(s).normalize();this.set(s.x,s.y,s.z,0,e.x,e.y,e.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,s,e){return t.setFromMatrixColumn(this,0),s.setFromMatrixColumn(this,1),e.setFromMatrixColumn(this,2),this}makeBasis(t,s,e){return this.set(t.x,s.x,e.x,0,t.y,s.y,e.y,0,t.z,s.z,e.z,0,0,0,0,1),this}extractRotation(t){const s=this.elements,e=t.elements,n=1/tt.setFromMatrixColumn(t,0).length(),i=1/tt.setFromMatrixColumn(t,1).length(),r=1/tt.setFromMatrixColumn(t,2).length();return s[0]=e[0]*n,s[1]=e[1]*n,s[2]=e[2]*n,s[3]=0,s[4]=e[4]*i,s[5]=e[5]*i,s[6]=e[6]*i,s[7]=0,s[8]=e[8]*r,s[9]=e[9]*r,s[10]=e[10]*r,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Ns,t,js)}lookAt(t,s,e){const n=this.elements;return L.subVectors(t,s),L.lengthSq()===0&&(L.z=1),L.normalize(),G.crossVectors(e,L),G.lengthSq()===0&&(Math.abs(e.z)===1?L.x+=1e-4:L.z+=1e-4,L.normalize(),G.crossVectors(e,L)),G.normalize(),At.crossVectors(L,G),n[0]=G.x,n[4]=At.x,n[8]=L.x,n[1]=G.y,n[5]=At.y,n[9]=L.y,n[2]=G.z,n[6]=At.z,n[10]=L.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,s){const e=t.elements,n=s.elements,i=this.elements,r=e[0],o=e[4],a=e[8],h=e[12],c=e[1],l=e[5],m=e[9],d=e[13],g=e[2],y=e[6],x=e[10],f=e[14],b=e[3],p=e[7],C=e[11],S=e[15],k=n[0],w=n[4],R=n[8],E=n[12],V=n[1],D=n[5],et=n[9],wt=n[13],zt=n[2],Pt=n[6],Mt=n[10],bt=n[14],St=n[3],Ct=n[7],Et=n[11],It=n[15];return i[0]=r*k+o*V+a*zt+h*St,i[4]=r*w+o*D+a*Pt+h*Ct,i[8]=r*R+o*et+a*Mt+h*Et,i[12]=r*E+o*wt+a*bt+h*It,i[1]=c*k+l*V+m*zt+d*St,i[5]=c*w+l*D+m*Pt+d*Ct,i[9]=c*R+l*et+m*Mt+d*Et,i[13]=c*E+l*wt+m*bt+d*It,i[2]=g*k+y*V+x*zt+f*St,i[6]=g*w+y*D+x*Pt+f*Ct,i[10]=g*R+y*et+x*Mt+f*Et,i[14]=g*E+y*wt+x*bt+f*It,i[3]=b*k+p*V+C*zt+S*St,i[7]=b*w+p*D+C*Pt+S*Ct,i[11]=b*R+p*et+C*Mt+S*Et,i[15]=b*E+p*wt+C*bt+S*It,this}multiplyScalar(t){const s=this.elements;return s[0]*=t,s[4]*=t,s[8]*=t,s[12]*=t,s[1]*=t,s[5]*=t,s[9]*=t,s[13]*=t,s[2]*=t,s[6]*=t,s[10]*=t,s[14]*=t,s[3]*=t,s[7]*=t,s[11]*=t,s[15]*=t,this}determinant(){const t=this.elements,s=t[0],e=t[4],n=t[8],i=t[12],r=t[1],o=t[5],a=t[9],h=t[13],c=t[2],l=t[6],m=t[10],d=t[14],g=t[3],y=t[7],x=t[11],f=t[15];return g*(+i*a*l-n*h*l-i*o*m+e*h*m+n*o*d-e*a*d)+y*(+s*a*d-s*h*m+i*r*m-n*r*d+n*h*c-i*a*c)+x*(+s*h*l-s*o*d-i*r*l+e*r*d+i*o*c-e*h*c)+f*(-n*o*c-s*a*l+s*o*m+n*r*l-e*r*m+e*a*c)}transpose(){const t=this.elements;let s;return s=t[1],t[1]=t[4],t[4]=s,s=t[2],t[2]=t[8],t[8]=s,s=t[6],t[6]=t[9],t[9]=s,s=t[3],t[3]=t[12],t[12]=s,s=t[7],t[7]=t[13],t[13]=s,s=t[11],t[11]=t[14],t[14]=s,this}setPosition(t,s,e){const n=this.elements;return t instanceof _?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=s,n[14]=e),this}invert(){const t=this.elements,s=t[0],e=t[1],n=t[2],i=t[3],r=t[4],o=t[5],a=t[6],h=t[7],c=t[8],l=t[9],m=t[10],d=t[11],g=t[12],y=t[13],x=t[14],f=t[15],b=l*x*h-y*m*h+y*a*d-o*x*d-l*a*f+o*m*f,p=g*m*h-c*x*h-g*a*d+r*x*d+c*a*f-r*m*f,C=c*y*h-g*l*h+g*o*d-r*y*d-c*o*f+r*l*f,S=g*l*a-c*y*a-g*o*m+r*y*m+c*o*x-r*l*x,k=s*b+e*p+n*C+i*S;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/k;return t[0]=b*w,t[1]=(y*m*i-l*x*i-y*n*d+e*x*d+l*n*f-e*m*f)*w,t[2]=(o*x*i-y*a*i+y*n*h-e*x*h-o*n*f+e*a*f)*w,t[3]=(l*a*i-o*m*i-l*n*h+e*m*h+o*n*d-e*a*d)*w,t[4]=p*w,t[5]=(c*x*i-g*m*i+g*n*d-s*x*d-c*n*f+s*m*f)*w,t[6]=(g*a*i-r*x*i-g*n*h+s*x*h+r*n*f-s*a*f)*w,t[7]=(r*m*i-c*a*i+c*n*h-s*m*h-r*n*d+s*a*d)*w,t[8]=C*w,t[9]=(g*l*i-c*y*i-g*e*d+s*y*d+c*e*f-s*l*f)*w,t[10]=(r*y*i-g*o*i+g*e*h-s*y*h-r*e*f+s*o*f)*w,t[11]=(c*o*i-r*l*i-c*e*h+s*l*h+r*e*d-s*o*d)*w,t[12]=S*w,t[13]=(c*y*n-g*l*n+g*e*m-s*y*m-c*e*x+s*l*x)*w,t[14]=(g*o*n-r*y*n-g*e*a+s*y*a+r*e*x-s*o*x)*w,t[15]=(r*l*n-c*o*n+c*e*a-s*l*a-r*e*m+s*o*m)*w,this}scale(t){const s=this.elements,e=t.x,n=t.y,i=t.z;return s[0]*=e,s[4]*=n,s[8]*=i,s[1]*=e,s[5]*=n,s[9]*=i,s[2]*=e,s[6]*=n,s[10]*=i,s[3]*=e,s[7]*=n,s[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,s=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],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(s,e,n))}makeTranslation(t,s,e){return t instanceof _?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,s,0,0,1,e,0,0,0,1),this}makeRotationX(t){const s=Math.cos(t),e=Math.sin(t);return this.set(1,0,0,0,0,s,-e,0,0,e,s,0,0,0,0,1),this}makeRotationY(t){const s=Math.cos(t),e=Math.sin(t);return this.set(s,0,e,0,0,1,0,0,-e,0,s,0,0,0,0,1),this}makeRotationZ(t){const s=Math.cos(t),e=Math.sin(t);return this.set(s,-e,0,0,e,s,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,s){const e=Math.cos(s),n=Math.sin(s),i=1-e,r=t.x,o=t.y,a=t.z,h=i*r,c=i*o;return this.set(h*r+e,h*o-n*a,h*a+n*o,0,h*o+n*a,c*o+e,c*a-n*r,0,h*a-n*o,c*a+n*r,i*a*a+e,0,0,0,0,1),this}makeScale(t,s,e){return this.set(t,0,0,0,0,s,0,0,0,0,e,0,0,0,0,1),this}makeShear(t,s,e,n,i,r){return this.set(1,e,i,0,t,1,r,0,s,n,1,0,0,0,0,1),this}compose(t,s,e){const n=this.elements,i=s.x,r=s.y,o=s.z,a=s.w,h=i+i,c=r+r,l=o+o,m=i*h,d=i*c,g=i*l,y=r*c,x=r*l,f=o*l,b=a*h,p=a*c,C=a*l,S=e.x,k=e.y,w=e.z;return n[0]=(1-(y+f))*S,n[1]=(d+C)*S,n[2]=(g-p)*S,n[3]=0,n[4]=(d-C)*k,n[5]=(1-(m+f))*k,n[6]=(x+b)*k,n[7]=0,n[8]=(g+p)*w,n[9]=(x-b)*w,n[10]=(1-(m+y))*w,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,s,e){const n=this.elements;let i=tt.set(n[0],n[1],n[2]).length();const r=tt.set(n[4],n[5],n[6]).length(),o=tt.set(n[8],n[9],n[10]).length();this.determinant()<0&&(i=-i),t.x=n[12],t.y=n[13],t.z=n[14],v.copy(this);const h=1/i,c=1/r,l=1/o;return v.elements[0]*=h,v.elements[1]*=h,v.elements[2]*=h,v.elements[4]*=c,v.elements[5]*=c,v.elements[6]*=c,v.elements[8]*=l,v.elements[9]*=l,v.elements[10]*=l,s.setFromRotationMatrix(v),e.x=i,e.y=r,e.z=o,this}equals(t){const s=this.elements,e=t.elements;for(let n=0;n<16;n++)if(s[n]!==e[n])return!1;return!0}fromArray(t,s=0){for(let e=0;e<16;e++)this.elements[e]=t[e+s];return this}toArray(t=[],s=0){const e=this.elements;return t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3],t[s+4]=e[4],t[s+5]=e[5],t[s+6]=e[6],t[s+7]=e[7],t[s+8]=e[8],t[s+9]=e[9],t[s+10]=e[10],t[s+11]=e[11],t[s+12]=e[12],t[s+13]=e[13],t[s+14]=e[14],t[s+15]=e[15],t}};xt.IDENTITY=Object.freeze(new xt);let Z=xt;const tt=new _,v=new Z,Ns=new _(0,0,0),js=new _(1,1,1),G=new _,At=new _,L=new _;class X{constructor(t=void 0,s=void 0){this.min=t==null?new _(1/0,1/0,1/0):new _(t.x,t.y,t.z),this.max=s==null?new _(-1/0,-1/0,-1/0):new _(s.x,s.y,s.z)}set(t,s){return this.min.copy(t),this.max.copy(s),this}setFromArray(t){this.makeEmpty();for(let s=0,e=t.length;s<e;s+=3)this.expandByPoint(Ut.fromArray(t,s));return this}setFromPoints(t){this.makeEmpty();for(let s=0,e=t.length;s<e;s++)this.expandByPoint(t[s]);return this}setFromCenterAndSize(t,s){const e=Ut.copy(s).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new X().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 _(0,0,0):new _(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new _(0,0,0):new _(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,s){return s.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 s,e;return t.normal.x>0?(s=t.normal.x*this.min.x,e=t.normal.x*this.max.x):(s=t.normal.x*this.max.x,e=t.normal.x*this.min.x),t.normal.y>0?(s+=t.normal.y*this.min.y,e+=t.normal.y*this.max.y):(s+=t.normal.y*this.max.y,e+=t.normal.y*this.min.y),t.normal.z>0?(s+=t.normal.z*this.min.z,e+=t.normal.z*this.max.z):(s+=t.normal.z*this.max.z,e+=t.normal.z*this.min.z),s<=-t.constant&&e>=-t.constant}clampPoint(t,s){return s.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ut).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:(O[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),O[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),O[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),O[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),O[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),O[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),O[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),O[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(O),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 O=[new _,new _,new _,new _,new _,new _,new _,new _],Ut=new _,_s=new B;class U{constructor(t=void 0,s=void 0){this.min=t==null?new B(1/0,1/0):new B(t.x,t.y),this.max=s==null?new B(-1/0,-1/0):new B(s.x,s.y)}set(t,s){return this.min.copy(t),this.max.copy(s),this}setFromPoints(t){this.makeEmpty();for(let s=0,e=t.length;s<e;s++)this.expandByPoint(t[s]);return this}setFromCenterAndSize(t,s){const e=_s.copy(s).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new U().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 B(0,0):new B(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new B(0,0):new B(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,s){return s.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,s){return s.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,_s).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 As=new _,qs=new _,Vs=new J;class ot{constructor(t=new _(1,0,0),s=0){this.normal=t,this.constant=s}set(t,s){return this.normal.copy(t),this.constant=s,this}setComponents(t,s,e,n){return this.normal.set(t,s,e),this.constant=n,this}setFromNormalAndCoplanarPoint(t,s){return this.normal.copy(t),this.constant=-s.dot(this.normal),this}setFromCoplanarPoints(t,s,e){const n=As.subVectors(e,s).cross(qs.subVectors(t,s)).normalize();return this.setFromNormalAndCoplanarPoint(n,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,s){return s.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,s){const e=s||Vs.getNormalMatrix(t),n=this.coplanarPoint(As).applyMatrix4(t),i=this.normal.applyMatrix3(e).normalize();return this.constant=-n.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new ot().copy(this)}}class M extends B{clone(){return new M(this.x,this.y)}static pointArrayToNumberArray(t){const s=new Array(t.length*2);return t.forEach((e,n)=>{e.toArray(s,n*2)}),s}}class z extends _{clone(){return new z(this.x,this.y,this.z)}static pointArrayToNumberArray(t,s=!0){const e=s?3:2,n=new Array(t.length*e);return t.forEach((i,r)=>{i.toArray(n,r*e)}),n}}const fs=new Z,ps=new rt,_t=class _t{constructor(t=0,s=0,e=0,n=_t.DEFAULT_ORDER){this._x=t,this._y=s,this._z=e,this._order=n}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,s,e,n=this._order){return this._x=t,this._y=s,this._z=e,this._order=n,this._onChangeCallback(),this}clone(){return new _t(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,s=this._order,e=!0){const n=t.elements,i=n[0],r=n[4],o=n[8],a=n[1],h=n[5],c=n[9],l=n[2],m=n[6],d=n[10];switch(s){case"XYZ":this._y=Math.asin(Y(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-r,i)):(this._x=Math.atan2(m,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Y(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(a,h)):(this._y=Math.atan2(-l,i),this._z=0);break;case"ZXY":this._x=Math.asin(Y(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-l,d),this._z=Math.atan2(-r,h)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-Y(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(m,d),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-r,h));break;case"YZX":this._z=Math.asin(Y(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,h),this._y=Math.atan2(-l,i)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-Y(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(m,h),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-c,d),this._y=0);break}return this._order=s,e===!0&&this._onChangeCallback(),this}setFromQuaternion(t,s,e=!0){return fs.makeRotationFromQuaternion(t),this.setFromRotationMatrix(fs,s,e)}setFromVector3(t,s=this._order){return this.set(t.x,t.y,t.z,s)}reorder(t){return ps.setFromEuler(this),this.setFromQuaternion(ps,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=[],s=0){return t[s]=this._x,t[s+1]=this._y,t[s+2]=this._z,t[s+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}};_t.DEFAULT_ORDER="XYZ";let Ft=_t;function Dt(u,t,s=!1){const e=u.x,n=u.y;let i=!1;const r=t.length;for(let o=0,a=r-1;o<r;a=o++){const h=t[o].x,c=t[o].y,l=t[a].x,m=t[a].y;let d=c>n!=m>n;s&&(d=c>=n!=m>=n),d&&e<(l-h)*(n-c)/(m-c)+h&&(i=!i)}return i}function ws(u,t){if(u.length===0||t.length===0)return!1;const s=new U().setFromPoints(u),e=new U().setFromPoints(t);if(!s.intersectsBox(e))return!1;for(let n=0;n<u.length;){if(Dt(u[n],t,!0))return!0;n<u.length-1&&Vt.equalPoint2d(u[n+1],u[n])&&++n,++n}return!1}const zs={isPointInPolygon:Dt,isPolygonIntersect:ws};function Ls(u,t){const s=[],e=t-1,n=u;for(let i=0;i<=n;i++)s.push(0);for(let i=1;i<=e-n;i++)s.push(i);for(let i=0;i<=n;i++)s.push(e-n+1);return s}function Us(u,t){const s=t.length-1,e=u,n=[0];let i=0;for(let o=1;o<=s;o++){const a=t[o][0]-t[o-1][0],h=t[o][1]-t[o-1][1],c=t[o][2]-t[o-1][2],l=Math.sqrt(a*a+h*h+c*c);i+=l,n.push(i)}const r=[];for(let o=0;o<=e;o++)r.push(0);for(let o=1;o<=s-e;o++){const a=n[o]/i;r.push(a*(s-e+1))}for(let o=0;o<=e;o++)r.push(s-e+1);return r}function Ps(u,t="Uniform"){const s=u.length;if(s===0)return[];if(s===1)return[0];const e=s-1;if(t==="Uniform")return new Array(s).fill(0).map((r,o)=>o/e);const n=[0];let i=0;for(let r=1;r<=e;r++){const o=u[r][0]-u[r-1][0],a=u[r][1]-u[r-1][1],h=u[r][2]-u[r-1][2],c=Math.sqrt(o*o+a*a+h*h),l=t==="SqrtChord"?Math.sqrt(c):c;i+=l,n.push(i)}return i<1e-12?new Array(s).fill(0).map((r,o)=>o/e):n.map(r=>r/i)}function Ms(u,t){const s=t.length-1,e=u,n=s+e+1,i=new Array(n+1).fill(0),r=t[t.length-1];for(let o=n-e;o<=n;o++)i[o]=r;for(let o=1;o<=s-e;o++){let a=0;for(let h=o;h<o+e;h++)a+=t[h];i[o+e]=a/e}return i}function Fs(u,t){const s=t.length-1,e=u,n=[0];let i=0;for(let o=1;o<=s;o++){const a=t[o][0]-t[o-1][0],h=t[o][1]-t[o-1][1],c=t[o][2]-t[o-1][2],l=Math.sqrt(a*a+h*h+c*c),m=Math.sqrt(l);i+=m,n.push(i)}const r=[];for(let o=0;o<=e;o++)r.push(0);for(let o=1;o<=s-e;o++){const a=n[o]/i;r.push(a*(s-e+1))}for(let o=0;o<=e;o++)r.push(s-e+1);return r}function vt(u,t){const s=u.length,e=u.map(r=>r.slice()),n=t.slice();for(let r=0;r<s;r++){let o=r,a=Math.abs(e[r][r]);for(let h=r+1;h<s;h++){const c=Math.abs(e[h][r]);c>a&&(a=c,o=h)}if(a<1e-12)throw new Error("Interpolation matrix is singular.");if(o!==r){const h=e[r];e[r]=e[o],e[o]=h;const c=n[r];n[r]=n[o],n[o]=c}for(let h=r+1;h<s;h++){const c=e[h][r]/e[r][r];if(!(Math.abs(c)<1e-14)){for(let l=r;l<s;l++)e[h][l]-=c*e[r][l];n[h]-=c*n[r]}}}const i=new Array(s).fill(0);for(let r=s-1;r>=0;r--){let o=n[r];for(let a=r+1;a<s;a++)o-=e[r][a]*i[a];i[r]=o/e[r][r]}return i}function Xt(u,t,s="Uniform",e,n){if(u.length===0)return{controlPoints:[],knots:[],weights:[]};const i=u.map(E=>[E[0],E[1],E[2]??0]),r=!!e,o=!!n,a=(r?1:0)+(o?1:0),h=i.length-1,c=h+a;if(c<t)throw new Error("Not enough points to interpolate a curve of this degree.");const l=Ps(i,s),m=l.slice();r&&m.unshift(l[0]),o&&m.push(l[l.length-1]);const d=Ms(t,m),g=c+1,y=new Array(g),x=new Array(g),f=new Array(g),b=new Array(g);let p=0;y[p]=new Array(g).fill(0),y[p][0]=1,x[p]=i[0][0],f[p]=i[0][1],b[p]=i[0][2],p++;for(let E=1;E<=h-1;E++){const V=l[E];y[p]=new Array(g).fill(0);for(let D=0;D<=c;D++)y[p][D]=ht(D,t,V,d);x[p]=i[E][0],f[p]=i[E][1],b[p]=i[E][2],p++}if(y[p]=new Array(g).fill(0),y[p][c]=1,x[p]=i[h][0],f[p]=i[h][1],b[p]=i[h][2],p++,r){const E=d[t+1]-d[0],V=E!==0?t/E:0;y[p]=new Array(g).fill(0),y[p][0]=-V,y[p][1]=V,x[p]=(e==null?void 0:e[0])??0,f[p]=(e==null?void 0:e[1])??0,b[p]=(e==null?void 0:e[2])??0,p++}if(o){const E=d[c+t+1]-d[c],V=E!==0?t/E:0;y[p]=new Array(g).fill(0),y[p][c-1]=-V,y[p][c]=V,x[p]=(n==null?void 0:n[0])??0,f[p]=(n==null?void 0:n[1])??0,b[p]=(n==null?void 0:n[2])??0,p++}const C=vt(y,x),S=vt(y,f),k=vt(y,b),w=new Array(g);for(let E=0;E<g;E++)w[E]=[C[E],S[E],k[E]];const R=new Array(g).fill(1);return{controlPoints:w,knots:d,weights:R}}function ht(u,t,s,e){if(t===0)return s>=e[u]&&s<e[u+1]?1:0;const n=e[u+t]-e[u],i=e[u+t+1]-e[u+1],r=n>1e-10?(s-e[u])/n:0,o=i>1e-10?(e[u+t+1]-s)/i:0;return r*ht(u,t-1,s,e)+o*ht(u+1,t-1,s,e)}function at(u,t,s,e,n){const i=e.length-1,r=t;if(u=Math.max(s[r],Math.min(s[i+1],u)),Math.abs(u-s[i+1])<1e-8)return[...e[i]];if(Math.abs(u-s[r])<1e-8)return[...e[0]];const o=[0,0,0];let a=0;for(let h=0;h<=i;h++){const c=ht(h,r,u,s),l=n[h]*c;o[0]+=e[h][0]*l,o[1]+=e[h][1]*l,o[2]+=e[h][2]*l,a+=l}if(Math.abs(a)<1e-10){const h=s[s.length-r-1];if(Math.abs(u-h)<1e-8)return[...e[i]];if(Math.abs(u-s[r])<1e-8)return[...e[0]]}return Math.abs(a)>=1e-10&&(o[0]/=a,o[1]/=a,o[2]/=a),o}function bs(u,t,s,e){const n=u,i=t[n],r=t[t.length-n-1];let o=0;const a=1e3,h=(r-i)/a;let c=at(i,u,t,s,e);for(let y=1;y<=a;y++){const x=i+y*h,f=at(x,u,t,s,e),b=f[0]-c[0],p=f[1]-c[1],C=f[2]-c[2];o+=Math.sqrt(b*b+p*p+C*C),c=f}const l=at(r,u,t,s,e),m=l[0]-c[0],d=l[1]-c[1],g=l[2]-c[2];return o+=Math.sqrt(m*m+d*d+g*g),o}function Ds(u,t=3,s="Uniform",e,n){return u.length===0?[]:Xt(u,t,s,e,n).controlPoints}const Ss=new Z,Cs=new _,vs=new _,Xs=new _,Yt=new z;function Es(u){return new Z().setFromExtrusionDirection(new _(u.x,u.y,u.z))}function Ys(u){return Ss.setFromExtrusionDirection(new _(u.x,u.y,u.z)),Ss.extractBasis(Cs,vs,Xs),Cs.clone()}function Zs(u,t){return new z(u.x,u.y,u.z??0).applyMatrix4(Es(t))}function Zt(u,t){return new z(u.x,u.y,u.z??0).applyMatrix4(Es(t).invert())}function Os(u,t,s){const e=Zt(u,s),n=Zt(t,s);return Yt.set(n.x-e.x,n.y-e.y,(n.z??0)-(e.z??0)),P.normalizeAngle(Math.atan2(Yt.y,Yt.x))}class Is{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Ot extends Is{translate(t){return this.transform(new J().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class Gt extends Ot{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new U}transform(t){return this._loops.forEach(s=>{s.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){const t=new Gt;return this._loops.forEach(s=>{t.add(s.clone())}),t}getPoints(t){const s=[];for(let e=0;e<this.loops.length;++e){const i=this.loops[e].getPoints(t);s.push(i)}return s}buildHierarchy(){var o;const t=this.getPoints(100),s=this.calculateBoundaryBoxes(t),e=this.sortBoundaryBoxesByAreas(s),n=new Map,i=e.length;for(let a=0;a<i;a++)n.set(e[a],{index:e[a],children:[]});const r={index:-1,children:[]};for(let a=0;a<i;a++){const h=e[a],c=t[h],l=s[h];let m=a+1;for(;m<i;m++){const d=e[m],g=t[d];if(s[d].containsBox(l)&&zs.isPointInPolygon(c[P.randInt(0,c.length-1)],g)){(o=n.get(d))==null||o.children.push(n.get(h));break}}m===i&&r.children.push(n.get(h))}return r}get area(){if(this._loops.length===0)return 0;let t=0;for(let s=0;s<this._loops.length;s++){const n=this._loops[s].getPoints(128),i=this.polygonArea(n);s===0?t+=Math.abs(i):t-=Math.abs(i)}return t}polygonArea(t){const s=t.length;if(s<3)return 0;let e=0;for(let n=0,i=s-1;n<s;i=n++){const r=t[i],o=t[n];e+=r.x*o.y-o.x*r.y}return e*.5}calculateBoundaryBoxes(t){const s=[];return t.forEach(e=>{s.push(new U().setFromPoints(e))}),s}sortBoundaryBoxesByAreas(t){const s=[];t.forEach((n,i)=>{const r=n.size,o=r.width*r.height;s.push({area:o,index:i})}),s.sort((n,i)=>n.area-i.area);const e=[];return s.forEach(n=>{e.push(n.index)}),e}}class st extends Ot{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 s=this.getUtoTmapping(t);return this.getPoint(s)}getPoints(t=5){const s=[];for(let e=0;e<=t;e++)s.push(this.getPoint(e/t));return s}getSpacedPoints(t=5){const s=[];for(let e=0;e<=t;e++)s.push(this.getPointAt(e/t));return s}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const s=[];let e,n=this.getPoint(0),i=0;s.push(0);for(let r=1;r<=t;r++)e=this.getPoint(r/t),i+=e.distanceTo(n),s.push(i),n=e;return s}getUtoTmapping(t,s){const e=this.getLengths();let n=0;const i=e.length;let r;s?r=s:r=t*e[i-1];let o=0,a=i-1,h;for(;o<=a;)if(n=Math.floor(o+(a-o)/2),h=e[n]-r,h<0)o=n+1;else if(h>0)a=n-1;else{a=n;break}if(n=a,e[n]===r)return n/(i-1);const c=e[n],m=e[n+1]-c,d=(r-c)/m;return(n+d)/(i-1)}getTangent(t){let e=t-1e-4,n=t+1e-4;e<0&&(e=0),n>1&&(n=1);const i=this.getPoint(e),r=this.getPoint(n),o=new M;return o.copy(r).sub(i).normalize(),o}getTangentAt(t){const s=this.getUtoTmapping(t);return this.getTangent(s)}}class Q extends st{constructor(t,s,e,n,i){super();const r=+(t!==void 0)+ +(s!==void 0)+ +(e!==void 0)+ +(n!==void 0)+ +(i!==void 0);if(r==3)typeof t=="object"&&typeof s=="object"&&typeof e=="object"?this.createByThreePoints(t,s,e):this.createByStartEndPointsAndBulge(t,s,e);else if(r==5){const o=t;this.center=new M(o.x,o.y),this.radius=s,this._clockwise=i,this._startAngle=this._clockwise?this._mirrorAngle(P.normalizeAngle(e)):P.normalizeAngle(e),this._endAngle=this._clockwise?this._mirrorAngle(P.normalizeAngle(n)):P.normalizeAngle(n)}else throw N.AcCmErrors.ILLEGAL_PARAMETERS}createByThreePoints(t,s,e){const n=(w,R)=>({x:(w.x+R.x)/2,y:(w.y+R.y)/2}),i=(w,R)=>(R.y-w.y)/(R.x-w.x),r=w=>-1/w,o=n(t,s),a=n(s,e),h=i(t,s),c=i(s,e),l=r(h),m=r(c),d=(w,R,E,V)=>{const D=(V-R)/(w-E),et=w*D+R;return{x:D,y:et}},g=o.y-l*o.x,y=a.y-m*a.x,x=d(l,g,m,y),f=Math.sqrt(Math.pow(t.x-x.x,2)+Math.pow(t.y-x.y,2)),b=(w,R)=>Math.atan2(w.y-R.y,w.x-R.x),p=b(t,x),C=b(s,x),S=b(e,x),k=S>p&&S<C||p>S&&p<C||C>S&&C<p;this.center=x,this.radius=f,this._clockwise=!k,this._startAngle=p,this._endAngle=S}createByStartEndPointsAndBulge(t,s,e){let n,i,r;e<0?(n=Math.atan(-e)*4,i=new B(t),r=new B(s)):(n=Math.atan(e)*4,i=new B(s),r=new B(t));const o=new B().subVectors(r,i),a=o.length(),h=new B().addVectors(i,o.multiplyScalar(.5)),c=Math.abs(a/2/Math.tan(n/2)),l=o.normalize(),m=e<0?-Math.PI/2:Math.PI/2,d=new B(l.x*Math.cos(m)-l.y*Math.sin(m),l.y*Math.cos(m)+l.x*Math.sin(m));let g;n<Math.PI?e<0?g=h.add(d.multiplyScalar(c)):g=h.add(d.multiplyScalar(-c)):e<0?g=h.add(d.multiplyScalar(-c)):g=h.add(d.multiplyScalar(c)),e<0?(this._startAngle=Math.atan2(i.y-g.y,i.x-g.x),this._endAngle=Math.atan2(r.y-g.y,r.x-g.x)):(this._startAngle=Math.atan2(r.y-g.y,r.x-g.x),this._endAngle=Math.atan2(i.y-g.y,i.x-g.x)),this._clockwise=e<0,this.center=g,this.radius=r.sub(g).length()}get center(){return this._center}set center(t){this._center=new M(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(t){this._startAngle=this._clockwise?this._mirrorAngle(P.normalizeAngle(t)):P.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(t){const s=this.startAngle==0&&t==I?t:P.normalizeAngle(t);this._endAngle=this._clockwise?this._mirrorAngle(s):s,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),s=this._getInternalAngle(this.endAngle);return this.clockwise?P.normalizeAngle(t-s):P.normalizeAngle(s-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),s=this._clockwise?P.normalizeAngle(t-this.deltaAngle/2):P.normalizeAngle(t+this.deltaAngle/2),e=this._clockwise?this._mirrorAngle(s):s;return this.getPointAtAngle(e)}get closed(){const t=this._getInternalAngle(this.startAngle),s=this._getInternalAngle(this.endAngle);return Math.abs(s-t)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],s=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const i of s){const r=this._getInternalAngle(i);P.isBetweenAngle(r,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(i))}const e=t.map(i=>i.x),n=t.map(i=>i.y);return new U(new M(Math.min(...e),Math.min(...n)),new M(Math.max(...e),Math.max(...n)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){const s=t,e=this.center.clone().applyMatrix2d(s),n=this.startPoint.clone().applyMatrix2d(s);if(this.closed)return this.center=e,this.radius=e.distanceTo(n),this._startAngle=Math.atan2(n.y-e.y,n.x-e.x),this._endAngle=this._startAngle,this._clockwise=s.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;const i=this.midPoint.clone().applyMatrix2d(s),r=this.endPoint.clone().applyMatrix2d(s),o=new Q(n,i,r),a=s.determinant()<0?!this.clockwise:this.clockwise,h=c=>{const l=P.normalizeAngle(c);return a?this._mirrorAngle(l):l};return this.center=o.center,this.radius=o.radius,this.clockwise=a,this.startAngle=h(Math.atan2(n.y-o.center.y,n.x-o.center.x)),this.endAngle=h(Math.atan2(r.y-o.center.y,r.x-o.center.x)),this._boundingBoxNeedsUpdate=!0,this}clone(){return new Q(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const s=this._getInternalAngle(t),e=this.center.x+this.radius*Math.cos(s),n=this.center.y+this.radius*Math.sin(s);return new M(e,n)}getQuadrantPoints(){const t=[],s=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle),n=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const i of n){const r=this._getInternalAngle(i);P.isBetweenAngle(r,s,e,this.clockwise)&&t.push(this.getPointAtAngle(i))}return t}nearestPoint(t){const s=new M(t.x,t.y),e=s.x-this.center.x,n=s.y-this.center.y;if(Math.hypot(e,n)<1e-12)return this.startPoint.clone();const r=Math.atan2(n,e),o=this.clockwise?this._mirrorAngle(P.normalizeAngle(r)):P.normalizeAngle(r),a=this._getInternalAngle(o),h=this._getInternalAngle(this.startAngle),c=this._getInternalAngle(this.endAngle);if(P.isBetweenAngle(a,h,c,this.clockwise))return this.getPointAtAngle(o);const l=s.distanceToSquared(this.startPoint),m=s.distanceToSquared(this.endPoint);return l<=m?this.startPoint.clone():this.endPoint.clone()}getPoints(t=100){const s=[];let e=this.deltaAngle,n=this._getInternalAngle(this.startAngle);if(this.closed&&(e=I,n=0),this.clockwise)for(let i=0;i<=t;i++){const r=n-e*(i/t),o=this._clockwise?this._mirrorAngle(r):r,a=this.getPointAtAngle(o);s.push(new M(a.x,a.y))}else for(let i=0;i<=t;i++){const r=n+e*(i/t),o=this._clockwise?this._mirrorAngle(r):r,a=this.getPointAtAngle(o);s.push(new M(a.x,a.y))}return s}}class Gs extends Is{translate(t){return this.transform(new Z().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 ct extends Gs{}class lt extends ct{constructor(t,s){super(),this._start=new z(t),this._end=new z(s)}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 _().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,s){return this.delta(s).multiplyScalar(t).add(this._start)}atLength(t,s=!1){if(s){const e=this.delta($).normalize();return new z(this._start).addScaledVector(e,t)}else{const e=this.delta($).normalize();return new z(this._end).addScaledVector(e,t)}}extend(t,s=!1){if(s){const e=$.subVectors(this._start,this._end).normalize();this._start=new z(this._start).addScaledVector(e,t)}else{const e=this.delta($).normalize();this._end=new z(this._end).addScaledVector(e,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,s){Bs.subVectors(t,this._start),ft.subVectors(this.endPoint,this.startPoint);const e=ft.dot(ft);let i=ft.dot(Bs)/e;return s&&(i=P.clamp(i,0,1)),i}closestPointToPoint(t,s,e){const n=this.closestPointToPointParameter(t,s);return this.delta(e).multiplyScalar(n).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 s=this.direction,n=$.subVectors(t,this.startPoint).dot(s);return new z().copy(s).multiplyScalar(n).add(this.startPoint)}perpPoint(t){const s=this.direction,e=this.startPoint,i=$.subVectors(t,e).dot(s),r=$.copy(s).multiplyScalar(i);return new z().addVectors(e,r)}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)),s=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 X(t,s)}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 lt(this._start.clone(),this._end.clone())}}const $=new _,Bs=new _,ft=new _;class ut extends ct{static computeCenterPoint(t,s,e){const n=new _().addVectors(t,s).multiplyScalar(.5),i=new _().addVectors(t,e).multiplyScalar(.5),r=new _().subVectors(s,t),o=new _().subVectors(e,t),a=new _().crossVectors(r,o).normalize();if(a.lengthSq()===0)return null;const h=new _().crossVectors(r,a).normalize(),c=new _().crossVectors(o,a).normalize(),l=h.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),m=c.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),d=new lt(n,n.clone().add(l)),g=new lt(i,i.clone().add(m)),y=new _;return d.closestPointToPoint(g.startPoint,!0,y)?y:null}static createByThreePoints(t,s,e){const n=ut.computeCenterPoint(t,s,e);if(n){const i=n.distanceTo(t),r=new _().subVectors(t,n),o=new _().subVectors(s,n),a=Math.atan2(r.y,r.x),h=Math.atan2(o.y,o.x);return new ut(n,i,a,h,_.Z_AXIS)}}constructor(t,s,e,n,i,r=_.X_AXIS){super(),this.center=t,this.radius=s,this.startAngle=e,this.endAngle=n,this.normal=i,this.refVec=r,(n-e)%I==0?(this.startAngle=0,this.endAngle=I):(this.startAngle=e,this.endAngle=n)}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 N.AcCmErrors.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=P.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==I?t:P.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return P.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new _(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new _(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,s=this.deltaAngle;this.closed&&(t=0,s=I);const e=t+s*.5;return this.getPointAtAngle(e)}get length(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)}get area(){return this.closed?Math.PI*this.radius*this.radius:Math.abs(this.deltaAngle*this.radius*this.radius)}nearestPoint(t){const s=new _(t.x,t.y,t.z||0),e=this.center,n=this.normal,r=s.clone().sub(e).dot(n),a=s.clone().sub(n.clone().multiplyScalar(r)).clone().sub(e);if(a.lengthSq()===0)return this.startPoint.clone();a.normalize().multiplyScalar(this.radius);const h=e.clone().add(a),c=this.getAngle(h.clone()),l=this.startAngle,m=this.deltaAngle;let d=P.normalizeAngle(c-l);d<0&&(d=0),d>m&&(d=m);const g=this.getPointAtAngle(l+d),y=g.distanceTo(s),x=this.startPoint.distanceTo(s),f=this.endPoint.distanceTo(s);return x<y&&x<=f?this.startPoint.clone():f<y&&f<x?this.endPoint.clone():g}tangentPoints(t){const s=[],e=new _(t.x,t.y,t.z||0),n=this.center,i=this.normal,r=this.radius,a=e.clone().sub(n).dot(i),h=e.clone().sub(i.clone().multiplyScalar(a)),c=n.clone(),m=h.clone().sub(c).length();if(m<r)return s;const d=Math.acos(r/m),g=this.getAngle(h.clone()),y=[g+d,g-d];for(const x of y){const f=P.normalizeAngle(x-this.startAngle);f>=0&&f<=this.deltaAngle&&s.push(this.getPointAtAngle(this.startAngle+f))}return s}nearestTangentPoint(t){const s=this.tangentPoints(t);if(s.length===0)return null;const e=new z(t.x,t.y,t.z||0);return s.length===1||s[0].distanceTo(e)<s[1].distanceTo(e)?s[0]:s[1]}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let a=0;a<2*Math.PI;a+=Math.PI/2)P.isBetweenAngle(a,this.startAngle,this.endAngle)&&t.push(a);let s=1/0,e=1/0,n=1/0,i=-1/0,r=-1/0,o=-1/0;for(const a of t){const h=this.getPointAtAngle(a);h.x<s&&(s=h.x),h.y<e&&(e=h.y),h.z<n&&(n=h.z),h.x>i&&(i=h.x),h.y>r&&(r=h.y),h.z>o&&(o=h.z)}return new X({x:s,y:e,z:n},{x:i,y:r,z:o})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const s=[];let e=this.deltaAngle,n=this.startAngle;this.closed&&(e=I,n=0);for(let i=0;i<=t;i++){const r=n+e*(i/t),o=this.getPointAtAngle(r);s.push(o)}return s}transform(t){const s=this.center.clone().applyMatrix4(t),e=this.startPoint.clone().applyMatrix4(t),n=this.endPoint.clone().applyMatrix4(t),i=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(t),r=new _(e).sub(s).normalize(),o=s.distanceTo(e);let a=new _().crossVectors(new _(e).sub(s),new _(i).sub(s)).normalize();a.lengthSq()===0&&(a=this.normal.clone().transformDirection(t));const h=c=>{const l=new _(c).sub(s);return Math.atan2(l.dot(ks.crossVectors(a,r)),l.dot(r))};return this.center=s,this.radius=o,this.normal=a,this.refVec=r,this.startAngle=0,this.endAngle=this.closed?I:h(n),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 ut(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(ks.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const s=this.normal,e=this.refVec,n={x:s.y*e.z-s.z*e.y,y:s.z*e.x-s.x*e.z,z:s.x*e.y-s.y*e.x},i=this.center,r=this.radius;return new z(i.x+r*(e.x*Math.cos(t)+n.x*Math.sin(t)),i.y+r*(e.y*Math.cos(t)+n.y*Math.sin(t)),i.z+r*(e.z*Math.cos(t)+n.z*Math.sin(t)))}get plane(){const t=new _(this.center).distanceTo(qt);return new ot(this.normal,t)}}const ks=new _;class H extends st{constructor(t,s,e,n=0,i=I,r=!1,o=0){super(),this.center=t,this.majorAxisRadius=s,this.minorAxisRadius=e,(i-n)%I==0?(this.startAngle=0,this.endAngle=I):(this.startAngle=n,this.endAngle=i),this.clockwise=r,this.rotation=o}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 N.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw N.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=P.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==I?t:P.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return P.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let s=1/0,e=1/0,n=-1/0,i=-1/0;for(let r=0;r<=100;r++){const o=this.getPoint(r/100);s=Math.min(s,o.x),e=Math.min(e,o.y),n=Math.max(n,o.x),i=Math.max(i,o.y)}return new U({x:s,y:e},{x:n,y:i})}get closed(){return this.deltaAngle==0}getPoint(t){const s=Math.PI*2;let e=this.endAngle-this.startAngle;const n=Math.abs(e)<Number.EPSILON;for(;e<0;)e+=s;for(;e>s;)e-=s;e<Number.EPSILON&&(n?e=0:e=s),this.clockwise===!0&&!n&&(e===s?e=-s:e=e-s);const i=this.startAngle+t*e;let r=this.center.x+this.majorAxisRadius*Math.cos(i),o=this.center.y+this.minorAxisRadius*Math.sin(i);if(this.rotation!==0){const a=Math.cos(this.rotation),h=Math.sin(this.rotation),c=r-this.center.x,l=o-this.center.y;r=c*a-l*h+this.center.x,o=c*h+l*a+this.center.y}return new M(r,o)}transform(t){const s=t,e=new M(this.center).applyMatrix2d(s),n=new z(e.x,e.y,this.center.z),i=this.getPointAtAngle(0).clone().applyMatrix2d(s),r=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(s),o=new M(i).sub(e),a=new M(r).sub(e),h=o.length(),c=a.length(),l=Math.atan2(o.y,o.x),m=o.clone().normalize(),d=a.clone().normalize(),g=f=>{const b=new M(f).sub(e),p=b.dot(m),C=b.dot(d);return P.normalizeAngle(Math.atan2(C/c,p/h))},y=s.determinant()<0?!this.clockwise:this.clockwise,x=this.closed?new H(n,h,c,0,I,y,l):new H(n,h,c,g(this.startPoint.clone().applyMatrix2d(s)),g(this.endPoint.clone().applyMatrix2d(s)),y,l);return this.center=x.center,this.majorAxisRadius=x.majorAxisRadius,this.minorAxisRadius=x.minorAxisRadius,this._startAngle=x._startAngle,this._endAngle=x._endAngle,this._clockwise=x._clockwise,this.rotation=x.rotation,this._boundingBoxNeedsUpdate=!0,this}getPointAtAngle(t){return this.getPoint(this.closed?t/I:P.normalizeAngle(t-this.startAngle)/this.deltaAngle)}copy(t){return this.center=t.center,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}clone(){return new H(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}getFocusPoints(){const t=Math.max(this.majorAxisRadius,this.minorAxisRadius),s=Math.min(this.majorAxisRadius,this.minorAxisRadius);if(t-s<1e-9)return[];const e=Math.sqrt(t*t-s*s),n=Math.cos(this.rotation),i=Math.sin(this.rotation),r=this.majorAxisRadius>=this.minorAxisRadius,o=r?n:-i,a=r?i:n;return[new M(this.center.x-e*o,this.center.y-e*a),new M(this.center.x+e*o,this.center.y+e*a)]}getQuadrantPoints(){return this.closed?[this.getPoint(0),this.getPoint(.25),this.getPoint(.5),this.getPoint(.75)]:[]}nearestPoint(t){const s=new M(t.x,t.y);let e=this.getPoint(0),n=s.distanceToSquared(e);const i=72;for(let r=1;r<=i;r++){const o=this.getPoint(r/i),a=s.distanceToSquared(o);a<n&&(n=a,e=o)}return e}}class dt extends ct{constructor(t,s,e,n,i,r=0,o=I){super(),this.center=t,this.normal=s,this.majorAxis=e,this.majorAxisRadius=n,this.minorAxisRadius=i;const a=Math.abs(o-r);Math.abs(a-I)<1e-10||Math.abs(a-2*I)<1e-10?(this.startAngle=0,this.endAngle=I):(this.startAngle=r,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new z(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw N.AcCmErrors.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw N.AcCmErrors.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=P.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==I?t:P.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-I)<1e-10?I:P.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new _(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new _(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new _().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,s=this.deltaAngle;(this.closed||Math.abs(s-I)<1e-10)&&(t=0,s=I);const e=t+s/2;return this.getPointAtAngle(e)}get isCircular(){return it.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const t=1e3,s=this.deltaAngle/t;let e=0,n=this.getPointAtAngle(this.startAngle);for(let i=1;i<=t;i++){const r=this.startAngle+i*s,o=this.getPointAtAngle(r),a=o.x-n.x,h=o.y-n.y,c=o.z-n.z;e+=Math.sqrt(a*a+h*h+c*c),n=o}return e}get area(){const t=this.majorAxisRadius,s=this.minorAxisRadius,e=this.startAngle,n=e+this.deltaAngle;if(Math.abs(this.deltaAngle-I)<1e-10)return Math.PI*t*s;const i=t*s/2*(n-e-(Math.sin(n)*Math.cos(n)-Math.sin(e)*Math.cos(e)));return Math.abs(i)}calculateBoundingBox(){if(this.majorAxis.equals(_.X_AXIS)||this.majorAxis.equals(_.Y_AXIS)||this.majorAxis.isParallelTo(_.X_AXIS)||this.majorAxis.isParallelTo(_.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let a=0;a<2*Math.PI;a+=Math.PI/2)P.isBetweenAngle(a,this.startAngle,this.endAngle)&&t.push(a);let s=1/0,e=1/0,n=1/0,i=-1/0,r=-1/0,o=-1/0;for(const a of t){const h=this.getPointAtAngle(a);h.x<s&&(s=h.x),h.y<e&&(e=h.y),h.z<n&&(n=h.z),h.x>i&&(i=h.x),h.y>r&&(r=h.y),h.z>o&&(o=h.z)}return new X({x:s,y:e,z:n},{x:i,y:r,z:o})}else{let s=1/0,e=1/0,n=1/0,i=-1/0,r=-1/0,o=-1/0;for(let a=0;a<=100;a++){const h=this.startAngle+this.deltaAngle*(a/100),c=this.getPointAtAngle(h);s=Math.min(s,c.x),e=Math.min(e,c.y),n=Math.min(n,c.z),i=Math.max(i,c.x),r=Math.max(r,c.y),o=Math.max(o,c.z)}return new X({x:s,y:e,z:n},{x:i,y:r,z:o})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const s=[];let e=this.deltaAngle,n=this.startAngle;this.closed&&(e=I,n=0);for(let i=0;i<=t;i++){const r=n+e*(i/t),o=this.getPointAtAngle(r);s.push(o)}return s}getPointAtAngle(t){const s=Math.cos(t),e=Math.sin(t),n=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(e),i=this.majorAxis.clone().multiplyScalar(s*this.majorAxisRadius).add(n);return new z(this.center.x+i.x,this.center.y+i.y,this.center.z+i.z)}contains(t){const s=new _(t).sub(this.center),e=s.dot(this.majorAxis),n=s.dot(this.minorAxis),i=e/this.majorAxisRadius,r=n/this.minorAxisRadius;return i*i+r*r<=1}transform(t){const s=t,e=this.center.clone().applyMatrix4(s),n=this.getPointAtAngle(0).clone().applyMatrix4(s),i=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(s),r=new _(n).sub(e),o=new _(i).sub(e),a=r.length(),h=o.length(),c=r.clone().normalize(),l=new _().crossVectors(r,o).normalize();let m=new _().crossVectors(l,c).normalize();m.dot(o)<0&&(l.negate(),m=new _().crossVectors(l,c).normalize());const d=y=>{const x=new _(y).sub(e),f=x.dot(c),b=x.dot(m);return P.normalizeAngle(Math.atan2(b/h,f/a))},g=this.closed?new dt(e,l,c,a,h,0,I):new dt(e,l,c,a,h,d(this.startPoint.clone().applyMatrix4(s)),d(this.endPoint.clone().applyMatrix4(s)));return this.center=g.center,this.normal=g.normal,this.majorAxis=g.majorAxis,this.majorAxisRadius=g.majorAxisRadius,this.minorAxisRadius=g.minorAxisRadius,this._startAngle=g._startAngle,this._endAngle=g._endAngle,this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new dt(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new _(this.center).distanceTo(qt);return new ot(this.normal,t)}}class Qt extends st{constructor(t=null,s=!1){super(),this._vertices=t||new Array,this._closed=s}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 M(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 s=this._vertices[0];return new M(s.x,s.y)}else{const s=this._vertices[t-1];return new M(s.x,s.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let t=0;const s=this._vertices.length;for(let e=0;e<s;++e){const n=this._vertices[e];let i=null;if(e<s-1?i=this._vertices[e+1]:e==s-1&&this.closed&&(i=this._vertices[0]),i)if(n.bulge){const r=new Q(n,i,n.bulge);t+=r.length}else t+=new M(n.x,n.y).distanceTo(i)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,s){t<=0?this._vertices.unshift(s):this._vertices.splice(t,0,s),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,s){t?s!==void 0&&s>=0&&s<this._vertices.length&&(this._vertices=this._vertices.slice(0,s),this._boundingBoxNeedsUpdate=!0):(this._vertices=new Array,this._boundingBoxNeedsUpdate=!0)}getPointAt(t){const s=this._vertices[t];return new M(s.x,s.y)}calculateBoundingBox(){const t=this.getPoints(100);return new U().setFromPoints(t)}transform(t){const s=t.determinant()<0;return this._vertices.forEach(e=>{const n=new M(e).applyMatrix2d(t);e.x=n.x,e.y=n.y,s&&e.bulge!=null&&(e.bulge=-e.bulge)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new Qt(this._vertices.map(t=>({...t})),this._closed)}getPoints3d(t,s){const e=[];return this.getPoints(t).forEach(i=>e.push(new z().set(i.x,i.y,s))),e}getPoints(t){const s=[],e=this._vertices.length;for(let n=0;n<e;++n){const i=this._vertices[n];if(i.bulge){let r=null;if(n<e-1?r=this._vertices[n+1]:n==e-1&&this.closed&&(r=this._vertices[0]),r){const a=new Q(i,r,i.bulge).getPoints(t),h=a.length;for(let c=0;c<h;++c){const l=a[c];s.push(new M(l.x,l.y))}}}else s.push(new M(i.x,i.y)),n==e-1&&this.closed&&s.push(s[0])}return s}}class mt extends st{constructor(t,s){super(),this._start=new M(t),this._end=new M(s)}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 M(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),s=new M(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new U(t,s)}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 mt(this._start.clone(),this._end.clone())}project(t){const s=this._end.x-this._start.x,e=this._end.y-this._start.y,n=s*s+e*e;if(n<1e-18)return this._start.clone();let i=((t.x-this._start.x)*s+(t.y-this._start.y)*e)/n;return i=Math.max(0,Math.min(1,i)),new M(this._start.x+i*s,this._start.y+i*e)}nearestPoint(t){return this.project(t)}}class F extends st{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}static buildFromEdges(t,s=.001){if(t.length===0)return[];const e=[...t],n=[],i=s*s,r=(o,a)=>{const h=o.x-a.x,c=o.y-a.y;return h*h+c*c<=i};for(;e.length>0;){const o=[],a=e.shift();o.push(a);const h=F.getEdgeStartPoint(a);let c=F.getEdgeEndPoint(a);if(!r(h,c))for(;e.length>0;){const l=F.findConnectingEdge(e,c,i);if(l.index<0)break;let m=e.splice(l.index,1)[0];if(l.reverse&&(m=F.reverseEdge(m)),o.push(m),c=F.getEdgeEndPoint(m),r(c,h))break}n.push(new F(o))}return n}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 M(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(s=>{t+=s.length}),t}calculateBoundingBox(){const t=this.getPoints(100),s=new U;return s.setFromPoints(t),s}transform(t){const s=new Z().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 K?e.transform(s):e.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new F(this._curves.map(t=>t.clone()))}get closed(){return!0}getPoints(t){const s=[];return this.curves.forEach(e=>{e.getPoints(t).forEach(n=>{s.push(new M(n.x,n.y))})}),s}static findConnectingEdge(t,s,e){let n=-1,i=!1,r=Number.POSITIVE_INFINITY;for(let o=0;o<t.length;o++){const a=t[o],h=F.getEdgeStartPoint(a),c=F.getEdgeEndPoint(a),l=s.x-h.x,m=s.y-h.y,d=l*l+m*m;d<r&&(r=d,n=o,i=!1);const g=s.x-c.x,y=s.y-c.y,x=g*g+y*y;x<r&&(r=x,n=o,i=!0)}return r>e?{index:-1,reverse:!1}:{index:n,reverse:i}}static getEdgeStartPoint(t){const s=t.startPoint;return new M(s.x,s.y)}static getEdgeEndPoint(t){const s=t.endPoint;return new M(s.x,s.y)}static reverseEdge(t){return t instanceof mt?new mt(t.endPoint,t.startPoint):t instanceof Q?new Q(t.center,t.radius,t.endAngle,t.startAngle,!t.clockwise):t instanceof H?new H(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof K?F.reverseSplineEdge(t):t}static reverseSplineEdge(t){const s=[...t.controlPoints].reverse(),e=t.knots,n=e[0],i=e[e.length-1],r=e.map(h=>n+i-h).reverse(),o=t.weights,a=o.length>0?[...o].reverse():void 0;return new K(s,r,a,t.degree,t.closed)}}class Kt{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,s,e,n){this.c0=t,this.c1=e,this.c2=-3*t+3*s-2*e-n,this.c3=2*t-2*s+e+n}initCatmullRom(t,s,e,n,i){this.init(s,e,i*(e-t),i*(n-s))}initNonuniformCatmullRom(t,s,e,n,i,r,o){let a=(s-t)/i-(e-t)/(i+r)+(e-s)/r,h=(e-s)/r-(n-s)/(r+o)+(n-e)/o;a*=r,h*=r,this.init(s,e,a,h)}calc(t){const s=t*t,e=s*t;return this.c0+this.c1*t+this.c2*s+this.c3*e}}class pt extends ct{constructor(t=[],s=!1,e="centripetal",n=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new _,this._px=new Kt,this._py=new Kt,this._pz=new Kt,this._points=t.map(i=>new z(i)),this._closed=s,this._curveType=e,this._tension=n}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 s=1;s<this._points.length;s++)t+=this._points[s-1].distanceTo(this._points[s]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,s=new z){const e=s,n=this._points,i=n.length;if(i===0)return e.set(0,0,0);if(i===1)return e.copy(n[0]);const r=(i-(this._closed?0:1))*t;let o=Math.floor(r),a=r-o;this._closed?o+=o>0?0:(Math.floor(Math.abs(o)/i)+1)*i:a===0&&o===i-1&&(o=i-2,a=1);let h,c;this._closed||o>0?h=n[(o-1)%i]:(this._tmp.subVectors(n[0],n[1]).add(n[0]),h=new z(this._tmp.x,this._tmp.y,this._tmp.z));const l=n[o%i],m=n[(o+1)%i];if(this._closed||o+2<i?c=n[(o+2)%i]:(this._tmp.subVectors(n[i-1],n[i-2]).add(n[i-1]),c=new z(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const d=this._curveType==="chordal"?.5:.25;let g=Math.pow(h.distanceToSquared(l),d),y=Math.pow(l.distanceToSquared(m),d),x=Math.pow(m.distanceToSquared(c),d);y<1e-4&&(y=1),g<1e-4&&(g=y),x<1e-4&&(x=y),this._px.initNonuniformCatmullRom(h.x,l.x,m.x,c.x,g,y,x),this._py.initNonuniformCatmullRom(h.y,l.y,m.y,c.y,g,y,x),this._pz.initNonuniformCatmullRom(h.z,l.z,m.z,c.z,g,y,x)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(h.x,l.x,m.x,c.x,this._tension),this._py.initCatmullRom(h.y,l.y,m.y,c.y,this._tension),this._pz.initCatmullRom(h.z,l.z,m.z,c.z,this._tension));return e.set(this._px.calc(a),this._py.calc(a),this._pz.calc(a)),e}getPoints(t){const s=[];for(let e=0;e<=t;e++)s.push(this.getPoint(e/t));return s}setPoints(t){this._points=t.map(s=>new z(s)),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 pt(this._points.map(t=>t.clone()),this._closed,this._curveType,this._tension)}transform(t){return this._points=this._points.map(s=>{const e=new z;return e.copy(s),e.applyMatrix4(t),e}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new X;const t=new X;return this._points.forEach(s=>{t.expandByPoint(s)}),t}}function Rs(u,t){const s=u.x-t[0],e=u.y-t[1],n=(u.z??0)-(t[2]??0);return s*s+e*e+n*n}class q{constructor(t,s,e,n){this._degree=t,this._knots=[...s],this._controlPoints=e.map(i=>({x:i.x,y:i.y,z:i.z})),this._weights=n?[...n]: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 q(this._degree,this._knots,this._controlPoints,this._weights)}point(t){const s=this._controlPoints.map(e=>[e.x,e.y,e.z]);return at(t,this._degree,this._knots,s,this._weights)}length(){const t=this._controlPoints.map(s=>[s.x,s.y,s.z]);return bs(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,s,e,n){return new q(t,s,e,n)}static byPoints(t,s,e="Uniform",n,i){const r=Xt(t,s,e,n,i),o=r.controlPoints.map(a=>({x:a[0],y:a[1],z:a[2]}));return new q(s,r.knots,o,r.weights)}getParameterRange(){const t=this._knots[this._degree],s=this._knots[this._knots.length-this._degree-1];return{start:t,end:s}}getPoints(t){const s=[],{start:e,end:n}=this.getParameterRange();for(let i=0;i<=t;i++){const r=e+(n-e)*(i/t);s.push(this.point(r))}return s}isClosed(t=1e-6){const{start:s,end:e}=this.getParameterRange(),n=this.point(s),i=this.point(e),r=n[0]-i[0],o=n[1]-i[1],a=n[2]-i[2];return Math.sqrt(r*r+o*o+a*a)<t}static createFitPointsForClosedCurve(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const s=new pt(t,!0,"centripetal"),e=Math.max(50,t.length*2);return s.getPoints(e)}nearestPoint(t,s=64){const{start:e,end:n}=this.getParameterRange();let i=this.point(e),r=Rs(t,i);for(let o=0;o<=s;o++){const a=e+(n-e)*o/s,h=this.point(a),c=Rs(t,h);c<r&&(r=c,i=h)}return{x:i[0],y:i[1],z:i[2]??0}}static createClosedCurve(t,s,e="Chord"){const i=this.createFitPointsForClosedCurve(t).map(r=>[r.x,r.y,r.z]);return q.byPoints(i,s,e)}}class K extends ct{constructor(t,s,e,n,i,r){super();const o=arguments.length;if(this._degree=3,this._closed=!1,Array.isArray(s)){if(o<2||o>5)throw N.AcCmErrors.ILLEGAL_PARAMETERS;this._controlPoints=t;let a,h=3,c=!1;if(o>=3&&(Array.isArray(e)?(a=e,o>=4&&(h=n||3),o>=5&&(c=i)):e!==void 0&&(h=e||3,o>=4&&(c=n))),e===void 0&&o>=4&&(h=n||3,o>=5&&(c=i)),this._degree=h,this._closed=c,this._controlPoints.length<this._degree+1)throw N.AcCmErrors.ILLEGAL_PARAMETERS;this._nurbsCurve=q.byKnotsControlPointsWeights(this._degree,s,this._controlPoints,a)}else{if(o<2||o>6)throw N.AcCmErrors.ILLEGAL_PARAMETERS;this._fitPoints=t,this._knotParameterization=s,o>=3&&(this._degree=e||3);const a=typeof n=="boolean";o>=4&&a&&(this._closed=n),a?(o>=5&&(this._startTangent=i),o>=6&&(this._endTangent=r)):(o>=4&&(this._startTangent=n),o>=5&&(this._endTangent=i)),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 N.AcCmErrors.ILLEGAL_PARAMETERS;if(this._closed)this._nurbsCurve=q.createClosedCurve(this._fitPoints,this._degree,this._knotParameterization);else{const c=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=q.byPoints(c,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(c=>[c.x,c.y,c.z||0]))}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=q.createFitPointsForClosedCurve(this._fitPoints),s=this.toNurbsPoints(t);this._nurbsCurve=q.byPoints(s,this._degree,this._knotParameterization)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=q.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=q.createFitPointsForClosedCurve(this._controlPoints),s=this.toNurbsPoints(t);this._nurbsCurve=q.byPoints(s,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(),s=this._nurbsCurve.weights();this._nurbsCurve=q.byKnotsControlPointsWeights(this._degree,t,this._controlPoints,s)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z||0}))}get fitPoints(){var t;return(t=this._fitPoints)==null?void 0:t.map(s=>({x:s.x,y:s.y,z:s.z||0}))}get knots(){return[...this._nurbsCurve.knots()]}get weights(){return[...this._nurbsCurve.weights()]}get startPoint(){const t=this._nurbsCurve.knots(),s=this._nurbsCurve.degree(),e=t[s],n=this._nurbsCurve.point(e);return new z(n[0],n[1],n[2])}get endPoint(){const t=this._nurbsCurve.knots(),s=this._nurbsCurve.degree(),e=t[t.length-s-1],n=this._nurbsCurve.point(e);return new z(n[0],n[1],n[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const s=this._fitPoints.length,e=t<0||t>=s?s-1:t,n=this._fitPoints[e];return{x:n.x,y:n.y,z:n.z||0}}getControlPointAt(t){const s=this._controlPoints.length,e=t<0||t>=s?s-1:t;return this._controlPoints[e]}getPoints(t=100){const s=this._nurbsCurve,e=[],n=s.knots(),i=this._nurbsCurve.degree(),r=n[i],o=n[n.length-i-1],a=(o-r)/(t-1);for(let h=0;h<t;h++){const c=h===t-1?o:r+h*a,l=s.point(c);e.push(new z(l[0],l[1],l[2]))}return e}getCurvePoints(t,s){const e=[],n=t.knots(),i=t.degree(),r=n[i],a=(n[n.length-i-1]-r)/(s-1);for(let h=0;h<s;h++){const c=r+h*a;e.push(t.point(c))}return e}calculateBoundingBox(){const t=this.getPoints(100);return new X().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(s=>new z(s).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 s=this._nurbsCurve.knots(),e=this._nurbsCurve.weights();this._controlPoints=this._controlPoints.map(n=>new z(n).applyMatrix4(t)),this._nurbsCurve=q.byKnotsControlPointsWeights(this._degree,s,this._controlPoints,e.length>0?e:void 0)}return this._boundingBoxNeedsUpdate=!0,this}clone(){return this._fitPoints&&this._knotParameterization?new K(this._fitPoints.map(t=>({x:t.x,y:t.y,z:t.z||0})),this._knotParameterization,this._degree,this._closed,this._startTangent?{x:this._startTangent.x,y:this._startTangent.y,z:this._startTangent.z||0}:void 0,this._endTangent?{x:this._endTangent.x,y:this._endTangent.y,z:this._endTangent.z||0}:void 0):new K(this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z||0})),this._nurbsCurve.knots(),this._nurbsCurve.weights(),this._degree,this._closed)}toNurbsPoints(t){const s=new Array(t.length);return t.forEach((e,n)=>{s[n]=[e.x,e.y,e.z||0]}),s}toGePoints(t){const s=new Array(t.length);return t.forEach((e,n)=>{s[n]={x:e[0],y:e[1],z:e[2]}}),s}toNurbsPoint(t){return[t.x,t.y,t.z||0]}static createClosedSpline(t,s="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 K(t,s,e,!0)}}A.AcGeArea2d=Gt,A.AcGeBox2d=U,A.AcGeBox3d=X,A.AcGeCatmullRomCurve3d=pt,A.AcGeCircArc2d=Q,A.AcGeCircArc3d=ut,A.AcGeCurve2d=st,A.AcGeEllipseArc2d=H,A.AcGeEllipseArc3d=dt,A.AcGeEuler=Ft,A.AcGeGeometryUtil=zs,A.AcGeLine2d=mt,A.AcGeLine3d=lt,A.AcGeLoop2d=F,A.AcGeMathUtil=P,A.AcGeMatrix2d=J,A.AcGeMatrix3d=Z,A.AcGeNurbsCurve=q,A.AcGePlane=ot,A.AcGePoint2d=M,A.AcGePoint3d=z,A.AcGePolyline2d=Qt,A.AcGeQuaternion=rt,A.AcGeShape2d=Ot,A.AcGeSpline3d=K,A.AcGeTol=it,A.AcGeVector2d=B,A.AcGeVector3d=_,A.DEFAULT_TOL=Vt,A.DEG2RAD=Bt,A.FLOAT_TOL=W,A.ORIGIN_POINT_2D=Ts,A.ORIGIN_POINT_3D=qt,A.RAD2DEG=kt,A.TAU=I,A.basisFunction=ht,A.calculateCurveLength=bs,A.ceilPowerOfTwo=us,A.clamp=Y,A.computeParameterValues=Ps,A.damp=ts,A.degToRad=as,A.euclideanModulo=Rt,A.evaluateNurbsPoint=at,A.floorPowerOfTwo=ds,A.generateAveragedKnots=Ms,A.generateChordKnots=Us,A.generateSqrtChordKnots=Fs,A.generateUUID=$t,A.generateUniformKnots=Ls,A.getOcsAngle=Os,A.getOcsReferenceVector=Ys,A.intPartLength=Nt,A.interpolateControlPoints=Ds,A.interpolateNurbsCurve=Xt,A.inverseLerp=Jt,A.isBetween=ms,A.isBetweenAngle=gs,A.isPointInPolygon=Dt,A.isPolygonIntersect=ws,A.isPowerOfTwo=ls,A.lerp=Tt,A.mapLinear=Ht,A.normalizeAngle=nt,A.pingpong=ss,A.radToDeg=cs,A.randFloat=rs,A.randFloatSpread=os,A.randInt=is,A.relativeEps=ys,A.seededRandom=hs,A.smootherstep=ns,A.smoothstep=es,A.transformOcsPointToWcs=Zs,A.transformWcsPointToOcs=Zt,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 L=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let sn=1234567;const qt=Math.PI/180,Vt=180/Math.PI;function rn(){const o=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,e=Math.random()*4294967295|0;return(L[o&255]+L[o>>8&255]+L[o>>16&255]+L[o>>24&255]+"-"+L[t&255]+L[t>>8&255]+"-"+L[t>>16&15|64]+L[t>>24&255]+"-"+L[n&63|128]+L[n>>8&255]+"-"+L[n>>16&255]+L[n>>24&255]+L[e&255]+L[e>>8&255]+L[e>>16&255]+L[e>>24&255]).toLowerCase()}function Q(o,t,n){return Math.max(t,Math.min(n,o))}function jt(o,t){return(o%t+t)%t}function on(o,t,n,e,s){return e+(o-t)*(s-e)/(n-t)}function hn(o,t,n){return o!==t?(n-o)/(t-o):0}function Lt(o,t,n){return(1-n)*o+n*t}function an(o,t,n,e){return Lt(o,t,1-Math.exp(-n*e))}function cn(o,t=1){return t-Math.abs(jt(o,t*2)-t)}function ln(o,t,n){return o<=t?0:o>=n?1:(o=(o-t)/(n-t),o*o*(3-2*o))}function un(o,t,n){return o<=t?0:o>=n?1:(o=(o-t)/(n-t),o*o*o*(o*(o*6-15)+10))}function dn(o,t){return o+Math.floor(Math.random()*(t-o+1))}function mn(o,t){return o+Math.random()*(t-o)}function gn(o){return o*(.5-Math.random())}function yn(o){o!==void 0&&(sn=o);let t=sn+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function xn(o){return o*qt}function _n(o){return o*Vt}function fn(o){return(o&o-1)===0&&o!==0}function An(o){return Math.pow(2,Math.ceil(Math.log(o)/Math.LN2))}function wn(o){return Math.pow(2,Math.floor(Math.log(o)/Math.LN2))}function ut(o){const t=Math.PI*2;return(o%t+t)%t}function Pn(o,t,n){return o>t&&o<n||o>n&&o<t}function pn(o,t,n,e=!1){return o=ut(o),t=ut(t),n=ut(n),e?t>n?o<=t&&o>=n:o<=t||o>=n:t<n?o>=t&&o<=n:o>=t||o<=n}function Ut(o){return o=Math.abs(o),o<1?0:Math.ceil(Math.log10(Math.abs(o)+1))}function Mn(o,t=1e-7){const n=Ut(o);return Math.max(Math.pow(10,n)*t,t)}const M={DEG2RAD:qt,RAD2DEG:Vt,generateUUID:rn,clamp:Q,euclideanModulo:jt,mapLinear:on,inverseLerp:hn,lerp:Lt,damp:an,pingpong:cn,smoothstep:ln,smootherstep:un,randInt:dn,randFloat:mn,randFloatSpread:gn,seededRandom:yn,degToRad:xn,radToDeg:_n,isPowerOfTwo:fn,ceilPowerOfTwo:An,floorPowerOfTwo:wn,normalizeAngle:ut,isBetween:Pn,isBetweenAngle:pn,intPartLength:Ut,relativeEps:Mn},_t=class _t{constructor(t,n){this.x=0,this.y=0;const e=+(t!==void 0)+ +(n!==void 0);if(e!==0){if(e===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(e===1){const{x:s,y:i}=t;this.x=s,this.y=i;return}if(e===2){this.x=t,this.y=n;return}throw 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 _t(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const n=this.x,e=this.y,s=t.elements;return this.x=s[0]*n+s[3]*e+s[6],this.y=s[1]*n+s[4]*e+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this}clampScalar(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this}clampLength(t,n){const e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(n,e)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const n=Math.sqrt(this.lengthSq()*t.lengthSq());if(n===0)return Math.PI/2;const e=this.dot(t)/n;return Math.acos(Math.max(-1,Math.min(1,e)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const n=this.x-t.x,e=this.y-t.y;return n*n+e*e}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this}lerpVectors(t,n,e){return this.x=t.x+(n.x-t.x)*e,this.y=t.y+(n.y-t.y)*e,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t}rotateAround(t,n){const e=Math.cos(n),s=Math.sin(n),i=this.x-t.x,r=this.y-t.y;return this.x=i*e-r*s+t.x,this.y=i*s+r*e+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(M.relativeEps(this.x,t),M.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};_t.EMPTY=Object.freeze(new _t(0,0));let T=_t;const ft=class ft{constructor(t,n,e,s,i,r,h,a,c){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&n!=null&&e!=null&&s!=null&&i!=null&&r!=null&&h!=null&&a!=null&&c!=null&&this.set(t,n,e,s,i,r,h,a,c)}set(t,n,e,s,i,r,h,a,c){const l=this.elements;return l[0]=t,l[1]=s,l[2]=h,l[3]=n,l[4]=i,l[5]=a,l[6]=e,l[7]=r,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const n=this.elements,e=t.elements;return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],this}extractBasis(t,n,e){return t.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),e.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const n=t.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const e=t.elements,s=n.elements,i=this.elements,r=e[0],h=e[3],a=e[6],c=e[1],l=e[4],u=e[7],d=e[2],m=e[5],g=e[8],y=s[0],x=s[3],f=s[6],b=s[1],P=s[4],C=s[7],S=s[2],B=s[5],p=s[8];return i[0]=r*y+h*b+a*S,i[3]=r*x+h*P+a*B,i[6]=r*f+h*C+a*p,i[1]=c*y+l*b+u*S,i[4]=c*x+l*P+u*B,i[7]=c*f+l*C+u*p,i[2]=d*y+m*b+g*S,i[5]=d*x+m*P+g*B,i[8]=d*f+m*C+g*p,this}multiplyScalar(t){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=t,n[4]*=t,n[7]*=t,n[2]*=t,n[5]*=t,n[8]*=t,this}determinant(){const t=this.elements,n=t[0],e=t[1],s=t[2],i=t[3],r=t[4],h=t[5],a=t[6],c=t[7],l=t[8];return n*r*l-n*h*c-e*i*l+e*h*a+s*i*c-s*r*a}invert(){const t=this.elements,n=t[0],e=t[1],s=t[2],i=t[3],r=t[4],h=t[5],a=t[6],c=t[7],l=t[8],u=l*r-h*c,d=h*a-l*i,m=c*i-r*a,g=n*u+e*d+s*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/g;return t[0]=u*y,t[1]=(s*c-l*e)*y,t[2]=(h*e-s*r)*y,t[3]=d*y,t[4]=(l*n-s*a)*y,t[5]=(s*i-h*n)*y,t[6]=m*y,t[7]=(e*a-c*n)*y,t[8]=(r*n-e*i)*y,this}transpose(){let t;const n=this.elements;return t=n[1],n[1]=n[3],n[3]=t,t=n[2],n[2]=n[6],n[6]=t,t=n[5],n[5]=n[7],n[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const n=this.elements;return t.elements[0]=n[0],t.elements[1]=n[3],t.elements[2]=n[6],t.elements[3]=n[1],t.elements[4]=n[4],t.elements[5]=n[7],t.elements[6]=n[2],t.elements[7]=n[5],t.elements[8]=n[8],this}setUvTransform(t,n,e,s,i,r,h){const a=Math.cos(i),c=Math.sin(i);return this.set(e*a,e*c,-e*(a*r+c*h)+r+t,-s*c,s*a,-s*(-c*r+a*h)+h+n,0,0,1),this}scale(t,n){return this.premultiply(vt.makeScale(t,n)),this}rotate(t){return this.premultiply(vt.makeRotation(-t)),this}translate(t,n){return this.premultiply(vt.makeTranslation(t,n)),this}makeTranslation(t,n){return t instanceof T?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,n,0,0,1),this}makeRotation(t){const n=Math.cos(t),e=Math.sin(t);return this.set(n,-e,0,e,n,0,0,0,1),this}makeScale(t,n){return this.set(t,0,0,0,n,0,0,0,1),this}equals(t){const n=this.elements,e=t.elements;for(let s=0;s<9;s++)if(n[s]!==e[s])return!1;return!0}fromArray(t,n=0){for(let e=0;e<9;e++)this.elements[e]=t[e+n];return this}toArray(t=[],n=0){const e=this.elements;return t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3],t[n+4]=e[4],t[n+5]=e[5],t[n+6]=e[6],t[n+7]=e[7],t[n+8]=e[8],t}clone(){return new ft().fromArray(this.elements)}};ft.IDENTITY=Object.freeze(new ft);let rt=ft;const vt=new rt,K=1e-6,I=2*Math.PI,Hn={x:0,y:0},Ft={x:0,y:0,z:0};class k{constructor(){this.equalPointTol=K,this.equalVectorTol=K}clone(){const t=new k;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t}equalPoint2d(t,n){return new T(t).sub(n).length()<this.equalPointTol}equalPoint3d(t,n){return new _(t).sub(n).length()<this.equalPointTol}static equalToZero(t,n=K){return t<n&&t>-n}static equal(t,n,e=K){return Math.abs(t-n)<e}static great(t,n,e=K){return t-n>e}static less(t,n,e=K){return t-n<e}static isPositive(t,n=K){return t>n}static isNonPositive(t,n=K){return t<=n}}const Pt=new k;class dt{constructor(t=0,n=0,e=0,s=1){this._x=t,this._y=n,this._z=e,this._w=s}static slerpFlat(t,n,e,s,i,r,h){let a=e[s+0],c=e[s+1],l=e[s+2],u=e[s+3];const d=i[r+0],m=i[r+1],g=i[r+2],y=i[r+3];if(h===0){t[n+0]=a,t[n+1]=c,t[n+2]=l,t[n+3]=u;return}if(h===1){t[n+0]=d,t[n+1]=m,t[n+2]=g,t[n+3]=y;return}if(u!==y||a!==d||c!==m||l!==g){let x=1-h;const f=a*d+c*m+l*g+u*y,b=f>=0?1:-1,P=1-f*f;if(P>Number.EPSILON){const S=Math.sqrt(P),B=Math.atan2(S,f*b);x=Math.sin(x*B)/S,h=Math.sin(h*B)/S}const C=h*b;if(a=a*x+d*C,c=c*x+m*C,l=l*x+g*C,u=u*x+y*C,x===1-h){const S=1/Math.sqrt(a*a+c*c+l*l+u*u);a*=S,c*=S,l*=S,u*=S}}t[n]=a,t[n+1]=c,t[n+2]=l,t[n+3]=u}static multiplyQuaternionsFlat(t,n,e,s,i,r){const h=e[s],a=e[s+1],c=e[s+2],l=e[s+3],u=i[r],d=i[r+1],m=i[r+2],g=i[r+3];return t[n]=h*g+l*u+a*m-c*d,t[n+1]=a*g+l*d+c*u-h*m,t[n+2]=c*g+l*m+h*d-a*u,t[n+3]=l*g-h*u-a*d-c*m,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,n,e,s){return this._x=t,this._y=n,this._z=e,this._w=s,this._onChangeCallback(),this}clone(){return new dt(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,n=!0){const e=t.x,s=t.y,i=t.z,r=t.order,h=Math.cos,a=Math.sin,c=h(e/2),l=h(s/2),u=h(i/2),d=a(e/2),m=a(s/2),g=a(i/2);switch(r){case"XYZ":this._x=d*l*u+c*m*g,this._y=c*m*u-d*l*g,this._z=c*l*g+d*m*u,this._w=c*l*u-d*m*g;break;case"YXZ":this._x=d*l*u+c*m*g,this._y=c*m*u-d*l*g,this._z=c*l*g-d*m*u,this._w=c*l*u+d*m*g;break;case"ZXY":this._x=d*l*u-c*m*g,this._y=c*m*u+d*l*g,this._z=c*l*g+d*m*u,this._w=c*l*u-d*m*g;break;case"ZYX":this._x=d*l*u-c*m*g,this._y=c*m*u+d*l*g,this._z=c*l*g-d*m*u,this._w=c*l*u+d*m*g;break;case"YZX":this._x=d*l*u+c*m*g,this._y=c*m*u+d*l*g,this._z=c*l*g-d*m*u,this._w=c*l*u-d*m*g;break;case"XZY":this._x=d*l*u-c*m*g,this._y=c*m*u-d*l*g,this._z=c*l*g+d*m*u,this._w=c*l*u+d*m*g;break}return n===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,n){const e=n/2,s=Math.sin(e);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(t){const n=t.elements,e=n[0],s=n[4],i=n[8],r=n[1],h=n[5],a=n[9],c=n[2],l=n[6],u=n[10],d=e+h+u;if(d>0){const m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(l-a)*m,this._y=(i-c)*m,this._z=(r-s)*m}else if(e>h&&e>u){const m=2*Math.sqrt(1+e-h-u);this._w=(l-a)/m,this._x=.25*m,this._y=(s+r)/m,this._z=(i+c)/m}else if(h>u){const m=2*Math.sqrt(1+h-e-u);this._w=(i-c)/m,this._x=(s+r)/m,this._y=.25*m,this._z=(a+l)/m}else{const m=2*Math.sqrt(1+u-e-h);this._w=(r-s)/m,this._x=(i+c)/m,this._y=(a+l)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(t,n){let e=t.dot(n)+1;return e<Number.EPSILON?(e=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=e):(this._x=0,this._y=-t.z,this._z=t.y,this._w=e)):(this._x=t.y*n.z-t.z*n.y,this._y=t.z*n.x-t.x*n.z,this._z=t.x*n.y-t.y*n.x,this._w=e),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Q(this.dot(t),-1,1)))}rotateTowards(t,n){const e=this.angleTo(t);if(e===0)return this;const s=Math.min(1,n/e);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,n){const e=t._x,s=t._y,i=t._z,r=t._w,h=n._x,a=n._y,c=n._z,l=n._w;return this._x=e*l+r*h+s*c-i*a,this._y=s*l+r*a+i*h-e*c,this._z=i*l+r*c+e*a-s*h,this._w=r*l-e*h-s*a-i*c,this._onChangeCallback(),this}slerp(t,n){if(n===0)return this;if(n===1)return this.copy(t);const e=this._x,s=this._y,i=this._z,r=this._w;let h=r*t._w+e*t._x+s*t._y+i*t._z;if(h<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,h=-h):this.copy(t),h>=1)return this._w=r,this._x=e,this._y=s,this._z=i,this;const a=1-h*h;if(a<=Number.EPSILON){const m=1-n;return this._w=m*r+n*this._w,this._x=m*e+n*this._x,this._y=m*s+n*this._y,this._z=m*i+n*this._z,this.normalize(),this}const c=Math.sqrt(a),l=Math.atan2(c,h),u=Math.sin((1-n)*l)/c,d=Math.sin(n*l)/c;return this._w=r*u+this._w*d,this._x=e*u+this._x*d,this._y=s*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,n,e){return this.copy(t).slerp(n,e)}random(){const t=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),e=Math.random(),s=Math.sqrt(1-e),i=Math.sqrt(e);return this.set(s*Math.sin(t),s*Math.cos(t),i*Math.sin(n),i*Math.cos(n))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,n=0){return this._x=t[n],this._y=t[n+1],this._z=t[n+2],this._w=t[n+3],this._onChangeCallback(),this}toArray(t=[],n=0){return t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const q=class q{constructor(t,n,e){this.x=0,this.y=0,this.z=0;const s=+(t!==void 0)+ +(n!==void 0)+ +(e!==void 0);if(s!==0){if(s===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(s===1){const{x:i,y:r,z:h}=t;this.x=i,this.y=r,this.z=h||0;return}if(s===3){this.x=t,this.y=n,this.z=e;return}throw 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 q(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this}addScaledVector(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,n){return this.x=t.x*n.x,this.y=t.y*n.y,this.z=t.z*n.z,this}applyEuler(t){return this.applyQuaternion(zn.setFromEuler(t))}applyAxisAngle(t,n){return this.applyQuaternion(zn.setFromAxisAngle(t,n))}applyMatrix3(t){const n=this.x,e=this.y,s=this.z,i=t.elements;return this.x=i[0]*n+i[3]*e+i[6]*s,this.y=i[1]*n+i[4]*e+i[7]*s,this.z=i[2]*n+i[5]*e+i[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const n=this.x,e=this.y,s=this.z,i=t.elements,r=1/(i[3]*n+i[7]*e+i[11]*s+i[15]);return this.x=(i[0]*n+i[4]*e+i[8]*s+i[12])*r,this.y=(i[1]*n+i[5]*e+i[9]*s+i[13])*r,this.z=(i[2]*n+i[6]*e+i[10]*s+i[14])*r,this}applyQuaternion(t){const n=this.x,e=this.y,s=this.z,i=t.x,r=t.y,h=t.z,a=t.w,c=2*(r*s-h*e),l=2*(h*n-i*s),u=2*(i*e-r*n);return this.x=n+a*c+r*u-h*l,this.y=e+a*l+h*c-i*u,this.z=s+a*u+i*l-r*c,this}transformDirection(t){const n=this.x,e=this.y,s=this.z,i=t.elements;return this.x=i[0]*n+i[4]*e+i[8]*s,this.y=i[1]*n+i[5]*e+i[9]*s,this.z=i[2]*n+i[6]*e+i[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this.z=Math.max(t.z,Math.min(n.z,this.z)),this}clampScalar(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this.z=Math.max(t,Math.min(n,this.z)),this}clampLength(t,n){const e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(n,e)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const n=this.dot(t),e=this.length(),s=t.length();return Math.abs(n)===e*s}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this}lerpVectors(t,n,e){return this.x=t.x+(n.x-t.x)*e,this.y=t.y+(n.y-t.y)*e,this.z=t.z+(n.z-t.z)*e,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,n){const e=t.x,s=t.y,i=t.z,r=n.x,h=n.y,a=n.z;return this.x=s*a-i*h,this.y=i*r-e*a,this.z=e*h-s*r,this}projectOnVector(t){const n=t.lengthSq();if(n===0)return this.set(0,0,0);const e=t.dot(this)/n;return this.copy(t).multiplyScalar(e)}projectOnPlane(t){return Ot.copy(this).projectOnVector(t),this.sub(Ot)}reflect(t){return this.sub(Ot.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const n=Math.sqrt(this.lengthSq()*t.lengthSq());if(n===0)return Math.PI/2;const e=this.dot(t)/n;return Math.acos(Math.max(-1,Math.min(1,e)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const n=this.x-t.x,e=this.y-t.y,s=this.z-t.z;return n*n+e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromMatrixPosition(t){const n=t.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(t){const n=this.setFromMatrixColumn(t,0).length(),e=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=n,this.y=e,this.z=s,this}setFromMatrixColumn(t,n){return this.fromArray(t.elements,n*4)}setFromMatrix3Column(t,n){return this.fromArray(t.elements,n*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,n=0){return this.x=t[n],this.y=t[n+1],this.z=t[n+2],this}toArray(t=[],n=0){return t[n]=this.x,t[n+1]=this.y,t[n+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,n=Math.random()*2-1,e=Math.sqrt(1-n*n);return this.x=e*Math.cos(t),this.y=n,this.z=e*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};q.ORIGIN=Object.freeze(new q(0,0,0)),q.X_AXIS=Object.freeze(new q(1,0,0)),q.NEGATIVE_X_AXIS=Object.freeze(new q(-1,0,0)),q.Y_AXIS=Object.freeze(new q(0,1,0)),q.NEGATIVE_Y_AXIS=Object.freeze(new q(0,-1,0)),q.Z_AXIS=Object.freeze(new q(0,0,1)),q.NEGATIVE_Z_AXIS=Object.freeze(new q(0,0,-1));let _=q;const Ot=new _,zn=new dt,At=class At{constructor(t,n,e,s,i,r,h,a,c,l,u,d,m,g,y,x){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&n!=null&&e!=null&&s!=null&&i!=null&&r!=null&&h!=null&&a!=null&&c!=null&&l!=null&&u!=null&&d!=null&&m!=null&&g!=null&&y!=null&&x!=null&&this.set(t,n,e,s,i,r,h,a,c,l,u,d,m,g,y,x)}set(t,n,e,s,i,r,h,a,c,l,u,d,m,g,y,x){const f=this.elements;return f[0]=t,f[4]=n,f[8]=e,f[12]=s,f[1]=i,f[5]=r,f[9]=h,f[13]=a,f[2]=c,f[6]=l,f[10]=u,f[14]=d,f[3]=m,f[7]=g,f[11]=y,f[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new At().fromArray(this.elements)}copy(t){const n=this.elements,e=t.elements;return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],this}copyPosition(t){const n=this.elements,e=t.elements;return n[12]=e[12],n[13]=e[13],n[14]=e[14],this}setFromMatrix3(t){const n=t.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}setFromExtrusionDirection(t){if(Pt.equalPoint3d(t,_.Z_AXIS))this.identity();else{const n=new _(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?n.crossVectors(_.Y_AXIS,t).normalize():n.crossVectors(_.Z_AXIS,t).normalize();const e=t.clone().cross(n).normalize();this.set(n.x,n.y,n.z,0,e.x,e.y,e.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,n,e){return t.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),e.setFromMatrixColumn(this,2),this}makeBasis(t,n,e){return this.set(t.x,n.x,e.x,0,t.y,n.y,e.y,0,t.z,n.z,e.z,0,0,0,0,1),this}extractRotation(t){const n=this.elements,e=t.elements,s=1/ot.setFromMatrixColumn(t,0).length(),i=1/ot.setFromMatrixColumn(t,1).length(),r=1/ot.setFromMatrixColumn(t,2).length();return n[0]=e[0]*s,n[1]=e[1]*s,n[2]=e[2]*s,n[3]=0,n[4]=e[4]*i,n[5]=e[5]*i,n[6]=e[6]*i,n[7]=0,n[8]=e[8]*r,n[9]=e[9]*r,n[10]=e[10]*r,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(t){return this.compose(te,t,ne)}lookAt(t,n,e){const s=this.elements;return F.subVectors(t,n),F.lengthSq()===0&&(F.z=1),F.normalize(),H.crossVectors(e,F),H.lengthSq()===0&&(Math.abs(e.z)===1?F.x+=1e-4:F.z+=1e-4,F.normalize(),H.crossVectors(e,F)),H.normalize(),pt.crossVectors(F,H),s[0]=H.x,s[4]=pt.x,s[8]=F.x,s[1]=H.y,s[5]=pt.y,s[9]=F.y,s[2]=H.z,s[6]=pt.z,s[10]=F.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,n){const e=t.elements,s=n.elements,i=this.elements,r=e[0],h=e[4],a=e[8],c=e[12],l=e[1],u=e[5],d=e[9],m=e[13],g=e[2],y=e[6],x=e[10],f=e[14],b=e[3],P=e[7],C=e[11],S=e[15],B=s[0],p=s[4],N=s[8],E=s[12],R=s[1],V=s[5],Y=s[9],J=s[13],v=s[2],Et=s[6],It=s[10],Bt=s[14],kt=s[3],Tt=s[7],Nt=s[11],Rt=s[15];return i[0]=r*B+h*R+a*v+c*kt,i[4]=r*p+h*V+a*Et+c*Tt,i[8]=r*N+h*Y+a*It+c*Nt,i[12]=r*E+h*J+a*Bt+c*Rt,i[1]=l*B+u*R+d*v+m*kt,i[5]=l*p+u*V+d*Et+m*Tt,i[9]=l*N+u*Y+d*It+m*Nt,i[13]=l*E+u*J+d*Bt+m*Rt,i[2]=g*B+y*R+x*v+f*kt,i[6]=g*p+y*V+x*Et+f*Tt,i[10]=g*N+y*Y+x*It+f*Nt,i[14]=g*E+y*J+x*Bt+f*Rt,i[3]=b*B+P*R+C*v+S*kt,i[7]=b*p+P*V+C*Et+S*Tt,i[11]=b*N+P*Y+C*It+S*Nt,i[15]=b*E+P*J+C*Bt+S*Rt,this}multiplyScalar(t){const n=this.elements;return n[0]*=t,n[4]*=t,n[8]*=t,n[12]*=t,n[1]*=t,n[5]*=t,n[9]*=t,n[13]*=t,n[2]*=t,n[6]*=t,n[10]*=t,n[14]*=t,n[3]*=t,n[7]*=t,n[11]*=t,n[15]*=t,this}determinant(){const t=this.elements,n=t[0],e=t[4],s=t[8],i=t[12],r=t[1],h=t[5],a=t[9],c=t[13],l=t[2],u=t[6],d=t[10],m=t[14],g=t[3],y=t[7],x=t[11],f=t[15];return g*(+i*a*u-s*c*u-i*h*d+e*c*d+s*h*m-e*a*m)+y*(+n*a*m-n*c*d+i*r*d-s*r*m+s*c*l-i*a*l)+x*(+n*c*u-n*h*m-i*r*u+e*r*m+i*h*l-e*c*l)+f*(-s*h*l-n*a*u+n*h*d+s*r*u-e*r*d+e*a*l)}transpose(){const t=this.elements;let n;return n=t[1],t[1]=t[4],t[4]=n,n=t[2],t[2]=t[8],t[8]=n,n=t[6],t[6]=t[9],t[9]=n,n=t[3],t[3]=t[12],t[12]=n,n=t[7],t[7]=t[13],t[13]=n,n=t[11],t[11]=t[14],t[14]=n,this}setPosition(t,n,e){const s=this.elements;return t instanceof _?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=n,s[14]=e),this}invert(){const t=this.elements,n=t[0],e=t[1],s=t[2],i=t[3],r=t[4],h=t[5],a=t[6],c=t[7],l=t[8],u=t[9],d=t[10],m=t[11],g=t[12],y=t[13],x=t[14],f=t[15],b=u*x*c-y*d*c+y*a*m-h*x*m-u*a*f+h*d*f,P=g*d*c-l*x*c-g*a*m+r*x*m+l*a*f-r*d*f,C=l*y*c-g*u*c+g*h*m-r*y*m-l*h*f+r*u*f,S=g*u*a-l*y*a-g*h*d+r*y*d+l*h*x-r*u*x,B=n*b+e*P+s*C+i*S;if(B===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const p=1/B;return t[0]=b*p,t[1]=(y*d*i-u*x*i-y*s*m+e*x*m+u*s*f-e*d*f)*p,t[2]=(h*x*i-y*a*i+y*s*c-e*x*c-h*s*f+e*a*f)*p,t[3]=(u*a*i-h*d*i-u*s*c+e*d*c+h*s*m-e*a*m)*p,t[4]=P*p,t[5]=(l*x*i-g*d*i+g*s*m-n*x*m-l*s*f+n*d*f)*p,t[6]=(g*a*i-r*x*i-g*s*c+n*x*c+r*s*f-n*a*f)*p,t[7]=(r*d*i-l*a*i+l*s*c-n*d*c-r*s*m+n*a*m)*p,t[8]=C*p,t[9]=(g*u*i-l*y*i-g*e*m+n*y*m+l*e*f-n*u*f)*p,t[10]=(r*y*i-g*h*i+g*e*c-n*y*c-r*e*f+n*h*f)*p,t[11]=(l*h*i-r*u*i-l*e*c+n*u*c+r*e*m-n*h*m)*p,t[12]=S*p,t[13]=(l*y*s-g*u*s+g*e*d-n*y*d-l*e*x+n*u*x)*p,t[14]=(g*h*s-r*y*s-g*e*a+n*y*a+r*e*x-n*h*x)*p,t[15]=(r*u*s-l*h*s+l*e*a-n*u*a-r*e*d+n*h*d)*p,this}scale(t){const n=this.elements,e=t.x,s=t.y,i=t.z;return n[0]*=e,n[4]*=s,n[8]*=i,n[1]*=e,n[5]*=s,n[9]*=i,n[2]*=e,n[6]*=s,n[10]*=i,n[3]*=e,n[7]*=s,n[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,n=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],e=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(n,e,s))}makeTranslation(t,n,e){return t instanceof _?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,n,0,0,1,e,0,0,0,1),this}makeRotationX(t){const n=Math.cos(t),e=Math.sin(t);return this.set(1,0,0,0,0,n,-e,0,0,e,n,0,0,0,0,1),this}makeRotationY(t){const n=Math.cos(t),e=Math.sin(t);return this.set(n,0,e,0,0,1,0,0,-e,0,n,0,0,0,0,1),this}makeRotationZ(t){const n=Math.cos(t),e=Math.sin(t);return this.set(n,-e,0,0,e,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,n){const e=Math.cos(n),s=Math.sin(n),i=1-e,r=t.x,h=t.y,a=t.z,c=i*r,l=i*h;return this.set(c*r+e,c*h-s*a,c*a+s*h,0,c*h+s*a,l*h+e,l*a-s*r,0,c*a-s*h,l*a+s*r,i*a*a+e,0,0,0,0,1),this}makeScale(t,n,e){return this.set(t,0,0,0,0,n,0,0,0,0,e,0,0,0,0,1),this}makeShear(t,n,e,s,i,r){return this.set(1,e,i,0,t,1,r,0,n,s,1,0,0,0,0,1),this}compose(t,n,e){const s=this.elements,i=n.x,r=n.y,h=n.z,a=n.w,c=i+i,l=r+r,u=h+h,d=i*c,m=i*l,g=i*u,y=r*l,x=r*u,f=h*u,b=a*c,P=a*l,C=a*u,S=e.x,B=e.y,p=e.z;return s[0]=(1-(y+f))*S,s[1]=(m+C)*S,s[2]=(g-P)*S,s[3]=0,s[4]=(m-C)*B,s[5]=(1-(d+f))*B,s[6]=(x+b)*B,s[7]=0,s[8]=(g+P)*p,s[9]=(x-b)*p,s[10]=(1-(d+y))*p,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,n,e){const s=this.elements;let i=ot.set(s[0],s[1],s[2]).length();const r=ot.set(s[4],s[5],s[6]).length(),h=ot.set(s[8],s[9],s[10]).length();this.determinant()<0&&(i=-i),t.x=s[12],t.y=s[13],t.z=s[14],D.copy(this);const c=1/i,l=1/r,u=1/h;return D.elements[0]*=c,D.elements[1]*=c,D.elements[2]*=c,D.elements[4]*=l,D.elements[5]*=l,D.elements[6]*=l,D.elements[8]*=u,D.elements[9]*=u,D.elements[10]*=u,n.setFromRotationMatrix(D),e.x=i,e.y=r,e.z=h,this}equals(t){const n=this.elements,e=t.elements;for(let s=0;s<16;s++)if(n[s]!==e[s])return!1;return!0}fromArray(t,n=0){for(let e=0;e<16;e++)this.elements[e]=t[e+n];return this}toArray(t=[],n=0){const e=this.elements;return t[n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3],t[n+4]=e[4],t[n+5]=e[5],t[n+6]=e[6],t[n+7]=e[7],t[n+8]=e[8],t[n+9]=e[9],t[n+10]=e[10],t[n+11]=e[11],t[n+12]=e[12],t[n+13]=e[13],t[n+14]=e[14],t[n+15]=e[15],t}};At.IDENTITY=Object.freeze(new At);let W=At;const ot=new _,D=new W,te=new _(0,0,0),ne=new _(1,1,1),H=new _,pt=new _,F=new _;class Z{constructor(t=void 0,n=void 0){this.min=t==null?new _(1/0,1/0,1/0):new _(t.x,t.y,t.z),this.max=n==null?new _(-1/0,-1/0,-1/0):new _(n.x,n.y,n.z)}set(t,n){return this.min.copy(t),this.max.copy(n),this}setFromArray(t){this.makeEmpty();for(let n=0,e=t.length;n<e;n+=3)this.expandByPoint(Xt.fromArray(t,n));return this}setFromPoints(t){this.makeEmpty();for(let n=0,e=t.length;n<e;n++)this.expandByPoint(t[n]);return this}setFromCenterAndSize(t,n){const e=Xt.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new Z().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new _(0,0,0):new _(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new _(0,0,0):new _(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,n){return n.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsPlane(t){let n,e;return t.normal.x>0?(n=t.normal.x*this.min.x,e=t.normal.x*this.max.x):(n=t.normal.x*this.max.x,e=t.normal.x*this.min.x),t.normal.y>0?(n+=t.normal.y*this.min.y,e+=t.normal.y*this.max.y):(n+=t.normal.y*this.max.y,e+=t.normal.y*this.min.y),t.normal.z>0?(n+=t.normal.z*this.min.z,e+=t.normal.z*this.max.z):(n+=t.normal.z*this.max.z,e+=t.normal.z*this.min.z),n<=-t.constant&&e>=-t.constant}clampPoint(t,n){return n.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Xt).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:($[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),$[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),$[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),$[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),$[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),$[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),$[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),$[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints($),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const $=[new _,new _,new _,new _,new _,new _,new _,new _],Xt=new _,bn=new T;class O{constructor(t=void 0,n=void 0){this.min=t==null?new T(1/0,1/0):new T(t.x,t.y),this.max=n==null?new T(-1/0,-1/0):new T(n.x,n.y)}set(t,n){return this.min.copy(t),this.max.copy(n),this}setFromPoints(t){this.makeEmpty();for(let n=0,e=t.length;n<e;n++)this.expandByPoint(t[n]);return this}setFromCenterAndSize(t,n){const e=bn.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(e),this.max.copy(t).add(e),this}clone(){return new O().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new T(0,0):new T(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new T(0,0):new T(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,n){return n.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,n){return n.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,bn).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Sn=new _,ee=new _,se=new rt;class mt{constructor(t=new _(1,0,0),n=0){this.normal=t,this.constant=n}set(t,n){return this.normal.copy(t),this.constant=n,this}setComponents(t,n,e,s){return this.normal.set(t,n,e),this.constant=s,this}setFromNormalAndCoplanarPoint(t,n){return this.normal.copy(t),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(t,n,e){const s=Sn.subVectors(e,n).cross(ee.subVectors(t,n)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}projectPoint(t,n){return n.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectsBox(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,n){const e=n||se.getNormalMatrix(t),s=this.coplanarPoint(Sn).applyMatrix4(t),i=this.normal.applyMatrix3(e).normalize();return this.constant=-s.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new mt().copy(this)}}class w extends T{clone(){return new w(this.x,this.y)}static pointArrayToNumberArray(t){const n=new Array(t.length*2);return t.forEach((e,s)=>{e.toArray(n,s*2)}),n}}class z extends _{clone(){return new z(this.x,this.y,this.z)}static pointArrayToNumberArray(t,n=!0){const e=n?3:2,s=new Array(t.length*e);return t.forEach((i,r)=>{i.toArray(s,r*e)}),s}}const Cn=new W,En=new dt,wt=class wt{constructor(t=0,n=0,e=0,s=wt.DEFAULT_ORDER){this._x=t,this._y=n,this._z=e,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,n,e,s=this._order){return this._x=t,this._y=n,this._z=e,this._order=s,this._onChangeCallback(),this}clone(){return new wt(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,n=this._order,e=!0){const s=t.elements,i=s[0],r=s[4],h=s[8],a=s[1],c=s[5],l=s[9],u=s[2],d=s[6],m=s[10];switch(n){case"XYZ":this._y=Math.asin(Q(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-l,m),this._z=Math.atan2(-r,i)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Q(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(h,m),this._z=Math.atan2(a,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(Q(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,m),this._z=Math.atan2(-r,c)):(this._y=0,this._z=Math.atan2(a,i));break;case"ZYX":this._y=Math.asin(-Q(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(a,i)):(this._x=0,this._z=Math.atan2(-r,c));break;case"YZX":this._z=Math.asin(Q(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(h,m));break;case"XZY":this._z=Math.asin(-Q(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(h,i)):(this._x=Math.atan2(-l,m),this._y=0);break}return this._order=n,e===!0&&this._onChangeCallback(),this}setFromQuaternion(t,n,e=!0){return Cn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Cn,n,e)}setFromVector3(t,n=this._order){return this.set(t.x,t.y,t.z,n)}reorder(t){return En.setFromEuler(this),this.setFromQuaternion(En,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],n=0){return t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};wt.DEFAULT_ORDER="XYZ";let Dt=wt;function Yt(o,t,n=!1){const e=o.x,s=o.y;let i=!1;const r=t.length;for(let h=0,a=r-1;h<r;a=h++){const c=t[h].x,l=t[h].y,u=t[a].x,d=t[a].y;let m=l>s!=d>s;n&&(m=l>=s!=d>=s),m&&e<(u-c)*(s-l)/(d-l)+c&&(i=!i)}return i}function In(o,t){if(o.length===0||t.length===0)return!1;const n=new O().setFromPoints(o),e=new O().setFromPoints(t);if(!n.intersectsBox(e))return!1;for(let s=0;s<o.length;){if(Yt(o[s],t,!0))return!0;s<o.length-1&&Pt.equalPoint2d(o[s+1],o[s])&&++s,++s}return!1}const Bn={isPointInPolygon:Yt,isPolygonIntersect:In};function ie(o,t){const n=[],e=t-1,s=o;for(let i=0;i<=s;i++)n.push(0);for(let i=1;i<=e-s;i++)n.push(i);for(let i=0;i<=s;i++)n.push(e-s+1);return n}function re(o,t){const n=t.length-1,e=o,s=[0];let i=0;for(let h=1;h<=n;h++){const a=t[h][0]-t[h-1][0],c=t[h][1]-t[h-1][1],l=t[h][2]-t[h-1][2],u=Math.sqrt(a*a+c*c+l*l);i+=u,s.push(i)}const r=[];for(let h=0;h<=e;h++)r.push(0);for(let h=1;h<=n-e;h++){const a=s[h]/i;r.push(a*(n-e+1))}for(let h=0;h<=e;h++)r.push(n-e+1);return r}function kn(o,t="Uniform"){const n=o.length;if(n===0)return[];if(n===1)return[0];const e=n-1;if(t==="Uniform")return new Array(n).fill(0).map((r,h)=>h/e);const s=[0];let i=0;for(let r=1;r<=e;r++){const h=o[r][0]-o[r-1][0],a=o[r][1]-o[r-1][1],c=o[r][2]-o[r-1][2],l=Math.sqrt(h*h+a*a+c*c),u=t==="SqrtChord"?Math.sqrt(l):l;i+=u,s.push(i)}return i<1e-12?new Array(n).fill(0).map((r,h)=>h/e):s.map(r=>r/i)}function Tn(o,t){const n=t.length-1,e=o,s=n+e+1,i=new Array(s+1).fill(0),r=t[t.length-1];for(let h=s-e;h<=s;h++)i[h]=r;for(let h=1;h<=n-e;h++){let a=0;for(let c=h;c<h+e;c++)a+=t[c];i[h+e]=a/e}return i}function oe(o,t){const n=t.length-1,e=o,s=[0];let i=0;for(let h=1;h<=n;h++){const a=t[h][0]-t[h-1][0],c=t[h][1]-t[h-1][1],l=t[h][2]-t[h-1][2],u=Math.sqrt(a*a+c*c+l*l),d=Math.sqrt(u);i+=d,s.push(i)}const r=[];for(let h=0;h<=e;h++)r.push(0);for(let h=1;h<=n-e;h++){const a=s[h]/i;r.push(a*(n-e+1))}for(let h=0;h<=e;h++)r.push(n-e+1);return r}function Zt(o,t){const n=o.length,e=o.map(r=>r.slice()),s=t.slice();for(let r=0;r<n;r++){let h=r,a=Math.abs(e[r][r]);for(let c=r+1;c<n;c++){const l=Math.abs(e[c][r]);l>a&&(a=l,h=c)}if(a<1e-12)throw new Error("Interpolation matrix is singular.");if(h!==r){const c=e[r];e[r]=e[h],e[h]=c;const l=s[r];s[r]=s[h],s[h]=l}for(let c=r+1;c<n;c++){const l=e[c][r]/e[r][r];if(!(Math.abs(l)<1e-14)){for(let u=r;u<n;u++)e[c][u]-=l*e[r][u];s[c]-=l*s[r]}}}const i=new Array(n).fill(0);for(let r=n-1;r>=0;r--){let h=s[r];for(let a=r+1;a<n;a++)h-=e[r][a]*i[a];i[r]=h/e[r][r]}return i}function Gt(o,t,n="Uniform",e,s){if(o.length===0)return{controlPoints:[],knots:[],weights:[]};const i=o.map(E=>[E[0],E[1],E[2]??0]),r=!!e,h=!!s,a=(r?1:0)+(h?1:0),c=i.length-1,l=c+a;if(l<t)throw new Error("Not enough points to interpolate a curve of this degree.");const u=kn(i,n),d=u.slice();r&&d.unshift(u[0]),h&&d.push(u[u.length-1]);const m=Tn(t,d),g=l+1,y=new Array(g),x=new Array(g),f=new Array(g),b=new Array(g);let P=0;y[P]=new Array(g).fill(0),y[P][0]=1,x[P]=i[0][0],f[P]=i[0][1],b[P]=i[0][2],P++;for(let E=1;E<=c-1;E++){const R=u[E];y[P]=new Array(g).fill(0);for(let V=0;V<=l;V++)y[P][V]=tt(V,t,R,m);x[P]=i[E][0],f[P]=i[E][1],b[P]=i[E][2],P++}if(y[P]=new Array(g).fill(0),y[P][l]=1,x[P]=i[c][0],f[P]=i[c][1],b[P]=i[c][2],P++,r){const E=m[t+1]-m[0],R=E!==0?t/E:0;y[P]=new Array(g).fill(0),y[P][0]=-R,y[P][1]=R,x[P]=(e==null?void 0:e[0])??0,f[P]=(e==null?void 0:e[1])??0,b[P]=(e==null?void 0:e[2])??0,P++}if(h){const E=m[l+t+1]-m[l],R=E!==0?t/E:0;y[P]=new Array(g).fill(0),y[P][l-1]=-R,y[P][l]=R,x[P]=(s==null?void 0:s[0])??0,f[P]=(s==null?void 0:s[1])??0,b[P]=(s==null?void 0:s[2])??0,P++}const C=Zt(y,x),S=Zt(y,f),B=Zt(y,b),p=new Array(g);for(let E=0;E<g;E++)p[E]=[C[E],S[E],B[E]];const N=new Array(g).fill(1);return{controlPoints:p,knots:m,weights:N}}function tt(o,t,n,e){if(t===0)return n>=e[o]&&n<e[o+1]?1:0;const s=e[o+t]-e[o],i=e[o+t+1]-e[o+1],r=s>1e-10?(n-e[o])/s:0,h=i>1e-10?(e[o+t+1]-n)/i:0;return r*tt(o,t-1,n,e)+h*tt(o+1,t-1,n,e)}function gt(o,t,n,e,s){const i=e.length-1,r=t;if(o=Math.max(n[r],Math.min(n[i+1],o)),Math.abs(o-n[i+1])<1e-8)return[...e[i]];if(Math.abs(o-n[r])<1e-8)return[...e[0]];const h=[0,0,0];let a=0;for(let c=0;c<=i;c++){const l=tt(c,r,o,n),u=s[c]*l;h[0]+=e[c][0]*u,h[1]+=e[c][1]*u,h[2]+=e[c][2]*u,a+=u}if(Math.abs(a)<1e-10){const c=n[n.length-r-1];if(Math.abs(o-c)<1e-8)return[...e[i]];if(Math.abs(o-n[r])<1e-8)return[...e[0]]}return Math.abs(a)>=1e-10&&(h[0]/=a,h[1]/=a,h[2]/=a),h}function Qt(o,t,n,e){if(t===0)return 0;const s=e[o+t]-e[o],i=e[o+t+1]-e[o+1];let r=0;return s>1e-10&&(r+=t/s*tt(o,t-1,n,e)),i>1e-10&&(r-=t/i*tt(o+1,t-1,n,e)),r}function he(o,t,n,e){if(t<=1)return 0;const s=e[o+t]-e[o],i=e[o+t+1]-e[o+1];let r=0;return s>1e-10&&(r+=t/s*Qt(o,t-1,n,e)),i>1e-10&&(r-=t/i*Qt(o+1,t-1,n,e)),r}function Nn(o,t,n,e,s){const i=e.length-1,r=t,h=n[r],a=n[i+1];o=Math.max(h,Math.min(a,o));const c=[0,0,0],l=[0,0,0],u=[0,0,0];let d=0,m=0,g=0;for(let B=0;B<=i;B++){const p=tt(B,r,o,n),N=Qt(B,r,o,n),E=he(B,r,o,n),R=s[B],V=R*p,Y=R*N,J=R*E,v=e[B];c[0]+=V*v[0],c[1]+=V*v[1],c[2]+=V*v[2],l[0]+=Y*v[0],l[1]+=Y*v[1],l[2]+=Y*v[2],u[0]+=J*v[0],u[1]+=J*v[1],u[2]+=J*v[2],d+=V,m+=Y,g+=J}if(Math.abs(d)<1e-10)return{point:gt(o,t,n,e,s),deriv1:[0,0,0],deriv2:[0,0,0]};const y=d*d,x=[c[0]/d,c[1]/d,c[2]/d],f=[(l[0]*d-c[0]*m)/y,(l[1]*d-c[1]*m)/y,(l[2]*d-c[2]*m)/y],b=u[0]*d-c[0]*g,P=u[1]*d-c[1]*g,C=u[2]*d-c[2]*g,S=[b/y-2*m*f[0]/d,P/y-2*m*f[1]/d,C/y-2*m*f[2]/d];return{point:x,deriv1:f,deriv2:S}}function Rn(o,t){const n=o[0],e=o[1],s=t[0],i=t[1],r=n*n+e*e;return r<1e-20?0:(n*i-e*s)/Math.pow(r,1.5)}function qn(o,t,n,e){const s=o,i=t[s],r=t[t.length-s-1];let h=0;const a=1e3,c=(r-i)/a;let l=gt(i,o,t,n,e);for(let y=1;y<=a;y++){const x=i+y*c,f=gt(x,o,t,n,e),b=f[0]-l[0],P=f[1]-l[1],C=f[2]-l[2];h+=Math.sqrt(b*b+P*P+C*C),l=f}const u=gt(r,o,t,n,e),d=u[0]-l[0],m=u[1]-l[1],g=u[2]-l[2];return h+=Math.sqrt(d*d+m*m+g*g),h}function ae(o,t=3,n="Uniform",e,s){return o.length===0?[]:Gt(o,t,n,e,s).controlPoints}const Vn=new W,jn=new _,ce=new _,le=new _,Kt=new z;function Ln(o){return new W().setFromExtrusionDirection(new _(o.x,o.y,o.z))}function ue(o){return Vn.setFromExtrusionDirection(new _(o.x,o.y,o.z)),Vn.extractBasis(jn,ce,le),jn.clone()}function de(o,t){return new z(o.x,o.y,o.z??0).applyMatrix4(Ln(t))}function Wt(o,t){return new z(o.x,o.y,o.z??0).applyMatrix4(Ln(t).invert())}function me(o,t,n){const e=Wt(o,n),s=Wt(t,n);return Kt.set(s.x-e.x,s.y-e.y,(s.z??0)-(e.z??0)),M.normalizeAngle(Math.atan2(Kt.y,Kt.x))}class Un{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class $t extends Un{translate(t){return this.transform(new rt().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class ht extends $t{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const n=this.getUtoTmapping(t);return this.getPoint(n)}getPoints(t=5){const n=[];for(let e=0;e<=t;e++)n.push(this.getPoint(e/t));return n}getSpacedPoints(t=5){const n=[];for(let e=0;e<=t;e++)n.push(this.getPointAt(e/t));return n}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const n=[];let e,s=this.getPoint(0),i=0;n.push(0);for(let r=1;r<=t;r++)e=this.getPoint(r/t),i+=e.distanceTo(s),n.push(i),s=e;return n}getUtoTmapping(t,n){const e=this.getLengths();let s=0;const i=e.length;let r;n?r=n:r=t*e[i-1];let h=0,a=i-1,c;for(;h<=a;)if(s=Math.floor(h+(a-h)/2),c=e[s]-r,c<0)h=s+1;else if(c>0)a=s-1;else{a=s;break}if(s=a,e[s]===r)return s/(i-1);const l=e[s],d=e[s+1]-l,m=(r-l)/d;return(s+m)/(i-1)}getTangent(t){let e=t-1e-4,s=t+1e-4;e<0&&(e=0),s>1&&(s=1);const i=this.getPoint(e),r=this.getPoint(s),h=new w;return h.copy(r).sub(i).normalize(),h}getTangentAt(t){const n=this.getUtoTmapping(t);return this.getTangent(n)}}class G extends ht{constructor(t,n,e,s,i){super();const r=+(t!==void 0)+ +(n!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(i!==void 0);if(r==3)typeof t=="object"&&typeof n=="object"&&typeof e=="object"?this.createByThreePoints(t,n,e):this.createByStartEndPointsAndBulge(t,n,e);else if(r==5){const h=t;this.center=new w(h.x,h.y),this.radius=n,this._clockwise=i,this._startAngle=this._clockwise?this._mirrorAngle(M.normalizeAngle(e)):M.normalizeAngle(e),this._endAngle=this._clockwise?this._mirrorAngle(M.normalizeAngle(s)):M.normalizeAngle(s)}else throw j.AcCmErrors.ILLEGAL_PARAMETERS}createByThreePoints(t,n,e){const s=(p,N)=>({x:(p.x+N.x)/2,y:(p.y+N.y)/2}),i=(p,N)=>(N.y-p.y)/(N.x-p.x),r=p=>-1/p,h=s(t,n),a=s(n,e),c=i(t,n),l=i(n,e),u=r(c),d=r(l),m=(p,N,E,R)=>{const V=(R-N)/(p-E),Y=p*V+N;return{x:V,y:Y}},g=h.y-u*h.x,y=a.y-d*a.x,x=m(u,g,d,y),f=Math.sqrt(Math.pow(t.x-x.x,2)+Math.pow(t.y-x.y,2)),b=(p,N)=>Math.atan2(p.y-N.y,p.x-N.x),P=b(t,x),C=b(n,x),S=b(e,x),B=S>P&&S<C||P>S&&P<C||C>S&&C<P;this.center=x,this.radius=f,this._clockwise=!B,this._startAngle=P,this._endAngle=S}createByStartEndPointsAndBulge(t,n,e){let s,i,r;e<0?(s=Math.atan(-e)*4,i=new T(t),r=new T(n)):(s=Math.atan(e)*4,i=new T(n),r=new T(t));const h=new T().subVectors(r,i),a=h.length(),c=new T().addVectors(i,h.multiplyScalar(.5)),l=Math.abs(a/2/Math.tan(s/2)),u=h.normalize(),d=e<0?-Math.PI/2:Math.PI/2,m=new T(u.x*Math.cos(d)-u.y*Math.sin(d),u.y*Math.cos(d)+u.x*Math.sin(d));let g;s<Math.PI?e<0?g=c.add(m.multiplyScalar(l)):g=c.add(m.multiplyScalar(-l)):e<0?g=c.add(m.multiplyScalar(-l)):g=c.add(m.multiplyScalar(l)),e<0?(this._startAngle=Math.atan2(i.y-g.y,i.x-g.x),this._endAngle=Math.atan2(r.y-g.y,r.x-g.x)):(this._startAngle=Math.atan2(r.y-g.y,r.x-g.x),this._endAngle=Math.atan2(i.y-g.y,i.x-g.x)),this._clockwise=e<0,this.center=g,this.radius=r.sub(g).length()}get center(){return this._center}set center(t){this._center=new w(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==I?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 i of n){const r=this._getInternalAngle(i);M.isBetweenAngle(r,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(i))}const e=t.map(i=>i.x),s=t.map(i=>i.y);return new O(new w(Math.min(...e),Math.min(...s)),new w(Math.max(...e),Math.max(...s)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){const n=t,e=this.center.clone().applyMatrix2d(n),s=this.startPoint.clone().applyMatrix2d(n);if(this.closed)return this.center=e,this.radius=e.distanceTo(s),this._startAngle=Math.atan2(s.y-e.y,s.x-e.x),this._endAngle=this._startAngle,this._clockwise=n.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;const i=this.midPoint.clone().applyMatrix2d(n),r=this.endPoint.clone().applyMatrix2d(n),h=new G(s,i,r),a=n.determinant()<0?!this.clockwise:this.clockwise,c=l=>{const u=M.normalizeAngle(l);return a?this._mirrorAngle(u):u};return this.center=h.center,this.radius=h.radius,this.clockwise=a,this.startAngle=c(Math.atan2(s.y-h.center.y,s.x-h.center.x)),this.endAngle=c(Math.atan2(r.y-h.center.y,r.x-h.center.x)),this._boundingBoxNeedsUpdate=!0,this}clone(){return new G(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const n=this._getInternalAngle(t),e=this.center.x+this.radius*Math.cos(n),s=this.center.y+this.radius*Math.sin(n);return new w(e,s)}getQuadrantPoints(){const t=[],n=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle),s=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const i of s){const r=this._getInternalAngle(i);M.isBetweenAngle(r,n,e,this.clockwise)&&t.push(this.getPointAtAngle(i))}return t}nearestPoint(t){const n=new w(t.x,t.y),e=n.x-this.center.x,s=n.y-this.center.y;if(Math.hypot(e,s)<1e-12)return this.startPoint.clone();const r=Math.atan2(s,e),h=this.clockwise?this._mirrorAngle(M.normalizeAngle(r)):M.normalizeAngle(r),a=this._getInternalAngle(h),c=this._getInternalAngle(this.startAngle),l=this._getInternalAngle(this.endAngle);if(M.isBetweenAngle(a,c,l,this.clockwise))return this.getPointAtAngle(h);const u=n.distanceToSquared(this.startPoint),d=n.distanceToSquared(this.endPoint);return u<=d?this.startPoint.clone():this.endPoint.clone()}getPoints(t=100){const n=[];let e=this.deltaAngle,s=this._getInternalAngle(this.startAngle);if(this.closed&&(e=I,s=0),this.clockwise)for(let i=0;i<=t;i++){const r=s-e*(i/t),h=this._clockwise?this._mirrorAngle(r):r,a=this.getPointAtAngle(h);n.push(new w(a.x,a.y))}else for(let i=0;i<=t;i++){const r=s+e*(i/t),h=this._clockwise?this._mirrorAngle(r):r,a=this.getPointAtAngle(h);n.push(new w(a.x,a.y))}return n}}const Mt=1e-6;function vn(o,t){if(qe(o)){const i=ye(o,t);return i?[i]:[]}const n=Zn(o);if(n.numberOfVertices<2)return[];const s=je(n,t);return s?[s]:[]}function ge(o){return Zn(o)}function ye(o,t){const n=xe(o);if(n.length===0)return null;const e=[];for(const h of n){const a=fe(h,t);if(!a)return null;e.push(a)}const s=_e(o),i=pe(e,s,o.closed,t);if(i.length<2)return null;const r=new nt;return i.forEach((h,a)=>{r.addVertexAt(a,{x:h.x,y:h.y})}),r.closed=o.closed,r}function xe(o){const t=[],n=o.numberOfVertices,e=o.closed?n:n-1;for(let s=0;s<e;s++){const i=o.vertices[s],r=o.vertices[(s+1)%n];k.isPositive(Math.abs(i.bulge??0))?t.push({kind:"arc",arc:new G(i,r,i.bulge)}):t.push({kind:"line",start:new w(i.x,i.y),end:new w(r.x,r.y)})}return t}function _e(o){const t=[];for(let n=0;n<o.numberOfVertices;n++)t.push(o.getPointAt(n));return t}function fe(o,t){if(o.kind==="line"){const e=Pe(o.start,o.end,t);return e?{kind:"line",...e}:null}const n=Ae(o.arc,o.arc.startPoint,o.arc.endPoint,t);return n?{kind:"arc",arc:n}:null}function Ae(o,t,n,e){const s=we(o,t,n,e),i=o.radius+s;return k.isNonPositive(i)?null:new G(o.center,i,o.startAngle,o.endAngle,o.clockwise)}function we(o,t,n,e){const s=n.x-t.x,i=n.y-t.y,r=Math.hypot(s,i);if(k.isNonPositive(r))return o.clockwise?-e:e;const h=-i/r,a=s/r,c=o.center.x-(t.x+n.x)/2,l=o.center.y-(t.y+n.y)/2;return c*h+l*a>0?-e:e}function Pe(o,t,n){const e=t.x-o.x,s=t.y-o.y,i=Math.hypot(e,s);if(k.isNonPositive(i))return null;const r=-s/i*n,h=e/i*n;return{start:new w(o.x+r,o.y+h),end:new w(t.x+r,t.y+h),dx:e,dy:s}}function pe(o,t,n,e){var h;const s=o.length;if(s===0)return[];const i=Me(o,t,n,e),r=[((h=i[0].nextSegmentStart)==null?void 0:h.clone())??i[0].point.clone()];for(let a=0;a<s;a++){const c=o[a],l=a===s-1&&!n?{point:Ee(c)}:i[(a+1)%s];if(a>0&&i[a].filletPoints&&i[a].filletPoints.forEach(u=>r.push(u.clone())),c.kind==="arc"){const u=i[a].nextSegmentStart??i[a].point,d=l.point,m=ze(c.arc,u,d,Math.max(16,32));for(let g=1;g<m.length;g++)r.push(m[g])}else r.push(l.point.clone())}return Gn(r)}function Me(o,t,n,e){const s=o.length,i=[];for(let r=0;r<s;r++)r===0?i.push(n?Fn(o[s-1],o[0],t[0],e):{point:Ce(o[0])}):i.push(Fn(o[r-1],o[r],t[r],e));return i}function ze(o,t,n,e){const s=o.nearestPoint(t),i=o.nearestPoint(n),r=Jt(o,s),h=Jt(o,i),a=Se(o,r,h),c=[];for(let l=0;l<=e;l++){const u=l/e,d=o.clockwise?r-a*u:r+a*u;c.push(o.getPointAtAngle(be(o,d)))}return c}function Jt(o,t){return Math.atan2(t.y-o.center.y,t.x-o.center.x)}function be(o,t){const n=M.normalizeAngle(t);return o.clockwise?Ht(n):n}function Ht(o){return(360-o*180/Math.PI)%360*(Math.PI/180)}function Se(o,t,n){if(o.clockwise){let s=t-n;return k.isNonPositive(s)&&(s+=I),s}let e=n-t;return k.isNonPositive(e)&&(e+=I),e}function Ce(o){return o.kind==="line"?o.start.clone():o.arc.startPoint.clone()}function Ee(o){return o.kind==="line"?o.end.clone():o.arc.endPoint.clone()}function Fn(o,t,n,e){return o.kind==="line"&&t.kind==="line"?{point:tn({start:o.start,end:o.end,dx:o.dx,dy:o.dy},{start:t.start,end:t.end,dx:t.dx,dy:t.dy})}:o.kind==="line"&&t.kind==="arc"?On(o,t.arc,n,e,!0):o.kind==="arc"&&t.kind==="line"?On(t,o.arc,n,e,!1):o.kind==="arc"&&t.kind==="arc"?Ie(o.arc,t.arc,n,e):{point:n.clone()}}function Ie(o,t,n,e){const s=Yn(o.endPoint,t.startPoint),r=Re(o,t).filter(l=>zt(o,l)&&zt(t,l));if(r.length>0)return{point:Dn(r,s)};const h=o.endPoint.clone(),a=t.startPoint.clone(),c=Xn(n,Math.abs(e),h,a);return{point:h,filletPoints:c,nextSegmentStart:a}}function On(o,t,n,e,s){const i=Yn(s?o.end:o.start,s?t.startPoint:t.endPoint),r=Ne(o,t,i);if(ke(o,r)&&zt(t,r))return{point:r};const h=Be(o,n,e),a=s?t.startPoint.clone():t.endPoint.clone(),c=Xn(n,Math.abs(e),s?h:a,s?a:h);return s?{point:h,filletPoints:c,nextSegmentStart:a}:{point:a,filletPoints:c,nextSegmentStart:h}}function Be(o,t,n){const e=Math.hypot(o.dx,o.dy),s=-o.dy/e*n,i=o.dx/e*n;return new w(t.x+s,t.y+i)}function ke(o,t){const n=Math.hypot(o.dx,o.dy);if(k.isNonPositive(n))return!1;const e=o.dx/n,s=o.dy/n,i=t.x-o.start.x,r=t.y-o.start.y,h=Math.abs(i*s-r*e);return k.equalToZero(h)}function Xn(o,t,n,e){const s=Math.atan2(n.y-o.y,n.x-o.x),i=Math.atan2(e.y-o.y,e.x-o.x),r=Te(s,i);if(k.equalToZero(Math.abs(r)))return[];const h=[],a=Math.max(2,Math.ceil(Math.abs(r)/Math.PI*16));for(let c=1;c<a;c++){const l=c/a,u=s+r*l;h.push(new w(o.x+t*Math.cos(u),o.y+t*Math.sin(u)))}return h}function Te(o,t){let n=t-o;for(;n>Math.PI;)n-=I;for(;n<=-Math.PI;)n+=I;return n}function Ne(o,t,n){const e=Math.hypot(o.dx,o.dy);if(k.isNonPositive(e))return n.clone();const s=o.dx/e,i=o.dy/e,r=o.start.x-t.center.x,h=o.start.y-t.center.y,a=2*(r*s+h*i),c=r*r+h*h-t.radius*t.radius,l=a*a-4*c;if(l<0)return n.clone();const u=Math.sqrt(l),d=[(-a-u)/2,(-a+u)/2].map(g=>new w(o.start.x+s*g,o.start.y+i*g)),m=d.filter(g=>zt(t,g));return Dn(m.length>0?m:d,n)}function zt(o,t){const n=Math.abs(Math.hypot(t.x-o.center.x,t.y-o.center.y)-o.radius);if(k.isPositive(n))return!1;const e=Jt(o,t),s=o.clockwise?Ht(M.normalizeAngle(o.startAngle)):M.normalizeAngle(o.startAngle),i=o.clockwise?Ht(M.normalizeAngle(o.endAngle)):M.normalizeAngle(o.endAngle);return M.isBetweenAngle(e,s,i,o.clockwise)}function Re(o,t){const n=t.center.x-o.center.x,e=t.center.y-o.center.y,s=Math.hypot(n,e);if(k.isNonPositive(s))return[];const i=o.radius+t.radius,r=Math.abs(o.radius-t.radius);if(s>i+Mt)return[];if(s<r-Mt)return[];const h=(o.radius*o.radius-t.radius*t.radius+s*s)/(2*s),a=o.radius*o.radius-h*h;if(a<-Mt)return[];const c=o.center.x+h*n/s,l=o.center.y+h*e/s;if(a<=Mt)return[new w(c,l)];const u=Math.sqrt(a),d=-e*u/s,m=n*u/s;return[new w(c+d,l+m),new w(c-d,l-m)]}function Dn(o,t){let n=o[0],e=n.distanceToSquared(t);for(let s=1;s<o.length;s++){const i=o[s].distanceToSquared(t);i<e&&(n=o[s],e=i)}return n.clone()}function Yn(o,t){return new w((o.x+t.x)/2,(o.y+t.y)/2)}function qe(o){const t=o.numberOfVertices,n=o.closed?t:t-1;for(let e=0;e<n;e++){const s=o.vertices[e];if(k.isPositive(Math.abs(s.bulge??0)))return!0}return!1}function Zn(o){const t=Ve(o.vertices.map(n=>new w(n.x,n.y)),o.closed);return t.length===o.numberOfVertices?o:new nt(t.map(n=>({x:n.x,y:n.y})),o.closed)}function Ve(o,t){const n=Gn(o);if(!t||n.length<2)return n;const e=n[0],s=n[n.length-1];return k.isNonPositive(Math.hypot(e.x-s.x,e.y-s.y))&&n.pop(),n}function Gn(o){const t=[];return o.forEach(n=>{const e=t[t.length-1];(!e||k.isPositive(Math.hypot(e.x-n.x,e.y-n.y)))&&t.push(new w(n.x,n.y))}),t}function je(o,t){const n=[];for(let r=0;r<o.numberOfVertices;r++)n.push(o.getPointAt(r));const e=Le(n,o.closed,t);if(e.length===0)return null;const s=[];if(o.closed){if(e.length<2)return null;const r=e.length;for(let h=0;h<r;h++){const a=e[(h-1+r)%r],c=e[h];s.push(tn(a,c))}}else{s.push(e[0].start);for(let r=1;r<e.length;r++)s.push(tn(e[r-1],e[r]));s.push(e[e.length-1].end)}const i=new nt;return s.forEach((r,h)=>{i.addVertexAt(h,{x:r.x,y:r.y})}),i.closed=o.closed,i}function Le(o,t,n){const e=[],s=t?o.length:o.length-1;for(let i=0;i<s;i++){const r=o[i],h=o[t?(i+1)%o.length:i+1],a=h.x-r.x,c=h.y-r.y,l=Math.hypot(a,c);if(k.isNonPositive(l))continue;const u=-c/l*n,d=a/l*n;e.push({start:new w(r.x+u,r.y+d),end:new w(h.x+u,h.y+d),dx:a,dy:c})}return e}function tn(o,t){const n=o.dx*t.dy-o.dy*t.dx;if(k.equalToZero(n))return new w((o.end.x+t.start.x)/2,(o.end.y+t.start.y)/2);const e=t.start.x-o.start.x,s=t.start.y-o.start.y,i=(e*t.dy-s*t.dx)/n;return new w(o.start.x+i*o.dx,o.start.y+i*o.dy)}class nt extends ht{constructor(t=null,n=!1){super(),this._vertices=t||new Array,this._closed=n}get vertices(){return this._vertices}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new w(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 w(n.x,n.y)}else{const n=this._vertices[t-1];return new w(n.x,n.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let t=0;const n=this._vertices.length;for(let e=0;e<n;++e){const s=this._vertices[e];let i=null;if(e<n-1?i=this._vertices[e+1]:e==n-1&&this.closed&&(i=this._vertices[0]),i)if(s.bulge){const r=new G(s,i,s.bulge);t+=r.length}else t+=new w(s.x,s.y).distanceTo(i)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,n){t<=0?this._vertices.unshift(n):this._vertices.splice(t,0,n),this._boundingBoxNeedsUpdate=!0}removeVertexAt(t){if(t<0||t>=this._vertices.length)throw new Error(`Index ${t} is out of bounds. Valid range is 0 to ${this._vertices.length-1}.`);this._vertices.splice(t,1),this._boundingBoxNeedsUpdate=!0}reset(t,n){t?n!==void 0&&n>=0&&n<this._vertices.length&&(this._vertices=this._vertices.slice(0,n),this._boundingBoxNeedsUpdate=!0):(this._vertices=new Array,this._boundingBoxNeedsUpdate=!0)}getPointAt(t){const n=this._vertices[t];return new w(n.x,n.y)}calculateBoundingBox(){const t=this.getPoints(100);return new O().setFromPoints(t)}transform(t){const n=t.determinant()<0;return this._vertices.forEach(e=>{const s=new w(e).applyMatrix2d(t);e.x=s.x,e.y=s.y,n&&e.bulge!=null&&(e.bulge=-e.bulge)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new nt(this._vertices.map(t=>({...t})),this._closed)}getPoints3d(t,n){const e=[];return this.getPoints(t).forEach(i=>e.push(new z().set(i.x,i.y,n))),e}getPoints(t){const n=[],e=this._vertices.length;for(let s=0;s<e;++s){const i=this._vertices[s];if(i.bulge){let r=null;if(s<e-1?r=this._vertices[s+1]:s==e-1&&this.closed&&(r=this._vertices[0]),r){const a=new G(i,r,i.bulge).getPoints(t),c=a.length;for(let l=0;l<c;++l){const u=a[l];n.push(new w(u.x,u.y))}}}else n.push(new w(i.x,i.y)),s==e-1&&this.closed&&n.push(n[0])}return n}offset(t){return vn(this,t)}}function Ue(o,t,n){const e=Math.hypot(t.x,t.y);if(k.isNonPositive(e))return null;const s=-t.y/e*n,i=t.x/e*n;return new z(o.x+s,o.y+i,o.z)}function ve(o,t,n){if(o.length<2)return null;const e=ge(new nt(o.map(i=>({x:i.x,y:i.y})),t));return vn(e,n)[0]??null}function Fe(o,t,n,e){if(o.length<2||k.equalToZero(n))return null;const{points:s,tangents:i}=Kn(o,e);if(s.length<2)return null;const r=i??Oe(s,t),h=Xe(s,r,n),a=t?Ye(h):De(h);if(a.length<2)return null;const c=new nt;return a.forEach((l,u)=>{c.addVertexAt(u,{x:l.x,y:l.y})}),c.closed=t,c}function Oe(o,t){const n=o.length,e=new Array(n);for(let s=0;s<n;s++){let i=0,r=0;if(t){const a=o[(s-1+n)%n],c=o[(s+1)%n];i=c.x-a.x,r=c.y-a.y}else s===0?(i=o[1].x-o[0].x,r=o[1].y-o[0].y):s===n-1?(i=o[n-1].x-o[n-2].x,r=o[n-1].y-o[n-2].y):(i=o[s+1].x-o[s-1].x,r=o[s+1].y-o[s-1].y);const h=Math.hypot(i,r);k.isNonPositive(h)?e[s]=new w(1,0):e[s]=new w(i/h,r/h)}return e}function Xe(o,t,n){return o.map((e,s)=>{const i=t[s],r=-i.y*n,h=i.x*n;return new w(e.x+r,e.y+h)})}function De(o){let t=bt(o);if(t.length<3)return t;for(;;){const n=Qn(t,!1);if(!n||(t=bt([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<2))break}return t}function Ye(o){let t=bt(o);if(t.length<4)return t;for(;;){const n=Qn(t,!0);if(!n||(t=bt([...t.slice(0,n.segmentA+1),n.point,...t.slice(n.segmentB+1)]),t.length<3))break}return t}function Qn(o,t){const n=t?o.length:o.length-1;if(n<2)return null;for(let e=0;e<n;e++){const s=o[e],i=o[(e+1)%o.length];for(let r=e+1;r<n;r++){if(Ze(e,r,n,t))continue;const h=o[r],a=o[(r+1)%o.length],c=Ge(s,i,h,a);if(c)return{point:c,segmentA:e,segmentB:r}}}return null}function Ze(o,t,n,e){return!!(t===o||t===o+1||e&&o===0&&t===n-1)}function Ge(o,t,n,e){const s=t.x-o.x,i=t.y-o.y,r=e.x-n.x,h=e.y-n.y,a=s*h-i*r;if(k.equalToZero(a))return null;const c=n.x-o.x,l=n.y-o.y,u=(c*h-l*r)/a,d=(c*i-l*s)/a,m=Pt.equalPointTol;return u<-m||u>1+m||d<-m||d>1+m?null:new w(o.x+u*s,o.y+u*i)}function Kn(o,t){const n=[],e=[],s=t!=null&&t.length===o.length;return o.forEach((i,r)=>{const h=n[n.length-1];if((!h||k.isPositive(Math.hypot(h.x-i.x,h.y-i.y)))&&(n.push(new w(i.x,i.y)),s)){const a=t[r];e.push(new w(a.x,a.y))}}),{points:n,tangents:s?e:void 0}}function bt(o){return Kn(o).points}class nn extends $t{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new O}transform(t){return this._loops.forEach(n=>{n.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){const t=new nn;return this._loops.forEach(n=>{t.add(n.clone())}),t}getPoints(t){const n=[];for(let e=0;e<this.loops.length;++e){const i=this.loops[e].getPoints(t);n.push(i)}return n}buildHierarchy(){var h;const t=this.getPoints(100),n=this.calculateBoundaryBoxes(t),e=this.sortBoundaryBoxesByAreas(n),s=new Map,i=e.length;for(let a=0;a<i;a++)s.set(e[a],{index:e[a],children:[]});const r={index:-1,children:[]};for(let a=0;a<i;a++){const c=e[a],l=t[c],u=n[c];let d=a+1;for(;d<i;d++){const m=e[d],g=t[m];if(n[m].containsBox(u)&&Bn.isPointInPolygon(l[M.randInt(0,l.length-1)],g)){(h=s.get(m))==null||h.children.push(s.get(c));break}}d===i&&r.children.push(s.get(c))}return r}get area(){if(this._loops.length===0)return 0;let t=0;for(let n=0;n<this._loops.length;n++){const s=this._loops[n].getPoints(128),i=this.polygonArea(s);n===0?t+=Math.abs(i):t-=Math.abs(i)}return t}polygonArea(t){const n=t.length;if(n<3)return 0;let e=0;for(let s=0,i=n-1;s<n;i=s++){const r=t[i],h=t[s];e+=r.x*h.y-h.x*r.y}return e*.5}calculateBoundaryBoxes(t){const n=[];return t.forEach(e=>{n.push(new O().setFromPoints(e))}),n}sortBoundaryBoxesByAreas(t){const n=[];t.forEach((s,i)=>{const r=s.size,h=r.width*r.height;n.push({area:h,index:i})}),n.sort((s,i)=>s.area-i.area);const e=[];return n.forEach(s=>{e.push(s.index)}),e}}class Qe extends Un{translate(t){return this.transform(new W().makeTranslation(t.x,t.y,t.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class yt extends Qe{}class at extends yt{constructor(t,n){super(),this._start=new 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 _().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(st).normalize();return new z(this._start).addScaledVector(e,t)}else{const e=this.delta(st).normalize();return new z(this._end).addScaledVector(e,t)}}extend(t,n=!1){if(n){const e=st.subVectors(this._start,this._end).normalize();this._start=new z(this._start).addScaledVector(e,t)}else{const e=this.delta(st).normalize();this._end=new z(this._end).addScaledVector(e,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,n){Wn.subVectors(t,this._start),St.subVectors(this.endPoint,this.startPoint);const e=St.dot(St);let i=St.dot(Wn)/e;return n&&(i=M.clamp(i,0,1)),i}closestPointToPoint(t,n,e){const s=this.closestPointToPointParameter(t,n);return this.delta(e).multiplyScalar(s).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const n=this.direction,s=st.subVectors(t,this.startPoint).dot(n);return new z().copy(n).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const n=this.direction,e=this.startPoint,i=st.subVectors(t,e).dot(n),r=st.copy(n).multiplyScalar(i);return new z().addVectors(e,r)}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 Z(t,n)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new at(this._start.clone(),this._end.clone())}offset(t){const n=this.startPoint,e=this.endPoint;if(Math.hypot(e.x-n.x,e.y-n.y)===0)return this.clone();const i=new _(e.x-n.x,e.y-n.y,0).normalize(),r=new _(-i.y,i.x,0);return new at(new z(n.x+r.x*t,n.y+r.y*t,n.z),new z(e.x+r.x*t,e.y+r.y*t,e.z))}}const st=new _,Wn=new _,St=new _;class ct extends yt{static computeCenterPoint(t,n,e){const s=new _().addVectors(t,n).multiplyScalar(.5),i=new _().addVectors(t,e).multiplyScalar(.5),r=new _().subVectors(n,t),h=new _().subVectors(e,t),a=new _().crossVectors(r,h).normalize();if(a.lengthSq()===0)return null;const c=new _().crossVectors(r,a).normalize(),l=new _().crossVectors(h,a).normalize(),u=c.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),d=l.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),m=new at(s,s.clone().add(u)),g=new at(i,i.clone().add(d)),y=new _;return m.closestPointToPoint(g.startPoint,!0,y)?y:null}static createByThreePoints(t,n,e){const s=ct.computeCenterPoint(t,n,e);if(s){const i=s.distanceTo(t),r=new _().subVectors(t,s),h=new _().subVectors(n,s),a=Math.atan2(r.y,r.x),c=Math.atan2(h.y,h.x);return new ct(s,i,a,c,_.Z_AXIS)}}constructor(t,n,e,s,i,r=_.X_AXIS){super(),this.center=t,this.radius=n,this.startAngle=e,this.endAngle=s,this.normal=i,this.refVec=r,(s-e)%I==0?(this.startAngle=0,this.endAngle=I):(this.startAngle=e,this.endAngle=s)}get center(){return this._center}set center(t){this._center=new 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==I?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 _(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new _(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,n=this.deltaAngle;this.closed&&(t=0,n=I);const e=t+n*.5;return this.getPointAtAngle(e)}get length(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)}get area(){return this.closed?Math.PI*this.radius*this.radius:Math.abs(this.deltaAngle*this.radius*this.radius)}nearestPoint(t){const n=new _(t.x,t.y,t.z||0),e=this.center,s=this.normal,r=n.clone().sub(e).dot(s),a=n.clone().sub(s.clone().multiplyScalar(r)).clone().sub(e);if(a.lengthSq()===0)return this.startPoint.clone();a.normalize().multiplyScalar(this.radius);const c=e.clone().add(a),l=this.getAngle(c.clone()),u=this.startAngle,d=this.deltaAngle;let m=M.normalizeAngle(l-u);m<0&&(m=0),m>d&&(m=d);const g=this.getPointAtAngle(u+m),y=g.distanceTo(n),x=this.startPoint.distanceTo(n),f=this.endPoint.distanceTo(n);return x<y&&x<=f?this.startPoint.clone():f<y&&f<x?this.endPoint.clone():g}tangentPoints(t){const n=[],e=new _(t.x,t.y,t.z||0),s=this.center,i=this.normal,r=this.radius,a=e.clone().sub(s).dot(i),c=e.clone().sub(i.clone().multiplyScalar(a)),l=s.clone(),d=c.clone().sub(l).length();if(d<r)return n;const m=Math.acos(r/d),g=this.getAngle(c.clone()),y=[g+m,g-m];for(const x of y){const f=M.normalizeAngle(x-this.startAngle);f>=0&&f<=this.deltaAngle&&n.push(this.getPointAtAngle(this.startAngle+f))}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,s=1/0,i=-1/0,r=-1/0,h=-1/0;for(const a of t){const c=this.getPointAtAngle(a);c.x<n&&(n=c.x),c.y<e&&(e=c.y),c.z<s&&(s=c.z),c.x>i&&(i=c.x),c.y>r&&(r=c.y),c.z>h&&(h=c.z)}return new Z({x:n,y:e,z:s},{x:i,y:r,z:h})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const n=[];let e=this.deltaAngle,s=this.startAngle;this.closed&&(e=I,s=0);for(let i=0;i<=t;i++){const r=s+e*(i/t),h=this.getPointAtAngle(r);n.push(h)}return n}transform(t){const n=this.center.clone().applyMatrix4(t),e=this.startPoint.clone().applyMatrix4(t),s=this.endPoint.clone().applyMatrix4(t),i=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(t),r=new _(e).sub(n).normalize(),h=n.distanceTo(e);let a=new _().crossVectors(new _(e).sub(n),new _(i).sub(n)).normalize();a.lengthSq()===0&&(a=this.normal.clone().transformDirection(t));const c=l=>{const u=new _(l).sub(n);return Math.atan2(u.dot($n.crossVectors(a,r)),u.dot(r))};return this.center=n,this.radius=h,this.normal=a,this.refVec=r,this.startAngle=0,this.endAngle=this.closed?I:c(s),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new ct(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot($n.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const n=this.normal,e=this.refVec,s={x:n.y*e.z-n.z*e.y,y:n.z*e.x-n.x*e.z,z:n.x*e.y-n.y*e.x},i=this.center,r=this.radius;return new z(i.x+r*(e.x*Math.cos(t)+s.x*Math.sin(t)),i.y+r*(e.y*Math.cos(t)+s.y*Math.sin(t)),i.z+r*(e.z*Math.cos(t)+s.z*Math.sin(t)))}get plane(){const t=new _(this.center).distanceTo(Ft);return new mt(this.normal,t)}offset(t){const n=this.radius+t;return n<=0?null:new ct(this.center,n,this.startAngle,this.endAngle,this.normal,this.refVec)}}const $n=new _;class it extends ht{constructor(t,n,e,s=0,i=I,r=!1,h=0){super(),this.center=t,this.majorAxisRadius=n,this.minorAxisRadius=e,(i-s)%I==0?(this.startAngle=0,this.endAngle=I):(this.startAngle=s,this.endAngle=i),this.clockwise=r,this.rotation=h}get center(){return this._center}set center(t){this._center=new 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==I?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,s=-1/0,i=-1/0;for(let r=0;r<=100;r++){const h=this.getPoint(r/100);n=Math.min(n,h.x),e=Math.min(e,h.y),s=Math.max(s,h.x),i=Math.max(i,h.y)}return new O({x:n,y:e},{x:s,y:i})}get closed(){return this.deltaAngle==0}getPoint(t){const n=Math.PI*2;let e=this.endAngle-this.startAngle;const s=Math.abs(e)<Number.EPSILON;for(;e<0;)e+=n;for(;e>n;)e-=n;e<Number.EPSILON&&(s?e=0:e=n),this.clockwise===!0&&!s&&(e===n?e=-n:e=e-n);const i=this.startAngle+t*e;let r=this.center.x+this.majorAxisRadius*Math.cos(i),h=this.center.y+this.minorAxisRadius*Math.sin(i);if(this.rotation!==0){const a=Math.cos(this.rotation),c=Math.sin(this.rotation),l=r-this.center.x,u=h-this.center.y;r=l*a-u*c+this.center.x,h=l*c+u*a+this.center.y}return new w(r,h)}transform(t){const n=t,e=new w(this.center).applyMatrix2d(n),s=new z(e.x,e.y,this.center.z),i=this.getPointAtAngle(0).clone().applyMatrix2d(n),r=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(n),h=new w(i).sub(e),a=new w(r).sub(e),c=h.length(),l=a.length(),u=Math.atan2(h.y,h.x),d=h.clone().normalize(),m=a.clone().normalize(),g=f=>{const b=new w(f).sub(e),P=b.dot(d),C=b.dot(m);return M.normalizeAngle(Math.atan2(C/l,P/c))},y=n.determinant()<0?!this.clockwise:this.clockwise,x=this.closed?new it(s,c,l,0,I,y,u):new it(s,c,l,g(this.startPoint.clone().applyMatrix2d(n)),g(this.endPoint.clone().applyMatrix2d(n)),y,u);return this.center=x.center,this.majorAxisRadius=x.majorAxisRadius,this.minorAxisRadius=x.minorAxisRadius,this._startAngle=x._startAngle,this._endAngle=x._endAngle,this._clockwise=x._clockwise,this.rotation=x.rotation,this._boundingBoxNeedsUpdate=!0,this}getPointAtAngle(t){return this.getPoint(this.closed?t/I: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 it(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}getFocusPoints(){const t=Math.max(this.majorAxisRadius,this.minorAxisRadius),n=Math.min(this.majorAxisRadius,this.minorAxisRadius);if(t-n<1e-9)return[];const e=Math.sqrt(t*t-n*n),s=Math.cos(this.rotation),i=Math.sin(this.rotation),r=this.majorAxisRadius>=this.minorAxisRadius,h=r?s:-i,a=r?i:s;return[new w(this.center.x-e*h,this.center.y-e*a),new w(this.center.x+e*h,this.center.y+e*a)]}getQuadrantPoints(){return this.closed?[this.getPoint(0),this.getPoint(.25),this.getPoint(.5),this.getPoint(.75)]:[]}nearestPoint(t){const n=new w(t.x,t.y);let e=this.getPoint(0),s=n.distanceToSquared(e);const i=72;for(let r=1;r<=i;r++){const h=this.getPoint(r/i),a=n.distanceToSquared(h);a<s&&(s=a,e=h)}return e}}class lt extends yt{constructor(t,n,e,s,i,r=0,h=I){super(),this.center=t,this.normal=n,this.majorAxis=e,this.majorAxisRadius=s,this.minorAxisRadius=i;const a=Math.abs(h-r);Math.abs(a-I)<1e-10||Math.abs(a-2*I)<1e-10?(this.startAngle=0,this.endAngle=I):(this.startAngle=r,this.endAngle=h)}get center(){return this._center}set center(t){this._center=new 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==I?t:M.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-I)<1e-10?I: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 _(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new _(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new _().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,n=this.deltaAngle;(this.closed||Math.abs(n-I)<1e-10)&&(t=0,n=I);const e=t+n/2;return this.getPointAtAngle(e)}get isCircular(){return k.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const t=1e3,n=this.deltaAngle/t;let e=0,s=this.getPointAtAngle(this.startAngle);for(let i=1;i<=t;i++){const r=this.startAngle+i*n,h=this.getPointAtAngle(r),a=h.x-s.x,c=h.y-s.y,l=h.z-s.z;e+=Math.sqrt(a*a+c*c+l*l),s=h}return e}get area(){const t=this.majorAxisRadius,n=this.minorAxisRadius,e=this.startAngle,s=e+this.deltaAngle;if(Math.abs(this.deltaAngle-I)<1e-10)return Math.PI*t*n;const i=t*n/2*(s-e-(Math.sin(s)*Math.cos(s)-Math.sin(e)*Math.cos(e)));return Math.abs(i)}calculateBoundingBox(){if(this.majorAxis.equals(_.X_AXIS)||this.majorAxis.equals(_.Y_AXIS)||this.majorAxis.isParallelTo(_.X_AXIS)||this.majorAxis.isParallelTo(_.Y_AXIS)){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,s=1/0,i=-1/0,r=-1/0,h=-1/0;for(const a of t){const c=this.getPointAtAngle(a);c.x<n&&(n=c.x),c.y<e&&(e=c.y),c.z<s&&(s=c.z),c.x>i&&(i=c.x),c.y>r&&(r=c.y),c.z>h&&(h=c.z)}return new Z({x:n,y:e,z:s},{x:i,y:r,z:h})}else{let n=1/0,e=1/0,s=1/0,i=-1/0,r=-1/0,h=-1/0;for(let a=0;a<=100;a++){const c=this.startAngle+this.deltaAngle*(a/100),l=this.getPointAtAngle(c);n=Math.min(n,l.x),e=Math.min(e,l.y),s=Math.min(s,l.z),i=Math.max(i,l.x),r=Math.max(r,l.y),h=Math.max(h,l.z)}return new Z({x:n,y:e,z:s},{x:i,y:r,z:h})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const n=[];let e=this.deltaAngle,s=this.startAngle;this.closed&&(e=I,s=0);for(let i=0;i<=t;i++){const r=s+e*(i/t),h=this.getPointAtAngle(r);n.push(h)}return n}getPointAtAngle(t){const n=Math.cos(t),e=Math.sin(t),s=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(e),i=this.majorAxis.clone().multiplyScalar(n*this.majorAxisRadius).add(s);return new z(this.center.x+i.x,this.center.y+i.y,this.center.z+i.z)}contains(t){const n=new _(t).sub(this.center),e=n.dot(this.majorAxis),s=n.dot(this.minorAxis),i=e/this.majorAxisRadius,r=s/this.minorAxisRadius;return i*i+r*r<=1}transform(t){const n=t,e=this.center.clone().applyMatrix4(n),s=this.getPointAtAngle(0).clone().applyMatrix4(n),i=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(n),r=new _(s).sub(e),h=new _(i).sub(e),a=r.length(),c=h.length(),l=r.clone().normalize(),u=new _().crossVectors(r,h).normalize();let d=new _().crossVectors(u,l).normalize();d.dot(h)<0&&(u.negate(),d=new _().crossVectors(u,l).normalize());const m=y=>{const x=new _(y).sub(e),f=x.dot(l),b=x.dot(d);return M.normalizeAngle(Math.atan2(b/c,f/a))},g=this.closed?new lt(e,u,l,a,c,0,I):new lt(e,u,l,a,c,m(this.startPoint.clone().applyMatrix4(n)),m(this.endPoint.clone().applyMatrix4(n)));return this.center=g.center,this.normal=g.normal,this.majorAxis=g.majorAxis,this.majorAxisRadius=g.majorAxisRadius,this.minorAxisRadius=g.minorAxisRadius,this._startAngle=g._startAngle,this._endAngle=g._endAngle,this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new lt(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new _(this.center).distanceTo(Ft);return new mt(this.normal,t)}offset(t){const n=this.majorAxisRadius+t,e=this.minorAxisRadius+t;return n<=0||e<=0?null:new lt(this.center,this.normal,this.majorAxis,n,e,this.startAngle,this.endAngle)}}class xt extends ht{constructor(t,n){super(),this._start=new w(t),this._end=new w(n)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const t=new w(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),n=new w(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new O(t,n)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new xt(this._start.clone(),this._end.clone())}project(t){const n=this._end.x-this._start.x,e=this._end.y-this._start.y,s=n*n+e*e;if(s<1e-18)return this._start.clone();let i=((t.x-this._start.x)*n+(t.y-this._start.y)*e)/s;return i=Math.max(0,Math.min(1,i)),new w(this._start.x+i*n,this._start.y+i*e)}nearestPoint(t){return this.project(t)}}class X extends ht{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}static buildFromEdges(t,n=.001){if(t.length===0)return[];const e=[...t],s=[],i=n*n,r=(h,a)=>{const c=h.x-a.x,l=h.y-a.y;return c*c+l*l<=i};for(;e.length>0;){const h=[],a=e.shift();h.push(a);const c=X.getEdgeStartPoint(a);let l=X.getEdgeEndPoint(a);if(!r(c,l))for(;e.length>0;){const u=X.findConnectingEdge(e,l,i);if(u.index<0)break;let d=e.splice(u.index,1)[0];if(u.reverse&&(d=X.reverseEdge(d)),h.push(d),l=X.getEdgeEndPoint(d),r(l,c))break}s.push(new X(h))}return s}add(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const t=this._curves[0].startPoint;return new w(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let t=0;return this._curves.forEach(n=>{t+=n.length}),t}calculateBoundingBox(){const t=this.getPoints(100),n=new O;return n.setFromPoints(t),n}transform(t){const n=new W().set(t.elements[0],t.elements[3],0,t.elements[6],t.elements[1],t.elements[4],0,t.elements[7],0,0,1,0,0,0,0,1);return this._curves.forEach(e=>{e instanceof et?e.transform(n):e.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new X(this._curves.map(t=>t.clone()))}get closed(){return!0}getPoints(t){const n=[];return this.curves.forEach(e=>{e.getPoints(t).forEach(s=>{n.push(new w(s.x,s.y))})}),n}static findConnectingEdge(t,n,e){let s=-1,i=!1,r=Number.POSITIVE_INFINITY;for(let h=0;h<t.length;h++){const a=t[h],c=X.getEdgeStartPoint(a),l=X.getEdgeEndPoint(a),u=n.x-c.x,d=n.y-c.y,m=u*u+d*d;m<r&&(r=m,s=h,i=!1);const g=n.x-l.x,y=n.y-l.y,x=g*g+y*y;x<r&&(r=x,s=h,i=!0)}return r>e?{index:-1,reverse:!1}:{index:s,reverse:i}}static getEdgeStartPoint(t){const n=t.startPoint;return new w(n.x,n.y)}static getEdgeEndPoint(t){const n=t.endPoint;return new w(n.x,n.y)}static reverseEdge(t){return t instanceof xt?new xt(t.endPoint,t.startPoint):t instanceof G?new G(t.center,t.radius,t.endAngle,t.startAngle,!t.clockwise):t instanceof it?new it(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof et?X.reverseSplineEdge(t):t}static reverseSplineEdge(t){const n=[...t.controlPoints].reverse(),e=t.knots,s=e[0],i=e[e.length-1],r=e.map(c=>s+i-c).reverse(),h=t.weights,a=h.length>0?[...h].reverse():void 0;return new et(n,r,a,t.degree,t.closed)}}class en{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,n,e,s){this.c0=t,this.c1=e,this.c2=-3*t+3*n-2*e-s,this.c3=2*t-2*n+e+s}initCatmullRom(t,n,e,s,i){this.init(n,e,i*(e-t),i*(s-n))}initNonuniformCatmullRom(t,n,e,s,i,r,h){let a=(n-t)/i-(e-t)/(i+r)+(e-n)/r,c=(e-n)/r-(s-n)/(r+h)+(s-e)/h;a*=r,c*=r,this.init(n,e,a,c)}calc(t){const n=t*t,e=n*t;return this.c0+this.c1*t+this.c2*n+this.c3*e}}class Ct extends yt{constructor(t=[],n=!1,e="centripetal",s=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new _,this._px=new en,this._py=new en,this._pz=new en,this._points=t.map(i=>new z(i)),this._closed=n,this._curveType=e,this._tension=s}get points(){return this._points}get closed(){return this._closed}get curveType(){return this._curveType}get tension(){return this._tension}get startPoint(){return this._points.length>0?this._points[0]:new z}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new z}get length(){if(this._points.length<2)return 0;let t=0;for(let n=1;n<this._points.length;n++)t+=this._points[n-1].distanceTo(this._points[n]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,n=new z){const e=n,s=this._points,i=s.length;if(i===0)return e.set(0,0,0);if(i===1)return e.copy(s[0]);const r=(i-(this._closed?0:1))*t;let h=Math.floor(r),a=r-h;this._closed?h+=h>0?0:(Math.floor(Math.abs(h)/i)+1)*i:a===0&&h===i-1&&(h=i-2,a=1);let c,l;this._closed||h>0?c=s[(h-1)%i]:(this._tmp.subVectors(s[0],s[1]).add(s[0]),c=new z(this._tmp.x,this._tmp.y,this._tmp.z));const u=s[h%i],d=s[(h+1)%i];if(this._closed||h+2<i?l=s[(h+2)%i]:(this._tmp.subVectors(s[i-1],s[i-2]).add(s[i-1]),l=new z(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const m=this._curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(u),m),y=Math.pow(u.distanceToSquared(d),m),x=Math.pow(d.distanceToSquared(l),m);y<1e-4&&(y=1),g<1e-4&&(g=y),x<1e-4&&(x=y),this._px.initNonuniformCatmullRom(c.x,u.x,d.x,l.x,g,y,x),this._py.initNonuniformCatmullRom(c.y,u.y,d.y,l.y,g,y,x),this._pz.initNonuniformCatmullRom(c.z,u.z,d.z,l.z,g,y,x)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(c.x,u.x,d.x,l.x,this._tension),this._py.initCatmullRom(c.y,u.y,d.y,l.y,this._tension),this._pz.initCatmullRom(c.z,u.z,d.z,l.z,this._tension));return e.set(this._px.calc(a),this._py.calc(a),this._pz.calc(a)),e}getPoints(t){const n=[];for(let e=0;e<=t;e++)n.push(this.getPoint(e/t));return n}setPoints(t){this._points=t.map(n=>new 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 Ct(this._points.map(t=>t.clone()),this._closed,this._curveType,this._tension)}transform(t){return this._points=this._points.map(n=>{const e=new z;return e.copy(n),e.applyMatrix4(t),e}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new Z;const t=new Z;return this._points.forEach(n=>{t.expandByPoint(n)}),t}}function Jn(o,t){const n=o.x-t[0],e=o.y-t[1],s=(o.z??0)-(t[2]??0);return n*n+e*e+s*s}class U{constructor(t,n,e,s){this._degree=t,this._knots=[...n],this._controlPoints=e.map(i=>({x:i.x,y:i.y,z:i.z})),this._weights=s?[...s]:new Array(e.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z}))}weights(){return[...this._weights]}clone(){return new 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 Nn(t,this._degree,this._knots,n,this._weights)}signedPlanarCurvatureAt(t){const n=this.evaluate(t);return Rn(n.deriv1,n.deriv2)}getOffsetSamplePath2d(t,n=512){const e=Math.abs(t),{start:s,end:i}=this.getParameterRange(),r=this.length(),h=Math.max(64,Math.ceil(r/Math.max(e*.2,1e-6)));let a=Ke(s,i,Math.min(h,n));for(let u=0;u<8&&a.length<n;u++){const d=[];for(let m=0;m<a.length-1;m++){const g=a[m],y=a[m+1],x=(g+y)/2,f=Math.max(Math.abs(this.signedPlanarCurvatureAt(g)),Math.abs(this.signedPlanarCurvatureAt(y)),Math.abs(this.signedPlanarCurvatureAt(x)));e*f>.85&&d.push(x)}if(d.length===0)break;if(a=We(a,d),a.length>n){a=a.slice(0,n);break}}const c=[],l=[];return a.forEach(u=>{const d=this.evaluate(u);c.push(new w(d.point[0],d.point[1]));const m=d.deriv1[0],g=d.deriv1[1],y=Math.hypot(m,g);l.push(y>1e-10?new w(m/y,g/y):new w(1,0))}),{points:c,tangents:l}}length(){const t=this._controlPoints.map(n=>[n.x,n.y,n.z]);return qn(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,n,e,s){return new U(t,n,e,s)}static byPoints(t,n,e="Uniform",s,i){const r=Gt(t,n,e,s,i),h=r.controlPoints.map(a=>({x:a[0],y:a[1],z:a[2]}));return new U(n,r.knots,h,r.weights)}getParameterRange(){const t=this._knots[this._degree],n=this._knots[this._knots.length-this._degree-1];return{start:t,end:n}}getPoints(t){const n=[],{start:e,end:s}=this.getParameterRange();for(let i=0;i<=t;i++){const r=e+(s-e)*(i/t);n.push(this.point(r))}return n}isClosed(t=1e-6){const{start:n,end:e}=this.getParameterRange(),s=this.point(n),i=this.point(e),r=s[0]-i[0],h=s[1]-i[1],a=s[2]-i[2];return Math.sqrt(r*r+h*h+a*a)<t}static createFitPointsForClosedCurve(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const n=new Ct(t,!0,"centripetal"),e=Math.max(50,t.length*2);return n.getPoints(e)}nearestPoint(t,n=64){const{start:e,end:s}=this.getParameterRange();let i=this.point(e),r=Jn(t,i);for(let h=0;h<=n;h++){const a=e+(s-e)*h/n,c=this.point(a),l=Jn(t,c);l<r&&(r=l,i=c)}return{x:i[0],y:i[1],z:i[2]??0}}static createClosedCurve(t,n,e="Chord"){const i=this.createFitPointsForClosedCurve(t).map(r=>[r.x,r.y,r.z]);return U.byPoints(i,n,e)}}function Ke(o,t,n){if(n<2)return[o,t];const e=[];for(let s=0;s<n;s++)e.push(s===n-1?t:o+(t-o)*s/(n-1));return e}function We(o,t){const n=[...o,...t].sort((s,i)=>s-i),e=[];return n.forEach(s=>{const i=e[e.length-1];(i===void 0||Math.abs(i-s)>1e-10)&&e.push(s)}),e}class et extends yt{constructor(t,n,e,s,i,r){super();const h=arguments.length;if(this._degree=3,this._closed=!1,Array.isArray(n)){if(h<2||h>5)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._controlPoints=t;let a,c=3,l=!1;if(h>=3&&(Array.isArray(e)?(a=e,h>=4&&(c=s||3),h>=5&&(l=i)):e!==void 0&&(c=e||3,h>=4&&(l=s))),e===void 0&&h>=4&&(c=s||3,h>=5&&(l=i)),this._degree=c,this._closed=l,this._controlPoints.length<this._degree+1)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._nurbsCurve=U.byKnotsControlPointsWeights(this._degree,n,this._controlPoints,a)}else{if(h<2||h>6)throw j.AcCmErrors.ILLEGAL_PARAMETERS;this._fitPoints=t,this._knotParameterization=n,h>=3&&(this._degree=e||3);const a=typeof s=="boolean";h>=4&&a&&(this._closed=s),a?(h>=5&&(this._startTangent=i),h>=6&&(this._endTangent=r)):(h>=4&&(this._startTangent=s),h>=5&&(this._endTangent=i)),this._closed&&(this._startTangent=void 0,this._endTangent=void 0);const c=(this._startTangent?1:0)+(this._endTangent?1:0);if(this._fitPoints.length+c<this._degree+1)throw 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(t=>({x:t.x,y:t.y,z:t.z||0}))}get fitPoints(){var t;return(t=this._fitPoints)==null?void 0:t.map(n=>({x:n.x,y:n.y,z:n.z||0}))}get knots(){return[...this._nurbsCurve.knots()]}get weights(){return[...this._nurbsCurve.weights()]}get startPoint(){const t=this._nurbsCurve.knots(),n=this._nurbsCurve.degree(),e=t[n],s=this._nurbsCurve.point(e);return new z(s[0],s[1],s[2])}get endPoint(){const t=this._nurbsCurve.knots(),n=this._nurbsCurve.degree(),e=t[t.length-n-1],s=this._nurbsCurve.point(e);return new z(s[0],s[1],s[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const n=this._fitPoints.length,e=t<0||t>=n?n-1:t,s=this._fitPoints[e];return{x:s.x,y:s.y,z:s.z||0}}getControlPointAt(t){const n=this._controlPoints.length,e=t<0||t>=n?n-1:t;return this._controlPoints[e]}getOffsetSamplePath2d(t){return this._nurbsCurve.getOffsetSamplePath2d(t)}getPoints(t=100){const n=this._nurbsCurve,e=[],s=n.knots(),i=this._nurbsCurve.degree(),r=s[i],h=s[s.length-i-1],a=(h-r)/(t-1);for(let c=0;c<t;c++){const l=c===t-1?h:r+c*a,u=n.point(l);e.push(new z(u[0],u[1],u[2]))}return e}getCurvePoints(t,n){const e=[],s=t.knots(),i=t.degree(),r=s[i],a=(s[s.length-i-1]-r)/(n-1);for(let c=0;c<n;c++){const l=r+c*a;e.push(t.point(l))}return e}calculateBoundingBox(){const t=this.getPoints(100);return new Z().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(n=>new z(n).applyMatrix4(t)),this._startTangent&&(this._startTangent=new z(this._startTangent).transformDirection(t)),this._endTangent&&(this._endTangent=new z(this._endTangent).transformDirection(t)),this.buildCurve();else{const n=this._nurbsCurve.knots(),e=this._nurbsCurve.weights();this._controlPoints=this._controlPoints.map(s=>new z(s).applyMatrix4(t)),this._nurbsCurve=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 et(this._fitPoints.map(t=>({x:t.x,y:t.y,z:t.z||0})),this._knotParameterization,this._degree,this._closed,this._startTangent?{x:this._startTangent.x,y:this._startTangent.y,z:this._startTangent.z||0}:void 0,this._endTangent?{x:this._endTangent.x,y:this._endTangent.y,z:this._endTangent.z||0}:void 0):new et(this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z||0})),this._nurbsCurve.knots(),this._nurbsCurve.weights(),this._degree,this._closed)}toNurbsPoints(t){const n=new Array(t.length);return t.forEach((e,s)=>{n[s]=[e.x,e.y,e.z||0]}),n}toGePoints(t){const n=new Array(t.length);return t.forEach((e,s)=>{n[s]={x:e[0],y:e[1],z:e[2]}}),n}toNurbsPoint(t){return[t.x,t.y,t.z||0]}static createClosedSpline(t,n="Uniform",e=3){if(t.length<e+1)throw new Error(`At least ${e+1} points are required for a degree ${e} closed spline`);return new et(t,n,e,!0)}}A.AcGeArea2d=nn,A.AcGeBox2d=O,A.AcGeBox3d=Z,A.AcGeCatmullRomCurve3d=Ct,A.AcGeCircArc2d=G,A.AcGeCircArc3d=ct,A.AcGeCurve2d=ht,A.AcGeEllipseArc2d=it,A.AcGeEllipseArc3d=lt,A.AcGeEuler=Dt,A.AcGeGeometryUtil=Bn,A.AcGeLine2d=xt,A.AcGeLine3d=at,A.AcGeLoop2d=X,A.AcGeMathUtil=M,A.AcGeMatrix2d=rt,A.AcGeMatrix3d=W,A.AcGeNurbsCurve=U,A.AcGePlane=mt,A.AcGePoint2d=w,A.AcGePoint3d=z,A.AcGePolyline2d=nt,A.AcGeQuaternion=dt,A.AcGeShape2d=$t,A.AcGeSpline3d=et,A.AcGeTol=k,A.AcGeVector2d=T,A.AcGeVector3d=_,A.DEFAULT_TOL=Pt,A.DEG2RAD=qt,A.FLOAT_TOL=K,A.ORIGIN_POINT_2D=Hn,A.ORIGIN_POINT_3D=Ft,A.RAD2DEG=Vt,A.TAU=I,A.basisFunction=tt,A.calculateCurveLength=qn,A.ceilPowerOfTwo=An,A.clamp=Q,A.computeParameterValues=kn,A.damp=an,A.degToRad=xn,A.euclideanModulo=jt,A.evaluateNurbsDerivatives=Nn,A.evaluateNurbsPoint=gt,A.floorPowerOfTwo=wn,A.generateAveragedKnots=Tn,A.generateChordKnots=re,A.generateSqrtChordKnots=oe,A.generateUUID=rn,A.generateUniformKnots=ie,A.getOcsAngle=me,A.getOcsReferenceVector=ue,A.intPartLength=Ut,A.interpolateControlPoints=ae,A.interpolateNurbsCurve=Gt,A.inverseLerp=hn,A.isBetween=Pn,A.isBetweenAngle=pn,A.isPointInPolygon=Yt,A.isPolygonIntersect=In,A.isPowerOfTwo=fn,A.lerp=Lt,A.mapLinear=on,A.normalizeAngle=ut,A.offsetPointByDirectionInXY=Ue,A.offsetSmoothedSampledPath=Fe,A.offsetVertexPath=ve,A.pingpong=cn,A.radToDeg=_n,A.randFloat=mn,A.randFloatSpread=gn,A.randInt=dn,A.relativeEps=Mn,A.seededRandom=yn,A.signedPlanarCurvature=Rn,A.smootherstep=un,A.smoothstep=ln,A.transformOcsPointToWcs=de,A.transformWcsPointToOcs=Wt,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
@@ -157,5 +157,12 @@ export declare class AcGeCircArc3d extends AcGeCurve3d {
157
157
  * Return the plane in which the circular arc lies.
158
158
  */
159
159
  get plane(): AcGePlane;
160
+ /**
161
+ * Returns a concentric copy with radius adjusted by `offsetDist`.
162
+ *
163
+ * @param offsetDist - Signed offset distance in drawing units
164
+ * @returns Offset arc, or `null` when the resulting radius is not positive
165
+ */
166
+ offset(offsetDist: number): AcGeCircArc3d | null;
160
167
  }
161
168
  //# sourceMappingURL=AcGeCircArc3d.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AcGeCircArc3d.d.ts","sourceRoot":"","sources":["../../src/geometry/AcGeCircArc3d.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,SAAS,EACT,WAAW,EACX,eAAe,EACf,aAAa,EACb,YAAY,EACZ,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAG3C;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,OAAO,CAAe;IAE9B;;;;;;OAMG;IACH,MAAM,CAAC,kBAAkB,CACvB,UAAU,EAAE,eAAe,EAC3B,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,eAAe,GAC1B,WAAW,GAAG,IAAI;IAmDrB;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CACxB,UAAU,EAAE,eAAe,EAC3B,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,eAAe;IA4B7B;;;;;;;;OAQG;gBAED,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,EACxB,MAAM,GAAE,gBAAsC;IAmBhD;;OAEG;IACH,IAAI,MAAM,IAAI,WAAW,CAExB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,aAAa,EAG9B;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAIvB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAEvB;IACD,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,EAG3B;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAMzB;IAED;;OAEG;IACH,IAAI,UAAU,WAEb;IAED;;OAEG;IACH,IAAI,UAAU,UAEb;IAED;;OAEG;IACH,IAAI,SAAS,YAEZ;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,YAAY,CAEzB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAKjC;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,YAAY,CAEzB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAKjC;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,WAAW,CAE5B;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,WAAW,CAY1B;IAED;;OAEG;IACH,IAAI,MAAM,WAIT;IAED;;OAEG;IACH,IAAI,IAAI,WAIP;IAED;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW;IAgDjD;;;;OAIG;IACH,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW,EAAE;IA8CpD;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI;IAa/D;;OAEG;IACH,oBAAoB;IA+BpB;;OAEG;IACH,IAAI,MAAM,YAET;IAED;;;;;OAKG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE;IAgB3C;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,YAAY;IA4C9B;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,aAAa;IAWzB;;OAEG;IACH,KAAK;IAWL;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,YAAY;IAQ1B;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IAuB3C;;OAEG;IACH,IAAI,KAAK,IAAI,SAAS,CAGrB;CACF"}
1
+ {"version":3,"file":"AcGeCircArc3d.d.ts","sourceRoot":"","sources":["../../src/geometry/AcGeCircArc3d.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,SAAS,EACT,WAAW,EACX,eAAe,EACf,aAAa,EACb,YAAY,EACZ,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAG3C;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,OAAO,CAAe;IAE9B;;;;;;OAMG;IACH,MAAM,CAAC,kBAAkB,CACvB,UAAU,EAAE,eAAe,EAC3B,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,eAAe,GAC1B,WAAW,GAAG,IAAI;IAmDrB;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CACxB,UAAU,EAAE,eAAe,EAC3B,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,eAAe;IA4B7B;;;;;;;;OAQG;gBAED,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,EACxB,MAAM,GAAE,gBAAsC;IAmBhD;;OAEG;IACH,IAAI,MAAM,IAAI,WAAW,CAExB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,aAAa,EAG9B;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAIvB;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,MAAM,CAEvB;IACD,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,EAG3B;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAErB;IACD,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAMzB;IAED;;OAEG;IACH,IAAI,UAAU,WAEb;IAED;;OAEG;IACH,IAAI,UAAU,UAEb;IAED;;OAEG;IACH,IAAI,SAAS,YAEZ;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,YAAY,CAEzB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAKjC;IAED;;OAEG;IACH,IAAI,MAAM,IAAI,YAAY,CAEzB;IACD,IAAI,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAKjC;IAED;;OAEG;IACH,IAAI,UAAU,IAAI,WAAW,CAE5B;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,WAAW,CAE1B;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,WAAW,CAY1B;IAED;;OAEG;IACH,IAAI,MAAM,WAIT;IAED;;OAEG;IACH,IAAI,IAAI,WAIP;IAED;;;OAGG;IACH,YAAY,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW;IAgDjD;;;;OAIG;IACH,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW,EAAE;IA8CpD;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI;IAa/D;;OAEG;IACH,oBAAoB;IA+BpB;;OAEG;IACH,IAAI,MAAM,YAET;IAED;;;;;OAKG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE;IAgB3C;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,YAAY;IA4C9B;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,aAAa;IAWzB;;OAEG;IACH,KAAK;IAWL;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,YAAY;IAQ1B;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW;IAuB3C;;OAEG;IACH,IAAI,KAAK,IAAI,SAAS,CAGrB;IAED;;;;;OAKG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;CAYjD"}
@@ -590,6 +590,18 @@ var AcGeCircArc3d = /** @class */ (function (_super) {
590
590
  enumerable: false,
591
591
  configurable: true
592
592
  });
593
+ /**
594
+ * Returns a concentric copy with radius adjusted by `offsetDist`.
595
+ *
596
+ * @param offsetDist - Signed offset distance in drawing units
597
+ * @returns Offset arc, or `null` when the resulting radius is not positive
598
+ */
599
+ AcGeCircArc3d.prototype.offset = function (offsetDist) {
600
+ var radius = this.radius + offsetDist;
601
+ if (radius <= 0)
602
+ return null;
603
+ return new AcGeCircArc3d(this.center, radius, this.startAngle, this.endAngle, this.normal, this.refVec);
604
+ };
593
605
  return AcGeCircArc3d;
594
606
  }(AcGeCurve3d));
595
607
  export { AcGeCircArc3d };